From 8bad4a3252ef105dd2127af7cbb09a436d7faf22 Mon Sep 17 00:00:00 2001 From: tobtoht Date: Fri, 15 Sep 2023 14:29:58 +0200 Subject: [PATCH] add InfoFrame component --- src/components.cpp | 37 ++++++ src/components.h | 13 ++ src/wizard/PageSetPassword.cpp | 5 +- src/wizard/PageSetPassword.ui | 53 ++------ src/wizard/PageSetRestoreHeight.cpp | 15 ++- src/wizard/PageSetRestoreHeight.ui | 141 ++------------------- src/wizard/PageWalletFile.cpp | 8 +- src/wizard/PageWalletFile.ui | 91 +++++--------- src/wizard/PageWalletSeed.cpp | 22 ++-- src/wizard/PageWalletSeed.ui | 186 ++-------------------------- 10 files changed, 136 insertions(+), 435 deletions(-) diff --git a/src/components.cpp b/src/components.cpp index d1eb4bc..7badb70 100644 --- a/src/components.cpp +++ b/src/components.cpp @@ -88,4 +88,41 @@ WindowModalDialog::WindowModalDialog(QWidget *parent) #ifndef Q_OS_MACOS this->setWindowModality(Qt::WindowModal); #endif +} + +InfoFrame::InfoFrame(QWidget *parent) + : QFrame(parent) +{ + auto *layout = new QHBoxLayout(this); + + m_icon = new QPushButton(this); + m_icon->setFlat(true); + m_icon->setIconSize(QSize(32, 32)); + m_icon->setMaximumSize(32, 32); + m_icon->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred); + layout->addWidget(m_icon); + + auto *spacer = new QSpacerItem(5, 0, QSizePolicy::Fixed, QSizePolicy::Minimum); + layout->addSpacerItem(spacer); + + m_infoLabel = new QLabel(this); + m_infoLabel->setWordWrap(true); + m_infoLabel->setTextFormat(Qt::MarkdownText); + m_infoLabel->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse); + layout->addWidget(m_infoLabel); +} + +void InfoFrame::setInfo(const QIcon &icon, const QString &text) { + m_icon->setIcon(icon); + m_infoLabel->setText(text); + +#ifdef Q_OS_MACOS + this->setFrameShape(QFrame::Box); +#else + this->setFrameShape(QFrame::StyledPanel); +#endif +} + +void InfoFrame::setText(const QString &text) { + m_infoLabel->setText(text); } \ No newline at end of file diff --git a/src/components.h b/src/components.h index ce180c6..7b52033 100644 --- a/src/components.h +++ b/src/components.h @@ -84,4 +84,17 @@ public: explicit WindowModalDialog(QWidget *parent); }; +class InfoFrame : public QFrame { + Q_OBJECT + +public: + explicit InfoFrame(QWidget *parent); + void setInfo(const QIcon &icon, const QString &text); + void setText(const QString &text); + +private: + QPushButton *m_icon; + QLabel *m_infoLabel; +}; + #endif //FEATHER_COMPONENTS_H diff --git a/src/wizard/PageSetPassword.cpp b/src/wizard/PageSetPassword.cpp index 2d8a110..726cfcb 100644 --- a/src/wizard/PageSetPassword.cpp +++ b/src/wizard/PageSetPassword.cpp @@ -5,6 +5,8 @@ #include "ui_PageSetPassword.h" #include "WalletWizard.h" +#include "utils/Icons.h" + PageSetPassword::PageSetPassword(WizardFields *fields, QWidget *parent) : QWizardPage(parent) , ui(new Ui::PageSetPassword) @@ -13,8 +15,7 @@ PageSetPassword::PageSetPassword(WizardFields *fields, QWidget *parent) ui->setupUi(this); this->setFinalPage(true); - QPixmap pixmap = QPixmap(":/assets/images/lock.svg"); - ui->icon->setPixmap(pixmap.scaledToWidth(32, Qt::SmoothTransformation)); + ui->frame_password->setInfo(icons()->icon("lock"), "Choose a password to encrypt your wallet keys."); connect(ui->line_password, &QLineEdit::textChanged, [this]{ this->completeChanged(); diff --git a/src/wizard/PageSetPassword.ui b/src/wizard/PageSetPassword.ui index 66da66a..b9175d3 100644 --- a/src/wizard/PageSetPassword.ui +++ b/src/wizard/PageSetPassword.ui @@ -7,7 +7,7 @@ 0 0 431 - 231 + 232 @@ -15,54 +15,13 @@ - + QFrame::StyledPanel QFrame::Raised - - - - - - 0 - 0 - - - - TextLabel - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 5 - 20 - - - - - - - - Choose a password to encrypt your wallet keys. - - - true - - - - @@ -111,6 +70,14 @@ + + + InfoFrame + QFrame +
components.h
+ 1 +
+
diff --git a/src/wizard/PageSetRestoreHeight.cpp b/src/wizard/PageSetRestoreHeight.cpp index 25fd77b..55d02ac 100644 --- a/src/wizard/PageSetRestoreHeight.cpp +++ b/src/wizard/PageSetRestoreHeight.cpp @@ -7,6 +7,8 @@ #include "WalletWizard.h" #include "constants.h" +#include "utils/Icons.h" + PageSetRestoreHeight::PageSetRestoreHeight(WizardFields *fields, QWidget *parent) : QWizardPage(parent) , ui(new Ui::PageSetRestoreHeight) @@ -14,6 +16,10 @@ PageSetRestoreHeight::PageSetRestoreHeight(WizardFields *fields, QWidget *parent { ui->setupUi(this); + ui->frame_restoreHeight->setInfo(icons()->icon("unpaid"), "Enter the wallet creation date or set the restore height manually."); + ui->frame_walletAgeWarning->setInfo(icons()->icon("info2"), "Wallet is very old. Synchronization may take a long time."); + ui->frame_scanWarning->setInfo(icons()->icon("info2"), "Wallet will not scan for transactions before YYYY/MM/DD."); + QRegularExpression yearRe(R"(\d{2,4}-\d{1,2}-\d{1,2})"); QValidator *yearValidator = new QRegularExpressionValidator(yearRe, this); ui->line_creationDate->setValidator(yearValidator); @@ -22,13 +28,6 @@ PageSetRestoreHeight::PageSetRestoreHeight(WizardFields *fields, QWidget *parent QValidator *heightValidator = new QRegularExpressionValidator(heightRe, this); ui->line_restoreHeight->setValidator(heightValidator); - QPixmap pixmap = QPixmap(":/assets/images/unpaid.png"); - ui->icon->setPixmap(pixmap.scaledToWidth(32, Qt::SmoothTransformation)); - - QPixmap pixmap2 = QPixmap(":/assets/images/info2.svg"); - ui->warningIcon->setPixmap(pixmap2.scaledToWidth(32, Qt::SmoothTransformation)); - ui->infoIcon->setPixmap(pixmap2.scaledToWidth(32, Qt::SmoothTransformation)); - connect(ui->line_creationDate, &QLineEdit::textEdited, [this]{ this->onCreationDateEdited(); this->completeChanged(); @@ -88,7 +87,7 @@ void PageSetRestoreHeight::onRestoreHeightEdited() { void PageSetRestoreHeight::showScanWarning(const QDateTime &date) { QString dateString = date.toString("MMMM dd, yyyy"); - ui->label_scanWarning->setText(QString("Wallet will not scan for transactions before %1").arg(dateString)); + ui->frame_scanWarning->setText(QString("Wallet will not scan for transactions before %1").arg(dateString)); ui->frame_scanWarning->show(); } diff --git a/src/wizard/PageSetRestoreHeight.ui b/src/wizard/PageSetRestoreHeight.ui index 52be444..da165b1 100644 --- a/src/wizard/PageSetRestoreHeight.ui +++ b/src/wizard/PageSetRestoreHeight.ui @@ -15,58 +15,13 @@ - + QFrame::StyledPanel QFrame::Raised - - - - - - 0 - 0 - - - - icon - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 5 - 20 - - - - - - - - - - Enter the wallet creation date or set the restore height manually. - - - true - - - - - - @@ -171,109 +126,35 @@ - + QFrame::StyledPanel QFrame::Raised - - - - - - 0 - 0 - - - - icon - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 5 - 20 - - - - - - - - Wallet is very old. Synchronization may take a long time. - - - true - - - - - + QFrame::StyledPanel QFrame::Raised - - - - - - 0 - 0 - - - - icon - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 5 - 20 - - - - - - - - Wallet will not scan for transactions before YYYY/MM/DD. - - - true - - - - + + + InfoFrame + QFrame +
components.h
+ 1 +
+
diff --git a/src/wizard/PageWalletFile.cpp b/src/wizard/PageWalletFile.cpp index 1b5b18c..6acc60c 100644 --- a/src/wizard/PageWalletFile.cpp +++ b/src/wizard/PageWalletFile.cpp @@ -5,10 +5,11 @@ #include "PageWalletFile.h" #include "ui_PageWalletFile.h" -#include "utils/Utils.h" - #include +#include "utils/Icons.h" +#include "utils/Utils.h" + PageWalletFile::PageWalletFile(WizardFields *fields, QWidget *parent) : QWizardPage(parent) , ui(new Ui::PageWalletFile) @@ -17,8 +18,7 @@ PageWalletFile::PageWalletFile(WizardFields *fields, QWidget *parent) ui->setupUi(this); this->setButtonText(QWizard::FinishButton, "Open wallet"); - QPixmap pixmap = QPixmap(":/assets/images/file.png"); - ui->lockIcon->setPixmap(pixmap.scaledToWidth(32, Qt::SmoothTransformation)); + ui->frame_wallet->setInfo(icons()->icon("file"), "Choose a name and directory for your wallet files."); connect(ui->btnChange, &QPushButton::clicked, [=] { QString currentWalletDir = conf()->get(Config::walletDirectory).toString(); diff --git a/src/wizard/PageWalletFile.ui b/src/wizard/PageWalletFile.ui index c4e2807..30ab81c 100644 --- a/src/wizard/PageWalletFile.ui +++ b/src/wizard/PageWalletFile.ui @@ -14,6 +14,16 @@ Create Wallet + + + + + + + Set as default wallet directory + + + @@ -21,6 +31,16 @@ + + + + QFrame::StyledPanel + + + QFrame::Raised + + + @@ -39,9 +59,6 @@ - - - @@ -49,57 +66,6 @@ - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - - 0 - 0 - - - - icon - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 5 - 20 - - - - - - - - Choose a name and directory for your wallet files. - - - true - - - - - - @@ -113,20 +79,21 @@ - - - - Set as default wallet directory - - - label_9 label line_walletName - frame check_defaultWalletDirectory + frame_wallet + + + InfoFrame + QFrame +
components.h
+ 1 +
+
line_walletName line_walletDir diff --git a/src/wizard/PageWalletSeed.cpp b/src/wizard/PageWalletSeed.cpp index 342918a..212fbef 100644 --- a/src/wizard/PageWalletSeed.cpp +++ b/src/wizard/PageWalletSeed.cpp @@ -4,14 +4,15 @@ #include "WalletWizard.h" #include "PageWalletSeed.h" #include "ui_PageWalletSeed.h" -#include "constants.h" -#include "Seed.h" #include -#include #include #include +#include "constants.h" +#include "Seed.h" +#include "Icons.h" + PageWalletSeed::PageWalletSeed(WizardFields *fields, QWidget *parent) : QWizardPage(parent) , ui(new Ui::PageWalletSeed) @@ -19,15 +20,14 @@ PageWalletSeed::PageWalletSeed(WizardFields *fields, QWidget *parent) { ui->setupUi(this); + ui->frame_notice->setInfo(icons()->icon("seed"), "The following **16** words can be used to recover access to your wallet.\n\n" + "Write them down and store them somewhere safe and secure.\n\n" + "Feather uses **Polyseed**. For more information click **Help**."); + + ui->frame_invalidSeed->setInfo(icons()->icon("warning"), "Feather was unable to generate a valid seed.\n" + "This should never happen.\n" + "Please contact the developers immediately."); ui->frame_invalidSeed->hide(); - QPixmap warningIcon = QPixmap(":/assets/images/warning.png"); - ui->warningIcon->setPixmap(warningIcon.scaledToWidth(32, Qt::SmoothTransformation)); - - QPixmap infoIcon = QPixmap(":/assets/images/info2.svg"); - ui->newSeedWarningIcon->setPixmap(infoIcon.scaledToWidth(32, Qt::SmoothTransformation)); - - QPixmap pixmap = QPixmap(":/assets/images/seed.png"); - ui->seedIcon->setPixmap(pixmap.scaledToWidth(32, Qt::SmoothTransformation)); connect(ui->btnRoulette, &QPushButton::clicked, [=]{ this->seedRoulette(0); diff --git a/src/wizard/PageWalletSeed.ui b/src/wizard/PageWalletSeed.ui index aa91272..3575faa 100644 --- a/src/wizard/PageWalletSeed.ui +++ b/src/wizard/PageWalletSeed.ui @@ -15,192 +15,20 @@ - + - QFrame::StyledPanel + QFrame::Box - - QFrame::Raised - - - - - - - 0 - 0 - - - - icon - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 5 - 20 - - - - - - - - - - <html><head/><body><p>Store your <span style=" font-weight:600;">16-word</span> seed in a safe location.</p></body></html> - - - true - - - - - - - This seed will allow you to recover your wallet in case of computer failure. - - - true - - - - - - - + QFrame::StyledPanel QFrame::Raised - - - - - - 0 - 0 - - - - icon - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 5 - 20 - - - - - - - - - - <html><head/><body><p>Feather uses <span style=" font-weight:600;">Polyseed</span>. For more information click <span style=" font-weight:700;">Help</span>.</p></body></html> - - - true - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - - 0 - 0 - - - - icon - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 5 - 20 - - - - - - - - - - Feather was unable to generate a valid seed. - - - - - - - This should never happen. - - - - - - - Please contact the developers immediately. - - - - - - @@ -933,6 +761,14 @@ + + + InfoFrame + QFrame +
components.h
+ 1 +
+