Core: Move the only data member of ICore to ICorePrivate

Also change the caller side of the setter cosmetically.

Change-Id: I1422d90c3ede016ff872d23ad2291ae5b2b02264
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
hjk
2024-07-31 18:15:14 +02:00
parent e1c66ead66
commit 6ef00a1fd6
3 changed files with 8 additions and 11 deletions

View File

@@ -317,6 +317,8 @@ public:
QToolButton *m_toggleLeftSideBarButton = nullptr;
QToolButton *m_toggleRightSideBarButton = nullptr;
QList<std::function<bool()>> m_preCloseListeners;
std::function<Utils::FilePath(const Utils::FilePath &)> m_relativePathToProject = nullptr;
};
static QMenuBar *globalMenuBar()
@@ -1102,7 +1104,7 @@ void ICore::restart()
*/
void ICore::setRelativePathToProjectFunction(const std::function<FilePath(const FilePath &)> &func)
{
m_core->m_relativePathToProject = func;
d->m_relativePathToProject = func;
}
/*!
@@ -1110,8 +1112,8 @@ void ICore::setRelativePathToProjectFunction(const std::function<FilePath(const
*/
FilePath ICore::pathRelativeToActiveProject(const FilePath &path)
{
if (m_core->m_relativePathToProject)
return m_core->m_relativePathToProject(path);
if (d->m_relativePathToProject)
return d->m_relativePathToProject(path);
return path;
}

View File

@@ -171,9 +171,6 @@ public:
static IDocument *openFiles(const Utils::FilePaths &filePaths,
OpenFilesFlags flags = None,
const Utils::FilePath &workingDirectory = {});
private:
std::function<Utils::FilePath(const Utils::FilePath &)> m_relativePathToProject = nullptr;
};
} // namespace Core

View File

@@ -2120,15 +2120,13 @@ void ProjectExplorerPlugin::extensionsInitialized()
// Load devices immediately, as other plugins might want to use them
DeviceManager::instance()->load();
Core::ICore::instance()->setRelativePathToProjectFunction([=](const FilePath& path) -> FilePath
Core::ICore::setRelativePathToProjectFunction([](const FilePath &path)
{
ProjectExplorer::Project* p = ProjectExplorer::ProjectTree::currentProject();
if (p) {
if (Project *p = ProjectTree::currentProject()) {
FilePath relPath = path.relativeChildPath(p->projectFilePath().absolutePath());
return !relPath.isEmpty() ? relPath : path;
} else {
return path;
}
return path;
});
}