Skip to content

Commit

Permalink
Ui fixes (#1366)
Browse files Browse the repository at this point in the history
* Exclude RAP from addressbook

* RAP Addresses tab removed

* Disable spark addressbook untill HF

* Make igonre button default

* Button colors switched
  • Loading branch information
levonpetrosyan93 authored Nov 26, 2023
1 parent 9b4e7ef commit 39c41e5
Show file tree
Hide file tree
Showing 15 changed files with 76 additions and 58 deletions.
64 changes: 37 additions & 27 deletions src/qt/addressbookpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,7 @@ AddressBookPage::AddressBookPage(const PlatformStyle *platformStyle, Mode _mode,
tab(_tab)
{
ui->setupUi(this);

if (tab == SendingTab) {
ui->addressType->addItem(tr("Spark"), Spark);
ui->addressType->addItem(tr("Transparent"), Transparent);
ui->addressType->addItem(tr("RAP"), RAP);
} else if(tab == ReceivingTab && !isReused) {
ui->addressType->addItem(tr("Spark"), Spark);
ui->addressType->addItem(tr("Transparent"), Transparent);
} else {
ui->addressType->addItem(tr(""), Transparent);
ui->addressType->addItem(tr("Transparent"), Transparent);
ui->addressType->hide();
}
this->isReused = isReused;

if (!platformStyle->getImagesOnButtons()) {
ui->newAddress->setIcon(QIcon());
Expand Down Expand Up @@ -127,6 +115,23 @@ void AddressBookPage::setModel(AddressTableModel *_model)
this->model = _model;
if(!_model)
return;
bool spark = this->model->IsSparkAllowed();

if (tab == SendingTab) {
if (spark) {
ui->addressType->addItem(tr("Spark"), Spark);
}
ui->addressType->addItem(tr("Transparent"), Transparent);
} else if(tab == ReceivingTab && !this->isReused) {
if (spark) {
ui->addressType->addItem(tr("Spark"), Spark);
}
ui->addressType->addItem(tr("Transparent"), Transparent);
} else {
ui->addressType->addItem(tr(""), Transparent);
ui->addressType->addItem(tr("Transparent"), Transparent);
ui->addressType->hide();
}

proxyModel = new QSortFilterProxyModel(this);
fproxyModel = new AddressBookFilterProxy(this);
Expand Down Expand Up @@ -174,6 +179,23 @@ void AddressBookPage::setModel(AddressTableModel *_model)
connect(ui->addressType, qOverload<int>(&QComboBox::activated), this, &AddressBookPage::chooseAddressType);
}

void AddressBookPage::updateSpark() {
ui->addressType->clear();
if (tab == SendingTab) {
ui->addressType->addItem(tr("Spark"), Spark);
ui->addressType->addItem(tr("Transparent"), Transparent);
} else if(tab == ReceivingTab && !this->isReused) {
ui->addressType->addItem(tr("Spark"), Spark);
ui->addressType->addItem(tr("Transparent"), Transparent);
} else {
ui->addressType->addItem(tr(""), Transparent);
ui->addressType->addItem(tr("Transparent"), Transparent);
ui->addressType->hide();
}

chooseAddressType(0);
}

void AddressBookPage::on_copyAddress_clicked()
{
GUIUtil::copyEntryData(ui->tableView, AddressTableModel::Address);
Expand All @@ -191,9 +213,7 @@ void AddressBookPage::onEditAction()
EditAddressDialog::Mode mode;
AddressTableModel * pmodel;
pmodel = model;
if (ui->addressType->currentText() == AddressTableModel::RAP) {
mode = EditAddressDialog::EditPcode;
} else if (ui->addressType->currentText() == AddressTableModel::Transparent) {
if (ui->addressType->currentText() == AddressTableModel::Transparent) {
mode = tab == SendingTab ? EditAddressDialog::EditSendingAddress : EditAddressDialog::EditReceivingAddress;
} else {
mode = tab == SendingTab ? EditAddressDialog::EditSparkSendingAddress : EditAddressDialog::EditSparkReceivingAddress;
Expand Down Expand Up @@ -224,8 +244,6 @@ void AddressBookPage::on_newAddress_clicked()
pmodel = model;
if (ui->addressType->currentText() == AddressTableModel::Spark) {
mode = tab == SendingTab ? EditAddressDialog::NewSparkSendingAddress : EditAddressDialog::NewSparkReceivingAddress;
} else if (ui->addressType->currentText() == AddressTableModel::RAP) {
mode = EditAddressDialog::NewPcode;
} else {
mode = tab == SendingTab ? EditAddressDialog::NewSendingAddress : EditAddressDialog::NewReceivingAddress;
}
Expand Down Expand Up @@ -333,10 +351,6 @@ void AddressBookPage::on_exportButton_clicked()
writer.addColumn("Label", AddressTableModel::Label, Qt::EditRole);
writer.addColumn("Transparent Address", AddressTableModel::Address, Qt::EditRole);
writer.addColumn("Address Type", AddressTableModel::AddressType, Qt::EditRole);
} else if (ui->addressType->currentText() == AddressTableModel::RAP) {
writer.addColumn("Label", AddressTableModel::Label, Qt::EditRole);
writer.addColumn("PaymentCode", AddressTableModel::Address, Qt::EditRole);
writer.addColumn("Address Type", AddressTableModel::AddressType, Qt::EditRole);
} else {
writer.addColumn("Label", AddressTableModel::Label, Qt::EditRole);
writer.addColumn("Spark Address", AddressTableModel::Address, Qt::EditRole);
Expand All @@ -356,8 +370,6 @@ void AddressBookPage::contextualMenu(const QPoint &point)

if (ui->addressType->currentText() == "Spark") {
copyAddressAction->setText(tr("&Copy Spark Address"));
} else if (ui->addressType->currentText() == "RAP") {
copyAddressAction->setText(tr("&Copy RAP address"));
} else {
copyAddressAction->setText(tr("&Copy Transparent Address"));
}
Expand Down Expand Up @@ -397,14 +409,12 @@ bool AddressBookFilterProxy::filterAcceptsRow(int sourceRow, const QModelIndex &
QModelIndex index = sourceModel()->index(sourceRow, 2, sourceParent);
bool res0 = sourceModel()->data(index).toString().contains("spark");
bool res1 = sourceModel()->data(index).toString().contains("transparent");
bool res2 = sourceModel()->data(index).toString().contains("RAP");

if(res0 && typeFilter == 0)
return true;
if(res1 && typeFilter == 1)
return true;
if(res2 && typeFilter == 2)
return true;

return false;
}

Expand Down
6 changes: 4 additions & 2 deletions src/qt/addressbookpage.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ class AddressBookPage : public QDialog
enum AddressTypeEnum
{
Spark,
Transparent,
RAP
Transparent
};

explicit AddressBookPage(const PlatformStyle *platformStyle, Mode mode, Tabs tab, QWidget *parent, bool isReused = true);
Expand All @@ -55,6 +54,8 @@ class AddressBookPage : public QDialog
void setModel(AddressTableModel *model);
const QString &getReturnValue() const { return returnValue; }

void updateSpark();

public Q_SLOTS:
void done(int retval);

Expand All @@ -70,6 +71,7 @@ public Q_SLOTS:
QAction *copyAddressAction;
QAction *deleteAction; // to be able to explicitly disable it
QString newAddressToSelect;
bool isReused;

private Q_SLOTS:
/** Delete currently selected address entry */
Expand Down
5 changes: 5 additions & 0 deletions src/qt/addresstablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,11 @@ PcodeAddressTableModel * AddressTableModel::getPcodeAddressTableModel()
return walletModel->getPcodeAddressTableModel();
}

bool AddressTableModel::IsSparkAllowed(){
return spark::IsSparkAllowed();
}


// RAP pcodes

static void NotifyPcodeLabeled(PcodeAddressTableModel *walletmodel, std::string pcode, std::string label, bool removed)
Expand Down
2 changes: 2 additions & 0 deletions src/qt/addresstablemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ class AddressTableModel : public QAbstractTableModel
EditStatus getEditStatus() const { return editStatus; }

PcodeAddressTableModel * getPcodeAddressTableModel();

bool IsSparkAllowed();
protected:
WalletModel *walletModel;
CWallet *wallet;
Expand Down
2 changes: 1 addition & 1 deletion src/qt/bitcoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ void BitcoinApplication::unlockWallet_(void * wallet)
{
CWallet * wallet_ = reinterpret_cast<CWallet *>(wallet);

QString info = tr("You need to unlock to allow spark wallet be created.");
QString info = tr("You need to unlock to allow Spark wallet be created.");

walletModel = new WalletModel(platformStyle, wallet_, optionsModel);

Expand Down
3 changes: 3 additions & 0 deletions src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1517,6 +1517,9 @@ void BitcoinGUI::checkLelantusVisibility(int numBlocks)
}
lelantusAction->setVisible(allowLelantusPage);
}

if (numBlocks == ::Params().GetConsensus().nSparkStartBlock)
walletFrame->updateAddressbook();
}

void BitcoinGUI::toggleNetworkActive()
Expand Down
10 changes: 0 additions & 10 deletions src/qt/forms/optionsdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -173,16 +173,6 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="enableRapAddresses">
<property name="toolTip">
<string>Whether to show RAP addresses or not.</string>
</property>
<property name="text">
<string>Display RAP addresses</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down
1 change: 0 additions & 1 deletion src/qt/optionsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ void OptionsDialog::setMapper()
mapper->addMapping(ui->spendZeroConfChange, OptionsModel::SpendZeroConfChange);
mapper->addMapping(ui->reindexLelantus, OptionsModel::ReindexLelantus);
mapper->addMapping(ui->coinControlFeatures, OptionsModel::CoinControlFeatures);
mapper->addMapping(ui->enableRapAddresses, OptionsModel::enableRapAddresses);

/* Lelantus */
mapper->addMapping(ui->autoAnonymize, OptionsModel::AutoAnonymize);
Expand Down
11 changes: 0 additions & 11 deletions src/qt/optionsmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,6 @@ void OptionsModel::Init(bool resetSettings)
settings.setValue("fCoinControlFeatures", false);
fCoinControlFeatures = settings.value("fCoinControlFeatures", false).toBool();

if (!settings.contains("fenableRapAddresses"))
settings.setValue("fenableRapAddresses", false);
fenableRapAddresses = settings.value("fenableRapAddresses", false).toBool();

if (!settings.contains("fAutoAnonymize"))
settings.setValue("fAutoAnonymize", false);
fAutoAnonymize = settings.value("fAutoAnonymize", false).toBool();
Expand Down Expand Up @@ -281,8 +277,6 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const
return settings.value("language");
case CoinControlFeatures:
return fCoinControlFeatures;
case enableRapAddresses:
return fenableRapAddresses;
case AutoAnonymize:
return fAutoAnonymize;
case LelantusPage:
Expand Down Expand Up @@ -430,11 +424,6 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
settings.setValue("fCoinControlFeatures", fCoinControlFeatures);
Q_EMIT coinControlFeaturesChanged(fCoinControlFeatures);
break;
case enableRapAddresses:
fenableRapAddresses = value.toBool();
settings.setValue("fenableRapAddresses", fenableRapAddresses);
Q_EMIT enableRapAddressesChanged(fenableRapAddresses);
break;
case AutoAnonymize:
fAutoAnonymize = value.toBool();
settings.setValue("fAutoAnonymize", fAutoAnonymize);
Expand Down
8 changes: 4 additions & 4 deletions src/qt/overviewpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,10 +425,10 @@ MigrateLelantusToSparkDialog::MigrateLelantusToSparkDialog(WalletModel *_model):

QPushButton *ignore = new QPushButton(this);
ignore->setText("Ignore");
ignore->setStyleSheet("color:#9b1c2e;background-color:none;margin-top:30px;margin-bottom:60px;margin-left:50px;margin-right:20px;border:1px solid #9b1c2e;");
ignore->setStyleSheet("margin-top:30px;margin-bottom:60px;margin-left:20px;margin-right:50px;");
QPushButton *migrate = new QPushButton(this);
migrate->setText("Migrate");
migrate->setStyleSheet("margin-top:30px;margin-bottom:60px;margin-left:20px;margin-right:50px;");
migrate->setStyleSheet("color:#9b1c2e;background-color:none;margin-top:30px;margin-bottom:60px;margin-left:50px;margin-right:20px;border:1px solid #9b1c2e;");
QHBoxLayout *groupButton = new QHBoxLayout(this);
groupButton->addWidget(ignore);
groupButton->addWidget(migrate);
Expand Down Expand Up @@ -462,13 +462,13 @@ MigrateLelantusToSparkDialog::MigrateLelantusToSparkDialog(WalletModel *_model):
void MigrateLelantusToSparkDialog::onIgnoreClicked()
{
setVisible(false);
clickedButton = false;
clickedButton = true;
}

void MigrateLelantusToSparkDialog::onMigrateClicked()
{
setVisible(false);
clickedButton = true;
clickedButton = false;
model->migrateLelantusToSpark();
}

Expand Down
4 changes: 2 additions & 2 deletions src/qt/sendcoinsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ void SendCoinsDialog::on_sendButton_clicked()
if (model->getLelantusModel()->getPrivateBalance().first > 0 && spark::IsSparkAllowed() && chainActive.Height() < ::Params().GetConsensus().nLelantusGracefulPeriod) {
MigrateLelantusToSparkDialog migrateLelantusToSpark(model);
bool clickedButton = migrateLelantusToSpark.getClickedButton();
if(clickedButton) {
if(!clickedButton) {
fNewRecipientAllowed = true;
return;
}
Expand All @@ -343,7 +343,7 @@ void SendCoinsDialog::on_sendButton_clicked()
if (spark::IsSparkAllowed()) {
SendGoPrivateDialog goPrivateDialog;
bool clickedButton = goPrivateDialog.getClickedButton();
if (clickedButton) {
if (!clickedButton) {
setAnonymizeMode(true);
fNewRecipientAllowed = true;
return;
Expand Down
7 changes: 7 additions & 0 deletions src/qt/walletframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,3 +259,10 @@ void WalletFrame::outOfSyncWarningClicked()
{
Q_EMIT requestedSyncWarningInfo();
}

void WalletFrame::updateAddressbook() {
WalletView *walletView = currentWalletView();

if (walletView)
walletView->updateAddressbook();
}
2 changes: 2 additions & 0 deletions src/qt/walletframe.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ public Q_SLOTS:
void usedReceivingAddresses();
/** Pass on signal over requested out-of-sync-warning information */
void outOfSyncWarningClicked();

void updateAddressbook();
};

#endif // BITCOIN_QT_WALLETFRAME_H
6 changes: 6 additions & 0 deletions src/qt/walletview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,12 @@ void WalletView::usedSendingAddresses()
usedSendingAddressesPage->activateWindow();
}

void WalletView::updateAddressbook()
{
usedReceivingAddressesPage->updateSpark();
usedSendingAddressesPage->updateSpark();
}

void WalletView::usedReceivingAddresses()
{
if(!walletModel)
Expand Down
3 changes: 3 additions & 0 deletions src/qt/walletview.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ public Q_SLOTS:

/** Show used sending addresses */
void usedSendingAddresses();

void updateAddressbook();

/** Show used receiving addresses */
void usedReceivingAddresses();

Expand Down

0 comments on commit 39c41e5

Please sign in to comment.