diff --git a/BasePopUp.qml b/NotifyModule/BasePopUp.qml similarity index 100% rename from BasePopUp.qml rename to NotifyModule/BasePopUp.qml diff --git a/NotifyModule/Metrix.qml b/NotifyModule/Metrix.qml new file mode 100644 index 0000000..f0bacc8 --- /dev/null +++ b/NotifyModule/Metrix.qml @@ -0,0 +1,27 @@ +import QtQuick 2.0 +import QtQuick.Window 2.12 +import QtQuick.Controls.Material 2.0 +import QtQuick.Controls 2.3 + +Item { + readonly property int pointCount: 100; + readonly property real mm: Screen.pixelDensity + readonly property real sm: 10 * mm + readonly property real dsm: Math.sqrt(Math.pow(Screen.desktopAvailableWidth, 2) + Math.pow(Screen.desktopAvailableHeight, 2)) / sm + readonly property real pt: getfactor(dsm) * sm + readonly property real controlPtMaterial: Material.buttonHeight + readonly property real gamePt: (width < height) ? width / pointCount : height / pointCount; + + function getfactor(dsm) { + if (dsm < 30) { + return 0.5 + } else if ( dsm < 70) { + return 1 + } else if (dsm < 140) { + return 2; + } else + return 4; + } + + anchors.fill: parent; +} diff --git a/NotificationForm.qml b/NotifyModule/NotificationForm.qml similarity index 100% rename from NotificationForm.qml rename to NotifyModule/NotificationForm.qml diff --git a/NotificationServiceView.qml b/NotifyModule/NotificationServiceView.qml similarity index 94% rename from NotificationServiceView.qml rename to NotifyModule/NotificationServiceView.qml index fb6d18e..4e3420f 100644 --- a/NotificationServiceView.qml +++ b/NotifyModule/NotificationServiceView.qml @@ -9,6 +9,9 @@ Item { readonly property var msg: model.notify readonly property var history: model.history + Metrix { + id: metrix + } NotificationForm { id: notyfyView diff --git a/NotifyModule/qmldir b/NotifyModule/qmldir new file mode 100644 index 0000000..68f7ce0 --- /dev/null +++ b/NotifyModule/qmldir @@ -0,0 +1,5 @@ +module NotifyModule +BasePopUp 1.0 BasePopUp.qml +NotificationForm 1.0 NotificationForm.qml +NotificationServiceView 1.0 NotificationServiceView.qml +Metrix 1.0 Metrix.qml diff --git a/QML.qrc b/QML.qrc index d760c9a..2eaf24b 100644 --- a/QML.qrc +++ b/QML.qrc @@ -1,7 +1,9 @@ - - NotificationServiceView.qml - NotificationForm.qml - BasePopUp.qml + + NotifyModule/qmldir + NotifyModule/NotificationServiceView.qml + NotifyModule/NotificationForm.qml + NotifyModule/BasePopUp.qml + NotifyModule/Metrix.qml diff --git a/QmlNotify.pri b/QmlNotify.pri index 866300e..aff355e 100644 --- a/QmlNotify.pri +++ b/QmlNotify.pri @@ -21,3 +21,10 @@ INCLUDEPATH += "$$PWD/" +QML2_IMPORT_PATH += \ + "$$PWD/" \ + "$$PWD/" + +QML_IMPORT_PATH += \ + "$$PWD/" \ + "$$PWD/" diff --git a/qmlnotifyservice.cpp b/qmlnotifyservice.cpp index c82697e..61664e4 100644 --- a/qmlnotifyservice.cpp +++ b/qmlnotifyservice.cpp @@ -7,10 +7,15 @@ namespace QmlNotificationService { bool init(QQmlApplicationEngine *engine) { + if (!engine) + return false; + auto root = engine->rootContext(); if (!root) return false; + engine->addImportPath(":/"); + root->setContextProperty("notificationService", NotificationService::getService()); return true; }