aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui/Wizard.cpp
diff options
context:
space:
mode:
authorSaturneric <[email protected]>2021-10-02 14:08:50 +0000
committerSaturneric <[email protected]>2021-10-02 14:16:27 +0000
commit3c65d087eeee687ac01af2e80f3dd538f9a2c230 (patch)
tree1e860dc6343c1897e2224a002f2ca44c574381b3 /src/ui/Wizard.cpp
parentThe basic functions of the core pass the test. (diff)
downloadGpgFrontend-3c65d087eeee687ac01af2e80f3dd538f9a2c230.tar.gz
GpgFrontend-3c65d087eeee687ac01af2e80f3dd538f9a2c230.zip
UI Framework Modified.
Diffstat (limited to 'src/ui/Wizard.cpp')
-rw-r--r--src/ui/Wizard.cpp408
1 files changed, 215 insertions, 193 deletions
diff --git a/src/ui/Wizard.cpp b/src/ui/Wizard.cpp
index 4c7b8d7c..2f050e80 100644
--- a/src/ui/Wizard.cpp
+++ b/src/ui/Wizard.cpp
@@ -24,234 +24,256 @@
#include "ui/Wizard.h"
-Wizard::Wizard(GpgFrontend::GpgContext *ctx, KeyMgmt *keyMgmt, QWidget *parent)
- : QWizard(parent), appPath(qApp->applicationDirPath()),
- settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini", QSettings::IniFormat) {
- mCtx = ctx;
- mKeyMgmt = keyMgmt;
-
- setPage(Page_Intro, new IntroPage(this));
- setPage(Page_Choose, new ChoosePage(this));
- setPage(Page_GenKey, new KeyGenPage(mCtx, this));
- setPage(Page_Conclusion, new ConclusionPage(this));
+namespace GpgFrontend::UI {
+
+Wizard::Wizard(KeyMgmt* keyMgmt, QWidget* parent)
+ : QWizard(parent),
+ appPath(qApp->applicationDirPath()),
+ settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini",
+ QSettings::IniFormat) {
+ mKeyMgmt = keyMgmt;
+
+ setPage(Page_Intro, new IntroPage(this));
+ setPage(Page_Choose, new ChoosePage(this));
+ setPage(Page_GenKey, new KeyGenPage(this));
+ setPage(Page_Conclusion, new ConclusionPage(this));
#ifndef Q_WS_MAC
- setWizardStyle(ModernStyle);
+ setWizardStyle(ModernStyle);
#endif
- setWindowTitle(tr("First Start Wizard"));
+ setWindowTitle(tr("First Start Wizard"));
- // http://www.flickr.com/photos/laureenp/6141822934/
- setPixmap(QWizard::WatermarkPixmap, QPixmap(":/keys2.jpg"));
- setPixmap(QWizard::LogoPixmap, QPixmap(":/logo_small.png"));
- setPixmap(QWizard::BannerPixmap, QPixmap(":/banner.png"));
+ // http://www.flickr.com/photos/laureenp/6141822934/
+ setPixmap(QWizard::WatermarkPixmap, QPixmap(":/keys2.jpg"));
+ setPixmap(QWizard::LogoPixmap, QPixmap(":/logo_small.png"));
+ setPixmap(QWizard::BannerPixmap, QPixmap(":/banner.png"));
- setStartId(settings.value("wizard/nextPage", -1).toInt());
- settings.remove("wizard/nextPage");
-
- connect(this, SIGNAL(accepted()), this, SLOT(slotWizardAccepted()));
+ setStartId(settings.value("wizard/nextPage", -1).toInt());
+ settings.remove("wizard/nextPage");
+ connect(this, SIGNAL(accepted()), this, SLOT(slotWizardAccepted()));
}
void Wizard::slotWizardAccepted() {
- // Don't show is mapped to show -> negation
- settings.setValue("wizard/showWizard", !field("showWizard").toBool());
+ // Don't show is mapped to show -> negation
+ settings.setValue("wizard/showWizard", !field("showWizard").toBool());
- if (field("openHelp").toBool()) {
- emit signalOpenHelp("docu.html#content");
- }
+ if (field("openHelp").toBool()) {
+ emit signalOpenHelp("docu.html#content");
+ }
}
-IntroPage::IntroPage(QWidget *parent)
- : QWizardPage(parent), appPath(qApp->applicationDirPath()),
- settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini", QSettings::IniFormat) {
- setTitle(tr("Getting Started..."));
- setSubTitle(tr("... with GPGFrontend"));
-
- auto *topLabel = new QLabel(tr("Welcome to use GPGFrontend for decrypting and signing text or file!") +
- " <br><br><a href='https://gpgfrontend.pub'>GpgFrontend</a> " +
- tr("is a Powerful, Easy-to-Use, Compact, Cross-Platform, and Installation-Free OpenPGP Crypto Tool.") +
- tr("For brief information have a look at the") +
- " <a href='https://gpgfrontend.pub/index.html#/overview'>" +
- tr("Overview") + "</a> (" +
- tr("by clicking the link, the page will open in the web browser") +
- "). <br>");
- topLabel->setTextFormat(Qt::RichText);
- topLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
- topLabel->setOpenExternalLinks(true);
- topLabel->setWordWrap(true);
-
- // QComboBox for language selection
- auto *langLabel = new QLabel(tr("Choose a Language"));
- langLabel->setWordWrap(true);
-
- languages = SettingsDialog::listLanguages();
- auto *langSelectBox = new QComboBox();
-
- for (const auto &l : languages) {
- langSelectBox->addItem(l);
- }
- // selected entry from config
- 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(slotLangChange(QString)));
-
- // set layout and add widgets
- auto *layout = new QVBoxLayout;
- layout->addWidget(topLabel);
- layout->addWidget(langLabel);
- layout->addWidget(langSelectBox);
- setLayout(layout);
+IntroPage::IntroPage(QWidget* parent)
+ : QWizardPage(parent),
+ appPath(qApp->applicationDirPath()),
+ settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini",
+ QSettings::IniFormat) {
+ setTitle(tr("Getting Started..."));
+ setSubTitle(tr("... with GPGFrontend"));
+
+ auto* topLabel = new QLabel(
+ tr("Welcome to use GPGFrontend for decrypting and signing text or "
+ "file!") +
+ " <br><br><a href='https://gpgfrontend.pub'>GpgFrontend</a> " +
+ tr("is a Powerful, Easy-to-Use, Compact, Cross-Platform, and "
+ "Installation-Free OpenPGP Crypto Tool.") +
+ tr("For brief information have a look at the") +
+ " <a href='https://gpgfrontend.pub/index.html#/overview'>" +
+ tr("Overview") + "</a> (" +
+ tr("by clicking the link, the page will open in the web browser") +
+ "). <br>");
+ topLabel->setTextFormat(Qt::RichText);
+ topLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
+ topLabel->setOpenExternalLinks(true);
+ topLabel->setWordWrap(true);
+
+ // QComboBox for language selection
+ auto* langLabel = new QLabel(tr("Choose a Language"));
+ langLabel->setWordWrap(true);
+
+ languages = SettingsDialog::listLanguages();
+ auto* langSelectBox = new QComboBox();
+
+ for (const auto& l : languages) {
+ langSelectBox->addItem(l);
+ }
+ // selected entry from config
+ 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(slotLangChange(QString)));
+
+ // set layout and add widgets
+ auto* layout = new QVBoxLayout;
+ layout->addWidget(topLabel);
+ layout->addWidget(langLabel);
+ layout->addWidget(langSelectBox);
+ setLayout(layout);
}
-void IntroPage::slotLangChange(const QString &lang) {
- settings.setValue("int/lang", languages.key(lang));
- settings.setValue("wizard/nextPage", this->wizard()->currentId());
- qApp->exit(RESTART_CODE);
+void IntroPage::slotLangChange(const QString& lang) {
+ settings.setValue("int/lang", languages.key(lang));
+ settings.setValue("wizard/nextPage", this->wizard()->currentId());
+ qApp->exit(RESTART_CODE);
}
int IntroPage::nextId() const {
- return Wizard::Page_Choose;
+ return Wizard::Page_Choose;
}
-ChoosePage::ChoosePage(QWidget *parent)
- : QWizardPage(parent) {
- setTitle(tr("Choose your action..."));
- setSubTitle(tr("...by clicking on the appropriate link."));
-
- auto *keygenLabel = new QLabel(tr("If you have never used GPGFrontend before and also don't own a gpg key yet you "
- "may possibly want to read how to") +
- " <a href=\"https://gpgfrontend.pub/index.html#/manual/generate-key\">"
- + tr("Generate Key") + "</a><hr>");
- keygenLabel->setTextFormat(Qt::RichText);
- keygenLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
- keygenLabel->setOpenExternalLinks(true);
- keygenLabel->setWordWrap(true);
-
- auto *encrDecyTextLabel = new QLabel(
- tr("If you want to learn how to encrypt, decrypt, sign and verify text, you can read ")
- + "<a href=\"https://gpgfrontend.pub/index.html#/manual/encrypt-decrypt-text\">"
- + tr("Encrypt & Decrypt Text") + "</a> " + tr("or")
- + " <a href=\"https://gpgfrontend.pub/index.html#/manual/sign-verify-text\">"
- + tr("Sign & Verify Text")
- + "</a><hr>");
-
- encrDecyTextLabel->setTextFormat(Qt::RichText);
- encrDecyTextLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
- encrDecyTextLabel->setOpenExternalLinks(true);
- encrDecyTextLabel->setWordWrap(true);
-
- auto *signVerifyTextLabel = new QLabel(tr("If you want to operate file, you can read ")
- +
- "<a href=\"https://gpgfrontend.pub/index.html#/manual/encrypt-decrypt-file\">"
- + tr("Encrypt & Sign File") + "</a> " + tr("or")
- +
- " <a href=\"https://gpgfrontend.pub/index.html#/manual/sign-verify-file\">"
- + tr("Sign & Verify File")
- + "</a><hr>");
- signVerifyTextLabel->setTextFormat(Qt::RichText);
- signVerifyTextLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
- signVerifyTextLabel->setOpenExternalLinks(true);
- signVerifyTextLabel->setWordWrap(true);
-
- auto *layout = new QVBoxLayout();
- layout->addWidget(keygenLabel);
- layout->addWidget(encrDecyTextLabel);
- layout->addWidget(signVerifyTextLabel);
- setLayout(layout);
- nextPage = Wizard::Page_Conclusion;
+ChoosePage::ChoosePage(QWidget* parent) : QWizardPage(parent) {
+ setTitle(tr("Choose your action..."));
+ setSubTitle(tr("...by clicking on the appropriate link."));
+
+ auto* keygenLabel = new QLabel(
+ tr("If you have never used GPGFrontend before and also don't own a gpg "
+ "key yet you "
+ "may possibly want to read how to") +
+ " <a href=\"https://gpgfrontend.pub/index.html#/manual/generate-key\">" +
+ tr("Generate Key") + "</a><hr>");
+ keygenLabel->setTextFormat(Qt::RichText);
+ keygenLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
+ keygenLabel->setOpenExternalLinks(true);
+ keygenLabel->setWordWrap(true);
+
+ auto* encrDecyTextLabel = new QLabel(
+ tr("If you want to learn how to encrypt, decrypt, sign and verify text, "
+ "you can read ") +
+ "<a "
+ "href=\"https://gpgfrontend.pub/index.html#/manual/"
+ "encrypt-decrypt-text\">" +
+ tr("Encrypt & Decrypt Text") + "</a> " + tr("or") +
+ " <a "
+ "href=\"https://gpgfrontend.pub/index.html#/manual/sign-verify-text\">" +
+ tr("Sign & Verify Text") + "</a><hr>");
+
+ encrDecyTextLabel->setTextFormat(Qt::RichText);
+ encrDecyTextLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
+ encrDecyTextLabel->setOpenExternalLinks(true);
+ encrDecyTextLabel->setWordWrap(true);
+
+ auto* signVerifyTextLabel = new QLabel(
+ tr("If you want to operate file, you can read ") +
+ "<a "
+ "href=\"https://gpgfrontend.pub/index.html#/manual/"
+ "encrypt-decrypt-file\">" +
+ tr("Encrypt & Sign File") + "</a> " + tr("or") +
+ " <a "
+ "href=\"https://gpgfrontend.pub/index.html#/manual/sign-verify-file\">" +
+ tr("Sign & Verify File") + "</a><hr>");
+ signVerifyTextLabel->setTextFormat(Qt::RichText);
+ signVerifyTextLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
+ signVerifyTextLabel->setOpenExternalLinks(true);
+ signVerifyTextLabel->setWordWrap(true);
+
+ auto* layout = new QVBoxLayout();
+ layout->addWidget(keygenLabel);
+ layout->addWidget(encrDecyTextLabel);
+ layout->addWidget(signVerifyTextLabel);
+ setLayout(layout);
+ nextPage = Wizard::Page_Conclusion;
}
int ChoosePage::nextId() const {
- return nextPage;
+ return nextPage;
}
-void ChoosePage::slotJumpPage(const QString &page) {
- QMetaObject qmo = Wizard::staticMetaObject;
- int index = qmo.indexOfEnumerator("WizardPages");
- QMetaEnum m = qmo.enumerator(index);
+void ChoosePage::slotJumpPage(const QString& page) {
+ QMetaObject qmo = Wizard::staticMetaObject;
+ int index = qmo.indexOfEnumerator("WizardPages");
+ QMetaEnum m = qmo.enumerator(index);
- nextPage = m.keyToValue(page.toUtf8().data());
- wizard()->next();
+ nextPage = m.keyToValue(page.toUtf8().data());
+ wizard()->next();
}
-KeyGenPage::KeyGenPage(GpgFrontend::GpgContext *ctx, QWidget *parent)
- : QWizardPage(parent) {
- mCtx = ctx;
- setTitle(tr("Create a keypair..."));
- setSubTitle(tr("...for decrypting and signing messages"));
- auto *topLabel = new QLabel(tr("You should create a new keypair."
- "The pair consists of a public and a private key.<br>"
- "Other users can use the public key to encrypt messages for you "
- "and verify messages signed by you."
- "You can use the private key to decrypt and sign messages.<br>"
- "For more information have a look at the offline tutorial (which then is shown in the main window):"));
- topLabel->setWordWrap(true);
- auto *linkLabel = new QLabel("<a href=""docu_keygen.html#content"">" + tr("Offline tutorial") + "</a>");
- //linkLabel->setOpenExternalLinks(true);
-
- // connect(linkLabel, SIGNAL(linkActivated(QString)), parentWidget()->parentWidget(), SLOT(openHelp(QString)));
-
- auto *createKeyButtonBox = new QWidget(this);
- auto *createKeyButtonBoxLayout = new QHBoxLayout(createKeyButtonBox);
- auto *createKeyButton = new QPushButton(tr("Create New Key"));
- createKeyButtonBoxLayout->addWidget(createKeyButton);
- createKeyButtonBoxLayout->addStretch(1);
- auto *layout = new QVBoxLayout();
- layout->addWidget(topLabel);
- layout->addWidget(linkLabel);
- layout->addWidget(createKeyButtonBox);
- connect(createKeyButton, SIGNAL(clicked(bool)), this, SLOT(slotGenerateKeyDialog()));
-
- setLayout(layout);
+KeyGenPage::KeyGenPage(QWidget* parent) : QWizardPage(parent) {
+ setTitle(tr("Create a keypair..."));
+ setSubTitle(tr("...for decrypting and signing messages"));
+ auto* topLabel = new QLabel(
+ tr("You should create a new keypair."
+ "The pair consists of a public and a private key.<br>"
+ "Other users can use the public key to encrypt messages for you "
+ "and verify messages signed by you."
+ "You can use the private key to decrypt and sign messages.<br>"
+ "For more information have a look at the offline tutorial (which then "
+ "is shown in the main window):"));
+ topLabel->setWordWrap(true);
+ auto* linkLabel = new QLabel(
+ "<a href="
+ "docu_keygen.html#content"
+ ">" +
+ tr("Offline tutorial") + "</a>");
+ // linkLabel->setOpenExternalLinks(true);
+
+ // connect(linkLabel, SIGNAL(linkActivated(QString)),
+ // parentWidget()->parentWidget(), SLOT(openHelp(QString)));
+
+ auto* createKeyButtonBox = new QWidget(this);
+ auto* createKeyButtonBoxLayout = new QHBoxLayout(createKeyButtonBox);
+ auto* createKeyButton = new QPushButton(tr("Create New Key"));
+ createKeyButtonBoxLayout->addWidget(createKeyButton);
+ createKeyButtonBoxLayout->addStretch(1);
+ auto* layout = new QVBoxLayout();
+ layout->addWidget(topLabel);
+ layout->addWidget(linkLabel);
+ layout->addWidget(createKeyButtonBox);
+ connect(createKeyButton, SIGNAL(clicked(bool)), this,
+ SLOT(slotGenerateKeyDialog()));
+
+ setLayout(layout);
}
int KeyGenPage::nextId() const {
- return Wizard::Page_Conclusion;
+ return Wizard::Page_Conclusion;
}
void KeyGenPage::slotGenerateKeyDialog() {
- qDebug() << "Try Opening KeyGenDialog";
- auto *keyGenDialog = new KeyGenDialog(mCtx, this);
- keyGenDialog->show();
- wizard()->next();
+ qDebug() << "Try Opening KeyGenDialog";
+ (new KeyGenDialog(this))->show();
+ wizard()->next();
}
-ConclusionPage::ConclusionPage(QWidget *parent)
- : QWizardPage(parent) {
- setTitle(tr("Ready."));
- setSubTitle(tr("Have fun with GPGFrontend!"));
-
- auto *bottomLabel = new QLabel(tr("You are ready to use GPGFrontend now.<br><br>") +
- "<a href=\"https://saturneric.github.io/GpgFrontend/index.html#/overview\">"
- + tr("The Online Document") + "</a>"
- +
- tr(" will get you started with GPGFrontend. It will open in the main window.<br>"));
-
- bottomLabel->setTextFormat(Qt::RichText);
- bottomLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
- bottomLabel->setOpenExternalLinks(true);
- bottomLabel->setWordWrap(true);
-
- openHelpCheckBox = new QCheckBox(tr("Open offline help."));
- openHelpCheckBox->setChecked(Qt::Checked);
-
- dontShowWizardCheckBox = new QCheckBox(tr("Dont show the wizard again."));
- dontShowWizardCheckBox->setChecked(Qt::Checked);
-
- registerField("showWizard", dontShowWizardCheckBox);
- // registerField("openHelp", openHelpCheckBox);
-
- auto *layout = new QVBoxLayout;
- layout->addWidget(bottomLabel);
- // layout->addWidget(openHelpCheckBox);
- layout->addWidget(dontShowWizardCheckBox);
- setLayout(layout);
- setVisible(true);
+ConclusionPage::ConclusionPage(QWidget* parent) : QWizardPage(parent) {
+ setTitle(tr("Ready."));
+ setSubTitle(tr("Have fun with GPGFrontend!"));
+
+ auto* bottomLabel =
+ new QLabel(tr("You are ready to use GPGFrontend now.<br><br>") +
+ "<a "
+ "href=\"https://saturneric.github.io/GpgFrontend/index.html#/"
+ "overview\">" +
+ tr("The Online Document") + "</a>" +
+ tr(" will get you started with GPGFrontend. It will open in "
+ "the main window.<br>"));
+
+ bottomLabel->setTextFormat(Qt::RichText);
+ bottomLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
+ bottomLabel->setOpenExternalLinks(true);
+ bottomLabel->setWordWrap(true);
+
+ openHelpCheckBox = new QCheckBox(tr("Open offline help."));
+ openHelpCheckBox->setChecked(Qt::Checked);
+
+ dontShowWizardCheckBox = new QCheckBox(tr("Dont show the wizard again."));
+ dontShowWizardCheckBox->setChecked(Qt::Checked);
+
+ registerField("showWizard", dontShowWizardCheckBox);
+ // registerField("openHelp", openHelpCheckBox);
+
+ auto* layout = new QVBoxLayout;
+ layout->addWidget(bottomLabel);
+ // layout->addWidget(openHelpCheckBox);
+ layout->addWidget(dontShowWizardCheckBox);
+ setLayout(layout);
+ setVisible(true);
}
int ConclusionPage::nextId() const {
- return -1;
+ return -1;
}
+
+} // namespace GpgFrontend::UI