feat: Add About Window

This commit is contained in:
Fabio Lenherr / DashieTM 2023-10-29 14:00:37 +01:00
parent 3dc0bdd792
commit 4f425c6428
3 changed files with 70 additions and 20 deletions

View file

@ -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::<SidebarEntry>().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 {
}
}
}

View file

@ -31,6 +31,8 @@ pub struct Window {
pub resetPopoverMenu: TemplateChild<PopoverMenu>,
#[template_child]
pub resetClose: TemplateChild<Button>,
#[template_child]
pub resetAboutButton: TemplateChild<Button>,
pub sidebarEntries: RefCell<Vec<(SidebarEntry, Vec<SidebarEntry>)>>,
}
@ -56,6 +58,7 @@ impl ObjectImpl for Window {
let object = self.obj();
object.setupCallback();
object.setupPopoverButtons();
object.handleDynamicSidebar();
object.setupSidebarEntries();
}

View file

@ -71,7 +71,7 @@
</object>
</child>
<child>
<object class="GtkButton">
<object class="GtkButton" id="resetAboutButton">
<property name="has-frame">False</property>
<property name="label">About</property>
</object>
@ -153,7 +153,7 @@
<!-- Custom fragments -->
<child>
<object id="resetSidebarBreakpoint" class="AdwBreakpoint">
</object>
</object>
</child>
</template>
</interface>