Sort Mode finished

This commit is contained in:
reionwong 2021-09-01 04:39:44 +08:00
parent a11f2aac1c
commit 99b76afe5e
7 changed files with 86 additions and 46 deletions

View file

@ -65,6 +65,8 @@ bool ShortCut::eventFilter(QObject *obj, QEvent *e)
emit backspace(); emit backspace();
} else if (keyEvent->key() == Qt::Key_Delete) { } else if (keyEvent->key() == Qt::Key_Delete) {
emit deleteFile(); emit deleteFile();
} else if (keyEvent->key() == Qt::Key_F5) {
emit refresh();
} }
} }

View file

@ -50,6 +50,7 @@ signals:
void cut(); void cut();
void paste(); void paste();
void rename(); void rename();
void refresh();
void openPathEditor(); void openPathEditor();
void selectAll(); void selectAll();
void backspace(); void backspace();

View file

@ -517,6 +517,11 @@ void FolderModel::goForward()
setUrl(url.toString()); setUrl(url.toString());
} }
void FolderModel::refresh()
{
m_dirModel->dirLister()->updateDirectory(m_dirModel->dirLister()->url());
}
bool FolderModel::supportSetAsWallpaper(const QString &mimeType) bool FolderModel::supportSetAsWallpaper(const QString &mimeType)
{ {
if (mimeType == "image/jpeg" || mimeType == "image/png") if (mimeType == "image/jpeg" || mimeType == "image/png")

View file

@ -144,6 +144,7 @@ public:
Q_INVOKABLE void up(); Q_INVOKABLE void up();
Q_INVOKABLE void goBack(); Q_INVOKABLE void goBack();
Q_INVOKABLE void goForward(); Q_INVOKABLE void goForward();
Q_INVOKABLE void refresh();
Q_INVOKABLE bool supportSetAsWallpaper(const QString &mimeType); Q_INVOKABLE bool supportSetAsWallpaper(const QString &mimeType);
Q_INVOKABLE int fileExtensionBoundary(int row); Q_INVOKABLE int fileExtensionBoundary(int row);

View file

@ -140,6 +140,7 @@ Item {
FM.FolderModel { FM.FolderModel {
id: dirModel id: dirModel
viewAdapter: viewAdapter viewAdapter: viewAdapter
sortMode: settings.sortMode
Component.onCompleted: { Component.onCompleted: {
if (arg) if (arg)
@ -375,6 +376,9 @@ Item {
onDeleteFile: { onDeleteFile: {
dirModel.keyDeletePress() dirModel.keyDeletePress()
} }
onRefresh: {
dirModel.refresh()
}
} }
function openUrl(url) { function openUrl(url) {

View file

@ -26,6 +26,7 @@ Settings {
// Name, Date, Size // Name, Date, Size
property int orderBy: 0 property int orderBy: 0
property int sortMode: 0
// UI // UI
property int width: 900 property int width: 900

View file

@ -101,25 +101,27 @@ FishUI.DesktopMenu {
onTriggered: settings.viewMethod = 0 onTriggered: settings.viewMethod = 0
} }
// MenuSeparator {} MenuSeparator {
Layout.fillWidth: true
}
MenuItem { MenuItem {
Layout.fillWidth: true Layout.fillWidth: true
Image { // Image {
id: orderByNameIcon // id: orderByNameIcon
anchors.verticalCenter: parent.verticalCenter // anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left // anchors.left: parent.left
anchors.leftMargin: FishUI.Units.largeSpacing // anchors.leftMargin: FishUI.Units.largeSpacing
source: FishUI.Theme.darkMode ? "qrc:/images/dark/order_by_name.svg" : "qrc:/images/light/order_by_name.svg" // source: FishUI.Theme.darkMode ? "qrc:/images/dark/order_by_name.svg" : "qrc:/images/light/order_by_name.svg"
sourceSize: Qt.size(width, height) // sourceSize: Qt.size(width, height)
width: 22 // width: 22
height: width // height: width
smooth: false // smooth: false
} // }
Text { Text {
anchors.left: orderByNameIcon.right anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.leftMargin: FishUI.Units.largeSpacing anchors.leftMargin: FishUI.Units.largeSpacing
text: qsTr("Name") text: qsTr("Name")
@ -130,34 +132,34 @@ FishUI.DesktopMenu {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: FishUI.Units.largeSpacing * 1.5 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) sourceSize: Qt.size(width, height)
height: width height: width
width: 22 width: 22
visible: settings.orderBy === 0 visible: settings.sortMode === 0
smooth: false smooth: false
} }
onTriggered: settings.orderBy = 0 onTriggered: settings.sortMode = 0
} }
MenuItem { MenuItem {
Layout.fillWidth: true Layout.fillWidth: true
Image { // Image {
id: orderByDateIcon // id: orderByDateIcon
anchors.verticalCenter: parent.verticalCenter // anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left // anchors.left: parent.left
anchors.leftMargin: FishUI.Units.largeSpacing // anchors.leftMargin: FishUI.Units.largeSpacing
source: FishUI.Theme.darkMode ? "qrc:/images/dark/date.svg" : "qrc:/images/light/date.svg" // source: FishUI.Theme.darkMode ? "qrc:/images/dark/date.svg" : "qrc:/images/light/date.svg"
sourceSize: Qt.size(width, height) // sourceSize: Qt.size(width, height)
width: 22 // width: 22
height: width // height: width
smooth: false // smooth: false
} // }
Text { Text {
anchors.left: orderByDateIcon.right anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.leftMargin: FishUI.Units.largeSpacing anchors.leftMargin: FishUI.Units.largeSpacing
text: qsTr("Date") text: qsTr("Date")
@ -168,34 +170,58 @@ FishUI.DesktopMenu {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: FishUI.Units.largeSpacing * 1.5 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) sourceSize: Qt.size(width, height)
width: 22 width: 22
height: width height: width
visible: settings.orderBy === 1 visible: settings.sortMode === 2
smooth: false 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 { MenuItem {
Layout.fillWidth: true Layout.fillWidth: true
Image { // Image {
id: orderBySizeIcon // id: orderBySizeIcon
anchors.verticalCenter: parent.verticalCenter // anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left // anchors.left: parent.left
anchors.leftMargin: FishUI.Units.largeSpacing // anchors.leftMargin: FishUI.Units.largeSpacing
source: FishUI.Theme.darkMode ? "qrc:/images/dark/size.svg" : "qrc:/images/light/size.svg" // source: FishUI.Theme.darkMode ? "qrc:/images/dark/size.svg" : "qrc:/images/light/size.svg"
sourceSize: Qt.size(width, height) // sourceSize: Qt.size(width, height)
width: 22 // width: 22
height: width // height: width
smooth: false // smooth: false
} // }
Text { Text {
anchors.left: orderBySizeIcon.right anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.leftMargin: FishUI.Units.largeSpacing anchors.leftMargin: FishUI.Units.largeSpacing
text: qsTr("Size") text: qsTr("Size")
@ -206,14 +232,14 @@ FishUI.DesktopMenu {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: FishUI.Units.largeSpacing * 1.5 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) sourceSize: Qt.size(width, height)
width: 22 width: 22
height: width height: width
visible: settings.orderBy === 2 visible: settings.sortMode === 1
smooth: false smooth: false
} }
onTriggered: settings.orderBy = 2 onTriggered: settings.sortMode = 1
} }
} }