summaryrefslogtreecommitdiff
path: root/src/plugins/coreplugin
diff options
context:
space:
mode:
authorcon <qtc-committer@nokia.com>2010-11-30 12:55:41 +0100
committercon <qtc-committer@nokia.com>2010-11-30 13:18:34 +0100
commitaf99e09b0531e312e901ddeb139775e2104fedd8 (patch)
treeca3c4f4e4db601b897ff64520263754e2afb2209 /src/plugins/coreplugin
parent14a71bc770641e28c8e960318791df4485ddb2c9 (diff)
downloadqt-creator-af99e09b0531e312e901ddeb139775e2104fedd8.tar.gz
Window title didn't show nice name for e.g. diff views.
Use the editor's displayName for the window title. Also there were missing change signal emissions in setDisplayName implementations. Moves the actual handling of the window title from Session to EditorManager (so it now is also done for the hypothetical case of no project explorer plugin). Task-number: QTCREATORBUG-3207
Diffstat (limited to 'src/plugins/coreplugin')
-rw-r--r--src/plugins/coreplugin/editormanager/editormanager.cpp46
-rw-r--r--src/plugins/coreplugin/editormanager/editormanager.h5
2 files changed, 48 insertions, 3 deletions
diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp
index 8e06c85175..1ed1edae57 100644
--- a/src/plugins/coreplugin/editormanager/editormanager.cpp
+++ b/src/plugins/coreplugin/editormanager/editormanager.cpp
@@ -218,6 +218,8 @@ struct EditorManagerPrivate {
IFile::ReloadSetting m_reloadSetting;
IFile::Utf8BomSetting m_utf8BomSetting;
+
+ QString m_titleAddition;
};
}
@@ -530,13 +532,17 @@ void EditorManager::setCurrentEditor(IEditor *editor, bool ignoreNavigationHisto
if (m_d->m_currentEditor && !ignoreNavigationHistory)
addCurrentPositionToNavigationHistory();
+ if (m_d->m_currentEditor)
+ disconnect(m_d->m_currentEditor, SIGNAL(changed()), this, SLOT(updateWindowTitle()));
m_d->m_currentEditor = editor;
if (editor) {
if (SplitterOrView *splitterOrView = m_d->m_splitter->findView(editor))
splitterOrView->view()->setCurrentEditor(editor);
m_d->m_view->updateEditorHistory(editor); // the global view should have a complete history
+ connect(m_d->m_currentEditor, SIGNAL(changed()), this, SLOT(updateWindowTitle()));
}
updateActions();
+ updateWindowTitle();
emit currentEditorChanged(editor);
}
@@ -847,6 +853,7 @@ bool EditorManager::closeEditors(const QList<IEditor*> &editorsToClose, bool ask
if (!currentEditor()) {
emit currentEditorChanged(0);
updateActions();
+ updateWindowTitle();
}
return !closingFailed;
@@ -1569,6 +1576,26 @@ void EditorManager::makeCurrentEditorWritable()
makeEditorWritable(curEditor);
}
+void EditorManager::updateWindowTitle()
+{
+ QString windowTitle = tr("Qt Creator");
+ if (!m_d->m_titleAddition.isEmpty()) {
+ windowTitle.prepend(m_d->m_titleAddition + " - ");
+ }
+ IEditor *curEditor = currentEditor();
+ if (curEditor) {
+ QString editorName = curEditor->displayName();
+ if (!editorName.isEmpty())
+ windowTitle.prepend(editorName + " - ");
+ QString filePath = QFileInfo(curEditor->file()->fileName()).absoluteFilePath();
+ if (!filePath.isEmpty())
+ m_d->m_core->mainWindow()->setWindowFilePath(filePath);
+ } else {
+ m_d->m_core->mainWindow()->setWindowFilePath(QString());
+ }
+ m_d->m_core->mainWindow()->setWindowTitle(windowTitle);
+}
+
void EditorManager::updateActions()
{
QString fName;
@@ -2069,7 +2096,12 @@ void EditorManager::removeAllSplits()
if (!m_d->m_splitter->isSplitter())
return;
IEditor *editor = m_d->m_currentEditor;
- m_d->m_currentEditor = 0; // trigger update below
+ {
+ // trigger update below
+ disconnect(m_d->m_currentEditor, SIGNAL(changed()),
+ this, SLOT(updateWindowTitle()));
+ m_d->m_currentEditor = 0;
+ }
if (editor && m_d->m_editorModel->isDuplicate(editor))
m_d->m_editorModel->makeOriginal(editor);
m_d->m_splitter->unsplitAll();
@@ -2104,5 +2136,15 @@ qint64 EditorManager::maxTextFileSize()
{
return (qint64(3) << 24);
}
-//===================EditorClosingCoreListener======================
+
+void EditorManager::setWindowTitleAddition(const QString &addition)
+{
+ m_d->m_titleAddition = addition;
+ updateWindowTitle();
+}
+
+QString EditorManager::windowTitleAddition() const
+{
+ return m_d->m_titleAddition;
+}
diff --git a/src/plugins/coreplugin/editormanager/editormanager.h b/src/plugins/coreplugin/editormanager/editormanager.h
index 6b55561dc6..2dbdc4adec 100644
--- a/src/plugins/coreplugin/editormanager/editormanager.h
+++ b/src/plugins/coreplugin/editormanager/editormanager.h
@@ -208,6 +208,9 @@ public:
static qint64 maxTextFileSize();
+ void setWindowTitleAddition(const QString &addition);
+ QString windowTitleAddition() const;
+
signals:
void currentEditorChanged(Core::IEditor *editor);
void editorCreated(Core::IEditor *editor, const QString &fileName);
@@ -231,6 +234,7 @@ private slots:
void handleContextChange(Core::IContext *context);
void updateActions();
void makeCurrentEditorWritable();
+ void updateWindowTitle();
public slots:
void goBackInNavigationHistory();
@@ -269,7 +273,6 @@ private:
Core::Internal::EditorView *currentEditorView() const;
IEditor *pickUnusedEditor() const;
-
static EditorManager *m_instance;
EditorManagerPrivate *m_d;