Explorar o código

Create commonly accessible properties for current user colours in Style.qml

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
Claudio Cambra %!s(int64=3) %!d(string=hai) anos
pai
achega
1a6326ed97

+ 3 - 3
src/gui/tray/ActivityActionButton.qml

@@ -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
     }

+ 1 - 7
src/gui/tray/ActivityItem.qml

@@ -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
         }
     }

+ 3 - 4
src/gui/tray/ActivityItemActions.qml

@@ -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)
         }

+ 3 - 5
src/gui/tray/ActivityItemContent.qml

@@ -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()
     }

+ 1 - 0
src/gui/tray/CustomButton.qml

@@ -28,6 +28,7 @@ Button {
 
     leftPadding: root.text === "" ? 5 : 10
     rightPadding: root.text === "" ? 5 : 10
+    implicitWidth: contentItem.implicitWidth + leftPadding + rightPadding
 
     NCToolTip {
         text: root.toolTipText

+ 1 - 1
src/gui/tray/HeaderButton.qml

@@ -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
     }
 }

+ 12 - 12
src/gui/tray/Window.qml

@@ -172,7 +172,7 @@ ApplicationWindow {
             anchors.right:  trayWindowMainItem.right
             anchors.top:    trayWindowMainItem.top
             height:         Style.trayWindowHeaderHeight
-            color:          UserModel.currentUser.headerColor
+            color:          Style.currentUserHeaderColor
 
             RowLayout {
                 id: trayWindowHeaderLayout
@@ -383,7 +383,7 @@ ApplicationWindow {
                     }
 
                     background: Rectangle {
-                        color: parent.hovered || parent.visualFocus ? UserModel.currentUser.headerTextColor : "transparent"
+                        color: parent.hovered || parent.visualFocus ? Style.currentUserHeaderTextColor : "transparent"
                         opacity: 0.2
                     }
 
@@ -415,7 +415,7 @@ ApplicationWindow {
                                 height: width
                                 anchors.bottom: currentAccountAvatar.bottom
                                 anchors.right: currentAccountAvatar.right
-                                color: UserModel.currentUser.headerColor
+                                color: Style.currentUserHeaderColor
                                 radius: width*0.5
                             }
 
@@ -427,7 +427,7 @@ ApplicationWindow {
                                 height: width
                                 anchors.bottom: currentAccountAvatar.bottom
                                 anchors.right: currentAccountAvatar.right
-                                color: currentAccountButton.hovered ? UserModel.currentUser.headerTextColor : "transparent"
+                                color: currentAccountButton.hovered ? Style.currentUserHeaderTextColor : "transparent"
                                 opacity: 0.2
                                 radius: width*0.5
                             }
@@ -463,7 +463,7 @@ ApplicationWindow {
                                 text: UserModel.currentUser.name
                                 textFormat: Text.PlainText
                                 elide: Text.ElideRight
-                                color: UserModel.currentUser.headerTextColor
+                                color: Style.currentUserHeaderTextColor
 
                                 font.pixelSize: Style.topLinePixelSize
                                 font.bold: true
@@ -494,7 +494,7 @@ ApplicationWindow {
                                           : UserModel.currentUser.server
                                     textFormat: Text.PlainText
                                     elide: Text.ElideRight
-                                    color: UserModel.currentUser.headerTextColor
+                                    color: Style.currentUserHeaderTextColor
                                     font.pixelSize: Style.subLinePixelSize
                                 }
                             }
@@ -502,7 +502,7 @@ ApplicationWindow {
 
                         ColorOverlay {
                             cached: true
-                            color: UserModel.currentUser.headerTextColor
+                            color: Style.currentUserHeaderTextColor
                             width: source.width
                             height: source.height
                             source: Image {
@@ -538,7 +538,7 @@ ApplicationWindow {
                         id: openLocalFolderButton
                         visible: UserModel.currentUser.hasLocalFolder
                         icon.source: "qrc:///client/theme/white/folder.svg"
-                        icon.color: UserModel.currentUser.headerTextColor
+                        icon.color: Style.currentUserHeaderTextColor
                         onClicked: UserModel.openCurrentAccountLocalFolder()
 
                         Image {
@@ -563,7 +563,7 @@ ApplicationWindow {
                                 width: Style.folderStateIndicatorSize + 2
                                 height: width
                                 anchors.centerIn: parent
-                                color: UserModel.currentUser.headerColor
+                                color: Style.currentUserHeaderColor
                                 radius: width*0.5
                                 z: -2
                             }
@@ -573,7 +573,7 @@ ApplicationWindow {
                                 width: Style.folderStateIndicatorSize + 2
                                 height: width
                                 anchors.centerIn: parent
-                                color: openLocalFolderButton.hovered ? UserModel.currentUser.headerTextColor : "transparent"
+                                color: openLocalFolderButton.hovered ? Style.currentUserHeaderTextColor : "transparent"
                                 opacity: 0.2
                                 radius: width*0.5
                                 z: -1
@@ -587,7 +587,7 @@ ApplicationWindow {
 
                     visible: UserModel.currentUser.serverHasTalk
                     icon.source: "qrc:///client/theme/white/talk-app.svg"
-                    icon.color: UserModel.currentUser.headerTextColor
+                    icon.color: Style.currentUserHeaderTextColor
                     onClicked: UserModel.openCurrentAccountTalk()
 
                     Accessible.role: Accessible.Button
@@ -598,7 +598,7 @@ ApplicationWindow {
                 HeaderButton {
                     id: trayWindowAppsButton
                     icon.source: "qrc:///client/theme/white/more-apps.svg"
-                    icon.color: UserModel.currentUser.headerTextColor
+                    icon.color: Style.currentUserHeaderTextColor
 
                     onClicked: {
                         if(appsMenuListView.count <= 0) {

+ 5 - 0
theme/Style/Style.qml

@@ -18,6 +18,11 @@ QtObject {
     readonly property color backgroundColor: Theme.systemPalette.base
     readonly property color buttonBackgroundColor: Theme.systemPalette.button
 
+    readonly property color currentUserHeaderColor: UserModel.currentUser ? UserModel.currentUser.headerColor : ncBlue
+    readonly property color currentUserHeaderTextColor: UserModel.currentUser ? UserModel.currentUser.headerTextColor : ncHeaderTextColor
+    readonly property color adjustedCurrentUserHeaderColor: Theme.darkMode ? Qt.lighter(currentUserHeaderColor, 2)
+                                                                           : Qt.darker(currentUserHeaderColor, 1.5)
+
     // ErrorBox colors
     readonly property color errorBoxBackgroundColor: Qt.rgba(0.89, 0.18, 0.18, 1)
     readonly property int errorBoxStripeWidth: 4