From: Claudio Cambra Date: Fri, 2 Dec 2022 13:51:09 +0000 (+0100) Subject: Introduce EnforcedPlainTextLabel, convert all Label or Text labels to use this X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~11^2~93^2~3 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=6c4070e786765aefb48db5b75172b99438919074;p=nextcloud-desktop.git Introduce EnforcedPlainTextLabel, convert all Label or Text labels to use this Signed-off-by: Claudio Cambra --- 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