Beispiel #1
0
    def setupUi(self):
        Ui_ConfigDlg.setupUi(self, self)
        self.resize(
            app_cache.get_value('ConfigDlg_Width',
                                self.size().width(), int),
            app_cache.get_value('ConfigDlg_Height',
                                self.size().height(), int))

        self.setWindowTitle("Configuration")
        self.splitter.setStretchFactor(0, 0)
        self.splitter.setStretchFactor(1, 1)
        self.accepted.connect(self.on_accepted)
        self.tabWidget.setCurrentIndex(0)

        self.disable_cfg_update = True

        layout_details = self.detailsFrame.layout()
        self.chbConnEnabled = QCheckBox("Enabled")
        self.chbConnEnabled.toggled.connect(self.on_chbConnEnabled_toggled)
        layout_details.addWidget(self.chbConnEnabled)
        self.chbUseSshTunnel = QCheckBox("Use SSH tunnel")
        self.chbUseSshTunnel.toggled.connect(self.on_chbUseSshTunnel_toggled)
        layout_details.addWidget(self.chbUseSshTunnel)
        self.ssh_tunnel_widget = SshConnectionWidget(self)
        layout_details.addWidget(self.ssh_tunnel_widget)

        # layout for button for reading RPC configuration from remote host over SSH:
        hl = QHBoxLayout()
        self.btnSshReadRpcConfig = QPushButton(
            "\u2193 Read RPC configuration from SSH host \u2193")
        self.btnSshReadRpcConfig.clicked.connect(
            self.on_btnSshReadRpcConfig_clicked)
        hl.addWidget(self.btnSshReadRpcConfig)
        hl.addStretch()
        layout_details.addLayout(hl)

        # add connection-editing controls widget:
        self.rpc_cfg_widget = RpcConnectionWidget(self.detailsFrame)
        layout_details.addWidget(self.rpc_cfg_widget)

        # layout for controls related to setting up an additional encryption
        hl = QHBoxLayout()
        self.btnEncryptionPublicKey = QPushButton("RPC encryption public key")
        self.btnEncryptionPublicKey.clicked.connect(
            self.on_btnEncryptionPublicKey_clicked)
        hl.addWidget(self.btnEncryptionPublicKey)
        self.lblEncryptionPublicKey = QLabel(self)
        self.lblEncryptionPublicKey.setText('')
        hl.addWidget(self.lblEncryptionPublicKey)
        hl.addStretch()
        layout_details.addLayout(hl)

        # layout for the 'test connection' button:
        hl = QHBoxLayout()
        self.btnTestConnection = QPushButton("\u2713 Test connection")
        self.btnTestConnection.clicked.connect(
            self.on_btnTestConnection_clicked)
        sp = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum,
                                   QtWidgets.QSizePolicy.Minimum)
        sp.setHorizontalStretch(0)
        sp.setVerticalStretch(0)
        sp.setHeightForWidth(
            self.btnTestConnection.sizePolicy().hasHeightForWidth())
        self.btnTestConnection.setSizePolicy(sp)
        hl.addWidget(self.btnTestConnection)
        hl.addStretch()
        layout_details.addLayout(hl)
        layout_details.addStretch()

        self.rpc_cfg_widget.edtRpcHost.textEdited.connect(
            self.on_edtRpcHost_textEdited)
        self.rpc_cfg_widget.edtRpcPort.textEdited.connect(
            self.on_edtRpcPort_textEdited)
        self.rpc_cfg_widget.edtRpcUsername.textEdited.connect(
            self.on_edtRpcUsername_textEdited)
        self.rpc_cfg_widget.edtRpcPassword.textEdited.connect(
            self.on_edtRpcPassword_textEdited)
        self.rpc_cfg_widget.chbRpcSSL.toggled.connect(self.chbRpcSSL_toggled)
        self.ssh_tunnel_widget.edtSshHost.textEdited.connect(
            self.on_edtSshHost_textEdited)
        self.ssh_tunnel_widget.edtSshPort.textEdited.connect(
            self.on_edtSshPort_textEdited)
        self.ssh_tunnel_widget.edtSshUsername.textEdited.connect(
            self.on_edtSshUsername_textEdited)
        self.ssh_tunnel_widget.cboAuthentication.currentIndexChanged.connect(
            self.on_cboSshAuthentication_currentIndexChanged)
        self.ssh_tunnel_widget.edtPrivateKeyPath.textChanged.connect(
            self.on_edtSshPrivateKeyPath_textChanged)

        self.lstConns.setContextMenuPolicy(Qt.CustomContextMenu)
        self.popMenu = QMenu(self)

        self.action_new_connection = self.popMenu.addAction(
            "Add new connection")
        self.action_new_connection.triggered.connect(
            self.on_action_new_connection_triggered)
        self.setIcon(self.action_new_connection, '*****@*****.**')
        self.btnNewConn.setDefaultAction(self.action_new_connection)

        self.action_delete_connections = self.popMenu.addAction(
            "Delete selected connection(s)")
        self.action_delete_connections.triggered.connect(
            self.on_action_delete_connections_triggered)
        self.setIcon(self.action_delete_connections, '*****@*****.**')
        self.btnDeleteConn.setDefaultAction(self.action_delete_connections)

        self.action_copy_connections = self.popMenu.addAction(
            "Copy connection(s) to clipboard",
            self.on_action_copy_connections_triggered, QKeySequence("Ctrl+C"))
        self.setIcon(self.action_copy_connections, '*****@*****.**')
        self.addAction(self.action_copy_connections)

        self.action_paste_connections = self.popMenu.addAction(
            "Paste connection(s) from clipboard",
            self.on_action_paste_connections_triggered, QKeySequence("Ctrl+V"))
        self.setIcon(self.action_paste_connections, '*****@*****.**')
        self.addAction(self.action_paste_connections)

        self.btnNewConn.setText("")
        self.btnDeleteConn.setText("")
        self.btnMoveDownConn.setText("")
        self.btnMoveUpConn.setText("")
        self.btnRestoreDefault.setText("")
        self.setIcon(self.btnMoveDownConn, "*****@*****.**")
        self.setIcon(self.btnMoveUpConn, "*****@*****.**", rotate=180)
        self.setIcon(self.btnRestoreDefault, "*****@*****.**")
        self.setIcon(self.rpc_cfg_widget.btnShowPassword, "*****@*****.**")

        self.rpc_cfg_widget.btnShowPassword.setText("")
        self.rpc_cfg_widget.btnShowPassword.pressed.connect(
            lambda: self.rpc_cfg_widget.edtRpcPassword.setEchoMode(QLineEdit.
                                                                   Normal))
        self.rpc_cfg_widget.btnShowPassword.released.connect(
            lambda: self.rpc_cfg_widget.edtRpcPassword.setEchoMode(QLineEdit.
                                                                   Password))

        if self.local_config.is_mainnet():
            self.cboDashNetwork.setCurrentIndex(0)
            self.connections_current = self.connections_mainnet
        else:
            self.cboDashNetwork.setCurrentIndex(1)
            self.connections_current = self.connections_testnet
        for cfg in self.local_config.dash_net_configs:
            if cfg.testnet:
                self.connections_testnet.append(cfg)
            else:
                self.connections_mainnet.append(cfg)

        if self.local_config.hw_type == HWType.trezor:
            self.chbHwTrezor.setChecked(True)
        elif self.local_config.hw_type == HWType.keepkey:
            self.chbHwKeepKey.setChecked(True)
        else:
            self.chbHwLedgerNanoS.setChecked(True)

        if self.local_config.hw_keepkey_psw_encoding == 'NFC':
            self.cboKeepkeyPassEncoding.setCurrentIndex(0)
        else:
            self.cboKeepkeyPassEncoding.setCurrentIndex(1)
        note_url = get_note_url('DMTN0001')
        self.lblKeepkeyPassEncoding.setText(
            f'KepKey passphrase encoding (<a href="{note_url}">see</a>)')

        self.chbCheckForUpdates.setChecked(self.local_config.check_for_updates)
        self.chbBackupConfigFile.setChecked(
            self.local_config.backup_config_file)
        self.chbDownloadProposalExternalData.setChecked(
            self.local_config.read_proposals_external_attributes)
        self.chbDontUseFileDialogs.setChecked(
            self.local_config.dont_use_file_dialogs)
        self.chbConfirmWhenVoting.setChecked(
            self.local_config.confirm_when_voting)
        self.chbAddRandomOffsetToVotingTime.setChecked(
            self.local_config.add_random_offset_to_vote_time)
        self.chbEncryptConfigFile.setChecked(
            self.local_config.encrypt_config_file)

        idx = {
            'CRITICAL': 0,
            'ERROR': 1,
            'WARNING': 2,
            'INFO': 3,
            'DEBUG': 4,
            'NOTSET': 5
        }.get(self.local_config.log_level_str, 2)
        self.cboLogLevel.setCurrentIndex(idx)

        self.display_connection_list()
        if len(self.local_config.dash_net_configs):
            self.lstConns.setCurrentRow(0)

        self.update_keepkey_pass_encoding_ui()
        self.update_connection_details_ui()
        self.disable_cfg_update = False
        self.splitter.setSizes(
            app_cache.get_value('ConfigDlg_ConnectionSplitter_Sizes',
                                [100, 100], list))
