diff --git a/res/icons/AUTHORS b/res/icons/AUTHORS index addcf88f78fa3415459c4a08669b7f7c93d36984..23af4ae9d95d73a77e3cc96aee08e56473c1843c 100644 --- a/res/icons/AUTHORS +++ b/res/icons/AUTHORS @@ -24,4 +24,5 @@ noun_41979_cc.svg : by by hunotika noun_155533_cc.svg : by anbileru adaleru noun_155520_cc.svg : by anbileru adaleru noun_155540_cc.svg : by anbileru adaleru -noun_100552_cc.svg : by Rui \ No newline at end of file +noun_100552_cc.svg : by Rui +noun_178537_cc.svg : by Nathan David Smith \ No newline at end of file diff --git a/res/icons/icons.qrc b/res/icons/icons.qrc index 124d65e81e31b9aebb118e28682fcd38683b0fcd..d90ac81e928c98e47dba6f3254738262727428bd 100644 --- a/res/icons/icons.qrc +++ b/res/icons/icons.qrc @@ -1,5 +1,6 @@ <RCC> <qresource prefix="icons"> + <file alias="guest_icon">noun_178537_cc.svg</file> <file alias="menu_icon">noun_100552_cc.svg</file> <file alias="leave_icon">noun_155520_cc.svg</file> <file alias="new_membership">noun_155540_cc.svg</file> diff --git a/res/ui/community_cfg.ui b/res/ui/community_cfg.ui index 408cf47d40b91f5bc117fb7a2ed3ec55f1ca4752..f5743e91376736441b4f6af78d0e47b1afb72b7b 100644 --- a/res/ui/community_cfg.ui +++ b/res/ui/community_cfg.ui @@ -126,6 +126,23 @@ </property> </widget> </item> + <item> + <widget class="QPushButton" name="button_guest"> + <property name="text"> + <string>Connect as a guest</string> + </property> + <property name="icon"> + <iconset resource="../icons/icons.qrc"> + <normaloff>:/icons/guest_icon</normaloff>:/icons/guest_icon</iconset> + </property> + <property name="iconSize"> + <size> + <width>32</width> + <height>32</height> + </size> + </property> + </widget> + </item> <item> <widget class="QLabel" name="label_error"> <property name="text"> diff --git a/src/cutecoin/gui/process_cfg_community.py b/src/cutecoin/gui/process_cfg_community.py index 8493ddc38f42a273d3cdb00795f5ccfb192b2cf7..a9fcbab6d7b7680f87b465f54a1f308b1156d861 100644 --- a/src/cutecoin/gui/process_cfg_community.py +++ b/src/cutecoin/gui/process_cfg_community.py @@ -18,6 +18,7 @@ from ..core import Community from ..core.net import Node from cutecoin.gui.widgets import toast from .widgets.dialogs import QAsyncMessageBox +from ..tools.decorators import asyncify class Step(QObject): @@ -38,6 +39,7 @@ class StepPageInit(Step): logging.debug("Init") self.config_dialog.button_connect.clicked.connect(self.check_connect) self.config_dialog.button_register.clicked.connect(self.check_register) + self.config_dialog.button_guest.clicked.connect(self.check_guest) @property def app(self): @@ -55,8 +57,27 @@ class StepPageInit(Step): def password_asker(self): return self.config_dialog.password_asker + @asyncify @asyncio.coroutine - def coroutine_check_connect(self): + def check_guest(self, checked=False): + server = self.config_dialog.lineedit_server.text() + port = self.config_dialog.spinbox_port.value() + logging.debug("Is valid ? ") + try: + self.node = yield from Node.from_address(None, server, port) + community = Community.create(self.node) + self.config_dialog.button_connect.setEnabled(False) + self.config_dialog.button_register.setEnabled(False) + self.config_dialog.community = community + self.config_dialog.next() + except aiohttp.errors.DisconnectedError as e: + self.config_dialog.label_error.setText(str(e)) + except aiohttp.errors.ClientError as e: + self.config_dialog.label_error.setText(str(e)) + + @asyncify + @asyncio.coroutine + def check_connect(self, checked=False): server = self.config_dialog.lineedit_server.text() port = self.config_dialog.spinbox_port.value() logging.debug("Is valid ? ") @@ -76,16 +97,14 @@ class StepPageInit(Step): else: self.config_dialog.community = community self.config_dialog.next() - except Exception as e: - self.config_dialog.label_error.setText(self.tr(str(e))) - - @pyqtSlot() - def check_connect(self): - logging.debug("Check node") - asyncio.async(self.coroutine_check_connect()) + except aiohttp.errors.DisconnectedError as e: + self.config_dialog.label_error.setText(str(e)) + except aiohttp.errors.ClientError as e: + self.config_dialog.label_error.setText(str(e)) + @asyncify @asyncio.coroutine - def coroutine_check_register(self): + def check_register(self, checked=False): server = self.config_dialog.lineedit_server.text() port = self.config_dialog.spinbox_port.value() logging.debug("Is valid ? ") @@ -125,11 +144,6 @@ Yours : {0}, the network : {1}""".format(registered[1], registered[2]))) except aiohttp.errors.ClientError as e: self.config_dialog.label_error.setText(str(e)) - @pyqtSlot() - def check_register(self): - logging.debug("Check node") - asyncio.async(self.coroutine_check_register()) - def is_valid(self): return self.node is not None