diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2019-10-07 02:31:42 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-10-07 02:31:42 -0400 |
| commit | 85f1635d2d3bbc6f23dbb8f1e39d400c6ab12203 (patch) | |
| tree | 88e0405e7f1bff0f0103ded82e987be2629d6487 /src | |
| parent | 7fae2fb9f1d81a352eb6169b0a3a4c7671b94dfb (diff) | |
| parent | ef993a693c9ca5acf60daac3506411ef6b81bb89 (diff) | |
Merge pull request #855 from isanae/context-menu-log-toggle
Log toggle in context menu
Diffstat (limited to 'src')
| -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 76109e00..295c60a6 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() |
