r18318 by jghali - #11588: incorrect page size in preferences

scribus-commit scribus-commit at lists.scribus.net
Fri Jun 14 20:19:35 UTC 2013


Author: jghali
Date: Fri Jun 14 20:19:35 2013
New Revision: 18318

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=18318
Log:
#11588: incorrect page size in preferences

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

Modified: trunk/Scribus/scribus/ui/prefs_documentsetup.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18318&path=/trunk/Scribus/scribus/ui/prefs_documentsetup.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/prefs_documentsetup.cpp (original)
+++ trunk/Scribus/scribus/ui/prefs_documentsetup.cpp Fri Jun 14 20:19:35 2013
@@ -125,14 +125,6 @@
 
 	unitRatio = unitGetRatioFromIndex(prefsData->docSetupPrefs.docUnitIndex);
 	setupPageSizes(prefsData);
-//	prefsPageSizeName = prefsData->docSetupPrefs.pageSize;
-//	PageSize *ps=new PageSize(prefsPageSizeName);
-//	pageSizeComboBox->addItems(ps->activeSizeTRList());
-//	pageSizeComboBox->addItem( CommonStrings::trCustomPageSize );
-//	if (prefsData->docSetupPrefs.pageSize == CommonStrings::customPageSize)
-//		setCurrentComboItem(pageSizeComboBox, CommonStrings::trCustomPageSize);
-//	else
-//		setCurrentComboItem(pageSizeComboBox, prefsPageSizeName);
 
 	pageOrientationComboBox->setCurrentIndex(prefsData->docSetupPrefs.pageOrientation);
 	pageUnitsComboBox->setCurrentIndex(prefsData->docSetupPrefs.docUnitIndex);
@@ -189,7 +181,7 @@
 
 void Prefs_DocumentSetup::saveGuiToPrefs(struct ApplicationPrefs *prefsData) const
 {
-	prefsData->docSetupPrefs.pageSize=prefsPageSizeName;
+	prefsData->docSetupPrefs.pageSize = prefsPageSizeName;
 	prefsData->docSetupPrefs.pageOrientation=pageOrientationComboBox->currentIndex();
 	prefsData->docSetupPrefs.docUnitIndex=pageUnitsComboBox->currentIndex();
 	prefsData->docSetupPrefs.pageWidth=pageW;
@@ -233,20 +225,38 @@
 
 void Prefs_DocumentSetup::setupPageSizes(struct ApplicationPrefs *prefsData)
 {
+	PageSize ps(prefsData->docSetupPrefs.pageSize);
+	QStringList insertList(ps.activeSizeList());
+	QStringList insertTrList(ps.activeSizeTRList());
+
 	prefsPageSizeName = prefsData->docSetupPrefs.pageSize;
-	PageSize *ps=new PageSize(prefsPageSizeName);
-	QStringList insertList(ps->activeSizeTRList());
-	if (insertList.indexOf(prefsPageSizeName)==-1)
-		insertList<<prefsPageSizeName;
-	insertList.sort();
-	insertList<<CommonStrings::trCustomPageSize;
+	if (insertList.indexOf(prefsPageSizeName) ==-1)
+	{
+		insertList << prefsPageSizeName;
+		insertTrList << prefsPageSizeName;
+	}
+
+	QMap<QString, QString> insertMap;
+	for (int i = 0; i < insertTrList.count(); ++i)
+	{
+		QString key = insertTrList.at(i);
+		insertMap[key] = insertList.at(i);
+	}
+	insertTrList.sort();
+
 	pageSizeComboBox->clear();
-	pageSizeComboBox->addItems(insertList);
-
-	if (prefsData->docSetupPrefs.pageSize == CommonStrings::customPageSize)
-		setCurrentComboItem(pageSizeComboBox, CommonStrings::trCustomPageSize);
-	else
-		setCurrentComboItem(pageSizeComboBox, prefsPageSizeName);
+	for (int i = 0; i < insertList.count(); ++i)
+	{
+		QString key = insertTrList.at(i);
+		pageSizeComboBox->addItem(key, insertMap[key]);
+	}
+	pageSizeComboBox->addItem(CommonStrings::trCustomPageSize, CommonStrings::customPageSize);
+
+	QString pageSizeName = CommonStrings::trCustomPageSize;
+	int index = pageSizeComboBox->findData(prefsPageSizeName);
+	if (index >= 0)
+		pageSizeName = pageSizeComboBox->itemText(index);
+	setCurrentComboItem(pageSizeComboBox, pageSizeName);
 	marginsWidget->setPageSize(prefsPageSizeName);
 	bleedsWidget->setPageSize(prefsPageSizeName);
 }




More information about the scribus-commit mailing list