Commit 553e3397 authored by Eike Ziller's avatar Eike Ziller

Fix external file change notification in case of multiple windows.

The notification was only done when the main window was activated which
leads to funny results with external editor windows.

Change-Id: I657ef7e429256f9c098b1fc744d40ffbc2bb5260
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent 82133aa5
...@@ -216,10 +216,9 @@ DocumentManager::DocumentManager(QMainWindow *mw) ...@@ -216,10 +216,9 @@ DocumentManager::DocumentManager(QMainWindow *mw)
{ {
d = new DocumentManagerPrivate(mw); d = new DocumentManagerPrivate(mw);
m_instance = this; m_instance = this;
connect(d->m_mainWindow, SIGNAL(windowActivated()),
this, SLOT(mainWindowActivated()));
connect(ICore::instance(), SIGNAL(contextChanged(QList<Core::IContext*>,Core::Context)), connect(ICore::instance(), SIGNAL(contextChanged(QList<Core::IContext*>,Core::Context)),
this, SLOT(syncWithEditor(QList<Core::IContext*>))); this, SLOT(syncWithEditor(QList<Core::IContext*>)));
qApp->installEventFilter(this);
readSettings(); readSettings();
} }
...@@ -812,19 +811,11 @@ void DocumentManager::changedFile(const QString &fileName) ...@@ -812,19 +811,11 @@ void DocumentManager::changedFile(const QString &fileName)
QTimer::singleShot(200, this, SLOT(checkForReload())); QTimer::singleShot(200, this, SLOT(checkForReload()));
} }
void DocumentManager::mainWindowActivated()
{
//we need to do this asynchronously because
//opening a dialog ("Reload?") in a windowactivated event
//freezes on Mac
QTimer::singleShot(0, this, SLOT(checkForReload()));
}
void DocumentManager::checkForReload() void DocumentManager::checkForReload()
{ {
if (d->m_changedFiles.isEmpty()) if (d->m_changedFiles.isEmpty())
return; return;
if (QApplication::activeWindow() != d->m_mainWindow) if (!QApplication::activeWindow() || QApplication::activeModalWidget())
return; return;
if (d->m_blockActivated) if (d->m_blockActivated)
...@@ -1365,6 +1356,15 @@ void DocumentManager::slotExecuteOpenWithMenuAction(QAction *action) ...@@ -1365,6 +1356,15 @@ void DocumentManager::slotExecuteOpenWithMenuAction(QAction *action)
executeOpenWithMenuAction(action); executeOpenWithMenuAction(action);
} }
bool DocumentManager::eventFilter(QObject *obj, QEvent *e)
{
if (obj == qApp && e->type() == QEvent::ApplicationActivate) {
// activeWindow is not necessarily set yet, do checkForReload asynchronously
QTimer::singleShot(0, this, SLOT(checkForReload()));
}
return false;
}
// -------------- FileChangeBlocker // -------------- FileChangeBlocker
FileChangeBlocker::FileChangeBlocker(const QString &fileName) FileChangeBlocker::FileChangeBlocker(const QString &fileName)
......
...@@ -142,13 +142,15 @@ signals: ...@@ -142,13 +142,15 @@ signals:
/// emitted if one document changed its name e.g. due to save as /// emitted if one document changed its name e.g. due to save as
void documentRenamed(Core::IDocument *document, const QString &from, const QString &to); void documentRenamed(Core::IDocument *document, const QString &from, const QString &to);
protected:
bool eventFilter(QObject *obj, QEvent *e);
private slots: private slots:
void documentDestroyed(QObject *obj); void documentDestroyed(QObject *obj);
void fileNameChanged(const QString &oldName, const QString &newName); void fileNameChanged(const QString &oldName, const QString &newName);
void checkForNewFileName(); void checkForNewFileName();
void checkForReload(); void checkForReload();
void changedFile(const QString &file); void changedFile(const QString &file);
void mainWindowActivated();
void syncWithEditor(const QList<Core::IContext *> &context); void syncWithEditor(const QList<Core::IContext *> &context);
}; };
......
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