Merged fullscreen combos. Fixed bug when config file can't be loaded.

This commit is contained in:
=
2025-04-20 13:43:14 -07:00
parent 4c20994d59
commit aefcdc9e01
4 changed files with 52 additions and 57 deletions

View File

@@ -225,6 +225,28 @@ int other_scsi_present = 0; /* SCSI contro
// Accelerator key array
struct accelKey acc_keys[NUM_ACCELS];
// Default accelerator key values
struct accelKey def_acc_keys[NUM_ACCELS] = {
{ .name="send_ctrl_alt_del", .desc="Send Control+Alt+Del",
.seq="Ctrl+F12" },
{ .name="send_ctrl_alt_esc", .desc="Send Control+Alt+Escape",
.seq="Ctrl+F10" },
{ .name="fullscreen", .desc="Toggle fullscreen",
.seq="Ctrl+Alt+PgUp" },
{ .name="screenshot", .desc="Screenshot",
.seq="Ctrl+F11" },
{ .name="release_mouse", .desc="Release mouse pointer",
.seq="Ctrl+End" },
{ .name="hard_reset", .desc="Hard reset",
.seq="Ctrl+Alt+F12" }
};
/* Statistics. */
extern int mmuflush;
extern int readlnum;
@@ -998,6 +1020,14 @@ usage:
gdbstub_init();
// Initialize the keyboard accelerator list with default values
for(int x=0;x<NUM_ACCELS;x++) {
strcpy(acc_keys[x].name, def_acc_keys[x].name);
strcpy(acc_keys[x].desc, def_acc_keys[x].desc);
strcpy(acc_keys[x].seq, def_acc_keys[x].seq);
}
/* All good! */
return 1;
}

View File

@@ -107,29 +107,6 @@ config_log(const char *fmt, ...)
# define config_log(fmt, ...)
#endif
// Default accelerator key values
struct accelKey def_acc_keys[NUM_ACCELS] = {
{ .name="send_ctrl_alt_del", .desc="Send Control+Alt+Del",
.seq="Ctrl+F12" },
{ .name="send_ctrl_alt_esc", .desc="Send Control+Alt+Escape",
.seq="Ctrl+F10" },
{ .name="fullscreen", .desc="Fullscreen",
.seq="Ctrl+Alt+PgUp" },
{ .name="screenshot", .desc="Screenshot",
.seq="Ctrl+F11" },
{ .name="release_mouse", .desc="Release mouse pointer",
.seq="Ctrl+End" },
{ .name="hard_reset", .desc="Hard reset",
.seq="Ctrl+Alt+F12" },
{ .name="leave_fullscreen", .desc="Leave fullscreen",
.seq="Ctrl+Alt+PgDn" }
};
/* Load "General" section. */
static void
@@ -1795,13 +1772,6 @@ load_keybinds(void)
char temp[512];
memset(temp, 0, sizeof(temp));
// Initialize the bind list with the defaults
for(int x=0;x<NUM_ACCELS;x++) {
strcpy(acc_keys[x].name, def_acc_keys[x].name);
strcpy(acc_keys[x].desc, def_acc_keys[x].desc);
strcpy(acc_keys[x].seq, def_acc_keys[x].seq);
}
// Now load values from config
for(int x=0;x<NUM_ACCELS;x++)
{

View File

@@ -242,8 +242,9 @@ struct accelKey {
char desc[64];
char seq[64];
};
#define NUM_ACCELS 7
#define NUM_ACCELS 6
extern struct accelKey acc_keys[NUM_ACCELS];
extern struct accelKey def_acc_keys[NUM_ACCELS];
extern int FindAccelerator(const char *name);
#ifdef __cplusplus

View File

@@ -676,17 +676,6 @@ 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, [](){});
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
windowedShortcut = new QShortcut(QKeySequence(Qt::CTRL | Qt::ALT | Qt::Key_PageDown), this);
#else
windowedShortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_PageDown), this);
#endif
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);
@@ -836,10 +825,11 @@ void MainWindow::updateShortcuts()
// Note that the "Release mouse" shortcut is hardcoded elsewhere
// This section only applies to shortcuts anchored to UI elements
// First we need to wipe all existing accelerators, otherwise Qt will
// run into conflicts with old ones.
ui->actionTake_screenshot->setShortcut(QKeySequence());
ui->actionCtrl_Alt_Del->setShortcut(QKeySequence());
ui->actionCtrl_Alt_Esc->setShortcut(QKeySequence());
ui->actionFullscreen->setShortcut(QKeySequence());
ui->actionHard_Reset->setShortcut(QKeySequence());
int accID;
@@ -857,25 +847,13 @@ void MainWindow::updateShortcuts()
seq = QKeySequence::fromString(acc_keys[accID].seq);
ui->actionCtrl_Alt_Esc->setShortcut(seq);
accID = FindAccelerator("fullscreen");
seq = QKeySequence::fromString(acc_keys[accID].seq);
ui->actionFullscreen->setShortcut(seq);
accID = FindAccelerator("hard_reset");
seq = QKeySequence::fromString(acc_keys[accID].seq);
ui->actionHard_Reset->setShortcut(seq);
// To rebind leave_fullscreen we have to disconnect the existing signal,
// build a new shortcut, then connect it.
accID = FindAccelerator("leave_fullscreen");
accID = FindAccelerator("fullscreen");
seq = QKeySequence::fromString(acc_keys[accID].seq);
disconnect(windowedShortcut,0,0,0);
windowedShortcut = new QShortcut(seq, this);
windowedShortcut->setContext(Qt::ShortcutContext::ApplicationShortcut);
connect(windowedShortcut, &QShortcut::activated, this, [this] () {
if (video_fullscreen)
ui->actionFullscreen->trigger();
});
ui->actionFullscreen->setShortcut(seq);
}
void
@@ -1361,6 +1339,20 @@ MainWindow::eventFilter(QObject *receiver, QEvent *event)
if (event->type() == QEvent::KeyPress) {
event->accept();
this->keyPressEvent((QKeyEvent *) event);
// Detect fullscreen shortcut when menubar is hidden
int accID = FindAccelerator("fullscreen");
QKeySequence seq = QKeySequence::fromString(acc_keys[accID].seq);
if (event->type() == QEvent::KeyPress)
{
QKeyEvent *ke = (QKeyEvent *) event;
if ((QKeySequence)(ke->key() | ke->modifiers()) == seq && video_fullscreen != 0)
{
ui->actionFullscreen->trigger();
}
}
return true;
}
if (event->type() == QEvent::KeyRelease) {
@@ -1380,6 +1372,8 @@ MainWindow::eventFilter(QObject *receiver, QEvent *event)
plat_pause(curdopause);
}
}
return QMainWindow::eventFilter(receiver, event);
}