Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make '-min' minimize wallet loading dialog #749

Merged
merged 1 commit into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/qt/bitcoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,18 +407,21 @@ void BitcoinApplication::initializeResult(bool success, interfaces::BlockAndHead
qInfo() << "Platform customization:" << platformStyle->getName();
clientModel = new ClientModel(node(), optionsModel);
window->setClientModel(clientModel, &tip_info);

// If '-min' option passed, start window minimized (iconified) or minimized to tray
bool start_minimized = gArgs.GetBoolArg("-min", false);
#ifdef ENABLE_WALLET
if (WalletModel::isWalletEnabled()) {
m_wallet_controller = new WalletController(*clientModel, platformStyle, this);
window->setWalletController(m_wallet_controller);
window->setWalletController(m_wallet_controller, /*show_loading_minimized=*/start_minimized);
if (paymentServer) {
paymentServer->setOptionsModel(optionsModel);
}
}
#endif // ENABLE_WALLET

// If -min option passed, start window minimized (iconified) or minimized to tray
if (!gArgs.GetBoolArg("-min", false)) {
// Show or minimize window
if (!start_minimized) {
window->show();
} else if (clientModel->getOptionsModel()->getMinimizeToTray() && window->hasTrayIcon()) {
// do nothing as the window is managed by the tray icon
Expand Down
4 changes: 2 additions & 2 deletions src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ void BitcoinGUI::enableHistoryAction(bool privacy)
if (historyAction->isChecked()) gotoOverviewPage();
}

void BitcoinGUI::setWalletController(WalletController* wallet_controller)
void BitcoinGUI::setWalletController(WalletController* wallet_controller, bool show_loading_minimized)
{
assert(!m_wallet_controller);
assert(wallet_controller);
Expand All @@ -699,7 +699,7 @@ void BitcoinGUI::setWalletController(WalletController* wallet_controller)
});

auto activity = new LoadWalletsActivity(m_wallet_controller, this);
activity->load();
activity->load(show_loading_minimized);
}

WalletController* BitcoinGUI::getWalletController()
Expand Down
2 changes: 1 addition & 1 deletion src/qt/bitcoingui.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class BitcoinGUI : public QMainWindow
*/
void setClientModel(ClientModel *clientModel = nullptr, interfaces::BlockAndHeaderTipInfo* tip_info = nullptr);
#ifdef ENABLE_WALLET
void setWalletController(WalletController* wallet_controller);
void setWalletController(WalletController* wallet_controller, bool show_loading_minimized);
WalletController* getWalletController();
#endif

Expand Down
9 changes: 6 additions & 3 deletions src/qt/walletcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ WalletControllerActivity::WalletControllerActivity(WalletController* wallet_cont
connect(this, &WalletControllerActivity::finished, this, &QObject::deleteLater);
}

void WalletControllerActivity::showProgressDialog(const QString& title_text, const QString& label_text)
void WalletControllerActivity::showProgressDialog(const QString& title_text, const QString& label_text, bool show_minimized)
{
auto progress_dialog = new QProgressDialog(m_parent_widget);
progress_dialog->setAttribute(Qt::WA_DeleteOnClose);
Expand All @@ -206,6 +206,8 @@ void WalletControllerActivity::showProgressDialog(const QString& title_text, con
// The setValue call forces QProgressDialog to start the internal duration estimation.
// See details in https://bugreports.qt.io/browse/QTBUG-47042.
progress_dialog->setValue(0);
// When requested, launch dialog minimized
if (show_minimized) progress_dialog->showMinimized();
}

CreateWalletActivity::CreateWalletActivity(WalletController* wallet_controller, QWidget* parent_widget)
Expand Down Expand Up @@ -368,14 +370,15 @@ LoadWalletsActivity::LoadWalletsActivity(WalletController* wallet_controller, QW
{
}

void LoadWalletsActivity::load()
void LoadWalletsActivity::load(bool show_loading_minimized)
{
showProgressDialog(
//: Title of progress window which is displayed when wallets are being loaded.
tr("Load Wallets"),
/*: Descriptive text of the load wallets progress window which indicates to
the user that wallets are currently being loaded.*/
tr("Loading wallets…"));
tr("Loading wallets…"),
/*show_minimized=*/show_loading_minimized);

QTimer::singleShot(0, worker(), [this] {
for (auto& wallet : node().walletLoader().getWallets()) {
Expand Down
4 changes: 2 additions & 2 deletions src/qt/walletcontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class WalletControllerActivity : public QObject
interfaces::Node& node() const { return m_wallet_controller->m_node; }
QObject* worker() const { return m_wallet_controller->m_activity_worker; }

void showProgressDialog(const QString& title_text, const QString& label_text);
void showProgressDialog(const QString& title_text, const QString& label_text, bool show_minimized=false);

WalletController* const m_wallet_controller;
QWidget* const m_parent_widget;
Expand Down Expand Up @@ -156,7 +156,7 @@ class LoadWalletsActivity : public WalletControllerActivity
public:
LoadWalletsActivity(WalletController* wallet_controller, QWidget* parent_widget);

void load();
void load(bool show_loading_minimized);
};

class RestoreWalletActivity : public WalletControllerActivity
Expand Down