Ejemplo n.º 1
0
    def refresh_shortcuts(self):
        while self.shortcuts_listwidget.count(): 
            self.shortcuts_listwidget.takeItem(0)
        
        for shortcut in self.shortcuts:
            item = QtGui.QListWidgetItem()
            
            item.setText(shortcut["name"])
            item.setIcon(get_qicon(shortcut["icon"]))

            self.shortcuts_listwidget.addItem(item)
Ejemplo n.º 2
0
    def refresh_shortcuts(self):
        layout = self.shortcut_layout

        if not self.settings:
            self.settings_button_clicked()
            return

        options = self.settings["options"]
            
        column_width = options["column_width"]
        column_count = options["column_count"]
        
        row, column = layout.rowCount(), layout.columnCount()
        
        for x in range(row):
            for y in range(column):
                item = layout.itemAtPosition(x, y)
                if item is not None:
                    item.widget().hide()
                    layout.removeItem(item)
          

        shortcuts = self.settings["shortcuts"]

        rows = self._chunks(shortcuts, column_count)
        
        for x, row in enumerate(rows):
            for y, shortcut in enumerate(row):
                button = QtGui.QPushButton()
                button.setMaximumWidth(column_width)
                button.setMinimumWidth(column_width)
                
                if options["show_names"]:                
                    name = shortcut["name"]
                    
                    if options["show_hints"]:
                        try:
                            name += " (&{})".format(
                                 options["row{}_keys".format(x+1)][y]
                                 )
                        except:
                            pass
                    button.setText(name)
                    
                button.setIcon(get_qicon(shortcut["icon"]))
                
                size = options["icon_size"]
                
                button.setIconSize(QtCore.QSize(size, size))
                
                button.clicked.connect(partial(self.run, shortcut["command"]))
                
                layout.addWidget(button, x, y)
Ejemplo n.º 3
0
    def refresh_shortcuts(self):
        layout = self.shortcut_layout

        if not self.settings:
            self.settings_button_clicked()
            return

        options = self.settings["options"]

        column_width = options["column_width"]
        column_count = options["column_count"]

        row, column = layout.rowCount(), layout.columnCount()

        for x in range(row):
            for y in range(column):
                item = layout.itemAtPosition(x, y)
                if item is not None:
                    item.widget().hide()
                    layout.removeItem(item)

        shortcuts = self.settings["shortcuts"]

        rows = self._chunks(shortcuts, column_count)

        for x, row in enumerate(rows):
            for y, shortcut in enumerate(row):
                button = QtGui.QPushButton()
                button.setMaximumWidth(column_width)
                button.setMinimumWidth(column_width)

                if options["show_names"]:
                    name = shortcut["name"]

                    if options["show_hints"]:
                        try:
                            name += " (&{})".format(
                                options["row{}_keys".format(x + 1)][y])
                        except:
                            pass
                    button.setText(name)

                button.setIcon(get_qicon(shortcut["icon"]))

                size = options["icon_size"]

                button.setIconSize(QtCore.QSize(size, size))

                button.clicked.connect(partial(self.run, shortcut["command"]))

                layout.addWidget(button, x, y)
Ejemplo n.º 4
0
    def selected_shortcut_changed(self):
        self.name_edit.setEnabled(True)
        self.command_edit.setEnabled(True)
        self.icon_button.setEnabled(True)
                       

        current = self.shortcuts_listwidget.currentRow()

        self.move_up_button.setEnabled(True)
        self.move_down_button.setEnabled(True)
 
        if current == -1:
            self.name_edit.setText("")
            self.command_edit.setText("")
            self.icon_button.setIcon(QtGui.QIcon(""))
            
            self.name_edit.setDisabled(True)
            self.command_edit.setDisabled(True)
            self.icon_button.setDisabled(True)
            
            return
        
        if current == 0:
            self.move_up_button.setEnabled(False)
        if current == self.shortcuts_listwidget.count()-1:
            self.move_down_button.setEnabled(False)

        shortcut = self.shortcuts[current]
        
        self.name_edit.setText(shortcut["name"])
        self.command_edit.setText(shortcut["command"])
        self.icon_button.setIcon(get_qicon(shortcut["icon"]))

        if self.icon_button.icon().isNull():
            self.icon_button.setText("Select\nIcon")
        else:
            self.icon_button.setText("")
