add InfoFrame component

This commit is contained in:
tobtoht 2023-09-15 14:29:58 +02:00
parent 7ed8c0ee79
commit 135f1987c9
No known key found for this signature in database
GPG key ID: E45B10DD027D2472
10 changed files with 136 additions and 435 deletions

View file

@ -84,4 +84,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);
}

View file

@ -80,4 +80,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

View file

@ -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();

View file

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>431</width>
<height>231</height>
<height>232</height>
</rect>
</property>
<property name="windowTitle">
@ -15,54 +15,13 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QFrame" name="frame">
<widget class="InfoFrame" name="frame_password">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="icon">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>5</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Choose a password to encrypt your wallet keys.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
@ -111,6 +70,14 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>InfoFrame</class>
<extends>QFrame</extends>
<header>components.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View file

@ -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();
}

View file

@ -15,58 +15,13 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QFrame" name="frame">
<widget class="InfoFrame" name="frame_restoreHeight">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="icon">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>icon</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>5</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Enter the wallet creation date or set the restore height manually.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
@ -171,109 +126,35 @@
</spacer>
</item>
<item>
<widget class="QFrame" name="frame_walletAgeWarning">
<widget class="InfoFrame" name="frame_walletAgeWarning">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="infoIcon">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>icon</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>5</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>Wallet is very old. Synchronization may take a long time.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="frame_scanWarning">
<widget class="InfoFrame" name="frame_scanWarning">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="warningIcon">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>icon</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>5</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_scanWarning">
<property name="text">
<string>Wallet will not scan for transactions before YYYY/MM/DD.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>InfoFrame</class>
<extends>QFrame</extends>
<header>components.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View file

@ -5,10 +5,11 @@
#include "PageWalletFile.h"
#include "ui_PageWalletFile.h"
#include "utils/Utils.h"
#include <QFileDialog>
#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();

View file

@ -14,6 +14,16 @@
<string>Create Wallet</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0">
<widget class="QLineEdit" name="line_walletName"/>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="check_defaultWalletDirectory">
<property name="text">
<string>Set as default wallet directory</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
@ -21,6 +31,16 @@
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="InfoFrame" name="frame_wallet">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item row="5" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
@ -39,9 +59,6 @@
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QLineEdit" name="line_walletName"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
@ -49,57 +66,6 @@
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="lockIcon">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>icon</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>5</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Choose a name and directory for your wallet files.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="8" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
@ -113,20 +79,21 @@
</property>
</spacer>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="check_defaultWalletDirectory">
<property name="text">
<string>Set as default wallet directory</string>
</property>
</widget>
</item>
</layout>
<zorder>label_9</zorder>
<zorder>label</zorder>
<zorder>line_walletName</zorder>
<zorder>frame</zorder>
<zorder>check_defaultWalletDirectory</zorder>
<zorder>frame_wallet</zorder>
</widget>
<customwidgets>
<customwidget>
<class>InfoFrame</class>
<extends>QFrame</extends>
<header>components.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>line_walletName</tabstop>
<tabstop>line_walletDir</tabstop>

View file

@ -4,14 +4,15 @@
#include "WalletWizard.h"
#include "PageWalletSeed.h"
#include "ui_PageWalletSeed.h"
#include "constants.h"
#include "Seed.h"
#include <QMessageBox>
#include <QLineEdit>
#include <QCheckBox>
#include <QDialogButtonBox>
#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);

View file

@ -15,192 +15,20 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QFrame" name="frame">
<widget class="InfoFrame" name="frame_notice">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_12">
<item>
<widget class="QLabel" name="seedIcon">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>icon</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>5</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Store your &lt;span style=&quot; font-weight:600;&quot;&gt;16-word&lt;/span&gt; seed in a safe location.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>This seed will allow you to recover your wallet in case of computer failure.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="frame_18">
<widget class="InfoFrame" name="frame_invalidSeed">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_20">
<item>
<widget class="QLabel" name="newSeedWarningIcon">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>icon</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>5</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_9">
<item>
<widget class="QLabel" name="label_14">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Feather uses &lt;span style=&quot; font-weight:600;&quot;&gt;Polyseed&lt;/span&gt;. For more information click &lt;span style=&quot; font-weight:700;&quot;&gt;Help&lt;/span&gt;.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="frame_invalidSeed">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_17">
<item>
<widget class="QLabel" name="warningIcon">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>icon</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>5</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>Feather was unable to generate a valid seed.</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_8">
<property name="text">
<string>This should never happen.</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_10">
<property name="text">
<string>Please contact the developers immediately.</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
@ -933,6 +761,14 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>InfoFrame</class>
<extends>QFrame</extends>
<header>components.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>