[TD] Balloon fixes

- remove the unused property OriginIsSet
- refurbish TaskDialog and add new settings:
  - use SpinBox for Shape Scale
  - add Font Size
  - add Text Color
  - add Line Width
  - add Kink Length
- correct and add tooltips
This commit is contained in:
donovaly
2020-03-20 02:15:47 +01:00
committed by WandererFan
parent 7f6dde209f
commit 14fbda341c
6 changed files with 302 additions and 144 deletions

View File

@@ -94,7 +94,6 @@ DrawViewBalloon::DrawViewBalloon(void)
ADD_PROPERTY_TYPE(SourceView,(0),"",(App::PropertyType)(App::Prop_None),"Source view for balloon");
ADD_PROPERTY_TYPE(OriginX,(0),"",(App::PropertyType)(App::Prop_None),"Balloon origin x");
ADD_PROPERTY_TYPE(OriginY,(0),"",(App::PropertyType)(App::Prop_None),"Balloon origin y");
ADD_PROPERTY_TYPE(OriginIsSet, (false), "",(App::PropertyType)(App::Prop_None),"Balloon origin is set");
EndType.setEnums(ArrowPropEnum::ArrowTypeEnums);
ADD_PROPERTY(EndType,(prefEnd()));
@@ -110,9 +109,6 @@ DrawViewBalloon::DrawViewBalloon(void)
ADD_PROPERTY_TYPE(KinkLength,(prefKinkLength()),"",(App::PropertyType)(App::Prop_None),
"Distance from symbol to leader kink");
OriginIsSet.setStatus(App::Property::Hidden,false);
OriginIsSet.setStatus(App::Property::ReadOnly,true);
SourceView.setScope(App::LinkScope::Global);
Rotation.setStatus(App::Property::Hidden,true);
Caption.setStatus(App::Property::Hidden,true);

View File

@@ -56,9 +56,7 @@ public:
App::PropertyFloatConstraint ShapeScale;
App::PropertyDistance OriginX;
App::PropertyDistance OriginY;
App::PropertyBool OriginIsSet;
App::PropertyFloat TextWrapLen;
App::PropertyDistance KinkLength;
short mustExecute() const override;

View File

