Commit 4e3214d4 authored by Volker Krause's avatar Volker Krause
Browse files

Don't render pkpass tickets not specifying all colors as black on black

parent 929e666e
......@@ -25,7 +25,7 @@ Item {
Rectangle {
id: bodyBackground
color: pass.backgroundColor
color: Util.isValidColor(pass.backgroundColor) ? pass.backgroundColor : Kirigami.Theme.backgroundColor
//implicitHeight: topLayout.implicitHeight + 2 * topLayout.anchors.margins
width: parent.width
......@@ -77,21 +77,21 @@ Item {
Layout.rowSpan: 2
Layout.fillWidth: pass ? true : false
text: pass ? pass.logoText : ""
color: pass.foregroundColor
color: Util.isValidColor(pass.foregroundColor) ? pass.foregroundColor : Kirigami.Theme.textColor
}
Repeater {
model: pass.headerFields
delegate: QQC2.Label {
text: modelData.label
color: pass.labelColor
color: Util.isValidColor(pass.labelColor) ? pass.labelColor : Kirigami.Theme.textColor
}
}
Repeater {
model: pass.headerFields
delegate: QQC2.Label {
text: modelData.valueDisplayString
color: pass.foregroundColor
color: Util.isValidColor(pass.foregroundColor) ? pass.foregroundColor : Kirigami.Theme.textColor
}
}
}
......@@ -116,7 +116,7 @@ Item {
model: pass.primaryFields
delegate: QQC2.Label {
Layout.fillWidth: true
color: pass.labelColor
color: Util.isValidColor(pass.labelColor) ? pass.labelColor : Kirigami.Theme.textColor
text: modelData.label
horizontalAlignment: modelData.textAlignment
}
......@@ -125,7 +125,7 @@ Item {
model: pass.primaryFields
delegate: QQC2.Label {
Layout.fillWidth: true
color: pass.foregroundColor
color: Util.isValidColor(pass.foregroundColor) ? pass.foregroundColor : Kirigami.Theme.textColor
text: modelData.valueDisplayString
horizontalAlignment: modelData.textAlignment
}
......@@ -143,7 +143,7 @@ Item {
model: pass.secondaryFields
delegate: QQC2.Label {
Layout.fillWidth: true
color: pass.labelColor
color: Util.isValidColor(pass.labelColor) ? pass.labelColor : Kirigami.Theme.textColor
text: modelData.label
horizontalAlignment: modelData.textAlignment
}
......@@ -152,7 +152,7 @@ Item {
model: pass.secondaryFields
delegate: QQC2.Label {
Layout.fillWidth: true
color: pass.foregroundColor
color: Util.isValidColor(pass.foregroundColor) ? pass.foregroundColor : Kirigami.Theme.textColor
text: modelData.valueDisplayString
horizontalAlignment: modelData.textAlignment
}
......@@ -170,7 +170,7 @@ Item {
model: pass.auxiliaryFields
delegate: QQC2.Label {
Layout.fillWidth: true
color: pass.labelColor
color: Util.isValidColor(pass.labelColor) ? pass.labelColor : Kirigami.Theme.textColor
text: modelData.label
horizontalAlignment: modelData.textAlignment
}
......@@ -179,7 +179,7 @@ Item {
model: pass.auxiliaryFields
delegate: QQC2.Label {
Layout.fillWidth: true
color: pass.foregroundColor
color: Util.isValidColor(pass.foregroundColor) ? pass.foregroundColor : Kirigami.Theme.textColor
text: modelData.valueDisplayString
horizontalAlignment: modelData.textAlignment
}
......@@ -211,14 +211,14 @@ Item {
ColumnLayout {
QQC2.Label {
Layout.fillWidth: true
color: pass.labelColor
color: Util.isValidColor(pass.labelColor) ? pass.labelColor : Kirigami.Theme.textColor
text: modelData.label
wrapMode: Text.WordWrap
horizontalAlignment: modelData.textAlignment
}
QQC2.Label {
Layout.fillWidth: true
color: pass.foregroundColor
color: Util.isValidColor(pass.foregroundColor) ? pass.foregroundColor : Kirigami.Theme.textColor
text: Util.textToHtml(modelData.valueDisplayString)
textFormat: Util.isRichText(modelData.valueDisplayString) ? Text.RichText : Text.AutoText
wrapMode: Text.WordWrap
......
......@@ -12,6 +12,7 @@
#include <KTextToHTML>
#include <QAbstractItemModel>
#include <QColor>
#include <QDateTime>
#include <QFile>
#include <QTimeZone>
......@@ -119,4 +120,9 @@ float Util::svgAspectRatio(const QString &svgFilePath)
return 1.0f;
}
bool Util::isValidColor(const QColor &color)
{
return color.isValid();
}
#include "moc_util.cpp"
......@@ -9,6 +9,7 @@
#include <qobjectdefs.h>
class QColor;
class QDateTime;
class QVariant;
......@@ -36,6 +37,9 @@ public:
* This is a dirty workaround for the problem that Kirigami.Icon has its implicit size hardcoded to 32x32...
*/
Q_INVOKABLE static float svgAspectRatio(const QString &svgFilePath);
/** QColor::isValid for QML. */
Q_INVOKABLE static bool isValidColor(const QColor &color);
};
#endif // UTIL_H
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment