r17995 by craig - #10113: Change fallback to QLocale and now activate this code

scribus-commit scribus-commit at lists.scribus.net
Thu Dec 27 22:42:04 UTC 2012


Author: craig
Date: Thu Dec 27 22:42:04 2012
New Revision: 17995

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17995
Log:
#10113: Change fallback to QLocale and now activate this code

Modified:
    trunk/Scribus/scribus/localemgr.cpp
    trunk/Scribus/scribus/localemgr.h
    trunk/Scribus/scribus/prefsmanager.cpp

Modified: trunk/Scribus/scribus/localemgr.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17995&path=/trunk/Scribus/scribus/localemgr.cpp
==============================================================================
--- trunk/Scribus/scribus/localemgr.cpp (original)
+++ trunk/Scribus/scribus/localemgr.cpp Thu Dec 27 22:42:04 2012
@@ -46,35 +46,40 @@
 
 void LocaleManager::init()
 {
+	sysLocale=QLocale::system();
+//	qDebug()<<"language:"<<QLocale::languageToString(sysLocale.language());
+//	qDebug()<<"measurement:"<<sysLocale.measurementSystem();
+//	qDebug()<<"bcp47name:"<<sysLocale.bcp47Name();
+
 	generateLocaleList();
 }
 
 void LocaleManager::generateLocaleList()
 {
 	//Build table;
+	//No, we don't translate these, they are internal use that don't get to the GUI
 	localeTable.clear();
 	localeTable.append(LocaleDef("default","mm",   "A4"   ));
-	localeTable.append(LocaleDef("en",     "in",   "Legal"));
+	localeTable.append(LocaleDef("en",     "in",   "Letter"));
+	localeTable.append(LocaleDef("en_AU",  "mm",   "A4"   ));
 	localeTable.append(LocaleDef("en_GB",  "mm",   "A4"   ));
-	localeTable.append(LocaleDef("en_US",  "in",   "Legal"));
+	localeTable.append(LocaleDef("en_US",  "in",   "Letter"));
 	localeTable.append(LocaleDef("fr",     "mm",   "A4"   ));
-	localeTable.append(LocaleDef("fr_QC",  "pica", "Legal"));
+	localeTable.append(LocaleDef("fr_QC",  "pica", "Letter"));
 }
 
 void LocaleManager::printSelectedForLocale(const QString& locale)
 {
 	QString selectedLocale(locale);
-	if (!locale.isEmpty())
+	for (int i = 0; i < localeTable.size(); ++i)
 	{
-		for (int i = 0; i < localeTable.size(); ++i)
+		if (localeTable[i].m_locale==selectedLocale)
 		{
-			if (localeTable[i].m_locale==selectedLocale)
-			{
-				qDebug()<<localeTable[i].m_locale.leftJustified(6) << ": " << localeTable[i].m_unit << ": " << localeTable[i].m_pageSize;
-				return;
-			}
+			qDebug()<<localeTable[i].m_locale.leftJustified(6) << ": " << localeTable[i].m_unit << ": " << localeTable[i].m_pageSize;
+			return;
 		}
 	}
+
 	qDebug()<<"No definition for locale: "<<selectedLocale;
 	selectedLocale="default";
 	for (int i = 0; i < localeTable.size(); ++i)
@@ -90,21 +95,18 @@
 QString LocaleManager::pageSizeForLocale(const QString& locale)
 {
 	QString selectedLocale(locale);
-	if (!locale.isEmpty())
-	{
-		for (int i = 0; i < localeTable.size(); ++i)
-		{
-			if (localeTable[i].m_locale==selectedLocale)
-				return localeTable[i].m_pageSize;
-		}
-	}
-	qDebug()<<"No definition for locale: "<<selectedLocale;
-	selectedLocale="default";
 	for (int i = 0; i < localeTable.size(); ++i)
 	{
 		if (localeTable[i].m_locale==selectedLocale)
 			return localeTable[i].m_pageSize;
 	}
+
+	//qDebug()<<"No definition for locale: "<<selectedLocale;
+	//No, we don't translate these, they are internal use that don't get to the GUI
+	if (sysLocale.measurementSystem()==0)
+		return "A4";
+	else
+		return "Letter";
 	qFatal("Page Size not found in LocaleManager");
 	return "";
 }
@@ -112,21 +114,17 @@
 QString LocaleManager::unitForLocale(const QString &locale)
 {
 	QString selectedLocale(locale);
-	if (!locale.isEmpty())
-	{
-		for (int i = 0; i < localeTable.size(); ++i)
-		{
-			if (localeTable[i].m_locale==selectedLocale)
-				return localeTable[i].m_unit;
-		}
-	}
-	qDebug()<<"No definition for locale: "<<selectedLocale;
-	selectedLocale="default";
 	for (int i = 0; i < localeTable.size(); ++i)
 	{
 		if (localeTable[i].m_locale==selectedLocale)
 			return localeTable[i].m_unit;
 	}
+	//qDebug()<<"No definition for locale: "<<selectedLocale;
+	//No, we don't translate these, they are internal use that don't get to the GUI
+	if (sysLocale.measurementSystem()==0)
+		return "mm";
+	else
+		return "in";
 	qFatal("Unit not found in LocaleManager");
 	return "";
 }

Modified: trunk/Scribus/scribus/localemgr.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17995&path=/trunk/Scribus/scribus/localemgr.h
==============================================================================
--- trunk/Scribus/scribus/localemgr.h (original)
+++ trunk/Scribus/scribus/localemgr.h Thu Dec 27 22:42:04 2012
@@ -22,6 +22,7 @@
 #ifndef LOCALEMANAGER_H
 #define LOCALEMANAGER_H
 
+#include <QLocale>
 #include <QMap>
 #include <QString>
 
@@ -66,7 +67,7 @@
 
 private:
 	QList <LocaleDef> localeTable;
-
+	QLocale sysLocale;
 	void generateLocaleList();
 };
 

