Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
Signals | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
WorkspaceState Class Reference

Manages workspace state that persists between sessions. More...

#include <workspace_state.h>

Inheritance diagram for WorkspaceState:

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

 WorkspaceState (const WorkspaceState &)=delete
 
WorkspaceStateoperator= (const WorkspaceState &)=delete
 
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.
 
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 WorkspaceStateinstance ()
 Returns the singleton instance.
 

Protected Member Functions

 WorkspaceState (QObject *parent=nullptr)
 

Detailed Description

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.

Member Function Documentation

◆ addRecentCaptureFile()

void WorkspaceState::addRecentCaptureFile ( const QString &  filePath)

Add a capture file to the recent files list.

Parameters
filePathThe path to the capture file.

◆ instance()

WorkspaceState * WorkspaceState::instance ( )
static

Returns the singleton instance.

Thread-safe in C++11 and later (Meyer's Singleton).

◆ loadCommonState()

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.

Parameters
[out]errorPathIf loading fails, contains the path that failed.
[out]errorCodeIf loading fails, contains the errno.
Returns
true on success, false on failure.

◆ recentCaptureFilenames()

QStringList WorkspaceState::recentCaptureFilenames ( ) const

Get just the filenames of recent capture files.

Convenience method for code that only needs the paths.

Returns
List of file paths, most recent last.

◆ recentCaptureFiles()

const QList< RecentFileInfo > & WorkspaceState::recentCaptureFiles ( ) const

Get the list of recently opened capture files.

Returns
List of file info structs, most recent last.

◆ recentCommonFilePath()

QString WorkspaceState::recentCommonFilePath ( ) const

Get the path to the recent_common file.

Returns
Full path to the recent_common file.

◆ recentFileStatusChanged

void WorkspaceState::recentFileStatusChanged ( const QString &  filename)
signal

Emitted when a file's status (size/accessibility) is updated.

Parameters
filenameThe file whose status was updated.

◆ recentProfileFilePath()

QString WorkspaceState::recentProfileFilePath ( ) const

Get the path to the profile-specific recent file.

Returns
Full path to the recent file for the current profile.

◆ removeRecentCaptureFile()

void WorkspaceState::removeRecentCaptureFile ( const QString &  filePath)

Remove a capture file from the recent files list.

Parameters
filePathThe path to remove.

The documentation for this class was generated from the following files: