mupp 1.1.0
Loading...
Searching...
No Matches
PmuppAdmin Class Reference

Main administration class for mupp configuration management. More...

#include <PmuppAdmin.h>

Inheritance diagram for PmuppAdmin:
Collaboration diagram for PmuppAdmin:

Public Member Functions

 PmuppAdmin ()
 Constructor. Loads configuration from mupp_startup.xml.
 
virtual ~PmuppAdmin ()
 Destructor. Saves recent files list before destruction.
 
void addRecentFile (const QString str)
 Adds a file to the recent files list.
 
int getNumRecentFiles ()
 Gets the number of recent files.
 
QString getRecentFile (int idx)
 Gets a recent file path by index.
 
int getNoOfMarkers ()
 Gets the number of configured markers.
 
QVector< PmuppMarkergetMarkers ()
 Gets all markers.
 
PmuppMarker getMarker (int idx)
 Gets a marker definition by index.
 
int getNoOfColors ()
 Gets the number of configured colors.
 
QVector< PmuppColorgetColors ()
 Gets all colors.
 
void getColor (QString name, int &r, int &g, int &b)
 Gets a color by name.
 
void getColor (int idx, int &r, int &g, int &b)
 Gets a color by index.
 
bool getIgnoreThemeAutoDetection ()
 Checks if theme auto-detection should be ignored.
 
bool getDarkThemeIconsMenuFlag ()
 Checks if dark theme icons should be used for menus.
 
bool getDarkThemeIconsToolbarFlag ()
 Checks if dark theme icons should be used for toolbars.
 
void setIgnoreThemeAutoDetection (const bool theme)
 Sets the theme auto-detection preference.
 
void setThemeIconsMenu (const bool theme)
 Sets the menu icon theme preference.
 
void setThemeIconsToolbar (const bool theme)
 Sets the toolbar icon theme preference.
 
void setMarker (const int marker, const double size)
 Adds a marker definition to the configuration.
 
void setColor (const int r, const int g, const int b, QString name="")
 Adds a color definition to the configuration.
 

Private Member Functions

void saveRecentFiles ()
 Saves the recent files list to the configuration file.
 
void createMuppStartupFile ()
 Creates a default mupp_startup.xml configuration file.
 

Private Attributes

QVector< QString > fRecentFile
 ring buffer of recent file paths (max MAX_RECENT_FILES)
 
bool fIgnoreThemeAutoDetection {false}
 flag to override automatic theme detection
 
bool fDarkThemeIconsMenu {false}
 flag for dark theme menu icons
 
bool fDarkThemeIconsToolbar {false}
 flag for dark theme toolbar icons
 
QVector< PmuppMarkerfMarker
 vector of configured plot markers
 
QVector< PmuppColorfColor
 vector of configured plot colors
 

Friends

class PmuppAdminXMLParser
 

Detailed Description

Main administration class for mupp configuration management.

The PmuppAdmin class manages all configuration settings and user preferences for the mupp application. It loads settings from the XML startup file (mupp_startup.xml) and provides access to:

  • Recent file history (up to MAX_RECENT_FILES entries)
  • Plot appearance settings (markers and colors)
  • Theme preferences for UI icons

Configuration file search order:

  1. ./mupp_startup.xml (local directory)
  2. $HOME/.musrfit/mupp/mupp_startup.xml (user home)
  3. $MUSRFITPATH/mupp_startup.xml (installation directory)
  4. $ROOTSYS/bin/mupp_startup.xml (ROOT installation)

If no configuration file is found, a default one is created in the user's home directory (~/.musrfit/mupp/).

The class automatically saves the recent file list when destroyed, updating the configuration file with the current session's file history.

Definition at line 323 of file PmuppAdmin.h.

Constructor & Destructor Documentation

◆ PmuppAdmin()

PmuppAdmin::PmuppAdmin ( )

Constructor. Loads configuration from mupp_startup.xml.

Constructor for PmuppAdmin.

Initializes the administration object and searches for a configuration file in multiple standard locations. The search proceeds in order:

  1. Current directory (./mupp_startup.xml)
  2. User home directory ($HOME/.musrfit/mupp/mupp_startup.xml)
  3. MUSRFITPATH directory ($MUSRFITPATH/mupp_startup.xml)
  4. ROOTSYS directory ($ROOTSYS/bin/mupp_startup.xml)

If no configuration file is found, creates a default one in the user's home directory using the embedded resource template.

The constructor loads all configuration settings including recent files, markers, colors, and theme preferences via the PmuppAdminXMLParser.

Definition at line 388 of file PmuppAdmin.cpp.

◆ ~PmuppAdmin()

PmuppAdmin::~PmuppAdmin ( )
virtual

Destructor. Saves recent files list before destruction.

Destructor for PmuppAdmin.

Saves the current recent file list to the configuration file before destruction. This ensures that the file history is preserved across application sessions.

Definition at line 442 of file PmuppAdmin.cpp.

Member Function Documentation

◆ addRecentFile()

void PmuppAdmin::addRecentFile ( const QString str)

Adds a file to the recent files list.

Parameters
strthe file path to add

Adds a file path to the front of the recent files ring buffer. If the file is already in the list, it is not added again (no duplicates). The list is limited to MAX_RECENT_FILES entries; older entries are removed when the limit is exceeded.

Parameters
strthe full path and filename to add to recent files

Definition at line 458 of file PmuppAdmin.cpp.

◆ createMuppStartupFile()

void PmuppAdmin::createMuppStartupFile ( )
private

Creates a default mupp_startup.xml configuration file.

Called when no configuration file is found. Creates the file in $HOME/.musrfit/mupp/ using the embedded resource template.

This method is called when no configuration file is found in any of the standard locations. It creates a new default configuration file in the user's home directory ($HOME/.musrfit/mupp/mupp_startup.xml).

The implementation:

  1. Creates the directory $HOME/.musrfit/mupp if it doesn't exist
  2. Loads the default template from embedded resources (mupp_startup.xml.in)
  3. Writes the template to the user's home directory

The default configuration includes standard marker styles, color definitions, and empty recent file list, providing a working baseline for new users or clean installations.

Definition at line 722 of file PmuppAdmin.cpp.

◆ getColor() [1/2]

void PmuppAdmin::getColor ( int idx,
int & r,
int & g,
int & b )

Gets a color by index.

Retrieves a color by index.

Parameters
idxzero-based index into the color list
routput parameter: red component (0-255, or -1 if invalid)
goutput parameter: green component (0-255, or -1 if invalid)
boutput parameter: blue component (0-255, or -1 if invalid)

Returns the RGB values of the color at the specified index in the color list. If the index is out of range, all RGB components are set to -1.

Parameters
idxzero-based index into the color list
routput parameter: red component (0-255, or -1 if invalid index)
goutput parameter: green component (0-255, or -1 if invalid index)
boutput parameter: blue component (0-255, or -1 if invalid index)

Definition at line 556 of file PmuppAdmin.cpp.

◆ getColor() [2/2]

void PmuppAdmin::getColor ( QString name,
int & r,
int & g,
int & b )

Gets a color by name.

Retrieves a color by name.

Parameters
namethe color name to search for
routput parameter: red component (0-255, or -1 if not found)
goutput parameter: green component (0-255, or -1 if not found)
boutput parameter: blue component (0-255, or -1 if not found)

Searches for a color with the specified name and returns its RGB values. If the color is not found, all RGB components are set to -1.

Parameters
namethe name of the color to retrieve
routput parameter: red component (0-255, or -1 if not found)
goutput parameter: green component (0-255, or -1 if not found)
boutput parameter: blue component (0-255, or -1 if not found)

Definition at line 524 of file PmuppAdmin.cpp.

◆ getColors()

QVector< PmuppColor > PmuppAdmin::getColors ( )
inline

Gets all colors.

Returns
vector of all color definitions

Definition at line 384 of file PmuppAdmin.h.

◆ getDarkThemeIconsMenuFlag()

bool PmuppAdmin::getDarkThemeIconsMenuFlag ( )
inline

Checks if dark theme icons should be used for menus.

Returns
true if dark theme icons are enabled for menus

Definition at line 414 of file PmuppAdmin.h.

◆ getDarkThemeIconsToolbarFlag()

bool PmuppAdmin::getDarkThemeIconsToolbarFlag ( )
inline

Checks if dark theme icons should be used for toolbars.

Returns
true if dark theme icons are enabled for toolbars

Definition at line 420 of file PmuppAdmin.h.

◆ getIgnoreThemeAutoDetection()

bool PmuppAdmin::getIgnoreThemeAutoDetection ( )
inline

Checks if theme auto-detection should be ignored.

Returns
true if auto-detection is disabled, false otherwise

Definition at line 408 of file PmuppAdmin.h.

◆ getMarker()

PmuppMarker PmuppAdmin::getMarker ( int idx)

Gets a marker definition by index.

Retrieves a marker definition by index.

Parameters
idxzero-based index into the marker list
Returns
the marker definition, or default marker if index is out of range

Returns the marker at the specified index in the marker list. Markers are used to define the visual appearance of data points in plots.

Parameters
idxzero-based index into the marker list
Returns
the marker definition if index is valid, or a default marker otherwise

Definition at line 503 of file PmuppAdmin.cpp.

◆ getMarkers()

QVector< PmuppMarker > PmuppAdmin::getMarkers ( )
inline

Gets all markers.

Returns
vector of all marker definitions

Definition at line 365 of file PmuppAdmin.h.

◆ getNoOfColors()

int PmuppAdmin::getNoOfColors ( )
inline

Gets the number of configured colors.

Returns
the count of color definitions

Definition at line 378 of file PmuppAdmin.h.

◆ getNoOfMarkers()

int PmuppAdmin::getNoOfMarkers ( )
inline

Gets the number of configured markers.

