Bitcoin-Qt: updates to addressbookpage

- use labelExplanation for sending and receiving tab and move the string
  from the ui-file to the source
- ensure that the table holding the label and address is resized so that
  the address column fits the address and the label column is stretched to
  fit the window size
- rename some stuff for much easier readbility in the code (I find it hard
  to get the meaning of stuff like labels or buttons)
This commit is contained in:
Philip Kaufmann 2013-04-02 12:08:13 +02:00
parent 4240bdaac1
commit b9564d7e54
3 changed files with 30 additions and 35 deletions

View File

@ -51,25 +51,26 @@ AddressBookPage::AddressBookPage(Mode mode, Tabs tab, QWidget *parent) :
switch(tab) switch(tab)
{ {
case SendingTab: case SendingTab:
ui->labelExplanation->setVisible(false); ui->labelExplanation->setText(tr("These are your Bitcoin addresses for sending payments. Always check the amount and the receiving address before sending coins."));
ui->deleteButton->setVisible(true); ui->deleteAddress->setVisible(true);
ui->signMessage->setVisible(false); ui->signMessage->setVisible(false);
break; break;
case ReceivingTab: case ReceivingTab:
ui->deleteButton->setVisible(false); ui->labelExplanation->setText(tr("These are your Bitcoin addresses for receiving payments. You may want to give a different one to each sender so you can keep track of who is paying you."));
ui->deleteAddress->setVisible(false);
ui->signMessage->setVisible(true); ui->signMessage->setVisible(true);
break; break;
} }
// Context menu actions // Context menu actions
QAction *copyAddressAction = new QAction(ui->copyToClipboard->text(), this); QAction *copyAddressAction = new QAction(ui->copyAddress->text(), this);
QAction *copyLabelAction = new QAction(tr("Copy &Label"), this); QAction *copyLabelAction = new QAction(tr("Copy &Label"), this);
QAction *editAction = new QAction(tr("&Edit"), this); QAction *editAction = new QAction(tr("&Edit"), this);
QAction *sendCoinsAction = new QAction(tr("Send &Coins"), this); QAction *sendCoinsAction = new QAction(tr("Send &Coins"), this);
QAction *showQRCodeAction = new QAction(ui->showQRCode->text(), this); QAction *showQRCodeAction = new QAction(ui->showQRCode->text(), this);
QAction *signMessageAction = new QAction(ui->signMessage->text(), this); QAction *signMessageAction = new QAction(ui->signMessage->text(), this);
QAction *verifyMessageAction = new QAction(ui->verifyMessage->text(), this); QAction *verifyMessageAction = new QAction(ui->verifyMessage->text(), this);
deleteAction = new QAction(ui->deleteButton->text(), this); deleteAction = new QAction(ui->deleteAddress->text(), this);
// Build context menu // Build context menu
contextMenu = new QMenu(); contextMenu = new QMenu();
@ -90,11 +91,11 @@ AddressBookPage::AddressBookPage(Mode mode, Tabs tab, QWidget *parent) :
contextMenu->addAction(verifyMessageAction); contextMenu->addAction(verifyMessageAction);
// Connect signals for context menu actions // Connect signals for context menu actions
connect(copyAddressAction, SIGNAL(triggered()), this, SLOT(on_copyToClipboard_clicked())); connect(copyAddressAction, SIGNAL(triggered()), this, SLOT(on_copyAddress_clicked()));
connect(copyLabelAction, SIGNAL(triggered()), this, SLOT(onCopyLabelAction())); connect(copyLabelAction, SIGNAL(triggered()), this, SLOT(onCopyLabelAction()));
connect(editAction, SIGNAL(triggered()), this, SLOT(onEditAction())); connect(editAction, SIGNAL(triggered()), this, SLOT(onEditAction()));
connect(deleteAction, SIGNAL(triggered()), this, SLOT(on_deleteButton_clicked())); connect(deleteAction, SIGNAL(triggered()), this, SLOT(on_deleteAddress_clicked()));
connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(onSendCoins_clicked())); connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(onSendCoinsAction()));
connect(showQRCodeAction, SIGNAL(triggered()), this, SLOT(on_showQRCode_clicked())); connect(showQRCodeAction, SIGNAL(triggered()), this, SLOT(on_showQRCode_clicked()));
connect(signMessageAction, SIGNAL(triggered()), this, SLOT(on_signMessage_clicked())); connect(signMessageAction, SIGNAL(triggered()), this, SLOT(on_signMessage_clicked()));
connect(verifyMessageAction, SIGNAL(triggered()), this, SLOT(on_verifyMessage_clicked())); connect(verifyMessageAction, SIGNAL(triggered()), this, SLOT(on_verifyMessage_clicked()));
@ -138,17 +139,14 @@ void AddressBookPage::setModel(AddressTableModel *model)
ui->tableView->sortByColumn(0, Qt::AscendingOrder); ui->tableView->sortByColumn(0, Qt::AscendingOrder);
// Set column widths // Set column widths
ui->tableView->horizontalHeader()->resizeSection( ui->tableView->horizontalHeader()->setResizeMode(AddressTableModel::Label, QHeaderView::Stretch);
AddressTableModel::Address, 320); ui->tableView->horizontalHeader()->setResizeMode(AddressTableModel::Address, QHeaderView::ResizeToContents);
ui->tableView->horizontalHeader()->setResizeMode(
AddressTableModel::Label, QHeaderView::Stretch);
connect(ui->tableView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), connect(ui->tableView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
this, SLOT(selectionChanged())); this, SLOT(selectionChanged()));
// Select row for newly created address // Select row for newly created address
connect(model, SIGNAL(rowsInserted(QModelIndex,int,int)), connect(model, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(selectNewAddress(QModelIndex,int,int)));
this, SLOT(selectNewAddress(QModelIndex,int,int)));
selectionChanged(); selectionChanged();
} }
@ -158,7 +156,7 @@ void AddressBookPage::setOptionsModel(OptionsModel *optionsModel)
this->optionsModel = optionsModel; this->optionsModel = optionsModel;
} }
void AddressBookPage::on_copyToClipboard_clicked() void AddressBookPage::on_copyAddress_clicked()
{ {
GUIUtil::copyEntryData(ui->tableView, AddressTableModel::Address); GUIUtil::copyEntryData(ui->tableView, AddressTableModel::Address);
} }
@ -210,7 +208,7 @@ void AddressBookPage::on_verifyMessage_clicked()
} }
} }
void AddressBookPage::onSendCoins_clicked() void AddressBookPage::onSendCoinsAction()
{ {
QTableView *table = ui->tableView; QTableView *table = ui->tableView;
QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address); QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address);
@ -222,7 +220,7 @@ void AddressBookPage::onSendCoins_clicked()
} }
} }
void AddressBookPage::on_newAddressButton_clicked() void AddressBookPage::on_newAddress_clicked()
{ {
if(!model) if(!model)
return; return;
@ -238,7 +236,7 @@ void AddressBookPage::on_newAddressButton_clicked()
} }
} }
void AddressBookPage::on_deleteButton_clicked() void AddressBookPage::on_deleteAddress_clicked()
{ {
QTableView *table = ui->tableView; QTableView *table = ui->tableView;
if(!table->selectionModel()) if(!table->selectionModel())
@ -264,8 +262,8 @@ void AddressBookPage::selectionChanged()
{ {
case SendingTab: case SendingTab:
// In sending tab, allow deletion of selection // In sending tab, allow deletion of selection
ui->deleteButton->setEnabled(true); ui->deleteAddress->setEnabled(true);
ui->deleteButton->setVisible(true); ui->deleteAddress->setVisible(true);
deleteAction->setEnabled(true); deleteAction->setEnabled(true);
ui->signMessage->setEnabled(false); ui->signMessage->setEnabled(false);
ui->signMessage->setVisible(false); ui->signMessage->setVisible(false);
@ -274,8 +272,8 @@ void AddressBookPage::selectionChanged()
break; break;
case ReceivingTab: case ReceivingTab:
// Deleting receiving addresses, however, is not allowed // Deleting receiving addresses, however, is not allowed
ui->deleteButton->setEnabled(false); ui->deleteAddress->setEnabled(false);
ui->deleteButton->setVisible(false); ui->deleteAddress->setVisible(false);
deleteAction->setEnabled(false); deleteAction->setEnabled(false);
ui->signMessage->setEnabled(true); ui->signMessage->setEnabled(true);
ui->signMessage->setVisible(true); ui->signMessage->setVisible(true);
@ -283,14 +281,14 @@ void AddressBookPage::selectionChanged()
ui->verifyMessage->setVisible(false); ui->verifyMessage->setVisible(false);
break; break;
} }
ui->copyToClipboard->setEnabled(true); ui->copyAddress->setEnabled(true);
ui->showQRCode->setEnabled(true); ui->showQRCode->setEnabled(true);
} }
else else
{ {
ui->deleteButton->setEnabled(false); ui->deleteAddress->setEnabled(false);
ui->showQRCode->setEnabled(false); ui->showQRCode->setEnabled(false);
ui->copyToClipboard->setEnabled(false); ui->copyAddress->setEnabled(false);
ui->signMessage->setEnabled(false); ui->signMessage->setEnabled(false);
ui->verifyMessage->setEnabled(false); ui->verifyMessage->setEnabled(false);
} }

