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();
} else if (keyEvent->key() == Qt::Key_H && keyEvent->modifiers() & Qt::ControlModifier) {
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) {
// Handle select
// KeyboardSearchManager::self()->addKeys(keyEvent->text());

View file

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

View file

@ -729,6 +729,13 @@ void FolderModel::refresh()
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)
{
if (mimeType == "image/jpeg" || mimeType == "image/png")

View file

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

View file

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

View file

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