Improve select item logic

This commit is contained in:
cutefishd 2021-04-13 10:17:23 +08:00
parent 3c0d077970
commit 9b838e58a9
3 changed files with 9 additions and 8 deletions

View file

@ -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();
}

View file

@ -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
}
}

View file

@ -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