Skip to content

Commit

Permalink
manage names tab v2
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonrobertz committed Nov 8, 2017
1 parent 0dde2d4 commit 2f7d103
Show file tree
Hide file tree
Showing 30 changed files with 2,342 additions and 12 deletions.
16 changes: 15 additions & 1 deletion src/Makefile.qt.include
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ QT_FORMS_UI = \
qt/forms/debugwindow.ui \
qt/forms/sendcoinsdialog.ui \
qt/forms/sendcoinsentry.ui \
qt/forms/managenamespage.ui \
qt/forms/configurenamedialog.ui \
qt/forms/signverifymessagedialog.ui \
qt/forms/transactiondescdialog.ui

Expand All @@ -126,13 +128,16 @@ QT_MOC_CPP = \
qt/moc_clientmodel.cpp \
qt/moc_coincontroldialog.cpp \
qt/moc_coincontroltreewidget.cpp \
qt/moc_configurenamedialog.cpp \
qt/moc_csvmodelwriter.cpp \
qt/moc_editaddressdialog.cpp \
qt/moc_guiutil.cpp \
qt/moc_intro.cpp \
qt/moc_macdockiconhandler.cpp \
qt/moc_macnotificationhandler.cpp \
qt/moc_modaloverlay.cpp \
qt/moc_managenamespage.cpp \
qt/moc_nametablemodel.cpp \
qt/moc_notificator.cpp \
qt/moc_openuridialog.cpp \
qt/moc_optionsdialog.cpp \
Expand Down Expand Up @@ -195,16 +200,20 @@ BITCOIN_QT_H = \
qt/clientmodel.h \
qt/coincontroldialog.h \
qt/coincontroltreewidget.h \
qt/configurenamedialog.h \
qt/csvmodelwriter.h \
qt/configurenamedialog.h \
qt/editaddressdialog.h \
qt/guiconstants.h \
qt/guiutil.h \
qt/intro.h \
qt/macdockiconhandler.h \
qt/macnotificationhandler.h \
qt/modaloverlay.h \
qt/managenamespage.h \
qt/networkstyle.h \
qt/notificator.h \
qt/nametablemodel.h \
qt/openuridialog.h \
qt/optionsdialog.h \
qt/optionsmodel.h \
Expand Down Expand Up @@ -291,8 +300,10 @@ RES_ICONS = \
qt/res/icons/tx_input.png \
qt/res/icons/tx_output.png \
qt/res/icons/tx_mined.png \
qt/res/icons/tx_nameop.png \
qt/res/icons/warning.png \
qt/res/icons/verify.png
qt/res/icons/verify.png \
qt/res/icons/transaction_abandoned.png

BITCOIN_QT_BASE_CPP = \
qt/bantablemodel.cpp \
Expand Down Expand Up @@ -326,7 +337,10 @@ BITCOIN_QT_WALLET_CPP = \
qt/askpassphrasedialog.cpp \
qt/coincontroldialog.cpp \
qt/coincontroltreewidget.cpp \
qt/configurenamedialog.cpp \
qt/editaddressdialog.cpp \
qt/managenamespage.cpp \
qt/nametablemodel.cpp \
qt/openuridialog.cpp \
qt/overviewpage.cpp \
qt/paymentrequestplus.cpp \
Expand Down
3 changes: 2 additions & 1 deletion src/Makefile.test.include
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ BITCOIN_TESTS += \
wallet/test/wallet_test_fixture.h \
wallet/test/accounting_tests.cpp \
wallet/test/wallet_tests.cpp \
wallet/test/crypto_tests.cpp
wallet/test/crypto_tests.cpp \
wallet/test/wallet_name_pending_tests.cpp
endif

test_test_namecoin_SOURCES = $(BITCOIN_TESTS) $(JSON_TEST_FILES) $(RAW_TEST_FILES)
Expand Down
38 changes: 38 additions & 0 deletions src/names/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -477,4 +477,42 @@ class CNameCache

};

/* ************************************************************************** */
/* CNamePendingData. */

/**
* Keeps track of name_new data for a pending name_firstupdate. This is
* serialized to the wallet so that the firstupdate can be broadcast
* between client runs.
*/
class CNamePendingData
{
private:
valtype vchToAddress;
valtype vchHex;
valtype vchRand;
valtype vchData;

public:
ADD_SERIALIZE_METHODS;

template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action) {
READWRITE(vchToAddress);
READWRITE(vchHex);
READWRITE(vchRand);
READWRITE(vchData);
}

