diff --git a/src/qml/main.qml b/src/qml/main.qml index 5225a49..756ba7f 100755 --- a/src/qml/main.qml +++ b/src/qml/main.qml @@ -102,6 +102,13 @@ ApplicationWindow { } } + Loader { + id: loaderMainTheme + + anchors.fill: parent + source: "themes/tiles/ThemeMain.qml" + } + Loader { id: loader @@ -111,8 +118,7 @@ ApplicationWindow { anchors.fill: parent - /// TODO: load only if this has never been displayed - // sourceComponent: introView + sourceComponent: !QL.ApplicationInfo.hasShownInitialDialog ? introView : undefined Component { id: introView @@ -131,7 +137,10 @@ ApplicationWindow { ListElement { name: "IntroEnd.qml"; backgroundColor: "#2c3e50" } } - onDone: loader.unload() + onDone: { + QL.ApplicationInfo.hasShownInitialDialog = true + loader.unload() + } } } @@ -167,13 +176,6 @@ ApplicationWindow { source: QL.ScreenValues.navBarVisible ? "qrc:/images/shadow_navigationbar" : "" } - Loader { - id: loaderMainTheme - - anchors.fill: parent - source: "themes/classic/ThemeMain.qml" - } - // D.Debug { // debugData: { // 'sdkInt': QL.System.sdkInt, diff --git a/src/src/applicationinfo.cpp b/src/src/applicationinfo.cpp new file mode 100644 index 0000000..c733476 --- /dev/null +++ b/src/src/applicationinfo.cpp @@ -0,0 +1,106 @@ +#include "applicationinfo.h" + +#include +#include + +#ifdef Q_OS_ANDROID +#include +#include +#endif + +ApplicationInfo::ApplicationInfo(QObject *parent) : + QObject(parent), + m_timesLaunched(0), + m_hasShownInitialDialog(false) +{ + QSettings settings; + m_timesLaunched = settings.value("timesLaunched", 0).toInt(); + m_hasShownInitialDialog = settings.value("hasShownInitialDialog", false).toBool(); + + m_firstTimeLaunched = settings.value("firstTimeLaunched", QDate::fromString("20000101", "yyyyMMdd")).toDate(); + + if (m_firstTimeLaunched.toString("yyyyMMdd") == "20000101") + setFirstTimeLaunched(QDate::currentDate()); + + m_OSVersion = getOSVersion(); + setTimesLaunched(m_timesLaunched + 1); +} + +int ApplicationInfo::timesLaunched() const +{ + return m_timesLaunched; +} + +void ApplicationInfo::setTimesLaunched(int timesLaunched) +{ + if (m_timesLaunched == timesLaunched) + return; + + m_timesLaunched = timesLaunched; + + QSettings settings; + settings.setValue("timesLaunched", m_timesLaunched); + + emit timesLaunchedChanged(); +} + +QDate ApplicationInfo::firstTimeLaunched() const +{ + return m_firstTimeLaunched; +} + +void ApplicationInfo::setFirstTimeLaunched(const QDate &firstTimeLaunched) +{ + if (m_firstTimeLaunched == firstTimeLaunched) + return; + + m_firstTimeLaunched = firstTimeLaunched; + + QSettings settings; + settings.setValue("firstTimeLaunched", m_firstTimeLaunched); + + emit firstTimeLaunchedChanged(); +} + +bool ApplicationInfo::hasShownInitialDialog() const +{ + return m_hasShownInitialDialog; +} + +void ApplicationInfo::setHasShownInitialDialog(bool hasShownInitialDialog) +{ + if (m_hasShownInitialDialog == hasShownInitialDialog) + return; + + m_hasShownInitialDialog = hasShownInitialDialog; + + QSettings settings; + settings.setValue("hasShownInitialDialog", m_hasShownInitialDialog); + + emit hasShownInitialDialogChanged(); +} + +int ApplicationInfo::OSVersion() const +{ + return m_OSVersion; +} + +void ApplicationInfo::setOSVersion(int version) +{ + if (m_OSVersion == version) + return; + + m_OSVersion = version; + emit OSVersionChanged(); +} + +int ApplicationInfo::getOSVersion() +{ +#ifdef Q_OS_ANDROID + jint version = QAndroidJniObject::getStaticField("android.os.Build$VERSION", "SDK_INT"); + return version; +#else + return -1; +#endif +} + diff --git a/src/src/applicationinfo.h b/src/src/applicationinfo.h new file mode 100644 index 0000000..68870cf --- /dev/null +++ b/src/src/applicationinfo.h @@ -0,0 +1,47 @@ +#ifndef APPLICATIONINFO_H +#define APPLICATIONINFO_H + +#include +#include + +class ApplicationInfo : public QObject +{ + Q_OBJECT + + Q_PROPERTY(int timesLaunched READ timesLaunched NOTIFY timesLaunchedChanged) + Q_PROPERTY(QDate firstTimeLaunched READ firstTimeLaunched NOTIFY firstTimeLaunchedChanged) + Q_PROPERTY(bool hasShownInitialDialog READ hasShownInitialDialog WRITE setHasShownInitialDialog NOTIFY hasShownInitialDialogChanged) + Q_PROPERTY(int OSVersion READ OSVersion WRITE setOSVersion NOTIFY OSVersionChanged) + +public: + ApplicationInfo(QObject *parent = 0); + + int timesLaunched() const; + void setTimesLaunched(int timesLaunched); + + QDate firstTimeLaunched() const; + void setFirstTimeLaunched(const QDate &firstTimeLaunched); + + bool hasShownInitialDialog() const; + void setHasShownInitialDialog(bool hasShownInitialDialog); + + int OSVersion() const; + void setOSVersion(int version); + +signals: + void timesLaunchedChanged(); + void firstTimeLaunchedChanged(); + void hasShownInitialDialogChanged(); + void OSVersionChanged(); + +private: + int m_timesLaunched; + QDate m_firstTimeLaunched; + bool m_hasShownInitialDialog; + int m_OSVersion; + + int getOSVersion(); + +}; + +#endif // APPLICATIONINFO_H diff --git a/src/src/main.cpp b/src/src/main.cpp index 858b421..456393c 100755 --- a/src/src/main.cpp +++ b/src/src/main.cpp @@ -8,10 +8,11 @@ #include #include -#include "packagemanager.h" +#include "applicationinfo.h" #include "iconimageprovider.h" -#include "screenvalues.h" #include "launcher.h" +#include "packagemanager.h" +#include "screenvalues.h" #include "system.h" static QObject *package_manager_provider(QQmlEngine *engine, QJSEngine *scriptEngine) @@ -46,6 +47,14 @@ static QObject *system_provider(QQmlEngine *engine, QJSEngine *scriptEngine) return new System(); } +static QObject *application_info_provider(QQmlEngine *engine, QJSEngine *scriptEngine) +{ + Q_UNUSED(engine) + Q_UNUSED(scriptEngine) + + return new ApplicationInfo(); +} + int main(int argc, char *argv[]) { QScopedPointer app(new QApplication(argc, argv)); @@ -59,6 +68,7 @@ int main(int argc, char *argv[]) QObject::connect(&engine, SIGNAL(quit()), QCoreApplication::instance(), SLOT(quit())); qmlRegisterSingletonType("com.iktwo.qutelauncher", 1, 0, "PackageManager", package_manager_provider); + qmlRegisterSingletonType("com.iktwo.qutelauncher", 1, 0, "ApplicationInfo", application_info_provider); qmlRegisterSingletonType("com.iktwo.qutelauncher", 1, 0, "ScreenValues", screen_values_provider); qmlRegisterSingletonType("com.iktwo.qutelauncher", 1, 0, "System", system_provider); qmlRegisterSingletonType("com.iktwo.qutelauncher", 1, 0, "Launcher", launcher_provider);