Merge pull request #4976 from nextcloud/feature/nicer-errorbox

Improve the error box QML component
This commit is contained in:
Claudio Cambra 2022-09-29 12:48:47 +02:00 committed by GitHub
commit 53573745a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 64 additions and 46 deletions

View file

@ -1,4 +1,5 @@
import QtQuick 2.15 import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15 import QtQuick.Controls 2.15
import Style 1.0 import Style 1.0
@ -6,29 +7,74 @@ import Style 1.0
Item { Item {
id: errorBox id: errorBox
property var text: "" signal closeButtonClicked
property string text: ""
property color color: Style.errorBoxTextColor
property color backgroundColor: Style.errorBoxBackgroundColor property color backgroundColor: Style.errorBoxBackgroundColor
property color borderColor: Style.errorBoxBorderColor property bool showCloseButton: false
implicitHeight: errorMessage.implicitHeight + 2 * 8 implicitHeight: errorMessageLayout.implicitHeight + (2 * Style.standardSpacing)
Rectangle {
id: solidStripe
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.left: parent.left
width: Style.errorBoxStripeWidth
color: errorBox.backgroundColor
}
Rectangle { Rectangle {
anchors.fill: parent anchors.fill: parent
color: errorBox.backgroundColor color: errorBox.backgroundColor
border.color: errorBox.borderColor opacity: 0.2
}
GridLayout {
id: errorMessageLayout
anchors.fill: parent
anchors.margins: Style.standardSpacing
anchors.leftMargin: Style.standardSpacing + solidStripe.width
columns: 2
Label {
Layout.fillWidth: true
color: Style.ncTextColor
font.bold: true
text: qsTr("Error")
visible: errorBox.showCloseButton
}
Button {
Layout.preferredWidth: Style.iconButtonWidth
Layout.preferredHeight: Style.iconButtonWidth
background: null
icon.color: Style.ncTextColor
icon.source: "qrc:///client/theme/close.svg"
visible: errorBox.showCloseButton
enabled: visible
onClicked: errorBox.closeButtonClicked()
} }
Label { Label {
id: errorMessage id: errorMessage
anchors.fill: parent Layout.fillWidth: true
anchors.margins: 8 Layout.fillHeight: true
width: parent.width Layout.columnSpan: 2
color: errorBox.color
color: Style.ncTextColor
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
text: errorBox.text text: errorBox.text
textFormat: Text.PlainText textFormat: Text.PlainText
} }
}
} }

View file

@ -887,21 +887,6 @@ QColor Theme::defaultColor()
return QColor{NEXTCLOUD_BACKGROUND_COLOR}; return QColor{NEXTCLOUD_BACKGROUND_COLOR};
} }
QColor Theme::errorBoxTextColor() const
{
return QColor{"white"};
}
QColor Theme::errorBoxBackgroundColor() const
{
return QColor{"red"};
}
QColor Theme::errorBoxBorderColor() const
{
return QColor{"black"};
}
void Theme::connectToPaletteSignal() void Theme::connectToPaletteSignal()
{ {
if (!_paletteSignalsConnected) { if (!_paletteSignalsConnected) {

View file

@ -64,9 +64,6 @@ class OWNCLOUDSYNC_EXPORT Theme : public QObject
Q_PROPERTY(QString updateCheckUrl READ updateCheckUrl CONSTANT) Q_PROPERTY(QString updateCheckUrl READ updateCheckUrl CONSTANT)
Q_PROPERTY(QColor defaultColor READ defaultColor CONSTANT) Q_PROPERTY(QColor defaultColor READ defaultColor CONSTANT)
Q_PROPERTY(QColor errorBoxTextColor READ errorBoxTextColor CONSTANT)
Q_PROPERTY(QColor errorBoxBackgroundColor READ errorBoxBackgroundColor CONSTANT)
Q_PROPERTY(QColor errorBoxBorderColor READ errorBoxBorderColor CONSTANT)
Q_PROPERTY(QPalette systemPalette READ systemPalette NOTIFY systemPaletteChanged) Q_PROPERTY(QPalette systemPalette READ systemPalette NOTIFY systemPaletteChanged)
Q_PROPERTY(bool darkMode READ darkMode NOTIFY darkModeChanged) Q_PROPERTY(bool darkMode READ darkMode NOTIFY darkModeChanged)
@ -583,15 +580,6 @@ public:
static QColor defaultColor(); static QColor defaultColor();
/** @return color for the ErrorBox text. */
virtual QColor errorBoxTextColor() const;
/** @return color for the ErrorBox background. */
virtual QColor errorBoxBackgroundColor() const;
/** @return color for the ErrorBox border. */
virtual QColor errorBoxBorderColor() const;
static constexpr const char *themePrefix = ":/client/theme/"; static constexpr const char *themePrefix = ":/client/theme/";
QPalette systemPalette(); QPalette systemPalette();

View file

@ -19,9 +19,8 @@ QtObject {
readonly property color buttonBackgroundColor: Theme.systemPalette.button readonly property color buttonBackgroundColor: Theme.systemPalette.button
// ErrorBox colors // ErrorBox colors
readonly property color errorBoxTextColor: Theme.errorBoxTextColor readonly property color errorBoxBackgroundColor: Qt.rgba(0.89, 0.18, 0.18, 1)
readonly property color errorBoxBackgroundColor: Theme.errorBoxBackgroundColor readonly property int errorBoxStripeWidth: 4
readonly property color errorBoxBorderColor: Theme.errorBoxBorderColor
// Fonts // Fonts
// We are using pixel size because this is cross platform comparable, point size isn't // We are using pixel size because this is cross platform comparable, point size isn't