All shortcuts now work in fullscreen

This commit is contained in:
=
2025-04-20 13:59:52 -07:00
parent aefcdc9e01
commit 24a4ed445e
2 changed files with 40 additions and 7 deletions

View File

@@ -1325,6 +1325,19 @@ MainWindow::getTitle(wchar_t *title)
} }
} }
// Helper to find an accelerator key and return it's sequence
// TODO: Is there a more central place to put this?
QKeySequence
MainWindow::FindAcceleratorSeq(const char *name)
{
int accID = FindAccelerator(name);
if(accID == -1)
return false;
return(QKeySequence::fromString(acc_keys[accID].seq));
}
bool bool
MainWindow::eventFilter(QObject *receiver, QEvent *event) MainWindow::eventFilter(QObject *receiver, QEvent *event)
{ {
@@ -1337,22 +1350,40 @@ MainWindow::eventFilter(QObject *receiver, QEvent *event)
} }
} }
if (event->type() == QEvent::KeyPress) { if (event->type() == QEvent::KeyPress) {
event->accept();
this->keyPressEvent((QKeyEvent *) event); this->keyPressEvent((QKeyEvent *) event);
// Detect fullscreen shortcut when menubar is hidden // Detect shortcuts when menubar is hidden
int accID = FindAccelerator("fullscreen"); // TODO: Could this be simplified by proxying the event and manually
QKeySequence seq = QKeySequence::fromString(acc_keys[accID].seq); // shoving it into the menubar?
QKeySequence accKey;
if (event->type() == QEvent::KeyPress) if (event->type() == QEvent::KeyPress && video_fullscreen != 0)
{ {
QKeyEvent *ke = (QKeyEvent *) event; QKeyEvent *ke = (QKeyEvent *) event;
if ((QKeySequence)(ke->key() | ke->modifiers()) == seq && video_fullscreen != 0)
if ((QKeySequence)(ke->key() | ke->modifiers()) == FindAcceleratorSeq("screenshot"))
{
ui->actionTake_screenshot->trigger();
}
if ((QKeySequence)(ke->key() | ke->modifiers()) == FindAcceleratorSeq("send_ctrl_alt_del"))
{
ui->actionCtrl_Alt_Del->trigger();
}
if ((QKeySequence)(ke->key() | ke->modifiers()) == FindAcceleratorSeq("send_ctrl_alt_esc"))
{
ui->actionCtrl_Alt_Esc->trigger();
}
if ((QKeySequence)(ke->key() | ke->modifiers()) == FindAcceleratorSeq("hard_reset"))
{
ui->actionHard_Reset->trigger();
}
if ((QKeySequence)(ke->key() | ke->modifiers()) == FindAcceleratorSeq("fullscreen"))
{ {
ui->actionFullscreen->trigger(); ui->actionFullscreen->trigger();
} }
} }
event->accept();
return true; return true;
} }
if (event->type() == QEvent::KeyRelease) { if (event->type() == QEvent::KeyRelease) {

View File

@@ -34,6 +34,8 @@ public:
void setSendKeyboardInput(bool enabled); void setSendKeyboardInput(bool enabled);
void reloadAllRenderers(); void reloadAllRenderers();
QShortcut *windowedShortcut; QShortcut *windowedShortcut;
QKeySequence FindAcceleratorSeq(const char *name);
std::array<std::unique_ptr<RendererStack>, 8> renderers; std::array<std::unique_ptr<RendererStack>, 8> renderers;
signals: signals: