Falkon Develop
Cross-platform Qt-based web browser
sessionmanager.h
Go to the documentation of this file.
1/* ============================================================
2* Falkon - Qt web browser
3* Copyright (C) 2017 Razi Alavizadeh <s.r.alavizadeh@gmail.com>
4*
5* This program is free software: you can redistribute it and/or modify
6* it under the terms of the GNU General Public License as published by
7* the Free Software Foundation, either version 3 of the License, or
8* (at your option) any later version.
9*
10* This program is distributed in the hope that it will be useful,
11* but WITHOUT ANY WARRANTY; without even the implied warranty of
12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13* GNU General Public License for more details.
14*
15* You should have received a copy of the GNU General Public License
16* along with this program. If not, see <http://www.gnu.org/licenses/>.
17* ============================================================ */
18#ifndef SESSIONMANAGER_H
19#define SESSIONMANAGER_H
20
21#include "qzcommon.h"
22
23class QAction;
24class QMenu;
25class QFileInfo;
26
27class FALKON_EXPORT SessionManager : public QObject
28{
29 Q_OBJECT
30
31public:
33 QString name;
34 QString filePath;
35 bool isActive = false;
36 bool isDefault = false;
37 bool isBackup = false;
38 };
39
41 SwitchSession = 1,
42 CloneSession = 2,
43 ReplaceSession = SwitchSession | 4
44 };
45 Q_DECLARE_FLAGS(SessionFlags, SessionFlag)
46
47 explicit SessionManager(QObject* parent = nullptr);
48
49 void loadSettings();
50 void saveSettings();
51
52 static QString defaultSessionPath();
53 QString lastActiveSessionPath() const;
54 QString askSessionFromUser();
55
56 void backupSavedSessions();
57 void writeCurrentSession(const QString &filePath);
58
59Q_SIGNALS:
61
62public Q_SLOTS:
63 void autoSaveLastSession();
64 void openSessionManagerDialog();
65
66private Q_SLOTS:
67 void aboutToShowSessionsMenu();
68 void sessionsDirectoryChanged();
69 void openSession(QString sessionFilePath = QString(), SessionManager::SessionFlags flags = {});
70 void renameSession(QString sessionFilePath = QString(), SessionManager::SessionFlags flags = {});
71 void saveSession();
72
73 void replaceSession(const QString &filePath);
74 void switchToSession(const QString &filePath);
75 void cloneSession(const QString &filePath);
76 void deleteSession(const QString &filePath);
77 void newSession();
78
79 QList<SessionManager::SessionMetaData> sessionMetaData(bool withBackups = true);
80
81private:
82 bool isActive(const QString &filePath) const;
83 bool isActive(const QFileInfo &fileInfo) const;
84 void fillSessionsMetaDataListIfNeeded();
85
86 QList<SessionMetaData> m_sessionsMetaDataList;
87
88 QString m_firstBackupSession;
89 QString m_secondBackupSession;
90 QString m_lastActiveSessionPath;
91
93};
94
95Q_DECLARE_OPERATORS_FOR_FLAGS(SessionManager::SessionFlags)
96
97#endif // SESSIONMANAGER_H
void sessionsMetaDataChanged()
#define FALKON_EXPORT
Definition: qzcommon.h:28