Add widget combobox line weight to element editor

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2660 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
scorpio810
2013-12-19 15:22:12 +00:00
parent f4cd3cd58e
commit 5c3e0d6dc4
5 changed files with 50 additions and 32 deletions

View File

@@ -35,7 +35,10 @@ void CustomElementGraphicPart::stylesToXml(QDomElement &qde) const {
if (_lineweight == NoneWeight) css_like_styles += "none";
else if (_lineweight == ThinWeight) css_like_styles += "thin";
else if (_lineweight == NormalWeight) css_like_styles += "normal";
else if (_lineweight == UltraWeight) css_like_styles += "hight";
else if (_lineweight == BigWeight) css_like_styles += "eleve";
css_like_styles += ";filling:";
if (_filling == NoneFilling) css_like_styles += "none";
else if (_filling == BlackFilling) css_like_styles += "black";
@@ -79,9 +82,11 @@ void CustomElementGraphicPart::stylesFromXml(const QDomElement &qde) {
else if (style_value == "normal") _linestyle = NormalStyle;
// il n'y a pas de else car les valeurs non conformes sont ignorees (idem par la suite)
} else if (style_name == "line-weight") {
if (style_value == "thin") _lineweight = ThinWeight;
if (style_value == "none") _lineweight = NoneWeight;
else if (style_value == "thin") _lineweight = ThinWeight;
else if (style_value == "normal") _lineweight = NormalWeight;
else if (style_value == "none") _lineweight = NoneWeight;
else if (style_value == "hight") _lineweight = UltraWeight;
else if (style_value == "eleve") _lineweight = BigWeight;
} else if (style_name == "filling") {
if (style_value == "white") _filling = WhiteFilling;
else if (style_value == "black") _filling = BlackFilling;
@@ -129,9 +134,13 @@ void CustomElementGraphicPart::applyStylesToQPainter(QPainter &painter) const {
else if (_linestyle == NormalStyle) pen.setStyle(Qt::SolidLine);
// applique l'epaisseur de trait
if (_lineweight == NoneWeight) pen.setColor(QColor(0, 0, 0, 0));
else if (_lineweight == ThinWeight) pen.setWidth(0);
else if (_lineweight == NormalWeight) pen.setWidthF(1.0);
if (_lineweight == NoneWeight) pen.setColor(QColor(0, 0, 0, 0));
else if (_lineweight == ThinWeight) pen.setWidth(0);
else if (_lineweight == NormalWeight) pen.setWidthF(1.0);
else if (_lineweight == UltraWeight) pen.setWidthF(2.0);
else if (_lineweight == BigWeight) pen.setWidthF(5.0);
// applique le remplissage
if (_filling == NoneFilling) {

View File

@@ -38,9 +38,12 @@ class CustomElementGraphicPart : public CustomElementPart {
/// This enum lists the various line weights available to draw primitives.
enum LineWeight {
NormalWeight, ///< Normal line
NoneWeight, ///< Invisible line
ThinWeight, ///< Thin line
NoneWeight ///< Invisible line
NormalWeight, ///< Normal line 1px
UltraWeight, ///< Normal line 2px
BigWeight ///< Big Line
};
/// This enum lists the various filling colors available to draw primitives.

View File

@@ -45,11 +45,13 @@ StyleEditor::StyleEditor(QETElementEditor *editor, CustomElementGraphicPart *p,
normal_style -> setChecked(true);
// epaisseur
weight = new QButtonGroup(this);
weight -> addButton(none_weight = new QRadioButton(tr("Nulle", "element part weight")), CustomElementGraphicPart::NoneWeight);
weight -> addButton(thin_weight = new QRadioButton(tr("Fine", "element part weight")), CustomElementGraphicPart::ThinWeight);
weight -> addButton(normal_weight = new QRadioButton(tr("Normale", "element part weight")), CustomElementGraphicPart::NormalWeight);
size_weight = new QComboBox(this);
size_weight -> addItem(tr("Nulle", "element part weight"), CustomElementGraphicPart::NoneWeight);
size_weight -> addItem(tr("Fine", "element part weight"), CustomElementGraphicPart::ThinWeight);
size_weight -> addItem(tr("Normale", "element part weight"), CustomElementGraphicPart::NormalWeight);
size_weight -> addItem(tr("Forte", "element part weight"), CustomElementGraphicPart::UltraWeight);
size_weight -> addItem(tr("\311lev\351", "element part weight"), CustomElementGraphicPart::BigWeight);
// remplissage
filling_color = new QComboBox (this);
filling_color -> addItem(tr("Aucun", "element part filling"), CustomElementGraphicPart::NoneFilling);
@@ -85,16 +87,14 @@ StyleEditor::StyleEditor(QETElementEditor *editor, CustomElementGraphicPart *p,
style_layout -> addWidget(dotted_style);
style_layout -> addStretch();
main_layout -> addLayout(style_layout);
QHBoxLayout *weight_layout = new QHBoxLayout();
weight_layout -> addWidget(new QLabel(tr("\311paisseur : ")));
weight_layout -> addWidget(none_weight);
weight_layout -> addWidget(thin_weight);
weight_layout -> addWidget(normal_weight);
weight_layout -> addStretch();
main_layout -> addLayout(weight_layout);
main_layout -> addWidget(antialiasing);
QHBoxLayout *weight_layout = new QHBoxLayout();
weight_layout -> addWidget(new QLabel(tr("\311paisseur : ")), 0, Qt::AlignRight);
weight_layout -> addWidget(size_weight);
main_layout -> addLayout(weight_layout);
main_layout -> addSpacing(10);
main_layout -> addWidget(new QLabel("<u>" + tr("G\351om\351trie :") + "</u> "));
main_layout -> addStretch();
@@ -122,8 +122,8 @@ void StyleEditor::updatePart() {
part -> setLineStyle(static_cast<CEGP::LineStyle>(style -> checkedId()));
// applique l'epaisseur
part -> setLineWeight(static_cast<CEGP::LineWeight>(weight -> checkedId()));
part -> setLineWeight(static_cast<CEGP::LineWeight>(size_weight -> currentIndex()));
// applique le remplissage
part -> setFilling(static_cast<CEGP::Filling>(filling_color -> currentIndex()));
}
@@ -135,7 +135,7 @@ void StyleEditor::updatePartColor() { addChangePartCommand(tr("style co
/// Met a jour le style du trait et cree un objet d'annulation
void StyleEditor::updatePartLineStyle() { addChangePartCommand(tr("style ligne"), part, "line-style", style -> checkedId()); }
/// Met a jour l'epaisseur du trait et cree un objet d'annulation
void StyleEditor::updatePartLineWeight() { addChangePartCommand(tr("style epaisseur"), part, "line-weight", weight -> checkedId()); }
void StyleEditor::updatePartLineWeight() { addChangePartCommand(tr("style epaisseur"), part, "line-weight", size_weight -> currentIndex());}
/// Met a jour la couleur de fond et cree un objet d'annulation
void StyleEditor::updatePartFilling() { addChangePartCommand(tr("style remplissage"), part, "filling", filling_color -> currentIndex());}
@@ -155,8 +155,8 @@ void StyleEditor::updateForm() {
style -> button(part -> lineStyle()) -> setChecked(true);
// lit l'epaisseur
weight -> button(part -> lineWeight()) -> setChecked(true);
size_weight -> setCurrentIndex(part -> lineWeight());
// lit le remplissage
filling_color -> setCurrentIndex(part -> filling());
activeConnections(true);
@@ -199,13 +199,13 @@ void StyleEditor::activeConnections(bool active) {
if (active) {
connect (outline_color, SIGNAL(activated(int)), this, SLOT(updatePartColor()));
connect(style, SIGNAL(buttonClicked(int)), this, SLOT(updatePartLineStyle()));
connect(weight, SIGNAL(buttonClicked(int)), this, SLOT(updatePartLineWeight()));
connect(size_weight, SIGNAL(activated(int)), this, SLOT(updatePartLineWeight()));
connect(filling_color, SIGNAL(activated(int)), this, SLOT(updatePartFilling()));
connect(antialiasing, SIGNAL(stateChanged(int)), this, SLOT(updatePartAntialiasing()));
} else {
disconnect(outline_color, SIGNAL(activated(int)), this, SLOT(updatePartColor()));
disconnect(style, SIGNAL(buttonClicked(int)), this, SLOT(updatePartLineStyle()));
disconnect(weight, SIGNAL(buttonClicked(int)), this, SLOT(updatePartLineWeight()));
disconnect(size_weight, SIGNAL(activated(int)), this, SLOT(updatePartLineWeight()));
disconnect(filling_color, SIGNAL(activated(int)), this, SLOT(updatePartFilling()));
disconnect(antialiasing, SIGNAL(stateChanged(int)), this, SLOT(updatePartAntialiasing()));
}

View File

@@ -40,12 +40,12 @@ class StyleEditor : public ElementItemEditor {
private:
CustomElementGraphicPart *part;
QVBoxLayout *main_layout;
QButtonGroup *style, *weight;
QButtonGroup *style;
QRadioButton *black_color, *white_color, *normal_style, *dashed_style, *dashdotted_style, *dotted_style, *green_color, *red_color, *blue_color;
QRadioButton *none_weight, *thin_weight, *normal_weight, *no_filling;
QRadioButton *black_filling, *white_filling, *green_filling, *red_filling, *blue_filling;
QCheckBox *antialiasing;
QComboBox *filling_color, *outline_color;
QComboBox *filling_color, *outline_color, *size_weight;
// methods
public:

View File

@@ -719,6 +719,9 @@ bool CustomElement::validOrientationAttribute(const QDomElement &e) {
- line-weight : epaiseur du trait
- thin : trait fin
- normal : trait d'epaisseur 1 [par defaut]
- none : trait invisible
- forte : trait d'epaisseur 2
- eleve : trait d'epaisseur 5
- filling : remplissage de la forme
- white : remplissage blanc
- black : remplissage noir
@@ -761,9 +764,12 @@ void CustomElement::setPainterStyle(QDomElement &e, QPainter &qp) {
else if (style_value == "dashdotted") pen.setStyle(Qt::DashDotLine);
else if (style_value == "normal") pen.setStyle(Qt::SolidLine);
} else if (style_name == "line-weight") {
if (style_value == "thin") pen.setWidth(0);
if (style_value == "none") pen.setColor(QColor(0, 0, 0, 0));
else if (style_value == "thin") pen.setWidth(0);
else if (style_value == "normal") pen.setWidthF(1.0);
else if (style_value == "none") pen.setColor(QColor(0, 0, 0, 0));
else if (style_value == "hight") pen.setWidthF(2.0);
else if (style_value == "eleve") pen.setWidthF(5.0);
} else if (style_name == "filling") {
if (style_value == "white") {
brush.setStyle(Qt::SolidPattern);