mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
Check for undefined and null values in QML
Conditional chaining is not available in Qt5.15, so this is uglier than it should be.
This commit is contained in:
parent
68dbd90413
commit
6892a28d0a
@ -49,7 +49,7 @@ Rectangle {
|
|||||||
x: 27
|
x: 27
|
||||||
y: 5
|
y: 5
|
||||||
|
|
||||||
read: comicInfo.read
|
read: comicInfo ? comicInfo.read ?? false : false
|
||||||
|
|
||||||
onReadChangedByUser: {
|
onReadChangedByUser: {
|
||||||
comicInfo.read = read;
|
comicInfo.read = read;
|
||||||
@ -82,7 +82,7 @@ Rectangle {
|
|||||||
InfoTick {
|
InfoTick {
|
||||||
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
|
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
|
||||||
|
|
||||||
read: comicInfo.read
|
read: comicInfo ? comicInfo.read ?? false : false
|
||||||
|
|
||||||
onReadChangedByUser: {
|
onReadChangedByUser: {
|
||||||
comicInfo.read = read;
|
comicInfo.read = read;
|
||||||
@ -99,7 +99,7 @@ Rectangle {
|
|||||||
Layout.rightMargin: 17
|
Layout.rightMargin: 17
|
||||||
Layout.alignment: Qt.AlignTop
|
Layout.alignment: Qt.AlignTop
|
||||||
|
|
||||||
active: comicInfo.isFavorite
|
active: comicInfo ? comicInfo.isFavorite ?? false : false
|
||||||
|
|
||||||
onActiveChangedByUser: {
|
onActiveChangedByUser: {
|
||||||
if(active)
|
if(active)
|
||||||
@ -114,7 +114,7 @@ Rectangle {
|
|||||||
InfoRating {
|
InfoRating {
|
||||||
Layout.alignment: Qt.AlignTop
|
Layout.alignment: Qt.AlignTop
|
||||||
Layout.rightMargin: 30
|
Layout.rightMargin: 30
|
||||||
rating: comicInfo.rating
|
rating: comicInfo ? comicInfo.rating ?? 0 : 0
|
||||||
|
|
||||||
onRatingChangedByUser: {
|
onRatingChangedByUser: {
|
||||||
comicInfo.rating = rating;
|
comicInfo.rating = rating;
|
||||||
@ -140,7 +140,7 @@ Rectangle {
|
|||||||
font.pixelSize: mainContainer.compact ? 18 : 21;
|
font.pixelSize: mainContainer.compact ? 18 : 21;
|
||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.WordWrap
|
||||||
|
|
||||||
text: comic.getTitleIncludingNumber()
|
text: comic ? comic.getTitleIncludingNumber() ?? "" : ""
|
||||||
}
|
}
|
||||||
|
|
||||||
RowLayout
|
RowLayout
|
||||||
@ -155,7 +155,7 @@ Rectangle {
|
|||||||
Layout.rightMargin: 17
|
Layout.rightMargin: 17
|
||||||
Layout.alignment: Qt.AlignTop
|
Layout.alignment: Qt.AlignTop
|
||||||
|
|
||||||
active: comicInfo.isFavorite
|
active: comicInfo ? comicInfo.isFavorite ?? false : false
|
||||||
|
|
||||||
onActiveChangedByUser: {
|
onActiveChangedByUser: {
|
||||||
if(active)
|
if(active)
|
||||||
@ -170,7 +170,7 @@ Rectangle {
|
|||||||
InfoRating {
|
InfoRating {
|
||||||
Layout.alignment: Qt.AlignTop
|
Layout.alignment: Qt.AlignTop
|
||||||
Layout.rightMargin: 30
|
Layout.rightMargin: 30
|
||||||
rating: comicInfo.rating
|
rating: comicInfo ? comicInfo.rating ?? 0 : 0
|
||||||
|
|
||||||
onRatingChangedByUser: {
|
onRatingChangedByUser: {
|
||||||
comicInfo.rating = rating;
|
comicInfo.rating = rating;
|
||||||
@ -188,45 +188,45 @@ Rectangle {
|
|||||||
id: volume
|
id: volume
|
||||||
color: infoColor
|
color: infoColor
|
||||||
font: mainContainer.infoFont
|
font: mainContainer.infoFont
|
||||||
text: comicInfo.volume
|
text: comicInfo ? comicInfo.volume ?? "" : ""
|
||||||
rightPadding: 20
|
rightPadding: 20
|
||||||
visible: comicInfo.volume
|
visible: comicInfo ? comicInfo.volume ?? false : false
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
id: numbering
|
id: numbering
|
||||||
color: infoColor
|
color: infoColor
|
||||||
font: mainContainer.infoFont
|
font: mainContainer.infoFont
|
||||||
text: comicInfo.number + "/" + comicInfo.count
|
text: (comicInfo ? comicInfo.number ?? "" : "") + "/" + (comicInfo ? comicInfo.count ?? "" : "")
|
||||||
rightPadding: 20
|
rightPadding: 20
|
||||||
visible : comicInfo.number
|
visible : comicInfo ? comicInfo.number ?? false : false
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
id: genre
|
id: genre
|
||||||
color: infoColor
|
color: infoColor
|
||||||
font: mainContainer.infoFont
|
font: mainContainer.infoFont
|
||||||
text: comicInfo.genere
|
text: comicInfo ? comicInfo.genere ?? "" : ""
|
||||||
rightPadding: 20
|
rightPadding: 20
|
||||||
visible: comicInfo.genere
|
visible: comicInfo ? comicInfo.genere ?? false : false
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
id: date
|
id: date
|
||||||
color: infoColor
|
color: infoColor
|
||||||
font: mainContainer.infoFont
|
font: mainContainer.infoFont
|
||||||
text: comicInfo.date
|
text: comicInfo ? comicInfo.date ?? "" : ""
|
||||||
rightPadding: 20
|
rightPadding: 20
|
||||||
visible: comicInfo.date
|
visible: comicInfo ? comicInfo.date ?? false : false
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
id: pages
|
id: pages
|
||||||
color: infoColor
|
color: infoColor
|
||||||
font: mainContainer.infoFont
|
font: mainContainer.infoFont
|
||||||
text: comicInfo.numPages + " pages"
|
text: comicInfo ? comicInfo.numPages ?? "" : "" + " pages"
|
||||||
rightPadding: 20
|
rightPadding: 20
|
||||||
visible: comicInfo.numPages
|
visible: comicInfo ? comicInfo.numPages ?? false : false
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
@ -234,11 +234,11 @@ Rectangle {
|
|||||||
font: mainContainer.infoFont
|
font: mainContainer.infoFont
|
||||||
color: "#ffcc00"
|
color: "#ffcc00"
|
||||||
text: "Show in Comic Vine"
|
text: "Show in Comic Vine"
|
||||||
visible: comicInfo.comicVineID
|
visible: comicInfo ? comicInfo.comicVineID ?? false : false
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onClicked: {
|
onClicked: {
|
||||||
Qt.openUrlExternally("http://www.comicvine.com/comic/4000-%1/".arg(comicInfo.comicVineID));
|
Qt.openUrlExternally("http://www.comicvine.com/comic/4000-%1/".arg(comicInfo ? comicInfo.comicVineID ?? "" : ""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -261,8 +261,8 @@ Rectangle {
|
|||||||
color: #FFCB00;
|
color: #FFCB00;
|
||||||
text-decoration:none;
|
text-decoration:none;
|
||||||
}
|
}
|
||||||
</style></head><body>' + comicInfo.synopsis + '</body></html>'
|
</style></head><body>' + (comicInfo ? comicInfo.synopsis ?? "" : "") + '</body></html>'
|
||||||
visible: comicInfo.synopsis
|
visible: comicInfo ? comicInfo.synopsis ?? false : false
|
||||||
textFormat: Text.RichText
|
textFormat: Text.RichText
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,12 +278,12 @@ Rectangle {
|
|||||||
|
|
||||||
text: qsTr("Authors")
|
text: qsTr("Authors")
|
||||||
|
|
||||||
visible: comicInfo.getWriters().length +
|
visible: comicInfo ? (comicInfo.getWriters().length +
|
||||||
comicInfo.getPencillers().length +
|
comicInfo.getPencillers().length +
|
||||||
comicInfo.getInkers().length +
|
comicInfo.getInkers().length +
|
||||||
comicInfo.getColorists().length +
|
comicInfo.getColorists().length +
|
||||||
comicInfo.getLetterers().length +
|
comicInfo.getLetterers().length +
|
||||||
comicInfo.getCoverArtists().length > 0
|
comicInfo.getCoverArtists().length > 0) : false
|
||||||
}
|
}
|
||||||
|
|
||||||
Flow {
|
Flow {
|
||||||
@ -291,14 +291,14 @@ Rectangle {
|
|||||||
spacing: 20
|
spacing: 20
|
||||||
Repeater {
|
Repeater {
|
||||||
id: writers
|
id: writers
|
||||||
model: comicInfo.getWriters().length
|
model: comicInfo ? comicInfo.getWriters().length : null
|
||||||
Column{
|
Column{
|
||||||
Text {
|
Text {
|
||||||
color: infoTitleColor
|
color: infoTitleColor
|
||||||
font.family: "Arial"
|
font.family: "Arial"
|
||||||
font.pixelSize: 15
|
font.pixelSize: 15
|
||||||
|
|
||||||
text: comicInfo.getWriters()[index]
|
text: comicInfo ? comicInfo.getWriters()[index] : ""
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
@ -313,14 +313,14 @@ Rectangle {
|
|||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
id: pencilllers
|
id: pencilllers
|
||||||
model: comicInfo.getPencillers().length
|
model: comicInfo ? comicInfo.getPencillers().length : null
|
||||||
Column{
|
Column{
|
||||||
Text {
|
Text {
|
||||||
color: infoTitleColor
|
color: infoTitleColor
|
||||||
font.family: "Arial"
|
font.family: "Arial"
|
||||||
font.pixelSize: 15
|
font.pixelSize: 15
|
||||||
|
|
||||||
text: comicInfo.getPencillers()[index]
|
text: comicInfo ? comicInfo.getPencillers()[index] : ""
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
@ -335,14 +335,14 @@ Rectangle {
|
|||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
id: inkers
|
id: inkers
|
||||||
model: comicInfo.getInkers().length
|
model: comicInfo ? comicInfo.getInkers().length : null
|
||||||
Column{
|
Column{
|
||||||
Text {
|
Text {
|
||||||
color: infoTitleColor
|
color: infoTitleColor
|
||||||
font.family: "Arial"
|
font.family: "Arial"
|
||||||
font.pixelSize: 15
|
font.pixelSize: 15
|
||||||
|
|
||||||
text: comicInfo.getInkers()[index]
|
text: comicInfo ? comicInfo.getInkers()[index] : ""
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
@ -357,14 +357,14 @@ Rectangle {
|
|||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
id: colorist
|
id: colorist
|
||||||
model: comicInfo.getColorists().length
|
model: comicInfo ? comicInfo.getColorists().length : null
|
||||||
Column{
|
Column{
|
||||||
Text {
|
Text {
|
||||||
color: infoTitleColor
|
color: infoTitleColor
|
||||||
font.family: "Arial"
|
font.family: "Arial"
|
||||||
font.pixelSize: 15
|
font.pixelSize: 15
|
||||||
|
|
||||||
text: comicInfo.getColorists()[index]
|
text: comicInfo ? comicInfo.getColorists()[index] : ""
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
@ -379,14 +379,14 @@ Rectangle {
|
|||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
id: letterers
|
id: letterers
|
||||||
model: comicInfo.getLetterers().length
|
model: comicInfo ? comicInfo.getLetterers().length : null
|
||||||
Column{
|
Column{
|
||||||
Text {
|
Text {
|
||||||
color: infoTitleColor
|
color: infoTitleColor
|
||||||
font.family: "Arial"
|
font.family: "Arial"
|
||||||
font.pixelSize: 15
|
font.pixelSize: 15
|
||||||
|
|
||||||
text: comicInfo.getLetterers()[index]
|
text: comicInfo ? comicInfo.getLetterers()[index] : ""
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
@ -401,14 +401,14 @@ Rectangle {
|
|||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
id: cover_artist
|
id: cover_artist
|
||||||
model: comicInfo.getCoverArtists().length
|
model: comicInfo ? comicInfo.getCoverArtists().length : ""
|
||||||
Column{
|
Column{
|
||||||
Text {
|
Text {
|
||||||
color: infoTitleColor
|
color: infoTitleColor
|
||||||
font.family: "Arial"
|
font.family: "Arial"
|
||||||
font.pixelSize: 15
|
font.pixelSize: 15
|
||||||
|
|
||||||
text: comicInfo.getCoverArtists()[index]
|
text: comicInfo ? comicInfo.getCoverArtists()[index] : ""
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
@ -447,9 +447,9 @@ Rectangle {
|
|||||||
font.family: "Arial"
|
font.family: "Arial"
|
||||||
font.pixelSize: 15
|
font.pixelSize: 15
|
||||||
|
|
||||||
text: comicInfo.publisher
|
text: comicInfo ? comicInfo.publisher ?? "" : ""
|
||||||
|
|
||||||
visible: comicInfo.publisher
|
visible: comicInfo ? comicInfo.publisher ?? false : false
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
@ -459,9 +459,9 @@ Rectangle {
|
|||||||
font.family: "Arial"
|
font.family: "Arial"
|
||||||
font.pixelSize: 15
|
font.pixelSize: 15
|
||||||
|
|
||||||
text: comicInfo.format
|
text: comicInfo ? comicInfo.format ?? "" : ""
|
||||||
|
|
||||||
visible: comicInfo.format
|
visible: comicInfo ? comicInfo.format ?? false : false
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
@ -471,9 +471,9 @@ Rectangle {
|
|||||||
font.family: "Arial"
|
font.family: "Arial"
|
||||||
font.pixelSize: 15
|
font.pixelSize: 15
|
||||||
|
|
||||||
text: comicInfo.color ? qsTr("color") : qsTr("b/w")
|
text: (comicInfo ? comicInfo.color : false) ? qsTr("color") : qsTr("b/w")
|
||||||
|
|
||||||
visible: comicInfo.color
|
visible: comicInfo ? comicInfo.color ?? false : false
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
@ -483,9 +483,9 @@ Rectangle {
|
|||||||
font.family: "Arial"
|
font.family: "Arial"
|
||||||
font.pixelSize: 15
|
font.pixelSize: 15
|
||||||
|
|
||||||
text: comicInfo.ageRating
|
text: comicInfo ? comicInfo.ageRating ?? "" : ""
|
||||||
|
|
||||||
visible: comicInfo.ageRating
|
visible: comicInfo ? comicInfo.ageRating ?? false : false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -501,7 +501,7 @@ Rectangle {
|
|||||||
|
|
||||||
text: qsTr("Characters")
|
text: qsTr("Characters")
|
||||||
|
|
||||||
visible: comicInfo.getCharacters().length > 0
|
visible: comicInfo ? comicInfo.getCharacters().length > 0 : false
|
||||||
}
|
}
|
||||||
|
|
||||||
Flow {
|
Flow {
|
||||||
@ -509,14 +509,14 @@ Rectangle {
|
|||||||
spacing: 20
|
spacing: 20
|
||||||
Repeater {
|
Repeater {
|
||||||
id: characters
|
id: characters
|
||||||
model: comicInfo.getCharacters().length
|
model: comicInfo ? comicInfo.getCharacters().length : null
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
color: infoTitleColor
|
color: infoTitleColor
|
||||||
font.family: "Arial"
|
font.family: "Arial"
|
||||||
font.pixelSize: 15
|
font.pixelSize: 15
|
||||||
|
|
||||||
text: comicInfo.getCharacters()[index]
|
text: comicInfo ? comicInfo.getCharacters()[index] : ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -637,8 +637,8 @@ Rectangle {
|
|||||||
color: #FFCB00;
|
color: #FFCB00;
|
||||||
text-decoration:none;
|
text-decoration:none;
|
||||||
}
|
}
|
||||||
</style></head><body>' + currentComicInfo.synopsis + '</body></html>'
|
</style></head><body>' + currentComicInfo.synopsis ?? "" + '</body></html>'
|
||||||
visible: currentComicInfo.synopsis
|
visible: currentComicInfo.synopsis ?? false
|
||||||
textFormat: Text.RichText
|
textFormat: Text.RichText
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user