From 0e55f3c74dda329f3723f28deca2a437340ed1e0 Mon Sep 17 00:00:00 2001 From: Fredrik Arvidsson Date: Sat, 24 Nov 2012 14:55:46 +0100 Subject: [PATCH] OP-723 Changed default locale to English. Updated default configuration files to have tag set to en_US. --- .../default_configurations/OpenPilotGCS.xml | 2 +- .../OpenPilotGCS_wide.xml | 1 + ground/openpilotgcs/src/app/main.cpp | 5 ++ .../coreplugin/dialogs/importsettings.cpp | 32 +++++----- .../coreplugin/dialogs/importsettings.h | 6 +- .../src/plugins/coreplugin/mainwindow.cpp | 58 +++++++++---------- 6 files changed, 53 insertions(+), 51 deletions(-) diff --git a/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS.xml b/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS.xml index 3c79bd742..619c00b9e 100644 --- a/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS.xml +++ b/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS.xml @@ -6,7 +6,7 @@ Default configuration
Default configuration built to work on all screen sizes
false - en_AU + en_US true 700 800 diff --git a/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS_wide.xml b/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS_wide.xml index c79ffd3ed..4e344fcf1 100644 --- a/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS_wide.xml +++ b/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS_wide.xml @@ -8,6 +8,7 @@ true 700 800 + en_US false Wide configuration
Default configuration built for wide screens (17"up)
diff --git a/ground/openpilotgcs/src/app/main.cpp b/ground/openpilotgcs/src/app/main.cpp index 9d4010165..a5fe5ca8a 100644 --- a/ground/openpilotgcs/src/app/main.cpp +++ b/ground/openpilotgcs/src/app/main.cpp @@ -241,6 +241,11 @@ int main(int argc, char **argv) #ifdef Q_OS_LINUX QApplication::setAttribute(Qt::AA_X11InitThreads, true); #endif + + //Set the default locale to EN, if this is not set the system locale will be used + //and as of now we dont want that behaviour. + QLocale::setDefault(QLocale::English); + QApplication::setGraphicsSystem("raster"); SharedTools::QtSingleApplication app((QLatin1String(appNameC)), argc, argv); diff --git a/ground/openpilotgcs/src/plugins/coreplugin/dialogs/importsettings.cpp b/ground/openpilotgcs/src/plugins/coreplugin/dialogs/importsettings.cpp index c48f5a6a6..715b95e88 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/dialogs/importsettings.cpp +++ b/ground/openpilotgcs/src/plugins/coreplugin/dialogs/importsettings.cpp @@ -10,47 +10,47 @@ importSettings::importSettings(QWidget *parent) : ui(new Ui::importSettings) { ui->setupUi(this); - connect(ui->cbConfigs,SIGNAL(currentIndexChanged(int)),this,SLOT(updateDetails(int))); - connect(ui->btnLoad,SIGNAL(clicked()),this,SLOT(accept())); - QTimer::singleShot(500,this,SLOT(repaint())); + connect(ui->cbConfigs, SIGNAL(currentIndexChanged(int)), this, SLOT(updateDetails(int))); + connect(ui->btnLoad, SIGNAL(clicked()), this, SLOT(accept())); + QTimer::singleShot(500, this, SLOT(repaint())); } + void importSettings::loadFiles(QString path) { QDir myDir(path); QStringList filters; filters << "*.xml"; QStringList list = myDir.entryList(filters,QDir::Files); - int x=0; - foreach(QString fileStr, list) - { - fileInfo * info=new fileInfo; - QSettings settings(path+QDir::separator()+fileStr, XmlConfig::XmlSettingsFormat); + int x = 0; + foreach(QString fileStr, list) { + fileInfo *info = new fileInfo; + QSettings settings(path+QDir::separator() + fileStr, XmlConfig::XmlSettingsFormat); settings.beginGroup("General"); - info->description=settings.value("Description","None").toString(); - info->details=settings.value("Details","None").toString(); + info->description = settings.value("Description", "None").toString(); + info->details = settings.value("Details", "None").toString(); settings.endGroup(); - info->file=path+QDir::separator()+fileStr; + info->file = path + QDir::separator() + fileStr; configList.insert(x,info); - ui->cbConfigs->addItem(info->description,x); + ui->cbConfigs->addItem(info->description, x); ++x; } } void importSettings::updateDetails(int index) { - fileInfo * info=configList.value(ui->cbConfigs->itemData(index).toInt()); + fileInfo *info = configList.value(ui->cbConfigs->itemData(index).toInt()); ui->lblDetails->setText(info->details); } + QString importSettings::choosenConfig() { - fileInfo * info=configList.value(ui->cbConfigs->itemData(ui->cbConfigs->currentIndex()).toInt()); + fileInfo *info = configList.value(ui->cbConfigs->itemData(ui->cbConfigs->currentIndex()).toInt()); return info->file; } importSettings::~importSettings() { - foreach(fileInfo * info,configList.values()) - { + foreach(fileInfo * info,configList.values()) { delete info; } delete ui; diff --git a/ground/openpilotgcs/src/plugins/coreplugin/dialogs/importsettings.h b/ground/openpilotgcs/src/plugins/coreplugin/dialogs/importsettings.h index 58e5e8e44..8bf5f303f 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/dialogs/importsettings.h +++ b/ground/openpilotgcs/src/plugins/coreplugin/dialogs/importsettings.h @@ -1,3 +1,4 @@ + #ifndef IMPORTSETTINGS_H #define IMPORTSETTINGS_H @@ -10,8 +11,7 @@ class importSettings; class importSettings : public QDialog { Q_OBJECT - struct fileInfo - { + struct fileInfo { QString file; QString description; QString details; @@ -23,9 +23,11 @@ public: void loadFiles(QString path); QString choosenConfig(); + private: Ui::importSettings *ui; QMap configList; + private slots: void updateDetails(int); }; diff --git a/ground/openpilotgcs/src/plugins/coreplugin/mainwindow.cpp b/ground/openpilotgcs/src/plugins/coreplugin/mainwindow.cpp index dc74094a5..ff71ce839 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/mainwindow.cpp +++ b/ground/openpilotgcs/src/plugins/coreplugin/mainwindow.cpp @@ -266,18 +266,15 @@ void MainWindow::modeChanged(Core::IMode */*mode*/) void MainWindow::extensionsInitialized() { - - QSettings* qs = m_settings; - QSettings * settings; + QSettings *qs = m_settings; + QSettings *settings; QString commandLine; - if ( ! qs->allKeys().count() ){ - foreach(QString str,qApp->arguments()) - { - if(str.contains("configfile")) - { - qDebug()<<"ass"; - commandLine=str.split("=").at(1); - qDebug()<allKeys().count() ) { + foreach(QString str, qApp->arguments()) { + if(str.contains("configfile")) { + qDebug() << "ass"; + commandLine = str.split("=").at(1); + qDebug() << commandLine; } } QDir directory(QCoreApplication::applicationDirPath()); @@ -289,37 +286,34 @@ void MainWindow::extensionsInitialized() directory.cd("share"); directory.cd("openpilotgcs"); #endif - directory.cd("default_configurations"); + directory.cd("default_configurations"); - qDebug() << "Looking for default config files in: " + directory.absolutePath(); - bool showDialog=true; + qDebug() << "Looking for default config files in: " + directory.absolutePath(); + bool showDialog = true; QString filename; - if(!commandLine.isEmpty()) - { - if(QFile::exists(directory.absolutePath()+QDir::separator()+commandLine)) - { - filename=directory.absolutePath()+QDir::separator()+commandLine; - qDebug()<<"Load configuration from command line"; - settings=new QSettings(filename, XmlConfig::XmlSettingsFormat); - showDialog=false; + if(!commandLine.isEmpty()) { + if(QFile::exists(directory.absolutePath() + QDir::separator()+commandLine)) { + filename = directory.absolutePath() + QDir::separator()+commandLine; + qDebug() << "Load configuration from command line"; + settings = new QSettings(filename, XmlConfig::XmlSettingsFormat); + showDialog = false; } } - if(showDialog) - { - importSettings * dialog=new importSettings(this); + if(showDialog) { + importSettings *dialog = new importSettings(this); dialog->loadFiles(directory.absolutePath()); dialog->exec(); - filename=dialog->choosenConfig(); - settings=new QSettings(filename, XmlConfig::XmlSettingsFormat); + filename = dialog->choosenConfig(); + settings = new QSettings(filename, XmlConfig::XmlSettingsFormat); delete dialog; } - qs=settings; - qDebug() << "Load default config from resource "<beginGroup("General"); - m_config_description=qs->value("Description","none").toString(); - m_config_details=qs->value("Details","none").toString(); - m_config_stylesheet=qs->value("StyleSheet","none").toString(); + m_config_description=qs->value("Description", "none").toString(); + m_config_details=qs->value("Details", "none").toString(); + m_config_stylesheet=qs->value("StyleSheet", "none").toString(); loadStyleSheet(m_config_stylesheet); qs->endGroup(); m_uavGadgetInstanceManager = new UAVGadgetInstanceManager(this);