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:
parent
c7fcb38a05
commit
f9289438af
16
main.cpp
16
main.cpp
|
@ -1,4 +1,5 @@
|
|||
#include "widget/widget.h"
|
||||
#include "settings.h"
|
||||
#include <QApplication>
|
||||
#include <QFontDatabase>
|
||||
#include <QTranslator>
|
||||
|
@ -10,13 +11,16 @@ int main(int argc, char *argv[])
|
|||
a.setOrganizationName("Tox");
|
||||
|
||||
// Load translations
|
||||
QString locale = QLocale::system().name().section('_', 0, 0);
|
||||
QTranslator translator;
|
||||
if (translator.load(locale,":translations/"))
|
||||
qDebug() << "Loaded translation "+locale;
|
||||
else
|
||||
qDebug() << "Error loading translation "+locale;
|
||||
a.installTranslator(&translator);
|
||||
if (Settings::getInstance().getUseTranslations())
|
||||
{
|
||||
QString locale = QLocale::system().name().section('_', 0, 0);
|
||||
if (translator.load(locale,":translations/"))
|
||||
qDebug() << "Loaded translation "+locale;
|
||||
else
|
||||
qDebug() << "Error loading translation "+locale;
|
||||
a.installTranslator(&translator);
|
||||
}
|
||||
|
||||
// Install Unicode 6.1 supporting font
|
||||
QFontDatabase::addApplicationFont("://DejaVuSans.ttf");
|
||||
|
|
28
settings.cpp
28
settings.cpp
|
@ -72,18 +72,11 @@ void Settings::load()
|
|||
s.endArray();
|
||||
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");
|
||||
username = s.value("username", "My name").toString();
|
||||
statusMessage = s.value("statusMessage", "My status").toString();
|
||||
enableIPv6 = s.value("enableIPv6", true).toBool();
|
||||
useTranslations = s.value("useTranslations", true).toBool();
|
||||
s.endGroup();
|
||||
|
||||
s.beginGroup("Widgets");
|
||||
|
@ -132,18 +125,11 @@ void Settings::save()
|
|||
s.endArray();
|
||||
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.setValue("username", username);
|
||||
s.setValue("statusMessage", statusMessage);
|
||||
s.setValue("enableIPv6", enableIPv6);
|
||||
s.setValue("useTranslations",useTranslations);
|
||||
s.endGroup();
|
||||
|
||||
s.beginGroup("Widgets");
|
||||
|
@ -221,6 +207,16 @@ void Settings::setEnableIPv6(bool newValue)
|
|||
enableIPv6 = newValue;
|
||||
}
|
||||
|
||||
bool Settings::getUseTranslations() const
|
||||
{
|
||||
return useTranslations;
|
||||
}
|
||||
|
||||
void Settings::setUseTranslations(bool newValue)
|
||||
{
|
||||
useTranslations = newValue;
|
||||
}
|
||||
|
||||
bool Settings::getEnableLogging() const
|
||||
{
|
||||
return enableLogging;
|
||||
|
|
|
@ -52,6 +52,9 @@ public:
|
|||
bool getEnableIPv6() const;
|
||||
void setEnableIPv6(bool newValue);
|
||||
|
||||
bool getUseTranslations() const;
|
||||
void setUseTranslations(bool newValue);
|
||||
|
||||
bool getEnableLogging() const;
|
||||
void setEnableLogging(bool newValue);
|
||||
|
||||
|
@ -134,6 +137,7 @@ private:
|
|||
QString statusMessage;
|
||||
|
||||
bool enableIPv6;
|
||||
bool useTranslations;
|
||||
|
||||
bool enableLogging;
|
||||
bool encryptLogs;
|
||||
|
|
|
@ -22,14 +22,14 @@ SettingsForm::SettingsForm()
|
|||
id.setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||
id.setReadOnly(true);
|
||||
id.setFrameStyle(QFrame::NoFrame);
|
||||
id.setMinimumHeight(10);
|
||||
id.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
|
||||
id.setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents);
|
||||
id.setMaximumHeight(40);
|
||||
id.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
id.setFixedHeight(id.document()->size().height());
|
||||
|
||||
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.setChecked(Settings::getInstance().getEnableIPv6());
|
||||
useTranslations.setText(tr("Use translations","Text on a checkbox to enable translations"));
|
||||
useTranslations.setChecked(Settings::getInstance().getUseTranslations());
|
||||
|
||||
main->setLayout(&layout);
|
||||
layout.addWidget(&nameLabel);
|
||||
|
@ -40,6 +40,7 @@ SettingsForm::SettingsForm()
|
|||
layout.addWidget(&id);
|
||||
layout.addWidget(&videoTest);
|
||||
layout.addWidget(&enableIPv6);
|
||||
layout.addWidget(&useTranslations);
|
||||
layout.addStretch();
|
||||
|
||||
head->setLayout(&headLayout);
|
||||
|
@ -84,3 +85,8 @@ void SettingsForm::copyIdClicked()
|
|||
id.selectAll();;
|
||||
QApplication::clipboard()->setText(id.toPlainText());
|
||||
}
|
||||
|
||||
void SettingsForm::onUseTranslationUpdated()
|
||||
{
|
||||
Settings::getInstance().setUseTranslations(useTranslations.isChecked());
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ public slots:
|
|||
private slots:
|
||||
void onTestVideoClicked();
|
||||
void onEnableIPv6Updated();
|
||||
void onUseTranslationUpdated();
|
||||
void copyIdClicked();
|
||||
|
||||
private:
|
||||
|
@ -36,7 +37,7 @@ private:
|
|||
QTextEdit id;
|
||||
ClickableLabel idLabel;
|
||||
QPushButton videoTest;
|
||||
QCheckBox enableIPv6;
|
||||
QCheckBox enableIPv6, useTranslations;
|
||||
QVBoxLayout layout, headLayout;
|
||||
QWidget *main, *head;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user