Commit 3e8defff authored by Waqar Ahmed's avatar Waqar Ahmed Committed by Christoph Cullmann
Browse files

Dont bring kate to front when files externally modified

If you have the following setting checked:

[x] Warn about files modified by foreign processes

Then kate will activate the app and bring it to front interrupting any
other work that you might have been doing. This is very annoying and
makes this option very hard to use.

BUG: 353712
parent 5e62e617
Pipeline #127112 passed with stage
in 3 minutes and 22 seconds
......@@ -1172,6 +1172,20 @@ void KateMainWindow::queueModifiedOnDisc(KTextEditor::Document *doc)
connect(s_modOnHdDialog, &KateMwModOnHdDialog::requestOpenDiffDocument, this, [this](const QUrl &url) {
viewManager()->openUrl(url, QString(), true, true);
// Someone modified a doc outside and now we are here
// but Kate isn't the active app. Delay the dialog exec
// otherwise it will bring us front interrupting user's
// work.
if (!qApp->activeWindow() || !hasFocus()) {
m_modignore = false;
// hopefully this shows an alert to the user in task bar
// that something changed in Kate
qApp->alert(this, 3000);
delete s_modOnHdDialog; // s_modOnHdDialog is set to 0 in destructor of KateMwModOnHdDialog (jowenn!!!)
m_modignore = false;
......@@ -1190,6 +1204,21 @@ bool KateMainWindow::event(QEvent *e)
if (e->type() == QEvent::ActivationChange) {
// After queueModifiedOnDisc, the app wasn't active but now it got
// active. Show the dialog.
if (s_modOnHdDialog && s_modOnHdDialog->showOnWindowActivation()) {
// Must set this to false, we want only one exec to happen.
// do it on next event loop iteration to avoid blocking here
QTimer::singleShot(1, this, [] {
delete s_modOnHdDialog;
return KateMDI::MainWindow::event(e);
......@@ -32,6 +32,15 @@ public:
~KateMwModOnHdDialog() override;
void addDocument(KTextEditor::Document *doc);
void setShowOnWindowActivation(bool show)
m_showOnWindowActivation = show;
bool showOnWindowActivation() const
return m_showOnWindowActivation;
void requestOpenDiffDocument(const QUrl &documentUrl);
......@@ -55,6 +64,7 @@ private:
QTemporaryFile *m_diffFile;
QStringList m_stateTexts;
bool m_blockAddDocument;
bool m_showOnWindowActivation = false;
void closeEvent(QCloseEvent *e) override;
Supports Markdown
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