[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [gcompris] src: core, add iinitial support for the demo mode
From:       Bruno Coudoin <bruno.coudoin () gcompris ! net>
Date:       2014-11-30 21:26:28
Message-ID: E1XvC0i-00014n-DR () scm ! kde ! org
[Download RAW message or body]

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/ApplicationSettings.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 = "filterLevelMax";
 
 static const QString DEFAULT_CURSOR = "defaultCursor";
 static const QString NO_CURSOR = "noCursor";
+static const QString DEMO_KEY = "demo";
 
 ApplicationSettings *ApplicationSettings::m_instance = NULL;
 
@@ -97,6 +98,14 @@ ApplicationSettings::ApplicationSettings(QObject *parent): \
QObject(parent),  m_font = m_config.value(FONT_KEY, GC_DEFAULT_FONT).toString();
     m_isEmbeddedFont = m_config.value(IS_CURRENT_FONT_EMBEDDED, true).toBool();
 
+// 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 = m_config.value(DEMO_KEY, true).toBool();
+#else
+	m_isDemoMode = m_config.value(DEMO_KEY, false).toBool();
+#endif
+
     m_isAutomaticDownloadsEnabled = m_config.value(ENABLE_AUTOMATIC_DOWNLOADS,
             !ApplicationInfo::getInstance()->isMobile()).toBool();
     m_filterLevelMin = m_config.value(FILTER_LEVEL_MIN, 1).toUInt();
@@ -128,7 +137,8 @@ ApplicationSettings::ApplicationSettings(QObject *parent): \
                QObject(parent),
     connect(this, SIGNAL(automaticDownloadsEnabledChanged()), this, \
                SLOT(notifyAutomaticDownloadsEnabledChanged()));
     connect(this, SIGNAL(filterLevelMinChanged()), this, \
                SLOT(notifyFilterLevelMinChanged()));
     connect(this, SIGNAL(filterLevelMaxChanged()), this, \
                SLOT(notifyFilterLevelMaxChanged()));
-    connect(this, SIGNAL(downloadServerUrlChanged()), this, \
SLOT(notifyDownloadServerUrlChanged())); +	connect(this, SIGNAL(demoModeChanged()), \
this, SLOT(notifyDemoModeChanged())); +	connect(this, \
                SIGNAL(downloadServerUrlChanged()), this, \
                SLOT(notifyDownloadServerUrlChanged()));
     connect(this, SIGNAL(exeCountChanged()), this, SLOT(notifyExeCountChanged()));
     connect(this, SIGNAL(barHiddenChanged()), this, SLOT(notifyBarHiddenChanged()));
 }
@@ -147,6 +157,7 @@ ApplicationSettings::~ApplicationSettings()
     m_config.setValue(ENABLE_AUTOMATIC_DOWNLOADS, m_isAutomaticDownloadsEnabled);
     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_downloadServerUrl);
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 <QQmlEngine>
 #include <QUrl>
 #include <QtGlobal>
+#include <QDebug>
 
 #include <QSettings>
 
@@ -64,6 +65,7 @@ class ApplicationSettings : public QObject
     Q_PROPERTY(bool isAutomaticDownloadsEnabled READ isAutomaticDownloadsEnabled \
                WRITE setIsAutomaticDownloadsEnabled NOTIFY \
                automaticDownloadsEnabledChanged)
     Q_PROPERTY(quint32 filterLevelMin READ filterLevelMin WRITE setFilterLevelMin \
                NOTIFY filterLevelMinChanged)
     Q_PROPERTY(quint32 filterLevelMax READ filterLevelMax WRITE setFilterLevelMax \
NOTIFY filterLevelMaxChanged) +	Q_PROPERTY(bool isDemoMode READ isDemoMode WRITE \
setDemoMode NOTIFY demoModeChanged)  
     // admin group
     Q_PROPERTY(QString downloadServerUrl READ downloadServerUrl WRITE \
setDownloadServerUrl 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=" << newMode;
+		m_isDemoMode = newMode;
+		emit demoModeChanged();
+	}
+
+	QString downloadServerUrl() const { return m_downloadServerUrl; }
     void setDownloadServerUrl(const QString newDownloadServerUrl) {
         m_downloadServerUrl = 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 = !checked;
+                            }
+
+                            Image {
+                                    sourceSize.height: 50 * ApplicationInfo.ratio
+                                    source:
+                                        demoModeBox.checked ? \
"qrc:/gcompris/src/core/resource/apply.svgz" : +                                      \
"qrc:/gcompris/src/core/resource/cancel.svgz" +                                    \
MouseArea { +                                        anchors.fill: parent
+                                        onClicked: isDemoMode ? console.log("call \
buying api") : "" +                                    }
+                                }
+
+                            Button {
+                                width: parent.parent.width - 50 * \
ApplicationInfo.ratio - 10 * 2 +                                height: parent.height
+                                enabled: isDemoMode
+                                anchors.leftMargin: 10
+                                anchors.verticalCenter: parent.verticalCenter
+                                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 ; color: \
control.pressed ? "#87ff5c" : +                                                       \
isDemoMode ? "#ffe85c" : "#EEEEEE"} +                                            \
GradientStop { position: 1 ; color: control.pressed ? "#44ff00" : +                   \
isDemoMode ? "#f8d600" : "#AAAAAA"} +                                        }
+                                    }
+                                    label: GCText {
+                                        text: control.text
+                                        horizontalAlignment: Text.AlignHCenter
+                                        verticalAlignment: Text.AlignVCenter
+                                        wrapMode: Text.WordWrap
+                                    }
+                                }
+
+                                onClicked: {
+                                    isDemoMode = !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.isAutomaticDownloadsEnabled +    property bool isDemoMode
 
     onStart: {
         // Synchronize settings with data
         isAudioVoicesEnabled = ApplicationSettings.isAudioVoicesEnabled
         enableAudioVoicesBox.checked = isAudioVoicesEnabled
 
+        isDemoMode = ApplicationSettings.isDemoMode
+
         isAudioEffectsEnabled = ApplicationSettings.isAudioEffectsEnabled
         enableAudioEffectsBox.checked = isAudioEffectsEnabled
 
@@ -441,6 +503,8 @@ Rectangle {
 
     function save() {
         ApplicationSettings.isAudioVoicesEnabled = isAudioVoicesEnabled
+        console.log("isDemoMode", isDemoMode)
+        ApplicationSettings.isDemoMode = isDemoMode
         ApplicationSettings.isAudioEffectsEnabled = isAudioEffectsEnabled
         ApplicationSettings.isFullscreen = isFullscreen
         ApplicationSettings.isVirtualKeyboard = isVirtualKeyboard
@@ -555,6 +619,7 @@ Rectangle {
 
     function hasConfigChanged() {
         return (ApplicationSettings.locale != \
languages.get(languageBox.currentIndex).locale || +                \
                (ApplicationSettings.isDemoMode != isDemoMode) ||
                 (ApplicationSettings.font != fonts.get(fontBox.currentIndex).text) \
                ||
                 (ApplicationSettings.isEmbeddedFont != \
                fonts.get(fontBox.currentIndex).isLocalResource) ||
                 (ApplicationSettings.isAudioVoicesEnabled != isAudioVoicesEnabled) \
||


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic