Skip to content

Commit

Permalink
Namecoin: Add Qt GUI for name_list
Browse files Browse the repository at this point in the history
Based on namecoin#187
by Brandon Roberts.
  • Loading branch information
JeremyRand committed Oct 22, 2020
1 parent 94dba95 commit 5b45181
Show file tree
Hide file tree
Showing 17 changed files with 1,052 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Makefile.qt.include
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ QT_FORMS_UI = \
qt/forms/debugwindow.ui \
qt/forms/sendcoinsdialog.ui \
qt/forms/sendcoinsentry.ui \
qt/forms/managenamespage.ui \
qt/forms/signverifymessagedialog.ui \
qt/forms/transactiondescdialog.ui

Expand All @@ -55,6 +56,8 @@ QT_MOC_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 @@ -125,8 +128,10 @@ BITCOIN_QT_H = \
qt/macnotificationhandler.h \
qt/macos_appnap.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 @@ -245,6 +250,8 @@ BITCOIN_QT_WALLET_CPP = \
qt/coincontroltreewidget.cpp \
qt/createwalletdialog.cpp \
qt/editaddressdialog.cpp \
qt/managenamespage.cpp \
qt/nametablemodel.cpp \
qt/openuridialog.cpp \
qt/overviewpage.cpp \
qt/paymentserver.cpp \
Expand Down
1 change: 1 addition & 0 deletions src/qt/bitcoin.qrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource prefix="/icons">
<file alias="bitcoin">res/icons/bitcoin.png</file>
<file alias="bitcoin_transparent_letter">res/icons/bitcoin_transparent_letter.png</file>
<file alias="address-book">res/icons/address-book.png</file>
<file alias="send">res/icons/send.png</file>
<file alias="connect_0">res/icons/connect0.png</file>
Expand Down
23 changes: 23 additions & 0 deletions src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <qt/createwalletdialog.h>
#include <qt/guiconstants.h>
#include <qt/guiutil.h>
#include <qt/managenamespage.h>
#include <qt/modaloverlay.h>
#include <qt/networkstyle.h>
#include <qt/notificator.h>
Expand Down Expand Up @@ -277,6 +278,17 @@ void BitcoinGUI::createActions()
historyAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_4));
tabGroup->addAction(historyAction);

manageNamesAction = new QAction(platformStyle->SingleColorIcon(":/icons/bitcoin_transparent_letter"), 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_5));
tabGroup->addAction(manageNamesAction);

manageNamesMenuAction = new QAction(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 @@ -292,6 +304,8 @@ void BitcoinGUI::createActions()
connect(receiveCoinsMenuAction, &QAction::triggered, this, &BitcoinGUI::gotoReceiveCoinsPage);
connect(historyAction, &QAction::triggered, [this]{ showNormalIfMinimized(); });
connect(historyAction, &QAction::triggered, this, &BitcoinGUI::gotoHistoryPage);
connect(manageNamesAction, &QAction::triggered, [this]{ showNormalIfMinimized(); });
connect(manageNamesAction, &QAction::triggered, this, &BitcoinGUI::gotoManageNamesPage);
#endif // ENABLE_WALLET

quitAction = new QAction(tr("E&xit"), this);
Expand Down Expand Up @@ -550,6 +564,7 @@ void BitcoinGUI::createToolBars()
toolbar->addAction(sendCoinsAction);
toolbar->addAction(receiveCoinsAction);
toolbar->addAction(historyAction);
toolbar->addAction(manageNamesAction);
overviewAction->setChecked(true);

#ifdef ENABLE_WALLET
Expand Down Expand Up @@ -736,6 +751,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 @@ -786,6 +802,7 @@ void BitcoinGUI::createTrayIconMenu()
if (enableWallet) {
trayIconMenu->addAction(sendCoinsMenuAction);
trayIconMenu->addAction(receiveCoinsMenuAction);
trayIconMenu->addAction(manageNamesMenuAction);
trayIconMenu->addSeparator();
trayIconMenu->addAction(signMessageAction);
trayIconMenu->addAction(verifyMessageAction);
Expand Down Expand Up @@ -881,6 +898,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 @@ -138,6 +138,8 @@ class BitcoinGUI : public QMainWindow
QAction* sendCoinsMenuAction = nullptr;
QAction* usedSendingAddressesAction = nullptr;
QAction* usedReceivingAddressesAction = nullptr;
QAction* manageNamesAction = nullptr;
QAction* manageNamesMenuAction = nullptr;
QAction* signMessageAction = nullptr;
QAction* verifyMessageAction = nullptr;
QAction* m_load_psbt_action = nullptr;
Expand Down Expand Up @@ -276,6 +278,8 @@ public 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
253 changes: 253 additions & 0 deletions src/qt/forms/managenamespage.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,253 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ManageNamesPage</class>
<widget class="QWidget" name="ManageNamesPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>776</width>
<height>364</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QFrame" name="frame2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<!--
<item>
<widget class="QLabel" name="label_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&amp;New name:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>registerName</cstring>
</property>
</widget>
</item>
<item>
<widget class="QValidatedLineEdit" name="registerName">
<property name="toolTip">
<string>Enter a name or domain name (prefixed with d/) to be registered via Namecoin.</string>
</property>
<property name="text">
<string>d/</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Use &lt;span style=&quot; font-weight:600;&quot;&gt;d/&lt;/span&gt; prefix for domain names. E.g. &lt;span style=&quot; font-weight:600;&quot;&gt;d/mysite&lt;/span&gt; will register &lt;span style=&quot; font-weight:600;&quot;&gt;mysite.bit&lt;/span&gt;&lt;/p&gt;&lt;p&gt;See &lt;a href=&quot;https://wiki.namecoin.info/index.php?title=Domain_Name_Specification&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;Domain names&lt;/span&gt;&lt;/a&gt; in Namecoin wiki for reference. Other prefixes can be used for miscellaneous purposes (not domain names).&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="submitNameButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Confirm the new name action. Sends name_new transaction
to the network and creates a pending name_firstupdate transaction.</string>
</property>
<property name="text">
<string>&amp;Submit</string>
</property>
<property name="icon">
<iconset resource="../bitcoin.qrc">
<normaloff>:/icons/send</normaloff>:/icons/send</iconset>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Maximum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>12</height>
</size>
</property>
</spacer>
</item>
-->
<item>
<widget class="QLabel" name="label_5">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Your registered names (pending and unconfirmed names have blank expiration):</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<!--
<property name="buddy">
<cstring>registerName</cstring>
</property>
-->
</widget>
</item>
<item>
<widget class="QTableView" name="tableView">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="toolTip">
<string>Double-click name to configure</string>
</property>
<property name="tabKeyNavigation">
<bool>false</bool>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
</widget>
</item>
<!--
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QPushButton" name="configureNameButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Configure name and submit update operation</string>
</property>
<property name="text">
<string>&amp;Configure Name...</string>
</property>
<property name="default">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="renewNameButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Renew the name with its current value</string>
</property>
<property name="text">
<string>&amp;Renew Name</string>
</property>
<property name="default">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
-->
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<!--
<customwidget>
<class>QValidatedLineEdit</class>
<extends>QLineEdit</extends>
<header>../../src/qt/qvalidatedlineedit.h</header>
</customwidget>
-->
</customwidgets>
<resources>
<!--
<include location="../bitcoin.qrc"/>
-->
</resources>
<connections/>
</ui>
Loading

0 comments on commit 5b45181

Please sign in to comment.