@@ -52,26 +52,26 @@
#include "DrawGuiUtil.h"
#include "QGIViewBalloon.h"
#include "ViewProviderBalloon.h"
#include "TaskBalloon.h"
using namespace Gui;
using namespace TechDraw;
using namespace TechDrawGui;
TaskBalloon::TaskBalloon(QGIViewBalloon *parent) :
TaskBalloon::TaskBalloon(QGIViewBalloon *parent, ViewProviderBalloon *balloonVP) :
ui(new Ui_TaskBalloon)
{
int i = 0;
m_parent = parent;
m_balloonVP = balloonVP;
ui->setupUi(this);
QString qs = QString::number(parent->dvBalloon->ShapeScale.getValue(), 'f', 2);
ui->inputScale->setText(qs);
ui->inputScale->setValue(parent->dvBalloon->ShapeScale.getValue());
std::string value = parent->dvBalloon->Text.getValue();
qs = QString::fromUtf8(value.data(), value.size());
QString qs = QString::fromUtf8(value.data(), value.size());
ui->inputValue->setText(qs);
ui->inputValue->selectAll();
QTimer::singleShot(0, ui->inputValue, SLOT(setFocus()));
@@ -82,6 +82,19 @@ TaskBalloon::TaskBalloon(QGIViewBalloon *parent) :
i = parent->dvBalloon->Shape.getValue();
ui->comboSymbol->setCurrentIndex(i);
if (m_balloonVP != nullptr)
ui->textColor->setColor(m_balloonVP->Color.getValue().asValue<QColor>());
ui->qsbFontSize->setUnit(Base::Unit::Length);
ui->qsbLineWidth->setUnit(Base::Unit::Length);
ui->qsbLineWidth->setSingleStep(0.100);
ui->qsbBalloonKink->setUnit(Base::Unit::Length);
ui->qsbFontSize->setValue(m_balloonVP->Fontsize.getValue());
ui->qsbLineWidth->setValue(m_balloonVP->LineWidth.getValue());
// new balloons have already the preferences BalloonKink length
ui->qsbBalloonKink->setValue(m_parent->dvBalloon->KinkLength.getValue());
}
TaskBalloon::~TaskBalloon()
@@ -92,9 +105,15 @@ TaskBalloon::~TaskBalloon()
bool TaskBalloon::accept()
{
m_parent->dvBalloon->Text.setValue(ui->inputValue->text().toUtf8().constData());
m_parent->dvBalloon->ShapeScale.setValue(ui->inputScale->text().toDouble());
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;
@@ -107,10 +126,10 @@ bool TaskBalloon::reject()
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TaskDlgBalloon::TaskDlgBalloon(QGIViewBalloon *parent) :
TaskDlgBalloon::TaskDlgBalloon(QGIViewBalloon *parent, ViewProviderBalloon *balloonVP) :
TaskDialog()
{
widget = new TaskBalloon(parent);
widget = new TaskBalloon(parent, balloonVP);
taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("TechDraw_Balloon"), widget->windowTitle(), true, 0);
taskbox->groupLayout()->addWidget(widget);
Content.push_back(taskbox);

View File

@@ -32,6 +32,7 @@
#include <Mod/TechDraw/App/DrawViewPart.h>
#include "QGIViewBalloon.h"
#include "ViewProviderBalloon.h"
class Ui_TaskBalloon;
@@ -43,7 +44,7 @@ class TaskBalloon : public QWidget
Q_OBJECT
public:
TaskBalloon(QGIViewBalloon *parent);
TaskBalloon(QGIViewBalloon *parent, ViewProviderBalloon *balloonVP);
~TaskBalloon();
public:
@@ -53,6 +54,7 @@ public:
private:
Ui_TaskBalloon *ui;
QGIViewBalloon *m_parent;
ViewProviderBalloon* m_balloonVP;
};
class TaskDlgBalloon : public Gui::TaskView::TaskDialog
@@ -60,7 +62,7 @@ class TaskDlgBalloon : public Gui::TaskView::TaskDialog
Q_OBJECT
public:
TaskDlgBalloon(QGIViewBalloon *parent);
TaskDlgBalloon(QGIViewBalloon *parent, ViewProviderBalloon *balloonVP);
~TaskDlgBalloon();
public:

View File

