Sketcher: Solver Message Widget simplification.

This commit is contained in:
Paddle
2023-03-10 21:46:21 +01:00
committed by abdullahtahiriyo
parent 0f4acc55be
commit 944c02f12b
4 changed files with 64 additions and 120 deletions

View File

@@ -56,8 +56,6 @@ TaskDlgEditSketch::TaskDlgEditSketch(ViewProviderSketch *sketchView)
Content.push_back(Constraints); Content.push_back(Constraints);
Content.push_back(Elements); Content.push_back(Elements);
if (!hGrp->GetBool("ExpandedMessagesWidget",true))
Messages->hideGroupBox();
if (!hGrp->GetBool("ExpandedSolverAdvancedWidget",false)) if (!hGrp->GetBool("ExpandedSolverAdvancedWidget",false))
SolverAdvanced->hideGroupBox(); SolverAdvanced->hideGroupBox();
if (!hGrp->GetBool("ExpandedConstraintsWidget",true)) if (!hGrp->GetBool("ExpandedConstraintsWidget",true))
@@ -96,7 +94,6 @@ bool TaskDlgEditSketch::accept()
bool TaskDlgEditSketch::reject() bool TaskDlgEditSketch::reject()
{ {
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher"); ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
hGrp->SetBool("ExpandedMessagesWidget",Messages->isGroupVisible());
hGrp->SetBool("ExpandedSolverAdvancedWidget",SolverAdvanced->isGroupVisible()); hGrp->SetBool("ExpandedSolverAdvancedWidget",SolverAdvanced->isGroupVisible());
hGrp->SetBool("ExpandedConstraintsWidget",Constraints->isGroupVisible()); hGrp->SetBool("ExpandedConstraintsWidget",Constraints->isGroupVisible());
hGrp->SetBool("ExpandedElementsWidget",Elements->isGroupVisible()); hGrp->SetBool("ExpandedElementsWidget",Elements->isGroupVisible());

View File

@@ -21,6 +21,9 @@
***************************************************************************/ ***************************************************************************/
#include "PreCompiled.h" #include "PreCompiled.h"
#ifndef _PreComp_
# include <QAction>
#endif
#include <Gui/Application.h> #include <Gui/Application.h>
#include <Gui/BitmapFactory.h> #include <Gui/BitmapFactory.h>
@@ -36,30 +39,17 @@ using namespace SketcherGui;
using namespace Gui::TaskView; using namespace Gui::TaskView;
namespace bp = boost::placeholders; namespace bp = boost::placeholders;
TaskSketcherMessages::TaskSketcherMessages(ViewProviderSketch *sketchView) : TaskSketcherMessages::TaskSketcherMessages(ViewProviderSketch* sketchView) :
TaskBox(Gui::BitmapFactory().pixmap("document-new"), tr("Solver messages"), true, nullptr), QWidget(),
sketchView(sketchView), sketchView(sketchView),
ui(new Ui_TaskSketcherMessages) ui(new Ui_TaskSketcherMessages)
{ {
// we need a separate container widget to add all controls to ui->setupUi(this);
proxy = new QWidget(this);
ui->setupUi(proxy);
QMetaObject::connectSlotsByName(this);
this->groupLayout()->addWidget(proxy);
connectionSetUp = sketchView->signalSetUp.connect(boost::bind(&SketcherGui::TaskSketcherMessages::slotSetUp, this, bp::_1, bp::_2, bp::_3, bp::_4)); connectionSetUp = sketchView->signalSetUp.connect(boost::bind(&SketcherGui::TaskSketcherMessages::slotSetUp, this, bp::_1, bp::_2, bp::_3, bp::_4));
ui->labelConstrainStatus->setOpenExternalLinks(false); ui->labelConstrainStatus->setOpenExternalLinks(false);
ui->autoUpdate->onRestore();
ui->autoRemoveRedundants->onRestore();
if(ui->autoUpdate->isChecked())
sketchView->getSketchObject()->noRecomputes=false;
else
sketchView->getSketchObject()->noRecomputes=true;
// Set up the possible state values for the status label // Set up the possible state values for the status label
ui->labelConstrainStatus->setParameterGroup("User parameter:BaseApp/Preferences/Mod/Sketcher/General"); ui->labelConstrainStatus->setParameterGroup("User parameter:BaseApp/Preferences/Mod/Sketcher/General");
ui->labelConstrainStatus->registerState(QString::fromUtf8("empty_sketch"), QColor("black"), std::string("EmptySketchMessageColor")); ui->labelConstrainStatus->registerState(QString::fromUtf8("empty_sketch"), QColor("black"), std::string("EmptySketchMessageColor"));
@@ -77,14 +67,27 @@ TaskSketcherMessages::TaskSketcherMessages(ViewProviderSketch *sketchView) :
connect(ui->labelConstrainStatusLink, &Gui::UrlLabel::linkClicked, connect(ui->labelConstrainStatusLink, &Gui::UrlLabel::linkClicked,
this, &TaskSketcherMessages::on_labelConstrainStatusLink_linkClicked); this, &TaskSketcherMessages::on_labelConstrainStatusLink_linkClicked);
//Set Auto Update in the 'Manual Update' button menu.
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool state = hGrp->GetBool("AutoRecompute", false);
sketchView->getSketchObject()->noRecomputes = !state;
QAction* action = new QAction(tr("Auto update"), this);
action->setToolTip(tr("Executes a recomputation of active document after every sketch action"));
action->setCheckable(true);
action->setChecked(state);
ui->manualUpdate->addAction(action);
QObject::connect(
qAsConst(ui->manualUpdate)->actions()[0], &QAction::changed,
this, &TaskSketcherMessages::onAutoUpdateStateChanged
);
/*QObject::connect( /*QObject::connect(
ui->labelConstrainStatus, SIGNAL(linkActivated(const QString &)), ui->labelConstrainStatus, SIGNAL(linkActivated(const QString &)),
this , SLOT (on_labelConstrainStatus_linkActivated(const QString &)) this , SLOT (on_labelConstrainStatus_linkActivated(const QString &))
); );
QObject::connect(
ui->autoUpdate, SIGNAL(stateChanged(int)),
this , SLOT (on_autoUpdate_stateChanged(int))
);
QObject::connect( QObject::connect(
ui->manualUpdate, SIGNAL(clicked(bool)), ui->manualUpdate, SIGNAL(clicked(bool)),
this , SLOT (on_manualUpdate_clicked(bool)) this , SLOT (on_manualUpdate_clicked(bool))
@@ -123,22 +126,13 @@ void TaskSketcherMessages::on_labelConstrainStatusLink_linkClicked(const QString
} }
void TaskSketcherMessages::on_autoUpdate_stateChanged(int state) void TaskSketcherMessages::onAutoUpdateStateChanged()
{ {
if(state==Qt::Checked) { bool state = qAsConst(ui->manualUpdate)->actions()[0]->isChecked();
sketchView->getSketchObject()->noRecomputes=false;
ui->autoUpdate->onSave();
}
else if (state==Qt::Unchecked) {
sketchView->getSketchObject()->noRecomputes=true;
ui->autoUpdate->onSave();
}
}
void TaskSketcherMessages::on_autoRemoveRedundants_stateChanged(int state) ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
{ hGrp->SetBool("AutoRecompute", state);
Q_UNUSED(state); sketchView->getSketchObject()->noRecomputes = !state;
ui->autoRemoveRedundants->onSave();
} }
void TaskSketcherMessages::on_manualUpdate_clicked(bool checked) void TaskSketcherMessages::on_manualUpdate_clicked(bool checked)

View File

@@ -39,20 +39,19 @@ namespace SketcherGui {
class ViewProviderSketch; class ViewProviderSketch;
class TaskSketcherMessages : public Gui::TaskView::TaskBox class TaskSketcherMessages : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit TaskSketcherMessages(ViewProviderSketch *sketchView); explicit TaskSketcherMessages(ViewProviderSketch* sketchView);
~TaskSketcherMessages() override; ~TaskSketcherMessages() override;
void slotSetUp(const QString &state, const QString &msg, const QString& link, const QString& linkText); void slotSetUp(const QString& state, const QString& msg, const QString& link, const QString& linkText);
private Q_SLOTS: private Q_SLOTS:
void on_labelConstrainStatusLink_linkClicked(const QString &); void on_labelConstrainStatusLink_linkClicked(const QString &);
void on_autoUpdate_stateChanged(int state); void onAutoUpdateStateChanged();
void on_autoRemoveRedundants_stateChanged(int state);
void on_manualUpdate_clicked(bool checked); void on_manualUpdate_clicked(bool checked);
protected: protected:
@@ -60,7 +59,6 @@ protected:
Connection connectionSetUp; Connection connectionSetUp;
private: private:
QWidget* proxy;
std::unique_ptr<Ui_TaskSketcherMessages> ui; std::unique_ptr<Ui_TaskSketcherMessages> ui;
}; };

View File

@@ -13,89 +13,44 @@
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_2"> <widget class="Gui::StatefulLabel" name="labelConstrainStatus">
<item>
<widget class="Gui::StatefulLabel" name="labelConstrainStatus">
<property name="text">
<string>DOF</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::UrlLabel" name="labelConstrainStatusLink">
<property name="text">
<string>Link</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="Gui::PrefCheckBox" name="autoRemoveRedundants">
<property name="toolTip">
<string>New constraints that would be redundant will automatically be removed</string>
</property>
<property name="text"> <property name="text">
<string>Auto remove redundants</string> <string>DOF</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>AutoRemoveRedundants</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Sketcher</cstring>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout"> <widget class="Gui::UrlLabel" name="labelConstrainStatusLink">
<item> <property name="text">
<widget class="Gui::PrefCheckBox" name="autoUpdate"> <string>Link</string>
<property name="toolTip"> </property>
<string>Executes a recomputation of active document after every sketch action</string> </widget>
</property> </item>
<property name="text"> <item>
<string>Auto update</string> <widget class="QToolButton" name="manualUpdate">
</property> <property name="sizePolicy">
<property name="checked"> <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<bool>false</bool> <horstretch>0</horstretch>
</property> <verstretch>0</verstretch>
<property name="prefEntry" stdset="0"> </sizepolicy>
<cstring>AutoRecompute</cstring> </property>
</property> <property name="toolTip">
<property name="prefPath" stdset="0"> <string>Forces recomputation of active document</string>
<cstring>Mod/Sketcher</cstring> </property>
</property> <property name="text">
</widget> <string></string>
</item> <string/>
<item> </property>
<widget class="QPushButton" name="manualUpdate"> <property name="icon">
<property name="toolTip"> <iconset resource="Resources.qrc">
<string>Forces recomputation of active document</string> <normaloff>:/icons/view-refresh.svg</normaloff>:/icons/view-refresh.svg</iconset>
</property> </property>
<property name="text"> <property name="popupMode">
<string>Update</string> <enum>QToolButton::MenuButtonPopup</enum>
</property> </property>
</widget> </widget>
</item>
</layout>
</item> </item>
</layout> </layout>
</widget> </widget>