mirror of
https://github.com/wownero/wowlet.git
synced 2026-11-26 01:54:21 +01:00
Allow opening multiple windows
This commit is contained in:
@@ -7,21 +7,21 @@
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
|
||||
PageOpenWallet::PageOpenWallet(AppContext *ctx, WalletKeysFilesModel *wallets, QWidget *parent)
|
||||
#include "constants.h"
|
||||
#include "WalletWizard.h"
|
||||
|
||||
PageOpenWallet::PageOpenWallet(WalletKeysFilesModel *wallets, QWidget *parent)
|
||||
: QWizardPage(parent)
|
||||
, ui(new Ui::PageOpenWallet)
|
||||
, m_ctx(ctx)
|
||||
, m_walletKeysFilesModel(wallets)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
connect(ui->btnBrowse, &QPushButton::clicked, [=]{
|
||||
// manually browsing for wallet
|
||||
auto walletPath = config()->get(Config::walletPath).toString();
|
||||
if (walletPath.isEmpty())
|
||||
walletPath = m_ctx->defaultWalletDir;
|
||||
QString path = QFileDialog::getOpenFileName(this, "Select your wallet file", walletPath, "Wallet file (*.keys)");
|
||||
if(path.isEmpty()) return;
|
||||
connect(ui->btnBrowse, &QPushButton::clicked, [this]{
|
||||
QString walletDir = config()->get(Config::walletDirectory).toString();
|
||||
QString path = QFileDialog::getOpenFileName(this, "Select your wallet file", walletDir, "Wallet file (*.keys)");
|
||||
if (path.isEmpty())
|
||||
return;
|
||||
|
||||
QFileInfo infoPath(path);
|
||||
if(!infoPath.isReadable()) {
|
||||
@@ -30,7 +30,7 @@ PageOpenWallet::PageOpenWallet(AppContext *ctx, WalletKeysFilesModel *wallets, Q
|
||||
}
|
||||
|
||||
if (ui->openOnStartup->isChecked())
|
||||
config()->set(Config::autoOpenWalletPath, QString("%1%2").arg(m_ctx->networkType).arg(path));
|
||||
config()->set(Config::autoOpenWalletPath, QString("%1%2").arg(constants::networkType).arg(path));
|
||||
|
||||
emit openWallet(path);
|
||||
});
|
||||
@@ -41,7 +41,7 @@ PageOpenWallet::PageOpenWallet(AppContext *ctx, WalletKeysFilesModel *wallets, Q
|
||||
ui->walletTable->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
ui->walletTable->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
|
||||
m_keysProxy = new WalletKeysFilesProxyModel(this, m_ctx->networkType);
|
||||
m_keysProxy = new WalletKeysFilesProxyModel(this, constants::networkType);
|
||||
m_keysProxy->setSourceModel(m_walletKeysFilesModel);
|
||||
m_keysProxy->setSortRole(Qt::UserRole);
|
||||
|
||||
@@ -57,7 +57,13 @@ PageOpenWallet::PageOpenWallet(AppContext *ctx, WalletKeysFilesModel *wallets, Q
|
||||
connect(ui->walletTable->selectionModel(), &QItemSelectionModel::currentRowChanged, [this](QModelIndex current, QModelIndex prev){
|
||||
this->updatePath();
|
||||
});
|
||||
connect(ui->walletTable, &QTreeView::doubleClicked, this, &PageOpenWallet::validatePage);
|
||||
connect(ui->walletTable, &QTreeView::doubleClicked, [this]{
|
||||
// Simulate next button click
|
||||
QWizard *wizard = this->wizard();
|
||||
if (wizard) {
|
||||
wizard->button(QWizard::FinishButton)->click();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void PageOpenWallet::initializePage() {
|
||||
@@ -87,7 +93,7 @@ bool PageOpenWallet::validatePage() {
|
||||
}
|
||||
QString walletPath = index.model()->data(index.siblingAtColumn(WalletKeysFilesModel::ModelColumns::Path), Qt::UserRole).toString();
|
||||
|
||||
auto autoWallet = ui->openOnStartup->isChecked() ? QString("%1%2").arg(m_ctx->networkType).arg(walletPath) : "";
|
||||
auto autoWallet = ui->openOnStartup->isChecked() ? QString("%1%2").arg(constants::networkType).arg(walletPath) : "";
|
||||
config()->set(Config::autoOpenWalletPath, autoWallet);
|
||||
|
||||
emit openWallet(walletPath);
|
||||
|
||||
Reference in New Issue
Block a user