Skip to content

Commit

Permalink
Merge #6168: backport: bitcoin-core#gui18, #121, #257, #263, #281, #335
Browse files Browse the repository at this point in the history
…, #362, #828, bitcoin#21912, bitcoin#21942, bitcoin#21988

c7d3161 Merge bitcoin-core/gui#362: Add keyboard shortcuts to context menus (Hennadii Stepanov)
25f87b9 Merge bitcoin-core/gui#121: Early subscribe core signals in transaction table model (Hennadii Stepanov)
ed56e28 Merge bitcoin-core/gui#335: test: Use QSignalSpy instead of QEventLoop (Hennadii Stepanov)
c52b756 Merge bitcoin-core/gui#281: set shortcuts for console's resize buttons (W. J. van der Laan)
b442a59 Merge bitcoin#21988: doc: note that brew installed qt is not supported (W. J. van der Laan)
0e2e315 Merge bitcoin#21942: docs: improve make with parallel jobs description. (MarcoFalke)
c2735a8 Merge bitcoin#21912: doc: Remove mention of priority estimation (W. J. van der Laan)
1d56d20 Merge bitcoin-core/gui#257: refactor: Use template function qOverload in signal-slot connections (Hennadii Stepanov)
b5fb559 Merge bitcoin-core/gui#18: Add peertablesortproxy module (Hennadii Stepanov)
1cdd9fb refactor: use new QAction style for governance list and masternode list (Konstantin Akimov)
4f89c98 Merge bitcoin-core/gui#263: Revamp context menus (Hennadii Stepanov)
c36bb8e fix: use && in governance urls instead & (Konstantin Akimov)
1e585b1 Merge bitcoin-core/gui#828: Rendering an amp characters in the wallet name for QMenu (Hennadii Stepanov)