View File

@ -59,17 +59,17 @@ private:
private slots: private slots:
/** Delete currently selected address entry */ /** Delete currently selected address entry */
void on_deleteButton_clicked(); void on_deleteAddress_clicked();
/** Create a new address for receiving coins and / or add a new address book entry */ /** Create a new address for receiving coins and / or add a new address book entry */
void on_newAddressButton_clicked(); void on_newAddress_clicked();
/** Copy address of currently selected address entry to clipboard */ /** Copy address of currently selected address entry to clipboard */
void on_copyToClipboard_clicked(); void on_copyAddress_clicked();
/** Open the sign message tab in the Sign/Verify Message dialog with currently selected address */ /** Open the sign message tab in the Sign/Verify Message dialog with currently selected address */
void on_signMessage_clicked(); void on_signMessage_clicked();
/** Open the verify message tab in the Sign/Verify Message dialog with currently selected address */ /** Open the verify message tab in the Sign/Verify Message dialog with currently selected address */
void on_verifyMessage_clicked(); void on_verifyMessage_clicked();
/** Open send coins dialog for currently selected address (no button) */ /** Open send coins dialog for currently selected address (no button) */
void onSendCoins_clicked(); void onSendCoinsAction();
/** Generate a QR Code from the currently selected address */ /** Generate a QR Code from the currently selected address */
void on_showQRCode_clicked(); void on_showQRCode_clicked();
/** Copy label of currently selected address entry to clipboard (no button) */ /** Copy label of currently selected address entry to clipboard (no button) */

View File

@ -16,9 +16,6 @@
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<widget class="QLabel" name="labelExplanation"> <widget class="QLabel" name="labelExplanation">
<property name="text">
<string>These are your Bitcoin addresses for receiving payments. You may want to give a different one to each sender so you can keep track of who is paying you.</string>
</property>
<property name="textFormat"> <property name="textFormat">
<enum>Qt::PlainText</enum> <enum>Qt::PlainText</enum>
</property> </property>
@ -58,7 +55,7 @@
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QPushButton" name="newAddressButton"> <widget class="QPushButton" name="newAddress">
<property name="toolTip"> <property name="toolTip">
<string>Create a new address</string> <string>Create a new address</string>
</property> </property>
@ -72,7 +69,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="copyToClipboard"> <widget class="QPushButton" name="copyAddress">
<property name="toolTip"> <property name="toolTip">
<string>Copy the currently selected address to the system clipboard</string> <string>Copy the currently selected address to the system clipboard</string>
</property> </property>
@ -125,7 +122,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="deleteButton"> <widget class="QPushButton" name="deleteAddress">
<property name="toolTip"> <property name="toolTip">
<string>Delete the currently selected address from the list</string> <string>Delete the currently selected address from the list</string>
</property> </property>