diff options
author | Eike Ziller <eike.ziller@digia.com> | 2014-07-23 15:36:55 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@digia.com> | 2014-08-13 15:47:58 +0200 |
commit | 49a8cf44daa965d421466fb9c922b08594658e2d (patch) | |
tree | 85af246435cd46478b15cb25e17785578b442003 /src/plugins/vcsbase/vcsbaseplugin.cpp | |
parent | 2a9a014c9d78b902da6332f081b37a830bb0541d (diff) | |
download | qt-creator-49a8cf44daa965d421466fb9c922b08594658e2d.tar.gz |
Editors: Set window title for external editor windows
Change-Id: I54ed77c0f1b2122ae8833109d8dcac7d8eec7ac4
Task-number: QTCREATORBUG-9612
Reviewed-by: Daniel Teske <daniel.teske@digia.com>
Diffstat (limited to 'src/plugins/vcsbase/vcsbaseplugin.cpp')
-rw-r--r-- | src/plugins/vcsbase/vcsbaseplugin.cpp | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/src/plugins/vcsbase/vcsbaseplugin.cpp b/src/plugins/vcsbase/vcsbaseplugin.cpp index 5db0cf47a8..609a7425cd 100644 --- a/src/plugins/vcsbase/vcsbaseplugin.cpp +++ b/src/plugins/vcsbase/vcsbaseplugin.cpp @@ -43,6 +43,7 @@ #include <coreplugin/vcsmanager.h> #include <projectexplorer/projectexplorer.h> #include <projectexplorer/project.h> +#include <projectexplorer/session.h> #include <utils/qtcassert.h> #include <utils/synchronousprocess.h> @@ -196,6 +197,8 @@ class StateListener : public QObject public: explicit StateListener(QObject *parent); + static QString windowTitleVcsTopic(const QString &filePath); + signals: void stateChanged(const VcsBase::Internal::State &s, Core::IVersionControl *vc); @@ -216,6 +219,27 @@ StateListener::StateListener(QObject *parent) : connect(ProjectExplorer::ProjectExplorerPlugin::instance(), SIGNAL(currentProjectChanged(ProjectExplorer::Project*)), this, SLOT(slotStateChanged())); + + Core::EditorManager::setWindowTitleVcsTopicHandler(&StateListener::windowTitleVcsTopic); +} + +QString StateListener::windowTitleVcsTopic(const QString &filePath) +{ + QString searchPath; + if (!filePath.isEmpty()) { + searchPath = filePath; + } else { + // use single project's information if there is only one loaded. + const QList<ProjectExplorer::Project *> projects = ProjectExplorer::SessionManager::projects(); + if (projects.size() == 1) + searchPath = projects.first()->projectDirectory().toString(); + } + if (searchPath.isEmpty()) + return QString(); + QString topLevelPath; + Core::IVersionControl *vc = Core::VcsManager::findVersionControlForDirectory( + searchPath, &topLevelPath); + return (vc && !topLevelPath.isEmpty()) ? vc->vcsTopic(topLevelPath) : QString(); } static inline QString displayNameOfEditor(const QString &fileName) @@ -300,12 +324,11 @@ void StateListener::slotStateChanged() Core::IVersionControl *vc = fileControl; if (!vc) vc = projectControl; - if (!vc) { + if (!vc) state.clearPatchFile(); // Need a repository to patch - Core::EditorManager::setWindowTitleVcsTopic(QString()); - } if (debug) qDebug() << state << (vc ? vc->displayName() : QLatin1String("No version control")); + Core::EditorManager::updateWindowTitles(); emit stateChanged(state, vc); } @@ -586,7 +609,6 @@ void VcsBasePlugin::slotStateChanged(const VcsBase::Internal::State &newInternal d->m_state.setState(newInternalState); updateActions(VcsEnabled); } - Core::EditorManager::setWindowTitleVcsTopic(vc->vcsTopic(d->m_state.topLevel())); } else { // Some other VCS plugin or state changed: Reset us to empty state. const ActionState newActionState = vc ? OtherVcsEnabled : NoVcsEnabled; |