diff options
| author | Gleb Kasachou <[email protected]> | 2025-09-07 13:24:28 +0300 |
|---|---|---|
| committer | Méven Car <[email protected]> | 2025-09-07 10:24:28 +0000 |
| commit | bfa9c13cb24da62bea8d45f9f99a884a50a039a3 (patch) | |
| tree | e6e416358149fc2ea97578d426182df1ae7361ea /src/dolphinmainwindow.cpp | |
| parent | 5d66b4f5ecce950cd6f643fa27463b733bfc5c66 (diff) | |
Add support for Redo operations
This MR updates Dolphin to support redo functionality added in KIO's FileUndoManager. It enables triggering redo operations from the user interface and ensures appropriate integration with the undo/redo command flow.
Require: [!1941](https://invent.kde.org/frameworks/kio/-/merge_requests/1941)
BUG: 451746
Diffstat (limited to 'src/dolphinmainwindow.cpp')
| -rw-r--r-- | src/dolphinmainwindow.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 917aa42ce..f7ca69553 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -156,6 +156,10 @@ DolphinMainWindow::DolphinMainWindow() connect(undoManager, &KIO::FileUndoManager::undoAvailable, this, &DolphinMainWindow::slotUndoAvailable); connect(undoManager, &KIO::FileUndoManager::undoTextChanged, this, &DolphinMainWindow::slotUndoTextChanged); +#if KIO_VERSION >= QT_VERSION_CHECK(6, 17, 0) + connect(undoManager, &KIO::FileUndoManager::redoAvailable, this, &DolphinMainWindow::slotRedoAvailable); + connect(undoManager, &KIO::FileUndoManager::redoTextChanged, this, &DolphinMainWindow::slotRedoTextChanged); +#endif connect(undoManager, &KIO::FileUndoManager::jobRecordingStarted, this, &DolphinMainWindow::clearStatusBar); connect(undoManager, &KIO::FileUndoManager::jobRecordingFinished, this, &DolphinMainWindow::showCommand); @@ -891,6 +895,31 @@ void DolphinMainWindow::undo() KIO::FileUndoManager::self()->undo(); } +#if KIO_VERSION >= QT_VERSION_CHECK(6, 17, 0) +void DolphinMainWindow::slotRedoAvailable(bool available) +{ + QAction *redoAction = actionCollection()->action(KStandardAction::name(KStandardAction::Redo)); + if (redoAction) { + redoAction->setEnabled(available); + } +} + +void DolphinMainWindow::slotRedoTextChanged(const QString &text) +{ + QAction *redoAction = actionCollection()->action(KStandardAction::name(KStandardAction::Redo)); + if (redoAction) { + redoAction->setText(text); + } +} + +void DolphinMainWindow::redo() +{ + clearStatusBar(); + KIO::FileUndoManager::self()->uiInterface()->setParentWidget(this); + KIO::FileUndoManager::self()->redo(); +} +#endif + void DolphinMainWindow::cut() { if (m_activeViewContainer->view()->selectedItems().isEmpty()) { @@ -1554,6 +1583,9 @@ void DolphinMainWindow::updateHamburgerMenu() } menu->addAction(ac->action(QStringLiteral("basic_actions"))); menu->addAction(ac->action(KStandardAction::name(KStandardAction::Undo))); +#if KIO_VERSION >= QT_VERSION_CHECK(6, 17, 0) + menu->addAction(ac->action(KStandardAction::name(KStandardAction::Redo))); +#endif if (!toolBar()->isVisible() || (!toolbarActions.contains(ac->action(QStringLiteral("toggle_search"))) && !toolbarActions.contains(ac->action(QStringLiteral("open_preferred_search_tool"))))) { @@ -1813,6 +1845,9 @@ void DolphinMainWindow::setupActions() // setup 'Edit' menu KStandardAction::undo(this, &DolphinMainWindow::undo, actionCollection()); +#if KIO_VERSION >= QT_VERSION_CHECK(6, 17, 0) + KStandardAction::redo(this, &DolphinMainWindow::redo, actionCollection()); +#endif // i18n: This will be the last paragraph for the whatsthis for all three: // Cut, Copy and Paste @@ -2094,6 +2129,18 @@ void DolphinMainWindow::setupActions() "will ask for your confirmation beforehand.")); undoAction->setEnabled(false); // undo should be disabled by default +#if KIO_VERSION >= QT_VERSION_CHECK(6, 17, 0) + auto redoAction = actionCollection()->action(KStandardAction::name(KStandardAction::Redo)); + redoAction->setWhatsThis(xi18nc("@info:whatsthis", + "This redoes " + "the last change you undid.<nl/>" + "Such changes include <interface>creating</interface>, <interface>renaming</interface> " + "and <interface>moving</interface> files or folders to a different location " + "or to the <filename>Trash</filename>.<nl/>Any changes that cannot be undone " + "will ask for your confirmation beforehand.")); + redoAction->setEnabled(false); // redo should be disabled by default +#endif + { QScopedPointer<QAction> forwardAction(KStandardAction::forward(nullptr, nullptr, nullptr)); m_forwardAction = new KToolBarPopupAction(forwardAction->icon(), forwardAction->text(), actionCollection()); |
