forked from domob1812/namecoin-core
-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0dde2d4
commit ea6071a
Showing
30 changed files
with
2,359 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#ifndef CONFIGURENAMEDIALOG_H | ||
#define CONFIGURENAMEDIALOG_H | ||
|
||
#include "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, | ||
bool _firstUpdate, QWidget *parent = 0); | ||
~ConfigureNameDialog(); | ||
|
||
void setModel(WalletModel *walletModel); | ||
const QString &getReturnData() const { return returnData; } | ||
const QString &getTransferTo() const { 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; | ||
QString name; | ||
bool firstUpdate; | ||
}; | ||
|
||
#endif // CONFIGURENAMEDIALOG_H |
Oops, something went wrong.