r21351 by jghali -

scribus-commit scribus-commit at lists.scribus.net
Tue May 24 18:27:54 UTC 2016


Author: jghali
Date: Tue May 24 18:27:54 2016
New Revision: 21351

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=21351
Log:
#14093: Paragraph Style and Character Style combo boxes keep going back to "No Style" after modifying styles

Modified:
    trunk/Scribus/scribus/ui/spalette.cpp

Modified: trunk/Scribus/scribus/ui/spalette.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21351&path=/trunk/Scribus/scribus/ui/spalette.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/spalette.cpp	(original)
+++ trunk/Scribus/scribus/ui/spalette.cpp	Tue May 24 18:27:54 2016
@@ -50,7 +50,11 @@
 
 void ParaStyleComboBox::updateFormatList()
 {
-	disconnect(this, SIGNAL(activated(int)), this, SLOT(selFormat(int)));
+	QString oldStyleName;
+	if (currentDoc && this->count() > 0)
+		oldStyleName = this->currentText();
+
+	bool sigBlocked = this->blockSignals(true);
 	clear();
 	if (currentDoc != NULL)
 	{
@@ -63,6 +67,13 @@
 		}
 		st.sort();
 		addItems(st);
+
+		if (oldStyleName.length() > 0)
+		{
+			int newIndex = this->findText(oldStyleName);
+			if (newIndex >= 0)
+				setCurrentIndex(newIndex);
+		}
 	}
 	QListView *tmpView = dynamic_cast<QListView*>(view());
 	if (tmpView)
@@ -71,7 +82,7 @@
 		if (tmpWidth > 0)
 			tmpView->setMinimumWidth(tmpWidth + 24);
 	}
-	connect(this, SIGNAL(activated(int)), this, SLOT(selFormat(int)));
+	this->blockSignals(sigBlocked);
 }
 
 void ParaStyleComboBox::selFormat(int e)
@@ -103,7 +114,11 @@
 
 void CharStyleComboBox::updateFormatList()
 {
-	disconnect(this, SIGNAL(activated(int)), this, SLOT(selFormat(int)));
+	QString oldStyleName;
+	if (currentDoc && this->count() > 0)
+		oldStyleName = this->currentText();
+
+	bool sigBlocked = this->blockSignals(true);
 	clear();
 	if (currentDoc != NULL)
 	{
@@ -116,6 +131,13 @@
 		}
 		st.sort();
 		addItems(st);
+
+		if (oldStyleName.length() > 0)
+		{
+			int newIndex = this->findText(oldStyleName);
+			if (newIndex >= 0)
+				setCurrentIndex(newIndex);
+		}
 	}
 	QListView *tmpView = dynamic_cast<QListView*>(view());
 	if (tmpView)
@@ -124,7 +146,7 @@
 		if (tmpWidth > 0)
 			tmpView->setMinimumWidth(tmpWidth + 24);
 	}
-	connect(this, SIGNAL(activated(int)), this, SLOT(selFormat(int)));
+	this->blockSignals(sigBlocked);
 }
 
 void CharStyleComboBox::selFormat(int e)
@@ -156,12 +178,15 @@
 
 void CellStyleComboBox::updateFormatList()
 {
-	disconnect(this, SIGNAL(activated(int)), this, SLOT(selFormat(int)));
-	clear();
-	if (currentDoc != NULL)
-	{
-		QStringList st;
-		st.clear();
+	QString oldStyleName;
+	if (currentDoc && this->count() > 0)
+		oldStyleName = this->currentText();
+
+	bool sigBlocked = this->blockSignals(true);
+	clear();
+	if (currentDoc != NULL)
+	{
+		QStringList st;
 		addItem( tr("No Style"));
 		for (int x = 0; x < currentDoc->cellStyles().count(); ++x)
 		{
@@ -170,12 +195,19 @@
 		}
 		st.sort();
 		addItems(st);
+
+		if (oldStyleName.length() > 0)
+		{
+			int newIndex = this->findText(oldStyleName);
+			if (newIndex >= 0)
+				setCurrentIndex(newIndex);
+		}
 	}
 	QListView *tmpView = dynamic_cast<QListView*>(view());
 	int tmpWidth = tmpView->sizeHintForColumn(0);
 	if (tmpWidth > 0)
 		tmpView->setMinimumWidth(tmpWidth + 24);
-	connect(this, SIGNAL(activated(int)), this, SLOT(selFormat(int)));
+	this->blockSignals(sigBlocked);
 }
 
 void CellStyleComboBox::selFormat(int e)
@@ -211,12 +243,15 @@
 
 void TableStyleComboBox::updateFormatList()
 {
-	disconnect(this, SIGNAL(activated(int)), this, SLOT(selFormat(int)));
-	clear();
-	if (currentDoc != NULL)
-	{
-		QStringList st;
-		st.clear();
+	QString oldStyleName;
+	if (currentDoc && this->count() > 0)
+		oldStyleName = this->currentText();
+
+	bool sigBlocked = this->blockSignals(true);
+	clear();
+	if (currentDoc != NULL)
+	{
+		QStringList st;
 		addItem( tr("No Style"));
 		for (int x = 0; x < currentDoc->tableStyles().count(); ++x)
 		{
@@ -225,12 +260,19 @@
 		}
 		st.sort();
 		addItems(st);
+
+		if (oldStyleName.length() > 0)
+		{
+			int newIndex = this->findText(oldStyleName);
+			if (newIndex >= 0)
+				setCurrentIndex(newIndex);
+		}
 	}
 	QListView *tmpView = dynamic_cast<QListView*>(view());
 	int tmpWidth = tmpView->sizeHintForColumn(0);
 	if (tmpWidth > 0)
 		tmpView->setMinimumWidth(tmpWidth + 24);
-	connect(this, SIGNAL(activated(int)), this, SLOT(selFormat(int)));
+	this->blockSignals(sigBlocked);
 }
 
 void TableStyleComboBox::selFormat(int e)




More information about the scribus-commit mailing list