From 4f425c64282e3e6872e4f3e944162eb9d10b5a2f Mon Sep 17 00:00:00 2001 From: Fabio Lenherr / DashieTM Date: Sun, 29 Oct 2023 14:00:37 +0100 Subject: [PATCH] feat: Add About Window --- src/components/window/mod.rs | 83 +++++++++++++++++++++++++------- src/components/window/window.rs | 3 ++ src/resources/resetMainWindow.ui | 4 +- 3 files changed, 70 insertions(+), 20 deletions(-) diff --git a/src/components/window/mod.rs b/src/components/window/mod.rs index 4d9914b..96018a9 100644 --- a/src/components/window/mod.rs +++ b/src/components/window/mod.rs @@ -1,11 +1,11 @@ #![allow(non_snake_case)] -use adw::BreakpointCondition; use adw::glib::clone; use adw::subclass::prelude::ObjectSubclassIsExt; +use adw::BreakpointCondition; use glib::Object; -use gtk::{Application, FlowBox, gio, glib}; use gtk::prelude::*; +use gtk::{gio, glib, Application, FlowBox}; use crate::components::window::handleSidebarClick::{ HANDLE_AUDIO_CLICK, HANDLE_BLUETOOTH_CLICK, HANDLE_CONNECTIVITY_CLICK, HANDLE_MICROPHONE_CLICK, @@ -39,23 +39,31 @@ impl Window { fn setupCallback(&self) { let selfImp = self.imp(); - selfImp.resetSearchEntry.connect_search_changed(clone!(@ weak self as window => move |_| { - window.filterList(); - })); + selfImp + .resetSearchEntry + .connect_search_changed(clone!(@ weak self as window => move |_| { + window.filterList(); + })); - selfImp.resetSideBarToggle.connect_clicked(clone!(@ weak self as window => move |_| { - window.toggleSidebar(); - })); + selfImp + .resetSideBarToggle + .connect_clicked(clone!(@ weak self as window => move |_| { + window.toggleSidebar(); + })); - selfImp.resetSidebarList.connect_row_activated(clone!(@ weak selfImp as flowbox => move |_, y| { + selfImp.resetSidebarList.connect_row_activated( + clone!(@ weak selfImp as flowbox => move |_, y| { let result = y.downcast_ref::().unwrap(); let clickEvent = result.imp().onClickEvent.borrow().onClickEvent; (clickEvent)(flowbox.resetMain.get()); - })); + }), + ); - selfImp.resetClose.connect_clicked(clone!(@ weak self as window => move |_| { - window.close(); - })); + selfImp + .resetClose + .connect_clicked(clone!(@ weak self as window => move |_| { + window.close(); + })); // selfImp.resetMenu.connect_clicked(|_| { // WifiBox::donotdisturb(); @@ -65,7 +73,9 @@ impl Window { fn handleDynamicSidebar(&self) { let selfImp = self.imp(); - selfImp.resetSidebarBreakpoint.set_condition(BreakpointCondition::parse("max-width: 500sp").as_ref().ok()); + selfImp + .resetSidebarBreakpoint + .set_condition(BreakpointCondition::parse("max-width: 500sp").as_ref().ok()); selfImp.resetSidebarBreakpoint.add_setter( &Object::from(selfImp.resetOverlaySplitView.get()), "collapsed", @@ -88,13 +98,25 @@ impl Window { } continue; } - if mainEntry.imp().name.borrow().to_lowercase().contains(&text.to_lowercase()) { + if mainEntry + .imp() + .name + .borrow() + .to_lowercase() + .contains(&text.to_lowercase()) + { mainEntry.set_visible(true); } else { mainEntry.set_visible(false); } for subEntry in subEntries { - if subEntry.imp().name.borrow().to_lowercase().contains(&text.to_lowercase()) { + if subEntry + .imp() + .name + .borrow() + .to_lowercase() + .contains(&text.to_lowercase()) + { subEntry.set_visible(true); mainEntry.set_visible(true); } else { @@ -186,6 +208,30 @@ impl Window { } } } + + fn setupPopoverButtons(&self) { + let selfImp = self.imp(); + selfImp + .resetAboutButton + .connect_clicked(clone!(@ weak self as window => move |_| { + let dialog = adw::AboutWindow::builder() + .application_name("ReSet") + // .application_icon("") + .developer_name("Xetibo") + .license_type(gtk::License::Gpl30) + .website("https://github.com/Xetibo/ReSet") + .issue_url("https://github.com/Xetibo/ReSet/issues") + .version("0.0.1") + .transient_for(&window) + .modal(true) + .copyright("© 2022-2023 Xetibo") + .developers(vec!["DashieTM".to_string(), "Takatori".to_string()]) + .designers(vec!["DashieTM".to_string(), "Takatori".to_string()]) + .build(); + + dialog.present(); + })); + } } impl SidebarEntry { @@ -199,7 +245,9 @@ impl SidebarEntry { let entry: SidebarEntry = Object::builder().build(); let entryImp = entry.imp(); entryImp.resetSidebarLabel.get().set_text(entryName); - entryImp.resetSidebarImage.set_from_icon_name(Some(iconName)); + entryImp + .resetSidebarImage + .set_from_icon_name(Some(iconName)); entryImp.category.set(category); entryImp.isSubcategory.set(isSubcategory); { @@ -221,4 +269,3 @@ impl SidebarEntry { } } } - diff --git a/src/components/window/window.rs b/src/components/window/window.rs index bc42a89..e44abe2 100644 --- a/src/components/window/window.rs +++ b/src/components/window/window.rs @@ -31,6 +31,8 @@ pub struct Window { pub resetPopoverMenu: TemplateChild, #[template_child] pub resetClose: TemplateChild