aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--wizard.cpp260
-rw-r--r--wizard.h66
2 files changed, 171 insertions, 155 deletions
diff --git a/wizard.cpp b/wizard.cpp
index 36779e6..bea9292 100644
--- a/wizard.cpp
+++ b/wizard.cpp
@@ -27,15 +27,12 @@ Wizard::Wizard(GpgME::GpgContext *ctx, KeyMgmt *keyMgmt, QWidget *parent)
{
mCtx=ctx;
mKeyMgmt=keyMgmt;
- IntroPage *introPage = new IntroPage(this);
- KeyGenPage *keyGenPage = new KeyGenPage(mCtx, this);
- ImportPage *importPage = new ImportPage(mCtx,mKeyMgmt, this);
- ConclusionPage *conclusionPage = new ConclusionPage(this);
- addPage(introPage);
- addPage(keyGenPage);
- addPage(importPage);
- addPage(conclusionPage);
-
+ setPage(Page_Intro,new IntroPage(this));
+ setPage(Page_ImportFromGpg4usb,new ImportFromGpg4usbPage(mCtx, mKeyMgmt, this));
+ setPage(Page_ImportFromGnupg,new ImportFromGnupgPage(mCtx, mKeyMgmt, this));
+ setPage(Page_GenKey,new KeyGenPage(mCtx, this));
+ setPage(Page_Conclusion,new ConclusionPage(this));
+ qDebug() << Page_Intro;
#ifndef Q_WS_MAC
setWizardStyle(ModernStyle);
#endif
@@ -44,137 +41,49 @@ Wizard::Wizard(GpgME::GpgContext *ctx, KeyMgmt *keyMgmt, QWidget *parent)
QSettings settings;
setStartId(settings.value("wizard/page", -1).toInt());
settings.remove("wizard/page");
-
}
-LanguagePage::LanguagePage(QWidget *parent)
- : QWizardPage(parent){
-
- setTitle(tr("Choose Language"));
+IntroPage::IntroPage(QWidget *parent)
+ : QWizardPage(parent)
+{
+ setTitle(tr("Introduction"));
setPixmap(QWizard::WatermarkPixmap, QPixmap(":/logo-flipped.png"));
- QVBoxLayout *layout = new QVBoxLayout;
-
- topLabel = new QLabel(tr("Choose a Language"));
+ topLabel = new QLabel(tr("This wizard will help you getting started with encrypting "
+ "and decrypting or to import keys from an older version of "
+ "gpg4usb or an existing installation of Gnupg."));
topLabel->setWordWrap(true);
- layout->addWidget(topLabel);
+
+
+ // QComboBox for language selection
+ langLabel = new QLabel(tr("Choose a Language"));
+ langLabel->setWordWrap(true);
QHash<QString, QString> languages = SettingsDialog::listLanguages();
foreach(QString l, languages) {
qDebug() << l;
}
-
- setLayout(layout);
-}
-
-int LanguagePage::nextId() const
-{
- return 1;
-}
-
-IntroPage::IntroPage(QWidget *parent)
- : QWizardPage(parent)
- {
- setTitle(tr("Introduction"));
- setPixmap(QWizard::WatermarkPixmap, QPixmap(":/logo-flipped.png"));
-
- topLabel = new QLabel(tr("This wizard will help you getting started with encrypting and decrypting or to import keys from an older version of gpg4usb or an existing installation of Gnupg."));
- topLabel->setWordWrap(true);
-
- QVBoxLayout *layout = new QVBoxLayout;
- layout->addWidget(topLabel);
- setLayout(layout);
- }
-
-int IntroPage::nextId() const
-{
- return 1;
-}
-
-KeyGenPage::KeyGenPage(GpgME::GpgContext *ctx, QWidget *parent)
- : QWizardPage(parent)
-{
-
- setPixmap(QWizard::WatermarkPixmap, QPixmap(":/logo-flipped.png"));
- mCtx=ctx;
- setTitle(tr("Key-Generating"));
- topLabel = new QLabel(tr("First you've got to create an own keypair.<br/>"
- "The pair contains a public and a private key.<br/>"
- "Other users can use the public key to encrypt texts for you<br/>"
- "and verify texts signed by you.<br/>"
- "You can use the private key to decrypt and sign texts.<br/>"
- "For more information have a look in the online tutorial:"));
- QLabel *linkLabel = new QLabel("<a href=""docu_keygen.html#content"">"+tr("Online tutorial")+"</a>");
- //linkLabel->setOpenExternalLinks(true);
-
- connect(linkLabel, SIGNAL(linkActivated(const QString&)), parentWidget()->parentWidget(), SLOT(openHelp(const QString&)));
-
- QWidget *createKeyButtonBox = new QWidget(this);
- QHBoxLayout *createKeyButtonBoxLayout = new QHBoxLayout(createKeyButtonBox);
- createKeyButton = new QPushButton(tr("Create New Key"));
- createKeyButtonBoxLayout->addWidget(createKeyButton);
- createKeyButtonBoxLayout->addStretch(1);
- layout = new QVBoxLayout();
+ // set layout and add widgets
+ QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(topLabel);
- layout->addWidget(linkLabel);
- layout->addWidget(createKeyButtonBox);
- connect(createKeyButton, SIGNAL(clicked()), this, SLOT(generateKeyDialog()));
-
+ layout->addWidget(langLabel);
setLayout(layout);
+ this->setFinalPage(true);
}
-int KeyGenPage::nextId() const
-{
- return 2;
-}
-
-void KeyGenPage::generateKeyDialog()
-{
- KeyGenDialog *keyGenDialog = new KeyGenDialog(mCtx, this);
- connect(mCtx, SIGNAL(keyDBChanged()), this, SLOT(showKeyGeneratedMessage()));
- keyGenDialog->show();
-}
-
-void KeyGenPage::showKeyGeneratedMessage()
+int IntroPage::nextId() const
{
- layout->addWidget(new QLabel(tr("key generated. Now you can crypt and sign texts.")));
+ return Wizard::Page_ImportFromGpg4usb;
}
-ImportPage::ImportPage(GpgME::GpgContext *ctx, KeyMgmt *keyMgmt, QWidget *parent)
+ImportFromGpg4usbPage::ImportFromGpg4usbPage(GpgME::GpgContext *ctx, KeyMgmt *keyMgmt, QWidget *parent)
: QWizardPage(parent)
{
setPixmap(QWizard::WatermarkPixmap, QPixmap(":/logo-flipped.png"));
mCtx=ctx;
mKeyMgmt=keyMgmt;
setTitle(tr("Keyring Import"));
- QGroupBox *gnupgBox = new QGroupBox(tr("Import from GnuPG"), this);
-
- QGridLayout *gnupgLayout = new QGridLayout();
- gnupgLabel = new QLabel(tr("Should I try to import keys from GnuPG?"));
- gnupgLayout->addWidget(gnupgLabel,1,1,1,2);
-
- gnupgPrivKeyCheckBox = new QCheckBox();
- gnupgPrivKeyCheckBox->setChecked(true);
- gnupgLayout->addWidget(gnupgPrivKeyCheckBox,2,1,Qt::AlignRight);
- QLabel *privateKeyLabel = new QLabel(tr("Private Keys"));
- gnupgLayout->addWidget(privateKeyLabel,2,2);
-
- gnupgpPubKeyCheckBox = new QCheckBox();
- gnupgpPubKeyCheckBox->setChecked(true);
- gnupgLayout->addWidget(gnupgpPubKeyCheckBox,3,1,Qt::AlignRight);
- QLabel *gnupgPrivKeyLabel = new QLabel(tr("Public Keys"));
- gnupgLayout->addWidget(gnupgPrivKeyLabel,3,2);
-
-
- QWidget *importFromGnupgButtonBox = new QWidget(this);
- QHBoxLayout *importFromGnupgButtonBoxLayout = new QHBoxLayout(importFromGnupgButtonBox);
- importFromGnupgButton = new QPushButton(tr("Import keys from GnuPG"));
- connect(importFromGnupgButton, SIGNAL(clicked()), this, SLOT(importKeysFromGnupg()));
- importFromGnupgButtonBox->setLayout(importFromGnupgButtonBoxLayout);
- gnupgLayout->addWidget(importFromGnupgButton,2,3);
-
- gnupgBox->setLayout(gnupgLayout);
QGroupBox *gpg4usbBox = new QGroupBox(tr("Import from older gpg4usb"), this);
@@ -204,13 +113,12 @@ ImportPage::ImportPage(GpgME::GpgContext *ctx, KeyMgmt *keyMgmt, QWidget *parent
gpg4usbBox->setLayout(gpg4usbLayout);
layout = new QVBoxLayout();
- layout->addWidget(gnupgBox);
layout->addWidget(gpg4usbBox);
- setLayout(layout);
+ this->setLayout(layout);
}
-bool ImportPage::importKeysFromGpg4usb()
+bool ImportFromGpg4usbPage::importKeysFromGpg4usb()
{
QString dir = QFileDialog::getExistingDirectory(this,tr("Old gpg4usb directory"));
@@ -231,7 +139,7 @@ bool ImportPage::importKeysFromGpg4usb()
return false;
}
- if (pubRing.exists() and gnupgpPubKeyCheckBox->isChecked()) {
+/* if (pubRing.exists() and gnupgpPubKeyCheckBox->isChecked()) {
if (!pubRing.open(QIODevice::ReadOnly)) {
QMessageBox::critical(0, tr("Import error"), tr("Couldn't open public keyringfile: ") + pubRing.fileName());
return false;
@@ -248,26 +156,73 @@ bool ImportPage::importKeysFromGpg4usb()
QByteArray inBuffer = secRing.readAll();
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());
+
+ // TODO: edit->maybesave?
+ qApp->exit(RESTART_CODE);
return true;
}
-bool ImportPage::importConfFromGpg4usb(QString dir) {
+bool ImportFromGpg4usbPage::importConfFromGpg4usb(QString dir) {
QString path = dir+"/conf/gpg4usb.ini";
QSettings oldconf(path, QSettings::IniFormat, this);
QSettings actualConf;
foreach(QString key, oldconf.allKeys()) {
actualConf.setValue(key, oldconf.value(key));
}
+ return true;
+}
+
+int ImportFromGpg4usbPage::nextId() const
+{
+ return Wizard::Page_ImportFromGnupg;
+}
+
+ImportFromGnupgPage::ImportFromGnupgPage(GpgME::GpgContext *ctx, KeyMgmt *keyMgmt, QWidget *parent)
+ : QWizardPage(parent)
+{
+ setPixmap(QWizard::WatermarkPixmap, QPixmap(":/logo-flipped.png"));
+ mCtx=ctx;
+ mKeyMgmt=keyMgmt;
+ setTitle(tr("Keyring Import"));
+ QGroupBox *gnupgBox = new QGroupBox(tr("Import from GnuPG"), this);
+
+ QGridLayout *gnupgLayout = new QGridLayout();
+ gnupgLabel = new QLabel(tr("Should I try to import keys from GnuPG?"));
+ gnupgLayout->addWidget(gnupgLabel,1,1,1,2);
+
+ gnupgPrivKeyCheckBox = new QCheckBox();
+ gnupgPrivKeyCheckBox->setChecked(true);
+ gnupgLayout->addWidget(gnupgPrivKeyCheckBox,2,1,Qt::AlignRight);
+ QLabel *privateKeyLabel = new QLabel(tr("Private Keys"));
+ gnupgLayout->addWidget(privateKeyLabel,2,2);
+
+ gnupgpPubKeyCheckBox = new QCheckBox();
+ gnupgpPubKeyCheckBox->setChecked(true);
+ gnupgLayout->addWidget(gnupgpPubKeyCheckBox,3,1,Qt::AlignRight);
+ QLabel *gnupgPrivKeyLabel = new QLabel(tr("Public Keys"));
+ gnupgLayout->addWidget(gnupgPrivKeyLabel,3,2);
+
+
+ QWidget *importFromGnupgButtonBox = new QWidget(this);
+ QHBoxLayout *importFromGnupgButtonBoxLayout = new QHBoxLayout(importFromGnupgButtonBox);
+ importFromGnupgButton = new QPushButton(tr("Import keys from GnuPG"));
+ connect(importFromGnupgButton, SIGNAL(clicked()), this, SLOT(importKeysFromGnupg()));
+ importFromGnupgButtonBox->setLayout(importFromGnupgButtonBoxLayout);
+ gnupgLayout->addWidget(importFromGnupgButton,2,3);
+
+ gnupgBox->setLayout(gnupgLayout);
+
+ layout = new QVBoxLayout();
+ layout->addWidget(gnupgBox);
+ this->setLayout(layout);
}
-bool ImportPage::importKeysFromGnupg()
+bool ImportFromGnupgPage::importKeysFromGnupg()
{
// first get gnupghomedir and check, if it exists
QString gnuPGHome = getGnuPGHome();
@@ -307,7 +262,7 @@ bool ImportPage::importKeysFromGnupg()
return true;
}
-QString ImportPage::getGnuPGHome()
+QString ImportFromGnupgPage::getGnuPGHome()
{
QString gnuPGHome="";
#ifdef _WIN32
@@ -327,9 +282,58 @@ QString ImportPage::getGnuPGHome()
return gnuPGHome;
}
-int ImportPage::nextId() const
+int ImportFromGnupgPage::nextId() const
{
- return 3;
+ return Wizard::Page_GenKey;
+}
+
+KeyGenPage::KeyGenPage(GpgME::GpgContext *ctx, QWidget *parent)
+ : QWizardPage(parent)
+{
+
+ setPixmap(QWizard::WatermarkPixmap, QPixmap(":/logo-flipped.png"));
+ mCtx=ctx;
+ setTitle(tr("Key-Generating"));
+ topLabel = new QLabel(tr("First you've got to create an own keypair.<br/>"
+ "The pair contains a public and a private key.<br/>"
+ "Other users can use the public key to encrypt texts for you<br/>"
+ "and verify texts signed by you.<br/>"
+ "You can use the private key to decrypt and sign texts.<br/>"
+ "For more information have a look in the online tutorial:"));
+ QLabel *linkLabel = new QLabel("<a href=""docu_keygen.html#content"">"+tr("Online tutorial")+"</a>");
+ //linkLabel->setOpenExternalLinks(true);
+
+ connect(linkLabel, SIGNAL(linkActivated(const QString&)), parentWidget()->parentWidget(), SLOT(openHelp(const QString&)));
+
+ QWidget *createKeyButtonBox = new QWidget(this);
+ QHBoxLayout *createKeyButtonBoxLayout = new QHBoxLayout(createKeyButtonBox);
+ createKeyButton = new QPushButton(tr("Create New Key"));
+ createKeyButtonBoxLayout->addWidget(createKeyButton);
+ createKeyButtonBoxLayout->addStretch(1);
+ layout = new QVBoxLayout();
+ layout->addWidget(topLabel);
+ layout->addWidget(linkLabel);
+ layout->addWidget(createKeyButtonBox);
+ connect(createKeyButton, SIGNAL(clicked()), this, SLOT(generateKeyDialog()));
+
+ setLayout(layout);
+}
+
+int KeyGenPage::nextId() const
+{
+ return Wizard::Page_Conclusion;
+}
+
+void KeyGenPage::generateKeyDialog()
+{
+ KeyGenDialog *keyGenDialog = new KeyGenDialog(mCtx, this);
+ connect(mCtx, SIGNAL(keyDBChanged()), this, SLOT(showKeyGeneratedMessage()));
+ keyGenDialog->show();
+}
+
+void KeyGenPage::showKeyGeneratedMessage()
+{
+ layout->addWidget(new QLabel(tr("key generated. Now you can crypt and sign texts.")));
}
ConclusionPage::ConclusionPage(QWidget *parent)
diff --git a/wizard.h b/wizard.h
index 597ffee..09ceb25 100644
--- a/wizard.h
+++ b/wizard.h
@@ -39,6 +39,9 @@ class Wizard : public QWizard
Q_OBJECT
public:
+ enum { Page_Intro, Page_ImportFromGpg4usb, Page_ImportFromGnupg, Page_GenKey,
+ Page_Conclusion };
+
Wizard(GpgME::GpgContext *ctx, KeyMgmt *keyMgmt, QWidget *parent = 0);
private:
@@ -53,54 +56,47 @@ class IntroPage : public QWizardPage
public:
IntroPage(QWidget *parent = 0);
QLabel *topLabel;
-
- int nextId() const;
-};
-
-class LanguagePage : public QWizardPage
-{
- Q_OBJECT
-
-public:
- LanguagePage(QWidget *parent = 0);
- QLabel *topLabel;
-
+ QLabel *langLabel;
int nextId() const;
};
-class KeyGenPage : public QWizardPage
+class ImportFromGpg4usbPage : public QWizardPage
{
Q_OBJECT
public:
- KeyGenPage(GpgME::GpgContext *ctx, QWidget *parent = 0);
- int nextId() const;
+ ImportFromGpg4usbPage(GpgME::GpgContext *ctx, KeyMgmt *keyMgmt, QWidget *parent = 0);
private slots:
- void generateKeyDialog();
- void showKeyGeneratedMessage();
+ /**
+ * @details Import keys from gnupg-homedir, private or/and public depend on the checked boxes
+ */
+ bool importKeysFromGpg4usb();
+ bool importConfFromGpg4usb(QString dir);
private:
- QLabel *topLabel;
- QPushButton *createKeyButton;
- GpgME::GpgContext *mCtx;
+ int nextId() const;
+
+ KeyMgmt *mKeyMgmt;
QVBoxLayout *layout;
+ GpgME::GpgContext *mCtx;
+ QCheckBox *gpg4usbPrivKeyCheckBox;
+ QCheckBox *gpg4usbPubKeyCheckBox;
+ QPushButton *importFromGpg4usbButton;
};
-class ImportPage : public QWizardPage
+class ImportFromGnupgPage : public QWizardPage
{
Q_OBJECT
public:
- ImportPage(GpgME::GpgContext *ctx, KeyMgmt *keyMgmt, QWidget *parent = 0);
+ ImportFromGnupgPage(GpgME::GpgContext *ctx, KeyMgmt *keyMgmt, QWidget *parent = 0);
private slots:
/**
* @details Import keys from gnupg-homedir, private or/and public depend on the checked boxes
*/
bool importKeysFromGnupg();
- bool importKeysFromGpg4usb();
- bool importConfFromGpg4usb(QString dir);
private:
KeyMgmt *mKeyMgmt;
@@ -118,10 +114,26 @@ private:
GpgME::GpgContext *mCtx;
QCheckBox *gnupgPrivKeyCheckBox;
QCheckBox *gnupgpPubKeyCheckBox;
- QCheckBox *gpg4usbPrivKeyCheckBox;
- QCheckBox *gpg4usbPubKeyCheckBox;
QPushButton *importFromGnupgButton;
- QPushButton *importFromGpg4usbButton;
+};
+
+class KeyGenPage : public QWizardPage
+{
+ Q_OBJECT
+
+public:
+ KeyGenPage(GpgME::GpgContext *ctx, QWidget *parent = 0);
+ int nextId() const;
+
+private slots:
+ void generateKeyDialog();
+ void showKeyGeneratedMessage();
+
+private:
+ QLabel *topLabel;
+ QPushButton *createKeyButton;
+ GpgME::GpgContext *mCtx;
+ QVBoxLayout *layout;
};
class ConclusionPage : public QWizardPage