Skip to content

Commit

Permalink
Simplify user status selector and use custom button instead where pos…
Browse files Browse the repository at this point in the history
…sible

Signed-off-by: Claudio Cambra <[email protected]>
  • Loading branch information
claucambra committed Nov 25, 2022
1 parent b96f35f commit 948eacd
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 30 deletions.
31 changes: 23 additions & 8 deletions src/gui/UserStatusSelector.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -142,7 +143,6 @@ ColumnLayout {
onClicked: emojiDialog.open()
onHeightChanged: topButtonsLayout.maxButtonHeight = Math.max(topButtonsLayout.maxButtonHeight, height)

primary: true
padding: 0
z: hovered ? 2 : 0 // Make sure highlight is seen on top of text field

Expand Down Expand Up @@ -313,27 +313,42 @@ ColumnLayout {
Layout.fillWidth: true
Layout.alignment: Qt.AlignBottom

UserStatusSelectorButton {
CustomButton {
// Prevent being squashed by the other buttons with larger text
Layout.minimumWidth: implicitWidth
Layout.fillHeight: true
primary: true

text: qsTr("Cancel")
contentsFont.bold: true
bgColor: Style.buttonBackgroundColor
bgNormalOpacity: 1.0
bgHoverOpacity: Style.hoverOpacity

onClicked: finished()
}
UserStatusSelectorButton {
CustomButton {
Layout.fillWidth: true
Layout.fillHeight: true
primary: true

text: qsTr("Clear status message")
contentsFont.bold: true
bgColor: Style.buttonBackgroundColor
bgNormalOpacity: 1.0
bgHoverOpacity: Style.hoverOpacity

onClicked: userStatusSelectorModel.clearUserStatus()
}
UserStatusSelectorButton {
CustomButton {
Layout.fillWidth: true
Layout.fillHeight: true
primary: true
colored: true

text: qsTr("Set status message")
textColor: Style.ncHeaderTextColor
contentsFont.bold: true
bgColor: Style.ncBlue
bgNormalOpacity: 1.0
bgHoverOpacity: Style.hoverOpacity

onClicked: userStatusSelectorModel.setUserStatus()
}
}
Expand Down
42 changes: 20 additions & 22 deletions src/gui/UserStatusSelectorButton.qml
Original file line number Diff line number Diff line change
Expand Up @@ -22,71 +22,69 @@ AbstractButton {
id: root

property string secondaryText: ""
property bool colored: false
property bool primary: false
property bool highlighted: false
readonly property bool showBorder: hovered || highlighted || checked
readonly property bool showBorder: hovered || checked

readonly property bool hasImage: root.icon.source !== ""
readonly property bool hasSecondaryText: root.secondaryText !== ""
readonly property bool hasPrimaryText: root.text !== ""

hoverEnabled: true
padding: Style.standardSpacing

background: Rectangle {
radius: root.primary ? Style.veryRoundedButtonRadius : Style.mediumRoundedButtonRadius
color: root.colored ? Style.ncBlue : Style.buttonBackgroundColor
opacity: root.colored && root.hovered ? Style.hoverOpacity : 1.0
border.color: Style.ncBlue
border.width: root.showBorder ? root.primary ? Style.normalBorderWidth : Style.thickBorderWidth : 0
radius: Style.mediumRoundedButtonRadius
color: Style.buttonBackgroundColor
border.color: root.checked ? Style.ncBlue : Style.menuBorder
border.width: root.showBorder ? Style.thickBorderWidth : 0
}

contentItem: GridLayout {
columns: 2
columns: root.hasImage ? 2 : 1
rows: 2
columnSpacing: Style.standardSpacing
rowSpacing: Style.standardSpacing / 2

Image {
Layout.column: 0
Layout.columnSpan: root.text === "" && root.secondaryText == "" ? 2 : 1
Layout.columnSpan: !root.hasPrimaryText && !root.hasSecondaryText ? 2 : 1
Layout.row: 0
Layout.rowSpan: 2
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter


source: root.icon.source
visible: root.icon.source !== ""
visible: root.hasImage
}

Label {
Layout.column: root.icon.source === "" ? 0 : 1
Layout.columnSpan: root.icon.source === "" ? 2 : 1
Layout.column: root.hasImage ? 1 : 0
Layout.columnSpan: root.hasImage ? 1 : 2
Layout.row: 0
Layout.rowSpan: root.secondaryText === "" ? 2 : 1
Layout.rowSpan: root.hasSecondaryText ? 1 : 2
Layout.fillWidth: true
horizontalAlignment: root.primary ? Text.AlignHCenter : Text.AlignLeft
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter

text: root.text
textFormat: Text.PlainText
wrapMode: Text.Wrap
color: root.colored ? Style.ncHeaderTextColor : Style.ncTextColor
font.bold: root.primary
}

Label {
Layout.column: root.icon.source === "" ? 0 : 1
Layout.columnSpan: root.icon.source === "" ? 2 : 1
Layout.column: root.hasImage ? 1 : 0
Layout.columnSpan: root.hasImage ? 1 : 2
Layout.row: 1
Layout.fillWidth: true
horizontalAlignment: root.primary ? Text.AlignHCenter : Text.AlignLeft
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter

text: root.secondaryText
textFormat: Text.PlainText
wrapMode: Text.Wrap
color: Style.ncSecondaryTextColor
visible: root.secondaryText !== ""
visible: root.hasSecondaryText
}
}
}

0 comments on commit 948eacd

Please sign in to comment.