Skip to content

Commit c27e646

Browse files
committed
Porting source files from qt folder to qtum core 27
Porting source files from qt folder to qtum core 27
1 parent 08d5260 commit c27e646

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+4513
-781
lines changed

src/qt/addressbookpage.cpp

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

5+
#if defined(HAVE_CONFIG_H)
6+
#include <config/bitcoin-config.h>
7+
#endif
8+
59
#include <qt/addressbookpage.h>
610
#include <qt/forms/ui_addressbookpage.h>
711

@@ -10,6 +14,7 @@
1014
#include <qt/editaddressdialog.h>
1115
#include <qt/guiutil.h>
1216
#include <qt/platformstyle.h>
17+
#include <qt/styleSheet.h>
1318

1419
#include <QIcon>
1520
#include <QMenu>
@@ -63,20 +68,27 @@ AddressBookPage::AddressBookPage(const PlatformStyle *platformStyle, Mode _mode,
6368
mode(_mode),
6469
tab(_tab)
6570
{
66-
ui->setupUi(this);
67-
71+
ui->setupUi(this);
72+
SetObjectStyleSheet(ui->tableView, StyleSheetNames::TableViewLight);
73+
setStyleSheet("");
6874
if (!platformStyle->getImagesOnButtons()) {
6975
ui->newAddress->setIcon(QIcon());
7076
ui->copyAddress->setIcon(QIcon());
7177
ui->deleteAddress->setIcon(QIcon());
7278
ui->exportButton->setIcon(QIcon());
7379
} else {
74-
ui->newAddress->setIcon(platformStyle->SingleColorIcon(":/icons/add"));
75-
ui->copyAddress->setIcon(platformStyle->SingleColorIcon(":/icons/editcopy"));
76-
ui->deleteAddress->setIcon(platformStyle->SingleColorIcon(":/icons/remove"));
77-
ui->exportButton->setIcon(platformStyle->SingleColorIcon(":/icons/export"));
80+
ui->newAddress->setIcon(platformStyle->MultiStatesIcon(":/icons/add", PlatformStyle::PushButtonLight));
81+
ui->copyAddress->setIcon(platformStyle->MultiStatesIcon(":/icons/editcopy", PlatformStyle::PushButtonLight));
82+
ui->deleteAddress->setIcon(platformStyle->MultiStatesIcon(":/icons/remove", PlatformStyle::PushButtonLight));
83+
ui->exportButton->setIcon(platformStyle->MultiStatesIcon(":/icons/export", PlatformStyle::PushButton));
7884
}
7985

86+
SetObjectStyleSheet(ui->newAddress, StyleSheetNames::ButtonLight);
87+
SetObjectStyleSheet(ui->copyAddress, StyleSheetNames::ButtonLight);
88+
SetObjectStyleSheet(ui->deleteAddress, StyleSheetNames::ButtonLight);
89+
SetObjectStyleSheet(ui->exportButton, StyleSheetNames::ButtonGray);
90+
SetObjectStyleSheet(ui->closeButton, StyleSheetNames::ButtonGray);
91+
8092
if (mode == ForSelection) {
8193
switch(tab)
8294
{
@@ -92,12 +104,11 @@ AddressBookPage::AddressBookPage(const PlatformStyle *platformStyle, Mode _mode,
92104
switch(tab)
93105
{
94106
case SendingTab:
95-
ui->labelExplanation->setText(tr("These are your Bitcoin addresses for sending payments. Always check the amount and the receiving address before sending coins."));
96-
ui->deleteAddress->setVisible(true);
107+
ui->labelExplanation->setText(tr("These are your Qtum addresses for sending payments. Always check the amount and the receiving address before sending coins."));
97108
ui->newAddress->setVisible(true);
98109
break;
99110
case ReceivingTab:
100-
ui->labelExplanation->setText(tr("These are your Bitcoin addresses for receiving payments. Use the 'Create new receiving address' button in the receive tab to create new addresses.\nSigning is only possible with addresses of the type 'legacy'."));
111+
ui->labelExplanation->setText(tr("These are your Qtum addresses for receiving payments. Use the 'Create new receiving address' button in the receive tab to create new addresses.\nSigning is only possible with addresses of the type 'legacy'."));
101112
ui->deleteAddress->setVisible(false);
102113
ui->newAddress->setVisible(false);
103114
break;

src/qt/addresstablemodel.cpp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -406,11 +406,27 @@ bool AddressTableModel::removeRows(int row, int count, const QModelIndex &parent
406406
return true;
407407
}
408408

409-
QString AddressTableModel::labelForAddress(const QString &address) const
409+
QString AddressTableModel::labelForAddress(const QString &address, bool cached) const
410410
{
411-
std::string name;
412-
if (getAddressData(address, &name, /* purpose= */ nullptr)) {
413-
return QString::fromStdString(name);
411+
if(cached)
412+
{
413+
// Find address / label in model
414+
QList<AddressTableEntry>::iterator lower = std::lower_bound(
415+
priv->cachedAddressTable.begin(), priv->cachedAddressTable.end(), address, AddressTableEntryLessThan());
416+
QList<AddressTableEntry>::iterator upper = std::upper_bound(
417+
priv->cachedAddressTable.begin(), priv->cachedAddressTable.end(), address, AddressTableEntryLessThan());
418+
bool inModel = (lower != upper);
419+
if(inModel)
420+
{
421+
return lower->label;
422+
}
423+
}
424+
else
425+
{
426+
std::string name;
427+
if (getAddressData(address, &name, /* purpose= */ nullptr)) {
428+
return QString::fromStdString(name);
429+
}
414430
}
415431
return QString();
416432
}

src/qt/addresstablemodel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class AddressTableModel : public QAbstractTableModel
7373
QString addRow(const QString &type, const QString &label, const QString &address, const OutputType address_type);
7474

7575
/** Look up label for address in address book, if not found return empty string. */
76-
QString labelForAddress(const QString &address) const;
76+
QString labelForAddress(const QString &address, bool cached = true) const;
7777

7878
/** Look up purpose for address in address book, if not found return empty string. */
7979
std::optional<wallet::AddressPurpose> purposeForAddress(const QString &address) const;

src/qt/askpassphrasedialog.cpp

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,19 @@
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

5+
#if defined(HAVE_CONFIG_H)
6+
#include <config/bitcoin-config.h>
7+
#endif
8+
59
#include <qt/askpassphrasedialog.h>
610
#include <qt/forms/ui_askpassphrasedialog.h>
711

812
#include <qt/guiconstants.h>
913
#include <qt/guiutil.h>
1014
#include <qt/walletmodel.h>
15+
#include <qt/styleSheet.h>
16+
#include <wallet/wallet.h>
17+
#include <node/miner.h>
1118

1219
#include <support/allocators/secure.h>
1320

@@ -23,6 +30,8 @@ AskPassphraseDialog::AskPassphraseDialog(Mode _mode, QWidget *parent, SecureStri
2330
{
2431
ui->setupUi(this);
2532

33+
SetObjectStyleSheet(ui->buttonBox->button(QDialogButtonBox::Cancel), StyleSheetNames::ButtonLight);
34+
SetObjectStyleSheet(ui->buttonBox->button(QDialogButtonBox::Ok), StyleSheetNames::ButtonGray);
2635
ui->passEdit1->setMinimumSize(ui->passEdit1->sizeHint());
2736
ui->passEdit2->setMinimumSize(ui->passEdit2->sizeHint());
2837
ui->passEdit3->setMinimumSize(ui->passEdit3->sizeHint());
@@ -36,6 +45,7 @@ AskPassphraseDialog::AskPassphraseDialog(Mode _mode, QWidget *parent, SecureStri
3645
ui->passEdit2->installEventFilter(this);
3746
ui->passEdit3->installEventFilter(this);
3847

48+
ui->stakingCheckBox->hide();
3949
switch(mode)
4050
{
4151
case Encrypt: // Ask passphrase x2
@@ -44,6 +54,10 @@ AskPassphraseDialog::AskPassphraseDialog(Mode _mode, QWidget *parent, SecureStri
4454
ui->passEdit1->hide();
4555
setWindowTitle(tr("Encrypt wallet"));
4656
break;
57+
case UnlockStaking:
58+
ui->stakingCheckBox->setChecked(true);
59+
ui->stakingCheckBox->show();
60+
[[fallthrough]];
4761
case Unlock: // Ask passphrase
4862
ui->warningLabel->setText(tr("This operation needs your wallet passphrase to unlock the wallet."));
4963
ui->passLabel2->hide();
@@ -75,6 +89,7 @@ AskPassphraseDialog::~AskPassphraseDialog()
7589
void AskPassphraseDialog::setModel(WalletModel *_model)
7690
{
7791
this->model = _model;
92+
if(model) ui->stakingCheckBox->setChecked(model->getWalletUnlockStakingOnly() || mode == UnlockStaking);
7893
}
7994

8095
void AskPassphraseDialog::accept()
@@ -101,15 +116,15 @@ void AskPassphraseDialog::accept()
101116
break;
102117
}
103118
QMessageBox::StandardButton retval = QMessageBox::question(this, tr("Confirm wallet encryption"),
104-
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?"),
119+
tr("Warning: If you encrypt your wallet and lose your passphrase, you will <b>LOSE ALL OF YOUR QTUMS</b>!") + "<br><br>" + tr("Are you sure you wish to encrypt your wallet?"),
105120
QMessageBox::Yes|QMessageBox::Cancel,
106121
QMessageBox::Cancel);
107122
if(retval == QMessageBox::Yes)
108123
{
109124
if(newpass1 == newpass2)
110125
{
111126
QString encryption_reminder = tr("Remember that encrypting your wallet cannot fully protect "
112-
"your bitcoins from being stolen by malware infecting your computer.");
127+
"your qtums from being stolen by malware infecting your computer.");
113128
if (m_passphrase_out) {
114129
m_passphrase_out->assign(newpass1);
115130
QMessageBox::warning(this, tr("Wallet to be encrypted"),
@@ -146,6 +161,7 @@ void AskPassphraseDialog::accept()
146161
QDialog::reject(); // Cancelled
147162
}
148163
} break;
164+
case UnlockStaking:
149165
case Unlock:
150166
try {
151167
if (!model->setWalletLocked(false, oldpass)) {
@@ -166,6 +182,13 @@ void AskPassphraseDialog::accept()
166182
if (m_passphrase_out) {
167183
m_passphrase_out->assign(oldpass);
168184
}
185+
model->setWalletUnlockStakingOnly(ui->stakingCheckBox->isChecked());
186+
if(UnlockStaking == mode)
187+
{
188+
// Start the staking if enabled on the machine
189+
bool staking = node::CanStake();
190+
model->wallet().setEnabledStaking(staking);
191+
}
169192
QDialog::accept(); // Success
170193
}
171194
} catch (const std::runtime_error& e) {
@@ -215,6 +238,7 @@ void AskPassphraseDialog::textChanged()
215238
case Encrypt: // New passphrase x2
216239
acceptable = !ui->passEdit2->text().isEmpty() && !ui->passEdit3->text().isEmpty();
217240
break;
241+
case UnlockStaking:
218242
case Unlock: // Old passphrase x1
219243
acceptable = !ui->passEdit1->text().isEmpty();
220244
break;

src/qt/askpassphrasedialog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class AskPassphraseDialog : public QDialog
2424
public:
2525
enum Mode {
2626
Encrypt, /**< Ask passphrase twice and encrypt */
27+
UnlockStaking, /**< Ask passphrase and unlock staking only */
2728
Unlock, /**< Ask passphrase and unlock */
2829
ChangePass, /**< Ask old passphrase + new passphrase twice */
2930
};

0 commit comments

Comments
 (0)