Merge pull request #5233 from nextcloud/bugfix/enforce-plain-text-qml-labels

Make use of plain text-enforcing qml labels
This commit is contained in:
Claudio Cambra 2022-12-05 16:18:57 +01:00 committed by GitHub
commit 98e6ab2c64
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 116 additions and 80 deletions

24
.github/workflows/qml-label-check.yml vendored Normal file
View file

@ -0,0 +1,24 @@
name: QML Label component check
on:
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run label component count
run: |
MATCHESRESULT=$(find . -iname "*.qml" | xargs grep -r -e "^\s*Label\s*[{]" | wc -l | sed "s/ //g")
echo "MATCHES=${MATCHESRESULT}" >> $GITHUB_ENV
echo "EXPECTED_MATCHES=1" >> $GITHUB_ENV
- name: Check label component use count
if: env.MATCHES != env.EXPECTED_MATCHES
uses: actions/github-script@v3
with:
script: |
core.setFailed('Using QML Labels! Make sure to use EnforcedPlainTextLabel instead!')

View file

@ -46,6 +46,7 @@
<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>
<file>theme/Style/Style.qml</file>
<file>theme/Style/qmldir</file>
</qresource>

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,12 +32,11 @@ ComboBox {
opacity: clearComboBox.hovered ? Style.hoverOpacity : 1.0
}
contentItem: Label {
contentItem: EnforcedPlainTextLabel {
leftPadding: 0
rightPadding: clearComboBox.indicator.width + clearComboBox.spacing
text: clearComboBox.displayText
textFormat: Text.PlainText
color: Style.ncTextColor
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
@ -86,9 +86,8 @@ ComboBox {
delegate: ItemDelegate {
id: clearStatusDelegate
width: clearComboBox.width
contentItem: Label {
contentItem: EnforcedPlainTextLabel {
text: modelData.display
textFormat: Text.PlainText
color: Style.ncTextColor
elide: Text.ElideRight
verticalAlignment: Text.AlignVCenter

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

@ -3,6 +3,7 @@ import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15
import Style 1.0
import "./tray"
Item {
id: errorBox
@ -42,7 +43,7 @@ Item {
columns: 2
Label {
EnforcedPlainTextLabel {
Layout.fillWidth: true
color: Style.ncTextColor
font.bold: true
@ -64,7 +65,7 @@ Item {
onClicked: errorBox.closeButtonClicked()
}
Label {
EnforcedPlainTextLabel {
id: errorMessage
Layout.fillWidth: true
@ -74,7 +75,6 @@ Item {
color: Style.ncTextColor
wrapMode: Text.WordWrap
text: errorBox.text
textFormat: Text.PlainText
}
}
}

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,33 +43,30 @@ AbstractButton {
contentItem: Row {
spacing: root.internalSpacing
Label {
EnforcedPlainTextLabel {
width: root.emojiWidth > 0 ? root.emojiWidth : implicitWidth
text: emoji
textFormat: Text.PlainText
horizontalAlignment: Image.AlignHCenter
verticalAlignment: Image.AlignVCenter
}
Row {
spacing: Style.smallSpacing
Label {
EnforcedPlainTextLabel {
text: root.statusText
textFormat: Text.PlainText
color: Style.ncTextColor
verticalAlignment: Text.AlignVCenter
font.bold: true
}
Label {
EnforcedPlainTextLabel {
text: "-"
color: Style.ncTextColor
verticalAlignment: Text.AlignVCenter
}
Label {
EnforcedPlainTextLabel {
text: root.clearAtText
textFormat: Text.PlainText
color: Style.ncTextColor
verticalAlignment: Text.AlignVCenter
}

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
@ -69,13 +71,12 @@ AbstractButton {
verticalAlignment: Text.AlignVCenter
text: root.text
textFormat: Text.PlainText
wrapMode: Text.Wrap
color: root.colored ? Style.ncHeaderTextColor : Style.ncTextColor
font.bold: root.primary
}
Label {
EnforcedPlainTextLabel {
Layout.column: root.icon.source === "" ? 0 : 1
Layout.columnSpan: root.icon.source === "" ? 2 : 1
Layout.row: 1
@ -84,7 +85,6 @@ AbstractButton {
verticalAlignment: Text.AlignVCenter
text: root.secondaryText
textFormat: Text.PlainText
wrapMode: Text.Wrap
color: Style.ncSecondaryTextColor
visible: root.secondaryText !== ""

View file

@ -18,6 +18,7 @@ import QtQuick.Controls 2.15
import com.nextcloud.desktopclient 1.0
import Style 1.0
import "../tray"
Page {
id: root
@ -94,7 +95,7 @@ Page {
fillMode: Image.PreserveAspectFit
}
Label {
EnforcedPlainTextLabel {
id: fileNameLabel
Layout.fillWidth: true
@ -106,7 +107,7 @@ Page {
wrapMode: Text.Wrap
}
Label {
EnforcedPlainTextLabel {
id: fileDetailsLabel
Layout.fillWidth: true
@ -117,7 +118,7 @@ Page {
wrapMode: Text.Wrap
}
Label {
EnforcedPlainTextLabel {
id: fileLockedLabel
Layout.fillWidth: true

View file

@ -19,6 +19,7 @@ import QtQuick.Controls 2.15
import com.nextcloud.desktopclient 1.0
import Style 1.0
import "../tray"
TabButton {
id: tabButton
@ -57,7 +58,7 @@ TabButton {
}
}
Label {
EnforcedPlainTextLabel {
id: tabButtonLabel
Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter

View file

@ -208,7 +208,7 @@ GridLayout {
}
}
Label {
EnforcedPlainTextLabel {
id: shareTypeLabel
Layout.fillWidth: true
@ -222,7 +222,7 @@ GridLayout {
elide: Text.ElideRight
}
Label {
EnforcedPlainTextLabel {
id: linkDetailLabel
Layout.fillWidth: true

View file

@ -280,7 +280,7 @@ ColumnLayout {
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
Label {
EnforcedPlainTextLabel {
id: sharingDisabledLabel
width: parent.width
text: qsTr("Sharing is disabled")
@ -289,7 +289,7 @@ ColumnLayout {
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
Label {
EnforcedPlainTextLabel {
width: parent.width
text: qsTr("This item cannot be shared.")
color: Style.ncSecondaryTextColor
@ -298,7 +298,7 @@ ColumnLayout {
verticalAlignment: Text.AlignVCenter
visible: !root.shareModel.canShare
}
Label {
EnforcedPlainTextLabel {
width: parent.width
text: qsTr("Sharing is disabled.")
color: Style.ncSecondaryTextColor

View file

@ -40,7 +40,7 @@ AbstractButton {
text: root.toolTipText
delay: Qt.styleHints.mousePressAndHoldInterval
visible: root.toolTipText !== "" && root.hovered
contentItem: Label {
contentItem: EnforcedPlainTextLabel {
text: customTextButtonTooltip.text
color: Style.ncTextColor
}

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
@ -129,12 +129,11 @@ RowLayout {
wrapMode: Text.Wrap
maximumLineCount: 2
font.pixelSize: Style.topLinePixelSize
textFormat: Text.PlainText
color: Style.ncTextColor
visible: text !== ""
}
Label {
EnforcedPlainTextLabel {
id: activityTextInfo
text: (root.activityData.type === "Sync") ? root.activityData.displayPath
: (root.activityData.type === "File") ? root.activityData.subject
@ -146,12 +145,11 @@ RowLayout {
wrapMode: Text.Wrap
maximumLineCount: 2
font.pixelSize: Style.subLinePixelSize
textFormat: Text.PlainText
color: Style.ncTextColor
visible: text !== ""
}
Label {
EnforcedPlainTextLabel {
id: activityTextDateTime
text: root.activityData.dateTime
height: (text === "") ? 0 : implicitHeight
@ -160,12 +158,11 @@ RowLayout {
wrapMode: Text.Wrap
maximumLineCount: 2
font.pixelSize: Style.subLinePixelSize
textFormat: Text.PlainText
color: Style.ncSecondaryTextColor
visible: text !== ""
}
Label {
EnforcedPlainTextLabel {
id: talkReplyMessageSent
text: root.activityData.messageSent
height: (text === "") ? 0 : implicitHeight
@ -174,7 +171,6 @@ RowLayout {
wrapMode: Text.Wrap
maximumLineCount: 2
font.pixelSize: Style.topLinePixelSize
textFormat: Text.PlainText
color: Style.ncSecondaryTextColor
visible: text !== ""
}

View file

@ -107,7 +107,7 @@ ScrollView {
source: "image://svgimage-custom-color/activity.svg/" + Style.ncSecondaryTextColor
}
Label {
EnforcedPlainTextLabel {
width: parent.width
text: qsTr("No activities yet")
color: Style.ncSecondaryTextColor

View file

@ -192,10 +192,9 @@ Window {
}
}
Label {
EnforcedPlainTextLabel {
id: message
text: root.subject
textFormat: Text.PlainText
color: root.usingUserAvatar ? "white" : Style.ncTextColor
font.pixelSize: Style.topLinePixelSize
wrapMode: Text.WordWrap

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

@ -42,13 +42,12 @@ RowLayout {
visible: root.hovered ? root.imageSourceHover !== "" : root.imageSource !== ""
}
Label {
EnforcedPlainTextLabel {
id: buttonLabel
Layout.fillWidth: true
text: root.text
textFormat: Text.PlainText
visible: root.text !== ""

View file

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

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,13 +18,12 @@ import QtQuick.Layouts 1.15
import Style 1.0
Label {
EnforcedPlainTextLabel {
property bool hovered: false
property color textColor: Style.ncTextColor
property color textColorHovered: Style.ncSecondaryTextColor
property bool bold: false
textFormat: Text.PlainText
font.underline: true
font.bold: bold
color: hovered ? textColorHovered : textColor

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,20 +86,18 @@ RowLayout {
Layout.rightMargin: Style.trayHorizontalMargin
spacing: Style.standardSpacing
Label {
EnforcedPlainTextLabel {
id: unifiedSearchResultTitleText
Layout.fillWidth: true
text: unifiedSearchResultItemDetails.title.replace(/[\r\n]+/g, " ")
textFormat: Text.PlainText
elide: Text.ElideRight
font.pixelSize: unifiedSearchResultItemDetails.titleFontSize
color: unifiedSearchResultItemDetails.titleColor
}
Label {
EnforcedPlainTextLabel {
id: unifiedSearchResultTextSubline
Layout.fillWidth: true
text: unifiedSearchResultItemDetails.subline.replace(/[\r\n]+/g, " ")
textFormat: Text.PlainText
elide: Text.ElideRight
font.pixelSize: unifiedSearchResultItemDetails.sublineFontSize
color: unifiedSearchResultItemDetails.sublineColor

View file

@ -21,7 +21,7 @@ ColumnLayout {
Layout.alignment: Qt.AlignHCenter
}
Label {
EnforcedPlainTextLabel {
id: unifiedSearchResultsNoResultsLabel
text: qsTr("No results for")
color: Style.menuBorder
@ -32,10 +32,9 @@ ColumnLayout {
horizontalAlignment: Text.AlignHCenter
}
Label {
EnforcedPlainTextLabel {
id: unifiedSearchResultsNoResultsLabelDetails
text: unifiedSearchResultNothingFoundContainer.text
textFormat: Text.PlainText
color: Style.ncTextColor
font.pixelSize: Style.topLinePixelSize * 1.25
wrapMode: Text.Wrap

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
@ -13,7 +13,6 @@ Label {
leftPadding: Style.unifiedSearchResultSectionItemLeftPadding
text: section
textFormat: Text.PlainText
font.pixelSize: Style.unifiedSearchResultTitleFontSize
color: UserModel.currentUser.accentColor

View file

@ -71,13 +71,12 @@ AbstractButton {
Layout.fillWidth: true
Layout.fillHeight: true
Label {
EnforcedPlainTextLabel {
id: accountUser
Layout.fillWidth: true
Layout.alignment: Qt.AlignLeft | Qt.AlignBottom
verticalAlignment: Text.AlignBottom
text: name
textFormat: Text.PlainText
elide: Text.ElideRight
color: Style.ncTextColor
font.pixelSize: Style.topLinePixelSize
@ -92,20 +91,18 @@ AbstractButton {
model.serverHasUserStatus &&
(model.statusEmoji !== "" || model.statusMessage !== "")
Label {
EnforcedPlainTextLabel {
id: emoji
visible: model.statusEmoji !== ""
text: statusEmoji
textFormat: Text.PlainText
topPadding: -Style.accountLabelsSpacing
}
Label {
EnforcedPlainTextLabel {
id: message
Layout.fillWidth: true
visible: model.statusMessage !== ""
text: statusMessage
textFormat: Text.PlainText
elide: Text.ElideRight
color: Style.ncTextColor
font.pixelSize: Style.subLinePixelSize
@ -113,13 +110,12 @@ AbstractButton {
}
}
Label {
EnforcedPlainTextLabel {
id: accountServer
Layout.fillWidth: true
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
verticalAlignment: Text.AlignTop
text: server
textFormat: Text.PlainText
elide: Text.ElideRight
color: Style.ncTextColor
font.pixelSize: Style.subLinePixelSize

View file

@ -277,7 +277,7 @@ ApplicationWindow {
sourceSize.width: Style.headerButtonIconSize
sourceSize.height: Style.headerButtonIconSize
}
Label {
EnforcedPlainTextLabel {
Layout.leftMargin: 14
text: qsTr("Add account")
color: Style.ncTextColor
@ -446,12 +446,11 @@ ApplicationWindow {
Layout.fillWidth: true
Layout.maximumWidth: parent.width
Label {
EnforcedPlainTextLabel {
id: currentAccountUser
Layout.alignment: Qt.AlignLeft | Qt.AlignBottom
width: Style.currentAccountLabelWidth
text: UserModel.currentUser.name
textFormat: Text.PlainText
elide: Text.ElideRight
color: Style.currentUserHeaderTextColor
@ -466,14 +465,13 @@ 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
@ -482,7 +480,6 @@ ApplicationWindow {
text: UserModel.currentUser.statusMessage !== ""
? UserModel.currentUser.statusMessage
: UserModel.currentUser.server
textFormat: Text.PlainText
elide: Text.ElideRight
color: Style.currentUserHeaderTextColor
font.pixelSize: Style.subLinePixelSize