aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mainwindow/mainwindow.cpp1
-rw-r--r--src/mainwindow/menubar.cpp26
-rw-r--r--src/mainwindow/menubar.h3
3 files changed, 27 insertions, 3 deletions
diff --git a/src/mainwindow/mainwindow.cpp b/src/mainwindow/mainwindow.cpp
index ea024c5..5358fb6 100644
--- a/src/mainwindow/mainwindow.cpp
+++ b/src/mainwindow/mainwindow.cpp
@@ -252,6 +252,7 @@ SubWindow *MainWindow::createSubWindow(WebProfile *profile, bool openProfileNewt
}
auto *w = new SubWindow(configuration, this);
+ m_menuBar->insertSubWindow(w);
w->setProfile(profile);
mdiArea->addSubWindow(w);
diff --git a/src/mainwindow/menubar.cpp b/src/mainwindow/menubar.cpp
index bc06f65..e74069e 100644
--- a/src/mainwindow/menubar.cpp
+++ b/src/mainwindow/menubar.cpp
@@ -122,7 +122,7 @@ MenuBar::MenuBar(const Configuration *config, MainWindow *parent)
config->setShortcut(actionQuit, "mainwindow.shortcuts.quit");
}
- auto *window = this->addMenu(tr("Window"));
+ window = this->addMenu(tr("&Window"));
{
auto *actionNewWindow = window->addAction(tr("New Window"), browser, &Browser::createWindow);
config->setShortcut(actionNewWindow, "mainwindow.shortcuts.newWindow");
@@ -139,9 +139,11 @@ MenuBar::MenuBar(const Configuration *config, MainWindow *parent)
auto *actionCascadeSubwindows = window->addAction(tr("Cascade Subwindows"), parent->mdiArea, &QMdiArea::cascadeSubWindows);
config->setShortcut(actionCascadeSubwindows, "mainwindow.shortcuts.cascadeWindows");
+
+ window->addSeparator()->setText(tr("Subwindows"));
}
- auto *subwindow = this->addMenu(tr("Subwindow"));
+ auto *subwindow = this->addMenu(tr("&Subwindow"));
{
auto *actionNewTab = subwindow->addAction(tr("New Tab"), parent, [parent]() {
run_if(parent->currentSubWindow(), [](SubWindow *_subwindow, int) {
@@ -318,7 +320,7 @@ MenuBar::MenuBar(const Configuration *config, MainWindow *parent)
});
}
- auto *page = this->addMenu(tr("Page"));
+ auto *page = this->addMenu(tr("&Page"));
{
page->addAction(tr("Create Bookmark"), parent, [browser, parent]() {
if(parent->currentView != nullptr)
@@ -374,3 +376,21 @@ QAction *MenuBar::insertPlugin(QMenu *menu)
{
return smolbote->insertMenu(pluginInsertLocation, 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();
+ });
+
+ action->setCheckable(true);
+ connect(subwindow, &SubWindow::windowStateChanged, action, [action](Qt::WindowStates, Qt::WindowStates state) {
+ action->setChecked(state.testFlag(Qt::WindowMaximized) | state.testFlag(Qt::WindowActive));
+ });
+
+ connect(subwindow, &SubWindow::windowTitleChanged, action, &QAction::setText);
+ connect(subwindow, &SubWindow::destroyed, action, &QAction::deleteLater);
+}
diff --git a/src/mainwindow/menubar.h b/src/mainwindow/menubar.h
index 7b592dd..0d94f30 100644
--- a/src/mainwindow/menubar.h
+++ b/src/mainwindow/menubar.h
@@ -13,6 +13,7 @@
class Configuration;
class MainWindow;
+class SubWindow;
class MenuBar : public QMenuBar
{
Q_OBJECT
@@ -21,9 +22,11 @@ public:
MenuBar(const Configuration *config, MainWindow *parent = nullptr);
QAction *insertPlugin(QMenu *menu);
+ void insertSubWindow(SubWindow *subwindow);
private:
QMenu *smolbote = nullptr;
+ QMenu *window = nullptr;
QAction *pluginInsertLocation = nullptr;
};