Create commonly accessible properties for current user colours in Style.qml
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Thu, 20 Oct 2022 11:41:25 +0000 (13:41 +0200)
committerClaudio Cambra <claudio.cambra@gmail.com>
Tue, 25 Oct 2022 17:14:40 +0000 (19:14 +0200)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
src/gui/tray/ActivityActionButton.qml
src/gui/tray/ActivityItem.qml
src/gui/tray/ActivityItemActions.qml
src/gui/tray/ActivityItemContent.qml
src/gui/tray/CustomButton.qml
src/gui/tray/HeaderButton.qml
src/gui/tray/Window.qml
theme/Style/Style.qml

index 2c5a0e57e134343a68d5b539c41186d87b5d373e..7741f4f16070ca03d1dc51ead06183c9db52f0b7 100644 (file)
@@ -13,16 +13,16 @@ AbstractButton {
     property string imageSource: ""
     property string imageSourceHover: ""
 
-    property color adjustedHeaderColor: Style.ncBlue
+    property color adjustedHeaderColor: Style.adjustedCurrentUserHeaderColor
     property color textColor: primaryButton ? adjustedHeaderColor : Style.ncTextColor
-    property color textColorHovered: primaryButton ? UserModel.currentUser.headerTextColor : Style.ncTextColor
+    property color textColorHovered: primaryButton ? Style.currentUserHeaderTextColor : Style.ncTextColor
 
     property string verb: ""
     property bool isTalkReplyButton: false
 
 
     background: NCButtonBackground {
-        color: UserModel.currentUser.headerColor
+        color: Style.currentUserHeaderColor
         hovered: root.hovered
         visible: root.primaryButton
     }
index 9b67f1e57fb7d7cd8bf0862479270dd85b377f78..020555ed36dac7565b735b5f8576f6f9fadad981 100644 (file)
@@ -16,9 +16,6 @@ ItemDelegate {
     readonly property bool isTalkReplyPossible: model.conversationToken !== ""
     property bool isTalkReplyOptionVisible: model.messageSent !== ""
 
-    property color adjustedHeaderColor: Theme.darkMode ? Qt.lighter(UserModel.currentUser.headerColor, 2)
-                                                       : Qt.darker(UserModel.currentUser.headerColor, 1.5)
-
     enabled: (model.path !== "" || model.link !== "" || model.links.length > 0 ||  model.isCurrentUserFileActivity === true)
     padding: Style.standardSpacing
 
@@ -50,8 +47,6 @@ ItemDelegate {
 
             activityData: model
 
-            adjustedHeaderColor: root.adjustedHeaderColor
-
             onShareButtonClicked: Systray.openShareDialog(model.displayPath, model.path)
 
             onDismissButtonClicked: activityModel.slotTriggerDismiss(model.activityIndex)
@@ -92,9 +87,8 @@ ItemDelegate {
 
             flickable: root.flickable
 
-            adjustedHeaderColor: root.adjustedHeaderColor
-
             onTriggerAction: activityModel.slotTriggerAction(model.activityIndex, actionIndex)
+
             onShowReplyField: root.isTalkReplyOptionVisible = true
         }
     }
index 57230cc56d6211d6ec3b28625543186f6b1fe594..1b7ffc4f9b58b16caf905c361ddf48487c4393d0 100644 (file)
@@ -16,7 +16,6 @@ RowLayout {
     property bool displayActions: false
 
     property color moreActionsButtonColor: "transparent"
-    property color adjustedHeaderColor: "transparent"
 
     property int maxActionButtons: 0
 
@@ -43,10 +42,10 @@ RowLayout {
 
             text: model.modelData.label
 
-            adjustedHeaderColor: root.adjustedHeaderColor
+            adjustedHeaderColor: Style.adjustedCurrentUserHeaderColor
 
-            imageSource: model.modelData.imageSource ? model.modelData.imageSource + root.adjustedHeaderColor : ""
-            imageSourceHover: model.modelData.imageSourceHovered ? model.modelData.imageSourceHovered + UserModel.currentUser.headerTextColor : ""
+            imageSource: model.modelData.imageSource ? model.modelData.imageSource + Style.adjustedCurrentUserHeaderColor : ""
+            imageSourceHover: model.modelData.imageSourceHovered ? model.modelData.imageSourceHovered + Style.currentUserHeaderTextColor : ""
 
             onClicked: isTalkReplyButton ? root.showReplyField() : root.triggerAction(model.index)
         }
index 50aa41d5f2dc13b857dfa3485c71335ed33114d2..51c653312e5b37fda14de1e8cfbbc37c2a85326e 100644 (file)
@@ -17,8 +17,6 @@ RowLayout {
 
     property bool childHovered: shareButton.hovered || dismissActionButton.hovered
 
-    property color adjustedHeaderColor: "transparent"
-
     signal dismissButtonClicked()
     signal shareButtonClicked()
 
@@ -206,12 +204,12 @@ RowLayout {
 
         visible: root.activityData.isShareable
 
-        imageSource: "image://svgimage-custom-color/share.svg" + "/" + root.adjustedHeaderColor
-        imageSourceHover: "image://svgimage-custom-color/share.svg" + "/" + UserModel.currentUser.headerTextColor
+        imageSource: "image://svgimage-custom-color/share.svg" + "/" + Style.adjustedCurrentUserHeaderColor
+        imageSourceHover: "image://svgimage-custom-color/share.svg" + "/" + Style.currentUserHeaderTextColor
 
         toolTipText: qsTr("Open share dialog")
 
-        bgColor: UserModel.currentUser.headerColor
+        bgColor: Style.currentUserHeaderColor
 
         onClicked: root.shareButtonClicked()
     }
index 97b50b7dd81dfa7ac28f6e9413303b057f74c98a..c132830be4ca8e8312b892777e1e038fdd019348 100644 (file)
@@ -28,6 +28,7 @@ Button {
 
     leftPadding: root.text === "" ? 5 : 10
     rightPadding: root.text === "" ? 5 : 10
+    implicitWidth: contentItem.implicitWidth + leftPadding + rightPadding
 
     NCToolTip {
         text: root.toolTipText
index c101188774daa9429cb4b581f913af26a7eb1a1d..f2528c10bafae6cc2fb2c592630b76cc2cfaec41 100644 (file)
@@ -26,7 +26,7 @@ Button {
     Layout.preferredHeight: Style.trayWindowHeaderHeight
 
     background: Rectangle {
-        color: root.hovered || root.visualFocus ? UserModel.currentUser.headerTextColor : "transparent"
+        color: root.hovered || root.visualFocus ? Style.currentUserHeaderTextColor : "transparent"
         opacity: 0.2
     }
 }
index 66a5adf6e298f11072f5e21f713852cd73dfe7fc..94611c6474a41fe249c2e39ddba72dbe5002a7ff 100644 (file)
@@ -172,7 +172,7 @@ ApplicationWindow {
             anchors.right:  trayWindowMainItem.right\r
             anchors.top:    trayWindowMainItem.top\r
             height:         Style.trayWindowHeaderHeight\r
-            color:          UserModel.currentUser.headerColor\r
+            color:          Style.currentUserHeaderColor\r
 \r
             RowLayout {\r
                 id: trayWindowHeaderLayout\r
@@ -383,7 +383,7 @@ ApplicationWindow {
                     }\r
 \r
                     background: Rectangle {\r
-                        color: parent.hovered || parent.visualFocus ? UserModel.currentUser.headerTextColor : "transparent"\r
+                        color: parent.hovered || parent.visualFocus ? Style.currentUserHeaderTextColor : "transparent"\r
                         opacity: 0.2\r
                     }\r
 \r
@@ -415,7 +415,7 @@ ApplicationWindow {
                                 height: width\r
                                 anchors.bottom: currentAccountAvatar.bottom\r
                                 anchors.right: currentAccountAvatar.right\r
-                                color: UserModel.currentUser.headerColor\r
+                                color: Style.currentUserHeaderColor\r
                                 radius: width*0.5\r
                             }\r
 \r
@@ -427,7 +427,7 @@ ApplicationWindow {
                                 height: width\r
                                 anchors.bottom: currentAccountAvatar.bottom\r
                                 anchors.right: currentAccountAvatar.right\r
-                                color: currentAccountButton.hovered ? UserModel.currentUser.headerTextColor : "transparent"\r
+                                color: currentAccountButton.hovered ? Style.currentUserHeaderTextColor : "transparent"\r
                                 opacity: 0.2\r
                                 radius: width*0.5\r
                             }\r
@@ -463,7 +463,7 @@ ApplicationWindow {
                                 text: UserModel.currentUser.name\r
                                 textFormat: Text.PlainText\r
                                 elide: Text.ElideRight\r
-                                color: UserModel.currentUser.headerTextColor\r
+                                color: Style.currentUserHeaderTextColor\r
 \r
                                 font.pixelSize: Style.topLinePixelSize\r
                                 font.bold: true\r
@@ -494,7 +494,7 @@ ApplicationWindow {
                                           : UserModel.currentUser.server\r
                                     textFormat: Text.PlainText\r
                                     elide: Text.ElideRight\r
-                                    color: UserModel.currentUser.headerTextColor\r
+                                    color: Style.currentUserHeaderTextColor\r
                                     font.pixelSize: Style.subLinePixelSize\r
                                 }\r
                             }\r
@@ -502,7 +502,7 @@ ApplicationWindow {
 \r
                         ColorOverlay {\r
                             cached: true\r
-                            color: UserModel.currentUser.headerTextColor\r
+                            color: Style.currentUserHeaderTextColor\r
                             width: source.width\r
                             height: source.height\r
                             source: Image {\r
@@ -538,7 +538,7 @@ ApplicationWindow {
                         id: openLocalFolderButton\r
                         visible: UserModel.currentUser.hasLocalFolder\r
                         icon.source: "qrc:///client/theme/white/folder.svg"\r
-                        icon.color: UserModel.currentUser.headerTextColor\r
+                        icon.color: Style.currentUserHeaderTextColor\r
                         onClicked: UserModel.openCurrentAccountLocalFolder()\r
 \r
                         Image {\r
@@ -563,7 +563,7 @@ ApplicationWindow {
                                 width: Style.folderStateIndicatorSize + 2\r
                                 height: width\r
                                 anchors.centerIn: parent\r
-                                color: UserModel.currentUser.headerColor\r
+                                color: Style.currentUserHeaderColor\r
                                 radius: width*0.5\r
                                 z: -2\r
                             }\r
@@ -573,7 +573,7 @@ ApplicationWindow {
                                 width: Style.folderStateIndicatorSize + 2\r
                                 height: width\r
                                 anchors.centerIn: parent\r
-                                color: openLocalFolderButton.hovered ? UserModel.currentUser.headerTextColor : "transparent"\r
+                                color: openLocalFolderButton.hovered ? Style.currentUserHeaderTextColor : "transparent"\r
                                 opacity: 0.2\r
                                 radius: width*0.5\r
                                 z: -1\r
@@ -587,7 +587,7 @@ ApplicationWindow {
 \r
                     visible: UserModel.currentUser.serverHasTalk\r
                     icon.source: "qrc:///client/theme/white/talk-app.svg"\r
-                    icon.color: UserModel.currentUser.headerTextColor\r
+                    icon.color: Style.currentUserHeaderTextColor\r
                     onClicked: UserModel.openCurrentAccountTalk()\r
 \r
                     Accessible.role: Accessible.Button\r
@@ -598,7 +598,7 @@ ApplicationWindow {
                 HeaderButton {\r
                     id: trayWindowAppsButton\r
                     icon.source: "qrc:///client/theme/white/more-apps.svg"\r
-                    icon.color: UserModel.currentUser.headerTextColor\r
+                    icon.color: Style.currentUserHeaderTextColor\r
 \r
                     onClicked: {\r
                         if(appsMenuListView.count <= 0) {\r
index 3aa6fd83573d0f9cc91aa078fec346a933d819ce..9214c17eab5a0926322ca235ed91d349bc351df0 100644 (file)
@@ -18,6 +18,11 @@ QtObject {
     readonly property color backgroundColor: Theme.systemPalette.base\r
     readonly property color buttonBackgroundColor: Theme.systemPalette.button\r
 \r
+    readonly property color currentUserHeaderColor: UserModel.currentUser ? UserModel.currentUser.headerColor : ncBlue\r
+    readonly property color currentUserHeaderTextColor: UserModel.currentUser ? UserModel.currentUser.headerTextColor : ncHeaderTextColor\r
+    readonly property color adjustedCurrentUserHeaderColor: Theme.darkMode ? Qt.lighter(currentUserHeaderColor, 2)\r
+                                                                           : Qt.darker(currentUserHeaderColor, 1.5)\r
+\r
     // ErrorBox colors\r
     readonly property color errorBoxBackgroundColor: Qt.rgba(0.89, 0.18, 0.18, 1)\r
     readonly property int errorBoxStripeWidth: 4\r