Add Ctrl + Q shortcut to quit
This commit is contained in:
@@ -27,6 +27,12 @@
|
||||
<property name="title">{{ tr(key="sc-gen-close-window") }}</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="accelerator"><Ctrl>q</property>
|
||||
<property name="title">{{ tr(key="sc-gen-quit") }}</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
|
@@ -18,7 +18,8 @@
|
||||
(2,11,"GtkShortcutsShortcut",None,5,None,None,None,-1,None),
|
||||
(2,12,"GtkShortcutsShortcut",None,5,None,None,None,6,None),
|
||||
(2,13,"GtkShortcutsShortcut",None,3,None,None,None,1,None),
|
||||
(2,14,"GtkShortcutsShortcut",None,3,None,None,None,2,None)
|
||||
(2,14,"GtkShortcutsShortcut",None,3,None,None,None,2,None),
|
||||
(2,15,"GtkShortcutsShortcut",None,3,None,None,None,3,None)
|
||||
</object>
|
||||
<object_property>
|
||||
(2,2,"GtkShortcutsSection","section-name","Video Player",None,None,None,None,None,None,None,None,None),
|
||||
@@ -43,6 +44,8 @@
|
||||
(2,13,"GtkShortcutsShortcut","accelerator","<Ctrl>f",None,None,None,None,None,None,None,None,None),
|
||||
(2,13,"GtkShortcutsShortcut","title","{{ tr(key=\"sc-gen-library\") }}",None,None,None,None,None,None,None,None,None),
|
||||
(2,14,"GtkShortcutsShortcut","accelerator","<Ctrl>w",None,None,None,None,None,None,None,None,None),
|
||||
(2,14,"GtkShortcutsShortcut","title","{{ tr(key=\"sc-gen-close-window\") }}",None,None,None,None,None,None,None,None,None)
|
||||
(2,14,"GtkShortcutsShortcut","title","{{ tr(key=\"sc-gen-close-window\") }}",None,None,None,None,None,None,None,None,None),
|
||||
(2,15,"GtkShortcutsShortcut","accelerator","<Ctrl>q",None,None,None,None,None,None,None,None,None),
|
||||
(2,15,"GtkShortcutsShortcut","title","{{ tr(key=\"sc-gen-quit\") }}",None,None,None,None,None,None,None,None,None)
|
||||
</object_property>
|
||||
</cambalache-project>
|
||||
|
@@ -1,7 +1,11 @@
|
||||
use adw::prelude::*;
|
||||
use gtk::glib;
|
||||
use jellyfin_api::types::BaseItemDto;
|
||||
use relm4::{prelude::*, MessageBroker};
|
||||
use relm4::{
|
||||
actions::{AccelsPlus, RelmAction, RelmActionGroup},
|
||||
prelude::*,
|
||||
MessageBroker,
|
||||
};
|
||||
use std::{
|
||||
cell::OnceCell,
|
||||
sync::{Arc, RwLock},
|
||||
@@ -165,9 +169,7 @@ impl Component for App {
|
||||
|
||||
let widgets = view_output!();
|
||||
|
||||
let app = relm4::main_application();
|
||||
app.set_accels_for_action("win.show-help-overlay", &["<Ctrl>question"]);
|
||||
app.set_accels_for_action("window.close", &["<Ctrl>w"]);
|
||||
model.register_actions();
|
||||
|
||||
ComponentParts { model, widgets }
|
||||
}
|
||||
@@ -267,6 +269,24 @@ impl Component for App {
|
||||
}
|
||||
}
|
||||
|
||||
impl App {
|
||||
fn register_actions(&self) {
|
||||
let app = relm4::main_application();
|
||||
app.set_accels_for_action("win.show-help-overlay", &["<Ctrl>question"]);
|
||||
app.set_accels_for_action("window.close", &["<Ctrl>w"]);
|
||||
|
||||
let mut group = RelmActionGroup::<AppActionGroup>::new();
|
||||
|
||||
let quit_action: RelmAction<QuitAction> = RelmAction::new_stateless(|_| {
|
||||
relm4::main_application().quit();
|
||||
});
|
||||
app.set_accelerators_for_action::<QuitAction>(&["<Ctrl>q"]);
|
||||
|
||||
group.add_action(quit_action);
|
||||
group.register_for_main_application();
|
||||
}
|
||||
}
|
||||
|
||||
fn keyboard_shortcuts() -> gtk::ShortcutsWindow {
|
||||
gtk::Builder::from_string(&tera_tr(include_str!("../../data/ui/shortcuts.ui")).unwrap())
|
||||
.object::<gtk::ShortcutsWindow>("shortcuts")
|
||||
@@ -298,3 +318,6 @@ fn convert_library_output(output: LibraryOutput) -> AppInput {
|
||||
LibraryOutput::PlayVideo(media) => AppInput::PlayVideo(*media),
|
||||
}
|
||||
}
|
||||
|
||||
relm4::new_action_group!(AppActionGroup, "app");
|
||||
relm4::new_stateless_action!(QuitAction, AppActionGroup, "quit");
|
||||
|
@@ -4,6 +4,7 @@ sc-gen = General
|
||||
sc-gen-shortcuts = Show shortcuts
|
||||
sc-gen-library = Search library
|
||||
sc-gen-close-window = Close window
|
||||
sc-gen-quit = Quit
|
||||
# Video Player
|
||||
# ============
|
||||
sc-vp = Video Player
|
||||
|
Reference in New Issue
Block a user