Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
054ffdb
merge bitcoin-core/gui#557: revert bitcoin-core/gui#296
kwvg May 23, 2025
27951a3
merge bitcoin-core/gui#552: Refactor `TransactionDesc::FormatTxStatus…
kwvg May 23, 2025
212e54d
merge bitcoin-core/gui#556: Make BitcoinUnits::Unit a scoped enum
kwvg Jan 21, 2021
a334b68
merge bitcoin-core/gui#590: Declare `WalletModel` member functions wi…
kwvg Apr 23, 2022
bb5b44e
merge bitcoin-core/gui#581: Revamp `ClientModel` code to handle core …
kwvg May 27, 2025
320f0e6
merge bitcoin-core/gui#608: Make `WalletModel::sendCoins()` return `v…
kwvg May 29, 2022
13990d8
merge bitcoin-core/gui#673: Use fallback value for Version and User A…
kwvg Sep 16, 2022
5c894e1
merge bitcoin-core/gui#676: Update peers window "Transaction Relay" l…
kwvg May 23, 2025
6cc422d
merge bitcoin-core/gui#681: Fix Transaction Relay tooltip text in Pee…
kwvg May 23, 2025
8bdcd12
merge bitcoin-core/gui#690: Catch invalid networks combination crash
kwvg May 23, 2025
fd651ee
merge bitcoin-core/gui#697: Remove reindex special case from the prog…
kwvg Jan 17, 2023
9385d44
merge bitcoin-core/gui#717: Use the stored CSubNet entry when unbanning
kwvg Mar 6, 2023
107a180
merge bitcoin-core/gui#757: Add wallet name to address book page title
kwvg Sep 13, 2023
ae0ca10
merge bitcoin-core/gui#751: macOS, do not process actions during shut…
kwvg May 23, 2025
56fc672
merge bitcoin-core/gui#773: Check for private keys disabled before at…
kwvg May 23, 2025
a41f4e7
merge bitcoin-core/gui#801: Fix nullptr clientModel access during shu…
kwvg Feb 28, 2024
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
7 changes: 2 additions & 5 deletions src/interfaces/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,8 @@ class Node
//! Is masternode.
virtual bool isMasternode() = 0;

//! Get reindex.
virtual bool getReindex() = 0;

//! Get importing.
virtual bool getImporting() = 0;
//! Is loading blocks.
virtual bool isLoadingBlocks() = 0;

