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

Add dialog box if necessary + fix checkbox status

parent 60cb9b23
Pipeline #87749 passed with stage
in 9 minutes and 8 seconds
......@@ -10,6 +10,13 @@
<whatsthis>Hides feeds with no unread articles</whatsthis>
<default>false</default>
</entry>
<entry key="ShowMenuBar" type="Bool">
<default>true</default>
<!-- label and whatsthis are already provided by KStandardAction::showMenubar -->
<label></label>
<whatsthis></whatsthis>
</entry>
<entry key="Lock Feeds In Place" type="Bool">
<label>Prevent feeds from being moved in the list</label>
<whatsthis>Locks feeds where they are</whatsthis>
......
......@@ -58,7 +58,9 @@ MainWindow::MainWindow(QWidget *parent)
statusBar()->addWidget(m_statusLabel, 1);
KStandardAction::quit(qApp, &QApplication::quit, actionCollection());
mShowMenuBarAction = KStandardAction::showMenubar(menuBar(), &QMenuBar::setVisible, actionCollection());
mShowMenuBarAction = KStandardAction::showMenubar(this, &MainWindow::slotToggleMenubar, actionCollection());
mShowMenuBarAction->setChecked(Settings::showMenuBar());
slotToggleMenubar(true);
if (menuBar()) {
mHamburgerMenu = KStandardAction::hamburgerMenu(nullptr, nullptr, actionCollection());
......@@ -81,6 +83,27 @@ MainWindow::MainWindow(QWidget *parent)
connect(qApp, &QCoreApplication::aboutToQuit, this, &MainWindow::slotOnShutdown);
}
void MainWindow::slotToggleMenubar(bool dontShowWarning)
{
if (menuBar()) {
if (mShowMenuBarAction->isChecked()) {
menuBar()->show();
} else {
if (!dontShowWarning && (!toolBar()->isVisible() || !toolBar()->actions().contains(mHamburgerMenu))) {
const QString accel = mShowMenuBarAction->shortcut().toString();
KMessageBox::information(this,
i18n("<qt>This will hide the menu bar completely."
" You can show it again by typing %1.</qt>",
accel),
i18n("Hide menu bar"),
QStringLiteral("HideMenuBarWarning"));
}
menuBar()->hide();
}
Settings::setShowMenuBar(mShowMenuBarAction->isChecked());
}
}
void MainWindow::updateHamburgerMenu()
{
QMenu *menu = new QMenu(this);
......
......@@ -81,6 +81,7 @@ private Q_SLOTS:
private:
void updateHamburgerMenu();
void slotToggleMenubar(bool dontShowWarning);
QPointer<Akregator::Part> m_part;
KSqueezedTextLabel *const m_statusLabel;
KHamburgerMenu *mHamburgerMenu = nullptr;
......
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