mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-20 16:20:52 +01:00
Add widget to select langage, must relauch qet for make change
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2762 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -51,7 +51,7 @@ NewDiagramPage::NewDiagramPage(QWidget *parent) : ConfigPage(parent) {
|
|||||||
|
|
||||||
// default propertie of report label
|
// default propertie of report label
|
||||||
rpw = new ReportPropertieWidget(QETDiagramEditor::defaultReportProperties());
|
rpw = new ReportPropertieWidget(QETDiagramEditor::defaultReportProperties());
|
||||||
tab_widget->addTab(rpw, ("Report de folio"));
|
tab_widget->addTab(rpw, tr("Report de folio"));
|
||||||
|
|
||||||
QVBoxLayout *vlayout1 = new QVBoxLayout();
|
QVBoxLayout *vlayout1 = new QVBoxLayout();
|
||||||
vlayout1->addWidget(tab_widget);
|
vlayout1->addWidget(tab_widget);
|
||||||
@@ -157,6 +157,15 @@ GeneralConfigurationPage::GeneralConfigurationPage(QWidget *parent) : ConfigPage
|
|||||||
elements_management_layout -> addWidget(default_element_infos_textfield_);
|
elements_management_layout -> addWidget(default_element_infos_textfield_);
|
||||||
elements_management_ -> setLayout(elements_management_layout);
|
elements_management_ -> setLayout(elements_management_layout);
|
||||||
|
|
||||||
|
//setup lang combo box selection widget
|
||||||
|
lang_group_box = new QGroupBox(tr("Langue"), this);
|
||||||
|
QHBoxLayout *lang_layout = new QHBoxLayout(lang_group_box);
|
||||||
|
lang_combo_box = new QComboBox();
|
||||||
|
lang_label = new QLabel(tr("La nouvelle langue sera pris en compte au prochain lancement de QElectroTech."));
|
||||||
|
lang_layout->addWidget(lang_combo_box);
|
||||||
|
lang_layout->addWidget(lang_label);
|
||||||
|
fillLang(settings);
|
||||||
|
|
||||||
QVBoxLayout *vlayout1 = new QVBoxLayout();
|
QVBoxLayout *vlayout1 = new QVBoxLayout();
|
||||||
|
|
||||||
QLabel *title_label_ = new QLabel(title());
|
QLabel *title_label_ = new QLabel(title());
|
||||||
@@ -169,6 +178,7 @@ GeneralConfigurationPage::GeneralConfigurationPage(QWidget *parent) : ConfigPage
|
|||||||
vlayout1 -> addWidget(appearance_);
|
vlayout1 -> addWidget(appearance_);
|
||||||
vlayout1 -> addWidget(projects_view_mode_);
|
vlayout1 -> addWidget(projects_view_mode_);
|
||||||
vlayout1 -> addWidget(elements_management_);
|
vlayout1 -> addWidget(elements_management_);
|
||||||
|
vlayout1 -> addWidget(lang_group_box);
|
||||||
vlayout1 -> addStretch();
|
vlayout1 -> addStretch();
|
||||||
|
|
||||||
setLayout(vlayout1);
|
setLayout(vlayout1);
|
||||||
@@ -179,7 +189,8 @@ GeneralConfigurationPage::~GeneralConfigurationPage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Applique la configuration de cette page
|
* @brief GeneralConfigurationPage::applyConf
|
||||||
|
* Write all configuration in settings file
|
||||||
*/
|
*/
|
||||||
void GeneralConfigurationPage::applyConf() {
|
void GeneralConfigurationPage::applyConf() {
|
||||||
QSettings &settings = QETApp::settings();
|
QSettings &settings = QETApp::settings();
|
||||||
@@ -191,6 +202,8 @@ void GeneralConfigurationPage::applyConf() {
|
|||||||
QETApp::instance() -> useSystemPalette(must_use_system_colors);
|
QETApp::instance() -> useSystemPalette(must_use_system_colors);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
settings.setValue("lang", lang_combo_box->itemData(lang_combo_box->currentIndex()).toString());
|
||||||
|
|
||||||
QString view_mode = tabbed_mode_ -> isChecked() ? "tabbed" : "windowed";
|
QString view_mode = tabbed_mode_ -> isChecked() ? "tabbed" : "windowed";
|
||||||
settings.setValue("diagrameditor/viewmode", view_mode) ;
|
settings.setValue("diagrameditor/viewmode", view_mode) ;
|
||||||
|
|
||||||
@@ -209,6 +222,42 @@ QString GeneralConfigurationPage::title() const {
|
|||||||
return(tr("G\351n\351ral", "configuration page title"));
|
return(tr("G\351n\351ral", "configuration page title"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief GeneralConfigurationPage::fillLang
|
||||||
|
* fill all available lang in @lang_combo_box
|
||||||
|
*/
|
||||||
|
void GeneralConfigurationPage::fillLang(QSettings &settings) {
|
||||||
|
lang_combo_box->addItem(tr("Syst\350me"), "system");
|
||||||
|
lang_combo_box->insertSeparator(1);
|
||||||
|
|
||||||
|
// all lang available on lang directory
|
||||||
|
lang_combo_box->addItem(tr("Arabe"), "ar");
|
||||||
|
lang_combo_box->addItem(tr("Catalan"), "ca");
|
||||||
|
lang_combo_box->addItem(tr("Tch\350que"), "cs");
|
||||||
|
lang_combo_box->addItem(tr("Allemand"), "de");
|
||||||
|
lang_combo_box->addItem(tr("Grec"), "el");
|
||||||
|
lang_combo_box->addItem(tr("Anglais"), "en");
|
||||||
|
lang_combo_box->addItem(tr("Espagnol"), "es");
|
||||||
|
lang_combo_box->addItem(tr("Fran\347ais"), "fr");
|
||||||
|
lang_combo_box->addItem(tr("Croate"), "hr");
|
||||||
|
lang_combo_box->addItem(tr("Italien"), "it");
|
||||||
|
lang_combo_box->addItem(tr("Polonais"), "pl");
|
||||||
|
lang_combo_box->addItem(tr("Portugais"), "pt");
|
||||||
|
lang_combo_box->addItem(tr("Roumains"), "ro");
|
||||||
|
lang_combo_box->addItem(tr("Russe"), "ru");
|
||||||
|
lang_combo_box->addItem(tr("Slov\350ne"), "sl");
|
||||||
|
|
||||||
|
//set curent index to the lang found in setting file
|
||||||
|
//if lang doesn't exist set to system
|
||||||
|
for (int i=0; i<lang_combo_box->count(); i++) {
|
||||||
|
if (lang_combo_box->itemData(i).toString() == settings.value("lang").toString()) {
|
||||||
|
lang_combo_box->setCurrentIndex(i);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lang_combo_box->setCurrentIndex(0);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Constructeur
|
Constructeur
|
||||||
@param parent QWidget parent
|
@param parent QWidget parent
|
||||||
|
|||||||
@@ -71,8 +71,11 @@ class GeneralConfigurationPage : public ConfigPage {
|
|||||||
QString title() const;
|
QString title() const;
|
||||||
QIcon icon() const;
|
QIcon icon() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void fillLang(QSettings &);
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
public:
|
private:
|
||||||
QLabel *title_label_;
|
QLabel *title_label_;
|
||||||
QFrame *horiz_line_;
|
QFrame *horiz_line_;
|
||||||
QGroupBox *appearance_;
|
QGroupBox *appearance_;
|
||||||
@@ -86,6 +89,9 @@ class GeneralConfigurationPage : public ConfigPage {
|
|||||||
QCheckBox *highlight_integrated_elements_;
|
QCheckBox *highlight_integrated_elements_;
|
||||||
QLabel *default_element_infos_label_;
|
QLabel *default_element_infos_label_;
|
||||||
QTextEdit *default_element_infos_textfield_;
|
QTextEdit *default_element_infos_textfield_;
|
||||||
|
QGroupBox *lang_group_box;
|
||||||
|
QComboBox *lang_combo_box;
|
||||||
|
QLabel *lang_label;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -48,8 +48,7 @@ ElementsCollectionCache *GenericPanel::getElementsCache() {
|
|||||||
// build a default cache
|
// build a default cache
|
||||||
QString cache_path = "./genericpanel.sqlite";
|
QString cache_path = "./genericpanel.sqlite";
|
||||||
cache_ = new ElementsCollectionCache(cache_path, this);
|
cache_ = new ElementsCollectionCache(cache_path, this);
|
||||||
/// @todo we need a unique function to get the good language
|
cache_->setLocale(QETApp::langFromSetting());
|
||||||
cache_ -> setLocale(QLocale::system().name().left(2));
|
|
||||||
}
|
}
|
||||||
return(cache_);
|
return(cache_);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "nameslist.h"
|
#include "nameslist.h"
|
||||||
|
#include "qetapp.h"
|
||||||
|
|
||||||
// make this class usable with QVariant
|
// make this class usable with QVariant
|
||||||
int NamesList::MetaTypeId = qRegisterMetaType<NamesList>("NamesList");
|
int NamesList::MetaTypeId = qRegisterMetaType<NamesList>("NamesList");
|
||||||
|
|
||||||
@@ -201,8 +203,7 @@ bool NamesList::operator==(const NamesList &nl) const {
|
|||||||
@return The adequate name regarding the current system locale.
|
@return The adequate name regarding the current system locale.
|
||||||
*/
|
*/
|
||||||
QString NamesList::name(const QString &fallback_name) const {
|
QString NamesList::name(const QString &fallback_name) const {
|
||||||
// recupere les deux premiers caracteres de la locale en cours du systeme
|
QString system_language = QETApp::langFromSetting();
|
||||||
QString system_language = QLocale::system().name().left(2);
|
|
||||||
QString returned_name;
|
QString returned_name;
|
||||||
if (!hash_names[system_language].isEmpty()) {
|
if (!hash_names[system_language].isEmpty()) {
|
||||||
returned_name = hash_names[system_language];
|
returned_name = hash_names[system_language];
|
||||||
|
|||||||
@@ -281,7 +281,7 @@ void ProjectNewDiagramConfigPage::initLayout() {
|
|||||||
|
|
||||||
tab_widget->addTab(conductor_, tr("Conducteur"));
|
tab_widget->addTab(conductor_, tr("Conducteur"));
|
||||||
|
|
||||||
tab_widget->addTab(report_, ("Report de folio"));
|
tab_widget->addTab(report_, tr("Report de folio"));
|
||||||
|
|
||||||
QVBoxLayout *vlayout1 = new QVBoxLayout();
|
QVBoxLayout *vlayout1 = new QVBoxLayout();
|
||||||
vlayout1->addWidget(tab_widget);
|
vlayout1->addWidget(tab_widget);
|
||||||
|
|||||||
@@ -71,9 +71,9 @@ QETApp::QETApp(int &argc, char **argv) :
|
|||||||
non_interactive_execution_(false)
|
non_interactive_execution_(false)
|
||||||
{
|
{
|
||||||
parseArguments();
|
parseArguments();
|
||||||
|
initConfiguration();
|
||||||
initLanguage();
|
initLanguage();
|
||||||
QET::Icons::initIcons();
|
QET::Icons::initIcons();
|
||||||
initConfiguration();
|
|
||||||
initStyle();
|
initStyle();
|
||||||
|
|
||||||
if (!non_interactive_execution_ && isRunning()) {
|
if (!non_interactive_execution_ && isRunning()) {
|
||||||
@@ -107,7 +107,7 @@ QETApp::QETApp(int &argc, char **argv) :
|
|||||||
if (!collections_cache_) {
|
if (!collections_cache_) {
|
||||||
QString cache_path = QETApp::configDir() + "/elements_cache.sqlite";
|
QString cache_path = QETApp::configDir() + "/elements_cache.sqlite";
|
||||||
collections_cache_ = new ElementsCollectionCache(cache_path, this);
|
collections_cache_ = new ElementsCollectionCache(cache_path, this);
|
||||||
collections_cache_ -> setLocale(QLocale::system().name().left(2)); // @todo we need a unique function to get the good language
|
collections_cache_->setLocale(langFromSetting());
|
||||||
}
|
}
|
||||||
|
|
||||||
// loads known collections into memory (this does not include items rendering made in elements panels)
|
// loads known collections into memory (this does not include items rendering made in elements panels)
|
||||||
@@ -183,6 +183,16 @@ void QETApp::setLanguage(const QString &desired_language) {
|
|||||||
if (ltr_special_string == "RTL") switchLayout(Qt::RightToLeft);
|
if (ltr_special_string == "RTL") switchLayout(Qt::RightToLeft);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief QETApp::langFromSetting
|
||||||
|
* @return the langage found in setting file
|
||||||
|
* if nothing was found return the system local.
|
||||||
|
*/
|
||||||
|
QString QETApp::langFromSetting() {
|
||||||
|
QString system_language = settings().value("lang", "system").toString();
|
||||||
|
if(system_language == "system") {system_language = QLocale::system().name().left(2);}
|
||||||
|
return system_language;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
Switches the application to the provided layout.
|
Switches the application to the provided layout.
|
||||||
*/
|
*/
|
||||||
@@ -1300,9 +1310,7 @@ void QETApp::setSplashScreenStep(const QString &message) {
|
|||||||
Determine et applique le langage a utiliser pour l'application
|
Determine et applique le langage a utiliser pour l'application
|
||||||
*/
|
*/
|
||||||
void QETApp::initLanguage() {
|
void QETApp::initLanguage() {
|
||||||
// selectionne le langage du systeme
|
setLanguage(langFromSetting());
|
||||||
QString system_language = QLocale::system().name().left(2);
|
|
||||||
setLanguage(system_language);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ class QETApp : public QETSingleApplication {
|
|||||||
public:
|
public:
|
||||||
static QETApp *instance();
|
static QETApp *instance();
|
||||||
void setLanguage(const QString &);
|
void setLanguage(const QString &);
|
||||||
|
static QString langFromSetting ();
|
||||||
void switchLayout(Qt::LayoutDirection);
|
void switchLayout(Qt::LayoutDirection);
|
||||||
static void printHelp();
|
static void printHelp();
|
||||||
static void printVersion();
|
static void printVersion();
|
||||||
|
|||||||
Reference in New Issue
Block a user