summaryrefslogtreecommitdiff
path: root/src/mainwindow.cpp
diff options
context:
space:
mode:
authorisanae <14251494+isanae@users.noreply.github.com>2019-10-07 02:31:42 -0400
committerGitHub <noreply@github.com>2019-10-07 02:31:42 -0400
commit85f1635d2d3bbc6f23dbb8f1e39d400c6ab12203 (patch)
tree88e0405e7f1bff0f0103ded82e987be2629d6487 /src/mainwindow.cpp
parent7fae2fb9f1d81a352eb6169b0a3a4c7671b94dfb (diff)
parentef993a693c9ca5acf60daac3506411ef6b81bb89 (diff)
Merge pull request #855 from isanae/context-menu-log-toggle
Log toggle in context menu
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r--src/mainwindow.cpp30
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()