Browse Source

Merge pull request #5189 from nextcloud/bugfix/custom-buttons-alignments

Fix bad custom button alignments, sizings, etc.
Claudio Cambra 3 years ago
parent
commit
4f21aa537b

+ 2 - 0
src/gui/tray/ActivityActionButton.qml

@@ -20,6 +20,8 @@ AbstractButton {
     property string verb: ""
     property bool isTalkReplyButton: false
 
+    leftPadding: root.text === "" ? Style.smallSpacing : Style.standardSpacing
+    rightPadding: root.text === "" ? Style.smallSpacing : Style.standardSpacing
 
     background: NCButtonBackground {
         color: Style.currentUserHeaderColor

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

@@ -80,7 +80,7 @@ ItemDelegate {
 
             Layout.fillWidth: true
             Layout.leftMargin: Style.trayListItemIconSize + activityContent.spacing
-            Layout.minimumHeight: Style.minActivityHeight
+            Layout.preferredHeight: Style.standardPrimaryButtonHeight
 
             displayActions: model.displayActions
             objectType: model.objectType

+ 2 - 2
src/gui/tray/CustomButton.qml

@@ -26,8 +26,8 @@ Button {
         hovered: root.hovered
     }
 
-    leftPadding: root.text === "" ? 5 : 10
-    rightPadding: root.text === "" ? 5 : 10
+    leftPadding: root.text === "" ? Style.smallSpacing : Style.standardSpacing
+    rightPadding: root.text === "" ? Style.smallSpacing : Style.standardSpacing
     implicitWidth: contentItem.implicitWidth + leftPadding + rightPadding
 
     NCToolTip {

+ 6 - 4
src/gui/tray/NCButtonContents.qml

@@ -33,17 +33,19 @@ RowLayout {
     Image {
         id: icon
 
-        Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
+        Layout.fillWidth: !buttonLabel.visible
 
         source: root.hovered ? root.imageSourceHover : root.imageSource
         fillMode: Image.PreserveAspectFit
+        horizontalAlignment: Image.AlignHCenter
+        verticalAlignment: Image.AlignVCenter
+        visible: root.hovered ? root.imageSourceHover !== "" : root.imageSource !== ""
     }
 
     Label {
         id: buttonLabel
 
-        Layout.maximumWidth: icon.width > 0 ? parent.width - icon.width - parent.spacing : parent.width
-        Layout.fillWidth: icon.status !== Image.Ready
+        Layout.fillWidth: true
 
         text: root.text
         textFormat: Text.PlainText
@@ -52,7 +54,7 @@ RowLayout {
 
         color: root.hovered ? root.textColorHovered : root.textColor
 
-        horizontalAlignment: Text.AlignHCenter
+        horizontalAlignment: icon.visible ? Text.AlignLeft : Text.AlignHCenter
         verticalAlignment: Text.AlignVCenter
 
         elide: Text.ElideRight

+ 1 - 0
theme/Style/Style.qml

@@ -53,6 +53,7 @@ QtObject {
     property int smallSpacing: 5
 
     property int iconButtonWidth: 36
+    property int standardPrimaryButtonHeight: 40
 
     property int minActivityHeight: variableSize(40)