diff options
author | ubbo <ubbo@34ebc366-c3a9-4b3c-9f84-69acf7962910> | 2012-01-15 22:09:03 +0000 |
---|---|---|
committer | ubbo <ubbo@34ebc366-c3a9-4b3c-9f84-69acf7962910> | 2012-01-15 22:09:03 +0000 |
commit | ecd73365728f03123cb2b412ae11d49610b4a12f (patch) | |
tree | f5e52465f5e09bb6790f89c30e2930db8c32afbd | |
parent | restart app after loading old qgq4usb config (diff) | |
download | gpg4usb-ecd73365728f03123cb2b412ae11d49610b4a12f.tar.gz gpg4usb-ecd73365728f03123cb2b412ae11d49610b4a12f.zip |
reopen wizard on specified page after restart
git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@743 34ebc366-c3a9-4b3c-9f84-69acf7962910
-rw-r--r-- | mainwindow.cpp | 3 | ||||
-rwxr-xr-x | settingsdialog.cpp | 74 | ||||
-rwxr-xr-x | settingsdialog.h | 3 | ||||
-rw-r--r-- | wizard.cpp | 37 | ||||
-rw-r--r-- | wizard.h | 12 |
5 files changed, 88 insertions, 41 deletions
diff --git a/mainwindow.cpp b/mainwindow.cpp index 1813bdc..5449246 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -75,7 +75,8 @@ MainWindow::MainWindow() // Show wizard, if the don't show wizard message box wasn't checked // and keylist doesn't contain a private key QSettings settings; - if (settings.value("wizard/showWizard",true).toBool() && !mKeyList->containsPrivateKeys()) { + //if (settings.value("wizard/showWizard",true).toBool() && !mKeyList->containsPrivateKeys()) { + if (settings.value("wizard/showWizard",true).toBool() || !settings.value("wizard/next").isNull()) { startWizard(); } } diff --git a/settingsdialog.cpp b/settingsdialog.cpp index 088b351..c00cd06 100755 --- a/settingsdialog.cpp +++ b/settingsdialog.cpp @@ -63,6 +63,42 @@ void SettingsDialog::accept() close(); } +// http://www.informit.com/articles/article.aspx?p=1405555&seqNum=3 +// http://developer.qt.nokia.com/wiki/How_to_create_a_multi_language_application +QHash<QString, QString> SettingsDialog::listLanguages() +{ + QHash<QString, QString> languages; + + languages.insert("", tr("System Default")); + + QString appPath = qApp->applicationDirPath(); + QDir qmDir = QDir(appPath + "/ts/"); + QStringList fileNames = + qmDir.entryList(QStringList("gpg4usb_*.qm")); + + for (int i = 0; i < fileNames.size(); ++i) { + QString locale = fileNames[i]; + locale.truncate(locale.lastIndexOf('.')); + locale.remove(0, locale.indexOf('_') + 1); + + // this works in qt 4.8 + QLocale qloc(locale); + #if QT_VERSION < 0x040800 + QString language = QLocale::languageToString(qloc.language()) +" (" + locale + ")"; //+ " (" + QLocale::languageToString(qloc.language()) + ")"; + #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; +} + + GeneralTab::GeneralTab(QWidget *parent) : QWidget(parent) @@ -101,7 +137,7 @@ GeneralTab::GeneralTab(QWidget *parent) QGroupBox *langBox = new QGroupBox(tr("Language")); QVBoxLayout *langBoxLayout = new QVBoxLayout(); langSelectBox = new QComboBox; - lang = listLanguages(); + lang = SettingsDialog::listLanguages(); foreach(QString l , lang) { langSelectBox->addItem(l); @@ -166,42 +202,6 @@ void GeneralTab::applySettings() settings.setValue("general/confirmImportKeys", importConfirmationCheckBox->isChecked()); } -// http://www.informit.com/articles/article.aspx?p=1405555&seqNum=3 -// http://developer.qt.nokia.com/wiki/How_to_create_a_multi_language_application -QHash<QString, QString> GeneralTab::listLanguages() -{ - QHash<QString, QString> languages; - - languages.insert("", tr("System Default")); - - QString appPath = qApp->applicationDirPath(); - QDir qmDir = QDir(appPath + "/ts/"); - QStringList fileNames = - qmDir.entryList(QStringList("gpg4usb_*.qm")); - - for (int i = 0; i < fileNames.size(); ++i) { - QString locale = fileNames[i]; - locale.truncate(locale.lastIndexOf('.')); - locale.remove(0, locale.indexOf('_') + 1); - - // this works in qt 4.8 - QLocale qloc(locale); - #if QT_VERSION < 0x040800 - QString language = QLocale::languageToString(qloc.language()) +" (" + locale + ")"; //+ " (" + QLocale::languageToString(qloc.language()) + ")"; - #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; -} - - MimeTab::MimeTab(QWidget *parent) : QWidget(parent) { diff --git a/settingsdialog.h b/settingsdialog.h index db83f33..b27864e 100755 --- a/settingsdialog.h +++ b/settingsdialog.h @@ -65,7 +65,6 @@ class GeneralTab : public QWidget QHash<QString, QString> lang; private slots: - QHash<QString, QString> listLanguages(); }; @@ -143,6 +142,8 @@ public: AppearanceTab *appearanceTab; KeyserverTab *keyserverTab; AdvancedTab *advancedTab; + static QHash<QString, QString> listLanguages(); + public slots: void accept(); @@ -41,6 +41,37 @@ Wizard::Wizard(GpgME::GpgContext *ctx, KeyMgmt *keyMgmt, QWidget *parent) setWizardStyle(ModernStyle); #endif setWindowTitle(tr("First Start Wizard")); + + QSettings settings; + setStartId(settings.value("wizard/page", -1).toInt()); + settings.remove("wizard/page"); + +} + +LanguagePage::LanguagePage(QWidget *parent) + : QWizardPage(parent){ + + setTitle(tr("Choose Language")); + setPixmap(QWizard::WatermarkPixmap, QPixmap(":/logo-flipped.png")); + + QVBoxLayout *layout = new QVBoxLayout; + + topLabel = new QLabel(tr("Choose a Language")); + topLabel->setWordWrap(true); + layout->addWidget(topLabel); + + QHash<QString, QString> languages = SettingsDialog::listLanguages(); + foreach(QString l, languages) { + qDebug() << l; + } + + + setLayout(layout); +} + +int LanguagePage::nextId() const +{ + return 1; } IntroPage::IntroPage(QWidget *parent) @@ -217,17 +248,19 @@ bool ImportPage::importKeysFromGpg4usb() mKeyMgmt->importKeys(inBuffer); } + // TODO: edit->maybesave? qApp->exit(RESTART_CODE); + QSettings settings; + //settings.setValue("wizard/page", this->wizard()->currentId()); + settings.setValue("wizard/page", this->nextId()); return true; } bool ImportPage::importConfFromGpg4usb(QString dir) { QString path = dir+"/conf/gpg4usb.ini"; - qDebug() << "import old conf from: " << path; QSettings oldconf(path, QSettings::IniFormat, this); QSettings actualConf; foreach(QString key, oldconf.allKeys()) { - qDebug() << key << ": " << oldconf.value(key); actualConf.setValue(key, oldconf.value(key)); } @@ -27,6 +27,7 @@ #include "keygendialog.h" #include "keymgmt.h" #include "gpgconstants.h" +#include "settingsdialog.h" class QCheckBox; class QLabel; @@ -57,6 +58,17 @@ public: int nextId() const; }; +class LanguagePage : public QWizardPage +{ + Q_OBJECT + +public: + LanguagePage(QWidget *parent = 0); + QLabel *topLabel; + + int nextId() const; +}; + class KeyGenPage : public QWizardPage { Q_OBJECT |