Skip to content

Commit 8948988

Browse files
committed
fix: profile image status cast, loader sizing, and imageFormat QUrl overload
1 parent a58e238 commit 8948988

3 files changed

Lines changed: 13 additions & 1 deletion

File tree

components/images/ProfileImage.qml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Item {
99
property string path
1010
property string _format: CUtils.imageFormat(path)
1111

12-
readonly property int status: (loader.item as Image)?.status ?? Image.Null
12+
readonly property int status: loader.item?.status ?? Image.Null // qmllint disable
1313

1414
function reload(): void {
1515
_format = Qt.binding(() => CUtils.imageFormat(path));
@@ -28,6 +28,7 @@ Item {
2828
id: animatedComponent
2929

3030
AnimatedImage {
31+
anchors.fill: parent
3132
fillMode: AnimatedImage.PreserveAspectCrop
3233
asynchronous: true
3334
playing: true
@@ -39,6 +40,7 @@ Item {
3940
id: cachingComponent
4041

4142
CachingImage {
43+
anchors.fill: parent
4244
path: root.path
4345
}
4446
}

plugin/src/Caelestia/cutils.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,15 @@ QString CUtils::toLocalFile(const QUrl& url) const {
139139
return url.toLocalFile();
140140
}
141141

142+
QString CUtils::imageFormat(const QUrl& url) const {
143+
if (!url.isLocalFile()) {
144+
qCWarning(lcCUtils) << "imageFormat: url" << url << "is not a local file";
145+
return QString();
146+
}
147+
148+
return imageFormat(url.toLocalFile());
149+
}
150+
142151
QString CUtils::imageFormat(const QString& path) const {
143152
return QString::fromLatin1(QImageReader::imageFormat(path));
144153
}

plugin/src/Caelestia/cutils.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class CUtils : public QObject {
2424
Q_INVOKABLE bool copyFile(const QUrl& source, const QUrl& target, bool overwrite = true) const;
2525
Q_INVOKABLE bool deleteFile(const QUrl& path) const;
2626
Q_INVOKABLE QString toLocalFile(const QUrl& url) const;
27+
Q_INVOKABLE QString imageFormat(const QUrl& url) const;
2728
Q_INVOKABLE QString imageFormat(const QString& path) const;
2829
};
2930

0 commit comments

Comments
 (0)