Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve activity list highlighting/keyboard item selection #4781

Merged
merged 1 commit into from
Sep 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/gui/tray/ActivityItem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ ItemDelegate {
Accessible.name: (model.path !== "" && model.displayPath !== "") ? qsTr("Open %1 locally").arg(model.displayPath) : model.message
Accessible.onPressAction: root.clicked()

background: Rectangle {
color: root.hovered ? Style.lightHover : "transparent"
}

NCToolTip {
visible: root.hovered && !activityContent.childHovered && model.displayLocation !== ""
text: qsTr("In %1").arg(model.displayLocation)
Expand Down
38 changes: 35 additions & 3 deletions src/gui/tray/ActivityList.qml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import QtQuick 2.15
import QtQuick.Controls 2.15

import com.nextcloud.desktopclient 1.0 as NC
import Style 1.0

ScrollView {
id: controlRoot
Expand All @@ -14,6 +15,7 @@ ScrollView {

contentWidth: availableWidth
padding: 1
focus: false

ScrollBar.horizontal.policy: ScrollBar.AlwaysOff

Expand All @@ -24,19 +26,49 @@ ScrollView {
ListView {
id: activityList

keyNavigationEnabled: true

Accessible.role: Accessible.List
Accessible.name: qsTr("Activity list")

clip: true

spacing: 0
currentIndex: -1
interactive: true

highlight: Rectangle {
id: activityHover
width: activityList.currentItem.width
height: activityList.currentItem.height
color: Style.lightHover
visible: activityList.activeFocus
}
highlightFollowsCurrentItem: true
highlightMoveDuration: 0
highlightResizeDuration: 0
highlightRangeMode: ListView.ApplyRange
preferredHighlightBegin: 0
preferredHighlightEnd: controlRoot.height

delegate: ActivityItem {
isFileActivityList: controlRoot.isFileActivityList
width: activityList.contentWidth
flickable: activityList
onEntered: {
// When we set the currentIndex the list view will scroll...
// unless we tamper with the preferred highlight points to stop this.
const savedPreferredHighlightBegin = activityList.preferredHighlightBegin;
const savedPreferredHighlightEnd = activityList.preferredHighlightEnd;
// Set overkill values to make sure no scroll happens when we hover with mouse
activityList.preferredHighlightBegin = -controlRoot.height;
activityList.preferredHighlightEnd = controlRoot.height * 2;

activityList.currentIndex = index

// Reset original values so keyboard navigation makes list view scroll
activityList.preferredHighlightBegin = savedPreferredHighlightBegin;
activityList.preferredHighlightEnd = savedPreferredHighlightEnd;

forceActiveFocus();
}
onClicked: {
if (model.isCurrentUserFileActivity && model.openablePath) {
openFile("file://" + model.openablePath);
Expand Down