예제 #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")
 def create_ui(self):
     self.urlField = QLineEdit()
     self.usernameField = QLineEdit()
     self.passwordField = QLineEdit()
     layout = QFormLayout()
     layout.addRow("URL:", self.urlField)
     layout.addRow("Username:"******"Password:", self.passwordField)
     self.setLayout(layout)
예제 #3
0
    def ask_link(self):
        d = QDialog(self)
        d.setWindowTitle(_('Create link'))
        l = QFormLayout()
        l.setFieldGrowthPolicy(QFormLayout.ExpandingFieldsGrow)
        d.setLayout(l)
        d.url = QLineEdit(d)
        d.name = QLineEdit(d)
        d.treat_as_image = QCheckBox(d)
        d.setMinimumWidth(600)
        d.bb = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        d.br = b = QPushButton(_('&Browse'))
        b.setIcon(QIcon(I('document_open.png')))

        def cf():
            files = choose_files(d,
                                 'select link file',
                                 _('Choose file'),
                                 select_only_single_file=True)
            if files:
                path = files[0]
                d.url.setText(path)
                if path and os.path.exists(path):
                    with lopen(path, 'rb') as f:
                        q = what(f)
                    is_image = q in {'jpeg', 'png', 'gif'}
                    d.treat_as_image.setChecked(is_image)

        b.clicked.connect(cf)
        d.la = la = QLabel(
            _('Enter a URL. If you check the "Treat the URL as an image" box '
              'then the URL will be added as an image reference instead of as '
              'a link. You can also choose to create a link to a file on '
              'your computer. '
              'Note that if you create a link to a file on your computer, it '
              'will stop working if the file is moved.'))
        la.setWordWrap(True)
        la.setStyleSheet('QLabel { margin-bottom: 1.5ex }')
        l.setWidget(0, l.SpanningRole, la)
        l.addRow(_('Enter &URL:'), d.url)
        l.addRow(_('Treat the URL as an &image'), d.treat_as_image)
        l.addRow(_('Enter &name (optional):'), d.name)
        l.addRow(_('Choose a file on your computer:'), d.br)
        l.addRow(d.bb)
        d.bb.accepted.connect(d.accept)
        d.bb.rejected.connect(d.reject)
        d.resize(d.sizeHint())
        link, name, is_image = None, None, False
        if d.exec_() == d.Accepted:
            link, name = unicode_type(d.url.text()).strip(), unicode_type(
                d.name.text()).strip()
            is_image = d.treat_as_image.isChecked()
        return link, name, is_image
예제 #4
0
    def ask_link(self):
        d = QDialog(self)
        d.setWindowTitle(_('Create link'))
        l = QFormLayout()
        l.setFieldGrowthPolicy(QFormLayout.ExpandingFieldsGrow)
        d.setLayout(l)
        d.url = QLineEdit(d)
        d.name = QLineEdit(d)
        d.treat_as_image = QCheckBox(d)
        d.setMinimumWidth(600)
        d.bb = QDialogButtonBox(QDialogButtonBox.Ok|QDialogButtonBox.Cancel)
        d.br = b = QPushButton(_('&Browse'))
        b.setIcon(QIcon(I('document_open.png')))

        def cf():
            files = choose_files(d, 'select link file', _('Choose file'), select_only_single_file=True)
            if files:
                path = files[0]
                d.url.setText(path)
                if path and os.path.exists(path):
                    with lopen(path, 'rb') as f:
                        q = what(f)
                    is_image = q in {'jpeg', 'png', 'gif'}
                    d.treat_as_image.setChecked(is_image)

        b.clicked.connect(cf)
        d.la = la = QLabel(_(
            'Enter a URL. If you check the "Treat the URL as an image" box '
            'then the URL will be added as an image reference instead of as '
            'a link. You can also choose to create a link to a file on '
            'your computer. '
            'Note that if you create a link to a file on your computer, it '
            'will stop working if the file is moved.'))
        la.setWordWrap(True)
        la.setStyleSheet('QLabel { margin-bottom: 1.5ex }')
        l.setWidget(0, l.SpanningRole, la)
        l.addRow(_('Enter &URL:'), d.url)
        l.addRow(_('Treat the URL as an &image'), d.treat_as_image)
        l.addRow(_('Enter &name (optional):'), d.name)
        l.addRow(_('Choose a file on your computer:'), d.br)
        l.addRow(d.bb)
        d.bb.accepted.connect(d.accept)
        d.bb.rejected.connect(d.reject)
        d.resize(d.sizeHint())
        link, name, is_image = None, None, False
        if d.exec_() == d.Accepted:
            link, name = unicode(d.url.text()).strip(), unicode(d.name.text()).strip()
            is_image = d.treat_as_image.isChecked()
        return link, name, is_image
예제 #5
0
    def __init__(self, parent=None):
        super(NewTournamentWidget, self).__init__(parent)
        self.setMinimumWidth(200)
        self.setMaximumHeight(200)
        self.setModal(True)

        self.mainLayout = QVBoxLayout()
        titleLabel = QLabel("Tournament Search")
        titleLabel.setAlignment(Qt.AlignCenter)
        self.mainLayout.addWidget(titleLabel)

        formLayout = QFormLayout()
        self.nameLine = QLineEdit()
        formLayout.addRow(QLabel("Name"), self.nameLine)
        self.skuLine = QLineEdit()
        formLayout.addRow(QLabel("SKU"), self.skuLine)
        self.requiresTeamEdit = QLineEdit()
        formLayout.addRow(QLabel("Required Team"), self.requiresTeamEdit)

        self.mainLayout.addLayout(formLayout)

        self.searchButton = QPushButton("Search")
        self.searchButton.clicked.connect(self.search)
        self.mainLayout.addWidget(self.searchButton)

        self.manuallyButton = QPushButton("Create Tournament Manually")
        self.manuallyButton.clicked.connect(self.dontSearch)
        self.mainLayout.addWidget(self.manuallyButton)

        self.setLayout(self.mainLayout)
        self.setWindowTitle("New Tournament")
    def __init__(self, parent):
        QDialog.__init__(self, parent)
        self.app = FSApp.get_instance()

        self.setWindowTitle("Settings")
        self.setMinimumHeight(200)
        self.setMinimumWidth(450)

        layout = QVBoxLayout(self)
        form_layout = QFormLayout()
        self.extension_inputs = list()
        for extension_setting_key in self.app.extension_setting_keys():
            extension_input = QLineEdit(
                self.app.load_setting(extension_setting_key))
            self.extension_inputs.append(extension_input)
            form_layout.addRow(extension_setting_key + ":", extension_input)

        ok_button = QPushButton("OK")
        ok_button.clicked.connect(self.ok_clicked)
        layout.addLayout(form_layout)
        layout.addWidget(ok_button)
        self.setLayout(layout)
