Skip to content

Commit

Permalink
Namecoin: Add DNS subdomain dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
JeremyRand committed Dec 12, 2019
1 parent a74b22c commit 8a9b5b9
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Run install (this should install dependencies)::
Compile the Qt UI:

sudo apt-get install pyqt5-dev-tools
for i in dnsdialog; do pyuic5 electrum_nmc/electrum/gui/qt/forms/$i.ui --execute --output=electrum_nmc/electrum/gui/qt/forms/$i.py; sed -i s/qvalidatedlineedit/.qvalidatedlineedit/ electrum_nmc/electrum/gui/qt/forms/$i.py; done
for i in dnsdialog dnssubdomaindialog; do pyuic5 electrum_nmc/electrum/gui/qt/forms/$i.ui --execute --output=electrum_nmc/electrum/gui/qt/forms/$i.py; sed -i s/qvalidatedlineedit/.qvalidatedlineedit/ electrum_nmc/electrum/gui/qt/forms/$i.py; done

Compile the protobuf description file::

Expand Down
16 changes: 13 additions & 3 deletions electrum_nmc/electrum/gui/qt/configure_dns_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from electrum.names import add_domain_record, get_domain_records

from .forms.dnsdialog import Ui_DNSDialog
from .forms.dnssubdomaindialog import Ui_DNSSubDomainDialog
from .util import MessageBoxMixin

dialogs = [] # Otherwise python randomly garbage collects the dialogs...
Expand Down Expand Up @@ -70,8 +71,7 @@ class Columns(IntEnum):
TEXT_ADD_SUBDOMAIN = "Add Subdomain..."

def __init__(self, value, parent):
# We want to be a top-level window
QDialog.__init__(self, parent=None)
QDialog.__init__(self, parent=parent)

self.name_dialog = parent

Expand Down Expand Up @@ -128,7 +128,17 @@ def __init__(self, value, parent):

def domain_changed(self, index):
if self.ui.comboDomain.itemText(index) == _(self.__class__.TEXT_ADD_SUBDOMAIN):
self.show_error(_("Adding a subdomain is not yet implemented."))
d = QDialog(parent=self)

ui = Ui_DNSSubDomainDialog()
ui.setupUi(d)

ui.labelDomainName.setText(self.base_domain)

ui.btnAdd.accepted.connect(lambda: self.ui.comboDomain.addItem(ui.editSubDomain.text() + "." + self.base_domain))

dialogs.append(d)
d.show()

def get_selected_domain(self):
return self.ui.comboDomain.currentText()
Expand Down
96 changes: 96 additions & 0 deletions electrum_nmc/electrum/gui/qt/forms/dnssubdomaindialog.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DNSSubDomainDialog</class>
<widget class="QDialog" name="DNSSubDomainDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>100</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="labelSubDomain">
<property name="text">
<string>Select a subdomain to add to your domain.</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLineEdit" name="editSubDomain">
<property name="placeholderText">
<string>e.g., www</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>.</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelDomainName">
<property name="text">
<string>domain.bit</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="btnAdd">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>btnAdd</sender>
<signal>accepted()</signal>
<receiver>DNSSubDomainDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>btnAdd</sender>
<signal>rejected()</signal>
<receiver>DNSSubDomainDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

0 comments on commit 8a9b5b9

Please sign in to comment.