mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-25 14:04:23 +00:00
Fix locale change from the Web UI
This commit is contained in:
parent
790db14b51
commit
c64f02c9bf
@ -38,6 +38,7 @@
|
|||||||
//#include "proplistdelegate.h"
|
//#include "proplistdelegate.h"
|
||||||
#include "torrentpersistentdata.h"
|
#include "torrentpersistentdata.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QTranslator>
|
||||||
|
|
||||||
EventManager::EventManager(QObject *parent, Bittorrent *BTSession)
|
EventManager::EventManager(QObject *parent, Bittorrent *BTSession)
|
||||||
: QObject(parent), BTSession(BTSession)
|
: QObject(parent), BTSession(BTSession)
|
||||||
@ -124,8 +125,20 @@ QList<QVariantMap> EventManager::getPropFilesInfo(QString hash) const {
|
|||||||
|
|
||||||
void EventManager::setGlobalPreferences(QVariantMap m) const {
|
void EventManager::setGlobalPreferences(QVariantMap m) const {
|
||||||
// UI
|
// UI
|
||||||
if(m.contains("locale"))
|
if(m.contains("locale")) {
|
||||||
Preferences::setLocale(m["locale"].toString());
|
QString locale = m["locale"].toString();
|
||||||
|
if(Preferences::getLocale() != locale) {
|
||||||
|
QTranslator *translator = new QTranslator;
|
||||||
|
if(translator->load(QString::fromUtf8(":/lang/qbittorrent_") + locale)){
|
||||||
|
qDebug("%s locale recognized, using translation.", qPrintable(locale));
|
||||||
|
}else{
|
||||||
|
qDebug("%s locale unrecognized, using default (en_GB).", qPrintable(locale));
|
||||||
|
}
|
||||||
|
qApp->installTranslator(translator);
|
||||||
|
}
|
||||||
|
|
||||||
|
Preferences::setLocale(locale);
|
||||||
|
}
|
||||||
// Downloads
|
// Downloads
|
||||||
if(m.contains("save_path"))
|
if(m.contains("save_path"))
|
||||||
Preferences::setSavePath(m["save_path"].toString());
|
Preferences::setSavePath(m["save_path"].toString());
|
||||||
|
@ -132,6 +132,7 @@ namespace json {
|
|||||||
tmp += c;
|
tmp += c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(!tmp.isEmpty()) couples << tmp;
|
||||||
foreach(QString couple, couples) {
|
foreach(QString couple, couples) {
|
||||||
QStringList parts = couple.split(":");
|
QStringList parts = couple.split(":");
|
||||||
if(parts.size() != 2) continue;
|
if(parts.size() != 2) continue;
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
#include <QCloseEvent>
|
#include <QCloseEvent>
|
||||||
#include <QDesktopWidget>
|
#include <QDesktopWidget>
|
||||||
#include <QStyleFactory>
|
#include <QStyleFactory>
|
||||||
|
#include <QTranslator>
|
||||||
|
|
||||||
#include <libtorrent/version.hpp>
|
#include <libtorrent/version.hpp>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
@ -353,10 +354,22 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
|
|||||||
QIniSettings settings("qBittorrent", "qBittorrent");
|
QIniSettings settings("qBittorrent", "qBittorrent");
|
||||||
// Apply style
|
// Apply style
|
||||||
useStyle();
|
useStyle();
|
||||||
|
// Load the translation
|
||||||
|
QString locale = getLocale();
|
||||||
|
if(Preferences::getLocale() != locale) {
|
||||||
|
QTranslator *translator = new QTranslator;
|
||||||
|
if(translator->load(QString::fromUtf8(":/lang/qbittorrent_") + locale)){
|
||||||
|
qDebug("%s locale recognized, using translation.", qPrintable(locale));
|
||||||
|
}else{
|
||||||
|
qDebug("%s locale unrecognized, using default (en_GB).", qPrintable(locale));
|
||||||
|
}
|
||||||
|
qApp->installTranslator(translator);
|
||||||
|
}
|
||||||
|
|
||||||
settings.beginGroup("Preferences");
|
settings.beginGroup("Preferences");
|
||||||
// General preferences
|
// General preferences
|
||||||
settings.beginGroup("General");
|
settings.beginGroup("General");
|
||||||
settings.setValue(QString::fromUtf8("Locale"), getLocale());
|
settings.setValue(QString::fromUtf8("Locale"), locale);
|
||||||
settings.setValue(QString::fromUtf8("Style"), getStyle());
|
settings.setValue(QString::fromUtf8("Style"), getStyle());
|
||||||
settings.setValue(QString::fromUtf8("AlternatingRowColors"), checkAltRowColors->isChecked());
|
settings.setValue(QString::fromUtf8("AlternatingRowColors"), checkAltRowColors->isChecked());
|
||||||
settings.setValue(QString::fromUtf8("SystrayEnabled"), systrayIntegration());
|
settings.setValue(QString::fromUtf8("SystrayEnabled"), systrayIntegration());
|
||||||
|
@ -539,6 +539,7 @@
|
|||||||
},
|
},
|
||||||
onSuccess: function() {
|
onSuccess: function() {
|
||||||
// Close window
|
// Close window
|
||||||
|
window.parent.location.reload();
|
||||||
window.parent.closeWindows();
|
window.parent.closeWindows();
|
||||||
}
|
}
|
||||||
}).send();
|
}).send();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user