From ff0201bc23545d6794b43f6a5fd558cfcdd29e15 Mon Sep 17 00:00:00 2001 From: Florent Revest Date: Mon, 8 Feb 2016 18:16:02 +0100 Subject: Use MDeclarativeCache from mapplauncherd to get faster startup --- asteroid-stopwatch.desktop | 2 +- asteroid-stopwatch.pro | 2 ++ main.cpp | 30 ++++++++++-------------------- main.qml | 4 ++-- 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 . */ -#include -#include -#include -#include -#include +#include +#include +#include -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(topLevel); - if(!window) { - qWarning("Error: Your root item has to be a Window."); - return -1; - } - window->showFullScreen(); - return app.exec(); + QScopedPointer app(MDeclarativeCache::qApplication(argc, argv)); + QScopedPointer 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 -- cgit v1.2.3-70-g09d2