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-qtquick-window2,
qml-module-qtquick-shapes,
qml-module-qtquick-dialogs,
${misc:Depends},
${shlibs:Depends}
Description: CutefishOS File Manager

View file

@ -424,6 +424,11 @@ QString FolderModel::statusText()
return tr("%1 items").arg(m_dirModel->rowCount());
}
int FolderModel::selectionCound() const
{
return m_selectionModel->selectedIndexes().size();
}
QString FolderModel::homePath() const
{
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)
{
m_dragHotSpotScrollOffset.setX(x);
@ -898,6 +911,7 @@ void FolderModel::selectionChanged(const QItemSelection &selected, const QItemSe
// 选中状态信息
emit statusTextChanged();
emit selectionCoundChanged();
}
void FolderModel::dragSelectedInternal(int x, int y)

View file

@ -104,6 +104,7 @@ public:
KFileItem rootItem() const;
QString statusText();
int selectionCound() const;
Q_INVOKABLE QString homePath() const;
Q_INVOKABLE QString desktopPath() const;
@ -137,6 +138,7 @@ public:
Q_INVOKABLE void deleteSelected();
Q_INVOKABLE void moveSelectedToTrash();
Q_INVOKABLE void emptyTrash();
Q_INVOKABLE void keyDeletePress();
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);
@ -164,6 +166,7 @@ signals:
void viewAdapterChanged();
void statusTextChanged();
void isDesktopChanged();
void selectionCoundChanged();
private slots:
void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);

View file

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

View file

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