Add a sampleUrl function to get back the sample url of an image
The sample url is a mid-scaled version of the image, used for previewing.
This commit is contained in:
parent
4cf88931b5
commit
a11bc79309
2 changed files with 17 additions and 4 deletions
|
@ -60,10 +60,11 @@ DanbooruPost::DanbooruPost(QVariantMap postData, QPixmap pixmap,
|
||||||
m_height = postData.value("height").toString().toInt();
|
m_height = postData.value("height").toString().toInt();
|
||||||
m_width = postData.value("width").toString().toInt();
|
m_width = postData.value("width").toString().toInt();
|
||||||
|
|
||||||
m_url = QUrl(postData.value("file_url").toUrl());
|
m_url = postData.value("file_url").toUrl();
|
||||||
m_thumbnailUrl = QUrl(postData.value("preview_url").toUrl());
|
m_thumbnailUrl = postData.value("preview_url").toUrl();
|
||||||
m_size = postData.value("file_size").toInt();
|
m_size = postData.value("file_size").toInt();
|
||||||
m_rating = RATING_MAP.value(postData.value("rating").toString());
|
m_rating = RATING_MAP.value(postData.value("rating").toString());
|
||||||
|
m_sampleUrl = postData.value("sample_url").toUrl();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,8 +78,10 @@ DanbooruPost::DanbooruPost(QXmlStreamAttributes &postData, QPixmap pixmap, QObje
|
||||||
m_height = postData.value("height").toString().toInt();
|
m_height = postData.value("height").toString().toInt();
|
||||||
m_width = postData.value("width").toString().toInt();
|
m_width = postData.value("width").toString().toInt();
|
||||||
|
|
||||||
m_url = QUrl(postData.value("file_url").toString());
|
m_url = QUrl::fromUserInput(postData.value("file_url").toString());
|
||||||
m_thumbnailUrl = QUrl(postData.value("preview_url").toString());
|
m_thumbnailUrl = QUrl::fromUserInput(postData.value("preview_url").toString());
|
||||||
|
m_sampleUrl = QUrl::fromUserInput(postData.value("sample_url").toString());
|
||||||
|
|
||||||
m_size = postData.value("file_size").toString().toInt();
|
m_size = postData.value("file_size").toString().toInt();
|
||||||
m_rating = RATING_MAP.value(postData.value("rating").toString());
|
m_rating = RATING_MAP.value(postData.value("rating").toString());
|
||||||
}
|
}
|
||||||
|
@ -141,6 +144,12 @@ const QUrl DanbooruPost::thumbnailUrl() const
|
||||||
return m_thumbnailUrl;
|
return m_thumbnailUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QUrl DanbooruPost::sampleUrl() const
|
||||||
|
{
|
||||||
|
return m_sampleUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QPixmap DanbooruPost::pixmap() const
|
QPixmap DanbooruPost::pixmap() const
|
||||||
{
|
{
|
||||||
return m_pixmap;
|
return m_pixmap;
|
||||||
|
|
|
@ -72,6 +72,7 @@ class DanbooruPost : public QObject
|
||||||
Q_PROPERTY(QUrl fileUrl READ fileUrl)
|
Q_PROPERTY(QUrl fileUrl READ fileUrl)
|
||||||
Q_PROPERTY(QSet<QString> tags READ tags)
|
Q_PROPERTY(QSet<QString> tags READ tags)
|
||||||
Q_PROPERTY(QUrl thumbnailUrl READ thumbnailUrl)
|
Q_PROPERTY(QUrl thumbnailUrl READ thumbnailUrl)
|
||||||
|
Q_PROPERTY(QUrl sampleUrl READ sampleUrl)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -103,6 +104,7 @@ private:
|
||||||
|
|
||||||
QUrl m_url;
|
QUrl m_url;
|
||||||
QUrl m_thumbnailUrl;
|
QUrl m_thumbnailUrl;
|
||||||
|
QUrl m_sampleUrl;
|
||||||
QSet<QString> m_tags;
|
QSet<QString> m_tags;
|
||||||
DanbooruPost::Rating m_rating;
|
DanbooruPost::Rating m_rating;
|
||||||
|
|
||||||
|
@ -181,6 +183,8 @@ public:
|
||||||
**/
|
**/
|
||||||
const QUrl fileUrl() const;
|
const QUrl fileUrl() const;
|
||||||
|
|
||||||
|
const QUrl sampleUrl() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The tags associated to the post.
|
* @return The tags associated to the post.
|
||||||
**/
|
**/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue