Class sh::settings::SettingsManager

class sh::settings::SettingsManager : public QObject, public sh::base::Singleton

Manager for Shallot settings.

This is the more flexible way of shallot customization. It includes everything you see in the ‘Manage saved settings’ or ‘Save settings’.

See sh::settings::Setting for more.

Public Functions

void applyPerEurlSettingsToFileView(sh::ui::FileView *list)

Applies all stored settings, which are per-eurl to a fileview.

void applyGlobalSettingsToFileView(sh::ui::FileView *list)

Applies all stored settings, which are global to a fileview.

void applyPerEurlSettingsToMainWindow()

Applies all stored settings, which are per-eurl to main window.

void applyGlobalSettingsToMainWindow()

Applies all stored settings, which are global to a main window.

QList<sh::settings::ProfileNode*> getNodesForProfile(QString profile)

Returns a list of all stored settings (as ProfileNodes) for a given profile.

sh::settings::ProfileNode *getNodeByNodeId(QString nodeId)

Searches and returns a ProfileNode by id.

std::shared_ptr<sh::settings::Setting> getSettingByName(QString name)

Searches and returns a Setting by name.

QList<std::shared_ptr<sh::settings::Setting>> getAllSettings()

Returns a list of all available settings, primarily sorted by group.

QStringList getProfileList()

Returns a list of all existing profiles.

void removeProfile(QString profile)

Removes a profile (including all ProfileNodes inside it).

void removeNode(QString nodeId)

Removes a ProfileNode by id.

void storeProfile(std::shared_ptr<const sh::filesystem::Eurl> eurl, QString profilename, QMap<QString, QString> values, QMap<QString, int> onlyinfileviewindex, bool withSubfolders, QStringList inheritFrom)

Stores one setting into a profile.

~SettingsManager()
void doInitialize()

Executes singleton initialization.

void doShutdown()

Executes singleton shutdown.

void shutdown()

Shutdown down this singleton.

bool isAlive()

Returns if this singleton is alive (true until its shutdown begins).

Signals

void profilesChanged()

Triggered when the list of profiles or the nodes inside it change.

Can also be triggered when nothing really changed!

Private Functions

void applyToFileView(sh::ui::FileView *list, QMap<QString, QString> settings)

Applies some settings (as string tuples) to a fileview.

void applyToMainWindow(QMap<QString, QString> settings)

Applies some settings (as string tuples) to main window.

QMap<QString, QString> _getSettings(std::shared_ptr<const sh::filesystem::Eurl> eurl, QString profilename, int fileviewindex, bool directNode = true)

Computes all effective settings (including inheritance and sub-directories) for a given situation (global or eurl-bound; fileview- or mainwindow-bound) and returns it as string tuples.

Parameters
  • eurl: The directory to consider as current (or nullptr for global settings).

  • profilename: The current profile.

  • fileviewindex: The fileview index (or -1 for mainwindow-bound settings).

  • directNode: If the given directory is to be considered as the real current directory (not e.g. a parent).

QList<_SettingsFinderStructure> _getSettings_flat(std::shared_ptr<const sh::filesystem::Eurl> eurl, QString profilename)

Used internally by _getSettings().

void invalidateCache()

Invalidates the _getSettings cache.

void readStoredProfiles()

Reads all profiles (including all setting nodes) from filesystem.

SettingsManager()

Private Members

QMap<QString, QMap<QString, QString>> _getSettings_cache
QMap<QString, std::shared_ptr<sh::settings::Setting>> _settings
QMap<std::shared_ptr<const sh::filesystem::Eurl>, QMap<QString, QList<sh::settings::ProfileNode*>>> _profileNodes
QMap<QString, sh::settings::ProfileNode*> _profileNodesById
QList<QString> _profileNames

Friends

friend class sh::settings::SettingsRegistration
class _MyHandler : public QXmlDefaultHandler

Used internally for reading profile node XMLs.

Public Functions

_MyHandler(sh::settings::ProfileNode *node, QString filename)
bool startElement(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts)
bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName)

Private Functions

void throwError()

Private Members

bool _stateStarted = true
bool _stateInProfile = false
sh::settings::ProfileNode *_node
QString _filename
class _SettingsFinderStructure

Used internally by _getSettings().

Public Functions

_SettingsFinderStructure(QMap<QString, QString> settings, QMap<QString, int> onlyinfileviewindexes, QStringList inheritFrom, bool withSubfolders)
_SettingsFinderStructure()

Public Members

QMap<QString, QString> _settings
QMap<QString, int> _onlyinfileviewindexes
QStringList _inheritFrom
bool _withSubfolders
int _onlyFileviewIndex