예제 #7
0
 def setupUi(self, ConfigureRPCserverDlg):
     ConfigureRPCserverDlg.setModal(True)
     ## -- Layout
     self.layout = QGroupBox(ConfigureRPCserverDlg)
     self.layout.setTitle("Local Pivx-Cli wallet Configuration")
     self.layout.setContentsMargins(80, 30, 10, 10)
     form = QFormLayout(ConfigureRPCserverDlg)
     form.setFieldGrowthPolicy(QFormLayout.AllNonFixedFieldsGrow)
     ## -- ROW 1
     line1 = QHBoxLayout()
     self.edt_rpcIp = QLineEdit()
     self.edt_rpcIp.setToolTip(
         "rpc server (local wallet) IP address\n-- example [IPv4] 88.172.23.1\n-- example [IPv6] 2001:db8:85a3::8a2e:370:7334"
     )
     self.edt_rpcIp.setText(ConfigureRPCserverDlg.rpc_ip)
     line1.addWidget(self.edt_rpcIp)
     line1.addWidget(QLabel("IP Port"))
     self.edt_rpcPort = QSpinBox()
     self.edt_rpcPort.setRange(1, 65535)
     self.edt_rpcPort.setValue(ConfigureRPCserverDlg.rpc_port)
     self.edt_rpcPort.setFixedWidth(180)
     line1.addWidget(self.edt_rpcPort)
     form.addRow(QLabel("IP Address"), line1)
     ## -- ROW 2
     self.edt_rpcUser = QLineEdit()
     self.edt_rpcUser.setText(ConfigureRPCserverDlg.rpc_user)
     form.addRow(QLabel("RPC Username"), self.edt_rpcUser)
     ## -- ROW 3
     self.edt_rpcPassword = QLineEdit()
     self.edt_rpcPassword.setText(ConfigureRPCserverDlg.rpc_password)
     form.addRow(QLabel("RPC Password"), self.edt_rpcPassword)
     ## -- ROW 4
     hBox = QHBoxLayout()
     self.buttonCancel = QPushButton("Cancel")
     self.buttonCancel.clicked.connect(
         lambda: self.onButtonCancel(ConfigureRPCserverDlg))
     hBox.addWidget(self.buttonCancel)
     self.buttonSave = QPushButton("Save")
     self.buttonSave.clicked.connect(
         lambda: self.onButtonSave(ConfigureRPCserverDlg))
     hBox.addWidget(self.buttonSave)
     form.addRow(hBox)
     ## Set Layout
     self.layout.setLayout(form)
     ConfigureRPCserverDlg.setFixedSize(self.layout.sizeHint())
예제 #8
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")
예제 #9
0
class ConfigWidget(QWidget):

    def __init__(self):
        QWidget.__init__(self)
        self.l = QFormLayout(self)
        self.setLayout(self.l)
        self.form_elements = {}

        self.l.addRow(QLabel(_("Currently anonymous Crossref requests are unbearable slow.")))
        self.l.addRow(QLabel(_("They say requests including an email address will go to 'polite' servers that are more responsive.")))
        # self.l.addRow(QLabel(_("I feel bibliographic research data very sensitive so I suggest using an anonyomous address.")))

        self.put_element(
            'email4polite',
            QLineEdit(self)
            ,_('Email address for "polite" servers:')
        )
        self.put_element(
            'prefer_short_title',
            QCheckBox(_('Prefer short title if available'), self)
        )
        self.put_element(
            'prefer_short_journal',
            QCheckBox(_('Prefer short journal name if available'), self)
        )

        self.put_element(
            'abstract_to_comment',
            QCheckBox(_('Put abstract in comment'), self)
        )
        self.put_element(
            'query_to_comment',
            QCheckBox(_('Write additional info in comments'), self)
        )
        self.put_element(
            'query_extra_by_name',
            QCheckBox(_('If object has DOI also search by title'), self)
        )
        self.put_element(
            'add_tags',
            QCheckBox(_('Store Subjects as tags'), self)
        )
        self.init_editors()


    def put_element(self, name, widget, title=None):
        if not name in self.form_elements:
            self.form_elements[name] = widget
            if title:
                self.l.addRow(title,widget)
            else:
                self.l.addRow(widget)
        else:
            raise Exception("Duplicate preference: %s", name)

    def init_editors(self):
        for key,obj in self.form_elements.items():
            if isinstance(obj, QCheckBox):
                obj.setChecked(prefs[key])
            elif isinstance(obj, QLineEdit):
                obj.setText(str(prefs[key]))
            else:
                raise Exception("unimplemented pref for: %s", obj)

    def save_settings(self):
        for key,obj in self.form_elements.items():
            if isinstance(obj, QCheckBox):
                prefs[key] = obj.checkState() == Qt.Checked
            elif isinstance(obj, QLineEdit):
                prefs[key] = obj.text()
            else:
                raise Exception("unimplemented pref for: %s", obj)
예제 #10
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)
예제 #11
0
        def __init__(self, parent=None):
            QDialog.__init__(self, parent)
            self.setWindowTitle('Preferences')
            self.resize(600, 240)
            layout = QHBoxLayout()
            preview = Preview(self)
            #Antonio has a problem with the width of Preview
            form = QFormLayout()
            self.widthSB = QSpinBox()
            self.heightSB = QSpinBox()
            self.widthSB.setRange(1, 1000)
            self.heightSB.setRange(1, 1000)
            self.widthSB.setValue(label_size[0])
            self.heightSB.setValue(label_size[1])
            form.addRow('Width', self.widthSB)
            form.addRow('Height', self.heightSB)
            self.spacingDS = DoubleSpin()
            self.spacingDS.setX(spacing[0])
            self.spacingDS.setY(spacing[1])
            form.addRow('Spacing', self.spacingDS)
            self.offsetDS = DoubleSpin()
            self.offsetDS.setX(first_label_offset[0])
            self.offsetDS.setY(first_label_offset[1])
            form.addRow('Offset', self.offsetDS)
            self.p1 = DoubleSpin()
            self.p1.setX(item_positions['article'][0])
            self.p1.setY(item_positions['article'][1])
            form.addRow('p1', self.p1)
            self.p2 = DoubleSpin()
            self.p2.setX(item_positions['week'][0])
            self.p2.setY(item_positions['week'][1])
            form.addRow('p2', self.p2)
            self.p3 = DoubleSpin()
            self.p3.setX(item_positions['lot'][0])
            self.p3.setY(item_positions['lot'][1])
            form.addRow('p3', self.p3)
            self.p4 = DoubleSpin()
            self.p4.setX(item_positions['code'][0])
            self.p4.setY(item_positions['code'][1])
            form.addRow('p4', self.p4)
            self.qr_sizeDS = DoubleSpin()
            self.qr_sizeDS.setX(qr_size[0])
            self.qr_sizeDS.setY(qr_size[1])
            form.addRow('QR size', self.qr_sizeDS)
            self.alignament_mark = DoubleSpin()
            self.alignament_mark.setX(
                item_positions['logo']
                [0])  #instead of logo, position of alignment_mark is used
            self.alignament_mark.setY(item_positions['logo'][1])
            form.addRow('Alignment mark', self.alignament_mark)

            self.numberofColumnsSB = QSpinBox()
            self.numberofColumnsSB.setRange(1, 10)
            self.numberofColumnsSB.setValue(n_columns)
            form.addRow('Number of columns', self.numberofColumnsSB)

            self.numberofRowsSB = QSpinBox()
            self.numberofRowsSB.setRange(1, 50)
            self.numberofRowsSB.setValue(n_rows_per_page)
            form.addRow('Number of rows', self.numberofRowsSB)

            self.fontSizeSB = QSpinBox()
            self.fontSizeSB.setRange(4, 25)
            self.fontSizeSB.setValue(font['size'])
            form.addRow('Font size', self.fontSizeSB)
            self.frame_visible = QComboBox()
            self.frame_visible.addItem('True')
            self.frame_visible.addItem('False')

            form.addRow('Frame visible?', self.frame_visible)
            pbOk = QPushButton('OK')
            pbOk.clicked.connect(self.accept)
            form.addRow('', pbOk)
            pbCancel = QPushButton('Cancel')
            pbCancel.clicked.connect(self.reject)
            form.addRow('', pbCancel)
            layout.addWidget(preview)
            layout.addLayout(form)
            self.setLayout(layout)
