2023-05-23 15:05:38 +02:00
|
|
|
// Copyright (C) 2023 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2008-12-02 16:19:05 +01:00
|
|
|
|
2016-02-02 18:26:51 +01:00
|
|
|
#pragma once
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2023-05-23 15:05:38 +02:00
|
|
|
#include "core_global.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2017-12-04 13:53:38 +01:00
|
|
|
#include <QDateTime>
|
2023-10-02 18:24:45 +02:00
|
|
|
#include <QObject>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QString>
|
|
|
|
|
#include <QStringList>
|
2009-09-29 11:39:55 +02:00
|
|
|
|
2023-10-02 18:24:45 +02:00
|
|
|
namespace Utils {
|
|
|
|
|
class FilePath;
|
|
|
|
|
class Key;
|
|
|
|
|
} // Utils
|
|
|
|
|
|
2023-05-23 15:05:38 +02:00
|
|
|
namespace Core {
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2023-05-23 15:05:38 +02:00
|
|
|
class CORE_EXPORT SessionManager : public QObject
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2023-02-14 15:47:22 +01:00
|
|
|
SessionManager();
|
2016-02-02 18:26:51 +01:00
|
|
|
~SessionManager() override;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2014-10-09 16:46:13 +02:00
|
|
|
static SessionManager *instance();
|
2013-09-05 11:46:07 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
// higher level session management
|
2013-09-05 11:46:07 +02:00
|
|
|
static QString activeSession();
|
|
|
|
|
static QString lastSession();
|
2020-01-07 12:34:31 +01:00
|
|
|
static QString startupSession();
|
2013-09-05 11:46:07 +02:00
|
|
|
static QStringList sessions();
|
2016-09-23 19:14:50 +02:00
|
|
|
static QDateTime sessionDateTime(const QString &session);
|
2022-10-20 17:53:09 +02:00
|
|
|
static QDateTime lastActiveTime(const QString &session);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2013-09-05 11:46:07 +02:00
|
|
|
static bool createSession(const QString &session);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2019-05-09 16:21:42 +02:00
|
|
|
static bool confirmSessionDelete(const QStringList &sessions);
|
2013-09-05 11:46:07 +02:00
|
|
|
static bool deleteSession(const QString &session);
|
2019-05-09 16:21:42 +02:00
|
|
|
static void deleteSessions(const QStringList &sessions);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2013-09-05 11:46:07 +02:00
|
|
|
static bool cloneSession(const QString &original, const QString &clone);
|
|
|
|
|
static bool renameSession(const QString &original, const QString &newName);
|
2023-05-22 14:56:33 +02:00
|
|
|
static void showSessionManager();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2019-05-28 13:49:26 +02:00
|
|
|
static Utils::FilePath sessionNameToFileName(const QString &session);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2013-09-05 11:46:07 +02:00
|
|
|
static bool isDefaultVirgin();
|
|
|
|
|
static bool isDefaultSession(const QString &session);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
// Let other plugins store persistent values within the session file
|
2023-05-15 15:19:01 +02:00
|
|
|
// These are settings that are also saved and loaded at startup, and are taken over
|
|
|
|
|
// to the default session when switching from implicit to explicit default session
|
2023-08-23 18:18:46 +02:00
|
|
|
static void setValue(const Utils::Key &name, const QVariant &value);
|
|
|
|
|
static QVariant value(const Utils::Key &name);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2023-05-15 15:19:01 +02:00
|
|
|
// These are settings that are specific to a session and are not loaded
|
|
|
|
|
// at startup and also not taken over to the default session when switching from implicit
|
2023-08-23 18:18:46 +02:00
|
|
|
static void setSessionValue(const Utils::Key &name, const QVariant &value);
|
|
|
|
|
static QVariant sessionValue(const Utils::Key &name, const QVariant &defaultValue = {});
|
2023-05-15 15:19:01 +02:00
|
|
|
|
2023-05-23 10:08:16 +02:00
|
|
|
static bool isLoadingSession();
|
2023-02-14 15:47:22 +01:00
|
|
|
static void markSessionFileDirty();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2023-05-15 15:19:01 +02:00
|
|
|
static void sessionLoadingProgress();
|
|
|
|
|
static void addSessionLoadingSteps(int steps);
|
2023-05-15 16:09:56 +02:00
|
|
|
|
|
|
|
|
static bool loadSession(const QString &session, bool initial = false);
|
2023-05-22 12:07:18 +02:00
|
|
|
static bool saveSession();
|
2023-05-15 16:09:56 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
signals:
|
2023-05-15 10:31:33 +02:00
|
|
|
void startupSessionRestored();
|
2012-02-10 12:46:33 +01:00
|
|
|
void aboutToUnloadSession(QString sessionName);
|
2023-05-15 15:19:01 +02:00
|
|
|
// Sent during session loading, after the values of the session are available via value() and
|
|
|
|
|
// sessionValue. Use to restore values from the new session
|
2011-11-09 17:03:00 +01:00
|
|
|
void aboutToLoadSession(QString sessionName);
|
2012-02-10 12:46:33 +01:00
|
|
|
void sessionLoaded(QString sessionName);
|
2008-12-02 12:01:29 +01:00
|
|
|
void aboutToSaveSession();
|
|
|
|
|
|
2023-05-22 14:56:33 +02:00
|
|
|
void sessionCreated(const QString &name);
|
2021-11-23 17:04:13 +01:00
|
|
|
void sessionRenamed(const QString &oldName, const QString &newName);
|
|
|
|
|
void sessionRemoved(const QString &name);
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
2023-05-23 15:05:38 +02:00
|
|
|
} // namespace Core
|