From 3a1c12207f6bd443bc746858338dfff5cf2d9b1d Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 17 Mar 2020 10:03:32 +0100 Subject: [PATCH] Gui: [skip ci] add slot to update editor related commands --- src/Gui/MainWindow.cpp | 25 +++++++++++++++++++++++++ src/Gui/MainWindow.h | 4 ++++ 2 files changed, 29 insertions(+) diff --git a/src/Gui/MainWindow.cpp b/src/Gui/MainWindow.cpp index f7f60d55f6..484295f5b8 100644 --- a/src/Gui/MainWindow.cpp +++ b/src/Gui/MainWindow.cpp @@ -347,6 +347,10 @@ MainWindow::MainWindow(QWidget * parent, Qt::WindowFlags f) d->activityTimer->setSingleShot(false); d->activityTimer->start(150); + // update view-sensitive commands when clipboard has changed + QClipboard *clipbd = QApplication::clipboard(); + connect(clipbd, SIGNAL(dataChanged()), this, SLOT(updateEditorActions())); + // show main window timer d->visibleTimer = new QTimer(this); d->visibleTimer->setObjectName(QString::fromLatin1("visibleTimer")); @@ -1336,6 +1340,27 @@ void MainWindow::_updateActions() d->actionUpdateDelay = 0; } +void MainWindow::updateEditorActions() +{ + Command* cmd = nullptr; + CommandManager& mgr = Application::Instance->commandManager(); + + cmd = mgr.getCommandByName("Std_Cut"); + if (cmd) cmd->testActive(); + + cmd = mgr.getCommandByName("Std_Copy"); + if (cmd) cmd->testActive(); + + cmd = mgr.getCommandByName("Std_Paste"); + if (cmd) cmd->testActive(); + + cmd = mgr.getCommandByName("Std_Undo"); + if (cmd) cmd->testActive(); + + cmd = mgr.getCommandByName("Std_Redo"); + if (cmd) cmd->testActive(); +} + void MainWindow::switchToTopLevelMode() { QList dw = this->findChildren(); diff --git a/src/Gui/MainWindow.h b/src/Gui/MainWindow.h index 1bafcaa2de..c27bc406b5 100644 --- a/src/Gui/MainWindow.h +++ b/src/Gui/MainWindow.h @@ -185,6 +185,10 @@ public: public Q_SLOTS: + /** + * Updates the standard actions of a text editor such as Cut, Copy, Paste, Undo and Redo. + */ + void updateEditorActions(); /** * Sets text to the pane in the status bar. */