1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-09-15 06:52:34 +02: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:
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);

View File

@ -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
}

View File

@ -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)
{

View File

@ -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