1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-07 03:22:33 +01:00

Fix sidebar preview if now gif is available

This commit is contained in:
Elias Steurer 2022-11-04 16:21:46 +01:00
parent 51e34eca16
commit ad8074ed12
4 changed files with 77 additions and 36 deletions

View File

@ -114,11 +114,12 @@ signals:
public slots: public slots:
void copyToClipboard(const QString& text) const; void copyToClipboard(const QString& text) const;
void openFolderInExplorer(const QString& url) 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 exportProject(QString& contentPath, QString& exportFileName);
bool importProject(QString& archivePath, QString extractionPath); bool importProject(QString& archivePath, QString extractionPath);
void requestAllLicenses(); void requestAllLicenses();
void requestDataProtection(); void requestDataProtection();
bool fileExists(const QString& filePath) const;
static void logToGui(QtMsgType type, const QMessageLogContext& context, const QString& msg); static void logToGui(QtMsgType type, const QMessageLogContext& context, const QString& msg);
static bool writeJsonObjectToFile(const QString& absoluteFilePath, const QJsonObject& object, bool truncate = true); static bool writeJsonObjectToFile(const QString& absoluteFilePath, const QJsonObject& object, bool truncate = true);

View File

@ -37,24 +37,30 @@ Item {
width: 400 width: 400
state: "inactive" state: "inactive"
property bool hasPreviewGif: false
onContentFolderNameChanged: { onContentFolderNameChanged: {
txtHeadline.text = App.installedListModel.get( txtHeadline.text = App.installedListModel.get(
root.contentFolderName).m_title root.contentFolderName).m_title
const hasPreviewGif = App.installedListModel.get(
root.contentFolderName).m_previewGIF !== undefined const previewGiFilePath = Qt.resolvedUrl(
if (!hasPreviewGif) {
image.source = Qt.resolvedUrl(
App.globalVariables.localStoragePath + "/"
+ root.contentFolderName + "/" + App.installedListModel.get(
root.contentFolderName).m_preview)
image.playing = false
} else {
image.source = Qt.resolvedUrl(
App.globalVariables.localStoragePath + "/" App.globalVariables.localStoragePath + "/"
+ root.contentFolderName + "/" + App.installedListModel.get( + root.contentFolderName + "/" + App.installedListModel.get(
root.contentFolderName).m_previewGIF) root.contentFolderName).m_previewGIF)
image.playing = true
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 {
imagePreview.source = previewImageFilePath
} }
if (JSUtil.isWidget(root.type) if (JSUtil.isWidget(root.type)
|| (monitorSelection.activeMonitors.length > 0)) { || (monitorSelection.activeMonitors.length > 0)) {
btnSetWallpaper.enabled = true btnSetWallpaper.enabled = true
@ -162,19 +168,27 @@ Item {
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: 0 anchors.leftMargin: 0
AnimatedImage {
id: image
// Do NOT enable async image loading! // Do NOT enable async image loading!
// Otherwhise it will still hold the file // Otherwhise it will still hold the file
// when calling InstalledListModel::deinstallItemAt // when calling InstalledListModel::deinstallItemAt
// -> asynchronous: false
AnimatedImage {
id: animatedImagePreview
asynchronous: false asynchronous: false
playing: true playing: true
fillMode: Image.PreserveAspectCrop fillMode: Image.PreserveAspectCrop
anchors.fill: parent anchors.fill: parent
onStatusChanged: { visible: enabled
if (image.status === Image.Error) enabled: root.hasPreviewGif
source = "qrc:/qml/ScreenPlayApp/assets/images/missingPreview.png"
} }
Image {
id: imagePreview
asynchronous: false
fillMode: Image.PreserveAspectCrop
anchors.fill: parent
enabled: !root.hasPreviewGif
visible: enabled
} }
LinearGradient { LinearGradient {
@ -409,7 +423,12 @@ Item {
} }
PropertyChanges { PropertyChanges {
target: image target: imagePreview
opacity: 0
anchors.topMargin: 20
}
PropertyChanges {
target: animatedImagePreview
opacity: 0 opacity: 0
anchors.topMargin: 20 anchors.topMargin: 20
} }
@ -429,7 +448,12 @@ Item {
} }
PropertyChanges { PropertyChanges {
target: image target: imagePreview
opacity: 1
anchors.topMargin: 0
}
PropertyChanges {
target: animatedImagePreview
opacity: 1 opacity: 1
anchors.topMargin: 0 anchors.topMargin: 0
} }
@ -443,7 +467,12 @@ Item {
name: "activeWallpaper" name: "activeWallpaper"
PropertyChanges { PropertyChanges {
target: image target: imagePreview
opacity: 1
anchors.topMargin: 0
}
PropertyChanges {
target: animatedImagePreview
opacity: 1 opacity: 1
anchors.topMargin: 0 anchors.topMargin: 0
} }
@ -469,7 +498,12 @@ Item {
name: "activeScene" name: "activeScene"
PropertyChanges { PropertyChanges {
target: image target: imagePreview
opacity: 1
anchors.topMargin: 0
}
PropertyChanges {
target: animatedImagePreview
opacity: 1 opacity: 1
anchors.topMargin: 0 anchors.topMargin: 0
} }
@ -493,13 +527,13 @@ Item {
reversible: true reversible: true
NumberAnimation { NumberAnimation {
target: image targets: [animatedImagePreview, imagePreview]
property: "opacity" property: "opacity"
duration: 200 duration: 200
} }
NumberAnimation { NumberAnimation {
target: image targets: [animatedImagePreview, imagePreview]
property: "anchors.topMargin" property: "anchors.topMargin"
duration: 400 duration: 400
} }
@ -525,13 +559,13 @@ Item {
ParallelAnimation { ParallelAnimation {
NumberAnimation { NumberAnimation {
target: image targets: [animatedImagePreview, imagePreview]
property: "opacity" property: "opacity"
duration: 200 duration: 200
} }
NumberAnimation { NumberAnimation {
target: image targets: [animatedImagePreview, imagePreview]
property: "anchors.topMargin" property: "anchors.topMargin"
duration: 100 duration: 100
} }
@ -552,13 +586,13 @@ Item {
ParallelAnimation { ParallelAnimation {
NumberAnimation { NumberAnimation {
target: image targets: [animatedImagePreview, imagePreview]
property: "opacity" property: "opacity"
duration: 200 duration: 200
} }
NumberAnimation { NumberAnimation {
target: image targets: [animatedImagePreview, imagePreview]
property: "anchors.topMargin" property: "anchors.topMargin"
duration: 100 duration: 100
} }
@ -578,13 +612,13 @@ Item {
ParallelAnimation { ParallelAnimation {
NumberAnimation { NumberAnimation {
target: image targets: [animatedImagePreview, imagePreview]
property: "opacity" property: "opacity"
duration: 200 duration: 200
} }
NumberAnimation { NumberAnimation {
target: image targets: [animatedImagePreview, imagePreview]
property: "anchors.topMargin" property: "anchors.topMargin"
duration: 100 duration: 100
} }

View File

@ -100,7 +100,7 @@ void Util::openFolderInExplorer(const QString& url) const
/*! /*!
\brief Removes file///: or file:// from the url/string \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); return ScreenPlayUtil::toLocal(url);
} }
@ -243,6 +243,12 @@ void Util::Util::requestDataProtection()
emit this->allDataProtectionLoaded(tmp); emit this->allDataProtectionLoaded(tmp);
} }
bool Util::fileExists(const QString& filePath) const
{
const QFileInfo file(toLocal(filePath));
return file.isFile();
}
static const char* static const char*
logLevelForMessageType(QtMsgType msgType) logLevelForMessageType(QtMsgType msgType)
{ {

View File

@ -3,7 +3,7 @@ Encoding=UTF-8
Name=ScreenPlay Name=ScreenPlay
Keywords=ScreenPlay Keywords=ScreenPlay
Icon=preferences-desktop-wallpaper Icon=preferences-desktop-wallpaper
Version=0.15.0 Version=0.15.0-RC3
Type=Service Type=Service