Support delete keypress

This commit is contained in:
cutefishd 2021-04-01 10:25:20 +08:00
parent fde2b90d3f
commit cffa47cf6e
5 changed files with 21 additions and 2 deletions

1
debian/control vendored
View file

@ -26,6 +26,7 @@ Depends: qml-module-qtquick-controls2,
qml-module-qtqml, qml-module-qtqml,
qml-module-qtquick-window2, qml-module-qtquick-window2,
qml-module-qtquick-shapes, qml-module-qtquick-shapes,
qml-module-qtquick-dialogs,
${misc:Depends}, ${misc:Depends},
${shlibs:Depends} ${shlibs:Depends}
Description: CutefishOS File Manager Description: CutefishOS File Manager

View file

@ -424,6 +424,11 @@ QString FolderModel::statusText()
return tr("%1 items").arg(m_dirModel->rowCount()); return tr("%1 items").arg(m_dirModel->rowCount());
} }
int FolderModel::selectionCound() const
{
return m_selectionModel->selectedIndexes().size();
}
QString FolderModel::homePath() const QString FolderModel::homePath() const
{ {
return QStandardPaths::writableLocation(QStandardPaths::HomeLocation); return QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
@ -722,6 +727,14 @@ void FolderModel::emptyTrash()
} }
} }
void FolderModel::keyDeletePress()
{
if (!m_selectionModel->hasSelection())
return;
resolvedUrl().scheme() == "trash" ? deleteSelected() : moveSelectedToTrash();
}
void FolderModel::setDragHotSpotScrollOffset(int x, int y) void FolderModel::setDragHotSpotScrollOffset(int x, int y)
{ {
m_dragHotSpotScrollOffset.setX(x); m_dragHotSpotScrollOffset.setX(x);
@ -898,6 +911,7 @@ void FolderModel::selectionChanged(const QItemSelection &selected, const QItemSe
// 选中状态信息 // 选中状态信息
emit statusTextChanged(); emit statusTextChanged();
emit selectionCoundChanged();
} }
void FolderModel::dragSelectedInternal(int x, int y) void FolderModel::dragSelectedInternal(int x, int y)

View file

@ -104,6 +104,7 @@ public:
KFileItem rootItem() const; KFileItem rootItem() const;
QString statusText(); QString statusText();
int selectionCound() const;
Q_INVOKABLE QString homePath() const; Q_INVOKABLE QString homePath() const;
Q_INVOKABLE QString desktopPath() const; Q_INVOKABLE QString desktopPath() const;
@ -137,6 +138,7 @@ public:
Q_INVOKABLE void deleteSelected(); Q_INVOKABLE void deleteSelected();
Q_INVOKABLE void moveSelectedToTrash(); Q_INVOKABLE void moveSelectedToTrash();
Q_INVOKABLE void emptyTrash(); Q_INVOKABLE void emptyTrash();
Q_INVOKABLE void keyDeletePress();
Q_INVOKABLE void setDragHotSpotScrollOffset(int x, int y); Q_INVOKABLE void setDragHotSpotScrollOffset(int x, int y);
Q_INVOKABLE void addItemDragImage(int row, int x, int y, int width, int height, const QVariant &image); Q_INVOKABLE void addItemDragImage(int row, int x, int y, int width, int height, const QVariant &image);
@ -164,6 +166,7 @@ signals:
void viewAdapterChanged(); void viewAdapterChanged();
void statusTextChanged(); void statusTextChanged();
void isDesktopChanged(); void isDesktopChanged();
void selectionCoundChanged();
private slots: private slots:
void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected); void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);

View file

@ -96,8 +96,7 @@ Item {
anchors.topMargin: Meui.Units.smallSpacing anchors.topMargin: Meui.Units.smallSpacing
maximumLineCount: 2 maximumLineCount: 2
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
width: Math.round(Math.min(_label.implicitWidth + Meui.Units.smallSpacing, width: parent.width - Meui.Units.largeSpacing * 2
parent.width - Meui.Units.largeSpacing * 2))
textFormat: Text.PlainText textFormat: Text.PlainText
elide: Qt.ElideRight elide: Qt.ElideRight
wrapMode: Text.Wrap wrapMode: Text.Wrap

View file

@ -215,6 +215,8 @@ Item {
folderModel.selectAll() folderModel.selectAll()
else if (event.key === Qt.Key_Backspace) else if (event.key === Qt.Key_Backspace)
folderModel.up() folderModel.up()
else if (event.key === Qt.Key_Delete)
folderModel.keyDeletePress()
} }
} }