mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-09-13 20:23:04 +02:00
Add a new tab in settings, user can select a font size, a rotation angle
and a text width by default for new dynamic text, it work also in element editor command. git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@5568 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
parent
5f85edcc8c
commit
9e7899fd40
@ -31,11 +31,15 @@ PartDynamicTextField::PartDynamicTextField(QETElementEditor *editor, QGraphicsIt
|
||||
m_uuid(QUuid::createUuid())
|
||||
{
|
||||
setDefaultTextColor(Qt::black);
|
||||
setFont(QETApp::diagramTextsFont(9));
|
||||
setFont(QETApp::dynamicTextsItemFont());
|
||||
QSettings settings;
|
||||
setRotation(settings.value("dynamic_rotation", 0).toInt());
|
||||
setTextWidth(settings.value("dynamic_with", 0).toInt());
|
||||
setText("_");
|
||||
setTextFrom(DynamicElementTextItem::UserText);
|
||||
setFlags(QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemSendsGeometryChanges | QGraphicsItem::ItemIsMovable);
|
||||
|
||||
|
||||
//Option when text is displayed in multiple line
|
||||
QTextOption option = document()->defaultTextOption();
|
||||
option.setAlignment(Qt::AlignHCenter);
|
||||
@ -91,6 +95,7 @@ const QDomElement PartDynamicTextField::toXml(QDomDocument &dom_doc) const
|
||||
root_element.setAttribute("z", QString::number(zValue()));
|
||||
root_element.setAttribute("rotation", QString::number(QET::correctAngle(rotation())));
|
||||
root_element.setAttribute("font_size", font().pointSize());
|
||||
root_element.setAttribute("dynamicitemfont", (QETApp::dynamicTextsItemFont().family()));
|
||||
root_element.setAttribute("uuid", m_uuid.toString());
|
||||
root_element.setAttribute("frame", m_frame? "true" : "false");
|
||||
root_element.setAttribute("text_width", QString::number(m_text_width));
|
||||
@ -354,7 +359,7 @@ QColor PartDynamicTextField::color() const {
|
||||
void PartDynamicTextField::setFontSize(int s)
|
||||
{
|
||||
prepareAlignment();
|
||||
setFont(QETApp::diagramTextsFont(s));
|
||||
setFont(QETApp::dynamicTextsItemFont(s));
|
||||
finishAlignment();
|
||||
emit fontSizeChanged(s);
|
||||
}
|
||||
@ -496,7 +501,7 @@ void PartDynamicTextField::paint(QPainter *painter, const QStyleOptionGraphicsIt
|
||||
if (m_frame)
|
||||
{
|
||||
painter->save();
|
||||
painter->setFont(QETApp::diagramTextsFont(fontSize()));
|
||||
painter->setFont(QETApp::dynamicTextsItemFont(fontSize()));
|
||||
|
||||
//Adjust the thickness according to the font size,
|
||||
qreal w=0.3;
|
||||
|
@ -62,7 +62,7 @@ class PartText : public QGraphicsTextItem, public CustomElementPart {
|
||||
// Size value
|
||||
Q_PROPERTY(qreal size READ size WRITE setSize)
|
||||
qreal size () const {return font().pointSize();}
|
||||
void setSize (qreal s) {setFont(QETApp::diagramTextsFont(s));}
|
||||
void setSize (qreal s) {setFont(QETApp::dynamicTextsItemFont(s));}
|
||||
// Real size value
|
||||
Q_PROPERTY(qreal real_size READ realSize WRITE setRealSize)
|
||||
qreal realSize() const {return real_font_size_;}
|
||||
|
@ -850,12 +850,44 @@ QFont QETApp::diagramTextsItemFont(qreal size)
|
||||
}
|
||||
return(diagram_texts_item_font);
|
||||
}
|
||||
/**
|
||||
* @brief QETApp::dynamicTextsFont
|
||||
* the font for to use when add a dynamic texte
|
||||
* @param size
|
||||
* @return
|
||||
*/
|
||||
|
||||
|
||||
QFont QETApp::dynamicTextsItemFont(qreal size)
|
||||
{
|
||||
QSettings settings;
|
||||
|
||||
//Font to use
|
||||
QString dynamic_texts_item_family = settings.value("dynamicitemfont", "Sans Serif").toString();
|
||||
qreal dynamic_texts_item_size = settings.value("dynamicitemsize", 9.0).toDouble();
|
||||
qreal dynamic_texts_item_weight = settings.value("dynamicitemweight").toDouble();
|
||||
QString dynamic_texts_item_style = settings.value("dynamicitemstyle", "normal").toString();
|
||||
|
||||
if (size != -1.0) {
|
||||
dynamic_texts_item_size = size;
|
||||
}
|
||||
QFont dynamic_texts_item_font = QFont(dynamic_texts_item_family);
|
||||
dynamic_texts_item_font.setPointSizeF(dynamic_texts_item_size);
|
||||
dynamic_texts_item_font.setWeight(dynamic_texts_item_weight);
|
||||
dynamic_texts_item_font.setStyleName(dynamic_texts_item_style);
|
||||
if (dynamic_texts_item_size <= 4.0) {
|
||||
dynamic_texts_item_font.setWeight(QFont::Light);
|
||||
}
|
||||
return(dynamic_texts_item_font);
|
||||
}
|
||||
/**
|
||||
* @brief QETApp::foliolistTextsFont
|
||||
* the font for to use in summary pages
|
||||
* @param size
|
||||
* @return
|
||||
*/
|
||||
|
||||
|
||||
QFont QETApp::foliolistTextsFont(qreal size)
|
||||
{
|
||||
QSettings settings;
|
||||
|
@ -128,6 +128,7 @@ class QETApp : public QObject
|
||||
static QString lang_dir; ///< Directory containing localization files.
|
||||
static QFont diagramTextsFont(qreal = -1.0);
|
||||
static QFont diagramTextsItemFont(qreal = -1.0);
|
||||
static QFont dynamicTextsItemFont(qreal = -1.0);
|
||||
static QFont foliolistTextsFont(qreal = -1.0);
|
||||
static QETDiagramEditor *diagramEditorForFile(const QString &);
|
||||
static QETDiagramEditor *diagramEditorAncestorOf (const QWidget *child);
|
||||
|
@ -39,9 +39,12 @@ DynamicElementTextItem::DynamicElementTextItem(Element *parent_element) :
|
||||
m_parent_element(parent_element),
|
||||
m_uuid(QUuid::createUuid())
|
||||
{
|
||||
setFont(QETApp::diagramTextsFont(9));
|
||||
setFont(QETApp::dynamicTextsItemFont());
|
||||
setText(tr("Texte"));
|
||||
setParentItem(parent_element);
|
||||
setParentItem(parent_element);
|
||||
QSettings settings;
|
||||
setRotation(settings.value("dynamic_rotation", 0).toInt());
|
||||
setTextWidth(settings.value("dynamic_with", 0).toInt());
|
||||
connect(this, &DynamicElementTextItem::textEdited, [this](const QString &old_str, const QString &new_str)
|
||||
{
|
||||
if(this->m_parent_element && this->m_parent_element->diagram())
|
||||
@ -91,6 +94,7 @@ QDomElement DynamicElementTextItem::toXml(QDomDocument &dom_doc) const
|
||||
root_element.setAttribute("rotation", QString::number(QET::correctAngle(rotation())));
|
||||
root_element.setAttribute("font_size", font().pointSize());
|
||||
root_element.setAttribute("uuid", m_uuid.toString());
|
||||
root_element.setAttribute("dynamicitemfont", font().family());
|
||||
root_element.setAttribute("frame", m_frame? "true" : "false");
|
||||
root_element.setAttribute("text_width", QString::number(m_text_width));
|
||||
|
||||
@ -113,9 +117,9 @@ QDomElement DynamicElementTextItem::toXml(QDomDocument &dom_doc) const
|
||||
root_element.setAttribute("Valignment", me.valueToKey(Qt::AlignVCenter));
|
||||
|
||||
|
||||
QDomElement dom_text = dom_doc.createElement("text");
|
||||
dom_text.appendChild(dom_doc.createTextNode(toPlainText()));
|
||||
root_element.appendChild(dom_text);
|
||||
QDomElement dom_text = dom_doc.createElement("text");
|
||||
dom_text.appendChild(dom_doc.createTextNode(toPlainText()));
|
||||
root_element.appendChild(dom_text);
|
||||
|
||||
//Info name
|
||||
if(!m_info_name.isEmpty())
|
||||
@ -140,8 +144,8 @@ QDomElement DynamicElementTextItem::toXml(QDomDocument &dom_doc) const
|
||||
dom_color.appendChild(dom_doc.createTextNode(color().name()));
|
||||
root_element.appendChild(dom_color);
|
||||
}
|
||||
|
||||
return root_element;
|
||||
|
||||
return root_element;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -173,7 +177,7 @@ void DynamicElementTextItem::fromXml(const QDomElement &dom_elmt)
|
||||
setAlignment(Qt::Alignment(me.keyToValue(dom_elmt.attribute("Valignment").toStdString().data())) | this->alignment());
|
||||
|
||||
//Text
|
||||
QDomElement dom_text = dom_elmt.firstChildElement("text");
|
||||
QDomElement dom_text = dom_elmt.firstChildElement("text");
|
||||
if (!dom_text.isNull())
|
||||
setText(dom_text.text());
|
||||
|
||||
@ -635,7 +639,7 @@ void DynamicElementTextItem::paint(QPainter *painter, const QStyleOptionGraphics
|
||||
if (m_frame)
|
||||
{
|
||||
painter->save();
|
||||
painter->setFont(QETApp::diagramTextsFont(fontSize()));
|
||||
painter->setFont(QETApp::dynamicTextsItemFont(fontSize()));
|
||||
|
||||
//Adjust the thickness according to the font size,
|
||||
qreal w=0.3;
|
||||
|
@ -54,11 +54,19 @@ GeneralConfigurationPage::GeneralConfigurationPage(QWidget *parent) :
|
||||
settings.value("diagramitemstyle").toString() + ")";
|
||||
ui->m_font_pb->setText(fontInfos);
|
||||
|
||||
QString dynamicfontInfos = settings.value("dynamicitemfont").toString() + " " +
|
||||
settings.value("dynamicitemsize").toString() + " (" +
|
||||
settings.value("dynamicitemstyle").toString() + ")";
|
||||
ui->m_dynamic_font_pb->setText(dynamicfontInfos);
|
||||
|
||||
QString foliolistfontInfos = settings.value("foliolistfont").toString() + " " +
|
||||
settings.value("foliolistsize").toString() + " (" +
|
||||
settings.value("folioliststyle").toString() + ")";
|
||||
ui->m_folio_list_pb->setText(foliolistfontInfos);
|
||||
|
||||
ui->m_rotation->setValue(settings.value("dynamic_rotation", 0).toInt());
|
||||
ui->m_text_width_sb->setValue(settings.value("dynamic_with", 0).toInt());
|
||||
|
||||
ui->m_highlight_integrated_elements->setChecked(settings.value("diagrameditor/highlight-integrated-elements", true).toBool());
|
||||
ui->m_default_elements_info->setPlainText(settings.value("elementeditor/default-informations", "").toString());
|
||||
|
||||
@ -117,6 +125,8 @@ void GeneralConfigurationPage::applyConf()
|
||||
settings.setValue("nomenclature/terminal-exportlist",ui->m_export_terminal->isChecked());
|
||||
settings.setValue("border-columns_0",ui->m_border_0->isChecked());
|
||||
settings.setValue("diagrameditor/autosave-interval", ui->m_autosave_sb->value());
|
||||
settings.setValue("dynamic_rotation", ui->m_rotation->value());
|
||||
settings.setValue("dynamic_with", ui->m_text_width_sb->value());
|
||||
|
||||
QString path = settings.value("elements-collections/common-collection-path").toString();
|
||||
if (ui->m_common_elmt_path_cb->currentIndex() == 1)
|
||||
@ -232,6 +242,29 @@ void GeneralConfigurationPage::on_m_font_pb_clicked()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief GeneralConfigurationPage::m_dynamic_font_pb_clicked
|
||||
* Apply font to config
|
||||
*/
|
||||
void GeneralConfigurationPage::on_m_dynamic_font_pb_clicked()
|
||||
{
|
||||
bool ok;
|
||||
QSettings settings;
|
||||
QFont font = QFontDialog::getFont(&ok, QFont("Sans Serif", 9), this);
|
||||
if (ok)
|
||||
{
|
||||
settings.setValue("dynamicitemfont", font.family());
|
||||
settings.setValue("dynamicitemsize", font.pointSize());
|
||||
settings.setValue("dynamicitemweight", font.weight());
|
||||
settings.setValue("dynamicitemstyle", font.styleName());
|
||||
QString fontInfos = settings.value("dynamicitemfont").toString() + " " +
|
||||
settings.value("dynamicitemsize").toString() + " (" +
|
||||
settings.value("dynamicitemstyle").toString() + ")";
|
||||
ui->m_dynamic_font_pb->setText(fontInfos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief GeneralConfigurationPage::on_m_folio_list_pb_clicked
|
||||
* Apply font to summary pages
|
||||
@ -282,3 +315,4 @@ void GeneralConfigurationPage::on_m_custom_elmt_path_cb_currentIndexChanged(int
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,6 +39,7 @@ class GeneralConfigurationPage : public ConfigPage
|
||||
|
||||
private slots:
|
||||
void on_m_font_pb_clicked();
|
||||
void on_m_dynamic_font_pb_clicked();
|
||||
void on_m_folio_list_pb_clicked();
|
||||
void on_m_common_elmt_path_cb_currentIndexChanged(int index);
|
||||
void on_m_custom_elmt_path_cb_currentIndexChanged(int index);
|
||||
|
@ -41,7 +41,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>4</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab_3">
|
||||
<attribute name="title">
|
||||
@ -169,7 +169,7 @@
|
||||
<x>0</x>
|
||||
<y>20</y>
|
||||
<width>971</width>
|
||||
<height>376</height>
|
||||
<height>391</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
@ -468,6 +468,99 @@ Vous pouvez spécifier ici la valeur par défaut de ce champ pour les éléments
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string>Textes dynamiques</string>
|
||||
</attribute>
|
||||
<widget class="QGroupBox" name="groupBox6">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>20</y>
|
||||
<width>971</width>
|
||||
<height>391</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string/>
|
||||
</property>
|
||||
<widget class="QLabel" name="label_11">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>100</y>
|
||||
<width>535</width>
|
||||
<height>27</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Rotation des textes dynamiques</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSpinBox" name="m_rotation">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>850</x>
|
||||
<y>110</y>
|
||||
<width>87</width>
|
||||
<height>27</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>360</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="m_dynamic_font_pb">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>804</x>
|
||||
<y>60</y>
|
||||
<width>141</width>
|
||||
<height>34</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_12">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>60</y>
|
||||
<width>535</width>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Police des textes dynamiques</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSpinBox" name="m_text_width_sb">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>850</x>
|
||||
<y>150</y>
|
||||
<width>91</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>-1</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>150</y>
|
||||
<width>211</width>
|
||||
<height>18</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Longueur des textes</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@ -491,6 +584,9 @@ Vous pouvez spécifier ici la valeur par défaut de ce champ pour les éléments
|
||||
<tabstop>m_highlight_integrated_elements</tabstop>
|
||||
<tabstop>m_default_elements_info</tabstop>
|
||||
<tabstop>m_lang_cb</tabstop>
|
||||
<tabstop>m_dynamic_font_pb</tabstop>
|
||||
<tabstop>m_rotation</tabstop>
|
||||
<tabstop>m_text_width_sb</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user