[TD] refurbish LineDecorDlg

- also set a better step size
- also apply the changes in the DLG immediately

see: https://forum.freecadweb.org/viewtopic.php?f=35&t=44362&p=379377#p379377
This commit is contained in:
donovaly
2020-03-22 15:22:40 +01:00
committed by WandererFan
parent a564c468f0
commit 147c78d9e9
2 changed files with 182 additions and 215 deletions

View File

@@ -69,10 +69,10 @@ TaskLineDecor::TaskLineDecor(TechDraw::DrawViewPart* partFeat,
getDefaults();
ui->setupUi(this);
connect(ui->cb_Style, SIGNAL(currentIndexChanged( int )), this, SLOT(onStyleChanged(void)));
connect(ui->cc_Color, SIGNAL(changed( )), this, SLOT(onColorChanged(void)));
connect(ui->dsb_Weight, SIGNAL(valueChanged( double )), this, SLOT(onWeightChanged( void )));
connect(ui->cb_Visible, SIGNAL(currentIndexChanged( int )), this, SLOT(onVisibleChanged( void )));
connect(ui->cb_Style, SIGNAL(currentIndexChanged(int)), this, SLOT(onStyleChanged(void)));
connect(ui->cc_Color, SIGNAL(changed()), this, SLOT(onColorChanged(void)));
connect(ui->dsb_Weight, SIGNAL(valueChanged(double)), this, SLOT(onWeightChanged(void)));
connect(ui->cb_Visible, SIGNAL(currentIndexChanged(int)), this, SLOT(onVisibleChanged(void)));
initUi();
}
@@ -101,6 +101,7 @@ void TaskLineDecor::initUi()
ui->cb_Style->setCurrentIndex(m_style - 1); //combobox does not have 0:NoLine choice
ui->cc_Color->setColor(m_color.asValue<QColor>());
ui->dsb_Weight->setValue(m_weight);
ui->dsb_Weight->setSingleStep(0.1);
ui->cb_Visible->setCurrentIndex(m_visible);
}
@@ -157,25 +158,29 @@ void TaskLineDecor::getDefaults(void)
void TaskLineDecor::onStyleChanged(void)
{
m_style = ui->cb_Style->currentIndex() + 1;
//livePreview();
applyDecorations();
m_partFeat->requestPaint();
}
void TaskLineDecor::onColorChanged(void)
{
m_color.setValue<QColor>(ui->cc_Color->color());
//livePreview();
applyDecorations();
m_partFeat->requestPaint();
}
void TaskLineDecor::onWeightChanged(void)
{
m_weight = ui->dsb_Weight->value();
//livePreview();
applyDecorations();
m_partFeat->requestPaint();
}
void TaskLineDecor::onVisibleChanged(void)
{
m_visible = ui->cb_Visible->currentIndex();
//livePreview();
applyDecorations();
m_partFeat->requestPaint();
}
void TaskLineDecor::applyDecorations(void)

View File

@@ -6,12 +6,12 @@
<rect>
<x>0</x>
<y>0</y>
<width>395</width>
<height>294</height>
<width>350</width>
<height>200</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
<sizepolicy hsizetype="Fixed" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -25,215 +25,177 @@
<property name="windowTitle">
<string>Line Decoration</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<layout class="QVBoxLayout" name="verticalLayout">
<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::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QGridLayout" name="gridLayout_5">
<item row="1" column="1">
<widget class="QLineEdit" name="le_Lines">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Lines</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>View</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="le_View">
<property name="enabled">
<bool>false</bool>
</property>
<property name="mouseTracking">
<bool>false</bool>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="acceptDrops">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>View</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLineEdit" name="le_View">
<property name="enabled">
<bool>false</bool>
</property>
<property name="mouseTracking">
<bool>false</bool>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="acceptDrops">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Lines</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLineEdit" name="le_Lines">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="0" colspan="3">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</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">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="2">
<widget class="QComboBox" name="cb_Style">
<property name="currentIndex">
<number>0</number>
</property>
<item>
<property name="text">
<string>Continuous</string>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</item>
<item>
<property name="text">
<string>Dash</string>
</property>
</spacer>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_4" columnstretch="0,0,1">
<item row="0" column="1">
<spacer name="horizontalSpacer_4">
<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="1" column="0">
<widget class="QLabel" name="label_14">
<property name="text">
<string>Color</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Style</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_15">
<property name="text">
<string>Weight</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="Gui::ColorButton" name="cc_Color">
<property name="color">
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QDoubleSpinBox" name="dsb_Weight">
<property name="toolTip">
<string>Thickness of pattern lines.</string>
</property>
<property name="value">
<double>0.500000000000000</double>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Visible</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QComboBox" name="cb_Visible">
<property name="currentIndex">
<number>1</number>
</property>
<property name="maxVisibleItems">
<number>2</number>
</property>
<property name="maxCount">
<number>2</number>
</property>
<property name="minimumContentsLength">
<number>2</number>
</property>
<item>
<property name="text">
<string>False</string>
</property>
</item>
<item>
<property name="text">
<string>True</string>
</property>
</item>
</widget>
</item>
<item row="0" column="2">
<widget class="QComboBox" name="cb_Style">
<property name="currentIndex">
<number>0</number>
</property>
<item>
<property name="text">
<string>Continuous</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>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</item>
<item>
<property name="text">
<string>Dot</string>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</item>
<item>
<property name="text">
<string>DashDot</string>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<property name="text">
<string>DashDotDot</string>
</property>
</item>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_14">
<property name="text">
<string>Color</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="Gui::ColorButton" name="cc_Color">
<property name="color" stdset="0">
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_15">
<property name="text">
<string>Weight</string>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QDoubleSpinBox" name="dsb_Weight">
<property name="toolTip">
<string>Thickness of pattern lines.</string>
</property>
<property name="value">
<double>0.500000000000000</double>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Visible</string>
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="QComboBox" name="cb_Visible">
<property name="currentIndex">
<number>1</number>
</property>
<property name="maxVisibleItems">
<number>2</number>
</property>
<property name="maxCount">
<number>2</number>
</property>
<property name="minimumContentsLength">
<number>2</number>
</property>
<item>
<property name="text">
<string>False</string>
</property>
</item>
<item>
<property name="text">
<string>True</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
</layout>
</widget>