aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorent Revest <revestflo@gmail.com>2016-02-08 18:16:02 +0100
committerFlorent Revest <revestflo@gmail.com>2016-02-08 18:16:02 +0100
commitff0201bc23545d6794b43f6a5fd558cfcdd29e15 (patch)
treec67d89eb9043b4a7578074c87af504836213ef08
parentcdcf5e8496b51091f9d71a6a52a588a97686c49d (diff)
Use MDeclarativeCache from mapplauncherd to get faster startup
-rw-r--r--asteroid-stopwatch.desktop2
-rw-r--r--asteroid-stopwatch.pro2
-rw-r--r--main.cpp30
-rw-r--r--main.qml4
4 files changed, 15 insertions, 23 deletions
diff --git a/asteroid-stopwatch.desktop b/asteroid-stopwatch.desktop
index 4f80516..ba8ce7b 100644
--- a/asteroid-stopwatch.desktop
+++ b/asteroid-stopwatch.desktop
@@ -2,6 +2,6 @@
Type=Application
Name=Stopwatch
Categories=Applications;
-Exec=env QT_QUICK_CONTROLS_STYLE=Asteroid /usr/bin/asteroid-stopwatch
+Exec=invoker --type=qtcomponents-qt5 /usr/bin/asteroid-stopwatch
Icon=clock
X-Desktop-File-Install-Version=0.20
diff --git a/asteroid-stopwatch.pro b/asteroid-stopwatch.pro
index 387ddf3..8647880 100644
--- a/asteroid-stopwatch.pro
+++ b/asteroid-stopwatch.pro
@@ -1,6 +1,8 @@
TEMPLATE = app
QT += widgets qml quick xml svg
QTPLUGIN += qsvg
+CONFIG += link_pkgconfig
+PKGCONFIG += qdeclarative5-boostable
SOURCES += main.cpp
RESOURCES += resources.qrc
diff --git a/main.cpp b/main.cpp
index 3b88dd7..534a9cc 100644
--- a/main.cpp
+++ b/main.cpp
@@ -15,26 +15,16 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <QtQml>
-#include <QtQuick/QQuickView>
-#include <QtCore/QString>
-#include <QScreen>
-#include <QtGui/QGuiApplication>
+#include <QQuickView>
+#include <QGuiApplication>
+#include <MDeclarativeCache>
-int main(int argc, char *argv[])
+Q_DECL_EXPORT int main(int argc, char *argv[])
{
- QGuiApplication app(argc, argv);
- QScreen* sc = app.primaryScreen();
- if(sc) {
- sc->setOrientationUpdateMask(Qt::LandscapeOrientation | Qt::PortraitOrientation | Qt::InvertedLandscapeOrientation | Qt::InvertedPortraitOrientation);
- }
- QQmlApplicationEngine engine(QUrl("qrc:/main.qml"));
- QObject *topLevel = engine.rootObjects().value(0);
- QQuickWindow *window = qobject_cast<QQuickWindow *>(topLevel);
- if(!window) {
- qWarning("Error: Your root item has to be a Window.");
- return -1;
- }
- window->showFullScreen();
- return app.exec();
+ QScopedPointer<QGuiApplication> app(MDeclarativeCache::qApplication(argc, argv));
+ QScopedPointer<QQuickView> view(MDeclarativeCache::qQuickView());
+ view->setSource(QUrl("qrc:/main.qml"));
+ view->setTitle("Stopwatch");
+ view->showFullScreen();
+ return app->exec();
}
diff --git a/main.qml b/main.qml
index 98adb39..84daa79 100644
--- a/main.qml
+++ b/main.qml
@@ -22,9 +22,9 @@ import QtGraphicalEffects 1.0
import QtQuick.Controls 1.3
import org.asteroid.controls 1.0
-Application {
+Item {
id: app
- title: "Stopwatch"
+ anchors.fill: parent
property bool running
property var previousTime