• Settings
  • Settings Class

    (ScreenPlay::Settings)

    Global settings class for reading and writing settings. More...

    Header: #include <Settings>

    Public Functions

    Settings(const shared_ptr<ScreenPlay::GlobalVariables> &globalVariables, QObject *parent = nullptr)
    bool anonymousTelemetry() const
    bool autostart() const
    QString decoder() const
    QString gitBuildHash() const
    bool highPriorityStart() const
    QString language() const
    bool offlineMode() const
    bool pauseWallpaperWhenIngame() const
    bool silentStart() const
    QVersionNumber version() const

    Public Slots

    void setAnonymousTelemetry(bool anonymousTelemetry)
    void setAutostart(bool autostart)
    void setDecoder(QString decoder)
    void setGitBuildHash(QString gitBuildHash)
    void setHighPriorityStart(bool highPriorityStart)
    void setLanguage(QString language)
    void setOfflineMode(bool offlineMode)
    void setPauseWallpaperWhenIngame(bool pauseWallpaperWhenIngame)
    void setSilentStart(bool silentStart)
    void setupWidgetAndWindowPaths()
    void writeJsonFileFromResource(const QString &filename)
    bool writeSingleSettingConfig(QString name, QVariant value)

    Signals

    void anonymousTelemetryChanged(bool anonymousTelemetry)
    void autostartChanged(bool autostart)
    void decoderChanged(QString decoder)
    void gitBuildHashChanged(QString gitBuildHash)
    void highPriorityStartChanged(bool highPriorityStart)
    void languageChanged(QString language)
    void offlineModeChanged(bool offlineMode)
    void pauseWallpaperWhenIngameChanged(bool pauseWallpaperWhenIngame)
    void silentStartChanged(bool silentStart)

    Detailed Description

    Used for:

    Currently we save the regular settings (not the setup of the wallpaper and widgets) in two different locations. This can change in the future!

    Member Function Documentation

    Settings::Settings(const shared_ptr<ScreenPlay::GlobalVariables> &globalVariables, QObject *parent = nullptr)

    Constructor and sets up:

    1. Sets the git build hash via ScreenPlay.pro c++ define
    2. Checks the langauge via settings or system and available ones and installes a translator.
    3. Checks the paths for config folders in appdata
    4. Checks if settings.json and profiles.json are available. If first run it creates the default settings and profiles json.
    5. Parses the version and checks with the compiled one.
    6. Checks the absoluteStoragePath.
    7. Checks regisitry for steam plugin settings
    8. Parses autostart, anonymousTelemetry, highPriorityStart
    9. Checks ScreenPlayWallpaper and ScreenPlayWidgets executable paths.

    More errorchecking is needed here. For example when the proile or settings json cannot to parsed, use the default settings.

    [slot] void Settings::setupWidgetAndWindowPaths()

    To have a better developer experience we check if we use a debug version. Then we assume That the paths are the default QtCreator paths and set the widgets and wallpaper executable paths accordingly.

    [slot] void Settings::writeJsonFileFromResource(const QString &filename)

    Writes the default JsonFile from the resources and the given filename. Currently we have two default json files:

    [slot] bool Settings::writeSingleSettingConfig(QString name, QVariant value)

    Save a single value with a given name (key) into the settings.json. Returns true when successful otherise returns false.