@@ -6,140 +6,283 @@
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>306</height>
<width>307</width>
<height>229</height>
</rect>
</property>
<property name="windowTitle">
<string>Balloon</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="3" column="1">
<widget class="QComboBox" name="comboEndType"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Start Symbol</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Shape:</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Value:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="comboSymbol">
<item>
<property name="text">
<string>Circular</string>
</property>
<property name="icon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/circular.svg</normaloff>:/icons/circular.svg</iconset>
</property>
</item>
<item>
<property name="text">
<string>None</string>
</property>
<property name="icon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/none.svg</normaloff>:/icons/none.svg</iconset>
</property>
</item>
<item>
<property name="text">
<string>Triangle</string>
</property>
<property name="icon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/triangle.svg</normaloff>:/icons/triangle.svg</iconset>
</property>
</item>
<item>
<property name="text">
<string>Inspection</string>
</property>
<property name="icon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/inspection.svg</normaloff>:/icons/inspection.svg</iconset>
</property>
</item>
<item>
<property name="text">
<string>Hexagon</string>
</property>
<property name="icon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/hexagon.svg</normaloff>:/icons/hexagon.svg</iconset>
</property>
</item>
<item>
<property name="text">
<string>Square</string>
</property>
<property name="icon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/square.svg</normaloff>:/icons/square.svg</iconset>
</property>
</item>
<item>
<property name="text">
<string>Rectangle</string>
</property>
<property name="icon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/rectangle.svg</normaloff>:/icons/rectangle.svg</iconset>
</property>
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Scale:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="inputValue"/>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="inputScale"/>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Text:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="inputValue">
<property name="toolTip">
<string>Text to be displayed</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Text Color:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="Gui::ColorButton" name="textColor">
<property name="color" stdset="0">
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Font Size:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="Gui::QuantitySpinBox" name="qsbFontSize" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
<property name="toolTip">
<string>Length of balloon leader line kink</string>
</property>
<property name="value" stdset="0">
<double>4.000000000000000</double>
</property>
<property name="prefEntry" stdset="0">
<cstring>BalloonKink</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw/Dimensions</cstring>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Shape:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="comboSymbol">
<property name="toolTip">
<string>Shape of the balloon bubble</string>
</property>
<item>
<property name="text">
<string>Circular</string>
</property>
<property name="icon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/circular.svg</normaloff>:/icons/circular.svg</iconset>
</property>
</item>
<item>
<property name="text">
<string>None</string>
</property>
<property name="icon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/none.svg</normaloff>:/icons/none.svg</iconset>
</property>
</item>
<item>
<property name="text">
<string>Triangle</string>
</property>
<property name="icon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/triangle.svg</normaloff>:/icons/triangle.svg</iconset>
</property>
</item>
<item>
<property name="text">
<string>Inspection</string>
</property>
<property name="icon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/inspection.svg</normaloff>:/icons/inspection.svg</iconset>
</property>
</item>
<item>
<property name="text">
<string>Hexagon</string>
</property>
<property name="icon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/hexagon.svg</normaloff>:/icons/hexagon.svg</iconset>
</property>
</item>
<item>
<property name="text">
<string>Square</string>
</property>
<property name="icon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/square.svg</normaloff>:/icons/square.svg</iconset>
</property>
</item>
<item>
<property name="text">
<string>Rectangle</string>
</property>
<property name="icon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/rectangle.svg</normaloff>:/icons/rectangle.svg</iconset>
</property>
</item>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Shape Scale:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QDoubleSpinBox" name="inputScale">
<property name="toolTip">
<string>Scale factor for the 'Shape'</string>
</property>
<property name="minimum">
<double>0.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>End Symbol:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QComboBox" name="comboEndType">
<property name="toolTip">
<string>End symbol for the balloon line</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Line Width:</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="Gui::QuantitySpinBox" name="qsbLineWidth" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
<property name="toolTip">
<string>Length of balloon leader line kink</string>
</property>
<property name="value" stdset="0">
<double>0.350000000000000</double>
</property>
<property name="prefEntry" stdset="0">
<cstring>BalloonKink</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw/Dimensions</cstring>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Leader Kink Length:</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="Gui::QuantitySpinBox" name="qsbBalloonKink" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
<property name="toolTip">
<string>Length of balloon leader line kink</string>
</property>
<property name="value" stdset="0">
<double>5.000000000000000</double>
</property>
<property name="prefEntry" stdset="0">
<cstring>BalloonKink</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw/Dimensions</cstring>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Gui::ColorButton</class>
<extends>QPushButton</extends>
<header>Gui/Widgets.h</header>
</customwidget>
<customwidget>
<class>Gui::QuantitySpinBox</class>
<extends>QWidget</extends>
<header>Gui/QuantitySpinBox.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="Resources/TechDraw.qrc"/>
</resources>

View File

@@ -79,13 +79,13 @@ ViewProviderBalloon::ViewProviderBalloon()
auto lg = TechDraw::LineGroup::lineGroupFactory(lgName);
double weight = lg->getWeight("Thin");
delete lg; //Coverity CID 174670
ADD_PROPERTY_TYPE(LineWidth,(weight),group,(App::PropertyType)(App::Prop_None),"Balloon line width");
ADD_PROPERTY_TYPE(LineWidth,(weight),group,(App::PropertyType)(App::Prop_None),"Leader line width");
hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Dimensions");
App::Color fcColor;
fcColor.setPackedValue(hGrp->GetUnsigned("Color", 0x00000000));
ADD_PROPERTY_TYPE(Color,(fcColor),group,App::Prop_None,"The color of the Dimension");
ADD_PROPERTY_TYPE(Color,(fcColor),group,App::Prop_None,"Color of the text");
}
ViewProviderBalloon::~ViewProviderBalloon()
@@ -121,7 +121,7 @@ bool ViewProviderBalloon::setEdit(int ModNum)
Gui::Selection().clearSelection();
auto qgivBalloon(dynamic_cast<QGIViewBalloon*>(getQView()));
if (qgivBalloon) {
Gui::Control().showDialog(new TaskDlgBalloon(qgivBalloon));
Gui::Control().showDialog(new TaskDlgBalloon(qgivBalloon, this));
}
return true;
} else {