diff --git a/ScreenPlay/inc/public/ScreenPlay/util.h b/ScreenPlay/inc/public/ScreenPlay/util.h index 36260f87..4af8e9e2 100644 --- a/ScreenPlay/inc/public/ScreenPlay/util.h +++ b/ScreenPlay/inc/public/ScreenPlay/util.h @@ -114,11 +114,12 @@ signals: public slots: void copyToClipboard(const QString& text) const; void openFolderInExplorer(const QString& url) const; - QString toLocal(const QString& url); + QString toLocal(const QString& url) const; bool exportProject(QString& contentPath, QString& exportFileName); bool importProject(QString& archivePath, QString extractionPath); void requestAllLicenses(); void requestDataProtection(); + bool fileExists(const QString& filePath) const; static void logToGui(QtMsgType type, const QMessageLogContext& context, const QString& msg); static bool writeJsonObjectToFile(const QString& absoluteFilePath, const QJsonObject& object, bool truncate = true); diff --git a/ScreenPlay/qml/Installed/Sidebar.qml b/ScreenPlay/qml/Installed/Sidebar.qml index 1b7f2d22..1aa6a79c 100644 --- a/ScreenPlay/qml/Installed/Sidebar.qml +++ b/ScreenPlay/qml/Installed/Sidebar.qml @@ -37,24 +37,30 @@ Item { width: 400 state: "inactive" + property bool hasPreviewGif: false onContentFolderNameChanged: { txtHeadline.text = App.installedListModel.get( root.contentFolderName).m_title - const hasPreviewGif = App.installedListModel.get( - root.contentFolderName).m_previewGIF !== undefined - if (!hasPreviewGif) { - image.source = Qt.resolvedUrl( - App.globalVariables.localStoragePath + "/" - + root.contentFolderName + "/" + App.installedListModel.get( - root.contentFolderName).m_preview) - image.playing = false + + const previewGiFilePath = Qt.resolvedUrl( + App.globalVariables.localStoragePath + "/" + + root.contentFolderName + "/" + App.installedListModel.get( + root.contentFolderName).m_previewGIF) + + const previewImageFilePath = Qt.resolvedUrl( + App.globalVariables.localStoragePath + "/" + + root.contentFolderName + "/" + App.installedListModel.get( + root.contentFolderName).m_preview) + + root.hasPreviewGif = App.util.fileExists(previewGiFilePath) + + if (hasPreviewGif) { + animatedImagePreview.source = previewGiFilePath + animatedImagePreview.playing = true } else { - image.source = Qt.resolvedUrl( - App.globalVariables.localStoragePath + "/" - + root.contentFolderName + "/" + App.installedListModel.get( - root.contentFolderName).m_previewGIF) - image.playing = true + imagePreview.source = previewImageFilePath } + if (JSUtil.isWidget(root.type) || (monitorSelection.activeMonitors.length > 0)) { btnSetWallpaper.enabled = true @@ -162,19 +168,27 @@ Item { anchors.left: parent.left anchors.leftMargin: 0 + // Do NOT enable async image loading! + // Otherwhise it will still hold the file + // when calling InstalledListModel::deinstallItemAt + // -> asynchronous: false AnimatedImage { - id: image - // Do NOT enable async image loading! - // Otherwhise it will still hold the file - // when calling InstalledListModel::deinstallItemAt + id: animatedImagePreview asynchronous: false playing: true fillMode: Image.PreserveAspectCrop anchors.fill: parent - onStatusChanged: { - if (image.status === Image.Error) - source = "qrc:/qml/ScreenPlayApp/assets/images/missingPreview.png" - } + visible: enabled + enabled: root.hasPreviewGif + } + + Image { + id: imagePreview + asynchronous: false + fillMode: Image.PreserveAspectCrop + anchors.fill: parent + enabled: !root.hasPreviewGif + visible: enabled } LinearGradient { @@ -409,7 +423,12 @@ Item { } PropertyChanges { - target: image + target: imagePreview + opacity: 0 + anchors.topMargin: 20 + } + PropertyChanges { + target: animatedImagePreview opacity: 0 anchors.topMargin: 20 } @@ -429,7 +448,12 @@ Item { } PropertyChanges { - target: image + target: imagePreview + opacity: 1 + anchors.topMargin: 0 + } + PropertyChanges { + target: animatedImagePreview opacity: 1 anchors.topMargin: 0 } @@ -443,7 +467,12 @@ Item { name: "activeWallpaper" PropertyChanges { - target: image + target: imagePreview + opacity: 1 + anchors.topMargin: 0 + } + PropertyChanges { + target: animatedImagePreview opacity: 1 anchors.topMargin: 0 } @@ -469,7 +498,12 @@ Item { name: "activeScene" PropertyChanges { - target: image + target: imagePreview + opacity: 1 + anchors.topMargin: 0 + } + PropertyChanges { + target: animatedImagePreview opacity: 1 anchors.topMargin: 0 } @@ -493,13 +527,13 @@ Item { reversible: true NumberAnimation { - target: image + targets: [animatedImagePreview, imagePreview] property: "opacity" duration: 200 } NumberAnimation { - target: image + targets: [animatedImagePreview, imagePreview] property: "anchors.topMargin" duration: 400 } @@ -525,13 +559,13 @@ Item { ParallelAnimation { NumberAnimation { - target: image + targets: [animatedImagePreview, imagePreview] property: "opacity" duration: 200 } NumberAnimation { - target: image + targets: [animatedImagePreview, imagePreview] property: "anchors.topMargin" duration: 100 } @@ -552,13 +586,13 @@ Item { ParallelAnimation { NumberAnimation { - target: image + targets: [animatedImagePreview, imagePreview] property: "opacity" duration: 200 } NumberAnimation { - target: image + targets: [animatedImagePreview, imagePreview] property: "anchors.topMargin" duration: 100 } @@ -578,13 +612,13 @@ Item { ParallelAnimation { NumberAnimation { - target: image + targets: [animatedImagePreview, imagePreview] property: "opacity" duration: 200 } NumberAnimation { - target: image + targets: [animatedImagePreview, imagePreview] property: "anchors.topMargin" duration: 100 } diff --git a/ScreenPlay/src/util.cpp b/ScreenPlay/src/util.cpp index 4529c946..62f56d23 100644 --- a/ScreenPlay/src/util.cpp +++ b/ScreenPlay/src/util.cpp @@ -100,7 +100,7 @@ void Util::openFolderInExplorer(const QString& url) const /*! \brief Removes file///: or file:// from the url/string */ -QString Util::toLocal(const QString& url) +QString Util::toLocal(const QString& url) const { return ScreenPlayUtil::toLocal(url); } @@ -243,6 +243,12 @@ void Util::Util::requestDataProtection() emit this->allDataProtectionLoaded(tmp); } +bool Util::fileExists(const QString& filePath) const +{ + const QFileInfo file(toLocal(filePath)); + return file.isFile(); +} + static const char* logLevelForMessageType(QtMsgType msgType) { diff --git a/ScreenPlayWallpaper/kde/ScreenPlay/metadata.desktop b/ScreenPlayWallpaper/kde/ScreenPlay/metadata.desktop index 149c69de..4dbf0710 100644 --- a/ScreenPlayWallpaper/kde/ScreenPlay/metadata.desktop +++ b/ScreenPlayWallpaper/kde/ScreenPlay/metadata.desktop @@ -3,7 +3,7 @@ Encoding=UTF-8 Name=ScreenPlay Keywords=ScreenPlay Icon=preferences-desktop-wallpaper -Version=0.15.0 +Version=0.15.0-RC3 Type=Service