Source Code (Use browser search to find items of interest.)
Class Index
kcontrol'KLocaleConfig (./kdebase/kcontrol/locale/locale.h:35)
class KLocaleConfig : public QWidget
{
Q_OBJECT
public:
KLocaleConfig( QWidget *parent=0, const char *name=0);
~KLocaleConfig( );
void loadLocaleList(KLanguageCombo *combo, const QString &sub, const QStringList &first);
void load();
void save();
void defaults();
public slots:
void reTranslateLists();
void reTranslate();
signals:
void translate();
void resample();
void countryChanged();
void moneyChanged();
void numberChanged();
void timeChanged();
void chsetChanged();
private:
KLanguageCombo *comboCountry, *comboLang, *comboNumber, *comboMoney, *comboDate, *comboChset;
private slots:
void changedCountry(int);
void changedLanguage(int);
void changedNumber(int);
void changedMoney(int);
void changedTime(int);
void changedCharset(int);
void readLocale(const QString &path, QString &name, const QString &sub) const;
};
kcontrol'KLocaleConfig::KLocaleConfig() (./kdebase/kcontrol/locale/locale.cpp:49)
KLocaleConfig::KLocaleConfig(QWidget *parent, const char *name)
: QWidget (parent, name)
{
QGridLayout *tl1 = new QGridLayout(this, 1, 1, 10, 5);
tl1->setColStretch( 2, 1);
QLabel *label = new QLabel(this, I18N_NOOP("&Country"));
comboCountry = new KLanguageCombo(this);
comboCountry->setFixedHeight(comboCountry->sizeHint().height());
label->setBuddy(comboCountry);
connect( comboCountry, SIGNAL(activated(int)),
this, SLOT(changedCountry(int)) );
tl1->addWidget(label, 1, 1);
tl1->addWidget(comboCountry, 1, 2);
label = new QLabel(this, I18N_NOOP("&Language"));
comboLang = new KLanguageCombo(this);
comboLang->setFixedHeight(comboLang->sizeHint().height());
label->setBuddy(comboLang);
connect( comboLang, SIGNAL(activated(int)),
this, SLOT(changedLanguage(int)) );
tl1->addWidget(label, 2, 1);
tl1->addWidget(comboLang, 2, 2);
label = new QLabel(this, I18N_NOOP("&Numbers"));
comboNumber = new KLanguageCombo(this);
comboNumber->setFixedHeight(comboNumber->sizeHint().height());
label->setBuddy(comboNumber);
connect( comboNumber, SIGNAL(activated(int)),
this, SLOT(changedNumber(int)) );
tl1->addWidget(label, 3, 1);
tl1->addWidget(comboNumber, 3, 2);
label = new QLabel(this, I18N_NOOP("&Money"));
comboMoney = new KLanguageCombo(this);
comboMoney->setFixedHeight(comboMoney->sizeHint().height());
label->setBuddy(comboMoney);
connect( comboMoney, SIGNAL(activated(int)),
this, SLOT(changedMoney(int)) );
tl1->addWidget(label, 4, 1);
tl1->addWidget(comboMoney, 4, 2);
label = new QLabel(this, I18N_NOOP("&Date and time"));
comboDate = new KLanguageCombo(this);
comboDate->setFixedHeight(comboDate->sizeHint().height());
label->setBuddy(comboDate);
connect( comboDate, SIGNAL(activated(int)),
this, SLOT(changedTime(int)) );
tl1->addWidget(label, 5, 1);
tl1->addWidget(comboDate, 5, 2);
label = new QLabel(this, I18N_NOOP("C&harset"));
comboChset = new KLanguageCombo(this);
comboChset->setFixedHeight(comboChset->sizeHint().height());
label->setBuddy(comboChset);
connect( comboChset, SIGNAL(activated(int)),
this, SLOT(changedCharset(int)) );
tl1->addWidget(label, 6, 1);
tl1->addWidget(comboChset, 6, 2);
QStringList list = KGlobal::charsets()->availableCharsetNames();
for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
comboChset->insertItem(*it, *it);
tl1->setRowStretch(7, 1);
}
kcontrol'KLocaleConfig::~KLocaleConfig() (./kdebase/kcontrol/locale/locale.cpp:116)
KLocaleConfig::~KLocaleConfig ()
{
}
kcontrol'KLocaleConfig::loadLocaleList() (./kdebase/kcontrol/locale/locale.cpp:120)
void KLocaleConfig::loadLocaleList(KLanguageCombo *combo, const QString &sub, const QStringList &first)
{
// temperary use of our locale as the global locale
KLocale *lsave = KGlobal::_locale;
KGlobal::_locale = locale;
QString name;
// clear the list
combo->clear();
QStringList prilang;
// add the primary languages for the country to the list
for ( QStringList::ConstIterator it = first.begin(); it != first.end(); ++it )
{
QString str = locate("locale", sub + *it + QString::fromLatin1("/entry.desktop"));
if (!str.isNull())
prilang << str;
}
// add all languages to the list
QStringList alllang = KGlobal::dirs()->findAllResources("locale",
sub + QString::fromLatin1("*/entry.desktop"));
alllang.sort();
QStringList langlist = prilang;
if (langlist.count() > 0)
langlist << QString::null; // separator
langlist += alllang;
QString submenu; // we are working on this menu
for ( QStringList::ConstIterator it = langlist.begin();
it != langlist.end(); ++it )
{
if ((*it).isNull())
{
combo->insertSeparator();
submenu = QString::fromLatin1("other");
combo->insertSubmenu(locale->translate("Other"), submenu);
continue;
}
KSimpleConfig entry(*it);
entry.setGroup(QString::fromLatin1("KCM Locale"));
name = entry.readEntry(QString::fromLatin1("Name"), locale->translate("without name"));
QString path = *it;
int index = path.findRev('/');
path = path.left(index);
index = path.findRev('/');
path = path.mid(index+1);
combo->insertLanguage(path, name, sub, submenu);
}
// restore the old global locale
KGlobal::_locale = lsave;
}
kcontrol'KLocaleConfig::load() (./kdebase/kcontrol/locale/locale.cpp:175)
void KLocaleConfig::load()
{
KConfig *config = KGlobal::config();
config->setGroup(QString::fromLatin1("Locale"));
QString country = config->readEntry(QString::fromLatin1("Country"));
QString lang = config->readEntry(QString::fromLatin1("Language"));
lang = lang.left(lang.find(':')); // only use the first lang
locale->setLanguage(lang);
QString number = config->readEntry(QString::fromLatin1("Numeric"));
QString money = config->readEntry(QString::fromLatin1("Monetary"));
QString time = config->readEntry(QString::fromLatin1("Time"));
locale->setCountry(number, money, time);
QString charset = config->readEntry(QString::fromLatin1("Charset"), QString::fromLatin1("iso-8859-1"));
emit chsetChanged();
KSimpleConfig ent(locate("locale", QString::fromLatin1("l10n/") + country + QString::fromLatin1("/entry.desktop")), true);
ent.setGroup(QString::fromLatin1("KCM Locale"));
QStringList langs = ent.readListEntry(QString::fromLatin1("Languages"));
if (langs.isEmpty()) langs = QString::fromLatin1("C");
// load lists into widgets
loadLocaleList(comboLang, QString::null, langs);
loadLocaleList(comboCountry, QString::fromLatin1("l10n/"), QStringList());
loadLocaleList(comboNumber, QString::fromLatin1("l10n/"), QStringList());
loadLocaleList(comboMoney, QString::fromLatin1("l10n/"), QStringList());
loadLocaleList(comboDate, QString::fromLatin1("l10n/"), QStringList());
// update widgets
comboLang->setCurrentItem(locale->language());
comboNumber->setCurrentItem(number);
comboMoney->setCurrentItem(money);
comboDate->setCurrentItem(time);
comboCountry->setCurrentItem(country);
comboChset->setCurrentItem(charset);
}
kcontrol'KLocaleConfig::readLocale() (./kdebase/kcontrol/locale/locale.cpp:215)
void KLocaleConfig::readLocale(const QString &path, QString &name, const QString &sub) const
{
// temperary use of our locale as the global locale
KLocale *lsave = KGlobal::_locale;
KGlobal::_locale = locale;
// read the name
KSimpleConfig entry(locate("locale", sub + path + QString::fromLatin1("/entry.desktop")));
entry.setGroup(QString::fromLatin1("KCM Locale"));
name = entry.readEntry(QString::fromLatin1("Name"), locale->translate("without name"));
// restore the old global locale
KGlobal::_locale = lsave;
}
kcontrol'KLocaleConfig::save() (./kdebase/kcontrol/locale/locale.cpp:230)
void KLocaleConfig::save()
{
KConfigBase *config = KGlobal::config();
config->setGroup(QString::fromLatin1("Locale"));
config->writeEntry(QString::fromLatin1("Country"), comboCountry->currentTag(), true, true);
config->writeEntry(QString::fromLatin1("Language"), comboLang->currentTag(), true, true);
config->writeEntry(QString::fromLatin1("Numeric"), comboNumber->currentTag(), true, true);
config->writeEntry(QString::fromLatin1("Monetary"), comboMoney->currentTag(), true, true);
config->writeEntry(QString::fromLatin1("Time"), comboDate->currentTag(), true, true);
config->writeEntry(QString::fromLatin1("Charset"), comboChset->currentTag(), true, true);
config->sync();
}
kcontrol'KLocaleConfig::defaults() (./kdebase/kcontrol/locale/locale.cpp:246)
void KLocaleConfig::defaults()
{
QString C = QString::fromLatin1("C");
locale->setLanguage(C);
locale->setCountry(C);
reTranslateLists();
loadLocaleList(comboLang, QString::null, QStringList());
comboCountry->setCurrentItem(C);
comboLang->setCurrentItem(C);
comboNumber->setCurrentItem(C);
comboMoney->setCurrentItem(C);
comboDate->setCurrentItem(C);
comboChset->setCurrentItem(QString::fromLatin1("iso-8859-1"));
emit resample();
emit countryChanged();
}
kcontrol'KLocaleConfig::changedCountry() (./kdebase/kcontrol/locale/locale.cpp:266)
void KLocaleConfig::changedCountry(int i)
{
QString country = comboCountry->tag(i);
KSimpleConfig ent(locate("locale", QString::fromLatin1("l10n/") + country + QString::fromLatin1("/entry.desktop")), true);
ent.setGroup(QString::fromLatin1("KCM Locale"));
QStringList langs = ent.readListEntry(QString::fromLatin1("Languages"));
if (langs.isEmpty()) langs = QString::fromLatin1("C");
locale->setLanguage(*langs.at(0));
locale->setCountry(country);
reTranslateLists();
loadLocaleList(comboLang, QString::null, langs);
comboLang->setCurrentItem(*langs.at(0));
comboNumber->setCurrentItem(country);
comboMoney->setCurrentItem(country);
comboDate->setCurrentItem(country);
emit countryChanged();
emit resample();
}
kcontrol'KLocaleConfig::changedLanguage() (./kdebase/kcontrol/locale/locale.cpp:290)
void KLocaleConfig::changedLanguage(int i)
{
locale->setLanguage(comboLang->tag(i));
reTranslateLists();
emit resample();
}
kcontrol'KLocaleConfig::changedNumber() (./kdebase/kcontrol/locale/locale.cpp:299)
void KLocaleConfig::changedNumber(int i)
{
locale->setCountry(comboNumber->tag(i),
QString::null,
QString::null);
emit numberChanged();
emit resample();
}
kcontrol'KLocaleConfig::changedMoney() (./kdebase/kcontrol/locale/locale.cpp:309)
void KLocaleConfig::changedMoney(int i)
{
locale->setCountry(QString::null,
comboMoney->tag(i),
QString::null);
emit moneyChanged();
emit resample();
}
kcontrol'KLocaleConfig::changedTime() (./kdebase/kcontrol/locale/locale.cpp:319)
void KLocaleConfig::changedTime(int i)
{
locale->setCountry(QString::null,
QString::null,
comboDate->tag(i));
emit timeChanged();
emit resample();
}
kcontrol'KLocaleConfig::changedCharset() (./kdebase/kcontrol/locale/locale.cpp:329)
void KLocaleConfig::changedCharset(int)
{
locale->setChset(comboChset->currentTag());
emit chsetChanged();
}
kcontrol'KLocaleConfig::reTranslateLists() (./kdebase/kcontrol/locale/locale.cpp:336)
void KLocaleConfig::reTranslateLists()
{
int j;
QString name;
for (j = 0; j < comboCountry->count(); j++)
{
readLocale(comboCountry->tag(j), name, QString::fromLatin1("l10n/"));
comboCountry->changeLanguage(name, j);
comboNumber->changeLanguage(name, j);
comboMoney->changeLanguage(name, j);
comboDate->changeLanguage(name, j);
}
for (j = 0; j < comboLang->count(); j++)
{
if (comboLang->tag(j) == QString::fromLatin1("other"))
comboLang->changeItem(locale->translate("Other"), j);
else
{
readLocale(comboLang->tag(j), name, QString::null);
comboLang->changeLanguage(name, j);
}
}
}
kcontrol'KLocaleConfig::reTranslate() (./kdebase/kcontrol/locale/locale.cpp:361)
void KLocaleConfig::reTranslate()
{
QToolTip::add(comboCountry, locale->translate("This is were you live. KDE will use the defaults for this country."));
QToolTip::add(comboLang, locale->translate("All KDE programs will be displayed in this language (if available)."));
QToolTip::add(comboNumber, locale->translate("The rules of this country will be used to localize numbers."));
QToolTip::add(comboMoney, locale->translate("The rules of this country will be used to localize money."));
QToolTip::add(comboDate, locale->translate("The rules of this country will be used to display time and dates."));
QToolTip::add(comboChset, locale->translate("The prefered charset for fonts."));
}