Ejemplo n.º 5
0
    def __init__(self, *args):
        super(QtGui.QDialog, self).__init__(*args)
        
        ui_path = os.path.join(
                               os.path.dirname(__file__), 
                               "settingsdialogui.ui"
                               )
        
        uic.loadUi(ui_path, self)
        
        self.name_edit.setDisabled(True)
        self.command_edit.setDisabled(True)
        self.icon_button.setDisabled(True)

        self.move_up_button.setIcon(get_qicon("go-up"))
        self.move_down_button.setIcon(get_qicon("go-down"))
        self.add_button.setIcon(get_qicon("list-add"))
        self.delete_button.setIcon(get_qicon("list-remove"))

        self.drop_zone = DropZone()
        self.drop_zone.setMinimumHeight(100)
        self.drop_zone.setText("Drag and drop your desktop shortcut here to use it in this application.")
        self.options_layout.addWidget(self.drop_zone)
        
        validator = QtGui.QRegExpValidator(QtCore.QRegExp("[^&]*"))
        self.name_edit.setValidator(validator)
        
        for edit in (self.row1_edit, self.row2_edit, self.row3_edit):
            validator = QtGui.QRegExpValidator(QtCore.QRegExp("[^ ]*"))
            edit.setValidator(validator)
        
        self.settings = Settings.read()

        try:
            self.options = self.settings["options"]
        except KeyError:
            self.options = {}
            self.settings["options"] = self.options
        
        try:
            self.shortcuts = self.settings["shortcuts"]
        except KeyError:
            self.shortcuts = []
            self.settings["shortcuts"] = self.shortcuts
        
        self.icon_size_spinbox.setValue(self.options.get("icon_size", 48))
        self.column_count_spinbox.setValue(self.options.get("column_count", 3))
        self.column_width_spinbox.setValue(self.options.get("column_width", 230))
        self.show_names_checkbox.setChecked(self.options.get("show_names", True))
        self.show_hints_checkbox.setChecked(self.options.get("show_hints", True))
        self.use_lock_checkbox.setChecked(self.options.get("use_lock", False))
        
        self.row1_edit.setText(self.options.get("row1_keys", "QWERTY"))
        self.row2_edit.setText(self.options.get("row2_keys", "ASDFGH"))
        self.row3_edit.setText(self.options.get("row3_keys", "ZXCVBN"))
        
        self.value_edited()
        
        self.refresh_shortcuts()
        
        self.shortcuts_listwidget.currentRowChanged.connect(self.selected_shortcut_changed)
        
        self.add_button.clicked.connect(self.add_button_clicked)
        self.delete_button.clicked.connect(self.delete_button_clicked)
        self.move_up_button.clicked.connect(self.move_up_button_clicked)
        self.move_down_button.clicked.connect(self.move_down_button_clicked)
    
        self.icon_size_spinbox.valueChanged.connect(self.value_edited)
        self.column_count_spinbox.valueChanged.connect(self.value_edited)
        self.column_width_spinbox.valueChanged.connect(self.value_edited)
        self.show_names_checkbox.stateChanged.connect(self.value_edited)
        self.show_hints_checkbox.stateChanged.connect(self.value_edited)
        self.use_lock_checkbox.stateChanged.connect(self.value_edited)
        
        self.row1_edit.textEdited.connect(self.value_edited)
        self.row2_edit.textEdited.connect(self.value_edited)
        self.row3_edit.textEdited.connect(self.value_edited)
        
        self.name_edit.textEdited.connect(self.value_edited)
        self.command_edit.textEdited.connect(self.value_edited)
        
        self.drop_zone.dropped.connect(self.shortcut_dropped)
        
        self.icon_button.clicked.connect(self.icon_button_clicked)