Skip to content

Commit 4fbecb1

Browse files
memuratsgithub-actions
authored andcommitted
fix hover state
1 parent 5fccbad commit 4fbecb1

2 files changed

Lines changed: 35 additions & 42 deletions

File tree

src/gui/tray/ActivityItem.qml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import QtQml
77
import QtQuick
88
import QtQuick.Controls
99
import QtQuick.Layouts
10+
1011
import Style
1112
import com.nextcloud.desktopclient
1213

@@ -24,25 +25,31 @@ ItemDelegate {
2425
property bool isTalkReplyOptionVisible: model.messageSent !== ""
2526

2627
padding: Style.standardSpacing
28+
hoverEnabled: true
2729

2830
Accessible.role: Accessible.ListItem
2931
Accessible.name: (model.path !== "" && model.displayPath !== "") ? qsTr("Open %1 locally").arg(model.displayPath) : model.message
3032
Accessible.onPressAction: root.clicked()
3133

34+
background: Rectangle {
35+
color: root.hovered || root.activeFocus ? palette.highlight : "transparent"
36+
radius: Style.mediumRoundedButtonRadius
37+
border.width: 0
38+
}
39+
3240
ToolTip {
3341
popupType: Qt.platform.os === "windows" ? Popup.Item : Popup.Native
3442
visible: root.hovered && !activityContent.childHovered && model.displayLocation !== ""
3543
text: qsTr("In %1").arg(model.displayLocation)
3644
}
3745

38-
// TODO: the current style does not support customization of this control
3946
contentItem: ColumnLayout {
4047
spacing: Style.smallSpacing
4148

4249
ActivityItemContent {
4350
id: activityContent
4451

45-
adaptiveTextColor: root.activeFocus ? palette.highlightedText : palette.text
52+
adaptiveTextColor: root.hovered || root.activeFocus ? palette.highlightedText : palette.text
4653

4754
Layout.fillWidth: true
4855
Layout.minimumHeight: Style.minActivityHeight
@@ -60,6 +67,7 @@ ItemDelegate {
6067

6168
Loader {
6269
id: talkReplyTextFieldLoader
70+
6371
active: root.isChatActivity && root.isTalkReplyPossible && model.messageSent === ""
6472
visible: root.isTalkReplyOptionVisible
6573

@@ -69,8 +77,8 @@ ItemDelegate {
6977

7078
sourceComponent: TalkReplyTextField {
7179
onSendReply: {
72-
UserModel.currentUser.sendReplyMessage(model.activityIndex, model.conversationToken, reply, model.messageId);
73-
talkReplyTextFieldLoader.visible = false;
80+
UserModel.currentUser.sendReplyMessage(model.activityIndex, model.conversationToken, reply, model.messageId)
81+
talkReplyTextFieldLoader.visible = false
7482
}
7583
}
7684
}

src/gui/tray/ActivityList.qml

Lines changed: 23 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ import com.nextcloud.desktopclient as NC
1111

1212
ScrollView {
1313
id: controlRoot
14+
1415
property alias model: sortedActivityList.sourceModel
1516
property alias count: activityList.count
16-
property alias atYBeginning : activityList.atYBeginning
17+
property alias atYBeginning: activityList.atYBeginning
1718
property bool isFileActivityList: false
1819
property int iconSize: Style.trayListItemIconSize
1920
property int delegateHorizontalPadding: 0
2021

2122
property bool scrollingToTop: false
2223

2324
function scrollToTop() {
24-
// Triggers activation of repeating upward flick timer
2525
scrollingToTop = true
2626
}
2727

@@ -33,7 +33,7 @@ ScrollView {
3333
topPadding: 0
3434
bottomPadding: 0
3535
rightPadding: ScrollBar.vertical.width
36-
36+
3737
focus: false
3838

3939
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
@@ -60,6 +60,9 @@ ScrollView {
6060
currentIndex: -1
6161
interactive: true
6262

63+
highlight: null
64+
highlightFollowsCurrentItem: false
65+
6366
Timer {
6467
id: repeatUpFlickTimer
6568
interval: Style.activityListScrollToTopTimerInterval
@@ -74,53 +77,34 @@ ScrollView {
7477
}
7578
}
7679

77-
highlight: Rectangle {
78-
id: activityHover
79-
anchors.fill: activityList.currentItem
80-
color: palette.highlight
81-
radius: Style.mediumRoundedButtonRadius
82-
visible: activityList.activeFocus
83-
}
84-
85-
highlightFollowsCurrentItem: true
86-
highlightMoveDuration: 0
87-
highlightResizeDuration: 0
88-
highlightRangeMode: ListView.ApplyRange
89-
preferredHighlightBegin: 0
90-
preferredHighlightEnd: controlRoot.height
91-
9280
model: NC.SortedActivityListModel {
9381
id: sortedActivityList
9482
}
9583

9684
delegate: ActivityItem {
97-
background: null
9885
width: activityList.contentItem.width
9986

10087
isFileActivityList: controlRoot.isFileActivityList
10188
iconSize: Style.nmcListViewIconSize
10289
leftPadding: Style.nmcListViewLeftPadding
10390
flickable: activityList
91+
10492
onHoveredChanged: if (hovered) {
105-
// When we set the currentIndex the list view will scroll...
106-
// unless we tamper with the preferred highlight points to stop this.
107-
const savedPreferredHighlightBegin = activityList.preferredHighlightBegin;
108-
const savedPreferredHighlightEnd = activityList.preferredHighlightEnd;
109-
// Set overkill values to make sure no scroll happens when we hover with mouse
110-
activityList.preferredHighlightBegin = -controlRoot.height;
111-
activityList.preferredHighlightEnd = controlRoot.height * 2;
93+
const savedPreferredHighlightBegin = activityList.preferredHighlightBegin
94+
const savedPreferredHighlightEnd = activityList.preferredHighlightEnd
11295

113-
activityList.currentIndex = index
96+
activityList.preferredHighlightBegin = -controlRoot.height
97+
activityList.preferredHighlightEnd = controlRoot.height * 2
11498

115-
// Reset original values so keyboard navigation makes list view scroll
116-
activityList.preferredHighlightBegin = savedPreferredHighlightBegin;
117-
activityList.preferredHighlightEnd = savedPreferredHighlightEnd;
99+
activityList.currentIndex = index
118100

119-
forceActiveFocus();
101+
activityList.preferredHighlightBegin = savedPreferredHighlightBegin
102+
activityList.preferredHighlightEnd = savedPreferredHighlightEnd
120103
}
104+
121105
onClicked: {
122106
if (model.isCurrentUserFileActivity && model.openablePath) {
123-
openFile("file://" + model.openablePath);
107+
openFile("file://" + model.openablePath)
124108
} else {
125109
activityItemClicked(model.activityIndex)
126110
}
@@ -151,6 +135,7 @@ ScrollView {
151135

152136
Column {
153137
id: placeholderColumn
138+
154139
width: parent.width * 0.75
155140
anchors.centerIn: parent
156141
visible: activityList.count === 0
@@ -165,12 +150,12 @@ ScrollView {
165150
}
166151

167152
EnforcedPlainTextLabel {
168-
width: parent.width
169-
text: qsTr("No activities yet")
170-
font.bold: true
171-
wrapMode: Text.Wrap
172-
horizontalAlignment: Text.AlignHCenter
173-
verticalAlignment: Text.AlignVCenter
153+
width: parent.width
154+
text: qsTr("No activities yet")
155+
font.bold: true
156+
wrapMode: Text.Wrap
157+
horizontalAlignment: Text.AlignHCenter
158+
verticalAlignment: Text.AlignVCenter
174159
}
175160
}
176161
}

0 commit comments

Comments
 (0)