diff --git a/CMakeLists.txt b/CMakeLists.txt index 2b6d95ac..c4b82a9d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,6 +32,7 @@ endif() set(VCPKG_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../ScreenPlay-vcpkg") set(VCPKG_INSTALLED_PATH "${VCPKG_PATH}/installed/${VCPKG_ARCH}") + find_package(Git REQUIRED) if(WIN32) set(date_command "CMD") diff --git a/ScreenPlay/qml/Navigation/Navigation.qml b/ScreenPlay/qml/Navigation/Navigation.qml index 5959a08c..af3c4310 100644 --- a/ScreenPlay/qml/Navigation/Navigation.qml +++ b/ScreenPlay/qml/Navigation/Navigation.qml @@ -152,9 +152,17 @@ Rectangle { rightMargin: 10 bottom: parent.bottom } + property bool contentActive: ScreenPlay.screenPlayManager.activeWallpaperCounter > 0 || ScreenPlay.screenPlayManager.activeWidgetsCounter > 0 + onContentActiveChanged: { + if(!contentActive){ + miMuteAll.isMuted = false + miStopAll.isPlaying = false + } + } + ToolButton { id: miMuteAll Layout.alignment: Qt.AlignVCenter @@ -162,18 +170,23 @@ Rectangle { icon.width: root.iconWidth icon.height: root.iconHeight enabled: quickActionRow.contentActive + + onClicked: isMuted = !isMuted property bool isMuted: false - onClicked: { + onIsMutedChanged: { if (miMuteAll.isMuted) { - isMuted = false; + isMuted = false miMuteAll.icon.source = "qrc:/assets/icons/icon_volume.svg" - ScreenPlay.screenPlayManager.setAllWallpaperValue("muted", "false"); + ScreenPlay.screenPlayManager.setAllWallpaperValue("muted", + "false") } else { - isMuted = true; + isMuted = true miMuteAll.icon.source = "qrc:/assets/icons/icon_volume_mute.svg" - ScreenPlay.screenPlayManager.setAllWallpaperValue("muted", "true"); + ScreenPlay.screenPlayManager.setAllWallpaperValue("muted", + "true") } } + hoverEnabled: true ToolTip.text: qsTr("Mute/Unmute all Wallpaper") ToolTip.visible: hovered @@ -187,18 +200,20 @@ Rectangle { icon.height: root.iconHeight property bool isPlaying: false - - onClicked: { + onIsPlayingChanged:{ if (miStopAll.isPlaying) { - isPlaying = false; + isPlaying = false miStopAll.icon.source = "qrc:/assets/icons/icon_pause.svg" - ScreenPlay.screenPlayManager.setAllWallpaperValue("isPlaying", "true"); + ScreenPlay.screenPlayManager.setAllWallpaperValue( + "isPlaying", "true") } else { - isPlaying = true; + isPlaying = true miStopAll.icon.source = "qrc:/assets/icons/icon_play.svg" - ScreenPlay.screenPlayManager.setAllWallpaperValue("isPlaying", "false"); + ScreenPlay.screenPlayManager.setAllWallpaperValue( + "isPlaying", "false") } } + onClicked: isPlaying = !isPlaying hoverEnabled: true ToolTip.text: qsTr("Pause/Play all Wallpaper") ToolTip.visible: hovered diff --git a/ScreenPlay/src/installedlistmodel.cpp b/ScreenPlay/src/installedlistmodel.cpp index c132e0e0..f9da58a0 100644 --- a/ScreenPlay/src/installedlistmodel.cpp +++ b/ScreenPlay/src/installedlistmodel.cpp @@ -41,6 +41,7 @@ void InstalledListModel::init() QObject::connect(&m_fileSystemWatcher, &QFileSystemWatcher::directoryChanged, this, reloadLambda); QObject::connect(&m_fileSystemWatcher, &QFileSystemWatcher::fileChanged, this, reloadLambda); + loadInstalledContent(); } /*! diff --git a/ScreenPlay/src/screenplaywallpaper.cpp b/ScreenPlay/src/screenplaywallpaper.cpp index 3434554b..481cb4cc 100644 --- a/ScreenPlay/src/screenplaywallpaper.cpp +++ b/ScreenPlay/src/screenplaywallpaper.cpp @@ -208,7 +208,13 @@ void ScreenPlayWallpaper::setSDKConnection(std::unique_ptr connec { m_connection = std::move(connection); qInfo() << "[3/3] SDKConnection (Wallpaper) saved!"; + setIsConnected(true); + QObject::connect(m_connection.get(), &SDKConnection::disconnected, this, [this]() { + setIsConnected(false); + qInfo() << "disconnecetd;"; + + }); QTimer::singleShot(1000, this, [this]() { if (playbackRate() != 1.0) { setWallpaperValue("playbackRate", QString::number(playbackRate()), false); @@ -239,8 +245,10 @@ void ScreenPlayWallpaper::replace( const InstalledType::InstalledType type, const bool checkWallpaperVisible) { - if (!m_connection) + if (!m_connection) { + qWarning() << "Cannot replace for unconnected wallpaper!"; return; + } m_previewImage = previewImage; m_type = type; diff --git a/ScreenPlay/src/screenplaywallpaper.h b/ScreenPlay/src/screenplaywallpaper.h index 557921f1..fd15b06d 100644 --- a/ScreenPlay/src/screenplaywallpaper.h +++ b/ScreenPlay/src/screenplaywallpaper.h @@ -51,6 +51,8 @@ namespace ScreenPlay { class ScreenPlayWallpaper : public QObject { Q_OBJECT + Q_PROPERTY(bool isConnected READ isConnected WRITE setIsConnected NOTIFY isConnectedChanged) + Q_PROPERTY(QVector screenNumber READ screenNumber WRITE setScreenNumber NOTIFY screenNumberChanged) Q_PROPERTY(float volume READ volume WRITE setVolume NOTIFY volumeChanged) @@ -108,6 +110,7 @@ public: bool isLooping() const { return m_isLooping; } ProjectSettingsListModel* getProjectSettingsListModel() { return &m_projectSettingsListModel; } float playbackRate() const { return m_playbackRate; } + bool isConnected() const { return m_isConnected; } signals: void screenNumberChanged(QVector screenNumber); @@ -126,6 +129,8 @@ signals: void requestClose(const QString& appID); void error(const QString& msg); + void isConnectedChanged(bool isConnected); + public slots: void messageQuit(); void processExit(int exitCode, QProcess::ExitStatus exitStatus); @@ -225,6 +230,14 @@ public slots: emit playbackRateChanged(m_playbackRate); } + void setIsConnected(bool isConnected) + { + if (m_isConnected == isConnected) + return; + m_isConnected = isConnected; + emit isConnectedChanged(m_isConnected); + } + private: const std::shared_ptr m_globalVariables; std::unique_ptr m_connection; @@ -243,5 +256,6 @@ private: float m_playbackRate { 1.0f }; QTimer m_pingAliveTimer; QStringList m_appArgumentsList; + bool m_isConnected; }; } diff --git a/ScreenPlay/src/sdkconnection.cpp b/ScreenPlay/src/sdkconnection.cpp index 5ef313d8..bbadddc9 100644 --- a/ScreenPlay/src/sdkconnection.cpp +++ b/ScreenPlay/src/sdkconnection.cpp @@ -17,6 +17,8 @@ ScreenPlay::SDKConnection::SDKConnection(QLocalSocket* socket, QObject* parent) : QObject(parent) { m_socket = socket; + + connect(m_socket, &QLocalSocket::disconnected, this, &SDKConnection::disconnected); connect(m_socket, &QLocalSocket::readyRead, this, &SDKConnection::readyRead); connect(m_socket, &QLocalSocket::errorOccurred, this, [](QLocalSocket::LocalSocketError socketError) { qInfo() << "Localsocket error:" << socketError; diff --git a/ScreenPlay/src/sdkconnection.h b/ScreenPlay/src/sdkconnection.h index 74fbb572..bb576423 100644 --- a/ScreenPlay/src/sdkconnection.h +++ b/ScreenPlay/src/sdkconnection.h @@ -78,6 +78,7 @@ public: QString type() const { return m_type; } signals: + void disconnected(); void requestCloseAt(int at); void appIDChanged(QString appID); void monitorChanged(QVector monitor); diff --git a/ScreenPlay/src/wizards.cpp b/ScreenPlay/src/wizards.cpp index 1ad9a541..149c2c2d 100644 --- a/ScreenPlay/src/wizards.cpp +++ b/ScreenPlay/src/wizards.cpp @@ -270,7 +270,7 @@ void Wizards::createGifWallpaper( const QString& file, const QVector& tags) { - QtConcurrent::run([=]() { + auto con = QtConcurrent::run([=]() { std::optional folderName = createTemporaryFolder(); if (!folderName.has_value()) { diff --git a/ScreenPlaySDK/inc/screenplaysdk.h b/ScreenPlaySDK/inc/screenplaysdk.h index 991c7143..db72753a 100644 --- a/ScreenPlaySDK/inc/screenplaysdk.h +++ b/ScreenPlaySDK/inc/screenplaysdk.h @@ -49,33 +49,19 @@ #include #include -class ScreenPlaySDK : public QQuickItem { +class ScreenPlaySDK : public QObject { Q_OBJECT - Q_DISABLE_COPY(ScreenPlaySDK) public: - ScreenPlaySDK(QQuickItem* parent = nullptr); - ScreenPlaySDK(const QString& appID, const QString& type, QQuickItem* parent = nullptr); + ScreenPlaySDK(const QString& appID, const QString& type); ~ScreenPlaySDK(); - Q_PROPERTY(QString type READ type WRITE setType NOTIFY typeChanged) Q_PROPERTY(bool isConnected READ isConnected WRITE setIsConnected NOTIFY isConnectedChanged) Q_PROPERTY(QString appID READ appID WRITE setAppID NOTIFY appIDChanged) - QString type() const - { - return m_type; - } - - bool isConnected() const - { - return m_isConnected; - } - - QString appID() const - { - return m_appID; - } + QString type() const { return m_type; } + bool isConnected() const { return m_isConnected; } + QString appID() const { return m_appID; } public slots: void sendMessage(const QJsonObject& obj); @@ -140,7 +126,7 @@ signals: private: QLocalSocket m_socket; - QString m_type = "undefined"; + QString m_type; bool m_isConnected = false; QString m_appID; diff --git a/ScreenPlaySDK/src/screenplaysdk.cpp b/ScreenPlaySDK/src/screenplaysdk.cpp index 619960a1..bb5b4e3a 100644 --- a/ScreenPlaySDK/src/screenplaysdk.cpp +++ b/ScreenPlaySDK/src/screenplaysdk.cpp @@ -15,16 +15,8 @@ static ScreenPlaySDK* global_sdkPtr = nullptr; \brief . */ -ScreenPlaySDK::ScreenPlaySDK(QQuickItem* parent) - : QQuickItem(parent) -{ -} - -ScreenPlaySDK::ScreenPlaySDK( - const QString& appID, - const QString& type, - QQuickItem* parent) - : QQuickItem(parent) +ScreenPlaySDK::ScreenPlaySDK(const QString& appID, const QString& type) + : QObject(nullptr) , m_type { type } , m_appID { appID } { diff --git a/ScreenPlaySysInfo/CMakeLists.txt b/ScreenPlaySysInfo/CMakeLists.txt index 5c43fb69..7e7d1f21 100644 --- a/ScreenPlaySysInfo/CMakeLists.txt +++ b/ScreenPlaySysInfo/CMakeLists.txt @@ -34,7 +34,10 @@ set(HEADER add_library(${PROJECT_NAME} SHARED ${SOURCES} ${HEADER}) -qt_add_qml_module(${PROJECT_NAME} URI ${PROJECT_NAME} VERSION 1.0) +qt_add_qml_module(${PROJECT_NAME} + OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/SysInfo + URI ${PROJECT_NAME} + VERSION 1.0) target_compile_definitions(${PROJECT_NAME} PRIVATE $<$,$>:QT_QML_DEBUG>) diff --git a/ScreenPlayWallpaper/main.cpp b/ScreenPlayWallpaper/main.cpp index f2d6512c..899fe96d 100644 --- a/ScreenPlayWallpaper/main.cpp +++ b/ScreenPlayWallpaper/main.cpp @@ -32,8 +32,8 @@ int main(int argc, char* argv[]) // For testing purposes when starting the ScreenPlayWallpaper directly. if (argumentList.length() == 1) { #if defined(Q_OS_WIN) - //WinWindow window1({ 0 }, "test", "appID=test", "1", "fill", "videoWallpaper", true, true); - WinWindow window1({ 0 }, "C:/Program Files (x86)/Steam/steamapps/workshop/content/672870/2453869686", "appID=test", "1", "fill", "videoWallpaper", true, true); + // WinWindow window1({ 0 }, "test", "appID=test", "1", "fill", "videoWallpaper", true, true); + WinWindow window1({ 0, 1, 2 }, "C:/Program Files (x86)/Steam/steamapps/workshop/content/672870/hordemp4", "appID=test", "1", "fill", "videoWallpaper", true, true); #elif defined(Q_OS_LINUX) LinuxWindow window({ 0 }, "test", "appID=test", "1", "fill", "videoWallpaper", false, true); #elif defined(Q_OS_OSX) diff --git a/ScreenPlayWallpaper/qml/MultimediaView.qml b/ScreenPlayWallpaper/qml/MultimediaView.qml index 113dd832..6b49bac3 100644 --- a/ScreenPlayWallpaper/qml/MultimediaView.qml +++ b/ScreenPlayWallpaper/qml/MultimediaView.qml @@ -6,12 +6,15 @@ Item { id: root anchors.fill: parent property bool loops: Wallpaper.loops + property bool isPlaying: Wallpaper.isPlaying + onIsPlayingChanged: isPlaying ? mediaPlayer.play() : mediaPlayer.pause() property bool isWindows: Qt.platform.os === "windows" signal requestFadeIn MediaPlayer { id: mediaPlayer + source: Wallpaper.projectSourceFileAbsolute Component.onCompleted: { mediaPlayer.play() diff --git a/ScreenPlayWallpaper/qml/Wallpaper.qml b/ScreenPlayWallpaper/qml/Wallpaper.qml index 6e870c77..55df1635 100644 --- a/ScreenPlayWallpaper/qml/Wallpaper.qml +++ b/ScreenPlayWallpaper/qml/Wallpaper.qml @@ -31,13 +31,16 @@ Rectangle { if (Qt.platform.os === "windows") { loader.source = "qrc:/ScreenPlayWallpaper/qml/MultimediaView.qml" } + + print(loader.source) fadeIn() break case InstalledType.HTMLWallpaper: - loader.setSource("qrc:/ScreenPlayWallpaper/qml/WebsiteWallpaper.qml", { - "url": Qt.resolvedUrl( - Wallpaper.projectSourceFileAbsolute) - }) + loader.setSource( + "qrc:/ScreenPlayWallpaper/qml/WebsiteWallpaper.qml", { + "url": Qt.resolvedUrl( + Wallpaper.projectSourceFileAbsolute) + }) break case InstalledType.QMLWallpaper: loader.source = Qt.resolvedUrl(Wallpaper.projectSourceFileAbsolute) @@ -61,49 +64,50 @@ Rectangle { } function fadeIn() { - Wallpaper.setVisible(true); + Wallpaper.setVisible(true) if (canFadeByWallpaperFillMode && Wallpaper.canFade) - imgCover.state = "hideDefaultBackgroundImage"; + imgCover.state = "hideDefaultBackgroundImage" else - imgCover.opacity = 0; + imgCover.opacity = 0 } anchors.fill: parent color: { if (Qt.platform.os !== "windows") - return "black"; + return "black" else - return Wallpaper.windowsDesktopProperties.color; + return Wallpaper.windowsDesktopProperties.color } Component.onCompleted: { - init(); + init() } Connections { function onQmlExit() { if (canFadeByWallpaperFillMode && Wallpaper.canFade) - imgCover.state = "exit"; + imgCover.state = "exit" else - Wallpaper.terminate(); + Wallpaper.terminate() } function onQmlSceneValueReceived(key, value) { - var obj2 = 'import QtQuick; Item {Component.onCompleted: loader.item.' + key + ' = ' + value + '; }'; - var newObject = Qt.createQmlObject(obj2.toString(), root, "err"); - newObject.destroy(10000); + var obj2 = 'import QtQuick; Item {Component.onCompleted: loader.item.' + + key + ' = ' + value + '; }' + var newObject = Qt.createQmlObject(obj2.toString(), root, "err") + newObject.destroy(10000) } // Replace wallpaper with QML Scene function onReloadQML(oldType) { - loader.sourceComponent = undefined; - loader.source = ""; - Wallpaper.clearComponentCache(); - loader.source = Qt.resolvedUrl(Wallpaper.projectSourceFileAbsolute); + loader.sourceComponent = undefined + loader.source = "" + Wallpaper.clearComponentCache() + loader.source = Qt.resolvedUrl(Wallpaper.projectSourceFileAbsolute) } // Replace wallpaper with GIF function onReloadGIF(oldType) { - init(); + init() } // This function only gets called here (the same function @@ -113,9 +117,9 @@ Rectangle { // We need to check if the old type // was also Video not get called twice if (oldType === InstalledType.VideoWallpaper) - return ; + return - loader.source = "qrc:/ScreenPlayWallpaper/qml/MultimediaView.qml"; + loader.source = "qrc:/ScreenPlayWallpaper/qml/MultimediaView.qml" } target: Wallpaper @@ -130,20 +134,19 @@ Rectangle { //asynchronous: true onStatusChanged: { if (loader.status === Loader.Error) { - loader.source = ""; - // Wallpaper.terminate(); + loader.source = "" + // Wallpaper.terminate(); } } Connections { function onRequestFadeIn() { - fadeIn(); + fadeIn() } ignoreUnknownSignals: true target: loader.item } - } Image { @@ -154,40 +157,41 @@ Rectangle { sourceSize.height: Wallpaper.height source: { if (Qt.platform.os === "windows") - return Qt.resolvedUrl("file:///" + Wallpaper.windowsDesktopProperties.wallpaperPath); + return Qt.resolvedUrl( + "file:///" + Wallpaper.windowsDesktopProperties.wallpaperPath) else return "" } - + Component.onCompleted: { if (Qt.platform.os !== "windows") { - root.canFadeByWallpaperFillMode = false; - return ; + root.canFadeByWallpaperFillMode = false + return } switch (Wallpaper.windowsDesktopProperties.wallpaperStyle) { case 10: - imgCover.fillMode = Image.PreserveAspectCrop; - break; + imgCover.fillMode = Image.PreserveAspectCrop + break case 6: - imgCover.fillMode = Image.PreserveAspectFit; - break; + imgCover.fillMode = Image.PreserveAspectFit + break case 2: - break; + break case 0: if (desktopProperties.isTiled) { // Tiled - imgCover.fillMode = Image.Tile; + imgCover.fillMode = Image.Tile } else { // Center - imgCover.fillMode = Image.PreserveAspectFit; - imgCover.anchors.centerIn = parent; - imgCover.width = sourceSize.width; - imgCover.height = sourceSize.height; + imgCover.fillMode = Image.PreserveAspectFit + imgCover.anchors.centerIn = parent + imgCover.width = sourceSize.width + imgCover.height = sourceSize.height } - break; + break case 22: - root.canFadeByWallpaperFillMode = false; - break; + root.canFadeByWallpaperFillMode = false + break } } @@ -206,7 +210,6 @@ Rectangle { target: imgCover opacity: 1 } - }, State { name: "hideDefaultBackgroundImage" @@ -215,7 +218,6 @@ Rectangle { target: imgCover opacity: 0 } - }, State { name: "exit" @@ -224,7 +226,6 @@ Rectangle { target: imgCover opacity: 1 } - } ] transitions: [ @@ -243,9 +244,7 @@ Rectangle { duration: 600 property: "opacity" } - } - }, Transition { from: "hideDefaultBackgroundImage" @@ -262,9 +261,7 @@ Rectangle { ScriptAction { script: Wallpaper.terminate() } - } - } ] } @@ -294,7 +291,12 @@ Rectangle { } Text { - text: "projectSourceFileAbsolute " + Wallpaper.projectSourceFileAbsolute + text: "getApplicationPath " + Wallpaper.getApplicationPath() + font.pointSize: 14 + } + + Text { + text: "projectSourceFileAbsolute " + Qt.resolvedUrl(Wallpaper.projectSourceFileAbsolute) font.pointSize: 14 } @@ -331,9 +333,10 @@ Rectangle { Text { text: { if (Qt.platform.os === "windows") - return "imgCover.source " + Qt.resolvedUrl("file:///" + Wallpaper.windowsDesktopProperties.wallpaperPath) - else - return "" + return "imgCover.source " + Qt.resolvedUrl( + "file:///" + Wallpaper.windowsDesktopProperties.wallpaperPath) + else + return "" } font.pointSize: 14 } @@ -342,13 +345,10 @@ Rectangle { text: "imgCover.status " + imgCover.status font.pointSize: 14 } - } background: Rectangle { opacity: 0.5 } - } - } diff --git a/ScreenPlayWallpaper/src/basewindow.cpp b/ScreenPlayWallpaper/src/basewindow.cpp index de9d2ecb..396e782a 100644 --- a/ScreenPlayWallpaper/src/basewindow.cpp +++ b/ScreenPlayWallpaper/src/basewindow.cpp @@ -85,7 +85,13 @@ BaseWindow::BaseWindow( if (auto typeOpt = ScreenPlayUtil::getInstalledTypeFromString(project.value("type").toString())) { setType(typeOpt.value()); - if (!project.contains("videoCodec")) { + if (this->type() == ScreenPlay::InstalledType::InstalledType::VideoWallpaper) { + if (auto videoCodecOpt = ScreenPlayUtil::getVideoCodecFromString(project.value("videoCodec").toString())) { + setVideoCodec(videoCodecOpt.value()); + } else { + qCritical() << "Cannot parse Wallpaper video codec from value" << project.value("type"); + } + } else if (!project.contains("videoCodec") && this->type() == ScreenPlay::InstalledType::InstalledType::VideoWallpaper) { qWarning("No videoCodec was specified inside the json object!"); const QString filename = project.value("file").toString(); if (filename.endsWith(".mp4")) { @@ -93,14 +99,6 @@ BaseWindow::BaseWindow( } else if (filename.endsWith(".webm")) { setVideoCodec(ScreenPlay::VideoCodec::VideoCodec::VP8); } - } else { - if (this->type() == ScreenPlay::InstalledType::InstalledType::VideoWallpaper) { - if (auto videoCodecOpt = ScreenPlayUtil::getVideoCodecFromString(project.value("videoCodec").toString())) { - setVideoCodec(videoCodecOpt.value()); - } else { - qCritical() << "Cannot parse Wallpaper video codec from value" << project.value("type"); - } - } } } else { diff --git a/ScreenPlayWallpaper/src/winwindow.cpp b/ScreenPlayWallpaper/src/winwindow.cpp index 2ee42195..28177872 100644 --- a/ScreenPlayWallpaper/src/winwindow.cpp +++ b/ScreenPlayWallpaper/src/winwindow.cpp @@ -285,20 +285,43 @@ void WinWindow::setupWallpaperForOneScreen(int activeScreen) */ void WinWindow::setupWallpaperForAllScreens() { + ScreenPlayUtil::WinMonitorStats monitors; QRect rect; - for (int i = 0; i < QApplication::screens().count(); i++) { - QScreen* screenTmp = QApplication::screens().at(i); - rect.setWidth(rect.width() + screenTmp->geometry().width()); - rect.setHeight(rect.height() + screenTmp->geometry().height()); + for (int i = 0; i < monitors.iMonitors.size(); i++) { + const int width = std::abs(monitors.rcMonitors[i].right - monitors.rcMonitors[i].left); + const int height = std::abs(monitors.rcMonitors[i].top - monitors.rcMonitors[i].bottom); + qInfo() << width << height; + rect.setWidth(rect.width() + width); + rect.setHeight(rect.height() + height); } - m_window.setHeight(rect.height()); - m_window.setWidth(rect.width()); - if (!SetWindowPos(m_windowHandle, HWND_TOPMOST, 0, 0, rect.width(), rect.height(), SWP_NOSIZE | SWP_NOMOVE)) { + int offsetX = 0; + int offsetY = 0; + for (int i = 0; i < monitors.iMonitors.size(); i++) { + const int x = monitors.rcMonitors[i].left; + const int y = monitors.rcMonitors[i].top; + qInfo() << x << y; + if (x < offsetX) { + offsetX = x; + } + if (y < offsetY) { + offsetY += y; + } + } + if (!SetWindowPos(m_windowHandle, nullptr, offsetX, offsetY, rect.width(), rect.height(), SWP_NOSIZE | SWP_NOMOVE)) { + qFatal("Could not set window pos: "); + } + if (!SetWindowPos(m_windowHandle, nullptr, offsetX, offsetY, rect.width(), rect.height(), SWP_NOSIZE | SWP_NOMOVE)) { qFatal("Could not set window pos: "); } if (SetParent(m_windowHandle, m_windowHandleWorker) == nullptr) { qFatal("Could not attach to parent window"); } + qInfo() << rect.width() << rect.height() << offsetX << offsetY; + m_window.setHeight(rect.height()); + m_window.setWidth(rect.width()); + m_window.setY(offsetY); + m_window.setX(offsetX+1920); + qInfo() << m_window.geometry(); } /*! diff --git a/ScreenPlayWorkshop/CMakeLists.txt b/ScreenPlayWorkshop/CMakeLists.txt index 9faaee43..1ca487fb 100644 --- a/ScreenPlayWorkshop/CMakeLists.txt +++ b/ScreenPlayWorkshop/CMakeLists.txt @@ -55,8 +55,7 @@ qt_add_qml_module( OUTPUT_DIRECTORY ${WORKSHOP_PLUGIN_DIR} URI "Workshop" SOURCES ${SOURCES} ${HEADER} - VERSION - 1.0) + VERSION 1.0) if(APPLE) if(${SCREENPLAY_STEAM}) diff --git a/ScreenPlayWorkshop/src/installedlistmodel.cpp b/ScreenPlayWorkshop/src/installedlistmodel.cpp index 112f7ef7..7773c35a 100644 --- a/ScreenPlayWorkshop/src/installedlistmodel.cpp +++ b/ScreenPlayWorkshop/src/installedlistmodel.cpp @@ -88,8 +88,10 @@ void InstalledListModel::append(const QJsonObject& obj, const QString& folderNam void InstalledListModel::loadInstalledContent() { + if(m_loadContentFutureWatcher.isRunning()) + return; - QtConcurrent::run([this]() { + m_loadContentFuture = QtConcurrent::run([this]() { QFileInfoList list = QDir(m_absoluteStoragePath.toLocalFile()).entryInfoList(QDir::NoDotAndDotDot | QDir::AllDirs); for (const auto& item : list) { @@ -117,6 +119,7 @@ void InstalledListModel::loadInstalledContent() emit installedLoadingFinished(); }); + m_loadContentFutureWatcher.setFuture(m_loadContentFuture); } QVariantMap InstalledListModel::get(QString folderId) diff --git a/ScreenPlayWorkshop/src/installedlistmodel.h b/ScreenPlayWorkshop/src/installedlistmodel.h index 90cb1712..b4c90454 100644 --- a/ScreenPlayWorkshop/src/installedlistmodel.h +++ b/ScreenPlayWorkshop/src/installedlistmodel.h @@ -89,6 +89,8 @@ signals: private: QVector m_screenPlayFiles; QUrl m_absoluteStoragePath; + QFuture m_loadContentFuture; + QFutureWatcher m_loadContentFutureWatcher; }; }