mirror of
https://git.wownero.com/wowlet/wowlet.git
synced 2024-08-15 01:03:14 +00:00
Merge pull request 'Settings: allow changing default wallet directory' (#261) from tobtoht/feather:wizard_reset_restore_page into master
Reviewed-on: https://git.wownero.com/feather/feather/pulls/261
This commit is contained in:
commit
d8625fdb29
13 changed files with 135 additions and 32 deletions
|
@ -80,13 +80,19 @@ AppContext::AppContext(QCommandLineParser *cmdargs) {
|
||||||
this->accountName = Utils::getUnixAccountName();
|
this->accountName = Utils::getUnixAccountName();
|
||||||
this->homeDir = QDir::homePath();
|
this->homeDir = QDir::homePath();
|
||||||
|
|
||||||
|
QString walletDir = config()->get(Config::walletDirectory).toString();
|
||||||
|
if (walletDir.isEmpty()) {
|
||||||
#if defined(Q_OS_LINUX) or defined(Q_OS_MAC)
|
#if defined(Q_OS_LINUX) or defined(Q_OS_MAC)
|
||||||
this->defaultWalletDir = QString("%1/Monero/wallets").arg(this->configRoot);
|
this->defaultWalletDir = QString("%1/Monero/wallets").arg(this->configRoot);
|
||||||
this->defaultWalletDirRoot = QString("%1/Monero").arg(this->configRoot);
|
this->defaultWalletDirRoot = QString("%1/Monero").arg(this->configRoot);
|
||||||
#elif defined(Q_OS_WIN)
|
#elif defined(Q_OS_WIN)
|
||||||
this->defaultWalletDir = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation) + "/Monero";
|
this->defaultWalletDir = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation) + "/Monero";
|
||||||
this->defaultWalletDirRoot = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
|
this->defaultWalletDirRoot = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
|
||||||
#endif
|
#endif
|
||||||
|
} else {
|
||||||
|
this->defaultWalletDir = walletDir;
|
||||||
|
this->defaultWalletDirRoot = walletDir;
|
||||||
|
}
|
||||||
|
|
||||||
// Create wallet dirs
|
// Create wallet dirs
|
||||||
if (!QDir().mkpath(defaultWalletDir))
|
if (!QDir().mkpath(defaultWalletDir))
|
||||||
|
|
|
@ -522,6 +522,7 @@ void MainWindow::initWidgets() {
|
||||||
WalletWizard *MainWindow::createWizard(WalletWizard::Page startPage){
|
WalletWizard *MainWindow::createWizard(WalletWizard::Page startPage){
|
||||||
auto *wizard = new WalletWizard(m_ctx, startPage, this);
|
auto *wizard = new WalletWizard(m_ctx, startPage, this);
|
||||||
connect(wizard, &WalletWizard::openWallet, m_ctx, &AppContext::onOpenWallet);
|
connect(wizard, &WalletWizard::openWallet, m_ctx, &AppContext::onOpenWallet);
|
||||||
|
connect(wizard, &WalletWizard::defaultWalletDirChanged, m_windowSettings, &Settings::updatePaths);
|
||||||
return wizard;
|
return wizard;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -177,7 +177,6 @@ private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
Settings *m_windowSettings = nullptr;
|
Settings *m_windowSettings = nullptr;
|
||||||
CalcWindow *m_windowCalc = nullptr;
|
CalcWindow *m_windowCalc = nullptr;
|
||||||
SignVerifyDialog *m_windowSignVerify = nullptr;
|
|
||||||
RestoreDialog *m_restoreDialog = nullptr;
|
RestoreDialog *m_restoreDialog = nullptr;
|
||||||
AboutDialog *m_aboutDialog = nullptr;
|
AboutDialog *m_aboutDialog = nullptr;
|
||||||
XMRigWidget *m_xmrig = nullptr;
|
XMRigWidget *m_xmrig = nullptr;
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
#include "utils/config.h"
|
#include "utils/config.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
||||||
|
#include <QFileDialog>
|
||||||
|
|
||||||
Settings::Settings(QWidget *parent) :
|
Settings::Settings(QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
ui(new Ui::Settings)
|
ui(new Ui::Settings)
|
||||||
|
@ -58,16 +60,26 @@ Settings::Settings(QWidget *parent) :
|
||||||
|
|
||||||
connect(ui->comboBox_fiatCurrency, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &Settings::fiatCurrencySelected);
|
connect(ui->comboBox_fiatCurrency, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &Settings::fiatCurrencySelected);
|
||||||
|
|
||||||
// setup path tab
|
// setup paths tab
|
||||||
#if defined(Q_OS_LINUX)
|
this->updatePaths();
|
||||||
ui->textEditPaths->appendPlainText(m_ctx->applicationPath);
|
connect(ui->btn_browseDefaultWalletDir, &QPushButton::clicked, [this]{
|
||||||
#endif
|
QString walletDir = QFileDialog::getExistingDirectory(this, "Select wallet directory ", m_ctx->defaultWalletDir, QFileDialog::ShowDirsOnly);
|
||||||
ui->textEditPaths->appendPlainText(m_ctx->configDirectory);
|
if (walletDir.isEmpty()) return;
|
||||||
ui->textEditPaths->appendPlainText(m_ctx->defaultWalletDir);
|
m_ctx->defaultWalletDir = walletDir;
|
||||||
|
m_ctx->defaultWalletDirRoot = walletDir;
|
||||||
|
config()->set(Config::walletDirectory, walletDir);
|
||||||
|
ui->lineEdit_defaultWalletDir->setText(m_ctx->defaultWalletDir);
|
||||||
|
});
|
||||||
|
|
||||||
this->adjustSize();
|
this->adjustSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Settings::updatePaths() {
|
||||||
|
ui->lineEdit_defaultWalletDir->setText(m_ctx->defaultWalletDir);
|
||||||
|
ui->lineEdit_configDir->setText(m_ctx->configDirectory);
|
||||||
|
ui->lineEdit_applicationDir->setText(m_ctx->applicationPath);
|
||||||
|
}
|
||||||
|
|
||||||
void Settings::fiatCurrencySelected(int index) {
|
void Settings::fiatCurrencySelected(int index) {
|
||||||
QString selection = ui->comboBox_fiatCurrency->itemText(index);
|
QString selection = ui->comboBox_fiatCurrency->itemText(index);
|
||||||
config()->set(Config::preferredFiatCurrency, selection);
|
config()->set(Config::preferredFiatCurrency, selection);
|
||||||
|
|
|
@ -31,6 +31,7 @@ signals:
|
||||||
void blockExplorerChanged(QString blockExplorer);
|
void blockExplorerChanged(QString blockExplorer);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
void updatePaths();
|
||||||
void copyToClipboard();
|
void copyToClipboard();
|
||||||
void checkboxExternalLinkWarn();
|
void checkboxExternalLinkWarn();
|
||||||
void fiatCurrencySelected(int index);
|
void fiatCurrencySelected(int index);
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>1019</width>
|
<width>1123</width>
|
||||||
<height>336</height>
|
<height>555</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -282,11 +282,74 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPlainTextEdit" name="textEditPaths">
|
<layout class="QFormLayout" name="formLayout_2">
|
||||||
<property name="readOnly">
|
<item row="0" column="1">
|
||||||
<bool>true</bool>
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="lineEdit_defaultWalletDir">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btn_browseDefaultWalletDir">
|
||||||
|
<property name="text">
|
||||||
|
<string>Browse</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>Wallet directory:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label_4">
|
||||||
|
<property name="text">
|
||||||
|
<string>Config directory:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QLineEdit" name="lineEdit_configDir">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="label_5">
|
||||||
|
<property name="text">
|
||||||
|
<string>Application directory:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QLineEdit" name="lineEdit_applicationDir">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
|
|
@ -46,19 +46,11 @@ int WalletKeysFiles::networkType() const {
|
||||||
return m_networkType;
|
return m_networkType;
|
||||||
}
|
}
|
||||||
|
|
||||||
WalletKeysFilesModel::WalletKeysFilesModel(AppContext *ctx, QObject *parent) :
|
WalletKeysFilesModel::WalletKeysFilesModel(AppContext *ctx, QObject *parent)
|
||||||
QAbstractTableModel(parent),
|
: QAbstractTableModel(parent)
|
||||||
m_ctx(ctx) {
|
, m_ctx(ctx)
|
||||||
this->walletDirectories << m_ctx->defaultWalletDirRoot;
|
{
|
||||||
auto walletPath = config()->get(Config::walletPath).toString();
|
this->updateDirectories();
|
||||||
if(!walletPath.isEmpty() && Utils::fileExists(walletPath)) {
|
|
||||||
QDir d = QFileInfo(walletPath).absoluteDir();
|
|
||||||
this->walletDirectories << d.absolutePath();
|
|
||||||
}
|
|
||||||
|
|
||||||
this->walletDirectories << m_ctx->homeDir;
|
|
||||||
this->walletDirectories.removeDuplicates();
|
|
||||||
|
|
||||||
this->m_walletKeysFilesItemModel = qobject_cast<QAbstractItemModel *>(this);
|
this->m_walletKeysFilesItemModel = qobject_cast<QAbstractItemModel *>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,6 +63,20 @@ void WalletKeysFilesModel::clear() {
|
||||||
void WalletKeysFilesModel::refresh() {
|
void WalletKeysFilesModel::refresh() {
|
||||||
this->clear();
|
this->clear();
|
||||||
this->findWallets();
|
this->findWallets();
|
||||||
|
endResetModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
void WalletKeysFilesModel::updateDirectories() {
|
||||||
|
this->walletDirectories.clear();
|
||||||
|
this->walletDirectories << m_ctx->defaultWalletDirRoot;
|
||||||
|
auto walletPath = config()->get(Config::walletPath).toString();
|
||||||
|
if(!walletPath.isEmpty() && Utils::fileExists(walletPath)) {
|
||||||
|
QDir d = QFileInfo(walletPath).absoluteDir();
|
||||||
|
this->walletDirectories << d.absolutePath();
|
||||||
|
}
|
||||||
|
|
||||||
|
this->walletDirectories << m_ctx->homeDir;
|
||||||
|
this->walletDirectories.removeDuplicates();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WalletKeysFilesModel::findWallets() {
|
void WalletKeysFilesModel::findWallets() {
|
||||||
|
|
|
@ -54,6 +54,8 @@ public:
|
||||||
QStringList walletDirectories;
|
QStringList walletDirectories;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void updateDirectories();
|
||||||
|
|
||||||
AppContext *m_ctx;
|
AppContext *m_ctx;
|
||||||
QList<WalletKeysFiles> m_walletKeyFiles;
|
QList<WalletKeysFiles> m_walletKeyFiles;
|
||||||
QAbstractItemModel *m_walletKeysFilesItemModel;
|
QAbstractItemModel *m_walletKeysFilesItemModel;
|
||||||
|
|
|
@ -34,7 +34,11 @@ CreateWalletPage::CreateWalletPage(AppContext *ctx, QWidget *parent) :
|
||||||
connect(ui->btnChange, &QPushButton::clicked, [=] {
|
connect(ui->btnChange, &QPushButton::clicked, [=] {
|
||||||
QString walletDir = QFileDialog::getExistingDirectory(this, "Select wallet directory ", m_ctx->defaultWalletDir, QFileDialog::ShowDirsOnly);
|
QString walletDir = QFileDialog::getExistingDirectory(this, "Select wallet directory ", m_ctx->defaultWalletDir, QFileDialog::ShowDirsOnly);
|
||||||
if(walletDir.isEmpty()) return;
|
if(walletDir.isEmpty()) return;
|
||||||
|
m_ctx->defaultWalletDir = walletDir;
|
||||||
|
m_ctx->defaultWalletDirRoot = walletDir;
|
||||||
ui->directory->setText(walletDir);
|
ui->directory->setText(walletDir);
|
||||||
|
config()->set(Config::walletDirectory, walletDir);
|
||||||
|
emit defaultWalletDirChanged(walletDir);
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(ui->directory, &QLineEdit::textChanged, [=](const QString &data) {
|
connect(ui->directory, &QLineEdit::textChanged, [=](const QString &data) {
|
||||||
|
@ -47,6 +51,10 @@ CreateWalletPage::CreateWalletPage(AppContext *ctx, QWidget *parent) :
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CreateWalletPage::initializePage() {
|
||||||
|
ui->directory->setText(m_ctx->defaultWalletDir);
|
||||||
|
}
|
||||||
|
|
||||||
bool CreateWalletPage::validateWidgets(){
|
bool CreateWalletPage::validateWidgets(){
|
||||||
ui->walletName->setStyleSheet("");
|
ui->walletName->setStyleSheet("");
|
||||||
ui->directory->setStyleSheet("");
|
ui->directory->setStyleSheet("");
|
||||||
|
|
|
@ -20,15 +20,16 @@ class CreateWalletPage : public QWizardPage
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CreateWalletPage(AppContext *ctx, QWidget *parent = nullptr);
|
explicit CreateWalletPage(AppContext *ctx, QWidget *parent = nullptr);
|
||||||
|
void initializePage() override;
|
||||||
bool validatePage() override;
|
bool validatePage() override;
|
||||||
int nextId() const override;
|
int nextId() const override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void createWallet();
|
void createWallet();
|
||||||
|
void defaultWalletDirChanged(QString walletDir);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AppContext *m_ctx;
|
AppContext *m_ctx;
|
||||||
QLabel *topLabel;
|
|
||||||
Ui::CreateWalletPage *ui;
|
Ui::CreateWalletPage *ui;
|
||||||
QString m_walletDir;
|
QString m_walletDir;
|
||||||
bool validateWidgets();
|
bool validateWidgets();
|
||||||
|
|
|
@ -23,7 +23,6 @@ public:
|
||||||
explicit CreateWalletSeedPage(AppContext *ctx, QWidget *parent = nullptr);
|
explicit CreateWalletSeedPage(AppContext *ctx, QWidget *parent = nullptr);
|
||||||
bool validatePage() override;
|
bool validatePage() override;
|
||||||
int nextId() const override;
|
int nextId() const override;
|
||||||
// bool isFinalPage() const;
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void displaySeed(const QString &seed);
|
void displaySeed(const QString &seed);
|
||||||
|
|
|
@ -54,6 +54,9 @@ WalletWizard::WalletWizard(AppContext *ctx, WalletWizard::Page startPage, QWidge
|
||||||
|
|
||||||
connect(createWalletSeed, &CreateWalletSeedPage::createWallet, this, &WalletWizard::createWallet);
|
connect(createWalletSeed, &CreateWalletSeedPage::createWallet, this, &WalletWizard::createWallet);
|
||||||
connect(createWallet, &CreateWalletPage::createWallet, this, &WalletWizard::createWallet);
|
connect(createWallet, &CreateWalletPage::createWallet, this, &WalletWizard::createWallet);
|
||||||
|
connect(createWallet, &CreateWalletPage::defaultWalletDirChanged, [this](const QString &walletDir){
|
||||||
|
emit defaultWalletDirChanged(walletDir);
|
||||||
|
});
|
||||||
|
|
||||||
connect(openWalletPage, &OpenWalletPage::openWallet, [=](const QString &path){
|
connect(openWalletPage, &OpenWalletPage::openWallet, [=](const QString &path){
|
||||||
const auto walletPasswd = this->field("walletPasswd").toString();
|
const auto walletPasswd = this->field("walletPasswd").toString();
|
||||||
|
|
|
@ -20,8 +20,10 @@ public:
|
||||||
enum Page { Page_Menu, Page_CreateWallet, Page_CreateWalletSeed, Page_OpenWallet, Page_Network, Page_Restore, Page_ViewOnly };
|
enum Page { Page_Menu, Page_CreateWallet, Page_CreateWalletSeed, Page_OpenWallet, Page_Network, Page_Restore, Page_ViewOnly };
|
||||||
|
|
||||||
explicit WalletWizard(AppContext *ctx, WalletWizard::Page startPage = WalletWizard::Page::Page_Menu, QWidget *parent = nullptr);
|
explicit WalletWizard(AppContext *ctx, WalletWizard::Page startPage = WalletWizard::Page::Page_Menu, QWidget *parent = nullptr);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void openWallet(QString path, QString password);
|
void openWallet(QString path, QString password);
|
||||||
|
void defaultWalletDirChanged(QString walletDir);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AppContext *m_ctx;
|
AppContext *m_ctx;
|
||||||
|
|
Loading…
Reference in a new issue