class ConfigWidget(QWidget):
    def __init__(self):
        QWidget.__init__(self)

        self.main_layout = QVBoxLayout()
        self.l = QFormLayout()
        self.l2 = QHBoxLayout()
        self.l3 = QHBoxLayout()

        self.group_box = QGroupBox('Ustawienia ogólne')
        self.group_box2 = QGroupBox('Pobieraj metadane')
        self.group_box3 = QGroupBox(
            'Pobieraj dodatkowe metadane i dołącz je do komentarza')

        # general settings
        self.max_results_label = QLabel('Maksymalna liczba wyników')
        self.max_results_label.setToolTip(
            'Maksymalna liczba pobieranych metadanych. Dla książek o nieunikalnych tytułach \
pierwszy wynik może być niepoprawny')
        self.max_results = QLineEdit(self)
        self.max_results.setValidator(QIntValidator())
        self.max_results.setText(str(PREFS['max_results']))
        self.max_results_label.setBuddy(self.max_results)
        self.l.addRow(self.max_results_label, self.max_results)

        self.authors_search_label = QLabel('Używaj autorów do wyszukiwań')
        self.authors_search_label.setToolTip(
            'Wyszukuj uwzględniając autorów. Może poprawić trafność wyników, ale błędni autorzy spowodują brak wyników'
        )
        self.authors_search = QCheckBox()
        self.authors_search.setChecked(PREFS['authors_search'])
        self.authors_search_label.setBuddy(self.authors_search)
        self.l.addRow(self.authors_search_label, self.authors_search)

        self.only_first_author_label = QLabel(
            'Używaj tylko pierwszego autora do wyszukiwania')
        self.only_first_author_label.setToolTip(
            'Używaj tylko pierwszego autora do wyszukiwań, obowiązuje tylko gdy wyszukiwanie z autorami jest aktywowane'
        )
        self.only_first_author = QCheckBox()
        self.only_first_author.setChecked(PREFS['only_first_author'])
        self.only_first_author_label.setBuddy(self.only_first_author)
        self.l.addRow(self.only_first_author_label, self.only_first_author)

        self.covers_label = QLabel('Pobieraj okładki')
        self.covers = QCheckBox()
        self.covers.setChecked(PREFS['covers'])
        self.covers_label.setBuddy(self.covers)
        self.l.addRow(self.covers_label, self.covers)

        self.max_covers_label = QLabel('Maksymalna liczba okładek')
        self.max_covers_label.setToolTip(
            'Maksymalna liczba pobieranych okładek')
        self.max_covers = QLineEdit(self)
        self.max_covers.setValidator(QIntValidator())
        self.max_covers.setText(str(PREFS['max_covers']))
        self.max_covers_label.setBuddy(self.max_covers)
        self.l.addRow(self.max_covers_label, self.max_covers)

        self.threads_label = QLabel('Wielowątkowe przetwarzanie')
        self.threads_label.setToolTip(
            'Przyśpiesza pracę używając wielu wątków')
        self.threads = QCheckBox()
        self.threads.setChecked(PREFS['threads'])
        self.threads_label.setBuddy(self.threads)
        self.l.addRow(self.threads_label, self.threads)

        self.max_threads_label = QLabel('Maksymalna liczba wątków')
        self.max_threads = QLineEdit(self)
        self.max_threads.setValidator(QIntValidator())
        self.max_threads.setText(str(PREFS['max_threads']))
        self.max_threads_label.setBuddy(self.max_threads)
        self.l.addRow(self.max_threads_label, self.max_threads)

        self.thread_delay_label = QLabel('Opóźnienie wątku')
        self.thread_delay_label.setToolTip(
            'Czas oczekiwania na uruchomienie kolejnego wątku')
        self.thread_delay = QLineEdit(self)
        self.thread_delay.setValidator(QDoubleValidator())
        self.thread_delay.setText(str(PREFS['thread_delay']))
        self.thread_delay_label.setBuddy(self.thread_delay)
        self.l.addRow(self.thread_delay_label, self.thread_delay)

        # metadata settings
        if 'title' in PREFS.defaults:
            self.title = QCheckBox('Tytuł')
            self.title.setChecked(PREFS['title'])
            self.l2.addWidget(self.title)

        if 'authors' in PREFS.defaults:
            self.authors = QCheckBox('Autorzy')
            self.authors.setChecked(PREFS['authors'])
            self.l2.addWidget(self.authors)

        if 'pubdate' in PREFS.defaults:
            self.pubdate = QCheckBox('Data wydania')
            self.pubdate.setChecked(PREFS['pubdate'])
            self.l2.addWidget(self.pubdate)

        if 'publisher' in PREFS.defaults:
            self.publisher = QCheckBox('Wydawca')
            self.publisher.setChecked(PREFS['publisher'])
            self.l2.addWidget(self.publisher)

        if 'isbn' in PREFS.defaults:
            self.isbn = QCheckBox('ISBN')
            self.isbn.setChecked(PREFS['isbn'])
            self.l2.addWidget(self.isbn)

        if 'comments' in PREFS.defaults:
            self.comments = QCheckBox('Opis')
            self.comments.setChecked(PREFS['comments'])
            self.l2.addWidget(self.comments)

        if 'languages' in PREFS.defaults:
            self.languages = QCheckBox('Języki')
            self.languages.setChecked(PREFS['languages'])
            self.l2.addWidget(self.languages)

        if 'rating' in PREFS.defaults:
            self.rating = QCheckBox('Ocena')
            self.rating.setChecked(PREFS['rating'])
            self.l2.addWidget(self.rating)

        if 'tags' in PREFS.defaults:
            self.tags = QCheckBox('Etykiety (tagi)')
            self.tags.setChecked(PREFS['tags'])
            self.l2.addWidget(self.tags)

        if 'series' in PREFS.defaults:
            self.series = QCheckBox('Cykle')
            self.series.setChecked(PREFS['series'])
            self.l2.addWidget(self.series)

        if 'identifier' in PREFS.defaults:
            self.identifier = QCheckBox('Identyfikator')
            self.identifier.setChecked(PREFS['identifier'])
            self.l2.addWidget(self.identifier)

        # custom metadata
        if 'translators' in PREFS.defaults:
            self.translators = QCheckBox('Tłumaczenie')
            self.translators.setChecked(PREFS['translators'])
            self.l3.addWidget(self.translators)

        if 'original_title' in PREFS.defaults:
            self.original_title = QCheckBox('Tytuł oryginału')
            self.original_title.setChecked(PREFS['original_title'])
            self.l3.addWidget(self.original_title)

        if 'categories' in PREFS.defaults:
            self.categories = QCheckBox('Kategorie')
            self.categories.setChecked(PREFS['categories'])
            self.l3.addWidget(self.categories)

        if 'genres' in PREFS.defaults:
            self.genres = QCheckBox('Gatunki')
            self.genres.setChecked(PREFS['genres'])
            self.l3.addWidget(self.genres)

        self.group_box.setLayout(self.l)
        self.group_box2.setLayout(self.l2)
        self.group_box3.setLayout(self.l3)
        self.main_layout.addWidget(self.group_box)
        self.main_layout.addWidget(self.group_box2)
        self.main_layout.addWidget(self.group_box3)
        self.main_layout.setAlignment(Qt.AlignTop)
        self.setLayout(self.main_layout)

    def save_settings(self):
        PREFS['max_results'] = int(self.max_results.text())
        PREFS['authors_search'] = self.authors_search.isChecked()
        PREFS['only_first_author'] = self.only_first_author.isChecked()
        PREFS['covers'] = self.covers.isChecked()
        PREFS['max_covers'] = int(self.max_covers.text())
        PREFS['threads'] = self.threads.isChecked()
        PREFS['max_threads'] = int(self.max_threads.text())
        PREFS['thread_delay'] = float(self.thread_delay.text().replace(
            ',', '.'))

        # metadata settings
        if 'title' in PREFS.defaults:
            PREFS['title'] = self.title.isChecked()
        if 'authors' in PREFS.defaults:
            PREFS['authors'] = self.authors.isChecked()
        if 'pubdate' in PREFS.defaults:
            PREFS['pubdate'] = self.pubdate.isChecked()
        if 'publisher' in PREFS.defaults:
            PREFS['publisher'] = self.publisher.isChecked()
        if 'isbn' in PREFS.defaults:
            PREFS['isbn'] = self.isbn.isChecked()
        if 'comments' in PREFS.defaults:
            PREFS['comments'] = self.comments.isChecked()
        if 'languages' in PREFS.defaults:
            PREFS['languages'] = self.languages.isChecked()
        if 'rating' in PREFS.defaults:
            PREFS['rating'] = self.rating.isChecked()
        if 'tags' in PREFS.defaults:
            PREFS['tags'] = self.tags.isChecked()
        if 'series' in PREFS.defaults:
            PREFS['series'] = self.series.isChecked()
        if 'identifier' in PREFS.defaults:
            PREFS['identifier'] = self.identifier.isChecked()

        # custom metadata settings
        if 'translators' in PREFS.defaults:
            PREFS['translators'] = self.translators.isChecked()
        if 'original_title' in PREFS.defaults:
            PREFS['original_title'] = self.original_title.isChecked()
        if 'categories' in PREFS.defaults:
            PREFS['categories'] = self.categories.isChecked()
        if 'genres' in PREFS.defaults:
            PREFS['genres'] = self.genres.isChecked()

        return PREFS
예제 #13
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
예제 #14
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)
예제 #15
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")
예제 #16
0
파일: main_window.py 프로젝트: bjoerng/mpdj
class MainWindowMPDJ(QMainWindow):
    """Display the main window of the application where the connections
        and other stuff is edited by the user."""
    def show(self):
        """Shows this window (maximized). I will work on a better solution."""
        QMainWindow.showMaximized(self)

    def update(self):
        """Updates the view."""
        global_properties = GlobalProperties.get_instance()
        mpdj_data = global_properties.mpdj_data
        self.tf_min_per_selection.setText(
            str(mpdj_data.min_units_per_node_touch))
        self.tf_max_per_selection.setText(
            str(mpdj_data.max_units_per_node_touch))
        self.tf_min_global_song_duration.setText(
            str(mpdj_data.global_min_song_duration))
        self.tf_max_global_song_duration.setText(
            str(mpdj_data.global_max_song_duration))
        self.cb_global_limit_overflow.setChecked(
            mpdj_data.limit_overspill_global)
        self.tf_global_node_max_overflow_minutes.setText(
            str(mpdj_data.global_node_max_overspill))
        self.tf_global_node_max_overflow_minutes.setDisabled(
            not mpdj_data.limit_overspill_global)
        text_to_find = mpdj_data.unit_per_node_touch.gui_representation()
        index = self.combo_box_minutes_or_titles.findText(
            text_to_find, Qt.MatchFixedString)
        self.combo_box_minutes_or_titles.setCurrentIndex(index)
        #        self.limit_artist_play_chk_box.setChecked(
        #            global_properties.mpdj_data.limit_artist_in_node_touch)
        self.chk_box_graph_is_directed.setChecked(mpdj_data.graph_is_directed)
        self.setWindowTitle('MPDJ: {}'.format(
            global_properties.path_of_current_file))

    def write_min_global_song_duration_to_mpdj(self):
        """Writes min global song duration to mpdj."""
        global_properties = GlobalProperties.get_instance()
        global_properties.mpdj_data.global_min_song_duration = int(
            self.tf_min_global_song_duration.text())

    def write_max_global_song_duration_to_mpdj(self):
        """Writes min global song duration to mpdj."""
        global_properties = GlobalProperties.get_instance()
        global_properties.mpdj_data.global_max_song_duration = int(
            self.tf_max_global_song_duration.text())

    def write_min_per_note_to_mpdj(self):
        """Write the selected min count per node touch to the mpdj which
            is currently worked on."""
        global_properties = GlobalProperties.get_instance()
        global_properties.mpdj_data.min_units_per_node_touch = int(
            self.tf_min_per_selection.text())

    def write_max_per_note_to_mpdj(self):
        """Writes the selected max count per node touch to the mpdj which is
            currently worked on."""
        global_properties = GlobalProperties.get_instance()
        global_properties.mpdj_data.max_units_per_node_touch = int(
            self.tf_max_per_selection.text())

    def write_unit_per_node_touch_to_mpdj(self):
        """Writes the selected unit for min and max per touch to the mpdj.
            This does not do anything at the moment. Has to be
            implemented properly"""
        global_properties = GlobalProperties.get_instance()
        selection_text = self.combo_box_minutes_or_titles.currentText()
        global_properties.mpdj_data.unit_per_node_touch = UnitPerNodeTouch[
            selection_text.upper()]

    def write_limit_artists_played_to_mpdj(self):  #
        """Write to the current mpdj if the artist are limited per
            node touch."""
        global_properties = GlobalProperties.get_instance()
        state = self.limit_artist_play_chk_box.isChecked()
        global_properties.mpdj_data.limit_artists_in_node_touch = state

    def write_limit_overspill_to_mpdj(self):
        global_properties = GlobalProperties.get_instance()
        state = self.cb_global_limit_overflow.isChecked()
        global_properties.mpdj_data.limit_overspill_global = state

    def write_global_node_max_overflow_to_mpdj(self):
        global_properties = GlobalProperties.get_instance()
        global_node_max_overflow_text = self.tf_global_node_max_overflow_minutes.text(
        )
        if global_node_max_overflow_text:
            new_max_overflow = int(global_node_max_overflow_text)
            global_properties.mpdj_data.global_node_max_overspill = new_max_overflow

    def write_graph_is_directed_to_mpdj(self):
        """Write if the graph is directed to mpd, this should be
            changed somehow, since this does only concern the editing
            of the connections."""
        global_properties = GlobalProperties.get_instance()
        state = self.chk_box_graph_is_directed.isChecked()
        global_properties.mpdj_data.graph_is_directed = state

    def file_dialog(self, load_save_type=QFileDialog.AcceptSave):
        """Opens an file save dialog and returns the selected
            filename."""
        file_save_dialog = QFileDialog(self)
        file_save_dialog.setFileMode(QFileDialog.AnyFile)
        file_save_dialog.setAcceptMode(load_save_type)
        file_save_dialog.setNameFilters(
            ["MPDJ files (*.{})".format(FILE_SUFFIX)])
        file_save_dialog.selectNameFilter(
            "MPDJ files (*.{})".format(FILE_SUFFIX))
        file_save_dialog.setDefaultSuffix((FILE_SUFFIX))
        exec_value = file_save_dialog.exec()
        if exec_value == 0:
            return None
        file_names = file_save_dialog.selectedFiles()
        if len(file_names) != 1:
            message_box = QMessageBox()
            message_box.setText('Please select only one file!')
            message_box.setWindowTitle('Save error.')
            message_box.setStandardButtons(QMessageBox.Ok)
            message_box.setIcon(QMessageBox.Information)
            message_box.exec_()
            return None
        return file_names[0]

    def file_save_as(self):
        """Saves the file. opens a file_dialog which asks for the
            filename."""
        file_name = self.file_dialog(load_save_type=QFileDialog.AcceptSave)
        if file_name:
            self.save_mpdj_data_to_file(file_name)

    def save_mpdj_data_to_file(self, p_file_name: str):
        """Saves the current mpdj data to the file by the path given
            in p_file_name."""
        try:
            global_properties = GlobalProperties.get_instance()
            global_properties.save_mpdj_data_to_file(p_file_name)
            self.statusBar().showMessage('Saved to {}'.format(p_file_name),
                                         5000)
        except (OSError, IOError) as exception:
            message_box = QMessageBox()
            message_box.setText('Error saving the file: {}'.format(
                str(exception)))
            message_box.setWindowTitle('Error saving the file.')
            message_box.setStandardButtons(QMessageBox.Ok)
            message_box.setIcon(QMessageBox.Warning)
            message_box.exec_()

    def file_save(self):
        """Saves the current mpdj data to the current file."""
        global_properties = GlobalProperties.get_instance()
        if len(global_properties.path_of_current_file) > 0:
            self.save_mpdj_data_to_file(global_properties.path_of_current_file)
        else:
            self.file_save_as()

    def file_load(self):
        """Loads mpdj data from a file. Opens a file dialog which
            asks for the file to load."""
        global_properties = GlobalProperties.get_instance()
        file_name = self.file_dialog(load_save_type=QFileDialog.AcceptOpen)
        if file_name:
            if global_properties.changes_happened_since_last_save:
                retval = show_discard_data_ok_cancel_message()
            if not global_properties.changes_happened_since_last_save or retval == QMessageBox.Ok:
                try:
                    global_properties.load_mpdjdata_from_file(file_name)
                except AttributeError as err:
                    message_box = QMessageBox()
                    message_box.setText(
                        'Error reading your MPDJ-File: {}'.format(err))
                    message_box.setWindowTitle('Load error.')
                    message_box.setStandardButtons(QMessageBox.Ok)
                    message_box.setIcon(QMessageBox.Warning)
                    message_box.exec_()

    def __init__(self):
        """Constructor"""
        QMainWindow.__init__(self)
        global_properties = GlobalProperties.get_instance()
        self.connection_table = ConnectionTableWidget()
        global_properties.add_listener(self.connection_table)
        self.setCentralWidget(self.connection_table)
        self.connection_table.update()

        self.menu_bar = self.menuBar()
        self.menu_file = self.menu_bar.addMenu('File')
        self.menu_file.addAction('New', file_new_clicked)
        self.menu_file.addAction('Open', self.file_load)
        self.menu_file.addSeparator()
        self.menu_file.addAction('Save', self.file_save)
        self.menu_file.addAction('Save as', self.file_save_as)
        self.menu_file.addSeparator()
        self.menu_file.addAction('Exit', sys.exit)

        self.menu_file = self.menu_bar.addMenu('Connections')
        self.make_birectional_menu = self.menu_file.addMenu(
            'Make bidirectional')
        self.make_birectional_menu.addAction("with and",
                                             make_bidirectional_and)
        self.make_birectional_menu.addAction("with or", make_bidirectional_or)

        self.menu_selection = self.menu_bar.addMenu('Selections')
        self.action_add_selection = self.menu_selection.addAction(
            'Add Selection')
        self.action_add_selection.triggered.connect(
            create_add_selection_window)
        self.action_merge_selections = self.menu_selection.addAction(
            'Merge Selections')
        self.action_merge_selections.triggered.connect(
            create_merge_selectoon_window)
        self.setMenuBar(self.menu_bar)
        self.statusBar().showMessage('Welcome to mpdj!', 5000)

        self.mpdj_options_dock = QDockWidget("MPDJ Options Panel", self)
        self.mpdj_options_dock_layout = QFormLayout()
        self.mpdj_docked_widget = QWidget()

        self.tf_min_global_song_duration = QLineEdit()
        self.tf_min_global_song_duration.setValidator(
            QIntValidator(0, 2147483647))
        self.mpdj_options_dock_layout.addRow('Global min song duration:',
                                             self.tf_min_global_song_duration)
        self.tf_min_global_song_duration.editingFinished.connect(
            self.write_min_global_song_duration_to_mpdj)

        self.tf_max_global_song_duration = QLineEdit()
        self.tf_max_global_song_duration.setValidator(
            QIntValidator(0, 2147483647))
        self.mpdj_options_dock_layout.addRow('Global max song duration:',
                                             self.tf_max_global_song_duration)
        self.tf_max_global_song_duration.editingFinished.connect(
            self.write_max_global_song_duration_to_mpdj)

        self.tf_min_per_selection = QLineEdit()
        self.tf_min_per_selection.setValidator(QIntValidator(0, 2147483647))
        self.mpdj_options_dock_layout.addRow('Min per Node touch:',
                                             self.tf_min_per_selection)
        self.tf_min_per_selection.editingFinished.connect(
            self.write_min_per_note_to_mpdj)

        self.tf_max_per_selection = QLineEdit()
        self.tf_max_per_selection.setValidator(QIntValidator(0, 2147483647))
        self.mpdj_options_dock_layout.addRow('Max per Node touch:',
                                             self.tf_max_per_selection)
        self.tf_max_per_selection.editingFinished.connect(
            self.write_max_per_note_to_mpdj)

        self.combo_box_minutes_or_titles = QComboBox()
        self.combo_box_minutes_or_titles.addItems(
            [unit.gui_representation() for unit in UnitPerNodeTouch])
        self.mpdj_options_dock_layout.addRow('Unit:',
                                             self.combo_box_minutes_or_titles)
        self.combo_box_minutes_or_titles.currentTextChanged.connect(
            self.write_unit_per_node_touch_to_mpdj)

        self.tf_global_node_max_overflow_minutes = QLineEdit()
        self.tf_global_node_max_overflow_minutes.setValidator(
            QIntValidator(0, 2147483647))
        self.tf_global_node_max_overflow_minutes.editingFinished.connect(
            self.write_global_node_max_overflow_to_mpdj)
        self.cb_global_limit_overflow = QCheckBox()
        self.cb_global_limit_overflow.stateChanged.connect(lambda: list(
            map(lambda m: m(), [
                lambda: self.tf_global_node_max_overflow_minutes.setDisabled(
                    not self.cb_global_limit_overflow.isChecked()), self.
                write_limit_overspill_to_mpdj
            ])))
        self.overflow_layoout = QHBoxLayout()

        self.overflow_layoout.addWidget(self.cb_global_limit_overflow)
        self.overflow_layoout.addWidget(
            self.tf_global_node_max_overflow_minutes)
        self.mpdj_options_dock_layout.addRow("Limit overflow:",
                                             self.overflow_layoout)

        self.mpdj_docked_widget.setLayout(self.mpdj_options_dock_layout)
        self.mpdj_options_dock.setWidget(self.mpdj_docked_widget)
        self.addDockWidget(Qt.LeftDockWidgetArea, self.mpdj_options_dock)

        self.chk_box_graph_is_directed = QCheckBox()
        self.chk_box_graph_is_directed.stateChanged.connect(
            self.write_graph_is_directed_to_mpdj)
        self.mpdj_options_dock_layout.addRow(QLabel('Graph is directed'),
                                             self.chk_box_graph_is_directed)
        self.opened_selection_window = None
        global_properties.add_listener(self)
        self.update()
