From 9b838e58a948bb498f27628a934e14f3f9ce010e Mon Sep 17 00:00:00 2001 From: cutefishd Date: Tue, 13 Apr 2021 10:17:23 +0800 Subject: [PATCH] Improve select item logic --- desktop/desktopview.cpp | 7 +++---- qml/FolderGridView.qml | 4 ++-- qml/FolderListView.qml | 6 ++++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/desktop/desktopview.cpp b/desktop/desktopview.cpp index 7921855..9108df2 100644 --- a/desktop/desktopview.cpp +++ b/desktop/desktopview.cpp @@ -48,9 +48,9 @@ DesktopView::DesktopView(QQuickView *parent) onGeometryChanged(); - connect(qApp->primaryScreen(), &QScreen::virtualGeometryChanged, this, &DesktopView::onGeometryChanged); - connect(qApp->primaryScreen(), &QScreen::geometryChanged, this, &DesktopView::onGeometryChanged); - connect(qApp->primaryScreen(), &QScreen::availableGeometryChanged, this, &DesktopView::onAvailableGeometryChanged); + connect(qApp->primaryScreen(), &QScreen::virtualGeometryChanged, this, &DesktopView::onGeometryChanged, Qt::QueuedConnection); + connect(qApp->primaryScreen(), &QScreen::geometryChanged, this, &DesktopView::onGeometryChanged, Qt::QueuedConnection); + connect(qApp->primaryScreen(), &QScreen::availableGeometryChanged, this, &DesktopView::onAvailableGeometryChanged, Qt::QueuedConnection); } QRect DesktopView::screenRect() @@ -67,7 +67,6 @@ void DesktopView::onGeometryChanged() { m_screenRect = qApp->primaryScreen()->geometry(); setGeometry(qApp->primaryScreen()->geometry()); - emit screenRectChanged(); } diff --git a/qml/FolderGridView.qml b/qml/FolderGridView.qml index e4be3df..3e3ecbc 100644 --- a/qml/FolderGridView.qml +++ b/qml/FolderGridView.qml @@ -297,6 +297,7 @@ GridView { if (control.ctrlPressed) { dirModel.toggleSelected(hoveredItem.index) } else { + dirModel.clearSelection() dirModel.setSelected(hoveredItem.index) } } @@ -317,8 +318,7 @@ GridView { // 弹出文件夹菜单 if (mouse.buttons & Qt.RightButton) { clearPressState() - // dirModel.openContextMenu(null, mouse.modifiers) - folderMenu.open() + dirModel.openContextMenu(null, mouse.modifiers) mouse.accepted = true } } diff --git a/qml/FolderListView.qml b/qml/FolderListView.qml index 7e45593..c04f97e 100644 --- a/qml/FolderListView.qml +++ b/qml/FolderListView.qml @@ -211,10 +211,12 @@ ListView { dirModel.clearSelection() } - if (control.ctrlPressed) + if (control.ctrlPressed) { dirModel.toggleSelected(hoveredItem.index) - else + } else { + dirModel.clearSelection() dirModel.setSelected(hoveredItem.index) + } } control.currentIndex = hoveredItem.index