feat(time): show_date_in_top_panel config
This commit is contained in:
parent
10dd3b312a
commit
3ea612f843
3 changed files with 21 additions and 0 deletions
|
|
@ -19,6 +19,7 @@ pub struct Page {
|
||||||
auto: bool,
|
auto: bool,
|
||||||
auto_timezone: bool,
|
auto_timezone: bool,
|
||||||
military_time: bool,
|
military_time: bool,
|
||||||
|
show_date_in_top_panel: bool,
|
||||||
// info: Option<cosmic_settings_time::Info>,
|
// info: Option<cosmic_settings_time::Info>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -29,11 +30,16 @@ impl Default for Page {
|
||||||
error!(?err, "Failed to read config 'military_time'");
|
error!(?err, "Failed to read config 'military_time'");
|
||||||
false
|
false
|
||||||
});
|
});
|
||||||
|
let show_date_in_top_panel = config.get("show_date_in_top_panel").unwrap_or_else(|err| {
|
||||||
|
error!(?err, "Failed to read config 'show_date_in_top_panel'");
|
||||||
|
true
|
||||||
|
});
|
||||||
Self {
|
Self {
|
||||||
config,
|
config,
|
||||||
auto: false,
|
auto: false,
|
||||||
auto_timezone: false,
|
auto_timezone: false,
|
||||||
military_time,
|
military_time,
|
||||||
|
show_date_in_top_panel,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -68,6 +74,12 @@ impl Page {
|
||||||
error!(?err, "Failed to set config 'military_time'");
|
error!(?err, "Failed to set config 'military_time'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Message::ShowDate(enable) => {
|
||||||
|
self.show_date_in_top_panel = enable;
|
||||||
|
if let Err(err) = self.config.set("show_date_in_top_panel", enable) {
|
||||||
|
error!(?err, "Failed to set config 'show_date_in_top_panel'");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -77,6 +89,7 @@ pub enum Message {
|
||||||
Automatic(bool),
|
Automatic(bool),
|
||||||
AutomaticTimezone(bool),
|
AutomaticTimezone(bool),
|
||||||
MilitaryTime(bool),
|
MilitaryTime(bool),
|
||||||
|
ShowDate(bool),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl page::AutoBind<crate::pages::Message> for Page {}
|
impl page::AutoBind<crate::pages::Message> for Page {}
|
||||||
|
|
@ -109,6 +122,7 @@ fn format() -> Section<crate::pages::Message> {
|
||||||
.descriptions(vec![
|
.descriptions(vec![
|
||||||
fl!("time-format", "twenty-four").into(),
|
fl!("time-format", "twenty-four").into(),
|
||||||
fl!("time-format", "first").into(),
|
fl!("time-format", "first").into(),
|
||||||
|
fl!("time-format", "show-date").into(),
|
||||||
])
|
])
|
||||||
.view::<Page>(|_binder, page, section| {
|
.view::<Page>(|_binder, page, section| {
|
||||||
settings::view_section(§ion.title)
|
settings::view_section(§ion.title)
|
||||||
|
|
@ -122,6 +136,11 @@ fn format() -> Section<crate::pages::Message> {
|
||||||
&*section.descriptions[1],
|
&*section.descriptions[1],
|
||||||
horizontal_space(Length::Fill),
|
horizontal_space(Length::Fill),
|
||||||
))
|
))
|
||||||
|
// Date on top panel toggle
|
||||||
|
.add(
|
||||||
|
settings::item::builder(&*section.descriptions[2])
|
||||||
|
.toggler(page.show_date_in_top_panel, Message::ShowDate),
|
||||||
|
)
|
||||||
.apply(cosmic::Element::from)
|
.apply(cosmic::Element::from)
|
||||||
.map(crate::pages::Message::DateAndTime)
|
.map(crate::pages::Message::DateAndTime)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -293,6 +293,7 @@ time-zone = Time Zone
|
||||||
time-format = Date & Time Format
|
time-format = Date & Time Format
|
||||||
.twenty-four = 24-hour time
|
.twenty-four = 24-hour time
|
||||||
.first = First day of week
|
.first = First day of week
|
||||||
|
.show-date = Show Date on Top Panel
|
||||||
|
|
||||||
time-region = Region & Language
|
time-region = Region & Language
|
||||||
.desc = Format dates, times, and numbers based on your region
|
.desc = Format dates, times, and numbers based on your region
|
||||||
|
|
|
||||||
|
|
@ -298,6 +298,7 @@ time-zone = Strefa Czasowa
|
||||||
time-format = Format Daty i Czasu
|
time-format = Format Daty i Czasu
|
||||||
.twenty-four = Czas 24-godzinny
|
.twenty-four = Czas 24-godzinny
|
||||||
.first = Pierwszy dzień tygodnia
|
.first = Pierwszy dzień tygodnia
|
||||||
|
.show-date = Pokaż Datę w Górnym Panelu
|
||||||
|
|
||||||
time-region = Region i Język
|
time-region = Region i Język
|
||||||
.desc = Format dat, czasu i numerów na podstawie wybranego regionu
|
.desc = Format dat, czasu i numerów na podstawie wybranego regionu
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue