openlp/openlp/core/ui/mainwindow.py

1451 lines
66 KiB
Python
Raw Normal View History

# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
# --------------------------------------------------------------------------- #
2011-12-27 10:33:55 +00:00
# Copyright (c) 2008-2012 Raoul Snyman #
# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan #
2011-05-26 16:25:54 +00:00
# Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, #
2011-05-26 17:11:22 +00:00
# Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias #
2011-06-12 16:02:52 +00:00
# Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
2011-06-12 15:41:01 +00:00
# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode Woldsund #
# --------------------------------------------------------------------------- #
# This program is free software; you can redistribute it and/or modify it #
# under the terms of the GNU General Public License as published by the Free #
# Software Foundation; version 2 of the License. #
# #
# This program is distributed in the hope that it will be useful, but WITHOUT #
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
# more details. #
# #
# You should have received a copy of the GNU General Public License along #
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
import logging
import os
import sys
import shutil
from tempfile import gettempdir
from datetime import datetime
from PyQt4 import QtCore, QtGui
2011-03-28 18:12:46 +00:00
from openlp.core.lib import Renderer, build_icon, OpenLPDockWidget, \
2011-11-26 21:26:50 +00:00
PluginManager, Receiver, translate, ImageManager, PluginStatus
from openlp.core.lib.ui import UiStrings, create_action
2012-05-17 15:13:09 +00:00
from openlp.core.lib import SlideLimits, Settings
2010-04-23 18:30:53 +00:00
from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, \
2010-10-07 21:27:26 +00:00
ThemeManager, SlideController, PluginForm, MediaDockManager, \
ShortcutListForm, FormattingTagForm
2011-08-29 21:51:03 +00:00
from openlp.core.ui.media import MediaController
from openlp.core.utils import AppLocation, add_actions, LanguageManager, \
2011-11-26 21:26:50 +00:00
get_application_version
2011-04-09 16:11:02 +00:00
from openlp.core.utils.actions import ActionList, CategoryOrder
from openlp.core.ui.firsttimeform import FirstTimeForm
from openlp.core.ui import ScreenList
2010-02-27 15:31:23 +00:00
log = logging.getLogger(__name__)
2010-07-07 14:44:22 +00:00
MEDIA_MANAGER_STYLE = """
2010-07-22 19:55:09 +00:00
QToolBox {
padding-bottom: 2px;
}
QToolBox::tab {
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
2010-07-22 20:01:03 +00:00
stop: 0 palette(button), stop: 0.5 palette(button),
stop: 1.0 palette(mid));
border: 1px groove palette(mid);
border-radius: 5px;
}
QToolBox::tab:selected {
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
2010-07-22 20:01:03 +00:00
stop: 0 palette(light), stop: 0.5 palette(midlight),
stop: 1.0 palette(dark));
border: 1px groove palette(dark);
font-weight: bold;
}
"""
2010-02-02 20:05:21 +00:00
2011-06-29 06:12:32 +00:00
PROGRESSBAR_STYLE = """
2011-06-28 16:40:17 +00:00
QProgressBar{
height: 10px;
}
"""
2009-08-09 17:58:37 +00:00
class Ui_MainWindow(object):
2011-01-21 19:09:56 +00:00
def setupUi(self, mainWindow):
"""
Set up the user interface
"""
2011-01-21 19:09:56 +00:00
mainWindow.setObjectName(u'MainWindow')
2011-04-22 06:30:07 +00:00
mainWindow.setWindowIcon(build_icon(u':/icon/openlp-logo-64x64.png'))
2011-01-21 19:09:56 +00:00
mainWindow.setDockNestingEnabled(True)
2010-12-26 14:44:07 +00:00
# Set up the main container, which contains all the other form widgets.
2011-05-25 07:59:51 +00:00
self.mainContent = QtGui.QWidget(mainWindow)
self.mainContent.setObjectName(u'mainContent')
self.mainContentLayout = QtGui.QHBoxLayout(self.mainContent)
2011-02-17 02:33:12 +00:00
self.mainContentLayout.setSpacing(0)
self.mainContentLayout.setMargin(0)
self.mainContentLayout.setObjectName(u'mainContentLayout')
2011-05-25 07:59:51 +00:00
mainWindow.setCentralWidget(self.mainContent)
self.controlSplitter = QtGui.QSplitter(self.mainContent)
2011-02-07 22:07:48 +00:00
self.controlSplitter.setOrientation(QtCore.Qt.Horizontal)
self.controlSplitter.setObjectName(u'controlSplitter')
2011-02-17 02:33:12 +00:00
self.mainContentLayout.addWidget(self.controlSplitter)
# Create slide controllers
2011-05-05 11:51:47 +00:00
self.previewController = SlideController(self)
self.liveController = SlideController(self, True)
2012-05-17 15:13:09 +00:00
previewVisible = Settings().value(
u'user interface/preview panel', True)
2011-02-01 18:05:59 +00:00
self.previewController.panel.setVisible(previewVisible)
2012-05-17 15:13:09 +00:00
liveVisible = Settings().value(u'user interface/live panel',
True)
panelLocked = Settings().value(u'user interface/lock panel',
False)
2011-02-01 18:05:59 +00:00
self.liveController.panel.setVisible(liveVisible)
# Create menu
2011-05-25 07:59:51 +00:00
self.menuBar = QtGui.QMenuBar(mainWindow)
self.menuBar.setObjectName(u'menuBar')
self.fileMenu = QtGui.QMenu(self.menuBar)
self.fileMenu.setObjectName(u'fileMenu')
self.recentFilesMenu = QtGui.QMenu(self.fileMenu)
self.recentFilesMenu.setObjectName(u'recentFilesMenu')
2011-05-25 07:59:51 +00:00
self.fileImportMenu = QtGui.QMenu(self.fileMenu)
self.fileImportMenu.setObjectName(u'fileImportMenu')
self.fileExportMenu = QtGui.QMenu(self.fileMenu)
self.fileExportMenu.setObjectName(u'fileExportMenu')
2010-07-03 20:39:29 +00:00
# View Menu
2011-05-25 07:59:51 +00:00
self.viewMenu = QtGui.QMenu(self.menuBar)
2011-02-07 22:07:48 +00:00
self.viewMenu.setObjectName(u'viewMenu')
2011-05-25 07:59:51 +00:00
self.viewModeMenu = QtGui.QMenu(self.viewMenu)
self.viewModeMenu.setObjectName(u'viewModeMenu')
2010-07-03 20:39:29 +00:00
# Tools Menu
2011-05-25 07:59:51 +00:00
self.toolsMenu = QtGui.QMenu(self.menuBar)
self.toolsMenu.setObjectName(u'toolsMenu')
2010-07-03 20:39:29 +00:00
# Settings Menu
2011-05-25 07:59:51 +00:00
self.settingsMenu = QtGui.QMenu(self.menuBar)
self.settingsMenu.setObjectName(u'settingsMenu')
self.settingsLanguageMenu = QtGui.QMenu(self.settingsMenu)
self.settingsLanguageMenu.setObjectName(u'settingsLanguageMenu')
2010-07-03 20:39:29 +00:00
# Help Menu
2011-05-25 07:59:51 +00:00
self.helpMenu = QtGui.QMenu(self.menuBar)
self.helpMenu.setObjectName(u'helpMenu')
mainWindow.setMenuBar(self.menuBar)
2011-04-28 18:13:19 +00:00
self.statusBar = QtGui.QStatusBar(mainWindow)
self.statusBar.setObjectName(u'statusBar')
mainWindow.setStatusBar(self.statusBar)
self.loadProgressBar = QtGui.QProgressBar(self.statusBar)
self.loadProgressBar.setObjectName(u'loadProgressBar')
self.statusBar.addPermanentWidget(self.loadProgressBar)
2011-04-29 07:40:19 +00:00
self.loadProgressBar.hide()
2011-04-28 18:13:19 +00:00
self.loadProgressBar.setValue(0)
2011-06-29 06:12:32 +00:00
self.loadProgressBar.setStyleSheet(PROGRESSBAR_STYLE)
2011-04-28 18:13:19 +00:00
self.defaultThemeLabel = QtGui.QLabel(self.statusBar)
self.defaultThemeLabel.setObjectName(u'defaultThemeLabel')
self.statusBar.addPermanentWidget(self.defaultThemeLabel)
# Create the MediaManager
2011-02-07 22:07:48 +00:00
self.mediaManagerDock = OpenLPDockWidget(mainWindow,
u'mediaManagerDock', u':/system/system_mediamanager.png')
self.mediaManagerDock.setStyleSheet(MEDIA_MANAGER_STYLE)
# Create the media toolbox
2011-05-25 08:32:37 +00:00
self.mediaToolBox = QtGui.QToolBox(self.mediaManagerDock)
self.mediaToolBox.setObjectName(u'mediaToolBox')
self.mediaManagerDock.setWidget(self.mediaToolBox)
2011-01-21 19:09:56 +00:00
mainWindow.addDockWidget(QtCore.Qt.LeftDockWidgetArea,
2011-02-07 22:07:48 +00:00
self.mediaManagerDock)
# Create the service manager
2011-02-07 22:07:48 +00:00
self.serviceManagerDock = OpenLPDockWidget(mainWindow,
u'serviceManagerDock', u':/system/system_servicemanager.png')
2011-05-25 08:32:37 +00:00
self.serviceManagerContents = ServiceManager(mainWindow,
2011-02-07 22:07:48 +00:00
self.serviceManagerDock)
2011-05-25 08:32:37 +00:00
self.serviceManagerDock.setWidget(self.serviceManagerContents)
2011-01-21 19:09:56 +00:00
mainWindow.addDockWidget(QtCore.Qt.RightDockWidgetArea,
2011-02-07 22:07:48 +00:00
self.serviceManagerDock)
# Create the theme manager
2011-02-07 22:07:48 +00:00
self.themeManagerDock = OpenLPDockWidget(mainWindow,
u'themeManagerDock', u':/system/system_thememanager.png')
2011-02-17 02:33:12 +00:00
self.themeManagerContents = ThemeManager(mainWindow,
2011-02-07 22:07:48 +00:00
self.themeManagerDock)
2011-02-17 02:33:12 +00:00
self.themeManagerContents.setObjectName(u'themeManagerContents')
self.themeManagerDock.setWidget(self.themeManagerContents)
2011-01-21 19:09:56 +00:00
mainWindow.addDockWidget(QtCore.Qt.RightDockWidgetArea,
2011-02-07 22:07:48 +00:00
self.themeManagerDock)
# Create the menu items
2011-04-09 16:11:02 +00:00
action_list = ActionList.get_instance()
action_list.add_category(unicode(UiStrings().File),
CategoryOrder.standardMenu)
self.fileNewItem = create_action(mainWindow, u'fileNewItem',
icon=u':/general/general_new.png',
shortcuts=[QtGui.QKeySequence(u'Ctrl+N')],
category=UiStrings().File,
triggers=self.serviceManagerContents.onNewServiceClicked)
self.fileOpenItem = create_action(mainWindow, u'fileOpenItem',
icon=u':/general/general_open.png',
shortcuts=[QtGui.QKeySequence(u'Ctrl+O')],
category=UiStrings().File,
triggers=self.serviceManagerContents.onLoadServiceClicked)
self.fileSaveItem = create_action(mainWindow, u'fileSaveItem',
icon=u':/general/general_save.png',
shortcuts=[QtGui.QKeySequence(u'Ctrl+S')],
category=UiStrings().File,
triggers=self.serviceManagerContents.saveFile)
self.fileSaveAsItem = create_action(mainWindow, u'fileSaveAsItem',
shortcuts=[QtGui.QKeySequence(u'Ctrl+Shift+S')],
category=UiStrings().File,
triggers=self.serviceManagerContents.saveFileAs)
self.printServiceOrderItem = create_action(mainWindow,
u'printServiceItem', shortcuts=[QtGui.QKeySequence(u'Ctrl+P')],
category=UiStrings().File,
triggers=self.serviceManagerContents.printServiceOrder)
self.fileExitItem = create_action(mainWindow, u'fileExitItem',
icon=u':/system/system_exit.png',
shortcuts=[QtGui.QKeySequence(u'Alt+F4')],
category=UiStrings().File, triggers=mainWindow.close)
action_list.add_category(unicode(UiStrings().Import),
CategoryOrder.standardMenu)
self.importThemeItem = create_action(mainWindow,
u'importThemeItem', category=UiStrings().Import)
self.importLanguageItem = create_action(mainWindow,
u'importLanguageItem')#, category=UiStrings().Import)
action_list.add_category(unicode(UiStrings().Export),
CategoryOrder.standardMenu)
self.exportThemeItem = create_action(mainWindow,
u'exportThemeItem', category=UiStrings().Export)
self.exportLanguageItem = create_action(mainWindow,
u'exportLanguageItem')#, category=UiStrings().Export)
action_list.add_category(unicode(UiStrings().View),
CategoryOrder.standardMenu)
self.viewMediaManagerItem = create_action(mainWindow,
u'viewMediaManagerItem', shortcuts=[QtGui.QKeySequence(u'F8')],
icon=u':/system/system_mediamanager.png',
checked=self.mediaManagerDock.isVisible(),
category=UiStrings().View, triggers=self.toggleMediaManager)
self.viewThemeManagerItem = create_action(mainWindow,
u'viewThemeManagerItem', shortcuts=[QtGui.QKeySequence(u'F10')],
icon=u':/system/system_thememanager.png',
checked=self.themeManagerDock.isVisible(),
category=UiStrings().View, triggers=self.toggleThemeManager)
self.viewServiceManagerItem = create_action(mainWindow,
u'viewServiceManagerItem', shortcuts=[QtGui.QKeySequence(u'F9')],
icon=u':/system/system_servicemanager.png',
checked=self.serviceManagerDock.isVisible(),
category=UiStrings().View, triggers=self.toggleServiceManager)
self.viewPreviewPanel = create_action(mainWindow, u'viewPreviewPanel',
shortcuts=[QtGui.QKeySequence(u'F11')], checked=previewVisible,
category=UiStrings().View, triggers=self.setPreviewPanelVisibility)
self.viewLivePanel = create_action(mainWindow, u'viewLivePanel',
shortcuts=[QtGui.QKeySequence(u'F12')], checked=liveVisible,
category=UiStrings().View, triggers=self.setLivePanelVisibility)
self.lockPanel = create_action(mainWindow, u'lockPanel',
checked=panelLocked, triggers=self.setLockPanel)
action_list.add_category(unicode(UiStrings().ViewMode),
2011-06-12 14:19:32 +00:00
CategoryOrder.standardMenu)
self.modeDefaultItem = create_action(mainWindow, u'modeDefaultItem',
checked=False, category=UiStrings().ViewMode)
self.modeSetupItem = create_action(mainWindow, u'modeSetupItem',
checked=False, category=UiStrings().ViewMode)
self.modeLiveItem = create_action(mainWindow, u'modeLiveItem',
checked=True, category=UiStrings().ViewMode)
2011-05-25 08:32:37 +00:00
self.modeGroup = QtGui.QActionGroup(mainWindow)
self.modeGroup.addAction(self.modeDefaultItem)
self.modeGroup.addAction(self.modeSetupItem)
self.modeGroup.addAction(self.modeLiveItem)
self.modeDefaultItem.setChecked(True)
action_list.add_category(unicode(UiStrings().Tools),
CategoryOrder.standardMenu)
self.toolsAddToolItem = create_action(mainWindow,
u'toolsAddToolItem', icon=u':/tools/tools_add.png',
category=UiStrings().Tools)
self.toolsOpenDataFolder = create_action(mainWindow,
u'toolsOpenDataFolder', icon=u':/general/general_open.png',
category=UiStrings().Tools)
self.toolsFirstTimeWizard = create_action(mainWindow,
u'toolsFirstTimeWizard', icon=u':/general/general_revert.png',
category=UiStrings().Tools)
self.updateThemeImages = create_action(mainWindow,
u'updateThemeImages', category=UiStrings().Tools)
action_list.add_category(unicode(UiStrings().Settings),
2011-06-12 14:19:32 +00:00
CategoryOrder.standardMenu)
self.settingsPluginListItem = create_action(mainWindow,
u'settingsPluginListItem',
icon=u':/system/settings_plugin_list.png',
shortcuts=[QtGui.QKeySequence(u'Alt+F7')],
category=UiStrings().Settings, triggers=self.onPluginItemClicked)
2010-12-26 14:44:07 +00:00
# i18n Language Items
self.autoLanguageItem = create_action(mainWindow, u'autoLanguageItem',
checked=LanguageManager.auto_language)
2011-05-25 08:32:37 +00:00
self.languageGroup = QtGui.QActionGroup(mainWindow)
self.languageGroup.setExclusive(True)
self.languageGroup.setObjectName(u'languageGroup')
add_actions(self.languageGroup, [self.autoLanguageItem])
2010-10-07 21:27:26 +00:00
qmList = LanguageManager.get_qm_list()
savedLanguage = LanguageManager.get_language()
for key in sorted(qmList.keys()):
languageItem = create_action(mainWindow, key,
checked=qmList[key] == savedLanguage)
2011-05-25 08:32:37 +00:00
add_actions(self.languageGroup, [languageItem])
self.settingsShortcutsItem = create_action(mainWindow,
2011-05-25 08:32:37 +00:00
u'settingsShortcutsItem',
icon=u':/system/system_configure_shortcuts.png',
category=UiStrings().Settings)
2011-07-30 07:40:34 +00:00
# Formatting Tags were also known as display tags.
self.formattingTagItem = create_action(mainWindow,
u'displayTagItem', icon=u':/system/tag_editor.png',
category=UiStrings().Settings)
self.settingsConfigureItem = create_action(mainWindow,
u'settingsConfigureItem', icon=u':/system/system_settings.png',
category=UiStrings().Settings)
self.settingsImportItem = create_action(mainWindow,
u'settingsImportItem', category=UiStrings().Settings)
self.settingsExportItem = create_action(mainWindow,
u'settingsExportItem', category=UiStrings().Settings)
action_list.add_category(unicode(UiStrings().Help),
CategoryOrder.standardMenu)
self.aboutItem = create_action(mainWindow, u'aboutItem',
icon=u':/system/system_about.png',
shortcuts=[QtGui.QKeySequence(u'Ctrl+F1')],
category=UiStrings().Help, triggers=self.onAboutItemClicked)
2011-06-29 17:30:53 +00:00
if os.name == u'nt':
self.localHelpFile = os.path.join(
AppLocation.get_directory(AppLocation.AppDir), 'OpenLP.chm')
self.offlineHelpItem = create_action(mainWindow, u'offlineHelpItem',
icon=u':/system/system_help_contents.png',
shortcuts=[QtGui.QKeySequence(u'F1')],
category=UiStrings().Help, triggers=self.onOfflineHelpClicked)
self.onlineHelpItem = create_action(mainWindow, u'onlineHelpItem',
icon=u':/system/system_online_help.png',
shortcuts=[QtGui.QKeySequence(u'Alt+F1')],
category=UiStrings().Help, triggers=self.onOnlineHelpClicked)
self.webSiteItem = create_action(mainWindow,
u'webSiteItem', category=UiStrings().Help)
add_actions(self.fileImportMenu, (self.settingsImportItem, None,
self.importThemeItem, self.importLanguageItem))
add_actions(self.fileExportMenu, (self.settingsExportItem, None,
self.exportThemeItem, self.exportLanguageItem))
add_actions(self.fileMenu, (self.fileNewItem, self.fileOpenItem,
self.fileSaveItem, self.fileSaveAsItem,
self.recentFilesMenu.menuAction(), None,
self.fileImportMenu.menuAction(), self.fileExportMenu.menuAction(),
None, self.printServiceOrderItem, self.fileExitItem))
2011-05-25 08:32:37 +00:00
add_actions(self.viewModeMenu, (self.modeDefaultItem,
self.modeSetupItem, self.modeLiveItem))
2011-05-25 07:59:51 +00:00
add_actions(self.viewMenu, (self.viewModeMenu.menuAction(),
2011-05-25 08:32:37 +00:00
None, self.viewMediaManagerItem, self.viewServiceManagerItem,
self.viewThemeManagerItem, None, self.viewPreviewPanel,
2011-06-12 14:19:32 +00:00
self.viewLivePanel, None, self.lockPanel))
2010-12-26 14:44:07 +00:00
# i18n add Language Actions
2011-05-25 08:32:37 +00:00
add_actions(self.settingsLanguageMenu, (self.autoLanguageItem, None))
add_actions(self.settingsLanguageMenu, self.languageGroup.actions())
# Order things differently in OS X so that Preferences menu item in the
# app menu is correct (this gets picked up automatically by Qt).
if sys.platform == u'darwin':
add_actions(self.settingsMenu, (self.settingsPluginListItem,
self.settingsLanguageMenu.menuAction(), None,
self.settingsConfigureItem, self.settingsShortcutsItem,
self.formattingTagItem))
else:
add_actions(self.settingsMenu, (self.settingsPluginListItem,
self.settingsLanguageMenu.menuAction(), None,
self.formattingTagItem, self.settingsShortcutsItem,
self.settingsConfigureItem))
2011-05-25 08:32:37 +00:00
add_actions(self.toolsMenu, (self.toolsAddToolItem, None))
add_actions(self.toolsMenu, (self.toolsOpenDataFolder, None))
add_actions(self.toolsMenu, (self.toolsFirstTimeWizard, None))
2011-05-25 07:59:51 +00:00
add_actions(self.toolsMenu, [self.updateThemeImages])
2011-06-29 17:30:53 +00:00
if os.name == u'nt':
add_actions(self.helpMenu, (self.offlineHelpItem,
2011-07-10 10:52:30 +00:00
self.onlineHelpItem, None, self.webSiteItem,
self.aboutItem))
else:
add_actions(self.helpMenu, (self.onlineHelpItem, None,
2011-07-10 10:52:30 +00:00
self.webSiteItem, self.aboutItem))
2011-05-25 07:59:51 +00:00
add_actions(self.menuBar, (self.fileMenu.menuAction(),
self.viewMenu.menuAction(), self.toolsMenu.menuAction(),
self.settingsMenu.menuAction(), self.helpMenu.menuAction()))
# Initialise the translation
2011-01-21 19:09:56 +00:00
self.retranslateUi(mainWindow)
2011-05-25 08:32:37 +00:00
self.mediaToolBox.setCurrentIndex(0)
# Connect up some signals and slots
2011-05-25 07:59:51 +00:00
QtCore.QObject.connect(self.fileMenu,
QtCore.SIGNAL(u'aboutToShow()'), self.updateRecentFilesMenu)
2011-03-15 20:53:36 +00:00
# Hide the entry, as it does not have any functionality yet.
2011-05-25 08:32:37 +00:00
self.toolsAddToolItem.setVisible(False)
self.importLanguageItem.setVisible(False)
self.exportLanguageItem.setVisible(False)
2011-06-12 14:19:32 +00:00
self.setLockPanel(panelLocked)
self.settingsImported = False
2011-01-21 19:09:56 +00:00
def retranslateUi(self, mainWindow):
"""
Set up the translation system
"""
mainWindow.mainTitle = UiStrings().OLPV2
2011-01-21 19:09:56 +00:00
mainWindow.setWindowTitle(mainWindow.mainTitle)
2011-05-25 07:59:51 +00:00
self.fileMenu.setTitle(translate('OpenLP.MainWindow', '&File'))
self.fileImportMenu.setTitle(translate('OpenLP.MainWindow', '&Import'))
self.fileExportMenu.setTitle(translate('OpenLP.MainWindow', '&Export'))
self.recentFilesMenu.setTitle(
translate('OpenLP.MainWindow', '&Recent Files'))
2011-02-07 22:07:48 +00:00
self.viewMenu.setTitle(translate('OpenLP.MainWindow', '&View'))
2011-05-25 07:59:51 +00:00
self.viewModeMenu.setTitle(translate('OpenLP.MainWindow', 'M&ode'))
self.toolsMenu.setTitle(translate('OpenLP.MainWindow', '&Tools'))
self.settingsMenu.setTitle(translate('OpenLP.MainWindow', '&Settings'))
self.settingsLanguageMenu.setTitle(translate('OpenLP.MainWindow',
2010-07-03 20:39:29 +00:00
'&Language'))
2011-05-25 07:59:51 +00:00
self.helpMenu.setTitle(translate('OpenLP.MainWindow', '&Help'))
2011-02-07 22:07:48 +00:00
self.mediaManagerDock.setWindowTitle(
2010-07-21 05:20:03 +00:00
translate('OpenLP.MainWindow', 'Media Manager'))
2011-02-07 22:07:48 +00:00
self.serviceManagerDock.setWindowTitle(
2010-07-21 05:20:03 +00:00
translate('OpenLP.MainWindow', 'Service Manager'))
2011-02-07 22:07:48 +00:00
self.themeManagerDock.setWindowTitle(
2010-07-21 05:20:03 +00:00
translate('OpenLP.MainWindow', 'Theme Manager'))
2011-05-25 08:32:37 +00:00
self.fileNewItem.setText(translate('OpenLP.MainWindow', '&New'))
self.fileNewItem.setToolTip(UiStrings().NewService)
self.fileNewItem.setStatusTip(UiStrings().CreateService)
self.fileOpenItem.setText(translate('OpenLP.MainWindow', '&Open'))
self.fileOpenItem.setToolTip(UiStrings().OpenService)
self.fileOpenItem.setStatusTip(
2010-07-21 05:20:03 +00:00
translate('OpenLP.MainWindow', 'Open an existing service.'))
2011-05-25 08:32:37 +00:00
self.fileSaveItem.setText(translate('OpenLP.MainWindow', '&Save'))
self.fileSaveItem.setToolTip(UiStrings().SaveService)
self.fileSaveItem.setStatusTip(
2010-07-21 05:20:03 +00:00
translate('OpenLP.MainWindow', 'Save the current service to disk.'))
2011-05-25 08:32:37 +00:00
self.fileSaveAsItem.setText(
2010-07-21 05:20:03 +00:00
translate('OpenLP.MainWindow', 'Save &As...'))
2011-05-25 08:32:37 +00:00
self.fileSaveAsItem.setToolTip(
2010-07-21 05:20:03 +00:00
translate('OpenLP.MainWindow', 'Save Service As'))
2011-05-25 08:32:37 +00:00
self.fileSaveAsItem.setStatusTip(translate('OpenLP.MainWindow',
2010-07-03 20:39:29 +00:00
'Save the current service under a new name.'))
2011-06-09 22:03:30 +00:00
self.printServiceOrderItem.setText(UiStrings().PrintService)
2011-02-01 18:22:48 +00:00
self.printServiceOrderItem.setStatusTip(translate('OpenLP.MainWindow',
2011-06-09 22:03:30 +00:00
'Print the current service.'))
2011-05-25 08:32:37 +00:00
self.fileExitItem.setText(
2010-07-21 05:20:03 +00:00
translate('OpenLP.MainWindow', 'E&xit'))
2011-05-25 08:32:37 +00:00
self.fileExitItem.setStatusTip(
2010-07-21 05:20:03 +00:00
translate('OpenLP.MainWindow', 'Quit OpenLP'))
2011-05-25 08:32:37 +00:00
self.importThemeItem.setText(
2010-07-21 05:20:03 +00:00
translate('OpenLP.MainWindow', '&Theme'))
2011-05-25 08:32:37 +00:00
self.importLanguageItem.setText(
2010-07-21 05:20:03 +00:00
translate('OpenLP.MainWindow', '&Language'))
2011-05-25 08:32:37 +00:00
self.exportThemeItem.setText(
2010-07-21 05:20:03 +00:00
translate('OpenLP.MainWindow', '&Theme'))
2011-05-25 08:32:37 +00:00
self.exportLanguageItem.setText(
2010-07-21 05:20:03 +00:00
translate('OpenLP.MainWindow', '&Language'))
2011-05-25 08:32:37 +00:00
self.settingsShortcutsItem.setText(
2010-10-07 21:27:26 +00:00
translate('OpenLP.MainWindow', 'Configure &Shortcuts...'))
self.formattingTagItem.setText(
2011-08-20 19:36:51 +00:00
translate('OpenLP.MainWindow', 'Configure &Formatting Tags...'))
2011-05-25 08:32:37 +00:00
self.settingsConfigureItem.setText(
2010-07-21 05:20:03 +00:00
translate('OpenLP.MainWindow', '&Configure OpenLP...'))
self.settingsExportItem.setStatusTip(translate('OpenLP.MainWindow',
2011-08-29 06:30:31 +00:00
'Export OpenLP settings to a specified *.config file'))
self.settingsExportItem.setText(
translate('OpenLP.MainWindow', 'Settings'))
self.settingsImportItem.setStatusTip(translate('OpenLP.MainWindow',
2011-08-29 06:30:31 +00:00
'Import OpenLP settings from a specified *.config file previously '
'exported on this or another machine'))
self.settingsImportItem.setText(
translate('OpenLP.MainWindow', 'Settings'))
2011-05-25 08:32:37 +00:00
self.viewMediaManagerItem.setText(
2010-07-21 05:20:03 +00:00
translate('OpenLP.MainWindow', '&Media Manager'))
2011-05-25 08:32:37 +00:00
self.viewMediaManagerItem.setToolTip(
2010-07-21 05:20:03 +00:00
translate('OpenLP.MainWindow', 'Toggle Media Manager'))
2011-05-25 08:32:37 +00:00
self.viewMediaManagerItem.setStatusTip(translate('OpenLP.MainWindow',
2010-07-03 20:39:29 +00:00
'Toggle the visibility of the media manager.'))
2011-05-25 08:32:37 +00:00
self.viewThemeManagerItem.setText(
2010-07-21 05:20:03 +00:00
translate('OpenLP.MainWindow', '&Theme Manager'))
2011-05-25 08:32:37 +00:00
self.viewThemeManagerItem.setToolTip(
2010-07-21 05:20:03 +00:00
translate('OpenLP.MainWindow', 'Toggle Theme Manager'))
2011-05-25 08:32:37 +00:00
self.viewThemeManagerItem.setStatusTip(translate('OpenLP.MainWindow',
2010-07-03 20:39:29 +00:00
'Toggle the visibility of the theme manager.'))
2011-05-25 08:32:37 +00:00
self.viewServiceManagerItem.setText(
2010-07-21 05:20:03 +00:00
translate('OpenLP.MainWindow', '&Service Manager'))
2011-05-25 08:32:37 +00:00
self.viewServiceManagerItem.setToolTip(
2010-07-21 05:20:03 +00:00
translate('OpenLP.MainWindow', 'Toggle Service Manager'))
2011-05-25 08:32:37 +00:00
self.viewServiceManagerItem.setStatusTip(translate('OpenLP.MainWindow',
2010-07-03 20:39:29 +00:00
'Toggle the visibility of the service manager.'))
2011-05-25 08:32:37 +00:00
self.viewPreviewPanel.setText(
2010-07-21 05:20:03 +00:00
translate('OpenLP.MainWindow', '&Preview Panel'))
2011-05-25 08:32:37 +00:00
self.viewPreviewPanel.setToolTip(
2010-07-21 05:20:03 +00:00
translate('OpenLP.MainWindow', 'Toggle Preview Panel'))
2011-05-25 08:32:37 +00:00
self.viewPreviewPanel.setStatusTip(translate('OpenLP.MainWindow',
2010-07-03 20:39:29 +00:00
'Toggle the visibility of the preview panel.'))
2011-05-25 08:32:37 +00:00
self.viewLivePanel.setText(
2010-07-21 05:20:03 +00:00
translate('OpenLP.MainWindow', '&Live Panel'))
2011-05-25 08:32:37 +00:00
self.viewLivePanel.setToolTip(
2010-07-21 05:20:03 +00:00
translate('OpenLP.MainWindow', 'Toggle Live Panel'))
2011-06-12 14:19:32 +00:00
self.lockPanel.setText(
translate('OpenLP.MainWindow', 'L&ock Panels'))
2011-06-26 06:49:10 +00:00
self.lockPanel.setStatusTip(
2011-06-27 15:56:48 +00:00
translate('OpenLP.MainWindow', 'Prevent the panels being moved.'))
2011-05-25 08:32:37 +00:00
self.viewLivePanel.setStatusTip(translate('OpenLP.MainWindow',
2010-07-06 20:05:48 +00:00
'Toggle the visibility of the live panel.'))
2011-02-07 22:07:48 +00:00
self.settingsPluginListItem.setText(translate('OpenLP.MainWindow',
2010-07-03 20:39:29 +00:00
'&Plugin List'))
2011-02-07 22:07:48 +00:00
self.settingsPluginListItem.setStatusTip(
2010-07-21 05:20:03 +00:00
translate('OpenLP.MainWindow', 'List the Plugins'))
2011-07-10 10:52:30 +00:00
self.aboutItem.setText(translate('OpenLP.MainWindow', '&About'))
self.aboutItem.setStatusTip(
2010-07-21 05:20:03 +00:00
translate('OpenLP.MainWindow', 'More information about OpenLP'))
2011-06-29 17:30:53 +00:00
if os.name == u'nt':
self.offlineHelpItem.setText(
translate('OpenLP.MainWindow', '&User Guide'))
self.onlineHelpItem.setText(
2010-07-21 05:20:03 +00:00
translate('OpenLP.MainWindow', '&Online Help'))
2011-07-10 10:52:30 +00:00
self.webSiteItem.setText(
2010-07-21 05:20:03 +00:00
translate('OpenLP.MainWindow', '&Web Site'))
2011-05-25 08:32:37 +00:00
for item in self.languageGroup.actions():
2010-05-11 19:00:21 +00:00
item.setText(item.objectName())
2010-07-21 05:20:03 +00:00
item.setStatusTip(unicode(translate('OpenLP.MainWindow',
'Set the interface language to %s')) % item.objectName())
2011-05-25 08:32:37 +00:00
self.autoLanguageItem.setText(
translate('OpenLP.MainWindow', '&Autodetect'))
2011-05-25 08:32:37 +00:00
self.autoLanguageItem.setStatusTip(translate('OpenLP.MainWindow',
'Use the system language, if available.'))
2011-05-25 08:32:37 +00:00
self.toolsAddToolItem.setText(
2010-07-21 05:20:03 +00:00
translate('OpenLP.MainWindow', 'Add &Tool...'))
2011-05-25 08:32:37 +00:00
self.toolsAddToolItem.setStatusTip(translate('OpenLP.MainWindow',
2011-01-21 19:09:56 +00:00
'Add an application to the list of tools.'))
2011-05-25 08:32:37 +00:00
self.toolsOpenDataFolder.setText(
2011-02-09 22:53:35 +00:00
translate('OpenLP.MainWindow', 'Open &Data Folder...'))
2011-05-25 08:32:37 +00:00
self.toolsOpenDataFolder.setStatusTip(translate('OpenLP.MainWindow',
2011-02-09 22:53:35 +00:00
'Open the folder where songs, bibles and other data resides.'))
self.toolsFirstTimeWizard.setText(
translate('OpenLP.MainWindow', 'Re-run First Time Wizard'))
self.toolsFirstTimeWizard.setStatusTip(translate('OpenLP.MainWindow',
2011-11-26 21:26:50 +00:00
'Re-run the First Time Wizard, importing songs, Bibles and '
'themes.'))
self.updateThemeImages.setText(
translate('OpenLP.MainWindow', 'Update Theme Images'))
self.updateThemeImages.setStatusTip(
translate('OpenLP.MainWindow', 'Update the preview images for all '
'themes.'))
2011-05-25 08:32:37 +00:00
self.modeDefaultItem.setText(
2010-07-21 05:20:03 +00:00
translate('OpenLP.MainWindow', '&Default'))
2011-05-25 08:32:37 +00:00
self.modeDefaultItem.setStatusTip(translate('OpenLP.MainWindow',
2011-01-21 19:09:56 +00:00
'Set the view mode back to the default.'))
2011-05-25 08:32:37 +00:00
self.modeSetupItem.setText(translate('OpenLP.MainWindow', '&Setup'))
self.modeSetupItem.setStatusTip(
2011-01-21 19:09:56 +00:00
translate('OpenLP.MainWindow', 'Set the view mode to Setup.'))
2011-05-25 08:32:37 +00:00
self.modeLiveItem.setText(translate('OpenLP.MainWindow', '&Live'))
self.modeLiveItem.setStatusTip(
2011-01-21 19:09:56 +00:00
translate('OpenLP.MainWindow', 'Set the view mode to Live.'))
2009-08-09 17:58:37 +00:00
class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
"""
The main window.
"""
log.info(u'MainWindow loaded')
def __init__(self, clipboard, arguments):
2009-08-09 17:58:37 +00:00
"""
This constructor sets up the interface, the various managers, and the
plugins.
"""
QtGui.QMainWindow.__init__(self)
self.clipboard = clipboard
self.arguments = arguments
2010-04-30 01:31:41 +00:00
# Set up settings sections for the main application
# (not for use by plugins)
self.uiSettingsSection = u'user interface'
self.generalSettingsSection = u'general'
self.advancedSettingsSection = u'advanced'
self.shortcutsSettingsSection = u'shortcuts'
self.serviceManagerSettingsSection = u'servicemanager'
self.songsSettingsSection = u'songs'
self.themesSettingsSection = u'themes'
2011-08-24 16:17:24 +00:00
self.displayTagsSection = u'displayTags'
self.headerSection = u'SettingsImport'
2009-09-19 21:45:50 +00:00
self.serviceNotSaved = False
2011-03-25 16:29:39 +00:00
self.aboutForm = AboutForm(self)
self.settingsForm = SettingsForm(self, self)
self.formattingTagForm = FormattingTagForm(self)
2010-10-07 21:27:26 +00:00
self.shortcutForm = ShortcutListForm(self)
2010-06-11 13:26:24 +00:00
self.recentFiles = QtCore.QStringList()
2009-08-09 17:58:37 +00:00
# Set up the path with plugins
plugin_path = AppLocation.get_directory(AppLocation.PluginsDir)
self.pluginManager = PluginManager(plugin_path)
2010-12-11 20:49:50 +00:00
self.pluginHelpers = {}
self.imageManager = ImageManager()
2011-08-30 16:54:45 +00:00
self.mediaController = MediaController(self)
2009-08-09 17:58:37 +00:00
# Set up the interface
self.setupUi(self)
2010-04-28 01:28:37 +00:00
# Load settings after setupUi so default UI sizes are overwritten
2010-04-23 18:30:53 +00:00
self.loadSettings()
# Once settings are loaded update the menu with the recent files.
self.updateRecentFilesMenu()
2009-10-06 21:07:12 +00:00
self.pluginForm = PluginForm(self)
2009-08-09 17:58:37 +00:00
# Set up signals and slots
2011-05-25 08:32:37 +00:00
QtCore.QObject.connect(self.importThemeItem,
QtCore.SIGNAL(u'triggered()'),
2011-02-17 02:33:12 +00:00
self.themeManagerContents.onImportTheme)
2011-05-25 08:32:37 +00:00
QtCore.QObject.connect(self.exportThemeItem,
QtCore.SIGNAL(u'triggered()'),
2011-02-17 02:33:12 +00:00
self.themeManagerContents.onExportTheme)
2011-02-07 22:07:48 +00:00
QtCore.QObject.connect(self.mediaManagerDock,
QtCore.SIGNAL(u'visibilityChanged(bool)'),
2011-05-25 08:32:37 +00:00
self.viewMediaManagerItem.setChecked)
2011-02-07 22:07:48 +00:00
QtCore.QObject.connect(self.serviceManagerDock,
QtCore.SIGNAL(u'visibilityChanged(bool)'),
2011-05-25 08:32:37 +00:00
self.viewServiceManagerItem.setChecked)
2011-02-07 22:07:48 +00:00
QtCore.QObject.connect(self.themeManagerDock,
QtCore.SIGNAL(u'visibilityChanged(bool)'),
2011-05-25 08:32:37 +00:00
self.viewThemeManagerItem.setChecked)
2011-07-10 10:52:30 +00:00
QtCore.QObject.connect(self.webSiteItem,
QtCore.SIGNAL(u'triggered()'), self.onHelpWebSiteClicked)
2011-05-25 08:32:37 +00:00
QtCore.QObject.connect(self.toolsOpenDataFolder,
2011-02-09 22:53:35 +00:00
QtCore.SIGNAL(u'triggered()'), self.onToolsOpenDataFolderClicked)
QtCore.QObject.connect(self.toolsFirstTimeWizard,
QtCore.SIGNAL(u'triggered()'), self.onFirstTimeWizardClicked)
QtCore.QObject.connect(self.updateThemeImages,
QtCore.SIGNAL(u'triggered()'), self.onUpdateThemeImages)
QtCore.QObject.connect(self.formattingTagItem,
QtCore.SIGNAL(u'triggered()'), self.onFormattingTagItemClicked)
2011-05-25 08:32:37 +00:00
QtCore.QObject.connect(self.settingsConfigureItem,
2010-10-07 21:27:26 +00:00
QtCore.SIGNAL(u'triggered()'), self.onSettingsConfigureItemClicked)
2011-05-25 08:32:37 +00:00
QtCore.QObject.connect(self.settingsShortcutsItem,
2010-10-07 21:27:26 +00:00
QtCore.SIGNAL(u'triggered()'), self.onSettingsShortcutsItemClicked)
QtCore.QObject.connect(self.settingsImportItem,
QtCore.SIGNAL(u'triggered()'), self.onSettingsImportItemClicked)
QtCore.QObject.connect(self.settingsExportItem,
QtCore.SIGNAL(u'triggered()'), self.onSettingsExportItemClicked)
2010-10-30 09:29:59 +00:00
# i18n set signals for languages
2011-05-25 08:32:37 +00:00
self.languageGroup.triggered.connect(LanguageManager.set_language)
QtCore.QObject.connect(self.modeDefaultItem,
2010-09-18 18:15:54 +00:00
QtCore.SIGNAL(u'triggered()'), self.onModeDefaultItemClicked)
2011-05-25 08:32:37 +00:00
QtCore.QObject.connect(self.modeSetupItem,
2010-07-30 22:48:09 +00:00
QtCore.SIGNAL(u'triggered()'), self.onModeSetupItemClicked)
2011-05-25 08:32:37 +00:00
QtCore.QObject.connect(self.modeLiveItem,
2010-07-30 22:48:09 +00:00
QtCore.SIGNAL(u'triggered()'), self.onModeLiveItemClicked)
2010-07-06 20:05:48 +00:00
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'theme_update_global'), self.defaultThemeChanged)
QtCore.QObject.connect(Receiver.get_receiver(),
2010-07-30 22:48:09 +00:00
QtCore.SIGNAL(u'openlp_version_check'), self.versionNotice)
2010-07-06 20:05:48 +00:00
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'live_display_blank_check'), self.blankCheck)
2010-07-06 20:05:48 +00:00
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'config_screen_changed'), self.screenChanged)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'mainwindow_status_text'), self.showStatusMessage)
# Media Manager
QtCore.QObject.connect(self.mediaToolBox,
QtCore.SIGNAL(u'currentChanged(int)'), self.onMediaToolBoxChanged)
2011-01-01 11:44:16 +00:00
Receiver.send_message(u'cursor_busy')
2011-01-01 10:33:14 +00:00
# Simple message boxes
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'openlp_error_message'), self.onErrorMessage)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'openlp_warning_message'), self.onWarningMessage)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'openlp_information_message'),
self.onInformationMessage)
2010-10-30 09:29:59 +00:00
# warning cyclic dependency
2011-03-28 18:12:46 +00:00
# renderer needs to call ThemeManager and
2011-03-28 18:56:39 +00:00
# ThemeManager needs to call Renderer
self.renderer = Renderer(self.imageManager, self.themeManagerContents)
2010-10-30 09:29:59 +00:00
# Define the media Dock Manager
2011-05-25 08:32:37 +00:00
self.mediaDockManager = MediaDockManager(self.mediaToolBox)
2009-08-09 17:58:37 +00:00
log.info(u'Load Plugins')
2010-10-30 09:29:59 +00:00
# make the controllers available to the plugins
2010-12-11 20:49:50 +00:00
self.pluginHelpers[u'preview'] = self.previewController
self.pluginHelpers[u'live'] = self.liveController
2011-03-28 18:56:39 +00:00
self.pluginHelpers[u'renderer'] = self.renderer
2011-05-25 08:32:37 +00:00
self.pluginHelpers[u'service'] = self.serviceManagerContents
2010-12-11 20:49:50 +00:00
self.pluginHelpers[u'settings form'] = self.settingsForm
self.pluginHelpers[u'toolbox'] = self.mediaDockManager
self.pluginHelpers[u'pluginmanager'] = self.pluginManager
self.pluginHelpers[u'formparent'] = self
2011-08-30 16:54:45 +00:00
self.pluginHelpers[u'mediacontroller'] = self.mediaController
self.pluginManager.find_plugins(plugin_path, self.pluginHelpers)
2009-09-19 21:45:50 +00:00
# hook methods have to happen after find_plugins. Find plugins needs
# the controllers hence the hooks have moved from setupUI() to here
2009-08-09 17:58:37 +00:00
# Find and insert settings tabs
log.info(u'hook settings')
2010-12-11 20:49:50 +00:00
self.pluginManager.hook_settings_tabs(self.settingsForm)
2009-08-09 17:58:37 +00:00
# Find and insert media manager items
log.info(u'hook media')
self.pluginManager.hook_media_manager()
2009-08-09 17:58:37 +00:00
# Call the hook method to pull in import menus.
log.info(u'hook menus')
2011-05-25 07:59:51 +00:00
self.pluginManager.hook_import_menu(self.fileImportMenu)
2009-08-09 17:58:37 +00:00
# Call the hook method to pull in export menus.
2011-05-25 07:59:51 +00:00
self.pluginManager.hook_export_menu(self.fileExportMenu)
2009-09-17 18:24:13 +00:00
# Call the hook method to pull in tools menus.
2011-05-25 07:59:51 +00:00
self.pluginManager.hook_tools_menu(self.toolsMenu)
2009-08-09 17:58:37 +00:00
# Call the initialise method to setup plugins.
log.info(u'initialise plugins')
2010-12-11 20:49:50 +00:00
self.pluginManager.initialise_plugins()
2011-05-05 18:40:04 +00:00
# Create the displays as all necessary components are loaded.
self.previewController.screenSizeChanged()
self.liveController.screenSizeChanged()
2009-08-29 07:17:56 +00:00
log.info(u'Load data from Settings')
2012-05-17 15:13:09 +00:00
if Settings().value(u'advanced/save current plugin', False):
savedPlugin = Settings().value(
u'advanced/current media plugin', )
if savedPlugin != -1:
2011-05-25 08:32:37 +00:00
self.mediaToolBox.setCurrentIndex(savedPlugin)
2009-08-29 07:17:56 +00:00
self.settingsForm.postSetUp()
# Once all components are initialised load the Themes
log.info(u'Load Themes')
self.themeManagerContents.loadThemes(True)
# Hide/show the theme combobox on the service manager
self.serviceManagerContents.themeChange()
# Reset the cursor
2011-01-01 11:44:16 +00:00
Receiver.send_message(u'cursor_normal')
2009-10-11 05:47:38 +00:00
2010-04-16 22:06:28 +00:00
def setAutoLanguage(self, value):
2011-05-25 08:32:37 +00:00
self.languageGroup.setDisabled(value)
LanguageManager.auto_language = value
2011-05-25 08:32:37 +00:00
LanguageManager.set_language(self.languageGroup.checkedAction())
2010-04-16 22:06:28 +00:00
def onMediaToolBoxChanged(self, index):
widget = self.mediaToolBox.widget(index)
if widget:
widget.onFocus()
2010-07-30 22:48:09 +00:00
def versionNotice(self, version):
"""
2010-07-30 22:48:09 +00:00
Notifies the user that a newer version of OpenLP is available.
Triggered by delay thread.
"""
2010-07-21 05:20:03 +00:00
version_text = unicode(translate('OpenLP.MainWindow',
'Version %s of OpenLP is now available for download (you are '
'currently running version %s). \n\nYou can download the latest '
'version from http://openlp.org/.'))
2010-02-25 21:09:27 +00:00
QtGui.QMessageBox.question(self,
2010-07-21 05:20:03 +00:00
translate('OpenLP.MainWindow', 'OpenLP Version Updated'),
2011-03-25 16:29:39 +00:00
version_text % (version, get_application_version()[u'full']))
2009-08-09 17:58:37 +00:00
def show(self):
"""
Show the main form, as well as the display form
"""
2010-04-23 21:31:54 +00:00
QtGui.QWidget.show(self)
2010-12-11 20:49:50 +00:00
if self.liveController.display.isVisible():
self.liveController.display.setFocus()
self.activateWindow()
if self.arguments:
2011-03-19 10:08:05 +00:00
args = []
for a in self.arguments:
2011-03-19 10:08:05 +00:00
args.extend([a])
2011-12-05 21:40:56 +00:00
filename = args[0]
if not isinstance(filename, unicode):
filename = unicode(filename, sys.getfilesystemencoding())
self.serviceManagerContents.loadFile(filename)
2012-05-17 15:13:09 +00:00
elif Settings().value(
self.generalSettingsSection + u'/auto open',
2012-05-17 15:13:09 +00:00
False):
2011-05-25 08:32:37 +00:00
self.serviceManagerContents.loadLastFile()
2012-05-17 15:13:09 +00:00
view_mode = Settings().value(u'%s/view mode' % \
self.generalSettingsSection, u'default')
2010-09-18 17:14:27 +00:00
if view_mode == u'default':
2011-05-25 08:32:37 +00:00
self.modeDefaultItem.setChecked(True)
2010-09-18 17:14:27 +00:00
elif view_mode == u'setup':
self.setViewMode(True, True, False, True, False)
2011-05-25 08:32:37 +00:00
self.modeSetupItem.setChecked(True)
2010-09-18 17:14:27 +00:00
elif view_mode == u'live':
self.setViewMode(False, True, False, False, True)
2011-05-25 08:32:37 +00:00
self.modeLiveItem.setChecked(True)
2010-04-10 10:28:57 +00:00
def appStartup(self):
"""
Give all the plugins a chance to perform some tasks at startup
"""
Receiver.send_message(u'openlp_process_events')
for plugin in self.pluginManager.plugins:
if plugin.isActive():
plugin.appStartup()
Receiver.send_message(u'openlp_process_events')
def firstTime(self):
# Import themes if first time
Receiver.send_message(u'openlp_process_events')
for plugin in self.pluginManager.plugins:
if hasattr(plugin, u'firstTime'):
Receiver.send_message(u'openlp_process_events')
plugin.firstTime()
Receiver.send_message(u'openlp_process_events')
temp_dir = os.path.join(unicode(gettempdir()), u'openlp')
shutil.rmtree(temp_dir, True)
def onFirstTimeWizardClicked(self):
"""
Re-run the first time wizard. Prompts the user for run confirmation
If wizard is run, songs, bibles and themes are imported. The default
theme is changed (if necessary). The plugins in pluginmanager are
set active/in-active to match the selection in the wizard.
"""
answer = QtGui.QMessageBox.warning(self,
translate('OpenLP.MainWindow', 'Re-run First Time Wizard?'),
translate('OpenLP.MainWindow',
'Are you sure you want to re-run the First Time Wizard?\n\n'
'Re-running this wizard may make changes to your current '
2011-07-27 17:04:31 +00:00
'OpenLP configuration and possibly add songs to your '
'existing songs list and change your default theme.'),
QtGui.QMessageBox.StandardButtons(
QtGui.QMessageBox.Yes |
QtGui.QMessageBox.No),
QtGui.QMessageBox.No)
if answer == QtGui.QMessageBox.No:
return
Receiver.send_message(u'cursor_busy')
screens = ScreenList.get_instance()
FirstTimeForm(screens, self).exec_()
self.firstTime()
for plugin in self.pluginManager.plugins:
self.activePlugin = plugin
oldStatus = self.activePlugin.status
self.activePlugin.setStatus()
if oldStatus != self.activePlugin.status:
if self.activePlugin.status == PluginStatus.Active:
self.activePlugin.toggleStatus(PluginStatus.Active)
self.activePlugin.appStartup()
else:
self.activePlugin.toggleStatus(PluginStatus.Inactive)
self.themeManagerContents.configUpdated()
self.themeManagerContents.loadThemes(True)
Receiver.send_message(u'theme_update_global',
self.themeManagerContents.global_theme)
# Check if any Bibles downloaded. If there are, they will be
# processed.
Receiver.send_message(u'bibles_load_list', True)
def blankCheck(self):
"""
Check and display message if screen blank on setup.
"""
2012-05-17 15:13:09 +00:00
settings = Settings()
2011-06-01 07:38:19 +00:00
self.liveController.mainDisplaySetBackground()
2010-09-18 17:14:27 +00:00
if settings.value(u'%s/screen blank' % self.generalSettingsSection,
2012-05-17 15:13:09 +00:00
False):
2011-06-01 07:38:19 +00:00
if settings.value(u'%s/blank warning' % self.generalSettingsSection,
2012-05-17 15:13:09 +00:00
False):
QtGui.QMessageBox.question(self,
2010-07-21 05:20:03 +00:00
translate('OpenLP.MainWindow',
'OpenLP Main Display Blanked'),
translate('OpenLP.MainWindow',
'The Main Display has been blanked out'))
2009-08-09 17:58:37 +00:00
2011-01-01 10:33:14 +00:00
def onErrorMessage(self, data):
Receiver.send_message(u'close_splash')
2011-01-01 10:33:14 +00:00
QtGui.QMessageBox.critical(self, data[u'title'], data[u'message'])
def onWarningMessage(self, data):
Receiver.send_message(u'close_splash')
2011-01-01 10:33:14 +00:00
QtGui.QMessageBox.warning(self, data[u'title'], data[u'message'])
def onInformationMessage(self, data):
Receiver.send_message(u'close_splash')
2011-01-01 10:33:14 +00:00
QtGui.QMessageBox.information(self, data[u'title'], data[u'message'])
def onHelpWebSiteClicked(self):
"""
Load the OpenLP website
"""
import webbrowser
webbrowser.open_new(u'http://openlp.org/')
def onOfflineHelpClicked(self):
"""
Load the local OpenLP help file
"""
os.startfile(self.localHelpFile)
def onOnlineHelpClicked(self):
2011-03-24 21:20:38 +00:00
"""
Load the online OpenLP manual
"""
import webbrowser
webbrowser.open_new(u'http://manual.openlp.org/')
2011-07-10 10:52:30 +00:00
def onAboutItemClicked(self):
2009-08-09 17:58:37 +00:00
"""
Show the About form
"""
self.aboutForm.exec_()
def onPluginItemClicked(self):
"""
Show the Plugin form
"""
self.pluginForm.load()
self.pluginForm.exec_()
2011-02-09 22:53:35 +00:00
def onToolsOpenDataFolderClicked(self):
"""
Open data folder
"""
path = AppLocation.get_data_path()
QtGui.QDesktopServices.openUrl(QtCore.QUrl("file:///" + path))
def onUpdateThemeImages(self):
"""
Updates the new theme preview images.
"""
self.themeManagerContents.updatePreviewImages()
def onFormattingTagItemClicked(self):
2011-02-20 15:35:52 +00:00
"""
Show the Settings dialog
"""
self.formattingTagForm.exec_()
2011-02-20 15:35:52 +00:00
2010-10-07 21:27:26 +00:00
def onSettingsConfigureItemClicked(self):
2009-08-09 17:58:37 +00:00
"""
Show the Settings dialog
"""
self.settingsForm.exec_()
2010-04-02 18:12:54 +00:00
def paintEvent(self, event):
"""
We need to make sure, that the SlidePreview's size is correct.
"""
self.previewController.previewSizeChanged()
self.liveController.previewSizeChanged()
2010-10-07 21:27:26 +00:00
def onSettingsShortcutsItemClicked(self):
"""
Show the shortcuts dialog
"""
if self.shortcutForm.exec_():
2011-03-30 17:50:36 +00:00
self.shortcutForm.save()
2010-10-07 21:27:26 +00:00
def onSettingsImportItemClicked(self):
"""
Import settings from an export INI file
"""
answer = QtGui.QMessageBox.critical(self,
translate('OpenLP.MainWindow', 'Import settings?'),
translate('OpenLP.MainWindow',
'Are you sure you want to import settings?\n\n'
'Importing settings will make permanent changes to your current '
'OpenLP configuration.\n\n'
'Importing incorrect settings may cause erratic behaviour or '
'OpenLP to terminate abnormally.'),
QtGui.QMessageBox.StandardButtons(
QtGui.QMessageBox.Yes |
QtGui.QMessageBox.No),
QtGui.QMessageBox.No)
if answer == QtGui.QMessageBox.No:
return
import_file_name = unicode(QtGui.QFileDialog.getOpenFileName(self,
translate('OpenLP.MainWindow', 'Open File'),
'',
translate('OpenLP.MainWindow',
'OpenLP Export Settings Files (*.conf)')))
if not import_file_name:
return
setting_sections = []
# Add main sections.
setting_sections.extend([self.generalSettingsSection])
setting_sections.extend([self.advancedSettingsSection])
setting_sections.extend([self.uiSettingsSection])
setting_sections.extend([self.shortcutsSettingsSection])
setting_sections.extend([self.serviceManagerSettingsSection])
setting_sections.extend([self.themesSettingsSection])
setting_sections.extend([self.displayTagsSection])
setting_sections.extend([self.headerSection])
# Add plugin sections.
for plugin in self.pluginManager.plugins:
setting_sections.extend([plugin.name])
2012-05-17 15:13:09 +00:00
settings = Settings()
import_settings = Settings(import_file_name,
QtCore.QSettings.IniFormat)
import_keys = import_settings.allKeys()
for section_key in import_keys:
# We need to handle the really bad files.
try:
section, key = section_key.split(u'/')
except ValueError:
section = u'unknown'
key = u''
# Switch General back to lowercase.
if section == u'General':
section = u'general'
section_key = section + "/" + key
# Make sure it's a valid section for us.
if not section in setting_sections:
QtGui.QMessageBox.critical(self,
translate('OpenLP.MainWindow', 'Import settings'),
translate('OpenLP.MainWindow',
'The file you selected does appear to be a valid OpenLP '
'settings file.\n\n'
'Section [%s] is not valid \n\n'
'Processing has terminated and no changed have been made.'
% section),
QtGui.QMessageBox.StandardButtons(
QtGui.QMessageBox.Ok))
return
# We have a good file, import it.
for section_key in import_keys:
value = import_settings.value(section_key)
2012-05-17 15:13:09 +00:00
settings.setValue(u'%s' % (section_key), value)
2011-08-24 16:17:24 +00:00
now = datetime.now()
settings.beginGroup(self.headerSection)
2012-05-17 15:13:09 +00:00
settings.setValue(u'file_imported', import_file_name)
2011-08-24 16:17:24 +00:00
settings.setValue(u'file_date_imported',
now.strftime("%Y-%m-%d %H:%M"))
settings.endGroup()
settings.sync()
# We must do an immediate restart or current configuration will
# overwrite what was just imported when application terminates
# normally. We need to exit without saving configuration.
QtGui.QMessageBox.information(self,
translate('OpenLP.MainWindow', 'Import settings'),
translate('OpenLP.MainWindow',
'OpenLP will now close. Imported settings will '
'be applied the next time you start OpenLP.'),
QtGui.QMessageBox.StandardButtons(
QtGui.QMessageBox.Ok))
self.settingsImported = True
self.cleanUp()
2011-08-28 13:39:34 +00:00
QtCore.QCoreApplication.exit()
2011-09-05 13:03:30 +00:00
def onSettingsExportItemClicked(self):
"""
2011-09-05 13:03:30 +00:00
Export settings to a .conf file in INI format
"""
2011-09-05 13:03:30 +00:00
export_file_name = unicode(QtGui.QFileDialog.getSaveFileName(self,
translate('OpenLP.MainWindow', 'Export Settings File'), '',
translate('OpenLP.MainWindow',
'OpenLP Export Settings File (*.conf)')))
if not export_file_name:
return
2011-09-05 13:03:30 +00:00
# Make sure it's a .conf file.
if not export_file_name.endswith(u'conf'):
export_file_name = export_file_name + u'.conf'
2011-08-29 06:30:31 +00:00
temp_file = os.path.join(unicode(gettempdir()),
2011-09-05 13:03:30 +00:00
u'openlp', u'exportConf.tmp')
self.saveSettings()
setting_sections = []
# Add main sections.
setting_sections.extend([self.generalSettingsSection])
setting_sections.extend([self.advancedSettingsSection])
setting_sections.extend([self.uiSettingsSection])
setting_sections.extend([self.shortcutsSettingsSection])
setting_sections.extend([self.serviceManagerSettingsSection])
setting_sections.extend([self.themesSettingsSection])
setting_sections.extend([self.displayTagsSection])
# Add plugin sections.
for plugin in self.pluginManager.plugins:
setting_sections.extend([plugin.name])
2011-08-24 16:17:24 +00:00
# Delete old files if found.
if os.path.exists(temp_file):
os.remove(temp_file)
2011-09-05 13:03:30 +00:00
if os.path.exists(export_file_name):
os.remove(export_file_name)
2012-05-17 15:13:09 +00:00
settings = Settings()
2011-08-24 16:17:24 +00:00
settings.remove(self.headerSection)
# Get the settings.
keys = settings.allKeys()
2012-05-17 15:13:09 +00:00
export_settings = Settings(temp_file,
QtCore.QSettings.IniFormat)
# Add a header section.
2011-09-05 13:03:30 +00:00
# This is to insure it's our conf file for import.
now = datetime.now()
application_version = get_application_version()
# Write INI format using Qsettings.
# Write our header.
export_settings.beginGroup(self.headerSection)
export_settings.setValue(u'Make_Changes', u'At_Own_RISK')
export_settings.setValue(u'type', u'OpenLP_settings_export')
export_settings.setValue(u'file_date_created',
now.strftime("%Y-%m-%d %H:%M"))
export_settings.setValue(u'version', application_version[u'full'])
export_settings.endGroup()
# Write all the sections and keys.
for section_key in keys:
key_value = settings.value(section_key)
export_settings.setValue(section_key, key_value)
export_settings.sync()
2011-09-05 13:03:30 +00:00
# Temp CONF file has been written. Blanks in keys are now '%20'.
# Read the temp file and output the user's CONF file with blanks to
2011-08-24 16:17:24 +00:00
# make it more readable.
2011-09-05 13:03:30 +00:00
temp_conf = open(temp_file, u'r')
export_conf = open(export_file_name, u'w')
for file_record in temp_conf:
# Get rid of any invalid entries.
if file_record.find(u'@Invalid()') == -1:
2011-09-05 13:03:30 +00:00
file_record = file_record.replace(u'%20', u' ')
export_conf.write(file_record)
temp_conf.close()
export_conf.close()
2011-08-24 16:17:24 +00:00
os.remove(temp_file)
return
2010-09-18 18:15:54 +00:00
def onModeDefaultItemClicked(self):
2010-09-18 17:14:27 +00:00
"""
Put OpenLP into "Default" view mode.
"""
2011-02-02 05:31:11 +00:00
self.setViewMode(True, True, True, True, True, u'default')
2010-09-18 17:14:27 +00:00
2010-07-06 20:05:48 +00:00
def onModeSetupItemClicked(self):
"""
Put OpenLP into "Setup" view mode.
"""
2011-02-02 05:31:11 +00:00
self.setViewMode(True, True, False, True, False, u'setup')
2010-07-06 20:05:48 +00:00
def onModeLiveItemClicked(self):
"""
Put OpenLP into "Live" view mode.
"""
2011-02-02 05:31:11 +00:00
self.setViewMode(False, True, False, False, True, u'live')
2010-07-30 22:48:09 +00:00
def setViewMode(self, media=True, service=True, theme=True, preview=True,
2011-02-02 05:31:11 +00:00
live=True, mode=u''):
2010-07-30 22:48:09 +00:00
"""
Set OpenLP to a different view mode.
"""
2011-02-02 05:31:11 +00:00
if mode:
2012-05-17 15:13:09 +00:00
settings = Settings()
2011-02-02 05:31:11 +00:00
settings.setValue(u'%s/view mode' % self.generalSettingsSection,
mode)
2011-02-07 22:07:48 +00:00
self.mediaManagerDock.setVisible(media)
self.serviceManagerDock.setVisible(service)
self.themeManagerDock.setVisible(theme)
2010-07-30 22:48:09 +00:00
self.setPreviewPanelVisibility(preview)
self.setLivePanelVisibility(live)
2010-07-06 20:05:48 +00:00
2010-04-02 18:12:54 +00:00
def screenChanged(self):
"""
The screen has changed so we have to update components such as the
renderer.
"""
2010-08-26 16:51:27 +00:00
log.debug(u'screenChanged')
Receiver.send_message(u'cursor_busy')
self.imageManager.update_display()
2011-05-05 11:51:47 +00:00
self.renderer.update_display()
self.previewController.screenSizeChanged()
self.liveController.screenSizeChanged()
2011-05-05 15:16:55 +00:00
self.setFocus()
self.activateWindow()
Receiver.send_message(u'cursor_normal')
2009-08-09 17:58:37 +00:00
2009-10-16 21:29:38 +00:00
def closeEvent(self, event):
2009-08-09 17:58:37 +00:00
"""
Hook to close the main window and display windows on exit
"""
# If we just did a settings import, close without saving changes.
if self.settingsImported:
event.accept()
2011-05-25 08:32:37 +00:00
if self.serviceManagerContents.isModified():
ret = self.serviceManagerContents.saveModifiedService()
2009-08-09 17:58:37 +00:00
if ret == QtGui.QMessageBox.Save:
2011-05-25 08:32:37 +00:00
if self.serviceManagerContents.saveFile():
self.cleanUp()
event.accept()
else:
event.ignore()
2009-08-09 17:58:37 +00:00
elif ret == QtGui.QMessageBox.Discard:
self.cleanUp()
event.accept()
else:
event.ignore()
else:
2012-05-17 15:13:09 +00:00
if Settings().value(u'advanced/enable exit confirmation',
True):
2011-01-02 16:42:30 +00:00
ret = QtGui.QMessageBox.question(self,
translate('OpenLP.MainWindow', 'Close OpenLP'),
2011-01-04 09:19:53 +00:00
translate('OpenLP.MainWindow',
'Are you sure you want to close OpenLP?'),
2011-01-02 16:42:30 +00:00
QtGui.QMessageBox.StandardButtons(
QtGui.QMessageBox.Yes |
QtGui.QMessageBox.No),
QtGui.QMessageBox.Yes)
if ret == QtGui.QMessageBox.Yes:
self.cleanUp()
event.accept()
else:
event.ignore()
else:
2010-12-29 12:45:16 +00:00
self.cleanUp()
event.accept()
2011-01-02 16:42:30 +00:00
2009-08-09 17:58:37 +00:00
def cleanUp(self):
2009-09-19 23:05:30 +00:00
"""
Runs all the cleanup code before OpenLP shuts down
"""
# Clean temporary files used by services
2011-05-25 08:32:37 +00:00
self.serviceManagerContents.cleanUp()
2012-05-17 15:13:09 +00:00
if Settings().value(u'advanced/save current plugin',
False):
Settings().setValue(u'advanced/current media plugin',
self.mediaToolBox.currentIndex())
2009-08-09 17:58:37 +00:00
# Call the cleanup method to shutdown plugins.
log.info(u'cleanup plugins')
2010-12-11 20:49:50 +00:00
self.pluginManager.finalise_plugins()
2010-04-23 18:30:53 +00:00
# Save settings
self.saveSettings()
2010-10-30 11:09:36 +00:00
# Close down the display
2010-12-11 20:49:50 +00:00
self.liveController.display.close()
2009-08-09 17:58:37 +00:00
2009-09-19 21:45:50 +00:00
def serviceChanged(self, reset=False, serviceName=None):
2009-08-09 17:58:37 +00:00
"""
2010-04-19 18:43:20 +00:00
Hook to change the main window title when the service changes
2009-09-19 21:45:50 +00:00
``reset``
Shows if the service has been cleared or saved
``serviceName``
The name of the service (if it has one)
2009-08-09 17:58:37 +00:00
"""
2009-09-19 21:45:50 +00:00
if not serviceName:
2009-08-09 17:58:37 +00:00
service_name = u'(unsaved service)'
else:
2009-09-19 21:45:50 +00:00
service_name = serviceName
2009-11-03 15:13:52 +00:00
if reset:
2009-09-19 21:45:50 +00:00
self.serviceNotSaved = False
2009-08-09 17:58:37 +00:00
title = u'%s - %s' % (self.mainTitle, service_name)
else:
2009-09-19 21:45:50 +00:00
self.serviceNotSaved = True
2009-08-09 17:58:37 +00:00
title = u'%s - %s*' % (self.mainTitle, service_name)
self.setWindowTitle(title)
def setServiceModified(self, modified, fileName):
"""
This method is called from the ServiceManager to set the title of the
main window.
``modified``
Whether or not this service has been modified.
``fileName``
The file name of the service file.
"""
if modified:
title = u'%s - %s*' % (self.mainTitle, fileName)
else:
title = u'%s - %s' % (self.mainTitle, fileName)
self.setWindowTitle(title)
def showStatusMessage(self, message):
2011-04-28 18:13:19 +00:00
self.statusBar.showMessage(message)
def defaultThemeChanged(self, theme):
2011-04-28 18:13:19 +00:00
self.defaultThemeLabel.setText(
2010-07-26 15:19:11 +00:00
unicode(translate('OpenLP.MainWindow', 'Default Theme: %s')) %
theme)
2011-03-31 18:53:50 +00:00
def toggleMediaManager(self):
self.mediaManagerDock.setVisible(not self.mediaManagerDock.isVisible())
2011-03-31 18:53:50 +00:00
def toggleServiceManager(self):
2011-06-12 14:19:32 +00:00
self.serviceManagerDock.setVisible(
not self.serviceManagerDock.isVisible())
2011-03-31 18:53:50 +00:00
def toggleThemeManager(self):
self.themeManagerDock.setVisible(not self.themeManagerDock.isVisible())
2011-04-17 11:00:44 +00:00
def setPreviewPanelVisibility(self, visible):
2010-07-06 21:18:55 +00:00
"""
Sets the visibility of the preview panel including saving the setting
and updating the menu.
``visible``
A bool giving the state to set the panel to
True - Visible
False - Hidden
"""
2011-02-01 18:05:59 +00:00
self.previewController.panel.setVisible(visible)
2012-05-17 15:13:09 +00:00
Settings().setValue(u'user interface/preview panel', visible)
2011-05-25 08:32:37 +00:00
self.viewPreviewPanel.setChecked(visible)
2010-07-06 20:05:48 +00:00
2011-06-12 14:19:32 +00:00
def setLockPanel(self, lock):
"""
2011-06-26 06:49:10 +00:00
Sets the ability to stop the toolbars being changed.
2011-06-12 14:19:32 +00:00
"""
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)
2012-05-17 15:13:09 +00:00
Settings().setValue(u'user interface/lock panel', lock)
2011-06-12 14:19:32 +00:00
2011-04-17 11:00:44 +00:00
def setLivePanelVisibility(self, visible):
2010-07-06 21:18:55 +00:00
"""
Sets the visibility of the live panel including saving the setting and
updating the menu.
``visible``
A bool giving the state to set the panel to
True - Visible
False - Hidden
"""
2011-02-01 18:05:59 +00:00
self.liveController.panel.setVisible(visible)
2012-05-17 15:13:09 +00:00
Settings().setValue(u'user interface/live panel', visible)
2011-05-25 08:32:37 +00:00
self.viewLivePanel.setChecked(visible)
2010-04-23 18:30:53 +00:00
def loadSettings(self):
2010-07-09 21:32:32 +00:00
"""
Load the main window settings.
"""
2010-04-23 18:30:53 +00:00
log.debug(u'Loading QSettings')
2012-02-06 13:28:16 +00:00
# Migrate Wrap Settings to Slide Limits Settings
2012-05-17 15:13:09 +00:00
if Settings().contains(self.generalSettingsSection +
u'/enable slide loop'):
2012-05-17 15:13:09 +00:00
if Settings().value(self.generalSettingsSection +
u'/enable slide loop', True):
Settings().setValue(self.advancedSettingsSection +
u'/slide limits', SlideLimits.Wrap)
else:
2012-05-17 15:13:09 +00:00
Settings().setValue(self.advancedSettingsSection +
u'/slide limits', SlideLimits.End)
Settings().remove(self.generalSettingsSection +
u'/enable slide loop')
2012-02-06 13:28:16 +00:00
Receiver.send_message(u'slidecontroller_update_slide_limits')
2012-05-17 15:13:09 +00:00
settings = Settings()
# Remove obsolete entries.
settings.remove(u'custom slide')
settings.remove(u'service')
settings.beginGroup(self.generalSettingsSection)
2010-04-30 01:31:41 +00:00
self.recentFiles = settings.value(u'recent files').toStringList()
settings.endGroup()
settings.beginGroup(self.uiSettingsSection)
2010-04-28 14:17:42 +00:00
self.move(settings.value(u'main window position',
2012-05-17 15:13:09 +00:00
QtCore.QPoint(0, 0))).toPoint()
2010-04-28 14:17:42 +00:00
self.restoreGeometry(
settings.value(u'main window geometry').toByteArray())
self.restoreState(settings.value(u'main window state').toByteArray())
self.liveController.splitter.restoreState(
settings.value(u'live splitter geometry').toByteArray())
self.previewController.splitter.restoreState(
settings.value(u'preview splitter geometry').toByteArray())
2011-06-29 16:11:19 +00:00
self.controlSplitter.restoreState(
settings.value(u'mainwindow splitter geometry').toByteArray())
2010-04-28 14:17:42 +00:00
settings.endGroup()
2010-04-23 18:30:53 +00:00
def saveSettings(self):
2010-07-09 21:32:32 +00:00
"""
Save the main window settings.
"""
# Exit if we just did a settings import.
if self.settingsImported:
return
2010-04-23 18:30:53 +00:00
log.debug(u'Saving QSettings')
2012-05-17 15:13:09 +00:00
settings = Settings()
settings.beginGroup(self.generalSettingsSection)
2012-05-17 15:13:09 +00:00
recentFiles = self.recentFiles if self.recentFiles else u''
2010-04-30 01:31:41 +00:00
settings.setValue(u'recent files', recentFiles)
settings.endGroup()
settings.beginGroup(self.uiSettingsSection)
2012-05-17 15:13:09 +00:00
settings.setValue(u'main window position', self.pos())
settings.setValue(u'main window state', self.saveState())
settings.setValue(u'main window geometry', self.saveGeometry())
settings.setValue(u'live splitter geometry',
2012-05-17 15:13:09 +00:00
self.liveController.splitter.saveState())
settings.setValue(u'preview splitter geometry',
2012-05-17 15:13:09 +00:00
self.previewController.splitter.saveState())
2011-06-29 16:11:19 +00:00
settings.setValue(u'mainwindow splitter geometry',
2012-05-17 15:13:09 +00:00
self.controlSplitter.saveState())
2010-04-28 14:17:42 +00:00
settings.endGroup()
2010-04-23 18:30:53 +00:00
def updateRecentFilesMenu(self):
2010-07-09 21:32:32 +00:00
"""
Updates the recent file menu with the latest list of service files
accessed.
2010-07-09 21:32:32 +00:00
"""
2012-05-17 15:13:09 +00:00
recentFileCount = Settings().value(
u'advanced/recent file count', 4)
2011-02-04 01:56:19 +00:00
existingRecentFiles = [recentFile for recentFile in self.recentFiles
2012-02-26 21:09:22 +00:00
if os.path.isfile(unicode(recentFile))]
2010-07-09 21:32:32 +00:00
recentFilesToDisplay = existingRecentFiles[0:recentFileCount]
self.recentFilesMenu.clear()
for fileId, filename in enumerate(recentFilesToDisplay):
log.debug('Recent file name: %s', filename)
action = create_action(self, u'',
text=u'&%d %s' % (fileId + 1, os.path.splitext(os.path.basename(
unicode(filename)))[0]), data=filename,
triggers=self.serviceManagerContents.onRecentServiceClicked)
self.recentFilesMenu.addAction(action)
clearRecentFilesAction = create_action(self, u'',
text=translate('OpenLP.MainWindow', 'Clear List',
'Clear List of recent files'),
statustip=translate('OpenLP.MainWindow',
'Clear the list of recent files.'),
enabled=not self.recentFiles.isEmpty(),
triggers=self.recentFiles.clear)
add_actions(self.recentFilesMenu, (None, clearRecentFilesAction))
clearRecentFilesAction.setEnabled(not self.recentFiles.isEmpty())
2010-04-23 18:30:53 +00:00
def addRecentFile(self, filename):
2010-07-09 21:32:32 +00:00
"""
Adds a service to the list of recently used files.
``filename``
The service filename to add
"""
# The maxRecentFiles value does not have an interface and so never gets
2010-12-26 14:44:07 +00:00
# actually stored in the settings therefore the default value of 20 will
# always be used.
2012-05-17 15:13:09 +00:00
maxRecentFiles = Settings().value(
u'advanced/max recent files', 20)
2010-06-30 11:59:09 +00:00
if filename:
# Add some cleanup to reduce duplication in the recent file list
filename = os.path.abspath(filename)
# abspath() only capitalises the drive letter if it wasn't provided
# in the given filename which then causes duplication.
if filename[1:3] == ':\\':
filename = filename[0].upper() + filename[1:]
2010-06-30 11:59:09 +00:00
position = self.recentFiles.indexOf(filename)
if position != -1:
self.recentFiles.removeAt(position)
2012-05-17 15:13:09 +00:00
self.recentFiles.insert(0, filename)
2010-07-10 10:44:23 +00:00
while self.recentFiles.count() > maxRecentFiles:
2010-07-10 01:01:14 +00:00
# Don't care what API says takeLast works, removeLast doesn't!
2011-04-17 11:00:44 +00:00
self.recentFiles.takeLast()
2011-04-28 18:13:19 +00:00
def displayProgressBar(self, size):
"""
Make Progress bar visible and set size
"""
self.loadProgressBar.show()
self.loadProgressBar.setMaximum(size)
self.loadProgressBar.setValue(0)
Receiver.send_message(u'openlp_process_events')
def incrementProgressBar(self):
"""
2011-04-29 07:40:19 +00:00
Increase the Progress Bar value by 1
2011-04-28 18:13:19 +00:00
"""
self.loadProgressBar.setValue(self.loadProgressBar.value() + 1)
Receiver.send_message(u'openlp_process_events')
def finishedProgressBar(self):
"""
2011-04-29 07:40:19 +00:00
Trigger it's removal after 2.5 second
2011-04-28 18:13:19 +00:00
"""
2011-04-29 07:40:19 +00:00
self.timer_id = self.startTimer(2500)
2011-04-28 18:13:19 +00:00
2011-04-29 07:40:19 +00:00
def timerEvent(self, event):
2011-04-28 18:13:19 +00:00
"""
Remove the Progress bar from view.
"""
2011-04-29 07:40:19 +00:00
if event.timerId() == self.timer_id:
2011-04-29 08:54:11 +00:00
self.timer_id = 0
2011-04-29 07:40:19 +00:00
self.loadProgressBar.hide()
Receiver.send_message(u'openlp_process_events')