1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Add option to disable translations

This commit is contained in:
Tux3 / Mlkj / !Lev.uXFMLA 2014-07-04 19:22:43 +02:00
parent c7fcb38a05
commit f9289438af
5 changed files with 38 additions and 27 deletions

View File

@ -1,4 +1,5 @@
#include "widget/widget.h" #include "widget/widget.h"
#include "settings.h"
#include <QApplication> #include <QApplication>
#include <QFontDatabase> #include <QFontDatabase>
#include <QTranslator> #include <QTranslator>
@ -10,13 +11,16 @@ int main(int argc, char *argv[])
a.setOrganizationName("Tox"); a.setOrganizationName("Tox");
// Load translations // Load translations
QString locale = QLocale::system().name().section('_', 0, 0);
QTranslator translator; QTranslator translator;
if (Settings::getInstance().getUseTranslations())
{
QString locale = QLocale::system().name().section('_', 0, 0);
if (translator.load(locale,":translations/")) if (translator.load(locale,":translations/"))
qDebug() << "Loaded translation "+locale; qDebug() << "Loaded translation "+locale;
else else
qDebug() << "Error loading translation "+locale; qDebug() << "Error loading translation "+locale;
a.installTranslator(&translator); a.installTranslator(&translator);
}
// Install Unicode 6.1 supporting font // Install Unicode 6.1 supporting font
QFontDatabase::addApplicationFont("://DejaVuSans.ttf"); QFontDatabase::addApplicationFont("://DejaVuSans.ttf");

View File

@ -72,18 +72,11 @@ void Settings::load()
s.endArray(); s.endArray();
s.endGroup(); s.endGroup();
//NOTE: uncomment when logging will be implemented
/*
s.beginGroup("Logging");
enableLogging = s.value("enableLogging", false).toBool();
encryptLogs = s.value("encryptLogs", true).toBool();
s.endGroup();
*/
s.beginGroup("General"); s.beginGroup("General");
username = s.value("username", "My name").toString(); username = s.value("username", "My name").toString();
statusMessage = s.value("statusMessage", "My status").toString(); statusMessage = s.value("statusMessage", "My status").toString();
enableIPv6 = s.value("enableIPv6", true).toBool(); enableIPv6 = s.value("enableIPv6", true).toBool();
useTranslations = s.value("useTranslations", true).toBool();
s.endGroup(); s.endGroup();
s.beginGroup("Widgets"); s.beginGroup("Widgets");
@ -132,18 +125,11 @@ void Settings::save()
s.endArray(); s.endArray();
s.endGroup(); s.endGroup();
//NOTE: uncomment when logging will be implemented
/*
s.beginGroup("Logging");
s.setValue("storeLogs", enableLogging);
s.setValue("encryptLogs", encryptLogs);
s.endGroup();
*/
s.beginGroup("General"); s.beginGroup("General");
s.setValue("username", username); s.setValue("username", username);
s.setValue("statusMessage", statusMessage); s.setValue("statusMessage", statusMessage);
s.setValue("enableIPv6", enableIPv6); s.setValue("enableIPv6", enableIPv6);
s.setValue("useTranslations",useTranslations);
s.endGroup(); s.endGroup();
s.beginGroup("Widgets"); s.beginGroup("Widgets");
@ -221,6 +207,16 @@ void Settings::setEnableIPv6(bool newValue)
enableIPv6 = newValue; enableIPv6 = newValue;
} }
bool Settings::getUseTranslations() const
{
return useTranslations;
}
void Settings::setUseTranslations(bool newValue)
{
useTranslations = newValue;
}
bool Settings::getEnableLogging() const bool Settings::getEnableLogging() const
{ {
return enableLogging; return enableLogging;

View File

@ -52,6 +52,9 @@ public:
bool getEnableIPv6() const; bool getEnableIPv6() const;
void setEnableIPv6(bool newValue); void setEnableIPv6(bool newValue);
bool getUseTranslations() const;
void setUseTranslations(bool newValue);
bool getEnableLogging() const; bool getEnableLogging() const;
void setEnableLogging(bool newValue); void setEnableLogging(bool newValue);
@ -134,6 +137,7 @@ private:
QString statusMessage; QString statusMessage;
bool enableIPv6; bool enableIPv6;
bool useTranslations;
bool enableLogging; bool enableLogging;
bool encryptLogs; bool encryptLogs;

View File

@ -22,14 +22,14 @@ SettingsForm::SettingsForm()
id.setTextInteractionFlags(Qt::TextSelectableByMouse); id.setTextInteractionFlags(Qt::TextSelectableByMouse);
id.setReadOnly(true); id.setReadOnly(true);
id.setFrameStyle(QFrame::NoFrame); id.setFrameStyle(QFrame::NoFrame);
id.setMinimumHeight(10); id.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
id.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); id.setFixedHeight(id.document()->size().height());
id.setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents);
id.setMaximumHeight(40);
videoTest.setText(tr("Test video","Text on a button to test the video/webcam")); videoTest.setText(tr("Test video","Text on a button to test the video/webcam"));
enableIPv6.setText(tr("Enable IPv6 (recommended)","Text on a checkbox to enable IPv6")); enableIPv6.setText(tr("Enable IPv6 (recommended)","Text on a checkbox to enable IPv6"));
enableIPv6.setChecked(Settings::getInstance().getEnableIPv6()); enableIPv6.setChecked(Settings::getInstance().getEnableIPv6());
useTranslations.setText(tr("Use translations","Text on a checkbox to enable translations"));
useTranslations.setChecked(Settings::getInstance().getUseTranslations());
main->setLayout(&layout); main->setLayout(&layout);
layout.addWidget(&nameLabel); layout.addWidget(&nameLabel);
@ -40,6 +40,7 @@ SettingsForm::SettingsForm()
layout.addWidget(&id); layout.addWidget(&id);
layout.addWidget(&videoTest); layout.addWidget(&videoTest);
layout.addWidget(&enableIPv6); layout.addWidget(&enableIPv6);
layout.addWidget(&useTranslations);
layout.addStretch(); layout.addStretch();
head->setLayout(&headLayout); head->setLayout(&headLayout);
@ -84,3 +85,8 @@ void SettingsForm::copyIdClicked()
id.selectAll();; id.selectAll();;
QApplication::clipboard()->setText(id.toPlainText()); QApplication::clipboard()->setText(id.toPlainText());
} }
void SettingsForm::onUseTranslationUpdated()
{
Settings::getInstance().setUseTranslations(useTranslations.isChecked());
}

View File

@ -29,6 +29,7 @@ public slots:
private slots: private slots:
void onTestVideoClicked(); void onTestVideoClicked();
void onEnableIPv6Updated(); void onEnableIPv6Updated();
void onUseTranslationUpdated();
void copyIdClicked(); void copyIdClicked();
private: private:
@ -36,7 +37,7 @@ private:
QTextEdit id; QTextEdit id;
ClickableLabel idLabel; ClickableLabel idLabel;
QPushButton videoTest; QPushButton videoTest;
QCheckBox enableIPv6; QCheckBox enableIPv6, useTranslations;
QVBoxLayout layout, headLayout; QVBoxLayout layout, headLayout;
QWidget *main, *head; QWidget *main, *head;