Skip to content

Class ConfigHandler#

ClassList > ConfigHandler

Inherits the following classes: QObject

Public Attributes#

Type Name
setShowDesktopNotification
bool setShowStartupLaunchMessage
bool bool setUploadWithoutConfirmation
bool bool bool showSelectionGeometryHideTime

Public Functions#

Type Name
CONFIG_GETTER_SETTER (userColors, setUserColors, QVector< QColor >)
CONFIG_GETTER_SETTER (predefinedColorPaletteLarge, setPredefinedColorPaletteLarge, bool)
bool CONFIG_GETTER_SETTER (allowMultipleGuiInstances, setAllowMultipleGuiInstances, bool)
bool bool CONFIG_GETTER_SETTER (historyConfirmationToDelete, setHistoryConfirmationToDelete, bool)
bool bool bool CONFIG_GETTER_SETTER (ignoreUpdateToVersion, setIgnoreUpdateToVersion, QString)
ConfigHandler ()
void checkAndHandleError () const
Parse the configuration to find any errors in it.
bool checkForErrors (AbstractLogger * log=nullptr) const
bool checkSemantics (AbstractLogger * log=nullptr, QList< QString > * offenders=nullptr) const
Check each config value semantically.
bool checkShortcutConflicts (AbstractLogger * log=nullptr) const
Check if there are multiple actions with the same shortcut.
bool checkUnrecognizedSettings (AbstractLogger * log=nullptr, QList< QString > * offenders=nullptr) const
Parse the config to find settings with unrecognized names.
QString configFilePath () const
QString errorMessage () const
Error message that can be used by other classes as well.
QString filenamePatternDefault ()
bool hasError () const
Return if the config contains an error.
QSet< QString > keysFromGroup (const QString & group) const
Return keys from group group . Use CONFIG_GROUP_GENERAL (General) for general settings.
void remove (const QString & key)
void resetValue (const QString & key)
void setAllTheButtons ()
void setDefaultSettings ()
void setErrorState (bool error) const
Update the tracked error state of the config.
bool setShortcut (const QString & actionName, const QString & shortcut)
void setStartupLaunch (const bool start)
void setToolSize (CaptureTool::Type toolType, int size)
void setValue (const QString & key, const QVariant & value)
QString shortcut (const QString & actionName)
bool bool bool int bool startupLaunch ()
int toolSize (CaptureTool::Type toolType)
QVariant value (const QString & key) const

Public Static Functions#

Type Name
ConfigHandler * getInstance ()
Serves as an object to which slots can be connected.
QSet< QString > & recognizedGeneralOptions ()
QSet< QString > & recognizedShortcutNames ()

Public Attributes Documentation#

variable setShowDesktopNotification#

ConfigHandler::setShowDesktopNotification;

variable setShowStartupLaunchMessage#

bool ConfigHandler::setShowStartupLaunchMessage;

variable setUploadWithoutConfirmation#

bool bool ConfigHandler::setUploadWithoutConfirmation;

variable showSelectionGeometryHideTime#

bool bool bool ConfigHandler::showSelectionGeometryHideTime;

Public Functions Documentation#

function CONFIG_GETTER_SETTER [1/5]#

ConfigHandler::CONFIG_GETTER_SETTER (
    userColors,
    setUserColors,
    QVector< QColor >
) 

function CONFIG_GETTER_SETTER [2/5]#

ConfigHandler::CONFIG_GETTER_SETTER (
    predefinedColorPaletteLarge,
    setPredefinedColorPaletteLarge,
    bool
) 

function CONFIG_GETTER_SETTER [3/5]#

bool ConfigHandler::CONFIG_GETTER_SETTER (
    allowMultipleGuiInstances,
    setAllowMultipleGuiInstances,
    bool
) 

function CONFIG_GETTER_SETTER [4/5]#

bool bool ConfigHandler::CONFIG_GETTER_SETTER (
    historyConfirmationToDelete,
    setHistoryConfirmationToDelete,
    bool
) 

