File indexing completed on 2024-04-21 14:43:48
0001 /* GCompris - ApplicationSettings.h 0002 * 0003 * SPDX-FileCopyrightText: 2014 Johnny Jazeix <jazeix@gmail.com> 0004 * 0005 * Authors: 0006 * Johnny Jazeix <jazeix@gmail.com> 0007 * 0008 * SPDX-License-Identifier: GPL-3.0-or-later 0009 */ 0010 0011 #ifndef APPLICATIONSETTINGS_H 0012 #define APPLICATIONSETTINGS_H 0013 0014 #include <QObject> 0015 #include <QQmlEngine> 0016 0017 #include <QSettings> 0018 #include <QStandardPaths> 0019 0020 #include <config.h> 0021 0022 #define GC_DEFAULT_LOCALE "system" 0023 0024 /** 0025 * @class ApplicationSettings 0026 * @short Singleton that contains GCompris' persistent settings. 0027 * @ingroup infrastructure 0028 * 0029 * Settings are persisted using QSettings, which stores them in platform 0030 * specific locations. 0031 * 0032 * The settings are subdivided in different groups of settings. 0033 * 0034 * <em>[General]</em> settings are mostly changeable by users in the DialogConfig 0035 * dialog. 0036 * 0037 * <em>[Admin]</em> and <em>[Internal]</em> settings are not changeable by the 0038 * user and used for internal purposes. Should only be changed if you really know 0039 * what you are doing. 0040 * 0041 * The <em>[Favorite]</em> group is auto-generated from the favorite activities 0042 * selected by a user. 0043 * 0044 * The <em>[Levels]</em> group is auto-generated from the levels chosen by 0045 * a user (if the activity provides multiple datasets). 0046 * 0047 * Besides these global settings there is one group for each activity that 0048 * stores persistent settings. 0049 * 0050 * Settings defaults are defined in the source code. 0051 * 0052 * @sa DialogActivityConfig 0053 */ 0054 class ApplicationSettings : public QObject 0055 { 0056 Q_OBJECT 0057 0058 /* General group */ 0059 0060 /** 0061 * Whether audio voices/speech should be enabled. 0062 */ 0063 Q_PROPERTY(bool isAudioVoicesEnabled READ isAudioVoicesEnabled WRITE setIsAudioVoicesEnabled NOTIFY audioVoicesEnabledChanged) 0064 0065 /** 0066 * Whether audio effects should be enabled. 0067 */ 0068 Q_PROPERTY(bool isAudioEffectsEnabled READ isAudioEffectsEnabled WRITE setIsAudioEffectsEnabled NOTIFY audioEffectsEnabledChanged) 0069 0070 /** Whether background music should be enabled. 0071 */ 0072 Q_PROPERTY(bool isBackgroundMusicEnabled READ isBackgroundMusicEnabled WRITE setIsBackgroundMusicEnabled NOTIFY backgroundMusicEnabledChanged) 0073 0074 /** 0075 * Whether GCompris should run in fullscreen mode. 0076 */ 0077 Q_PROPERTY(bool isFullscreen READ isFullscreen WRITE setFullscreen NOTIFY fullscreenChanged) 0078 0079 /** 0080 * Window Height on Application's Startup 0081 */ 0082 Q_PROPERTY(quint32 previousHeight READ previousHeight WRITE setPreviousHeight NOTIFY previousHeightChanged) 0083 0084 /** 0085 * Window Width on Application's Startup 0086 */ 0087 Q_PROPERTY(quint32 previousWidth READ previousWidth WRITE setPreviousWidth NOTIFY previousWidthChanged) 0088 0089 /** 0090 * Whether on-screen keyboard should be enabled per default in activities 0091 * that use it. 0092 */ 0093 Q_PROPERTY(bool isVirtualKeyboard READ isVirtualKeyboard WRITE setVirtualKeyboard NOTIFY virtualKeyboardChanged) 0094 0095 /** 0096 * Locale string for currently active language. 0097 */ 0098 Q_PROPERTY(QString locale READ locale WRITE setLocale NOTIFY localeChanged) 0099 0100 /** 0101 * Currently selected font. 0102 */ 0103 Q_PROPERTY(QString font READ font WRITE setFont NOTIFY fontChanged) 0104 0105 /** 0106 * Whether currently active font is a shipped font (or a system font). 0107 * 0108 * Updated automatically. 0109 * @sa font 0110 */ 0111 Q_PROPERTY(bool isEmbeddedFont READ isEmbeddedFont WRITE setIsEmbeddedFont NOTIFY embeddedFontChanged) 0112 0113 /** 0114 * Font Capitalization 0115 * 0116 * Force all texts to be rendered in UpperCase, LowerCase or MixedCase (default) 0117 * @sa font 0118 */ 0119 Q_PROPERTY(quint32 fontCapitalization READ fontCapitalization WRITE setFontCapitalization NOTIFY fontCapitalizationChanged) 0120 0121 /** 0122 * Font letter spacing 0123 * 0124 * Change the letter spacing of all the texts 0125 * @sa font 0126 */ 0127 Q_PROPERTY(qreal fontLetterSpacing READ fontLetterSpacing WRITE setFontLetterSpacing NOTIFY fontLetterSpacingChanged) 0128 0129 /** 0130 * Minimum allowed value for font spacing letter. 0131 * 0132 * Constant value: +0.0 0133 */ 0134 Q_PROPERTY(qreal fontLetterSpacingMin READ fontLetterSpacingMin CONSTANT) 0135 0136 /** 0137 * Maximum allowed value for font spacing letter. 0138 * 0139 * Constant value: +8.0 0140 */ 0141 Q_PROPERTY(qreal fontLetterSpacingMax READ fontLetterSpacingMax CONSTANT) 0142 0143 /** 0144 * Whether downloads/updates of resource files should be done automatically, 0145 * without user-interaction. 0146 * 0147 * Note, that on Android GCompris currently can't distinguish Wifi 0148 * from mobile data connections (cf. Qt ticket #30394). 0149 */ 0150 Q_PROPERTY(bool isAutomaticDownloadsEnabled READ isAutomaticDownloadsEnabled WRITE setIsAutomaticDownloadsEnabled NOTIFY automaticDownloadsEnabledChanged) 0151 0152 /** 0153 * Minimum value for difficulty level filter. 0154 */ 0155 Q_PROPERTY(quint32 filterLevelMin READ filterLevelMin WRITE setFilterLevelMin NOTIFY filterLevelMinChanged) 0156 0157 /** 0158 * Maximum value for difficulty level filter. 0159 */ 0160 Q_PROPERTY(quint32 filterLevelMax READ filterLevelMax WRITE setFilterLevelMax NOTIFY filterLevelMaxChanged) 0161 0162 /** 0163 * Boolean to know if the difficulty level filter has been set via command-line option. 0164 * In this case, we hide the possibility to change the level in the configuration and we never override the levels in the GCompris config file. 0165 */ 0166 Q_PROPERTY(bool filterLevelOverridedByCommandLineOption READ filterLevelOverridedByCommandLineOption WRITE setFilterLevelOverridedByCommandLineOption NOTIFY filterLevelOverridedByCommandLineOptionChanged) 0167 0168 /** 0169 * Whether kiosk mode is currently active. 0170 */ 0171 Q_PROPERTY(bool isKioskMode READ isKioskMode WRITE setKioskMode NOTIFY kioskModeChanged) 0172 0173 /** 0174 * Whether the section selection row is visible in the menu view. 0175 */ 0176 Q_PROPERTY(bool sectionVisible READ sectionVisible WRITE setSectionVisible NOTIFY sectionVisibleChanged) 0177 0178 /** 0179 * When true a dialog will pop up when we try to exit asking for confirmation. In mobile devices, it will be true by default and on desktops, it will be false. 0180 */ 0181 Q_PROPERTY(bool exitConfirmation READ exitConfirmation WRITE setExitConfirmation NOTIFY exitConfirmationChanged) 0182 0183 /** 0184 * Current base font-size used for font scaling. 0185 * 0186 * This setting is the basis for application-wide font-scaling. A value 0187 * of 0 means to use the font-size as set by the application. Other values 0188 * between @ref baseFontSizeMin and @ref baseFontSizeMax enforce 0189 * font-scaling. 0190 * 0191 * @sa GCText.fontSize baseFontSizeMin baseFontSizeMax 0192 */ 0193 Q_PROPERTY(int baseFontSize READ baseFontSize WRITE setBaseFontSize NOTIFY baseFontSizeChanged) 0194 0195 /** 0196 * Stores the background music volume set by the user. 0197 */ 0198 Q_PROPERTY(qreal backgroundMusicVolume READ backgroundMusicVolume WRITE setBackgroundMusicVolume NOTIFY backgroundMusicVolumeChanged) 0199 0200 /** 0201 * Stores the audio effects volume set by the user. 0202 */ 0203 Q_PROPERTY(qreal audioEffectsVolume READ audioEffectsVolume WRITE setAudioEffectsVolume NOTIFY audioEffectsVolumeChanged) 0204 0205 /** 0206 * Minimum allowed value for font-scaling. 0207 * 0208 * Constant value: -7 0209 */ 0210 Q_PROPERTY(int baseFontSizeMin READ baseFontSizeMin CONSTANT) 0211 0212 /** 0213 * Maximum allowed value for font-scaling. 0214 * 0215 * Constant value: +7 0216 */ 0217 Q_PROPERTY(int baseFontSizeMax READ baseFontSizeMax CONSTANT) 0218 0219 // admin group 0220 0221 /** 0222 * Base-URL for resource downloads. 0223 * 0224 * @sa DownloadManager 0225 */ 0226 Q_PROPERTY(QString downloadServerUrl READ downloadServerUrl WRITE setDownloadServerUrl NOTIFY downloadServerUrlChanged) 0227 0228 /** 0229 * Path where resources are downloaded and stored. 0230 * 0231 * @sa DownloadManager 0232 */ 0233 Q_PROPERTY(QString cachePath READ cachePath WRITE setCachePath NOTIFY cachePathChanged) 0234 0235 /** 0236 * Return the platform specific path for storing data shared between apps 0237 * 0238 * On Android: /storage/emulated/0/GCompris (>= Android 4.2), 0239 * /storage/sdcard0/GCompris (< Android 4.2) 0240 * On Linux: $HOME/local/share/GCompris 0241 */ 0242 Q_PROPERTY(QString userDataPath READ userDataPath WRITE setUserDataPath NOTIFY userDataPathChanged) 0243 0244 /** 0245 * Define the renderer used. 0246 * Either openGL or software renderer (only for Qt >= 5.8) 0247 */ 0248 Q_PROPERTY(QString renderer READ renderer WRITE setRenderer NOTIFY rendererChanged) 0249 0250 /** 0251 * Stores the filtered background music playlist by the user. 0252 */ 0253 Q_PROPERTY(QStringList filteredBackgroundMusic READ filteredBackgroundMusic WRITE setFilteredBackgroundMusic NOTIFY filteredBackgroundMusicChanged) 0254 0255 // internal group 0256 Q_PROPERTY(quint32 exeCount READ exeCount WRITE setExeCount NOTIFY exeCountChanged) 0257 0258 // keep last version ran. If different than ApplicationInfo.GCVersionCode(), it means a new version is running 0259 Q_PROPERTY(int lastGCVersionRan READ lastGCVersionRan WRITE setLastGCVersionRan NOTIFY lastGCVersionRanChanged) 0260 0261 // no group 0262 Q_PROPERTY(bool isBarHidden READ isBarHidden WRITE setBarHidden NOTIFY barHiddenChanged) 0263 0264 public: 0265 /// @cond INTERNAL_DOCS 0266 #if defined(UBUNTUTOUCH) 0267 explicit ApplicationSettings(const QString &configPath = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) 0268 + "/gcompris/" + GCOMPRIS_APPLICATION_NAME + ".conf", 0269 QObject *parent = 0); 0270 #else 0271 explicit ApplicationSettings(const QString &configPath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) 0272 + "/gcompris/" + GCOMPRIS_APPLICATION_NAME + ".conf", 0273 QObject *parent = nullptr); 0274 #endif 0275 virtual ~ApplicationSettings(); 0276 // It is not recommended to create a singleton of Qml Singleton registered 0277 // object but we could not found a better way to let us access ApplicationInfo 0278 // on the C++ side. All our test shows that it works. 0279 static ApplicationSettings *getInstance() 0280 { 0281 if (!m_instance) { 0282 m_instance = new ApplicationSettings(); 0283 } 0284 return m_instance; 0285 } 0286 static QObject *applicationSettingsProvider(QQmlEngine *engine, 0287 QJSEngine *scriptEngine); 0288 0289 bool isAudioVoicesEnabled() const { return m_isAudioVoicesEnabled; } 0290 void setIsAudioVoicesEnabled(const bool newMode) 0291 { 0292 m_isAudioVoicesEnabled = newMode; 0293 Q_EMIT audioVoicesEnabledChanged(); 0294 } 0295 0296 bool isAudioEffectsEnabled() const { return m_isAudioEffectsEnabled; } 0297 void setIsAudioEffectsEnabled(const bool newMode) 0298 { 0299 m_isAudioEffectsEnabled = newMode; 0300 Q_EMIT audioEffectsEnabledChanged(); 0301 } 0302 0303 bool isBackgroundMusicEnabled() const { return m_isBackgroundMusicEnabled; } 0304 void setIsBackgroundMusicEnabled(const bool newMode) 0305 { 0306 m_isBackgroundMusicEnabled = newMode; 0307 Q_EMIT backgroundMusicEnabledChanged(); 0308 } 0309 0310 bool isFullscreen() const { return m_isFullscreen; } 0311 void setFullscreen(const bool newMode) 0312 { 0313 if (m_isFullscreen != newMode) { 0314 m_isFullscreen = newMode; 0315 Q_EMIT fullscreenChanged(); 0316 } 0317 } 0318 0319 quint32 previousHeight() const { return m_previousHeight; } 0320 void setPreviousHeight(quint32 height) 0321 { 0322 if (m_previousHeight != height) { 0323 m_previousHeight = height; 0324 Q_EMIT previousHeightChanged(); 0325 } 0326 } 0327 0328 quint32 previousWidth() const { return m_previousWidth; } 0329 void setPreviousWidth(quint32 width) 0330 { 0331 if (m_previousWidth != width) { 0332 m_previousWidth = width; 0333 Q_EMIT previousWidthChanged(); 0334 } 0335 } 0336 0337 bool isVirtualKeyboard() const { return m_isVirtualKeyboard; } 0338 void setVirtualKeyboard(const bool newMode) 0339 { 0340 m_isVirtualKeyboard = newMode; 0341 Q_EMIT virtualKeyboardChanged(); 0342 } 0343 0344 QString locale() const 0345 { 0346 return m_locale; 0347 } 0348 void setLocale(const QString &newLocale) 0349 { 0350 m_locale = newLocale; 0351 Q_EMIT localeChanged(); 0352 } 0353 0354 QString font() const { return m_font; } 0355 void setFont(const QString &newFont) 0356 { 0357 m_font = newFont; 0358 Q_EMIT fontChanged(); 0359 } 0360 0361 bool isEmbeddedFont() const { return m_isEmbeddedFont; } 0362 void setIsEmbeddedFont(const bool newIsEmbeddedFont) 0363 { 0364 m_isEmbeddedFont = newIsEmbeddedFont; 0365 Q_EMIT embeddedFontChanged(); 0366 } 0367 0368 quint32 fontCapitalization() const { return m_fontCapitalization; } 0369 void setFontCapitalization(quint32 newFontCapitalization) 0370 { 0371 m_fontCapitalization = newFontCapitalization; 0372 Q_EMIT fontCapitalizationChanged(); 0373 } 0374 0375 qreal fontLetterSpacing() const { return m_fontLetterSpacing; } 0376 void setFontLetterSpacing(qreal newFontLetterSpacing) 0377 { 0378 m_fontLetterSpacing = newFontLetterSpacing; 0379 Q_EMIT fontLetterSpacingChanged(); 0380 } 0381 0382 qreal fontLetterSpacingMin() const { return m_fontLetterSpacingMin; } 0383 qreal fontLetterSpacingMax() const { return m_fontLetterSpacingMax; } 0384 0385 bool isAutomaticDownloadsEnabled() const; 0386 void setIsAutomaticDownloadsEnabled(const bool newIsAutomaticDownloadsEnabled); 0387 0388 quint32 filterLevelMin() const { return m_filterLevelMin; } 0389 void setFilterLevelMin(const quint32 newFilterLevelMin) 0390 { 0391 m_filterLevelMin = newFilterLevelMin; 0392 Q_EMIT filterLevelMinChanged(); 0393 } 0394 0395 quint32 filterLevelMax() const { return m_filterLevelMax; } 0396 void setFilterLevelMax(const quint32 newFilterLevelMax) 0397 { 0398 m_filterLevelMax = newFilterLevelMax; 0399 Q_EMIT filterLevelMaxChanged(); 0400 } 0401 0402 bool filterLevelOverridedByCommandLineOption() const { return m_filterLevelOverridedByCommandLineOption; } 0403 void setFilterLevelOverridedByCommandLineOption(const bool newValue) 0404 { 0405 m_filterLevelOverridedByCommandLineOption = newValue; 0406 Q_EMIT filterLevelOverridedByCommandLineOptionChanged(); 0407 } 0408 0409 bool isKioskMode() const { return m_isKioskMode; } 0410 void setKioskMode(const bool newMode) 0411 { 0412 m_isKioskMode = newMode; 0413 Q_EMIT kioskModeChanged(); 0414 } 0415 0416 bool sectionVisible() const { return m_sectionVisible; } 0417 void setSectionVisible(const bool newMode) 0418 { 0419 m_sectionVisible = newMode; 0420 Q_EMIT sectionVisibleChanged(); 0421 } 0422 0423 bool exitConfirmation() const { return m_exitConfirmation; } 0424 void setExitConfirmation(const bool newMode) 0425 { 0426 m_exitConfirmation = newMode; 0427 Q_EMIT exitConfirmationChanged(); 0428 } 0429 0430 QString downloadServerUrl() const { return m_downloadServerUrl; } 0431 void setDownloadServerUrl(const QString &newDownloadServerUrl) 0432 { 0433 m_downloadServerUrl = newDownloadServerUrl; 0434 Q_EMIT downloadServerUrlChanged(); 0435 } 0436 0437 QString cachePath() const { return m_cachePath; } 0438 void setCachePath(const QString &newCachePath) 0439 { 0440 m_cachePath = newCachePath; 0441 Q_EMIT cachePathChanged(); 0442 } 0443 0444 QString userDataPath() const { return m_userDataPath; } 0445 void setUserDataPath(const QString &newUserDataPath) 0446 { 0447 m_userDataPath = newUserDataPath; 0448 Q_EMIT userDataPathChanged(); 0449 } 0450 quint32 exeCount() const { return m_exeCount; } 0451 void setExeCount(const quint32 newExeCount) 0452 { 0453 m_exeCount = newExeCount; 0454 Q_EMIT exeCountChanged(); 0455 } 0456 0457 bool isBarHidden() const { return m_isBarHidden; } 0458 void setBarHidden(const bool newBarHidden) 0459 { 0460 m_isBarHidden = newBarHidden; 0461 Q_EMIT barHiddenChanged(); 0462 } 0463 0464 int baseFontSize() const { return m_baseFontSize; } 0465 void setBaseFontSize(const int newBaseFontSize) 0466 { 0467 m_baseFontSize = qMax(qMin(newBaseFontSize, baseFontSizeMax()), baseFontSizeMin()); 0468 Q_EMIT baseFontSizeChanged(); 0469 } 0470 0471 int baseFontSizeMin() const { return m_baseFontSizeMin; } 0472 int baseFontSizeMax() const { return m_baseFontSizeMax; } 0473 0474 qreal backgroundMusicVolume() const { return m_backgroundMusicVolume; } 0475 void setBackgroundMusicVolume(const qreal newBackgroundMusicVolume) 0476 { 0477 m_backgroundMusicVolume = newBackgroundMusicVolume; 0478 Q_EMIT backgroundMusicVolumeChanged(); 0479 } 0480 0481 qreal audioEffectsVolume() const { return m_audioEffectsVolume; } 0482 void setAudioEffectsVolume(const qreal newAudioEffectsVolume) 0483 { 0484 m_audioEffectsVolume = newAudioEffectsVolume; 0485 Q_EMIT audioEffectsVolumeChanged(); 0486 } 0487 0488 int lastGCVersionRan() const { return m_lastGCVersionRan; } 0489 void setLastGCVersionRan(const int newLastGCVersionRan) 0490 { 0491 m_lastGCVersionRan = newLastGCVersionRan; 0492 Q_EMIT lastGCVersionRanChanged(); 0493 } 0494 0495 QString renderer() const { return m_renderer; } 0496 void setRenderer(const QString &newRenderer) 0497 { 0498 m_renderer = newRenderer; 0499 Q_EMIT rendererChanged(); 0500 } 0501 0502 QStringList filteredBackgroundMusic() const { return m_filteredBackgroundMusic; } 0503 void setFilteredBackgroundMusic(const QStringList &newFilteredBackgroundMusic) 0504 { 0505 m_filteredBackgroundMusic = newFilteredBackgroundMusic; 0506 Q_EMIT filteredBackgroundMusicChanged(); 0507 } 0508 0509 /** 0510 * Check if we use the external wordset for activity based on lang_api 0511 * @returns true if wordset is loaded 0512 * false if wordset is not loaded 0513 */ 0514 Q_INVOKABLE bool useExternalWordset(); 0515 0516 void setDifficultyFromCommandLine(quint32 newFilterLevelMin, quint32 newFilterLevelMax) 0517 { 0518 m_filterLevelOverridedByCommandLineOption = true; 0519 setFilterLevelMin(newFilterLevelMin); 0520 setFilterLevelMax(newFilterLevelMax); 0521 } 0522 0523 protected Q_SLOTS: 0524 0525 Q_INVOKABLE void notifyAudioVoicesEnabledChanged(); 0526 Q_INVOKABLE void notifyAudioEffectsEnabledChanged(); 0527 Q_INVOKABLE void notifyBackgroundMusicEnabledChanged(); 0528 Q_INVOKABLE void notifyFullscreenChanged(); 0529 Q_INVOKABLE void notifyPreviousHeightChanged(); 0530 Q_INVOKABLE void notifyPreviousWidthChanged(); 0531 Q_INVOKABLE void notifyVirtualKeyboardChanged(); 0532 Q_INVOKABLE void notifyLocaleChanged(); 0533 Q_INVOKABLE void notifyFontChanged(); 0534 Q_INVOKABLE void notifyFontCapitalizationChanged(); 0535 Q_INVOKABLE void notifyFontLetterSpacingChanged(); 0536 Q_INVOKABLE void notifyEmbeddedFontChanged(); 0537 Q_INVOKABLE void notifyAutomaticDownloadsEnabledChanged(); 0538 Q_INVOKABLE void notifyFilterLevelMinChanged(); 0539 Q_INVOKABLE void notifyFilterLevelMaxChanged(); 0540 Q_INVOKABLE void notifyKioskModeChanged(); 0541 Q_INVOKABLE void notifySectionVisibleChanged(); 0542 Q_INVOKABLE void notifyExitConfirmationChanged(); 0543 Q_INVOKABLE void notifyFilteredBackgroundMusicChanged(); 0544 Q_INVOKABLE void notifyBackgroundMusicVolumeChanged(); 0545 Q_INVOKABLE void notifyAudioEffectsVolumeChanged(); 0546 0547 Q_INVOKABLE void notifyDownloadServerUrlChanged(); 0548 Q_INVOKABLE void notifyCachePathChanged(); 0549 Q_INVOKABLE void notifyUserDataPathChanged(); 0550 Q_INVOKABLE void notifyExeCountChanged(); 0551 0552 Q_INVOKABLE void notifyLastGCVersionRanChanged(); 0553 Q_INVOKABLE void notifyRendererChanged(); 0554 0555 Q_INVOKABLE void notifyBarHiddenChanged(); 0556 0557 public Q_SLOTS: 0558 Q_INVOKABLE bool isFavorite(const QString &activity); 0559 Q_INVOKABLE void setFavorite(const QString &activity, bool favorite); 0560 Q_INVOKABLE void setCurrentLevels(const QString &activity, const QStringList &level, bool sync = true); 0561 Q_INVOKABLE QStringList currentLevels(const QString &activity); 0562 0563 Q_INVOKABLE void saveBaseFontSize(); 0564 /// @endcond 0565 0566 /** 0567 * Stores per-activity configuration @p data for @p activity. 0568 * 0569 * @param activity Name of the activity that wants to persist settings. 0570 * @param data Map of configuration data so save. 0571 */ 0572 Q_INVOKABLE void saveActivityConfiguration(const QString &activity, const QVariantMap &data); 0573 0574 /** 0575 * Loads per-activity configuration data for @p activity. 0576 * 0577 * @param activity Name of the activity that wants to persist settings. 0578 * @returns Map of configuration items. 0579 */ 0580 Q_INVOKABLE QVariantMap loadActivityConfiguration(const QString &activity); 0581 0582 /** 0583 * Loads per-activity progress using the default "progress" key. 0584 * 0585 * @param activity Name of the activity to load progress for. 0586 * @returns Last started level of the activity, 0 if none saved. 0587 */ 0588 Q_INVOKABLE int loadActivityProgress(const QString &activity); 0589 0590 /** 0591 * Saves per-activity progress using the default "progress" key. 0592 * 0593 * @param activity Name of the activity that wants to persist settings. 0594 * @param progress Last started level to save as progress value. 0595 */ 0596 Q_INVOKABLE void saveActivityProgress(const QString &activity, int progress); 0597 /** 0598 * Synchronize the changes done in the application in the configuration file. 0599 */ 0600 Q_INVOKABLE void sync(); 0601 0602 Q_SIGNALS: 0603 void audioVoicesEnabledChanged(); 0604 void audioEffectsEnabledChanged(); 0605 void backgroundMusicEnabledChanged(); 0606 void fullscreenChanged(); 0607 void previousHeightChanged(); 0608 void previousWidthChanged(); 0609 void virtualKeyboardChanged(); 0610 void localeChanged(); 0611 void fontChanged(); 0612 void fontCapitalizationChanged(); 0613 void fontLetterSpacingChanged(); 0614 void embeddedFontChanged(); 0615 void automaticDownloadsEnabledChanged(); 0616 void filterLevelMinChanged(); 0617 void filterLevelMaxChanged(); 0618 void filterLevelOverridedByCommandLineOptionChanged(); 0619 void kioskModeChanged(); 0620 void sectionVisibleChanged(); 0621 void exitConfirmationChanged(); 0622 void baseFontSizeChanged(); 0623 void filteredBackgroundMusicChanged(); 0624 void backgroundMusicVolumeChanged(); 0625 void audioEffectsVolumeChanged(); 0626 0627 void downloadServerUrlChanged(); 0628 void cachePathChanged(); 0629 void userDataPathChanged(); 0630 0631 void exeCountChanged(); 0632 0633 void lastGCVersionRanChanged(); 0634 void rendererChanged(); 0635 void barHiddenChanged(); 0636 0637 protected: 0638 static ApplicationSettings *m_instance; 0639 0640 private: 0641 // Update in configuration the couple {key, value} in the group. 0642 template <class T> 0643 void updateValueInConfig(const QString &group, 0644 const QString &key, const T &value, bool sync = true); 0645 0646 bool m_isAudioVoicesEnabled; 0647 bool m_isAudioEffectsEnabled; 0648 bool m_isBackgroundMusicEnabled; 0649 bool m_isFullscreen; 0650 quint32 m_previousHeight; 0651 quint32 m_previousWidth; 0652 bool m_isVirtualKeyboard; 0653 bool m_isAutomaticDownloadsEnabled; 0654 bool m_isEmbeddedFont; 0655 quint32 m_fontCapitalization; 0656 qreal m_fontLetterSpacing; 0657 quint32 m_filterLevelMin; 0658 quint32 m_filterLevelMax; 0659 bool m_filterLevelOverridedByCommandLineOption = false; 0660 bool m_defaultCursor; 0661 bool m_noCursor; 0662 QString m_locale; 0663 QString m_font; 0664 bool m_isKioskMode; 0665 bool m_sectionVisible; 0666 bool m_exitConfirmation; 0667 QStringList m_filteredBackgroundMusic; 0668 qreal m_backgroundMusicVolume; 0669 qreal m_audioEffectsVolume; 0670 int m_baseFontSize; 0671 const int m_baseFontSizeMin; 0672 const int m_baseFontSizeMax; 0673 const qreal m_fontLetterSpacingMin; 0674 const qreal m_fontLetterSpacingMax; 0675 0676 QString m_downloadServerUrl; 0677 QString m_cachePath; 0678 QString m_userDataPath; 0679 0680 quint32 m_exeCount; 0681 0682 int m_lastGCVersionRan; 0683 QString m_renderer; 0684 0685 bool m_isBarHidden; 0686 0687 QSettings m_config; 0688 }; 0689 0690 #endif // APPLICATIONSETTINGS_H