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

Reduce duplicate code

parent 76cc490e
......@@ -85,6 +85,8 @@ public: // kmkernel, kmcommands, callback
virtual void addExtraCustomHeaders(const QMap<QByteArray, QString> &header) = 0;
virtual void showAndActivateComposer() = 0;
public: // kmcommand
/**
* If this folder is set, the original message is inserted back after
......
......@@ -3090,6 +3090,13 @@ void KMComposerWin::slotAutoSpellCheckingToggled(bool on)
mStatusBarLabelSpellCheckingChangeMode->setToggleMode(on);
}
void KMComposerWin::showAndActivateComposer()
{
show();
raise();
activateWindow();
}
void KMComposerWin::slotSpellCheckingStatus(const QString &status)
{
mStatusbarLabel->setText(status);
......
......@@ -366,6 +366,8 @@ private Q_SLOTS:
*/
void slotAutoSpellCheckingToggled(bool);
void showAndActivateComposer() override;
void setAutoSaveFileName(const QString &fileName) override;
void slotSpellCheckingLanguage(const QString &language);
void forceAutoSaveMessage();
......
......@@ -141,7 +141,7 @@ void FillComposerJob::slotOpenComposer()
cWin->disableForgottenAttachmentsCheck();
}
if (mSettings.mForceShowWindow || (!mSettings.mHidden && !iCalAutoSend)) {
cWin->show();
cWin->showAndActivateComposer();
} else {
// Always disable word wrap when we don't show the composer, since otherwise QTextEdit
// gets the widget size wrong and wraps much too early.
......
......@@ -72,9 +72,7 @@ void OpenComposerHiddenJob::slotOpenComposer()
: KMail::Composer::NoTemplate;
KMail::Composer *cWin = KMail::makeComposer(mMsg, false, false, context);
if (!mSettings.mHidden) {
cWin->show();
cWin->raise();
cWin->activateWindow();
cWin->showAndActivateComposer();
} else {
// Always disable word wrap when we don't show the composer; otherwise,
// QTextEdit gets the widget size wrong and wraps much too early.
......
......@@ -150,9 +150,7 @@ void OpenComposerJob::slotOpenComposer()
}
}
if (!mOpenComposerSettings.mHidden) {
cWin->show();
cWin->raise();
cWin->activateWindow();
cWin->showAndActivateComposer();
}
deleteLater();
}
......@@ -547,16 +547,12 @@ void KMKernel::openReader(bool onlyCheck, bool startInTray)
KMMainWin *win = static_cast<KMMainWin *>(ktmw);
activate = !onlyCheck; // existing window: only activate if not --check
if (activate) {
win->show();
win->raise();
win->activateWindow();
win->showAndActivateWindow();
}
} else {
KMMainWin *win = new KMMainWin;
if (!startInTray && !KMailSettings::self()->startInTray()) {
win->show();
win->raise();
win->activateWindow();
win->showAndActivateWindow();
}
activate = false; // new window: no explicit activation (#73591)
}
......
......@@ -203,6 +203,13 @@ bool KMMainWin::restoreDockedState(int n)
return KMainWindow::restore(n, show);
}
void KMMainWin::showAndActivateWindow()
{
show();
raise();
activateWindow();
}
void KMMainWin::saveProperties(KConfigGroup &config)
{
// This is called by the session manager on log-off
......
......@@ -46,6 +46,7 @@ public:
/// TODO: KDE5: Move to kdelibs, see http://reviewboard.kde.org/r/504
Q_REQUIRED_RESULT bool restoreDockedState(int number);
void showAndActivateWindow();
public Q_SLOTS:
void displayStatusMessage(const QString &);
void slotEditToolbars();
......
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