aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2020-01-14 13:38:43 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2020-01-14 13:38:43 +0200
commit14d8b65c25b74527da1313111543f83b09d41880 (patch)
treed1b6f3aad111c14b860d90a8907edda98a329b08
parentUpdate pkgbuild (diff)
downloadsmolbote-14d8b65c25b74527da1313111543f83b09d41880.tar.xz
Add close action to subwindow list
Adding a menu to an action is incompatible with triggerring that action. This means a "Toggle to" action is required as well to preserve the functionality.
-rw-r--r--src/mainwindow/menubar.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/mainwindow/menubar.cpp b/src/mainwindow/menubar.cpp
index 76e08c6..7fdad24 100644
--- a/src/mainwindow/menubar.cpp
+++ b/src/mainwindow/menubar.cpp
@@ -508,12 +508,7 @@ QAction *MenuBar::insertPlugin(QMenu *menu)
void MenuBar::insertSubWindow(SubWindow *subwindow)
{
- auto *action = window->addAction(subwindow->windowTitle(), subwindow, [subwindow]() {
- if(!subwindow->windowState().testFlag(Qt::WindowMaximized))
- subwindow->showMaximized();
- else
- subwindow->showNormal();
- });
+ auto *action = window->addAction(subwindow->windowTitle());
action->setCheckable(true);
connect(subwindow, &SubWindow::windowStateChanged, action, [action](Qt::WindowStates, Qt::WindowStates state) {
@@ -522,4 +517,16 @@ void MenuBar::insertSubWindow(SubWindow *subwindow)
connect(subwindow, &SubWindow::windowTitleChanged, action, &QAction::setText);
connect(subwindow, &SubWindow::destroyed, action, &QAction::deleteLater);
+
+ auto *optionsMenu = new QMenu;
+ optionsMenu->addAction(tr("Switch to"), subwindow, [subwindow]() {
+ if(!subwindow->windowState().testFlag(Qt::WindowMaximized))
+ subwindow->showMaximized();
+ else
+ subwindow->showNormal();
+ });
+ optionsMenu->addAction(tr("Close"), subwindow, [subwindow]() {
+ subwindow->close();
+ });
+ action->setMenu(optionsMenu);
}