diff --git a/main.cpp b/main.cpp index 999b49a5f..1f3dc01e2 100644 --- a/main.cpp +++ b/main.cpp @@ -1,4 +1,5 @@ #include "widget/widget.h" +#include "settings.h" #include #include #include @@ -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"); diff --git a/settings.cpp b/settings.cpp index 204119f6b..3885fdd5c 100644 --- a/settings.cpp +++ b/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; diff --git a/settings.h b/settings.h index d113f8e11..38667ef01 100644 --- a/settings.h +++ b/settings.h @@ -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; diff --git a/widget/form/settingsform.cpp b/widget/form/settingsform.cpp index 26e7fbbf7..d3e93a995 100644 --- a/widget/form/settingsform.cpp +++ b/widget/form/settingsform.cpp @@ -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()); +} diff --git a/widget/form/settingsform.h b/widget/form/settingsform.h index 86cc5e6ce..0091e8fe8 100644 --- a/widget/form/settingsform.h +++ b/widget/form/settingsform.h @@ -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;