// Set up i18n support
QLocale locale = QLocale::system();
- QTranslator qtTranslator;
+ QTranslator qtTranslator(&app);
+ qtTranslator.setObjectName("QtTr");
qtTranslator.load(QString(":i18n/qt_%1").arg(locale.name()));
app.installTranslator(&qtTranslator);
- QTranslator quasselTranslator;
+ QTranslator quasselTranslator(&app);
+ quasselTranslator.setObjectName("QuasselTr");
quasselTranslator.load(QString(":i18n/quassel_%1").arg(locale.name()));
app.installTranslator(&quasselTranslator);
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
+#include "util.h"
+
#include <QCoreApplication>
#include <QDebug>
#include <QTextCodec>
-
-#include "util.h"
+#include <QTranslator>
class QMetaMethod;
uint editingDistance(const QString &s1, const QString &s2) {
uint n = s1.size()+1;
uint m = s2.size()+1;
- //uint matrix[n][m];
QVector< QVector< uint > >matrix(n,QVector<uint>(m,0));
for(uint i = 0; i < n; i++)
return qDir;
}
+void loadTranslation(const QLocale &locale) {
+ QTranslator *qtTranslator = QCoreApplication::instance()->findChild<QTranslator *>("QtTr");
+ QTranslator *quasselTranslator = QCoreApplication::instance()->findChild<QTranslator *>("QuasselTr");
+ Q_ASSERT(qtTranslator);
+ Q_ASSERT(quasselTranslator);
+
+ QLocale::setDefault(locale);
+
+ QCoreApplication::removeTranslator(qtTranslator);
+ QCoreApplication::removeTranslator(quasselTranslator);
+
+ if(locale.language() == QLocale::C)
+ return;
+
+ qtTranslator->load(QString(":i18n/qt_%1").arg(locale.name()));
+ quasselTranslator->load(QString(":i18n/quassel_%1").arg(locale.name()));
+
+ QCoreApplication::installTranslator(qtTranslator);
+ QCoreApplication::installTranslator(quasselTranslator);
+}
QString secondsToString(int timeInSeconds) {
QList< QPair<int, QString> > timeUnit;
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
-#ifndef _UTIL_H_
-#define _UTIL_H_
+#ifndef UTIL_H
+#define UTIL_H
#include <QDir>
-#include <QIODevice>
+#include <QLocale>
#include <QVariant>
#include <QString>
#include <QMetaMethod>
*/
QString decodeString(const QByteArray &input, QTextCodec *codec = 0);
-// NOTE: We have static copies of these in SignalProxy...
-//void writeDataToDevice(QIODevice *, const QVariant &);
-//bool readDataFromDevice(QIODevice *, quint32 &, QVariant &);
-
uint editingDistance(const QString &s1, const QString &s2);
QByteArray methodName(const QMetaMethod &method);
QDir quasselDir();
+void loadTranslation(const QLocale &locale);
+
#endif
#include "irclistmodel.h"
#include "verticaldock.h"
#include "uisettings.h"
+#include "util.h"
#include "qtuisettings.h"
#include "jumpkeyhandler.h"
settingsDlg(new SettingsDlg(this)),
debugConsole(new DebugConsole(this))
{
+ UiSettings uiSettings;
+ loadTranslation(uiSettings.value("Locale", QLocale::system()).value<QLocale>());
+
+ QString style = uiSettings.value("Style", QString("")).toString();
+ if(style != "") {
+ QApplication::setStyle(style);
+ }
+
ui.setupUi(this);
setWindowTitle("Quassel IRC");
setWindowIcon(offlineTrayIcon);
installEventFilter(new JumpKeyHandler(this));
- UiSettings uiSettings;
- QString style = uiSettings.value("Style", QString("")).toString();
- if(style != "") {
- QApplication::setStyle(style);
- }
}
void MainWin::init() {
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU Appearance Public License as published by *
+ * 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. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU Appearance Public License for more details. *
+ * GNU General Public License for more details. *
* *
- * You should have received a copy of the GNU Appearance Public License *
+ * You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
#include "qtui.h"
#include "uisettings.h"
+#include "util.h"
+#include <QDir>
#include <QStyleFactory>
AppearanceSettingsPage::AppearanceSettingsPage(QWidget *parent)
: SettingsPage(tr("Appearance"), tr("General"), parent) {
ui.setupUi(this);
initStyleComboBox();
+ initLanguageComboBox();
connect(ui.styleComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(widgetHasChanged()));
+ connect(ui.languageComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(widgetHasChanged()));
}
void AppearanceSettingsPage::initStyleComboBox() {
}
}
-bool AppearanceSettingsPage::hasDefaults() const {
- return true;
+void AppearanceSettingsPage::initLanguageComboBox() {
+ QDir i18nDir(":/i18n", "quassel_*.qm");
+
+ foreach(QString translationFile, i18nDir.entryList()) {
+ QString localeName(translationFile.mid(8));
+ localeName.chop(3);
+ QLocale locale(localeName);
+ _locales << locale;
+ ui.languageComboBox->addItem(QLocale::languageToString(locale.language()));
+ }
+
}
void AppearanceSettingsPage::defaults() {
QApplication::setStyle(settings["Style"].toString());
}
+ QLocale locale = uiSettings.value("Locale", QLocale::system()).value<QLocale>();
+ if(locale == QLocale::system())
+ ui.languageComboBox->setCurrentIndex(0);
+ else if(locale.language() == QLocale::C)
+ ui.languageComboBox->setCurrentIndex(1);
+ else
+ ui.languageComboBox->setCurrentIndex(ui.languageComboBox->findText(QLocale::languageToString(locale.language()), Qt::MatchExactly));
+ loadTranslation(selectedLocale());
+
setChangedState(false);
}
uiSettings.setValue("Style", ui.styleComboBox->currentText());
}
+ if(ui.languageComboBox->currentIndex() == 0) {
+ uiSettings.remove("Locale"); // force the default (QLocale::system())
+ } else {
+ uiSettings.setValue("Locale", selectedLocale());
+ }
+
load();
setChangedState(false);
}
+QLocale AppearanceSettingsPage::selectedLocale() const {
+ QLocale locale;
+ int index = ui.languageComboBox->currentIndex();
+ if(index == 0)
+ locale = QLocale::system();
+ else if(index == 1)
+ locale = QLocale::c();
+ else if(index > 1)
+ locale = _locales[index - 2];
+
+ return locale;
+}
+
void AppearanceSettingsPage::widgetHasChanged() {
- bool changed = testHasChanged();
- if(changed != hasChanged()) setChangedState(changed);
+ setChangedState(testHasChanged());
}
bool AppearanceSettingsPage::testHasChanged() {
if(settings["Style"].toString() != ui.styleComboBox->currentText()) return true;
+ if(selectedLocale() != QLocale()) return true; // QLocale() returns the default locale (manipulated via loadTranslation())
return false;
}
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU Appearance Public License as published by *
+ * 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. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU Appearance Public License for more details. *
+ * GNU General Public License for more details. *
* *
- * You should have received a copy of the GNU Appearance Public License *
+ * You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
-#ifndef _APPEARANCESETTINGSPAGE_H_
-#define _APPEARANCESETTINGSPAGE_H_
+#ifndef APPEARANCESETTINGSPAGE_H
+#define APPEARANCESETTINGSPAGE_H
#include <QHash>
+#include <QList>
+#include <QLocale>
#include "settingspage.h"
#include "ui_appearancesettingspage.h"
class AppearanceSettingsPage : public SettingsPage {
Q_OBJECT
- public:
- AppearanceSettingsPage(QWidget *parent = 0);
-
- bool hasDefaults() const;
-
- public slots:
- void save();
- void load();
- void defaults();
-
- private slots:
- void widgetHasChanged();
-
- private:
- Ui::AppearanceSettingsPage ui;
- QHash<QString, QVariant> settings;
-
- bool testHasChanged();
- void initStyleComboBox();
+public:
+ AppearanceSettingsPage(QWidget *parent = 0);
+
+ inline bool hasDefaults() const { return true; }
+
+public slots:
+ void save();
+ void load();
+ void defaults();
+
+private slots:
+ void widgetHasChanged();
+
+private:
+ Ui::AppearanceSettingsPage ui;
+ QHash<QString, QVariant> settings;
+ QList<QLocale> _locales;
+
+ bool testHasChanged();
+ void initStyleComboBox();
+ void initLanguageComboBox();
+ QLocale selectedLocale() const;
};
#endif
<rect>
<x>0</x>
<y>0</y>
- <width>400</width>
- <height>300</height>
+ <width>331</width>
+ <height>269</height>
</rect>
</property>
<property name="windowTitle" >
<string>Form</string>
</property>
- <layout class="QVBoxLayout" >
+ <layout class="QVBoxLayout" name="verticalLayout_2" >
<item>
<widget class="QGroupBox" name="groupBox" >
<property name="title" >
</layout>
</widget>
</item>
+ <item>
+ <widget class="QGroupBox" name="groupBox_2" >
+ <property name="title" >
+ <string>Language:</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout" >
+ <item>
+ <widget class="QComboBox" name="languageComboBox" >
+ <item>
+ <property name="text" >
+ <string><System></string>
+ </property>
+ </item>
+ <item>
+ <property name="text" >
+ <string><Original></string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label" >
+ <property name="text" >
+ <string>Note: needs client restart for full effect!</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
- <property name="sizeHint" >
+ <property name="sizeHint" stdset="0" >
<size>
<width>20</width>
<height>40</height>
#include "uisettings.h"
-UiSettings::UiSettings(const QString &group) : ClientSettings(group) {
-
-
+UiSettings::UiSettings(const QString &group)
+ : ClientSettings(group)
+{
}
void UiSettings::setValue(const QString &key, const QVariant &data) {
QVariant UiSettings::value(const QString &key, const QVariant &def) {
return localValue(key, def);
}
+
+void UiSettings::remove(const QString &key) {
+ removeLocalKey(key);
+}
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
-#ifndef _UISETTINGS_H_
-#define _UISETTINGS_H_
+#ifndef UISETTINGS_H
+#define UISETTINGS_H
#include "clientsettings.h"
class UiSettings : public ClientSettings {
-
- public:
- UiSettings(const QString &group = "Ui");
-
- void setValue(const QString &key, const QVariant &data);
- QVariant value(const QString &key, const QVariant &def = QVariant());
-
-
+public:
+ UiSettings(const QString &group = "Ui");
+
+ void setValue(const QString &key, const QVariant &data);
+ QVariant value(const QString &key, const QVariant &def = QVariant());
+ void remove(const QString &key);
};
-/*
-class GuiProfile : public ClientSettings {
-
- public:
- GuiProfile();
-
- static QStringList availableProfiles();
- static GuiProfile *profile(QString name);
-
-
-
-};
-*/
#endif