[kde-doc-english] [trojita] src/Gui: GUI: Merge the main menu into the main toolbar

Jan Kundrát jkt at kde.org
Fri Jan 29 11:39:25 UTC 2016


Git commit ae3e320c8d2ad6039aecb0bab021c3a1112a4c2b by Jan Kundrát.
Committed on 27/01/2016 at 14:19.
Pushed by gerrit into branch 'master'.

GUI: Merge the main menu into the main toolbar

This has been a long-term plan since the QStatusBar removal. I find this
pretty useful because it saves the screen real estate -- especially when
the toolbar itself is vertical, and the screen is a wide one.

Change-Id: I37624b13e4091d8ecfde0d63f90982cbb37bcc51

M  +21   -1    src/Gui/Window.cpp
M  +1    -0    src/Gui/Window.h

http://commits.kde.org/trojita/ae3e320c8d2ad6039aecb0bab021c3a1112a4c2b

diff --git a/src/Gui/Window.cpp b/src/Gui/Window.cpp
index d27e5b3..687da1f 100644
--- a/src/Gui/Window.cpp
+++ b/src/Gui/Window.cpp
@@ -494,6 +494,18 @@ void MainWindow::createActions()
     m_replyButton->setMenu(m_replyMenu);
     m_replyButton->setDefaultAction(m_replyPrivate);
 
+    m_menuFromToolBar = new QToolButton(this);
+    m_menuFromToolBar->setIcon(UiUtils::loadIcon(QLatin1String("menu_new")));
+    m_menuFromToolBar->setText(QChar(0x205d)); // Unicode 'TRICOLON'
+    m_menuFromToolBar->setPopupMode(QToolButton::MenuButtonPopup);
+    connect(m_menuFromToolBar, &QAbstractButton::clicked, m_menuFromToolBar, &QToolButton::showMenu);
+    m_mainToolbar->addWidget(m_menuFromToolBar);
+    connect(showMenuBar, &QAction::toggled, [this](const bool menuBarVisible) {
+        // https://bugreports.qt.io/browse/QTBUG-35768 , we have to work on the QAction, not QToolButton
+        m_mainToolbar->actions()[0]->setVisible(!menuBarVisible);
+    });
+    m_mainToolbar->actions()[0]->setVisible(false); // initial state to complement the default of the QMenuBar's visibility
+
     m_mainToolbar->addWidget(m_composeButton);
     m_mainToolbar->addWidget(m_replyButton);
     m_mainToolbar->addAction(m_forwardAsAttachment);
@@ -505,7 +517,6 @@ void MainWindow::createActions()
     m_mainToolbar->addAction(markAsJunk);
     m_mainToolbar->addAction(markAsNotJunk);
     m_mainToolbar->addSeparator();
-    m_mainToolbar->addAction(showMenuBar);
     m_mainToolbar->addAction(configSettings);
 
     // Push the status indicators all the way to the other side of the toolbar -- either to the far right, or far bottom.
@@ -635,6 +646,15 @@ void MainWindow::createMenus()
     helpMenu->addSeparator();
     ADD_ACTION(helpMenu, aboutTrojita);
 
+    QMenu *mainMenuBehindToolBar = new QMenu(this);
+    m_menuFromToolBar->setMenu(mainMenuBehindToolBar);
+    m_menuFromToolBar->menu()->addMenu(imapMenu);
+    m_menuFromToolBar->menu()->addMenu(viewMenu);
+    m_menuFromToolBar->menu()->addMenu(mailboxMenu);
+    m_menuFromToolBar->menu()->addMenu(helpMenu);
+    m_menuFromToolBar->menu()->addSeparator();
+    m_menuFromToolBar->menu()->addAction(showMenuBar);
+
     networkIndicator->setMenu(netPolicyMenu);
     m_netToolbarDefaultAction = new QAction(this);
     networkIndicator->setDefaultAction(m_netToolbarDefaultAction);
diff --git a/src/Gui/Window.h b/src/Gui/Window.h
index 2e80465..b6235a0 100644
--- a/src/Gui/Window.h
+++ b/src/Gui/Window.h
@@ -336,6 +336,7 @@ private:
     QAction *m_actionContactEditor;
 
     QToolBar *m_mainToolbar;
+    QToolButton *m_menuFromToolBar;
     QToolButton *m_replyButton;
     QMenu *m_replyMenu;
     QToolButton *m_composeButton;



More information about the kde-doc-english mailing list