forked from qt-creator/qt-creator
Core: FilePathify WindowTitleHandler
Change-Id: I905a193e70b199cbbd483e76e14c7f9fd2b179ef Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -2148,8 +2148,8 @@ void EditorManagerPrivate::updateWindowTitleForDocument(IDocument *document, QWi
|
|||||||
if (!documentName.isEmpty())
|
if (!documentName.isEmpty())
|
||||||
windowTitle.append(documentName);
|
windowTitle.append(documentName);
|
||||||
|
|
||||||
const QString filePath = document ? document->filePath().absoluteFilePath().path()
|
const Utils::FilePath filePath = document ? document->filePath().absoluteFilePath()
|
||||||
: QString();
|
: Utils::FilePath();
|
||||||
const QString windowTitleAddition = d->m_titleAdditionHandler
|
const QString windowTitleAddition = d->m_titleAdditionHandler
|
||||||
? d->m_titleAdditionHandler(filePath)
|
? d->m_titleAdditionHandler(filePath)
|
||||||
: QString();
|
: QString();
|
||||||
@@ -2181,7 +2181,7 @@ void EditorManagerPrivate::updateWindowTitleForDocument(IDocument *document, QWi
|
|||||||
windowTitle.append(dashSep);
|
windowTitle.append(dashSep);
|
||||||
windowTitle.append(Core::Constants::IDE_DISPLAY_NAME);
|
windowTitle.append(Core::Constants::IDE_DISPLAY_NAME);
|
||||||
window->window()->setWindowTitle(windowTitle);
|
window->window()->setWindowTitle(windowTitle);
|
||||||
window->window()->setWindowFilePath(filePath);
|
window->window()->setWindowFilePath(filePath.path());
|
||||||
|
|
||||||
if (HostOsInfo::isMacHost()) {
|
if (HostOsInfo::isMacHost()) {
|
||||||
if (document)
|
if (document)
|
||||||
|
@@ -71,7 +71,7 @@ class CORE_EXPORT EditorManager : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using WindowTitleHandler = std::function<QString (const QString &)>;
|
using WindowTitleHandler = std::function<QString (const Utils::FilePath &)>;
|
||||||
|
|
||||||
static EditorManager *instance();
|
static EditorManager *instance();
|
||||||
|
|
||||||
|
@@ -96,8 +96,8 @@ public:
|
|||||||
QStringList dependenciesOrder() const;
|
QStringList dependenciesOrder() const;
|
||||||
void dependencies(const QString &proName, QStringList &result) const;
|
void dependencies(const QString &proName, QStringList &result) const;
|
||||||
|
|
||||||
static QString windowTitleAddition(const QString &filePath);
|
static QString windowTitleAddition(const FilePath &filePath);
|
||||||
static QString sessionTitle(const QString &filePath);
|
static QString sessionTitle(const FilePath &filePath);
|
||||||
|
|
||||||
bool hasProjects() const { return !m_projects.isEmpty(); }
|
bool hasProjects() const { return !m_projects.isEmpty(); }
|
||||||
|
|
||||||
@@ -118,7 +118,7 @@ public:
|
|||||||
PersistentSettingsWriter *m_writer = nullptr;
|
PersistentSettingsWriter *m_writer = nullptr;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static QString locationInProject(const QString &filePath);
|
static QString locationInProject(const FilePath &filePath);
|
||||||
};
|
};
|
||||||
|
|
||||||
static SessionManager *m_instance = nullptr;
|
static SessionManager *m_instance = nullptr;
|
||||||
@@ -598,7 +598,7 @@ void SessionManagerPrivate::dependencies(const QString &proName, QStringList &re
|
|||||||
result.append(proName);
|
result.append(proName);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString SessionManagerPrivate::sessionTitle(const QString &filePath)
|
QString SessionManagerPrivate::sessionTitle(const FilePath &filePath)
|
||||||
{
|
{
|
||||||
if (SessionManager::isDefaultSession(d->m_sessionName)) {
|
if (SessionManager::isDefaultSession(d->m_sessionName)) {
|
||||||
if (filePath.isEmpty()) {
|
if (filePath.isEmpty()) {
|
||||||
@@ -616,18 +616,17 @@ QString SessionManagerPrivate::sessionTitle(const QString &filePath)
|
|||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString SessionManagerPrivate::locationInProject(const QString &filePath) {
|
QString SessionManagerPrivate::locationInProject(const FilePath &filePath) {
|
||||||
const Project *project = SessionManager::projectForFile(Utils::FilePath::fromString(filePath));
|
const Project *project = SessionManager::projectForFile(filePath);
|
||||||
if (!project)
|
if (!project)
|
||||||
return QString();
|
return QString();
|
||||||
|
|
||||||
const Utils::FilePath file = Utils::FilePath::fromString(filePath);
|
const FilePath parentDir = filePath.parentDir();
|
||||||
const Utils::FilePath parentDir = file.parentDir();
|
|
||||||
if (parentDir == project->projectDirectory())
|
if (parentDir == project->projectDirectory())
|
||||||
return "@ " + project->displayName();
|
return "@ " + project->displayName();
|
||||||
|
|
||||||
if (file.isChildOf(project->projectDirectory())) {
|
if (filePath.isChildOf(project->projectDirectory())) {
|
||||||
const Utils::FilePath dirInProject = parentDir.relativeChildPath(project->projectDirectory());
|
const FilePath dirInProject = parentDir.relativeChildPath(project->projectDirectory());
|
||||||
return "(" + dirInProject.toUserOutput() + " @ " + project->displayName() + ")";
|
return "(" + dirInProject.toUserOutput() + " @ " + project->displayName() + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -637,7 +636,7 @@ QString SessionManagerPrivate::locationInProject(const QString &filePath) {
|
|||||||
return "(" + parentDir.toUserOutput() + " @ " + project->displayName() + ")";
|
return "(" + parentDir.toUserOutput() + " @ " + project->displayName() + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
QString SessionManagerPrivate::windowTitleAddition(const QString &filePath)
|
QString SessionManagerPrivate::windowTitleAddition(const FilePath &filePath)
|
||||||
{
|
{
|
||||||
return filePath.isEmpty() ? QString() : locationInProject(filePath);
|
return filePath.isEmpty() ? QString() : locationInProject(filePath);
|
||||||
}
|
}
|
||||||
|
@@ -199,7 +199,7 @@ public:
|
|||||||
explicit StateListener(QObject *parent);
|
explicit StateListener(QObject *parent);
|
||||||
~StateListener();
|
~StateListener();
|
||||||
|
|
||||||
static QString windowTitleVcsTopic(const QString &filePath);
|
static QString windowTitleVcsTopic(const FilePath &filePath);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void stateChanged(const VcsBase::Internal::State &s, IVersionControl *vc);
|
void stateChanged(const VcsBase::Internal::State &s, IVersionControl *vc);
|
||||||
@@ -230,11 +230,11 @@ StateListener::~StateListener()
|
|||||||
EditorManager::setWindowTitleVcsTopicHandler({});
|
EditorManager::setWindowTitleVcsTopicHandler({});
|
||||||
}
|
}
|
||||||
|
|
||||||
QString StateListener::windowTitleVcsTopic(const QString &filePath)
|
QString StateListener::windowTitleVcsTopic(const FilePath &filePath)
|
||||||
{
|
{
|
||||||
FilePath searchPath;
|
FilePath searchPath;
|
||||||
if (!filePath.isEmpty()) {
|
if (!filePath.isEmpty()) {
|
||||||
searchPath = FilePath::fromString(filePath).absolutePath();
|
searchPath = filePath.absolutePath();
|
||||||
} else {
|
} else {
|
||||||
// use single project's information if there is only one loaded.
|
// use single project's information if there is only one loaded.
|
||||||
const QList<Project *> projects = SessionManager::projects();
|
const QList<Project *> projects = SessionManager::projects();
|
||||||
|
Reference in New Issue
Block a user