diff --git a/Docs/DeveloperSetup.md b/Docs/DeveloperSetup.md index edf1a73e..465dc443 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 @@ -68,7 +68,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/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/ScreenPlay/src/createimportvideo.cpp b/ScreenPlay/src/createimportvideo.cpp index cce0bae3..5eacd89c 100644 --- a/ScreenPlay/src/createimportvideo.cpp +++ b/ScreenPlay/src/createimportvideo.cpp @@ -53,8 +53,15 @@ CreateImportVideo::CreateImportVideo(const QString& videoPath, const QString& ex void CreateImportVideo::setupFFMPEG() { + +#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(); +#endif if (!QFileInfo::exists(m_ffprobeExecutable)) { qFatal("FFPROBE executable not found!"); @@ -126,10 +133,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 dcaaf14f..f0f2e997 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 7513330e..9c496f39 100644 --- a/ScreenPlay/src/screenplaywallpaper.cpp +++ b/ScreenPlay/src/screenplaywallpaper.cpp @@ -24,7 +24,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 } @@ -37,6 +37,7 @@ ScreenPlayWallpaper::ScreenPlayWallpaper(const QVector& screenNumber, , m_file { file } , m_volume { volume } , m_playbackRate { playbackRate } + , m_settings { settings } { QJsonObject projectSettingsListModelProperties; @@ -81,7 +82,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 557921f1..1dde44c3 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( @@ -228,6 +232,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/config.qml b/ScreenPlayWallpaper/kde/ScreenPlay/contents/ui/config.qml index d508a3bf..6dae3f0a 100644 --- a/ScreenPlayWallpaper/kde/ScreenPlay/contents/ui/config.qml +++ b/ScreenPlayWallpaper/kde/ScreenPlay/contents/ui/config.qml @@ -1,13 +1,14 @@ -import QtQuick -import QtQuick.Controls as QQC -import QtQuick.Window -import Qt5Compat.GraphicalEffects +import QtQuick 2.11 +import QtQuick.Controls 2.4 as QQC +import QtQuick.Window 2.0 +import QtGraphicalEffects 1.0 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.wallpapers.image 2.0 as Wallpaper import org.kde.kcm 1.1 as KCM import org.kde.kirigami 2.4 as Kirigami import org.kde.newstuff 1.1 as NewStuff + Column { id: root diff --git a/ScreenPlayWallpaper/kde/ScreenPlay/contents/ui/main.qml b/ScreenPlayWallpaper/kde/ScreenPlay/contents/ui/main.qml index d69899f0..7afbbed6 100644 --- a/ScreenPlayWallpaper/kde/ScreenPlay/contents/ui/main.qml +++ b/ScreenPlayWallpaper/kde/ScreenPlay/contents/ui/main.qml @@ -1,11 +1,13 @@ -import QtQuick -import Qt5Compat.GraphicalEffects -import QtQuick.Window +import QtQuick 2.11 +import QtQuick.Controls 2.0 +import QtGraphicalEffects 1.0 +import QtQuick.Window 2.15 import Qt.WebSockets 1.15 -import QtWebEngine +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,25 @@ 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) + print(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 +73,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 - } - - } - } diff --git a/ScreenPlayWallpaper/src/linuxwindow.cpp b/ScreenPlayWallpaper/src/linuxwindow.cpp index fab82bd5..2dd66b5c 100644 --- a/ScreenPlayWallpaper/src/linuxwindow.cpp +++ b/ScreenPlayWallpaper/src/linuxwindow.cpp @@ -46,24 +46,9 @@ LinuxWindow::LinuxWindow( setHeight(m_window.height()); m_window.setResizeMode(QQuickView::ResizeMode::SizeRootObjectToView); - m_window.rootContext()->setContextProperty("window", this); - //m_window.rootContext()->setContextProperty("desktopProperties", &m_windowsDesktopProperties); - // Instead of setting "renderType: Text.NativeRendering" every time - // we can set it here once :) - + qmlRegisterSingletonInstance("ScreenPlayWallpaper", 1, 0, "Wallpaper", this); m_window.setTextRenderType(QQuickWindow::TextRenderType::NativeTextRendering); - m_window.setSource(QUrl("qrc:/mainWindow.qml")); - - // WARNING: Setting Window flags must be called *here*! - Qt::WindowFlags flags = m_window.flags(); - m_window.setFlags(flags | Qt::FramelessWindowHint | Qt::Desktop); - - m_window.setResizeMode(QQuickView::ResizeMode::SizeRootObjectToView); - m_window.rootContext()->setContextProperty("window", this); - // Instead of setting "renderType: Text.NativeRendering" every time - // we can set it here once :) - m_window.setTextRenderType(QQuickWindow::TextRenderType::NativeTextRendering); - m_window.setSource(QUrl("qrc:/Wallpaper.qml")); + m_window.setSource(QUrl("qrc:/ScreenPlayWallpaper/qml/Wallpaper.qml")); } void LinuxWindow::setupWallpaperForOneScreen(int activeScreen) 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() 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 = ""