From 6c4070e786765aefb48db5b75172b99438919074 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Fri, 2 Dec 2022 14:51:09 +0100 Subject: [PATCH 1/4] Introduce EnforcedPlainTextLabel, convert all Label or Text labels to use this Signed-off-by: Claudio Cambra --- resources.qrc | 1 + src/gui/BasicComboBox.qml | 5 ++-- src/gui/EmojiPicker.qml | 7 +++-- src/gui/ErrorBox.qml | 5 ++-- src/gui/PredefinedStatusButton.qml | 9 +++--- src/gui/UserStatusSelector.qml | 7 +++-- src/gui/UserStatusSelectorButton.qml | 6 ++-- src/gui/filedetails/FileDetailsPage.qml | 7 +++-- src/gui/filedetails/NCTabButton.qml | 3 +- src/gui/filedetails/ShareDelegate.qml | 4 +-- src/gui/filedetails/ShareView.qml | 6 ++-- src/gui/tray/ActivityActionButton.qml | 2 +- src/gui/tray/ActivityItemContent.qml | 8 ++--- src/gui/tray/ActivityList.qml | 2 +- src/gui/tray/CallNotificationDialog.qml | 2 +- src/gui/tray/EditFileLocallyLoadingDialog.qml | 4 +-- src/gui/tray/EnforcedPlainTextLabel.qml | 29 +++++++++++++++++++ src/gui/tray/NCButtonContents.qml | 2 +- src/gui/tray/NCToolTip.qml | 2 +- src/gui/tray/SyncStatus.qml | 4 +-- src/gui/tray/TextButtonContents.qml | 2 +- .../UnifiedSearchResultFetchMoreTrigger.qml | 2 +- src/gui/tray/UnifiedSearchResultItem.qml | 4 +-- .../tray/UnifiedSearchResultNothingFound.qml | 4 +-- .../tray/UnifiedSearchResultSectionItem.qml | 2 +- src/gui/tray/UserLine.qml | 8 ++--- src/gui/tray/Window.qml | 8 ++--- 27 files changed, 92 insertions(+), 53 deletions(-) create mode 100644 src/gui/tray/EnforcedPlainTextLabel.qml diff --git a/resources.qrc b/resources.qrc index 3132330e2..2c6f6a299 100644 --- a/resources.qrc +++ b/resources.qrc @@ -46,6 +46,7 @@ src/gui/tray/EditFileLocallyLoadingDialog.qml src/gui/tray/NCBusyIndicator.qml src/gui/tray/NCToolTip.qml + src/gui/tray/EnforcedPlainTextLabel.qml theme/Style/Style.qml theme/Style/qmldir diff --git a/src/gui/BasicComboBox.qml b/src/gui/BasicComboBox.qml index 8917260d3..03a7ed8ad 100644 --- a/src/gui/BasicComboBox.qml +++ b/src/gui/BasicComboBox.qml @@ -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 diff --git a/src/gui/EmojiPicker.qml b/src/gui/EmojiPicker.qml index 5bff1924e..bcc853fd5 100644 --- a/src/gui/EmojiPicker.qml +++ b/src/gui/EmojiPicker.qml @@ -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 diff --git a/src/gui/ErrorBox.qml b/src/gui/ErrorBox.qml index 44bbc2983..26ff0d4bc 100644 --- a/src/gui/ErrorBox.qml +++ b/src/gui/ErrorBox.qml @@ -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 diff --git a/src/gui/PredefinedStatusButton.qml b/src/gui/PredefinedStatusButton.qml index 416f7e752..27fc634f0 100644 --- a/src/gui/PredefinedStatusButton.qml +++ b/src/gui/PredefinedStatusButton.qml @@ -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 diff --git a/src/gui/UserStatusSelector.qml b/src/gui/UserStatusSelector.qml index 489814956..51d80718c 100644 --- a/src/gui/UserStatusSelector.qml +++ b/src/gui/UserStatusSelector.qml @@ -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 diff --git a/src/gui/UserStatusSelectorButton.qml b/src/gui/UserStatusSelectorButton.qml index 91310839d..286c89e58 100644 --- a/src/gui/UserStatusSelectorButton.qml +++ b/src/gui/UserStatusSelectorButton.qml @@ -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 diff --git a/src/gui/filedetails/FileDetailsPage.qml b/src/gui/filedetails/FileDetailsPage.qml index fc39825a3..aa3f4f488 100644 --- a/src/gui/filedetails/FileDetailsPage.qml +++ b/src/gui/filedetails/FileDetailsPage.qml @@ -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 diff --git a/src/gui/filedetails/NCTabButton.qml b/src/gui/filedetails/NCTabButton.qml index cd863cea8..569569e63 100644 --- a/src/gui/filedetails/NCTabButton.qml +++ b/src/gui/filedetails/NCTabButton.qml @@ -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 diff --git a/src/gui/filedetails/ShareDelegate.qml b/src/gui/filedetails/ShareDelegate.qml index 613f40228..885b78c6c 100644 --- a/src/gui/filedetails/ShareDelegate.qml +++ b/src/gui/filedetails/ShareDelegate.qml @@ -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 diff --git a/src/gui/filedetails/ShareView.qml b/src/gui/filedetails/ShareView.qml index 73e1636f3..ebb04d21c 100644 --- a/src/gui/filedetails/ShareView.qml +++ b/src/gui/filedetails/ShareView.qml @@ -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 diff --git a/src/gui/tray/ActivityActionButton.qml b/src/gui/tray/ActivityActionButton.qml index 6693153b7..250da5ab9 100644 --- a/src/gui/tray/ActivityActionButton.qml +++ b/src/gui/tray/ActivityActionButton.qml @@ -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 } diff --git a/src/gui/tray/ActivityItemContent.qml b/src/gui/tray/ActivityItemContent.qml index 80bc931fc..c817be54b 100644 --- a/src/gui/tray/ActivityItemContent.qml +++ b/src/gui/tray/ActivityItemContent.qml @@ -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 diff --git a/src/gui/tray/ActivityList.qml b/src/gui/tray/ActivityList.qml index 97c4a5f5d..995d225b2 100644 --- a/src/gui/tray/ActivityList.qml +++ b/src/gui/tray/ActivityList.qml @@ -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 diff --git a/src/gui/tray/CallNotificationDialog.qml b/src/gui/tray/CallNotificationDialog.qml index d53daf7bc..6f54712c8 100644 --- a/src/gui/tray/CallNotificationDialog.qml +++ b/src/gui/tray/CallNotificationDialog.qml @@ -192,7 +192,7 @@ Window { } } - Label { + EnforcedPlainTextLabel { id: message text: root.subject textFormat: Text.PlainText diff --git a/src/gui/tray/EditFileLocallyLoadingDialog.qml b/src/gui/tray/EditFileLocallyLoadingDialog.qml index 12e8f757b..d0a50614a 100644 --- a/src/gui/tray/EditFileLocallyLoadingDialog.qml +++ b/src/gui/tray/EditFileLocallyLoadingDialog.qml @@ -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 diff --git a/src/gui/tray/EnforcedPlainTextLabel.qml b/src/gui/tray/EnforcedPlainTextLabel.qml new file mode 100644 index 000000000..f47692c2c --- /dev/null +++ b/src/gui/tray/EnforcedPlainTextLabel.qml @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2022 by Claudio Cambra + * + * 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() +} diff --git a/src/gui/tray/NCButtonContents.qml b/src/gui/tray/NCButtonContents.qml index 2ca45fd19..5144d58b3 100644 --- a/src/gui/tray/NCButtonContents.qml +++ b/src/gui/tray/NCButtonContents.qml @@ -42,7 +42,7 @@ RowLayout { visible: root.hovered ? root.imageSourceHover !== "" : root.imageSource !== "" } - Label { + EnforcedPlainTextLabel { id: buttonLabel Layout.fillWidth: true diff --git a/src/gui/tray/NCToolTip.qml b/src/gui/tray/NCToolTip.qml index 2c1b85312..af43d5727 100644 --- a/src/gui/tray/NCToolTip.qml +++ b/src/gui/tray/NCToolTip.qml @@ -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 diff --git a/src/gui/tray/SyncStatus.qml b/src/gui/tray/SyncStatus.qml index 55da5589b..b0828f195 100644 --- a/src/gui/tray/SyncStatus.qml +++ b/src/gui/tray/SyncStatus.qml @@ -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 diff --git a/src/gui/tray/TextButtonContents.qml b/src/gui/tray/TextButtonContents.qml index 8699faa35..15b77b272 100644 --- a/src/gui/tray/TextButtonContents.qml +++ b/src/gui/tray/TextButtonContents.qml @@ -18,7 +18,7 @@ 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 diff --git a/src/gui/tray/UnifiedSearchResultFetchMoreTrigger.qml b/src/gui/tray/UnifiedSearchResultFetchMoreTrigger.qml index 65600e33d..51b88718b 100644 --- a/src/gui/tray/UnifiedSearchResultFetchMoreTrigger.qml +++ b/src/gui/tray/UnifiedSearchResultFetchMoreTrigger.qml @@ -18,7 +18,7 @@ ColumnLayout { Accessible.name: unifiedSearchResultItemFetchMoreText.text Accessible.onPressAction: unifiedSearchResultMouseArea.clicked() - Label { + EnforcedPlainTextLabel { id: unifiedSearchResultItemFetchMoreText Layout.fillWidth: true diff --git a/src/gui/tray/UnifiedSearchResultItem.qml b/src/gui/tray/UnifiedSearchResultItem.qml index 87cd4eace..3876a1c8b 100644 --- a/src/gui/tray/UnifiedSearchResultItem.qml +++ b/src/gui/tray/UnifiedSearchResultItem.qml @@ -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, " ") @@ -95,7 +95,7 @@ RowLayout { font.pixelSize: unifiedSearchResultItemDetails.titleFontSize color: unifiedSearchResultItemDetails.titleColor } - Label { + EnforcedPlainTextLabel { id: unifiedSearchResultTextSubline Layout.fillWidth: true text: unifiedSearchResultItemDetails.subline.replace(/[\r\n]+/g, " ") diff --git a/src/gui/tray/UnifiedSearchResultNothingFound.qml b/src/gui/tray/UnifiedSearchResultNothingFound.qml index 35166e81e..d73e8d352 100644 --- a/src/gui/tray/UnifiedSearchResultNothingFound.qml +++ b/src/gui/tray/UnifiedSearchResultNothingFound.qml @@ -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 textFormat: Text.PlainText diff --git a/src/gui/tray/UnifiedSearchResultSectionItem.qml b/src/gui/tray/UnifiedSearchResultSectionItem.qml index e310effa1..4e7da57d6 100644 --- a/src/gui/tray/UnifiedSearchResultSectionItem.qml +++ b/src/gui/tray/UnifiedSearchResultSectionItem.qml @@ -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 diff --git a/src/gui/tray/UserLine.qml b/src/gui/tray/UserLine.qml index 4127faf84..9c290d36f 100644 --- a/src/gui/tray/UserLine.qml +++ b/src/gui/tray/UserLine.qml @@ -71,7 +71,7 @@ AbstractButton { Layout.fillWidth: true Layout.fillHeight: true - Label { + EnforcedPlainTextLabel { id: accountUser Layout.fillWidth: true Layout.alignment: Qt.AlignLeft | Qt.AlignBottom @@ -92,7 +92,7 @@ AbstractButton { model.serverHasUserStatus && (model.statusEmoji !== "" || model.statusMessage !== "") - Label { + EnforcedPlainTextLabel { id: emoji visible: model.statusEmoji !== "" text: statusEmoji @@ -100,7 +100,7 @@ AbstractButton { topPadding: -Style.accountLabelsSpacing } - Label { + EnforcedPlainTextLabel { id: message Layout.fillWidth: true visible: model.statusMessage !== "" @@ -113,7 +113,7 @@ AbstractButton { } } - Label { + EnforcedPlainTextLabel { id: accountServer Layout.fillWidth: true Layout.alignment: Qt.AlignLeft | Qt.AlignTop diff --git a/src/gui/tray/Window.qml b/src/gui/tray/Window.qml index 16d4fe012..885180e45 100644 --- a/src/gui/tray/Window.qml +++ b/src/gui/tray/Window.qml @@ -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,7 +446,7 @@ ApplicationWindow { Layout.fillWidth: true Layout.maximumWidth: parent.width - Label { + EnforcedPlainTextLabel { id: currentAccountUser Layout.alignment: Qt.AlignLeft | Qt.AlignBottom width: Style.currentAccountLabelWidth @@ -466,14 +466,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 From 2ec1da22edd5891011950da6a8b4732abb6b4d89 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Fri, 2 Dec 2022 14:58:12 +0100 Subject: [PATCH 2/4] Remove now redundant use of textFormat Signed-off-by: Claudio Cambra --- src/gui/BasicComboBox.qml | 2 -- src/gui/ErrorBox.qml | 1 - src/gui/PredefinedStatusButton.qml | 3 --- src/gui/UserStatusSelectorButton.qml | 2 -- src/gui/tray/ActivityItemContent.qml | 4 ---- src/gui/tray/CallNotificationDialog.qml | 1 - src/gui/tray/NCButtonContents.qml | 1 - src/gui/tray/NCToolTip.qml | 1 - src/gui/tray/TextButtonContents.qml | 1 - src/gui/tray/UnifiedSearchResultItem.qml | 2 -- src/gui/tray/UnifiedSearchResultNothingFound.qml | 1 - src/gui/tray/UnifiedSearchResultSectionItem.qml | 1 - src/gui/tray/UserLine.qml | 4 ---- src/gui/tray/Window.qml | 3 --- 14 files changed, 27 deletions(-) diff --git a/src/gui/BasicComboBox.qml b/src/gui/BasicComboBox.qml index 03a7ed8ad..b844ad1f7 100644 --- a/src/gui/BasicComboBox.qml +++ b/src/gui/BasicComboBox.qml @@ -37,7 +37,6 @@ ComboBox { rightPadding: clearComboBox.indicator.width + clearComboBox.spacing text: clearComboBox.displayText - textFormat: Text.PlainText color: Style.ncTextColor verticalAlignment: Text.AlignVCenter elide: Text.ElideRight @@ -89,7 +88,6 @@ ComboBox { width: clearComboBox.width contentItem: EnforcedPlainTextLabel { text: modelData.display - textFormat: Text.PlainText color: Style.ncTextColor elide: Text.ElideRight verticalAlignment: Text.AlignVCenter diff --git a/src/gui/ErrorBox.qml b/src/gui/ErrorBox.qml index 26ff0d4bc..2a84c130e 100644 --- a/src/gui/ErrorBox.qml +++ b/src/gui/ErrorBox.qml @@ -75,7 +75,6 @@ Item { color: Style.ncTextColor wrapMode: Text.WordWrap text: errorBox.text - textFormat: Text.PlainText } } } diff --git a/src/gui/PredefinedStatusButton.qml b/src/gui/PredefinedStatusButton.qml index 27fc634f0..dcd52df37 100644 --- a/src/gui/PredefinedStatusButton.qml +++ b/src/gui/PredefinedStatusButton.qml @@ -46,7 +46,6 @@ AbstractButton { EnforcedPlainTextLabel { width: root.emojiWidth > 0 ? root.emojiWidth : implicitWidth text: emoji - textFormat: Text.PlainText horizontalAlignment: Image.AlignHCenter verticalAlignment: Image.AlignVCenter } @@ -55,7 +54,6 @@ AbstractButton { spacing: Style.smallSpacing EnforcedPlainTextLabel { text: root.statusText - textFormat: Text.PlainText color: Style.ncTextColor verticalAlignment: Text.AlignVCenter font.bold: true @@ -69,7 +67,6 @@ AbstractButton { EnforcedPlainTextLabel { text: root.clearAtText - textFormat: Text.PlainText color: Style.ncTextColor verticalAlignment: Text.AlignVCenter } diff --git a/src/gui/UserStatusSelectorButton.qml b/src/gui/UserStatusSelectorButton.qml index 286c89e58..717774b97 100644 --- a/src/gui/UserStatusSelectorButton.qml +++ b/src/gui/UserStatusSelectorButton.qml @@ -71,7 +71,6 @@ AbstractButton { verticalAlignment: Text.AlignVCenter text: root.text - textFormat: Text.PlainText wrapMode: Text.Wrap color: root.colored ? Style.ncHeaderTextColor : Style.ncTextColor font.bold: root.primary @@ -86,7 +85,6 @@ AbstractButton { verticalAlignment: Text.AlignVCenter text: root.secondaryText - textFormat: Text.PlainText wrapMode: Text.Wrap color: Style.ncSecondaryTextColor visible: root.secondaryText !== "" diff --git a/src/gui/tray/ActivityItemContent.qml b/src/gui/tray/ActivityItemContent.qml index c817be54b..6a049ca9d 100644 --- a/src/gui/tray/ActivityItemContent.qml +++ b/src/gui/tray/ActivityItemContent.qml @@ -129,7 +129,6 @@ RowLayout { wrapMode: Text.Wrap maximumLineCount: 2 font.pixelSize: Style.topLinePixelSize - textFormat: Text.PlainText color: Style.ncTextColor visible: text !== "" } @@ -146,7 +145,6 @@ RowLayout { wrapMode: Text.Wrap maximumLineCount: 2 font.pixelSize: Style.subLinePixelSize - textFormat: Text.PlainText color: Style.ncTextColor visible: text !== "" } @@ -160,7 +158,6 @@ RowLayout { wrapMode: Text.Wrap maximumLineCount: 2 font.pixelSize: Style.subLinePixelSize - textFormat: Text.PlainText color: Style.ncSecondaryTextColor visible: text !== "" } @@ -174,7 +171,6 @@ RowLayout { wrapMode: Text.Wrap maximumLineCount: 2 font.pixelSize: Style.topLinePixelSize - textFormat: Text.PlainText color: Style.ncSecondaryTextColor visible: text !== "" } diff --git a/src/gui/tray/CallNotificationDialog.qml b/src/gui/tray/CallNotificationDialog.qml index 6f54712c8..e9402c11c 100644 --- a/src/gui/tray/CallNotificationDialog.qml +++ b/src/gui/tray/CallNotificationDialog.qml @@ -195,7 +195,6 @@ Window { EnforcedPlainTextLabel { id: message text: root.subject - textFormat: Text.PlainText color: root.usingUserAvatar ? "white" : Style.ncTextColor font.pixelSize: Style.topLinePixelSize wrapMode: Text.WordWrap diff --git a/src/gui/tray/NCButtonContents.qml b/src/gui/tray/NCButtonContents.qml index 5144d58b3..c9148a17e 100644 --- a/src/gui/tray/NCButtonContents.qml +++ b/src/gui/tray/NCButtonContents.qml @@ -48,7 +48,6 @@ RowLayout { Layout.fillWidth: true text: root.text - textFormat: Text.PlainText visible: root.text !== "" diff --git a/src/gui/tray/NCToolTip.qml b/src/gui/tray/NCToolTip.qml index af43d5727..efe514196 100644 --- a/src/gui/tray/NCToolTip.qml +++ b/src/gui/tray/NCToolTip.qml @@ -24,7 +24,6 @@ ToolTip { delay: Qt.styleHints.mousePressAndHoldInterval contentItem: EnforcedPlainTextLabel { text: toolTip.text - textFormat: Text.PlainText color: Style.ncTextColor wrapMode: Text.Wrap } diff --git a/src/gui/tray/TextButtonContents.qml b/src/gui/tray/TextButtonContents.qml index 15b77b272..031da73c0 100644 --- a/src/gui/tray/TextButtonContents.qml +++ b/src/gui/tray/TextButtonContents.qml @@ -24,7 +24,6 @@ EnforcedPlainTextLabel { property color textColorHovered: Style.ncSecondaryTextColor property bool bold: false - textFormat: Text.PlainText font.underline: true font.bold: bold color: hovered ? textColorHovered : textColor diff --git a/src/gui/tray/UnifiedSearchResultItem.qml b/src/gui/tray/UnifiedSearchResultItem.qml index 3876a1c8b..8909a372d 100644 --- a/src/gui/tray/UnifiedSearchResultItem.qml +++ b/src/gui/tray/UnifiedSearchResultItem.qml @@ -90,7 +90,6 @@ RowLayout { 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 @@ -99,7 +98,6 @@ RowLayout { 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 diff --git a/src/gui/tray/UnifiedSearchResultNothingFound.qml b/src/gui/tray/UnifiedSearchResultNothingFound.qml index d73e8d352..5ceb1e5e7 100644 --- a/src/gui/tray/UnifiedSearchResultNothingFound.qml +++ b/src/gui/tray/UnifiedSearchResultNothingFound.qml @@ -35,7 +35,6 @@ ColumnLayout { EnforcedPlainTextLabel { id: unifiedSearchResultsNoResultsLabelDetails text: unifiedSearchResultNothingFoundContainer.text - textFormat: Text.PlainText color: Style.ncTextColor font.pixelSize: Style.topLinePixelSize * 1.25 wrapMode: Text.Wrap diff --git a/src/gui/tray/UnifiedSearchResultSectionItem.qml b/src/gui/tray/UnifiedSearchResultSectionItem.qml index 4e7da57d6..27ad780ed 100644 --- a/src/gui/tray/UnifiedSearchResultSectionItem.qml +++ b/src/gui/tray/UnifiedSearchResultSectionItem.qml @@ -13,7 +13,6 @@ EnforcedPlainTextLabel { leftPadding: Style.unifiedSearchResultSectionItemLeftPadding text: section - textFormat: Text.PlainText font.pixelSize: Style.unifiedSearchResultTitleFontSize color: UserModel.currentUser.accentColor diff --git a/src/gui/tray/UserLine.qml b/src/gui/tray/UserLine.qml index 9c290d36f..1292ea4a4 100644 --- a/src/gui/tray/UserLine.qml +++ b/src/gui/tray/UserLine.qml @@ -77,7 +77,6 @@ AbstractButton { Layout.alignment: Qt.AlignLeft | Qt.AlignBottom verticalAlignment: Text.AlignBottom text: name - textFormat: Text.PlainText elide: Text.ElideRight color: Style.ncTextColor font.pixelSize: Style.topLinePixelSize @@ -96,7 +95,6 @@ AbstractButton { id: emoji visible: model.statusEmoji !== "" text: statusEmoji - textFormat: Text.PlainText topPadding: -Style.accountLabelsSpacing } @@ -105,7 +103,6 @@ AbstractButton { Layout.fillWidth: true visible: model.statusMessage !== "" text: statusMessage - textFormat: Text.PlainText elide: Text.ElideRight color: Style.ncTextColor font.pixelSize: Style.subLinePixelSize @@ -119,7 +116,6 @@ AbstractButton { Layout.alignment: Qt.AlignLeft | Qt.AlignTop verticalAlignment: Text.AlignTop text: server - textFormat: Text.PlainText elide: Text.ElideRight color: Style.ncTextColor font.pixelSize: Style.subLinePixelSize diff --git a/src/gui/tray/Window.qml b/src/gui/tray/Window.qml index 885180e45..f363bc5c3 100644 --- a/src/gui/tray/Window.qml +++ b/src/gui/tray/Window.qml @@ -451,7 +451,6 @@ ApplicationWindow { Layout.alignment: Qt.AlignLeft | Qt.AlignBottom width: Style.currentAccountLabelWidth text: UserModel.currentUser.name - textFormat: Text.PlainText elide: Text.ElideRight color: Style.currentUserHeaderTextColor @@ -471,7 +470,6 @@ ApplicationWindow { visible: UserModel.currentUser.statusEmoji !== "" width: Style.userStatusEmojiSize text: UserModel.currentUser.statusEmoji - textFormat: Text.PlainText } EnforcedPlainTextLabel { id: message @@ -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 From 2e3768278d3f92e57893927a19b3a016b9e0ceb9 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Fri, 2 Dec 2022 16:38:54 +0100 Subject: [PATCH 3/4] Add QML label check to CI Signed-off-by: Claudio Cambra --- .github/workflows/qml-label-check.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/qml-label-check.yml diff --git a/.github/workflows/qml-label-check.yml b/.github/workflows/qml-label-check.yml new file mode 100644 index 000000000..b6760f909 --- /dev/null +++ b/.github/workflows/qml-label-check.yml @@ -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=$(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!') From 19afb905c0bcd0c055552059d24e75d0d88dd745 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 5 Dec 2022 16:06:15 +0100 Subject: [PATCH 4/4] Only perform Label check on QML files Signed-off-by: Claudio Cambra --- .github/workflows/qml-label-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/qml-label-check.yml b/.github/workflows/qml-label-check.yml index b6760f909..2dae22c5c 100644 --- a/.github/workflows/qml-label-check.yml +++ b/.github/workflows/qml-label-check.yml @@ -13,7 +13,7 @@ jobs: - uses: actions/checkout@v2 - name: Run label component count run: | - MATCHESRESULT=$(grep -r -e "^\s*Label\s*[{]" . | wc -l | sed 's/ //g') + 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