Skip to content
Open
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
34 changes: 34 additions & 0 deletions src/qt/test/wallettests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,37 @@ struct MiniGUI {

};

void TestCloseTransactionDialogs(TransactionView& transactionView, const Txid& txid)
{
// Select a transaction row in the view.
QTableView* table = transactionView.findChild<QTableView*>("transactionView");
QModelIndex index = FindTx(*table->selectionModel()->model(), txid);
QVERIFY2(index.isValid(), "Could not find txid for dialog test");
table->selectionModel()->select(index, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);

// Open the transaction details dialog.
bool invoked = QMetaObject::invokeMethod(&transactionView, "showDetails");
QVERIFY(invoked);

// Verify a TransactionDescDialog is now open.
int open_count = 0;
for (QWidget* widget : QApplication::topLevelWidgets()) {
if (widget->inherits("TransactionDescDialog")) ++open_count;
}
QCOMPARE(open_count, 1);

// Simulate wallet switch: close open dialogs.
transactionView.closeOpenedDialogs();
qApp->processEvents();

// Verify the dialog is gone.
int closed_count = 0;
for (QWidget* widget : QApplication::topLevelWidgets()) {
if (widget->inherits("TransactionDescDialog")) ++closed_count;
}
QCOMPARE(closed_count, 0);
}

//! Simple qt wallet tests.
//
// Test widgets can be debugged interactively calling show() on them and
Expand Down Expand Up @@ -293,6 +324,9 @@ void TestGUI(interfaces::Node& node, const std::shared_ptr<CWallet>& wallet)
BumpFee(transactionView, txid2, /*expectDisabled=*/false, /*expectError=*/{}, /*cancel=*/false);
BumpFee(transactionView, txid2, /*expectDisabled=*/true, /*expectError=*/"already bumped", /*cancel=*/false);

// Verify transaction detail dialogs are closed when the wallet view is hidden (e.g. on wallet switch).
TestCloseTransactionDialogs(transactionView, txid1);

// Check current balance on OverviewPage
OverviewPage overviewPage(platformStyle.get());
overviewPage.setWalletModel(&walletModel);
Expand Down
1 change: 1 addition & 0 deletions src/qt/walletframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ void WalletFrame::setCurrentWallet(WalletModel* wallet_model)
QSizePolicy sp = view_about_to_hide->sizePolicy();
sp.setHorizontalPolicy(QSizePolicy::Ignored);
view_about_to_hide->setSizePolicy(sp);
view_about_to_hide->closeTransactionDialogs();
}

WalletView *walletView = mapWalletViews.value(wallet_model);
Expand Down
5 changes: 5 additions & 0 deletions src/qt/walletview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,3 +284,8 @@ void WalletView::disableTransactionView(bool disable)
{
transactionView->setDisabled(disable);
}

void WalletView::closeTransactionDialogs()
{
transactionView->closeOpenedDialogs();
}
3 changes: 3 additions & 0 deletions src/qt/walletview.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ public Q_SLOTS:
/** Show progress dialog e.g. for rescan */
void showProgress(const QString &title, int nProgress);

/** Close all open transaction detail dialogs for this wallet view. */
void closeTransactionDialogs();

private Q_SLOTS:
void disableTransactionView(bool disable);

Expand Down
Loading