Shutup LinkPreviewDelegate
Make sure that the console isn't spammed having `linkpreviewer` undefined in `LinkPreviewDelegate`, even though it shouldn't ever be and I couldn't find any case where it was but my console was still intermittently getting spammed.
This commit is contained in:
@@ -93,4 +93,9 @@ void LinkPreviewer::loadUrlPreview()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool LinkPreviewer::empty() const
|
||||||
|
{
|
||||||
|
return m_url.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
#include "moc_linkpreviewer.cpp"
|
#include "moc_linkpreviewer.cpp"
|
||||||
|
|||||||
@@ -44,6 +44,13 @@ class LinkPreviewer : public QObject
|
|||||||
*/
|
*/
|
||||||
Q_PROPERTY(QUrl imageSource READ imageSource NOTIFY imageSourceChanged)
|
Q_PROPERTY(QUrl imageSource READ imageSource NOTIFY imageSourceChanged)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Whether the there is a link to preview.
|
||||||
|
*
|
||||||
|
* A linkPreviwer is empty if the URL is empty.
|
||||||
|
*/
|
||||||
|
Q_PROPERTY(bool empty READ empty NOTIFY emptyChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit LinkPreviewer(QObject *parent = nullptr, const NeoChatRoom *room = nullptr, const QUrl &url = {});
|
explicit LinkPreviewer(QObject *parent = nullptr, const NeoChatRoom *room = nullptr, const QUrl &url = {});
|
||||||
|
|
||||||
@@ -53,6 +60,7 @@ public:
|
|||||||
[[nodiscard]] QString title() const;
|
[[nodiscard]] QString title() const;
|
||||||
[[nodiscard]] QString description() const;
|
[[nodiscard]] QString description() const;
|
||||||
[[nodiscard]] QUrl imageSource() const;
|
[[nodiscard]] QUrl imageSource() const;
|
||||||
|
[[nodiscard]] bool empty() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const NeoChatRoom *m_currentRoom = nullptr;
|
const NeoChatRoom *m_currentRoom = nullptr;
|
||||||
@@ -71,5 +79,6 @@ Q_SIGNALS:
|
|||||||
void descriptionChanged();
|
void descriptionChanged();
|
||||||
void imageSourceChanged();
|
void imageSourceChanged();
|
||||||
void urlChanged();
|
void urlChanged();
|
||||||
|
void emptyChanged();
|
||||||
};
|
};
|
||||||
Q_DECLARE_METATYPE(LinkPreviewer *)
|
Q_DECLARE_METATYPE(LinkPreviewer *)
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ Loader {
|
|||||||
* - description - the description of the URL preview.
|
* - description - the description of the URL preview.
|
||||||
* - imageSource - a source URL for the preview image.
|
* - imageSource - a source URL for the preview image.
|
||||||
*/
|
*/
|
||||||
property var linkPreviewer
|
required property var linkPreviewer
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Standard height for the link preview.
|
* @brief Standard height for the link preview.
|
||||||
@@ -39,7 +39,7 @@ Loader {
|
|||||||
property bool indicatorEnabled: false
|
property bool indicatorEnabled: false
|
||||||
|
|
||||||
visible: active
|
visible: active
|
||||||
sourceComponent: linkPreviewer.loaded ? linkPreviewComponent : loadingComponent
|
sourceComponent: linkPreviewer && linkPreviewer.loaded ? linkPreviewComponent : loadingComponent
|
||||||
|
|
||||||
Component {
|
Component {
|
||||||
id: linkPreviewComponent
|
id: linkPreviewComponent
|
||||||
@@ -61,10 +61,10 @@ Loader {
|
|||||||
color: Kirigami.Theme.highlightColor
|
color: Kirigami.Theme.highlightColor
|
||||||
}
|
}
|
||||||
Image {
|
Image {
|
||||||
visible: linkPreviewer.imageSource
|
visible: root.linkPreviewer.imageSource
|
||||||
Layout.maximumHeight: root.defaultHeight
|
Layout.maximumHeight: root.defaultHeight
|
||||||
Layout.maximumWidth: root.defaultHeight
|
Layout.maximumWidth: root.defaultHeight
|
||||||
source: linkPreviewer.imageSource
|
source: root.linkPreviewer.imageSource
|
||||||
fillMode: Image.PreserveAspectFit
|
fillMode: Image.PreserveAspectFit
|
||||||
}
|
}
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ TimelineContainer {
|
|||||||
}
|
}
|
||||||
LinkPreviewDelegate {
|
LinkPreviewDelegate {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
active: !currentRoom.usesEncryption && currentRoom.urlPreviewEnabled && Config.showLinkPreview && root.showLinkPreview
|
active: !currentRoom.usesEncryption && currentRoom.urlPreviewEnabled && Config.showLinkPreview && root.showLinkPreview && !root.linkPreview.empty
|
||||||
linkPreviewer: root.linkPreview
|
linkPreviewer: root.linkPreview
|
||||||
indicatorEnabled: root.isVisibleInTimeline()
|
indicatorEnabled: root.isVisibleInTimeline()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user