gui::Settings Class Reference

Saving and loading settings. More...

#include <settings.h>

List of all members.

Public Slots

void flush ()
QString readExpand (const QString &key, const QString &defValue=QString::null)
QString read (const QString &key, const QString &defValue=QString::null)
bool readBool (const QString &key, bool defValue=false)
int readNum (const QString &key, int defValue=0)
void write (const QString &key, const QString &value)
void write (const QString &key, int value)
void remove (const QString &key)
void removeAll (const QString &key)
QString expand (QString s)
QString getFullPathName (const QString &nameOfPath, QString fileName=QString::null, const QString &prefix=QString::null)

Signals

void settingChanged (QString)

Public Member Functions

 ~Settings ()
void saveWindow (QWidget *win, const QString &name)
void restoreWindow (QWidget *win, const QString &name)
void saveSplitter (QSplitter *spl, const QString &name)
void restoreSplitter (QSplitter *spl, const QString &name)
QStringList readPath (const QString &name, const QString &prefix="path/")
QStringList readList (const QString &name, const QString &separator=",")

Static Public Member Functions

static SettingsgetInstance ()

Private Member Functions

 Settings ()
void init ()
void initSettings ()

Private Attributes

QSettings * set
StaticSettingsstaticSet

Detailed Description

Saving and loading settings.

Class managing settings, saving and loading single settings or window states


Constructor & Destructor Documentation

gui::Settings::~Settings (  ) 

Default destructor

References staticSet.

gui::Settings::Settings (  )  [private]

Default constructor

References init().

Referenced by getInstance().


Member Function Documentation

QString gui::Settings::expand ( QString  s  )  [slot]

Expand environment variables in given string (like $HOME, etc ..)

Parameters:
s String to expand
Returns:
QString with variables expanded

References gui::APP_PATH_VAR, appPath, and gui::DATA_PATH_VAR.

Referenced by readExpand(), and readPath().

void gui::Settings::flush (  )  [slot]

flushes settings, saving all changes to disk

References initSettings(), and staticSet.

QString gui::Settings::getFullPathName ( const QString &  nameOfPath,
QString  fileName = QString::null,
const QString &  prefix = QString::null 
) [slot]

Given name of the file, finds and returns full path to the file, considering all relevant settings

See also:
readPath
Parameters:
nameOfPath Name of paths in settings for this file (e.g. "icon")
fileName Name of file. If not specified, the path itself is the filename we want to find
prefix Path prefix (Can be specified if desired to read from different configuration key than default)
Returns:
QString with full path to the file, or NULL if no file found in path

References debug::DBG_WARN, guiPrintDbg, Q_OUT, and readPath().

Referenced by gui::PropertyModeController::PropertyModeController().

Settings * gui::Settings::getInstance (  )  [static]

Return Instance of Settings. Ensures only one instance of Settings exists at any time (singleton) If no instance exists, it is created.

Returns:
existing Settings object

References gui::globalSettings, and Settings().

void gui::Settings::init (  )  [private]

private initialization function

References initSettings().

Referenced by Settings().

void gui::Settings::initSettings (  )  [private]

creates and inits new QSettings Object. Set paths to config files

References appPath, CONFIG_DIR, gui::CONFIG_FILE, debug::DBG_ERR, guiPrintDbg, Q_OUT, staticSet, and gui::StaticSettings::tryLoad().

Referenced by flush(), and init().

QString gui::Settings::read ( const QString &  key,
const QString &  defValue = QString::null 
) [slot]

Read settings with given key from configuration file and return as QString

Parameters:
key Key to read from settings
defValue default value to use if key not found in settings.
Returns:
Value of given setting

References gui::APP_KEY, gui::StaticSettings::readEntry(), and staticSet.

Referenced by gui::IconCache::IconCache(), main(), gui::PageSpace::PageSpace(), readBool(), readExpand(), readList(), readNum(), readPath(), gui::StringOption::readValue(), restoreSplitter(), and restoreWindow().

bool gui::Settings::readBool ( const QString &  key,
bool  defValue = false 
) [slot]

Read settings with given key from configuration file and return as bool

Parameters:
key Key to read from settings
defValue default value to use if key not found in settings.
Returns:
Value of given setting (true or false)

References read().

Referenced by gui::CommandWindow::reloadSettings().

QString gui::Settings::readExpand ( const QString &  key,
const QString &  defValue = QString::null 
) [slot]

Read settings with given key from configuration file and return as QString Any environment variable references (in form $VARIABLE) are expanded in the string.

