From b38394da6848568123330ac5164df26fdc9c4a77 Mon Sep 17 00:00:00 2001 From: B0cho Date: Fri, 30 May 2025 18:49:39 +0200 Subject: [PATCH 1/3] CORE: 'Std_ToggleSkipRecompute' implemented, no icon --- src/Gui/CommandFeat.cpp | 61 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/src/Gui/CommandFeat.cpp b/src/Gui/CommandFeat.cpp index a16c801daf..05af21cfca 100644 --- a/src/Gui/CommandFeat.cpp +++ b/src/Gui/CommandFeat.cpp @@ -29,6 +29,7 @@ #include #include #include "Application.h" +#include "Action.h" #include "cet_lut.hpp" #include "CommandT.h" #include "DockWindowManager.h" @@ -298,6 +299,65 @@ void StdCmdSendToPythonConsole::activated(int iMsg) } +//=========================================================================== +// Std_ToggleSkipRecompute +//=========================================================================== + +DEF_STD_CMD_AC(StdCmdToggleSkipRecompute) + +StdCmdToggleSkipRecompute::StdCmdToggleSkipRecompute() + : Command("Std_ToggleSkipRecompute") +{ + sGroup = "File"; + sMenuText = QT_TR_NOOP("Skip Recomputes"); + + static std::string toolTip = QT_TR_NOOP("Enables or disables the recomputations of the document"); + + sToolTipText = toolTip.c_str(); + sStatusTip = sToolTipText; + sWhatsThis = "Std_ToggleSkipRecompute"; + //sPixmap = "Std_ToggleSkipRecomputes"; // TODO: to be added when icon is provided + eType = AlterDoc; +} + +Gui::Action* StdCmdToggleSkipRecompute::createAction() +{ + Action* pcAction = Command::createAction(); + pcAction->setCheckable(true); + pcAction->setIcon(QIcon()); // TODO: to be deleted, when icon is provided + _pcAction = pcAction; + isActive(); + return pcAction; +} + +void StdCmdToggleSkipRecompute::activated(int iMsg) +{ + const auto doc = this->getDocument(); + if (doc == nullptr) { + return; + } + + Command::openCommand(QT_TRANSLATE_NOOP("Command", "Skip recomputes")); + doc->setStatus(App::Document::SkipRecompute, (bool) iMsg); + if (_pcAction) { + _pcAction->setChecked((bool) iMsg); + } + Command::commitCommand(); +} + +bool StdCmdToggleSkipRecompute::isActive() +{ + const auto doc = this->getDocument(); + if (doc == nullptr) { + return false; + } + + const bool skipRecomputeStatus = doc->testStatus(App::Document::SkipRecompute); + if (_pcAction && _pcAction->isChecked() != skipRecomputeStatus) { + _pcAction->setChecked(skipRecomputeStatus); + } + return true; +} namespace Gui { @@ -309,6 +369,7 @@ void CreateFeatCommands() rcCmdMgr.addCommand(new StdCmdToggleFreeze()); rcCmdMgr.addCommand(new StdCmdRandomColor()); rcCmdMgr.addCommand(new StdCmdSendToPythonConsole()); + rcCmdMgr.addCommand(new StdCmdToggleSkipRecompute()); } } // namespace Gui From 62e5d0df2312349c18a55b3f82e4bb47ff80fcf3 Mon Sep 17 00:00:00 2001 From: B0cho Date: Fri, 30 May 2025 18:51:58 +0200 Subject: [PATCH 2/3] CORE: Tree context menu upgraded with 'Std_ToggleSkipRecompute' --- src/Gui/Tree.cpp | 11 +++++++++-- src/Gui/Tree.h | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Gui/Tree.cpp b/src/Gui/Tree.cpp index 919c2ffaa9..0bb3c931ee 100644 --- a/src/Gui/Tree.cpp +++ b/src/Gui/Tree.cpp @@ -668,6 +668,7 @@ TreeWidget::TreeWidget(const char* name, QWidget* parent) this->skipRecomputeAction->setCheckable(true); connect(this->skipRecomputeAction, &QAction::toggled, this, &TreeWidget::onSkipRecompute); + this->skipRecomputeCommand = Gui::Application::Instance->commandManager().getCommandByName("Std_ToggleSkipRecompute"); this->allowPartialRecomputeAction = new QAction(this); this->allowPartialRecomputeAction->setCheckable(true); @@ -1053,8 +1054,14 @@ void TreeWidget::contextMenuEvent(QContextMenuEvent* e) } } contextMenu.addAction(this->selectDependentsAction); - this->skipRecomputeAction->setChecked(doc->testStatus(App::Document::SkipRecompute)); - contextMenu.addAction(this->skipRecomputeAction); + if (doc == App::GetApplication().getActiveDocument() && this->skipRecomputeCommand != nullptr) { + // if active document is selected, use Command + this->skipRecomputeCommand->addTo(&contextMenu); + } else { + // if other document is selected or Command load fails, edit selected Document directly + this->skipRecomputeAction->setChecked(doc->testStatus(App::Document::SkipRecompute)); + contextMenu.addAction(this->skipRecomputeAction); + } this->allowPartialRecomputeAction->setChecked(doc->testStatus(App::Document::AllowPartialRecompute)); if (doc->testStatus(App::Document::SkipRecompute)) contextMenu.addAction(this->allowPartialRecomputeAction); diff --git a/src/Gui/Tree.h b/src/Gui/Tree.h index 1c0c9dada9..72a048ef62 100644 --- a/src/Gui/Tree.h +++ b/src/Gui/Tree.h @@ -49,6 +49,7 @@ using DocumentObjectDataPtr = std::shared_ptr; class TreeWidgetItemDelegate; class DocumentItem; +class Command; GuiExport bool isTreeViewDragging(); @@ -242,6 +243,7 @@ private: QAction* closeDocAction; QAction* searchObjectsAction; QAction* openFileLocationAction; + Command* skipRecomputeCommand; QTreeWidgetItem *contextItem; App::DocumentObject *searchObject; Gui::Document *searchDoc; From 37a653ef33593f1f470b68eed1515f594ec9ffc2 Mon Sep 17 00:00:00 2001 From: Benjamin Nauck Date: Mon, 4 Aug 2025 19:17:15 +0200 Subject: [PATCH 3/3] Gui: Remove toggleskiprecomputes todos --- src/Gui/CommandFeat.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Gui/CommandFeat.cpp b/src/Gui/CommandFeat.cpp index 05af21cfca..371d430c5e 100644 --- a/src/Gui/CommandFeat.cpp +++ b/src/Gui/CommandFeat.cpp @@ -316,7 +316,6 @@ StdCmdToggleSkipRecompute::StdCmdToggleSkipRecompute() sToolTipText = toolTip.c_str(); sStatusTip = sToolTipText; sWhatsThis = "Std_ToggleSkipRecompute"; - //sPixmap = "Std_ToggleSkipRecomputes"; // TODO: to be added when icon is provided eType = AlterDoc; } @@ -324,7 +323,7 @@ Gui::Action* StdCmdToggleSkipRecompute::createAction() { Action* pcAction = Command::createAction(); pcAction->setCheckable(true); - pcAction->setIcon(QIcon()); // TODO: to be deleted, when icon is provided + pcAction->setIcon(QIcon()); _pcAction = pcAction; isActive(); return pcAction;