def _create_ui(self):
        """Creates the configuration UI for this widget."""
        self.key_label = QtWidgets.QLabel("Not set")
        if self.condition_data.scan_code is not None:
            self.key_label.setText("<b>{}</b>".format(
                macro.key_from_code(
                    self.condition_data.scan_code,
                    self.condition_data.is_extended
                ).name
            ))
        self.record_button = QtWidgets.QPushButton("Change")
        self.record_button.clicked.connect(self._request_user_input)
        self.delete_button = QtWidgets.QPushButton("Delete")
        self.delete_button.clicked.connect(
            lambda: self.deleted.emit(self.condition_data)
        )

        self.comparison_dropdown = QtWidgets.QComboBox()
        self.comparison_dropdown.addItem("Pressed")
        self.comparison_dropdown.addItem("Released")
        if self.condition_data.comparison:
            self.comparison_dropdown.setCurrentText(
                self.condition_data.comparison.capitalize()
            )
        self.comparison_dropdown.currentTextChanged.connect(
            self._comparison_changed_cb
        )

        self.main_layout.addWidget(QtWidgets.QLabel("Activate if"))
        self.main_layout.addWidget(self.key_label)
        self.main_layout.addWidget(QtWidgets.QLabel("is"))
        self.main_layout.addWidget(self.comparison_dropdown)
        self.main_layout.addStretch()
        self.main_layout.addWidget(self.record_button)
        self.main_layout.addWidget(self.delete_button)
Example #2
0
    def _create_ui(self):
        """Creates the configuration UI for this widget."""
        self.key_label = QtWidgets.QLabel("")
        if self.condition_data.scan_code is not None:
            self.key_label.setText("<b>{}</b>".format(
                macro.key_from_code(self.condition_data.scan_code,
                                    self.condition_data.is_extended).name))
        self.record_button = common.NoKeyboardPushButton(
            QtGui.QIcon("gfx/button_edit.png"), "")
        self.record_button.clicked.connect(self._request_user_input)
        self.delete_button = QtWidgets.QPushButton(
            QtGui.QIcon("gfx/button_delete.png"), "")
        self.delete_button.clicked.connect(
            lambda: self.deleted.emit(self.condition_data))

        self.comparison_dropdown = QtWidgets.QComboBox()
        self.comparison_dropdown.addItem("Pressed")
        self.comparison_dropdown.addItem("Released")
        if self.condition_data.comparison:
            self.comparison_dropdown.setCurrentText(
                self.condition_data.comparison.capitalize())
        self.comparison_dropdown.currentTextChanged.connect(
            self._comparison_changed_cb)

        self.main_layout.addWidget(QtWidgets.QLabel("Activate if"), 0, 0)
        self.main_layout.addWidget(self.key_label, 0, 1)
        self.main_layout.addWidget(QtWidgets.QLabel("is"), 0, 2)
        self.main_layout.addWidget(self.comparison_dropdown,
                                   0,
                                   3,
                                   alignment=QtCore.Qt.AlignLeft)
        self.main_layout.addWidget(self.record_button, 0, 4)
        self.main_layout.addWidget(self.delete_button, 0, 5)
    def _get_bound_to_string(self, input_item):
        """Returns a string representing the input the action is bound to.

        :param input_item the entry for which to generate the string
        :return string indicating what input is bound to the given entry
        """
        if input_item not in self.bound_inputs:
            return "Unbound"

        bound_input = self.bound_inputs[input_item]

        # Special handling of keyboards
        if bound_input.parent.parent.hardware_id == 0:
            key_name = macro.key_from_code(
                bound_input.input_id[0],
                bound_input.input_id[1]
            ).name
            return "{} - {}".format(
                self.device_names[bound_input.parent.parent.hardware_id],
                key_name
            )
        else:
            return "{} - {} {}".format(
                self.device_names[bound_input.parent.parent.hardware_id],
                gremlin.common.input_type_to_name[bound_input.input_type],
                bound_input.input_id
            )
Example #4
0
    def _key_pressed_cb(self, key):
        """Updates the UI and model with the newly pressed key information.

        :param key the key that has been pressed
        """
        self.condition_data.scan_code = key.identifier[0]
        self.condition_data.is_extended = key.identifier[1]
        self.condition_data.comparison = \
            self.comparison_dropdown.currentText().lower()
        self.key_label.setText("<b>{}</b>".format(
            macro.key_from_code(self.condition_data.scan_code,
                                self.condition_data.is_extended).name))