Skip to content

Commit

Permalink
Merge pull request #570 from Tarsnap/quit-keyboard
Browse files Browse the repository at this point in the history
Fix cmd-Q on macOS
  • Loading branch information
gperciva authored Nov 18, 2023
2 parents b2758ff + 4b08848 commit 9c0fb97
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
3 changes: 0 additions & 3 deletions src/widgets/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,6 @@ void MainWindow::setupMenuBar()
this->showNormal();
});
#ifdef Q_OS_OSX
// Remove the file menu, because macOS will add an "app menu".
_ui->menu_File->menuAction()->setVisible(false);

// Leave the three Windows actions enabled and visible.
#else
// Set default shortcut for showing the help.
Expand Down
21 changes: 21 additions & 0 deletions tests/mainwindow/test-mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ private slots:
void about_window_menubar();
void stoptasksdialog_nonquit();
void quit_simple();
void quit_keyboard();
void quit_tasks();
void tab_navigation();
void other_navigation();
Expand Down Expand Up @@ -208,6 +209,26 @@ void TestMainWindow::quit_simple()
delete mainwindow;
}

void TestMainWindow::quit_keyboard()
{
IF_MACOS_PRE_5_15_SKIP;
IF_NOT_VISUAL { QSKIP("can't check keyboard with --platform=offscreen"); }

MainWindow *mainwindow = new MainWindow();

VISUAL_INIT(mainwindow);

// We should be visible.
QVERIFY(mainwindow->isVisible() == true);
VISUAL_WAIT;

// Try to close the window with a keyboard shortcut
QTest::keyClick(mainwindow, Qt::Key_Q, Qt::ControlModifier);
QVERIFY(mainwindow->isVisible() == false);

delete mainwindow;
}

void TestMainWindow::quit_tasks()
{
IF_MACOS_PRE_5_15_SKIP;
Expand Down

0 comments on commit 9c0fb97

Please sign in to comment.