//! Set network active.
virtual void setNetworkActive(bool active) = 0;
Expand Down
3 changes: 1 addition & 2 deletions src/node/interfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,7 @@ class NodeImpl : public Node
{
return m_context->mn_activeman != nullptr;
}
bool getReindex() override { return ::fReindex; }
bool getImporting() override { return ::fImporting; }
bool isLoadingBlocks() override { return ::fReindex || ::fImporting; }
void setNetworkActive(bool active) override
{
if (m_context->connman) {
Expand Down
26 changes: 15 additions & 11 deletions src/qt/addressbookpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ AddressBookPage::AddressBookPage(Mode _mode, Tabs _tab, QWidget* parent) :
ui->showAddressQRCode->setEnabled(false);
#endif

switch(mode)
{
case ForSelection:
if (mode == ForSelection) {
switch(tab)
{
case SendingTab: setWindowTitle(tr("Choose the address to send coins to")); break;
Expand All @@ -84,14 +82,6 @@ AddressBookPage::AddressBookPage(Mode _mode, Tabs _tab, QWidget* parent) :
ui->tableView->setFocus();
ui->closeButton->setText(tr("C&hoose"));
ui->exportButton->hide();
break;
case ForEditing:
switch(tab)
{
case SendingTab: setWindowTitle(tr("Sending addresses")); break;
case ReceivingTab: setWindowTitle(tr("Receiving addresses")); break;
}
break;
}
switch(tab)
{
Expand Down Expand Up @@ -162,6 +152,7 @@ void AddressBookPage::setModel(AddressTableModel *_model)
connect(_model, &AddressTableModel::rowsInserted, this, &AddressBookPage::selectNewAddress);

selectionChanged();
this->updateWindowsTitleWithWalletName();
}

void AddressBookPage::on_copyAddress_clicked()
Expand Down Expand Up @@ -347,3 +338,16 @@ void AddressBookPage::selectNewAddress(const QModelIndex &parent, int begin, int
newAddressToSelect.clear();
}
}

void AddressBookPage::updateWindowsTitleWithWalletName()
{
const QString walletName = this->model->GetWalletDisplayName();

if (mode == ForEditing) {
switch(tab)
{
case SendingTab: setWindowTitle(tr("Sending addresses - %1").arg(walletName)); break;
case ReceivingTab: setWindowTitle(tr("Receiving addresses - %1").arg(walletName)); break;
}
}
}
1 change: 1 addition & 0 deletions src/qt/addressbookpage.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public Q_SLOTS:
AddressBookSortFilterProxyModel *proxyModel;
QMenu *contextMenu;
QString newAddressToSelect;
void updateWindowsTitleWithWalletName();

private Q_SLOTS:
/** Delete currently selected address entry */
Expand Down
2 changes: 2 additions & 0 deletions src/qt/addresstablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,3 +448,5 @@ void AddressTableModel::emitDataChanged(int idx)
{
Q_EMIT dataChanged(index(idx, 0, QModelIndex()), index(idx, columns.length()-1, QModelIndex()));
}

QString AddressTableModel::GetWalletDisplayName() const { return walletModel->getDisplayName(); };
2 changes: 2 additions & 0 deletions src/qt/addresstablemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ class AddressTableModel : public QAbstractTableModel

EditStatus getEditStatus() const { return editStatus; }

QString GetWalletDisplayName() const;

private:
WalletModel* const walletModel;
AddressTablePriv *priv = nullptr;
Expand Down
8 changes: 7 additions & 1 deletion src/qt/bantablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class BanTablePriv
/** Order (ascending or descending) to sort nodes by */
Qt::SortOrder sortOrder;

/** Pull a full list of banned nodes from CNode into our cache */
/** Pull a full list of banned nodes from interfaces::Node into our cache */
void refreshBanlist(interfaces::Node& node)
{
banmap_t banMap;
Expand Down Expand Up @@ -181,3 +181,9 @@ bool BanTableModel::shouldShow()
{
return priv->size() > 0;
}

bool BanTableModel::unban(const QModelIndex& index)
{
CCombinedBan* ban{static_cast<CCombinedBan*>(index.internalPointer())};
return ban != nullptr && m_node.unban(ban->subnet);
}
4 changes: 3 additions & 1 deletion src/qt/bantablemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class BannedNodeLessThan
};

/**
Qt model providing information about connected peers, similar to the
Qt model providing information about banned peers, similar to the
"getpeerinfo" RPC call. Used by the rpc console UI.
*/
class BanTableModel : public QAbstractTableModel
Expand Down Expand Up @@ -68,6 +68,8 @@ class BanTableModel : public QAbstractTableModel

bool shouldShow();

bool unban(const QModelIndex& index);

public Q_SLOTS:
void refresh();

Expand Down
38 changes: 23 additions & 15 deletions src/qt/bitcoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ static void RegisterMetaTypes()
qRegisterMetaType<std::function<void()>>("std::function<void()>");
qRegisterMetaType<QMessageBox::Icon>("QMessageBox::Icon");
qRegisterMetaType<interfaces::BlockAndHeaderTipInfo>("interfaces::BlockAndHeaderTipInfo");

qRegisterMetaTypeStreamOperators<BitcoinUnit>("BitcoinUnit");
}

static QString GetLangTerritory()
Expand Down Expand Up @@ -346,6 +348,11 @@ void BitcoinApplication::requestShutdown()
// Request node shutdown, which can interrupt long operations, like
// rescanning a wallet.
node().startShutdown();
// Prior to unsetting the client model, stop listening backend signals
if (clientModel) {
clientModel->stop();
}

// Unsetting the client model can cause the current thread to wait for node
// to complete an operation, like wait for a RPC execution to complete.
window->setClientModel(nullptr);
Expand Down Expand Up @@ -564,29 +571,30 @@ int GuiMain(int argc, char* argv[])
// Gracefully exit if the user cancels
if (!Intro::showIfNeeded(did_show_intro, prune_MiB)) return EXIT_SUCCESS;

/// 6. Determine availability of data directory and parse dash.conf
/// - Do not call gArgs.GetDataDirNet() before this step finishes
/// 6a. Determine availability of data directory
if (!CheckDataDirOption()) {
InitError(strprintf(Untranslated("Specified data directory \"%s\" does not exist.\n"), gArgs.GetArg("-datadir", "")));
QMessageBox::critical(nullptr, PACKAGE_NAME,
QObject::tr("Error: Specified data directory \"%1\" does not exist.").arg(QString::fromStdString(gArgs.GetArg("-datadir", ""))));
return EXIT_FAILURE;
}
if (!gArgs.ReadConfigFiles(error, true)) {
InitError(strprintf(Untranslated("Error reading configuration file: %s\n"), error));
QMessageBox::critical(nullptr, PACKAGE_NAME,
QObject::tr("Error: Cannot parse configuration file: %1.").arg(QString::fromStdString(error)));
return EXIT_FAILURE;
}
try {
/// 6b. Parse dash.conf
/// - Do not call gArgs.GetDataDirNet() before this step finishes
if (!gArgs.ReadConfigFiles(error, true)) {
InitError(strprintf(Untranslated("Error reading configuration file: %s\n"), error));
QMessageBox::critical(nullptr, PACKAGE_NAME,
QObject::tr("Error: Cannot parse configuration file: %1.").arg(QString::fromStdString(error)));
return EXIT_FAILURE;
}

/// 7. Determine network (and switch to network specific options)
// - Do not call Params() before this step
// - Do this after parsing the configuration file, as the network can be switched there
// - QSettings() will use the new application name after this, resulting in network-specific settings
// - Needs to be done before createOptionsModel
/// 7. Determine network (and switch to network specific options)
// - Do not call Params() before this step
// - Do this after parsing the configuration file, as the network can be switched there
// - QSettings() will use the new application name after this, resulting in network-specific settings
// - Needs to be done before createOptionsModel

// Check for -chain, -testnet or -regtest parameter (Params() calls are only valid after this clause)
try {
// Check for -chain, -testnet or -regtest parameter (Params() calls are only valid after this clause)
SelectParams(gArgs.GetChainName());
} catch(std::exception &e) {
InitError(Untranslated(strprintf("%s\n", e.what())));
Expand Down
33 changes: 18 additions & 15 deletions src/qt/bitcoinamountfield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@
#include <QHBoxLayout>
#include <QKeyEvent>
#include <QLineEdit>
#include <QVariant>

#include <cassert>

/**
* Parse a string into a number of base monetary units and
* return validity.
* @note Must return 0 if !valid.
*/
static CAmount parse(const QString &text, int nUnit, bool *valid_out= nullptr)
static CAmount parse(const QString &text, BitcoinUnit nUnit, bool *valid_out= nullptr)
{
CAmount val = 0;
bool valid = BitcoinUnits::parse(nUnit, text, &val);
Expand All @@ -37,11 +40,12 @@ static CAmount parse(const QString &text, int nUnit, bool *valid_out= nullptr)
class AmountValidator : public QValidator
{
Q_OBJECT
int currentUnit;
BitcoinUnit currentUnit;

public:
explicit AmountValidator(QObject *parent) :
QValidator(parent),
currentUnit(BitcoinUnits::DASH) {}
currentUnit(BitcoinUnit::DASH) {}

State validate(QString &input, int &pos) const override
{
Expand All @@ -53,7 +57,7 @@ class AmountValidator : public QValidator
return valid ? QValidator::Intermediate : QValidator::Invalid;
}

void updateUnit(int nUnit)
void updateUnit(BitcoinUnit nUnit)
{
currentUnit = nUnit;
}
Expand All @@ -69,7 +73,7 @@ class AmountLineEdit: public QLineEdit
public:
explicit AmountLineEdit(QWidget *parent):
QLineEdit(parent),
currentUnit(BitcoinUnits::DASH)
currentUnit(BitcoinUnit::DASH)
{
setAlignment(Qt::AlignLeft);
amountValidator = new AmountValidator(this);
Expand Down Expand Up @@ -122,7 +126,7 @@ class AmountLineEdit: public QLineEdit
m_max_amount = value;
}

void setDisplayUnit(int unit)
void setDisplayUnit(BitcoinUnit unit)
{
bool valid = false;
CAmount val = value(&valid);
Expand All @@ -142,14 +146,14 @@ class AmountLineEdit: public QLineEdit
ensurePolished();
const QFontMetrics fm(fontMetrics());
int h = 0;
int w = GUIUtil::TextWidth(fm, BitcoinUnits::format(BitcoinUnits::DASH, BitcoinUnits::maxMoney(), false, BitcoinUnits::SeparatorStyle::ALWAYS));
int w = GUIUtil::TextWidth(fm, BitcoinUnits::format(BitcoinUnit::DASH, BitcoinUnits::maxMoney(), false, BitcoinUnits::SeparatorStyle::ALWAYS));
w += 2; // cursor blinking space
w += GUIUtil::dashThemeActive() ? 24 : 0; // counteract padding from css
return QSize(w, h);
}

private:
int currentUnit{BitcoinUnits::DASH};
BitcoinUnit currentUnit{BitcoinUnit::DASH};
bool m_allow_empty{true};
CAmount m_min_amount{CAmount(0)};
CAmount m_max_amount{BitcoinUnits::maxMoney()};
Expand Down Expand Up @@ -287,14 +291,13 @@ void BitcoinAmountField::unitChanged(int idx)
amount->setToolTip(units->data(idx, Qt::ToolTipRole).toString());

// Determine new unit ID
int newUnit = units->data(idx, BitcoinUnits::UnitRole).toInt();

amount->setPlaceholderText(tr("Amount in %1").arg(units->data(idx,Qt::DisplayRole).toString()));

amount->setDisplayUnit(newUnit);
QVariant new_unit = units->data(idx, BitcoinUnits::UnitRole);
assert(new_unit.isValid());
amount->setPlaceholderText(tr("Amount in %1").arg(units->data(idx, Qt::DisplayRole).toString()));
amount->setDisplayUnit(new_unit.value<BitcoinUnit>());
}

void BitcoinAmountField::setDisplayUnit(int newUnit)
void BitcoinAmountField::setDisplayUnit(BitcoinUnit new_unit)
{
unitChanged(newUnit);
unitChanged(QVariant::fromValue(new_unit).toInt());
}
3 changes: 2 additions & 1 deletion src/qt/bitcoinamountfield.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#define BITCOIN_QT_BITCOINAMOUNTFIELD_H

#include <consensus/amount.h>
#include <qt/bitcoinunits.h>

#include <QValidator>
#include <QWidget>
Expand Down Expand Up @@ -51,7 +52,7 @@ class BitcoinAmountField: public QWidget
bool validate();

/** Change unit used to display amount. */
void setDisplayUnit(int unit);
void setDisplayUnit(BitcoinUnit new_unit);

/** Make field empty and ready for new input. */
void clear();
Expand Down
Loading
Loading