Subversion Repositories Scribus

Compare Revisions

Ignore whitespace Rev 17985 → Rev 17986

/trunk/Scribus/scribus/localemgr.cpp
0,0 → 1,139
/*
For general Scribus (>=1.3.2) copyright and licensing information please refer
to the COPYING file provided with the program. Following this notice may exist
a copyright and/or license notice that predates the release of Scribus 1.3.2
for which a new license (GPL+exception) is in place.
*/
/***************************************************************************
begin : Jan 2005
copyright : (C) 2005 by Craig Bradney
email : cbradney@zip.com.au
***************************************************************************/
 
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
 
#include <QDebug>
#include <QDir>
#include <QtGlobal>
#include <QFileInfo>
#include <QMap>
#include <QObject>
#include <QStringList>
 
#include "scconfig.h"
#include "localemgr.h"
#include "scpaths.h"
 
LocaleManager * LocaleManager::m_instance = 0;
LocaleManager * LocaleManager::instance()
{
if(!m_instance)
{
m_instance = new LocaleManager;
Q_ASSERT(m_instance);
m_instance->init();
}
return m_instance;
}
 
void LocaleManager::init()
{
generateLocaleList();
}
 
void LocaleManager::generateLocaleList()
{
//Build table;
localeTable.clear();
localeTable.append(LocaleDef("default","mm", "A4" ));
localeTable.append(LocaleDef("en", "in", "Legal"));
localeTable.append(LocaleDef("en_GB", "mm", "A4" ));
localeTable.append(LocaleDef("en_US", "in", "Legal"));
localeTable.append(LocaleDef("fr", "mm", "A4" ));
localeTable.append(LocaleDef("fr_QC", "pica", "Legal"));
}
 
void LocaleManager::printSelectedForLocale(const QString& locale)
{
QString selectedLocale(locale);
if (!locale.isEmpty())
{
for (int i = 0; i < localeTable.size(); ++i)
{
if (localeTable[i].m_locale==selectedLocale)
{
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)
{
if (localeTable[i].m_locale==selectedLocale)
{
qDebug()<<localeTable[i].m_locale.leftJustified(6) << ": " << localeTable[i].m_unit << ": " << localeTable[i].m_pageSize;
return;
}
}
}
 
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;
}
qFatal("Page Size not found in LocaleManager");
return "";
}
 
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;
}
qFatal("Unit not found in LocaleManager");
return "";
}
 
