main window and theme manager

This commit is contained in:
Tim Bentley 2013-03-16 11:05:52 +00:00
parent 8c7bfc2bb7
commit e641c0e8b3
12 changed files with 491 additions and 489 deletions

View File

@ -28,8 +28,7 @@
############################################################################### ###############################################################################
""" """
Provide additional functionality required by OpenLP from the inherited Provide additional functionality required by OpenLP from the inherited QDockWidget.
QDockWidget.
""" """
import logging import logging
@ -56,8 +55,8 @@ class OpenLPDockWidget(QtGui.QDockWidget):
self.setWindowIcon(build_icon(icon)) self.setWindowIcon(build_icon(icon))
# Sort out the minimum width. # Sort out the minimum width.
screens = ScreenList() screens = ScreenList()
mainwindow_docbars = screens.current[u'size'].width() / 5 main_window_docbars = screens.current[u'size'].width() / 5
if mainwindow_docbars > 300: if main_window_docbars > 300:
self.setMinimumWidth(300) self.setMinimumWidth(300)
else: else:
self.setMinimumWidth(mainwindow_docbars) self.setMinimumWidth(main_window_docbars)

View File

@ -214,7 +214,7 @@ class Plugin(QtCore.QObject):
you need, and return it for integration into OpenLP. you need, and return it for integration into OpenLP.
""" """
if self.mediaItemClass: if self.mediaItemClass:
self.mediaItem = self.mediaItemClass(self.main_window.mediaDockManager.media_dock, self) self.mediaItem = self.mediaItemClass(self.main_window.media_dock_manager.media_dock, self)
def addImportMenuItem(self, importMenu): def addImportMenuItem(self, importMenu):
""" """
@ -284,14 +284,14 @@ class Plugin(QtCore.QObject):
""" """
if self.mediaItem: if self.mediaItem:
self.mediaItem.initialise() self.mediaItem.initialise()
self.main_window.mediaDockManager.insert_dock(self.mediaItem, self.icon, self.weight) self.main_window.media_dock_manager.insert_dock(self.mediaItem, self.icon, self.weight)
def finalise(self): def finalise(self):
""" """
Called by the plugin Manager to cleanup things. Called by the plugin Manager to cleanup things.
""" """
if self.mediaItem: if self.mediaItem:
self.main_window.mediaDockManager.remove_dock(self.mediaItem) self.main_window.media_dock_manager.remove_dock(self.mediaItem)
def app_startup(self): def app_startup(self):
""" """

File diff suppressed because it is too large Load Diff

View File

@ -208,7 +208,7 @@ class ServiceManagerDialog(object):
self.service_manager_list.itemCollapsed.connect(self.collapsed) self.service_manager_list.itemCollapsed.connect(self.collapsed)
self.service_manager_list.itemExpanded.connect(self.expanded) self.service_manager_list.itemExpanded.connect(self.expanded)
# Last little bits of setting up # Last little bits of setting up
self.service_theme = Settings().value(self.main_window.serviceManagerSettingsSection + u'/service theme') self.service_theme = Settings().value(self.main_window.service_manager_settings_section + u'/service theme')
self.servicePath = AppLocation.get_section_data_path(u'servicemanager') self.servicePath = AppLocation.get_section_data_path(u'servicemanager')
# build the drag and drop context menu # build the drag and drop context menu
self.dndMenu = QtGui.QMenu() self.dndMenu = QtGui.QMenu()
@ -323,7 +323,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
self.service_id += 1 self.service_id += 1
self._modified = modified self._modified = modified
service_file = self.short_file_name() or translate('OpenLP.ServiceManager', 'Untitled Service') service_file = self.short_file_name() or translate('OpenLP.ServiceManager', 'Untitled Service')
self.main_window.setServiceModified(modified, service_file) self.main_window.set_service_modified(modified, service_file)
def is_modified(self): def is_modified(self):
""" """
@ -336,7 +336,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
Setter for service file. Setter for service file.
""" """
self._file_name = unicode(file_name) self._file_name = unicode(file_name)
self.main_window.setServiceModified(self.is_modified(), self.short_file_name()) self.main_window.set_service_modified(self.is_modified(), self.short_file_name())
Settings().setValue(u'servicemanager/last file', file_name) Settings().setValue(u'servicemanager/last file', file_name)
self._save_lite = self._file_name.endswith(u'.oszl') self._save_lite = self._file_name.endswith(u'.oszl')
@ -401,14 +401,14 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
file_name = QtGui.QFileDialog.getOpenFileName( file_name = QtGui.QFileDialog.getOpenFileName(
self.main_window, self.main_window,
translate('OpenLP.ServiceManager', 'Open File'), translate('OpenLP.ServiceManager', 'Open File'),
Settings().value(self.main_window.serviceManagerSettingsSection + u'/last directory'), Settings().value(self.main_window.service_manager_settings_section + u'/last directory'),
translate('OpenLP.ServiceManager', 'OpenLP Service Files (*.osz *.oszl)') translate('OpenLP.ServiceManager', 'OpenLP Service Files (*.osz *.oszl)')
) )
if not file_name: if not file_name:
return False return False
else: else:
file_name = load_file file_name = load_file
Settings().setValue(self.main_window.serviceManagerSettingsSection + u'/last directory', Settings().setValue(self.main_window.service_manager_settings_section + u'/last directory',
split_filename(file_name)[0]) split_filename(file_name)[0])
self.load_file(file_name) self.load_file(file_name)
@ -461,7 +461,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
base_name = os.path.splitext(file_name)[0] base_name = os.path.splitext(file_name)[0]
service_file_name = '%s.osd' % base_name service_file_name = '%s.osd' % base_name
log.debug(u'ServiceManager.save_file - %s', path_file_name) log.debug(u'ServiceManager.save_file - %s', path_file_name)
Settings().setValue(self.main_window.serviceManagerSettingsSection + u'/last directory', path) Settings().setValue(self.main_window.service_manager_settings_section + u'/last directory', path)
service = [] service = []
write_list = [] write_list = []
missing_list = [] missing_list = []
@ -469,7 +469,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
total_size = 0 total_size = 0
self.application.set_busy_cursor() self.application.set_busy_cursor()
# Number of items + 1 to zip it # Number of items + 1 to zip it
self.main_window.displayProgressBar(len(self.service_items) + 1) self.main_window.display_progress_bar(len(self.service_items) + 1)
# Get list of missing files, and list of files to write # Get list of missing files, and list of files to write
for item in self.service_items: for item in self.service_items:
if not item[u'service_item'].uses_file(): if not item[u'service_item'].uses_file():
@ -491,7 +491,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
answer = QtGui.QMessageBox.critical(self, title, message, answer = QtGui.QMessageBox.critical(self, title, message,
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok | QtGui.QMessageBox.Cancel)) QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok | QtGui.QMessageBox.Cancel))
if answer == QtGui.QMessageBox.Cancel: if answer == QtGui.QMessageBox.Cancel:
self.main_window.finishedProgressBar() self.main_window.finished_progress_bar()
return False return False
# Check if item contains a missing file. # Check if item contains a missing file.
for item in list(self.service_items): for item in list(self.service_items):
@ -551,14 +551,14 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
finally: finally:
if zip_file: if zip_file:
zip_file.close() zip_file.close()
self.main_window.finishedProgressBar() self.main_window.finished_progress_bar()
self.application.set_normal_cursor() self.application.set_normal_cursor()
if success: if success:
try: try:
shutil.copy(temp_file_name, path_file_name) shutil.copy(temp_file_name, path_file_name)
except shutil.Error: except shutil.Error:
return self.save_file_as() return self.save_file_as()
self.main_window.addRecentFile(path_file_name) self.main_window.add_recent_file(path_file_name)
self.set_modified(False) self.set_modified(False)
delete_file(temp_file_name) delete_file(temp_file_name)
return success return success
@ -579,11 +579,11 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
base_name = os.path.splitext(file_name)[0] base_name = os.path.splitext(file_name)[0]
service_file_name = '%s.osd' % base_name service_file_name = '%s.osd' % base_name
log.debug(u'ServiceManager.save_file - %s', path_file_name) log.debug(u'ServiceManager.save_file - %s', path_file_name)
Settings().setValue(self.main_window.serviceManagerSettingsSection + u'/last directory', path) Settings().setValue(self.main_window.service_manager_settings_section + u'/last directory', path)
service = [] service = []
self.application.set_busy_cursor() self.application.set_busy_cursor()
# Number of items + 1 to zip it # Number of items + 1 to zip it
self.main_window.displayProgressBar(len(self.service_items) + 1) self.main_window.display_progress_bar(len(self.service_items) + 1)
for item in self.service_items: for item in self.service_items:
self.main_window.increment_progress_bar() self.main_window.increment_progress_bar()
service_item = item[u'service_item'].get_service_repr(self._save_lite) service_item = item[u'service_item'].get_service_repr(self._save_lite)
@ -608,14 +608,14 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
finally: finally:
if zip_file: if zip_file:
zip_file.close() zip_file.close()
self.main_window.finishedProgressBar() self.main_window.finished_progress_bar()
self.application.set_normal_cursor() self.application.set_normal_cursor()
if success: if success:
try: try:
shutil.copy(temp_file_name, path_file_name) shutil.copy(temp_file_name, path_file_name)
except shutil.Error: except shutil.Error:
return self.save_file_as() return self.save_file_as()
self.main_window.addRecentFile(path_file_name) self.main_window.add_recent_file(path_file_name)
self.set_modified(False) self.set_modified(False)
delete_file(temp_file_name) delete_file(temp_file_name)
return success return success
@ -643,7 +643,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
default_file_name = format_time(default_pattern, local_time) default_file_name = format_time(default_pattern, local_time)
else: else:
default_file_name = u'' default_file_name = u''
directory = Settings().value(self.main_window.serviceManagerSettingsSection + u'/last directory') directory = Settings().value(self.main_window.service_manager_settings_section + u'/last directory')
path = os.path.join(directory, default_file_name) path = os.path.join(directory, default_file_name)
# SaveAs from osz to oszl is not valid as the files will be deleted # SaveAs from osz to oszl is not valid as the files will be deleted
# on exit which is not sensible or usable in the long term. # on exit which is not sensible or usable in the long term.
@ -712,7 +712,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
file_to.close() file_to.close()
self.new_file() self.new_file()
self.set_file_name(file_name) self.set_file_name(file_name)
self.main_window.displayProgressBar(len(items)) self.main_window.display_progress_bar(len(items))
for item in items: for item in items:
self.main_window.increment_progress_bar() self.main_window.increment_progress_bar()
service_item = ServiceItem() service_item = ServiceItem()
@ -730,7 +730,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
service_item.temporary_edit = self.load_item_temporary service_item.temporary_edit = self.load_item_temporary
self.add_service_item(service_item, repaint=False) self.add_service_item(service_item, repaint=False)
delete_file(p_file) delete_file(p_file)
self.main_window.addRecentFile(file_name) self.main_window.add_recent_file(file_name)
self.set_modified(False) self.set_modified(False)
Settings().setValue('servicemanager/last file', file_name) Settings().setValue('servicemanager/last file', file_name)
else: else:
@ -758,7 +758,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
file_to.close() file_to.close()
if zip_file: if zip_file:
zip_file.close() zip_file.close()
self.main_window.finishedProgressBar() self.main_window.finished_progress_bar()
self.application.set_normal_cursor() self.application.set_normal_cursor()
self.repaint_service_list(-1, -1) self.repaint_service_list(-1, -1)
@ -871,7 +871,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
self.auto_play_slides_loop.setChecked(False) self.auto_play_slides_loop.setChecked(False)
if service_item.auto_play_slides_once and service_item.timed_slide_interval == 0: if service_item.auto_play_slides_once and service_item.timed_slide_interval == 0:
service_item.timed_slide_interval = Settings().value( service_item.timed_slide_interval = Settings().value(
self.main_window.generalSettingsSection + u'/loop delay') self.main_window.general_settings_section + u'/loop delay')
self.set_modified() self.set_modified()
def toggle_auto_play_slides_loop(self): def toggle_auto_play_slides_loop(self):
@ -886,7 +886,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
self.auto_play_slides_once.setChecked(False) self.auto_play_slides_once.setChecked(False)
if service_item.auto_play_slides_loop and service_item.timed_slide_interval == 0: if service_item.auto_play_slides_loop and service_item.timed_slide_interval == 0:
service_item.timed_slide_interval = Settings().value( service_item.timed_slide_interval = Settings().value(
self.main_window.generalSettingsSection + u'/loop delay') self.main_window.general_settings_section + u'/loop delay')
self.set_modified() self.set_modified()
def on_timed_slide_interval(self): def on_timed_slide_interval(self):
@ -1228,7 +1228,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
log.debug(u'on_theme_combo_box_selected') log.debug(u'on_theme_combo_box_selected')
self.service_theme = self.theme_combo_box.currentText() self.service_theme = self.theme_combo_box.currentText()
self.renderer.set_service_theme(self.service_theme) self.renderer.set_service_theme(self.service_theme)
Settings().setValue(self.main_window.serviceManagerSettingsSection + u'/service theme', self.service_theme) Settings().setValue(self.main_window.service_manager_settings_section + u'/service theme', self.service_theme)
self.regenerate_service_Items(True) self.regenerate_service_Items(True)
def theme_change(self): def theme_change(self):
@ -1397,7 +1397,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
self.application.set_busy_cursor() self.application.set_busy_cursor()
if self.service_items[item][u'service_item'].is_valid: if self.service_items[item][u'service_item'].is_valid:
self.live_controller.addServiceManagerItem(self.service_items[item][u'service_item'], child) self.live_controller.addServiceManagerItem(self.service_items[item][u'service_item'], child)
if Settings().value(self.main_window.generalSettingsSection + u'/auto preview'): if Settings().value(self.main_window.general_settings_section + u'/auto preview'):
item += 1 item += 1
if self.service_items and item < len(self.service_items) and \ if self.service_items and item < len(self.service_items) and \
self.service_items[item][u'service_item'].is_capable(ItemCapabilities.CanPreview): self.service_items[item][u'service_item'].is_capable(ItemCapabilities.CanPreview):

View File

@ -238,7 +238,7 @@ class SlideController(DisplayController):
self.play_slides_once = create_action(self, u'playSlidesOnce', text=UiStrings().PlaySlidesToEnd, self.play_slides_once = create_action(self, u'playSlidesOnce', text=UiStrings().PlaySlidesToEnd,
icon=u':/media/media_time.png', checked=False, can_shortcuts=True, icon=u':/media/media_time.png', checked=False, can_shortcuts=True,
category=self.category, triggers=self.onPlaySlidesOnce) category=self.category, triggers=self.onPlaySlidesOnce)
if Settings().value(self.main_window.advancedSettingsSection + u'/slide limits') == SlideLimits.Wrap: if Settings().value(self.main_window.advanced_settings_section + u'/slide limits') == SlideLimits.Wrap:
self.play_slides_menu.setDefaultAction(self.play_slides_loop) self.play_slides_menu.setDefaultAction(self.play_slides_loop)
else: else:
self.play_slides_menu.setDefaultAction(self.play_slides_once) self.play_slides_menu.setDefaultAction(self.play_slides_once)
@ -615,7 +615,7 @@ class SlideController(DisplayController):
""" """
Updates the Slide Limits variable from the settings. Updates the Slide Limits variable from the settings.
""" """
self.slide_limits = Settings().value(self.main_window.advancedSettingsSection + u'/slide limits') self.slide_limits = Settings().value(self.main_window.advanced_settings_section + u'/slide limits')
def enableToolBar(self, item): def enableToolBar(self, item):
""" """
@ -874,7 +874,7 @@ class SlideController(DisplayController):
Allow the main display to blank the main display at startup time Allow the main display to blank the main display at startup time
""" """
log.debug(u'mainDisplaySetBackground live = %s' % self.is_live) log.debug(u'mainDisplaySetBackground live = %s' % self.is_live)
display_type = Settings().value(self.main_window.generalSettingsSection + u'/screen blank') display_type = Settings().value(self.main_window.general_settings_section + u'/screen blank')
if self.screens.which_screen(self.window()) != self.screens.which_screen(self.display): if self.screens.which_screen(self.window()) != self.screens.which_screen(self.display):
# Order done to handle initial conversion # Order done to handle initial conversion
if display_type == u'themed': if display_type == u'themed':

View File

@ -62,8 +62,8 @@ class ThemeManager(QtGui.QWidget):
Registry().register_function(u'bootstrap_initialise', self.load_first_time_themes) Registry().register_function(u'bootstrap_initialise', self.load_first_time_themes)
Registry().register_function(u'bootstrap_post_set_up', self._push_themes) Registry().register_function(u'bootstrap_post_set_up', self._push_themes)
self.settingsSection = u'themes' self.settingsSection = u'themes'
self.themeForm = ThemeForm(self) self.theme_form = ThemeForm(self)
self.fileRenameForm = FileRenameForm() self.file_rename_form = FileRenameForm()
# start with the layout # start with the layout
self.layout = QtGui.QVBoxLayout(self) self.layout = QtGui.QVBoxLayout(self)
self.layout.setSpacing(0) self.layout.setSpacing(0)
@ -74,13 +74,13 @@ class ThemeManager(QtGui.QWidget):
self.toolbar.add_toolbar_action(u'newTheme', self.toolbar.add_toolbar_action(u'newTheme',
text=UiStrings().NewTheme, icon=u':/themes/theme_new.png', text=UiStrings().NewTheme, icon=u':/themes/theme_new.png',
tooltip=translate('OpenLP.ThemeManager', 'Create a new theme.'), tooltip=translate('OpenLP.ThemeManager', 'Create a new theme.'),
triggers=self.onAddTheme) triggers=self.on_add_theme)
self.toolbar.add_toolbar_action(u'editTheme', self.toolbar.add_toolbar_action(u'editTheme',
text=translate('OpenLP.ThemeManager', 'Edit Theme'), text=translate('OpenLP.ThemeManager', 'Edit Theme'),
icon=u':/themes/theme_edit.png', icon=u':/themes/theme_edit.png',
tooltip=translate('OpenLP.ThemeManager', 'Edit a theme.'), tooltip=translate('OpenLP.ThemeManager', 'Edit a theme.'),
triggers=self.on_edit_theme) triggers=self.on_edit_theme)
self.deleteToolbarAction = self.toolbar.add_toolbar_action(u'delete_theme', self.delete_toolbar_action = self.toolbar.add_toolbar_action(u'delete_theme',
text=translate('OpenLP.ThemeManager', 'Delete Theme'), text=translate('OpenLP.ThemeManager', 'Delete Theme'),
icon=u':/general/general_delete.png', icon=u':/general/general_delete.png',
tooltip=translate('OpenLP.ThemeManager', 'Delete a theme.'), tooltip=translate('OpenLP.ThemeManager', 'Delete a theme.'),
@ -137,11 +137,11 @@ class ThemeManager(QtGui.QWidget):
self.theme_list = [] self.theme_list = []
self.path = AppLocation.get_section_data_path(self.settingsSection) self.path = AppLocation.get_section_data_path(self.settingsSection)
check_directory_exists(self.path) check_directory_exists(self.path)
self.thumbPath = os.path.join(self.path, u'thumbnails') self.thumb_path = os.path.join(self.path, u'thumbnails')
check_directory_exists(self.thumbPath) check_directory_exists(self.thumb_path)
self.themeForm.path = self.path self.theme_form.path = self.path
self.oldBackgroundImage = None self.old_background_image = None
self.badV1NameChars = re.compile(r'[%+\[\]]') self.bad_v1_name_chars = re.compile(r'[%+\[\]]')
# Last little bits of setting up # Last little bits of setting up
self.global_theme = Settings().value(self.settingsSection + u'/global theme') self.global_theme = Settings().value(self.settingsSection + u'/global theme')
@ -155,9 +155,9 @@ class ThemeManager(QtGui.QWidget):
theme_name = item.text() theme_name = item.text()
# If default theme restrict actions # If default theme restrict actions
if real_theme_name == theme_name: if real_theme_name == theme_name:
self.deleteToolbarAction.setVisible(True) self.delete_toolbar_action.setVisible(True)
else: else:
self.deleteToolbarAction.setVisible(False) self.delete_toolbar_action.setVisible(False)
def context_menu(self, point): def context_menu(self, point):
""" """
@ -192,7 +192,7 @@ class ThemeManager(QtGui.QWidget):
if self.global_theme == new_name: if self.global_theme == new_name:
name = translate('OpenLP.ThemeManager', '%s (default)') % new_name name = translate('OpenLP.ThemeManager', '%s (default)') % new_name
self.theme_list_widget.item(count).setText(name) self.theme_list_widget.item(count).setText(name)
self.deleteToolbarAction.setVisible(item not in self.theme_list_widget.selectedItems()) self.delete_toolbar_action.setVisible(item not in self.theme_list_widget.selectedItems())
def change_global_from_screen(self, index=-1): def change_global_from_screen(self, index=-1):
""" """
@ -216,15 +216,15 @@ class ThemeManager(QtGui.QWidget):
Registry().execute(u'theme_update_global') Registry().execute(u'theme_update_global')
self._push_themes() self._push_themes()
def onAddTheme(self): def on_add_theme(self):
""" """
Loads a new theme with the default settings and then launches the theme Loads a new theme with the default settings and then launches the theme
editing form for the user to make their customisations. editing form for the user to make their customisations.
""" """
theme = ThemeXML() theme = ThemeXML()
theme.set_default_header_footer() theme.set_default_header_footer()
self.themeForm.theme = theme self.theme_form.theme = theme
self.themeForm.exec_() self.theme_form.exec_()
self.load_themes() self.load_themes()
def on_rename_theme(self): def on_rename_theme(self):
@ -236,14 +236,14 @@ class ThemeManager(QtGui.QWidget):
translate('OpenLP.ThemeManager', 'Rename %s theme?'), False, False): translate('OpenLP.ThemeManager', 'Rename %s theme?'), False, False):
item = self.theme_list_widget.currentItem() item = self.theme_list_widget.currentItem()
old_theme_name = item.data(QtCore.Qt.UserRole) old_theme_name = item.data(QtCore.Qt.UserRole)
self.fileRenameForm.file_name_edit.setText(old_theme_name) self.file_rename_form.file_name_edit.setText(old_theme_name)
if self.fileRenameForm.exec_(): if self.file_rename_form.exec_():
new_theme_name = self.fileRenameForm.file_name_edit.text() new_theme_name = self.file_rename_form.file_name_edit.text()
if old_theme_name == new_theme_name: if old_theme_name == new_theme_name:
return return
if self.check_if_theme_exists(new_theme_name): if self.check_if_theme_exists(new_theme_name):
old_theme_data = self.get_theme_data(old_theme_name) old_theme_data = self.get_theme_data(old_theme_name)
self.cloneThemeData(old_theme_data, new_theme_name) self.clone_theme_data(old_theme_data, new_theme_name)
self.delete_theme(old_theme_name) self.delete_theme(old_theme_name)
for plugin in self.plugin_manager.plugins: for plugin in self.plugin_manager.plugins:
if plugin.uses_theme(old_theme_name): if plugin.uses_theme(old_theme_name):
@ -257,19 +257,19 @@ class ThemeManager(QtGui.QWidget):
""" """
item = self.theme_list_widget.currentItem() item = self.theme_list_widget.currentItem()
old_theme_name = item.data(QtCore.Qt.UserRole) old_theme_name = item.data(QtCore.Qt.UserRole)
self.fileRenameForm.file_name_edit.setText(translate('OpenLP.ThemeManager', self.file_rename_form.file_name_edit.setText(translate('OpenLP.ThemeManager',
'Copy of %s', 'Copy of <theme name>') % old_theme_name) 'Copy of %s', 'Copy of <theme name>') % old_theme_name)
if self.fileRenameForm.exec_(True): if self.file_rename_form.exec_(True):
new_theme_name = self.fileRenameForm.file_name_edit.text() new_theme_name = self.file_rename_form.file_name_edit.text()
if self.check_if_theme_exists(new_theme_name): if self.check_if_theme_exists(new_theme_name):
theme_data = self.get_theme_data(old_theme_name) theme_data = self.get_theme_data(old_theme_name)
self.cloneThemeData(theme_data, new_theme_name) self.clone_theme_data(theme_data, new_theme_name)
def cloneThemeData(self, theme_data, new_theme_name): def clone_theme_data(self, theme_data, new_theme_name):
""" """
Takes a theme and makes a new copy of it as well as saving it. Takes a theme and makes a new copy of it as well as saving it.
""" """
log.debug(u'cloneThemeData') log.debug(u'clone_theme_data')
save_to = None save_to = None
save_from = None save_from = None
if theme_data.background_type == u'image': if theme_data.background_type == u'image':
@ -290,10 +290,10 @@ class ThemeManager(QtGui.QWidget):
item = self.theme_list_widget.currentItem() item = self.theme_list_widget.currentItem()
theme = self.get_theme_data(item.data(QtCore.Qt.UserRole)) theme = self.get_theme_data(item.data(QtCore.Qt.UserRole))
if theme.background_type == u'image': if theme.background_type == u'image':
self.oldBackgroundImage = theme.background_filename self.old_background_image = theme.background_filename
self.themeForm.theme = theme self.theme_form.theme = theme
self.themeForm.exec_(True) self.theme_form.exec_(True)
self.oldBackgroundImage = None self.old_background_image = None
self.renderer.update_theme(theme.theme_name) self.renderer.update_theme(theme.theme_name)
self.load_themes() self.load_themes()
@ -324,7 +324,7 @@ class ThemeManager(QtGui.QWidget):
self.theme_list.remove(theme) self.theme_list.remove(theme)
thumb = u'%s.png' % theme thumb = u'%s.png' % theme
delete_file(os.path.join(self.path, thumb)) delete_file(os.path.join(self.path, thumb))
delete_file(os.path.join(self.thumbPath, thumb)) delete_file(os.path.join(self.thumb_path, thumb))
try: try:
encoding = get_filesystem_encoding() encoding = get_filesystem_encoding()
shutil.rmtree(os.path.join(self.path, theme).encode(encoding)) shutil.rmtree(os.path.join(self.path, theme).encode(encoding))
@ -370,9 +370,8 @@ class ThemeManager(QtGui.QWidget):
def on_import_theme(self): def on_import_theme(self):
""" """
Opens a file dialog to select the theme file(s) to import before Opens a file dialog to select the theme file(s) to import before attempting to extract OpenLP themes from
attempting to extract OpenLP themes from those files. This process those files. This process will load both OpenLP version 1 and version 2 themes.
will load both OpenLP version 1 and version 2 themes.
""" """
files = QtGui.QFileDialog.getOpenFileNames(self, files = QtGui.QFileDialog.getOpenFileNames(self,
translate('OpenLP.ThemeManager', 'Select Theme Import File'), translate('OpenLP.ThemeManager', 'Select Theme Import File'),
@ -431,7 +430,7 @@ class ThemeManager(QtGui.QWidget):
name = translate('OpenLP.ThemeManager', '%s (default)') % text_name name = translate('OpenLP.ThemeManager', '%s (default)') % text_name
else: else:
name = text_name name = text_name
thumb = os.path.join(self.thumbPath, u'%s.png' % text_name) thumb = os.path.join(self.thumb_path, u'%s.png' % text_name)
item_name = QtGui.QListWidgetItem(name) item_name = QtGui.QListWidgetItem(name)
if validate_thumb(theme, thumb): if validate_thumb(theme, thumb):
icon = build_icon(thumb) icon = build_icon(thumb)
@ -504,8 +503,8 @@ class ThemeManager(QtGui.QWidget):
xml_tree = ElementTree(element=XML(theme_zip.read(xml_file[0]))).getroot() xml_tree = ElementTree(element=XML(theme_zip.read(xml_file[0]))).getroot()
v1_background = xml_tree.find(u'BackgroundType') v1_background = xml_tree.find(u'BackgroundType')
if v1_background is not None: if v1_background is not None:
theme_name, file_xml, out_file, abort_import = self.unzip_version_122( theme_name, file_xml, out_file, abort_import = \
directory, theme_zip, xml_file[0], xml_tree, v1_background, out_file) self.unzip_version_122(directory, theme_zip, xml_file[0], xml_tree, v1_background, out_file)
else: else:
theme_name = xml_tree.find(u'name').text.strip() theme_name = xml_tree.find(u'name').text.strip()
theme_folder = os.path.join(directory, theme_name) theme_folder = os.path.join(directory, theme_name)
@ -571,7 +570,7 @@ class ThemeManager(QtGui.QWidget):
this method, please keep in mind, that some parameters are redundant. this method, please keep in mind, that some parameters are redundant.
""" """
theme_name = xml_tree.find(u'Name').text.strip() theme_name = xml_tree.find(u'Name').text.strip()
theme_name = self.badV1NameChars.sub(u'', theme_name) theme_name = self.bad_v1_name_chars.sub(u'', theme_name)
theme_folder = os.path.join(dir_name, theme_name) theme_folder = os.path.join(dir_name, theme_name)
theme_exists = os.path.exists(theme_folder) theme_exists = os.path.exists(theme_folder)
if theme_exists and not self.over_write_message_box(theme_name): if theme_exists and not self.over_write_message_box(theme_name):
@ -634,8 +633,8 @@ class ThemeManager(QtGui.QWidget):
theme_dir = os.path.join(self.path, name) theme_dir = os.path.join(self.path, name)
check_directory_exists(theme_dir) check_directory_exists(theme_dir)
theme_file = os.path.join(theme_dir, name + u'.xml') theme_file = os.path.join(theme_dir, name + u'.xml')
if self.oldBackgroundImage and image_to != self.oldBackgroundImage: if self.old_background_image and image_to != self.old_background_image:
delete_file(self.oldBackgroundImage) delete_file(self.old_background_image)
out_file = None out_file = None
try: try:
out_file = open(theme_file, u'w') out_file = open(theme_file, u'w')
@ -663,7 +662,7 @@ class ThemeManager(QtGui.QWidget):
if os.path.exists(sample_path_name): if os.path.exists(sample_path_name):
os.unlink(sample_path_name) os.unlink(sample_path_name)
frame.save(sample_path_name, u'png') frame.save(sample_path_name, u'png')
thumb = os.path.join(self.thumbPath, u'%s.png' % name) thumb = os.path.join(self.thumb_path, u'%s.png' % name)
create_thumb(sample_path_name, thumb, False) create_thumb(sample_path_name, thumb, False)
log.debug(u'Theme image written to %s', sample_path_name) log.debug(u'Theme image written to %s', sample_path_name)
@ -672,11 +671,11 @@ class ThemeManager(QtGui.QWidget):
Called to update the themes' preview images. Called to update the themes' preview images.
""" """
log.debug('update_preview_images') log.debug('update_preview_images')
self.main_window.displayProgressBar(len(self.theme_list)) self.main_window.display_progress_bar(len(self.theme_list))
for theme in self.theme_list: for theme in self.theme_list:
self.main_window.increment_progress_bar() self.main_window.increment_progress_bar()
self.generate_and_save_image(self.path, theme, self.get_theme_data(theme)) self.generate_and_save_image(self.path, theme, self.get_theme_data(theme))
self.main_window.finishedProgressBar() self.main_window.finished_progress_bar()
self.load_themes() self.load_themes()
def generate_image(self, theme_data, forcePage=False): def generate_image(self, theme_data, forcePage=False):
@ -759,7 +758,7 @@ class ThemeManager(QtGui.QWidget):
""" """
theme = Theme(xml_data) theme = Theme(xml_data)
new_theme = ThemeXML() new_theme = ThemeXML()
new_theme.theme_name = self.badV1NameChars.sub(u'', theme.Name) new_theme.theme_name = self.bad_v1_name_chars.sub(u'', theme.Name)
if theme.BackgroundType == BackgroundType.Solid: if theme.BackgroundType == BackgroundType.Solid:
new_theme.background_type = BackgroundType.to_string(BackgroundType.Solid) new_theme.background_type = BackgroundType.to_string(BackgroundType.Solid)
new_theme.background_color = unicode(theme.BackgroundParameter1.name()) new_theme.background_color = unicode(theme.BackgroundParameter1.name())

View File

@ -99,7 +99,7 @@ class ImageMediaItem(MediaManagerItem):
row_list = [item.row() for item in self.listView.selectedIndexes()] row_list = [item.row() for item in self.listView.selectedIndexes()]
row_list.sort(reverse=True) row_list.sort(reverse=True)
self.application.set_busy_cursor() self.application.set_busy_cursor()
self.main_window.displayProgressBar(len(row_list)) self.main_window.display_progress_bar(len(row_list))
for row in row_list: for row in row_list:
text = self.listView.item(row) text = self.listView.item(row)
if text: if text:
@ -107,14 +107,14 @@ class ImageMediaItem(MediaManagerItem):
self.listView.takeItem(row) self.listView.takeItem(row)
self.main_window.increment_progress_bar() self.main_window.increment_progress_bar()
Settings.setValue(self.settingsSection + u'/images files', self.getFileList()) Settings.setValue(self.settingsSection + u'/images files', self.getFileList())
self.main_window.finishedProgressBar() self.main_window.finished_progress_bar()
self.application.set_normal_cursor() self.application.set_normal_cursor()
self.listView.blockSignals(False) self.listView.blockSignals(False)
def loadList(self, images, initialLoad=False): def loadList(self, images, initialLoad=False):
self.application.set_busy_cursor() self.application.set_busy_cursor()
if not initialLoad: if not initialLoad:
self.main_window.displayProgressBar(len(images)) self.main_window.display_progress_bar(len(images))
# Sort the images by its filename considering language specific # Sort the images by its filename considering language specific
# characters. # characters.
images.sort(cmp=locale_compare, key=lambda filename: os.path.split(unicode(filename))[1]) images.sort(cmp=locale_compare, key=lambda filename: os.path.split(unicode(filename))[1])
@ -136,7 +136,7 @@ class ImageMediaItem(MediaManagerItem):
if not initialLoad: if not initialLoad:
self.main_window.increment_progress_bar() self.main_window.increment_progress_bar()
if not initialLoad: if not initialLoad:
self.main_window.finishedProgressBar() self.main_window.finished_progress_bar()
self.application.set_normal_cursor() self.application.set_normal_cursor()
def generateSlideData(self, service_item, item=None, xmlVersion=False, def generateSlideData(self, service_item, item=None, xmlVersion=False,

View File

@ -151,7 +151,7 @@ class PresentationMediaItem(MediaManagerItem):
titles = [os.path.split(file)[1] for file in currlist] titles = [os.path.split(file)[1] for file in currlist]
self.application.set_busy_cursor() self.application.set_busy_cursor()
if not initialLoad: if not initialLoad:
self.main_window.displayProgressBar(len(files)) self.main_window.display_progress_bar(len(files))
# Sort the presentations by its filename considering language specific characters. # Sort the presentations by its filename considering language specific characters.
files.sort(cmp=locale_compare, files.sort(cmp=locale_compare,
key=lambda filename: os.path.split(unicode(filename))[1]) key=lambda filename: os.path.split(unicode(filename))[1])
@ -205,7 +205,7 @@ class PresentationMediaItem(MediaManagerItem):
item_name.setToolTip(file) item_name.setToolTip(file)
self.listView.addItem(item_name) self.listView.addItem(item_name)
if not initialLoad: if not initialLoad:
self.main_window.finishedProgressBar() self.main_window.finished_progress_bar()
self.application.set_normal_cursor() self.application.set_normal_cursor()
def onDeleteClick(self): def onDeleteClick(self):
@ -217,7 +217,7 @@ class PresentationMediaItem(MediaManagerItem):
row_list = [item.row() for item in items] row_list = [item.row() for item in items]
row_list.sort(reverse=True) row_list.sort(reverse=True)
self.application.set_busy_cursor() self.application.set_busy_cursor()
self.main_window.displayProgressBar(len(row_list)) self.main_window.display_progress_bar(len(row_list))
for item in items: for item in items:
filepath = unicode(item.data(QtCore.Qt.UserRole)) filepath = unicode(item.data(QtCore.Qt.UserRole))
for cidx in self.controllers: for cidx in self.controllers:
@ -225,7 +225,7 @@ class PresentationMediaItem(MediaManagerItem):
doc.presentation_deleted() doc.presentation_deleted()
doc.close_presentation() doc.close_presentation()
self.main_window.increment_progress_bar() self.main_window.increment_progress_bar()
self.main_window.finishedProgressBar() self.main_window.finished_progress_bar()
self.application.set_busy_cursor() self.application.set_busy_cursor()
for row in row_list: for row in row_list:
self.listView.takeItem(row) self.listView.takeItem(row)

View File

@ -110,7 +110,7 @@ class PresentationPlugin(Plugin):
Create the Media Manager List Create the Media Manager List
""" """
self.mediaItem = PresentationMediaItem( self.mediaItem = PresentationMediaItem(
self.main_window.mediaDockManager.media_dock, self, self.icon, self.controllers) self.main_window.media_dock_manager.media_dock, self, self.icon, self.controllers)
def registerControllers(self, controller): def registerControllers(self, controller):
""" """
@ -132,13 +132,12 @@ class PresentationPlugin(Plugin):
if filename.endswith(u'controller.py') and not filename == 'presentationcontroller.py': if filename.endswith(u'controller.py') and not filename == 'presentationcontroller.py':
path = os.path.join(controller_dir, filename) path = os.path.join(controller_dir, filename)
if os.path.isfile(path): if os.path.isfile(path):
modulename = u'openlp.plugins.presentations.lib.' + os.path.splitext(filename)[0] module_name = u'openlp.plugins.presentations.lib.' + os.path.splitext(filename)[0]
log.debug(u'Importing controller %s', modulename) log.debug(u'Importing controller %s', module_name)
try: try:
__import__(modulename, globals(), locals(), []) __import__(module_name, globals(), locals(), [])
except ImportError: except ImportError:
log.warn(u'Failed to import %s on path %s', log.warn(u'Failed to import %s on path %s', module_name, path)
modulename, path)
controller_classes = PresentationController.__subclasses__() controller_classes = PresentationController.__subclasses__()
for controller_class in controller_classes: for controller_class in controller_classes:
controller = controller_class(self) controller = controller_class(self)

View File

@ -84,7 +84,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.verse_delete_button.clicked.connect(self.on_verse_delete_button_clicked) self.verse_delete_button.clicked.connect(self.on_verse_delete_button_clicked)
self.verse_list_widget.itemClicked.connect(self.on_verse_list_view_clicked) self.verse_list_widget.itemClicked.connect(self.on_verse_list_view_clicked)
self.verse_order_edit.textChanged.connect(self.on_verse_order_text_changed) self.verse_order_edit.textChanged.connect(self.on_verse_order_text_changed)
self.theme_add_button.clicked.connect(self.theme_manager.onAddTheme) self.theme_add_button.clicked.connect(self.theme_manager.on_add_theme)
self.maintenance_button.clicked.connect(self.on_maintenance_button_clicked) self.maintenance_button.clicked.connect(self.on_maintenance_button_clicked)
self.from_file_button.clicked.connect(self.on_audio_add_from_file_button_clicked) self.from_file_button.clicked.connect(self.on_audio_add_from_file_button_clicked)
self.from_media_button.clicked.connect(self.on_audio_add_from_media_button_clicked) self.from_media_button.clicked.connect(self.on_audio_add_from_media_button_clicked)

View File

@ -366,7 +366,7 @@ class SongMediaItem(MediaManagerItem):
QtGui.QMessageBox.Yes) == QtGui.QMessageBox.No: QtGui.QMessageBox.Yes) == QtGui.QMessageBox.No:
return return
self.application.set_busy_cursor() self.application.set_busy_cursor()
self.main_window.displayProgressBar(len(items)) self.main_window.display_progress_bar(len(items))
for item in items: for item in items:
item_id = item.data(QtCore.Qt.UserRole) item_id = item.data(QtCore.Qt.UserRole)
media_files = self.plugin.manager.get_all_objects(MediaFile, MediaFile.song_id == item_id) media_files = self.plugin.manager.get_all_objects(MediaFile, MediaFile.song_id == item_id)
@ -383,7 +383,7 @@ class SongMediaItem(MediaManagerItem):
log.exception(u'Could not remove directory: %s', save_path) log.exception(u'Could not remove directory: %s', save_path)
self.plugin.manager.delete_object(Song, item_id) self.plugin.manager.delete_object(Song, item_id)
self.main_window.increment_progress_bar() self.main_window.increment_progress_bar()
self.main_window.finishedProgressBar() self.main_window.finished_progress_bar()
self.application.set_normal_cursor() self.application.set_normal_cursor()
self.onSearchTextButtonClicked() self.onSearchTextButtonClicked()

View File

@ -106,12 +106,12 @@ class SongUsagePlugin(Plugin):
self.song_usage_menu.addSeparator() self.song_usage_menu.addSeparator()
self.song_usage_menu.addAction(self.song_usage_report) self.song_usage_menu.addAction(self.song_usage_report)
self.song_usage_menu.addAction(self.song_usage_delete) self.song_usage_menu.addAction(self.song_usage_delete)
self.song_usage_active_button = QtGui.QToolButton(self.main_window.statusBar) self.song_usage_active_button = QtGui.QToolButton(self.main_window.status_bar)
self.song_usage_active_button.setCheckable(True) self.song_usage_active_button.setCheckable(True)
self.song_usage_active_button.setAutoRaise(True) self.song_usage_active_button.setAutoRaise(True)
self.song_usage_active_button.setStatusTip(translate('SongUsagePlugin', 'Toggle the tracking of song usage.')) self.song_usage_active_button.setStatusTip(translate('SongUsagePlugin', 'Toggle the tracking of song usage.'))
self.song_usage_active_button.setObjectName(u'song_usage_active_button') self.song_usage_active_button.setObjectName(u'song_usage_active_button')
self.main_window.statusBar.insertPermanentWidget(1, self.song_usage_active_button) self.main_window.status_bar.insertPermanentWidget(1, self.song_usage_active_button)
self.song_usage_active_button.hide() self.song_usage_active_button.hide()
# Signals and slots # Signals and slots
QtCore.QObject.connect(self.song_usage_status, QtCore.SIGNAL(u'visibilityChanged(bool)'), QtCore.QObject.connect(self.song_usage_status, QtCore.SIGNAL(u'visibilityChanged(bool)'),