Skip to content

Commit

Permalink
Porting qt folder to qtum core 26
Browse files Browse the repository at this point in the history
  • Loading branch information
toniqtum committed Apr 9, 2024
1 parent d54ff90 commit e8c013b
Show file tree
Hide file tree
Showing 332 changed files with 15,900 additions and 10,459 deletions.
25 changes: 16 additions & 9 deletions src/qt/addressbookpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <qt/editaddressdialog.h>
#include <qt/guiutil.h>
#include <qt/platformstyle.h>
#include <qt/styleSheet.h>

#include <QIcon>
#include <QMenu>
Expand Down Expand Up @@ -67,20 +68,27 @@ AddressBookPage::AddressBookPage(const PlatformStyle *platformStyle, Mode _mode,
mode(_mode),
tab(_tab)
{
ui->setupUi(this);

ui->setupUi(this);
SetObjectStyleSheet(ui->tableView, StyleSheetNames::TableViewLight);
setStyleSheet("");
if (!platformStyle->getImagesOnButtons()) {
ui->newAddress->setIcon(QIcon());
ui->copyAddress->setIcon(QIcon());
ui->deleteAddress->setIcon(QIcon());
ui->exportButton->setIcon(QIcon());
} else {
ui->newAddress->setIcon(platformStyle->SingleColorIcon(":/icons/add"));
ui->copyAddress->setIcon(platformStyle->SingleColorIcon(":/icons/editcopy"));
ui->deleteAddress->setIcon(platformStyle->SingleColorIcon(":/icons/remove"));
ui->exportButton->setIcon(platformStyle->SingleColorIcon(":/icons/export"));
ui->newAddress->setIcon(platformStyle->MultiStatesIcon(":/icons/add", PlatformStyle::PushButtonLight));
ui->copyAddress->setIcon(platformStyle->MultiStatesIcon(":/icons/editcopy", PlatformStyle::PushButtonLight));
ui->deleteAddress->setIcon(platformStyle->MultiStatesIcon(":/icons/remove", PlatformStyle::PushButtonLight));
ui->exportButton->setIcon(platformStyle->MultiStatesIcon(":/icons/export", PlatformStyle::PushButton));
}

SetObjectStyleSheet(ui->newAddress, StyleSheetNames::ButtonLight);
SetObjectStyleSheet(ui->copyAddress, StyleSheetNames::ButtonLight);
SetObjectStyleSheet(ui->deleteAddress, StyleSheetNames::ButtonLight);
SetObjectStyleSheet(ui->exportButton, StyleSheetNames::ButtonGray);
SetObjectStyleSheet(ui->closeButton, StyleSheetNames::ButtonGray);

if (mode == ForSelection) {
switch(tab)
{
Expand All @@ -96,12 +104,11 @@ AddressBookPage::AddressBookPage(const PlatformStyle *platformStyle, Mode _mode,
switch(tab)
{
case SendingTab:
ui->labelExplanation->setText(tr("These are your Bitcoin addresses for sending payments. Always check the amount and the receiving address before sending coins."));
ui->deleteAddress->setVisible(true);
ui->labelExplanation->setText(tr("These are your Qtum addresses for sending payments. Always check the amount and the receiving address before sending coins."));
ui->newAddress->setVisible(true);
break;
case ReceivingTab:
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'."));
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'."));
ui->deleteAddress->setVisible(false);
ui->newAddress->setVisible(false);
break;
Expand Down
24 changes: 20 additions & 4 deletions src/qt/addresstablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,11 +406,27 @@ bool AddressTableModel::removeRows(int row, int count, const QModelIndex &parent
return true;
}

QString AddressTableModel::labelForAddress(const QString &address) const
QString AddressTableModel::labelForAddress(const QString &address, bool cached) const
{
std::string name;
if (getAddressData(address, &name, /* purpose= */ nullptr)) {
return QString::fromStdString(name);
if(cached)
{
// Find address / label in model
QList<AddressTableEntry>::iterator lower = std::lower_bound(
priv->cachedAddressTable.begin(), priv->cachedAddressTable.end(), address, AddressTableEntryLessThan());
QList<AddressTableEntry>::iterator upper = std::upper_bound(
priv->cachedAddressTable.begin(), priv->cachedAddressTable.end(), address, AddressTableEntryLessThan());
bool inModel = (lower != upper);
if(inModel)
{
return lower->label;
}
}
else
{
std::string name;
if (getAddressData(address, &name, /* purpose= */ nullptr)) {
return QString::fromStdString(name);
}
}
return QString();
}
Expand Down
2 changes: 1 addition & 1 deletion src/qt/addresstablemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class AddressTableModel : public QAbstractTableModel
QString addRow(const QString &type, const QString &label, const QString &address, const OutputType address_type);

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

/** Look up purpose for address in address book, if not found return empty string. */
std::optional<wallet::AddressPurpose> purposeForAddress(const QString &address) const;
Expand Down
24 changes: 22 additions & 2 deletions src/qt/askpassphrasedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
#include <qt/guiconstants.h>
#include <qt/guiutil.h>
#include <qt/walletmodel.h>
#include <qt/styleSheet.h>
#include <wallet/wallet.h>
#include <node/miner.h>

#include <support/allocators/secure.h>

Expand All @@ -27,6 +30,8 @@ AskPassphraseDialog::AskPassphraseDialog(Mode _mode, QWidget *parent, SecureStri
{
ui->setupUi(this);

SetObjectStyleSheet(ui->buttonBox->button(QDialogButtonBox::Cancel), StyleSheetNames::ButtonLight);
SetObjectStyleSheet(ui->buttonBox->button(QDialogButtonBox::Ok), StyleSheetNames::ButtonGray);
ui->passEdit1->setMinimumSize(ui->passEdit1->sizeHint());
ui->passEdit2->setMinimumSize(ui->passEdit2->sizeHint());
ui->passEdit3->setMinimumSize(ui->passEdit3->sizeHint());
Expand All @@ -40,6 +45,7 @@ AskPassphraseDialog::AskPassphraseDialog(Mode _mode, QWidget *parent, SecureStri
ui->passEdit2->installEventFilter(this);
ui->passEdit3->installEventFilter(this);

ui->stakingCheckBox->hide();
switch(mode)
{
case Encrypt: // Ask passphrase x2
Expand All @@ -48,6 +54,10 @@ AskPassphraseDialog::AskPassphraseDialog(Mode _mode, QWidget *parent, SecureStri
ui->passEdit1->hide();
setWindowTitle(tr("Encrypt wallet"));
break;
case UnlockStaking:
ui->stakingCheckBox->setChecked(true);
ui->stakingCheckBox->show();
[[fallthrough]];
case Unlock: // Ask passphrase
ui->warningLabel->setText(tr("This operation needs your wallet passphrase to unlock the wallet."));
ui->passLabel2->hide();
Expand Down Expand Up @@ -79,6 +89,7 @@ AskPassphraseDialog::~AskPassphraseDialog()
void AskPassphraseDialog::setModel(WalletModel *_model)
{
this->model = _model;
if(model) ui->stakingCheckBox->setChecked(model->getWalletUnlockStakingOnly() || mode == UnlockStaking);
}

void AskPassphraseDialog::accept()
Expand All @@ -105,15 +116,15 @@ void AskPassphraseDialog::accept()
break;
}
QMessageBox::StandardButton retval = QMessageBox::question(this, 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?"),
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?"),
QMessageBox::Yes|QMessageBox::Cancel,
QMessageBox::Cancel);
if(retval == QMessageBox::Yes)
{
if(newpass1 == newpass2)
{
QString encryption_reminder = tr("Remember that encrypting your wallet cannot fully protect "
"your bitcoins from being stolen by malware infecting your computer.");
"your qtums from being stolen by malware infecting your computer.");
if (m_passphrase_out) {
m_passphrase_out->assign(newpass1);
QMessageBox::warning(this, tr("Wallet to be encrypted"),
Expand Down Expand Up @@ -150,6 +161,7 @@ void AskPassphraseDialog::accept()
QDialog::reject(); // Cancelled
}
} break;
case UnlockStaking:
case Unlock:
try {
if (!model->setWalletLocked(false, oldpass)) {
Expand All @@ -170,6 +182,13 @@ void AskPassphraseDialog::accept()
if (m_passphrase_out) {
m_passphrase_out->assign(oldpass);
}
model->setWalletUnlockStakingOnly(ui->stakingCheckBox->isChecked());
if(UnlockStaking == mode)
{
// Start the staking if enabled on the machine
bool staking = node::CanStake();
model->wallet().setEnabledStaking(staking);
}
QDialog::accept(); // Success
}
} catch (const std::runtime_error& e) {
Expand Down Expand Up @@ -219,6 +238,7 @@ void AskPassphraseDialog::textChanged()
case Encrypt: // New passphrase x2
acceptable = !ui->passEdit2->text().isEmpty() && !ui->passEdit3->text().isEmpty();
break;
case UnlockStaking:
case Unlock: // Old passphrase x1
acceptable = !ui->passEdit1->text().isEmpty();
break;
Expand Down
1 change: 1 addition & 0 deletions src/qt/askpassphrasedialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class AskPassphraseDialog : public QDialog
public:
enum Mode {
Encrypt, /**< Ask passphrase twice and encrypt */
UnlockStaking, /**< Ask passphrase and unlock staking only */
Unlock, /**< Ask passphrase and unlock */
ChangePass, /**< Ask old passphrase + new passphrase twice */
};
Expand Down
Loading

0 comments on commit e8c013b

Please sign in to comment.