Commit 8afc7223 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Use hamburger action menu in composerwin too

parent 37a50759
......@@ -1421,10 +1421,21 @@ void KMComposerWin::setupActions()
mPluginEditorConvertTextManagerInterface->initializePlugins();
mPluginEditorGrammarManagerInterface->initializePlugins();
mHideMenuBarAction = KStandardAction::showMenubar(this, &KMComposerWin::slotToggleMenubar, actionCollection());
mHideMenuBarAction->setChecked(KMailSettings::self()->composerShowMenuBar());
mShowMenuBarAction = KStandardAction::showMenubar(this, &KMComposerWin::slotToggleMenubar, actionCollection());
mShowMenuBarAction->setChecked(KMailSettings::self()->composerShowMenuBar());
slotToggleMenubar(true);
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);
});
createGUI(QStringLiteral("kmcomposerui.rc"));
initializePluginActions();
connect(toolBar(QStringLiteral("htmlToolBar"))->toggleViewAction(), &QAction::toggled, this, &KMComposerWin::htmlToolBarVisibilityChanged);
......@@ -1437,14 +1448,28 @@ void KMComposerWin::setupActions()
}
}
void KMComposerWin::updateHamburgerMenu()
{
QMenu *menu = new QMenu;
menu->addAction(actionCollection()->action(QStringLiteral("new_composer")));
menu->addSeparator();
menu->addAction(actionCollection()->action(QLatin1String(KStandardAction::name(KStandardAction::Print))));
menu->addAction(actionCollection()->action(QLatin1String(KStandardAction::name(KStandardAction::PrintPreview))));
menu->addSeparator();
menu->addAction(actionCollection()->action(QStringLiteral("attach_menu")));
menu->addSeparator();
menu->addAction(actionCollection()->action(QLatin1String(KStandardAction::name(KStandardAction::Close))));
mHamburgerMenu->setMenu(menu);
}
void KMComposerWin::slotToggleMenubar(bool dontShowWarning)
{
if (menuBar()) {
if (mHideMenuBarAction->isChecked()) {
if (mShowMenuBarAction->isChecked()) {
menuBar()->show();
} else {
if (!dontShowWarning) {
const QString accel = mHideMenuBarAction->shortcut().toString();
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>",
......@@ -1454,7 +1479,7 @@ void KMComposerWin::slotToggleMenubar(bool dontShowWarning)
}
menuBar()->hide();
}
KMailSettings::self()->setComposerShowMenuBar(mHideMenuBarAction->isChecked());
KMailSettings::self()->setComposerShowMenuBar(mShowMenuBarAction->isChecked());
}
}
......
......@@ -59,6 +59,7 @@ class IncorrectIdentityFolderWarning;
class KMailPluginEditorConvertTextManagerInterface;
class KMailPluginGrammarEditorManagerInterface;
class AttachmentAddedFromExternalWarning;
class KHamburgerMenu;
namespace MailTransport
{
class Transport;
......@@ -575,6 +576,7 @@ private:
void insertSnippetInfo(const MailCommon::SnippetInfo &info);
Q_REQUIRED_RESULT bool sendLaterRegistered() const;
void slotRecipientEditorLineFocused();
void updateHamburgerMenu();
Akonadi::Collection mCollectionForNewMessage;
QMap<QByteArray, QString> mExtraHeaders;
......@@ -630,7 +632,7 @@ private:
KToggleAction *mAutoSpellCheckingAction = nullptr;
KToggleAction *mDictionaryAction = nullptr;
KToggleAction *mSnippetAction = nullptr;
KToggleAction *mHideMenuBarAction = nullptr;
KToggleAction *mShowMenuBarAction = nullptr;
QAction *mAppendSignature = nullptr;
QAction *mPrependSignature = nullptr;
QAction *mInsertSignatureAtCursorPosition = nullptr;
......@@ -691,6 +693,7 @@ private:
KMailPluginGrammarEditorManagerInterface *const mPluginEditorGrammarManagerInterface;
AttachmentAddedFromExternalWarning *mAttachmentFromExternalMissing = nullptr;
KHamburgerMenu *mHamburgerMenu = nullptr;
ModeType mModeType = ModeType::ComposerType;
};
......
<?xml version="1.0"?>
<!DOCTYPE gui SYSTEM "kpartgui.dtd" >
<gui version="525" name="kmcomposer" translationDomain="kmail">
<gui version="526" name="kmcomposer" translationDomain="kmail">
<MenuBar>
<Menu noMerge="1" name="file" >
<text>&amp;Message</text>
......@@ -125,6 +125,8 @@
<Action name="add_emoticon" />
<Separator/>
<ActionList name="kmaileditor_toolbar_actions"/>
<Spacer/>
<Action name="hamburger_menu"/>
</ToolBar>
<ToolBar noMerge="1" newline="true" hidden="true" enable="0" name="htmlToolBar" iconText="icononly" >
<text>HTML Toolbar</text>
......
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