From f2bb03c93b3b41ebb496012ebdc6c0206f6a3a78 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Mon, 6 Sep 2021 19:18:56 +0200 Subject: [PATCH 01/14] Add basic kde wallpaper support via Websockets This means: Set ScreenPlay as a Wallpaper ( see ScreenPlayWallpaper/kde/ScreenPlay) and start a video wallpaper. Nothing else works yet. --- Docs/DeveloperSetup.md | 4 +- ScreenPlay/src/createimportvideo.cpp | 10 +- ScreenPlay/src/screenplaymanager.cpp | 38 +++++++- ScreenPlay/src/screenplaymanager.h | 1 + ScreenPlay/src/screenplaywallpaper.cpp | 5 +- ScreenPlay/src/screenplaywallpaper.h | 11 ++- ScreenPlayWallpaper/kde/ScreenPlay/README.md | 5 + .../kde/ScreenPlay/contents/ui/main.qml | 93 +++++++------------ 8 files changed, 97 insertions(+), 70 deletions(-) diff --git a/Docs/DeveloperSetup.md b/Docs/DeveloperSetup.md index 45e2a1df..ea79e49a 100644 --- a/Docs/DeveloperSetup.md +++ b/Docs/DeveloperSetup.md @@ -32,7 +32,7 @@ py setup.py Append this: ``` bash -CMAKE_TOOLCHAIN_FILE:STRING=%{CurrentProject:Path}/../ScreenPlay-vcpkg/vcpkg/scripts/buildsystems/vcpkg.cmake +CMAKE_TOOLCHAIN_FILE:STRING=%{CurrentProject:Path}/../ScreenPlay-vcpkg/scripts/buildsystems/vcpkg.cmake # Only _one_ of these lines that match your OS: VCPKG_TARGET_TRIPLET:STRING=x64-windows VCPKG_TARGET_TRIPLET:STRING=x64-linux @@ -65,7 +65,7 @@ VCPKG_TARGET_TRIPLET:STRING=x64-osx 1. Install dependencies for your distro: ``` bash # Debian/Ubuntu -sudo apt install build-essential libgl1-mesa-dev lld ninja-build cmake +sudo apt install build-essential libgl1-mesa-dev lld ninja-build cmake git curl pkg-config ffmpeg qml-module-qt-websockets qtwebengine5-* # Fedora/RHEL/CentOS (yum) sudo yum groupinstall "C Development Tools and Libraries" diff --git a/ScreenPlay/src/createimportvideo.cpp b/ScreenPlay/src/createimportvideo.cpp index eaa3d85f..d1befbdf 100644 --- a/ScreenPlay/src/createimportvideo.cpp +++ b/ScreenPlay/src/createimportvideo.cpp @@ -38,6 +38,12 @@ CreateImportVideo::CreateImportVideo( m_videoPath = videoPath; m_exportPath = exportPath; m_codec = codec; + +#ifdef Q_OS_LINUX + // Use system ffmpeg + m_ffprobeExecutable = "ffprobe"; + m_ffmpegExecutable = "ffmpeg"; +#else m_ffprobeExecutable = QApplication::applicationDirPath() + "/ffprobe" + ScreenPlayUtil::executableBinEnding(); m_ffmpegExecutable = QApplication::applicationDirPath() + "/ffmpeg" + ScreenPlayUtil::executableBinEnding(); @@ -48,6 +54,7 @@ CreateImportVideo::CreateImportVideo( if (!QFileInfo::exists(m_ffmpegExecutable)) { qFatal("FFMPEG executable not found!"); } +#endif } /*! @@ -111,10 +118,9 @@ bool CreateImportVideo::createWallpaperInfo() } if (obj->empty()) { - qWarning() << "Error! File could not be parsed."; + qCritical() << "Error! File could not be parsed."; emit processOutput("Error! File could not be parsed."); emit createWallpaperStateChanged(ImportVideoState::ImportVideoState::AnalyseVideoError); - return false; } diff --git a/ScreenPlay/src/screenplaymanager.cpp b/ScreenPlay/src/screenplaymanager.cpp index 7110c713..a58f3f4c 100644 --- a/ScreenPlay/src/screenplaymanager.cpp +++ b/ScreenPlay/src/screenplaymanager.cpp @@ -87,6 +87,18 @@ void ScreenPlayManager::init( QObject::connect(m_websocketServer.get(), &QWebSocketServer::newConnection, this, [this]() { qInfo() << "New Websocket Connection"; auto* socket = m_websocketServer->nextPendingConnection(); + QObject::connect(socket, &QWebSocket::textMessageReceived, this, [this](const QString &message) { + qInfo() << "Message:" << message; + }); + QObject::connect(socket, &QWebSocket::disconnected, this, [this,socket]() { + m_connections.removeOne(socket); + qInfo() << "Disconnected connection count: " << m_connections.count(); + }); + + + m_connections.push_back(socket); + socket->sendTextMessage("asdasd"); + socket->flush(); }); } @@ -137,6 +149,22 @@ bool ScreenPlayManager::createWallpaper( const QString path = QUrl::fromUserInput(absoluteStoragePath).toLocalFile(); const QString appID = ScreenPlayUtil::generateRandomString(); + if(m_settings->desktopEnvironment() == Settings::DesktopEnvironment::KDE){ + if(m_connections.empty()) + return false; + + QJsonObject msg; + msg.insert("command", "replace"); + msg.insert("absolutePath", path); + msg.insert("type", static_cast(type)); + msg.insert("fillMode", static_cast(fillMode)); + msg.insert("volume", volume); + msg.insert("file", file); + + m_connections.first()->sendTextMessage(QJsonDocument(msg).toJson()); + m_connections.first()->flush(); + } + // Only support remove wallpaper that spans over 1 monitor if (monitorIndex.length() == 1) { int i = 0; @@ -172,14 +200,16 @@ bool ScreenPlayManager::createWallpaper( fillMode, type, properties, - m_settings->checkWallpaperVisible()); + m_settings); QObject::connect(wallpaper.get(), &ScreenPlayWallpaper::requestSave, this, &ScreenPlayManager::requestSaveProfiles); QObject::connect(wallpaper.get(), &ScreenPlayWallpaper::requestClose, this, &ScreenPlayManager::removeWallpaper); QObject::connect(wallpaper.get(), &ScreenPlayWallpaper::error, this, &ScreenPlayManager::displayErrorPopup); - if (!wallpaper->start()) { - return false; - } + if(m_settings->desktopEnvironment() != Settings::DesktopEnvironment::KDE){ + if (!wallpaper->start()) { + return false; + } + } m_screenPlayWallpapers.append(wallpaper); m_monitorListModel->setWallpaperMonitor(wallpaper, monitorIndex); increaseActiveWallpaperCounter(); diff --git a/ScreenPlay/src/screenplaymanager.h b/ScreenPlay/src/screenplaymanager.h index 6e76e86b..54655562 100644 --- a/ScreenPlay/src/screenplaymanager.h +++ b/ScreenPlay/src/screenplaymanager.h @@ -182,6 +182,7 @@ private: std::shared_ptr m_settings; std::unique_ptr m_server; std::unique_ptr m_websocketServer; + QVector m_connections; QVector> m_screenPlayWallpapers; QVector> m_screenPlayWidgets; diff --git a/ScreenPlay/src/screenplaywallpaper.cpp b/ScreenPlay/src/screenplaywallpaper.cpp index 384e6064..001dc7fb 100644 --- a/ScreenPlay/src/screenplaywallpaper.cpp +++ b/ScreenPlay/src/screenplaywallpaper.cpp @@ -25,7 +25,7 @@ ScreenPlayWallpaper::ScreenPlayWallpaper(const QVector& screenNumber, const FillMode::FillMode fillMode, const InstalledType::InstalledType type, const QJsonObject& properties, - const bool checkWallpaperVisible, + const std::shared_ptr& settings, QObject* parent) : QObject(parent) , m_globalVariables { globalVariables } @@ -38,6 +38,7 @@ ScreenPlayWallpaper::ScreenPlayWallpaper(const QVector& screenNumber, , m_file { file } , m_volume { volume } , m_playbackRate { playbackRate } + , m_settings { settings } { QJsonObject projectSettingsListModelProperties; @@ -82,7 +83,7 @@ ScreenPlayWallpaper::ScreenPlayWallpaper(const QVector& screenNumber, QString::number(static_cast(volume)), QVariant::fromValue(fillMode).toString(), QVariant::fromValue(type).toString(), - QString::number(checkWallpaperVisible), + QString::number(m_settings->checkWallpaperVisible()), // Fixes issue 84 media key overlay " --disable-features=HardwareMediaKeyHandling" }; diff --git a/ScreenPlay/src/screenplaywallpaper.h b/ScreenPlay/src/screenplaywallpaper.h index 4abfecb5..654db2c9 100644 --- a/ScreenPlay/src/screenplaywallpaper.h +++ b/ScreenPlay/src/screenplaywallpaper.h @@ -45,6 +45,7 @@ #include "projectsettingslistmodel.h" #include "sdkconnection.h" #include "util.h" +#include "settings.h" namespace ScreenPlay { @@ -76,12 +77,15 @@ public: const QString& absolutePath, const QString& previewImage, const QString& file, - const float volume, const float playbackRate, + const float volume, + const float playbackRate, const FillMode::FillMode fillMode, - const InstalledType::InstalledType type, const QJsonObject& properties, - const bool checkWallpaperVisible, + const InstalledType::InstalledType type, + const QJsonObject& properties, + const std::shared_ptr& settings, QObject* parent = nullptr); + bool start(); void replace( @@ -227,6 +231,7 @@ public slots: private: const std::shared_ptr m_globalVariables; std::unique_ptr m_connection; + const std::shared_ptr m_settings; ProjectSettingsListModel m_projectSettingsListModel; QVector m_screenNumber; diff --git a/ScreenPlayWallpaper/kde/ScreenPlay/README.md b/ScreenPlayWallpaper/kde/ScreenPlay/README.md index 67f337e7..c62e5229 100644 --- a/ScreenPlayWallpaper/kde/ScreenPlay/README.md +++ b/ScreenPlayWallpaper/kde/ScreenPlay/README.md @@ -6,6 +6,8 @@ Will not work because KDE uses the kpluginindex.json (that is actually a bz2 fil #### Installation ``` +sudo apt install qml-module-qt-websockets qtwebengine5-* + plasmapkg2 --install ScreenPlay ``` @@ -21,3 +23,6 @@ Because Wallpaper and Widgets are already a different application we can extend 1. Open Desktop Settings - Select Wallpaper type ScreenPlay +``` +plasmapkg2 --upgrade ScreenPlay ; kquitapp5 plasmashell; kstart5 plasmashell +``` \ No newline at end of file diff --git a/ScreenPlayWallpaper/kde/ScreenPlay/contents/ui/main.qml b/ScreenPlayWallpaper/kde/ScreenPlay/contents/ui/main.qml index 60285a0a..f5f07dbc 100644 --- a/ScreenPlayWallpaper/kde/ScreenPlay/contents/ui/main.qml +++ b/ScreenPlayWallpaper/kde/ScreenPlay/contents/ui/main.qml @@ -1,11 +1,13 @@ import QtQuick 2.11 +import QtQuick.Controls 2.0 import QtGraphicalEffects 1.0 -import QtQuick.Window 2.0 +import QtQuick.Window 2.15 import Qt.WebSockets 1.15 import QtWebEngine 1.8 Rectangle { id: root + color: "orange" property string fullContentPath property real volume: 1 @@ -15,28 +17,25 @@ Rectangle { function getSetVideoCommand() { // TODO 30: // Currently wont work. Commit anyways til QtCreator and Qt work with js template literals - var src = ""; - src += "var videoPlayer = document.getElementById('videoPlayer');"; - src += "var videoSource = document.getElementById('videoSource');"; - src += "videoSource.src = '" + root.fullContentPath + "';"; - src += "videoPlayer.load();"; - src += "videoPlayer.volume = " + root.volume + ";"; - src += "videoPlayer.setAttribute('style', 'object-fit :" + root.fillMode + ";');"; - src += "videoPlayer.play();"; - print(src); - return src; + var src = "" + src += "var videoPlayer = document.getElementById('videoPlayer');" + src += "var videoSource = document.getElementById('videoSource');" + src += "videoSource.src = '" + root.fullContentPath + "';" + src += "videoPlayer.load();" + src += "videoPlayer.volume = " + root.volume + ";" + src += "videoPlayer.setAttribute('style', 'object-fit :" + root.fillMode + ";');" + src += "videoPlayer.play();" + return src } - - color: "#333333" Component.onCompleted: { - WebEngine.settings.localContentCanAccessFileUrls = true; - WebEngine.settings.localContentCanAccessRemoteUrls = true; - WebEngine.settings.allowRunningInsecureContent = true; - WebEngine.settings.accelerated2dCanvasEnabled = true; - WebEngine.settings.javascriptCanOpenWindows = false; - WebEngine.settings.showScrollBars = false; - WebEngine.settings.playbackRequiresUserGesture = false; - WebEngine.settings.focusOnNavigationEnabled = true; + WebEngine.settings.localContentCanAccessFileUrls = true + WebEngine.settings.localContentCanAccessRemoteUrls = true + WebEngine.settings.allowRunningInsecureContent = true + WebEngine.settings.accelerated2dCanvasEnabled = true + WebEngine.settings.javascriptCanOpenWindows = false + WebEngine.settings.showScrollBars = false + WebEngine.settings.playbackRequiresUserGesture = false + WebEngine.settings.focusOnNavigationEnabled = true } WebSocket { @@ -45,21 +44,24 @@ Rectangle { url: "ws://127.0.0.1:16395" active: true onStatusChanged: { - if (socket.status === WebSocket.Error) - messageBox.text = "Error: " + socket.errorString; - else if (socket.status === WebSocket.Open) - socket.sendTextMessage("Hello World"); - else if (socket.status === WebSocket.Closed) - messageBox.text += "Socket closed"; + if (socket.status === WebSocket.Open) + socket.sendTextMessage("Hello World from QML wallpaper") } + onTextMessageReceived: { - var obj = JSON.parse(message); + socket.sendTextMessage(message) + + var obj = JSON.parse(message) + if (obj.command === "replace") { - root.type = obj.type; - root.fillMode = obj.fillMode; - root.volume = obj.volume; - root.fullContentPath = obj.absolutePath + "/" + obj.file; - webView.setVideo(); + socket.sendTextMessage("replace") + root.type = obj.type + //root.fillMode = obj.fillMode + root.volume = obj.volume + root.fullContentPath = obj.absolutePath + "/" + obj.file + const msg = "JSON: " +root.type + root.fillMode + root.volume + root.fullContentPath; + socket.sendTextMessage(root.getSetVideoCommand()) + webView.setVideo() } } } @@ -70,31 +72,8 @@ Rectangle { function setVideo() { webView.runJavaScript(root.getSetVideoCommand()); } - + url:"index.html" anchors.fill: parent opacity: loadProgress === 100 ? 1 : 0 - onLoadProgressChanged: { - if (loadProgress === 100) - setVideo(); - - } } - - Rectangle { - id: infoWrapper - - width: 300 - height: 200 - opacity: 0 - anchors.centerIn: parent - - Text { - id: messageBox - - text: qsTr("text") - anchors.centerIn: parent - } - - } - } From 9ef52a33812663e15893dd476667bb07dd3107b4 Mon Sep 17 00:00:00 2001 From: Graphicscore Date: Sat, 16 Oct 2021 20:44:22 +0200 Subject: [PATCH 02/14] Add libarchive --- ScreenPlay/CMakeLists.txt | 7 +++++-- Tools/setup.py | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ScreenPlay/CMakeLists.txt b/ScreenPlay/CMakeLists.txt index 8c35f42a..642e9609 100644 --- a/ScreenPlay/CMakeLists.txt +++ b/ScreenPlay/CMakeLists.txt @@ -185,7 +185,9 @@ qt_add_big_resources(FONTS fonts.qrc) add_library(ScreenPlayLib ${SOURCES} ${HEADER} ${RESOURCES} ${FONTS}) -target_include_directories(ScreenPlayLib PUBLIC ./ src/) +target_include_directories(ScreenPlayLib PUBLIC ./ src/ ${LibArchive_INCLUDE_DIRS}) + +find_package(LibArchive REQUIRED) target_link_libraries( ScreenPlayLib @@ -203,7 +205,8 @@ target_link_libraries( Qt6::WebSockets Qt6::Svg Qt6::WebEngineQuick - Qt6::WebEngineCore) + Qt6::WebEngineCore + ${LibArchive_LIBRARIES}) if(${TESTS_ENABLED}) add_executable(tst_ScreenPlay tests/tst_main.cpp) diff --git a/Tools/setup.py b/Tools/setup.py index f402f0b3..a01fe7c9 100644 --- a/Tools/setup.py +++ b/Tools/setup.py @@ -31,7 +31,7 @@ if __name__ == "__main__": vcpkg_path = os.path.join(project_source_parent_path, "ScreenPlay-vcpkg") print("vcpkg_path: ", vcpkg_path) - vcpkg_version = "9172179c513aa84308e48b8dd0e3df90acec7204" # Master 25.06.2021 + vcpkg_version = "c1bd850c629977b98b71bd7a6ab6b7949a5f07e6" # Master 25.06.2021 print("Build vcpkg ", vcpkg_version) execute("git fetch", vcpkg_path) execute("git checkout {}".format(vcpkg_version), vcpkg_path) @@ -42,6 +42,7 @@ if __name__ == "__main__": "sentry-native", "doctest", "benchmark", + "libarchive", ] vcpkg_triplet = "" From 78eeec80803281932f0f6984071b8e3421be464d Mon Sep 17 00:00:00 2001 From: Graphicscore Date: Sat, 16 Oct 2021 20:44:50 +0200 Subject: [PATCH 03/14] Fix workshop not compiling for linux --- ScreenPlayWorkshop/CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ScreenPlayWorkshop/CMakeLists.txt b/ScreenPlayWorkshop/CMakeLists.txt index 1184246d..55ab3025 100644 --- a/ScreenPlayWorkshop/CMakeLists.txt +++ b/ScreenPlayWorkshop/CMakeLists.txt @@ -7,7 +7,7 @@ set(CMAKE_CXX_STANDARD 20) find_package( Qt6 - COMPONENTS Quick QML Widgets Gui + COMPONENTS Quick Widgets Gui REQUIRED) set(SOURCES @@ -99,6 +99,5 @@ else() if(${SCREENPLAY_STEAM}) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/steam_appid.txt ${CMAKE_BINARY_DIR}/bin/steam_appid.txt COPYONLY) endif() - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/qmldir ${WORKSHOP_PLUGIN_DIR}/qmldir COPYONLY) configure_file(${STEAM_BIN} ${CMAKE_BINARY_DIR}/bin/ COPYONLY) endif() From 172995e1f83949dcd5d06977e32f94a2339f6a84 Mon Sep 17 00:00:00 2001 From: Graphicscore Date: Mon, 25 Oct 2021 19:31:49 +0200 Subject: [PATCH 04/14] Remove debug string being send to wallpaper process --- ScreenPlay/src/screenplaymanager.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/ScreenPlay/src/screenplaymanager.cpp b/ScreenPlay/src/screenplaymanager.cpp index f0f2e997..2d9667c3 100644 --- a/ScreenPlay/src/screenplaymanager.cpp +++ b/ScreenPlay/src/screenplaymanager.cpp @@ -97,7 +97,6 @@ void ScreenPlayManager::init( m_connections.push_back(socket); - socket->sendTextMessage("asdasd"); socket->flush(); }); } From 0957975eac5f85ee566c3dd099cc9d600e863e2b Mon Sep 17 00:00:00 2001 From: Graphicscore Date: Mon, 25 Oct 2021 19:32:09 +0200 Subject: [PATCH 05/14] Basic KDE video playback without loops lagging --- .../kde/ScreenPlay/contents/ui/main.qml | 125 ++++++++++++------ 1 file changed, 81 insertions(+), 44 deletions(-) diff --git a/ScreenPlayWallpaper/kde/ScreenPlay/contents/ui/main.qml b/ScreenPlayWallpaper/kde/ScreenPlay/contents/ui/main.qml index 7afbbed6..faf198b1 100644 --- a/ScreenPlayWallpaper/kde/ScreenPlay/contents/ui/main.qml +++ b/ScreenPlayWallpaper/kde/ScreenPlay/contents/ui/main.qml @@ -1,41 +1,75 @@ -import QtQuick 2.11 -import QtQuick.Controls 2.0 -import QtGraphicalEffects 1.0 -import QtQuick.Window 2.15 -import Qt.WebSockets 1.15 +import QtQuick 2.0 +import QtQuick.Controls 2.12 +import QtWebSockets 1.1 import QtWebEngine 1.8 +import QtMultimedia 5.12 + Rectangle { id: root color: "orange" + anchors.fill: parent property string fullContentPath property real volume: 1 property string fillMode: "Cover" property string type + property string projectSourceFileAbsolute + property bool loops: true + + MediaPlayer { + id: player1 + volume: root.volume + source: root.projectSourceFileAbsolute + onStopped: { + //if(wallpaper.configuration.DualPlayback){ + videoOutput1.visible = false + videoOutput2.visible = true + if(player2.source != root.projectSourceFileAbsolute){ + player2.source = root.projectSourceFileAbsolute + } + player1.play() + player1.pause() + player2.play() + /*}else{ + if(player2.source == root.projectSourceFileAbsolute){ + player2.stop() + player2.source = '' + } + player1.play() + }*/ + } + } + + MediaPlayer { + id: player2 + volume: root.volume + onStopped: { + videoOutput2.visible = false + videoOutput1.visible = true + player2.play() + player2.pause() + player1.play() + } + } + + + VideoOutput { + id: videoOutput1 + fillMode: VideoOutput.PreserveAspectCrop + anchors.fill: parent + source: player1 + } + + VideoOutput { + id: videoOutput2 + fillMode: VideoOutput.PreserveAspectCrop + anchors.fill: parent + source: player2 + } - function getSetVideoCommand() { - // TODO 30: - // Currently wont work. Commit anyways til QtCreator and Qt work with js template literals - var src = "" - src += "var videoPlayer = document.getElementById('videoPlayer');" - src += "var videoSource = document.getElementById('videoSource');" - src += "videoSource.src = '" + root.fullContentPath + "';" - src += "videoPlayer.load();" - src += "videoPlayer.volume = " + root.volume + ";" - src += "videoPlayer.setAttribute('style', 'object-fit :" + root.fillMode + ";');" - src += "videoPlayer.play();" - return src - } Component.onCompleted: { - WebEngine.settings.localContentCanAccessFileUrls = true - WebEngine.settings.localContentCanAccessRemoteUrls = true - WebEngine.settings.allowRunningInsecureContent = true - WebEngine.settings.accelerated2dCanvasEnabled = true - WebEngine.settings.javascriptCanOpenWindows = false - WebEngine.settings.showScrollBars = false - WebEngine.settings.playbackRequiresUserGesture = false - WebEngine.settings.focusOnNavigationEnabled = true + } WebSocket { @@ -48,33 +82,36 @@ Rectangle { socket.sendTextMessage("Hello World from QML wallpaper") } - onTextMessageReceived: { + onTextMessageReceived: (message)=> { socket.sendTextMessage(message) print(message) var obj = JSON.parse(message) if (obj.command === "replace") { - socket.sendTextMessage("replace") + socket.sendTextMessage("replace") root.type = obj.type - //root.fillMode = obj.fillMode + root.fillMode = obj.fillMode root.volume = obj.volume - root.fullContentPath = obj.absolutePath + "/" + obj.file - const msg = "JSON: " +root.type + root.fillMode + root.volume + root.fullContentPath; - socket.sendTextMessage(root.getSetVideoCommand()) - webView.setVideo() - } - } - } + root.projectSourceFileAbsolute = "file://" + obj.absolutePath + "/" + obj.file + print("got: " + root.projectSourceFileAbsolute) + //mediaplayer.source = root.projectSourceFileAbsolute + //mediaplayer.play() + //videplayer.source = root.projectSourceFileAbsolute + //playlist.addItem(root.projectSourceFileAbsolute) + //playlist.addItem(root.projectSourceFileAbsolute) + //videplayer.play() - WebEngineView { - id: webView - - function setVideo() { - webView.runJavaScript(root.getSetVideoCommand()); + videoOutput2.visible = false + videoOutput1.visible = true + + //if(wallpaper.configuration.DualPlayback){ + player2.source = root.projectSourceFileAbsolute + player2.play() + player2.pause() + //} + player1.play() + } } - url:"index.html" - anchors.fill: parent - opacity: loadProgress === 100 ? 1 : 0 } } From 96f9621038a288c1b0ae41cfa444a2bba86bdebe Mon Sep 17 00:00:00 2001 From: Graphicscore Date: Wed, 27 Oct 2021 18:42:12 +0200 Subject: [PATCH 06/14] Implement support for KDE wallpaper being started prior to ScreenPlay --- .../contents/ui/WaitingForScreenplay.qml | 74 +++++++++++ .../kde/ScreenPlay/contents/ui/Wallpaper.qml | 110 +++++++++++++++++ .../contents/ui/WallpaperContainer.qml | 42 +++++++ .../kde/ScreenPlay/contents/ui/main.qml | 116 +----------------- 4 files changed, 230 insertions(+), 112 deletions(-) create mode 100644 ScreenPlayWallpaper/kde/ScreenPlay/contents/ui/WaitingForScreenplay.qml create mode 100644 ScreenPlayWallpaper/kde/ScreenPlay/contents/ui/Wallpaper.qml create mode 100644 ScreenPlayWallpaper/kde/ScreenPlay/contents/ui/WallpaperContainer.qml diff --git a/ScreenPlayWallpaper/kde/ScreenPlay/contents/ui/WaitingForScreenplay.qml b/ScreenPlayWallpaper/kde/ScreenPlay/contents/ui/WaitingForScreenplay.qml new file mode 100644 index 00000000..deda4063 --- /dev/null +++ b/ScreenPlayWallpaper/kde/ScreenPlay/contents/ui/WaitingForScreenplay.qml @@ -0,0 +1,74 @@ +import QtQuick 2.15 + +Rectangle { + anchors.fill: parent + color: "black" + + Rectangle { + id: toBeCreated + anchors.fill: parent + color: "black" + opacity: 0 + + Text { + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + wrapMode: Text.WordWrap + anchors.centerIn: parent + text: qsTr("Please start ScreenPlay before launching the wallpaper") + color: "White" + font.pixelSize: 50 + } + + OpacityAnimator on opacity{ + id: createAnimation + from: 0; + to: 1; + duration: 1000 + onRunningChanged: { + if(!running){ + toBeDeleted.opacity = 1 + toBeCreated.opacity = 0 + destroyAnimation.start() + } + } + } + Component.onCompleted: { + createAnimation.start() + } + } + + Rectangle { + opacity: 0 + id: toBeDeleted + anchors.fill: parent + color: "black" + + Text { + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + wrapMode: Text.WordWrap + anchors.centerIn: parent + text: qsTr("Please start ScreenPlay before launching the wallpaper") + color: "White" + font.pixelSize: 50 + } + + OpacityAnimator on opacity{ + id: destroyAnimation + from: 1; + to: 0; + duration: 1000 + running: false + onRunningChanged: { + if(!running){ + toBeDeleted.opacity = 0 + toBeCreated.opacity = 0 + createAnimation.start() + } + } + } + } +} + + diff --git a/ScreenPlayWallpaper/kde/ScreenPlay/contents/ui/Wallpaper.qml b/ScreenPlayWallpaper/kde/ScreenPlay/contents/ui/Wallpaper.qml new file mode 100644 index 00000000..4f029643 --- /dev/null +++ b/ScreenPlayWallpaper/kde/ScreenPlay/contents/ui/Wallpaper.qml @@ -0,0 +1,110 @@ +import QtQuick 2.0 +import QtQuick.Controls 2.12 +import QtWebSockets 1.1 +import QtWebEngine 1.8 +import QtMultimedia 5.12 + + +Rectangle { + id: root + color: "black" + anchors.fill: parent + + property string fullContentPath + property real volume: 1 + property string fillMode: "Cover" + property string type + property string projectSourceFileAbsolute + property bool loops: true + + MediaPlayer { + id: player1 + volume: root.volume + source: root.projectSourceFileAbsolute + onStopped: { + videoOutput1.visible = false + videoOutput2.visible = true + if(player2.source != root.projectSourceFileAbsolute){ + player2.source = root.projectSourceFileAbsolute + } + player1.play() + player1.pause() + player2.play() + } + } + + MediaPlayer { + id: player2 + volume: root.volume + onStopped: { + videoOutput2.visible = false + videoOutput1.visible = true + player2.play() + player2.pause() + player1.play() + } + } + + + VideoOutput { + id: videoOutput1 + fillMode: VideoOutput.PreserveAspectCrop + anchors.fill: parent + source: player1 + } + + VideoOutput { + id: videoOutput2 + fillMode: VideoOutput.PreserveAspectCrop + anchors.fill: parent + source: player2 + } + + Component.onCompleted: { + print("test") + } + + WebSocket { + id: socket + + url: "ws://127.0.0.1:16395" + active: true + onStatusChanged: { + if (socket.status === WebSocket.Open) + socket.sendTextMessage("Hello World from QML wallpaper") + } + + onTextMessageReceived: (message)=> { + socket.sendTextMessage(message) + print(message) + + var obj = JSON.parse(message) + wp.connected = true + + if (obj.command === "replace") { + socket.sendTextMessage("replace") + root.type = obj.type + root.fillMode = obj.fillMode + root.volume = obj.volume + root.projectSourceFileAbsolute = "file://" + obj.absolutePath + "/" + obj.file + print("got: " + root.projectSourceFileAbsolute) + //mediaplayer.source = root.projectSourceFileAbsolute + //mediaplayer.play() + //videplayer.source = root.projectSourceFileAbsolute + //playlist.addItem(root.projectSourceFileAbsolute) + //playlist.addItem(root.projectSourceFileAbsolute) + //videplayer.play() + + videoOutput2.visible = false + videoOutput1.visible = true + + //if(wallpaper.configuration.DualPlayback){ + player2.source = root.projectSourceFileAbsolute + player2.play() + player2.pause() + //} + player1.play() + } + } + } +} diff --git a/ScreenPlayWallpaper/kde/ScreenPlay/contents/ui/WallpaperContainer.qml b/ScreenPlayWallpaper/kde/ScreenPlay/contents/ui/WallpaperContainer.qml new file mode 100644 index 00000000..d7998261 --- /dev/null +++ b/ScreenPlayWallpaper/kde/ScreenPlay/contents/ui/WallpaperContainer.qml @@ -0,0 +1,42 @@ +import QtQuick 2.0 +import QtQuick.Controls 2.12 +import QtWebSockets 1.1 +import QtWebEngine 1.8 +import QtMultimedia 5.12 + + +Rectangle { + id: container + anchors.fill: parent + + Loader { + id: wp + anchors.fill: parent + source: "Wallpaper.qml" + property bool connected: false + + Timer { + id: connectTimer + interval: 1000 + running: true + repeat: true + onTriggered: { + if(!wp.connected){ + console.log("not connected") + wp.source = "" + wp.source = "Wallpaper.qml" + } else { + console.log("connected") + screensaver.visible = false + connectTimer.stop() + } + } + } + } + + Loader { + anchors.fill: parent + id: screensaver + source: "WaitingForScreenplay.qml" + } +} diff --git a/ScreenPlayWallpaper/kde/ScreenPlay/contents/ui/main.qml b/ScreenPlayWallpaper/kde/ScreenPlay/contents/ui/main.qml index faf198b1..503f74ee 100644 --- a/ScreenPlayWallpaper/kde/ScreenPlay/contents/ui/main.qml +++ b/ScreenPlayWallpaper/kde/ScreenPlay/contents/ui/main.qml @@ -1,117 +1,9 @@ -import QtQuick 2.0 -import QtQuick.Controls 2.12 -import QtWebSockets 1.1 -import QtWebEngine 1.8 -import QtMultimedia 5.12 +import QtQuick 2.15 +import QtQuick.Window 2.15 -Rectangle { - id: root - color: "orange" - anchors.fill: parent - - property string fullContentPath - property real volume: 1 - property string fillMode: "Cover" - property string type - property string projectSourceFileAbsolute - property bool loops: true - - MediaPlayer { - id: player1 - volume: root.volume - source: root.projectSourceFileAbsolute - onStopped: { - //if(wallpaper.configuration.DualPlayback){ - videoOutput1.visible = false - videoOutput2.visible = true - if(player2.source != root.projectSourceFileAbsolute){ - player2.source = root.projectSourceFileAbsolute - } - player1.play() - player1.pause() - player2.play() - /*}else{ - if(player2.source == root.projectSourceFileAbsolute){ - player2.stop() - player2.source = '' - } - player1.play() - }*/ - } - } - - MediaPlayer { - id: player2 - volume: root.volume - onStopped: { - videoOutput2.visible = false - videoOutput1.visible = true - player2.play() - player2.pause() - player1.play() - } - } +WallpaperContainer { - VideoOutput { - id: videoOutput1 - fillMode: VideoOutput.PreserveAspectCrop - anchors.fill: parent - source: player1 - } - - VideoOutput { - id: videoOutput2 - fillMode: VideoOutput.PreserveAspectCrop - anchors.fill: parent - source: player2 - } - - Component.onCompleted: { - - } - - WebSocket { - id: socket - - url: "ws://127.0.0.1:16395" - active: true - onStatusChanged: { - if (socket.status === WebSocket.Open) - socket.sendTextMessage("Hello World from QML wallpaper") - } - - onTextMessageReceived: (message)=> { - socket.sendTextMessage(message) - print(message) - - var obj = JSON.parse(message) - - if (obj.command === "replace") { - socket.sendTextMessage("replace") - root.type = obj.type - root.fillMode = obj.fillMode - root.volume = obj.volume - root.projectSourceFileAbsolute = "file://" + obj.absolutePath + "/" + obj.file - print("got: " + root.projectSourceFileAbsolute) - //mediaplayer.source = root.projectSourceFileAbsolute - //mediaplayer.play() - //videplayer.source = root.projectSourceFileAbsolute - //playlist.addItem(root.projectSourceFileAbsolute) - //playlist.addItem(root.projectSourceFileAbsolute) - //videplayer.play() - - videoOutput2.visible = false - videoOutput1.visible = true - - //if(wallpaper.configuration.DualPlayback){ - player2.source = root.projectSourceFileAbsolute - player2.play() - player2.pause() - //} - player1.play() - } - } - } } + From e6272e0db50f83865c2802bc33249bd1ec105ccc Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Mon, 8 Nov 2021 19:49:51 +0100 Subject: [PATCH 07/14] Refactor KDE plugin to work at any state... ... ScreenPlay no longer needs to run before the wallpaper. This paves the way to start the wallpaper from QSettings even when the main application is not running. Add quit command and action --- ScreenPlay/src/screenplaymanager.cpp | 18 ++- .../kde/ScreenPlay/contents/ui/Wallpaper.qml | 74 +++++------- .../kde/ScreenPlay/contents/ui/main.qml | 112 +++++++++++++++++- ScreenPlayWorkshop/CMakeLists.txt | 2 +- 4 files changed, 154 insertions(+), 52 deletions(-) diff --git a/ScreenPlay/src/screenplaymanager.cpp b/ScreenPlay/src/screenplaymanager.cpp index 2d9667c3..29e53f3d 100644 --- a/ScreenPlay/src/screenplaymanager.cpp +++ b/ScreenPlay/src/screenplaymanager.cpp @@ -83,7 +83,8 @@ void ScreenPlayManager::init( if (m_settings->desktopEnvironment() == Settings::DesktopEnvironment::KDE) { m_websocketServer = std::make_unique(QStringLiteral("ScreenPlayWebSocket"), QWebSocketServer::SslMode::NonSecureMode); - m_websocketServer->listen(QHostAddress::Any, m_webSocketPort); + const bool success = m_websocketServer->listen(QHostAddress::Any, m_webSocketPort); + qInfo() << "Open Websocket:" << success << "port:" <nextPendingConnection(); @@ -97,7 +98,7 @@ void ScreenPlayManager::init( m_connections.push_back(socket); - socket->flush(); + // socket->flush(); }); } @@ -127,6 +128,7 @@ bool ScreenPlayManager::createWallpaper( const QJsonObject& properties, const bool saveToProfilesConfigFile) { + const int screenCount = QGuiApplication::screens().count(); QJsonArray monitors; @@ -283,6 +285,16 @@ bool ScreenPlayManager::removeAllWallpapers() return false; } } + if(m_settings->desktopEnvironment() == Settings::DesktopEnvironment::KDE){ + for(auto& connection : m_connections){ + QJsonObject obj; + obj.insert("command", "quit"); + connection->sendTextMessage(QJsonDocument(obj).toJson(QJsonDocument::Compact)); + connection->flush(); + connection->close(); + } + + } emit requestSaveProfiles(); @@ -456,6 +468,8 @@ bool ScreenPlayManager::removeWallpaper(const QString& appID) if (wallpaper->appID() != appID) { return false; } + if(m_settings->desktopEnvironment() == Settings::DesktopEnvironment::Windows || + m_settings->desktopEnvironment() == Settings::DesktopEnvironment::OSX) wallpaper->messageQuit(); qInfo() << "Remove wallpaper " << wallpaper->file() << "at monitor " << wallpaper->screenNumber(); diff --git a/ScreenPlayWallpaper/kde/ScreenPlay/contents/ui/Wallpaper.qml b/ScreenPlayWallpaper/kde/ScreenPlay/contents/ui/Wallpaper.qml index 4f029643..15d0d782 100644 --- a/ScreenPlayWallpaper/kde/ScreenPlay/contents/ui/Wallpaper.qml +++ b/ScreenPlayWallpaper/kde/ScreenPlay/contents/ui/Wallpaper.qml @@ -3,6 +3,7 @@ import QtQuick.Controls 2.12 import QtWebSockets 1.1 import QtWebEngine 1.8 import QtMultimedia 5.12 +import Qt.labs.settings 1.1 Rectangle { @@ -17,14 +18,38 @@ Rectangle { property string projectSourceFileAbsolute property bool loops: true + function stop(){ + player1.stop() + player2.stop() + videoOutput1.visible = false + videoOutput2.visible = false + root.enabled = false + } + + function play(){ + root.enabled = true + videoOutput2.visible = false + videoOutput1.visible = true + + //if(wallpaper.configuration.DualPlayback){ + player2.source = root.projectSourceFileAbsolute + player2.play() + player2.pause() + //} + player1.play() + } + MediaPlayer { id: player1 volume: root.volume source: root.projectSourceFileAbsolute onStopped: { + if(!root.enabled) + return + videoOutput1.visible = false videoOutput2.visible = true - if(player2.source != root.projectSourceFileAbsolute){ + if(player2.source !== root.projectSourceFileAbsolute){ player2.source = root.projectSourceFileAbsolute } player1.play() @@ -37,6 +62,8 @@ Rectangle { id: player2 volume: root.volume onStopped: { + if(!root.enabled) + return videoOutput2.visible = false videoOutput1.visible = true player2.play() @@ -60,51 +87,6 @@ Rectangle { source: player2 } - Component.onCompleted: { - print("test") - } - WebSocket { - id: socket - url: "ws://127.0.0.1:16395" - active: true - onStatusChanged: { - if (socket.status === WebSocket.Open) - socket.sendTextMessage("Hello World from QML wallpaper") - } - - onTextMessageReceived: (message)=> { - socket.sendTextMessage(message) - print(message) - - var obj = JSON.parse(message) - wp.connected = true - - if (obj.command === "replace") { - socket.sendTextMessage("replace") - root.type = obj.type - root.fillMode = obj.fillMode - root.volume = obj.volume - root.projectSourceFileAbsolute = "file://" + obj.absolutePath + "/" + obj.file - print("got: " + root.projectSourceFileAbsolute) - //mediaplayer.source = root.projectSourceFileAbsolute - //mediaplayer.play() - //videplayer.source = root.projectSourceFileAbsolute - //playlist.addItem(root.projectSourceFileAbsolute) - //playlist.addItem(root.projectSourceFileAbsolute) - //videplayer.play() - - videoOutput2.visible = false - videoOutput1.visible = true - - //if(wallpaper.configuration.DualPlayback){ - player2.source = root.projectSourceFileAbsolute - player2.play() - player2.pause() - //} - player1.play() - } - } - } } diff --git a/ScreenPlayWallpaper/kde/ScreenPlay/contents/ui/main.qml b/ScreenPlayWallpaper/kde/ScreenPlay/contents/ui/main.qml index 503f74ee..e31b4ff0 100644 --- a/ScreenPlayWallpaper/kde/ScreenPlay/contents/ui/main.qml +++ b/ScreenPlayWallpaper/kde/ScreenPlay/contents/ui/main.qml @@ -1,8 +1,114 @@ -import QtQuick 2.15 -import QtQuick.Window 2.15 +import QtQuick 2.0 +import QtQuick.Controls 2.12 +import QtWebSockets 1.1 +import QtWebEngine 1.8 +import QtMultimedia 5.12 +import Qt.labs.settings 1.1 -WallpaperContainer { +Rectangle { + id:root + color:"orange" + property bool connected: false + + Settings { + id:settings + } + + Component.onCompleted: { + wallpaper.projectSourceFileAbsolute = settings.value("SP_projectSourceFileAbsolute","NULL") +// if(root.projectSourceFileAbsolute === "NULL") +// return + + wallpaper.type = settings.value("SP_type") + wallpaper.fillMode = settings.value("SP_fillMode") + wallpaper.volume = settings.value("SP_volume") + wallpaper.play() + } + + + Wallpaper { + id:wallpaper + anchors.fill: parent + // visible: root.connected + + onFullContentPathChanged: settings.setValue("SP_fullContentPath",fullContentPath) + onVolumeChanged: settings.setValue("SP_volume",volume) + onFillModeChanged: settings.setValue("SP_fillMode",fillMode) + onTypeChanged: settings.setValue("SP_type",type) + onProjectSourceFileAbsoluteChanged: settings.setValue("SP_projectSourceFileAbsolute",projectSourceFileAbsolute) + onLoopsChanged: settings.setValue("SP_loops",loops) + + } + + Timer { + id:reconnectTimer + interval: 1000 + running: true + repeat: true + onTriggered: { + if (socket.status === WebSocket.Open) + return + socket.active = false + socket.active = true + reconnectTimer.retryCounter += 1 + } + property int retryCounter: 0 + } + + WebSocket { + id: socket + url: "ws://127.0.0.1:16395" + onStatusChanged: { + if (socket.status === WebSocket.Open) + socket.sendTextMessage("Hello World from QML wallpaper") + } + + onTextMessageReceived: (message)=> { + + var obj = JSON.parse(message) + root.connected = true + txtCommand.text = obj.command + + if (obj.command === "replace") { + socket.sendTextMessage("replace") + wallpaper.type = obj.type + wallpaper.fillMode = obj.fillMode + wallpaper.volume = obj.volume + wallpaper.projectSourceFileAbsolute = "file://" + obj.absolutePath + "/" + obj.file + print("got: " + root.projectSourceFileAbsolute) + wallpaper.play() + return; + } + if(obj.command === "quit"){ + wallpaper.stop() + } + } + } +// WaitingForScreenplay { +// anchors.fill: parent +// visible: !root.connected +// } + Column { + anchors { + horizontalCenter: parent.horizontalCenter + bottom: parent.bottom + margins: 60 + } + Text { + id:txtCommand + color: "white" + } + Text { + color: "white" + text:wallpaper.type + wallpaper.projectSourceFileAbsolute + } + Text { + color: "white" + text:"Actitve: " +socket.active +" status: "+ socket.status + " reconnectTimer.retryCounter : "+ reconnectTimer.retryCounter + } + } + } diff --git a/ScreenPlayWorkshop/CMakeLists.txt b/ScreenPlayWorkshop/CMakeLists.txt index 740c89c9..cd3f553a 100644 --- a/ScreenPlayWorkshop/CMakeLists.txt +++ b/ScreenPlayWorkshop/CMakeLists.txt @@ -92,6 +92,6 @@ if(APPLE) else() if(${SCREENPLAY_STEAM}) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/steam_appid.txt ${CMAKE_BINARY_DIR}/bin/steam_appid.txt COPYONLY) - endif() configure_file(${STEAM_BIN} ${CMAKE_BINARY_DIR}/bin/ COPYONLY) + endif() endif() From 6bd7deaa43231ac533f05b2fac7ea4e3501b2ce2 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Thu, 2 Dec 2021 15:31:05 +0100 Subject: [PATCH 08/14] Update vcpkg Fix compilation Remove unused benchmark --- .gitlab-ci.yml | 1 - ScreenPlay/CMakeLists.txt | 3 --- ScreenPlayWorkshop/CMakeLists.txt | 2 +- Tools/setup.py | 3 +-- 4 files changed, 2 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 402395e4..84873e43 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,7 +2,6 @@ stages: - check - build - test - - benchmark check: stage: check diff --git a/ScreenPlay/CMakeLists.txt b/ScreenPlay/CMakeLists.txt index a7058fbc..4b44e746 100644 --- a/ScreenPlay/CMakeLists.txt +++ b/ScreenPlay/CMakeLists.txt @@ -160,7 +160,6 @@ qt_update_translations("${CMAKE_CURRENT_SOURCE_DIR}/qml" "${L10N_LIST}") # Needed on macos find_package(Threads REQUIRED) find_package(OpenSSL REQUIRED) -find_package(benchmark CONFIG REQUIRED) find_package(doctest CONFIG REQUIRED) # CURL must be included before sentry because sentry needs the module and does not include it itself on macos... @@ -191,8 +190,6 @@ target_link_libraries( ScreenPlayLib PUBLIC ScreenPlaySDK ScreenPlayUtil - benchmark::benchmark - benchmark::benchmark_main doctest::doctest sentry::sentry Threads::Threads diff --git a/ScreenPlayWorkshop/CMakeLists.txt b/ScreenPlayWorkshop/CMakeLists.txt index 9faaee43..3d61322f 100644 --- a/ScreenPlayWorkshop/CMakeLists.txt +++ b/ScreenPlayWorkshop/CMakeLists.txt @@ -7,7 +7,7 @@ set(CMAKE_CXX_STANDARD 20) find_package( Qt6 - COMPONENTS Quick QML Widgets Gui + COMPONENTS Quick Widgets Gui REQUIRED) set(SOURCES diff --git a/Tools/setup.py b/Tools/setup.py index 0980c10c..9e33f0a1 100644 --- a/Tools/setup.py +++ b/Tools/setup.py @@ -31,7 +31,7 @@ if __name__ == "__main__": vcpkg_path = os.path.join(project_source_parent_path, "ScreenPlay-vcpkg") print("vcpkg_path: ", vcpkg_path) - vcpkg_version = "9172179c513aa84308e48b8dd0e3df90acec7204" # Master 25.06.2021 + vcpkg_version = "5ddd7f0" # Master 02.12.2021 print("Build vcpkg ", vcpkg_version) execute("git fetch", vcpkg_path) execute("git checkout {}".format(vcpkg_version), vcpkg_path) @@ -41,7 +41,6 @@ if __name__ == "__main__": "curl", "sentry-native", "doctest", - "benchmark", "cpp-httplib" ] From f781b31173c6968171f972633bc01b85799af062 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Thu, 2 Dec 2021 16:15:21 +0100 Subject: [PATCH 09/14] Add basic kde setup --- ScreenPlay/app.cpp | 39 +++++++++++++++++++++++++++++++++++++++ ScreenPlay/app.h | 3 +++ 2 files changed, 42 insertions(+) diff --git a/ScreenPlay/app.cpp b/ScreenPlay/app.cpp index d73ded68..0672fca1 100644 --- a/ScreenPlay/app.cpp +++ b/ScreenPlay/app.cpp @@ -1,6 +1,7 @@ #include "app.h" #include "steam/steam_qt_enums_generated.h" +#include namespace ScreenPlay { /*! @@ -235,4 +236,42 @@ void App::exit() QApplication::instance()->quit(); } +/*! + \brief +*/ +bool App::setupKDE() +{ + QProcessEnvironment env; + qInfo() << qgetenv("KDE_FULL_SESSION"); + qInfo() << qgetenv("DESKTOP_SESSION"); + qInfo() << qgetenv("XDG_CURRENT_DESKTOP"); + + QProcess plasmaShellVersionProcess; + plasmaShellVersionProcess.start("plasmashell",{"--version"}); + plasmaShellVersionProcess.waitForFinished(); + QString versionOut = plasmaShellVersionProcess.readAll(); + if(!versionOut.contains("plasmashell ")){ + qWarning() << "Unable to read plasma shell version"; + return false; + } + + const QString basePath = QDir(QDir::homePath() + "/.local/share/plasma/wallpapers/ScreenPlay/").canonicalPath(); + const QFileInfo wallpaperMetadata(basePath + "/metadata.desktop"); + if (wallpaperMetadata.exists()) { + const QString appPath = QGuiApplication::instance()->applicationDirPath() + "/kde"; + + process.setWorkingDirectory(appPath); + process.start("plasmapkg2", { "--upgrade", "ScreenPlay" }); + process.waitForFinished(); + process.terminate(); + qInfo() << process.readAllStandardError() << process.readAllStandardOutput(); + process.start("kquitapp5", { "plasmashell" }); + process.waitForFinished(); + process.terminate(); + qInfo() << process.readAllStandardError() << process.readAllStandardOutput(); + process.startDetached("kstart5", { "plasmashell" }); + qInfo() << process.readAllStandardError() << process.readAllStandardOutput(); + } + return true; +} } diff --git a/ScreenPlay/app.h b/ScreenPlay/app.h index 40efdd7a..92e774c3 100644 --- a/ScreenPlay/app.h +++ b/ScreenPlay/app.h @@ -215,6 +215,8 @@ public slots: m_wizards.reset(wizards); emit wizardsChanged(m_wizards.get()); } +private: + bool setupKDE(); private: QPluginLoader m_workshopPlugin; @@ -234,5 +236,6 @@ private: std::shared_ptr m_monitorListModel; std::shared_ptr m_profileListModel; std::shared_ptr m_installedListFilter; + QProcess process; }; } From 996526c1cd8f4ef2eac0a1bd0cd1e9b519bdf2d9 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Fri, 3 Dec 2021 14:23:45 +0100 Subject: [PATCH 10/14] Add basic kde wallpaper installation --- CMake/CMakeLists.txt | 1 + CMake/CopyRecursive.cmake | 29 +++++++++ ScreenPlay/CMakeLists.txt | 2 - ScreenPlay/app.cpp | 63 ++++++++++++++----- ScreenPlayWallpaper/CMakeLists.txt | 5 ++ .../kde/ScreenPlay/metadata.desktop | 1 + 6 files changed, 84 insertions(+), 17 deletions(-) create mode 100644 CMake/CopyRecursive.cmake diff --git a/CMake/CMakeLists.txt b/CMake/CMakeLists.txt index 130bfc95..0b954bc4 100644 --- a/CMake/CMakeLists.txt +++ b/CMake/CMakeLists.txt @@ -1,6 +1,7 @@ project(CMake) set(FILES # cmake-format: sortable + CopyRecursive.cmake QtUpdateTranslations.cmake) add_custom_target( diff --git a/CMake/CopyRecursive.cmake b/CMake/CopyRecursive.cmake new file mode 100644 index 00000000..aecf3c76 --- /dev/null +++ b/CMake/CopyRecursive.cmake @@ -0,0 +1,29 @@ +# Copies all files with the same hierarchy (folder) +# via configure_file but only when the file content is different: +# +# copy_recursive(${SOURCE_PATH} ${DESTINATION_PATH} ${REGEX}) +# +# If you want to copy all files simply set the parameter to: "*" +# Example: +# +# include(CopyRecursive) +# copy_recursive(${CMAKE_CURRENT_SOURCE_DIR}/kde/ScreenPlay ${CMAKE_BINARY_DIR}/bin/kde/ScreenPlay "*") +# + +function(copy_recursive SOURCE_PATH DESTINATION_PATH REGEX) + + file(GLOB_RECURSE + FILES + ${SOURCE_PATH} + "${SOURCE_PATH}/${REGEX}") + + foreach(file ${FILES}) + # To recreate the same folder structure we first need to read the base folder + file(RELATIVE_PATH RELATIVE_FILE_PATH ${SOURCE_PATH} ${file}) + get_filename_component(FOLDER ${RELATIVE_FILE_PATH} DIRECTORY ${SOURCE_PATH}) + file(MAKE_DIRECTORY ${DESTINATION_PATH}/${FOLDER} ) + message(STATUS "${file} - ${DESTINATION_PATH}/${RELATIVE_FILE_PATH}") + configure_file(${file} "${DESTINATION_PATH}/${RELATIVE_FILE_PATH}" COPYONLY) + endforeach() + +endfunction() diff --git a/ScreenPlay/CMakeLists.txt b/ScreenPlay/CMakeLists.txt index 9ad0bb72..04e84ac4 100644 --- a/ScreenPlay/CMakeLists.txt +++ b/ScreenPlay/CMakeLists.txt @@ -186,8 +186,6 @@ add_library(ScreenPlayLib ${SOURCES} ${HEADER} ${RESOURCES} ${FONTS}) target_include_directories(ScreenPlayLib PUBLIC ./ src/ ${LibArchive_INCLUDE_DIRS}) -find_package(LibArchive REQUIRED) - target_link_libraries( ScreenPlayLib PUBLIC ScreenPlaySDK diff --git a/ScreenPlay/app.cpp b/ScreenPlay/app.cpp index 0672fca1..5267ba6b 100644 --- a/ScreenPlay/app.cpp +++ b/ScreenPlay/app.cpp @@ -2,6 +2,7 @@ #include "steam/steam_qt_enums_generated.h" #include +#include namespace ScreenPlay { /*! @@ -99,7 +100,6 @@ App::App() qRegisterMetaType(); qRegisterMetaType(); - // TODO: This is a workaround because I don't know how to // init this in the ScreenPlayWorkshop plugin. // Move to workshop plugin. @@ -215,6 +215,9 @@ void App::init() // Needed for macos .app files m_mainWindowEngine->addPluginPath(QGuiApplication::instance()->applicationDirPath()); #endif + if (m_settings->desktopEnvironment() == Settings::DesktopEnvironment::KDE) { + setupKDE(); + } m_mainWindowEngine->load(QUrl(QStringLiteral("qrc:/ScreenPlay/main.qml"))); // Must be called last to display a error message on startup by the qml engine @@ -247,31 +250,61 @@ bool App::setupKDE() qInfo() << qgetenv("XDG_CURRENT_DESKTOP"); QProcess plasmaShellVersionProcess; - plasmaShellVersionProcess.start("plasmashell",{"--version"}); + plasmaShellVersionProcess.start("plasmashell", { "--version" }); plasmaShellVersionProcess.waitForFinished(); - QString versionOut = plasmaShellVersionProcess.readAll(); - if(!versionOut.contains("plasmashell ")){ + QString versionOut = plasmaShellVersionProcess.readAll(); + if (!versionOut.contains("plasmashell ")) { qWarning() << "Unable to read plasma shell version"; return false; } - const QString basePath = QDir(QDir::homePath() + "/.local/share/plasma/wallpapers/ScreenPlay/").canonicalPath(); - const QFileInfo wallpaperMetadata(basePath + "/metadata.desktop"); - if (wallpaperMetadata.exists()) { - const QString appPath = QGuiApplication::instance()->applicationDirPath() + "/kde"; + const QString kdeWallpaperPath = QDir(QDir::homePath() + "/.local/share/plasma/wallpapers/ScreenPlay/").canonicalPath(); + const QFileInfo installedWallpaperMetadata(kdeWallpaperPath + "/metadata.desktop"); + const QString appKdeWallapperPath = QGuiApplication::instance()->applicationDirPath() + "/kde"; + const QFileInfo currentWallpaperMetadata(appKdeWallapperPath + "/ScreenPlay/metadata.desktop"); - process.setWorkingDirectory(appPath); + if (!installedWallpaperMetadata.exists()) { + process.setWorkingDirectory(appKdeWallapperPath); + process.start("plasmapkg2", { "--install", "ScreenPlay" }); + process.waitForFinished(); + process.terminate(); + qInfo() << "Install ScreenPlay KDE Wallpaper"; + } else { + QSettings installedWallpaperSettings(installedWallpaperMetadata.absoluteFilePath(), QSettings::Format::IniFormat); + installedWallpaperSettings.beginGroup("Desktop Entry"); + const QString installedWallpaperVersion = installedWallpaperSettings.value("Version").toString(); + installedWallpaperSettings.endGroup(); + const QVersionNumber installedVersionNumber = QVersionNumber::fromString(installedWallpaperVersion); + + QSettings currentWallpaperSettings(currentWallpaperMetadata.absoluteFilePath(), QSettings::Format::IniFormat); + currentWallpaperSettings.beginGroup("Desktop Entry"); + const QString currentWallpaperVersion = currentWallpaperSettings.value("Version").toString(); + currentWallpaperSettings.endGroup(); + const QVersionNumber currentVersionNumber = QVersionNumber::fromString(installedWallpaperVersion); + + if (installedVersionNumber.isNull() || currentVersionNumber.isNull()) { + qCritical() << "Unable to parse version number from:" << currentWallpaperVersion << installedWallpaperVersion; + return false; + } + + if (installedVersionNumber < currentVersionNumber) + return true; + + qInfo() << "Upgrade ScreenPlay KDE Wallpaper"; + process.setWorkingDirectory(appKdeWallapperPath); process.start("plasmapkg2", { "--upgrade", "ScreenPlay" }); process.waitForFinished(); process.terminate(); qInfo() << process.readAllStandardError() << process.readAllStandardOutput(); - process.start("kquitapp5", { "plasmashell" }); - process.waitForFinished(); - process.terminate(); - qInfo() << process.readAllStandardError() << process.readAllStandardOutput(); - process.startDetached("kstart5", { "plasmashell" }); - qInfo() << process.readAllStandardError() << process.readAllStandardOutput(); } + + qInfo() << "Restart KDE "; + process.start("kquitapp5", { "plasmashell" }); + process.waitForFinished(); + process.terminate(); + qInfo() << process.readAllStandardError() << process.readAllStandardOutput(); + process.startDetached("kstart5", { "plasmashell" }); + qInfo() << process.readAllStandardError() << process.readAllStandardOutput(); return true; } } diff --git a/ScreenPlayWallpaper/CMakeLists.txt b/ScreenPlayWallpaper/CMakeLists.txt index 7850cee2..71bd41ce 100644 --- a/ScreenPlayWallpaper/CMakeLists.txt +++ b/ScreenPlayWallpaper/CMakeLists.txt @@ -68,6 +68,11 @@ target_link_libraries( Qt6::WebEngineCore Qt6::WebEngineQuick) +if (UNIX AND NOT APPLE) + include(CopyRecursive) + copy_recursive(${CMAKE_CURRENT_SOURCE_DIR}/kde/ScreenPlay ${CMAKE_BINARY_DIR}/bin/kde/ScreenPlay "*") +endif() + if(APPLE) set_target_properties(${PROJECT_NAME} PROPERTIES MACOSX_BUNDLE TRUE MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist) target_link_libraries(${PROJECT_NAME} PRIVATE "-framework Cocoa") diff --git a/ScreenPlayWallpaper/kde/ScreenPlay/metadata.desktop b/ScreenPlayWallpaper/kde/ScreenPlay/metadata.desktop index 84c6968d..149c69de 100644 --- a/ScreenPlayWallpaper/kde/ScreenPlay/metadata.desktop +++ b/ScreenPlayWallpaper/kde/ScreenPlay/metadata.desktop @@ -3,6 +3,7 @@ Encoding=UTF-8 Name=ScreenPlay Keywords=ScreenPlay Icon=preferences-desktop-wallpaper +Version=0.15.0 Type=Service From c6c3e9abbe6bdb9bd3d596b4d7d879db15b2d106 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Fri, 3 Dec 2021 14:24:50 +0100 Subject: [PATCH 11/14] Fix Qt6 folder dialog --- ScreenPlay/qml/Settings/Settings.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ScreenPlay/qml/Settings/Settings.qml b/ScreenPlay/qml/Settings/Settings.qml index c61f6ffa..8f3c5ac5 100644 --- a/ScreenPlay/qml/Settings/Settings.qml +++ b/ScreenPlay/qml/Settings/Settings.qml @@ -125,7 +125,7 @@ Item { id: folderDialogSaveLocation folder: ScreenPlay.globalVariables.localStoragePath onAccepted: { - ScreenPlay.settings.setLocalStoragePath(folderDialogSaveLocation.fileUrls[0]); + ScreenPlay.settings.setLocalStoragePath(folderDialogSaveLocation.currentFolder); } } From eabe625cd9855dc8383b29f679bb8c556d50fbad Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Fri, 3 Dec 2021 15:30:17 +0100 Subject: [PATCH 12/14] Add cpack IFW installer Update to Qt 6.2.2 --- CMakeLists.txt | 88 +++++++++++++++++++++++++++----- Tools/CMakeLists.txt | 13 +++++ Tools/Installer/installscript.qs | 14 +++++ Tools/Installer/package.xml | 9 ++++ Tools/build.py | 5 +- 5 files changed, 115 insertions(+), 14 deletions(-) create mode 100644 Tools/CMakeLists.txt create mode 100644 Tools/Installer/installscript.qs create mode 100644 Tools/Installer/package.xml diff --git a/CMakeLists.txt b/CMakeLists.txt index 2b6d95ac..f686ed86 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.16.0) -project(ScreenPlay LANGUAGES CXX) +project(ScreenPlay + VERSION 0.15.0 + DESCRIPTION "Modern, Cross Plattform, Live Wallpaper, Widgets and AppDrawer!" + HOMEPAGE_URL "https://screen-play.app/" + LANGUAGES CXX) # This sets cmake to compile all dlls into the main directory set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) @@ -8,7 +12,8 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) option(SCREENPLAY_STEAM "For FOSS distribution so we do not bundle proprietary code." ON) -option(TESTS_ENABLED OFF) +option(SCREENPLAY_TESTS "Enables UI tests." OFF) +option(SCREENPLAY_CREATE_INSTALLER "Indicates whether an installer via the Qt Installer Framework is created." OFF) # Add our *.cmake diretory to the CMAKE_MODULE_PATH, so that our includes are found set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake" ${CMAKE_MODULE_PATH}) @@ -25,7 +30,7 @@ elseif(APPLE) set(VCPKG_ARCH "x64-osx") endif() -if(${TESTS_ENABLED}) +if(${SCREENPLAY_TESTS}) enable_testing() endif() @@ -73,6 +78,7 @@ add_subdirectory(ScreenPlayWallpaper) add_subdirectory(ScreenPlayWidget) add_subdirectory(ScreenPlayUtil) add_subdirectory(CMake) +add_subdirectory(Tools) if(${SCREENPLAY_STEAM}) add_subdirectory(ScreenPlayWorkshop) @@ -85,13 +91,69 @@ if(WIN32) add_subdirectory(ScreenPlaySysInfo) endif() -message(STATUS "[DEFINE] SOURCE_DIR = ${SOURCE_DIR}") -message(STATUS "[DEFINE] BUILD_DATE = ${BUILD_DATE}") -message(STATUS "[DEFINE] GIT_COMMIT_HASH = ${GIT_COMMIT_HASH}") -message(STATUS "[OPTION] SCREENPLAY_STEAM = ${SCREENPLAY_STEAM}") -message(STATUS "[OPTION] TESTS_ENABLED = ${TESTS_ENABLED}") -message(STATUS "[PROJECT] CMAKE_TOOLCHAIN_FILE = ${CMAKE_TOOLCHAIN_FILE}") -message(STATUS "[PROJECT] VCPKG_PATH = ${VCPKG_PATH}") -message(STATUS "[PROJECT] VCPKG_ARCH = ${VCPKG_ARCH}") -message(STATUS "[PROJECT] CMAKE_PREFIX_PATH = ${CMAKE_PREFIX_PATH}") -message(STATUS "[PROJECT] VCPKG_TARGET_TRIPLET = ${VCPKG_TARGET_TRIPLET}") +message(STATUS "[DEFINE] SOURCE_DIR = ${CMAKE_CURRENT_SOURCE_DIR}") +message(STATUS "[DEFINE] BUILD_DATE = ${BUILD_DATE}") +message(STATUS "[DEFINE] BUILD_TYPE = ${CMAKE_BUILD_TYPE}") +message(STATUS "[DEFINE] GIT_COMMIT_HASH = ${GIT_COMMIT_HASH}") +message(STATUS "[OPTION] SCREENPLAY_CREATE_INSTALLER = ${SCREENPLAY_CREATE_INSTALLER}") +message(STATUS "[OPTION] SCREENPLAY_STEAM = ${SCREENPLAY_STEAM}") +message(STATUS "[OPTION] SCREENPLAY_TESTS = ${SCREENPLAY_TESTS}") +message(STATUS "[PROJECT] CMAKE_TOOLCHAIN_FILE = ${CMAKE_TOOLCHAIN_FILE}") +message(STATUS "[PROJECT] VCPKG_PATH = ${VCPKG_PATH}") +message(STATUS "[PROJECT] VCPKG_TARGET_TRIPLET = ${VCPKG_TARGET_TRIPLET}") +message(STATUS "[PROJECT] CMAKE_PREFIX_PATH = ${CMAKE_PREFIX_PATH}") + + +if(${SCREENPLAY_CREATE_INSTALLER}) + + + set(CPACK_PACKAGE_NAME "${PROJECT_NAME}") + set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-Installer") + set(CPACK_PACKAGE_VENDOR "Elias Steurer") + set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PROJECT_DESCRIPTION}") + + set(CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_NAME}") + set(CPACK_PACKAGE_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") + + # Ensures that contents written to the CPack configuration files is escaped properly. + set(CPACK_VERBATIM_VARIABLES TRUE) + + set(CPACK_GENERATOR IFW) + + set(CPACK_IFW_PACKAGE_START_MENU_DIRECTORY "") # empty => default is install to top-level (?) + set(CPACK_IFW_TARGET_DIRECTORY "@HomeDir@/${CMAKE_PROJECT_NAME}") + set(CPACK_IFW_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/ScreenPlay/assets/icons/app.ico") + set(CPACK_IFW_PACKAGE_WINDOW_ICON "${CMAKE_CURRENT_SOURCE_DIR}/ScreenPlay/assets/icons/app.ico") + + set(CPACK_COMPONENTS_GROUPING IGNORE) + set(CPACK_IFW_PACKAGE_GROUP ScreenPlay) + + # Install Windows Universal CRT libs for app-local deployment + set(CMAKE_INSTALL_UCRT_LIBRARIES TRUE) + set(CPACK_IFW_PACKAGE_CONTROL_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/Tools/Installer/installscript.qs") + + set(CPACK_IFW_VERBOSE ON) + + include(CPack) + include(CPackIFW) + + install( + DIRECTORY "${CMAKE_BINARY_DIR}/bin/" + COMPONENT ScreenPlay + DESTINATION "/") + + cpack_add_component( + K3000 + DISPLAY_NAME "ScreenPlay" + DESCRIPTION "This installs ScreenPlay.") + + cpack_ifw_configure_component( + ScreenPlay FORCED_INSTALLATION + NAME "ScreenPlay" + DESCRIPTION "Welcome to the ScreenPlay installer." + # Gets ignored and I do not know why + SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/Tools/Installer/installscript.qs" + CHECKABLE FALSE) + +endif() + diff --git a/Tools/CMakeLists.txt b/Tools/CMakeLists.txt new file mode 100644 index 00000000..74329d96 --- /dev/null +++ b/Tools/CMakeLists.txt @@ -0,0 +1,13 @@ +project(Tools LANGUAGES CXX) + +file(GLOB PYTHON *.py) + +set(FILES + # cmake-format: sortable + Installer/package.xml + Installer/installscript.qs) + +add_custom_target( + ${PROJECT_NAME} + SOURCES ${FILES} ${PYTHON} + COMMENT "Dummy target to list these files in the IDE") diff --git a/Tools/Installer/installscript.qs b/Tools/Installer/installscript.qs new file mode 100644 index 00000000..c742aeea --- /dev/null +++ b/Tools/Installer/installscript.qs @@ -0,0 +1,14 @@ +function Component() +{ + // Install to @RootDir@ instead of @HomeDir@ on Windows + if (installer.value("os") === "win") { + var homeDir = installer.value("HomeDir"); + var targetDir = installer.value("TargetDir").replace(homeDir, "@RootDir@"); + installer.setValue("TargetDir", targetDir); + } + + // do not show component selection page + installer.setDefaultPageVisible(QInstaller.ComponentSelection, false); + // no startmenu entry so no need to ask where to create it + installer.setDefaultPageVisible(QInstaller.StartMenuSelection, false); +} diff --git a/Tools/Installer/package.xml b/Tools/Installer/package.xml new file mode 100644 index 00000000..bf774efd --- /dev/null +++ b/Tools/Installer/package.xml @@ -0,0 +1,9 @@ + + + Register a file extension + Register a randomly generated file extension to open with notepad.exe + 1.0.0-1 + 2020-01-01 + true + + diff --git a/Tools/build.py b/Tools/build.py index e15e5a8a..f0df92b6 100644 --- a/Tools/build.py +++ b/Tools/build.py @@ -45,7 +45,7 @@ if not args.build_type: print("Build type argument is missing (release,debug). Example: python build.py -t release -steam=True") sys.exit(1) -qt_version = "6.2.1" +qt_version = "6.2.2" steam_build = "OFF" if args.steam_build: if args.steam_build: @@ -182,3 +182,6 @@ for filename in os.listdir(os.getcwd()): full_file_path = os.path.join(os.getcwd(), filename) print("Remove: %s" % full_file_path) os.remove(full_file_path) + +os.chdir("..") +execute("cpack") \ No newline at end of file From 8ea96b052eac6b4191517ba96bc799d9fd55c10c Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Fri, 3 Dec 2021 15:30:27 +0100 Subject: [PATCH 13/14] Fix version check --- ScreenPlay/app.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ScreenPlay/app.cpp b/ScreenPlay/app.cpp index 5267ba6b..8c60f339 100644 --- a/ScreenPlay/app.cpp +++ b/ScreenPlay/app.cpp @@ -287,7 +287,7 @@ bool App::setupKDE() return false; } - if (installedVersionNumber < currentVersionNumber) + if (installedVersionNumber <= currentVersionNumber) return true; qInfo() << "Upgrade ScreenPlay KDE Wallpaper"; From 4f5bfe44d1a295dae958736e991d22e3a95ec8a3 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Sat, 4 Dec 2021 10:41:21 +0100 Subject: [PATCH 14/14] Add cpack based installer --- CMakeLists.txt | 32 +++++++++++++++++--------------- Tools/build.py | 30 ++++++++++++++++++++++-------- 2 files changed, 39 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f686ed86..da7d2998 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -102,55 +102,57 @@ message(STATUS "[PROJECT] CMAKE_TOOLCHAIN_FILE = ${CMAKE_TOOLCHAIN_FILE}") message(STATUS "[PROJECT] VCPKG_PATH = ${VCPKG_PATH}") message(STATUS "[PROJECT] VCPKG_TARGET_TRIPLET = ${VCPKG_TARGET_TRIPLET}") message(STATUS "[PROJECT] CMAKE_PREFIX_PATH = ${CMAKE_PREFIX_PATH}") - +message(STATUS "[PROJECT] CPACK_GENERATOR = ${CPACK_GENERATOR}") if(${SCREENPLAY_CREATE_INSTALLER}) + # Hardcoded Qt paths that are used by the QtMaintanance tool for now... + if(WIN32) + set(CPACK_IFW_ROOT "C:/Qt/Tools/QtInstallerFramework/4.2") + elseif(UNIX AND NOT APPLE) + set(CPACK_IFW_ROOT "$ENV{HOME}/Qt/Tools/QtInstallerFramework/4.2") + endif() set(CPACK_PACKAGE_NAME "${PROJECT_NAME}") set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-Installer") set(CPACK_PACKAGE_VENDOR "Elias Steurer") set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PROJECT_DESCRIPTION}") - - set(CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_NAME}") - set(CPACK_PACKAGE_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") + set(CPACK_PACKAGE_DIRECTORY "${CMAKE_BINARY_DIR}") # Ensures that contents written to the CPack configuration files is escaped properly. set(CPACK_VERBATIM_VARIABLES TRUE) - set(CPACK_GENERATOR IFW) set(CPACK_IFW_PACKAGE_START_MENU_DIRECTORY "") # empty => default is install to top-level (?) - set(CPACK_IFW_TARGET_DIRECTORY "@HomeDir@/${CMAKE_PROJECT_NAME}") + set(CPACK_IFW_TARGET_DIRECTORY "@HomeDir@/Apps/${CMAKE_PROJECT_NAME}") set(CPACK_IFW_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/ScreenPlay/assets/icons/app.ico") set(CPACK_IFW_PACKAGE_WINDOW_ICON "${CMAKE_CURRENT_SOURCE_DIR}/ScreenPlay/assets/icons/app.ico") + set(CPACK_IFW_PACKAGE_CONTROL_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/Tools/Installer/installscript.qs") set(CPACK_COMPONENTS_GROUPING IGNORE) set(CPACK_IFW_PACKAGE_GROUP ScreenPlay) - - # Install Windows Universal CRT libs for app-local deployment - set(CMAKE_INSTALL_UCRT_LIBRARIES TRUE) - set(CPACK_IFW_PACKAGE_CONTROL_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/Tools/Installer/installscript.qs") - set(CPACK_IFW_VERBOSE ON) include(CPack) include(CPackIFW) + # Install all files from /bin install( DIRECTORY "${CMAKE_BINARY_DIR}/bin/" COMPONENT ScreenPlay - DESTINATION "/") + DESTINATION ".") cpack_add_component( - K3000 + ScreenPlay DISPLAY_NAME "ScreenPlay" DESCRIPTION "This installs ScreenPlay.") cpack_ifw_configure_component( - ScreenPlay FORCED_INSTALLATION + ScreenPlayApp + FORCED_INSTALLATION NAME "ScreenPlay" - DESCRIPTION "Welcome to the ScreenPlay installer." + VERSION ${PROJECT_VERSION} # Version of component + DESCRIPTION "Welcome to the K3000 installer." # Gets ignored and I do not know why SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/Tools/Installer/installscript.qs" CHECKABLE FALSE) diff --git a/Tools/build.py b/Tools/build.py index f0df92b6..bc552c02 100644 --- a/Tools/build.py +++ b/Tools/build.py @@ -39,6 +39,10 @@ parser.add_argument('-sign', action="store", dest="sign_build", help="Enable if you want to sign the apps. This is macos only for now.") parser.add_argument('-steam', action="store", dest="steam_build", help="Enable if you want to build the Steam workshop plugin.") +parser.add_argument('-tests', action="store", dest="build_tests", + help="Build tests.") +parser.add_argument('-installer', action="store", dest="create_installer", + help="Create a installer.") args = parser.parse_args() if not args.build_type: @@ -47,9 +51,15 @@ if not args.build_type: qt_version = "6.2.2" steam_build = "OFF" +build_tests = "OFF" +create_installer = "OFF" + if args.steam_build: - if args.steam_build: - steam_build = "ON" + steam_build = "ON" +if args.build_tests: + build_tests = "ON" +if args.create_installer: + create_installer = "ON" print("Starting build with type %s. Qt Version: %s" % (args.build_type, qt_version)) @@ -79,7 +89,7 @@ elif platform == "darwin": deploy_command = "{prefix_path}/bin/macdeployqt {app}.app -qmldir=../../{app}/qml -executable={app}.app/Contents/MacOS/{app}" cmake_target_triplet = "x64-osx" elif platform == "linux": - deploy_command = "cqtdeployer -qmldir ../../{app}/qml -bin {app}" + deploy_command = "cqtdeployer -qmlDir ../../{app}/qml -bin {app}" cmake_prefix_path = "~/Qt/" + qt_version + "/gcc_64" cmake_target_triplet = "x64-linux" @@ -97,7 +107,6 @@ if os.path.isdir(build_folder): print("Remove previous build folder: " + build_folder) shutil.rmtree(build_folder) - os.mkdir(build_folder) os.chdir(build_folder) @@ -106,8 +115,9 @@ cmake_configure_command = """cmake ../ -DCMAKE_BUILD_TYPE={type} -DCMAKE_TOOLCHAIN_FILE={toolchain} -DVCPKG_TARGET_TRIPLET={triplet} - -DTESTS_ENABLED=OFF -DSCREENPLAY_STEAM={steam} + -DSCREENPLAY_TESTS={tests} + -DSCREENPLAY_CREATE_INSTALLER={installer} -G "CodeBlocks - Ninja" -B. """.format( @@ -115,7 +125,10 @@ cmake_configure_command = """cmake ../ prefix_path=cmake_prefix_path, triplet=cmake_target_triplet, toolchain=cmake_toolchain_file, - steam=steam_build).replace("\n", "") + steam=steam_build, + tests = build_tests, + installer= create_installer + ).replace("\n", "") execute(cmake_configure_command) execute("cmake --build . --target all") @@ -183,5 +196,6 @@ for filename in os.listdir(os.getcwd()): print("Remove: %s" % full_file_path) os.remove(full_file_path) -os.chdir("..") -execute("cpack") \ No newline at end of file +if args.create_installer: + os.chdir("..") + execute("cpack") \ No newline at end of file