Commit bf081dae authored by Matthieu Gras's avatar Matthieu Gras Committed by Daniel Vrátil
Browse files

[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
parent 3d5428e9
......@@ -876,8 +876,22 @@ AppearancePageGeneralTab::AppearancePageGeneralTab(QWidget *parent)
// "Enable system tray applet" check box
mSystemTrayCheck = new QCheckBox(i18n("Enable system tray icon"), this);
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
mShowNumberInTaskBar = new QCheckBox(i18n("Show unread email in Taskbar"), this);
......@@ -896,6 +910,7 @@ void AppearancePage::ReaderTab::doResetToDefaultsOther()
void AppearancePage::ReaderTab::doLoadOther()
{
loadWidget(mSystemTrayCheck, KMailSettings::self()->systemTrayEnabledItem());
loadWidget(mStartInTrayCheck, KMailSettings::self()->startInTrayItem());
loadWidget(mShowNumberInTaskBar, KMailSettings::self()->showUnreadInTaskbarItem());
loadWidget(mCloseAfterReplyOrForwardCheck, MessageViewer::MessageViewerSettings::self()->closeAfterReplyOrForwardItem());
mViewerSettings->readConfig();
......@@ -905,6 +920,7 @@ void AppearancePage::ReaderTab::doLoadOther()
void AppearancePage::ReaderTab::save()
{
saveCheckBox(mSystemTrayCheck, KMailSettings::self()->systemTrayEnabledItem());
saveCheckBox(mStartInTrayCheck, KMailSettings::self()->startInTrayItem());
saveCheckBox(mShowNumberInTaskBar, KMailSettings::self()->showUnreadInTaskbarItem());
KMailSettings::self()->save();
saveCheckBox(mCloseAfterReplyOrForwardCheck, MessageViewer::MessageViewerSettings::self()->closeAfterReplyOrForwardItem());
......
......@@ -172,6 +172,7 @@ private: // data
MessageViewer::ConfigureWidget *mViewerSettings = nullptr;
Gravatar::GravatarConfigWidget *mGravatarConfigWidget = nullptr;
QCheckBox *mSystemTrayCheck = nullptr;
QCheckBox *mStartInTrayCheck = nullptr;
QCheckBox *mShowNumberInTaskBar = nullptr;
};
......
......@@ -45,6 +45,9 @@ static void kmail_options(QCommandLineParser *parser)
QStringLiteral("check"),
i18n("Only check for new mail"))
<< QCommandLineOption(
QStringLiteral("startintray"),
i18n("Start minimized to tray"))
<< QCommandLineOption(
QStringLiteral("composer"),
i18n("Only open composer window"))
<< QCommandLineOption(
......
......@@ -274,6 +274,7 @@ bool KMKernel::handleCommandLine(bool noArgsOpensReader, const QStringList &args
QUrl messageFile;
QList<QUrl> attachURLs;
QString identity;
bool startInTray = false;
bool mailto = false;
bool checkMail = false;
bool viewOnly = false;
......@@ -371,6 +372,11 @@ bool KMKernel::handleCommandLine(bool noArgsOpensReader, const QStringList &args
checkMail = true;
}
if(parser.isSet(QStringLiteral("startintray"))) {
KMailSettings::self()->setSystemTrayEnabled(true);
startInTray = true;
}
if (parser.isSet(QStringLiteral("identity"))) {
identity = parser.value(QStringLiteral("identity"));
}
......@@ -456,7 +462,7 @@ bool KMKernel::handleCommandLine(bool noArgsOpensReader, const QStringList &args
if (viewOnly) {
viewMessage(messageFile);
} 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);
}
return true;
......@@ -496,7 +502,7 @@ void KMKernel::checkMail() //might create a new reader but won't show!!
void KMKernel::openReader()
{
openReader(false);
openReader(false, false);
}
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;
......@@ -546,7 +552,8 @@ void KMKernel::openReader(bool onlyCheck)
}
} else {
KMMainWin *win = new KMMainWin;
win->show();
if(!startInTray && !KMailSettings::self()->startInTray())
win->show();
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) {
openComposer(to, cc, bcc, subj, body, 0,
messageFile.toLocalFile(), QUrl::toStringList(attachURLs),
customHeaders, replyTo, inReplyTo, identity);
} else {
openReader(check);
openReader(check, startInTray);
}
if (check) {
......
......@@ -317,7 +317,7 @@ public:
bool doSessionManagement();
bool firstInstance() const;
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
void setAccountStatus(bool);
......@@ -478,7 +478,7 @@ private:
void verifyAccount();
void resourceGoOnLine();
void openReader(bool onlyCheck);
void openReader(bool onlyCheck, bool startInTray);
QSharedPointer<MailCommon::FolderSettings> currentFolderCollection();
void saveConfig();
......
......@@ -84,6 +84,10 @@
<label>Enable system tray icon</label>
<default>false</default>
</entry>
<entry name="StartInTray" type="Bool">
<label>Start minimized to tray</label>
<default>false</default>
</entry>
<entry name="ShowUnreadInTaskbar" type="Bool">
<label>Show Unread Email in TaskBar</label>
<default>true</default>
......
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