From 5a729f92c1cbf45a631c130ecfac00f784536d03 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 4 Jul 2020 19:19:41 -0400 Subject: [PATCH] Attempts to move the 'Help' menu to the correct place. --- OSBindings/Qt/mainwindow.cpp | 25 ++++++++++++++++--------- OSBindings/Qt/mainwindow.h | 3 +++ 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/OSBindings/Qt/mainwindow.cpp b/OSBindings/Qt/mainwindow.cpp index 1bb23dffd..79fa707d7 100644 --- a/OSBindings/Qt/mainwindow.cpp +++ b/OSBindings/Qt/mainwindow.cpp @@ -114,7 +114,6 @@ void MainWindow::createActions() { // Add file option: 'New' QAction *const newAct = new QAction(tr("&New"), this); newAct->setShortcuts(QKeySequence::New); - newAct->setStatusTip(tr("Create a new file")); connect(newAct, &QAction::triggered, this, [this] { storeSelections(); @@ -128,7 +127,6 @@ void MainWindow::createActions() { // Add file option: 'Open...' QAction *const openAct = new QAction(tr("&Open..."), this); openAct->setShortcuts(QKeySequence::Open); - openAct->setStatusTip(tr("Open an existing file")); connect(openAct, &QAction::triggered, this, [this] { const QString fileName = getFilename("Open..."); if(!fileName.isEmpty()) { @@ -149,7 +147,6 @@ void MainWindow::createActions() { // Add a separator and then an 'Insert...'. fileMenu->addSeparator(); insertAction = new QAction(tr("&Insert..."), this); - insertAction->setStatusTip(tr("Open an existing file")); insertAction->setEnabled(false); connect(insertAction, &QAction::triggered, this, [this] { const QString fileName = getFilename("Insert..."); @@ -159,9 +156,20 @@ void MainWindow::createActions() { }); fileMenu->addAction(insertAction); + addHelpMenu(); + + // Link up the start machine button. + connect(ui->startMachineButton, &QPushButton::clicked, this, &MainWindow::startMachine); +} + +void MainWindow::addHelpMenu() { + if(helpMenu) { + menuBar()->removeAction(helpMenu->menuAction()); + } + // Add Help menu, with an 'About...' option. - QMenu *helpMenu = menuBar()->addMenu(tr("&Help")); - QAction *aboutAct = helpMenu->addAction(tr("&About"), this, [this] { + helpMenu = menuBar()->addMenu(tr("&Help")); + helpMenu->addAction(tr("&About"), this, [this] { QMessageBox::about(this, tr("About Clock Signal"), tr( "

Clock Signal is an emulator of various platforms.

" @@ -174,10 +182,6 @@ void MainWindow::createActions() { "GitHub issue tracker.

" )); }); - aboutAct->setStatusTip(tr("Show the application's About box")); - - // Link up the start machine button. - connect(ui->startMachineButton, &QPushButton::clicked, this, &MainWindow::startMachine); } QString MainWindow::getFilename(const char *title) { @@ -412,6 +416,9 @@ void MainWindow::launchMachine() { default: break; } + + // Push the help menu after any that were just added. + addHelpMenu(); } void MainWindow::addDisplayMenu(const std::string &machinePrefix, const std::string &compositeColour, const std::string &compositeMono, const std::string &svideo, const std::string &rgb) { diff --git a/OSBindings/Qt/mainwindow.h b/OSBindings/Qt/mainwindow.h index 47c319644..515f3a3a0 100644 --- a/OSBindings/Qt/mainwindow.h +++ b/OSBindings/Qt/mainwindow.h @@ -124,6 +124,9 @@ class MainWindow : public QMainWindow, public Outputs::Speaker::Speaker::Delegat void setWindowTitle(); bool mouseIsCaptured = false; + + QMenu *helpMenu = nullptr; + void addHelpMenu(); }; #endif // MAINWINDOW_H