Subversion Repositories Scribus

Compare Revisions

Ignore whitespace Rev 12786 → Rev 12787

/trunk/Scribus/scribus/prefs.cpp
86,7 → 86,7
tabTools = new TabTools(prefsWidgets, &prefsData->toolSettings, docUnitIndex, ap->doc);
addItem( tr("Tools"), loadIcon("tools.png"), tabTools);
 
tabHyphenator = new HySettings(prefsWidgets, &ap->LangTransl);
tabHyphenator = new HySettings(prefsWidgets/*, &ap->LangTransl*/);
addItem( tr("Hyphenator"), loadIcon("hyphenate.png"), tabHyphenator);
 
tabFonts = new FontPrefs(prefsWidgets, false, prefsManager->preferencesLocation(), ap->doc);
/trunk/Scribus/scribus/about.cpp
203,8 → 203,8
tabLayout_2->setSpacing( 6 );
tabLayout_2->setMargin( 10 );
textView2 = new ScTextBrowser( tab_3);
LanguageManager langmgr;
langmgr.init(false);
// LanguageManager langmgr;
// langmgr.init(false);
 
/*! TRANSLATION tab */
// /usr/local/scribus14/share/doc/scribus-1.3.5svn/TRANSLATION
464,8 → 464,8
QString code;
QString name;
QString contact;
LanguageManager langmgr;
langmgr.init(false);
// LanguageManager langmgr;
// langmgr.init(false);
bool isSectionTitle = true;
bool isTitle = false;
bool startText = false;
496,7 → 496,7
{
code.replace("(", "");
code.replace(")", "");
code = langmgr.getLangFromAbbrev(code).toLocal8Bit();
code = LanguageManager::instance()->getLangFromAbbrev(code).toLocal8Bit();
}
result += "<tr><td><b>"+code+"</b></td><td></td></tr>";
isTitle = false;
/trunk/Scribus/scribus/scribus.cpp
343,7 → 343,7
ScCore->setSplashStatus( tr("Initializing Hyphenator") );
QString preLang = prefsManager->appPrefs.Language;
initHyphenator();
if (Sprachen.contains(preLang))
if (!LanguageManager::instance()->getHyphFilename( preLang, false ).isEmpty() )
prefsManager->appPrefs.Language = preLang;
if (primaryMainWindow)
ScCore->setSplashStatus( tr("Reading Scrapbook") );
8863,14 → 8863,14
QDir hyphDir(hyphDirName, "*.dic", QDir::Name, QDir::Files | QDir::NoSymLinks);
if ((hyphDir.exists()) && (hyphDir.count() != 0))
{
LanguageManager langmgr;
langmgr.init(false);
// LanguageManager langmgr;
// langmgr.init(false);
QString languageOfHyphFile;
for (uint dc = 0; dc < hyphDir.count(); ++dc)
{
QFileInfo fi(hyphDir[dc]);
QString fileLangAbbrev=fi.baseName().section('_', 1);
languageOfHyphFile = langmgr.getLangFromAbbrev(fileLangAbbrev, false);
languageOfHyphFile = LanguageManager::instance()->getLangFromAbbrev(fileLangAbbrev, false);
InstLang.insert(languageOfHyphFile, QStringList());
}
}
8907,18 → 8907,19
prefsManager->appPrefs.Language = "English";
if ((hyphDir.exists()) && (hyphDir.count() != 0))
{
LanguageManager langmgr;
langmgr.init(false);
LanguageManager *langmgr(LanguageManager::instance());
// langmgr.init(false);
QString datein = "";
for (uint dc = 0; dc < hyphDir.count(); ++dc)
{
QFileInfo fi(hyphDir[dc]);
QString fileLangAbbrev=fi.baseName().section('_', 1);
datein = langmgr.getLangFromAbbrev(fileLangAbbrev);
datein = langmgr->getLangFromAbbrev(fileLangAbbrev);
QString tDatein = datein;
datein = GetLang(datein);
LangTransl.insert(datein, tDatein);
Sprachen.insert(datein, hyphDir[dc]);
langmgr->addHyphLang(fileLangAbbrev, hyphDir[dc]);
// Sprachen.insert(datein, hyphDir[dc]);
if (fileLangAbbrev == lang)
prefsManager->appPrefs.Language = datein;
}
/trunk/Scribus/scribus/hyphenator.cpp
34,6 → 34,7
#include <QByteArray>
#include <cstdlib>
#include <string>
#include "langmgr.h"
#include "scpaths.h"
#include "scribuscore.h"
#include "prefsfile.h"
52,7 → 53,8
{
//FIXME:av pick up language from charstyle
QString pfad = ScPaths::instance().dictDir();
if (ScCore->primaryMainWindow()->Sprachen.contains(doc->Language))
LanguageManager * lmgr(LanguageManager::instance());
if (!lmgr->getHyphFilename(doc->Language, false).isEmpty() )
Language = doc->Language;
else
{
59,7 → 61,8
Language = PrefsManager::instance()->appPrefs.Language;
doc->Language = Language;
}
pfad += ScCore->primaryMainWindow()->Sprachen[Language];
// pfad += ScCore->primaryMainWindow()->Sprachen[Language];
pfad += lmgr->getHyphFilename( doc->Language, false );
QFile f(pfad);
if (f.open(QIODevice::ReadOnly))
{
92,9 → 95,11
 
void Hyphenator::NewDict(const QString& name)
{
if (!ScCore->primaryMainWindow()->Sprachen.contains(name))
// if (!ScCore->primaryMainWindow()->Sprachen.contains(name))
// return;
if( LanguageManager::instance()->getHyphFilename(name, false).isEmpty() )
return;
 
if (Language != name)
{
Language = name;
105,7 → 110,7
if (hdict != NULL)
hnj_hyphen_free(hdict);
 
pfad += ScCore->primaryMainWindow()->Sprachen[Language];
pfad += LanguageManager::instance()->getHyphFilename(Language, false) ;
QFile f(pfad);
if (f.open(QIODevice::ReadOnly))
{
/trunk/Scribus/scribus/smcstylewidget.cpp
249,8 → 249,8
defLang : parent->language();
 
int ci = -1, pi = -1, di = -1;
LanguageManager langmgr;
langmgr.init(true);
// LanguageManager langmgr;
// langmgr.init(true);
QString tl;
for (int i = 0; i < language_->count(); ++i)
{
259,7 → 259,7
if (hasParent && language_->itemText(i) == langMap_[plang])
pi = i;
tl=langmgr.getTransLangFromLang(defLang);
tl=LanguageManager::instance()->getTransLangFromLang(defLang);
// qDebug() << i << language_->itemText(i) << defLang << langMap_[defLang] << tl;
if (language_->itemText(i) == defLang || language_->itemText(i) == langMap_[defLang] || language_->itemText(i) == tl)
// {
/trunk/Scribus/scribus/loremipsum.cpp
195,8 → 195,8
QFileInfoList list = d.entryInfoList();
QListIterator<QFileInfo> it(list);
QFileInfo fi;
langmgr = new LanguageManager();
langmgr->init(false);
LanguageManager * langmgr( LanguageManager::instance() );
// langmgr->init(false);
 
while (it.hasNext())
{
229,7 → 229,7
resize( QSize(320, 340).expandedTo(minimumSizeHint()) );
QList<QTreeWidgetItem *> defItem;
defItem.clear();
defItem = loremList->findItems(m_Doc->Language, Qt::MatchExactly);
defItem = loremList->findItems(langmgr->getTransLangFromLang(m_Doc->Language), Qt::MatchExactly);
if (defItem.count() == 0)
defItem = loremList->findItems(standardloremtext, Qt::MatchExactly);
if (defItem.count() != 0)
246,7 → 246,7
 
LoremManager::~LoremManager()
{
delete langmgr;
// delete langmgr;
}
 
void LoremManager::changeEvent(QEvent *e)
285,7 → 285,7
if (li->text(0)==standardloremtext)
name="la";
else
name=langmgr->getAbbrevFromLang(li->text(0), true, false);
name=LanguageManager::instance()->getAbbrevFromLang(li->text(0), true, false);
insertLoremIpsum(availableLorems[name], paraBox->value(), randomCheckBox->isChecked());
accept();
/trunk/Scribus/scribus/langmgr.h
26,6 → 26,7
#include <utility>
 
#include <QString>
#include <QStringList>
#include "scribusapi.h"
 
typedef std::pair<QString, QString> langPair;
34,10 → 35,14
 
class SCRIBUS_API LanguageManager
{
public:
static LanguageManager* m_instance;
LanguageManager() {};
~LanguageManager();
void init(bool generateInstalledList = true);
public:
static LanguageManager* instance();
const QString getLangFromAbbrev(QString, bool getTranslated=true);
const QString getAbbrevFromLang(QString, bool getFromTranslated=true, bool useInstalled=true);
const QString getTransLangFromLang(QString lang);
44,10 → 49,15
void fillInstalledStringList(QStringList *stringListToFill, bool addDefaults);
void printInstalledList();
QString numericSequence(QString seq);
void addHyphLang(const QString& lang, const QString& filename);
const QString getHyphFilename(const QString& lang, bool langIsAbbreviated = true);
const QStringList hyphLangs();
 
private:
QMap<QString, langPair > langList;
QMap<QString, QString> installedLangList;
QMap<QString, QString> hyphLangList; // <lang abbreviated, dict filename>
 
void generateLangList();
void generateInstalledLangList();
/trunk/Scribus/scribus/reformdoc.cpp
81,7 → 81,7
tabTools = new TabTools( prefsWidgets, &doc->toolSettings, docUnitIndex, doc);
addItem( tr("Tools"), loadIcon("tools.png"), tabTools);
 
tabHyphenator = new HySettings(prefsWidgets, &ScMW->LangTransl);
tabHyphenator = new HySettings(prefsWidgets/*, &ScMW->LangTransl*/);
addItem( tr("Hyphenator"), loadIcon("hyphenate.png"), tabHyphenator);
 
tabFonts = new FontPrefs(prefsWidgets, true, PrefsManager::instance()->preferencesLocation(), doc);
436,6 → 436,8
/* FIXME: scribus determines dict by charstyle now, so this setting should go into the doc's default charstyle
currDoc->docHyphenator->slotNewDict(ScMW->GetLang(tabHyphenator->language->currentText()));
*/
currDoc->Language = tabHyphenator->getLanguage();
currDoc->docHyphenator->slotNewSettings(tabHyphenator->getWordLen(),
!tabHyphenator->getVerbose(),
tabHyphenator->getInput(),
/trunk/Scribus/scribus/tabgeneral.h
27,7 → 27,7
~TabGeneral(){};
void restoreDefaults(struct ApplicationPrefs *prefsData);
 
LanguageManager langMgr;
// LanguageManager langMgr;
QString selectedGUILang;
 
private slots:
/trunk/Scribus/scribus/tabgeneral.cpp
30,9 → 30,9
setupUi(this);
setObjectName(name);
// languages
langMgr.init();
// langMgr.init();
QStringList languageList;
langMgr.fillInstalledStringList(&languageList, true);
LanguageManager::instance()->fillInstalledStringList(&languageList, true);
languageList.sort();
guiLangCombo->addItems( languageList );
 
72,7 → 72,7
void TabGeneral::restoreDefaults(struct ApplicationPrefs *prefsData)
{
selectedGUILang = prefsData->guiLanguage;
setCurrentComboItem(guiLangCombo, langMgr.getLangFromAbbrev(selectedGUILang));
setCurrentComboItem(guiLangCombo, LanguageManager::instance()->getLangFromAbbrev(selectedGUILang));
setCurrentComboItem(GUICombo, prefsData->GUI);
GFsize->setValue( prefsData->AppFontSize );
GTFsize->setValue( prefsData->PaletteFontSize); // temp solution
90,7 → 90,7
 
void TabGeneral::setSelectedGUILang( const QString &newLang )
{
selectedGUILang = langMgr.getAbbrevFromLang(newLang);
selectedGUILang = LanguageManager::instance()->getAbbrevFromLang(newLang);
}
 
void TabGeneral::changeDocs()
/trunk/Scribus/scribus/hysettings.cpp
6,6 → 6,7
*/
#include "hysettings.h"
#include "hyphenator.h"
#include "langmgr.h"
#include "scribusdoc.h"
#include "util_icon.h"
#include "util.h"
12,16 → 13,23
#include "QHeaderView"
#include <QInputDialog>
 
HySettings::HySettings( QWidget* parent, QMap<QString,QString>* langs ) : QWidget( parent )
HySettings::HySettings( QWidget* parent/*, QMap<QString,QString>* langs*/ ) : QWidget( parent )
{
langsMap = *langs;
// langsMap = *langs;
setupUi(this);
QMap<QString,QString>::Iterator it;
QStringList lada;
for (it = langs->begin(); it != langs->end(); ++it)
lada.append(it.value());
lada.sort();
language->addItems(lada);
// QMap<QString,QString>::Iterator it;
// QStringList lada;
// for (it = langs->begin(); it != langs->end(); ++it)
// lada.append(it.value());
// lada.sort();
// language->addItems(lada);
LanguageManager *lmg(LanguageManager::instance());
language->setInsertPolicy(QComboBox::InsertAlphabetically);
foreach(QString hlang, lmg->hyphLangs())
{
language->addItem( lmg->getLangFromAbbrev(hlang), lmg->getLangFromAbbrev(hlang,false) );
}
buttonExceptAdd->setIcon(QIcon(loadIcon("16/list-add.png")));
buttonExceptEdit->setEnabled(false);
buttonExceptRemove->setIcon(QIcon(loadIcon("16/list-remove.png")));
44,7 → 52,7
{
verbose->setChecked(!prefsData->Automatic);
input->setChecked(prefsData->AutoCheck);
setCurrentComboItem(language, langsMap[prefsData->Language]);
setCurrentComboItem(language, LanguageManager::instance()->getTransLangFromLang(prefsData->Language));
wordLen->setValue(prefsData->MinWordLen);
maxCount->setValue(prefsData->HyCount);
ignoreList->addItems(prefsData->ignoredWords.toList());
57,7 → 65,7
{
verbose->setChecked(!prefsData->Automatic);
input->setChecked(prefsData->AutoCheck);
setCurrentComboItem(language, langsMap[prefsData->Language]);
setCurrentComboItem(language, LanguageManager::instance()->getTransLangFromLang(prefsData->Language));
wordLen->setValue(prefsData->MinWordLen);
maxCount->setValue(prefsData->HyCount);
ignoreList->addItems(prefsData->docHyphenator->ignoredWords.toList());
170,7 → 178,7
 
QString HySettings::getLanguage()
{
return language->currentText();
return language->itemData(language->currentIndex()).toString();
}
 
QSet<QString> HySettings::getIgnoreList()
/trunk/Scribus/scribus/plugins/short-words/configuration.cpp
166,7 → 166,7
{
QMap<QString,QString>::Iterator it;
QString lang;
LanguageManager langmgr;
langmgr.init(false);
return langmgr.getLangFromAbbrev(code, true);
// LanguageManager langmgr;
// langmgr.init(false);
return LanguageManager::instance()->getLangFromAbbrev(code, true);
}
/trunk/Scribus/scribus/plugins/short-words/parse.cpp
27,6 → 27,7
#include "page.h"
#include "pageitem.h"
#include "selection.h"
#include "langmgr.h"
 
SWParse::SWParse()
{
60,8 → 61,8
}
 
QString langCode;
if (aFrame->doc()->scMW()->Sprachen.contains(lang))
langCode = cfg->getLangCodeFromHyph(aFrame->doc()->scMW()->Sprachen[lang]);
// if (aFrame->doc()->scMW()->Sprachen.contains(lang))
langCode = cfg->getLangCodeFromHyph(LanguageManager::instance()->getHyphFilename(lang,false));
 
// apply spaces after shorts
shorts = cfg->getShortWords(langCode);
/trunk/Scribus/scribus/scribusapp.cpp
436,9 → 436,9
ts << tr("Installed interface languages for Scribus are as follows:"); endl(ts);
endl(ts);
 
LanguageManager langMgr;
langMgr.init();
langMgr.printInstalledList();
// LanguageManager langMgr;
// langMgr.init();
LanguageManager::instance()->printInstalledList();
 
endl(ts);
ts << tr("To override the default language choice:"); endl(ts);
/trunk/Scribus/scribus/scribus.h
225,7 → 225,7
AlignDistributePalette *alignDistributePalette;
StoryEditor* storyEditor;
StoryEditor* CurrStED;
QMap<QString,QString> Sprachen;
// QMap<QString,QString> Sprachen; // <language not translated, file name>
QWorkspace *wsp;
ScribusWin* ActWin;
QClipboard *ClipB;
/trunk/Scribus/scribus/langmgr.cpp
31,6 → 31,18
#include "langmgr.h"
#include "scpaths.h"
 
LanguageManager * LanguageManager::m_instance = 0;
LanguageManager * LanguageManager::instance()
{
if(!m_instance)
{
m_instance = new LanguageManager;
Q_ASSERT(m_instance);
m_instance->init();
}
return m_instance;
}
 
void LanguageManager::init(bool generateInstalledList)
{
//generateUntranslatedLangList();
41,6 → 53,8
 
void LanguageManager::generateLangList()
{
// TODO get rid of the redundant key, the english name.
// So internally language would always be manipulated as a code and otherwise presented translated.
langList.insert("af", langPair("Afrikaans", QObject::tr( "Afrikaans" )) );
langList.insert("ar", langPair("Arabic", QObject::tr( "Arabic" )) );
langList.insert("sq", langPair("Albanian", QObject::tr( "Albanian" )) );
188,7 → 202,11
const QString LanguageManager::getTransLangFromLang(QString lang)
{
QMap<QString, langPair>::Iterator it;
if (lang == "English" || lang == QObject::tr( "English"))
// Seems something is missing here!
QString enLang(QObject::tr( "English"));
if ((lang == "English") || (lang == enLang))
return enLang;
for (it=langList.begin();it!=langList.end();++it)
{
if (it.value().first==lang)
272,5 → 290,27
{
langList.clear();
installedLangList.clear();
hyphLangList.clear();
}
 
void LanguageManager::addHyphLang(const QString & lang, const QString & filename)
{
hyphLangList[lang] = filename;
}
 
const QString LanguageManager::getHyphFilename(const QString & lang, bool langIsAbbreviated)
{
if(langIsAbbreviated)
return hyphLangList.value(lang);
return hyphLangList.value(getAbbrevFromLang(lang, false));
}
 
const QStringList LanguageManager::hyphLangs()
{
return hyphLangList.keys();
}
 
 
 
 
 
/trunk/Scribus/scribus/hysettings.h
20,7 → 20,7
Q_OBJECT
 
public:
HySettings( QWidget* parent, QMap<QString,QString>* langs);
HySettings( QWidget* parent/*, QMap<QString,QString>* langs*/);
~HySettings() {};
void restoreDefaults(struct ApplicationPrefs *prefsData);
void restoreDefaults(ScribusDoc *prefsData);
42,8 → 42,8
void removeExceptListEntry();
void enableExceptButtons();
 
protected:
QMap<QString,QString> langsMap;
// protected:
// QMap<QString,QString> langsMap;
};
 
#endif // HYSETTINGS_H
/trunk/Scribus/scribus/loremipsum.h
35,7 → 35,7
class QVBoxLayout;
 
class ScribusDoc;
class LanguageManager;
// class LanguageManager;
 
 
/*! \brief XML parser for Lorem Ipsum file.
119,7 → 119,7
QSpacerItem* paraSpacer;
QHBoxLayout* layout1;
QSpacerItem* buttonSpacer;
LanguageManager* langmgr;
// LanguageManager* langmgr;
QString standardloremtext;
 
protected slots:
/trunk/Scribus/scribus/smtextstyles.cpp
212,6 → 212,7
ParagraphStyle p;
p.setDefaultStyle(false);
p.setName(s);
p.charStyle().setLanguage(doc_->Language);
tmpStyles_.create(p);
return s;
}
1382,6 → 1383,8
CharStyle c;
c.setDefaultStyle(false);
c.setName(s);
// #7360 - rather here than in CharStyle constructor as we have a pointer to doc.
c.setLanguage(doc_->Language);
tmpStyles_.create(c);
return s;
}