Make Qt shortcuts actually work in fullscreen

Also removes hacks related to fullscreen.
This commit is contained in:
Cacodemon345
2025-04-05 23:59:49 +06:00
parent fd2214f544
commit 6d2128ab05
3 changed files with 28 additions and 36 deletions

View File

@@ -674,6 +674,13 @@ MainWindow::MainWindow(QWidget *parent)
/* Remove default Shift+F10 handler, which unfocuses keyboard input even with no context menu. */
connect(new QShortcut(QKeySequence(Qt::SHIFT + Qt::Key_F10), this), &QShortcut::activated, this, [](){});
auto windowedShortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_PageDown), this);
windowedShortcut->setContext(Qt::ShortcutContext::ApplicationShortcut);
connect(windowedShortcut, &QShortcut::activated, this, [this] () {
if (video_fullscreen)
ui->actionFullscreen->trigger();
});
connect(this, &MainWindow::initRendererMonitor, this, &MainWindow::initRendererMonitorSlot);
connect(this, &MainWindow::initRendererMonitorForNonQtThread, this, &MainWindow::initRendererMonitorSlot, Qt::BlockingQueuedConnection);
connect(this, &MainWindow::destroyRendererMonitor, this, &MainWindow::destroyRendererMonitorSlot);
@@ -696,6 +703,22 @@ MainWindow::MainWindow(QWidget *parent)
});
#endif
QTimer::singleShot(0, this, [this]() {
for (auto curObj : this->menuBar()->children()) {
if (qobject_cast<QMenu *>(curObj)) {
auto menu = qobject_cast<QMenu *>(curObj);
for (auto curObj2 : menu->children()) {
if (qobject_cast<QAction *>(curObj2)) {
auto action = qobject_cast<QAction *>(curObj2);
if (!action->shortcut().isEmpty()) {
this->insertAction(nullptr, action);
}
}
}
}
}
});
actGroup = new QActionGroup(this);
actGroup->addAction(ui->actionCursor_Puck);
actGroup->addAction(ui->actionPen);
@@ -833,6 +856,11 @@ MainWindow::initRendererMonitorSlot(int monitor_index)
});
secondaryRenderer->setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
secondaryRenderer->setWindowTitle(QObject::tr("86Box Monitor #") + QString::number(monitor_index + 1));
secondaryRenderer->setContextMenuPolicy(Qt::PreventContextMenu);
for (int i = 0; i < this->actions().size(); i++) {
secondaryRenderer->addAction(this->actions()[i]);
}
if (vid_resize == 2)
secondaryRenderer->setFixedSize(fixed_size_x, fixed_size_y);
@@ -1360,18 +1388,9 @@ MainWindow::keyPressEvent(QKeyEvent *event)
#endif
}
checkFullscreenHotkey();
if (keyboard_ismsexit())
plat_mouse_capture(0);
if ((video_fullscreen > 0) && (keyboard_recv_ui(0x1D) || keyboard_recv_ui(0x11D))) {
if (keyboard_recv_ui(0x57))
ui->actionTake_screenshot->trigger();
else if (keyboard_recv_ui(0x58))
pc_send_cad();
}
event->accept();
}
@@ -1403,28 +1422,6 @@ MainWindow::keyReleaseEvent(QKeyEvent *event)
processKeyboardInput(false, event->nativeScanCode());
#endif
}
checkFullscreenHotkey();
}
void
MainWindow::checkFullscreenHotkey()
{
if (!fs_off_signal && video_fullscreen && keyboard_isfsexit()) {
/* Signal "exit fullscreen mode". */
fs_off_signal = true;
} else if (fs_off_signal && video_fullscreen && keyboard_isfsexit_up()) {
ui->actionFullscreen->trigger();
fs_off_signal = false;
}
if (!fs_on_signal && !video_fullscreen && keyboard_isfsenter()) {
/* Signal "enter fullscreen mode". */
fs_on_signal = true;
} else if (fs_on_signal && !video_fullscreen && keyboard_isfsenter_up()) {
ui->actionFullscreen->trigger();
fs_on_signal = false;
}
}
QSize