diff --git a/src/kmail_options.h b/src/kmail_options.h --- a/src/kmail_options.h +++ b/src/kmail_options.h @@ -45,6 +45,9 @@ 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( diff --git a/src/kmkernel.h b/src/kmkernel.h --- a/src/kmkernel.h +++ b/src/kmkernel.h @@ -317,7 +317,7 @@ 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 &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 &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 @@ void verifyAccount(); void resourceGoOnLine(); - void openReader(bool onlyCheck); + void openReader(bool onlyCheck, bool startInTray); QSharedPointer currentFolderCollection(); void saveConfig(); diff --git a/src/kmkernel.cpp b/src/kmkernel.cpp --- a/src/kmkernel.cpp +++ b/src/kmkernel.cpp @@ -274,6 +274,7 @@ QUrl messageFile; QList attachURLs; QString identity; + bool startInTray = false; bool mailto = false; bool checkMail = false; bool viewOnly = false; @@ -371,6 +372,11 @@ 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 @@ 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::openReader() { - openReader(false); + openReader(false, false); } QStringList KMKernel::accounts() const @@ -526,7 +532,7 @@ } } -void KMKernel::openReader(bool onlyCheck) +void KMKernel::openReader(bool onlyCheck, bool startInTray) { KMainWindow *ktmw = nullptr; @@ -546,7 +552,8 @@ } } else { KMMainWin *win = new KMMainWin; - win->show(); + if(!startInTray) + win->show(); activate = false; // new window: no explicit activation (#73591) } } @@ -1143,14 +1150,14 @@ } } -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 &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 &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) {