From f7478c20513880b86b35085c0ae80cba6b33c272 Mon Sep 17 00:00:00 2001 From: blacksun Date: Sun, 2 Jun 2013 21:37:04 +0000 Subject: [PATCH] add widget to configure rotation conductor text by default (not finish) git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2198 bfdf4180-ca20-0410-9c96-a3a8aa849046 --- sources/conductor.cpp | 4 +++- sources/conductorproperties.cpp | 4 ++++ sources/conductorproperties.h | 3 +++ sources/conductorpropertieswidget.cpp | 31 +++++++++++++++++++++++++-- sources/conductorpropertieswidget.h | 3 +++ sources/diagramview.cpp | 5 +++-- 6 files changed, 45 insertions(+), 5 deletions(-) diff --git a/sources/conductor.cpp b/sources/conductor.cpp index 6e70cb5e6..e8fd1ba93 100644 --- a/sources/conductor.cpp +++ b/sources/conductor.cpp @@ -1124,7 +1124,8 @@ void Conductor::calculateTextItemPosition() { } else { // positionnement automatique basique text_item -> setPos(middleSegment() -> middle()); - middleSegment() -> isVertical()? text_item -> setRotationAngle(270): text_item -> setRotationAngle(0); + middleSegment() -> isVertical()? text_item -> setRotationAngle(properties_.verti_rotate_text): + text_item -> setRotationAngle(properties_.horiz_rotate_text); } } @@ -1222,6 +1223,7 @@ ConductorProperties Conductor::properties() const { void Conductor::readProperties() { // la couleur n'est vraiment applicable que lors du rendu du conducteur setText(properties_.text); + calculateTextItemPosition(); text_item -> setVisible(properties_.type == ConductorProperties::Multi); } diff --git a/sources/conductorproperties.cpp b/sources/conductorproperties.cpp index 876affbea..789be7b13 100644 --- a/sources/conductorproperties.cpp +++ b/sources/conductorproperties.cpp @@ -346,6 +346,8 @@ int ConductorProperties::operator==(const ConductorProperties &other) { other.color == color &&\ other.style == style &&\ other.text == text &&\ + other.verti_rotate_text == verti_rotate_text &&\ + other.horiz_rotate_text == horiz_rotate_text &&\ other.singleLineProperties == singleLineProperties ); } @@ -360,6 +362,8 @@ int ConductorProperties::operator!=(const ConductorProperties &other) { other.color != color ||\ other.style != style ||\ other.text != text ||\ + other.verti_rotate_text != verti_rotate_text ||\ + other.horiz_rotate_text != horiz_rotate_text ||\ other.singleLineProperties != singleLineProperties ); } diff --git a/sources/conductorproperties.h b/sources/conductorproperties.h index 1bf010010..bd9443157 100644 --- a/sources/conductorproperties.h +++ b/sources/conductorproperties.h @@ -79,6 +79,9 @@ class ConductorProperties { QColor color; /// Texte displayed for multiline conductors QString text; + /// rotation angle texte + double verti_rotate_text; + double horiz_rotate_text; /// conducteur style (Qt::SolidLine or Qt::DashLine) Qt::PenStyle style; diff --git a/sources/conductorpropertieswidget.cpp b/sources/conductorpropertieswidget.cpp index e7f60271c..2efb25133 100644 --- a/sources/conductorpropertieswidget.cpp +++ b/sources/conductorpropertieswidget.cpp @@ -19,6 +19,7 @@ #include #include "conductor.h" #include "qeticons.h" +#include "qetapp.h" /** Constructeur @@ -46,7 +47,6 @@ ConductorPropertiesWidget::ConductorPropertiesWidget(const ConductorProperties & void ConductorPropertiesWidget::buildInterface() { setFocusPolicy(Qt::StrongFocus); - setMinimumSize(380, 350); QVBoxLayout *main_layout = new QVBoxLayout(this); main_layout -> setContentsMargins(0, 0, 0, 0); @@ -65,6 +65,22 @@ void ConductorPropertiesWidget::buildInterface() { text_field = new QLineEdit(); multiline_layout -> addWidget(text); multiline_layout -> addWidget(text_field); + + QGridLayout *rotate_text_layout = new QGridLayout; + QLabel *rotate_label = new QLabel(tr("Rotation du texte sur conducteur :")); + rotate_text_layout -> addWidget(rotate_label, 0, 0); + + QLabel *verti_text = new QLabel(tr("Vertical")); + verti_select = QETApp::createTextOrientationSpinBoxWidget(); + rotate_text_layout -> addWidget(verti_text, 1, 0); + rotate_text_layout -> setAlignment(verti_text, Qt::AlignCenter); + rotate_text_layout -> addWidget(verti_select, 2, 0); + + QLabel *horiz_text = new QLabel(tr("Horizontal")); + horiz_select = QETApp::createTextOrientationSpinBoxWidget(); + rotate_text_layout -> addWidget(horiz_text, 1, 1); + rotate_text_layout -> setAlignment(horiz_text, Qt::AlignCenter); + rotate_text_layout -> addWidget(horiz_select, 2, 1); singleline = new QRadioButton(tr("Unifilaire")); @@ -132,12 +148,13 @@ void ConductorPropertiesWidget::buildInterface() { groupbox_layout -> addWidget(simple); groupbox_layout -> addWidget(multiline); groupbox_layout -> addLayout(multiline_layout); + groupbox_layout -> addLayout(rotate_text_layout); groupbox_layout -> addWidget(singleline); groupbox_layout -> addLayout(singleline_layout1); groupbox2_layout -> addLayout(color_layout); groupbox2_layout -> addLayout(style_layout); - + radio_buttons = new QButtonGroup(this); radio_buttons -> addButton(simple, ConductorProperties::Simple); radio_buttons -> addButton(multiline, ConductorProperties::Multi); @@ -160,6 +177,8 @@ void ConductorPropertiesWidget::buildConnections() { connect(text_field, SIGNAL(textChanged(const QString &)), this, SLOT(updateConfig())); connect(line_style, SIGNAL(currentIndexChanged(int)), this, SLOT(updateConfig())); connect(color_button, SIGNAL(clicked()), this, SLOT(chooseColor())); + connect(verti_select, SIGNAL(editingFinished(double)), this, SLOT(updateConfig())); + connect(horiz_select, SIGNAL(editingFinished(double)), this, SLOT(updateConfig())); } /** @@ -204,10 +223,14 @@ void ConductorPropertiesWidget::destroyConnections() { disconnect(text_field, SIGNAL(textChanged(const QString &)), this, SLOT(updateConfig())); disconnect(color_button, SIGNAL(clicked()), this, SLOT(chooseColor())); disconnect(line_style, SIGNAL(currentIndexChanged(int)), this, SLOT(updateConfig())); + disconnect(verti_select, SIGNAL(editingFinished(double)), this, SLOT(updateConfig())); + disconnect(horiz_select, SIGNAL(editingFinished(double)), this, SLOT(updateConfig())); } /// Destructeur ConductorPropertiesWidget::~ConductorPropertiesWidget() { + delete verti_select; + delete horiz_select; } /// Met a jour les proprietes @@ -216,6 +239,8 @@ void ConductorPropertiesWidget::updateConfig() { properties_.color = colorButton(); properties_.style = static_cast(line_style -> itemData(line_style -> currentIndex()).toInt()); properties_.text = text_field -> text(); + properties_.verti_rotate_text = verti_select -> value(); + properties_.horiz_rotate_text = horiz_select -> value(); properties_.singleLineProperties.hasGround = ground_checkbox -> isChecked(); properties_.singleLineProperties.hasNeutral = neutral_checkbox -> isChecked(); properties_.singleLineProperties.is_pen = merge_checkbox -> isChecked(); @@ -240,6 +265,8 @@ void ConductorPropertiesWidget::updateDisplay() { phase_spinbox -> setValue(properties_.singleLineProperties.phasesCount()); phase_slider -> setValue(properties_.singleLineProperties.phasesCount()); phase_checkbox -> setChecked(properties_.singleLineProperties.phasesCount()); + verti_select -> setValue(properties_.verti_rotate_text); + horiz_select -> setValue(properties_.horiz_rotate_text); buildConnections(); updatePreview(); diff --git a/sources/conductorpropertieswidget.h b/sources/conductorpropertieswidget.h index f89751e8e..e4bad30d3 100644 --- a/sources/conductorpropertieswidget.h +++ b/sources/conductorpropertieswidget.h @@ -18,6 +18,7 @@ #ifndef CONDUCTOR_PROPERTIES_WIDGET_H #define CONDUCTOR_PROPERTIES_WIDGET_H #include "conductorproperties.h" +#include "qtextorientationspinboxwidget.h" #include /** This widget enables users to change the properties of a particular @@ -62,6 +63,8 @@ class ConductorPropertiesWidget : public QWidget { QRadioButton *simple; QRadioButton *multiline; QLineEdit *text_field; + QTextOrientationSpinBoxWidget *verti_select; + QTextOrientationSpinBoxWidget *horiz_select; QRadioButton *singleline; QCheckBox *phase_checkbox; QSlider *phase_slider; diff --git a/sources/diagramview.cpp b/sources/diagramview.cpp index 99a8e527a..74cab954a 100644 --- a/sources/diagramview.cpp +++ b/sources/diagramview.cpp @@ -545,8 +545,6 @@ void DiagramView::editDiagramProperties() { popup.setWindowFlags(Qt::Sheet); #endif - popup.setMinimumWidth(786); - popup.setMinimumHeight(500); popup.setWindowTitle(tr("Propri\351t\351s du sch\351ma", "window title")); BorderPropertiesWidget *border_infos = new BorderPropertiesWidget(border, &popup); @@ -588,6 +586,9 @@ void DiagramView::editDiagramProperties() { layout_v.addLayout(hlayout1); layout_v.addStretch(); layout_v.addWidget(&boutons); + //workaround to get a good size by default with this widget + popup.setMinimumSize(popup.minimumSizeHint()); + // si le dialogue est accepte if (popup.exec() == QDialog::Accepted && !diagram_is_read_only) { TitleBlockProperties new_titleblock = titleblock_infos -> titleBlockProperties();