A selection logic is improved

This commit is contained in:
cutefishd 2021-04-14 01:09:01 +08:00
parent eb9085cc8e
commit c061788e9c
4 changed files with 30 additions and 16 deletions

View file

@ -297,9 +297,6 @@ GridView {
if (control.ctrlPressed) {
dirModel.toggleSelected(hoveredItem.index)
} else {
if (mouse.button == Qt.LeftButton)
dirModel.clearSelection()
dirModel.setSelected(hoveredItem.index)
}
}
@ -416,7 +413,18 @@ GridView {
dirModel.openSelected()
}
onReleased: pressCanceled()
onReleased: {
//
if (pressedItem != null &&
!control.rubberBand &&
!dirModel.dragging) {
dirModel.clearSelection()
dirModel.setSelected(pressedItem.index)
}
pressCanceled()
}
onCanceled: pressCanceled()
onWheel: {

View file

@ -214,9 +214,6 @@ ListView {
if (control.ctrlPressed) {
dirModel.toggleSelected(hoveredItem.index)
} else {
if (mouse.button == Qt.LeftButton)
dirModel.clearSelection()
dirModel.setSelected(hoveredItem.index)
}
}
@ -322,7 +319,17 @@ ListView {
}
}
onReleased: pressCanceled()
onReleased: {
if (pressedItem != null &&
!control.rubberBand &&
!dirModel.dragging) {
dirModel.clearSelection()
dirModel.setSelected(pressedItem.index)
}
pressCanceled()
}
onCanceled: pressCanceled()
}

View file

@ -18,8 +18,8 @@ ListView {
model: placesModel
clip: true
leftMargin: FishUI.Units.smallSpacing
rightMargin: FishUI.Units.smallSpacing
leftMargin: FishUI.Units.smallSpacing * 1.5
rightMargin: FishUI.Units.smallSpacing * 1.5
bottomMargin: FishUI.Units.smallSpacing
spacing: FishUI.Units.smallSpacing

View file

@ -15,7 +15,7 @@ FishUI.Window {
visible: true
title: qsTr("File Manager")
headerBarHeight: 35 + FishUI.Units.largeSpacing
headerBarHeight: 35 + FishUI.Units.smallSpacing * 3
backgroundColor: FishUI.Theme.secondBackgroundColor
property QtObject settings: GlobalSettings { }
@ -31,10 +31,10 @@ FishUI.Window {
headerBar: Item {
RowLayout {
anchors.fill: parent
anchors.leftMargin: FishUI.Units.smallSpacing
anchors.rightMargin: FishUI.Units.smallSpacing
anchors.topMargin: FishUI.Units.smallSpacing
anchors.bottomMargin: FishUI.Units.smallSpacing
anchors.leftMargin: FishUI.Units.smallSpacing * 1.5
anchors.rightMargin: FishUI.Units.smallSpacing * 1.5
anchors.topMargin: FishUI.Units.smallSpacing * 1.5
anchors.bottomMargin: FishUI.Units.smallSpacing * 1.5
spacing: FishUI.Units.smallSpacing
@ -80,7 +80,6 @@ FishUI.Window {
RowLayout {
anchors.fill: parent
anchors.topMargin: 2
spacing: 0
SideBar {