|
Wireshark 4.7.3
The Wireshark network protocol analyzer
|
Manages workspace state that persists between sessions. More...
#include <workspace_state.h>
Signals | |
| void | recentCaptureFilesChanged () |
| Emitted when the recent capture files list changes. | |
| void | recentFileStatusChanged (const QString &filename) |
| Emitted when a file's status (size/accessibility) is updated. | |
| void | stateLoaded () |
| Emitted when state is loaded from disk. | |
| void | stateSaved () |
| Emitted when state is saved to disk. | |
Public Member Functions | |
| virtual | ~WorkspaceState () |
| Destroys the singleton and releases all owned resources. | |
| WorkspaceState (const WorkspaceState &)=delete | |
| Deleted copy constructor to enforce the singleton pattern. | |
| WorkspaceState & | operator= (const WorkspaceState &)=delete |
| Deleted assignment operator to enforce the singleton pattern. | |
| bool | loadCommonState (QString *errorPath=nullptr, int *errorCode=nullptr) |
| Load state from the recent_common file. | |
| QString | recentCommonFilePath () const |
| Get the path to the recent_common file. | |
| QString | recentProfileFilePath () const |
| Get the path to the profile-specific recent file. | |
| QString | personalThemesPath () const |
| Get the path to the personal themes directory. | |
| const QList< RecentFileInfo > & | recentCaptureFiles () const |
| Get the list of recently opened capture files. | |
| QStringList | recentCaptureFilenames () const |
| Get just the filenames of recent capture files. | |
| void | addRecentCaptureFile (const QString &filePath) |
| Add a capture file to the recent files list. | |
| void | removeRecentCaptureFile (const QString &filePath) |
| Remove a capture file from the recent files list. | |
| void | clearRecentCaptureFiles () |
| Clear all recent capture files. | |
Static Public Member Functions | |
| static WorkspaceState * | instance () |
| Returns the singleton instance. | |
| static bool | isDevelopmentBuild () |
| Check if this is a development build. | |
| static bool | isPortableApplication () |
| Check if the application is running in portable mode. (Windows only). | |
Protected Member Functions | |
| WorkspaceState (QObject *parent=nullptr) | |
| Constructs the WorkspaceState; use instance() to obtain the singleton. | |
Manages workspace state that persists between sessions.
This class provides Qt-native access to the "recent" settings. It currently runs parallel to ui/recent.c for gradual migration.
Usage: WorkspaceState::instance()->loadCommonState(); QStringList files = WorkspaceState::instance()->recentCaptureFiles();
The singleton pattern avoids adding more dependencies to MainApplication.
|
explicitprotected |
Constructs the WorkspaceState; use instance() to obtain the singleton.
| parent | Optional parent QObject. |
| void WorkspaceState::addRecentCaptureFile | ( | const QString & | filePath | ) |
Add a capture file to the recent files list.
| filePath | The path to the capture file. |
|
static |
Returns the singleton instance.
Thread-safe in C++11 and later (Meyer's Singleton).
|
static |
Check if this is a development build.
Returns true when VERSION_FLAVOR is non-empty (the default "Development Build" set by CMake). Release builds either leave VERSION_FLAVOR empty or undefine it entirely.
true for development builds, false for releases.
|
static |
Check if the application is running in portable mode. (Windows only).
In portable mode, state files are stored in the application directory instead of a user-specific location. For any other OS than Windows, this will return false.
true if running in portable mode, false otherwise. | bool WorkspaceState::loadCommonState | ( | QString * | errorPath = nullptr, |
| int * | errorCode = nullptr ) |
Load state from the recent_common file.
Call this during application startup after recent_read_static() has been called.
| [out] | errorPath | If loading fails, contains the path that failed. |
| [out] | errorCode | If loading fails, contains the errno. |
true on success, false on failure. | QString WorkspaceState::personalThemesPath | ( | ) | const |
Get the path to the personal themes directory.
Mirrors get_extcap_pers_dir() but stays UI-only. Layout: Windows: APPDATA%\Wireshark\themes Unix: ~/.local/lib/wireshark/themes
Unlike built-in themes (which live under :/themes/<name>/theme.jsonc), personal themes are plain *.jsonc files dropped directly into this directory. The filename stem (without .jsonc) becomes the theme's internal name; for example, mytheme.jsonc yields internalName "mytheme".
The directory is not created here. Callers should treat a missing directory as "no personal themes" rather than an error.
| QStringList WorkspaceState::recentCaptureFilenames | ( | ) | const |
Get just the filenames of recent capture files.
Convenience method for code that only needs the paths.
| const QList< RecentFileInfo > & WorkspaceState::recentCaptureFiles | ( | ) | const |
Get the list of recently opened capture files.
| QString WorkspaceState::recentCommonFilePath | ( | ) | const |
Get the path to the recent_common file.
|
signal |
Emitted when a file's status (size/accessibility) is updated.
| filename | The file whose status was updated. |
| QString WorkspaceState::recentProfileFilePath | ( | ) | const |
Get the path to the profile-specific recent file.
| void WorkspaceState::removeRecentCaptureFile | ( | const QString & | filePath | ) |
Remove a capture file from the recent files list.
| filePath | The path to remove. |