r21848 by jghali - make style manager font features pane react on language change

scribus-commit scribus-commit at lists.scribus.net
Mon Mar 20 23:28:32 UTC 2017


Author: jghali
Date: Mon Mar 20 23:28:32 2017
New Revision: 21848

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=21848
Log:
make style manager font features pane react on language change

Modified:
    trunk/Scribus/scribus/ui/smfontfeatures.cpp
    trunk/Scribus/scribus/ui/smfontfeatures.h

Modified: trunk/Scribus/scribus/ui/smfontfeatures.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21848&path=/trunk/Scribus/scribus/ui/smfontfeatures.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/smfontfeatures.cpp	(original)
+++ trunk/Scribus/scribus/ui/smfontfeatures.cpp	Mon Mar 20 23:28:32 2017
@@ -41,6 +41,68 @@
 	connect(this->widthComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotChange()));
 	connect(this->fractionComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotChange()));
 	connect(this->setMenu, SIGNAL(triggered(QAction*)), this, SLOT(slotChange()));
+}
+
+void SMFontFeatures::changeEvent(QEvent *e)
+{
+	if (e->type() == QEvent::LanguageChange)
+		languageChange();
+	else
+		QWidget::changeEvent(e);
+}
+
+void SMFontFeatures::languageChange()
+{
+	QSignalBlocker blocker01(this->CommonCheck);
+	QSignalBlocker blocker02(this->ContextualCheck);
+	QSignalBlocker blocker03(this->DiscretinoryCheck);
+	QSignalBlocker blocker04(this->HistoricalCheck);
+	QSignalBlocker blocker05(this->SlashedZeroCheck);
+	QSignalBlocker blocker06(this->capitalsComboBox);
+	QSignalBlocker blocker07(this->positionComboBox);
+	QSignalBlocker blocker08(this->numeralComboBox);
+	QSignalBlocker blocker09(this->widthComboBox);
+	QSignalBlocker blocker10(this->fractionComboBox);
+	QSignalBlocker blocker11(this->setMenu);
+
+	QStringList capitalFeatures  = comboboxFeatures(capitalsComboBox);
+	QStringList positionFeatures = comboboxFeatures(positionComboBox);
+	QStringList numeralFeatures  = comboboxFeatures(numeralComboBox);
+	QStringList widthFeatures    = comboboxFeatures(widthComboBox);
+	QStringList fractionFeatures = comboboxFeatures(fractionComboBox);
+
+	int oldCapitalIndex  = capitalsComboBox->currentIndex();
+	int oldPositionIndex = positionComboBox->currentIndex();
+	int oldNumeralIndex  = numeralComboBox->currentIndex();
+	int oldWidthIndex    = widthComboBox->currentIndex();
+	int oldFractionIndex = fractionComboBox->currentIndex();
+
+	retranslateUi(this);
+
+	setupCapitalCombo(capitalFeatures);
+	setupPositionCombo(positionFeatures);
+	setupNumeralStyleCombo(numeralFeatures);
+	setupNumeralWidthCombo(widthFeatures);
+	setupNumeralFractionCombo(fractionFeatures);
+
+	capitalsComboBox->setCurrentIndex(oldCapitalIndex);
+	positionComboBox->setCurrentIndex(oldPositionIndex);
+	numeralComboBox->setCurrentIndex(oldNumeralIndex);
+	widthComboBox->setCurrentIndex(oldWidthIndex);
+	fractionComboBox->setCurrentIndex(oldFractionIndex);
+}
+
+QStringList SMFontFeatures::comboboxFeatures(QComboBox* combo)
+{
+	QStringList features;
+	for (int i = 0; i < combo->count(); ++i)
+	{
+		QVariant varVal = combo->itemData(i);
+		QString value = varVal.toString();
+		if (value.length() > 0)
+			features.append(value);
+	}
+	return features;
 }
 
 void SMFontFeatures::setFontFeatures(QString s, QStringList fontFeaturesList)

Modified: trunk/Scribus/scribus/ui/smfontfeatures.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21848&path=/trunk/Scribus/scribus/ui/smfontfeatures.h
==============================================================================
--- trunk/Scribus/scribus/ui/smfontfeatures.h	(original)
+++ trunk/Scribus/scribus/ui/smfontfeatures.h	Mon Mar 20 23:28:32 2017
@@ -39,6 +39,9 @@
 	SMFontFeatures(QWidget *parent);
 	~SMFontFeatures(){}
 
+	virtual void changeEvent(QEvent *e);
+	void languageChange();
+
 	void setFontFeatures(QString s, QStringList fontFeaturesList);
 	void setFontFeatures(QString val, QStringList fontFeatures, bool isParentVal);
 	QString fontFeatures();
@@ -61,6 +64,9 @@
 	void setupNumeralStyleCombo(QStringList fontFeatures);
 	void setupNumeralWidthCombo(QStringList fontFeatures);
 	void setupNumeralFractionCombo(QStringList fontFeatures);
+
+	QStringList comboboxFeatures(QComboBox* combo);
+
 	bool m_hasParent;
 	bool m_useParentValue;
 	QString m_pValue;




More information about the scribus-commit mailing list