[TD] improve RichAnno and LeaderLine dialog

see: https://forum.freecadweb.org/viewtopic.php?f=35&t=42746&p=364126#p364126
This commit is contained in:
donovaly
2020-01-28 02:12:32 +01:00
committed by WandererFan
parent 81b50bf70e
commit 853dc6d884
4 changed files with 363 additions and 162 deletions

View File

@@ -120,6 +120,10 @@ TaskLeaderLine::TaskLeaderLine(TechDrawGui::ViewProviderLeader* leadVP) :
this, SLOT(onCancelEditClicked(bool)));
ui->pbCancelEdit->setEnabled(false);
ui->dsbWeight->setUnit(Base::Unit::Length);
ui->dsbWeight->setMinimum(0);
ui->dsbWeight->setValue(0.5);
saveState();
m_trackerMode = QGTracker::TrackerMode::Line;
@@ -165,6 +169,10 @@ TaskLeaderLine::TaskLeaderLine(TechDraw::DrawView* baseFeat,
this, SLOT(onCancelEditClicked(bool)));
ui->pbCancelEdit->setEnabled(false);
ui->dsbWeight->setUnit(Base::Unit::Length);
ui->dsbWeight->setMinimum(0);
ui->dsbWeight->setValue(0.5);
m_trackerMode = QGTracker::TrackerMode::Line;
m_saveContextPolicy = m_mdi->contextMenuPolicy();
@@ -297,7 +305,7 @@ void TaskLeaderLine::createLeaderFeature(std::vector<Base::Vector3d> converted)
App::Color ac;
ac.setValue<QColor>(ui->cpLineColor->color());
leadVP->Color.setValue(ac);
leadVP->LineWidth.setValue(ui->dsbWeight->value());
leadVP->LineWidth.setValue(ui->dsbWeight->rawValue());
leadVP->LineStyle.setValue(ui->cboxStyle->currentIndex());
}
}
@@ -324,7 +332,7 @@ void TaskLeaderLine::updateLeaderFeature(void)
App::Color ac;
ac.setValue<QColor>(ui->cpLineColor->color());
m_lineVP->Color.setValue(ac);
m_lineVP->LineWidth.setValue(ui->dsbWeight->value());
m_lineVP->LineWidth.setValue(ui->dsbWeight->rawValue());
m_lineVP->LineStyle.setValue(ui->cboxStyle->currentIndex());
Gui::Command::updateActive();

View File

@@ -313,6 +313,9 @@
</item>
<item row="3" column="1">
<widget class="Gui::ColorButton" name="cpLineColor">
<property name="toolTip">
<string>Line color</string>
</property>
<property name="color" stdset="0">
<color>
<red>0</red>
@@ -325,16 +328,22 @@
<item row="4" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Weight</string>
<string>Width</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QDoubleSpinBox" name="dsbWeight">
<property name="singleStep">
<widget class="Gui::QuantitySpinBox" name="dsbWeight" native="true">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Line width</string>
</property>
<property name="singleStep" stdset="0">
<double>0.100000000000000</double>
</property>
<property name="value">
<property name="value" stdset="0">
<double>0.500000000000000</double>
</property>
</widget>
@@ -348,6 +357,9 @@
</item>
<item row="5" column="1">
<widget class="QComboBox" name="cboxStyle">
<property name="toolTip">
<string>Line style</string>
</property>
<property name="currentIndex">
<number>1</number>
</property>
@@ -414,6 +426,11 @@
<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"/>

View File

@@ -123,6 +123,9 @@ TaskRichAnno::TaskRichAnno(TechDrawGui::ViewProviderRichAnno* annoVP) :
connect(ui->pbEditor, SIGNAL(clicked(bool)),
this, SLOT(onEditorClicked(bool)));
ui->dsbWidth->setUnit(Base::Unit::Length);
ui->dsbWidth->setMinimum(0);
ui->dsbWidth->setValue(0.5);
}
//ctor for creation
@@ -165,6 +168,9 @@ TaskRichAnno::TaskRichAnno(TechDraw::DrawView* baseFeat,
connect(ui->pbEditor, SIGNAL(clicked(bool)),
this, SLOT(onEditorClicked(bool)));
ui->dsbWidth->setUnit(Base::Unit::Length);
ui->dsbWidth->setMinimum(0);
ui->dsbWidth->setValue(0.5);
}
TaskRichAnno::~TaskRichAnno()
@@ -204,6 +210,8 @@ void TaskRichAnno::enableTextUi(bool b)
ui->teAnnoText->setEnabled(b);
}
//switch widgets related to ViewProvider on/off
//there is no ViewProvider until some time after feature is created.
void TaskRichAnno::enableVPUi(bool b)
{
Q_UNUSED(b);
@@ -230,6 +238,12 @@ void TaskRichAnno::setUiEdit()
ui->dsbMaxWidth->setValue(m_annoFeat->MaxWidth.getValue());
ui->cbShowFrame->setChecked(m_annoFeat->ShowFrame.getValue());
}
if (m_annoVP != nullptr) {
ui->cpFrameColor->setColor(m_annoVP->LineColor.getValue().asValue<QColor>());
ui->dsbWidth->setValue(m_annoVP->LineWidth.getValue());
ui->cFrameStyle->setCurrentIndex(m_annoVP->LineStyle.getValue());
}
}
void TaskRichAnno::onEditorClicked(bool b)
@@ -309,6 +323,18 @@ void TaskRichAnno::createAnnoFeature()
m_annoFeat->Y.setValue(Rez::appX(vTemp.y));
}
if (m_annoFeat != nullptr) {
Gui::ViewProvider* vp = QGIView::getViewProvider(m_annoFeat);
auto annoVP = dynamic_cast<ViewProviderRichAnno*>(vp);
if (annoVP != nullptr) {
App::Color ac;
ac.setValue<QColor>(ui->cpFrameColor->color());
annoVP->LineColor.setValue(ac);
annoVP->LineWidth.setValue(ui->dsbWidth->rawValue());
annoVP->LineStyle.setValue(ui->cFrameStyle->currentIndex());
}
}
Gui::Command::updateActive();
Gui::Command::commitCommand();
@@ -327,6 +353,11 @@ void TaskRichAnno::updateAnnoFeature()
// Base::Console().Message("TRA::updateAnnoFeature()\n");
Gui::Command::openCommand("Edit Anno");
commonFeatureUpdate();
App::Color ac;
ac.setValue<QColor>(ui->cpFrameColor->color());
m_annoVP->LineColor.setValue(ac);
m_annoVP->LineWidth.setValue(ui->dsbWidth->rawValue());
m_annoVP->LineStyle.setValue(ui->cFrameStyle->currentIndex());
Gui::Command::commitCommand();
m_annoFeat->requestPaint();