inline const std::string getToAddress() { return ValtypeToString(vchToAddress); }
inline const std::string getHex() { return ValtypeToString(vchHex); }
inline const std::string getRand() { return ValtypeToString(vchRand); }
inline const std::string getData() { return ValtypeToString(vchData); }

inline void setToAddress(const std::string &toAddress) { vchToAddress = ValtypeFromString(toAddress); }
inline void setHex(const std::string &hex) { vchHex = ValtypeFromString(hex); }
inline void setRand(const std::string &rand) { vchRand = ValtypeFromString(rand); }
inline void setData(const std::string &data) { vchData = ValtypeFromString(data); }
};

#endif // H_BITCOIN_NAMES_COMMON
1 change: 1 addition & 0 deletions src/qt/bitcoin.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<file alias="tx_input">res/icons/tx_input.png</file>
<file alias="tx_output">res/icons/tx_output.png</file>
<file alias="tx_inout">res/icons/tx_inout.png</file>
<file alias="tx_nameop">res/icons/tx_nameop.png</file>
<file alias="lock_closed">res/icons/lock_closed.png</file>
<file alias="lock_open">res/icons/lock_open.png</file>
<file alias="key">res/icons/key.png</file>
Expand Down
24 changes: 24 additions & 0 deletions src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "guiconstants.h"
#include "guiutil.h"
#include "modaloverlay.h"
#include "managenamespage.h"
#include "networkstyle.h"
#include "notificator.h"
#include "openuridialog.h"
Expand Down Expand Up @@ -47,6 +48,7 @@
#include <QMenuBar>
#include <QMessageBox>
#include <QMimeData>
#include <QProgressBar>
#include <QProgressDialog>
#include <QSettings>
#include <QShortcut>
Expand Down Expand Up @@ -317,6 +319,17 @@ void BitcoinGUI::createActions()
historyAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_4));
tabGroup->addAction(historyAction);

manageNamesAction = new QAction(QIcon(":/icons/bitcoin"), tr("&Manage Names"), this);
manageNamesAction->setStatusTip(tr("Manage names registered via Namecoin"));
manageNamesAction->setToolTip(manageNamesAction->statusTip());
manageNamesAction->setCheckable(true);
manageNamesAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_6));
tabGroup->addAction(manageNamesAction);

manageNamesMenuAction = new QAction(QIcon(":/icons/bitcoin"), manageNamesAction->text(), this);
manageNamesMenuAction->setStatusTip(manageNamesAction->statusTip());
manageNamesMenuAction->setToolTip(manageNamesMenuAction->statusTip());

#ifdef ENABLE_WALLET
// These showNormalIfMinimized are needed because Send Coins and Receive Coins
// can be triggered from the tray menu, and need to show the GUI to be useful.
Expand All @@ -332,6 +345,8 @@ void BitcoinGUI::createActions()
connect(receiveCoinsMenuAction, SIGNAL(triggered()), this, SLOT(gotoReceiveCoinsPage()));
connect(historyAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(historyAction, SIGNAL(triggered()), this, SLOT(gotoHistoryPage()));
connect(manageNamesAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(manageNamesAction, SIGNAL(triggered()), this, SLOT(gotoManageNamesPage()));
#endif // ENABLE_WALLET

quitAction = new QAction(platformStyle->TextColorIcon(":/icons/quit"), tr("E&xit"), this);
Expand Down Expand Up @@ -466,6 +481,7 @@ void BitcoinGUI::createToolBars()
toolbar->addAction(sendCoinsAction);
toolbar->addAction(receiveCoinsAction);
toolbar->addAction(historyAction);
toolbar->addAction(manageNamesAction);
overviewAction->setChecked(true);
}
}
Expand Down Expand Up @@ -565,6 +581,7 @@ void BitcoinGUI::setWalletActionsEnabled(bool enabled)
receiveCoinsAction->setEnabled(enabled);
receiveCoinsMenuAction->setEnabled(enabled);
historyAction->setEnabled(enabled);
manageNamesAction->setEnabled(enabled);
encryptWalletAction->setEnabled(enabled);
backupWalletAction->setEnabled(enabled);
changePassphraseAction->setEnabled(enabled);
Expand Down Expand Up @@ -612,6 +629,7 @@ void BitcoinGUI::createTrayIconMenu()
trayIconMenu->addSeparator();
trayIconMenu->addAction(sendCoinsMenuAction);
trayIconMenu->addAction(receiveCoinsMenuAction);
trayIconMenu->addAction(manageNamesMenuAction);
trayIconMenu->addSeparator();
trayIconMenu->addAction(signMessageAction);
trayIconMenu->addAction(verifyMessageAction);
Expand Down Expand Up @@ -707,6 +725,12 @@ void BitcoinGUI::gotoSendCoinsPage(QString addr)
if (walletFrame) walletFrame->gotoSendCoinsPage(addr);
}

