diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bookmarks/bookmarkstoolbar.cpp | 9 | ||||
-rw-r--r-- | src/mainwindow/mainwindow.cpp | 5 | ||||
-rw-r--r-- | src/mainwindow/menubar.cpp | 14 | ||||
-rw-r--r-- | src/mainwindow/widgets/navigationbar.cpp | 2 |
4 files changed, 26 insertions, 4 deletions
diff --git a/src/bookmarks/bookmarkstoolbar.cpp b/src/bookmarks/bookmarkstoolbar.cpp index 55710ca..b8747d8 100644 --- a/src/bookmarks/bookmarkstoolbar.cpp +++ b/src/bookmarks/bookmarkstoolbar.cpp @@ -15,6 +15,9 @@ BookmarksToolbar::BookmarksToolbar(const BookmarkModel *model, MainWindow *paren : QToolBar(parent) { m_window = parent; + setObjectName("bookmarkstoolbar"); + setWindowTitle(tr("Bookmarks Toolbar")); + setMovable(false); setToolButtonStyle(Qt::ToolButtonTextBesideIcon); const auto *root = model->root(); @@ -58,6 +61,12 @@ void BookmarksToolbar::addFolder(const BookmarkItem *item, QMenu *where) auto *menu = new QMenu(this); addFolder(child, menu); action->setMenu(menu); + + connect(action, &QAction::triggered, this, [this, action, menu]() { + const auto *widget = this->widgetForAction(action); + const auto pos = widget->mapToGlobal(QPoint(0, widget->height())); + menu->popup(pos); + }); } } } diff --git a/src/mainwindow/mainwindow.cpp b/src/mainwindow/mainwindow.cpp index 5386aab..e03ec46 100644 --- a/src/mainwindow/mainwindow.cpp +++ b/src/mainwindow/mainwindow.cpp @@ -41,8 +41,6 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , mdiArea(new QMdiArea(this)) { - m_menuBar = new MenuBar(this); - this->setMenuBar(m_menuBar); Configuration config; @@ -82,6 +80,9 @@ MainWindow::MainWindow(QWidget *parent) this->addToolBarBreak(); this->addToolBar(new BookmarksToolbar(app->bookmarks()->model(), this)); + m_menuBar = new MenuBar(this); + this->setMenuBar(m_menuBar); + mdiArea->setBackground(Qt::NoBrush); setCentralWidget(mdiArea); mdiArea->setFocus(); diff --git a/src/mainwindow/menubar.cpp b/src/mainwindow/menubar.cpp index 27a8561..f1b3565 100644 --- a/src/mainwindow/menubar.cpp +++ b/src/mainwindow/menubar.cpp @@ -29,6 +29,7 @@ #include <QVBoxLayout> #include <QWidgetAction> #include <functional> +#include <QToolBar> inline void run_if(SubWindow *_subwindow, const std::function<void(SubWindow *, int)> &f) { @@ -161,14 +162,23 @@ MenuBar::MenuBar(MainWindow *parent) }); setShortcut(actionNewSubwindow, "shortcuts.window.newgroup"); - window->addSeparator(); - auto *actionTileSubwindows = window->addAction(tr("Tile Subwindows"), parent->mdiArea, &QMdiArea::tileSubWindows); setShortcut(actionTileSubwindows, "shortcuts.subwindow.tile"); auto *actionCascadeSubwindows = window->addAction(tr("Cascade Subwindows"), parent->mdiArea, &QMdiArea::cascadeSubWindows); setShortcut(actionCascadeSubwindows, "shortcuts.subwindow.cascade"); + window->addSeparator()->setText(tr("Toolbars")); + + for(auto *toolbar : parent->findChildren<QToolBar*>()) { + auto *action = window->addAction(toolbar->windowTitle()); + action->setCheckable(true); + action->setChecked(toolbar->isVisible()); + connect(toolbar, &QToolBar::visibilityChanged, action, &QAction::setChecked); + connect(action, &QAction::triggered, toolbar, &QToolBar::setVisible); + setShortcut(action, qUtf8Printable("shortcuts."+toolbar->objectName()+".show")); + } + window->addSeparator()->setText(tr("Subwindows")); } diff --git a/src/mainwindow/widgets/navigationbar.cpp b/src/mainwindow/widgets/navigationbar.cpp index 89e1e50..75bc90c 100644 --- a/src/mainwindow/widgets/navigationbar.cpp +++ b/src/mainwindow/widgets/navigationbar.cpp @@ -23,6 +23,8 @@ NavigationBar::NavigationBar(QWidget *parent) : QToolBar(parent) { + setObjectName("navigationbar"); + setWindowTitle(tr("Navigation Toolbar")); Configuration config; // Back button |