Modified: trunk/Scribus/scribus/prefsmanager.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17995&path=/trunk/Scribus/scribus/prefsmanager.cpp
==============================================================================
--- trunk/Scribus/scribus/prefsmanager.cpp (original)
+++ trunk/Scribus/scribus/prefsmanager.cpp Thu Dec 27 22:42:04 2012
@@ -265,7 +265,7 @@
 	appPrefs.opToolPrefs.magMax = 3200;
 	appPrefs.opToolPrefs.magStep = 25;
 	qDebug()<<ScQApp->currGUILanguage();
-	appPrefs.docSetupPrefs.docUnitIndex = unitIndexFromString(LocaleManager::instance()->unitForLocale("default"));
+	appPrefs.docSetupPrefs.docUnitIndex = unitIndexFromString(LocaleManager::instance()->unitForLocale(ScQApp->currGUILanguage()));
 	appPrefs.itemToolPrefs.polyCorners = 4;
 	appPrefs.itemToolPrefs.polyFactor = 0.5;
 	appPrefs.itemToolPrefs.polyUseFactor = false;
@@ -300,7 +300,7 @@
 	appPrefs.scrapbookPrefs.writePreviews = true;
 	appPrefs.scrapbookPrefs.numScrapbookCopies = 10;
 	appPrefs.displayPrefs.marginColored = false;
-	appPrefs.docSetupPrefs.pageSize = LocaleManager::instance()->pageSizeForLocale("default");
+	appPrefs.docSetupPrefs.pageSize = LocaleManager::instance()->pageSizeForLocale(ScQApp->currGUILanguage());
 	appPrefs.docSetupPrefs.pageOrientation = 0;
 	PageSize defaultPageSize(appPrefs.docSetupPrefs.pageSize);
 	appPrefs.docSetupPrefs.pageWidth = defaultPageSize.width();




More information about the scribus-commit mailing list