| Wireshark 4.7.3 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
workspace_state.h
Go to the documentation of this file.
1
14
15#ifndef WORKSPACE_STATE_H
16#define WORKSPACE_STATE_H
17
18#include "config.h"
19
20#include <QObject>
21#include <QStringList>
22#include <QFileInfo>
23#include <QList>
24#include <functional>
25
32 struct RecentFileInfo {
33 QString filename;
34 qint64 size = 0;
35 bool accessible = false;
36};
37
38
51 class WorkspaceState : public QObject
52{
53 Q_OBJECT
54
55 public:
61 static WorkspaceState *instance();
62
66 virtual ~WorkspaceState();
67
71 WorkspaceState(const WorkspaceState &) = delete;
72
76 WorkspaceState &operator=(const WorkspaceState &) = delete;
77
87 bool loadCommonState(QString *errorPath = nullptr, int *errorCode = nullptr);
88
94 QString recentCommonFilePath() const;
95
101 QString recentProfileFilePath() const;
102
121 QString personalThemesPath() const;
122
128 const QList<RecentFileInfo> &recentCaptureFiles() const;
129
137 QStringList recentCaptureFilenames() const;
138
144 void addRecentCaptureFile(const QString &filePath);
145
151 void removeRecentCaptureFile(const QString &filePath);
152
156 void clearRecentCaptureFiles();
157
167 static bool isDevelopmentBuild();
168
177 static bool isPortableApplication();
178
179signals:
183 void recentCaptureFilesChanged();
184
190 void recentFileStatusChanged(const QString &filename);
191
195 void stateLoaded();
196
200 void stateSaved();
201
202 protected:
207 explicit WorkspaceState(QObject *parent = nullptr);
208
209 private slots:
216 void onFileStatusChecked(const QString &filename, qint64 size, bool accessible);
217
218 private:
226 bool parseRecentFile(const QString &filePath,
227 std::function<void(const QString &key, const QString &value)> handler);
228
234 void queueFileStatusCheck(const QString &filename);
235
236 QList<RecentFileInfo> recent_capture_files_;
237
238 static constexpr const char *RECENT_COMMON_FILE_NAME = "recent_common";
239 static constexpr const char *RECENT_PROFILE_FILE_NAME = "recent";
240 static constexpr const char *KEY_CAPTURE_FILE = "recent.capture_file";
241 static constexpr const char *THEMES_DIR_NAME = "themes";
242};
243
244#endif // WORKSPACE_STATE_H
WorkspaceState::personalThemesPath
QString personalThemesPath() const
Get the path to the personal themes directory.
Definition workspace_state.cpp:75
WorkspaceState::loadCommonState
bool loadCommonState(QString *errorPath=nullptr, int *errorCode=nullptr)
Load state from the recent_common file.
Definition workspace_state.cpp:133
WorkspaceState::operator=
WorkspaceState & operator=(const WorkspaceState &)=delete
Deleted assignment operator to enforce the singleton pattern.
WorkspaceState::recentCaptureFilenames
QStringList recentCaptureFilenames() const
Get just the filenames of recent capture files.
Definition workspace_state.cpp:189
WorkspaceState::recentCaptureFilesChanged
void recentCaptureFilesChanged()
Emitted when the recent capture files list changes.
WorkspaceState::recentProfileFilePath
QString recentProfileFilePath() const
Get the path to the profile-specific recent file.
Definition workspace_state.cpp:60
WorkspaceState::WorkspaceState
WorkspaceState(const WorkspaceState &)=delete
Deleted copy constructor to enforce the singleton pattern.
WorkspaceState::addRecentCaptureFile
void addRecentCaptureFile(const QString &filePath)
Add a capture file to the recent files list.
Definition workspace_state.cpp:199
WorkspaceState::recentCommonFilePath
QString recentCommonFilePath() const
Get the path to the recent_common file.
Definition workspace_state.cpp:45
WorkspaceState::stateLoaded
void stateLoaded()
Emitted when state is loaded from disk.
WorkspaceState::instance
static WorkspaceState * instance()
Returns the singleton instance.
Definition workspace_state.cpp:38
WorkspaceState::recentFileStatusChanged
void recentFileStatusChanged(const QString &filename)
Emitted when a file's status (size/accessibility) is updated.
WorkspaceState::recentCaptureFiles
const QList< RecentFileInfo > & recentCaptureFiles() const
Get the list of recently opened capture files.
Definition workspace_state.cpp:184
WorkspaceState::isDevelopmentBuild
static bool isDevelopmentBuild()
Check if this is a development build.
Definition workspace_state.cpp:304
WorkspaceState::isPortableApplication
static bool isPortableApplication()
Check if the application is running in portable mode. (Windows only).
Definition workspace_state.cpp:312
WorkspaceState::clearRecentCaptureFiles
void clearRecentCaptureFiles()
Clear all recent capture files.
Definition workspace_state.cpp:259
WorkspaceState::stateSaved
void stateSaved()
Emitted when state is saved to disk.
WorkspaceState::~WorkspaceState
virtual ~WorkspaceState()
Destroys the singleton and releases all owned resources.
Definition workspace_state.cpp:34
WorkspaceState::removeRecentCaptureFile
void removeRecentCaptureFile(const QString &filePath)
Remove a capture file from the recent files list.
Definition workspace_state.cpp:241
RecentFileInfo
Information about a recent capture file.
Definition workspace_state.h:32
RecentFileInfo::accessible
bool accessible
Definition workspace_state.h:35
RecentFileInfo::filename
QString filename
Definition workspace_state.h:33
RecentFileInfo::size
qint64 size
Definition workspace_state.h:34