예제 #17
0
class MergeNodeWindow(QWidget):
    '''
    Class to display the merge nodes window.
    '''
    def ok_button_clicked(self):
        """Is executed when the OK button is clicked. Merges the two nodes."""
        node_name1 = self.combo_node1.currentText()
        node_name2 = self.combo_node2.currentText()
        if node_name1 == node_name2:
            msg = QMessageBox()
            msg.setIcon(QMessageBox.Information)
            msg.setText("Please select two different nodes")
            msg.setInformativeText(
                "It makes to sense to merge a node with itself")
            msg.setWindowTitle("Cannot merge")
            msg.exec_()
            return
        new_name = self.tf_new_name.text()
        if new_name == '':
            msg = QMessageBox()
            msg.setIcon(QMessageBox.Information)
            msg.setText("Please provide the name for the resulting node.")
            msg.setInformativeText("The resulting node should have a name.")
            msg.setWindowTitle("No new name given")
            msg.exec_()
            return
        connection_mode = ConnectionMergeMode[
            self.combo_connection_transfer_mode.currentText().upper()]
        global_properties = GlobalProperties.get_instance()
        global_properties.mpdj_data.merge_two_nodes_into_one(
            node_name1, node_name2, new_name, connection_mode)
        self.close()

    def __init__(self):
        '''
        Constructor
        '''
        QWidget.__init__(self)
        self.layout = QFormLayout()
        self.combo_node1 = QComboBox()
        self.layout.addRow('Node 1:', self.combo_node1)
        self.combo_node2 = QComboBox()
        self.layout.addRow('Node 2:', self.combo_node2)
        node_names = GlobalProperties.get_instance(
        ).mpdj_data.get_song_selection_names()
        self.combo_node1.addItems(node_names)
        self.combo_node2.addItems(node_names)

        self.combo_connection_transfer_mode = QComboBox()
        self.combo_connection_transfer_mode.addItems(
            [mode.gui_representation() for mode in ConnectionMergeMode])
        self.layout.addRow('Connection transfer mode',
                           self.combo_connection_transfer_mode)

        self.tf_new_name = QLineEdit()
        self.layout.addRow('New name:', self.tf_new_name)

        self.button_ok = QPushButton('OK')
        self.button_ok.clicked.connect(self.ok_button_clicked)
        self.layout.addRow(self.button_ok)

        self.setWindowTitle('Merge selections')
        self.setLayout(self.layout)

    def closeEvent(self, *args, **kwargs):
        """Will be executed, when window is closed."""
        global_properties = GlobalProperties.get_instance()
        global_properties.opened_windows.remove(self)
예제 #18
0
class ConfigWidget(QWidget):
    def __init__(self):
        QWidget.__init__(self)
        self.l = QVBoxLayout()
        self.l.setContentsMargins(0, 0, 0, 0)
        self.setLayout(self.l)

        self.help_msg = QLabel('''
            <h2 style="text-align: center">Get Started</h2>
            <p>
                To start syncing your library you will need to create an account to retrieve<br>
                your API key.
            </p>
        ''')
        self.l.addWidget(self.help_msg)

        self.form = QFormLayout()
        self.form.setFieldGrowthPolicy(QFormLayout.ExpandingFieldsGrow)
        self.l.addLayout(self.form)

        self.link = QLabel('<a href="{0}">{0}</a>'.format(prefs['api_base'] + '/api-key'))
        self.link.setOpenExternalLinks(True)
        self.form.addRow('Visit:', self.link)

        self.api_key = QLineEdit(self)
        self.api_key.setText(prefs['api_key'])
        self.form.addRow('API Key:', self.api_key)

        self.debug = QCheckBox(self)
        self.debug.setChecked(prefs['debug'])
        self.form.addRow('Debug Logging:', self.debug)

        self.update_metadata_layout = QHBoxLayout()
        self.update_metadata_layout.setContentsMargins(0, 0, 0, 0)

        self.update_metadata = QCheckBox(self)
        self.update_metadata.setChecked(prefs['update_metadata'])
        self.update_metadata_layout.addWidget(self.update_metadata)

        self.update_metadata_hint = QLabel('(sync all metadata changes made)')
        self.update_metadata_layout.addWidget(self.update_metadata_hint)

        self.form.addRow('Update Metadata:', self.update_metadata_layout)

        self.threads = QComboBox(self)
        for n in range(3):
            self.threads.addItem(str(pow(2, n)))
        self.threads.setCurrentText(str(prefs['threads']))
        self.form.addRow('Sync Threads:', self.threads)

        self.bookshelves_custom_column = QComboBox(self)
        self.bookshelves_custom_column.addItem('')
        for key, meta in get_current_db().new_api.field_metadata.custom_iteritems():
            if meta['datatype'] == 'text':
                self.bookshelves_custom_column.addItem(key)
        self.bookshelves_custom_column.setCurrentText(prefs['bookshelves_custom_column'])
        self.form.addRow('Bookshelves Column:', self.bookshelves_custom_column)

    def save_settings(self):
        prefs['api_key'] = unicode(self.api_key.text())
        prefs['debug'] = self.debug.isChecked()
        prefs['update_metadata'] = self.update_metadata.isChecked()
        prefs['threads'] = int(self.threads.currentText())
        prefs['bookshelves_custom_column'] = unicode(self.bookshelves_custom_column.currentText())
예제 #19
0
def ask_about_cc_mismatch(gui, db, newdb, missing_cols,
                          incompatible_cols):  # {{{
    source_metadata = db.field_metadata.custom_field_metadata(
        include_composites=True)
    dest_library_path = newdb.library_path
    ndbname = os.path.basename(dest_library_path)

    d = QDialog(gui)
    d.setWindowTitle(_('Different custom columns'))
    l = QFormLayout()
    tl = QVBoxLayout()
    d.setLayout(tl)
    d.s = QScrollArea(d)
    tl.addWidget(d.s)
    d.w = QWidget(d)
    d.s.setWidget(d.w)
    d.s.setWidgetResizable(True)
    d.w.setLayout(l)
    d.setMinimumWidth(600)
    d.setMinimumHeight(500)
    d.bb = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)

    msg = _(
        'The custom columns in the <i>{0}</i> library are different from the '
        'custom columns in the <i>{1}</i> library. As a result, some metadata might not be copied.'
    ).format(os.path.basename(db.library_path), ndbname)
    d.la = la = QLabel(msg)
    la.setWordWrap(True)
    la.setStyleSheet('QLabel { margin-bottom: 1.5ex }')
    l.addRow(la)
    if incompatible_cols:
        la = d.la2 = QLabel(
            _('The following columns are incompatible - they have the same name'
              ' but different data types. They will be ignored: ') +
            ', '.join(sorted(incompatible_cols, key=sort_key)))
        la.setWordWrap(True)
        la.setStyleSheet('QLabel { margin-bottom: 1.5ex }')
        l.addRow(la)

    missing_widgets = []
    if missing_cols:
        la = d.la3 = QLabel(
            _('The following columns are missing in the <i>{0}</i> library.'
              ' You can choose to add them automatically below.').format(
                  ndbname))
        la.setWordWrap(True)
        l.addRow(la)
        for k in missing_cols:
            widgets = (k, QCheckBox(_('Add to the %s library') % ndbname))
            l.addRow(QLabel(k), widgets[1])
            missing_widgets.append(widgets)
    d.la4 = la = QLabel(
        _('This warning is only shown once per library, per session'))
    la.setWordWrap(True)
    tl.addWidget(la)

    tl.addWidget(d.bb)
    d.bb.accepted.connect(d.accept)
    d.bb.rejected.connect(d.reject)
    d.resize(d.sizeHint())
    if d.exec_() == d.Accepted:
        changes_made = False
        for k, cb in missing_widgets:
            if cb.isChecked():
                col_meta = source_metadata[k]
                newdb.create_custom_column(col_meta['label'], col_meta['name'],
                                           col_meta['datatype'],
                                           len(col_meta['is_multiple']) > 0,
                                           col_meta['is_editable'],
                                           col_meta['display'])
                changes_made = True
        if changes_made:
            # Unload the db so that the changes are available
            # when it is next accessed
            from calibre.gui2.ui import get_gui
            library_broker = get_gui().library_broker
            library_broker.unload_library(dest_library_path)
        return True
    return False
예제 #20
0
def ask_about_cc_mismatch(gui, db, newdb, missing_cols, incompatible_cols):  # {{{
    source_metadata = db.field_metadata.custom_field_metadata(include_composites=True)
    ndbname = os.path.basename(newdb.library_path)

    d = QDialog(gui)
    d.setWindowTitle(_('Different custom columns'))
    l = QFormLayout()
    tl = QVBoxLayout()
    d.setLayout(tl)
    d.s = QScrollArea(d)
    tl.addWidget(d.s)
    d.w = QWidget(d)
    d.s.setWidget(d.w)
    d.s.setWidgetResizable(True)
    d.w.setLayout(l)
    d.setMinimumWidth(600)
    d.setMinimumHeight(500)
    d.bb = QDialogButtonBox(QDialogButtonBox.Ok|QDialogButtonBox.Cancel)

    msg = _('The custom columns in the <i>{0}</i> library are different from the '
        'custom columns in the <i>{1}</i> library. As a result, some metadata might not be copied.').format(
        os.path.basename(db.library_path), ndbname)
    d.la = la = QLabel(msg)
    la.setWordWrap(True)
    la.setStyleSheet('QLabel { margin-bottom: 1.5ex }')
    l.addRow(la)
    if incompatible_cols:
        la = d.la2 = QLabel(_('The following columns are incompatible - they have the same name'
                ' but different data types. They will be ignored: ') +
                    ', '.join(sorted(incompatible_cols, key=sort_key)))
        la.setWordWrap(True)
        la.setStyleSheet('QLabel { margin-bottom: 1.5ex }')
        l.addRow(la)

    missing_widgets = []
    if missing_cols:
        la = d.la3 = QLabel(_('The following columns are missing in the <i>{0}</i> library.'
                                ' You can choose to add them automatically below.').format(
                                    ndbname))
        la.setWordWrap(True)
        l.addRow(la)
        for k in missing_cols:
            widgets = (k, QCheckBox(_('Add to the %s library') % ndbname))
            l.addRow(QLabel(k), widgets[1])
            missing_widgets.append(widgets)
    d.la4 = la = QLabel(_('This warning is only shown once per library, per session'))
    la.setWordWrap(True)
    tl.addWidget(la)

    tl.addWidget(d.bb)
    d.bb.accepted.connect(d.accept)
    d.bb.rejected.connect(d.reject)
    d.resize(d.sizeHint())
    if d.exec_() == d.Accepted:
        for k, cb in missing_widgets:
            if cb.isChecked():
                col_meta = source_metadata[k]
                newdb.create_custom_column(
                            col_meta['label'], col_meta['name'], col_meta['datatype'],
                            len(col_meta['is_multiple']) > 0,
                            col_meta['is_editable'], col_meta['display'])
        return True
    return False
예제 #21
0
    def ask_link(self):
        class Ask(QDialog):
            def accept(self):
                if self.treat_as_image.isChecked():
                    url = self.url.text()
                    if url.lower().split(':', 1)[0] in ('http', 'https'):
                        error_dialog(
                            self,
                            _('Remote images not supported'),
                            _('You must download the image to your computer, URLs pointing'
                              ' to remote images are not supported.'),
                            show=True)
                        return
                QDialog.accept(self)

        d = Ask(self)
        d.setWindowTitle(_('Create link'))
        l = QFormLayout()
        l.setFieldGrowthPolicy(
            QFormLayout.FieldGrowthPolicy.ExpandingFieldsGrow)
        d.setLayout(l)
        d.url = QLineEdit(d)
        d.name = QLineEdit(d)
        d.treat_as_image = QCheckBox(d)
        d.setMinimumWidth(600)
        d.bb = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok
                                | QDialogButtonBox.StandardButton.Cancel)
        d.br = b = QPushButton(_('&Browse'))
        b.setIcon(QIcon(I('document_open.png')))

        def cf():
            filetypes = []
            if d.treat_as_image.isChecked():
                filetypes = [(_('Images'), 'png jpeg jpg gif'.split())]
            files = choose_files(d,
                                 'select link file',
                                 _('Choose file'),
                                 filetypes,
                                 select_only_single_file=True)
            if files:
                path = files[0]
                d.url.setText(path)
                if path and os.path.exists(path):
                    with lopen(path, 'rb') as f:
                        q = what(f)
                    is_image = q in {'jpeg', 'png', 'gif'}
                    d.treat_as_image.setChecked(is_image)

        b.clicked.connect(cf)
        d.la = la = QLabel(
            _('Enter a URL. If you check the "Treat the URL as an image" box '
              'then the URL will be added as an image reference instead of as '
              'a link. You can also choose to create a link to a file on '
              'your computer. '
              'Note that if you create a link to a file on your computer, it '
              'will stop working if the file is moved.'))
        la.setWordWrap(True)
        la.setStyleSheet('QLabel { margin-bottom: 1.5ex }')
        l.setWidget(0, QFormLayout.ItemRole.SpanningRole, la)
        l.addRow(_('Enter &URL:'), d.url)
        l.addRow(_('Treat the URL as an &image'), d.treat_as_image)
        l.addRow(_('Enter &name (optional):'), d.name)
        l.addRow(_('Choose a file on your computer:'), d.br)
        l.addRow(d.bb)
        d.bb.accepted.connect(d.accept)
        d.bb.rejected.connect(d.reject)
        d.resize(d.sizeHint())
        link, name, is_image = None, None, False
        if d.exec_() == QDialog.DialogCode.Accepted:
            link, name = unicode_type(d.url.text()).strip(), unicode_type(
                d.name.text()).strip()
            is_image = d.treat_as_image.isChecked()
        return link, name, is_image
예제 #22
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)
예제 #23
0
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()
예제 #24
0
    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)
예제 #25
0
    class GenerateLabelsDialog(QDialog):
        #Generate labels dialog class
        def __init__(self, p=None):
            QDialog.__init__(self, p)
            self.setWindowTitle("Generate page layout...")
            self.layout = QFormLayout()

            self.numberOfLabelsSpinBox = QSpinBox()
            self.numberOfLabelsSpinBox.setRange(1, 200)
            self.numberOfLabelsSpinBox.setValue(
                generate_settings['defaultNumberOfLabels'])
            self.layout.addRow("Number of labels", self.numberOfLabelsSpinBox)

            self.firstLabelArticleNumberSB = QSpinBox()
            self.firstLabelArticleNumberSB.setRange(0, 9999)
            self.firstLabelArticleNumberSB.setValue(
                generate_settings['firstLabelArticleNumber'])
            self.layout.addRow("First label article number",
                               self.firstLabelArticleNumberSB)

            self.weekNrYearLE = QLineEdit()
            self.weekNrYearLE.setText(generate_settings['weekNrYear'])
            self.layout.addRow("Week nr/ year", self.weekNrYearLE)

            self.lotNameLE = QLineEdit()
            self.lotNameLE.setText(generate_settings['lotName'])
            self.layout.addRow("Lot", self.lotNameLE)

            self.generatePB = QPushButton("Generate")
            self.generatePB.clicked.connect(self.onGenerate)
            self.layout.addRow("", self.generatePB)
            self.cancelPB = QPushButton("Cancel")
            self.cancelPB.clicked.connect(self.close)
            self.layout.addRow("", self.cancelPB)
            self.setLayout(self.layout)

        def onGenerate(self):
            generate_settings[
                'defaultNumberOfLabels'] = self.numberOfLabelsSpinBox.value()
            generate_settings[
                'firstLabelArticleNumber'] = self.firstLabelArticleNumberSB.value(
                )
            generate_settings['weekNrYear'] = self.weekNrYearLE.text()
            generate_settings['lotName'] = self.lotNameLE.text()
            self.accept()
