From c061788e9c6c86e1f25515fc0d1ae3275900d4c6 Mon Sep 17 00:00:00 2001 From: cutefishd Date: Wed, 14 Apr 2021 01:09:01 +0800 Subject: [PATCH] A selection logic is improved --- qml/FolderGridView.qml | 16 ++++++++++++---- qml/FolderListView.qml | 15 +++++++++++---- qml/SideBar.qml | 4 ++-- qml/main.qml | 11 +++++------ 4 files changed, 30 insertions(+), 16 deletions(-) diff --git a/qml/FolderGridView.qml b/qml/FolderGridView.qml index fefd686..9f43554 100644 --- a/qml/FolderGridView.qml +++ b/qml/FolderGridView.qml @@ -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: { diff --git a/qml/FolderListView.qml b/qml/FolderListView.qml index 2066116..fa56bf2 100644 --- a/qml/FolderListView.qml +++ b/qml/FolderListView.qml @@ -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() } diff --git a/qml/SideBar.qml b/qml/SideBar.qml index d0043f6..a809af5 100644 --- a/qml/SideBar.qml +++ b/qml/SideBar.qml @@ -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 diff --git a/qml/main.qml b/qml/main.qml index 81e9967..2478c3f 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -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 {