diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2019-10-05 14:36:07 -0400 |
|---|---|---|
| committer | isanae <14251494+isanae@users.noreply.github.com> | 2019-10-05 14:36:07 -0400 |
| commit | ef993a693c9ca5acf60daac3506411ef6b81bb89 (patch) | |
| tree | 700ee40922e6180e7b9c12664546dccff71f5307 /src/mainwindow.cpp | |
| parent | 73556ad0845ee6dea2ec9f1fa50903de0448fa91 (diff) | |
stop reusing the view menu, just create a new context menu with the right stuff in it
Diffstat (limited to 'src/mainwindow.cpp')
| -rw-r--r-- | src/mainwindow.cpp | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 3b977dd6..c6f2ee5d 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -787,15 +787,6 @@ void MainWindow::updatePinnedExecutables() void MainWindow::updateToolbarMenu() { - // well, this is a bit of a hack to allow the same toolbar menu to be shown - // in both the main menu and the context menu - // - // the toolbar menu is returned by createPopupMenu(), but Qt takes ownership - // of it and deletes it by setting the WA_DeleteOnClose attribute on it - // - // to avoid deleting the menu, the attribute is removed here - ui->menuToolbars->setAttribute(Qt::WA_DeleteOnClose, false); - ui->actionMainMenuToggle->setChecked(ui->menuBar->isVisible()); ui->actionToolBarMainToggle->setChecked(ui->toolBar->isVisible()); ui->actionStatusBarToggle->setChecked(ui->statusBar->isVisible()); @@ -816,7 +807,23 @@ void MainWindow::updateViewMenu() QMenu* MainWindow::createPopupMenu() { - return ui->menuToolbars; + auto* m = new QMenu; + + // add all the actions from the toolbars menu + for (auto* a : ui->menuToolbars->actions()) { + m->addAction(a); + } + + m->addSeparator(); + + // other actions + m->addAction(ui->actionViewLog); + + // make sure the actions are updated + updateToolbarMenu(); + updateViewMenu(); + + return m; } void MainWindow::on_actionMainMenuToggle_triggered() @@ -900,8 +907,7 @@ void MainWindow::on_centralWidget_customContextMenuRequested(const QPoint &pos) return; } - auto* m = createPopupMenu(); - m->exec(ui->centralWidget->mapToGlobal(pos)); + createPopupMenu()->exec(ui->centralWidget->mapToGlobal(pos)); } void MainWindow::scheduleUpdateButton() |
