Skip to content

Commit

Permalink
Merge #394: name_update Qt GUI
Browse files Browse the repository at this point in the history
f10bde6 Namecoin: Add name_update Qt GUI (Jeremy Rand)
d6aff8e Namecoin / Qt: Fix registerName widget (Jeremy Rand)

Pull request description:

  This PR adds the `name_update` GUI.

Top commit has no ACKs.

Tree-SHA512: 1ff9509bd305ed10cf065bcef50787c344cf27a0fb0af759f70dcafbcf71d9d49fe231f0b82541a828655d5e05f3b44ab79be78562178fc86214b10c50511b1f
  • Loading branch information
domob1812 committed May 11, 2021
2 parents 041d115 + f10bde6 commit 5db3842
Show file tree
Hide file tree
Showing 9 changed files with 515 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/Makefile.qt.include
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ QT_FORMS_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 @@ -49,6 +50,7 @@ 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 \
Expand Down Expand Up @@ -120,6 +122,7 @@ BITCOIN_QT_H = \
qt/clientmodel.h \
qt/coincontroldialog.h \
qt/coincontroltreewidget.h \
qt/configurenamedialog.h \
qt/createwalletdialog.h \
qt/csvmodelwriter.h \
qt/editaddressdialog.h \
Expand Down Expand Up @@ -256,6 +259,7 @@ BITCOIN_QT_WALLET_CPP = \
qt/askpassphrasedialog.cpp \
qt/coincontroldialog.cpp \
qt/coincontroltreewidget.cpp \
qt/configurenamedialog.cpp \
qt/createwalletdialog.cpp \
qt/editaddressdialog.cpp \
qt/managenamespage.cpp \
Expand Down
92 changes: 92 additions & 0 deletions src/qt/configurenamedialog.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#include <qt/configurenamedialog.h>
#include <qt/forms/ui_configurenamedialog.h>

// TODO: How many of these are actually still needed?
#include <names/main.h>
#include <qt/addressbookpage.h>
#include <qt/guiutil.h>
#include <qt/platformstyle.h>
#include <qt/walletmodel.h>
#include <wallet/wallet.h>

#include <QMessageBox>
#include <QClipboard>

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

if (platformStyle->getUseExtraSpacing())
ui->transferToLayout->setSpacing(4);

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

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

returnData = data;

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 = ui->transferTo->text();

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

returnData = ui->dataEdit->text();
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());
}
53 changes: 53 additions & 0 deletions src/qt/configurenamedialog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#ifndef CONFIGURENAMEDIALOG_H
#define CONFIGURENAMEDIALOG_H

#include <optional.h>
#include <qt/platformstyle.h>

#include <QDialog>

namespace Ui {
class ConfigureNameDialog;
}

class WalletModel;

/** Dialog for editing an address and associated information.
*/
class ConfigureNameDialog : public QDialog
{
Q_OBJECT

public:

explicit ConfigureNameDialog(const PlatformStyle *platformStyle,
const QString &_name, const QString &data,
QWidget *parent = nullptr);
~ConfigureNameDialog();

void setModel(WalletModel *walletModel);
const QString &getReturnData() const { return returnData; }
const Optional<QString> getTransferTo() const
{
if (returnTransferTo == "")
{
return {};
}
return returnTransferTo;
}

public Q_SLOTS:
void accept() override;
void on_addressBookButton_clicked();
void on_pasteButton_clicked();

private:
Ui::ConfigureNameDialog *ui;
const PlatformStyle *platformStyle;
QString returnData;
QString returnTransferTo;
WalletModel *walletModel;
const QString name;
};

#endif // CONFIGURENAMEDIALOG_H
Loading

0 comments on commit 5db3842

Please sign in to comment.