Pull request description:

  ## Issue being fixed or feature implemented
  Just regular backports from bitcoin v22, mostly Qt related

  ## What was done?
  See commits for a list of backports.

  This PR also fixes a rendering an url on Governance tab if it has any '&' inside. see screenshots.

  Original url: `https://example.com/?test=nothing&to=see&&lol` - yes, double '&&' just for test even if url is silly.
  Failed behaviour:
  ![image](https://github.com/user-attachments/assets/ac45c192-7d0e-4cd2-97f8-060af8f3911b)
  Correctly rendered:
  ![image](https://github.com/user-attachments/assets/5e345197-776a-4bb8-9476-cab4aba3429e)

  ## How Has This Been Tested?
  Run unit/functional tests

  ## Breaking Changes
  N/A

  ## Checklist:
  - [x] I have performed a self-review of my own code
  - [ ] I have commented my code, particularly in hard-to-understand areas
  - [ ] I have added or updated relevant unit/integration/functional/e2e tests
  - [ ] I have made corresponding changes to the documentation
  - [x] I have assigned this pull request to a milestone

ACKs for top commit:
  PastaPastaPasta:
    utACK c7d3161
  UdjinM6:
    utACK c7d3161

Tree-SHA512: 67e7e8e0ec1a768d1f13baa48c123e4a415d3f32177a427d8117339a5eacf70864ebf46e9f1165bb8a3bf9c231f7929d33ac6aa19742e06a4e19d2f86dda6dc3
  • Loading branch information
PastaPastaPasta committed Aug 21, 2024
2 parents e4e6d9b + c7d3161 commit f2940c4
Show file tree
Hide file tree
Showing 33 changed files with 262 additions and 388 deletions.
2 changes: 1 addition & 1 deletion doc/build-freebsd.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,6 @@ This explicitly enables the GUI and disables legacy wallet support. If `qt5` is
**Important**: Use `gmake` (the non-GNU `make` will exit with an error).

```bash
gmake # use -jX here for parallelism
gmake # use "-j N" for N parallel jobs
gmake check # Run tests if Python 3 is available
```
2 changes: 1 addition & 1 deletion doc/build-netbsd.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,6 @@ Without wallet:

Build and run the tests:
```bash
gmake # use -jX here for parallelism
gmake # use "-j N" here for N parallel jobs
gmake check
```
2 changes: 1 addition & 1 deletion doc/build-openbsd.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ To configure with GUI:

Build and run the tests:
```bash
gmake # use -jX here for parallelism
gmake # use "-j N" here for N parallel jobs
gmake check
```

Expand Down
10 changes: 9 additions & 1 deletion doc/build-osx.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,14 @@ Skip if you don't intend to use the GUI.
brew install qt@5
```

Ensure that the `qt@5` package is installed, not the `qt` package.
If 'qt' is installed, the build process will fail.
if installed, remove the `qt` package with the following command:

``` bash
brew uninstall qt
```

Note: Building with Qt binaries downloaded from the Qt website is not officially supported.
See the notes in [#7714](https://github.com/dashpay/dash/issues/7714).

Expand Down Expand Up @@ -276,7 +284,7 @@ After configuration, you are ready to compile.
Run the following in your terminal to compile Dash Core:

``` bash
make -jx # use -jX here for parallelism
make # use "-j N" here for N parallel jobs
make check # Run tests if Python 3 is available
```

Expand Down
2 changes: 1 addition & 1 deletion doc/build-unix.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ To Build
```sh
./autogen.sh
./configure
make
make # use "-j N" for N parallel jobs
make install # optional
```

Expand Down
2 changes: 1 addition & 1 deletion doc/files.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Subdirectory | File(s) | Description
`./` | `governance.dat` | stores data for governance objects
`./` | `mncache.dat` | stores data for masternode list
`./` | `netfulfilled.dat` | stores data about recently made network requests
`./` | `fee_estimates.dat` | Stores statistics used to estimate minimum transaction fees and priorities required for confirmation
`./` | `fee_estimates.dat` | Stores statistics used to estimate minimum transaction fees required for confirmation
`./` | `guisettings.ini.bak` | Backup of former [GUI settings](#gui-settings) after `-resetguisettings` option is used
`./` | `ip_asn.map` | IP addresses to Autonomous System Numbers (ASNs) mapping used for bucketing of the peers; path can be specified with the `-asmap` option
`./` | `mempool.dat` | Dump of the mempool's transactions
Expand Down
3 changes: 3 additions & 0 deletions src/Makefile.qt.include
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ QT_MOC_CPP = \
qt/moc_optionsmodel.cpp \
qt/moc_overviewpage.cpp \
qt/moc_peertablemodel.cpp \
qt/moc_peertablesortproxy.cpp \
qt/moc_paymentserver.cpp \
qt/moc_psbtoperationsdialog.cpp \
qt/moc_qrdialog.cpp \
Expand Down Expand Up @@ -146,6 +147,7 @@ BITCOIN_QT_H = \
qt/overviewpage.h \
qt/paymentserver.h \
qt/peertablemodel.h \
qt/peertablesortproxy.h \
qt/psbtoperationsdialog.h \
qt/qrdialog.h \
qt/qrimagewidget.h \
Expand Down Expand Up @@ -227,6 +229,7 @@ BITCOIN_QT_BASE_CPP = \
qt/optionsdialog.cpp \
qt/optionsmodel.cpp \
qt/peertablemodel.cpp \
qt/peertablesortproxy.cpp \
qt/qvalidatedlineedit.cpp \
qt/qvaluecombobox.cpp \
qt/rpcconsole.cpp \
Expand Down
36 changes: 11 additions & 25 deletions src/qt/addressbookpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,32 +107,20 @@ AddressBookPage::AddressBookPage(Mode _mode, Tabs _tab, QWidget* parent) :
break;
}

// Context menu actions
QAction *copyAddressAction = new QAction(tr("&Copy Address"), this);
QAction *copyLabelAction = new QAction(tr("Copy &Label"), this);
QAction *editAction = new QAction(tr("&Edit"), this);
QAction *showAddressQRCodeAction = new QAction(tr("&Show address QR code"), this);
deleteAction = new QAction(ui->deleteAddress->text(), this);
// Build context menu
contextMenu = new QMenu(this);
contextMenu->addAction(tr("&Copy Address"), this, &AddressBookPage::on_copyAddress_clicked);
contextMenu->addAction(tr("Copy &Label"), this, &AddressBookPage::onCopyLabelAction);
contextMenu->addAction(tr("&Edit"), this, &AddressBookPage::onEditAction);
[[maybe_unused]] QAction* qrAction = contextMenu->addAction(tr("Show address &QR code"), this, &AddressBookPage::on_showAddressQRCode_clicked);
#ifndef USE_QRCODE
showAddressQRCodeAction->setEnabled(false);
qrAction->setEnabled(false);
#endif

// Build context menu
contextMenu = new QMenu(this);
contextMenu->addAction(copyAddressAction);
contextMenu->addAction(copyLabelAction);
contextMenu->addAction(editAction);
if(tab == SendingTab)
contextMenu->addAction(deleteAction);
contextMenu->addSeparator();
contextMenu->addAction(showAddressQRCodeAction);

// Connect signals for context menu actions
connect(copyAddressAction, &QAction::triggered, this, &AddressBookPage::on_copyAddress_clicked);
connect(copyLabelAction, &QAction::triggered, this, &AddressBookPage::onCopyLabelAction);
connect(editAction, &QAction::triggered, this, &AddressBookPage::onEditAction);
connect(deleteAction, &QAction::triggered, this, &AddressBookPage::on_deleteAddress_clicked);
connect(showAddressQRCodeAction, &QAction::triggered, this, &AddressBookPage::on_showAddressQRCode_clicked);
if (tab == SendingTab) {
contextMenu->addAction(tr("&Delete"), this, &AddressBookPage::on_deleteAddress_clicked);
}

connect(ui->tableView, &QWidget::customContextMenuRequested, this, &AddressBookPage::contextualMenu);
connect(ui->closeButton, &QPushButton::clicked, this, &QDialog::accept);

Expand Down Expand Up @@ -267,13 +255,11 @@ void AddressBookPage::selectionChanged()
// In sending tab, allow deletion of selection
ui->deleteAddress->setEnabled(true);
ui->deleteAddress->setVisible(true);
deleteAction->setEnabled(true);
break;
case ReceivingTab:
// Deleting receiving addresses, however, is not allowed
ui->deleteAddress->setEnabled(false);
ui->deleteAddress->setVisible(false);
deleteAction->setEnabled(false);
break;
}
ui->copyAddress->setEnabled(true);
Expand Down
1 change: 0 additions & 1 deletion src/qt/addressbookpage.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public Q_SLOTS:
QString returnValue;
AddressBookSortFilterProxyModel *proxyModel;
QMenu *contextMenu;
QAction *deleteAction; // to be able to explicitly disable it
QString newAddressToSelect;

private Q_SLOTS:
Expand Down
16 changes: 6 additions & 10 deletions src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,10 +520,9 @@ void BitcoinGUI::createActions()
for (const std::pair<const std::string, bool>& i : m_wallet_controller->listWalletDir()) {
const std::string& path = i.first;
QString name = path.empty() ? QString("["+tr("default wallet")+"]") : QString::fromStdString(path);
// Menu items remove single &. Single & are shown when && is in
// the string, but only the first occurrence. So replace only
// the first & with &&.
name.replace(name.indexOf(QChar('&')), 1, QString("&&"));
// An single ampersand in the menu item's text sets a shortcut for this item.
// Single & are shown when && is in the string. So replace & with &&.
name.replace(QChar('&'), QString("&&"));
QAction* action = m_open_wallet_menu->addAction(name);

if (i.second) {
Expand Down Expand Up @@ -747,7 +746,7 @@ void BitcoinGUI::createToolBars()
#ifdef ENABLE_WALLET
m_wallet_selector = new QComboBox(this);
m_wallet_selector->setSizeAdjustPolicy(QComboBox::AdjustToContents);
connect(m_wallet_selector, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &BitcoinGUI::setCurrentWalletBySelectorIndex);
connect(m_wallet_selector, qOverload<int>(&QComboBox::currentIndexChanged), this, &BitcoinGUI::setCurrentWalletBySelectorIndex);

QVBoxLayout* walletSelectorLayout = new QVBoxLayout(this);
walletSelectorLayout->addWidget(m_wallet_selector);
Expand Down Expand Up @@ -2055,11 +2054,8 @@ void UnitDisplayStatusBarControl::mousePressEvent(QMouseEvent *event)
void UnitDisplayStatusBarControl::createContextMenu()
{
menu = new QMenu(this);
for (const BitcoinUnits::Unit u : BitcoinUnits::availableUnits())
{
QAction *menuAction = new QAction(QString(BitcoinUnits::name(u)), this);
menuAction->setData(QVariant(u));
menu->addAction(menuAction);
for (const BitcoinUnits::Unit u : BitcoinUnits::availableUnits()) {
menu->addAction(BitcoinUnits::name(u))->setData(QVariant(u));
}
connect(menu, &QMenu::triggered, this, &UnitDisplayStatusBarControl::onMenuSelection);
}
Expand Down
10 changes: 10 additions & 0 deletions src/qt/clientmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <qt/guiconstants.h>
#include <qt/guiutil.h>
#include <qt/peertablemodel.h>
#include <qt/peertablesortproxy.h>

#include <evo/deterministicmns.h>

Expand Down Expand Up @@ -42,7 +43,11 @@ ClientModel::ClientModel(interfaces::Node& node, OptionsModel *_optionsModel, QO
{
cachedBestHeaderHeight = -1;
cachedBestHeaderTime = -1;

peerTableModel = new PeerTableModel(m_node, this);
m_peer_table_sort_proxy = new PeerTableSortProxy(this);
m_peer_table_sort_proxy->setSourceModel(peerTableModel);

banTableModel = new BanTableModel(m_node, this);
mnListCached = std::make_shared<CDeterministicMNList>();

Expand Down Expand Up @@ -219,6 +224,11 @@ PeerTableModel *ClientModel::getPeerTableModel()
return peerTableModel;
}

PeerTableSortProxy* ClientModel::peerTableSortProxy()
{
return m_peer_table_sort_proxy;
}

BanTableModel *ClientModel::getBanTableModel()
{
return banTableModel;
Expand Down
3 changes: 3 additions & 0 deletions src/qt/clientmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class BanTableModel;
class CBlockIndex;
class OptionsModel;
class PeerTableModel;
class PeerTableSortProxy;
enum class SynchronizationState;

QT_BEGIN_NAMESPACE
Expand Down Expand Up @@ -58,6 +59,7 @@ class ClientModel : public QObject
interfaces::CoinJoin::Options& coinJoinOptions() const { return m_node.coinJoinOptions(); }
OptionsModel *getOptionsModel();
PeerTableModel *getPeerTableModel();
PeerTableSortProxy* peerTableSortProxy();
BanTableModel *getBanTableModel();

//! Return number of connections, default is in- and outbound (total)
Expand Down Expand Up @@ -109,6 +111,7 @@ class ClientModel : public QObject
std::unique_ptr<interfaces::Handler> m_handler_notify_additional_data_sync_progess_changed;
OptionsModel *optionsModel;
PeerTableModel *peerTableModel;
PeerTableSortProxy* m_peer_table_sort_proxy{nullptr};
BanTableModel *banTableModel;

//! A thread to interact with m_node asynchronously
Expand Down
28 changes: 6 additions & 22 deletions src/qt/coincontroldialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,32 +62,16 @@ CoinControlDialog::CoinControlDialog(CCoinControl& coin_control, WalletModel* _m

GUIUtil::disableMacFocusRect(this);

// context menu actions
QAction *copyAddressAction = new QAction(tr("Copy address"), this);
QAction *copyLabelAction = new QAction(tr("Copy label"), this);
QAction *copyAmountAction = new QAction(tr("Copy amount"), this);
copyTransactionHashAction = new QAction(tr("Copy transaction ID"), this); // we need to enable/disable this
lockAction = new QAction(tr("Lock unspent"), this); // we need to enable/disable this
unlockAction = new QAction(tr("Unlock unspent"), this); // we need to enable/disable this

// context menu
contextMenu = new QMenu(this);
contextMenu->addAction(copyAddressAction);
contextMenu->addAction(copyLabelAction);
contextMenu->addAction(copyAmountAction);
contextMenu->addAction(copyTransactionHashAction);
contextMenu->addAction(tr("&Copy address"), this, &CoinControlDialog::copyAddress);
contextMenu->addAction(tr("Copy &label"), this, &CoinControlDialog::copyLabel);
contextMenu->addAction(tr("Copy &amount"), this, &CoinControlDialog::copyAmount);
copyTransactionHashAction = contextMenu->addAction(tr("Copy transaction &ID"), this, &CoinControlDialog::copyTransactionHash);
contextMenu->addSeparator();
contextMenu->addAction(lockAction);
contextMenu->addAction(unlockAction);

// context menu signals
lockAction = contextMenu->addAction(tr("L&ock unspent"), this, &CoinControlDialog::lockCoin);
unlockAction = contextMenu->addAction(tr("&Unlock unspent"), this, &CoinControlDialog::unlockCoin);
connect(ui->treeWidget, &QWidget::customContextMenuRequested, this, &CoinControlDialog::showMenu);
connect(copyAddressAction, &QAction::triggered, this, &CoinControlDialog::copyAddress);
connect(copyLabelAction, &QAction::triggered, this, &CoinControlDialog::copyLabel);
connect(copyAmountAction, &QAction::triggered, this, &CoinControlDialog::copyAmount);
connect(copyTransactionHashAction, &QAction::triggered, this, &CoinControlDialog::copyTransactionHash);
connect(lockAction, &QAction::triggered, this, &CoinControlDialog::lockCoin);
connect(unlockAction, &QAction::triggered, this, &CoinControlDialog::unlockCoin);

// clipboard actions
QAction *clipboardQuantityAction = new QAction(tr("Copy quantity"), this);
Expand Down
7 changes: 4 additions & 3 deletions src/qt/governancelist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,10 +388,11 @@ void GovernanceList::showProposalContextMenu(const QPoint& pos)
}

// right click menu with option to open proposal url
QAction* openProposalUrl = new QAction(proposal->url(), this);
QString proposal_url = proposal->url();
proposal_url.replace(QChar('&'), QString("&&"));

proposalContextMenu->clear();
proposalContextMenu->addAction(openProposalUrl);
connect(openProposalUrl, &QAction::triggered, proposal, &Proposal::openUrl);
proposalContextMenu->addAction(proposal_url, proposal, &Proposal::openUrl);
proposalContextMenu->exec(QCursor::pos());
}

Expand Down
5 changes: 5 additions & 0 deletions src/qt/guiutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,11 @@ void setupAppearance(QWidget* parent, OptionsModel* model)
}
}

void AddButtonShortcut(QAbstractButton* button, const QKeySequence& shortcut)
{
QObject::connect(new QShortcut(shortcut, button), &QShortcut::activated, [button]() { button->animateClick(); });
}

bool parseBitcoinURI(const QUrl &uri, SendCoinsRecipient *out)
{
// return if URI is not valid or is no dash: URI
Expand Down
9 changes: 9 additions & 0 deletions src/qt/guiutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class QAction;
class QButtonGroup;
class QDateTime;
class QFont;
class QKeySequence;
class QLineEdit;
class QMenu;
class QPoint;
Expand Down Expand Up @@ -135,6 +136,14 @@ namespace GUIUtil
// Setup appearance settings if not done yet
void setupAppearance(QWidget* parent, OptionsModel* model);

/**
* Connects an additional shortcut to a QAbstractButton. Works around the
* one shortcut limitation of the button's shortcut property.
* @param[in] button QAbstractButton to assign shortcut to
* @param[in] shortcut QKeySequence to use as shortcut
*/
void AddButtonShortcut(QAbstractButton* button, const QKeySequence& shortcut);

// Parse "dash:" URI into recipient object, return true on successful parsing
bool parseBitcoinURI(const QUrl &uri, SendCoinsRecipient *out);
bool parseBitcoinURI(QString uri, SendCoinsRecipient *out);
Expand Down
2 changes: 1 addition & 1 deletion src/qt/intro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ Intro::Intro(QWidget *parent, int64_t blockchain_size_gb, int64_t chain_state_si
UpdatePruneLabels(prune_checked);
UpdateFreeSpaceLabel();
});
connect(ui->pruneGB, QOverload<int>::of(&QSpinBox::valueChanged), [this](int prune_GB) {
connect(ui->pruneGB, qOverload<int>(&QSpinBox::valueChanged), [this](int prune_GB) {
m_prune_target_gb = prune_GB;
UpdatePruneLabels(ui->prune->isChecked());
UpdateFreeSpaceLabel();
Expand Down
9 changes: 3 additions & 6 deletions src/qt/masternodelist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,12 @@ MasternodeList::MasternodeList(QWidget* parent) :

ui->checkBoxMyMasternodesOnly->setEnabled(false);

QAction* copyProTxHashAction = new QAction(tr("Copy ProTx Hash"), this);
QAction* copyCollateralOutpointAction = new QAction(tr("Copy Collateral Outpoint"), this);
contextMenuDIP3 = new QMenu(this);
contextMenuDIP3->addAction(copyProTxHashAction);
contextMenuDIP3->addAction(copyCollateralOutpointAction);
contextMenuDIP3->addAction(tr("Copy ProTx Hash"), this, &MasternodeList::copyProTxHash_clicked);
contextMenuDIP3->addAction(tr("Copy Collateral Outpoint"), this, &MasternodeList::copyCollateralOutpoint_clicked);

connect(ui->tableWidgetMasternodesDIP3, &QTableWidget::customContextMenuRequested, this, &MasternodeList::showContextMenuDIP3);
connect(ui->tableWidgetMasternodesDIP3, &QTableWidget::doubleClicked, this, &MasternodeList::extraInfoDIP3_clicked);
connect(copyProTxHashAction, &QAction::triggered, this, &MasternodeList::copyProTxHash_clicked);
connect(copyCollateralOutpointAction, &QAction::triggered, this, &MasternodeList::copyCollateralOutpoint_clicked);

timer = new QTimer(this);
connect(timer, &QTimer::timeout, this, &MasternodeList::updateDIP3ListScheduled);
Expand Down
Loading

0 comments on commit f2940c4

Please sign in to comment.