[TD] make balloon dialog show changes

see https://forum.freecadweb.org/viewtopic.php?f=35&t=44362
This commit is contained in:
donovaly
2020-03-22 02:17:54 +01:00
committed by WandererFan
parent 2651dc8402
commit 3ea70429e7
2 changed files with 87 additions and 11 deletions

View File

@@ -69,27 +69,35 @@ TaskBalloon::TaskBalloon(QGIViewBalloon *parent, ViewProviderBalloon *balloonVP)
ui->setupUi(this);
ui->inputScale->setValue(parent->dvBalloon->ShapeScale.getValue());
connect(ui->inputScale, SIGNAL(valueChanged(double)), this, SLOT(onShapeScaleChanged()));
std::string value = parent->dvBalloon->Text.getValue();
QString qs = QString::fromUtf8(value.data(), value.size());
ui->inputValue->setText(qs);
ui->inputValue->selectAll();
connect(ui->inputValue, SIGNAL(textChanged(QString)), this, SLOT(onTextChanged()));
QTimer::singleShot(0, ui->inputValue, SLOT(setFocus()));
DrawGuiUtil::loadArrowBox(ui->comboEndType);
i = parent->dvBalloon->EndType.getValue();
ui->comboEndType->setCurrentIndex(i);
connect(ui->comboEndType, SIGNAL(currentIndexChanged(int)), this, SLOT(onEndTypeChanged()));
i = parent->dvBalloon->Shape.getValue();
ui->comboSymbol->setCurrentIndex(i);
connect(ui->comboSymbol, SIGNAL(currentIndexChanged(int)), this, SLOT(onShapeChanged()));
ui->qsbFontSize->setUnit(Base::Unit::Length);
connect(ui->qsbFontSize, SIGNAL(valueChanged(double)), this, SLOT(onFontsizeChanged()));
ui->qsbLineWidth->setUnit(Base::Unit::Length);
ui->qsbLineWidth->setSingleStep(0.100);
connect(ui->qsbLineWidth, SIGNAL(valueChanged(double)), this, SLOT(onLineWidthChanged()));
ui->qsbBalloonKink->setUnit(Base::Unit::Length);
connect(ui->qsbBalloonKink, SIGNAL(valueChanged(double)), this, SLOT(onBalloonKinkChanged()));
if (balloonVP != nullptr) {
ui->textColor->setColor(balloonVP->Color.getValue().asValue<QColor>());
connect(ui->textColor, SIGNAL(changed()), this, SLOT(onColorChanged()));
ui->qsbFontSize->setValue(balloonVP->Fontsize.getValue());
ui->qsbLineWidth->setValue(balloonVP->LineWidth.getValue());
}
@@ -104,17 +112,17 @@ TaskBalloon::~TaskBalloon()
bool TaskBalloon::accept()
{
m_parent->dvBalloon->Text.setValue(ui->inputValue->text().toUtf8().constData());
App::Color ac;
ac.setValue<QColor>(ui->textColor->color());
m_balloonVP->Color.setValue(ac);
m_balloonVP->Fontsize.setValue(ui->qsbFontSize->value().getValue());
m_parent->dvBalloon->ShapeScale.setValue(ui->inputScale->value());
m_parent->dvBalloon->EndType.setValue(ui->comboEndType->currentIndex());
m_parent->dvBalloon->Shape.setValue(ui->comboSymbol->currentIndex());
m_balloonVP->LineWidth.setValue(ui->qsbLineWidth->value().getValue());
m_parent->dvBalloon->KinkLength.setValue(ui->qsbBalloonKink->value().getValue());
m_parent->updateView(true);
m_parent->dvBalloon->Text.setValue(ui->inputValue->text().toUtf8().constData());
App::Color ac;
ac.setValue<QColor>(ui->textColor->color());
m_balloonVP->Color.setValue(ac);
m_balloonVP->Fontsize.setValue(ui->qsbFontSize->value().getValue());
m_parent->dvBalloon->ShapeScale.setValue(ui->inputScale->value());
m_parent->dvBalloon->EndType.setValue(ui->comboEndType->currentIndex());
m_parent->dvBalloon->Shape.setValue(ui->comboSymbol->currentIndex());
m_balloonVP->LineWidth.setValue(ui->qsbLineWidth->value().getValue());
m_parent->dvBalloon->KinkLength.setValue(ui->qsbBalloonKink->value().getValue());
m_parent->updateView(true);
return true;
}
@@ -124,6 +132,63 @@ bool TaskBalloon::reject()
return false;
}
void TaskBalloon::recomputeFeature()
{
App::DocumentObject* objVP = m_balloonVP->getObject();
assert(objVP);
objVP->getDocument()->recomputeFeature(objVP);
}
void TaskBalloon::onTextChanged()
{
m_parent->dvBalloon->Text.setValue(ui->inputValue->text().toUtf8().constData());
recomputeFeature();
}
void TaskBalloon::onColorChanged()
{
App::Color ac;
ac.setValue<QColor>(ui->textColor->color());
m_balloonVP->Color.setValue(ac);
recomputeFeature();
}
void TaskBalloon::onFontsizeChanged()
{
m_balloonVP->Fontsize.setValue(ui->qsbFontSize->value().getValue());
recomputeFeature();
}
void TaskBalloon::onShapeChanged()
{
m_parent->dvBalloon->Shape.setValue(ui->comboSymbol->currentIndex());
recomputeFeature();
}
void TaskBalloon::onShapeScaleChanged()
{
m_parent->dvBalloon->ShapeScale.setValue(ui->inputScale->value());
recomputeFeature();
}
void TaskBalloon::onEndTypeChanged()
{
m_parent->dvBalloon->EndType.setValue(ui->comboEndType->currentIndex());
recomputeFeature();
}
void TaskBalloon::onLineWidthChanged()
{
m_balloonVP->LineWidth.setValue(ui->qsbLineWidth->value().getValue());;
recomputeFeature();
}
void TaskBalloon::onBalloonKinkChanged()
{
m_parent->dvBalloon->KinkLength.setValue(ui->qsbBalloonKink->value().getValue());
recomputeFeature();
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TaskDlgBalloon::TaskDlgBalloon(QGIViewBalloon *parent, ViewProviderBalloon *balloonVP) :

View File

@@ -50,6 +50,17 @@ public:
public:
virtual bool accept();
virtual bool reject();
void recomputeFeature();
private Q_SLOTS:
void onTextChanged();
void onColorChanged();
void onFontsizeChanged();
void onShapeChanged();
void onShapeScaleChanged();
void onEndTypeChanged();
void onLineWidthChanged();
void onBalloonKinkChanged();
private:
Ui_TaskBalloon *ui;