Skip to content

Commit 17cbedb

Browse files
committed
Make activity action button an actual button, clean up contents
Signed-off-by: Claudio Cambra <claudio.cambra@gmail.com>
1 parent 16fd9c5 commit 17cbedb

8 files changed

Lines changed: 144 additions & 133 deletions

resources.qrc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
<file>src/gui/tray/UnifiedSearchResultNothingFound.qml</file>
2828
<file>src/gui/tray/UnifiedSearchResultSectionItem.qml</file>
2929
<file>src/gui/tray/CustomButton.qml</file>
30-
<file>src/gui/tray/CustomTextButton.qml</file>
30+
<file>src/gui/tray/NCButtonContents.qml</file>
31+
<file>src/gui/tray/NCButtonBackground.qml</file>
32+
<file>src/gui/tray/TextButtonContents.qml</file>
3133
<file>src/gui/tray/ActivityItemContextMenu.qml</file>
3234
<file>src/gui/tray/ActivityItemActions.qml</file>
3335
<file>src/gui/tray/ActivityItemContent.qml</file>
Lines changed: 42 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import QtQuick 2.15
22
import QtQuick.Controls 2.3
3-
import QtQuick.Layouts 1.15
43
import Style 1.0
54
import com.nextcloud.desktopclient 1.0
65

