aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWeblate <noreply@weblate.org>2017-06-21 10:53:14 +0200
committerWeblate <noreply@weblate.org>2017-06-21 10:53:14 +0200
commit822427d3b6e482e09d433c19b8517e10578c4fa7 (patch)
treeb06dccee376b00bb3abd8705b38af8dc83d3b91d
parentc57b8966d8c85e195494138c5ba1b33b75d0a601 (diff)
parent941e702b9d244a9f469bbdef531dffa1c6f3eac4 (diff)
Merge remote-tracking branch 'origin/master'
Diffstat (limited to '')
-rw-r--r--asteroid-stopwatch.pro34
-rw-r--r--main.cpp17
-rw-r--r--main.qml51
3 files changed, 38 insertions, 64 deletions
diff --git a/asteroid-stopwatch.pro b/asteroid-stopwatch.pro
index 600a861..ecb1f21 100644
--- a/asteroid-stopwatch.pro
+++ b/asteroid-stopwatch.pro
@@ -1,35 +1,9 @@
-TEMPLATE = app
-QT += qml quick
-CONFIG += link_pkgconfig
-PKGCONFIG += qdeclarative5-boostable
+TARGET = asteroid-stopwatch
+CONFIG += asteroidapp
SOURCES += main.cpp
RESOURCES += resources.qrc
OTHER_FILES += main.qml
-lupdate_only{
- SOURCES = i18n/asteroid-stopwatch.desktop.h
-}
-
-# Needed for lupdate
-TRANSLATIONS = i18n/asteroid-stopwatch.de_DE.ts \
- i18n/asteroid-stopwatch.es.ts \
- i18n/asteroid-stopwatch.fa.ts \
- i18n/asteroid-stopwatch.fr.ts \
- i18n/asteroid-stopwatch.ko.ts \
- i18n/asteroid-stopwatch.nl_NL.ts \
- i18n/asteroid-stopwatch.pl.ts \
- i18n/asteroid-stopwatch.pt_BR.ts \
- i18n/asteroid-stopwatch.ru.ts \
- i18n/asteroid-stopwatch.sv.ts \
- i18n/asteroid-stopwatch.uk.ts
-
-TARGET = asteroid-stopwatch
-target.path = /usr/bin/
-
-desktop.commands = bash $$PWD/i18n/generate-desktop.sh $$PWD asteroid-stopwatch.desktop
-desktop.files = $$OUT_PWD/asteroid-stopwatch.desktop
-desktop.path = /usr/share/applications
-desktop.CONFIG = no_check_exist
-
-INSTALLS += target desktop
+lupdate_only{ SOURCES = i18n/$$TARGET.desktop.h }
+TRANSLATIONS = $$files(i18n/$$TARGET.*.ts)
diff --git a/main.cpp b/main.cpp
index f710ec4..a44544c 100644
--- a/main.cpp
+++ b/main.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015 - Florent Revest <revestflo@gmail.com>
+ * Copyright (C) 2017 - Florent Revest <revestflo@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -15,18 +15,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <QQuickView>
-#include <QGuiApplication>
-#include <QScreen>
-#include <MDeclarativeCache>
+#include <asteroidapp.h>
-Q_DECL_EXPORT int main(int argc, char *argv[])
+int main(int argc, char *argv[])
{
- QScopedPointer<QGuiApplication> app(MDeclarativeCache::qApplication(argc, argv));
- QScopedPointer<QQuickView> view(MDeclarativeCache::qQuickView());
- view->setSource(QUrl("qrc:/main.qml"));
- view->setTitle("Stopwatch");
- view->resize(app->primaryScreen()->size());
- view->show();
- return app->exec();
+ return AsteroidApp::main(argc, argv);
}
diff --git a/main.qml b/main.qml
index 9c7c215..92fdf3f 100644
--- a/main.qml
+++ b/main.qml
@@ -20,6 +20,7 @@
import QtQuick 2.5
import org.asteroid.controls 1.0
+import org.nemomobile.configuration 1.0
Application {
id: app
@@ -27,9 +28,21 @@ Application {
centerColor: "#b01c7e"
outerColor: "#420a2f"
- property bool running
- property var previousTime
- property int elapsed: 0
+ ConfigurationValue {
+ id: previousTime
+ key: "/stopwatch/previousTime"
+ defaultValue: -1
+ }
+ ConfigurationValue {
+ id: elapsed
+ key: "/stopwatch/elapsed"
+ defaultValue: -1
+ }
+ ConfigurationValue {
+ id: running
+ key: "/stopwatch/running"
+ defaultValue: false
+ }
function zeroPad(n) {
return (n < 10 ? "0" : "") + n
@@ -56,7 +69,7 @@ Application {
id: mainPage
anchors.fill: parent
- state: "zero"
+ state: running.value ? "running" : elapsed.value == -1 ? "zero" : "paused"
states: [
State { name: "zero" },
State { name: "running" },
@@ -67,7 +80,7 @@ Application {
id: elapsedLabel
textFormat: Text.RichText
anchors.centerIn: parent
- text: toTimeString(elapsed)
+ text: toTimeString(elapsed.value)
font.pixelSize: parent.height*0.25
color: "#FFFFFF"
horizontalAlignment: Text.AlignHCenter
@@ -84,18 +97,19 @@ Application {
MouseArea {
anchors.fill: parent
onClicked: {
- switch (mainPage.state) {
+ console.log("from:" + mainPage.state + " " + elapsed.value + " " + running.value + " " + previousTime.value)
+ switch(mainPage.state) {
case "zero":
case "paused":
- previousTime = new Date;
- stopwatch.start();
- mainPage.state = "running";
+ var curTime = new Date
+ previousTime.value = curTime.getTime()
+ running.value = true
break;
case "running":
- mainPage.state = "paused";
- stopwatch.stop();
+ running.value = false
break;
}
+ console.log("from:" + mainPage.state + " " + elapsed.value + " " + running.value + " " + previousTime.value)
}
}
@@ -114,26 +128,21 @@ Application {
top: parent.top
}
- onClicked: {
- elapsed = 0;
- mainPage.state = "zero"
- }
+ onClicked: elapsed.value = -1
}
}
Timer {
- id: stopwatch
-
interval: 100
repeat: true
- running: false
+ running: mainPage.state == "running"
triggeredOnStart: true
onTriggered: {
var currentTime = new Date
- var delta = (currentTime.getTime() - previousTime.getTime())
- previousTime = currentTime
- elapsed += delta
+ var delta = (currentTime.getTime() - previousTime.value)
+ previousTime.value = currentTime.getTime()
+ elapsed.value += delta
}
}
}