Beispiel #2
0
    def setupUi(self):
        Ui_ConfigDlg.setupUi(self, self)
        self.setWindowTitle("Configuration")
        self.splitter.setStretchFactor(0, 0)
        self.splitter.setStretchFactor(1, 1)
        self.accepted.connect(self.on_accepted)
        self.tabWidget.setCurrentIndex(0)

        if sys.platform == 'win32':
            a_link = '<a href="file:///' + self.config.app_config_file_name + '">' + self.config.app_config_file_name + '</a>'
        else:
            a_link = '<a href="file://' + self.config.app_config_file_name + '">' + self.config.app_config_file_name + '</a>'
        self.lblStatus.setText('Config file: ' + a_link)
        self.lblStatus.setOpenExternalLinks(True)
        self.disable_cfg_update = True

        # display all connection configs
        self.displayConnsConfigs()

        lay = self.detailsFrame.layout()

        self.chbConnEnabled = QCheckBox("Enabled")
        self.chbConnEnabled.toggled.connect(self.on_chbConnEnabled_toggled)
        lay.addWidget(self.chbConnEnabled)

        self.chbUseSshTunnel = QCheckBox("Use SSH tunnel")
        self.chbUseSshTunnel.toggled.connect(self.on_chbUseSshTunnel_toggled)
        lay.addWidget(self.chbUseSshTunnel)
        self.ssh_tunnel_widget = SshConnectionWidget(self.detailsFrame)
        lay.addWidget(self.ssh_tunnel_widget)

        # layout for button for reading RPC configuration from remote host over SSH:
        hl = QHBoxLayout()
        self.btnSshReadRpcConfig = QPushButton(
            "\u2B07 Read RPC configuration from SSH host \u2B07")
        self.btnSshReadRpcConfig.clicked.connect(
            self.on_btnSshReadRpcConfig_clicked)
        hl.addWidget(self.btnSshReadRpcConfig)
        hl.addStretch()
        lay.addLayout(hl)

        # widget with RPC controls:
        self.rpc_cfg_widget = RpcConnectionWidget(self.detailsFrame)
        lay.addWidget(self.rpc_cfg_widget)

        # layout for test button:
        hl = QHBoxLayout()
        self.btnTestConnection = QPushButton("\u2705 Test connection")
        self.btnTestConnection.clicked.connect(
            self.on_btnTestConnection_clicked)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum,
                                           QtWidgets.QSizePolicy.Minimum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.btnTestConnection.sizePolicy().hasHeightForWidth())
        self.btnTestConnection.setSizePolicy(sizePolicy)
        hl.addWidget(self.btnTestConnection)
        hl.addStretch()
        lay.addLayout(hl)
        lay.addStretch()

        # set the default size of the left and right size of the splitter
        sh1 = self.lstConns.sizeHintForColumn(0) + 5
        sh2 = self.detailsFrame.sizeHint()
        self.splitter.setSizes([sh1, sh2.width()])

        self.rpc_cfg_widget.edtRpcHost.textEdited.connect(
            self.on_edtRpcHost_textEdited)
        self.rpc_cfg_widget.edtRpcPort.textEdited.connect(
            self.on_edtRpcPort_textEdited)
        self.rpc_cfg_widget.edtRpcUsername.textEdited.connect(
            self.on_edtRpcUsername_textEdited)
        self.rpc_cfg_widget.edtRpcPassword.textEdited.connect(
            self.on_edtRpcPassword_textEdited)
        self.rpc_cfg_widget.chbRpcSSL.toggled.connect(self.chbRpcSSL_toggled)
        self.ssh_tunnel_widget.edtSshHost.textEdited.connect(
            self.on_edtSshHost_textEdited)
        self.ssh_tunnel_widget.edtSshPort.textEdited.connect(
            self.on_edtSshPort_textEdited)
        self.ssh_tunnel_widget.edtSshUsername.textEdited.connect(
            self.on_edtSshUsername_textEdited)

        self.lstConns.setContextMenuPolicy(Qt.CustomContextMenu)
        self.popMenu = QMenu(self)

        # add new connection action
        self.actNewConn = self.popMenu.addAction("\u2795 Add new connection")
        self.actNewConn.triggered.connect(self.on_actNewConn_triggered)
        self.btnNewConn.setDefaultAction(self.actNewConn)

        # delete connection(s) action
        self.actDeleteConnections = self.popMenu.addAction(
            "\u2796 Delete selected connection(s)")
        self.actDeleteConnections.triggered.connect(
            self.on_actDeleteConnections_triggered)
        self.btnDeleteConn.setDefaultAction(self.actDeleteConnections)

        # copy connection(s) to clipboard
        self.actCopyConnections = self.popMenu.addAction(
            "\u274f Copy connection(s) to clipboard")
        self.actCopyConnections.triggered.connect(self.on_copyConns_triggered)

        # paste connection(s) from clipboard
        self.actPasteConnections = self.popMenu.addAction(
            "\u23ce Paste connection(s) from clipboard")
        self.actPasteConnections.triggered.connect(
            self.on_pasteConns_triggered)

        # set unicode symbols to the buttons
        self.btnNewConn.setText("\u2795")
        self.btnDeleteConn.setText("\u2796")
        self.btnMoveDownConn.setText("\u2B07")
        self.btnMoveUpConn.setText("\u2B06")
        self.btnRestoreDefault.setText('\u2606')
        self.rpc_cfg_widget.btnShowPassword.setText("\u29BF")
        self.rpc_cfg_widget.btnShowPassword.pressed.connect(
            self.on_btnShowPassword_pressed)
        self.rpc_cfg_widget.btnShowPassword.released.connect(
            self.on_btnShowPassword_released)

        if len(self.local_config.dash_net_configs):
            self.lstConns.setCurrentRow(0)

        if self.local_config.hw_type == HWType.trezor:
            self.chbHwTrezor.setChecked(True)
        elif self.local_config.hw_type == HWType.keepkey:
            self.chbHwKeepKey.setChecked(True)
        else:
            self.chbHwLedgerNanoS.setChecked(True)

        if self.local_config.hw_keepkey_psw_encoding == 'NFC':
            self.cboKeepkeyPassEncoding.setCurrentIndex(0)
        else:
            self.cboKeepkeyPassEncoding.setCurrentIndex(1)
        note_url = app_config.PROJECT_URL + '/blob/master/doc/notes.md#note-dmtn0001'
        self.lblKeepkeyPassEncoding.setText(
            f'KepKey passphrase encoding (<a href="{note_url}">see</a>)')

        self.chbCheckForUpdates.setChecked(self.local_config.check_for_updates)
        self.chbBackupConfigFile.setChecked(
            self.local_config.backup_config_file)
        self.chbDownloadProposalExternalData.setChecked(
            self.local_config.read_proposals_external_attributes)
        self.chbDontUseFileDialogs.setChecked(
            self.local_config.dont_use_file_dialogs)
        self.chbConfirmWhenVoting.setChecked(
            self.local_config.confirm_when_voting)
        self.chbAddRandomOffsetToVotingTime.setChecked(
            self.local_config.add_random_offset_to_vote_time)

        idx = {
            'CRITICAL': 0,
            'ERROR': 1,
            'WARNING': 2,
            'INFO': 3,
            'DEBUG': 4,
            'NOTSET': 5
        }.get(self.local_config.log_level_str, 2)
        self.cboLogLevel.setCurrentIndex(idx)

        self.update_keepkey_pass_encoding_ui()
        self.updateUi()
        self.disable_cfg_update = False
    def setupUi(self):
        Ui_ConfigDlg.setupUi(self, self)
        self.setWindowTitle("Configuration")
        self.splitter.setStretchFactor(0, 0)
        self.splitter.setStretchFactor(1, 1)
        self.accepted.connect(self.on_accepted)
        if sys.platform == 'win32':
            a_link = '<a href="file:///' + self.config.app_config_file_name + '">' + self.config.app_config_file_name + '</a>'
        else:
            a_link = '<a href="file://' + self.config.app_config_file_name + '">' + self.config.app_config_file_name + '</a>'
        self.lblStatus.setText('Config file: ' + a_link)
        self.lblStatus.setOpenExternalLinks(True)
        self.disable_cfg_update = True

        # display all connection configs
        self.displayConnsConfigs()

        lay = self.detailsFrame.layout()

        self.chbConnEnabled = QCheckBox("Enabled")
        self.chbConnEnabled.toggled.connect(self.on_chbConnEnabled_toggled)
        lay.addWidget(self.chbConnEnabled)

        self.chbUseSshTunnel = QCheckBox("Use SSH tunnel")
        self.chbUseSshTunnel.toggled.connect(self.on_chbUseSshTunnel_toggled)
        lay.addWidget(self.chbUseSshTunnel)
        self.ssh_tunnel_widget = SshConnectionWidget(self.detailsFrame)
        lay.addWidget(self.ssh_tunnel_widget)

        # layout for button for reading RPC configuration from remote host over SSH:
        hl = QHBoxLayout()
        self.btnSshReadRpcConfig = QPushButton(
            "\u2B07 Read RPC configuration from SSH host \u2B07")
        self.btnSshReadRpcConfig.clicked.connect(
            self.on_btnSshReadRpcConfig_clicked)
        hl.addWidget(self.btnSshReadRpcConfig)
        hl.addStretch()
        lay.addLayout(hl)

        # widget with RPC controls:
        self.rpc_cfg_widget = RpcConnectionWidget(self.detailsFrame)
        lay.addWidget(self.rpc_cfg_widget)

        # layout for test button:
        hl = QHBoxLayout()
        self.btnTestConnection = QPushButton("\u2705 Test connection")
        self.btnTestConnection.clicked.connect(
            self.on_btnTestConnection_clicked)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum,
                                           QtWidgets.QSizePolicy.Minimum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.btnTestConnection.sizePolicy().hasHeightForWidth())
        self.btnTestConnection.setSizePolicy(sizePolicy)
        hl.addWidget(self.btnTestConnection)
        hl.addStretch()
        lay.addLayout(hl)
        lay.addStretch()

        # set the default size of the left and right size of the splitter
        sh1 = self.lstConns.sizeHintForColumn(0) + 5
        sh2 = self.detailsFrame.sizeHint()
        self.splitter.setSizes([sh1, sh2.width()])

        self.rpc_cfg_widget.edtRpcHost.textEdited.connect(
            self.on_edtRpcHost_textEdited)
        self.rpc_cfg_widget.edtRpcPort.textEdited.connect(
            self.on_edtRpcPort_textEdited)
        self.rpc_cfg_widget.edtRpcUsername.textEdited.connect(
            self.on_edtRpcUsername_textEdited)
        self.rpc_cfg_widget.edtRpcPassword.textEdited.connect(
            self.on_edtRpcPassword_textEdited)
        self.rpc_cfg_widget.chbRpcSSL.toggled.connect(self.chbRpcSSL_toggled)
        self.ssh_tunnel_widget.edtSshHost.textEdited.connect(
            self.on_edtSshHost_textEdited)
        self.ssh_tunnel_widget.edtSshPort.textEdited.connect(
            self.on_edtSshPort_textEdited)
        self.ssh_tunnel_widget.edtSshUsername.textEdited.connect(
            self.on_edtSshUsername_textEdited)

        self.lstConns.setContextMenuPolicy(Qt.CustomContextMenu)
        self.popMenu = QMenu(self)

        # add new connection action
        self.actNewConn = self.popMenu.addAction("\u2795 Add new connection")
        self.actNewConn.triggered.connect(self.on_actNewConn_triggered)
        self.btnNewConn.setDefaultAction(self.actNewConn)

        # delete connection(s) action
        self.actDeleteConnections = self.popMenu.addAction(
            "\u2796 Delete selected connection(s)")
        self.actDeleteConnections.triggered.connect(
            self.on_actDeleteConnections_triggered)
        self.btnDeleteConn.setDefaultAction(self.actDeleteConnections)

        # copy connection(s) to clipboard
        self.actCopyConnections = self.popMenu.addAction(
            "\u274f Copy connection(s) to clipboard")
        self.actCopyConnections.triggered.connect(self.on_copyConns_triggered)

        # paste connection(s) from clipboard
        self.actPasteConnections = self.popMenu.addAction(
            "\u23ce Paste connection(s) from clipboard")
        self.actPasteConnections.triggered.connect(
            self.on_pasteConns_triggered)

        # set unicode symbols to the buttons
        self.btnNewConn.setText("\u2795")
        self.btnDeleteConn.setText("\u2796")
        self.btnMoveDownConn.setText("\u2B07")
        self.btnMoveUpConn.setText("\u2B06")
        self.rpc_cfg_widget.btnShowPassword.setText("\u29BF")
        self.rpc_cfg_widget.btnShowPassword.pressed.connect(
            self.on_btnShowPassword_pressed)
        self.rpc_cfg_widget.btnShowPassword.released.connect(
            self.on_btnShowPassword_released)

        if len(self.local_config.dash_net_configs):
            self.lstConns.setCurrentRow(0)

        if self.local_config.hw_type == 'TREZOR':
            self.chbHwTrezor.setChecked(True)
        else:
            self.chbHwKeepKey.setChecked(True)
        self.chbCheckForUpdates.setChecked(self.local_config.check_for_updates)
        self.chbBackupConfigFile.setChecked(
            self.local_config.backup_config_file)

        self.updateUi()
        self.disable_cfg_update = False