forked from openlp/openlp
Head r1824
This commit is contained in:
commit
fd8525bf89
@ -188,7 +188,6 @@ 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()
|
||||||
@ -227,41 +226,17 @@ 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):
|
||||||
"""
|
"""
|
||||||
@ -269,7 +244,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
|
||||||
@ -304,30 +279,6 @@ 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):
|
||||||
"""
|
"""
|
||||||
|
@ -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
|
||||||
@ -44,41 +44,6 @@ 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',
|
||||||
@ -138,7 +138,7 @@ 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 is not None:
|
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)
|
||||||
|
Loading…
Reference in New Issue
Block a user