Skip to content

Commit 13d7d2b

Browse files
committed
fix: route profile image format detection through image utils
1 parent 4e31f76 commit 13d7d2b

6 files changed

Lines changed: 14 additions & 21 deletions

File tree

components/images/ProfileImage.qml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@ pragma ComponentBehavior: Bound
22

33
import QtQuick
44
import Quickshell
5-
import Caelestia
5+
import Caelestia.Images
66

77
Item {
88
id: root
99

1010
property string path
11-
property string _format: CUtils.imageFormat(path)
11+
property string _format: IUtils.imageFormat(path)
1212

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

1515
function reload(): void {
16-
_format = Qt.binding(() => CUtils.imageFormat(path));
16+
_format = Qt.binding(() => IUtils.imageFormat(path));
1717
loader.active = false;
1818
loader.active = true;
1919
}
@@ -36,6 +36,7 @@ Item {
3636
return Qt.size(width * dpr, height * dpr);
3737
}
3838
asynchronous: true
39+
cache: false
3940
playing: true
4041
source: Qt.resolvedUrl(root.path)
4142
}
@@ -46,6 +47,7 @@ Item {
4647

4748
CachingImage {
4849
anchors.fill: parent
50+
cache: false
4951
path: root.path
5052
}
5153
}

modules/dashboard/dash/User.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ Row {
103103

104104
Connections {
105105
function onAccepted(): void {
106-
pfp.reload();
106+
Qt.callLater(pfp.reload);
107107
}
108108

109109
target: root.facePicker

plugin/src/Caelestia/Images/iutils.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
#include "cachingimageprovider.hpp"
44

5+
#include <qimagereader.h>
6+
57
namespace caelestia::images {
68

79
IUtils* IUtils::create(QQmlEngine* engine, QJSEngine* jsEngine) {
@@ -15,6 +17,10 @@ IUtils* IUtils::create(QQmlEngine* engine, QJSEngine* jsEngine) {
1517
return new IUtils(engine);
1618
}
1719

20+
QString IUtils::imageFormat(const QString& path) {
21+
return QString::fromLatin1(QImageReader::imageFormat(path));
22+
}
23+
1824
QUrl IUtils::urlForPath(const QString& path, int fillMode) {
1925
if (path.isEmpty())
2026
return QUrl();

plugin/src/Caelestia/Images/iutils.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class IUtils : public QObject {
1414
public:
1515
static IUtils* create(QQmlEngine* engine, QJSEngine* jsEngine);
1616

17+
Q_INVOKABLE static QString imageFormat(const QString& path);
1718
Q_INVOKABLE static QUrl urlForPath(const QString& path, int fillMode);
1819

1920
private:

plugin/src/Caelestia/cutils.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include <qdir.h>
77
#include <qfileinfo.h>
88
#include <qfuturewatcher.h>
9-
#include <qimagereader.h>
109
#include <qloggingcategory.h>
1110
#include <qqmlengine.h>
1211

@@ -139,17 +138,4 @@ QString CUtils::toLocalFile(const QUrl& url) const {
139138
return url.toLocalFile();
140139
}
141140

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-
151-
QString CUtils::imageFormat(const QString& path) const {
152-
return QString::fromLatin1(QImageReader::imageFormat(path));
153-
}
154-
155141
} // namespace caelestia

plugin/src/Caelestia/cutils.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ 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;
28-
Q_INVOKABLE QString imageFormat(const QString& path) const;
2927
};
3028

3129
} // namespace caelestia

0 commit comments

Comments
 (0)