From 2fb64748b615146b4de758422db19c5b7e644b54 Mon Sep 17 00:00:00 2001 From: cutefishd Date: Tue, 13 Apr 2021 10:46:20 +0800 Subject: [PATCH] Some improvements --- images/drive-harddisk-root.svg | 11 +++++++++++ images/drive-harddisk.svg | 11 +++++++++++ model/placesitem.cpp | 1 + model/placesmodel.cpp | 2 +- qml.qrc | 2 ++ qml/FolderGridView.qml | 4 +++- qml/FolderListView.qml | 12 +++++++----- qml/FolderPage.qml | 2 +- 8 files changed, 37 insertions(+), 8 deletions(-) create mode 100755 images/drive-harddisk-root.svg create mode 100755 images/drive-harddisk.svg diff --git a/images/drive-harddisk-root.svg b/images/drive-harddisk-root.svg new file mode 100755 index 0000000..c3a88a4 --- /dev/null +++ b/images/drive-harddisk-root.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/images/drive-harddisk.svg b/images/drive-harddisk.svg new file mode 100755 index 0000000..c3a88a4 --- /dev/null +++ b/images/drive-harddisk.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/model/placesitem.cpp b/model/placesitem.cpp index 6ae0d1c..dbc1e5a 100644 --- a/model/placesitem.cpp +++ b/model/placesitem.cpp @@ -113,6 +113,7 @@ void PlacesItem::updateDeviceInfo(const QString &udi) if (m_device.isValid()) { m_access = m_device.as(); m_iconName = m_device.icon(); + m_iconPath = QString("qrc:/images/%1.svg").arg(m_iconName); m_displayName = m_device.displayName(); if (m_access) { diff --git a/model/placesmodel.cpp b/model/placesmodel.cpp index 2eb70b1..0b8834c 100644 --- a/model/placesmodel.cpp +++ b/model/placesmodel.cpp @@ -116,7 +116,7 @@ PlacesModel::~PlacesModel() QHash PlacesModel::roleNames() const { - QHash roleNames; // = QAbstractItemModel::roleNames(); + QHash roleNames; roleNames[PlacesModel::NameRole] = "name"; roleNames[PlacesModel::IconNameRole] = "icon"; roleNames[PlacesModel::IconPathRole] = "iconPath"; diff --git a/qml.qrc b/qml.qrc index 12227de..9b1ade1 100644 --- a/qml.qrc +++ b/qml.qrc @@ -29,5 +29,7 @@ qml/GlobalSettings.qml qml/FolderGridItem.qml qml/Dialogs/CreateFolderDialog.qml + images/drive-harddisk.svg + images/drive-harddisk-root.svg diff --git a/qml/FolderGridView.qml b/qml/FolderGridView.qml index 3e3ecbc..fefd686 100644 --- a/qml/FolderGridView.qml +++ b/qml/FolderGridView.qml @@ -297,7 +297,9 @@ GridView { if (control.ctrlPressed) { dirModel.toggleSelected(hoveredItem.index) } else { - dirModel.clearSelection() + if (mouse.button == Qt.LeftButton) + dirModel.clearSelection() + dirModel.setSelected(hoveredItem.index) } } diff --git a/qml/FolderListView.qml b/qml/FolderListView.qml index c04f97e..2066116 100644 --- a/qml/FolderListView.qml +++ b/qml/FolderListView.qml @@ -27,7 +27,7 @@ ListView { property Item editor: null property int anchorIndex: 0 - property var itemHeight: FishUI.Units.fontMetrics.height * 2 + FishUI.Units.largeSpacing + property var itemHeight: FishUI.Units.fontMetrics.height * 2 + FishUI.Units.smallSpacing property variant cachedRectangleSelection: null @@ -214,7 +214,9 @@ ListView { if (control.ctrlPressed) { dirModel.toggleSelected(hoveredItem.index) } else { - dirModel.clearSelection() + if (mouse.button == Qt.LeftButton) + dirModel.clearSelection() + dirModel.setSelected(hoveredItem.index) } } @@ -245,7 +247,7 @@ ListView { control.shiftPressed = (mouse.modifiers & Qt.ShiftModifier) var cPos = mapToItem(control.contentItem, mouse.x, mouse.y) - var item = control.itemAt(mouse.x, mouse.y + control.contentY) + var item = control.itemAt(mouse.x - control.leftMargin, mouse.y + control.contentY) var leftEdge = Math.min(control.contentX, control.originX) if (!item || item.blank) { @@ -347,8 +349,8 @@ ListView { function rectangleSelect(x, y, width, height) { var indexes = [] for (var i = y; i <= y + height; i += 10) { - const index = control.indexAt(x, i) - if(!indexes.includes(index) && index > -1 && index< control.count) + const index = control.indexAt(control.leftMargin, i) + if(!indexes.includes(index) && index > -1 && index < control.count) indexes.push(index) } cachedRectangleSelection = indexes diff --git a/qml/FolderPage.qml b/qml/FolderPage.qml index 121785f..11ce93e 100644 --- a/qml/FolderPage.qml +++ b/qml/FolderPage.qml @@ -181,7 +181,7 @@ Item { id: _folderListView model: dirModel - topMargin: FishUI.Units.largeSpacing + topMargin: FishUI.Units.smallSpacing leftMargin: FishUI.Units.largeSpacing rightMargin: FishUI.Units.largeSpacing + FishUI.Theme.smallRadius spacing: FishUI.Units.largeSpacing