0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-03 09:56:38 -05:00

gui: Add wallet name to address book page

Extend addresstablemodel to return the display name from the wallet and
set it to the addressbookpage window title when its  model is set.
This commit is contained in:
pablomartin4btc 2023-09-13 15:01:38 -03:00
parent ab163b0fb5
commit 58c9b50a95
4 changed files with 20 additions and 11 deletions

View file

@ -81,9 +81,7 @@ AddressBookPage::AddressBookPage(const PlatformStyle *platformStyle, Mode _mode,
ui->exportButton->setIcon(platformStyle->SingleColorIcon(":/icons/export")); ui->exportButton->setIcon(platformStyle->SingleColorIcon(":/icons/export"));
} }
switch(mode) if (mode == ForSelection) {
{
case ForSelection:
switch(tab) switch(tab)
{ {
case SendingTab: setWindowTitle(tr("Choose the address to send coins to")); break; case SendingTab: setWindowTitle(tr("Choose the address to send coins to")); break;
@ -94,14 +92,6 @@ AddressBookPage::AddressBookPage(const PlatformStyle *platformStyle, Mode _mode,
ui->tableView->setFocus(); ui->tableView->setFocus();
ui->closeButton->setText(tr("C&hoose")); ui->closeButton->setText(tr("C&hoose"));
ui->exportButton->hide(); 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) switch(tab)
{ {
@ -164,6 +154,7 @@ void AddressBookPage::setModel(AddressTableModel *_model)
connect(_model, &AddressTableModel::rowsInserted, this, &AddressBookPage::selectNewAddress); connect(_model, &AddressTableModel::rowsInserted, this, &AddressBookPage::selectNewAddress);
selectionChanged(); selectionChanged();
this->updateWindowsTitleWithWalletName();
} }
void AddressBookPage::on_copyAddress_clicked() void AddressBookPage::on_copyAddress_clicked()
@ -328,3 +319,16 @@ void AddressBookPage::selectNewAddress(const QModelIndex &parent, int begin, int
newAddressToSelect.clear(); 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;
}
}
}

View file

@ -56,6 +56,7 @@ private:
AddressBookSortFilterProxyModel *proxyModel; AddressBookSortFilterProxyModel *proxyModel;
QMenu *contextMenu; QMenu *contextMenu;
QString newAddressToSelect; QString newAddressToSelect;
void updateWindowsTitleWithWalletName();
private Q_SLOTS: private Q_SLOTS:
/** Delete currently selected address entry */ /** Delete currently selected address entry */

View file

@ -451,3 +451,5 @@ void AddressTableModel::emitDataChanged(int idx)
{ {
Q_EMIT dataChanged(index(idx, 0, QModelIndex()), index(idx, columns.length()-1, QModelIndex())); Q_EMIT dataChanged(index(idx, 0, QModelIndex()), index(idx, columns.length()-1, QModelIndex()));
} }
QString AddressTableModel::GetWalletDisplayName() const { return walletModel->getDisplayName(); };

View file

@ -87,6 +87,8 @@ public:
OutputType GetDefaultAddressType() const; OutputType GetDefaultAddressType() const;
QString GetWalletDisplayName() const;
private: private:
WalletModel* const walletModel; WalletModel* const walletModel;
AddressTablePriv *priv = nullptr; AddressTablePriv *priv = nullptr;