void BitcoinGUI::gotoManageNamesPage()
{
manageNamesAction->setChecked(true);
if (walletFrame) walletFrame->gotoManageNamesPage();
}

void BitcoinGUI::gotoSignMessageTab(QString addr)
{
if (walletFrame) walletFrame->gotoSignMessageTab(addr);
Expand Down
4 changes: 4 additions & 0 deletions src/qt/bitcoingui.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ class BitcoinGUI : public QMainWindow
QAction *sendCoinsMenuAction;
QAction *usedSendingAddressesAction;
QAction *usedReceivingAddressesAction;
QAction *manageNamesAction;
QAction *manageNamesMenuAction;
QAction *signMessageAction;
QAction *verifyMessageAction;
QAction *aboutAction;
Expand Down Expand Up @@ -199,6 +201,8 @@ private Q_SLOTS:
void gotoReceiveCoinsPage();
/** Switch to send coins page */
void gotoSendCoinsPage(QString addr = "");
/** Switch to manage names page */
void gotoManageNamesPage();

/** Show Sign/Verify Message dialog and switch to sign message tab */
void gotoSignMessageTab(QString addr = "");
Expand Down
128 changes: 128 additions & 0 deletions src/qt/configurenamedialog.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
#include "configurenamedialog.h"
#include "ui_configurenamedialog.h"

#include "addressbookpage.h"
#include "guiutil.h"
#include "names/main.h"
#include "platformstyle.h"
#include "wallet/wallet.h"
#include "walletmodel.h"

#include <QMessageBox>
#include <QClipboard>

ConfigureNameDialog::ConfigureNameDialog(const PlatformStyle *platformStyle,
const QString &_name, const QString &data,
bool _firstUpdate, QWidget *parent) :
QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint),
ui(new Ui::ConfigureNameDialog),
platformStyle(platformStyle),
name(_name),
firstUpdate(_firstUpdate)
{
ui->setupUi(this);

#ifdef Q_OS_MAC
ui->transferToLayout->setSpacing(4);
#endif

GUIUtil::setupAddressWidget(ui->transferTo, this);

ui->labelName->setText(name);
ui->dataEdit->setText(data);

returnData = data;

if (name.startsWith("d/"))
ui->labelDomain->setText(name.mid(2) + ".bit");
else
ui->labelDomain->setText(tr("(not a domain name)"));

if (firstUpdate)
{
ui->labelTransferTo->hide();
ui->labelTransferToHint->hide();
ui->transferTo->hide();
ui->addressBookButton->hide();
ui->pasteButton->hide();
ui->labelSubmitHint->setText(
tr("name_firstupdate transaction will be queued and broadcasted when corresponding name_new is %1 blocks old")
.arg(MIN_FIRSTUPDATE_DEPTH));
}
else
{
ui->labelSubmitHint->setText(tr("name_update transaction will be issued immediately"));
setWindowTitle(tr("Update Name"));
}
}


ConfigureNameDialog::~ConfigureNameDialog()
{
delete ui;
}

void ConfigureNameDialog::accept()
{
if (!walletModel)
return;

QString addr;
if (!firstUpdate)
{
if (!ui->transferTo->text().isEmpty() && !ui->transferTo->hasAcceptableInput())
{
ui->transferTo->setValid(false);
return;
}

addr = ui->transferTo->text();

if (addr != "" && !walletModel->validateAddress(addr))
{
ui->transferTo->setValid(false);
return;
}

}

WalletModel::UnlockContext ctx(walletModel->requestUnlock());
if (!ctx.isValid())
return;

returnData = ui->dataEdit->text();
if (!firstUpdate)
returnTransferTo = ui->transferTo->text();

QDialog::accept();
}

void ConfigureNameDialog::setModel(WalletModel *walletModel)
{
this->walletModel = walletModel;
}

void ConfigureNameDialog::on_pasteButton_clicked()
{
// Paste text from clipboard into recipient field
ui->transferTo->setText(QApplication::clipboard()->text());
}

void ConfigureNameDialog::on_addressBookButton_clicked()
{
if (!walletModel)
return;

AddressBookPage dlg(
// platformStyle
platformStyle,
// mode
AddressBookPage::ForSelection,
// tab
AddressBookPage::SendingTab,
// *parent
this);
dlg.setModel(walletModel->getAddressTableModel());
if (dlg.exec())
ui->transferTo->setText(dlg.getReturnValue());
}
Loading

0 comments on commit 2f7d103

Please sign in to comment.