diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2020-01-29 16:52:51 +0200 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2020-01-29 16:55:34 +0200 |
commit | 209d060b6eff7cc3f13b61758e01837087c99291 (patch) | |
tree | dd36aa62f0b8dbcd8b2b040645ea4d53fa714487 | |
parent | BookmarksToolbar: add toggle shortcut (diff) | |
download | smolbote-209d060b6eff7cc3f13b61758e01837087c99291.tar.xz |
MenuBar: Add Unlock toolbars toggle
Add BookmarksToolbar config toggles
- bookmarks.toolbar.movable
- bookmarks.toolbar.visible
clang-format pass
-rw-r--r-- | Kconfig | 12 | ||||
-rw-r--r-- | src/bookmarks/bookmarkstoolbar.cpp | 8 | ||||
-rw-r--r-- | src/mainwindow/menubar.cpp | 20 | ||||
-rw-r--r-- | src/mainwindow/widgets/navigationbar.cpp | 2 |
4 files changed, 33 insertions, 9 deletions
@@ -38,7 +38,7 @@ menu "Keyboard shortcuts" default "Ctrl+D" comment "Navigation Bar shortcuts" - config shortcuts.navigationbar.show + config navigationbar.show string "Toggle navigation bar" default "Ctrl+Shift+N" config shortcuts.navigation.back @@ -127,9 +127,15 @@ menu "Bookmarks" config shortcuts.window.bookmarks.show string "Show bookmarks dialog in this window" default "Ctrl+B" - config shortcuts.bookmarkstoolbar.show - string "Toggle bookmarks toolbar" + config bookmarks.toolbar.show + string "Toggle bookmarks toolbar visibility" default "Ctrl+Shift+B" + config bookmarks.toolbar.movable + bool "Default bookmarks toolbar movable" + default n + config bookmarks.toolbar.visible + bool "Default bookmarks toolbar visibility" + default n endmenu menu "Profile Settings" diff --git a/src/bookmarks/bookmarkstoolbar.cpp b/src/bookmarks/bookmarkstoolbar.cpp index b8747d8..52dcae2 100644 --- a/src/bookmarks/bookmarkstoolbar.cpp +++ b/src/bookmarks/bookmarkstoolbar.cpp @@ -8,6 +8,7 @@ #include "bookmarkstoolbar.h" #include "bookmarkmodel.h" +#include "configuration.h" #include "mainwindow/mainwindow.h" #include <QMenu> @@ -15,9 +16,12 @@ BookmarksToolbar::BookmarksToolbar(const BookmarkModel *model, MainWindow *paren : QToolBar(parent) { m_window = parent; - setObjectName("bookmarkstoolbar"); + Configuration conf; + + setObjectName("bookmarks.toolbar"); setWindowTitle(tr("Bookmarks Toolbar")); - setMovable(false); + setMovable(conf.value<bool>("bookmarks.toolbar.movable").value()); + setVisible(conf.value<bool>("bookmarks.toolbar.visible").value()); setToolButtonStyle(Qt::ToolButtonTextBesideIcon); const auto *root = model->root(); diff --git a/src/mainwindow/menubar.cpp b/src/mainwindow/menubar.cpp index f1b3565..b695a20 100644 --- a/src/mainwindow/menubar.cpp +++ b/src/mainwindow/menubar.cpp @@ -26,10 +26,10 @@ #include <QPrintDialog> #include <QPrinter> #include <QPrinterInfo> +#include <QToolBar> #include <QVBoxLayout> #include <QWidgetAction> #include <functional> -#include <QToolBar> inline void run_if(SubWindow *_subwindow, const std::function<void(SubWindow *, int)> &f) { @@ -170,15 +170,29 @@ MenuBar::MenuBar(MainWindow *parent) window->addSeparator()->setText(tr("Toolbars")); - for(auto *toolbar : parent->findChildren<QToolBar*>()) { + bool hasMovableToolbar = false; + + 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")); + setShortcut(action, qUtf8Printable(toolbar->objectName() + ".show")); + + if(toolbar->isMovable()) + hasMovableToolbar = true; } + auto *lockAction = window->addAction(tr("Unlock toolbars")); + lockAction->setCheckable(true); + lockAction->setChecked(hasMovableToolbar); + connect(lockAction, &QAction::triggered, parent, [parent](bool checked) { + for(auto *toolbar : parent->findChildren<QToolBar *>()) { + toolbar->setMovable(checked); + } + }); + window->addSeparator()->setText(tr("Subwindows")); } diff --git a/src/mainwindow/widgets/navigationbar.cpp b/src/mainwindow/widgets/navigationbar.cpp index 75bc90c..725003d 100644 --- a/src/mainwindow/widgets/navigationbar.cpp +++ b/src/mainwindow/widgets/navigationbar.cpp @@ -10,6 +10,7 @@ #include "configuration.h" #include "urllineedit.h" #include "util.h" +#include "webengine/webprofile.h" #include "webengine/webview.h" #include <QHBoxLayout> #include <QMenu> @@ -18,7 +19,6 @@ #include <QToolBar> #include <QToolButton> #include <QWebEngineHistory> -#include "webengine/webprofile.h" NavigationBar::NavigationBar(QWidget *parent) : QToolBar(parent) |