diff --git a/nymea-app/images.qrc b/nymea-app/images.qrc index 0ccb1f66..dabaebe0 100644 --- a/nymea-app/images.qrc +++ b/nymea-app/images.qrc @@ -256,5 +256,6 @@ ui/images/sensors/water.svg ui/images/zigbee/deCONZ.svg ui/images/zigbee/NXP.svg + ui/images/nymea-splash-horizontal.svg diff --git a/nymea-app/main.cpp b/nymea-app/main.cpp index fd342d19..377210aa 100644 --- a/nymea-app/main.cpp +++ b/nymea-app/main.cpp @@ -88,6 +88,8 @@ int main(int argc, char *argv[]) parser.addOption(defaultViewsOption); QCommandLineOption kioskOption = QCommandLineOption({"k", "kiosk"}, "Start the application in kiosk mode."); parser.addOption(kioskOption); + QCommandLineOption splashOption = QCommandLineOption({"p", "splash"}, "Show a splash screen on startup."); + parser.addOption(splashOption); parser.process(application); // Initialize app log controller as early as possible, but after setting app name etc @@ -152,6 +154,7 @@ int main(int argc, char *argv[]) engine->rootContext()->setContextProperty("defaultMainViewFilter", parser.value(defaultViewsOption)); engine->rootContext()->setContextProperty("kioskMode", parser.isSet(kioskOption)); + engine->rootContext()->setContextProperty("showSplash", parser.isSet(splashOption)); engine->rootContext()->setContextProperty("autoConnectHost", parser.value(connectOption)); engine->rootContext()->setContextProperty("systemProductType", QSysInfo::productType()); diff --git a/nymea-app/platformhelper.cpp b/nymea-app/platformhelper.cpp index 584f4e2f..fcf84a4b 100644 --- a/nymea-app/platformhelper.cpp +++ b/nymea-app/platformhelper.cpp @@ -84,7 +84,7 @@ void PlatformHelper::requestPermissions() void PlatformHelper::hideSplashScreen() { - // No splash screen by default... + setSplashVisible(false); } @@ -173,6 +173,19 @@ void PlatformHelper::setBottomPanelColor(const QColor &color) } } +bool PlatformHelper::splashVisible() const +{ + return m_splashVisible; +} + +void PlatformHelper::setSplashVisible(bool splashVisible) +{ + if (m_splashVisible != splashVisible) { + m_splashVisible = splashVisible; + emit splashVisibleChanged(); + } +} + void PlatformHelper::vibrate(PlatformHelper::HapticsFeedback feedbackType) { Q_UNUSED(feedbackType) diff --git a/nymea-app/platformhelper.h b/nymea-app/platformhelper.h index 90bfc9bf..f3ad8edb 100644 --- a/nymea-app/platformhelper.h +++ b/nymea-app/platformhelper.h @@ -47,6 +47,7 @@ class PlatformHelper : public QObject Q_PROPERTY(QString deviceModel READ deviceModel CONSTANT) Q_PROPERTY(QString deviceManufacturer READ deviceManufacturer CONSTANT) Q_PROPERTY(QString machineHostname READ machineHostname CONSTANT) + Q_PROPERTY(bool splashVisible READ splashVisible WRITE setSplashVisible NOTIFY splashVisibleChanged) Q_PROPERTY(bool canControlScreen READ canControlScreen CONSTANT) Q_PROPERTY(int screenTimeout READ screenTimeout WRITE setScreenTimeout NOTIFY screenTimeoutChanged) Q_PROPERTY(int screenBrightness READ screenBrightness WRITE setScreenBrightness NOTIFY screenBrightnessChanged) @@ -85,7 +86,11 @@ public: virtual QColor bottomPanelColor() const; virtual void setBottomPanelColor(const QColor &color); + virtual bool splashVisible() const; + virtual void setSplashVisible(bool splashVisible); Q_INVOKABLE virtual void hideSplashScreen(); + + Q_INVOKABLE virtual void vibrate(HapticsFeedback feedbackType); Q_INVOKABLE virtual void toClipBoard(const QString &text); @@ -100,6 +105,7 @@ signals: void screenBrightnessChanged(); void topPanelColorChanged(); void bottomPanelColorChanged(); + void splashVisibleChanged(); protected: explicit PlatformHelper(QObject *parent = nullptr); @@ -109,6 +115,8 @@ private: QColor m_topPanelColor = QColor("black"); QColor m_bottomPanelColor = QColor("black"); + + bool m_splashVisible = true; }; #endif // PLATFORMHELPER_H diff --git a/nymea-app/platformintegration/generic/platformhelpergeneric.cpp b/nymea-app/platformintegration/generic/platformhelpergeneric.cpp index ef26b297..b3e11788 100644 --- a/nymea-app/platformintegration/generic/platformhelpergeneric.cpp +++ b/nymea-app/platformintegration/generic/platformhelpergeneric.cpp @@ -32,12 +32,11 @@ #include "logging.h" -extern "C" { -#include -} Q_DECLARE_LOGGING_CATEGORY(dcPlatformIntegration) +#include + PlatformHelperGeneric::PlatformHelperGeneric(QObject *parent) : PlatformHelper(parent) { m_piHelper = new ScreenHelper(this); @@ -73,19 +72,3 @@ void PlatformHelperGeneric::setScreenBrightness(int percent) emit screenTimeoutChanged(); } } - -void PlatformHelperGeneric::hideSplashScreen() -{ - ply_event_loop_t *loop = ply_event_loop_new(); - ply_boot_client_t *client = ply_boot_client_new(); - bool status = ply_boot_client_connect(client, [] (void* data, ply_boot_client_t *) -> void { - PlatformHelperGeneric *thiz = reinterpret_cast(data); -// ply_event_loop_exit(this.loop, 0); -// ply_boot_client_free(client); - }, this); - if (!status) { - qCCritical(dcPlatformIntegration()) << "Cannot deactivate splash screen"; - } - ply_boot_client_attach_to_event_loop(client, loop); - ply_boot_client_tell_daemon_to_deactivate(client, nullptr, nullptr, nullptr); -} diff --git a/nymea-app/platformintegration/generic/platformhelpergeneric.h b/nymea-app/platformintegration/generic/platformhelpergeneric.h index bad548ff..7f6f15eb 100644 --- a/nymea-app/platformintegration/generic/platformhelpergeneric.h +++ b/nymea-app/platformintegration/generic/platformhelpergeneric.h @@ -35,6 +35,10 @@ #include "platformhelper.h" #include "screenhelper.h" +extern "C" { +#include +} + class PlatformHelperGeneric : public PlatformHelper { Q_OBJECT @@ -46,10 +50,11 @@ public: virtual void setScreenTimeout(int timeout) override; virtual int screenBrightness() const override; virtual void setScreenBrightness(int percent) override; - - virtual void hideSplashScreen() override; private: ScreenHelper *m_piHelper = nullptr; + + ply_event_loop_t *m_plyLoop = nullptr; + ply_boot_client_t *m_plyClient = nullptr; }; #endif // PLATFORMHELPERGENERIC_H diff --git a/nymea-app/ui/Nymea.qml b/nymea-app/ui/Nymea.qml index e5be9b25..57541941 100644 --- a/nymea-app/ui/Nymea.qml +++ b/nymea-app/ui/Nymea.qml @@ -556,4 +556,19 @@ ApplicationWindow { z: 1 anchors { left: parent.left; bottom: parent.bottom; right: parent.right } } + + Image { + id: splashScreen + parent: overlay + source: "/ui/images/nymea-splash-horizontal.svg" + anchors.fill: parent + fillMode: Image.PreserveAspectCrop + opacity: PlatformHelper.splashVisible ? 1 : 0 + Behavior on opacity { NumberAnimation {duration: 300 }} + visible: showSplash && opacity > 0 + antialiasing: true + smooth: true + sourceSize.width: Math.max(width, height) + sourceSize.height: sourceSize.width + } } diff --git a/nymea-app/ui/RootItem.qml b/nymea-app/ui/RootItem.qml index c2deef0b..c2698959 100644 --- a/nymea-app/ui/RootItem.qml +++ b/nymea-app/ui/RootItem.qml @@ -236,7 +236,6 @@ Item { if (engine.jsonRpcClient.connected) { pageStack.push(Qt.resolvedUrl("MainPage.qml")) - PlatformHelper.hideSplashScreen(); return; } @@ -414,6 +413,7 @@ Item { if (!engine.thingManager.fetchingData) { updatePushNotificationThings() } + PlatformHelper.hideSplashScreen(); } } diff --git a/nymea-app/ui/images/nymea-splash-horizontal.svg b/nymea-app/ui/images/nymea-splash-horizontal.svg new file mode 100644 index 00000000..8df2c405 --- /dev/null +++ b/nymea-app/ui/images/nymea-splash-horizontal.svg @@ -0,0 +1,821 @@ + + + + + + image/svg+xml + + Artboard 1 copy 5 Kopie 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Artboard 1 copy 5 Kopie 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packaging/linux-common/nymea-app-kiosk-wrapper b/packaging/linux-common/nymea-app-kiosk-wrapper index 793cb88c..6258b82c 100755 --- a/packaging/linux-common/nymea-app-kiosk-wrapper +++ b/packaging/linux-common/nymea-app-kiosk-wrapper @@ -1,5 +1,5 @@ #!/bin/sh export QT_IM_MODULE=qtvirtualkeyboard while [ true ]; do - /usr/bin/nymea-app --kiosk --connect nymeas://127.0.0.1:2222 + /usr/bin/nymea-app --kiosk --splash --connect nymeas://127.0.0.1:2222 done diff --git a/packaging/linux-common/nymea-app-kiosk.service b/packaging/linux-common/nymea-app-kiosk.service index be9bdeae..1cacb133 100644 --- a/packaging/linux-common/nymea-app-kiosk.service +++ b/packaging/linux-common/nymea-app-kiosk.service @@ -6,15 +6,16 @@ After=systemd-user-sessions.service Conflicts=plymouth-quit.service After=plymouth-quit.service -# lightdm takes responsibility for stopping plymouth, so if it fails +# nymea-app takes responsibility for stopping plymouth, so if it fails # for any reason, make sure plymouth still stops OnFailure=plymouth-quit.service [Service] -# temporary safety check until all DMs are converted to correct -# display-manager.service symlink handling -Environment=QT_QPA_EGLFS_ALWAYS_SET_MODE=1 QT_QPA_PLATFORM=eglfs -ExecStart=/usr/bin/nymea-app-kiosk-wrapper +Environment=QT_QPA_EGLFS_ALWAYS_SET_MODE=1 QT_QPA_PLATFORM=eglfs QT_IM_MODULE=qtvirtualkeyboard +ExecStart=/usr/bin/nymea-app --kiosk --splash --connect nymeas://127.0.0.1:2222 Restart=always User=nymea Group=nymea + +[Install] +WantedBy=multi-user.target diff --git a/packaging/linux-common/nymea-splash-horizontal.jpg b/packaging/linux-common/nymea-splash-horizontal.jpg new file mode 100755 index 00000000..d4dddd4d Binary files /dev/null and b/packaging/linux-common/nymea-splash-horizontal.jpg differ diff --git a/packaging/linux-common/nymea-splashscreen.service b/packaging/linux-common/nymea-splashscreen.service new file mode 100644 index 00000000..d6908d8f --- /dev/null +++ b/packaging/linux-common/nymea-splashscreen.service @@ -0,0 +1,13 @@ +[Unit] +Description=nymea sSplash screen +DefaultDependencies=no +After=local-fs.target + +[Service] +ExecStart=/usr/bin/fbi --noverbose -d /dev/fb0 -a /usr/share/nymea-splashscreen/nymea-splash-horizontal.jpg -fitwidth +StandardInput=tty +StandardOutput=tty +#TTYPath=/dev/tty1 + +[Install] +WantedBy=sysinit.target diff --git a/packaging/ubuntu/debian/control b/packaging/ubuntu/debian/control index b168cdca..2b4b441f 100644 --- a/packaging/ubuntu/debian/control +++ b/packaging/ubuntu/debian/control @@ -65,6 +65,19 @@ Section: shells Multi-Arch: same Depends: nymea-app, qtvirtualkeyboard-plugin, -Conflicts: nymea-app-kiosk-x11 +Conflicts: nymea-app-kiosk-x11, + lightdm +Replaces: nymea-app-kiosk +Provides: nymea-app-kiosk Description: Run nymea:app in kiosk mode This package will install nymea:app in kiosk mode on your machine (using wayland). + + +Package: nymea-splashscreen +Architecture: any +Section: shells +Multi-Arch: same +Depends: plymouth, +Description: A nymea branded fbi splash theme + This package will install a nymea branded boot splash using fbi. + diff --git a/packaging/ubuntu/debian/nymea-app-kiosk-wayland.install b/packaging/ubuntu/debian/nymea-app-kiosk-wayland.install index d025cfe1..2b84dd7c 100644 --- a/packaging/ubuntu/debian/nymea-app-kiosk-wayland.install +++ b/packaging/ubuntu/debian/nymea-app-kiosk-wayland.install @@ -1 +1,2 @@ packaging/linux-common/nymea-app-kiosk.service /lib/systemd/system/ +packaging/linux-common/udev/90-pi-backlight.rules /lib/udev/rules.d/ diff --git a/packaging/ubuntu/debian/nymea-splashscreen.install b/packaging/ubuntu/debian/nymea-splashscreen.install new file mode 100644 index 00000000..1acca22a --- /dev/null +++ b/packaging/ubuntu/debian/nymea-splashscreen.install @@ -0,0 +1,2 @@ +packaging/linux-common/nymea-splashscreen.service /lib/systemd/system/ +packaging/linux-common/nymea-splash-horizontal.jpg /usr/share/nymea-splashscreen/ diff --git a/packaging/ubuntu/debian/rules b/packaging/ubuntu/debian/rules index 41d42f22..71262a39 100755 --- a/packaging/ubuntu/debian/rules +++ b/packaging/ubuntu/debian/rules @@ -7,4 +7,4 @@ override_dh_missing: dh_missing --fail-missing %: - dh $@ --buildsystem=qmake --parallel + dh $@ --buildsystem=qmake --parallel --with systemd