[KMail] Add an option to start in tray

Summary: Adds an option to launch Kmail minimized to tray

Reviewers: #kde_pim_kmail, mlaurent

Reviewed By: mlaurent

Subscribers: lbeltrame, dvratil, kde-pim

Tags: #kde_pim

Differential Revision: https://phabricator.kde.org/D19189
wilder
Matthieu Gras 7 years ago committed by Daniel Vrátil
parent 3d5428e9b4
commit bf081dae23
  1. 20
      src/configuredialog/configureappearancepage.cpp
  2. 1
      src/configuredialog/configureappearancepage.h
  3. 3
      src/kmail_options.h
  4. 19
      src/kmkernel.cpp
  5. 4
      src/kmkernel.h
  6. 4
      src/settings/kmail.kcfg.cmake

@ -876,8 +876,22 @@ AppearancePageGeneralTab::AppearancePageGeneralTab(QWidget *parent)
// "Enable system tray applet" check box // "Enable system tray applet" check box
mSystemTrayCheck = new QCheckBox(i18n("Enable system tray icon"), this); mSystemTrayCheck = new QCheckBox(i18n("Enable system tray icon"), this);
systrayBoxlayout->addWidget(mSystemTrayCheck); systrayBoxlayout->addWidget(mSystemTrayCheck);
connect(mSystemTrayCheck, &QCheckBox::stateChanged,
this, &ConfigModuleTab::slotEmitChanged); // "Enable start in system tray" check box
mStartInTrayCheck = new QCheckBox(i18n("Start minimized to tray"));
systrayBoxlayout->addWidget(mStartInTrayCheck);
// Dependencies between the two checkboxes
connect(mStartInTrayCheck, &QCheckBox::stateChanged, this, [this](int state) {
if (state == Qt::Checked)
mSystemTrayCheck->setCheckState(Qt::Checked);
slotEmitChanged();
});
connect(mSystemTrayCheck, &QCheckBox::stateChanged, this, [this](int state) {
if(state == Qt::Unchecked)
mStartInTrayCheck->setCheckState(Qt::Unchecked);
slotEmitChanged();
});
// "Enable system tray applet" check box // "Enable system tray applet" check box
mShowNumberInTaskBar = new QCheckBox(i18n("Show unread email in Taskbar"), this); mShowNumberInTaskBar = new QCheckBox(i18n("Show unread email in Taskbar"), this);
@ -896,6 +910,7 @@ void AppearancePage::ReaderTab::doResetToDefaultsOther()
void AppearancePage::ReaderTab::doLoadOther() void AppearancePage::ReaderTab::doLoadOther()
{ {
loadWidget(mSystemTrayCheck, KMailSettings::self()->systemTrayEnabledItem()); loadWidget(mSystemTrayCheck, KMailSettings::self()->systemTrayEnabledItem());
loadWidget(mStartInTrayCheck, KMailSettings::self()->startInTrayItem());
loadWidget(mShowNumberInTaskBar, KMailSettings::self()->showUnreadInTaskbarItem()); loadWidget(mShowNumberInTaskBar, KMailSettings::self()->showUnreadInTaskbarItem());
loadWidget(mCloseAfterReplyOrForwardCheck, MessageViewer::MessageViewerSettings::self()->closeAfterReplyOrForwardItem()); loadWidget(mCloseAfterReplyOrForwardCheck, MessageViewer::MessageViewerSettings::self()->closeAfterReplyOrForwardItem());
mViewerSettings->readConfig(); mViewerSettings->readConfig();
@ -905,6 +920,7 @@ void AppearancePage::ReaderTab::doLoadOther()
void AppearancePage::ReaderTab::save() void AppearancePage::ReaderTab::save()
{ {
saveCheckBox(mSystemTrayCheck, KMailSettings::self()->systemTrayEnabledItem()); saveCheckBox(mSystemTrayCheck, KMailSettings::self()->systemTrayEnabledItem());
saveCheckBox(mStartInTrayCheck, KMailSettings::self()->startInTrayItem());
saveCheckBox(mShowNumberInTaskBar, KMailSettings::self()->showUnreadInTaskbarItem()); saveCheckBox(mShowNumberInTaskBar, KMailSettings::self()->showUnreadInTaskbarItem());
KMailSettings::self()->save(); KMailSettings::self()->save();
saveCheckBox(mCloseAfterReplyOrForwardCheck, MessageViewer::MessageViewerSettings::self()->closeAfterReplyOrForwardItem()); saveCheckBox(mCloseAfterReplyOrForwardCheck, MessageViewer::MessageViewerSettings::self()->closeAfterReplyOrForwardItem());

@ -172,6 +172,7 @@ private: // data
MessageViewer::ConfigureWidget *mViewerSettings = nullptr; MessageViewer::ConfigureWidget *mViewerSettings = nullptr;
Gravatar::GravatarConfigWidget *mGravatarConfigWidget = nullptr; Gravatar::GravatarConfigWidget *mGravatarConfigWidget = nullptr;
QCheckBox *mSystemTrayCheck = nullptr; QCheckBox *mSystemTrayCheck = nullptr;
QCheckBox *mStartInTrayCheck = nullptr;
QCheckBox *mShowNumberInTaskBar = nullptr; QCheckBox *mShowNumberInTaskBar = nullptr;
}; };

@ -45,6 +45,9 @@ static void kmail_options(QCommandLineParser *parser)
QStringLiteral("check"), QStringLiteral("check"),
i18n("Only check for new mail")) i18n("Only check for new mail"))
<< QCommandLineOption( << QCommandLineOption(
QStringLiteral("startintray"),
i18n("Start minimized to tray"))
<< QCommandLineOption(
QStringLiteral("composer"), QStringLiteral("composer"),
i18n("Only open composer window")) i18n("Only open composer window"))
<< QCommandLineOption( << QCommandLineOption(

@ -274,6 +274,7 @@ bool KMKernel::handleCommandLine(bool noArgsOpensReader, const QStringList &args
QUrl messageFile; QUrl messageFile;
QList<QUrl> attachURLs; QList<QUrl> attachURLs;
QString identity; QString identity;
bool startInTray = false;
bool mailto = false; bool mailto = false;
bool checkMail = false; bool checkMail = false;
bool viewOnly = false; bool viewOnly = false;
@ -371,6 +372,11 @@ bool KMKernel::handleCommandLine(bool noArgsOpensReader, const QStringList &args
checkMail = true; checkMail = true;
} }
if(parser.isSet(QStringLiteral("startintray"))) {
KMailSettings::self()->setSystemTrayEnabled(true);
startInTray = true;
}
if (parser.isSet(QStringLiteral("identity"))) { if (parser.isSet(QStringLiteral("identity"))) {
identity = parser.value(QStringLiteral("identity")); identity = parser.value(QStringLiteral("identity"));
} }
@ -456,7 +462,7 @@ bool KMKernel::handleCommandLine(bool noArgsOpensReader, const QStringList &args
if (viewOnly) { if (viewOnly) {
viewMessage(messageFile); viewMessage(messageFile);
} else { } else {
action(mailto, checkMail, to, cc, bcc, subj, body, messageFile, action(mailto, checkMail, startInTray, to, cc, bcc, subj, body, messageFile,
attachURLs, customHeaders, replyTo, inReplyTo, identity); attachURLs, customHeaders, replyTo, inReplyTo, identity);
} }
return true; return true;
@ -496,7 +502,7 @@ void KMKernel::checkMail() //might create a new reader but won't show!!
void KMKernel::openReader() void KMKernel::openReader()
{ {
openReader(false); openReader(false, false);
} }
QStringList KMKernel::accounts() const QStringList KMKernel::accounts() const
@ -526,7 +532,7 @@ void KMKernel::checkAccount(const QString &account) //might create a new reade
} }
} }
void KMKernel::openReader(bool onlyCheck) void KMKernel::openReader(bool onlyCheck, bool startInTray)
{ {
KMainWindow *ktmw = nullptr; KMainWindow *ktmw = nullptr;
@ -546,7 +552,8 @@ void KMKernel::openReader(bool onlyCheck)
} }
} else { } else {
KMMainWin *win = new KMMainWin; KMMainWin *win = new KMMainWin;
win->show(); if(!startInTray && !KMailSettings::self()->startInTray())
win->show();
activate = false; // new window: no explicit activation (#73591) activate = false; // new window: no explicit activation (#73591)
} }
} }
@ -1143,14 +1150,14 @@ void KMKernel::dumpDeadLetters()
} }
} }
void KMKernel::action(bool mailto, bool check, const QString &to, const QString &cc, const QString &bcc, const QString &subj, const QString &body, const QUrl &messageFile, const QList<QUrl> &attachURLs, const QStringList &customHeaders, const QString &replyTo, const QString &inReplyTo, const QString &identity) void KMKernel::action(bool mailto, bool check, bool startInTray, const QString &to, const QString &cc, const QString &bcc, const QString &subj, const QString &body, const QUrl &messageFile, const QList<QUrl> &attachURLs, const QStringList &customHeaders, const QString &replyTo, const QString &inReplyTo, const QString &identity)
{ {
if (mailto) { if (mailto) {
openComposer(to, cc, bcc, subj, body, 0, openComposer(to, cc, bcc, subj, body, 0,
messageFile.toLocalFile(), QUrl::toStringList(attachURLs), messageFile.toLocalFile(), QUrl::toStringList(attachURLs),
customHeaders, replyTo, inReplyTo, identity); customHeaders, replyTo, inReplyTo, identity);
} else { } else {
openReader(check); openReader(check, startInTray);
} }
if (check) { if (check) {

@ -317,7 +317,7 @@ public:
bool doSessionManagement(); bool doSessionManagement();
bool firstInstance() const; bool firstInstance() const;
void setFirstInstance(bool value); void setFirstInstance(bool value);
void action(bool mailto, bool check, const QString &to, const QString &cc, const QString &bcc, const QString &subj, const QString &body, const QUrl &messageFile, const QList<QUrl> &attach, const QStringList &customHeaders, const QString &replyTo, const QString &inReplyTo, const QString &identity); void action(bool mailto, bool check, bool startInTray, const QString &to, const QString &cc, const QString &bcc, const QString &subj, const QString &body, const QUrl &messageFile, const QList<QUrl> &attach, const QStringList &customHeaders, const QString &replyTo, const QString &inReplyTo, const QString &identity);
//sets online status for akonadi accounts. true for online, false for offline //sets online status for akonadi accounts. true for online, false for offline
void setAccountStatus(bool); void setAccountStatus(bool);
@ -478,7 +478,7 @@ private:
void verifyAccount(); void verifyAccount();
void resourceGoOnLine(); void resourceGoOnLine();
void openReader(bool onlyCheck); void openReader(bool onlyCheck, bool startInTray);
QSharedPointer<MailCommon::FolderSettings> currentFolderCollection(); QSharedPointer<MailCommon::FolderSettings> currentFolderCollection();
void saveConfig(); void saveConfig();

@ -84,6 +84,10 @@
<label>Enable system tray icon</label> <label>Enable system tray icon</label>
<default>false</default> <default>false</default>
</entry> </entry>
<entry name="StartInTray" type="Bool">
<label>Start minimized to tray</label>
<default>false</default>
</entry>
<entry name="ShowUnreadInTaskbar" type="Bool"> <entry name="ShowUnreadInTaskbar" type="Bool">
<label>Show Unread Email in TaskBar</label> <label>Show Unread Email in TaskBar</label>
<default>true</default> <default>true</default>

Loading…
Cancel
Save