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
IFile::ReloadSetting m_reloadSetting;
IFile::Utf8BomSetting m_utf8BomSetting;
+
+ QString m_titleAddition;
};
}
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);
}
if (!currentEditor()) {
emit currentEditorChanged(0);
updateActions();
+ updateWindowTitle();
}
return !closingFailed;
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;
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();
{
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;
+}
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);
void handleContextChange(Core::IContext *context);
void updateActions();
void makeCurrentEditorWritable();
+ void updateWindowTitle();
public slots:
void goBackInNavigationHistory();
Core::Internal::EditorView *currentEditorView() const;
IEditor *pickUnusedEditor() const;
-
static EditorManager *m_instance;
EditorManagerPrivate *m_d;
void FormWindowEditor::setDisplayName(const QString &title)
{
d->m_textEditable.setDisplayName(title);
+ emit changed();
}
bool FormWindowEditor::duplicateSupported() const
m_core(Core::ICore::instance()),
m_file(new SessionFile),
m_sessionNode(new Internal::SessionNodeImpl(this)),
- m_currentEditor(0),
m_virginSession(true)
{
connect(m_core->modeManager(), SIGNAL(currentModeChanged(Core::IMode*)),
this, SLOT(setEditorCodec(Core::IEditor *, QString)));
connect(ProjectExplorerPlugin::instance(), SIGNAL(currentProjectChanged(ProjectExplorer::Project *)),
this, SLOT(updateWindowTitle()));
- connect(em, SIGNAL(currentEditorChanged(Core::IEditor*)),
- this, SLOT(handleCurrentEditorChange(Core::IEditor*)));
connect(em, SIGNAL(editorOpened(Core::IEditor*)),
this, SLOT(markSessionFileDirty()));
connect(em, SIGNAL(editorsClosed(QList<Core::IEditor*>)),
return m_file->fileName();
}
-void SessionManager::handleCurrentEditorChange(Core::IEditor *editor)
-{
- if (editor != m_currentEditor) {
- if (m_currentEditor)
- disconnect(m_currentEditor, SIGNAL(changed()), this, SLOT(updateWindowTitle()));
- if (editor)
- connect(editor, SIGNAL(changed()), this, SLOT(updateWindowTitle()));
- m_currentEditor = editor;
- }
- updateWindowTitle();
-}
-
void SessionManager::updateWindowTitle()
{
- QString windowTitle = tr("Qt Creator");
if (isDefaultSession(m_sessionName)) {
if (Project *currentProject = ProjectExplorerPlugin::instance()->currentProject())
- windowTitle.prepend(currentProject->displayName() + " - ");
+ m_core->editorManager()->setWindowTitleAddition(currentProject->displayName());
} else {
QString sessionName = m_sessionName;
if (sessionName.isEmpty())
sessionName = tr("Untitled");
- windowTitle.prepend(sessionName + " - ");
- }
- if (m_core->editorManager()->currentEditor()) {
- QFileInfo fi(m_core->editorManager()->currentEditor()->file()->fileName());
- QString fileName = fi.fileName();
- if (!fileName.isEmpty())
- windowTitle.prepend(fileName + " - ");
- m_core->mainWindow()->setWindowFilePath(fi.absoluteFilePath());
- } else {
- m_core->mainWindow()->setWindowFilePath(QString());
+ m_core->editorManager()->setWindowTitleAddition(sessionName);
}
- m_core->mainWindow()->setWindowTitle(windowTitle);
}
void SessionManager::updateName(const QString &session)
void saveActiveMode(Core::IMode *mode);
void clearProjectFileCache();
void setEditorCodec(Core::IEditor *editor, const QString &fileName);
- void handleCurrentEditorChange(Core::IEditor *editor);
void updateWindowTitle();
void markSessionFileDirty(bool makeDefaultVirginDirty = true);
Internal::SessionFile *m_file;
Internal::SessionNodeImpl *m_sessionNode;
- QPointer<Core::IEditor> m_currentEditor;
QString m_sessionName;
bool m_virginSession;
Core::IFile *file() { return m_resourceFile; }
QString id() const;
QString displayName() const { return m_displayName; }
- void setDisplayName(const QString &title) { m_displayName = title; }
+ void setDisplayName(const QString &title) { m_displayName = title; emit changed(); }
QWidget *toolBar() { return 0; }
QByteArray saveState() const { return QByteArray(); }
bool restoreState(const QByteArray &/*state*/) { return true; }
void BaseTextEditor::setDisplayName(const QString &title)
{
d->m_displayName = title;
+ emit changed();
}
BaseTextDocument *BaseTextEditor::baseTextDocument() const
return e->open(fileName);
}
inline QString displayName() const { return e->displayName(); }
- inline void setDisplayName(const QString &title) { e->setDisplayName(title); }
+ inline void setDisplayName(const QString &title) { e->setDisplayName(title); emit changed(); }
inline QByteArray saveState() const { return e->saveState(); }
inline bool restoreState(const QByteArray &state) { return e->restoreState(state); }
void VCSBaseSubmitEditor::setDisplayName(const QString &title)
{
m_d->m_displayName = title;
+ emit changed();
}
QString VCSBaseSubmitEditor::checkScriptWorkingDirectory() const