This commit is contained in:
Tim Bentley 2011-12-05 19:47:59 +00:00
commit 149a660dad
5 changed files with 117 additions and 55 deletions

View File

@ -720,7 +720,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
args = [] args = []
for a in self.arguments: for a in self.arguments:
args.extend([a]) args.extend([a])
self.serviceManagerContents.loadFile(unicode(args[0])) self.serviceManagerContents.loadFile(unicode(args[0],
sys.getfilesystemencoding()))
elif QtCore.QSettings().value( elif QtCore.QSettings().value(
self.generalSettingsSection + u'/auto open', self.generalSettingsSection + u'/auto open',
QtCore.QVariant(False)).toBool(): QtCore.QVariant(False)).toBool():
@ -1312,7 +1313,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
settings.value(u'preview splitter geometry').toByteArray()) settings.value(u'preview splitter geometry').toByteArray())
self.controlSplitter.restoreState( self.controlSplitter.restoreState(
settings.value(u'mainwindow splitter geometry').toByteArray()) settings.value(u'mainwindow splitter geometry').toByteArray())
settings.endGroup() settings.endGroup()
def saveSettings(self): def saveSettings(self):
@ -1388,6 +1388,12 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
maxRecentFiles = QtCore.QSettings().value(u'advanced/max recent files', maxRecentFiles = QtCore.QSettings().value(u'advanced/max recent files',
QtCore.QVariant(20)).toInt()[0] QtCore.QVariant(20)).toInt()[0]
if filename: if filename:
# Add some cleanup to reduce duplication in the recent file list
filename = os.path.abspath(filename)
# abspath() only capitalises the drive letter if it wasn't provided
# in the given filename which then causes duplication.
if filename[1:3] == ':\\':
filename = filename[0].upper() + filename[1:]
position = self.recentFiles.indexOf(filename) position = self.recentFiles.indexOf(filename)
if position != -1: if position != -1:
self.recentFiles.removeAt(position) self.recentFiles.removeAt(position)

View File

@ -206,15 +206,15 @@ class MediaController(object):
controller.mediabar = OpenLPToolbar(controller) controller.mediabar = OpenLPToolbar(controller)
controller.mediabar.addToolbarButton( controller.mediabar.addToolbarButton(
u'media_playback_play', u':/slides/media_playback_start.png', u'media_playback_play', u':/slides/media_playback_start.png',
translate('OpenLP.SlideController', 'Start playing media'), translate('OpenLP.SlideController', 'Start playing media.'),
controller.sendToPlugins) controller.sendToPlugins)
controller.mediabar.addToolbarButton( controller.mediabar.addToolbarButton(
u'media_playback_pause', u':/slides/media_playback_pause.png', u'media_playback_pause', u':/slides/media_playback_pause.png',
translate('OpenLP.SlideController', 'Pause playing media'), translate('OpenLP.SlideController', 'Pause playing media.'),
controller.sendToPlugins) controller.sendToPlugins)
controller.mediabar.addToolbarButton( controller.mediabar.addToolbarButton(
u'media_playback_stop', u':/slides/media_playback_stop.png', u'media_playback_stop', u':/slides/media_playback_stop.png',
translate('OpenLP.SlideController', 'Stop playing media'), translate('OpenLP.SlideController', 'Stop playing media.'),
controller.sendToPlugins) controller.sendToPlugins)
# Build the seekSlider. # Build the seekSlider.
controller.seekSlider = QtGui.QSlider(QtCore.Qt.Horizontal) controller.seekSlider = QtGui.QSlider(QtCore.Qt.Horizontal)
@ -223,7 +223,7 @@ class MediaController(object):
'OpenLP.SlideController', 'Video position.')) 'OpenLP.SlideController', 'Video position.'))
controller.seekSlider.setGeometry(QtCore.QRect(90, 260, 221, 24)) controller.seekSlider.setGeometry(QtCore.QRect(90, 260, 221, 24))
controller.seekSlider.setObjectName(u'seek_slider') controller.seekSlider.setObjectName(u'seek_slider')
controller.mediabar.addToolbarWidget(u'Seek Slider', controller.mediabar.addToolbarWidget(u'Seek Slider',
controller.seekSlider) controller.seekSlider)
# Build the volumeSlider. # Build the volumeSlider.
controller.volumeSlider = QtGui.QSlider(QtCore.Qt.Horizontal) controller.volumeSlider = QtGui.QSlider(QtCore.Qt.Horizontal)
@ -236,7 +236,7 @@ class MediaController(object):
controller.volumeSlider.setValue(controller.media_info.volume) controller.volumeSlider.setValue(controller.media_info.volume)
controller.volumeSlider.setGeometry(QtCore.QRect(90, 160, 221, 24)) controller.volumeSlider.setGeometry(QtCore.QRect(90, 160, 221, 24))
controller.volumeSlider.setObjectName(u'volume_slider') controller.volumeSlider.setObjectName(u'volume_slider')
controller.mediabar.addToolbarWidget(u'Audio Volume', controller.mediabar.addToolbarWidget(u'Audio Volume',
controller.volumeSlider) controller.volumeSlider)
control_panel.addWidget(controller.mediabar) control_panel.addWidget(controller.mediabar)
controller.mediabar.setVisible(False) controller.mediabar.setVisible(False)
@ -255,7 +255,7 @@ class MediaController(object):
def setup_display(self, display): def setup_display(self, display):
""" """
After a new display is configured, all media related widget will be After a new display is configured, all media related widget will be
created too created too
""" """
# clean up possible running old media files # clean up possible running old media files
@ -276,13 +276,13 @@ class MediaController(object):
def set_controls_visible(self, controller, value): def set_controls_visible(self, controller, value):
# Generic controls # Generic controls
controller.mediabar.setVisible(value) controller.mediabar.setVisible(value)
# Special controls: Here media type specific Controls will be enabled # Special controls: Here media type specific Controls will be enabled
# (e.g. for DVD control, ...) # (e.g. for DVD control, ...)
# TODO # TODO
def resize(self, controller, display, player): def resize(self, controller, display, player):
""" """
After Mainwindow changes or Splitter moved all related media widgets After Mainwindow changes or Splitter moved all related media widgets
have to be resized have to be resized
""" """
player.resize(display) player.resize(display)
@ -389,7 +389,7 @@ class MediaController(object):
def video_play(self, msg, status=True): def video_play(self, msg, status=True):
""" """
Responds to the request to play a loaded video Responds to the request to play a loaded video
``msg`` ``msg``
First element is the controller which should be used First element is the controller which should be used
""" """

