feat(short): support undo

This commit is contained in:
kateleet 2021-12-26 17:14:45 +08:00
parent 1eb918beb0
commit 7592e048ce
6 changed files with 17 additions and 0 deletions

View file

@ -73,6 +73,8 @@ bool ShortCut::eventFilter(QObject *obj, QEvent *e)
emit refresh(); emit refresh();
} else if (keyEvent->key() == Qt::Key_H && keyEvent->modifiers() & Qt::ControlModifier) { } else if (keyEvent->key() == Qt::Key_H && keyEvent->modifiers() & Qt::ControlModifier) {
emit showHidden(); emit showHidden();
} else if (keyEvent->key() == Qt::Key_Z && keyEvent->modifiers() & Qt::ControlModifier) {
emit undo();
} else if (keyEvent->key() >= Qt::Key_A && keyEvent->key() <= Qt::Key_Z) { } else if (keyEvent->key() >= Qt::Key_A && keyEvent->key() <= Qt::Key_Z) {
// Handle select // Handle select
// KeyboardSearchManager::self()->addKeys(keyEvent->text()); // KeyboardSearchManager::self()->addKeys(keyEvent->text());

View file

@ -47,6 +47,7 @@ signals:
void showHidden(); void showHidden();
void keyPressed(const QString &text); void keyPressed(const QString &text);
void close(); void close();
void undo();
protected: protected:
bool eventFilter(QObject *obj, QEvent *e) override; bool eventFilter(QObject *obj, QEvent *e) override;

View file

@ -729,6 +729,13 @@ void FolderModel::refresh()
m_dirModel->dirLister()->updateDirectory(m_dirModel->dirLister()->url()); m_dirModel->dirLister()->updateDirectory(m_dirModel->dirLister()->url());
} }
void FolderModel::undo()
{
if (KIO::FileUndoManager::self()->undoAvailable()) {
KIO::FileUndoManager::self()->undo();
}
}
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

@ -166,6 +166,7 @@ public:
Q_INVOKABLE void goBack(); Q_INVOKABLE void goBack();
Q_INVOKABLE void goForward(); Q_INVOKABLE void goForward();
Q_INVOKABLE void refresh(); Q_INVOKABLE void refresh();
Q_INVOKABLE void undo();
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

@ -141,6 +141,9 @@ Item {
onShowHidden: { onShowHidden: {
dirModel.showHiddenFiles = !dirModel.showHiddenFiles dirModel.showHiddenFiles = !dirModel.showHiddenFiles
} }
onUndo: {
dirModel.undo()
}
} }
Component { Component {

View file

@ -431,6 +431,9 @@ Item {
onClose: { onClose: {
root.close() root.close()
} }
onUndo: {
dirModel.undo()
}
} }
function openUrl(url) { function openUrl(url) {