Add ability to lock toolbar

bzr-revno: 1664
This commit is contained in:
Tim Bentley 2011-06-28 17:12:41 +01:00
commit 70709e9b12
2 changed files with 52 additions and 7 deletions

View File

@ -323,8 +323,9 @@ def shortcut_action(parent, name, shortcuts, function, icon=None, checked=None,
if checked is not None:
action.setCheckable(True)
action.setChecked(checked)
action.setShortcuts(shortcuts)
action.setShortcutContext(context)
if shortcuts:
action.setShortcuts(shortcuts)
action.setShortcutContext(context)
action_list = ActionList.get_instance()
action_list.add_action(action, category)
QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered(bool)'), function)

View File

@ -93,6 +93,8 @@ class Ui_MainWindow(object):
self.previewController.panel.setVisible(previewVisible)
liveVisible = QtCore.QSettings().value(u'user interface/live panel',
QtCore.QVariant(True)).toBool()
panelLocked = QtCore.QSettings().value(u'user interface/lock panel',
QtCore.QVariant(False)).toBool()
self.liveController.panel.setVisible(liveVisible)
# Create menu
self.menuBar = QtGui.QMenuBar(mainWindow)
@ -213,7 +215,11 @@ class Ui_MainWindow(object):
self.viewLivePanel = shortcut_action(mainWindow, u'viewLivePanel',
[QtGui.QKeySequence(u'F12')], self.setLivePanelVisibility,
checked=liveVisible, category=UiStrings().View)
action_list.add_category(UiStrings().ViewMode, CategoryOrder.standardMenu)
self.lockPanel = shortcut_action(mainWindow, u'lockPanel',
None, self.setLockPanel,
checked=panelLocked, category=None)
action_list.add_category(UiStrings().ViewMode,
CategoryOrder.standardMenu)
self.modeDefaultItem = checkable_action(
mainWindow, u'modeDefaultItem', category=UiStrings().ViewMode)
self.modeSetupItem = checkable_action(
@ -233,7 +239,8 @@ class Ui_MainWindow(object):
category=UiStrings().Tools)
self.updateThemeImages = base_action(mainWindow,
u'updateThemeImages', category=UiStrings().Tools)
action_list.add_category(UiStrings().Settings, CategoryOrder.standardMenu)
action_list.add_category(UiStrings().Settings,
CategoryOrder.standardMenu)
self.settingsPluginListItem = shortcut_action(mainWindow,
u'settingsPluginListItem', [QtGui.QKeySequence(u'Alt+F7')],
self.onPluginItemClicked, u':/system/settings_plugin_list.png',
@ -288,7 +295,7 @@ class Ui_MainWindow(object):
add_actions(self.viewMenu, (self.viewModeMenu.menuAction(),
None, self.viewMediaManagerItem, self.viewServiceManagerItem,
self.viewThemeManagerItem, None, self.viewPreviewPanel,
self.viewLivePanel))
self.viewLivePanel, None, self.lockPanel))
# i18n add Language Actions
add_actions(self.settingsLanguageMenu, (self.autoLanguageItem, None))
add_actions(self.settingsLanguageMenu, self.languageGroup.actions())
@ -325,6 +332,7 @@ class Ui_MainWindow(object):
self.importLanguageItem.setVisible(False)
self.exportLanguageItem.setVisible(False)
self.helpDocumentationItem.setVisible(False)
self.setLockPanel(panelLocked)
def retranslateUi(self, mainWindow):
"""
@ -414,6 +422,10 @@ class Ui_MainWindow(object):
translate('OpenLP.MainWindow', '&Live Panel'))
self.viewLivePanel.setToolTip(
translate('OpenLP.MainWindow', 'Toggle Live Panel'))
self.lockPanel.setText(
translate('OpenLP.MainWindow', 'L&ock Panels'))
self.lockPanel.setStatusTip(
translate('OpenLP.MainWindow', 'Prevent the panels being moved.'))
self.viewLivePanel.setStatusTip(translate('OpenLP.MainWindow',
'Toggle the visibility of the live panel.'))
self.settingsPluginListItem.setText(translate('OpenLP.MainWindow',
@ -653,7 +665,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
QtCore.QVariant(False)).toBool():
self.serviceManagerContents.loadLastFile()
view_mode = QtCore.QSettings().value(u'%s/view mode' % \
self.generalSettingsSection, u'default')
self.generalSettingsSection, u'default').toString()
if view_mode == u'default':
self.modeDefaultItem.setChecked(True)
elif view_mode == u'setup':
@ -936,7 +948,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
self.mediaManagerDock.setVisible(not self.mediaManagerDock.isVisible())
def toggleServiceManager(self):
self.serviceManagerDock.setVisible(not self.serviceManagerDock.isVisible())
self.serviceManagerDock.setVisible(
not self.serviceManagerDock.isVisible())
def toggleThemeManager(self):
self.themeManagerDock.setVisible(not self.themeManagerDock.isVisible())
@ -956,6 +969,37 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
QtCore.QVariant(visible))
self.viewPreviewPanel.setChecked(visible)
def setLockPanel(self, lock):
"""
Sets the ability to stop the toolbars being changed.
"""
if lock:
self.themeManagerDock.setFeatures(
QtGui.QDockWidget.NoDockWidgetFeatures)
self.serviceManagerDock.setFeatures(
QtGui.QDockWidget.NoDockWidgetFeatures)
self.mediaManagerDock.setFeatures(
QtGui.QDockWidget.NoDockWidgetFeatures)
self.viewMediaManagerItem.setEnabled(False)
self.viewServiceManagerItem.setEnabled(False)
self.viewThemeManagerItem.setEnabled(False)
self.viewPreviewPanel.setEnabled(False)
self.viewLivePanel.setEnabled(False)
else:
self.themeManagerDock.setFeatures(
QtGui.QDockWidget.AllDockWidgetFeatures)
self.serviceManagerDock.setFeatures(
QtGui.QDockWidget.AllDockWidgetFeatures)
self.mediaManagerDock.setFeatures(
QtGui.QDockWidget.AllDockWidgetFeatures)
self.viewMediaManagerItem.setEnabled(True)
self.viewServiceManagerItem.setEnabled(True)
self.viewThemeManagerItem.setEnabled(True)
self.viewPreviewPanel.setEnabled(True)
self.viewLivePanel.setEnabled(True)
QtCore.QSettings().setValue(u'user interface/lock panel',
QtCore.QVariant(lock))
def setLivePanelVisibility(self, visible):
"""
Sets the visibility of the live panel including saving the setting and