View File

@ -402,6 +402,9 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog):
settings.endGroup() settings.endGroup()
def update_song_usage(self): def update_song_usage(self):
# Only continue when we include the song's text.
if not self.slideTextCheckBox.isChecked():
return
for index, item in enumerate(self.serviceManager.serviceItems): for index, item in enumerate(self.serviceManager.serviceItems):
# Trigger Audit requests # Trigger Audit requests
Receiver.send_message(u'print_service_started', Receiver.send_message(u'print_service_started',

View File

@ -188,6 +188,7 @@ class ActionList(object):
actions or categories. actions or categories.
""" """
instance = None instance = None
shortcut_map = {}
def __init__(self): def __init__(self):
self.categories = CategoryList() self.categories = CategoryList()
@ -226,17 +227,41 @@ class ActionList(object):
self.categories[category].actions.append(action) self.categories[category].actions.append(action)
else: else:
self.categories[category].actions.add(action, weight) self.categories[category].actions.add(action, weight)
if category is None:
# Stop here, as this action is not configurable.
return
# Load the shortcut from the config. # Load the shortcut from the config.
settings = QtCore.QSettings() settings = QtCore.QSettings()
settings.beginGroup(u'shortcuts') settings.beginGroup(u'shortcuts')
shortcuts = settings.value(action.objectName(), shortcuts = settings.value(action.objectName(),
QtCore.QVariant(action.shortcuts())).toStringList() QtCore.QVariant(action.shortcuts())).toStringList()
settings.endGroup()
if not shortcuts:
action.setShortcuts([])
return
shortcuts = map(unicode, shortcuts)
# Check the alternate shortcut first, to avoid problems when the
# alternate shortcut becomes the primary shortcut after removing the
# (initial) primary shortcut due to confllicts.
if len(shortcuts) == 2:
existing_actions = ActionList.shortcut_map.get(shortcuts[1], [])
# Check for conflicts with other actions considering the shortcut
# context.
if self._shortcut_available(existing_actions, action):
actions = ActionList.shortcut_map.get(shortcuts[1], [])
actions.append(action)
ActionList.shortcut_map[shortcuts[1]] = actions
else:
shortcuts.remove(shortcuts[1])
# Check the primary shortcut.
existing_actions = ActionList.shortcut_map.get(shortcuts[0], [])
# Check for conflicts with other actions considering the shortcut
# context.
if self._shortcut_available(existing_actions, action):
actions = ActionList.shortcut_map.get(shortcuts[0], [])
actions.append(action)
ActionList.shortcut_map[shortcuts[0]] = actions
else:
shortcuts.remove(shortcuts[0])
action.setShortcuts( action.setShortcuts(
[QtGui.QKeySequence(shortcut) for shortcut in shortcuts]) [QtGui.QKeySequence(shortcut) for shortcut in shortcuts])
settings.endGroup()
def remove_action(self, action, category=None): def remove_action(self, action, category=None):
""" """
@ -244,7 +269,7 @@ class ActionList(object):
automatically removed. automatically removed.
``action`` ``action``
The QAction object to be removed. The ``QAction`` object to be removed.
``category`` ``category``
The name (unicode string) of the category, which contains the The name (unicode string) of the category, which contains the
@ -279,6 +304,30 @@ class ActionList(object):
return return
self.categories.add(name, weight) self.categories.add(name, weight)
def _shortcut_available(self, existing_actions, action):
"""
Checks if the given ``action`` may use its assigned shortcut(s) or not.
Returns ``True`` or ``False.
``existing_actions``
A list of actions which already use a particular shortcut.
``action``
The action which wants to use a particular shortcut.
"""
for existing_action in existing_actions:
if action is existing_action:
continue
if existing_action.parent() is action.parent():
return False
if existing_action.shortcutContext() in [QtCore.Qt.WindowShortcut,
QtCore.Qt.ApplicationShortcut]:
return False
if action.shortcutContext() in [QtCore.Qt.WindowShortcut,
QtCore.Qt.ApplicationShortcut]:
return False
return True
class CategoryOrder(object): class CategoryOrder(object):
""" """

View File

@ -30,7 +30,7 @@ song databases into the current installation database.
""" """
import logging import logging
from sqlalchemy import create_engine, MetaData from sqlalchemy import create_engine, MetaData, Table
from sqlalchemy.orm import class_mapper, mapper, relation, scoped_session, \ from sqlalchemy.orm import class_mapper, mapper, relation, scoped_session, \
sessionmaker sessionmaker
from sqlalchemy.orm.exc import UnmappedClassError from sqlalchemy.orm.exc import UnmappedClassError
@ -39,46 +39,11 @@ from openlp.core.lib import translate
from openlp.core.lib.db import BaseModel from openlp.core.lib.db import BaseModel
from openlp.core.ui.wizard import WizardStrings from openlp.core.ui.wizard import WizardStrings
from openlp.plugins.songs.lib import clean_song from openlp.plugins.songs.lib import clean_song
from openlp.plugins.songs.lib.db import Author, Book, MediaFile, Song, Topic from openlp.plugins.songs.lib.db import Author, Book, Song, Topic, MediaFile
from songimport import SongImport from songimport import SongImport
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class OldAuthor(BaseModel):
"""
Author model
"""
pass
class OldBook(BaseModel):
"""
Book model
"""
pass
class OldMediaFile(BaseModel):
"""
MediaFile model
"""
pass
class OldSong(BaseModel):
"""
Song model
"""
pass
class OldTopic(BaseModel):
"""
Topic model
"""
pass
class OpenLPSongImport(SongImport): class OpenLPSongImport(SongImport):
""" """
The :class:`OpenLPSongImport` class provides OpenLP with the ability to The :class:`OpenLPSongImport` class provides OpenLP with the ability to
@ -101,6 +66,41 @@ class OpenLPSongImport(SongImport):
""" """
Run the import for an OpenLP version 2 song database. Run the import for an OpenLP version 2 song database.
""" """
class OldAuthor(BaseModel):
"""
Author model
"""
pass
class OldBook(BaseModel):
"""
Book model
"""
pass
class OldMediaFile(BaseModel):
"""
MediaFile model
"""
pass
class OldSong(BaseModel):
"""
Song model
"""
pass
class OldTopic(BaseModel):
"""
Topic model
"""
pass
if not self.importSource.endswith(u'.sqlite'): if not self.importSource.endswith(u'.sqlite'):
self.logError(self.importSource, self.logError(self.importSource,
translate('SongsPlugin.OpenLPSongImport', translate('SongsPlugin.OpenLPSongImport',
@ -121,6 +121,7 @@ class OpenLPSongImport(SongImport):
source_topics_table = source_meta.tables[u'topics'] source_topics_table = source_meta.tables[u'topics']
source_authors_songs_table = source_meta.tables[u'authors_songs'] source_authors_songs_table = source_meta.tables[u'authors_songs']
source_songs_topics_table = source_meta.tables[u'songs_topics'] source_songs_topics_table = source_meta.tables[u'songs_topics']
source_media_files_songs_table = None
if has_media_files: if has_media_files:
source_media_files_table = source_meta.tables[u'media_files'] source_media_files_table = source_meta.tables[u'media_files']
source_media_files_songs_table = \ source_media_files_songs_table = \
@ -137,13 +138,16 @@ class OpenLPSongImport(SongImport):
secondary=source_songs_topics_table) secondary=source_songs_topics_table)
} }
if has_media_files: if has_media_files:
if source_media_files_songs_table: if isinstance(source_media_files_songs_table, Table):
song_props['media_files'] = relation(OldMediaFile, song_props['media_files'] = relation(OldMediaFile,
backref='songs', backref='songs',
secondary=source_media_files_songs_table) secondary=source_media_files_songs_table)
else: else:
song_props['media_files'] = relation(OldMediaFile, song_props['media_files'] = relation(OldMediaFile,
backref='songs') backref='songs',
foreign_keys=[source_media_files_table.c.song_id],
primaryjoin=source_songs_table.c.id == \
source_media_files_table.c.song_id)
try: try:
class_mapper(OldAuthor) class_mapper(OldAuthor)
except UnmappedClassError: except UnmappedClassError: