Core: FilePathify WindowTitleHandler

Change-Id: I905a193e70b199cbbd483e76e14c7f9fd2b179ef
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
David Schulz
2022-06-16 13:38:24 +02:00
parent 3ab822739d
commit e052d75987
4 changed files with 17 additions and 18 deletions

View File

@@ -2148,8 +2148,8 @@ void EditorManagerPrivate::updateWindowTitleForDocument(IDocument *document, QWi
if (!documentName.isEmpty())
windowTitle.append(documentName);
const QString filePath = document ? document->filePath().absoluteFilePath().path()
: QString();
const Utils::FilePath filePath = document ? document->filePath().absoluteFilePath()
: Utils::FilePath();
const QString windowTitleAddition = d->m_titleAdditionHandler
? d->m_titleAdditionHandler(filePath)
: QString();
@@ -2181,7 +2181,7 @@ void EditorManagerPrivate::updateWindowTitleForDocument(IDocument *document, QWi
windowTitle.append(dashSep);
windowTitle.append(Core::Constants::IDE_DISPLAY_NAME);
window->window()->setWindowTitle(windowTitle);
window->window()->setWindowFilePath(filePath);
window->window()->setWindowFilePath(filePath.path());
if (HostOsInfo::isMacHost()) {
if (document)

View File

@@ -71,7 +71,7 @@ class CORE_EXPORT EditorManager : public QObject
Q_OBJECT
public:
using WindowTitleHandler = std::function<QString (const QString &)>;
using WindowTitleHandler = std::function<QString (const Utils::FilePath &)>;
static EditorManager *instance();

View File

@@ -96,8 +96,8 @@ public:
QStringList dependenciesOrder() const;
void dependencies(const QString &proName, QStringList &result) const;
static QString windowTitleAddition(const QString &filePath);
static QString sessionTitle(const QString &filePath);
static QString windowTitleAddition(const FilePath &filePath);
static QString sessionTitle(const FilePath &filePath);
bool hasProjects() const { return !m_projects.isEmpty(); }
@@ -118,7 +118,7 @@ public:
PersistentSettingsWriter *m_writer = nullptr;
private:
static QString locationInProject(const QString &filePath);
static QString locationInProject(const FilePath &filePath);
};
static SessionManager *m_instance = nullptr;
@@ -598,7 +598,7 @@ void SessionManagerPrivate::dependencies(const QString &proName, QStringList &re
result.append(proName);
}
QString SessionManagerPrivate::sessionTitle(const QString &filePath)
QString SessionManagerPrivate::sessionTitle(const FilePath &filePath)
{
if (SessionManager::isDefaultSession(d->m_sessionName)) {
if (filePath.isEmpty()) {
@@ -616,18 +616,17 @@ QString SessionManagerPrivate::sessionTitle(const QString &filePath)
return QString();
}
QString SessionManagerPrivate::locationInProject(const QString &filePath) {
const Project *project = SessionManager::projectForFile(Utils::FilePath::fromString(filePath));
QString SessionManagerPrivate::locationInProject(const FilePath &filePath) {
const Project *project = SessionManager::projectForFile(filePath);
if (!project)
return QString();
const Utils::FilePath file = Utils::FilePath::fromString(filePath);
const Utils::FilePath parentDir = file.parentDir();
const FilePath parentDir = filePath.parentDir();
if (parentDir == project->projectDirectory())
return "@ " + project->displayName();
if (file.isChildOf(project->projectDirectory())) {
const Utils::FilePath dirInProject = parentDir.relativeChildPath(project->projectDirectory());
if (filePath.isChildOf(project->projectDirectory())) {
const FilePath dirInProject = parentDir.relativeChildPath(project->projectDirectory());
return "(" + dirInProject.toUserOutput() + " @ " + project->displayName() + ")";
}
@@ -637,7 +636,7 @@ QString SessionManagerPrivate::locationInProject(const QString &filePath) {
return "(" + parentDir.toUserOutput() + " @ " + project->displayName() + ")";
}
QString SessionManagerPrivate::windowTitleAddition(const QString &filePath)
QString SessionManagerPrivate::windowTitleAddition(const FilePath &filePath)
{
return filePath.isEmpty() ? QString() : locationInProject(filePath);
}

View File

@@ -199,7 +199,7 @@ public:
explicit StateListener(QObject *parent);
~StateListener();
static QString windowTitleVcsTopic(const QString &filePath);
static QString windowTitleVcsTopic(const FilePath &filePath);
signals:
void stateChanged(const VcsBase::Internal::State &s, IVersionControl *vc);
@@ -230,11 +230,11 @@ StateListener::~StateListener()
EditorManager::setWindowTitleVcsTopicHandler({});
}
QString StateListener::windowTitleVcsTopic(const QString &filePath)
QString StateListener::windowTitleVcsTopic(const FilePath &filePath)
{
FilePath searchPath;
if (!filePath.isEmpty()) {
searchPath = FilePath::fromString(filePath).absolutePath();
searchPath = filePath.absolutePath();
} else {
// use single project's information if there is only one loaded.
const QList<Project *> projects = SessionManager::projects();