mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-01-24 13:58:00 -05:00
- add ChangeDateAndTimeWindow, - extract EventTimeItem to common widgets folder and rename it to TimeWidget, - extract EventDateItem to common widgets folder and rename it to DateWidget, - replace timeWidget with common TimeWidget in NightshiftWindow, - refactor time setting in DesktopMainWindow and TopBar, - Remove dead code from EventManager (GetNextAlarmTimestamp and HandleAlarmTrigger)
78 lines
2.8 KiB
C++
78 lines
2.8 KiB
C++
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
|
|
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
|
|
|
|
#pragma once
|
|
|
|
#include <Label.hpp>
|
|
#include <Text.hpp>
|
|
#include <BoxLayout.hpp>
|
|
#include "widgets/DateWidget.hpp"
|
|
#include <module-utils/time/FromTillDate.hpp>
|
|
|
|
namespace gui
|
|
{
|
|
namespace timeConstants
|
|
{
|
|
inline constexpr auto before_noon = "AM";
|
|
inline constexpr auto after_noon = "PM";
|
|
} // namespace timeConstants
|
|
|
|
class TimeWidget : public VBox
|
|
{
|
|
public:
|
|
enum class Type
|
|
{
|
|
Start,
|
|
End
|
|
};
|
|
|
|
TimeWidget(Item *parent,
|
|
const std::string &description,
|
|
Type type,
|
|
std::function<void(const UTF8 &text)> bottomBarTemporaryMode = nullptr,
|
|
std::function<void()> bottomBarRestoreFromTemporaryMode = nullptr);
|
|
void loadData(const std::chrono::hours &hoursFrom,
|
|
const std::chrono::minutes &minutesFrom,
|
|
const std::chrono::hours &hoursTill,
|
|
const std::chrono::minutes &minutesTill);
|
|
bool saveData(std::shared_ptr<utils::time::FromTillDate> fromTillDate);
|
|
virtual ~TimeWidget() override = default;
|
|
|
|
void setConnectionToSecondItem(TimeWidget *item);
|
|
void setConnectionToDateItem(DateWidget *item);
|
|
|
|
private:
|
|
VBox *vBox = nullptr;
|
|
HBox *hBox = nullptr;
|
|
Label *colonLabel = nullptr;
|
|
Label *descriptionLabel = nullptr;
|
|
Label *hourInput = nullptr;
|
|
Label *minuteInput = nullptr;
|
|
Label *mode12hInput = nullptr;
|
|
bool mode24H = false;
|
|
TimeWidget *secondItem = nullptr;
|
|
DateWidget *dateItem = nullptr;
|
|
|
|
Type type;
|
|
std::function<void(const UTF8 &text)> bottomBarTemporaryMode = nullptr;
|
|
std::function<void()> bottomBarRestoreFromTemporaryMode = nullptr;
|
|
|
|
void applyInputCallbacks();
|
|
void prepareForTimeMode();
|
|
void prepareMode12HInputLabel();
|
|
void setTime(int keyValue, Label &item);
|
|
void onInputCallback(Label &timeInput);
|
|
void clearInput(Label &timeInput);
|
|
bool isPm(const std::string &text);
|
|
bool validateHour();
|
|
void validateHourFor12hMode(std::chrono::hours start_hour,
|
|
std::chrono::minutes end_hour,
|
|
uint32_t start_minutes,
|
|
uint32_t end_minutes);
|
|
void validateHourFor24hMode(std::chrono::hours start_hour,
|
|
std::chrono::minutes end_hour,
|
|
uint32_t start_minutes,
|
|
uint32_t end_minutes);
|
|
};
|
|
} /* namespace gui */
|