Returns
the count of marker definitions

Definition at line 359 of file PmuppAdmin.h.

◆ getNumRecentFiles()

int PmuppAdmin::getNumRecentFiles ( )
inline

Gets the number of recent files.

Returns
the count of recent files stored (maximum MAX_RECENT_FILES)

Definition at line 346 of file PmuppAdmin.h.

◆ getRecentFile()

QString PmuppAdmin::getRecentFile ( int idx)

Gets a recent file path by index.

Retrieves a recent file path by index.

Parameters
idxzero-based index (0 is most recent)
Returns
the file path, or empty string if index is out of range

Returns the file path at the specified position in the recent files list. Index 0 refers to the most recently accessed file.

Parameters
idxzero-based index into the recent files list (0 is most recent)
Returns
the file path if index is valid, or an empty string otherwise

Definition at line 482 of file PmuppAdmin.cpp.

◆ saveRecentFiles()

void PmuppAdmin::saveRecentFiles ( )
private

Saves the recent files list to the configuration file.

Updates mupp_startup.xml with current recent file history while preserving other configuration settings.

Updates the mupp_startup.xml file with the current recent file list. The method first searches for a local configuration file in the current directory; if not found, it uses the user's home directory version ($HOME/.musrfit/mupp/mupp_startup.xml).

The implementation:

  1. Reads the entire configuration file into memory
  2. Removes all existing <path_file_name> entries
  3. Inserts current recent files list
  4. Writes the updated configuration back to disk

This preserves all other configuration settings while updating only the recent file history.

Definition at line 640 of file PmuppAdmin.cpp.

◆ setColor()

void PmuppAdmin::setColor ( const int r,
const int g,
const int b,
QString name = "" )

Adds a color definition to the configuration.

Parameters
rred component (0-255)
ggreen component (0-255)
bblue component (0-255)
nameoptional name for the color

Creates a new color with the specified RGB values and optional name, validates it, and adds it to the color list. RGB values must be in the range 0-255. Invalid colors are rejected with a warning.

Parameters
rred component (0-255)
ggreen component (0-255)
bblue component (0-255)
nameoptional name for the color (empty by default)

Definition at line 606 of file PmuppAdmin.cpp.

◆ setIgnoreThemeAutoDetection()

void PmuppAdmin::setIgnoreThemeAutoDetection ( const bool theme)
inline

Sets the theme auto-detection preference.

Parameters
themetrue to ignore auto-detection, false to enable it

Definition at line 426 of file PmuppAdmin.h.

◆ setMarker()

void PmuppAdmin::setMarker ( const int marker,
const double size )

Adds a marker definition to the configuration.

Parameters
markerthe marker code (1-49, ROOT style)
sizethe marker size multiplier

Creates a new marker with the specified code and size, validates it, and adds it to the marker list. Marker codes must be in the range 1-49 (following ROOT conventions). Invalid markers are rejected with a warning.

Parameters
markerthe marker code (1-49, ROOT style marker codes)
sizethe marker size multiplier

Definition at line 578 of file PmuppAdmin.cpp.

◆ setThemeIconsMenu()

void PmuppAdmin::setThemeIconsMenu ( const bool theme)
inline

Sets the menu icon theme preference.

Parameters
themetrue for dark theme icons, false for light theme icons

Definition at line 432 of file PmuppAdmin.h.

◆ setThemeIconsToolbar()

void PmuppAdmin::setThemeIconsToolbar ( const bool theme)
inline

Sets the toolbar icon theme preference.

Parameters
themetrue for dark theme icons, false for light theme icons

Definition at line 438 of file PmuppAdmin.h.

Friends And Related Symbol Documentation

◆ PmuppAdminXMLParser

friend class PmuppAdminXMLParser
friend

Definition at line 457 of file PmuppAdmin.h.

Member Data Documentation

◆ fColor

QVector<PmuppColor> PmuppAdmin::fColor
private

vector of configured plot colors

Definition at line 465 of file PmuppAdmin.h.

◆ fDarkThemeIconsMenu

bool PmuppAdmin::fDarkThemeIconsMenu {false}
private

flag for dark theme menu icons

Definition at line 462 of file PmuppAdmin.h.

◆ fDarkThemeIconsToolbar

bool PmuppAdmin::fDarkThemeIconsToolbar {false}
private

flag for dark theme toolbar icons

Definition at line 463 of file PmuppAdmin.h.

◆ fIgnoreThemeAutoDetection

bool PmuppAdmin::fIgnoreThemeAutoDetection {false}
private

flag to override automatic theme detection

Definition at line 461 of file PmuppAdmin.h.

◆ fMarker

QVector<PmuppMarker> PmuppAdmin::fMarker
private

vector of configured plot markers

Definition at line 464 of file PmuppAdmin.h.

◆ fRecentFile

QVector<QString> PmuppAdmin::fRecentFile
private

ring buffer of recent file paths (max MAX_RECENT_FILES)

Definition at line 459 of file PmuppAdmin.h.


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