Introduce EnforcedPlainTextLabel, convert all Label or Text labels to use this

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2022-12-02 14:51:09 +01:00
parent 2f3373daf1
commit 28d062af7c
No known key found for this signature in database
GPG Key ID: C839200C384636B0
21 changed files with 78 additions and 43 deletions

View File

@ -37,5 +37,6 @@
<file>src/gui/tray/EditFileLocallyLoadingDialog.qml</file>
<file>src/gui/tray/NCBusyIndicator.qml</file>
<file>src/gui/tray/NCToolTip.qml</file>
<file>src/gui/tray/EnforcedPlainTextLabel.qml</file>
</qresource>
</RCC>

View File

@ -19,6 +19,7 @@ import QtQuick.Controls 2.15
import QtGraphicalEffects 1.0
import Style 1.0
import "./tray"
ComboBox {
id: clearComboBox
@ -31,7 +32,7 @@ ComboBox {
opacity: clearComboBox.hovered ? Style.hoverOpacity : 1.0
}
contentItem: Label {
contentItem: EnforcedPlainTextLabel {
leftPadding: 0
rightPadding: clearComboBox.indicator.width + clearComboBox.spacing
@ -86,7 +87,7 @@ ComboBox {
delegate: ItemDelegate {
id: clearStatusDelegate
width: clearComboBox.width
contentItem: Label {
contentItem: EnforcedPlainTextLabel {
text: modelData.display
textFormat: Text.PlainText
color: Style.ncTextColor

View File

@ -18,6 +18,7 @@ import QtQuick.Layouts 1.15
import Style 1.0
import com.nextcloud.desktopclient 1.0 as NC
import "./tray"
ColumnLayout {
NC.EmojiModel {
@ -54,7 +55,7 @@ ColumnLayout {
radius: Style.slightlyRoundedButtonRadius
}
contentItem: Label {
contentItem: EnforcedPlainTextLabel {
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
text: emoji
@ -113,7 +114,7 @@ ColumnLayout {
radius: Style.slightlyRoundedButtonRadius
}
contentItem: Label {
contentItem: EnforcedPlainTextLabel {
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
text: modelData === undefined ? "" : modelData.unicode
@ -126,7 +127,7 @@ ColumnLayout {
}
}
Label {
EnforcedPlainTextLabel {
id: placeholderMessage
width: parent.width * 0.8
anchors.centerIn: parent

View File

@ -2,6 +2,7 @@ import QtQuick 2.15
import QtQuick.Controls 2.15
import Style 1.0
import "./tray"
Item {
id: errorBox
@ -20,7 +21,7 @@ Item {
border.color: errorBox.borderColor
}
Label {
EnforcedPlainTextLabel {
id: errorMessage
anchors.fill: parent

View File

@ -18,6 +18,7 @@ import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15
import Style 1.0
import "./tray"
AbstractButton {
id: root
@ -42,7 +43,7 @@ AbstractButton {
contentItem: Row {
spacing: root.internalSpacing
Label {
EnforcedPlainTextLabel {
width: root.emojiWidth > 0 ? root.emojiWidth : implicitWidth
text: emoji
textFormat: Text.PlainText
@ -52,7 +53,7 @@ AbstractButton {
Row {
spacing: Style.smallSpacing
Label {
EnforcedPlainTextLabel {
text: root.statusText
textFormat: Text.PlainText
color: Style.ncTextColor
@ -60,13 +61,13 @@ AbstractButton {
font.bold: true
}
Label {
EnforcedPlainTextLabel {
text: "-"
color: Style.ncTextColor
verticalAlignment: Text.AlignVCenter
}
Label {
EnforcedPlainTextLabel {
text: root.clearAtText
textFormat: Text.PlainText
color: Style.ncTextColor

View File

@ -20,6 +20,7 @@ import QtQuick.Window 2.15
import com.nextcloud.desktopclient 1.0 as NC
import Style 1.0
import "./tray"
ColumnLayout {
id: rootLayout
@ -32,7 +33,7 @@ ColumnLayout {
Layout.fillWidth: true
spacing: Style.smallSpacing
Label {
EnforcedPlainTextLabel {
Layout.fillWidth: true
Layout.bottomMargin: Style.smallSpacing
horizontalAlignment: Text.AlignHCenter
@ -117,7 +118,7 @@ ColumnLayout {
Layout.fillHeight: true
spacing: Style.smallSpacing
Label {
EnforcedPlainTextLabel {
Layout.fillWidth: true
Layout.bottomMargin: Style.smallSpacing
horizontalAlignment: Text.AlignHCenter
@ -273,7 +274,7 @@ ColumnLayout {
Layout.fillWidth: true
spacing: Style.smallSpacing
Label {
EnforcedPlainTextLabel {
id: clearComboLabel
Layout.fillWidth: true

View File

@ -19,6 +19,8 @@ import QtQuick.Controls 2.15
import Style 1.0
import "./tray"
AbstractButton {
id: root
@ -59,7 +61,7 @@ AbstractButton {
visible: root.icon.source !== ""
}
Label {
EnforcedPlainTextLabel {
Layout.column: root.icon.source === "" ? 0 : 1
Layout.columnSpan: root.icon.source === "" ? 2 : 1
Layout.row: 0
@ -75,7 +77,7 @@ AbstractButton {
font.bold: root.primary
}
Label {
EnforcedPlainTextLabel {
Layout.column: root.icon.source === "" ? 0 : 1
Layout.columnSpan: root.icon.source === "" ? 2 : 1
Layout.row: 1

View File

@ -120,7 +120,7 @@ RowLayout {
spacing: Style.activityContentSpace
Label {
EnforcedPlainTextLabel {
id: activityTextTitle
text: (root.activityData.type === "Activity" || root.activityData.type === "Notification") ? root.activityData.subject : root.activityData.message
height: (text === "") ? 0 : implicitHeight
@ -134,7 +134,7 @@ RowLayout {
visible: text !== ""
}
Label {
EnforcedPlainTextLabel {
id: activityTextInfo
text: (root.activityData.type === "Sync") ? root.activityData.displayPath
: (root.activityData.type === "File") ? root.activityData.subject
@ -151,7 +151,7 @@ RowLayout {
visible: text !== ""
}
Label {
EnforcedPlainTextLabel {
id: activityTextDateTime
text: root.activityData.dateTime
height: (text === "") ? 0 : implicitHeight
@ -165,7 +165,7 @@ RowLayout {
visible: text !== ""
}
Label {
EnforcedPlainTextLabel {
id: talkReplyMessageSent
text: root.activityData.messageSent
height: (text === "") ? 0 : implicitHeight

View File

@ -192,7 +192,7 @@ Window {
}
}
Label {
EnforcedPlainTextLabel {
id: message
text: root.subject
textFormat: Text.PlainText

View File

@ -51,12 +51,11 @@ Button {
fillMode: Image.PreserveAspectFit
}
Label {
EnforcedPlainTextLabel {
Layout.maximumWidth: icon.width > 0 ? parent.width - icon.width - parent.spacing : parent.width
Layout.fillWidth: icon.status !== Image.Ready
text: root.text
textFormat: Text.PlainText
font.bold: root.bold
visible: root.text !== ""

View File

@ -2,7 +2,7 @@ import QtQuick 2.15
import QtQuick.Controls 2.3
import Style 1.0
Label {
EnforcedPlainTextLabel {
id: root
property string toolTipText: ""
@ -20,7 +20,6 @@ Label {
Accessible.onPressAction: root.clicked(null)
text: action ? action.text : ""
textFormat: Text.PlainText
enabled: !action || action.enabled
onClicked: if (action) action.trigger()

View File

@ -55,7 +55,7 @@ Window {
color: Style.ncTextColor
running: true
}
Label {
EnforcedPlainTextLabel {
id: labelFileName
Layout.alignment: Qt.AlignHCenter
Layout.fillWidth: true
@ -67,7 +67,7 @@ Window {
horizontalAlignment: Text.AlignHCenter
visible: root.fileName !== ""
}
Label {
EnforcedPlainTextLabel {
id: labelMessage
Layout.alignment: Qt.AlignHCenter
Layout.fillWidth: true

View File

@ -0,0 +1,29 @@
/*
* Copyright (C) 2022 by Claudio Cambra <claudio.cambra@nextcloud.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
import QtQuick 2.15
import QtQuick.Controls 2.15
Label {
function resetToPlainText() {
if (textFormat !== Text.PlainText) {
console.log("WARNING: this label was set to a non-plain text format. Resetting to plain text.")
textFormat = Text.PlainText;
}
}
textFormat: Text.PlainText
onTextFormatChanged: resetToPlainText()
Component.onCompleted: resetToPlainText()
}

View File

@ -22,7 +22,7 @@ ToolTip {
id: toolTip
clip: true
delay: Qt.styleHints.mousePressAndHoldInterval
contentItem: Label {
contentItem: EnforcedPlainTextLabel {
text: toolTip.text
textFormat: Text.PlainText
color: Style.ncTextColor

View File

@ -47,7 +47,7 @@ RowLayout {
Layout.fillWidth: true
Layout.fillHeight: true
Text {
EnforcedPlainTextLabel {
id: syncProgressText
Layout.fillWidth: true
@ -87,7 +87,7 @@ RowLayout {
}
}
Text {
EnforcedPlainTextLabel {
id: syncProgressDetailText
Layout.fillWidth: true

View File

@ -18,7 +18,7 @@ ColumnLayout {
Accessible.name: unifiedSearchResultItemFetchMoreText.text
Accessible.onPressAction: unifiedSearchResultMouseArea.clicked()
Label {
EnforcedPlainTextLabel {
id: unifiedSearchResultItemFetchMoreText
Layout.fillWidth: true

View File

@ -86,7 +86,7 @@ RowLayout {
Layout.rightMargin: Style.trayHorizontalMargin
spacing: Style.standardSpacing
Label {
EnforcedPlainTextLabel {
id: unifiedSearchResultTitleText
Layout.fillWidth: true
text: unifiedSearchResultItemDetails.title.replace(/[\r\n]+/g, " ")
@ -94,7 +94,7 @@ RowLayout {
font.pixelSize: unifiedSearchResultItemDetails.titleFontSize
color: unifiedSearchResultItemDetails.titleColor
}
Label {
EnforcedPlainTextLabel {
id: unifiedSearchResultTextSubline
Layout.fillWidth: true
text: unifiedSearchResultItemDetails.subline.replace(/[\r\n]+/g, " ")

View File

@ -21,7 +21,7 @@ ColumnLayout {
Layout.alignment: Qt.AlignHCenter
}
Label {
EnforcedPlainTextLabel {
id: unifiedSearchResultsNoResultsLabel
text: qsTr("No results for")
color: Style.menuBorder
@ -32,7 +32,7 @@ ColumnLayout {
horizontalAlignment: Text.AlignHCenter
}
Label {
EnforcedPlainTextLabel {
id: unifiedSearchResultsNoResultsLabelDetails
text: unifiedSearchResultNothingFoundContainer.text
color: Style.ncTextColor

View File

@ -5,7 +5,7 @@ import QtQuick.Layouts 1.2
import Style 1.0
import com.nextcloud.desktopclient 1.0
Label {
EnforcedPlainTextLabel {
required property string section
topPadding: Style.unifiedSearchResultSectionItemVerticalPadding

View File

@ -71,7 +71,7 @@ AbstractButton {
Layout.fillWidth: true
Layout.fillHeight: true
Label {
EnforcedPlainTextLabel {
id: accountUser
Layout.fillWidth: true
Layout.alignment: Qt.AlignLeft | Qt.AlignBottom
@ -91,14 +91,14 @@ AbstractButton {
model.serverHasUserStatus &&
(model.statusEmoji !== "" || model.statusMessage !== "")
Label {
EnforcedPlainTextLabel {
id: emoji
visible: model.statusEmoji !== ""
text: statusEmoji
topPadding: -Style.accountLabelsSpacing
}
Label {
EnforcedPlainTextLabel {
id: message
Layout.fillWidth: true
visible: model.statusMessage !== ""
@ -110,7 +110,7 @@ AbstractButton {
}
}
Label {
EnforcedPlainTextLabel {
id: accountServer
Layout.fillWidth: true
Layout.alignment: Qt.AlignLeft | Qt.AlignTop

View File

@ -287,7 +287,7 @@ ApplicationWindow {
sourceSize.width: Style.headerButtonIconSize
sourceSize.height: Style.headerButtonIconSize
}
Label {
EnforcedPlainTextLabel {
Layout.leftMargin: 14
text: qsTr("Add account")
color: Style.ncTextColor
@ -456,7 +456,7 @@ ApplicationWindow {
Layout.fillWidth: true
Layout.maximumWidth: parent.width
Label {
EnforcedPlainTextLabel {
id: currentAccountUser
Layout.alignment: Qt.AlignLeft | Qt.AlignBottom
width: Style.currentAccountLabelWidth
@ -476,14 +476,14 @@ ApplicationWindow {
spacing: Style.accountLabelsSpacing
width: parent.width
Label {
EnforcedPlainTextLabel {
id: emoji
visible: UserModel.currentUser.statusEmoji !== ""
width: Style.userStatusEmojiSize
text: UserModel.currentUser.statusEmoji
textFormat: Text.PlainText
}
Label {
EnforcedPlainTextLabel {
id: message
Layout.alignment: Qt.AlignLeft | Qt.AlignBottom
Layout.fillWidth: true