LocaleManager::~LocaleManager()
{
localeTable.clear();
}
 
 
Property changes:
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: Scribus/scribus/scribuscore.cpp
===================================================================
--- Scribus/scribus/scribuscore.cpp (revision 17985)
+++ Scribus/scribus/scribuscore.cpp (revision 17986)
@@ -28,6 +28,7 @@
#include "commonstrings.h"
#include "filewatcher.h"
+#include "localemgr.h"
#include "pluginmanager.h"
#include "prefsmanager.h"
#include "scimagecachemanager.h"
@@ -49,7 +50,6 @@
m_SplashScreen=0;
m_UseGUI=false;
m_HaveCMS=false;
-// m_PaletteParent=0;
m_currScMW=0;
ScColorMgmtStrategy strategy;
@@ -94,8 +94,6 @@
int ScribusCore::startGUI(bool showSplash, bool showFontInfo, bool showProfileInfo, const QString newGuiLanguage, const QString prefsUserFile)
{
-// m_PaletteParent=new QWidget(0);
-// Q_CHECK_PTR(m_PaletteParent);
ScribusMainWindow* scribus = new ScribusMainWindow();
Q_CHECK_PTR(scribus);
if (!scribus)
@@ -102,7 +100,6 @@
return(EXIT_FAILURE);
ScMWList.append(scribus);
m_currScMW=0;
-// ScMW=scribus;
int retVal=initScribusCore(showSplash, showFontInfo, showProfileInfo,newGuiLanguage, prefsUserFile);
if (retVal == 1)
return(EXIT_FAILURE);
@@ -113,7 +110,6 @@
closeSplash();
m_ScribusInitialized=true;
-// ScQApp->setMainWidget(scribus);
connect(ScQApp, SIGNAL(lastWindowClosed()), ScQApp, SLOT(quit()));
scribus->show();
@@ -155,6 +151,7 @@
int retVal=0;
//FIXME ExternalApp = 0;
initSplash(showSplash);
+ LocaleManager::instance();
prefsManager = PrefsManager::instance();
prefsManager->setup();
//CB #4428 Get fonts before prefs are set to default
/trunk/Scribus/scribus/prefsmanager.cpp
38,6 → 38,7
#include "commonstrings.h"
#include "filewatcher.h"
#include "latexhelpers.h"
#include "localemgr.h"
#include "pagesize.h"
#include "pagestructs.h"
#include "pdfoptions.h"
47,9 → 48,11
#include "scdomelement.h"
#include "scfonts.h"
#include "scpaths.h"
#include "scribusapp.h"
#include "scribuscore.h"
#include "scribusstructs.h"
#include "sctextstream.h"
#include "units.h"
#include "util_color.h"
#include "util_file.h"
#include "util_ghostscript.h"
58,6 → 61,7
#include "ui/modetoolbar.h"
#include "ui/prefs_keyboardshortcuts.h"
 
extern ScribusQApp* ScQApp;
extern bool emergencyActivated;
 
PrefsManager* PrefsManager::_instance = 0;
260,7 → 264,8
appPrefs.opToolPrefs.magMin = 1;
appPrefs.opToolPrefs.magMax = 3200;
appPrefs.opToolPrefs.magStep = 25;
appPrefs.docSetupPrefs.docUnitIndex = 0;
qDebug()<<ScQApp->currGUILanguage();
appPrefs.docSetupPrefs.docUnitIndex = unitIndexFromString(LocaleManager::instance()->unitForLocale("default"));
appPrefs.itemToolPrefs.polyCorners = 4;
appPrefs.itemToolPrefs.polyFactor = 0.5;
appPrefs.itemToolPrefs.polyUseFactor = false;
295,11 → 300,11
appPrefs.scrapbookPrefs.writePreviews = true;
appPrefs.scrapbookPrefs.numScrapbookCopies = 10;
appPrefs.displayPrefs.marginColored = false;
appPrefs.docSetupPrefs.pageSize = "A4";
appPrefs.docSetupPrefs.pageSize = LocaleManager::instance()->pageSizeForLocale("default");
appPrefs.docSetupPrefs.pageOrientation = 0;
PageSize a4("A4");
appPrefs.docSetupPrefs.pageWidth = a4.width();
appPrefs.docSetupPrefs.pageHeight = a4.height();
PageSize defaultPageSize(appPrefs.docSetupPrefs.pageSize);
appPrefs.docSetupPrefs.pageWidth = defaultPageSize.width();
appPrefs.docSetupPrefs.pageHeight = defaultPageSize.height();
appPrefs.docSetupPrefs.margins.Top = 40;
appPrefs.docSetupPrefs.margins.Bottom = 40;
appPrefs.docSetupPrefs.margins.Left = 40;
/trunk/Scribus/scribus/localemgr.h
0,0 → 1,74
/*
For general Scribus (>=1.3.2) copyright and licensing information please refer
to the COPYING file provided with the program. Following this notice may exist
a copyright and/or license notice that predates the release of Scribus 1.3.2
for which a new license (GPL+exception) is in place.
*/
/***************************************************************************
begin : Jan 2005
copyright : (C) 2005 by Craig Bradney
email : cbradney@zip.com.au
***************************************************************************/
 
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef LOCALEMANAGER_H
#define LOCALEMANAGER_H
 
#include <QMap>
#include <QString>
 
#include "scribusapi.h"
 
class SCRIBUS_API LocaleDef
{
friend class LocaleManager;
 
public:
LocaleDef();
LocaleDef(const QString& locale, const QString& unit, const QString& pageSize)
{
 
m_locale=locale;
m_unit=unit;
m_pageSize=pageSize;
 
}
~LocaleDef() {};
 
private:
QString m_locale;
QString m_unit;
QString m_pageSize;
};
 
class SCRIBUS_API LocaleManager
{
static LocaleManager* m_instance;
LocaleManager() {};
~LocaleManager();
void init();
public:
static LocaleManager* instance();
 
const QString getUnitFromLocale(QString);
void printSelectedForLocale(const QString &locale);
QString pageSizeForLocale(const QString &locale);
QString unitForLocale(const QString &locale);
 
private:
QList <LocaleDef> localeTable;
 
void generateLocaleList();
};
 
#endif
 
Property changes:
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: Scribus/scribus/scribusapp.cpp
===================================================================
--- Scribus/scribus/scribusapp.cpp (revision 17985)
+++ Scribus/scribus/scribusapp.cpp (revision 17986)
@@ -477,8 +477,6 @@
ts << tr("Installed interface languages for Scribus are as follows:"); endl(ts);
endl(ts);
-// LanguageManager langMgr;
-// langMgr.init();
LanguageManager::instance()->printInstalledList();
endl(ts);
/trunk/Scribus/scribus/scribus.h
231,8 → 231,6
ScribusWin* ActWin;
QClipboard *ClipB;
QString LoadEnc;
//QMap<QString, QStringList> InstLang;
//QMap<QString,QString> LangTransl;
 
QProcess *ExternalApp;
 
/trunk/Scribus/scribus/CMakeLists.txt
575,6 → 575,7
langmgr.cpp
latexhelpers.cpp
loadsaveplugin.cpp
localemgr.cpp
menumanager.cpp
mesh.cpp
navigator.cpp