diff --git a/openlp.pyw b/openlp.pyw index d7e43ede0..be5185c34 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -71,7 +71,7 @@ class OpenLP(QtGui.QApplication): self.mainWindow = MainWindow(screens) self.mainWindow.show() # now kill the splashscreen - self.splash.finish(self.mainWindow.mainWindow) + self.splash.finish(self.mainWindow) sys.exit(app.exec_()) if __name__ == u'__main__': diff --git a/openlp/core/lib/event.py b/openlp/core/lib/event.py index dcb84ffbb..bb857d4fe 100644 --- a/openlp/core/lib/event.py +++ b/openlp/core/lib/event.py @@ -28,6 +28,7 @@ class EventType(object): # "Default" event - a non-event Default = 0 # General application events + Ready = 10 # Service events LoadServiceItem = 20 # Preview events @@ -43,6 +44,7 @@ class Event(object): """ Provides an Event class to encapsulate events within openlp.org. """ - def __init__(self, event_type=EventType.Default, payload=None): + def __init__(self, event_type=EventType.Default, payload=None, sender=None): self.event_type = event_type self.payload = payload + self.sender = sender diff --git a/openlp/core/lib/eventmanager.py b/openlp/core/lib/eventmanager.py index 3b84a8d10..c5f768729 100644 --- a/openlp/core/lib/eventmanager.py +++ b/openlp/core/lib/eventmanager.py @@ -25,10 +25,10 @@ import logging class EventManager(object): """ - A mechanism to send events to all registered endpoints - the endpoints are registered and listen with a handle_event method - the endpoint will decide whether to do somthing with the event or ignore it - + A mechanism to send events to all registered endpoints. The + endpoints are registered and listen with a handle_event method. + The endpoint will decide whether to do somthing with the event or + ignore it. """ global log log = logging.getLogger(u'EventManager') diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index c24ee07b4..55c484d5e 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -154,11 +154,6 @@ class Renderer(object): text.append(line) #print text split_text = self.pre_render_text(text) -# print "-----------------------------" -# print split_text -# split_text = self._split_set_of_lines(text, False) -# print "-----------------------------" -# print split_text log.debug(u'format_slide - End') return split_text @@ -168,7 +163,7 @@ class Renderer(object): line_width = self._rect.width() - self._right_margin #number of lines on a page - adjust for rounding up. #print self._rect.height() , metrics.height(), int(self._rect.height() / metrics.height()) - page_length = int(self._rect.height() / metrics.height()) - 1 + page_length = int(self._rect.height() / metrics.height() - 2 ) - 1 ave_line_width = line_width / metrics.averageCharWidth() # print "A", ave_line_width ave_line_width = int(ave_line_width + (ave_line_width * 0.5)) @@ -272,113 +267,49 @@ class Renderer(object): log.debug(u'render background %s start', self._theme.background_type) painter = QtGui.QPainter() painter.begin(self._bg_frame) - if self._theme.background_type == u'solid': - painter.fillRect(self._frame.rect(), QtGui.QColor(self._theme.background_color)) - elif self._theme.background_type == u'gradient': - # gradient - gradient = None - if self._theme.background_direction == u'horizontal': - w = int(self._frame.width()) / 2 - # vertical - gradient = QtGui.QLinearGradient(w, 0, w, self._frame.height()) - elif self._theme.background_direction == u'vertical': - h = int(self._frame.height()) / 2 - # Horizontal - gradient = QtGui.QLinearGradient(0, h, self._frame.width(), h) - else: - w = int(self._frame.width()) / 2 - h = int(self._frame.height()) / 2 - # Circular - gradient = QtGui.QRadialGradient(w, h, w) - gradient.setColorAt(0, QtGui.QColor(self._theme.background_startColor)) - gradient.setColorAt(1, QtGui.QColor(self._theme.background_endColor)) - painter.setBrush(QtGui.QBrush(gradient)) - rectPath = QtGui.QPainterPath() - max_x = self._frame.width() - max_y = self._frame.height() - rectPath.moveTo(0, 0) - rectPath.lineTo(0, max_y) - rectPath.lineTo(max_x, max_y) - rectPath.lineTo(max_x, 0) - rectPath.closeSubpath() - painter.drawPath(rectPath) - elif self._theme.background_type== u'image': - # image - painter.fillRect(self._frame.rect(), QtCore.Qt.black) - if self.bg_image is not None: - painter.drawImage(0 ,0 , self.bg_image) + if self._theme.background_mode == u'transparent': + painter.fillRect(self._frame.rect(), QtCore.Qt.transparent) + else: + if self._theme.background_type == u'solid': + painter.fillRect(self._frame.rect(), QtGui.QColor(self._theme.background_color)) + elif self._theme.background_type == u'gradient': + # gradient + gradient = None + if self._theme.background_direction == u'horizontal': + w = int(self._frame.width()) / 2 + # vertical + gradient = QtGui.QLinearGradient(w, 0, w, self._frame.height()) + elif self._theme.background_direction == u'vertical': + h = int(self._frame.height()) / 2 + # Horizontal + gradient = QtGui.QLinearGradient(0, h, self._frame.width(), h) + else: + w = int(self._frame.width()) / 2 + h = int(self._frame.height()) / 2 + # Circular + gradient = QtGui.QRadialGradient(w, h, w) + gradient.setColorAt(0, QtGui.QColor(self._theme.background_startColor)) + gradient.setColorAt(1, QtGui.QColor(self._theme.background_endColor)) + painter.setBrush(QtGui.QBrush(gradient)) + rectPath = QtGui.QPainterPath() + max_x = self._frame.width() + max_y = self._frame.height() + rectPath.moveTo(0, 0) + rectPath.lineTo(0, max_y) + rectPath.lineTo(max_x, max_y) + rectPath.lineTo(max_x, 0) + rectPath.closeSubpath() + painter.drawPath(rectPath) + elif self._theme.background_type== u'image': + # image + painter.fillRect(self._frame.rect(), QtCore.Qt.black) + if self.bg_image is not None: + painter.drawImage(0 ,0 , self.bg_image) painter.end() self._bg_frame_small = self._bg_frame.scaled(QtCore.QSize(280, 210), QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation) log.debug(u'render background End') -# def _split_set_of_lines(self, lines, footer): -# """ -# Given a list of lines, decide how to split them best if they don't all -# fit on the screen. This is done by splitting at 1/2, 1/3 or 1/4 of the -# set. If it doesn't fit, even at this size, just split at each -# opportunity. We'll do this by getting the bounding box of each line, -# and then summing them appropriately. -# -# Returns a list of [lists of lines], one set for each screenful. -# -# ``lines`` -# The lines of text to split. -# -# ``footer`` -# The footer text. -# """ -# bboxes = [] -# for line in lines: -# bboxes.append(self._render_and_wrap_single_line(line, footer)) -# numlines = len(lines) -# bottom = self._rect.bottom() -# for ratio in (numlines, numlines/2, numlines/3, numlines/4): -# good = 1 -# startline = 0 -# endline = startline + ratio -# while (endline <= numlines and endline != 0): -# by = 0 -# for (x,y) in bboxes[startline:endline]: -# by += y -# if by > bottom: -# good = 0 -# break -# startline += ratio -# endline = startline + ratio -# if good == 1: -# break -# retval = [] -# numlines_per_page = ratio -# if good: -# c = 0 -# thislines = [] -# while c < numlines: -# thislines.append(lines[c]) -# c += 1 -# if len(thislines) == numlines_per_page: -# retval.append(thislines) -# thislines = [] -# if len(thislines) > 0: -# retval.append(thislines) -# else: -# # print "Just split where you can" -# retval = [] -# startline = 0 -# endline = startline + 1 -# while (endline <= numlines): -# by = 0 -# for (x,y) in bboxes[startline:endline]: -# by += y -# if by > bottom: -# retval.append(lines[startline:endline-1]) -# startline = endline-1 -# # gets incremented below -# endline = startline -# by = 0 -# endline += 1 -# return retval - def _correctAlignment(self, rect, bbox): """ Corrects the vertical alignment of text. diff --git a/openlp/core/lib/themexmlhandler.py b/openlp/core/lib/themexmlhandler.py index accd9cf53..73fe78d66 100644 --- a/openlp/core/lib/themexmlhandler.py +++ b/openlp/core/lib/themexmlhandler.py @@ -331,6 +331,11 @@ class ThemeXML(object): for element in iter: if len(element.getchildren()) > 0: master = element.tag + u'_' + else: + #background transparent tags have no children so special case + if element.tag == u'background': + for e in element.attrib.iteritems(): + setattr(self, element.tag + u'_' + e[0], e[1]) if len(element.attrib) > 0: for e in element.attrib.iteritems(): if master == u'font_' and e[0] == u'type': diff --git a/openlp/core/ui/amendthemeform.py b/openlp/core/ui/amendthemeform.py index f22c9212a..ef6f8368f 100644 --- a/openlp/core/ui/amendthemeform.py +++ b/openlp/core/ui/amendthemeform.py @@ -108,16 +108,19 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): new_theme.new_document(theme_name) save_from = None save_to = None - if self.theme.background_type == u'solid': - new_theme.add_background_solid(unicode(self.theme.background_color)) - elif self.theme.background_type == u'gradient': - new_theme.add_background_gradient(unicode(self.theme.background_startColor), - unicode(self.theme.background_endColor), self.theme.background_direction) + if self.theme.background_mode == u'transparent': + new_theme.add_background_transparent() else: - (path, filename) =os.path.split(unicode(self.theme.background_filename)) - new_theme.add_background_image(filename) - save_to= os.path.join(self.path, theme_name, filename ) - save_from = self.theme.background_filename + if self.theme.background_type == u'solid': + new_theme.add_background_solid(unicode(self.theme.background_color)) + elif self.theme.background_type == u'gradient': + new_theme.add_background_gradient(unicode(self.theme.background_startColor), + unicode(self.theme.background_endColor), self.theme.background_direction) + else: + (path, filename) =os.path.split(unicode(self.theme.background_filename)) + new_theme.add_background_image(filename) + save_to= os.path.join(self.path, theme_name, filename ) + save_from = self.theme.background_filename new_theme.add_font(unicode(self.theme.font_main_name), unicode(self.theme.font_main_color), unicode(self.theme.font_main_proportion), unicode(self.theme.font_main_override), u'main', diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 37459a347..d63dfd494 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -26,186 +26,28 @@ from openlp.core.ui import AboutForm, SettingsForm, AlertForm, \ ServiceManager, ThemeManager, MainDisplay, SlideController from openlp.core.lib import translate, Plugin, MediaManagerItem, \ SettingsTab, EventManager, RenderManager, PluginConfig, \ - SettingsManager, PluginManager + SettingsManager, PluginManager, EventType -class MainWindow(object): - """ - The main window. - """ - global log - log = logging.getLogger(u'MainWindow') - log.info(u'MainWindow loaded') - - def __init__(self, screens): - """ - This constructor sets up the interface, the various managers, and the - plugins. - """ - self.oosNotSaved = False - self.settingsmanager = SettingsManager(screens) - self.mainWindow = QtGui.QMainWindow() - self.mainWindow.__class__.closeEvent = self.onCloseEvent - self.mainDisplay = MainDisplay(None, screens) - self.screenList = screens - self.EventManager = EventManager() - self.generalConfig = PluginConfig(u'General') - self.alertForm = AlertForm(self) - self.aboutForm = AboutForm() - self.settingsForm = SettingsForm(self.screenList, self) - # Set up the path with plugins - pluginpath = os.path.split(os.path.abspath(__file__))[0] - pluginpath = os.path.abspath( - os.path.join(pluginpath, u'..', u'..', u'plugins')) - self.plugin_manager = PluginManager(pluginpath) - self.plugin_helpers = {} - # Set up the interface - self.setupUi() - #warning cyclic dependency - #RenderManager needs to call ThemeManager and - #ThemeManager needs to call RenderManager - self.RenderManager = RenderManager(self.ThemeManagerContents, - self.screenList, self.getMonitorNumber()) - log.info(u'Load Plugins') - #make the controllers available to the plugins - self.plugin_helpers[u'preview'] = self.PreviewController - self.plugin_helpers[u'live'] = self.LiveController - self.plugin_helpers[u'event'] = self.EventManager - self.plugin_helpers[u'theme'] = self.ThemeManagerContents - self.plugin_helpers[u'render'] = self.RenderManager - self.plugin_helpers[u'service'] = self.ServiceManagerContents - self.plugin_helpers[u'settings'] = self.settingsForm - self.plugin_manager.find_plugins(pluginpath, self.plugin_helpers, - self.EventManager) - # hook methods have to happen after find_plugins. Find plugins needs the - # controllers hence the hooks have moved from setupUI() to here - - # Find and insert settings tabs - log.info(u'hook settings') - self.plugin_manager.hook_settings_tabs(self.settingsForm) - # Find and insert media manager items - log.info(u'hook media') - self.plugin_manager.hook_media_manager(self.MediaToolBox) - # Call the hook method to pull in import menus. - log.info(u'hook menus') - self.plugin_manager.hook_import_menu(self.FileImportMenu) - # Call the hook method to pull in export menus. - self.plugin_manager.hook_export_menu(self.FileExportMenu) - # Call the initialise method to setup plugins. - log.info(u'initialise plugins') - self.plugin_manager.initialise_plugins() - # Once all components are initialised load the Themes - log.info(u'Load Themes') - self.ThemeManagerContents.loadThemes() - - def getMonitorNumber(self): - """ - Set up the default behaviour of the monitor configuration in - here. Currently it is set to default to monitor 0 if the saved - monitor number does not exist. - """ - screen_number = int(self.generalConfig.get_config(u'Monitor', 0)) - if screen_number not in self.screenList: - screen_number = 0 - return screen_number - - def show(self): - """ - Show the main form, as well as the display form - """ - self.mainWindow.showMaximized() - screen_number = self.getMonitorNumber() - self.mainDisplay.setup(screen_number) - self.mainWindow.setFocus() - - def onHelpAboutItemClicked(self): - """ - Show the About form - """ - self.aboutForm.exec_() - - def onToolsAlertItemClicked(self): - """ - Show the Alert form - """ - self.alertForm.exec_() - - def onOptionsSettingsItemClicked(self): - """ - Show the Settings dialog - """ - self.settingsForm.exec_() - screen_number = self.getMonitorNumber() - self.RenderManager.update_display(screen_number) - self.mainDisplay.setup(screen_number) - - def onCloseEvent(self, event): - """ - Hook to close the main window and display windows on exit - """ - if self.oosNotSaved == True: - ret = QtGui.QMessageBox.question(None, - translate(u'mainWindow', u'Save Changes to Service?'), - translate(u'mainWindow', u'Your service has been changed, do you want to save those changes?'), - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Cancel | QtGui.QMessageBox.Discard | QtGui.QMessageBox.Save), - QtGui.QMessageBox.Save) - if ret == QtGui.QMessageBox.Save: - self.ServiceManagerContents.onSaveService() - self.mainDisplay.close() - self.cleanUp() - event.accept() - elif ret == QtGui.QMessageBox.Discard: - self.mainDisplay.close() - self.cleanUp() - event.accept() - else: - event.ignore() - else: - self.mainDisplay.close() - self.cleanUp() - event.accept() - - def cleanUp(self): - # Call the cleanup method to shutdown plugins. - log.info(u'cleanup plugins') - self.plugin_manager.initialise_plugins() - - def OosChanged(self, reset=False, oosName=None): - """ - Hook to change the title if the OOS has been changed - reset - tells if the OOS has been cleared or saved - oosName - is the name of the OOS (if it has one) - """ - if not oosName: - service_name = u'(Unsaved Service)' - else: - service_name = oosName - if reset == True: - self.oosNotSaved = False - title = u'%s - %s' % (self.mainTitle, service_name) - else: - self.oosNotSaved = True - title = u'%s - %s*' % (self.mainTitle, service_name) - self.mainWindow.setWindowTitle(title) - - def setupUi(self): +class Ui_MainWindow(object): + def setupUi(self, MainWindow): """ Set up the user interface """ - self.mainWindow.setObjectName(u'mainWindow') - self.mainWindow.resize(self.settingsmanager.width, self.settingsmanager.height) + MainWindow.setObjectName(u'MainWindow') + MainWindow.resize(self.settingsmanager.width, self.settingsmanager.height) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( - self.mainWindow.sizePolicy().hasHeightForWidth()) - self.mainWindow.setSizePolicy(sizePolicy) + MainWindow.sizePolicy().hasHeightForWidth()) + MainWindow.setSizePolicy(sizePolicy) main_icon = QtGui.QIcon() main_icon.addPixmap(QtGui.QPixmap(u':/icon/openlp-logo-16x16.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.mainWindow.setWindowIcon(main_icon) + MainWindow.setWindowIcon(main_icon) # Set up the main container, which contains all the other form widgets - self.MainContent = QtGui.QWidget(self.mainWindow) + self.MainContent = QtGui.QWidget(MainWindow) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) @@ -218,7 +60,7 @@ class MainWindow(object): self.MainContentLayout.setSpacing(0) self.MainContentLayout.setMargin(0) self.MainContentLayout.setObjectName(u'MainContentLayout') - self.mainWindow.setCentralWidget(self.MainContent) + MainWindow.setCentralWidget(self.MainContent) self.ControlSplitter = QtGui.QSplitter(self.MainContent) self.ControlSplitter.setOrientation(QtCore.Qt.Horizontal) self.ControlSplitter.setObjectName(u'ControlSplitter') @@ -227,7 +69,7 @@ class MainWindow(object): self.PreviewController = SlideController(self) self.LiveController = SlideController(self, True) # Create menu - self.MenuBar = QtGui.QMenuBar(self.mainWindow) + self.MenuBar = QtGui.QMenuBar(MainWindow) self.MenuBar.setGeometry(QtCore.QRect(0, 0, 1087, 27)) self.MenuBar.setObjectName(u'MenuBar') self.FileMenu = QtGui.QMenu(self.MenuBar) @@ -248,12 +90,15 @@ class MainWindow(object): self.ToolsMenu.setObjectName(u'ToolsMenu') self.HelpMenu = QtGui.QMenu(self.MenuBar) self.HelpMenu.setObjectName(u'HelpMenu') - self.mainWindow.setMenuBar(self.MenuBar) - self.StatusBar = QtGui.QStatusBar(self.mainWindow) + MainWindow.setMenuBar(self.MenuBar) + self.StatusBar = QtGui.QStatusBar(MainWindow) self.StatusBar.setObjectName(u'StatusBar') - self.mainWindow.setStatusBar(self.StatusBar) + MainWindow.setStatusBar(self.StatusBar) + self.DefaultThemeLabel = QtGui.QLabel(self.StatusBar) + self.DefaultThemeLabel.setObjectName(u'DefaultThemeLabel') + self.StatusBar.addPermanentWidget(self.DefaultThemeLabel) # Create the MediaManager - self.MediaManagerDock = QtGui.QDockWidget(self.mainWindow) + self.MediaManagerDock = QtGui.QDockWidget(MainWindow) icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(u':/system/system_mediamanager.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off) @@ -270,10 +115,10 @@ class MainWindow(object): self.MediaToolBox.setObjectName(u'MediaToolBox') self.MediaManagerLayout.addWidget(self.MediaToolBox) self.MediaManagerDock.setWidget(self.MediaManagerContents) - self.mainWindow.addDockWidget( + MainWindow.addDockWidget( QtCore.Qt.DockWidgetArea(1), self.MediaManagerDock) # Create the service manager - self.ServiceManagerDock = QtGui.QDockWidget(self.mainWindow) + self.ServiceManagerDock = QtGui.QDockWidget(MainWindow) ServiceManagerIcon = QtGui.QIcon() ServiceManagerIcon.addPixmap( QtGui.QPixmap(u':/system/system_servicemanager.png'), @@ -285,10 +130,10 @@ class MainWindow(object): self.ServiceManagerDock.setMinimumWidth(300) self.ServiceManagerContents = ServiceManager(self) self.ServiceManagerDock.setWidget(self.ServiceManagerContents) - self.mainWindow.addDockWidget( + MainWindow.addDockWidget( QtCore.Qt.DockWidgetArea(2), self.ServiceManagerDock) # Create the theme manager - self.ThemeManagerDock = QtGui.QDockWidget(self.mainWindow) + self.ThemeManagerDock = QtGui.QDockWidget(MainWindow) ThemeManagerIcon = QtGui.QIcon() ThemeManagerIcon.addPixmap( QtGui.QPixmap(u':/system/system_thememanager.png'), @@ -298,97 +143,97 @@ class MainWindow(object): self.ThemeManagerDock.setObjectName(u'ThemeManagerDock') self.ThemeManagerContents = ThemeManager(self) self.ThemeManagerDock.setWidget(self.ThemeManagerContents) - self.mainWindow.addDockWidget( + MainWindow.addDockWidget( QtCore.Qt.DockWidgetArea(2), self.ThemeManagerDock) # Create the menu items - self.FileNewItem = QtGui.QAction(self.mainWindow) + self.FileNewItem = QtGui.QAction(MainWindow) self.FileNewItem.setIcon( self.ServiceManagerContents.Toolbar.getIconFromTitle(u'New Service')) self.FileNewItem.setObjectName(u'FileNewItem') - self.FileOpenItem = QtGui.QAction(self.mainWindow) + self.FileOpenItem = QtGui.QAction(MainWindow) self.FileOpenItem.setIcon( self.ServiceManagerContents.Toolbar.getIconFromTitle(u'Open Service')) self.FileOpenItem.setObjectName(u'FileOpenItem') - self.FileSaveItem = QtGui.QAction(self.mainWindow) + self.FileSaveItem = QtGui.QAction(MainWindow) self.FileSaveItem.setIcon( self.ServiceManagerContents.Toolbar.getIconFromTitle(u'Save Service')) self.FileSaveItem.setObjectName(u'FileSaveItem') - self.FileSaveAsItem = QtGui.QAction(self.mainWindow) + self.FileSaveAsItem = QtGui.QAction(MainWindow) self.FileSaveAsItem.setObjectName(u'FileSaveAsItem') - self.FileExitItem = QtGui.QAction(self.mainWindow) + self.FileExitItem = QtGui.QAction(MainWindow) ExitIcon = QtGui.QIcon() ExitIcon.addPixmap(QtGui.QPixmap(u':/system/system_exit.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.FileExitItem.setIcon(ExitIcon) self.FileExitItem.setObjectName(u'FileExitItem') - self.ImportThemeItem = QtGui.QAction(self.mainWindow) + self.ImportThemeItem = QtGui.QAction(MainWindow) self.ImportThemeItem.setObjectName(u'ImportThemeItem') - self.ImportLanguageItem = QtGui.QAction(self.mainWindow) + self.ImportLanguageItem = QtGui.QAction(MainWindow) self.ImportLanguageItem.setObjectName(u'ImportLanguageItem') - self.ExportThemeItem = QtGui.QAction(self.mainWindow) + self.ExportThemeItem = QtGui.QAction(MainWindow) self.ExportThemeItem.setObjectName(u'ExportThemeItem') - self.ExportLanguageItem = QtGui.QAction(self.mainWindow) + self.ExportLanguageItem = QtGui.QAction(MainWindow) self.ExportLanguageItem.setObjectName(u'ExportLanguageItem') - self.actionLook_Feel = QtGui.QAction(self.mainWindow) + self.actionLook_Feel = QtGui.QAction(MainWindow) self.actionLook_Feel.setObjectName(u'actionLook_Feel') - self.OptionsSettingsItem = QtGui.QAction(self.mainWindow) + self.OptionsSettingsItem = QtGui.QAction(MainWindow) SettingsIcon = QtGui.QIcon() SettingsIcon.addPixmap(QtGui.QPixmap(u':/system/system_settings.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.OptionsSettingsItem.setIcon(SettingsIcon) self.OptionsSettingsItem.setObjectName(u'OptionsSettingsItem') - self.ViewMediaManagerItem = QtGui.QAction(self.mainWindow) + self.ViewMediaManagerItem = QtGui.QAction(MainWindow) self.ViewMediaManagerItem.setCheckable(True) self.ViewMediaManagerItem.setChecked(True) self.ViewMediaManagerItem.setIcon(icon) self.ViewMediaManagerItem.setObjectName(u'ViewMediaManagerItem') - self.ViewThemeManagerItem = QtGui.QAction(self.mainWindow) + self.ViewThemeManagerItem = QtGui.QAction(MainWindow) self.ViewThemeManagerItem.setCheckable(True) self.ViewThemeManagerItem.setChecked(True) self.ViewThemeManagerItem.setIcon(ThemeManagerIcon) self.ViewThemeManagerItem.setObjectName(u'ViewThemeManagerItem') - self.ViewServiceManagerItem = QtGui.QAction(self.mainWindow) + self.ViewServiceManagerItem = QtGui.QAction(MainWindow) self.ViewServiceManagerItem.setCheckable(True) self.ViewServiceManagerItem.setChecked(True) self.ViewServiceManagerItem.setIcon(ServiceManagerIcon) self.ViewServiceManagerItem.setObjectName(u'ViewServiceManagerItem') - self.ToolsAlertItem = QtGui.QAction(self.mainWindow) + self.ToolsAlertItem = QtGui.QAction(MainWindow) AlertIcon = QtGui.QIcon() AlertIcon.addPixmap(QtGui.QPixmap(u':/tools/tools_alert.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.ToolsAlertItem.setIcon(AlertIcon) self.ToolsAlertItem.setObjectName(u'ToolsAlertItem') - self.HelpDocumentationItem = QtGui.QAction(self.mainWindow) + self.HelpDocumentationItem = QtGui.QAction(MainWindow) ContentsIcon = QtGui.QIcon() ContentsIcon.addPixmap(QtGui.QPixmap(u':/system/system_help_contents.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.HelpDocumentationItem.setIcon(ContentsIcon) self.HelpDocumentationItem.setObjectName(u'HelpDocumentationItem') - self.HelpAboutItem = QtGui.QAction(self.mainWindow) + self.HelpAboutItem = QtGui.QAction(MainWindow) AboutIcon = QtGui.QIcon() AboutIcon.addPixmap(QtGui.QPixmap(u':/system/system_about.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.HelpAboutItem.setIcon(AboutIcon) self.HelpAboutItem.setObjectName(u'HelpAboutItem') - self.HelpOnlineHelpItem = QtGui.QAction(self.mainWindow) + self.HelpOnlineHelpItem = QtGui.QAction(MainWindow) self.HelpOnlineHelpItem.setObjectName(u'HelpOnlineHelpItem') - self.HelpWebSiteItem = QtGui.QAction(self.mainWindow) + self.HelpWebSiteItem = QtGui.QAction(MainWindow) self.HelpWebSiteItem.setObjectName(u'HelpWebSiteItem') - self.LanguageTranslateItem = QtGui.QAction(self.mainWindow) + self.LanguageTranslateItem = QtGui.QAction(MainWindow) self.LanguageTranslateItem.setObjectName(u'LanguageTranslateItem') - self.LanguageEnglishItem = QtGui.QAction(self.mainWindow) + self.LanguageEnglishItem = QtGui.QAction(MainWindow) self.LanguageEnglishItem.setObjectName(u'LanguageEnglishItem') - self.ToolsAddToolItem = QtGui.QAction(self.mainWindow) + self.ToolsAddToolItem = QtGui.QAction(MainWindow) AddToolIcon = QtGui.QIcon() AddToolIcon.addPixmap(QtGui.QPixmap(u':/tools/tools_add.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.ToolsAddToolItem.setIcon(AddToolIcon) self.ToolsAddToolItem.setObjectName(u'ToolsAddToolItem') - self.action_Preview_Panel = QtGui.QAction(self.mainWindow) + self.action_Preview_Panel = QtGui.QAction(MainWindow) self.action_Preview_Panel.setCheckable(True) self.action_Preview_Panel.setChecked(True) self.action_Preview_Panel.setObjectName(u'action_Preview_Panel') - self.ModeLiveItem = QtGui.QAction(self.mainWindow) + self.ModeLiveItem = QtGui.QAction(MainWindow) self.ModeLiveItem.setObjectName(u'ModeLiveItem') self.FileImportMenu.addAction(self.ImportThemeItem) self.FileImportMenu.addAction(self.ImportLanguageItem) @@ -431,43 +276,20 @@ class MainWindow(object): self.MenuBar.addAction(self.ToolsMenu.menuAction()) self.MenuBar.addAction(self.HelpMenu.menuAction()) # Initialise the translation - self.retranslateUi() + self.retranslateUi(MainWindow) self.MediaToolBox.setCurrentIndex(0) # Connect up some signals and slots QtCore.QObject.connect(self.FileExitItem, - QtCore.SIGNAL(u'triggered()'), self.mainWindow.close) - QtCore.QObject.connect(self.ImportThemeItem, - QtCore.SIGNAL(u'triggered()'), self.ThemeManagerContents.onImportTheme) - QtCore.QObject.connect(self.ExportThemeItem, - QtCore.SIGNAL(u'triggered()'), self.ThemeManagerContents.onExportTheme) - QtCore.QObject.connect(self.ViewMediaManagerItem, - QtCore.SIGNAL(u'triggered(bool)'), self.MediaManagerDock.setVisible) - QtCore.QObject.connect(self.ViewServiceManagerItem, - QtCore.SIGNAL(u'triggered(bool)'), self.ServiceManagerDock.setVisible) - QtCore.QObject.connect(self.ViewThemeManagerItem, - QtCore.SIGNAL(u'triggered(bool)'), self.ThemeManagerDock.setVisible) - QtCore.QObject.connect(self.action_Preview_Panel, - QtCore.SIGNAL(u'toggled(bool)'), self.PreviewController.Panel.setVisible) - QtCore.QObject.connect(self.MediaManagerDock, - QtCore.SIGNAL(u'visibilityChanged(bool)'), self.ViewMediaManagerItem.setChecked) - QtCore.QObject.connect(self.ServiceManagerDock, - QtCore.SIGNAL(u'visibilityChanged(bool)'), self.ViewServiceManagerItem.setChecked) - QtCore.QObject.connect(self.ThemeManagerDock, - QtCore.SIGNAL(u'visibilityChanged(bool)'), self.ViewThemeManagerItem.setChecked) - QtCore.QObject.connect(self.HelpAboutItem, - QtCore.SIGNAL(u'triggered()'), self.onHelpAboutItemClicked) - QtCore.QObject.connect(self.ToolsAlertItem, - QtCore.SIGNAL(u'triggered()'), self.onToolsAlertItemClicked) - QtCore.QObject.connect(self.OptionsSettingsItem, - QtCore.SIGNAL(u'triggered()'), self.onOptionsSettingsItemClicked) - QtCore.QMetaObject.connectSlotsByName(self.mainWindow) + QtCore.SIGNAL(u'triggered()'), MainWindow.close) + QtCore.QMetaObject.connectSlotsByName(MainWindow) - def retranslateUi(self): + def retranslateUi(self, MainWindow): """ Set up the translation system """ - self.mainTitle = translate(u'mainWindow', u'OpenLP 2.0') - self.mainWindow.setWindowTitle(self.mainTitle) + MainWindow.mainTitle = translate(u'mainWindow', u'OpenLP 2.0') + MainWindow.defaultThemeText = translate(u'mainWindow', 'Default Theme: ') + MainWindow.setWindowTitle(MainWindow.mainTitle) self.FileMenu.setTitle(translate(u'mainWindow', u'&File')) self.FileImportMenu.setTitle(translate(u'mainWindow', u'&Import')) self.FileExportMenu.setTitle(translate(u'mainWindow', u'&Export')) @@ -483,6 +305,8 @@ class MainWindow(object): translate(u'mainWindow', u'Service Manager')) self.ThemeManagerDock.setWindowTitle( translate(u'mainWindow', u'Theme Manager')) + self.DefaultThemeLabel.setText(MainWindow.defaultThemeText + \ + self.ThemeManagerContents.getDefault()) self.FileNewItem.setText(translate(u'mainWindow', u'&New')) self.FileNewItem.setToolTip(translate(u'mainWindow', u'New Service')) self.FileNewItem.setStatusTip( @@ -560,3 +384,198 @@ class MainWindow(object): self.action_Preview_Panel.setText( translate(u'mainWindow', u'&Preview Pane')) self.ModeLiveItem.setText(translate(u'mainWindow', u'&Live')) + + +class MainWindow(QtGui.QMainWindow, Ui_MainWindow): + """ + The main window. + """ + global log + log = logging.getLogger(u'MainWindow') + log.info(u'MainWindow loaded') + + def __init__(self, screens): + """ + This constructor sets up the interface, the various managers, and the + plugins. + """ + QtGui.QMainWindow.__init__(self) + self.closeEvent = self.onCloseEvent + self.screenList = screens + self.oosNotSaved = False + self.settingsmanager = SettingsManager(screens) + self.mainDisplay = MainDisplay(None, screens) + self.EventManager = EventManager() + self.generalConfig = PluginConfig(u'General') + self.alertForm = AlertForm(self) + self.aboutForm = AboutForm() + self.settingsForm = SettingsForm(self.screenList, self) + # Set up the path with plugins + pluginpath = os.path.split(os.path.abspath(__file__))[0] + pluginpath = os.path.abspath( + os.path.join(pluginpath, u'..', u'..', u'plugins')) + self.plugin_manager = PluginManager(pluginpath) + self.plugin_helpers = {} + # Set up the interface + self.setupUi(self) + # Set up signals and slots + QtCore.QObject.connect(self.ImportThemeItem, + QtCore.SIGNAL(u'triggered()'), self.ThemeManagerContents.onImportTheme) + QtCore.QObject.connect(self.ExportThemeItem, + QtCore.SIGNAL(u'triggered()'), self.ThemeManagerContents.onExportTheme) + QtCore.QObject.connect(self.ViewMediaManagerItem, + QtCore.SIGNAL(u'triggered(bool)'), self.MediaManagerDock.setVisible) + QtCore.QObject.connect(self.ViewServiceManagerItem, + QtCore.SIGNAL(u'triggered(bool)'), self.ServiceManagerDock.setVisible) + QtCore.QObject.connect(self.ViewThemeManagerItem, + QtCore.SIGNAL(u'triggered(bool)'), self.ThemeManagerDock.setVisible) + QtCore.QObject.connect(self.action_Preview_Panel, + QtCore.SIGNAL(u'toggled(bool)'), self.PreviewController.Panel.setVisible) + QtCore.QObject.connect(self.MediaManagerDock, + QtCore.SIGNAL(u'visibilityChanged(bool)'), self.ViewMediaManagerItem.setChecked) + QtCore.QObject.connect(self.ServiceManagerDock, + QtCore.SIGNAL(u'visibilityChanged(bool)'), self.ViewServiceManagerItem.setChecked) + QtCore.QObject.connect(self.ThemeManagerDock, + QtCore.SIGNAL(u'visibilityChanged(bool)'), self.ViewThemeManagerItem.setChecked) + QtCore.QObject.connect(self.HelpAboutItem, + QtCore.SIGNAL(u'triggered()'), self.onHelpAboutItemClicked) + QtCore.QObject.connect(self.ToolsAlertItem, + QtCore.SIGNAL(u'triggered()'), self.onToolsAlertItemClicked) + QtCore.QObject.connect(self.OptionsSettingsItem, + QtCore.SIGNAL(u'triggered()'), self.onOptionsSettingsItemClicked) + #warning cyclic dependency + #RenderManager needs to call ThemeManager and + #ThemeManager needs to call RenderManager + self.RenderManager = RenderManager(self.ThemeManagerContents, + self.screenList, self.getMonitorNumber()) + log.info(u'Load Plugins') + #make the controllers available to the plugins + self.plugin_helpers[u'preview'] = self.PreviewController + self.plugin_helpers[u'live'] = self.LiveController + self.plugin_helpers[u'event'] = self.EventManager + self.plugin_helpers[u'theme'] = self.ThemeManagerContents + self.plugin_helpers[u'render'] = self.RenderManager + self.plugin_helpers[u'service'] = self.ServiceManagerContents + self.plugin_helpers[u'settings'] = self.settingsForm + self.plugin_manager.find_plugins(pluginpath, self.plugin_helpers, + self.EventManager) + # hook methods have to happen after find_plugins. Find plugins needs the + # controllers hence the hooks have moved from setupUI() to here + + # Find and insert settings tabs + log.info(u'hook settings') + self.plugin_manager.hook_settings_tabs(self.settingsForm) + # Find and insert media manager items + log.info(u'hook media') + self.plugin_manager.hook_media_manager(self.MediaToolBox) + # Call the hook method to pull in import menus. + log.info(u'hook menus') + self.plugin_manager.hook_import_menu(self.FileImportMenu) + # Call the hook method to pull in export menus. + self.plugin_manager.hook_export_menu(self.FileExportMenu) + # Call the initialise method to setup plugins. + log.info(u'initialise plugins') + self.plugin_manager.initialise_plugins() + # Once all components are initialised load the Themes + log.info(u'Load Themes') + self.ThemeManagerContents.loadThemes() + # Register the main form as an event consumer. + self.EventManager.register(self) + + def getMonitorNumber(self): + """ + Set up the default behaviour of the monitor configuration in + here. Currently it is set to default to monitor 0 if the saved + monitor number does not exist. + """ + screen_number = int(self.generalConfig.get_config(u'Monitor', 0)) + if screen_number not in self.screenList: + screen_number = 0 + return screen_number + + def show(self): + """ + Show the main form, as well as the display form + """ + self.showMaximized() + screen_number = self.getMonitorNumber() + self.mainDisplay.setup(screen_number) + self.setFocus() + + def onHelpAboutItemClicked(self): + """ + Show the About form + """ + self.aboutForm.exec_() + + def onToolsAlertItemClicked(self): + """ + Show the Alert form + """ + self.alertForm.exec_() + + def onOptionsSettingsItemClicked(self): + """ + Show the Settings dialog + """ + self.settingsForm.exec_() + screen_number = self.getMonitorNumber() + self.RenderManager.update_display(screen_number) + self.mainDisplay.setup(screen_number) + + def onCloseEvent(self, event): + """ + Hook to close the main window and display windows on exit + """ + if self.oosNotSaved == True: + ret = QtGui.QMessageBox.question(None, + translate(u'mainWindow', u'Save Changes to Service?'), + translate(u'mainWindow', u'Your service has been changed, do you want to save those changes?'), + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Cancel | QtGui.QMessageBox.Discard | QtGui.QMessageBox.Save), + QtGui.QMessageBox.Save) + if ret == QtGui.QMessageBox.Save: + self.ServiceManagerContents.onSaveService() + self.mainDisplay.close() + self.cleanUp() + event.accept() + elif ret == QtGui.QMessageBox.Discard: + self.mainDisplay.close() + self.cleanUp() + event.accept() + else: + event.ignore() + else: + self.mainDisplay.close() + self.cleanUp() + event.accept() + + def cleanUp(self): + # Call the cleanup method to shutdown plugins. + log.info(u'cleanup plugins') + self.plugin_manager.initialise_plugins() + + def OosChanged(self, reset=False, oosName=None): + """ + Hook to change the title if the OOS has been changed + reset - tells if the OOS has been cleared or saved + oosName - is the name of the OOS (if it has one) + """ + if not oosName: + service_name = u'(unsaved service)' + else: + service_name = oosName + if reset == True: + self.oosNotSaved = False + title = u'%s - %s' % (self.mainTitle, service_name) + else: + self.oosNotSaved = True + title = u'%s - %s*' % (self.mainTitle, service_name) + self.setWindowTitle(title) + + def handle_event(self, event): + if event.event_type == EventType.ThemeListChanged: + themes = self.ThemeManagerContents.getThemes() + self.ServiceManagerContents.updateThemeList(themes) + self.settingsForm.ThemesTab.updateThemeList(themes) + self.DefaultThemeLabel.setText(self.defaultThemeText + \ + self.ThemeManagerContents.getDefault()) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index e19d364f4..9f8f03959 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -161,7 +161,7 @@ class ServiceManager(QtGui.QWidget): # Last little bits of setting up self.config = PluginConfig(u'ServiceManager') self.servicePath = self.config.get_data_path() - self.service_theme = self.config.get_config(u'theme service theme', u'') + self.service_theme = unicode(self.config.get_config(u'theme service theme', u'')) def onMoveSelectionUp(self): """ @@ -412,7 +412,11 @@ class ServiceManager(QtGui.QWidget): def addServiceItem(self, item): """ - Add an item to the list + Add a Service item to the list + + ``item`` + Service Item to be added + """ self.serviceItems.append({u'data': item, u'order': len(self.serviceItems)+1, u'expanded':True}) treewidgetitem = QtGui.QTreeWidgetItem(self.ServiceManagerList) @@ -465,13 +469,21 @@ class ServiceManager(QtGui.QWidget): def dragEnterEvent(self, event): """ Accept Drag events + + ``event`` + Handle of the event pint passed + """ event.accept() def dropEvent(self, event): """ - Handle the release of the event and trigger the plugin - to add the data + Receive drop event and trigger an internal event to get the + plugins to build and push the correct service item + The drag event payload carries the plugin name + + ``event`` + Handle of the event pint passed """ link = event.mimeData() if link.hasText(): @@ -481,12 +493,16 @@ class ServiceManager(QtGui.QWidget): def updateThemeList(self, theme_list): """ Called from ThemeManager when the Themes have changed + + ``theme_list`` + A list of current themes to be displayed + """ self.ThemeComboBox.clear() self.ThemeComboBox.addItem(u'') for theme in theme_list: self.ThemeComboBox.addItem(theme) - id = self.ThemeComboBox.findText(unicode(self.service_theme), QtCore.Qt.MatchExactly) + id = self.ThemeComboBox.findText(self.service_theme, QtCore.Qt.MatchExactly) # Not Found if id == -1: id = 0 diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index f14a2fabc..5b7e669c4 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -28,7 +28,9 @@ from PyQt4 import QtCore, QtGui from openlp.core.ui import AmendThemeForm, ServiceManager from openlp.core.theme import Theme -from openlp.core.lib import Event, EventType, EventManager, OpenLPToolbar, ThemeXML, Renderer, translate, file_to_xml, buildIcon +from openlp.core.lib import PluginConfig, Event, EventType, \ + EventManager, OpenLPToolbar, ThemeXML, Renderer, translate, \ + file_to_xml, buildIcon from openlp.core.utils import ConfigHelper class ThemeManager(QtGui.QWidget): @@ -39,7 +41,7 @@ class ThemeManager(QtGui.QWidget): log = logging.getLogger(u'ThemeManager') def __init__(self, parent): - QtGui.QWidget.__init__(self) + QtGui.QWidget.__init__(self, parent) self.parent = parent self.Layout = QtGui.QVBoxLayout(self) self.Layout.setSpacing(0) @@ -68,10 +70,36 @@ class ThemeManager(QtGui.QWidget): self.ThemeListWidget.setAlternatingRowColors(True) self.ThemeListWidget.setIconSize(QtCore.QSize(88,50)) self.Layout.addWidget(self.ThemeListWidget) + #Signals + QtCore.QObject.connect(self.ThemeListWidget, + QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.changeGlobal) + #Variables self.themelist = [] self.path = os.path.join(ConfigHelper.get_data_path(), u'themes') self.checkThemesExists(self.path) self.amendThemeForm.path = self.path + # Last little bits of setting up + self.config = PluginConfig(u'themes') + self.servicePath = self.config.get_data_path() + self.global_theme = unicode(self.config.get_config(u'theme global theme', u'')) + + def getDefault(self): + return self.global_theme + + def changeGlobal(self, index): + for count in range (0, self.ThemeListWidget.count()): + item = self.ThemeListWidget.item(count) + oldName = item.text() + #reset the old name + if oldName != unicode(item.data(QtCore.Qt.UserRole).toString()): + self.ThemeListWidget.item(count).setText(unicode(item.data(QtCore.Qt.UserRole).toString())) + #Set the new name + if count == index.row(): + self.global_theme = unicode(self.ThemeListWidget.item(count).text()) + name = u'%s (%s)' % (self.global_theme, translate(u'ThemeManager', u'default')) + self.ThemeListWidget.item(count).setText(name) + self.config.set_config(u'theme global theme', self.global_theme) + self.pushThemes() def onAddTheme(self): self.amendThemeForm.loadTheme(None) @@ -80,30 +108,38 @@ class ThemeManager(QtGui.QWidget): def onEditTheme(self): item = self.ThemeListWidget.currentItem() if item is not None: - self.amendThemeForm.loadTheme(unicode(item.text())) + self.amendThemeForm.loadTheme(unicode(item.data(QtCore.Qt.UserRole).toString())) self.amendThemeForm.exec_() def onDeleteTheme(self): + self.global_theme = unicode(self.config.get_config(u'theme global theme', u'')) item = self.ThemeListWidget.currentItem() if item is not None: theme = unicode(item.text()) - th = theme + u'.png' - row = self.ThemeListWidget.row(item) - self.ThemeListWidget.takeItem(row) - try: - os.remove(os.path.join(self.path, th)) - except: - #if not present do not worry - pass - try: - shutil.rmtree(os.path.join(self.path, theme)) - except: - #if not present do not worry - pass - #As we do not reload the themes push out the change - self.parent.EventManager.post_event(Event(EventType.ThemeListChanged)) - self.parent.ServiceManagerContents.updateThemeList(self.getThemes()) - self.parent.settingsForm.ThemesTab.updateThemeList(self.getThemes()) + # should be the same unless default + if theme != unicode(item.data(QtCore.Qt.UserRole).toString()): + QtGui.QMessageBox.critical(self, + translate(u'ThemeManager', u'Error'), + translate(u'ThemeManager', u'You are unable to delete the default theme!'), + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok)) + else: + self.themelist.remove(theme) + th = theme + u'.png' + row = self.ThemeListWidget.row(item) + self.ThemeListWidget.takeItem(row) + try: + os.remove(os.path.join(self.path, th)) + except: + #if not present do not worry + pass + try: + shutil.rmtree(os.path.join(self.path, theme)) + except: + #if not present do not worry + pass + #As we do not reload the themes push out the change + #Reaload the list as the internal lists and events need to be triggered + self.pushThemes() def onExportTheme(self): pass @@ -136,14 +172,19 @@ class ThemeManager(QtGui.QWidget): if os.path.exists(theme): (path, filename) = os.path.split(unicode(file)) textName = os.path.splitext(name)[0] - item_name = QtGui.QListWidgetItem(textName) + if textName == self.global_theme: + name = u'%s (%s)' % (textName, translate(u'ThemeManager', u'default')) + else: + name = textName + item_name = QtGui.QListWidgetItem(name) item_name.setIcon(buildIcon(theme)) item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(textName)) self.ThemeListWidget.addItem(item_name) self.themelist.append(textName) + self.pushThemes() + + def pushThemes(self): self.parent.EventManager.post_event(Event(EventType.ThemeListChanged)) - self.parent.ServiceManagerContents.updateThemeList(self.getThemes()) - self.parent.settingsForm.ThemesTab.updateThemeList(self.getThemes()) def getThemes(self): return self.themelist @@ -153,6 +194,7 @@ class ThemeManager(QtGui.QWidget): xml_file = os.path.join(self.path, unicode(themename), unicode(themename) + u'.xml') try: xml = file_to_xml(xml_file) + #print xml except: newtheme = ThemeXML() newtheme.new_document(u'New Theme') @@ -163,7 +205,9 @@ class ThemeManager(QtGui.QWidget): unicode(0), unicode(0), unicode(0)) xml = newtheme.extract_xml() theme = ThemeXML() + #print theme theme.parse(xml) + #print "A ", theme theme.extend_image_filename(self.path) return theme @@ -211,6 +255,9 @@ class ThemeManager(QtGui.QWidget): self.generateAndSaveImage(dir, themename, filexml) def checkVersion1(self, xmlfile): + """ + Am I a version 1 theme + """ log.debug(u'checkVersion1 ') theme = xmlfile tree = ElementTree(element=XML(theme)).getroot() @@ -220,6 +267,11 @@ class ThemeManager(QtGui.QWidget): return True def migrateVersion122(self, filename, fullpath, xml_data): + """ + Called by convert the xml data from version 1 format + to the current format. + New fields are defaulted but the new theme is useable + """ log.debug(u'migrateVersion122 %s %s', filename, fullpath) theme = Theme(xml_data) newtheme = ThemeXML() diff --git a/openlp/core/ui/themestab.py b/openlp/core/ui/themestab.py index 622a0ba4b..7b18a9917 100644 --- a/openlp/core/ui/themestab.py +++ b/openlp/core/ui/themestab.py @@ -99,8 +99,6 @@ class ThemesTab(SettingsTab): QtCore.QObject.connect(self.DefaultComboBox, QtCore.SIGNAL(u'activated(int)'), self.onDefaultComboBoxChanged) - #self.DefaultListView.setScaledContents(True) - def retranslateUi(self): self.GlobalGroupBox.setTitle(translate(u'ThemesTab', u'Global theme')) self.LevelGroupBox.setTitle(translate(u'ThemesTab', u'Theme level')) @@ -138,9 +136,9 @@ class ThemesTab(SettingsTab): self.parent.RenderManager.set_global_theme(self.global_theme, self.global_style) def onDefaultComboBoxChanged(self, value): - self.global_theme = self.DefaultComboBox.currentText() + self.global_theme = unicode(self.DefaultComboBox.currentText()) self.parent.RenderManager.set_global_theme(self.global_theme, self.global_style) - image = self.parent.ThemeManagerContents.getPreviewImage(unicode(self.global_theme)) + image = self.parent.ThemeManagerContents.getPreviewImage(self.global_theme) preview = QtGui.QPixmap(unicode(image)) display = preview.scaled(300, 255, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation) self.DefaultListView.setPixmap(display) @@ -149,17 +147,19 @@ class ThemesTab(SettingsTab): """ Called from ThemeManager when the Themes have changed """ + #reload as may have been triggered by the ThemeManager + self.global_theme = self.config.get_config(u'theme global theme', u'') self.DefaultComboBox.clear() for theme in theme_list: self.DefaultComboBox.addItem(theme) - id = self.DefaultComboBox.findText(unicode(self.global_theme), QtCore.Qt.MatchExactly) + id = self.DefaultComboBox.findText(self.global_theme, QtCore.Qt.MatchExactly) if id == -1: id = 0 # Not Found self.global_theme = u'' self.DefaultComboBox.setCurrentIndex(id) self.parent.RenderManager.set_global_theme(self.global_theme, self.global_style) if self.global_theme is not u'': - image = self.parent.ThemeManagerContents.getPreviewImage(unicode(self.global_theme)) + image = self.parent.ThemeManagerContents.getPreviewImage(self.global_theme) preview = QtGui.QPixmap(unicode(image)) display = preview.scaled(300, 255, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation) - self.DefaultListView.setPixmap(display) \ No newline at end of file + self.DefaultListView.setPixmap(display) diff --git a/openlp/plugins/bibles/forms/bibleimportdialog.py b/openlp/plugins/bibles/forms/bibleimportdialog.py index 591178acd..8a8ec16a3 100644 --- a/openlp/plugins/bibles/forms/bibleimportdialog.py +++ b/openlp/plugins/bibles/forms/bibleimportdialog.py @@ -2,140 +2,22 @@ # Form implementation generated from reading ui file 'bibleimportdialog.ui' # -# Created: Fri Feb 20 05:45:22 2009 +# Created: Fri Aug 7 06:07:06 2009 # by: PyQt4 UI code generator 4.4.4 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui -from openlp.core.lib import translate class Ui_BibleImportDialog(object): def setupUi(self, BibleImportDialog): BibleImportDialog.setObjectName(u'BibleImportDialog') - BibleImportDialog.resize(494, 725) + BibleImportDialog.resize(500, 686) icon = QtGui.QIcon() - icon.addPixmap(QtGui.QPixmap(u':/icon/openlp-logo-16x16.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off) + icon.addPixmap(QtGui.QPixmap(u':/icon/openlp.org-icon-32.bmp'), QtGui.QIcon.Normal, QtGui.QIcon.Off) BibleImportDialog.setWindowIcon(icon) - self.ImportToolBox = QtGui.QToolBox(BibleImportDialog) - self.ImportToolBox.setGeometry(QtCore.QRect(20, 20, 451, 401)) - self.ImportToolBox.setFrameShape(QtGui.QFrame.StyledPanel) - self.ImportToolBox.setObjectName(u'ImportToolBox') - self.FileImportPage = QtGui.QWidget() - self.FileImportPage.setGeometry(QtCore.QRect(0, 0, 447, 337)) - self.FileImportPage.setObjectName(u'FileImportPage') - self.OSISGroupBox = QtGui.QGroupBox(self.FileImportPage) - self.OSISGroupBox.setGeometry(QtCore.QRect(18, 65, 411, 81)) - self.OSISGroupBox.setObjectName(u'OSISGroupBox') - self.gridLayout_2 = QtGui.QGridLayout(self.OSISGroupBox) - self.gridLayout_2.setMargin(8) - self.gridLayout_2.setSpacing(8) - self.gridLayout_2.setObjectName(u'gridLayout_2') - self.LocatioLabel = QtGui.QLabel(self.OSISGroupBox) - self.LocatioLabel.setObjectName(u'LocatioLabel') - self.gridLayout_2.addWidget(self.LocatioLabel, 0, 0, 1, 1) - self.OSISLocationEdit = QtGui.QLineEdit(self.OSISGroupBox) - self.OSISLocationEdit.setObjectName(u'OSISLocationEdit') - self.gridLayout_2.addWidget(self.OSISLocationEdit, 0, 1, 1, 1) - self.OsisFileButton = QtGui.QPushButton(self.OSISGroupBox) - icon1 = QtGui.QIcon() - icon1.addPixmap(QtGui.QPixmap(u':/imports/import_load.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.OsisFileButton.setIcon(icon1) - self.OsisFileButton.setObjectName(u'OsisFileButton') - self.gridLayout_2.addWidget(self.OsisFileButton, 0, 2, 1, 1) - self.CVSGroupBox = QtGui.QGroupBox(self.FileImportPage) - self.CVSGroupBox.setGeometry(QtCore.QRect(20, 170, 411, 191)) - self.CVSGroupBox.setObjectName(u'CVSGroupBox') - self.gridLayout = QtGui.QGridLayout(self.CVSGroupBox) - self.gridLayout.setMargin(8) - self.gridLayout.setSpacing(8) - self.gridLayout.setObjectName(u'gridLayout') - self.BooksLocationLabel = QtGui.QLabel(self.CVSGroupBox) - self.BooksLocationLabel.setObjectName(u'BooksLocationLabel') - self.gridLayout.addWidget(self.BooksLocationLabel, 0, 0, 1, 1) - self.VerseLocationLabel = QtGui.QLabel(self.CVSGroupBox) - self.VerseLocationLabel.setObjectName(u'VerseLocationLabel') - self.gridLayout.addWidget(self.VerseLocationLabel, 4, 0, 1, 1) - self.VerseLocationEdit = QtGui.QLineEdit(self.CVSGroupBox) - self.VerseLocationEdit.setObjectName(u'VerseLocationEdit') - self.gridLayout.addWidget(self.VerseLocationEdit, 4, 1, 1, 1) - self.BooksLocationEdit = QtGui.QLineEdit(self.CVSGroupBox) - self.BooksLocationEdit.setObjectName(u'BooksLocationEdit') - self.gridLayout.addWidget(self.BooksLocationEdit, 0, 1, 1, 1) - self.BooksFileButton = QtGui.QPushButton(self.CVSGroupBox) - self.BooksFileButton.setIcon(icon1) - self.BooksFileButton.setObjectName(u'BooksFileButton') - self.gridLayout.addWidget(self.BooksFileButton, 0, 2, 1, 1) - self.VersesFileButton = QtGui.QPushButton(self.CVSGroupBox) - self.VersesFileButton.setIcon(icon1) - self.VersesFileButton.setObjectName(u'VersesFileButton') - self.gridLayout.addWidget(self.VersesFileButton, 4, 2, 1, 1) - self.BibleNameEdit = QtGui.QLineEdit(self.FileImportPage) - self.BibleNameEdit.setGeometry(QtCore.QRect(100, 20, 280, 28)) - self.BibleNameEdit.setObjectName(u'BibleNameEdit') - self.BibleNameLabel = QtGui.QLabel(self.FileImportPage) - self.BibleNameLabel.setGeometry(QtCore.QRect(18, 20, 98, 22)) - self.BibleNameLabel.setObjectName(u'BibleNameLabel') - self.ImportToolBox.addItem(self.FileImportPage, u'') - self.WebBiblePage = QtGui.QWidget() - self.WebBiblePage.setGeometry(QtCore.QRect(0, 0, 447, 337)) - self.WebBiblePage.setObjectName(u'WebBiblePage') - self.WebBibleLayout = QtGui.QVBoxLayout(self.WebBiblePage) - self.WebBibleLayout.setSpacing(8) - self.WebBibleLayout.setMargin(8) - self.WebBibleLayout.setObjectName(u'WebBibleLayout') - self.OptionsGroupBox = QtGui.QGroupBox(self.WebBiblePage) - self.OptionsGroupBox.setObjectName(u'OptionsGroupBox') - self.formLayout_2 = QtGui.QFormLayout(self.OptionsGroupBox) - self.formLayout_2.setObjectName(u'formLayout_2') - self.LocationLabel = QtGui.QLabel(self.OptionsGroupBox) - self.LocationLabel.setObjectName(u'LocationLabel') - self.formLayout_2.setWidget(0, QtGui.QFormLayout.LabelRole, self.LocationLabel) - self.LocationComboBox = QtGui.QComboBox(self.OptionsGroupBox) - self.LocationComboBox.setObjectName(u'LocationComboBox') - self.LocationComboBox.addItem(QtCore.QString()) - self.formLayout_2.setWidget(0, QtGui.QFormLayout.FieldRole, self.LocationComboBox) - self.BibleLabel = QtGui.QLabel(self.OptionsGroupBox) - self.BibleLabel.setObjectName(u'BibleLabel') - self.formLayout_2.setWidget(1, QtGui.QFormLayout.LabelRole, self.BibleLabel) - self.BibleComboBox = QtGui.QComboBox(self.OptionsGroupBox) - self.BibleComboBox.setObjectName(u'BibleComboBox') - self.BibleComboBox.addItem(QtCore.QString()) - self.BibleComboBox.setItemText(0, u'') - self.BibleComboBox.addItem(QtCore.QString()) - self.BibleComboBox.addItem(QtCore.QString()) - self.formLayout_2.setWidget(1, QtGui.QFormLayout.FieldRole, self.BibleComboBox) - self.WebBibleLayout.addWidget(self.OptionsGroupBox) - self.ProxyGroupBox = QtGui.QGroupBox(self.WebBiblePage) - self.ProxyGroupBox.setObjectName(u'ProxyGroupBox') - self.ProxySettingsLayout = QtGui.QFormLayout(self.ProxyGroupBox) - self.ProxySettingsLayout.setFieldGrowthPolicy(QtGui.QFormLayout.AllNonFixedFieldsGrow) - self.ProxySettingsLayout.setMargin(8) - self.ProxySettingsLayout.setSpacing(8) - self.ProxySettingsLayout.setObjectName(u'ProxySettingsLayout') - self.AddressLabel = QtGui.QLabel(self.ProxyGroupBox) - self.AddressLabel.setObjectName(u'AddressLabel') - self.ProxySettingsLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.AddressLabel) - self.AddressEdit = QtGui.QLineEdit(self.ProxyGroupBox) - self.AddressEdit.setObjectName(u'AddressEdit') - self.ProxySettingsLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.AddressEdit) - self.UsernameLabel = QtGui.QLabel(self.ProxyGroupBox) - self.UsernameLabel.setObjectName(u'UsernameLabel') - self.ProxySettingsLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.UsernameLabel) - self.UsernameEdit = QtGui.QLineEdit(self.ProxyGroupBox) - self.UsernameEdit.setObjectName(u'UsernameEdit') - self.ProxySettingsLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.UsernameEdit) - self.PasswordLabel = QtGui.QLabel(self.ProxyGroupBox) - self.PasswordLabel.setObjectName(u'PasswordLabel') - self.ProxySettingsLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.PasswordLabel) - self.PasswordEdit = QtGui.QLineEdit(self.ProxyGroupBox) - self.PasswordEdit.setEchoMode(QtGui.QLineEdit.Password) - self.PasswordEdit.setObjectName(u'PasswordEdit') - self.ProxySettingsLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.PasswordEdit) - self.WebBibleLayout.addWidget(self.ProxyGroupBox) - self.ImportToolBox.addItem(self.WebBiblePage, u'') self.LicenceDetailsGroupBox = QtGui.QGroupBox(BibleImportDialog) - self.LicenceDetailsGroupBox.setGeometry(QtCore.QRect(10, 435, 471, 151)) + self.LicenceDetailsGroupBox.setGeometry(QtCore.QRect(10, 400, 480, 151)) self.LicenceDetailsGroupBox.setMinimumSize(QtCore.QSize(0, 123)) self.LicenceDetailsGroupBox.setObjectName(u'LicenceDetailsGroupBox') self.formLayout = QtGui.QFormLayout(self.LicenceDetailsGroupBox) @@ -164,7 +46,7 @@ class Ui_BibleImportDialog(object): self.MessageLabel.setGeometry(QtCore.QRect(20, 670, 271, 17)) self.MessageLabel.setObjectName(u'MessageLabel') self.ProgressGroupBox = QtGui.QGroupBox(BibleImportDialog) - self.ProgressGroupBox.setGeometry(QtCore.QRect(10, 600, 471, 70)) + self.ProgressGroupBox.setGeometry(QtCore.QRect(10, 550, 480, 70)) self.ProgressGroupBox.setObjectName(u'ProgressGroupBox') self.gridLayout_3 = QtGui.QGridLayout(self.ProgressGroupBox) self.gridLayout_3.setObjectName(u'gridLayout_3') @@ -174,7 +56,7 @@ class Ui_BibleImportDialog(object): self.ProgressBar.setObjectName(u'ProgressBar') self.gridLayout_3.addWidget(self.ProgressBar, 0, 0, 1, 1) self.layoutWidget = QtGui.QWidget(BibleImportDialog) - self.layoutWidget.setGeometry(QtCore.QRect(300, 680, 180, 38)) + self.layoutWidget.setGeometry(QtCore.QRect(310, 630, 180, 38)) self.layoutWidget.setObjectName(u'layoutWidget') self.horizontalLayout = QtGui.QHBoxLayout(self.layoutWidget) self.horizontalLayout.setMargin(6) @@ -185,10 +67,131 @@ class Ui_BibleImportDialog(object): self.CancelButton = QtGui.QPushButton(self.layoutWidget) self.CancelButton.setObjectName(u'CancelButton') self.horizontalLayout.addWidget(self.CancelButton) + self.tabWidget = QtGui.QTabWidget(BibleImportDialog) + self.tabWidget.setGeometry(QtCore.QRect(10, 30, 480, 361)) + self.tabWidget.setObjectName(u'tabWidget') + self.OsisTab = QtGui.QWidget() + self.OsisTab.setObjectName(u'OsisTab') + self.OSISGroupBox = QtGui.QGroupBox(self.OsisTab) + self.OSISGroupBox.setGeometry(QtCore.QRect(10, 10, 460, 141)) + self.OSISGroupBox.setObjectName(u'OSISGroupBox') + self.gridLayout_2 = QtGui.QGridLayout(self.OSISGroupBox) + self.gridLayout_2.setObjectName(u'gridLayout_2') + self.horizontalLayout_2 = QtGui.QHBoxLayout() + self.horizontalLayout_2.setObjectName(u'horizontalLayout_2') + self.BibleNameLabel = QtGui.QLabel(self.OSISGroupBox) + self.BibleNameLabel.setObjectName(u'BibleNameLabel') + self.horizontalLayout_2.addWidget(self.BibleNameLabel) + self.BibleNameEdit = QtGui.QLineEdit(self.OSISGroupBox) + self.BibleNameEdit.setObjectName(u'BibleNameEdit') + self.horizontalLayout_2.addWidget(self.BibleNameEdit) + self.gridLayout_2.addLayout(self.horizontalLayout_2, 0, 0, 1, 1) + self.horizontalLayout_3 = QtGui.QHBoxLayout() + self.horizontalLayout_3.setObjectName(u'horizontalLayout_3') + self.LocatioLabel = QtGui.QLabel(self.OSISGroupBox) + self.LocatioLabel.setObjectName(u'LocatioLabel') + self.horizontalLayout_3.addWidget(self.LocatioLabel) + self.OSISLocationEdit = QtGui.QLineEdit(self.OSISGroupBox) + self.OSISLocationEdit.setObjectName(u'OSISLocationEdit') + self.horizontalLayout_3.addWidget(self.OSISLocationEdit) + self.OsisFileButton = QtGui.QPushButton(self.OSISGroupBox) + icon1 = QtGui.QIcon() + icon1.addPixmap(QtGui.QPixmap(u':/imports/import_load.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.OsisFileButton.setIcon(icon1) + self.OsisFileButton.setObjectName(u'OsisFileButton') + self.horizontalLayout_3.addWidget(self.OsisFileButton) + self.gridLayout_2.addLayout(self.horizontalLayout_3, 1, 0, 1, 1) + self.tabWidget.addTab(self.OsisTab, u'') + self.CsvTab = QtGui.QWidget() + self.CsvTab.setObjectName(u'CsvTab') + self.CVSGroupBox = QtGui.QGroupBox(self.CsvTab) + self.CVSGroupBox.setGeometry(QtCore.QRect(10, 10, 460, 191)) + self.CVSGroupBox.setObjectName(u'CVSGroupBox') + self.gridLayout = QtGui.QGridLayout(self.CVSGroupBox) + self.gridLayout.setMargin(8) + self.gridLayout.setSpacing(8) + self.gridLayout.setObjectName(u'gridLayout') + self.BooksLocationLabel = QtGui.QLabel(self.CVSGroupBox) + self.BooksLocationLabel.setObjectName(u'BooksLocationLabel') + self.gridLayout.addWidget(self.BooksLocationLabel, 0, 0, 1, 1) + self.VerseLocationLabel = QtGui.QLabel(self.CVSGroupBox) + self.VerseLocationLabel.setObjectName(u'VerseLocationLabel') + self.gridLayout.addWidget(self.VerseLocationLabel, 4, 0, 1, 1) + self.VerseLocationEdit = QtGui.QLineEdit(self.CVSGroupBox) + self.VerseLocationEdit.setObjectName(u'VerseLocationEdit') + self.gridLayout.addWidget(self.VerseLocationEdit, 4, 1, 1, 1) + self.BooksLocationEdit = QtGui.QLineEdit(self.CVSGroupBox) + self.BooksLocationEdit.setObjectName(u'BooksLocationEdit') + self.gridLayout.addWidget(self.BooksLocationEdit, 0, 1, 1, 1) + self.BooksFileButton = QtGui.QPushButton(self.CVSGroupBox) + self.BooksFileButton.setIcon(icon1) + self.BooksFileButton.setObjectName(u'BooksFileButton') + self.gridLayout.addWidget(self.BooksFileButton, 0, 2, 1, 1) + self.VersesFileButton = QtGui.QPushButton(self.CVSGroupBox) + self.VersesFileButton.setIcon(icon1) + self.VersesFileButton.setObjectName(u'VersesFileButton') + self.gridLayout.addWidget(self.VersesFileButton, 4, 2, 1, 1) + self.tabWidget.addTab(self.CsvTab, u'') + self.HttpTab = QtGui.QWidget() + self.HttpTab.setObjectName(u'HttpTab') + self.OptionsGroupBox = QtGui.QGroupBox(self.HttpTab) + self.OptionsGroupBox.setGeometry(QtCore.QRect(10, 10, 460, 141)) + self.OptionsGroupBox.setObjectName(u'OptionsGroupBox') + self.verticalLayout = QtGui.QVBoxLayout(self.OptionsGroupBox) + self.verticalLayout.setObjectName(u'verticalLayout') + self.horizontalLayout_4 = QtGui.QHBoxLayout() + self.horizontalLayout_4.setObjectName(u'horizontalLayout_4') + self.LocationLabel = QtGui.QLabel(self.OptionsGroupBox) + self.LocationLabel.setObjectName(u'LocationLabel') + self.horizontalLayout_4.addWidget(self.LocationLabel) + self.LocationComboBox = QtGui.QComboBox(self.OptionsGroupBox) + self.LocationComboBox.setObjectName(u'LocationComboBox') + self.LocationComboBox.addItem(QtCore.QString()) + self.horizontalLayout_4.addWidget(self.LocationComboBox) + self.verticalLayout.addLayout(self.horizontalLayout_4) + self.horizontalLayout_5 = QtGui.QHBoxLayout() + self.horizontalLayout_5.setObjectName(u'horizontalLayout_5') + self.BibleLabel = QtGui.QLabel(self.OptionsGroupBox) + self.BibleLabel.setObjectName(u'BibleLabel') + self.horizontalLayout_5.addWidget(self.BibleLabel) + self.BibleComboBox = QtGui.QComboBox(self.OptionsGroupBox) + self.BibleComboBox.setObjectName(u'BibleComboBox') + self.BibleComboBox.addItem(QtCore.QString()) + self.BibleComboBox.setItemText(0, u'') + self.BibleComboBox.addItem(QtCore.QString()) + self.BibleComboBox.addItem(QtCore.QString()) + self.horizontalLayout_5.addWidget(self.BibleComboBox) + self.verticalLayout.addLayout(self.horizontalLayout_5) + self.ProxyGroupBox = QtGui.QGroupBox(self.HttpTab) + self.ProxyGroupBox.setGeometry(QtCore.QRect(10, 160, 460, 161)) + self.ProxyGroupBox.setObjectName(u'ProxyGroupBox') + self.ProxySettingsLayout = QtGui.QFormLayout(self.ProxyGroupBox) + self.ProxySettingsLayout.setFieldGrowthPolicy(QtGui.QFormLayout.AllNonFixedFieldsGrow) + self.ProxySettingsLayout.setMargin(8) + self.ProxySettingsLayout.setSpacing(8) + self.ProxySettingsLayout.setObjectName(u'ProxySettingsLayout') + self.AddressLabel = QtGui.QLabel(self.ProxyGroupBox) + self.AddressLabel.setObjectName(u'AddressLabel') + self.ProxySettingsLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.AddressLabel) + self.AddressEdit = QtGui.QLineEdit(self.ProxyGroupBox) + self.AddressEdit.setObjectName(u'AddressEdit') + self.ProxySettingsLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.AddressEdit) + self.UsernameLabel = QtGui.QLabel(self.ProxyGroupBox) + self.UsernameLabel.setObjectName(u'UsernameLabel') + self.ProxySettingsLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.UsernameLabel) + self.UsernameEdit = QtGui.QLineEdit(self.ProxyGroupBox) + self.UsernameEdit.setObjectName(u'UsernameEdit') + self.ProxySettingsLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.UsernameEdit) + self.PasswordLabel = QtGui.QLabel(self.ProxyGroupBox) + self.PasswordLabel.setObjectName(u'PasswordLabel') + self.ProxySettingsLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.PasswordLabel) + self.PasswordEdit = QtGui.QLineEdit(self.ProxyGroupBox) + self.PasswordEdit.setObjectName(u'PasswordEdit') + self.ProxySettingsLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.PasswordEdit) + self.tabWidget.addTab(self.HttpTab, u'') self.retranslateUi(BibleImportDialog) - self.ImportToolBox.setCurrentIndex(1) - + self.tabWidget.setCurrentIndex(2) QtCore.QMetaObject.connectSlotsByName(BibleImportDialog) BibleImportDialog.setTabOrder(self.BibleNameEdit, self.OSISLocationEdit) BibleImportDialog.setTabOrder(self.OSISLocationEdit, self.OsisFileButton) @@ -206,30 +209,31 @@ class Ui_BibleImportDialog(object): BibleImportDialog.setTabOrder(self.CopyrightEdit, self.PermisionEdit) def retranslateUi(self, BibleImportDialog): - BibleImportDialog.setWindowTitle(translate(u'BibleImportDialog', u'Bible Registration')) - self.OSISGroupBox.setTitle(translate(u'BibleImportDialog', u'OSIS Bible')) - self.LocatioLabel.setText(translate(u'BibleImportDialog', u'File Location:')) - self.CVSGroupBox.setTitle(translate(u'BibleImportDialog', u'CVS Bible')) - self.BooksLocationLabel.setText(translate(u'BibleImportDialog', u'Books Location:')) - self.VerseLocationLabel.setText(translate(u'BibleImportDialog', u'Verse Location:')) - self.BibleNameLabel.setText(translate(u'BibleImportDialog', u'Bible Name:')) - self.ImportToolBox.setItemText(self.ImportToolBox.indexOf(self.FileImportPage), translate(u'BibleImportDialog', u'File Import Page')) - self.OptionsGroupBox.setTitle(translate(u'BibleImportDialog', u'Download Options')) - self.LocationLabel.setText(translate(u'BibleImportDialog', u'Location:')) - self.LocationComboBox.setItemText(0, translate(u'BibleImportDialog', u'Crosswalk')) - self.BibleLabel.setText(translate(u'BibleImportDialog', u'Bible:')) - self.BibleComboBox.setItemText(1, translate(u'BibleImportDialog', u'NIV')) - self.BibleComboBox.setItemText(2, translate(u'BibleImportDialog', u'KJV')) - self.ProxyGroupBox.setTitle(translate(u'BibleImportDialog', u'Proxy Settings (Optional)')) - self.AddressLabel.setText(translate(u'BibleImportDialog', u'Proxy Address:')) - self.UsernameLabel.setText(translate(u'BibleImportDialog', u'Username:')) - self.PasswordLabel.setText(translate(u'BibleImportDialog', u'Password:')) - self.ImportToolBox.setItemText(self.ImportToolBox.indexOf(self.WebBiblePage), translate(u'BibleImportDialog', u'Web Bible Import page')) - self.LicenceDetailsGroupBox.setTitle(translate(u'BibleImportDialog', u'Licence Details')) - self.VersionNameLabel.setText(translate(u'BibleImportDialog', u'Version Name:')) - self.CopyrightLabel.setText(translate(u'BibleImportDialog', u'Copyright:')) - self.PermisionLabel.setText(translate(u'BibleImportDialog', u'Permission:')) - self.ProgressGroupBox.setTitle(translate(u'BibleImportDialog', u'Import Progress')) - self.ProgressBar.setFormat(translate(u'BibleImportDialog', u'%p')) - self.ImportButton.setText(translate(u'BibleImportDialog', u'Import')) - self.CancelButton.setText(translate(u'BibleImportDialog', u'Cancel')) + BibleImportDialog.setWindowTitle(QtGui.QApplication.translate(u'BibleImportDialog', u'Bible Registration', None, QtGui.QApplication.UnicodeUTF8)) + self.LicenceDetailsGroupBox.setTitle(QtGui.QApplication.translate(u'BibleImportDialog', u'Licence Details', None, QtGui.QApplication.UnicodeUTF8)) + self.VersionNameLabel.setText(QtGui.QApplication.translate(u'BibleImportDialog', u'Version Name:', None, QtGui.QApplication.UnicodeUTF8)) + self.CopyrightLabel.setText(QtGui.QApplication.translate(u'BibleImportDialog', u'Copyright:', None, QtGui.QApplication.UnicodeUTF8)) + self.PermisionLabel.setText(QtGui.QApplication.translate(u'BibleImportDialog', u'Permission:', None, QtGui.QApplication.UnicodeUTF8)) + self.ProgressGroupBox.setTitle(QtGui.QApplication.translate(u'BibleImportDialog', u'Import Progress', None, QtGui.QApplication.UnicodeUTF8)) + self.ProgressBar.setFormat(QtGui.QApplication.translate(u'BibleImportDialog', u'%p', None, QtGui.QApplication.UnicodeUTF8)) + self.ImportButton.setText(QtGui.QApplication.translate(u'BibleImportDialog', u'Import', None, QtGui.QApplication.UnicodeUTF8)) + self.CancelButton.setText(QtGui.QApplication.translate(u'BibleImportDialog', u'Cancel', None, QtGui.QApplication.UnicodeUTF8)) + self.OSISGroupBox.setTitle(QtGui.QApplication.translate(u'BibleImportDialog', u'OSIS Bible', None, QtGui.QApplication.UnicodeUTF8)) + self.BibleNameLabel.setText(QtGui.QApplication.translate(u'BibleImportDialog', u'Bible Name:', None, QtGui.QApplication.UnicodeUTF8)) + self.LocatioLabel.setText(QtGui.QApplication.translate(u'BibleImportDialog', u'File Location:', None, QtGui.QApplication.UnicodeUTF8)) + self.tabWidget.setTabText(self.tabWidget.indexOf(self.OsisTab), QtGui.QApplication.translate(u'BibleImportDialog', u'Osis (Sword) Imports', None, QtGui.QApplication.UnicodeUTF8)) + self.CVSGroupBox.setTitle(QtGui.QApplication.translate(u'BibleImportDialog', u'CVS Bible', None, QtGui.QApplication.UnicodeUTF8)) + self.BooksLocationLabel.setText(QtGui.QApplication.translate(u'BibleImportDialog', u'Books Location:', None, QtGui.QApplication.UnicodeUTF8)) + self.VerseLocationLabel.setText(QtGui.QApplication.translate(u'BibleImportDialog', u'Verse Location:', None, QtGui.QApplication.UnicodeUTF8)) + self.tabWidget.setTabText(self.tabWidget.indexOf(self.CsvTab), QtGui.QApplication.translate(u'BibleImportDialog', u'CSV File Imports', None, QtGui.QApplication.UnicodeUTF8)) + self.OptionsGroupBox.setTitle(QtGui.QApplication.translate(u'BibleImportDialog', u'Download Options', None, QtGui.QApplication.UnicodeUTF8)) + self.LocationLabel.setText(QtGui.QApplication.translate(u'BibleImportDialog', u'Location:', None, QtGui.QApplication.UnicodeUTF8)) + self.LocationComboBox.setItemText(0, QtGui.QApplication.translate(u'BibleImportDialog', u'Crosswalk', None, QtGui.QApplication.UnicodeUTF8)) + self.BibleLabel.setText(QtGui.QApplication.translate(u'BibleImportDialog', u'Bible:', None, QtGui.QApplication.UnicodeUTF8)) + self.BibleComboBox.setItemText(1, QtGui.QApplication.translate(u'BibleImportDialog', u'NIV', None, QtGui.QApplication.UnicodeUTF8)) + self.BibleComboBox.setItemText(2, QtGui.QApplication.translate(u'BibleImportDialog', u'KJV', None, QtGui.QApplication.UnicodeUTF8)) + self.ProxyGroupBox.setTitle(QtGui.QApplication.translate(u'BibleImportDialog', u'Proxy Settings (Optional)', None, QtGui.QApplication.UnicodeUTF8)) + self.AddressLabel.setText(QtGui.QApplication.translate(u'BibleImportDialog', u'Proxy Address:', None, QtGui.QApplication.UnicodeUTF8)) + self.UsernameLabel.setText(QtGui.QApplication.translate(u'BibleImportDialog', u'Username:', None, QtGui.QApplication.UnicodeUTF8)) + self.PasswordLabel.setText(QtGui.QApplication.translate(u'BibleImportDialog', u'Password:', None, QtGui.QApplication.UnicodeUTF8)) + self.tabWidget.setTabText(self.tabWidget.indexOf(self.HttpTab), QtGui.QApplication.translate(u'BibleImportDialog', u'Web Downloads', None, QtGui.QApplication.UnicodeUTF8)) diff --git a/openlp/plugins/images/lib/imageslidecontroller.py b/openlp/plugins/images/lib/imageslidecontroller.py index 926955846..f065b78d2 100644 --- a/openlp/plugins/images/lib/imageslidecontroller.py +++ b/openlp/plugins/images/lib/imageslidecontroller.py @@ -93,7 +93,7 @@ class ImageToolbar(MasterToolbar): Go to the last slide. """ if self.PreviewListWidget.rowCount() > 1: - self.timer_id = self.startTimer(int(self.TimeoutSpinBox.value()) * 1000) + self.timer_id = self.startTimer(int(self.TimeoutSpinBox.value()) * 1000) def onStopLoop(self): """ diff --git a/openlp/plugins/songs/forms/editsongdialog.py b/openlp/plugins/songs/forms/editsongdialog.py index 41b307446..f9c967225 100644 --- a/openlp/plugins/songs/forms/editsongdialog.py +++ b/openlp/plugins/songs/forms/editsongdialog.py @@ -380,11 +380,10 @@ class Ui_EditSongDialog(object): self.verticalLayout.addWidget(self.ButtonBox) self.retranslateUi(EditSongDialog) - self.SongTabWidget.setCurrentIndex(0) QtCore.QObject.connect(self.ButtonBox, QtCore.SIGNAL(u'rejected()'), EditSongDialog.close) QtCore.QObject.connect(self.ButtonBox, - QtCore.SIGNAL(u'accepted()'), EditSongDialog.close) + QtCore.SIGNAL(u'accepted()'), EditSongDialog.accept) QtCore.QMetaObject.connectSlotsByName(EditSongDialog) EditSongDialog.setTabOrder(self.SongTabWidget, self.TitleEditItem) EditSongDialog.setTabOrder(self.TitleEditItem, self.AlternativeEdit) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index ef5fd846a..0c4a1d6b2 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -122,6 +122,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): def newSong(self): log.debug(u'New Song') + self.SongTabWidget.setCurrentIndex(0) self.song = Song() self.TitleEditItem.setText(u'') self.AlternativeEdit.setText(u'') @@ -140,6 +141,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): def loadSong(self, id): log.debug(u'Load Song') + self.SongTabWidget.setCurrentIndex(0) self.loadAuthors() self.loadTopics() self.loadBooks() @@ -341,8 +343,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.loadBooks() self.loadTopics() - def onAccept(self): - log.debug(u'OnAccept') + def accept(self): + log.debug(u'accept') if not self._validate_song(): return self.song.title = unicode(self.TitleEditItem.displayText()) diff --git a/resources/forms/bibleimportdialog.ui b/resources/forms/bibleimportdialog.ui index a53e47e35..87740ec9e 100644 --- a/resources/forms/bibleimportdialog.ui +++ b/resources/forms/bibleimportdialog.ui @@ -6,307 +6,23 @@ 0 0 - 494 - 725 + 500 + 686 Bible Registration - + :/icon/openlp.org-icon-32.bmp:/icon/openlp.org-icon-32.bmp - - - - 20 - 20 - 451 - 401 - - - - QFrame::StyledPanel - - - 1 - - - - - 0 - 0 - 447 - 337 - - - - File Import Page - - - - - 18 - 65 - 411 - 81 - - - - OSIS Bible - - - - 8 - - - 8 - - - - - File Location: - - - - - - - - - - - - - - :/imports/import_load.png:/imports/import_load.png - - - - - - - - - 20 - 170 - 411 - 191 - - - - CVS Bible - - - - 8 - - - 8 - - - - - Books Location: - - - - - - - Verse Location: - - - - - - - - - - - - - - - - - :/imports/import_load.png:/imports/import_load.png - - - - - - - - - - - :/imports/import_load.png:/imports/import_load.png - - - - - - - - - 100 - 20 - 280 - 28 - - - - - - - 18 - 20 - 98 - 22 - - - - Bible Name: - - - - - - - 0 - 0 - 447 - 337 - - - - Web Bible Import page - - - - 8 - - - 8 - - - - - Download Options - - - - - - Location: - - - - - - - - Crosswalk - - - - - - - - Bible: - - - - - - - - - - - - - NIV - - - - - KJV - - - - - - BibleComboBox - LocationLabel - BibleLabel - LocationComboBox - - - - - - Proxy Settings (Optional) - - - - QFormLayout::AllNonFixedFieldsGrow - - - 8 - - - 8 - - - 8 - - - - - Proxy Address: - - - - - - - - - - Username: - - - - - - - - - - Password: - - - - - - - - - - - - 10 - 435 - 471 + 400 + 480 151 @@ -375,8 +91,8 @@ 10 - 600 - 471 + 550 + 480 70 @@ -402,8 +118,8 @@ - 300 - 680 + 310 + 630 180 38 @@ -428,6 +144,280 @@ + + + + 10 + 30 + 480 + 361 + + + + 2 + + + + Osis (Sword) Imports + + + + + 10 + 10 + 460 + 141 + + + + OSIS Bible + + + + + + + + Bible Name: + + + + + + + + + + + + + + File Location: + + + + + + + + + + + + + + :/imports/import_load.png:/imports/import_load.png + + + + + + + + + + + CSV File Imports + + + + + 10 + 10 + 460 + 191 + + + + CVS Bible + + + + 8 + + + 8 + + + + + Books Location: + + + + + + + Verse Location: + + + + + + + + + + + + + + + + + :/imports/import_load.png:/imports/import_load.png + + + + + + + + + + + :/imports/import_load.png:/imports/import_load.png + + + + + + + + + Web Downloads + + + + + 10 + 10 + 460 + 141 + + + + Download Options + + + + + + + + Location: + + + + + + + + Crosswalk + + + + + + + + + + + + Bible: + + + + + + + + + + + + + NIV + + + + + KJV + + + + + + + + BibleComboBox + LocationLabel + BibleLabel + LocationComboBox + + + + + 10 + 160 + 460 + 161 + + + + Proxy Settings (Optional) + + + + QFormLayout::AllNonFixedFieldsGrow + + + 8 + + + 8 + + + 8 + + + + + Proxy Address: + + + + + + + + + + Username: + + + + + + + + + + Password: + + + + + + + + + OptionsGroupBox + OptionsGroupBox + ProxyGroupBox + + BibleNameEdit