mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
Refactor Clock: generalize multi timezones and single timezone cases
After this refactoring: 1. Timezones parses only once on start and the we refer to saved values. All time_zone.isString() checks gone to the constructor. 2. Single timezone case handling as case of multi timezoned logic. 3. Scroll event seems more clear now. 4. Tooltip template parses on start to check if there calendar placeholder or not. To do not calculate calendar_text() if not necessary.
This commit is contained in:
@ -17,6 +17,8 @@ struct waybar_time {
|
||||
date::zoned_seconds ztime;
|
||||
};
|
||||
|
||||
const std::string kCalendarPlaceholder = "calendar";
|
||||
|
||||
class Clock : public ALabel {
|
||||
public:
|
||||
Clock(const std::string&, const Json::Value&);
|
||||
@ -26,18 +28,19 @@ class Clock : public ALabel {
|
||||
private:
|
||||
util::SleeperThread thread_;
|
||||
std::locale locale_;
|
||||
const date::time_zone* time_zone_;
|
||||
bool fixed_time_zone_;
|
||||
int time_zone_idx_;
|
||||
std::vector<const date::time_zone*> time_zones_;
|
||||
int current_time_zone_idx_;
|
||||
date::year_month_day cached_calendar_ymd_ = date::January/1/0;
|
||||
std::string cached_calendar_text_;
|
||||
bool is_calendar_in_tooltip_;
|
||||
|
||||
bool handleScroll(GdkEventScroll* e);
|
||||
|
||||
auto calendar_text(const waybar_time& wtime) -> std::string;
|
||||
auto weekdays_header(const date::weekday& first_dow, std::ostream& os) -> void;
|
||||
auto first_day_of_week() -> date::weekday;
|
||||
bool setTimeZone(Json::Value zone_name);
|
||||
const date::time_zone* current_timezone();
|
||||
bool is_timezone_fixed();
|
||||
};
|
||||
|
||||
} // namespace waybar::modules
|
||||
|
Reference in New Issue
Block a user