Merge pull request #21723 from B0cho/CORE_Skip_recompute_command
CORE: 'Skip recompute' command added
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
#include <App/GroupExtension.h>
|
||||
#include <App/Part.h>
|
||||
#include "Application.h"
|
||||
#include "Action.h"
|
||||
#include "cet_lut.hpp"
|
||||
#include "CommandT.h"
|
||||
#include "DockWindowManager.h"
|
||||
@@ -298,6 +299,64 @@ 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";
|
||||
eType = AlterDoc;
|
||||
}
|
||||
|
||||
Gui::Action* StdCmdToggleSkipRecompute::createAction()
|
||||
{
|
||||
Action* pcAction = Command::createAction();
|
||||
pcAction->setCheckable(true);
|
||||
pcAction->setIcon(QIcon());
|
||||
_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 +368,7 @@ void CreateFeatCommands()
|
||||
rcCmdMgr.addCommand(new StdCmdToggleFreeze());
|
||||
rcCmdMgr.addCommand(new StdCmdRandomColor());
|
||||
rcCmdMgr.addCommand(new StdCmdSendToPythonConsole());
|
||||
rcCmdMgr.addCommand(new StdCmdToggleSkipRecompute());
|
||||
}
|
||||
|
||||
} // namespace Gui
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -49,6 +49,7 @@ using DocumentObjectDataPtr = std::shared_ptr<DocumentObjectData>;
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user