diff --git a/src/wizard/menu.cpp b/src/wizard/menu.cpp
index 89a5556..339fda5 100644
--- a/src/wizard/menu.cpp
+++ b/src/wizard/menu.cpp
@@ -11,13 +11,22 @@
#include "libwalletqt/WalletManager.h"
-MenuPage::MenuPage(AppContext *ctx, QWidget *parent) :
- QWizardPage(parent),
- ui(new Ui::MenuPage),
- m_ctx(ctx) {
+MenuPage::MenuPage(AppContext *ctx, WalletKeysFilesModel *wallets, QWidget *parent)
+ : QWizardPage(parent)
+ , ui(new Ui::MenuPage)
+ , m_ctx(ctx)
+ , m_walletKeysFilesModel(wallets)
+{
ui->setupUi(this);
this->setButtonText(QWizard::FinishButton, "Open recent wallet");
- ui->radioCreate->setChecked(true);
+}
+
+void MenuPage::initializePage() {
+ if (m_walletKeysFilesModel->rowCount() > 0) {
+ ui->radioOpen->setChecked(true);
+ } else {
+ ui->radioCreate->setChecked(true);
+ }
}
int MenuPage::nextId() const {
diff --git a/src/wizard/menu.h b/src/wizard/menu.h
index 3b1c7bb..2fb24a2 100644
--- a/src/wizard/menu.h
+++ b/src/wizard/menu.h
@@ -19,13 +19,14 @@ class MenuPage : public QWizardPage
Q_OBJECT
public:
- explicit MenuPage(AppContext *ctx, QWidget *parent = nullptr);
+ explicit MenuPage(AppContext *ctx, WalletKeysFilesModel *wallets, QWidget *parent = nullptr);
+ void initializePage() override;
bool validatePage() override;
int nextId() const override;
private:
AppContext *m_ctx;
- QLabel *topLabel;
+ WalletKeysFilesModel *m_walletKeysFilesModel;
Ui::MenuPage *ui;
};
diff --git a/src/wizard/menu.ui b/src/wizard/menu.ui
index c022518..a45d1ee 100644
--- a/src/wizard/menu.ui
+++ b/src/wizard/menu.ui
@@ -6,8 +6,8 @@
0
0
- 424
- 245
+ 617
+ 463
@@ -29,6 +29,9 @@
-
+
+ Qt::ClickFocus
+
Create new wallet
@@ -36,6 +39,9 @@
-
+
+ Qt::ClickFocus
+
Open wallet file
@@ -43,6 +49,9 @@
-
+
+ Qt::ClickFocus
+
Restore wallet from seed
@@ -50,6 +59,9 @@
-
+
+ Qt::ClickFocus
+
Import from keys
diff --git a/src/wizard/openwallet.cpp b/src/wizard/openwallet.cpp
index 6ecab7a..74facc6 100644
--- a/src/wizard/openwallet.cpp
+++ b/src/wizard/openwallet.cpp
@@ -10,12 +10,12 @@
#include
#include
-// @TODO: rescan wallet dir on wizard open
-
-OpenWalletPage::OpenWalletPage(AppContext *ctx, QWidget *parent) :
- QWizardPage(parent),
- ui(new Ui::OpenWalletPage),
- m_ctx(ctx) {
+OpenWalletPage::OpenWalletPage(AppContext *ctx, WalletKeysFilesModel *wallets, QWidget *parent)
+ : QWizardPage(parent)
+ , ui(new Ui::OpenWalletPage)
+ , m_ctx(ctx)
+ , m_walletKeysFilesModel(wallets)
+{
ui->setupUi(this);
connect(ui->btnBrowse, &QPushButton::clicked, [=]{
@@ -46,11 +46,8 @@ OpenWalletPage::OpenWalletPage(AppContext *ctx, QWidget *parent) :
ui->walletTable->setSelectionBehavior(QAbstractItemView::SelectRows);
ui->walletTable->setContextMenuPolicy(Qt::CustomContextMenu);
- this->walletKeysFilesModel = new WalletKeysFilesModel(m_ctx);
- this->walletKeysFilesModel->refresh();
-
m_keysProxy = new WalletKeysFilesProxyModel(this, m_ctx->networkType);
- m_keysProxy->setSourceModel(this->walletKeysFilesModel);
+ m_keysProxy->setSourceModel(m_walletKeysFilesModel);
m_keysProxy->setSortRole(Qt::UserRole);
ui->walletTable->setModel(m_keysProxy);
@@ -67,6 +64,10 @@ OpenWalletPage::OpenWalletPage(AppContext *ctx, QWidget *parent) :
});
}
+void OpenWalletPage::initializePage() {
+ m_walletKeysFilesModel->refresh();
+}
+
void OpenWalletPage::updatePath() {
QModelIndex index = ui->walletTable->currentIndex();
if (!index.isValid()) {
diff --git a/src/wizard/openwallet.h b/src/wizard/openwallet.h
index 558dcf6..a6d0b78 100644
--- a/src/wizard/openwallet.h
+++ b/src/wizard/openwallet.h
@@ -20,7 +20,8 @@ class OpenWalletPage : public QWizardPage
Q_OBJECT
public:
- explicit OpenWalletPage(AppContext *ctx, QWidget *parent = nullptr);
+ explicit OpenWalletPage(AppContext *ctx, WalletKeysFilesModel *wallets, QWidget *parent = nullptr);
+ void initializePage() override;
bool validatePage() override;
int nextId() const override;
@@ -31,10 +32,8 @@ private:
void updatePath();
AppContext *m_ctx;
- WalletKeysFilesModel *walletKeysFilesModel;
+ WalletKeysFilesModel *m_walletKeysFilesModel;
WalletKeysFilesProxyModel *m_keysProxy;
- QSortFilterProxyModel *ll;
- QLabel *topLabel;
Ui::OpenWalletPage *ui;
QStandardItemModel *m_model;
};
diff --git a/src/wizard/walletwizard.cpp b/src/wizard/walletwizard.cpp
index 01ce572..f20d3d3 100644
--- a/src/wizard/walletwizard.cpp
+++ b/src/wizard/walletwizard.cpp
@@ -18,14 +18,20 @@
#include
#include
-WalletWizard::WalletWizard(AppContext *ctx, WalletWizard::Page startPage, QWidget *parent) : QWizard(parent),
- m_ctx(ctx) {
+WalletWizard::WalletWizard(AppContext *ctx, WalletWizard::Page startPage, QWidget *parent)
+ : QWizard(parent)
+ , m_ctx(ctx)
+{
this->setWindowTitle("Welcome to Feather Wallet");
this->setWindowIcon(QIcon(":/assets/images/appicons/64x64.png"));
- auto openWalletPage = new OpenWalletPage(m_ctx, this);
+
+ m_walletKeysFilesModel = new WalletKeysFilesModel(m_ctx, this);
+ m_walletKeysFilesModel->refresh();
+
+ auto openWalletPage = new OpenWalletPage(m_ctx, m_walletKeysFilesModel, this);
auto createWallet = new CreateWalletPage(m_ctx, this);
auto createWalletSeed = new CreateWalletSeedPage(m_ctx, this);
- setPage(Page_Menu, new MenuPage(m_ctx, this));
+ setPage(Page_Menu, new MenuPage(m_ctx, m_walletKeysFilesModel, this));
setPage(Page_CreateWallet, createWallet);
setPage(Page_OpenWallet, openWalletPage);
setPage(Page_CreateWalletSeed, createWalletSeed);
diff --git a/src/wizard/walletwizard.h b/src/wizard/walletwizard.h
index 589ac99..acffac5 100644
--- a/src/wizard/walletwizard.h
+++ b/src/wizard/walletwizard.h
@@ -25,6 +25,8 @@ signals:
private:
AppContext *m_ctx;
+ WalletKeysFilesModel *m_walletKeysFilesModel;
+
void createWallet();
};