Skip to content
Draft
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
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ include(CMakeDependentOption)
option(BUILD_BITCOIN_BIN "Build bitcoin executable." ON)
option(BUILD_DAEMON "Build bitcoind executable." ON)
option(BUILD_GUI "Build bitcoin-qt executable." OFF)
option(ENABLE_TEST_AUTOMATION "Enable test automation bridge for Qt widget UI testing." OFF)
option(BUILD_CLI "Build bitcoin-cli executable." ON)

option(BUILD_TESTS "Build test_bitcoin and other unit test executables." ON)
Expand Down Expand Up @@ -161,7 +162,7 @@ endif()
cmake_dependent_option(BUILD_GUI_TESTS "Build test_bitcoin-qt executable." ON "BUILD_GUI;BUILD_TESTS" OFF)
if(BUILD_GUI)
set(qt_components Core Gui Widgets LinguistTools)
if(ENABLE_WALLET)
if(ENABLE_WALLET OR ENABLE_TEST_AUTOMATION)
list(APPEND qt_components Network)
endif()
if(WITH_DBUS)
Expand Down
13 changes: 12 additions & 1 deletion src/qt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@ add_library(bitcoinqt STATIC EXCLUDE_FROM_ALL
${BITCOIN_QRC}
${BITCOIN_LOCALE_QRC}
)
if(ENABLE_TEST_AUTOMATION)
target_sources(bitcoinqt
PRIVATE
testbridge.cpp
testbridge.h
)
target_compile_definitions(bitcoinqt PUBLIC ENABLE_TEST_AUTOMATION)
endif()
target_compile_definitions(bitcoinqt
PUBLIC
QT_NO_KEYWORDS
Expand Down Expand Up @@ -223,10 +231,13 @@ if(ENABLE_WALLET)
target_link_libraries(bitcoinqt
PRIVATE
bitcoin_wallet
Qt6::Network
)
endif()

if(ENABLE_WALLET OR ENABLE_TEST_AUTOMATION)
target_link_libraries(bitcoinqt PRIVATE Qt6::Network)
endif()

if(WITH_DBUS)
target_link_libraries(bitcoinqt PRIVATE Qt6::DBus)
endif()
Expand Down
40 changes: 29 additions & 11 deletions src/qt/askpassphrasedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include <QKeyEvent>
#include <QMessageBox>
#include <QDialogButtonBox>
#include <QPushButton>

AskPassphraseDialog::AskPassphraseDialog(Mode _mode, QWidget *parent, SecureString* passphrase_out) :
Expand Down Expand Up @@ -59,6 +60,8 @@ AskPassphraseDialog::AskPassphraseDialog(Mode _mode, QWidget *parent, SecureStri
break;
}
textChanged();
ui->buttonBox->button(QDialogButtonBox::Ok)->setObjectName("passphraseOkButton");
ui->buttonBox->button(QDialogButtonBox::Cancel)->setObjectName("passphraseCancelButton");
connect(ui->toggleShowPasswordButton, &QPushButton::toggled, this, &AskPassphraseDialog::toggleShowPassword);
connect(ui->passEdit1, &QLineEdit::textChanged, this, &AskPassphraseDialog::textChanged);
connect(ui->passEdit2, &QLineEdit::textChanged, this, &AskPassphraseDialog::textChanged);
Expand Down Expand Up @@ -105,8 +108,11 @@ void AskPassphraseDialog::accept()
tr("Confirm wallet encryption"),
tr("Warning: If you encrypt your wallet and lose your passphrase, you will <b>LOSE ALL OF YOUR BITCOINS</b>!") + "<br><br>" + tr("Are you sure you wish to encrypt your wallet?"),
QMessageBox::Cancel | QMessageBox::Yes, this);
msgBoxConfirm.setObjectName("encryptWalletConfirmDialog");
msgBoxConfirm.button(QMessageBox::Yes)->setText(tr("Continue"));
msgBoxConfirm.button(QMessageBox::Cancel)->setText(tr("Back"));
msgBoxConfirm.button(QMessageBox::Yes)->setObjectName("encryptWalletContinueButton");
msgBoxConfirm.button(QMessageBox::Cancel)->setObjectName("encryptWalletBackButton");
msgBoxConfirm.setDefaultButton(QMessageBox::Cancel);
QMessageBox::StandardButton retval = (QMessageBox::StandardButton)msgBoxConfirm.exec();
if(retval == QMessageBox::Yes)
Expand All @@ -133,15 +139,21 @@ void AskPassphraseDialog::accept()
} else {
assert(model != nullptr);
if (model->setWalletEncrypted(newpass1)) {
QMessageBox::warning(this, tr("Wallet encrypted"),
"<qt>" +
tr("Your wallet is now encrypted. ") + encryption_reminder +
"<br><br><b>" +
tr("IMPORTANT: Any previous backups you have made of your wallet file "
"should be replaced with the newly generated, encrypted wallet file. "
"For security reasons, previous backups of the unencrypted wallet file "
"will become useless as soon as you start using the new, encrypted wallet.") +
"</b></qt>");
QMessageBox msgBoxEncrypted(QMessageBox::Warning,
tr("Wallet encrypted"),
"<qt>" +
tr("Your wallet is now encrypted. ") + encryption_reminder +
"<br><br><b>" +
tr("IMPORTANT: Any previous backups you have made of your wallet file "
"should be replaced with the newly generated, encrypted wallet file. "
"For security reasons, previous backups of the unencrypted wallet file "
"will become useless as soon as you start using the new, encrypted wallet.") +
"</b></qt>",
QMessageBox::Ok,
this);
msgBoxEncrypted.setObjectName("walletEncryptedDialog");
msgBoxEncrypted.button(QMessageBox::Ok)->setObjectName("walletEncryptedOkButton");
msgBoxEncrypted.exec();
} else {
QMessageBox::critical(this, tr("Wallet encryption failed"),
tr("Wallet encryption failed due to an internal error. Your wallet was not encrypted."));
Expand Down Expand Up @@ -191,8 +203,14 @@ void AskPassphraseDialog::accept()
{
if(model->changePassphrase(oldpass, newpass1))
{
QMessageBox::information(this, tr("Wallet encrypted"),
tr("Wallet passphrase was successfully changed."));
QMessageBox msgBoxChanged(QMessageBox::Information,
tr("Wallet encrypted"),
tr("Wallet passphrase was successfully changed."),
QMessageBox::Ok,
this);
msgBoxChanged.setObjectName("passphraseChangedDialog");
msgBoxChanged.button(QMessageBox::Ok)->setObjectName("passphraseChangedOkButton");
msgBoxChanged.exec();
QDialog::accept(); // Success
}
else
Expand Down
16 changes: 16 additions & 0 deletions src/qt/bitcoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
#include <qt/optionsmodel.h>
#include <qt/platformstyle.h>
#include <qt/splashscreen.h>
#ifdef ENABLE_TEST_AUTOMATION
#include <qt/testbridge.h>
#endif
#include <qt/utilitydialog.h>
#include <qt/winshutdownmonitor.h>
#include <uint256.h>
Expand Down Expand Up @@ -262,6 +265,16 @@ void BitcoinApplication::createWindow(const NetworkStyle *networkStyle)
window = new BitcoinGUI(node(), platformStyle, networkStyle, nullptr);
connect(window, &BitcoinGUI::quitRequested, this, &BitcoinApplication::requestShutdown);

#ifdef ENABLE_TEST_AUTOMATION
if (gArgs.IsArgSet("-test-automation")) {
QString socket_path = QString::fromStdString(gArgs.GetArg("-test-automation", ""));
if (socket_path.isEmpty()) {
socket_path = QString::fromStdString((gArgs.GetDataDirNet() / "test_bridge.sock").utf8string());
}
m_test_bridge = std::make_unique<TestBridge>(window, socket_path);
}
#endif

pollShutdownTimer = new QTimer(window);
connect(pollShutdownTimer, &QTimer::timeout, [this]{
if (!QApplication::activeModalWidget()) {
Expand Down Expand Up @@ -475,6 +488,9 @@ static void SetupUIArgs(ArgsManager& argsman)
argsman.AddArg("-resetguisettings", "Reset all settings changed in the GUI", ArgsManager::ALLOW_ANY, OptionsCategory::GUI);
argsman.AddArg("-splash", strprintf("Show splash screen on startup (default: %u)", DEFAULT_SPLASHSCREEN), ArgsManager::ALLOW_ANY, OptionsCategory::GUI);
argsman.AddArg("-uiplatform", strprintf("Select platform to customize UI for (one of windows, macosx, other; default: %s)", BitcoinGUI::DEFAULT_UIPLATFORM), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::GUI);
#ifdef ENABLE_TEST_AUTOMATION
argsman.AddArg("-test-automation=<path>", "Enable test automation bridge on the given local socket path", ArgsManager::ALLOW_ANY, OptionsCategory::GUI);
#endif
}

int GuiMain(int argc, char* argv[])
Expand Down
4 changes: 4 additions & 0 deletions src/qt/bitcoin.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class OptionsModel;
class PaymentServer;
class PlatformStyle;
class SplashScreen;
class TestBridge;
class WalletController;
class WalletModel;
namespace interfaces {
Expand Down Expand Up @@ -98,6 +99,9 @@ public Q_SLOTS:
#ifdef ENABLE_WALLET
PaymentServer* paymentServer{nullptr};
WalletController* m_wallet_controller{nullptr};
#endif
#ifdef ENABLE_TEST_AUTOMATION
std::unique_ptr<TestBridge> m_test_bridge;
#endif
const PlatformStyle* platformStyle{nullptr};
std::unique_ptr<QWidget> shutdownWindow;
Expand Down
16 changes: 16 additions & 0 deletions src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
platformStyle(_platformStyle),
m_network_style(networkStyle)
{
setObjectName("mainWindow");

QSettings settings;
if (!restoreGeometry(settings.value("MainWindowGeometry").toByteArray())) {
// Restore failed (perhaps missing setting), center the window
Expand All @@ -111,12 +113,15 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
updateWindowTitle();

rpcConsole = new RPCConsole(node, _platformStyle, nullptr);
rpcConsole->setObjectName("rpcConsole");
helpMessageDialog = new HelpMessageDialog(this, false);
helpMessageDialog->setObjectName("helpMessageDialog");
#ifdef ENABLE_WALLET
if(enableWallet)
{
/** Create wallet frame and make it the central widget */
walletFrame = new WalletFrame(_platformStyle, this);
walletFrame->setObjectName("walletFrame");
connect(walletFrame, &WalletFrame::createWalletButtonClicked, this, &BitcoinGUI::createWallet);
connect(walletFrame, &WalletFrame::message, [this](const QString& title, const QString& message, unsigned int style) {
this->message(title, message, style);
Expand Down Expand Up @@ -256,27 +261,31 @@ void BitcoinGUI::createActions()
connect(modalOverlay, &ModalOverlay::triggered, tabGroup, &QActionGroup::setEnabled);

overviewAction = new QAction(platformStyle->SingleColorIcon(":/icons/overview"), tr("&Overview"), this);
overviewAction->setObjectName("overviewAction");
overviewAction->setStatusTip(tr("Show general overview of wallet"));
overviewAction->setToolTip(overviewAction->statusTip());
overviewAction->setCheckable(true);
overviewAction->setShortcut(QKeySequence(QStringLiteral("Alt+1")));
tabGroup->addAction(overviewAction);

sendCoinsAction = new QAction(platformStyle->SingleColorIcon(":/icons/send"), tr("&Send"), this);
sendCoinsAction->setObjectName("sendCoinsAction");
sendCoinsAction->setStatusTip(tr("Send coins to a Bitcoin address"));
sendCoinsAction->setToolTip(sendCoinsAction->statusTip());
sendCoinsAction->setCheckable(true);
sendCoinsAction->setShortcut(QKeySequence(QStringLiteral("Alt+2")));
tabGroup->addAction(sendCoinsAction);

receiveCoinsAction = new QAction(platformStyle->SingleColorIcon(":/icons/receiving_addresses"), tr("&Receive"), this);
receiveCoinsAction->setObjectName("receiveCoinsAction");
receiveCoinsAction->setStatusTip(tr("Request payments (generates QR codes and bitcoin: URIs)"));
receiveCoinsAction->setToolTip(receiveCoinsAction->statusTip());
receiveCoinsAction->setCheckable(true);
receiveCoinsAction->setShortcut(QKeySequence(QStringLiteral("Alt+3")));
tabGroup->addAction(receiveCoinsAction);

historyAction = new QAction(platformStyle->SingleColorIcon(":/icons/history"), tr("&Transactions"), this);
historyAction->setObjectName("historyAction");
historyAction->setStatusTip(tr("Browse transaction history"));
historyAction->setToolTip(historyAction->statusTip());
historyAction->setCheckable(true);
Expand Down Expand Up @@ -311,14 +320,17 @@ void BitcoinGUI::createActions()
optionsAction->setStatusTip(tr("Modify configuration options for %1").arg(CLIENT_NAME));
optionsAction->setMenuRole(QAction::PreferencesRole);
optionsAction->setEnabled(false);
optionsAction->setObjectName("optionsAction");

encryptWalletAction = new QAction(tr("&Encrypt Wallet…"), this);
encryptWalletAction->setStatusTip(tr("Encrypt the private keys that belong to your wallet"));
encryptWalletAction->setCheckable(true);
encryptWalletAction->setObjectName("encryptWalletAction");
backupWalletAction = new QAction(tr("&Backup Wallet…"), this);
backupWalletAction->setStatusTip(tr("Backup wallet to another location"));
changePassphraseAction = new QAction(tr("&Change Passphrase…"), this);
changePassphraseAction->setStatusTip(tr("Change the passphrase used for wallet encryption"));
changePassphraseAction->setObjectName("changePassphraseAction");
signMessageAction = new QAction(tr("Sign &message…"), this);
signMessageAction->setStatusTip(tr("Sign messages with your Bitcoin addresses to prove you own them"));
verifyMessageAction = new QAction(tr("&Verify message…"), this);
Expand All @@ -345,14 +357,17 @@ void BitcoinGUI::createActions()
m_open_wallet_action = new QAction(tr("Open Wallet"), this);
m_open_wallet_action->setEnabled(false);
m_open_wallet_action->setStatusTip(tr("Open a wallet"));
m_open_wallet_action->setObjectName("openWalletAction");
m_open_wallet_menu = new QMenu(this);

m_close_wallet_action = new QAction(tr("Close Wallet…"), this);
m_close_wallet_action->setStatusTip(tr("Close wallet"));
m_close_wallet_action->setObjectName("closeWalletAction");

m_create_wallet_action = new QAction(tr("Create Wallet…"), this);
m_create_wallet_action->setEnabled(false);
m_create_wallet_action->setStatusTip(tr("Create a new wallet"));
m_create_wallet_action->setObjectName("createWalletAction");

//: Name of the menu item that restores wallet from a backup file.
m_restore_wallet_action = new QAction(tr("Restore Wallet…"), this);
Expand All @@ -376,6 +391,7 @@ void BitcoinGUI::createActions()
m_mask_values_action->setShortcut(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_M));
m_mask_values_action->setStatusTip(tr("Mask the values in the Overview tab"));
m_mask_values_action->setCheckable(true);
m_mask_values_action->setObjectName("maskValuesAction");

connect(quitAction, &QAction::triggered, this, &BitcoinGUI::quitRequested);
connect(aboutAction, &QAction::triggered, this, &BitcoinGUI::aboutClicked);
Expand Down
3 changes: 3 additions & 0 deletions src/qt/createwalletdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <qt/guiutil.h>

#include <QDialogButtonBox>
#include <QPushButton>

CreateWalletDialog::CreateWalletDialog(QWidget* parent) :
Expand All @@ -19,6 +20,8 @@ CreateWalletDialog::CreateWalletDialog(QWidget* parent) :
ui->setupUi(this);
ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Create"));
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
ui->buttonBox->button(QDialogButtonBox::Ok)->setObjectName("createWalletOkButton");
ui->buttonBox->button(QDialogButtonBox::Cancel)->setObjectName("createWalletCancelButton");
ui->wallet_name_line_edit->setFocus(Qt::ActiveWindowFocusReason);

connect(ui->wallet_name_line_edit, &QLineEdit::textEdited, [this](const QString& text) {
Expand Down
8 changes: 8 additions & 0 deletions src/qt/sendcoinsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,8 @@ void SendCoinsDialog::presentPSBT(PartiallySignedTransaction& psbtx)
msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard);
msgBox.setDefaultButton(QMessageBox::Discard);
msgBox.setObjectName("psbt_copied_message");
msgBox.button(QMessageBox::Save)->setObjectName("psbtSaveButton");
msgBox.button(QMessageBox::Discard)->setObjectName("psbtDiscardButton");
switch (msgBox.exec()) {
case QMessageBox::Save: {
QString selectedFilter;
Expand Down Expand Up @@ -589,6 +591,7 @@ void SendCoinsDialog::accept()
SendCoinsEntry *SendCoinsDialog::addEntry()
{
SendCoinsEntry *entry = new SendCoinsEntry(platformStyle, this);
entry->setObjectName(QStringLiteral("sendCoinsEntry_%1").arg(ui->entries->count()));
entry->setModel(model);
ui->entries->addWidget(entry);
connect(entry, &SendCoinsEntry::removeEntry, this, &SendCoinsDialog::removeEntry);
Expand Down Expand Up @@ -1055,6 +1058,7 @@ void SendCoinsDialog::coinControlUpdateLabels()
SendConfirmationDialog::SendConfirmationDialog(const QString& title, const QString& text, const QString& informative_text, const QString& detailed_text, int _secDelay, bool enable_send, bool always_show_unsigned, QWidget* parent)
: QMessageBox(parent), secDelay(_secDelay), m_enable_send(enable_send)
{
setObjectName("sendConfirmationDialog");
setIcon(QMessageBox::Question);
setWindowTitle(title); // On macOS, the window title is ignored (as required by the macOS Guidelines).
setText(text);
Expand All @@ -1064,10 +1068,14 @@ SendConfirmationDialog::SendConfirmationDialog(const QString& title, const QStri
if (always_show_unsigned || !enable_send) addButton(QMessageBox::Save);
setDefaultButton(QMessageBox::Cancel);
yesButton = button(QMessageBox::Yes);
yesButton->setObjectName("sendConfirmButton");
if (confirmButtonText.isEmpty()) {
confirmButtonText = yesButton->text();
}
m_psbt_button = button(QMessageBox::Save);
if (m_psbt_button) {
m_psbt_button->setObjectName("createUnsignedButton");
}
updateButtons();
connect(&countDownTimer, &QTimer::timeout, this, &SendConfirmationDialog::countDown);
}
Expand Down
Loading
Loading