Skip to content

Commit 58c9b50

Browse files
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.
1 parent ab163b0 commit 58c9b50

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

src/qt/addressbookpage.cpp

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,7 @@ AddressBookPage::AddressBookPage(const PlatformStyle *platformStyle, Mode _mode,
8181
ui->exportButton->setIcon(platformStyle->SingleColorIcon(":/icons/export"));
8282
}
8383

84-
switch(mode)
85-
{
86-
case ForSelection:
84+
if (mode == ForSelection) {
8785
switch(tab)
8886
{
8987
case SendingTab: setWindowTitle(tr("Choose the address to send coins to")); break;
@@ -94,14 +92,6 @@ AddressBookPage::AddressBookPage(const PlatformStyle *platformStyle, Mode _mode,
9492
ui->tableView->setFocus();
9593
ui->closeButton->setText(tr("C&hoose"));
9694
ui->exportButton->hide();
97-
break;
98-
case ForEditing:
99-
switch(tab)
100-
{
101-
case SendingTab: setWindowTitle(tr("Sending addresses")); break;
102-
case ReceivingTab: setWindowTitle(tr("Receiving addresses")); break;
103-
}
104-
break;
10595
}
10696
switch(tab)
10797
{
@@ -164,6 +154,7 @@ void AddressBookPage::setModel(AddressTableModel *_model)
164154
connect(_model, &AddressTableModel::rowsInserted, this, &AddressBookPage::selectNewAddress);
165155

166156
selectionChanged();
157+
this->updateWindowsTitleWithWalletName();
167158
}
168159

169160
void AddressBookPage::on_copyAddress_clicked()
@@ -328,3 +319,16 @@ void AddressBookPage::selectNewAddress(const QModelIndex &parent, int begin, int
328319
newAddressToSelect.clear();
329320
}
330321
}
322+
323+
void AddressBookPage::updateWindowsTitleWithWalletName()
324+
{
325+
const QString walletName = this->model->GetWalletDisplayName();
326+
327+
if (mode == ForEditing) {
328+
switch(tab)
329+
{
330+
case SendingTab: setWindowTitle(tr("Sending addresses - %1").arg(walletName)); break;
331+
case ReceivingTab: setWindowTitle(tr("Receiving addresses - %1").arg(walletName)); break;
332+
}
333+
}
334+
}

src/qt/addressbookpage.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public Q_SLOTS:
5656
AddressBookSortFilterProxyModel *proxyModel;
5757
QMenu *contextMenu;
5858
QString newAddressToSelect;
59+
void updateWindowsTitleWithWalletName();
5960

6061
private Q_SLOTS:
6162
/** Delete currently selected address entry */

src/qt/addresstablemodel.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,3 +451,5 @@ void AddressTableModel::emitDataChanged(int idx)
451451
{
452452
Q_EMIT dataChanged(index(idx, 0, QModelIndex()), index(idx, columns.length()-1, QModelIndex()));
453453
}
454+
455+
QString AddressTableModel::GetWalletDisplayName() const { return walletModel->getDisplayName(); };

src/qt/addresstablemodel.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ class AddressTableModel : public QAbstractTableModel
8787

8888
OutputType GetDefaultAddressType() const;
8989

90+
QString GetWalletDisplayName() const;
91+
9092
private:
9193
WalletModel* const walletModel;
9294
AddressTablePriv *priv = nullptr;

0 commit comments

Comments
 (0)