Skip to content

Commit

Permalink
Load image tags in QML (issue #2147)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bionus committed May 13, 2021
1 parent d74dbc8 commit 9962a8d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/gui-qml/src/components/ImageScreen.qml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ Page {
}
}
}

Component.onCompleted: modelData.loadTags()
}
}
}
Expand Down
13 changes: 11 additions & 2 deletions src/gui-qml/src/models/qml-image.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class QmlImage : public QObject
Q_PROPERTY(QString previewUrl READ previewUrl CONSTANT)
Q_PROPERTY(QString sampleUrl READ sampleUrl CONSTANT)
Q_PROPERTY(QString fileUrl READ fileUrl CONSTANT)
Q_PROPERTY(QStringList tags READ tags CONSTANT)
Q_PROPERTY(QStringList tags READ tags NOTIFY tagsChanged)
Q_PROPERTY(QString badge READ badge CONSTANT)
Q_PROPERTY(QColor color READ color CONSTANT)
Q_PROPERTY(QSharedPointer<Image> image READ image CONSTANT)
Expand All @@ -30,7 +30,10 @@ class QmlImage : public QObject

public:
QmlImage(QSharedPointer<Image> image, Profile *profile, QObject *parent = nullptr)
: QObject(parent), m_image(std::move(image)), m_profile(profile) {}
: QObject(parent), m_image(std::move(image)), m_profile(profile)
{
connect(m_image.data(), &Image::finishedLoadingTags, this, &QmlImage::tagsChanged);
}

QSharedPointer<Image> image() const { return m_image; }
QString previewUrl() const { return m_image->url(Image::Size::Thumbnail).toString(); }
Expand All @@ -43,6 +46,12 @@ class QmlImage : public QObject
bool isVideo() const { return m_image->isVideo(); }
bool isGallery() const { return m_image->isGallery(); }

public slots:
void loadTags() { m_image->loadDetails(); };

signals:
void tagsChanged();

private:
QSharedPointer<Image> m_image;
Profile *m_profile;
Expand Down

0 comments on commit 9962a8d

Please sign in to comment.