From 99b76afe5e7f68eb4beca3f54d42d32bcbf8d652 Mon Sep 17 00:00:00 2001 From: reionwong Date: Wed, 1 Sep 2021 04:39:44 +0800 Subject: [PATCH] Sort Mode finished --- helper/shortcut.cpp | 2 + helper/shortcut.h | 1 + model/foldermodel.cpp | 5 ++ model/foldermodel.h | 1 + qml/FolderPage.qml | 4 ++ qml/GlobalSettings.qml | 1 + qml/OptionsMenu.qml | 118 +++++++++++++++++++++++++---------------- 7 files changed, 86 insertions(+), 46 deletions(-) diff --git a/helper/shortcut.cpp b/helper/shortcut.cpp index 66de69e..e416179 100644 --- a/helper/shortcut.cpp +++ b/helper/shortcut.cpp @@ -65,6 +65,8 @@ bool ShortCut::eventFilter(QObject *obj, QEvent *e) emit backspace(); } else if (keyEvent->key() == Qt::Key_Delete) { emit deleteFile(); + } else if (keyEvent->key() == Qt::Key_F5) { + emit refresh(); } } diff --git a/helper/shortcut.h b/helper/shortcut.h index d4c9c80..0711ddf 100644 --- a/helper/shortcut.h +++ b/helper/shortcut.h @@ -50,6 +50,7 @@ signals: void cut(); void paste(); void rename(); + void refresh(); void openPathEditor(); void selectAll(); void backspace(); diff --git a/model/foldermodel.cpp b/model/foldermodel.cpp index 824002d..6230bec 100644 --- a/model/foldermodel.cpp +++ b/model/foldermodel.cpp @@ -517,6 +517,11 @@ void FolderModel::goForward() setUrl(url.toString()); } +void FolderModel::refresh() +{ + m_dirModel->dirLister()->updateDirectory(m_dirModel->dirLister()->url()); +} + bool FolderModel::supportSetAsWallpaper(const QString &mimeType) { if (mimeType == "image/jpeg" || mimeType == "image/png") diff --git a/model/foldermodel.h b/model/foldermodel.h index 6bf1672..3e81eb9 100644 --- a/model/foldermodel.h +++ b/model/foldermodel.h @@ -144,6 +144,7 @@ public: Q_INVOKABLE void up(); Q_INVOKABLE void goBack(); Q_INVOKABLE void goForward(); + Q_INVOKABLE void refresh(); Q_INVOKABLE bool supportSetAsWallpaper(const QString &mimeType); Q_INVOKABLE int fileExtensionBoundary(int row); diff --git a/qml/FolderPage.qml b/qml/FolderPage.qml index addd1fe..dd5edd1 100644 --- a/qml/FolderPage.qml +++ b/qml/FolderPage.qml @@ -140,6 +140,7 @@ Item { FM.FolderModel { id: dirModel viewAdapter: viewAdapter + sortMode: settings.sortMode Component.onCompleted: { if (arg) @@ -375,6 +376,9 @@ Item { onDeleteFile: { dirModel.keyDeletePress() } + onRefresh: { + dirModel.refresh() + } } function openUrl(url) { diff --git a/qml/GlobalSettings.qml b/qml/GlobalSettings.qml index fbf6ef3..b580b1d 100644 --- a/qml/GlobalSettings.qml +++ b/qml/GlobalSettings.qml @@ -26,6 +26,7 @@ Settings { // Name, Date, Size property int orderBy: 0 + property int sortMode: 0 // UI property int width: 900 diff --git a/qml/OptionsMenu.qml b/qml/OptionsMenu.qml index 6515e93..5e63f34 100644 --- a/qml/OptionsMenu.qml +++ b/qml/OptionsMenu.qml @@ -101,25 +101,27 @@ FishUI.DesktopMenu { onTriggered: settings.viewMethod = 0 } - // MenuSeparator {} + MenuSeparator { + Layout.fillWidth: true + } MenuItem { Layout.fillWidth: true - Image { - id: orderByNameIcon - anchors.verticalCenter: parent.verticalCenter - anchors.left: parent.left - anchors.leftMargin: FishUI.Units.largeSpacing - source: FishUI.Theme.darkMode ? "qrc:/images/dark/order_by_name.svg" : "qrc:/images/light/order_by_name.svg" - sourceSize: Qt.size(width, height) - width: 22 - height: width - smooth: false - } +// Image { +// id: orderByNameIcon +// anchors.verticalCenter: parent.verticalCenter +// anchors.left: parent.left +// anchors.leftMargin: FishUI.Units.largeSpacing +// source: FishUI.Theme.darkMode ? "qrc:/images/dark/order_by_name.svg" : "qrc:/images/light/order_by_name.svg" +// sourceSize: Qt.size(width, height) +// width: 22 +// height: width +// smooth: false +// } Text { - anchors.left: orderByNameIcon.right + anchors.left: parent.left anchors.verticalCenter: parent.verticalCenter anchors.leftMargin: FishUI.Units.largeSpacing text: qsTr("Name") @@ -130,34 +132,34 @@ FishUI.DesktopMenu { anchors.verticalCenter: parent.verticalCenter anchors.right: parent.right anchors.rightMargin: FishUI.Units.largeSpacing * 1.5 - source: FishUI.Theme.darkMode ? "qrc:/images/dark/up.svg" : "qrc:/images/light/up.svg" + source: FishUI.Theme.darkMode ? "qrc:/images/dark/checked.svg" : "qrc:/images/light/checked.svg" sourceSize: Qt.size(width, height) height: width width: 22 - visible: settings.orderBy === 0 + visible: settings.sortMode === 0 smooth: false } - onTriggered: settings.orderBy = 0 + onTriggered: settings.sortMode = 0 } MenuItem { Layout.fillWidth: true - Image { - id: orderByDateIcon - anchors.verticalCenter: parent.verticalCenter - anchors.left: parent.left - anchors.leftMargin: FishUI.Units.largeSpacing - source: FishUI.Theme.darkMode ? "qrc:/images/dark/date.svg" : "qrc:/images/light/date.svg" - sourceSize: Qt.size(width, height) - width: 22 - height: width - smooth: false - } +// Image { +// id: orderByDateIcon +// anchors.verticalCenter: parent.verticalCenter +// anchors.left: parent.left +// anchors.leftMargin: FishUI.Units.largeSpacing +// source: FishUI.Theme.darkMode ? "qrc:/images/dark/date.svg" : "qrc:/images/light/date.svg" +// sourceSize: Qt.size(width, height) +// width: 22 +// height: width +// smooth: false +// } Text { - anchors.left: orderByDateIcon.right + anchors.left: parent.left anchors.verticalCenter: parent.verticalCenter anchors.leftMargin: FishUI.Units.largeSpacing text: qsTr("Date") @@ -168,34 +170,58 @@ FishUI.DesktopMenu { anchors.verticalCenter: parent.verticalCenter anchors.right: parent.right anchors.rightMargin: FishUI.Units.largeSpacing * 1.5 - source: FishUI.Theme.darkMode ? "qrc:/images/dark/up.svg" : "qrc:/images/light/up.svg" + source: FishUI.Theme.darkMode ? "qrc:/images/dark/checked.svg" : "qrc:/images/light/checked.svg" sourceSize: Qt.size(width, height) width: 22 height: width - visible: settings.orderBy === 1 + visible: settings.sortMode === 2 smooth: false } - onTriggered: settings.orderBy = 1 + onTriggered: settings.sortMode = 2 + } + + MenuItem { + Text { + anchors.left: parent.left + anchors.verticalCenter: parent.verticalCenter + anchors.leftMargin: FishUI.Units.largeSpacing + text: qsTr("Type") + color: FishUI.Theme.textColor + } + + Image { + anchors.verticalCenter: parent.verticalCenter + anchors.right: parent.right + anchors.rightMargin: FishUI.Units.largeSpacing * 1.5 + source: FishUI.Theme.darkMode ? "qrc:/images/dark/checked.svg" : "qrc:/images/light/checked.svg" + sourceSize: Qt.size(width, height) + width: 22 + height: width + visible: settings.sortMode === 6 + smooth: false + } + + onTriggered: settings.sortMode = 6 } MenuItem { Layout.fillWidth: true - Image { - id: orderBySizeIcon - anchors.verticalCenter: parent.verticalCenter - anchors.left: parent.left - anchors.leftMargin: FishUI.Units.largeSpacing - source: FishUI.Theme.darkMode ? "qrc:/images/dark/size.svg" : "qrc:/images/light/size.svg" - sourceSize: Qt.size(width, height) - width: 22 - height: width - smooth: false - } +// Image { +// id: orderBySizeIcon +// anchors.verticalCenter: parent.verticalCenter +// anchors.left: parent.left +// anchors.leftMargin: FishUI.Units.largeSpacing +// source: FishUI.Theme.darkMode ? "qrc:/images/dark/size.svg" : "qrc:/images/light/size.svg" +// sourceSize: Qt.size(width, height) +// width: 22 +// height: width +// smooth: false +// } Text { - anchors.left: orderBySizeIcon.right + anchors.left: parent.left anchors.verticalCenter: parent.verticalCenter anchors.leftMargin: FishUI.Units.largeSpacing text: qsTr("Size") @@ -206,14 +232,14 @@ FishUI.DesktopMenu { anchors.verticalCenter: parent.verticalCenter anchors.right: parent.right anchors.rightMargin: FishUI.Units.largeSpacing * 1.5 - source: FishUI.Theme.darkMode ? "qrc:/images/dark/up.svg" : "qrc:/images/light/up.svg" + source: FishUI.Theme.darkMode ? "qrc:/images/dark/checked.svg" : "qrc:/images/light/checked.svg" sourceSize: Qt.size(width, height) width: 22 height: width - visible: settings.orderBy === 2 + visible: settings.sortMode === 1 smooth: false } - onTriggered: settings.orderBy = 2 + onTriggered: settings.sortMode = 1 } }