From kde-commits Sun Nov 30 21:26:28 2014 From: Bruno Coudoin Date: Sun, 30 Nov 2014 21:26:28 +0000 To: kde-commits Subject: [gcompris] src: core, add iinitial support for the demo mode Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=141738279811530 Git commit c9f4ceab240885e37e7858360f7cbccd551f2886 by Bruno Coudoin. Committed on 30/11/2014 at 00:57. Pushed by bcoudoin into branch 'master'. core, add iinitial support for the demo mode - add the demo property and a button in the config dialog to activate GCompris. - add a demo icon on activities in the menu M +12 -0 src/activities/menu/Menu.qml M +18 -1 src/core/ApplicationSettings.cpp M +13 -1 src/core/ApplicationSettings.h M +65 -0 src/core/DialogConfig.qml http://commits.kde.org/gcompris/c9f4ceab240885e37e7858360f7cbccd551f2886 diff --git a/src/activities/menu/Menu.qml b/src/activities/menu/Menu.qml index c86afa0..9224f77 100644 --- a/src/activities/menu/Menu.qml +++ b/src/activities/menu/Menu.qml @@ -155,6 +155,7 @@ ActivityBase { anchors.margins: 5 anchors.horizontalCenter: parent.horizontalCenter } + ParticleSystemStar { id: particles anchors.fill: backgroundSection @@ -235,6 +236,17 @@ ActivityBase { sourceSize.width: iconWidth * 0.15 x: 5 } + Image { + anchors { + right: parent.right + top: parent.top + rightMargin: 4 + } + source: demo || !ApplicationSettings.isDemoMode + ? "" : + "qrc:/gcompris/src/core/resource/cancel.= svgz" + sourceSize.width: 30 * ApplicationInfo.ratio + } GCText { anchors.top: parent.bottom anchors.horizontalCenter: parent.horizontalCenter diff --git a/src/core/ApplicationSettings.cpp b/src/core/ApplicationSetting= s.cpp index 422d0a9..a127f3a 100644 --- a/src/core/ApplicationSettings.cpp +++ b/src/core/ApplicationSettings.cpp @@ -76,6 +76,7 @@ static const QString FILTER_LEVEL_MAX =3D "filterLevelMax= "; = static const QString DEFAULT_CURSOR =3D "defaultCursor"; static const QString NO_CURSOR =3D "noCursor"; +static const QString DEMO_KEY =3D "demo"; = ApplicationSettings *ApplicationSettings::m_instance =3D NULL; = @@ -97,6 +98,14 @@ ApplicationSettings::ApplicationSettings(QObject *parent= ): QObject(parent), m_font =3D m_config.value(FONT_KEY, GC_DEFAULT_FONT).toString(); m_isEmbeddedFont =3D m_config.value(IS_CURRENT_FONT_EMBEDDED, true).to= Bool(); = +// The the default demo mode based on the platform +#if defined(Q_OS_ANDROID) || defined(Q_OS_MAC) || defined(Q_OS_BLACKBERRY)= || \ + defined(Q_OS_WIN) || defined(Q_OS_WINRT) + m_isDemoMode =3D m_config.value(DEMO_KEY, true).toBool(); +#else + m_isDemoMode =3D m_config.value(DEMO_KEY, false).toBool(); +#endif + m_isAutomaticDownloadsEnabled =3D m_config.value(ENABLE_AUTOMATIC_DOWN= LOADS, !ApplicationInfo::getInstance()->isMobile()).toBool(); m_filterLevelMin =3D m_config.value(FILTER_LEVEL_MIN, 1).toUInt(); @@ -128,7 +137,8 @@ ApplicationSettings::ApplicationSettings(QObject *paren= t): QObject(parent), connect(this, SIGNAL(automaticDownloadsEnabledChanged()), this, SLOT(n= otifyAutomaticDownloadsEnabledChanged())); connect(this, SIGNAL(filterLevelMinChanged()), this, SLOT(notifyFilter= LevelMinChanged())); connect(this, SIGNAL(filterLevelMaxChanged()), this, SLOT(notifyFilter= LevelMaxChanged())); - connect(this, SIGNAL(downloadServerUrlChanged()), this, SLOT(notifyDow= nloadServerUrlChanged())); + connect(this, SIGNAL(demoModeChanged()), this, SLOT(notifyDemoModeChanged= ())); + connect(this, SIGNAL(downloadServerUrlChanged()), this, SLOT(notifyDownlo= adServerUrlChanged())); connect(this, SIGNAL(exeCountChanged()), this, SLOT(notifyExeCountChan= ged())); connect(this, SIGNAL(barHiddenChanged()), this, SLOT(notifyBarHiddenCh= anged())); } @@ -147,6 +157,7 @@ ApplicationSettings::~ApplicationSettings() m_config.setValue(ENABLE_AUTOMATIC_DOWNLOADS, m_isAutomaticDownloadsEn= abled); m_config.setValue(FILTER_LEVEL_MIN, m_filterLevelMin); m_config.setValue(FILTER_LEVEL_MAX, m_filterLevelMax); + m_config.setValue(DEMO_KEY, m_isDemoMode); m_config.setValue(DEFAULT_CURSOR, m_defaultCursor); m_config.setValue(NO_CURSOR, m_noCursor); m_config.endGroup(); @@ -226,6 +237,12 @@ void ApplicationSettings::notifyFilterLevelMaxChanged() qDebug() << "filterLevelMax set to: " << m_filterLevelMax; } = +void ApplicationSettings::notifyDemoModeChanged() +{ + updateValueInConfig(GENERAL_GROUP_KEY, DEMO_KEY, m_isDemoMode); + qDebug() << "notifyDemoMode: " << m_isDemoMode; +} + void ApplicationSettings::notifyDownloadServerUrlChanged() { updateValueInConfig(ADMIN_GROUP_KEY, DOWNLOAD_SERVER_URL_KEY, m_downlo= adServerUrl); diff --git a/src/core/ApplicationSettings.h b/src/core/ApplicationSettings.h index a1ad7ed..a983ebb 100644 --- a/src/core/ApplicationSettings.h +++ b/src/core/ApplicationSettings.h @@ -46,6 +46,7 @@ #include #include #include +#include = #include = @@ -64,6 +65,7 @@ class ApplicationSettings : public QObject Q_PROPERTY(bool isAutomaticDownloadsEnabled READ isAutomaticDownloadsE= nabled WRITE setIsAutomaticDownloadsEnabled NOTIFY automaticDownloadsEnable= dChanged) Q_PROPERTY(quint32 filterLevelMin READ filterLevelMin WRITE setFilterL= evelMin NOTIFY filterLevelMinChanged) Q_PROPERTY(quint32 filterLevelMax READ filterLevelMax WRITE setFilterL= evelMax NOTIFY filterLevelMaxChanged) + Q_PROPERTY(bool isDemoMode READ isDemoMode WRITE setDemoMode NOTIFY demoM= odeChanged) = // admin group Q_PROPERTY(QString downloadServerUrl READ downloadServerUrl WRITE setD= ownloadServerUrl NOTIFY downloadServerUrlChanged) @@ -151,7 +153,14 @@ public: emit filterLevelMaxChanged(); } = - QString downloadServerUrl() const { return m_downloadServerUrl; } + bool isDemoMode() const { return m_isDemoMode; } + void setDemoMode(const bool newMode) { + qDebug() << "c++ setDemoMode=3D" << newMode; + m_isDemoMode =3D newMode; + emit demoModeChanged(); + } + + QString downloadServerUrl() const { return m_downloadServerUrl; } void setDownloadServerUrl(const QString newDownloadServerUrl) { m_downloadServerUrl =3D newDownloadServerUrl; emit downloadServerUrlChanged(); @@ -180,6 +189,7 @@ protected slots: Q_INVOKABLE void notifyAutomaticDownloadsEnabledChanged(); Q_INVOKABLE void notifyFilterLevelMinChanged(); Q_INVOKABLE void notifyFilterLevelMaxChanged(); + Q_INVOKABLE void notifyDemoModeChanged(); = Q_INVOKABLE void notifyDownloadServerUrlChanged(); = @@ -200,6 +210,7 @@ signals: void automaticDownloadsEnabledChanged(); void filterLevelMinChanged(); void filterLevelMaxChanged(); + void demoModeChanged(); = void downloadServerUrlChanged(); = @@ -226,6 +237,7 @@ private: bool m_noCursor; QString m_locale; QString m_font; + bool m_isDemoMode; = QString m_downloadServerUrl; = diff --git a/src/core/DialogConfig.qml b/src/core/DialogConfig.qml index 8718371..27c865a 100644 --- a/src/core/DialogConfig.qml +++ b/src/core/DialogConfig.qml @@ -94,6 +94,65 @@ Rectangle { spacing: 10 width: parent.width // Put configuration here + Row { + id: demoModeBox + width: parent.width + spacing: 10 + + property bool checked: !isDemoMode + onCheckedChanged: { + console.log("onCheckedChanged", checked) + isDemoMode =3D !checked; + } + + Image { + sourceSize.height: 50 * ApplicationInf= o.ratio + source: + demoModeBox.checked ? "qrc:/gcompr= is/src/core/resource/apply.svgz" : + "qrc:/gcompr= is/src/core/resource/cancel.svgz" + MouseArea { + anchors.fill: parent + onClicked: isDemoMode ? console.lo= g("call buying api") : "" + } + } + + Button { + width: parent.parent.width - 50 * Applicat= ionInfo.ratio - 10 * 2 + height: parent.height + enabled: isDemoMode + anchors.leftMargin: 10 + anchors.verticalCenter: parent.verticalCen= ter + text: demoModeBox.checked ? qsTr("You have= the full version") : + qsTr("Buy the = full version") + style: ButtonStyle { + background: Rectangle { + implicitWidth: 100 + implicitHeight: 25 + border.width: control.activeFocus = ? 4 : 2 + border.color: "black" + radius: 10 + gradient: Gradient { + GradientStop { position: 0 ; c= olor: control.pressed ? "#87ff5c" : + = isDemoMode ? "#ffe85c" : "#EEEEEE"} + GradientStop { position: 1 ; c= olor: control.pressed ? "#44ff00" : + = isDemoMode ? "#f8d600" : "#AAAAAA"} + } + } + label: GCText { + text: control.text + horizontalAlignment: Text.AlignHCe= nter + verticalAlignment: Text.AlignVCent= er + wrapMode: Text.WordWrap + } + } + + onClicked: { + isDemoMode =3D !isDemoMode + console.log("call buying api") + } + } + } + GCDialogCheckBox { id: enableAudioVoicesBox text: qsTr("Enable audio voices") @@ -404,12 +463,15 @@ Rectangle { property bool isFullscreen: ApplicationSettings.isFullscreen property bool isVirtualKeyboard: ApplicationSettings.isVirtualKeyboard property bool isAutomaticDownloadsEnabled: ApplicationSettings.isAutom= aticDownloadsEnabled + property bool isDemoMode = onStart: { // Synchronize settings with data isAudioVoicesEnabled =3D ApplicationSettings.isAudioVoicesEnabled enableAudioVoicesBox.checked =3D isAudioVoicesEnabled = + isDemoMode =3D ApplicationSettings.isDemoMode + isAudioEffectsEnabled =3D ApplicationSettings.isAudioEffectsEnabled enableAudioEffectsBox.checked =3D isAudioEffectsEnabled = @@ -441,6 +503,8 @@ Rectangle { = function save() { ApplicationSettings.isAudioVoicesEnabled =3D isAudioVoicesEnabled + console.log("isDemoMode", isDemoMode) + ApplicationSettings.isDemoMode =3D isDemoMode ApplicationSettings.isAudioEffectsEnabled =3D isAudioEffectsEnabled ApplicationSettings.isFullscreen =3D isFullscreen ApplicationSettings.isVirtualKeyboard =3D isVirtualKeyboard @@ -555,6 +619,7 @@ Rectangle { = function hasConfigChanged() { return (ApplicationSettings.locale !=3D languages.get(languageBox.= currentIndex).locale || + (ApplicationSettings.isDemoMode !=3D isDemoMode) || (ApplicationSettings.font !=3D fonts.get(fontBox.currentIn= dex).text) || (ApplicationSettings.isEmbeddedFont !=3D fonts.get(fontBox= .currentIndex).isLocalResource) || (ApplicationSettings.isAudioVoicesEnabled !=3D isAudioVoic= esEnabled) ||