From d7abab29704e086c013530b90ab7ed4e69784ba4 Mon Sep 17 00:00:00 2001 From: ubbo Date: Wed, 18 Jan 2012 21:15:00 +0000 Subject: instantly apply language selection in wizard git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@752 34ebc366-c3a9-4b3c-9f84-69acf7962910 --- mainwindow.cpp | 2 +- settingsdialog.cpp | 5 ----- wizard.cpp | 23 +++++++++++++++++++---- wizard.h | 4 ++++ 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 9460df5..611ec25 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -77,7 +77,7 @@ MainWindow::MainWindow() QSettings settings; //if (settings.value("wizard/showWizard",true).toBool() && !mKeyList->containsPrivateKeys()) { - if (settings.value("wizard/showWizard",true).toBool() || !settings.value("wizard/next").isNull()) { + if (settings.value("wizard/showWizard",true).toBool() || !settings.value("wizard/nextPage").isNull()) { startWizard(); } } diff --git a/settingsdialog.cpp b/settingsdialog.cpp index c00cd06..63f0c69 100755 --- a/settingsdialog.cpp +++ b/settingsdialog.cpp @@ -88,11 +88,6 @@ QHash SettingsDialog::listLanguages() #else QString language = qloc.nativeLanguageName() +" (" + locale + ")"; //+ " (" + QLocale::languageToString(qloc.language()) + ")"; #endif - /*QTranslator translator; - translator.load(fileNames[i], qmDir.absolutePath()); - QString language = translator.translate("SettingsDialog", - "English", "Insert local name of language here. This is used for the language menu of the settingsdialog"); -*/ languages.insert(locale, language); } return languages; diff --git a/wizard.cpp b/wizard.cpp index d4a95ad..fa255d6 100644 --- a/wizard.cpp +++ b/wizard.cpp @@ -58,11 +58,20 @@ IntroPage::IntroPage(QWidget *parent) langLabel = new QLabel(tr("Choose a Language")); langLabel->setWordWrap(true); + languages = SettingsDialog::listLanguages(); langSelectBox = new QComboBox(); - foreach(QString l, SettingsDialog::listLanguages()) { + foreach(QString l, languages) { langSelectBox->addItem(l); } + // selected entry from config + QSettings settings; + QString langKey = settings.value("int/lang").toString(); + QString langValue = languages.value(langKey); + if (langKey != "") { + langSelectBox->setCurrentIndex(langSelectBox->findText(langValue)); + } + connect(langSelectBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(langChange(QString))); // set layout and add widgets QVBoxLayout *layout = new QVBoxLayout; @@ -70,7 +79,14 @@ IntroPage::IntroPage(QWidget *parent) layout->addWidget(langLabel); layout->addWidget(langSelectBox); setLayout(layout); - this->setFinalPage(true); + //this->setFinalPage(true); +} + +void IntroPage::langChange(QString lang) { + QSettings settings; + settings.setValue("int/lang", languages.key(lang)); + settings.setValue("wizard/nextPage", this->wizard()->currentId()); + qApp->exit(RESTART_CODE); } int IntroPage::nextId() const @@ -140,8 +156,7 @@ bool ImportFromGpg4usbPage::importKeysFromGpg4usb() } QSettings settings; - //settings.setValue("wizard/page", this->wizard()->currentId()); - settings.setValue("wizard/page", this->nextId()); + settings.setValue("wizard/nextPage", this->nextId()); // TODO: edit->maybesave? qApp->exit(RESTART_CODE); diff --git a/wizard.h b/wizard.h index a7b2f0e..bd76ff6 100644 --- a/wizard.h +++ b/wizard.h @@ -58,7 +58,11 @@ public: QLabel *topLabel; QLabel *langLabel; QComboBox *langSelectBox; + QHash languages; int nextId() const; + +private slots: + void langChange(QString lang); }; class ImportFromGpg4usbPage : public QWizardPage -- cgit v1.2.3