Commit f5163ed0 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Add hamburger action

parent 7c53769c
Pipeline #63647 passed with stage
in 7 minutes and 56 seconds
<!DOCTYPE gui SYSTEM "kpartgui.dtd">
<gui name="akregator_part" version="430" translationDomain="akregator">
<gui name="akregator_part" version="431" translationDomain="akregator">
<MenuBar>
<Menu name="file">
<Action name="file_import"/>
......@@ -92,6 +92,9 @@
<Action name="feed_fetch_all"/>
<Action name="feed_stop"/>
<Action name="feed_mark_all_as_read"/>
<Spacer/>
<Action name="hamburger_menu"/>
<DefineGroup name="pageviewer_operations" />
<Merge/>
</ToolBar>
......
<!DOCTYPE gui SYSTEM "kpartgui.dtd">
<gui name="akregator_shell" version="396">
<gui name="akregator_shell" version="397">
<MenuBar>
<Menu noMerge="1" name="file"><text>&amp;File</text>
<Merge/>
......@@ -48,5 +48,7 @@
<ToolBar noMerge="1" name="mainToolBar"><text>Main Toolbar</text>
<Merge/>
<Action name="stop"/>
<Spacer/>
<Action name="hamburger_menu"/>
</ToolBar>
</gui>
......@@ -58,7 +58,19 @@ MainWindow::MainWindow(QWidget *parent)
statusBar()->addWidget(m_statusLabel, 1);
KStandardAction::quit(qApp, &QApplication::quit, actionCollection());
KStandardAction::showMenubar(menuBar(), &QMenuBar::setVisible, actionCollection());
mShowMenuBarAction = KStandardAction::showMenubar(menuBar(), &QMenuBar::setVisible, actionCollection());
mHamburgerMenu = KStandardAction::hamburgerMenu(nullptr, nullptr, actionCollection());
mHamburgerMenu->setShowMenuBarAction(mShowMenuBarAction);
mHamburgerMenu->setMenuBar(menuBar());
connect(mHamburgerMenu, &KHamburgerMenu::aboutToShowMenu, this, [this]() {
updateHamburgerMenu();
// Immediately disconnect. We only need to run this once, but on demand.
// NOTE: The nullptr at the end disconnects all connections between
// q and mHamburgerMenu's aboutToShowMenu signal.
disconnect(mHamburgerMenu, &KHamburgerMenu::aboutToShowMenu, this, nullptr);
});
setStandardToolBarMenuEnabled(true);
createStandardStatusBarAction();
......@@ -67,6 +79,15 @@ MainWindow::MainWindow(QWidget *parent)
connect(qApp, &QCoreApplication::aboutToQuit, this, &MainWindow::slotOnShutdown);
}
void MainWindow::updateHamburgerMenu()
{
QMenu *menu = new QMenu;
menu->addAction(actionCollection()->action(QLatin1String(KStandardAction::name(KStandardAction::Print))));
menu->addSeparator();
menu->addAction(actionCollection()->action(QLatin1String(KStandardAction::name(KStandardAction::Quit))));
mHamburgerMenu->setMenu(menu);
}
bool MainWindow::loadPart()
{
if (m_part) {
......
......@@ -14,7 +14,8 @@
#include <QPointer>
class KSqueezedTextLabel;
class KHamburgerMenu;
class KToggleAction;
namespace Akregator
{
class Part;
......@@ -79,8 +80,11 @@ private Q_SLOTS:
void slotOnShutdown();
private:
void updateHamburgerMenu();
QPointer<Akregator::Part> m_part;
KSqueezedTextLabel *const m_statusLabel;
KHamburgerMenu *mHamburgerMenu = nullptr;
KToggleAction *mShowMenuBarAction = nullptr;
};
} // namespace Akregator
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment