Example #1
1
    def __init__(self, main, channels, default_channel=None):
        super(ChannelAddWidget, self).__init__()
        self.setObjectName("ChannelAddWidget")
        self.main_win = main
        self.channels = channels
        self.default_channel = default_channel
        self.channel = {}
        self.linedit_list = []
        self.game = self.main_win.games[self.main_win.game_index]
        combox_items = os.listdir(Utils.get_full_path('channelsdk'))

        v_layout = QVBoxLayout()
        v_layout.addSpacing(30)
        select_channel_combox = QComboBox()
        select_channel_combox.addItems(combox_items)
        select_channel_combox.activated[str].connect(self.select_channel)
        v_layout.addWidget(select_channel_combox, alignment=Qt.AlignHCenter)
        v_layout.addSpacing(30)

        h_layout1 = QHBoxLayout()
        form_layout1 = QFormLayout()
        form_layout1.setContentsMargins(10, 10, 10, 0)
        game_appid_value = QLabel(self.game['id'])
        form_layout1.addRow("游戏ID:", game_appid_value)
        game_appid_value.setTextInteractionFlags(Qt.TextSelectableByMouse)
        self.channel_id_value = QLineEdit()
        self.channel_id_value.setPlaceholderText("必填参数")
        form_layout1.addRow("渠道ID:", self.channel_id_value)
        self.game_name_value = QLineEdit()
        self.game_name_value.setText(self.game['name'])
        form_layout1.addRow("游戏名称:", self.game_name_value)
        self.game_package_value = QLineEdit()
        form_layout1.addRow("游戏包名:", self.game_package_value)
        self.game_vcode_value = QLineEdit()
        form_layout1.addRow("游戏版本号:", self.game_vcode_value)
        self.game_vname_value = QLineEdit()
        form_layout1.addRow("游戏版本名:", self.game_vname_value)
        self.debug_value = QLineEdit("false")
        form_layout1.addRow("打印日志:", self.debug_value)
        h_layout1.addLayout(form_layout1)
        self.form_layout2 = QFormLayout()
        self.form_layout2.setContentsMargins(10, 10, 10, 0)
        h_layout1.addLayout(self.form_layout2)
        v_layout.addLayout(h_layout1)

        h_layout2 = QHBoxLayout()
        back_btn = QPushButton("返 回")
        back_btn.setFixedWidth(100)
        back_btn.clicked.connect(self.back)
        h_layout2.addWidget(back_btn, alignment=Qt.AlignLeft)
        add_btn = QPushButton("添 加")
        add_btn.setFixedWidth(100)
        add_btn.clicked.connect(self.add)
        h_layout2.addWidget(add_btn, alignment=Qt.AlignRight)
        v_layout.addSpacing(50)
        v_layout.addLayout(h_layout2)

        self.setLayout(v_layout)
        # 默认松鼠SDK
        select_channel_combox.setCurrentText("songshu")
        self.select_channel("songshu")
Example #2
0
    def __init__(self, main):
        super(GameListWidget, self).__init__()
        self.main_win = main
        self.keystore_exchanged = False

        self.setObjectName("GameListWidget")
        v_layout = QVBoxLayout()

        h_layout1 = QHBoxLayout()
        self.game_list_view = QListView()
        self.game_list_view.setViewMode(QListView.ListMode)
        self.game_list_view.setEditTriggers(QAbstractItemView.NoEditTriggers)
        self.game_list_model = GameListModel(self.main_win.games)
        self.game_list_view.setModel(self.game_list_model)
        self.game_list_view.clicked.connect(self.list_item_onclick)
        h_layout1.addWidget(self.game_list_view, 1)
        self.game_list_view.setCurrentIndex(
            self.game_list_model.index(self.main_win.game_index))
        self.game = self.main_win.games[self.main_win.game_index]

        form_layout = QFormLayout()
        form_layout.setContentsMargins(20, 50, 20, 50)
        self.game_name_value = QLineEdit()
        form_layout.addRow("游戏名称:", self.game_name_value)
        self.game_desc_value = QTextEdit()
        form_layout.addRow("游戏简介:", self.game_desc_value)
        self.game_appid_value = QLabel()
        self.game_appid_value.setTextInteractionFlags(Qt.TextSelectableByMouse)
        form_layout.addRow("游戏ID:", self.game_appid_value)
        self.game_appkey_value = QLabel()
        self.game_appkey_value.setTextInteractionFlags(
            Qt.TextSelectableByMouse)
        form_layout.addRow("客户端Key:", self.game_appkey_value)
        h_layout = QHBoxLayout()
        self.keystore_path = QLineEdit()
        select_key_btn = QPushButton("浏览")
        select_key_btn.setStyleSheet('QPushButton{border-radius: 0px;}')
        select_key_btn.clicked.connect(self.select_ketstore)
        h_layout.addWidget(self.keystore_path)
        h_layout.addWidget(select_key_btn)
        form_layout.addRow("KeyStore:", h_layout)
        self.keystore_pwd_value = QLineEdit()
        form_layout.addRow("KeyPass:"******"Alias:", self.keystore_alias_value)
        self.keystore_aliaspwd_value = QLineEdit()
        form_layout.addRow("AliasPass:"******"更换Icon")
        icon_exchange_btn.setFixedWidth(100)
        icon_exchange_btn.clicked.connect(self.exchange_icon)
        v_layout1.addWidget(icon_exchange_btn, alignment=Qt.AlignHCenter)
        v_layout1.addStretch(2)
        h_layout1.addLayout(v_layout1, 1)
        v_layout.addLayout(h_layout1)

        h_layout2 = QHBoxLayout()
        create_game_btn = QPushButton("返 回")
        create_game_btn.setFixedWidth(100)
        create_game_btn.clicked.connect(self.back)
        h_layout2.addWidget(create_game_btn,
                            alignment=Qt.AlignLeft | Qt.AlignBottom)
        back_btn = QPushButton("创建游戏")
        back_btn.setFixedWidth(100)
        back_btn.clicked.connect(self.add_game)
        h_layout2.addWidget(back_btn, alignment=Qt.AlignHCenter)
        next_btn = QPushButton("下一步")
        next_btn.setFixedWidth(100)
        next_btn.clicked.connect(self.next)
        h_layout2.addWidget(next_btn, alignment=Qt.AlignRight | Qt.AlignBottom)
        v_layout.addLayout(h_layout2)
        self.setLayout(v_layout)
        self.set_game_info()
Example #3
0
    def initConfigForm(self, masternode_alias=None):
        self.configForm = QGroupBox()
        if not masternode_alias:
            self.configForm.setTitle("New Masternode")
        else:
            self.configForm.setTitle("Edit Masternode [%s]" % masternode_alias)

        layout = QFormLayout()
        layout.setFieldGrowthPolicy(QFormLayout.AllNonFixedFieldsGrow)
        layout.setContentsMargins(10, 20, 10, 10)
        layout.setSpacing(13)
        ##--- ROW 1
        self.edt_name = QLineEdit()
        self.edt_name.setToolTip(
            "masternode Alias.\n-- example: My Masternode 1")
        layout.addRow(QLabel("Name"), self.edt_name)
        ##--- ROW 2
        line1 = QHBoxLayout()
        self.edt_masternodeIp = QLineEdit()
        self.edt_masternodeIp.setToolTip(
            "masternode IP address\n-- example [IPv4] 88.172.23.1\n-- example [IPv6] 2001:db8:85a3::8a2e:370:7334"
        )
        line1.addWidget(self.edt_masternodeIp)
        line1.addWidget(QLabel("IP Port"))
        self.edt_masternodePort = QSpinBox()
        self.edt_masternodePort.setRange(1, 65535)
        self.edt_masternodePort.setValue(51472)
        self.edt_masternodePort.setToolTip(
            "remote masternode tcp port \n-- example: 51472")
        self.edt_masternodePort.setFixedWidth(180)
        line1.addWidget(self.edt_masternodePort)
        layout.addRow(QLabel("IP Address"), line1)
        ##--- ROW 3
        self.edt_mnPrivKey = QLineEdit()
        self.edt_mnPrivKey.setToolTip(
            "masternode private key \n-- output of 'masternode genkey' command"
        )
        self.btn_genKey = QPushButton("Generate")
        self.btn_genKey.setToolTip(
            "generate masternode privKey from hardware wallet")
        hBox2 = QHBoxLayout()
        hBox2.addWidget(self.edt_mnPrivKey)
        hBox2.addWidget(self.btn_genKey)
        ## Testnet check
        self.testnetCheck = QCheckBox()
        self.testnetCheck.setToolTip("check for TESTNET masternode setup")
        hBox2.addWidget(QLabel("testnet"))
        hBox2.addWidget(self.testnetCheck)
        layout.addRow(QLabel("MN Priv Key"), hBox2)
        ##--- ROW 4/5
        layout.addRow(QFrame())
        layout.addRow(QLabel("<em>Masternode Collateral</em>"))
        hBox3 = QHBoxLayout()
        self.edt_hwAccount = QSpinBox()
        self.edt_hwAccount.setFixedWidth(50)
        self.edt_hwAccount.setToolTip(
            "account number of the hardware wallet.\nIf unsure put 0")
        self.edt_hwAccount.setValue(0)
        hBox3.addWidget(self.edt_hwAccount)
        hBox3.addWidget(QLabel("PIVX Address"))
        self.edt_address = QLineEdit()
        self.edt_address.setToolTip("the address containing 10000 PIV")
        self.edt_spath = QSpinBox()
        self.edt_spath.setToolTip("BIP44 spath for the address")
        self.edt_spath.setFixedWidth(75)
        self.edt_spath.setValue(0)
        self.btn_spathToAddress = QPushButton("<<")
        self.btn_spathToAddress.setToolTip(
            "find address and public key of given account/spath_id")
        self.btn_addressToSpath = QPushButton(">>")
        self.btn_addressToSpath.setToolTip(
            "find spath_id and public key of given account/address")
        hBox3.addWidget(self.edt_address)
        hBox3.addWidget(self.btn_spathToAddress)
        hBox3.addWidget(self.btn_addressToSpath)
        hBox3.addWidget(QLabel("spath_id"))
        hBox3.addWidget(self.edt_spath)
        layout.addRow(QLabel("Account HW"), hBox3)
        ##--- ROW 6
        self.edt_pubKey = QLineEdit()
        self.edt_pubKey.setToolTip("public key corresponding to address")
        self.edt_pubKey.setEnabled(False)
        layout.addRow(QLabel("Public Key"), self.edt_pubKey)
        ##--- ROW 7
        hBox5 = QHBoxLayout()
        self.btn_findTxid = QPushButton("Lookup")
        self.btn_findTxid.setToolTip("look for txid and txidn on explorer")
        hBox5.addWidget(self.btn_findTxid)
        hBox5.addWidget(QLabel("/"))
        self.btn_editTxid = QPushButton("Edit")
        self.btn_editTxid.setToolTip("edit txid and txidn manually")
        hBox5.addWidget(self.btn_editTxid)
        hBox5.addWidget(QLabel("txid"))
        self.edt_txid = QLineEdit()
        self.edt_txid.setToolTip("txid for the collateral")
        self.edt_txid.setEnabled(False)
        hBox5.addWidget(self.edt_txid)
        hBox5.addWidget(QLabel("txidn"))
        self.edt_txidn = QSpinBox()
        self.edt_txidn.setFixedWidth(50)
        self.edt_txidn.setToolTip("txidn for the collateral")
        self.edt_txidn.setEnabled(False)
        hBox5.addWidget(self.edt_txidn)
        layout.addRow(QLabel("Transaction"), hBox5)
        ##--- Set Layout
        self.configForm.setLayout(layout)
        ##--- Footer
        self.footer = QHBoxLayout()
        self.footer.addStretch(1)
        self.btn_cancelMNConf = QPushButton('Cancel')
        self.btn_cancelMNConf.setToolTip(
            "cancel changes and go back to main list")
        self.footer.addWidget(self.btn_cancelMNConf)
        self.btn_saveMNConf = QPushButton('Save')
        self.btn_saveMNConf.setToolTip(
            "save configuration and go back to main list")
        self.footer.addWidget(self.btn_saveMNConf)
Example #4
0
    def __init__(self, parent = None):
        super(SettingsWidget, self).__init__(parent, Qt.FramelessWindowHint)
        self._mousePressed = False
        self._orgPos = QPoint(0, 0)
        self.setObjectName('SettingsWidget')

        #
        self.stylize()

        # main layout
        labelTitle = QLabel('设置', self)
        buttonClose = JCloseButton(self)
        buttonClose.setObjectName('buttonClose')
        buttonClose.setToolTip('关闭')

        horiLayoutTitle = QHBoxLayout()
        horiLayoutTitle.setContentsMargins(6, 0, 6, 6)
        horiLayoutTitle.addWidget(labelTitle, 0, Qt.AlignTop)
        horiLayoutTitle.addStretch()
        horiLayoutTitle.addWidget(buttonClose, 0, Qt.AlignTop)

        groupBoxSettings = QGroupBox('设置端口', self)
        groupBoxSettings.setObjectName('groupBoxSettings')
        formLayoutSettings = QFormLayout(groupBoxSettings)
        formLayoutSettings.setContentsMargins(40, 10, 40, 10)
        formLayoutSettings.setVerticalSpacing(20)
        formLayoutSettings.setLabelAlignment(Qt.AlignRight)

        self.comboBoxPort = QComboBox(self)
        self.comboBoxPort.setMinimumWidth(100)
        formLayoutSettings.addRow('端口号:', self.comboBoxPort)

        self.comboBoxBaudRate = QComboBox(self)
        self.comboBoxBaudRate.setMinimumWidth(100)
        formLayoutSettings.addRow('波特率:', self.comboBoxBaudRate)

        self.labelDataBits = QComboBox(self)
        self.labelDataBits.setMinimumWidth(100)
        formLayoutSettings.addRow('数据位:', self.labelDataBits)

        self.comboBoxParity = QComboBox(self)
        self.comboBoxParity.setMinimumWidth(100)
        formLayoutSettings.addRow('校验位:', self.comboBoxParity)

        self.comboBoxStopBits = QComboBox(self)
        self.comboBoxStopBits.setMinimumWidth(100)
        formLayoutSettings.addRow('停止位:', self.comboBoxStopBits)

        # all
        horiLayoutSettings = QHBoxLayout();
        horiLayoutSettings.addStretch();
        horiLayoutSettings.addWidget(groupBoxSettings);
        horiLayoutSettings.addStretch();

        buttonOk = QPushButton('确定', self)
        buttonOk.setObjectName('buttonOk')
        horiLayoutButtons = QHBoxLayout()
        horiLayoutButtons.addStretch()
        horiLayoutButtons.addWidget(buttonOk)

        vertLayoutMain = QVBoxLayout(self)
        vertLayoutMain.addLayout(horiLayoutTitle)
        vertLayoutMain.addSpacing(5)
        # vertLayoutMain.addWidget(groupBoxSettings)
        vertLayoutMain.addLayout(horiLayoutSettings)
        vertLayoutMain.addStretch()
        vertLayoutMain.addLayout(horiLayoutButtons)

        buttonClose.clicked.connect(self.close)
Example #5
0
 def initRewardsForm(self):
     self.collateralHidden = True
     self.rewardsForm = QGroupBox()
     self.rewardsForm.setTitle("Transfer Rewards")
     layout = QFormLayout()
     layout.setContentsMargins(10, 10, 10, 10)
     layout.setSpacing(13)
     layout.setFieldGrowthPolicy(QFormLayout.AllNonFixedFieldsGrow)
     ##--- ROW 1
     hBox = QHBoxLayout()
     self.mnSelect = QComboBox()
     self.mnSelect.setToolTip("Select Masternode")
     hBox.addWidget(self.mnSelect)
     label = QLabel("Total Address Balance")
     label.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
     hBox.addWidget(label)
     self.addrAvailLine = QLabel()
     self.addrAvailLine.setToolTip("PIVX Address total balance")
     self.addrAvailLine.setText("--")
     hBox.addWidget(self.addrAvailLine)
     self.btn_toggleCollateral = QPushButton("Show Collateral")
     hBox.addWidget(self.btn_toggleCollateral)
     hBox.setStretch(0, 1)
     hBox.setStretch(1, 0)
     hBox.setStretch(2, 0)
     layout.addRow(QLabel("Masternode"), hBox)
     ## --- ROW 2: REWARDS
     self.rewardsList = QVBoxLayout()
     self.rewardsList.statusLabel = QLabel(
         '<b style="color:purple">Checking explorer...</b>')
     self.rewardsList.statusLabel.setVisible(True)
     self.rewardsList.addWidget(self.rewardsList.statusLabel)
     self.rewardsList.box = QTableWidget()
     self.rewardsList.box.setMinimumHeight(140)
     self.rewardsList.box.setMaximumHeight(140)
     self.rewardsList.box.setHorizontalScrollBarPolicy(
         Qt.ScrollBarAlwaysOff)
     self.rewardsList.box.setSelectionMode(QAbstractItemView.MultiSelection)
     self.rewardsList.box.setSelectionBehavior(QAbstractItemView.SelectRows)
     self.rewardsList.box.setShowGrid(True)
     self.rewardsList.box.setColumnCount(4)
     self.rewardsList.box.setRowCount(0)
     self.rewardsList.box.horizontalHeader().setSectionResizeMode(
         2, QHeaderView.Stretch)
     self.rewardsList.box.verticalHeader().hide()
     item = QTableWidgetItem()
     item.setText("PIVs")
     item.setTextAlignment(Qt.AlignCenter)
     self.rewardsList.box.setHorizontalHeaderItem(0, item)
     item = QTableWidgetItem()
     item.setText("Confirmations")
     item.setTextAlignment(Qt.AlignCenter)
     self.rewardsList.box.setHorizontalHeaderItem(1, item)
     item = QTableWidgetItem()
     item.setText("TX Hash")
     item.setTextAlignment(Qt.AlignCenter)
     self.rewardsList.box.setHorizontalHeaderItem(2, item)
     item = QTableWidgetItem()
     item.setText("TX Output N")
     item.setTextAlignment(Qt.AlignCenter)
     self.rewardsList.box.setHorizontalHeaderItem(3, item)
     item = QTableWidgetItem()
     self.rewardsList.addWidget(self.rewardsList.box)
     layout.addRow(self.rewardsList)
     ##--- ROW 3
     hBox2 = QHBoxLayout()
     self.btn_selectAllRewards = QPushButton("Select All")
     self.btn_selectAllRewards.setToolTip("Select all available UTXOs")
     hBox2.addWidget(self.btn_selectAllRewards)
     self.btn_deselectAllRewards = QPushButton("Deselect all")
     self.btn_deselectAllRewards.setToolTip("Deselect current selection")
     hBox2.addWidget(self.btn_deselectAllRewards)
     hBox2.addWidget(QLabel("Selected rewards"))
     self.selectedRewardsLine = QLabel()
     self.selectedRewardsLine.setMinimumWidth(200)
     self.selectedRewardsLine.setStyleSheet("color: purple")
     self.selectedRewardsLine.setToolTip("PIVX to move away")
     hBox2.addWidget(self.selectedRewardsLine)
     hBox2.addStretch(1)
     self.swiftxCheck = QCheckBox()
     self.swiftxCheck.setToolTip(
         "check for SwiftX instant transaction (flat fee rate of 0.01 PIV)")
     hBox2.addWidget(QLabel("Use SwiftX"))
     hBox2.addWidget(self.swiftxCheck)
     layout.addRow(hBox2)
     ##--- ROW 4
     hBox3 = QHBoxLayout()
     self.destinationLine = QLineEdit()
     self.destinationLine.setToolTip("PIVX address to transfer rewards to")
     hBox3.addWidget(self.destinationLine)
     hBox3.addWidget(QLabel("Fee"))
     self.feeLine = QDoubleSpinBox()
     self.feeLine.setDecimals(8)
     self.feeLine.setPrefix("PIV  ")
     self.feeLine.setToolTip("Insert a small fee amount")
     self.feeLine.setFixedWidth(150)
     self.feeLine.setSingleStep(0.001)
     hBox3.addWidget(self.feeLine)
     self.btn_sendRewards = QPushButton("Send")
     hBox3.addWidget(self.btn_sendRewards)
     layout.addRow(QLabel("Destination Address"), hBox3)
     ##--- ROW 5
     hBox4 = QHBoxLayout()
     hBox4.addStretch(1)
     self.loadingLine = QLabel(
         "<b style='color:red'>Preparing TX.</b> Completed: ")
     self.loadingLinePercent = QProgressBar()
     self.loadingLinePercent.setMaximumWidth(200)
     self.loadingLinePercent.setMaximumHeight(10)
     self.loadingLinePercent.setRange(0, 100)
     hBox4.addWidget(self.loadingLine)
     hBox4.addWidget(self.loadingLinePercent)
     self.loadingLine.hide()
     self.loadingLinePercent.hide()
     layout.addRow(hBox4)
     #--- Set Layout
     self.rewardsForm.setLayout(layout)
     #--- ROW 5
     self.btn_Cancel = QPushButton("Clear/Reload")
Example #6
0
 def initRewardsForm(self):
     self.rewardsForm = QGroupBox()
     self.rewardsForm.setTitle("Transfer UTXOs")
     layout = QFormLayout()
     layout.setContentsMargins(10, 10, 10, 10)
     layout.setSpacing(13)
     layout.setFieldGrowthPolicy(QFormLayout.AllNonFixedFieldsGrow)
     ##--- ROW 1
     line1 = QHBoxLayout()
     line1.addWidget(QLabel("Account HW"))
     self.edt_hwAccount = QSpinBox()
     self.edt_hwAccount.setMaximum(9999)
     self.edt_hwAccount.setFixedWidth(50)
     self.edt_hwAccount.setToolTip(
         "account number of the hardware wallet.\nIf unsure put 0")
     self.edt_hwAccount.setValue(0)
     line1.addWidget(self.edt_hwAccount)
     line1.addWidget(QLabel("spath from"))
     self.edt_spathFrom = QSpinBox()
     self.edt_spathFrom.setMaximum(9999)
     self.edt_spathFrom.setFixedWidth(50)
     self.edt_spathFrom.setToolTip("starting address n.")
     self.edt_spathFrom.setValue(0)
     line1.addWidget(self.edt_spathFrom)
     line1.addWidget(QLabel("spath to"))
     self.edt_spathTo = QSpinBox()
     self.edt_spathTo.setMaximum(9999)
     self.edt_spathTo.setFixedWidth(50)
     self.edt_spathTo.setToolTip("ending address n.")
     self.edt_spathTo.setValue(10)
     line1.addWidget(self.edt_spathTo)
     line1.addWidget(QLabel("internal/external"))
     self.edt_internalExternal = QSpinBox()
     self.edt_internalExternal.setFixedWidth(50)
     self.edt_internalExternal.setToolTip("ending address n.")
     self.edt_internalExternal.setValue(0)
     self.edt_internalExternal.setMaximum(1)
     line1.addWidget(self.edt_internalExternal)
     line1.addStretch(1)
     self.btn_reload = QPushButton("Scan Ledger device")
     self.btn_reload.setToolTip("Reload data from ledger device")
     line1.addWidget(self.btn_reload)
     layout.addRow(line1)
     hBox = QHBoxLayout()
     self.addySelect = QComboBox()
     self.addySelect.setToolTip("Select Address")
     hBox.addWidget(self.addySelect)
     layout.addRow(hBox)
     ## --- ROW 2: UTXOs
     self.rewardsList = QVBoxLayout()
     self.rewardsList.statusLabel = QLabel(
         '<b style="color:red">Reload Rewards</b>')
     self.rewardsList.statusLabel.setVisible(True)
     self.rewardsList.addWidget(self.rewardsList.statusLabel)
     self.rewardsList.box = QTableWidget()
     self.rewardsList.box.setMinimumHeight(200)
     #self.rewardsList.box.setMaximumHeight(140)
     self.rewardsList.box.setHorizontalScrollBarPolicy(
         Qt.ScrollBarAlwaysOff)
     self.rewardsList.box.setSelectionMode(QAbstractItemView.MultiSelection)
     self.rewardsList.box.setSelectionBehavior(QAbstractItemView.SelectRows)
     self.rewardsList.box.setShowGrid(True)
     self.rewardsList.box.setColumnCount(4)
     self.rewardsList.box.setRowCount(0)
     self.rewardsList.box.horizontalHeader().setSectionResizeMode(
         2, QHeaderView.Stretch)
     self.rewardsList.box.verticalHeader().hide()
     item = QTableWidgetItem()
     item.setText("PIVs")
     item.setTextAlignment(Qt.AlignCenter)
     self.rewardsList.box.setHorizontalHeaderItem(0, item)
     item = QTableWidgetItem()
     item.setText("Confirmations")
     item.setTextAlignment(Qt.AlignCenter)
     self.rewardsList.box.setHorizontalHeaderItem(1, item)
     item = QTableWidgetItem()
     item.setText("TX Hash")
     item.setTextAlignment(Qt.AlignCenter)
     self.rewardsList.box.setHorizontalHeaderItem(2, item)
     item = QTableWidgetItem()
     item.setText("TX Output N")
     item.setTextAlignment(Qt.AlignCenter)
     self.rewardsList.box.setHorizontalHeaderItem(3, item)
     item = QTableWidgetItem()
     self.rewardsList.addWidget(self.rewardsList.box)
     layout.addRow(self.rewardsList)
     ##--- ROW 3
     hBox2 = QHBoxLayout()
     self.btn_selectAllRewards = QPushButton("Select All")
     self.btn_selectAllRewards.setToolTip("Select all available UTXOs")
     hBox2.addWidget(self.btn_selectAllRewards)
     self.btn_deselectAllRewards = QPushButton("Deselect All")
     self.btn_deselectAllRewards.setToolTip("Deselect current selection")
     hBox2.addWidget(self.btn_deselectAllRewards)
     hBox2.addWidget(QLabel("Selected UTXOs"))
     self.selectedRewardsLine = QLabel()
     self.selectedRewardsLine.setMinimumWidth(200)
     self.selectedRewardsLine.setStyleSheet("color: purple")
     self.selectedRewardsLine.setToolTip("PIVX to move away")
     hBox2.addWidget(self.selectedRewardsLine)
     hBox2.addStretch(1)
     self.swiftxCheck = QCheckBox()
     self.swiftxCheck.setToolTip(
         "check for SwiftX instant transaction (flat fee rate of 0.01 PIV)")
     hBox2.addWidget(QLabel("Use SwiftX"))
     hBox2.addWidget(self.swiftxCheck)
     layout.addRow(hBox2)
     ##--- ROW 4
     hBox3 = QHBoxLayout()
     self.destinationLine = QLineEdit()
     self.destinationLine.setToolTip("PIVX address to send PIV to")
     hBox3.addWidget(self.destinationLine)
     hBox3.addWidget(QLabel("Fee"))
     self.feeLine = QDoubleSpinBox()
     self.feeLine.setDecimals(8)
     self.feeLine.setPrefix("PIV  ")
     self.feeLine.setToolTip("Insert a small fee amount")
     self.feeLine.setFixedWidth(150)
     self.feeLine.setSingleStep(0.001)
     hBox3.addWidget(self.feeLine)
     self.btn_sendRewards = QPushButton("Send")
     hBox3.addWidget(self.btn_sendRewards)
     layout.addRow(QLabel("Destination Address"), hBox3)
     hBox4 = QHBoxLayout()
     hBox4.addStretch(1)
     self.loadingLine = QLabel(
         "<b style='color:red'>Preparing TX.</b> Completed: ")
     self.loadingLinePercent = QProgressBar()
     self.loadingLinePercent.setMaximumWidth(200)
     self.loadingLinePercent.setMaximumHeight(10)
     self.loadingLinePercent.setRange(0, 100)
     hBox4.addWidget(self.loadingLine)
     hBox4.addWidget(self.loadingLinePercent)
     self.loadingLine.hide()
     self.loadingLinePercent.hide()
     layout.addRow(hBox4)
     #--- Set Layout
     self.rewardsForm.setLayout(layout)
     #--- ROW 5
     self.btn_Cancel = QPushButton("Clear")
Example #7
0
class ChannelAddWidget(QWidget):
    def __init__(self, main, channels, default_channel=None):
        super(ChannelAddWidget, self).__init__()
        self.setObjectName("ChannelAddWidget")
        self.main_win = main
        self.channels = channels
        self.default_channel = default_channel
        self.channel = {}
        self.linedit_list = []
        self.game = self.main_win.games[self.main_win.game_index]
        combox_items = os.listdir(Utils.get_full_path('channelsdk'))

        v_layout = QVBoxLayout()
        v_layout.addSpacing(30)
        select_channel_combox = QComboBox()
        select_channel_combox.addItems(combox_items)
        select_channel_combox.activated[str].connect(self.select_channel)
        v_layout.addWidget(select_channel_combox, alignment=Qt.AlignHCenter)
        v_layout.addSpacing(30)

        h_layout1 = QHBoxLayout()
        form_layout1 = QFormLayout()
        form_layout1.setContentsMargins(10, 10, 10, 0)
        game_appid_value = QLabel(self.game['id'])
        form_layout1.addRow("游戏ID:", game_appid_value)
        game_appid_value.setTextInteractionFlags(Qt.TextSelectableByMouse)
        self.channel_id_value = QLineEdit()
        self.channel_id_value.setPlaceholderText("必填参数")
        form_layout1.addRow("渠道ID:", self.channel_id_value)
        self.game_name_value = QLineEdit()
        self.game_name_value.setText(self.game['name'])
        form_layout1.addRow("游戏名称:", self.game_name_value)
        self.game_package_value = QLineEdit()
        form_layout1.addRow("游戏包名:", self.game_package_value)
        self.game_vcode_value = QLineEdit()
        form_layout1.addRow("游戏版本号:", self.game_vcode_value)
        self.game_vname_value = QLineEdit()
        form_layout1.addRow("游戏版本名:", self.game_vname_value)
        self.debug_value = QLineEdit("false")
        form_layout1.addRow("打印日志:", self.debug_value)
        h_layout1.addLayout(form_layout1)
        self.form_layout2 = QFormLayout()
        self.form_layout2.setContentsMargins(10, 10, 10, 0)
        h_layout1.addLayout(self.form_layout2)
        v_layout.addLayout(h_layout1)

        h_layout2 = QHBoxLayout()
        back_btn = QPushButton("返 回")
        back_btn.setFixedWidth(100)
        back_btn.clicked.connect(self.back)
        h_layout2.addWidget(back_btn, alignment=Qt.AlignLeft)
        add_btn = QPushButton("添 加")
        add_btn.setFixedWidth(100)
        add_btn.clicked.connect(self.add)
        h_layout2.addWidget(add_btn, alignment=Qt.AlignRight)
        v_layout.addSpacing(50)
        v_layout.addLayout(h_layout2)

        self.setLayout(v_layout)
        # 默认松鼠SDK
        select_channel_combox.setCurrentText("songshu")
        self.select_channel("songshu")

    def select_channel(self, text):
        # 先初始化数据
        self.linedit_list.clear()
        self.channel.clear()
        # 排序包体参数,防止参数写入乱排序
        self.channel['name'] = ''
        self.channel['sdk'] = text
        self.channel['channelId'] = ''
        self.channel['gameName'] = ''
        self.channel['package'] = ''
        self.channel['gameVersionCode'] = ''
        self.channel['gameVersionName'] = ''
        self.channel['debug'] = "false"
        # 获取渠道参数定义
        if not Utils.get_channel_config(self.channel):
            return

        # 再添加当前选择的渠道参数模板,刷新界面(先清空之前渠道参数表单,再添加)
        for i in range(self.form_layout2.rowCount()):
            # 因为formlayout清除一行,会自动上移,所以只需remove第一行
            self.form_layout2.removeRow(0)
        channel_name = QLabel(self.channel['name'] + '\t\t\tVersion:' +
                              self.channel['sdkVersionName'] + '\t\tUpdate:' +
                              self.channel['sdkUpdateTime'])
        channel_name.setAlignment(Qt.AlignRight)
        self.form_layout2.addRow(channel_name)
        if self.default_channel is not None and text == self.default_channel[
                'sdk']:
            self.channel_id_value.setText(self.default_channel['channelId'])
            self.game_name_value.setText(self.default_channel['gameName'])
            self.game_package_value.setText(self.default_channel['package'])
            self.game_vcode_value.setText(
                self.default_channel['gameVersionCode'])
            self.game_vname_value.setText(
                self.default_channel['gameVersionName'])
            for param in self.default_channel['sdkParams']:
                line_edit = QLineEdit()
                line_edit.setText(param['value'])
                self.form_layout2.addRow(param['showName'] + ':', line_edit)
                self.linedit_list.append(line_edit)
        else:
            for param in self.channel['sdkParams']:
                line_edit = QLineEdit()
                line_edit.setPlaceholderText("渠道参数必填")
                self.form_layout2.addRow(param['showName'] + ':', line_edit)
                self.linedit_list.append(line_edit)

    def back(self):
        if len(self.channels) <= 0:
            self.main_win.set_game_list_widget(self.main_win.games)
        else:
            self.main_win.set_channel_list_widget(self.channels)

    def add(self):
        if self.channel_id_value.text().strip() == "":
            QMessageBox.warning(self, "警告", "渠道ID不能为空!")
            return
        self.channel['channelId'] = self.channel_id_value.text().strip()
        for channel in self.channels:
            if self.channel['channelId'] == channel['channelId']:
                QMessageBox.warning(self, "警告", "渠道已存在!")
                return
        self.channel['gameName'] = self.game_name_value.text().strip()
        self.channel['package'] = self.game_package_value.text().strip()
        self.channel['gameVersionCode'] = self.game_vcode_value.text().strip()
        self.channel['gameVersionName'] = self.game_vname_value.text().strip()
        self.channel['debug'] = self.debug_value.text().strip()
        for i in range(len(self.linedit_list)):
            if self.linedit_list[i].text().strip() == "":
                QMessageBox.warning(self, "警告", "渠道参数不能为空!")
                return
            self.channel['sdkParams'][i]['value'] = self.linedit_list[i].text(
            ).strip()
        self.channels.append(self.channel)
        Utils.add_channel(
            Utils.get_full_path('games/' + self.game['id'] + '/config.xml'),
            self.channel)
        self.main_win.set_channel_list_widget(self.channels)
    def __init__(self, main, channels):
        super(ChannelListWidget, self).__init__()
        self.main_win = main
        self.channels = channels
        self.channel_index = len(channels) - 1
        self.linedit_list = []
        self.channel_ids = []
        for channel in self.channels:
            self.channel_ids.append(channel['channelId'])
        self.channel_ids.append(" + 添加渠道")

        self.setObjectName("ChannelListWidget")

        v_layout1 = QVBoxLayout()
        h_layout1 = QHBoxLayout()
        self.list_model = QStringListModel()
        self.list_model.setStringList(self.channel_ids)
        self.channel_list_view = QListView()
        self.channel_list_view.setModel(self.list_model)
        self.channel_list_view.setEditTriggers(
            QAbstractItemView.NoEditTriggers)
        self.channel_list_view.clicked.connect(self.list_item_onclick)
        self.channel_list_view.setContextMenuPolicy(Qt.CustomContextMenu)
        self.channel_list_view.customContextMenuRequested.connect(
            self.show_del_menu)
        h_layout1.addWidget(self.channel_list_view, 1)

        self.channel = self.channels[self.channel_index]

        form_layout = QFormLayout()
        form_layout.setContentsMargins(10, 100, 10, 50)
        form_layout.addRow(
            "游戏ID:",
            QLabel(self.main_win.games[self.main_win.game_index]['id']))
        self.channel_id_value = QLabel(self.channel['channelId'])
        self.channel_id_value.setTextInteractionFlags(Qt.TextSelectableByMouse)
        form_layout.addRow("渠道ID:", self.channel_id_value)
        self.game_name_value = QLineEdit()
        form_layout.addRow("游戏名称:", self.game_name_value)
        self.game_package_value = QLineEdit()
        form_layout.addRow("游戏包名:", self.game_package_value)
        self.game_vcode_value = QLineEdit()
        form_layout.addRow("游戏版本号:", self.game_vcode_value)
        self.game_vname_value = QLineEdit()
        form_layout.addRow("游戏版本名:", self.game_vname_value)
        self.debug_value = QLineEdit()
        form_layout.addRow("打印日志:", self.debug_value)
        h_layout1.addLayout(form_layout, 4)

        self.form_layout2 = QFormLayout()
        self.form_layout2.setContentsMargins(10, 100, 10, 50)
        self.set_info()
        h_layout1.addLayout(self.form_layout2, 4)
        v_layout1.addLayout(h_layout1)

        h_layout2 = QHBoxLayout()
        back_btn = QPushButton("返 回")
        back_btn.setFixedWidth(100)
        back_btn.clicked.connect(self.back)
        h_layout2.addWidget(back_btn, alignment=Qt.AlignLeft | Qt.AlignBottom)

        save_btn = QPushButton("保 存")
        save_btn.setFixedWidth(100)
        save_btn.clicked.connect(self.save_data)
        h_layout2.addWidget(save_btn, alignment=Qt.AlignHCenter)

        pack_btn = QPushButton("打 包")
        pack_btn.setFixedWidth(100)
        pack_btn.clicked.connect(self.to_package)
        h_layout2.addWidget(pack_btn, alignment=Qt.AlignRight | Qt.AlignBottom)

        v_layout1.addLayout(h_layout2)
        self.setLayout(v_layout1)
class ChannelListWidget(QWidget):
    def __init__(self, main, channels):
        super(ChannelListWidget, self).__init__()
        self.main_win = main
        self.channels = channels
        self.channel_index = len(channels) - 1
        self.linedit_list = []
        self.channel_ids = []
        for channel in self.channels:
            self.channel_ids.append(channel['channelId'])
        self.channel_ids.append(" + 添加渠道")

        self.setObjectName("ChannelListWidget")

        v_layout1 = QVBoxLayout()
        h_layout1 = QHBoxLayout()
        self.list_model = QStringListModel()
        self.list_model.setStringList(self.channel_ids)
        self.channel_list_view = QListView()
        self.channel_list_view.setModel(self.list_model)
        self.channel_list_view.setEditTriggers(
            QAbstractItemView.NoEditTriggers)
        self.channel_list_view.clicked.connect(self.list_item_onclick)
        self.channel_list_view.setContextMenuPolicy(Qt.CustomContextMenu)
        self.channel_list_view.customContextMenuRequested.connect(
            self.show_del_menu)
        h_layout1.addWidget(self.channel_list_view, 1)

        self.channel = self.channels[self.channel_index]

        form_layout = QFormLayout()
        form_layout.setContentsMargins(10, 100, 10, 50)
        form_layout.addRow(
            "游戏ID:",
            QLabel(self.main_win.games[self.main_win.game_index]['id']))
        self.channel_id_value = QLabel(self.channel['channelId'])
        self.channel_id_value.setTextInteractionFlags(Qt.TextSelectableByMouse)
        form_layout.addRow("渠道ID:", self.channel_id_value)
        self.game_name_value = QLineEdit()
        form_layout.addRow("游戏名称:", self.game_name_value)
        self.game_package_value = QLineEdit()
        form_layout.addRow("游戏包名:", self.game_package_value)
        self.game_vcode_value = QLineEdit()
        form_layout.addRow("游戏版本号:", self.game_vcode_value)
        self.game_vname_value = QLineEdit()
        form_layout.addRow("游戏版本名:", self.game_vname_value)
        self.debug_value = QLineEdit()
        form_layout.addRow("打印日志:", self.debug_value)
        h_layout1.addLayout(form_layout, 4)

        self.form_layout2 = QFormLayout()
        self.form_layout2.setContentsMargins(10, 100, 10, 50)
        self.set_info()
        h_layout1.addLayout(self.form_layout2, 4)
        v_layout1.addLayout(h_layout1)

        h_layout2 = QHBoxLayout()
        back_btn = QPushButton("返 回")
        back_btn.setFixedWidth(100)
        back_btn.clicked.connect(self.back)
        h_layout2.addWidget(back_btn, alignment=Qt.AlignLeft | Qt.AlignBottom)

        save_btn = QPushButton("保 存")
        save_btn.setFixedWidth(100)
        save_btn.clicked.connect(self.save_data)
        h_layout2.addWidget(save_btn, alignment=Qt.AlignHCenter)

        pack_btn = QPushButton("打 包")
        pack_btn.setFixedWidth(100)
        pack_btn.clicked.connect(self.to_package)
        h_layout2.addWidget(pack_btn, alignment=Qt.AlignRight | Qt.AlignBottom)

        v_layout1.addLayout(h_layout2)
        self.setLayout(v_layout1)

    def set_info(self):
        self.channel_id_value.setText(self.channel['channelId'])
        self.game_name_value.setText(self.channel['gameName'])
        self.game_package_value.setText(self.channel['package'])
        self.game_vcode_value.setText(self.channel['gameVersionCode'])
        self.game_vname_value.setText(self.channel['gameVersionName'])
        self.debug_value.setText(self.channel['debug'])
        # 先清空之前渠道参数表单,再添加
        for i in range(self.form_layout2.rowCount()):
            # 因为formlayout清除一行,会自动上移,所以只需remove第一行
            self.form_layout2.removeRow(0)
        self.linedit_list.clear()
        # 再添加当前选择的渠道参数
        channel_name = QLabel(self.channel['name'] + '\t\t\tVersion:' +
                              self.channel['sdkVersionName'] + '\t\tUpdate:' +
                              self.channel['sdkUpdateTime'])
        channel_name.setAlignment(Qt.AlignRight)
        self.form_layout2.addRow(channel_name)
        for param in self.channel['sdkParams']:
            line_edit = QLineEdit(param['value'])
            self.form_layout2.addRow(param['showName'] + ':', line_edit)
            self.linedit_list.append(line_edit)

    def list_item_onclick(self):
        if self.channel_list_view.currentIndex().row() == len(
                self.channel_ids) - 1:
            self.main_win.set_add_channel_widget(self.channels, self.channel)
        else:
            self.channel_index = self.channel_list_view.currentIndex().row()
            self.channel = self.channels[self.channel_index]
            self.set_info()

    def back(self):
        self.main_win.set_game_list_widget(self.main_win.games)

    def to_package(self):
        if not self.save_data():
            return
        self.main_win.set_package_widget(self.channels)

    def save_data(self):
        self.channel['gameName'] = self.game_name_value.text().strip()
        self.channel['package'] = self.game_package_value.text().strip()
        self.channel['gameVersionCode'] = self.game_vcode_value.text().strip()
        self.channel['gameVersionName'] = self.game_vname_value.text().strip()
        self.channel['debug'] = self.debug_value.text().strip()
        i = 0
        while i < len(self.linedit_list):
            if self.linedit_list[i].text().strip() == "":
                QMessageBox.warning(self, "警告", "渠道参数不能为空!")
                return False
            self.channel['sdkParams'][i]['value'] = self.linedit_list[i].text(
            ).strip()
            i += 1
        self.channels[self.channel_index] = self.channel
        game_id = self.main_win.games[self.main_win.game_index]['id']
        return Utils.update_channels(
            Utils.get_full_path('games/' + game_id + '/config.xml'),
            self.channel, self.channel_index)

    def show_del_menu(self, point):
        self.list_item_onclick()
        if -1 < self.channel_index < len(self.channel_ids) - 1:
            menu = QMenu(self.channel_list_view)
            del_action = QAction("删 除", menu)
            del_action.triggered.connect(self.del_channel)
            menu.addAction(del_action)
            menu.popup(self.channel_list_view.mapToGlobal(point))

    def del_channel(self):
        reply = QMessageBox.warning(self, "警告", "确定删除当前渠道?",
                                    QMessageBox.Yes | QMessageBox.No,
                                    QMessageBox.No)
        if reply == QMessageBox.Yes:
            # 更新listview
            self.channel_ids.pop(self.channel_index)
            self.list_model.setStringList(self.channel_ids)
            # 更新表单view(index前移一位)
            self.channel = self.channels[self.channel_index - 1]
            self.set_info()
            # 更新本地数据
            self.channels.pop(self.channel_index)
            game_id = self.main_win.games[self.main_win.game_index]['id']
            Utils.del_channel(
                Utils.get_full_path('games/' + game_id + '/config.xml'),
                self.channel_index)
            # 重置index,防止 index out of range
            self.channel_index = self.channel_index - 1
            if self.channel_index < 0:
                reply = QMessageBox.warning(self, "警告", "当前游戏未添加渠道,将返回游戏列表界面!",
                                            QMessageBox.Yes)
                if reply == QMessageBox.Yes:
                    self.back()
Example #10
0
    def __init__(self, main):
        super(GameCreateWidget, self).__init__()
        self.main_win = main
        self.setObjectName("GameCreateWidget")

        h_layout = QHBoxLayout()

        form_layout = QFormLayout()
        form_layout.setContentsMargins(20, 50, 20, 50)

        self.game_name_value = QLineEdit()
        form_layout.addRow("游戏名称:", self.game_name_value)

        self.game_desc_value = QTextEdit()
        form_layout.addRow("游戏简介:", self.game_desc_value)

        self.game_appid_value = QLineEdit()
        form_layout.addRow("游戏ID:", self.game_appid_value)

        self.game_appkey_value = QLineEdit()
        form_layout.addRow("客户端Key:", self.game_appkey_value)

        h_layout2 = QHBoxLayout()
        self.keystore_path = QLineEdit()
        select_key_btn = QPushButton("浏览")
        select_key_btn.setStyleSheet('QPushButton{border-radius: 0px;}')
        select_key_btn.clicked.connect(self.select_keystore)
        h_layout2.addWidget(self.keystore_path)
        h_layout2.addWidget(select_key_btn)
        form_layout.addRow("KeyStore:", h_layout2)

        self.keystore_pwd_value = QLineEdit()
        form_layout.addRow("KeyPass:"******"Alias:", self.keystore_alias_value)

        self.keystore_aliaspwd_value = QLineEdit()
        form_layout.addRow("AliasPass:"******"添加Icon")
        icon_add_btn.setFixedWidth(100)
        icon_add_btn.clicked.connect(self.add_icon)
        v_layout2.addWidget(icon_add_btn, alignment=Qt.AlignHCenter)
        v_layout2.addStretch(6)
        create_btn = QPushButton("创 建")
        create_btn.setFixedWidth(100)
        create_btn.clicked.connect(self.create)
        v_layout2.addWidget(create_btn,
                            alignment=Qt.AlignRight | Qt.AlignBottom)
        v_layout2.addStretch(1)
        back_btn = QPushButton("返 回")
        back_btn.setFixedWidth(100)
        back_btn.clicked.connect(self.back)
        v_layout2.addWidget(back_btn, alignment=Qt.AlignRight | Qt.AlignBottom)
        h_layout.addLayout(v_layout2, 1)

        self.setLayout(h_layout)
        self.game = {}
        self.icon_path = None