diff options
author | Eike Ziller <eike.ziller@qt.io> | 2023-05-22 13:45:27 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@qt.io> | 2023-05-23 13:14:04 +0000 |
commit | 5ac582a9b65c96210cee578aa62489ca3377176f (patch) | |
tree | faea997734058595cf6db6a7e847df1bc0bc2f83 /src | |
parent | 2726f7716f0e419ac75cb18e4ab5d7a5298be62e (diff) |
Remove usage of SessionManagerPrivate from project explorer
Change-Id: Ia12a9ba2d9e65605715110ea0330d5c1e1cae7c6
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/projectexplorer/projectexplorer.cpp | 9 | ||||
-rw-r--r-- | src/plugins/projectexplorer/projectmanager.cpp | 13 | ||||
-rw-r--r-- | src/plugins/projectexplorer/session.cpp | 55 | ||||
-rw-r--r-- | src/plugins/projectexplorer/session.h | 3 | ||||
-rw-r--r-- | src/plugins/projectexplorer/session_p.h | 1 |
5 files changed, 39 insertions, 42 deletions
diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index d6379488fa..d68b76a475 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -69,7 +69,6 @@ #include "sanitizerparser.h" #include "selectablefilesmodel.h" #include "session.h" -#include "session_p.h" #include "sessiondialog.h" #include "showineditortaskhandler.h" #include "simpleprojectwizard.h" @@ -1633,10 +1632,6 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er connect(ICore::instance(), &ICore::saveSettingsRequested, dd, &ProjectExplorerPluginPrivate::savePersistentSettings); - connect(EditorManager::instance(), &EditorManager::autoSaved, this, [] { - if (!PluginManager::isShuttingDown() && !SessionManager::loadingSession()) - SessionManager::saveSession(); - }); connect(qApp, &QApplication::applicationStateChanged, this, [](Qt::ApplicationState state) { if (!PluginManager::isShuttingDown() && state == Qt::ApplicationActive) dd->updateWelcomePage(); @@ -1714,7 +1709,6 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er .toBool(); dd->m_buildPropertiesSettings.readSettings(s); - sb_d->restoreSettings(); const int customParserCount = s->value(Constants::CUSTOM_PARSER_COUNT_KEY).toInt(); for (int i = 0; i < customParserCount; ++i) { @@ -2169,7 +2163,7 @@ void ProjectExplorerPlugin::restoreKits() KitManager::restoreKits(); // restoring startup session is supposed to be done as a result of ICore::coreOpened, // and that is supposed to happen after restoring kits: - QTC_CHECK(!sb_d->isStartupSessionRestored()); + QTC_CHECK(!SessionManager::isStartupSessionRestored()); } void ProjectExplorerPluginPrivate::updateRunWithoutDeployMenu() @@ -2304,7 +2298,6 @@ void ProjectExplorerPluginPrivate::savePersistentSettings() int(defaultSettings.stopBeforeBuild)); dd->m_buildPropertiesSettings.writeSettings(s); - sb_d->saveSettings(); s->setValueWithDefault(Constants::CUSTOM_PARSER_COUNT_KEY, int(dd->m_customParsers.count()), 0); for (int i = 0; i < dd->m_customParsers.count(); ++i) { diff --git a/src/plugins/projectexplorer/projectmanager.cpp b/src/plugins/projectexplorer/projectmanager.cpp index ff5b214b10..6d0730786b 100644 --- a/src/plugins/projectexplorer/projectmanager.cpp +++ b/src/plugins/projectexplorer/projectmanager.cpp @@ -3,7 +3,6 @@ #include "projectmanager.h" -#include "session_p.h" #include "session.h" #include "buildconfiguration.h" @@ -280,7 +279,7 @@ void ProjectManager::addProject(Project *pro) QTC_CHECK(!pro->displayName().isEmpty()); QTC_CHECK(pro->id().isValid()); - sb_d->m_virginSession = false; + SessionManager::markSessionFileDirty(); QTC_ASSERT(!d->m_projects.contains(pro), return); d->m_projects.append(pro); @@ -314,7 +313,7 @@ void ProjectManager::addProject(Project *pro) void ProjectManager::removeProject(Project *project) { - sb_d->m_virginSession = false; + SessionManager::markSessionFileDirty(); QTC_ASSERT(project, return); removeProjects({project}); } @@ -396,7 +395,8 @@ void ProjectManagerPrivate::dependencies(const FilePath &proName, FilePaths &res QString ProjectManagerPrivate::sessionTitle(const FilePath &filePath) { - if (SessionManager::isDefaultSession(sb_d->m_sessionName)) { + const QString sessionName = SessionManager::activeSession(); + if (SessionManager::isDefaultSession(sessionName)) { if (filePath.isEmpty()) { // use single project's name if there is only one loaded. const QList<Project *> projects = ProjectManager::projects(); @@ -404,10 +404,7 @@ QString ProjectManagerPrivate::sessionTitle(const FilePath &filePath) return projects.first()->displayName(); } } else { - QString sessionName = sb_d->m_sessionName; - if (sessionName.isEmpty()) - sessionName = Tr::tr("Untitled"); - return sessionName; + return sessionName.isEmpty() ? Tr::tr("Untitled") : sessionName; } return QString(); } diff --git a/src/plugins/projectexplorer/session.cpp b/src/plugins/projectexplorer/session.cpp index 9933ff070f..ceb57bd8d5 100644 --- a/src/plugins/projectexplorer/session.cpp +++ b/src/plugins/projectexplorer/session.cpp @@ -35,6 +35,7 @@ #include <QTimer> using namespace Core; +using namespace ExtensionSystem; using namespace Utils; namespace ProjectExplorer { @@ -70,24 +71,18 @@ SessionManager::SessionManager() connect(ModeManager::instance(), &ModeManager::currentModeChanged, this, &SessionManager::saveActiveMode); - connect(ICore::instance(), &ICore::saveSettingsRequested, this, [] { - QtcSettings *s = ICore::settings(); - QVariantMap times; - for (auto it = sb_d->m_lastActiveTimes.cbegin(); it != sb_d->m_lastActiveTimes.cend(); ++it) - times.insert(it.key(), it.value()); - s->setValue(LAST_ACTIVE_TIMES_KEY, times); - if (SessionManager::isDefaultVirgin()) { - s->remove(STARTUPSESSION_KEY); - } else { - s->setValue(STARTUPSESSION_KEY, SessionManager::activeSession()); - s->setValue(LASTSESSION_KEY, SessionManager::activeSession()); - } - }); + connect(ICore::instance(), &ICore::saveSettingsRequested, this, [] { sb_d->saveSettings(); }); connect(EditorManager::instance(), &EditorManager::editorOpened, this, &SessionManager::markSessionFileDirty); connect(EditorManager::instance(), &EditorManager::editorsClosed, this, &SessionManager::markSessionFileDirty); + connect(EditorManager::instance(), &EditorManager::autoSaved, this, [] { + if (!PluginManager::isShuttingDown() && !SessionManager::loadingSession()) + SessionManager::saveSession(); + }); + + sb_d->restoreSettings(); } SessionManager::~SessionManager() @@ -286,13 +281,12 @@ static QString determineSessionToRestoreAtStartup() { // TODO (session) move argument to core // Process command line arguments first: - const bool lastSessionArg = ExtensionSystem::PluginManager::specForPlugin( - ProjectExplorerPlugin::instance()) + const bool lastSessionArg = PluginManager::specForPlugin(ProjectExplorerPlugin::instance()) ->arguments() .contains("-lastsession"); if (lastSessionArg && !SessionManager::startupSession().isEmpty()) return SessionManager::startupSession(); - const QStringList arguments = ExtensionSystem::PluginManager::arguments(); + const QStringList arguments = PluginManager::arguments(); QStringList sessions = SessionManager::sessions(); // We have command line arguments, try to find a session in them // Default to no session loading @@ -316,7 +310,7 @@ void SessionManagerPrivate::restoreStartupSession() ModeManager::activateMode(Core::Constants::MODE_EDIT); // We have command line arguments, try to find a session in them - QStringList arguments = ExtensionSystem::PluginManager::arguments(); + QStringList arguments = PluginManager::arguments(); if (!sessionToRestoreAtStartup.isEmpty() && !arguments.isEmpty()) arguments.removeOne(sessionToRestoreAtStartup); @@ -365,16 +359,22 @@ void SessionManagerPrivate::restoreStartupSession() }); } -bool SessionManagerPrivate::isStartupSessionRestored() -{ - return sb_d->m_isStartupSessionRestored; -} - void SessionManagerPrivate::saveSettings() { - ICore::settings()->setValueWithDefault(AUTO_RESTORE_SESSION_SETTINGS_KEY, - sb_d->m_isAutoRestoreLastSession, - kIsAutoRestoreLastSessionDefault); + QtcSettings *s = ICore::settings(); + QVariantMap times; + for (auto it = sb_d->m_lastActiveTimes.cbegin(); it != sb_d->m_lastActiveTimes.cend(); ++it) + times.insert(it.key(), it.value()); + s->setValue(LAST_ACTIVE_TIMES_KEY, times); + if (SessionManager::isDefaultVirgin()) { + s->remove(STARTUPSESSION_KEY); + } else { + s->setValue(STARTUPSESSION_KEY, SessionManager::activeSession()); + s->setValue(LASTSESSION_KEY, SessionManager::activeSession()); + } + s->setValueWithDefault(AUTO_RESTORE_SESSION_SETTINGS_KEY, + sb_d->m_isAutoRestoreLastSession, + kIsAutoRestoreLastSessionDefault); } void SessionManagerPrivate::restoreSettings() @@ -645,4 +645,9 @@ bool SessionManager::saveSession() return result; } +bool SessionManager::isStartupSessionRestored() +{ + return sb_d->m_isStartupSessionRestored; +} + } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/session.h b/src/plugins/projectexplorer/session.h index a19e74a671..159a35f998 100644 --- a/src/plugins/projectexplorer/session.h +++ b/src/plugins/projectexplorer/session.h @@ -80,6 +80,9 @@ signals: void sessionRenamed(const QString &oldName, const QString &newName); void sessionRemoved(const QString &name); +public: // internal + static bool isStartupSessionRestored(); + private: static void saveActiveMode(Utils::Id mode); }; diff --git a/src/plugins/projectexplorer/session_p.h b/src/plugins/projectexplorer/session_p.h index 40f691ab2d..985dfd6661 100644 --- a/src/plugins/projectexplorer/session_p.h +++ b/src/plugins/projectexplorer/session_p.h @@ -18,7 +18,6 @@ public: void restoreSessionValues(const PersistentSettingsReader &reader); void restoreEditors(); - bool isStartupSessionRestored(); void saveSettings(); void restoreSettings(); bool isAutoRestoreLastSession(); |