예제 #26
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()
예제 #27
0
    def __init__(self, parent=None):
        super(HistoryWidget, self).__init__(parent)
        self.setObjectName("HistoryWidget")
        self.resize(800, 480)
        self.setWindowTitle("历史数据查看")

        # layout - top
        horiLayoutTop = QHBoxLayout()

        buttonQuit = QPushButton(self)
        buttonQuit.setObjectName("buttonQuit")
        horiLayoutTop.addSpacing(25)
        horiLayoutTop.addWidget(buttonQuit, 0, Qt.AlignLeft)
        horiLayoutTop.addStretch()

        # button-export
        buttonExport = QPushButton(self)
        buttonExport.setObjectName("buttonExport")
        horiLayoutTop.addWidget(buttonExport)
        horiLayoutTop.addStretch()

        # button-open
        buttonOpen = QPushButton(self)
        buttonOpen.setObjectName("buttonOpen")
        horiLayoutTop.addWidget(buttonOpen)
        horiLayoutTop.addStretch()

        formLayoutTime = QFormLayout()
        formLayoutTime.setFormAlignment(Qt.AlignVCenter)
        horiLayoutTop.addLayout(formLayoutTime)
        horiLayoutTop.addStretch()

        self.dateTimeEditStart = QDateTimeEdit(self)
        self.dateTimeEditStart.setObjectName("dateTimeEditStart")
        self.dateTimeEditStart.setDisplayFormat("yyyy-MM-dd HH:mm:ss")
        formLayoutTime.addRow("起始时间:", self.dateTimeEditStart)

        self.dateTimeEditEnd = QDateTimeEdit(self)
        self.dateTimeEditEnd.setObjectName("dateTimeEditEnd")
        self.dateTimeEditEnd.setDisplayFormat("yyyy-MM-dd HH:mm:ss")
        formLayoutTime.addRow("结束时间:", self.dateTimeEditEnd)

        # LBP
        formLayoutLBP = QFormLayout()
        formLayoutLBP.setFormAlignment(Qt.AlignVCenter)
        formLayoutLBP.setLabelAlignment(Qt.AlignRight)
        horiLayoutTop.addLayout(formLayoutLBP)
        horiLayoutTop.addStretch()
        self.checkBoxLBPMajor = QCheckBox("主", self)
        self.checkBoxLBPMajor.setProperty("curveColor", "#101010")
        self.checkBoxLBPMinor = QCheckBox("副", self)
        self.checkBoxLBPMinor.setProperty("curveColor", "#101010")
        formLayoutLBP.addRow("左刹车压力:", self.checkBoxLBPMajor)
        formLayoutLBP.addRow("", self.checkBoxLBPMinor)

        # RBP
        formLayoutRBP = QFormLayout()
        formLayoutRBP.setFormAlignment(Qt.AlignVCenter)
        formLayoutRBP.setLabelAlignment(Qt.AlignRight)
        horiLayoutTop.addLayout(formLayoutRBP)
        horiLayoutTop.addStretch()
        self.checkBoxRBPMajor = QCheckBox("主", self)
        self.checkBoxRBPMajor.setProperty("curveColor", "#101010")
        self.checkBoxRBPMinor = QCheckBox("副", self)
        self.checkBoxRBPMinor.setProperty("curveColor", "#101010")
        formLayoutRBP.addRow("右刹车压力:", self.checkBoxRBPMajor)
        formLayoutRBP.addRow("", self.checkBoxRBPMinor)

        # LRP
        formLayoutLRP = QFormLayout()
        formLayoutLRP.setFormAlignment(Qt.AlignVCenter)
        formLayoutLRP.setLabelAlignment(Qt.AlignRight)
        horiLayoutTop.addLayout(formLayoutLRP)
        horiLayoutTop.addStretch()
        self.checkBoxLRPTheory = QCheckBox("理论", self)
        self.checkBoxLRPTheory.setProperty("curveColor", "#101010")
        self.checkBoxLRPReal = QCheckBox("实际", self)
        self.checkBoxLRPReal.setProperty("curveColor", "#101010")
        formLayoutLRP.addRow("左转速:", self.checkBoxLRPTheory)
        formLayoutLRP.addRow("", self.checkBoxLRPReal)

        # RRP
        formLayoutRRP = QFormLayout()
        formLayoutRRP.setFormAlignment(Qt.AlignVCenter)
        formLayoutRRP.setLabelAlignment(Qt.AlignRight)
        horiLayoutTop.addLayout(formLayoutRRP)
        horiLayoutTop.addStretch()
        self.checkBoxRRPTheory = QCheckBox("理论", self)
        self.checkBoxRRPTheory.setProperty("curveColor", "#101010")
        self.checkBoxRRPReal = QCheckBox("实际", self)
        self.checkBoxRRPReal.setProperty("curveColor", "#101010")
        formLayoutRRP.addRow("右转速:", self.checkBoxRRPTheory)
        formLayoutRRP.addRow("", self.checkBoxRRPReal)

        # button-update
        buttonUpdate = QPushButton(self)
        buttonUpdate.setObjectName("buttonUpdate")
        horiLayoutTop.addWidget(buttonUpdate)
        horiLayoutTop.addStretch()

        # middle-curves
        self.curveHistory = CurveWidget("历史数据回放", True, self)
        self.curveHistory.setMaximumWidth(10e5)
        self.curveHistory.setScaleLabelFormat("yyyy/MM/dd\n  HH:mm:ss")
        self.curveHistory.clear()

        #
        vertLayoutMain = QVBoxLayout(self)
        vertLayoutMain.addLayout(horiLayoutTop)
        vertLayoutMain.addWidget(self.curveHistory)

        buttonQuit.clicked.connect(self.accept)
        buttonOpen.clicked.connect(self.buttonOpenClicked)
        buttonExport.clicked.connect(self.buttonExportClicked)
        self.dateTimeEditStart.dateTimeChanged.connect(self.dateTimeStartChanged)
        self.dateTimeEditEnd.dateTimeChanged.connect(self.dateTimeEndChanged)
        self.checkBoxLBPMajor.toggled.connect(self.checkBoxLBPMajorToggled)
        self.checkBoxLBPMinor.toggled.connect(self.checkBoxLBPMinorToggled)
        self.checkBoxRBPMajor.toggled.connect(self.checkBoxRBPMajorToggled)
        self.checkBoxRBPMinor.toggled.connect(self.checkBoxRBPMinorToggled)
        self.checkBoxLRPTheory.toggled.connect(self.checkBoxLRPTheoryToggled)
        self.checkBoxLRPReal.toggled.connect(self.checkBoxLRPRealToggled)
        self.checkBoxRRPTheory.toggled.connect(self.checkBoxRRPTheoryToggled)
        self.checkBoxRRPReal.toggled.connect(self.checkBoxRRPRealToggled)
        buttonUpdate.clicked.connect(self.buttonUpdateClicked)

        # finalLy initialize
        self.checkBoxLBPMajor.setChecked(self._v_curve_checked[0])
        self.checkBoxLBPMinor.setChecked(self._v_curve_checked[1])
        self.checkBoxRBPMajor.setChecked(self._v_curve_checked[2])
        self.checkBoxRBPMinor.setChecked(self._v_curve_checked[3])
        self.checkBoxLRPTheory.setChecked(self._v_curve_checked[4])
        self.checkBoxLRPReal.setChecked(self._v_curve_checked[5])
        self.checkBoxRRPTheory.setChecked(self._v_curve_checked[6])
        self.checkBoxRRPReal.setChecked(self._v_curve_checked[7])