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

View File

@@ -21,6 +21,9 @@
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
# include <QAction>
#endif
#include <Gui/Application.h>
#include <Gui/BitmapFactory.h>
@@ -36,30 +39,17 @@ using namespace SketcherGui;
using namespace Gui::TaskView;
namespace bp = boost::placeholders;
TaskSketcherMessages::TaskSketcherMessages(ViewProviderSketch *sketchView) :
TaskBox(Gui::BitmapFactory().pixmap("document-new"), tr("Solver messages"), true, nullptr),
TaskSketcherMessages::TaskSketcherMessages(ViewProviderSketch* sketchView) :
QWidget(),
sketchView(sketchView),
ui(new Ui_TaskSketcherMessages)
{
// we need a separate container widget to add all controls to
proxy = new QWidget(this);
ui->setupUi(proxy);
QMetaObject::connectSlotsByName(this);
this->groupLayout()->addWidget(proxy);
ui->setupUi(this);
connectionSetUp = sketchView->signalSetUp.connect(boost::bind(&SketcherGui::TaskSketcherMessages::slotSetUp, this, bp::_1, bp::_2, bp::_3, bp::_4));
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
ui->labelConstrainStatus->setParameterGroup("User parameter:BaseApp/Preferences/Mod/Sketcher/General");
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,
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(
ui->labelConstrainStatus, SIGNAL(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(
ui->manualUpdate, SIGNAL(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) {
sketchView->getSketchObject()->noRecomputes=false;
ui->autoUpdate->onSave();
}
else if (state==Qt::Unchecked) {
sketchView->getSketchObject()->noRecomputes=true;
ui->autoUpdate->onSave();
}
}
bool state = qAsConst(ui->manualUpdate)->actions()[0]->isChecked();
void TaskSketcherMessages::on_autoRemoveRedundants_stateChanged(int state)
{
Q_UNUSED(state);
ui->autoRemoveRedundants->onSave();
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
hGrp->SetBool("AutoRecompute", state);
sketchView->getSketchObject()->noRecomputes = !state;
}
void TaskSketcherMessages::on_manualUpdate_clicked(bool checked)

View File

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

View File

@@ -13,89 +13,44 @@
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<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>
<widget class="Gui::StatefulLabel" name="labelConstrainStatus">
<property name="text">
<string>Auto remove redundants</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>
<string>DOF</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="Gui::PrefCheckBox" name="autoUpdate">
<property name="toolTip">
<string>Executes a recomputation of active document after every sketch action</string>
</property>
<property name="text">
<string>Auto update</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>AutoRecompute</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Sketcher</cstring>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="manualUpdate">
<property name="toolTip">
<string>Forces recomputation of active document</string>
</property>
<property name="text">
<string>Update</string>
</property>
</widget>
</item>
</layout>
<widget class="Gui::UrlLabel" name="labelConstrainStatusLink">
<property name="text">
<string>Link</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="manualUpdate">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Forces recomputation of active document</string>
</property>
<property name="text">
<string></string>
<string/>
</property>
<property name="icon">
<iconset resource="Resources.qrc">
<normaloff>:/icons/view-refresh.svg</normaloff>:/icons/view-refresh.svg</iconset>
</property>
<property name="popupMode">
<enum>QToolButton::MenuButtonPopup</enum>
</property>
</widget>
</item>
</layout>
</widget>