[qet] qet/qet: [5568] Add a new tab in settings, user can select a font size, a rotation angle

[ Thread Index | Date Index | More lists.tuxfamily.org/qet Archives ]


Revision: 5568
Author:   scorpio810
Date:     2018-10-27 01:42:49 +0200 (Sat, 27 Oct 2018)
Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/sources/editor/graphicspart/partdynamictextfield.cpp
    trunk/sources/editor/graphicspart/parttext.h
    trunk/sources/qetapp.cpp
    trunk/sources/qetapp.h
    trunk/sources/qetgraphicsitem/dynamicelementtextitem.cpp
    trunk/sources/ui/configpage/generalconfigurationpage.cpp
    trunk/sources/ui/configpage/generalconfigurationpage.h
    trunk/sources/ui/configpage/generalconfigurationpage.ui

Modified: trunk/sources/editor/graphicspart/partdynamictextfield.cpp
===================================================================
--- trunk/sources/editor/graphicspart/partdynamictextfield.cpp	2018-10-26 08:45:38 UTC (rev 5567)
+++ trunk/sources/editor/graphicspart/partdynamictextfield.cpp	2018-10-26 23:42:49 UTC (rev 5568)
@@ -31,11 +31,15 @@
 	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 @@
 	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 @@
 void PartDynamicTextField::setFontSize(int s)
 {
 	prepareAlignment();
-	setFont(QETApp::diagramTextsFont(s));
+	setFont(QETApp::dynamicTextsItemFont(s));
 	finishAlignment();
 	emit fontSizeChanged(s);
 }
@@ -496,7 +501,7 @@
 	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;

Modified: trunk/sources/editor/graphicspart/parttext.h
===================================================================
--- trunk/sources/editor/graphicspart/parttext.h	2018-10-26 08:45:38 UTC (rev 5567)
+++ trunk/sources/editor/graphicspart/parttext.h	2018-10-26 23:42:49 UTC (rev 5568)
@@ -62,7 +62,7 @@
 	// 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_;}

Modified: trunk/sources/qetapp.cpp
===================================================================
--- trunk/sources/qetapp.cpp	2018-10-26 08:45:38 UTC (rev 5567)
+++ trunk/sources/qetapp.cpp	2018-10-26 23:42:49 UTC (rev 5568)
@@ -851,11 +851,43 @@
 	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;

Modified: trunk/sources/qetapp.h
===================================================================
--- trunk/sources/qetapp.h	2018-10-26 08:45:38 UTC (rev 5567)
+++ trunk/sources/qetapp.h	2018-10-26 23:42:49 UTC (rev 5568)
@@ -128,6 +128,7 @@
 		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);

Modified: trunk/sources/qetgraphicsitem/dynamicelementtextitem.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/dynamicelementtextitem.cpp	2018-10-26 08:45:38 UTC (rev 5567)
+++ trunk/sources/qetgraphicsitem/dynamicelementtextitem.cpp	2018-10-26 23:42:49 UTC (rev 5568)
@@ -39,9 +39,12 @@
 	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 @@
 	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 @@
 		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 @@
 		dom_color.appendChild(dom_doc.createTextNode(color().name()));
 		root_element.appendChild(dom_color);
 	}
-    
-    return root_element;
+	
+	return root_element;
 }
 
 /**
@@ -173,7 +177,7 @@
 		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 @@
 	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;

Modified: trunk/sources/ui/configpage/generalconfigurationpage.cpp
===================================================================
--- trunk/sources/ui/configpage/generalconfigurationpage.cpp	2018-10-26 08:45:38 UTC (rev 5567)
+++ trunk/sources/ui/configpage/generalconfigurationpage.cpp	2018-10-26 23:42:49 UTC (rev 5568)
@@ -54,11 +54,19 @@
                         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 @@
 	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)
@@ -233,6 +243,29 @@
 }
 
 /**
+ * @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 @@
 		}
 	}
 }
+

Modified: trunk/sources/ui/configpage/generalconfigurationpage.h
===================================================================
--- trunk/sources/ui/configpage/generalconfigurationpage.h	2018-10-26 08:45:38 UTC (rev 5567)
+++ trunk/sources/ui/configpage/generalconfigurationpage.h	2018-10-26 23:42:49 UTC (rev 5568)
@@ -39,6 +39,7 @@
 	
 	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);

Modified: trunk/sources/ui/configpage/generalconfigurationpage.ui
===================================================================
--- trunk/sources/ui/configpage/generalconfigurationpage.ui	2018-10-26 08:45:38 UTC (rev 5567)
+++ trunk/sources/ui/configpage/generalconfigurationpage.ui	2018-10-26 23:42:49 UTC (rev 5568)
@@ -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 @@
        </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 @@
   <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/>


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/