mirror of
https://github.com/Xetibo/ReSet.git
synced 2025-04-18 18:48:33 +02:00
feat: Add About Window
This commit is contained in:
parent
3dc0bdd792
commit
4f425c6428
|
@ -1,11 +1,11 @@
|
||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
|
|
||||||
use adw::BreakpointCondition;
|
|
||||||
use adw::glib::clone;
|
use adw::glib::clone;
|
||||||
use adw::subclass::prelude::ObjectSubclassIsExt;
|
use adw::subclass::prelude::ObjectSubclassIsExt;
|
||||||
|
use adw::BreakpointCondition;
|
||||||
use glib::Object;
|
use glib::Object;
|
||||||
use gtk::{Application, FlowBox, gio, glib};
|
|
||||||
use gtk::prelude::*;
|
use gtk::prelude::*;
|
||||||
|
use gtk::{gio, glib, Application, FlowBox};
|
||||||
|
|
||||||
use crate::components::window::handleSidebarClick::{
|
use crate::components::window::handleSidebarClick::{
|
||||||
HANDLE_AUDIO_CLICK, HANDLE_BLUETOOTH_CLICK, HANDLE_CONNECTIVITY_CLICK, HANDLE_MICROPHONE_CLICK,
|
HANDLE_AUDIO_CLICK, HANDLE_BLUETOOTH_CLICK, HANDLE_CONNECTIVITY_CLICK, HANDLE_MICROPHONE_CLICK,
|
||||||
|
@ -39,23 +39,31 @@ impl Window {
|
||||||
fn setupCallback(&self) {
|
fn setupCallback(&self) {
|
||||||
let selfImp = self.imp();
|
let selfImp = self.imp();
|
||||||
|
|
||||||
selfImp.resetSearchEntry.connect_search_changed(clone!(@ weak self as window => move |_| {
|
selfImp
|
||||||
window.filterList();
|
.resetSearchEntry
|
||||||
}));
|
.connect_search_changed(clone!(@ weak self as window => move |_| {
|
||||||
|
window.filterList();
|
||||||
|
}));
|
||||||
|
|
||||||
selfImp.resetSideBarToggle.connect_clicked(clone!(@ weak self as window => move |_| {
|
selfImp
|
||||||
window.toggleSidebar();
|
.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 result = y.downcast_ref::<SidebarEntry>().unwrap();
|
||||||
let clickEvent = result.imp().onClickEvent.borrow().onClickEvent;
|
let clickEvent = result.imp().onClickEvent.borrow().onClickEvent;
|
||||||
(clickEvent)(flowbox.resetMain.get());
|
(clickEvent)(flowbox.resetMain.get());
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
selfImp.resetClose.connect_clicked(clone!(@ weak self as window => move |_| {
|
selfImp
|
||||||
window.close();
|
.resetClose
|
||||||
}));
|
.connect_clicked(clone!(@ weak self as window => move |_| {
|
||||||
|
window.close();
|
||||||
|
}));
|
||||||
|
|
||||||
// selfImp.resetMenu.connect_clicked(|_| {
|
// selfImp.resetMenu.connect_clicked(|_| {
|
||||||
// WifiBox::donotdisturb();
|
// WifiBox::donotdisturb();
|
||||||
|
@ -65,7 +73,9 @@ impl Window {
|
||||||
|
|
||||||
fn handleDynamicSidebar(&self) {
|
fn handleDynamicSidebar(&self) {
|
||||||
let selfImp = self.imp();
|
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(
|
selfImp.resetSidebarBreakpoint.add_setter(
|
||||||
&Object::from(selfImp.resetOverlaySplitView.get()),
|
&Object::from(selfImp.resetOverlaySplitView.get()),
|
||||||
"collapsed",
|
"collapsed",
|
||||||
|
@ -88,13 +98,25 @@ impl Window {
|
||||||
}
|
}
|
||||||
continue;
|
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);
|
mainEntry.set_visible(true);
|
||||||
} else {
|
} else {
|
||||||
mainEntry.set_visible(false);
|
mainEntry.set_visible(false);
|
||||||
}
|
}
|
||||||
for subEntry in subEntries {
|
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);
|
subEntry.set_visible(true);
|
||||||
mainEntry.set_visible(true);
|
mainEntry.set_visible(true);
|
||||||
} else {
|
} 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 {
|
impl SidebarEntry {
|
||||||
|
@ -199,7 +245,9 @@ impl SidebarEntry {
|
||||||
let entry: SidebarEntry = Object::builder().build();
|
let entry: SidebarEntry = Object::builder().build();
|
||||||
let entryImp = entry.imp();
|
let entryImp = entry.imp();
|
||||||
entryImp.resetSidebarLabel.get().set_text(entryName);
|
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.category.set(category);
|
||||||
entryImp.isSubcategory.set(isSubcategory);
|
entryImp.isSubcategory.set(isSubcategory);
|
||||||
{
|
{
|
||||||
|
@ -221,4 +269,3 @@ impl SidebarEntry {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,8 @@ pub struct Window {
|
||||||
pub resetPopoverMenu: TemplateChild<PopoverMenu>,
|
pub resetPopoverMenu: TemplateChild<PopoverMenu>,
|
||||||
#[template_child]
|
#[template_child]
|
||||||
pub resetClose: TemplateChild<Button>,
|
pub resetClose: TemplateChild<Button>,
|
||||||
|
#[template_child]
|
||||||
|
pub resetAboutButton: TemplateChild<Button>,
|
||||||
pub sidebarEntries: RefCell<Vec<(SidebarEntry, Vec<SidebarEntry>)>>,
|
pub sidebarEntries: RefCell<Vec<(SidebarEntry, Vec<SidebarEntry>)>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,6 +58,7 @@ impl ObjectImpl for Window {
|
||||||
|
|
||||||
let object = self.obj();
|
let object = self.obj();
|
||||||
object.setupCallback();
|
object.setupCallback();
|
||||||
|
object.setupPopoverButtons();
|
||||||
object.handleDynamicSidebar();
|
object.handleDynamicSidebar();
|
||||||
object.setupSidebarEntries();
|
object.setupSidebarEntries();
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton">
|
<object class="GtkButton" id="resetAboutButton">
|
||||||
<property name="has-frame">False</property>
|
<property name="has-frame">False</property>
|
||||||
<property name="label">About</property>
|
<property name="label">About</property>
|
||||||
</object>
|
</object>
|
||||||
|
@ -153,7 +153,7 @@
|
||||||
<!-- Custom fragments -->
|
<!-- Custom fragments -->
|
||||||
<child>
|
<child>
|
||||||
<object id="resetSidebarBreakpoint" class="AdwBreakpoint">
|
<object id="resetSidebarBreakpoint" class="AdwBreakpoint">
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</template>
|
</template>
|
||||||
</interface>
|
</interface>
|
||||||
|
|
Loading…
Reference in a new issue