diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt index e10afb2469d463368ddfbe5d965543f4b066d033..b8cad3d392ae7d5ce2471ecaf3f4f521f84e1134 100644 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -1,3 +1,4 @@ set(BUILD_SHARED_LIBS 0) - + +set(DISABLE_DBUS ON) add_subdirectory(kirigami) diff --git a/src/main.cpp b/src/main.cpp index f6aa73e0bdf5e5fe35efdbba093d4a25d8a28956..ededaf5726e18817aa57f7ab74168665f88facc1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,9 +1,57 @@ -#include #include -int main(int argc, char *argv[]) +#ifdef Q_OS_ANDROID +#include +#else +#include +#endif + +#include +#include +#include + +#ifdef Q_OS_ANDROID +#include +// WindowManager.LayoutParams +#define FLAG_TRANSLUCENT_STATUS 0x04000000 +#define FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS 0x80000000 +// View +#define SYSTEM_UI_FLAG_LIGHT_STATUS_BAR 0x00002000 + +#endif + +Q_IMPORT_PLUGIN(KirigamiPlugin) + +Q_DECL_EXPORT int main(int argc, char *argv[]) { + QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); +//The desktop QQC2 style needs it to be a QApplication +#ifdef Q_OS_ANDROID QGuiApplication app(argc, argv); - QQmlApplicationEngine engine(QUrl(QStringLiteral("qrc:/qml/main.qml"))); +#else + QApplication app(argc, argv); +#endif + + //qputenv("QML_IMPORT_TRACE", "1"); + + QQmlApplicationEngine engine; + + engine.load(QUrl(QStringLiteral("qrc:/qml/main.qml"))); + + if (engine.rootObjects().isEmpty()) { + return -1; + } + + //HACK to color the system bar on Android, use qtandroidextras and call the appropriate Java methods +#ifdef Q_OS_ANDROID + QtAndroid::runOnAndroidThread([=]() { + QAndroidJniObject window = QtAndroid::androidActivity().callObjectMethod("getWindow", "()Landroid/view/Window;"); + window.callMethod("addFlags", "(I)V", FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); + window.callMethod("clearFlags", "(I)V", FLAG_TRANSLUCENT_STATUS); + window.callMethod("setStatusBarColor", "(I)V", QColor("#2196f3").rgba()); + window.callMethod("setNavigationBarColor", "(I)V", QColor("#2196f3").rgba()); + }); +#endif + return app.exec(); } diff --git a/src/qml/main.qml b/src/qml/main.qml index e8115eea2f852ffd28b0320ce28174f06ddf82d8..746ab1e1a6b6291065c096a72b7201ddaa57355f 100644 --- a/src/qml/main.qml +++ b/src/qml/main.qml @@ -1,14 +1,38 @@ -import QtQuick 2.0 -import QtQuick.Window 2.0 +import QtQuick 2.7 +import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.3 -Window -{ +import org.kde.kirigami 2.4 as Kirigami + +Kirigami.ApplicationWindow { visible: true - width: 300 - height: 240 + title: qsTr("Hello World") + + //pageStack.initialPage: Page1 {} - Rectangle { - anchors.fill: parent - color: "steelblue" + globalDrawer: Kirigami.GlobalDrawer { + title: "Hello App" + titleIcon: "applications-graphics" + actions: [ + Kirigami.Action { + text: "View" + iconName: "view-list-icons" + Kirigami.Action { + text: "action 1" + } + Kirigami.Action { + text: "action 2" + } + Kirigami.Action { + text: "action 3" + } + }, + Kirigami.Action { + text: "action 3" + }, + Kirigami.Action { + text: "action 4" + } + ] } } diff --git a/src/qtquickcontrols2.conf b/src/qtquickcontrols2.conf new file mode 100644 index 0000000000000000000000000000000000000000..c22fe2d13d3c21438472f53f7d9939bf3ed407b0 --- /dev/null +++ b/src/qtquickcontrols2.conf @@ -0,0 +1,15 @@ +; This file can be edited to change the style of the application +; See Styling Qt Quick Controls 2 in the documentation for details: +; http://doc.qt.io/qt-5/qtquickcontrols2-styles.html + +[Controls] +Style=Material + +[Universal] +Theme=Light +;Accent=Steel + +[Material] +Theme=Light +Accent=BlueGrey +Primary=BlueGray diff --git a/src/resources.qrc b/src/resources.qrc index 7c75584cd789b1d6c32a3da82754fc9ce366ddcc..03ff85afb01ea42ffe11273fdbd834bdf1c067ca 100644 --- a/src/resources.qrc +++ b/src/resources.qrc @@ -1,5 +1,6 @@ qml/main.qml + qtquickcontrols2.conf