mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-19 13:27:35 +02:00
Merge 9013f23b0a into merged_master (Bitcoin PR bitcoin-core/gui#342)
This commit is contained in:
commit
1d0e457f41
3 changed files with 41 additions and 46 deletions
|
|
@ -41,10 +41,6 @@ WalletController::WalletController(ClientModel& client_model, const PlatformStyl
|
|||
getOrCreateWallet(std::move(wallet));
|
||||
});
|
||||
|
||||
for (std::unique_ptr<interfaces::Wallet>& wallet : m_node.walletClient().getWallets()) {
|
||||
getOrCreateWallet(std::move(wallet));
|
||||
}
|
||||
|
||||
m_activity_worker->moveToThread(m_activity_thread);
|
||||
m_activity_thread->start();
|
||||
QTimer::singleShot(0, m_activity_worker, []() {
|
||||
|
|
@ -61,12 +57,6 @@ WalletController::~WalletController()
|
|||
delete m_activity_worker;
|
||||
}
|
||||
|
||||
std::vector<WalletModel*> WalletController::getOpenWallets() const
|
||||
{
|
||||
QMutexLocker locker(&m_mutex);
|
||||
return m_wallets;
|
||||
}
|
||||
|
||||
std::map<std::string, bool> WalletController::listWalletDir() const
|
||||
{
|
||||
QMutexLocker locker(&m_mutex);
|
||||
|
|
@ -192,33 +182,23 @@ WalletControllerActivity::WalletControllerActivity(WalletController* wallet_cont
|
|||
, m_wallet_controller(wallet_controller)
|
||||
, m_parent_widget(parent_widget)
|
||||
{
|
||||
}
|
||||
|
||||
WalletControllerActivity::~WalletControllerActivity()
|
||||
{
|
||||
delete m_progress_dialog;
|
||||
connect(this, &WalletControllerActivity::finished, this, &QObject::deleteLater);
|
||||
}
|
||||
|
||||
void WalletControllerActivity::showProgressDialog(const QString& label_text)
|
||||
{
|
||||
assert(!m_progress_dialog);
|
||||
m_progress_dialog = new QProgressDialog(m_parent_widget);
|
||||
auto progress_dialog = new QProgressDialog(m_parent_widget);
|
||||
progress_dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||
connect(this, &WalletControllerActivity::finished, progress_dialog, &QWidget::close);
|
||||
|
||||
m_progress_dialog->setLabelText(label_text);
|
||||
m_progress_dialog->setRange(0, 0);
|
||||
m_progress_dialog->setCancelButton(nullptr);
|
||||
m_progress_dialog->setWindowModality(Qt::ApplicationModal);
|
||||
GUIUtil::PolishProgressDialog(m_progress_dialog);
|
||||
progress_dialog->setLabelText(label_text);
|
||||
progress_dialog->setRange(0, 0);
|
||||
progress_dialog->setCancelButton(nullptr);
|
||||
progress_dialog->setWindowModality(Qt::ApplicationModal);
|
||||
GUIUtil::PolishProgressDialog(progress_dialog);
|
||||
// The setValue call forces QProgressDialog to start the internal duration estimation.
|
||||
// See details in https://bugreports.qt.io/browse/QTBUG-47042.
|
||||
m_progress_dialog->setValue(0);
|
||||
}
|
||||
|
||||
void WalletControllerActivity::destroyProgressDialog()
|
||||
{
|
||||
assert(m_progress_dialog);
|
||||
delete m_progress_dialog;
|
||||
m_progress_dialog = nullptr;
|
||||
progress_dialog->setValue(0);
|
||||
}
|
||||
|
||||
CreateWalletActivity::CreateWalletActivity(WalletController* wallet_controller, QWidget* parent_widget)
|
||||
|
|
@ -280,8 +260,6 @@ void CreateWalletActivity::createWallet()
|
|||
|
||||
void CreateWalletActivity::finish()
|
||||
{
|
||||
destroyProgressDialog();
|
||||
|
||||
if (!m_error_message.empty()) {
|
||||
QMessageBox::critical(m_parent_widget, tr("Create wallet failed"), QString::fromStdString(m_error_message.translated));
|
||||
} else if (!m_warning_message.empty()) {
|
||||
|
|
@ -330,8 +308,6 @@ OpenWalletActivity::OpenWalletActivity(WalletController* wallet_controller, QWid
|
|||
|
||||
void OpenWalletActivity::finish()
|
||||
{
|
||||
destroyProgressDialog();
|
||||
|
||||
if (!m_error_message.empty()) {
|
||||
QMessageBox::critical(m_parent_widget, tr("Open wallet failed"), QString::fromStdString(m_error_message.translated));
|
||||
} else if (!m_warning_message.empty()) {
|
||||
|
|
@ -357,3 +333,21 @@ void OpenWalletActivity::open(const std::string& path)
|
|||
QTimer::singleShot(0, this, &OpenWalletActivity::finish);
|
||||
});
|
||||
}
|
||||
|
||||
LoadWalletsActivity::LoadWalletsActivity(WalletController* wallet_controller, QWidget* parent_widget)
|
||||
: WalletControllerActivity(wallet_controller, parent_widget)
|
||||
{
|
||||
}
|
||||
|
||||
void LoadWalletsActivity::load()
|
||||
{
|
||||
showProgressDialog(tr("Loading wallets…"));
|
||||
|
||||
QTimer::singleShot(0, worker(), [this] {
|
||||
for (auto& wallet : node().walletClient().getWallets()) {
|
||||
m_wallet_controller->getOrCreateWallet(std::move(wallet));
|
||||
}
|
||||
|
||||
QTimer::singleShot(0, this, [this] { Q_EMIT finished(); });
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue