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();
} else if (keyEvent->key() == Qt::Key_Delete) {
emit deleteFile();
} else if (keyEvent->key() == Qt::Key_F5) {
emit refresh();
}
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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