7-
Item {
6+
AbstractButton {
87
id: root
98

10-
property string text: ""
119
property string toolTipText: ""
1210

1311
property bool bold: false
@@ -18,49 +16,60 @@ Item {
1816
property color textColor: Style.ncTextColor
1917
property color textColorHovered: Style.ncSecondaryTextColor
2018

21-
signal clicked()
19+
property string verb: ""
20+
property bool primary: false
21+
property bool isTalkReplyButton: false
2222

23-
Loader {
24-
active: root.imageSource === ""
25-
26-
anchors.fill: parent
27-
28-
sourceComponent: CustomTextButton {
29-
anchors.fill: parent
30-
text: root.text
31-
toolTipText: root.toolTipText
23+
background: NCButtonBackground {
24+
color: UserModel.currentUser.headerColor
25+
hovered: root.hovered
26+
visible: root.primary
27+
}
3228

33-
textColor: root.textColor
34-
textColorHovered: root.textColorHovered
29+
contentItem: Loader {
30+
id: contentItemLoader
31+
active: true
32+
sourceComponent: primary ? primaryButtonContent : textButtonContent
33+
}
3534

36-
onClicked: root.clicked()
35+
ToolTip {
36+
id: customTextButtonTooltip
37+
text: root.toolTipText
38+
delay: Qt.styleHints.mousePressAndHoldInterval
39+
visible: root.toolTipText !== "" && root.hovered
40+
contentItem: Label {
41+
text: customTextButtonTooltip.text
42+
color: Style.ncTextColor
43+
}
44+
background: Rectangle {
45+
border.color: Style.menuBorder
46+
color: Style.backgroundColor
3747
}
3848
}
3949

40-
Loader {
41-
active: root.imageSource !== ""
42-
43-
anchors.fill: parent
44-
45-
sourceComponent: CustomButton {
50+
Component {
51+
id: textButtonContent
52+
TextButtonContents {
4653
anchors.fill: parent
47-
anchors.topMargin: Style.roundedButtonBackgroundVerticalMargins
48-
anchors.bottomMargin: Style.roundedButtonBackgroundVerticalMargins
49-
54+
hovered: root.hovered
5055
text: root.text
51-
toolTipText: root.toolTipText
52-
5356
textColor: root.textColor
5457
textColorHovered: root.textColorHovered
55-
5658
bold: root.bold
59+
}
60+
}
5761

58-
imageSource: root.imageSource
62+
Component {
63+
id: primaryButtonContent
64+
NCButtonContents {
65+
anchors.fill: parent
66+
hovered: root.hovered
5967
imageSourceHover: root.imageSourceHover
60-
61-
bgColor: UserModel.currentUser.headerColor
62-
63-
onClicked: root.clicked()
68+
imageSource: root.imageSource
69+
text: root.text
70+
textColor: root.textColor
71+
textColorHovered: root.textColorHovered
72+
bold: root.bold
6473
}
6574
}
6675
}

src/gui/tray/ActivityItemActions.qml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,27 @@ RowLayout {
3333
ActivityActionButton {
3434
id: activityActionButton
3535

36-
readonly property string verb: model.modelData.verb
37-
readonly property bool primary: model.index === 0 && verb !== "DELETE"
38-
readonly property bool isTalkReplyButton: verb === "REPLY"
36+
property bool firstButton: model.index === 0 && verb !== "DELETE"
3937

40-
Layout.minimumWidth: primary ? Style.activityItemActionPrimaryButtonMinWidth : Style.activityItemActionSecondaryButtonMinWidth
41-
Layout.preferredHeight: primary ? parent.height : parent.height * 0.3
42-
Layout.preferredWidth: primary ? -1 : parent.height
38+
verb: model.modelData.verb
39+
primary: firstButton && model.modelData.imageSource
40+
isTalkReplyButton: verb === "REPLY"
41+
42+
Layout.minimumWidth: firstButton ? Style.activityItemActionPrimaryButtonMinWidth : Style.activityItemActionSecondaryButtonMinWidth
43+
Layout.preferredHeight: parent.height
44+
Layout.preferredWidth: firstButton ? -1 : parent.height
4345

4446
text: model.modelData.label
4547

4648
imageSource: model.modelData.imageSource ? model.modelData.imageSource + root.adjustedHeaderColor : ""
4749
imageSourceHover: model.modelData.imageSourceHovered ? model.modelData.imageSourceHovered + UserModel.currentUser.headerTextColor : ""
4850

49-
textColor: imageSource !== "" ? root.adjustedHeaderColor : Style.ncTextColor
50-
textColorHovered: imageSource !== "" ? UserModel.currentUser.headerTextColor : Style.ncTextColor
51+
textColor: primary ? root.adjustedHeaderColor : Style.ncTextColor
52+
textColorHovered: primary ? UserModel.currentUser.headerTextColor : Style.ncTextColor
5153

52-
bold: primary
54+
bold: firstButton
5355

54-
onClicked: !isTalkReplyButton ? root.triggerAction(model.index) : root.showReplyField()
56+
onClicked: isTalkReplyButton ? root.showReplyField() : root.triggerAction(model.index)
5557
}
5658
}
5759

src/gui/tray/CustomButton.qml

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ Button {
88

99
property string imageSource: ""
1010
property string imageSourceHover: ""
11-
property Image iconItem: icon
1211

1312
property string toolTipText: ""
1413

@@ -21,11 +20,9 @@ Button {
2120

2221
property real bgOpacity: 0.3
2322

24-
background: Rectangle {
23+
background: NCButtonBackground {
2524
id: bgRectangle
26-
color: "transparent"
27-
opacity: parent.hovered ? 1.0 : bgOpacity
28-
radius: width / 2
25+
hovered: root.hovered
2926
}
3027

3128
leftPadding: root.text === "" ? 5 : 10
@@ -46,31 +43,13 @@ Button {
4643
}
4744
}
4845

49-
contentItem: RowLayout {
50-
Image {
51-
id: icon
52-
53-
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
54-
55-
source: root.hovered ? root.imageSourceHover : root.imageSource
56-
fillMode: Image.PreserveAspectFit
57-
}
58-
59-
Label {
60-
Layout.maximumWidth: icon.width > 0 ? parent.width - icon.width - parent.spacing : parent.width
61-
Layout.fillWidth: icon.status !== Image.Ready
62-
63-
text: root.text
64-
font.bold: root.bold
65-
66-
visible: root.text !== ""
67-
68-
color: root.hovered ? root.textColorHovered : root.textColor
69-
70-
horizontalAlignment: Text.AlignHCenter
71-
verticalAlignment: Text.AlignVCenter
72-
73-
elide: Text.ElideRight
74-
}
46+
contentItem: NCButtonContents {
47+
hovered: root.hovered
48+
imageSourceHover: root.imageSourceHover
49+
imageSource: root.imageSource
50+
text: root.text
51+
textColor: root.textColor
52+
textColorHovered: root.textColorHovered
53+
bold: root.bold
7554
}
7655
}

src/gui/tray/CustomTextButton.qml

Lines changed: 0 additions & 58 deletions
This file was deleted.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import QtQuick 2.15
2+
3+
Rectangle {
4+
property bool hovered: false
5+
property real normalOpacity: 0.3
6+
property real hoverOpacity: 1.0
7+
8+
color: "transparent"
9+
opacity: hovered ? hoverOpacity : normalOpacity
10+
radius: width / 2
11+
}

src/gui/tray/NCButtonContents.qml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import QtQuick 2.15
2+
import QtQuick.Controls 2.3
3+
import QtQuick.Layouts 1.2
4+
5+
import Style 1.0
6+
7+
RowLayout {
8+
id: root
9+
10+
property bool hovered: false
11+
property string imageSourceHover: ""
12+
property string imageSource: ""
13+
property string text: ""
14+
15+
property color textColor: Style.ncTextColor
16+
property color textColorHovered: textColor
17+
property bool bold: false
18+
19+
Image {
20+
id: icon
21+
22+
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
23+
24+
source: root.hovered ? root.imageSourceHover : root.imageSource
25+
fillMode: Image.PreserveAspectFit
26+
}
27+
28+
Label {
29+
Layout.maximumWidth: icon.width > 0 ? parent.width - icon.width - parent.spacing : parent.width
30+
Layout.fillWidth: icon.status !== Image.Ready
31+
32+
text: root.text
33+
font.bold: root.bold
34+
35+
visible: root.text !== ""
36+
37+
color: root.hovered ? root.textColorHovered : root.textColor
38+
39+
horizontalAlignment: Text.AlignHCenter
40+
verticalAlignment: Text.AlignVCenter
41+
42+
elide: Text.ElideRight
43+
}
44+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import QtQuick 2.15
2+
import QtQuick.Controls 2.3
3+
import QtQuick.Layouts 1.2
4+
5+
import Style 1.0
6+
7+
Label {
8+
property bool hovered: false
9+
property color textColor: Style.ncTextColor
10+
property color textColorHovered: Style.ncSecondaryTextColor
11+
property bool bold: false
12+
13+
font.underline: true
14+
font.bold: bold
15+
color: hovered ? textColorHovered : textColor
16+
17+
horizontalAlignment: Text.AlignLeft
18+
verticalAlignment: Text.AlignVCenter
19+
20+
elide: Text.ElideRight
21+
}
22+

0 commit comments

Comments
 (0)