forked from qt-creator/qt-creator
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
This commit is contained in:
@@ -218,6 +218,8 @@ struct EditorManagerPrivate {
|
|||||||
|
|
||||||
IFile::ReloadSetting m_reloadSetting;
|
IFile::ReloadSetting m_reloadSetting;
|
||||||
IFile::Utf8BomSetting m_utf8BomSetting;
|
IFile::Utf8BomSetting m_utf8BomSetting;
|
||||||
|
|
||||||
|
QString m_titleAddition;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -530,13 +532,17 @@ void EditorManager::setCurrentEditor(IEditor *editor, bool ignoreNavigationHisto
|
|||||||
if (m_d->m_currentEditor && !ignoreNavigationHistory)
|
if (m_d->m_currentEditor && !ignoreNavigationHistory)
|
||||||
addCurrentPositionToNavigationHistory();
|
addCurrentPositionToNavigationHistory();
|
||||||
|
|
||||||
|
if (m_d->m_currentEditor)
|
||||||
|
disconnect(m_d->m_currentEditor, SIGNAL(changed()), this, SLOT(updateWindowTitle()));
|
||||||
m_d->m_currentEditor = editor;
|
m_d->m_currentEditor = editor;
|
||||||
if (editor) {
|
if (editor) {
|
||||||
if (SplitterOrView *splitterOrView = m_d->m_splitter->findView(editor))
|
if (SplitterOrView *splitterOrView = m_d->m_splitter->findView(editor))
|
||||||
splitterOrView->view()->setCurrentEditor(editor);
|
splitterOrView->view()->setCurrentEditor(editor);
|
||||||
m_d->m_view->updateEditorHistory(editor); // the global view should have a complete history
|
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();
|
updateActions();
|
||||||
|
updateWindowTitle();
|
||||||
emit currentEditorChanged(editor);
|
emit currentEditorChanged(editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -847,6 +853,7 @@ bool EditorManager::closeEditors(const QList<IEditor*> &editorsToClose, bool ask
|
|||||||
if (!currentEditor()) {
|
if (!currentEditor()) {
|
||||||
emit currentEditorChanged(0);
|
emit currentEditorChanged(0);
|
||||||
updateActions();
|
updateActions();
|
||||||
|
updateWindowTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
return !closingFailed;
|
return !closingFailed;
|
||||||
@@ -1569,6 +1576,26 @@ void EditorManager::makeCurrentEditorWritable()
|
|||||||
makeEditorWritable(curEditor);
|
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()
|
void EditorManager::updateActions()
|
||||||
{
|
{
|
||||||
QString fName;
|
QString fName;
|
||||||
@@ -2069,7 +2096,12 @@ void EditorManager::removeAllSplits()
|
|||||||
if (!m_d->m_splitter->isSplitter())
|
if (!m_d->m_splitter->isSplitter())
|
||||||
return;
|
return;
|
||||||
IEditor *editor = m_d->m_currentEditor;
|
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))
|
if (editor && m_d->m_editorModel->isDuplicate(editor))
|
||||||
m_d->m_editorModel->makeOriginal(editor);
|
m_d->m_editorModel->makeOriginal(editor);
|
||||||
m_d->m_splitter->unsplitAll();
|
m_d->m_splitter->unsplitAll();
|
||||||
@@ -2104,5 +2136,15 @@ qint64 EditorManager::maxTextFileSize()
|
|||||||
{
|
{
|
||||||
return (qint64(3) << 24);
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -208,6 +208,9 @@ public:
|
|||||||
|
|
||||||
static qint64 maxTextFileSize();
|
static qint64 maxTextFileSize();
|
||||||
|
|
||||||
|
void setWindowTitleAddition(const QString &addition);
|
||||||
|
QString windowTitleAddition() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void currentEditorChanged(Core::IEditor *editor);
|
void currentEditorChanged(Core::IEditor *editor);
|
||||||
void editorCreated(Core::IEditor *editor, const QString &fileName);
|
void editorCreated(Core::IEditor *editor, const QString &fileName);
|
||||||
@@ -231,6 +234,7 @@ private slots:
|
|||||||
void handleContextChange(Core::IContext *context);
|
void handleContextChange(Core::IContext *context);
|
||||||
void updateActions();
|
void updateActions();
|
||||||
void makeCurrentEditorWritable();
|
void makeCurrentEditorWritable();
|
||||||
|
void updateWindowTitle();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void goBackInNavigationHistory();
|
void goBackInNavigationHistory();
|
||||||
@@ -269,7 +273,6 @@ private:
|
|||||||
Core::Internal::EditorView *currentEditorView() const;
|
Core::Internal::EditorView *currentEditorView() const;
|
||||||
IEditor *pickUnusedEditor() const;
|
IEditor *pickUnusedEditor() const;
|
||||||
|
|
||||||
|
|
||||||
static EditorManager *m_instance;
|
static EditorManager *m_instance;
|
||||||
EditorManagerPrivate *m_d;
|
EditorManagerPrivate *m_d;
|
||||||
|
|
||||||
|
|||||||
@@ -212,6 +212,7 @@ QString FormWindowEditor::displayName() const
|
|||||||
void FormWindowEditor::setDisplayName(const QString &title)
|
void FormWindowEditor::setDisplayName(const QString &title)
|
||||||
{
|
{
|
||||||
d->m_textEditable.setDisplayName(title);
|
d->m_textEditable.setDisplayName(title);
|
||||||
|
emit changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FormWindowEditor::duplicateSupported() const
|
bool FormWindowEditor::duplicateSupported() const
|
||||||
|
|||||||
@@ -312,7 +312,6 @@ SessionManager::SessionManager(QObject *parent)
|
|||||||
m_core(Core::ICore::instance()),
|
m_core(Core::ICore::instance()),
|
||||||
m_file(new SessionFile),
|
m_file(new SessionFile),
|
||||||
m_sessionNode(new Internal::SessionNodeImpl(this)),
|
m_sessionNode(new Internal::SessionNodeImpl(this)),
|
||||||
m_currentEditor(0),
|
|
||||||
m_virginSession(true)
|
m_virginSession(true)
|
||||||
{
|
{
|
||||||
connect(m_core->modeManager(), SIGNAL(currentModeChanged(Core::IMode*)),
|
connect(m_core->modeManager(), SIGNAL(currentModeChanged(Core::IMode*)),
|
||||||
@@ -324,8 +323,6 @@ SessionManager::SessionManager(QObject *parent)
|
|||||||
this, SLOT(setEditorCodec(Core::IEditor *, QString)));
|
this, SLOT(setEditorCodec(Core::IEditor *, QString)));
|
||||||
connect(ProjectExplorerPlugin::instance(), SIGNAL(currentProjectChanged(ProjectExplorer::Project *)),
|
connect(ProjectExplorerPlugin::instance(), SIGNAL(currentProjectChanged(ProjectExplorer::Project *)),
|
||||||
this, SLOT(updateWindowTitle()));
|
this, SLOT(updateWindowTitle()));
|
||||||
connect(em, SIGNAL(currentEditorChanged(Core::IEditor*)),
|
|
||||||
this, SLOT(handleCurrentEditorChange(Core::IEditor*)));
|
|
||||||
connect(em, SIGNAL(editorOpened(Core::IEditor*)),
|
connect(em, SIGNAL(editorOpened(Core::IEditor*)),
|
||||||
this, SLOT(markSessionFileDirty()));
|
this, SLOT(markSessionFileDirty()));
|
||||||
connect(em, SIGNAL(editorsClosed(QList<Core::IEditor*>)),
|
connect(em, SIGNAL(editorsClosed(QList<Core::IEditor*>)),
|
||||||
@@ -839,40 +836,17 @@ QString SessionManager::currentSession() const
|
|||||||
return m_file->fileName();
|
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()
|
void SessionManager::updateWindowTitle()
|
||||||
{
|
{
|
||||||
QString windowTitle = tr("Qt Creator");
|
|
||||||
if (isDefaultSession(m_sessionName)) {
|
if (isDefaultSession(m_sessionName)) {
|
||||||
if (Project *currentProject = ProjectExplorerPlugin::instance()->currentProject())
|
if (Project *currentProject = ProjectExplorerPlugin::instance()->currentProject())
|
||||||
windowTitle.prepend(currentProject->displayName() + " - ");
|
m_core->editorManager()->setWindowTitleAddition(currentProject->displayName());
|
||||||
} else {
|
} else {
|
||||||
QString sessionName = m_sessionName;
|
QString sessionName = m_sessionName;
|
||||||
if (sessionName.isEmpty())
|
if (sessionName.isEmpty())
|
||||||
sessionName = tr("Untitled");
|
sessionName = tr("Untitled");
|
||||||
windowTitle.prepend(sessionName + " - ");
|
m_core->editorManager()->setWindowTitleAddition(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->mainWindow()->setWindowTitle(windowTitle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionManager::updateName(const QString &session)
|
void SessionManager::updateName(const QString &session)
|
||||||
|
|||||||
@@ -155,7 +155,6 @@ private slots:
|
|||||||
void saveActiveMode(Core::IMode *mode);
|
void saveActiveMode(Core::IMode *mode);
|
||||||
void clearProjectFileCache();
|
void clearProjectFileCache();
|
||||||
void setEditorCodec(Core::IEditor *editor, const QString &fileName);
|
void setEditorCodec(Core::IEditor *editor, const QString &fileName);
|
||||||
void handleCurrentEditorChange(Core::IEditor *editor);
|
|
||||||
void updateWindowTitle();
|
void updateWindowTitle();
|
||||||
|
|
||||||
void markSessionFileDirty(bool makeDefaultVirginDirty = true);
|
void markSessionFileDirty(bool makeDefaultVirginDirty = true);
|
||||||
@@ -176,7 +175,6 @@ private:
|
|||||||
|
|
||||||
Internal::SessionFile *m_file;
|
Internal::SessionFile *m_file;
|
||||||
Internal::SessionNodeImpl *m_sessionNode;
|
Internal::SessionNodeImpl *m_sessionNode;
|
||||||
QPointer<Core::IEditor> m_currentEditor;
|
|
||||||
QString m_sessionName;
|
QString m_sessionName;
|
||||||
bool m_virginSession;
|
bool m_virginSession;
|
||||||
|
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ public:
|
|||||||
Core::IFile *file() { return m_resourceFile; }
|
Core::IFile *file() { return m_resourceFile; }
|
||||||
QString id() const;
|
QString id() const;
|
||||||
QString displayName() const { return m_displayName; }
|
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; }
|
QWidget *toolBar() { return 0; }
|
||||||
QByteArray saveState() const { return QByteArray(); }
|
QByteArray saveState() const { return QByteArray(); }
|
||||||
bool restoreState(const QByteArray &/*state*/) { return true; }
|
bool restoreState(const QByteArray &/*state*/) { return true; }
|
||||||
|
|||||||
@@ -2050,6 +2050,7 @@ QString BaseTextEditor::displayName() const
|
|||||||
void BaseTextEditor::setDisplayName(const QString &title)
|
void BaseTextEditor::setDisplayName(const QString &title)
|
||||||
{
|
{
|
||||||
d->m_displayName = title;
|
d->m_displayName = title;
|
||||||
|
emit changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseTextDocument *BaseTextEditor::baseTextDocument() const
|
BaseTextDocument *BaseTextEditor::baseTextDocument() const
|
||||||
|
|||||||
@@ -572,7 +572,7 @@ public:
|
|||||||
return e->open(fileName);
|
return e->open(fileName);
|
||||||
}
|
}
|
||||||
inline QString displayName() const { return e->displayName(); }
|
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 QByteArray saveState() const { return e->saveState(); }
|
||||||
inline bool restoreState(const QByteArray &state) { return e->restoreState(state); }
|
inline bool restoreState(const QByteArray &state) { return e->restoreState(state); }
|
||||||
|
|||||||
@@ -329,6 +329,7 @@ QString VCSBaseSubmitEditor::displayName() const
|
|||||||
void VCSBaseSubmitEditor::setDisplayName(const QString &title)
|
void VCSBaseSubmitEditor::setDisplayName(const QString &title)
|
||||||
{
|
{
|
||||||
m_d->m_displayName = title;
|
m_d->m_displayName = title;
|
||||||
|
emit changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString VCSBaseSubmitEditor::checkScriptWorkingDirectory() const
|
QString VCSBaseSubmitEditor::checkScriptWorkingDirectory() const
|
||||||
|
|||||||
Reference in New Issue
Block a user