Skip to content

Commit

Permalink
Show an error messages in image preview popup on error
Browse files Browse the repository at this point in the history
Closes #150
  • Loading branch information
MartinBriza committed Oct 10, 2023
1 parent 2044b23 commit 9109636
Showing 1 changed file with 36 additions and 5 deletions.
41 changes: 36 additions & 5 deletions modules/Lith/UI/PreviewPopup.qml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
// along with this program; If not, see <http://www.gnu.org/licenses/>.

import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import QtMultimedia as Multimedia
//import QtWebView

import Lith.Core
import Lith.Style

Dialog {
id: root
Expand All @@ -35,7 +35,10 @@ Dialog {
topMargin: 0
bottomInset: 0
padding: 0
background: Item {}
background: Rectangle {
color: palette.base
opacity: 0.5
}

property string currentUrl

Expand Down Expand Up @@ -265,7 +268,6 @@ Dialog {
duration: 60
}
}

}

BusyIndicator {
Expand Down Expand Up @@ -344,6 +346,35 @@ Dialog {
delegateImage.scale = 1.0
}
}

ColumnLayout {
visible: delegateImage.status === Image.Error
anchors.centerIn: delegateImage
width: parent.width / 3.0 * 2.0
spacing: 12
Image {
Layout.alignment: Qt.AlignHCenter
width: 32
height: 32
source: "qrc:/navigation/"+WindowHelper.currentThemeName+"/dizzy.png"
}
Label {
Layout.alignment: Qt.AlignHCenter
Layout.fillWidth: true
wrapMode: Label.Wrap
color: "red"
horizontalAlignment: Label.AlignHCenter
text: delegateImage.status === Image.Error ? qsTr("The picture could not be displayed") : ""
}
Label {
Layout.alignment: Qt.AlignHCenter
Layout.fillWidth: true
wrapMode: Label.Wrap
horizontalAlignment: Label.AlignHCenter
text: qsTr("<span style='white-space: pre-wrap;'>URL: <a href='%1'>%1</a></span>").arg(delegateImage.source)
textFormat: Label.RichText
}
}
}

Item {
Expand Down Expand Up @@ -424,10 +455,10 @@ Dialog {
spacing: 12
Label {
id: errorMsgText
visible: delegateImage.status === Image.Error || delegateVideo.errorString.length > 0
visible: delegateVideo.errorString.length > 0
Layout.alignment: Qt.AlignHCenter
color: "red"
text: delegateImage.status === Image.Error ? qsTr("The picture could not be displayed") : delegateVideo.errorString
text: delegateVideo.errorString
}
RowLayout {
spacing: 24
Expand Down

0 comments on commit 9109636

Please sign in to comment.