citra-emu
/
citra
Archived
1
0
Fork 0

Qt: Implement more hotkeys for secondary window (#6198)

This commit is contained in:
Ameer J 2022-11-24 08:55:27 -05:00 committed by GitHub
parent 850e5bf81c
commit d1171328c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 11 deletions

View File

@ -473,6 +473,9 @@ void GMainWindow::InitializeHotkeys() {
const QString toggle_filter_bar = QStringLiteral("Toggle Filter Bar"); const QString toggle_filter_bar = QStringLiteral("Toggle Filter Bar");
const QString toggle_status_bar = QStringLiteral("Toggle Status Bar"); const QString toggle_status_bar = QStringLiteral("Toggle Status Bar");
const QString fullscreen = QStringLiteral("Fullscreen"); const QString fullscreen = QStringLiteral("Fullscreen");
const QString toggle_screen_layout = QStringLiteral("Toggle Screen Layout");
const QString swap_screens = QStringLiteral("Swap Screens");
const QString rotate_screens = QStringLiteral("Rotate Screens Upright");
ui->action_Show_Filter_Bar->setShortcut( ui->action_Show_Filter_Bar->setShortcut(
hotkey_registry.GetKeySequence(main_window, toggle_filter_bar)); hotkey_registry.GetKeySequence(main_window, toggle_filter_bar));
@ -510,28 +513,39 @@ void GMainWindow::InitializeHotkeys() {
return; return;
BootGame(QString(game_path)); BootGame(QString(game_path));
}); });
connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Swap Screens"), render_window), connect(hotkey_registry.GetHotkey(main_window, swap_screens, render_window),
&QShortcut::activated, ui->action_Screen_Layout_Swap_Screens, &QAction::trigger); &QShortcut::activated, ui->action_Screen_Layout_Swap_Screens, &QAction::trigger);
connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Rotate Screens Upright"), connect(hotkey_registry.GetHotkey(main_window, rotate_screens, render_window),
render_window),
&QShortcut::activated, ui->action_Screen_Layout_Upright_Screens, &QAction::trigger); &QShortcut::activated, ui->action_Screen_Layout_Upright_Screens, &QAction::trigger);
connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Toggle Screen Layout"), connect(hotkey_registry.GetHotkey(main_window, toggle_screen_layout, render_window),
render_window),
&QShortcut::activated, this, &GMainWindow::ToggleScreenLayout); &QShortcut::activated, this, &GMainWindow::ToggleScreenLayout);
connect(hotkey_registry.GetHotkey(main_window, fullscreen, render_window), connect(hotkey_registry.GetHotkey(main_window, fullscreen, render_window),
&QShortcut::activated, ui->action_Fullscreen, &QAction::trigger); &QShortcut::activated, ui->action_Fullscreen, &QAction::trigger);
connect(hotkey_registry.GetHotkey(main_window, fullscreen, render_window), connect(hotkey_registry.GetHotkey(main_window, fullscreen, render_window),
&QShortcut::activatedAmbiguously, ui->action_Fullscreen, &QAction::trigger); &QShortcut::activatedAmbiguously, ui->action_Fullscreen, &QAction::trigger);
// This action will fire specifically when secondary_window is in focus const auto add_secondary_window_hotkey = [this](QKeySequence hotkey, const char* slot) {
QAction* secondary_fullscreen_action = new QAction(secondary_window); // This action will fire specifically when secondary_window is in focus
QAction* secondary_window_action = new QAction(secondary_window);
secondary_window_action->setShortcut(hotkey);
connect(secondary_window_action, SIGNAL(triggered()), this, slot);
secondary_window->addAction(secondary_window_action);
};
// Use the same fullscreen hotkey as the main window // Use the same fullscreen hotkey as the main window
const auto fullscreen_hotkey = hotkey_registry.GetKeySequence(main_window, fullscreen); const auto fullscreen_hotkey = hotkey_registry.GetKeySequence(main_window, fullscreen);
secondary_fullscreen_action->setShortcut(fullscreen_hotkey); add_secondary_window_hotkey(fullscreen_hotkey, SLOT(ToggleSecondaryFullscreen()));
connect(secondary_fullscreen_action, SIGNAL(triggered()), this, const auto toggle_screen_hotkey =
SLOT(ToggleSecondaryFullscreen())); hotkey_registry.GetKeySequence(main_window, toggle_screen_layout);
secondary_window->addAction(secondary_fullscreen_action); add_secondary_window_hotkey(toggle_screen_hotkey, SLOT(ToggleScreenLayout()));
const auto swap_screen_hotkey = hotkey_registry.GetKeySequence(main_window, swap_screens);
add_secondary_window_hotkey(swap_screen_hotkey, SLOT(TriggerSwapScreens()));
const auto rotate_screen_hotkey = hotkey_registry.GetKeySequence(main_window, rotate_screens);
add_secondary_window_hotkey(rotate_screen_hotkey, SLOT(TriggerRotateScreens()));
connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Exit Fullscreen"), this), connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Exit Fullscreen"), this),
&QShortcut::activated, this, [&] { &QShortcut::activated, this, [&] {
@ -1819,6 +1833,14 @@ void GMainWindow::OnRotateScreens() {
Settings::Apply(); Settings::Apply();
} }
void GMainWindow::TriggerSwapScreens() {
ui->action_Screen_Layout_Swap_Screens->trigger();
}
void GMainWindow::TriggerRotateScreens() {
ui->action_Screen_Layout_Upright_Screens->trigger();
}
void GMainWindow::OnCheats() { void GMainWindow::OnCheats() {
CheatDialog cheat_dialog(this); CheatDialog cheat_dialog(this);
cheat_dialog.exec(); cheat_dialog.exec();

View File

@ -203,6 +203,8 @@ private slots:
void ToggleScreenLayout(); void ToggleScreenLayout();
void OnSwapScreens(); void OnSwapScreens();
void OnRotateScreens(); void OnRotateScreens();
void TriggerSwapScreens();
void TriggerRotateScreens();
void OnCheats(); void OnCheats();
void ShowFullscreen(); void ShowFullscreen();
void HideFullscreen(); void HideFullscreen();