forked from openlp/openlp
More fixes
This commit is contained in:
parent
da08356f1c
commit
ccde045e60
@ -56,20 +56,20 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog):
|
|||||||
self.load()
|
self.load()
|
||||||
self._clear_details()
|
self._clear_details()
|
||||||
# Right, now let's put some signals and slots together!
|
# Right, now let's put some signals and slots together!
|
||||||
self.pluginListWidget.itemSelectionChanged.connect(self.on_plugin_list_widget_selection_changed)
|
self.plugin_list_widget.itemSelectionChanged.connect(self.on_plugin_list_widget_selection_changed)
|
||||||
self.statusComboBox.currentIndexChanged.connect(self.on_status_combo_box_changed)
|
self.status_combo_box.currentIndexChanged.connect(self.on_status_combo_box_changed)
|
||||||
|
|
||||||
def load(self):
|
def load(self):
|
||||||
"""
|
"""
|
||||||
Load the plugin details into the screen
|
Load the plugin details into the screen
|
||||||
"""
|
"""
|
||||||
self.pluginListWidget.clear()
|
self.plugin_list_widget.clear()
|
||||||
self.programatic_change = True
|
self.programatic_change = True
|
||||||
self._clear_details()
|
self._clear_details()
|
||||||
self.programatic_change = True
|
self.programatic_change = True
|
||||||
plugin_list_width = 0
|
plugin_list_width = 0
|
||||||
for plugin in self.plugin_manager.plugins:
|
for plugin in self.plugin_manager.plugins:
|
||||||
item = QtGui.QListWidgetItem(self.pluginListWidget)
|
item = QtGui.QListWidgetItem(self.plugin_list_widget)
|
||||||
# We do this just to make 100% sure the status is an integer as
|
# We do this just to make 100% sure the status is an integer as
|
||||||
# sometimes when it's loaded from the config, it isn't cast to int.
|
# sometimes when it's loaded from the config, it isn't cast to int.
|
||||||
plugin.status = int(plugin.status)
|
plugin.status = int(plugin.status)
|
||||||
@ -85,43 +85,43 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog):
|
|||||||
# If the plugin has an icon, set it!
|
# If the plugin has an icon, set it!
|
||||||
if plugin.icon:
|
if plugin.icon:
|
||||||
item.setIcon(plugin.icon)
|
item.setIcon(plugin.icon)
|
||||||
self.pluginListWidget.addItem(item)
|
self.plugin_list_widget.addItem(item)
|
||||||
plugin_list_width = max(plugin_list_width, self.fontMetrics().width(
|
plugin_list_width = max(plugin_list_width, self.fontMetrics().width(
|
||||||
translate('OpenLP.PluginForm', '%s (Inactive)') % plugin.name_strings['singular']))
|
translate('OpenLP.PluginForm', '%s (Inactive)') % plugin.name_strings['singular']))
|
||||||
self.pluginListWidget.setFixedWidth(plugin_list_width + self.pluginListWidget.iconSize().width() + 48)
|
self.plugin_list_widget.setFixedWidth(plugin_list_width + self.plugin_list_widget.iconSize().width() + 48)
|
||||||
|
|
||||||
def _clear_details(self):
|
def _clear_details(self):
|
||||||
"""
|
"""
|
||||||
Clear the plugin details widgets
|
Clear the plugin details widgets
|
||||||
"""
|
"""
|
||||||
self.statusComboBox.setCurrentIndex(-1)
|
self.status_combo_box.setCurrentIndex(-1)
|
||||||
self.versionNumberLabel.setText('')
|
self.version_number_label.setText('')
|
||||||
self.aboutTextBrowser.setHtml('')
|
self.about_text_browser.setHtml('')
|
||||||
self.statusComboBox.setEnabled(False)
|
self.status_combo_box.setEnabled(False)
|
||||||
|
|
||||||
def _set_details(self):
|
def _set_details(self):
|
||||||
"""
|
"""
|
||||||
Set the details of the currently selected plugin
|
Set the details of the currently selected plugin
|
||||||
"""
|
"""
|
||||||
log.debug('PluginStatus: %s', str(self.active_plugin.status))
|
log.debug('PluginStatus: %s', str(self.active_plugin.status))
|
||||||
self.versionNumberLabel.setText(self.active_plugin.version)
|
self.version_number_label.setText(self.active_plugin.version)
|
||||||
self.aboutTextBrowser.setHtml(self.active_plugin.about())
|
self.about_text_browser.setHtml(self.active_plugin.about())
|
||||||
self.programatic_change = True
|
self.programatic_change = True
|
||||||
status = PluginStatus.Active
|
status = PluginStatus.Active
|
||||||
if self.active_plugin.status == PluginStatus.Active:
|
if self.active_plugin.status == PluginStatus.Active:
|
||||||
status = PluginStatus.Inactive
|
status = PluginStatus.Inactive
|
||||||
self.statusComboBox.setCurrentIndex(status)
|
self.status_combo_box.setCurrentIndex(status)
|
||||||
self.statusComboBox.setEnabled(True)
|
self.status_combo_box.setEnabled(True)
|
||||||
self.programatic_change = False
|
self.programatic_change = False
|
||||||
|
|
||||||
def on_plugin_list_widget_selection_changed(self):
|
def on_plugin_list_widget_selection_changed(self):
|
||||||
"""
|
"""
|
||||||
If the selected plugin changes, update the form
|
If the selected plugin changes, update the form
|
||||||
"""
|
"""
|
||||||
if self.pluginListWidget.currentItem() is None:
|
if self.plugin_list_widget.currentItem() is None:
|
||||||
self._clear_details()
|
self._clear_details()
|
||||||
return
|
return
|
||||||
plugin_name_singular = self.pluginListWidget.currentItem().text().split('(')[0][:-1]
|
plugin_name_singular = self.plugin_list_widget.currentItem().text().split('(')[0][:-1]
|
||||||
self.active_plugin = None
|
self.active_plugin = None
|
||||||
for plugin in self.plugin_manager.plugins:
|
for plugin in self.plugin_manager.plugins:
|
||||||
if plugin.status != PluginStatus.Disabled:
|
if plugin.status != PluginStatus.Disabled:
|
||||||
@ -153,7 +153,7 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog):
|
|||||||
status_text = translate('OpenLP.PluginForm', '%s (Inactive)')
|
status_text = translate('OpenLP.PluginForm', '%s (Inactive)')
|
||||||
elif self.active_plugin.status == PluginStatus.Disabled:
|
elif self.active_plugin.status == PluginStatus.Disabled:
|
||||||
status_text = translate('OpenLP.PluginForm', '%s (Disabled)')
|
status_text = translate('OpenLP.PluginForm', '%s (Disabled)')
|
||||||
self.pluginListWidget.currentItem().setText(
|
self.plugin_list_widget.currentItem().setText(
|
||||||
status_text % self.active_plugin.name_strings['singular'])
|
status_text % self.active_plugin.name_strings['singular'])
|
||||||
|
|
||||||
def _get_plugin_manager(self):
|
def _get_plugin_manager(self):
|
||||||
|
@ -154,19 +154,19 @@ class ServiceManagerDialog(object):
|
|||||||
self.order_toolbar = OpenLPToolbar(self)
|
self.order_toolbar = OpenLPToolbar(self)
|
||||||
action_list = ActionList.get_instance()
|
action_list = ActionList.get_instance()
|
||||||
action_list.add_category(UiStrings().Service, CategoryOrder.standard_toolbar)
|
action_list.add_category(UiStrings().Service, CategoryOrder.standard_toolbar)
|
||||||
self.service_manager_list.move_top = self.order_toolbar.add_toolbar_action('move_top',
|
self.service_manager_list.move_top = self.order_toolbar.add_toolbar_action('moveTop',
|
||||||
text=translate('OpenLP.ServiceManager', 'Move to &top'), icon=':/services/service_top.png',
|
text=translate('OpenLP.ServiceManager', 'Move to &top'), icon=':/services/service_top.png',
|
||||||
tooltip=translate('OpenLP.ServiceManager', 'Move item to the top of the service.'),
|
tooltip=translate('OpenLP.ServiceManager', 'Move item to the top of the service.'),
|
||||||
can_shortcuts=True, category=UiStrings().Service, triggers=self.on_service_top)
|
can_shortcuts=True, category=UiStrings().Service, triggers=self.on_service_top)
|
||||||
self.service_manager_list.move_up = self.order_toolbar.add_toolbar_action('move_up',
|
self.service_manager_list.move_up = self.order_toolbar.add_toolbar_action('moveUp',
|
||||||
text=translate('OpenLP.ServiceManager', 'Move &up'), icon=':/services/service_up.png',
|
text=translate('OpenLP.ServiceManager', 'Move &up'), icon=':/services/service_up.png',
|
||||||
tooltip=translate('OpenLP.ServiceManager', 'Move item up one position in the service.'),
|
tooltip=translate('OpenLP.ServiceManager', 'Move item up one position in the service.'),
|
||||||
can_shortcuts=True, category=UiStrings().Service, triggers=self.on_service_up)
|
can_shortcuts=True, category=UiStrings().Service, triggers=self.on_service_up)
|
||||||
self.service_manager_list.move_down = self.order_toolbar.add_toolbar_action('move_down',
|
self.service_manager_list.move_down = self.order_toolbar.add_toolbar_action('moveDown',
|
||||||
text=translate('OpenLP.ServiceManager', 'Move &down'), icon=':/services/service_down.png',
|
text=translate('OpenLP.ServiceManager', 'Move &down'), icon=':/services/service_down.png',
|
||||||
tooltip=translate('OpenLP.ServiceManager', 'Move item down one position in the service.'),
|
tooltip=translate('OpenLP.ServiceManager', 'Move item down one position in the service.'),
|
||||||
can_shortcuts=True, category=UiStrings().Service, triggers=self.on_service_down)
|
can_shortcuts=True, category=UiStrings().Service, triggers=self.on_service_down)
|
||||||
self.service_manager_list.move_bottom = self.order_toolbar.add_toolbar_action('move_bottom',
|
self.service_manager_list.move_bottom = self.order_toolbar.add_toolbar_action('moveBottom',
|
||||||
text=translate('OpenLP.ServiceManager', 'Move to &bottom'), icon=':/services/service_bottom.png',
|
text=translate('OpenLP.ServiceManager', 'Move to &bottom'), icon=':/services/service_bottom.png',
|
||||||
tooltip=translate('OpenLP.ServiceManager', 'Move item to the end of the service.'),
|
tooltip=translate('OpenLP.ServiceManager', 'Move item to the end of the service.'),
|
||||||
can_shortcuts=True, category=UiStrings().Service, triggers=self.on_service_end)
|
can_shortcuts=True, category=UiStrings().Service, triggers=self.on_service_end)
|
||||||
|
@ -101,7 +101,7 @@ class Ui_ShortcutListDialog(object):
|
|||||||
self.clear_primary_button.setMinimumSize(QtCore.QSize(0, 16))
|
self.clear_primary_button.setMinimumSize(QtCore.QSize(0, 16))
|
||||||
self.clear_primary_button.setIcon(build_icon(':/system/clear_shortcut.png'))
|
self.clear_primary_button.setIcon(build_icon(':/system/clear_shortcut.png'))
|
||||||
self.primary_layout.addWidget(self.clear_primary_button)
|
self.primary_layout.addWidget(self.clear_primary_button)
|
||||||
self.details_layout.add_layout(self.primary_layout, 1, 1, 1, 1)
|
self.details_layout.addLayout(self.primary_layout, 1, 1, 1, 1)
|
||||||
self.alternate_layout = QtGui.QHBoxLayout()
|
self.alternate_layout = QtGui.QHBoxLayout()
|
||||||
self.alternate_layout.setObjectName('alternate_layout')
|
self.alternate_layout.setObjectName('alternate_layout')
|
||||||
self.alternate_push_button = CaptureShortcutButton(shortcutListDialog)
|
self.alternate_push_button = CaptureShortcutButton(shortcutListDialog)
|
||||||
@ -112,14 +112,14 @@ class Ui_ShortcutListDialog(object):
|
|||||||
self.clear_alternate_button.setObjectName('clear_alternate_button')
|
self.clear_alternate_button.setObjectName('clear_alternate_button')
|
||||||
self.clear_alternate_button.setIcon(build_icon(':/system/clear_shortcut.png'))
|
self.clear_alternate_button.setIcon(build_icon(':/system/clear_shortcut.png'))
|
||||||
self.alternate_layout.addWidget(self.clear_alternate_button)
|
self.alternate_layout.addWidget(self.clear_alternate_button)
|
||||||
self.details_layout.add_layout(self.alternate_layout, 1, 2, 1, 1)
|
self.details_layout.addLayout(self.alternate_layout, 1, 2, 1, 1)
|
||||||
self.primary_label = QtGui.QLabel(shortcutListDialog)
|
self.primary_label = QtGui.QLabel(shortcutListDialog)
|
||||||
self.primary_label.setObjectName('primary_label')
|
self.primary_label.setObjectName('primary_label')
|
||||||
self.details_layout.addWidget(self.primary_label, 0, 1, 1, 1)
|
self.details_layout.addWidget(self.primary_label, 0, 1, 1, 1)
|
||||||
self.alternate_label = QtGui.QLabel(shortcutListDialog)
|
self.alternate_label = QtGui.QLabel(shortcutListDialog)
|
||||||
self.alternate_label.setObjectName('alternate_label')
|
self.alternate_label.setObjectName('alternate_label')
|
||||||
self.details_layout.addWidget(self.alternate_label, 0, 2, 1, 1)
|
self.details_layout.addWidget(self.alternate_label, 0, 2, 1, 1)
|
||||||
self.shortcut_list_layout.add_layout(self.details_layout)
|
self.shortcut_list_layout.addLayout(self.details_layout)
|
||||||
self.button_box = create_button_box(shortcutListDialog, 'button_box', ['cancel', 'ok', 'defaults'])
|
self.button_box = create_button_box(shortcutListDialog, 'button_box', ['cancel', 'ok', 'defaults'])
|
||||||
self.button_box.setOrientation(QtCore.Qt.Horizontal)
|
self.button_box.setOrientation(QtCore.Qt.Horizontal)
|
||||||
self.shortcut_list_layout.addWidget(self.button_box)
|
self.shortcut_list_layout.addWidget(self.button_box)
|
||||||
|
@ -57,15 +57,15 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
|
|||||||
self.changed_actions = {}
|
self.changed_actions = {}
|
||||||
self.action_list = ActionList.get_instance()
|
self.action_list = ActionList.get_instance()
|
||||||
self.dialog_was_shown = False
|
self.dialog_was_shown = False
|
||||||
self.primaryPushButton.toggled.connect(self.on_primary_push_button_clicked)
|
self.primary_push_button.toggled.connect(self.on_primary_push_button_clicked)
|
||||||
self.alternatePushButton.toggled.connect(self.on_alternate_push_button_clicked)
|
self.alternate_push_button.toggled.connect(self.on_alternate_push_button_clicked)
|
||||||
self.treeWidget.currentItemChanged.connect(self.on_current_item_changed)
|
self.tree_widget.currentItemChanged.connect(self.on_current_item_changed)
|
||||||
self.treeWidget.itemDoubleClicked.connect(self.on_item_double_clicked)
|
self.tree_widget.itemDoubleClicked.connect(self.on_item_double_clicked)
|
||||||
self.clearPrimaryButton.clicked.connect(self.on_clear_primary_button_clicked)
|
self.clear_primary_button.clicked.connect(self.on_clear_primary_button_clicked)
|
||||||
self.clearAlternateButton.clicked.connect(self.on_clear_alternate_button_clicked)
|
self.clear_alternate_button.clicked.connect(self.on_clear_alternate_button_clicked)
|
||||||
self.button_box.clicked.connect(self.on_restore_defaults_clicked)
|
self.button_box.clicked.connect(self.on_restore_defaults_clicked)
|
||||||
self.defaultRadioButton.clicked.connect(self.on_default_radio_button_clicked)
|
self.default_radio_button.clicked.connect(self.on_default_radio_button_clicked)
|
||||||
self.customRadioButton.clicked.connect(self.on_custom_radio_button_clicked)
|
self.custom_radio_button.clicked.connect(self.on_custom_radio_button_clicked)
|
||||||
|
|
||||||
def keyPressEvent(self, event):
|
def keyPressEvent(self, event):
|
||||||
"""
|
"""
|
||||||
@ -73,7 +73,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
|
|||||||
"""
|
"""
|
||||||
if event.key() == QtCore.Qt.Key_Space:
|
if event.key() == QtCore.Qt.Key_Space:
|
||||||
self.keyReleaseEvent(event)
|
self.keyReleaseEvent(event)
|
||||||
elif self.primaryPushButton.isChecked() or self.alternatePushButton.isChecked():
|
elif self.primary_push_button.isChecked() or self.alternate_push_button.isChecked():
|
||||||
self.keyReleaseEvent(event)
|
self.keyReleaseEvent(event)
|
||||||
elif event.key() == QtCore.Qt.Key_Escape:
|
elif event.key() == QtCore.Qt.Key_Escape:
|
||||||
event.accept()
|
event.accept()
|
||||||
@ -83,7 +83,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
|
|||||||
"""
|
"""
|
||||||
Respond to certain key presses
|
Respond to certain key presses
|
||||||
"""
|
"""
|
||||||
if not self.primaryPushButton.isChecked() and not self.alternatePushButton.isChecked():
|
if not self.primary_push_button.isChecked() and not self.alternate_push_button.isChecked():
|
||||||
return
|
return
|
||||||
# Do not continue, as the event is for the dialog (close it).
|
# Do not continue, as the event is for the dialog (close it).
|
||||||
if self.dialog_was_shown and event.key() in (QtCore.Qt.Key_Escape, QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return):
|
if self.dialog_was_shown and event.key() in (QtCore.Qt.Key_Escape, QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return):
|
||||||
@ -103,10 +103,10 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
|
|||||||
key_string = 'Meta+' + key_string
|
key_string = 'Meta+' + key_string
|
||||||
key_sequence = QtGui.QKeySequence(key_string)
|
key_sequence = QtGui.QKeySequence(key_string)
|
||||||
if self._validiate_shortcut(self._current_item_action(), key_sequence):
|
if self._validiate_shortcut(self._current_item_action(), key_sequence):
|
||||||
if self.primaryPushButton.isChecked():
|
if self.primary_push_button.isChecked():
|
||||||
self._adjust_button(self.primaryPushButton, False, text=key_sequence.toString())
|
self._adjust_button(self.primary_push_button, False, text=key_sequence.toString())
|
||||||
elif self.alternatePushButton.isChecked():
|
elif self.alternate_push_button.isChecked():
|
||||||
self._adjust_button(self.alternatePushButton, False, text=key_sequence.toString())
|
self._adjust_button(self.alternate_push_button, False, text=key_sequence.toString())
|
||||||
|
|
||||||
def exec_(self):
|
def exec_(self):
|
||||||
"""
|
"""
|
||||||
@ -114,15 +114,15 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
|
|||||||
"""
|
"""
|
||||||
self.changed_actions = {}
|
self.changed_actions = {}
|
||||||
self.reload_shortcut_list()
|
self.reload_shortcut_list()
|
||||||
self._adjust_button(self.primaryPushButton, False, False, '')
|
self._adjust_button(self.primary_push_button, False, False, '')
|
||||||
self._adjust_button(self.alternatePushButton, False, False, '')
|
self._adjust_button(self.alternate_push_button, False, False, '')
|
||||||
return QtGui.QDialog.exec_(self)
|
return QtGui.QDialog.exec_(self)
|
||||||
|
|
||||||
def reload_shortcut_list(self):
|
def reload_shortcut_list(self):
|
||||||
"""
|
"""
|
||||||
Reload the ``treeWidget`` list to add new and remove old actions.
|
Reload the ``tree_widget`` list to add new and remove old actions.
|
||||||
"""
|
"""
|
||||||
self.treeWidget.clear()
|
self.tree_widget.clear()
|
||||||
for category in self.action_list.categories:
|
for category in self.action_list.categories:
|
||||||
# Check if the category is for internal use only.
|
# Check if the category is for internal use only.
|
||||||
if category.name is None:
|
if category.name is None:
|
||||||
@ -141,7 +141,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
|
|||||||
action_item.setToolTip(1, tool_tip_text)
|
action_item.setToolTip(1, tool_tip_text)
|
||||||
action_item.setToolTip(2, tool_tip_text)
|
action_item.setToolTip(2, tool_tip_text)
|
||||||
item.addChild(action_item)
|
item.addChild(action_item)
|
||||||
self.treeWidget.addTopLevelItem(item)
|
self.tree_widget.addTopLevelItem(item)
|
||||||
item.setExpanded(True)
|
item.setExpanded(True)
|
||||||
self.refresh_shortcut_list()
|
self.refresh_shortcut_list()
|
||||||
|
|
||||||
@ -150,7 +150,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
|
|||||||
This refreshes the item's shortcuts shown in the list. Note, this neither adds new actions nor removes old
|
This refreshes the item's shortcuts shown in the list. Note, this neither adds new actions nor removes old
|
||||||
actions.
|
actions.
|
||||||
"""
|
"""
|
||||||
iterator = QtGui.QTreeWidgetItemIterator(self.treeWidget)
|
iterator = QtGui.QTreeWidgetItemIterator(self.tree_widget)
|
||||||
while iterator.value():
|
while iterator.value():
|
||||||
item = iterator.value()
|
item = iterator.value()
|
||||||
iterator += 1
|
iterator += 1
|
||||||
@ -173,16 +173,16 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
|
|||||||
"""
|
"""
|
||||||
Save the new primary shortcut.
|
Save the new primary shortcut.
|
||||||
"""
|
"""
|
||||||
self.customRadioButton.setChecked(True)
|
self.custom_radio_button.setChecked(True)
|
||||||
if toggled:
|
if toggled:
|
||||||
self.alternatePushButton.setChecked(False)
|
self.alternate_push_button.setChecked(False)
|
||||||
self.primaryPushButton.setText('')
|
self.primary_push_button.setText('')
|
||||||
return
|
return
|
||||||
action = self._current_item_action()
|
action = self._current_item_action()
|
||||||
if action is None:
|
if action is None:
|
||||||
return
|
return
|
||||||
shortcuts = self._action_shortcuts(action)
|
shortcuts = self._action_shortcuts(action)
|
||||||
new_shortcuts = [QtGui.QKeySequence(self.primaryPushButton.text())]
|
new_shortcuts = [QtGui.QKeySequence(self.primary_push_button.text())]
|
||||||
if len(shortcuts) == 2:
|
if len(shortcuts) == 2:
|
||||||
new_shortcuts.append(shortcuts[1])
|
new_shortcuts.append(shortcuts[1])
|
||||||
self.changed_actions[action] = new_shortcuts
|
self.changed_actions[action] = new_shortcuts
|
||||||
@ -192,10 +192,10 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
|
|||||||
"""
|
"""
|
||||||
Save the new alternate shortcut.
|
Save the new alternate shortcut.
|
||||||
"""
|
"""
|
||||||
self.customRadioButton.setChecked(True)
|
self.custom_radio_button.setChecked(True)
|
||||||
if toggled:
|
if toggled:
|
||||||
self.primaryPushButton.setChecked(False)
|
self.primary_push_button.setChecked(False)
|
||||||
self.alternatePushButton.setText('')
|
self.alternate_push_button.setText('')
|
||||||
return
|
return
|
||||||
action = self._current_item_action()
|
action = self._current_item_action()
|
||||||
if action is None:
|
if action is None:
|
||||||
@ -204,13 +204,13 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
|
|||||||
new_shortcuts = []
|
new_shortcuts = []
|
||||||
if shortcuts:
|
if shortcuts:
|
||||||
new_shortcuts.append(shortcuts[0])
|
new_shortcuts.append(shortcuts[0])
|
||||||
new_shortcuts.append(QtGui.QKeySequence(self.alternatePushButton.text()))
|
new_shortcuts.append(QtGui.QKeySequence(self.alternate_push_button.text()))
|
||||||
self.changed_actions[action] = new_shortcuts
|
self.changed_actions[action] = new_shortcuts
|
||||||
if not self.primaryPushButton.text():
|
if not self.primary_push_button.text():
|
||||||
# When we do not have a primary shortcut, the just entered alternate shortcut will automatically become the
|
# When we do not have a primary shortcut, the just entered alternate shortcut will automatically become the
|
||||||
# primary shortcut. That is why we have to adjust the primary button's text.
|
# primary shortcut. That is why we have to adjust the primary button's text.
|
||||||
self.primaryPushButton.setText(self.alternatePushButton.text())
|
self.primary_push_button.setText(self.alternate_push_button.text())
|
||||||
self.alternatePushButton.setText('')
|
self.alternate_push_button.setText('')
|
||||||
self.refresh_shortcut_list()
|
self.refresh_shortcut_list()
|
||||||
|
|
||||||
def on_item_double_clicked(self, item, column):
|
def on_item_double_clicked(self, item, column):
|
||||||
@ -221,29 +221,29 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
|
|||||||
action = self._current_item_action(item)
|
action = self._current_item_action(item)
|
||||||
if action is None:
|
if action is None:
|
||||||
return
|
return
|
||||||
self.primaryPushButton.setChecked(column in [0, 1])
|
self.primary_push_button.setChecked(column in [0, 1])
|
||||||
self.alternatePushButton.setChecked(column not in [0, 1])
|
self.alternate_push_button.setChecked(column not in [0, 1])
|
||||||
if column in [0, 1]:
|
if column in [0, 1]:
|
||||||
self.primaryPushButton.setText('')
|
self.primary_push_button.setText('')
|
||||||
self.primaryPushButton.setFocus()
|
self.primary_push_button.setFocus()
|
||||||
else:
|
else:
|
||||||
self.alternatePushButton.setText('')
|
self.alternate_push_button.setText('')
|
||||||
self.alternatePushButton.setFocus()
|
self.alternate_push_button.setFocus()
|
||||||
|
|
||||||
def on_current_item_changed(self, item=None, previousItem=None):
|
def on_current_item_changed(self, item=None, previousItem=None):
|
||||||
"""
|
"""
|
||||||
A item has been pressed. We adjust the button's text to the action's shortcut which is encapsulate in the item.
|
A item has been pressed. We adjust the button's text to the action's shortcut which is encapsulate in the item.
|
||||||
"""
|
"""
|
||||||
action = self._current_item_action(item)
|
action = self._current_item_action(item)
|
||||||
self.primaryPushButton.setEnabled(action is not None)
|
self.primary_push_button.setEnabled(action is not None)
|
||||||
self.alternatePushButton.setEnabled(action is not None)
|
self.alternate_push_button.setEnabled(action is not None)
|
||||||
primary_text = ''
|
primary_text = ''
|
||||||
alternate_text = ''
|
alternate_text = ''
|
||||||
primary_label_text = ''
|
primary_label_text = ''
|
||||||
alternate_label_text = ''
|
alternate_label_text = ''
|
||||||
if action is None:
|
if action is None:
|
||||||
self.primaryPushButton.setChecked(False)
|
self.primary_push_button.setChecked(False)
|
||||||
self.alternatePushButton.setChecked(False)
|
self.alternate_push_button.setChecked(False)
|
||||||
else:
|
else:
|
||||||
if action.defaultShortcuts:
|
if action.defaultShortcuts:
|
||||||
primary_label_text = action.defaultShortcuts[0].toString()
|
primary_label_text = action.defaultShortcuts[0].toString()
|
||||||
@ -253,29 +253,29 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
|
|||||||
# We do not want to loose pending changes, that is why we have to keep the text when, this function has not
|
# We do not want to loose pending changes, that is why we have to keep the text when, this function has not
|
||||||
# been triggered by a signal.
|
# been triggered by a signal.
|
||||||
if item is None:
|
if item is None:
|
||||||
primary_text = self.primaryPushButton.text()
|
primary_text = self.primary_push_button.text()
|
||||||
alternate_text = self.alternatePushButton.text()
|
alternate_text = self.alternate_push_button.text()
|
||||||
elif len(shortcuts) == 1:
|
elif len(shortcuts) == 1:
|
||||||
primary_text = shortcuts[0].toString()
|
primary_text = shortcuts[0].toString()
|
||||||
elif len(shortcuts) == 2:
|
elif len(shortcuts) == 2:
|
||||||
primary_text = shortcuts[0].toString()
|
primary_text = shortcuts[0].toString()
|
||||||
alternate_text = shortcuts[1].toString()
|
alternate_text = shortcuts[1].toString()
|
||||||
# When we are capturing a new shortcut, we do not want, the buttons to display the current shortcut.
|
# When we are capturing a new shortcut, we do not want, the buttons to display the current shortcut.
|
||||||
if self.primaryPushButton.isChecked():
|
if self.primary_push_button.isChecked():
|
||||||
primary_text = ''
|
primary_text = ''
|
||||||
if self.alternatePushButton.isChecked():
|
if self.alternate_push_button.isChecked():
|
||||||
alternate_text = ''
|
alternate_text = ''
|
||||||
self.primaryPushButton.setText(primary_text)
|
self.primary_push_button.setText(primary_text)
|
||||||
self.alternatePushButton.setText(alternate_text)
|
self.alternate_push_button.setText(alternate_text)
|
||||||
self.primaryLabel.setText(primary_label_text)
|
self.primary_label.setText(primary_label_text)
|
||||||
self.alternateLabel.setText(alternate_label_text)
|
self.alternate_label.setText(alternate_label_text)
|
||||||
# We do not want to toggle and radio button, as the function has not been triggered by a signal.
|
# We do not want to toggle and radio button, as the function has not been triggered by a signal.
|
||||||
if item is None:
|
if item is None:
|
||||||
return
|
return
|
||||||
if primary_label_text == primary_text and alternate_label_text == alternate_text:
|
if primary_label_text == primary_text and alternate_label_text == alternate_text:
|
||||||
self.defaultRadioButton.toggle()
|
self.default_radio_button.toggle()
|
||||||
else:
|
else:
|
||||||
self.customRadioButton.toggle()
|
self.custom_radio_button.toggle()
|
||||||
|
|
||||||
def on_restore_defaults_clicked(self, button):
|
def on_restore_defaults_clicked(self, button):
|
||||||
"""
|
"""
|
||||||
@ -289,8 +289,8 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
|
|||||||
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes |
|
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes |
|
||||||
QtGui.QMessageBox.No)) == QtGui.QMessageBox.No:
|
QtGui.QMessageBox.No)) == QtGui.QMessageBox.No:
|
||||||
return
|
return
|
||||||
self._adjust_button(self.primaryPushButton, False, text='')
|
self._adjust_button(self.primary_push_button, False, text='')
|
||||||
self._adjust_button(self.alternatePushButton, False, text='')
|
self._adjust_button(self.alternate_push_button, False, text='')
|
||||||
for category in self.action_list.categories:
|
for category in self.action_list.categories:
|
||||||
for action in category.actions:
|
for action in category.actions:
|
||||||
self.changed_actions[action] = action.defaultShortcuts
|
self.changed_actions[action] = action.defaultShortcuts
|
||||||
@ -315,8 +315,8 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
|
|||||||
primary_button_text = temp_shortcuts[0].toString()
|
primary_button_text = temp_shortcuts[0].toString()
|
||||||
if len(temp_shortcuts) == 2:
|
if len(temp_shortcuts) == 2:
|
||||||
alternate_button_text = temp_shortcuts[1].toString()
|
alternate_button_text = temp_shortcuts[1].toString()
|
||||||
self.primaryPushButton.setText(primary_button_text)
|
self.primary_push_button.setText(primary_button_text)
|
||||||
self.alternatePushButton.setText(alternate_button_text)
|
self.alternate_push_button.setText(alternate_button_text)
|
||||||
|
|
||||||
def on_custom_radio_button_clicked(self, toggled):
|
def on_custom_radio_button_clicked(self, toggled):
|
||||||
"""
|
"""
|
||||||
@ -352,7 +352,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
|
|||||||
"""
|
"""
|
||||||
Restore the defaults of this action.
|
Restore the defaults of this action.
|
||||||
"""
|
"""
|
||||||
self.primaryPushButton.setChecked(False)
|
self.primary_push_button.setChecked(False)
|
||||||
action = self._current_item_action()
|
action = self._current_item_action()
|
||||||
if action is None:
|
if action is None:
|
||||||
return
|
return
|
||||||
@ -370,13 +370,13 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
|
|||||||
new_shortcuts.append(shortcuts[1])
|
new_shortcuts.append(shortcuts[1])
|
||||||
self.changed_actions[action] = new_shortcuts
|
self.changed_actions[action] = new_shortcuts
|
||||||
self.refresh_shortcut_list()
|
self.refresh_shortcut_list()
|
||||||
self.on_current_item_changed(self.treeWidget.currentItem())
|
self.on_current_item_changed(self.tree_widget.currentItem())
|
||||||
|
|
||||||
def on_clear_alternate_button_clicked(self, toggled):
|
def on_clear_alternate_button_clicked(self, toggled):
|
||||||
"""
|
"""
|
||||||
Restore the defaults of this action.
|
Restore the defaults of this action.
|
||||||
"""
|
"""
|
||||||
self.alternatePushButton.setChecked(False)
|
self.alternate_push_button.setChecked(False)
|
||||||
action = self._current_item_action()
|
action = self._current_item_action()
|
||||||
if action is None:
|
if action is None:
|
||||||
return
|
return
|
||||||
@ -391,7 +391,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
|
|||||||
return
|
return
|
||||||
self.changed_actions[action] = new_shortcuts
|
self.changed_actions[action] = new_shortcuts
|
||||||
self.refresh_shortcut_list()
|
self.refresh_shortcut_list()
|
||||||
self.on_current_item_changed(self.treeWidget.currentItem())
|
self.on_current_item_changed(self.tree_widget.currentItem())
|
||||||
|
|
||||||
def _validiate_shortcut(self, changing_action, key_sequence):
|
def _validiate_shortcut(self, changing_action, key_sequence):
|
||||||
"""
|
"""
|
||||||
@ -411,9 +411,9 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
|
|||||||
if key_sequence not in shortcuts:
|
if key_sequence not in shortcuts:
|
||||||
continue
|
continue
|
||||||
if action is changing_action:
|
if action is changing_action:
|
||||||
if self.primaryPushButton.isChecked() and shortcuts.index(key_sequence) == 0:
|
if self.primary_push_button.isChecked() and shortcuts.index(key_sequence) == 0:
|
||||||
continue
|
continue
|
||||||
if self.alternatePushButton.isChecked() and shortcuts.index(key_sequence) == 1:
|
if self.alternate_push_button.isChecked() and shortcuts.index(key_sequence) == 1:
|
||||||
continue
|
continue
|
||||||
# Have the same parent, thus they cannot have the same shortcut.
|
# Have the same parent, thus they cannot have the same shortcut.
|
||||||
if action.parent() is changing_action.parent():
|
if action.parent() is changing_action.parent():
|
||||||
@ -444,10 +444,10 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
|
|||||||
def _current_item_action(self, item=None):
|
def _current_item_action(self, item=None):
|
||||||
"""
|
"""
|
||||||
Returns the action of the given ``item``. If no item is given, we return the action of the current item of
|
Returns the action of the given ``item``. If no item is given, we return the action of the current item of
|
||||||
the ``treeWidget``.
|
the ``tree_widget``.
|
||||||
"""
|
"""
|
||||||
if item is None:
|
if item is None:
|
||||||
item = self.treeWidget.currentItem()
|
item = self.tree_widget.currentItem()
|
||||||
if item is None:
|
if item is None:
|
||||||
return
|
return
|
||||||
return item.data(0, QtCore.Qt.UserRole)
|
return item.data(0, QtCore.Qt.UserRole)
|
||||||
|
@ -62,7 +62,7 @@ class Ui_StartTimeDialog(object):
|
|||||||
self.hour_label = QtGui.QLabel(StartTimeDialog)
|
self.hour_label = QtGui.QLabel(StartTimeDialog)
|
||||||
self.hour_label.setObjectName('hour_label')
|
self.hour_label.setObjectName('hour_label')
|
||||||
self.dialog_layout.addWidget(self.hour_label, 1, 0, 1, 1)
|
self.dialog_layout.addWidget(self.hour_label, 1, 0, 1, 1)
|
||||||
self.hour_spin_box = QtGui.R(StartTimeDialog)
|
self.hour_spin_box = QtGui.QSpinBox(StartTimeDialog)
|
||||||
self.hour_spin_box.setObjectName('hour_spin_box')
|
self.hour_spin_box.setObjectName('hour_spin_box')
|
||||||
self.hour_spin_box.setMinimum(0)
|
self.hour_spin_box.setMinimum(0)
|
||||||
self.hour_spin_box.setMaximum(4)
|
self.hour_spin_box.setMaximum(4)
|
||||||
|
Loading…
Reference in New Issue
Block a user