blob: 5b9ac1535e73e801301dc1a825bd3f93a5fc3944 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
#include "core_global.h"
#include <QDateTime>
#include <QObject>
#include <QString>
#include <QStringList>
namespace Utils {
class FilePath;
class FilePaths;
class Key;
} // Utils
namespace Core {
class CORE_EXPORT SessionManager : public QObject
{
Q_OBJECT
public:
SessionManager();
~SessionManager() override;
static SessionManager *instance();
static bool loadsSessionOrFileAtStartup();
// higher level session management
static QString activeSession();
static QString lastSession();
static QString startupSession();
static QStringList sessions();
static QDateTime sessionDateTime(const QString &session);
static QDateTime lastActiveTime(const QString &session);
static int sessionsCount();
static bool createSession(const QString &session);
static bool confirmSessionDelete(const QStringList &sessions);
static bool deleteSession(const QString &session);
static void deleteSessions(const QStringList &sessions);
static bool cloneSession(const QString &original, const QString &clone);
static bool renameSession(const QString &original, const QString &newName);
static void showSessionManager();
static Utils::FilePath sessionNameToFileName(const QString &session);
static bool isDefaultVirgin();
static bool isDefaultSession(const QString &session);
// Let other plugins store persistent values within the session file
// 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
static void setValue(const Utils::Key &name, const QVariant &value);
static QVariant value(const Utils::Key &name);
// 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
static void setSessionValue(const Utils::Key &name, const QVariant &value);
static QVariant sessionValue(const Utils::Key &name, const QVariant &defaultValue = {});
static bool isLoadingSession();
static void markSessionFileDirty();
static void sessionLoadingProgress();
static void addSessionLoadingSteps(int steps);
static bool loadSession(const QString &session, bool initial = false);
static bool saveSession();
static Utils::FilePaths openFilesForSessionName(const QString &session, int max = -1);
signals:
void startupSessionRestored();
void aboutToUnloadSession(QString sessionName);
// Sent during session loading, after the values of the session are available via value() and
// sessionValue. Use to restore values from the new session
void aboutToLoadSession(QString sessionName);
void sessionLoaded(QString sessionName);
void aboutToSaveSession();
void sessionCreated(const QString &name);
void sessionRenamed(const QString &oldName, const QString &newName);
void sessionRemoved(const QString &name);
};
} // namespace Core
|