View File

@@ -1,156 +1,301 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>TechDrawGui::TaskRichAnno</class>
<widget class="QWidget" name="TechDrawGui::TaskRichAnno">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>409</width>
<height>386</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>250</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string>Rich Text Annotation Block</string>
</property>
<property name="windowIcon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/actions/techdraw-RichTextAnnotation.svg</normaloff>:/icons/actions/techdraw-RichTextAnnotation.svg</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QFrame" name="frame">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<layout class="QGridLayout" name="gridLayout" rowstretch="0,0,0" columnstretch="3,1,3">
<property name="verticalSpacing">
<number>0</number>
</property>
<item row="1" column="2">
<widget class="QDoubleSpinBox" name="dsbMaxWidth">
<property name="minimum">
<double>-1.000000000000000</double>
</property>
<property name="value">
<double>-1.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Max Width</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Base Feature</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLineEdit" name="leBaseView">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<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>
<item row="2" column="2">
<widget class="QCheckBox" name="cbShowFrame">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Show Frame</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbEditor">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Start Rich Text Editor</string>
</property>
</widget>
</item>
<item>
<widget class="QTextEdit" name="teAnnoText">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="Resources/TechDraw.qrc"/>
</resources>
<connections/>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>TechDrawGui::TaskRichAnno</class>
<widget class="QWidget" name="TechDrawGui::TaskRichAnno">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>409</width>
<height>419</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>250</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string>Rich Text Annotation Block</string>
</property>
<property name="windowIcon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/actions/techdraw-RichTextAnnotation.svg</normaloff>:/icons/actions/techdraw-RichTextAnnotation.svg</iconset>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QFrame" name="frame">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Base Feature</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="leBaseView">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Max Width</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="dsbMaxWidth">
<property name="toolTip">
<string>Maximal width, if -1 then automatic width</string>
</property>
<property name="minimum">
<double>-1.000000000000000</double>
</property>
<property name="value">
<double>-1.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="pbEditor">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Start Rich Text Editor</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QTextEdit" name="teAnnoText">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="4" column="0">
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Show Frame</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="cbShowFrame">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Color</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="Gui::ColorButton" name="cpFrameColor">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Line color</string>
</property>
<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_5">
<property name="text">
<string>Width</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="Gui::QuantitySpinBox" name="dsbWidth" native="true">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Line width</string>
</property>
<property name="singleStep" stdset="0">
<double>0.100000000000000</double>
</property>
<property name="value" stdset="0">
<double>0.500000000000000</double>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Style</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="cFrameStyle">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Line style</string>
</property>
<property name="currentIndex">
<number>1</number>
</property>
<item>
<property name="text">
<string>NoLine</string>
</property>
</item>
<item>
<property name="text">
<string>Solid</string>
</property>
</item>
<item>
<property name="text">
<string>Dash</string>
</property>
</item>
<item>
<property name="text">
<string>Dot</string>
</property>
</item>
<item>
<property name="text">
<string>DashDot</string>
</property>
</item>
<item>
<property name="text">
<string>DashDotDot</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</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>
<connections>
<connection>
<sender>cbShowFrame</sender>
<signal>toggled(bool)</signal>
<receiver>cpFrameColor</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>183</x>
<y>270</y>
</hint>
<hint type="destinationlabel">
<x>183</x>
<y>294</y>
</hint>
</hints>
</connection>
<connection>
<sender>cbShowFrame</sender>
<signal>toggled(bool)</signal>
<receiver>cFrameStyle</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>236</x>
<y>277</y>
</hint>
<hint type="destinationlabel">
<x>236</x>
<y>354</y>
</hint>
</hints>
</connection>
<connection>
<sender>cbShowFrame</sender>
<signal>toggled(bool)</signal>
<receiver>dsbWidth</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>236</x>
<y>277</y>
</hint>
<hint type="destinationlabel">
<x>236</x>
<y>328</y>
</hint>
</hints>
</connection>
</connections>
</ui>