Note:
Some internal variables (beginning with $PDFEDIT_) can override corresponding environment variables. See documentation for details on them
Parameters:
key Key to read from settings
defValue default value to use if key not found in settings.
Returns:
Value of given setting

References expand(), and read().

Referenced by gui::CommandWindow::addCommand(), gui::CommandWindow::addError(), gui::CommandWindow::addString(), gui::CommandWindow::loadHistory(), and gui::CommandWindow::saveHistory().

QStringList gui::Settings::readList ( const QString &  name,
const QString &  separator = "," 
)

Read list of values from config file and return as string list. List elements are expected to be separated by defined separator (default is comma)

Parameters:
name Identifier of list in config file
separator String separating items in the list
Returns:
QStringList containing items from list

References read().

int gui::Settings::readNum ( const QString &  key,
int  defValue = 0 
) [slot]

Read settings with given key from configuration file and return as integer

Parameters:
key Key to read from settings
defValue default value to use if key not found in settings.
Returns:
Value of given setting

References read().

Referenced by gui::CommandWindow::CommandWindow(), gui::PageSpace::getResizingZone(), and gui::PageSpace::setSelectionMode().

QStringList gui::Settings::readPath ( const QString &  name,
const QString &  prefix = "path/" 
)

Read path list element from config file. Expands variables ($HOME, etc ...) and return as string list. Path elements are expected to be separated by semicolon. Trailing slashes are removed from path elements.

Parameters:
name Identifier of path in config file
prefix Path prefix (Can be specified if desired to read from different configuration key than default "path"/)
Returns:
QStringList containing expanded path directories

References expand(), and read().

Referenced by getFullPathName(), gui::HelpWindow::HelpWindow(), gui::IconCache::IconCache(), and gui::BaseConsole::runInitScript().

void gui::Settings::remove ( const QString &  key  )  [slot]

Remove key from user settings, effectively restoring the setting to its default value

Parameters:
key Key to remove
void gui::Settings::removeAll ( const QString &  key  )  [slot]

Remove all keys directly under specified key according to hiararchic structure

Parameters:
key Key to remove
void gui::Settings::restoreSplitter ( QSplitter *  spl,
const QString &  name 
)

Restore splitter positions from setting.

Parameters:
spl Splitter to be resized
name Name of key to be used in configuration

References util::explode(), and read().

Referenced by gui::CommandWindow::restoreWindowState().

void gui::Settings::restoreWindow ( QWidget *  win,
const QString &  name 
)

Restore window/widget size and position from setting.

Parameters:
win Widget that will be resized and moved
name Name of key to be used in configuration

References util::explode(), and read().

Referenced by gui::AddItemDialog::AddItemDialog(), and gui::HelpWindow::HelpWindow().

void gui::Settings::saveSplitter ( QSplitter *  spl,
const QString &  name 
)

Save splitter positions to settings.

Parameters:
spl Splitter to save positions
name Name of key to be used in configuration

References write().

Referenced by gui::CommandWindow::saveWindowState().

void gui::Settings::saveWindow ( QWidget *  win,
const QString &  name 
)

Save window/widget size and position to settings.

Parameters:
win Widget that will have it's size and position stored
name Name of key to be used in configuration

References write().

Referenced by gui::HelpWindow::~HelpWindow().

void gui::Settings::settingChanged ( QString   )  [signal]

Signal emitted when any setting is changed. Key of changed settings is sent. Can be used to monitor settings changes

Referenced by write().

void gui::Settings::write ( const QString &  key,
int  value 
) [slot]

Write settings with given key and value to configuration

Parameters:
key Key to write to settings
value Value to write to settings

References gui::APP_KEY, and settingChanged().

void gui::Settings::write ( const QString &  key,
const QString &  value 
) [slot]

Write settings with given key and value to configuration

Parameters:
key Key to write to settings
value Value to write to settings

References gui::APP_KEY, and settingChanged().

Referenced by main(), saveSplitter(), saveWindow(), gui::CommandWindow::setHistoryFile(), gui::CommandWindow::setHistorySize(), gui::PageSpace::setResizingZone(), and gui::StringOption::writeValue().


Member Data Documentation

QSettings* gui::Settings::set [private]

Settings object used to load configuration These settings takle precedence before staticSettings

Settings object used to load static configuration (menu, etc ...) These settings are never changed (and never written)

Referenced by flush(), initSettings(), read(), and ~Settings().


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