function CONFIG_GETTER_SETTER [5/5]#

bool bool bool ConfigHandler::CONFIG_GETTER_SETTER (
    ignoreUpdateToVersion,
    setIgnoreUpdateToVersion,
    QString
) 

function ConfigHandler#

explicit ConfigHandler::ConfigHandler () 

function checkAndHandleError#

Parse the configuration to find any errors in it.

void ConfigHandler::checkAndHandleError () const

If the error state changes as a result of the check, it will perform the appropriate action, e.g. notify the user.

See also: ConfigHandler::setErrorState for all the actions.

function checkForErrors#

bool ConfigHandler::checkForErrors (
    AbstractLogger * log=nullptr
) const

function checkSemantics#

Check each config value semantically.

bool ConfigHandler::checkSemantics (
    AbstractLogger * log=nullptr,
    QList< QString > * offenders=nullptr
) const

Parameters:

  • log Destination for error log output.
  • offenders Destination for the semantically invalid keys.

Returns:

Whether the config passes this check.

function checkShortcutConflicts#

Check if there are multiple actions with the same shortcut.

bool ConfigHandler::checkShortcutConflicts (
    AbstractLogger * log=nullptr
) const

Returns:

Whether the config passes this check.

Note:

It is not considered a conflict if action A uses shortcut S because it is the flameshot default (not because the user explicitly configured it), and action B uses the same shortcut.

function checkUnrecognizedSettings#

Parse the config to find settings with unrecognized names.

bool ConfigHandler::checkUnrecognizedSettings (
    AbstractLogger * log=nullptr,
    QList< QString > * offenders=nullptr
) const

Returns:

Whether the config passes this check.

Note:

An unrecognized option is one that is not included in recognizedGeneralOptions or recognizedShortcutNames depending on the group the option belongs to.

function configFilePath#

QString ConfigHandler::configFilePath () const

function errorMessage#

QString ConfigHandler::errorMessage () const

function filenamePatternDefault#

QString ConfigHandler::filenamePatternDefault () 

function hasError#

Return if the config contains an error.

bool ConfigHandler::hasError () const

If an error check is due, it will be performed.

function keysFromGroup#

QSet< QString > ConfigHandler::keysFromGroup (
    const QString & group
) const

function remove#

void ConfigHandler::remove (
    const QString & key
) 

function resetValue#

void ConfigHandler::resetValue (
    const QString & key
) 

function setAllTheButtons#

void ConfigHandler::setAllTheButtons () 

function setDefaultSettings#

void ConfigHandler::setDefaultSettings () 

function setErrorState#

Update the tracked error state of the config.

void ConfigHandler::setErrorState (
    bool error
) const

Parameters:

  • error The new error state.

The error state is tracked so that signals are not emitted and the user is not spammed every time the config file changes. Instead, only changes in error state get reported.

function setShortcut#

bool ConfigHandler::setShortcut (
    const QString & actionName,
    const QString & shortcut
) 

function setStartupLaunch#

void ConfigHandler::setStartupLaunch (
    const bool start
) 

function setToolSize#

void ConfigHandler::setToolSize (
    CaptureTool::Type toolType,
    int size
) 

function setValue#

void ConfigHandler::setValue (
    const QString & key,
    const QVariant & value
) 

function shortcut#

QString ConfigHandler::shortcut (
    const QString & actionName
) 

function startupLaunch#

bool bool bool int bool ConfigHandler::startupLaunch () 

function toolSize#

int ConfigHandler::toolSize (
    CaptureTool::Type toolType
) 

function value#

QVariant ConfigHandler::value (
    const QString & key
) const

Public Static Functions Documentation#

function getInstance#

static ConfigHandler * ConfigHandler::getInstance () 

function recognizedGeneralOptions#

static QSet< QString > & ConfigHandler::recognizedGeneralOptions () 

function recognizedShortcutNames#

static QSet< QString > & ConfigHandler::recognizedShortcutNames ()