forked from openlp/openlp
Merge branch 'settings_4' into 'master'
Settings 4 Fix breakage in editing songs Move the settings enums to a common location. Fix broken tests. See merge request openlp/openlp!101
This commit is contained in:
commit
d760134a0d
109
openlp/core/common/enum.py
Normal file
109
openlp/core/common/enum.py
Normal file
@ -0,0 +1,109 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
##########################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# ---------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2019 OpenLP Developers #
|
||||
# ---------------------------------------------------------------------- #
|
||||
# This program is free software: you can redistribute it and/or modify #
|
||||
# it under the terms of the GNU General Public License as published by #
|
||||
# the Free Software Foundation, either version 3 of the License, or #
|
||||
# (at your option) any later version. #
|
||||
# #
|
||||
# This program is distributed in the hope that it will be useful, #
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
||||
# GNU General Public License for more details. #
|
||||
# #
|
||||
# You should have received a copy of the GNU General Public License #
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
||||
##########################################################################
|
||||
"""
|
||||
The :mod:`enumm` module provides enumm functions.
|
||||
"""
|
||||
from enum import IntEnum, unique
|
||||
|
||||
|
||||
@unique
|
||||
class AlertLocation(IntEnum):
|
||||
"""
|
||||
This is an enumeration class which controls where Alerts are placed on the screen.
|
||||
|
||||
``Top``
|
||||
Place the text at the top of the screen.
|
||||
|
||||
``Middle``
|
||||
Place the text in the middle of the screen.
|
||||
|
||||
``Bottom``
|
||||
Place the text at the bottom of the screen.
|
||||
"""
|
||||
Top = 0
|
||||
Middle = 1
|
||||
Bottom = 2
|
||||
|
||||
|
||||
@unique
|
||||
class BibleSearch(IntEnum):
|
||||
"""
|
||||
Enumeration class for the different search types for the "Search" tab.
|
||||
"""
|
||||
Reference = 1
|
||||
Text = 2
|
||||
Combined = 3
|
||||
|
||||
|
||||
@unique
|
||||
class CustomSearch(IntEnum):
|
||||
"""
|
||||
An enumeration for custom search methods.
|
||||
"""
|
||||
Titles = 1
|
||||
Themes = 2
|
||||
|
||||
|
||||
@unique
|
||||
class DisplayStyle(IntEnum):
|
||||
"""
|
||||
An enumeration for bible text bracket display styles.
|
||||
"""
|
||||
NoBrackets = 0
|
||||
Round = 1
|
||||
Curly = 2
|
||||
Square = 3
|
||||
|
||||
|
||||
@unique
|
||||
class LayoutStyle(IntEnum):
|
||||
"""
|
||||
An enumeration for bible screen layout styles.
|
||||
"""
|
||||
VersePerSlide = 0
|
||||
VersePerLine = 1
|
||||
Continuous = 2
|
||||
|
||||
|
||||
@unique
|
||||
class LanguageSelection(IntEnum):
|
||||
"""
|
||||
An enumeration for bible bookname language. And standard strings for use throughout the bibles plugin.
|
||||
"""
|
||||
Bible = 0
|
||||
Application = 1
|
||||
English = 2
|
||||
|
||||
|
||||
@unique
|
||||
class SongSearch(IntEnum):
|
||||
"""
|
||||
An enumeration for song search methods.
|
||||
"""
|
||||
Entire = 1
|
||||
Titles = 2
|
||||
Lyrics = 3
|
||||
Authors = 4
|
||||
Topics = 5
|
||||
Books = 6
|
||||
Themes = 7
|
||||
Copyright = 8
|
||||
CCLInumber = 9
|
@ -43,24 +43,6 @@ class HideMode(object):
|
||||
Screen = 3
|
||||
|
||||
|
||||
class AlertLocation(object):
|
||||
"""
|
||||
This is an enumeration class which controls where Alerts are placed on the screen.
|
||||
|
||||
``Top``
|
||||
Place the text at the top of the screen.
|
||||
|
||||
``Middle``
|
||||
Place the text in the middle of the screen.
|
||||
|
||||
``Bottom``
|
||||
Place the text at the bottom of the screen.
|
||||
"""
|
||||
Top = 0
|
||||
Middle = 1
|
||||
Bottom = 2
|
||||
|
||||
|
||||
class DisplayControllerType(object):
|
||||
"""
|
||||
This is an enumeration class which says where a display controller originated from.
|
||||
|
@ -26,13 +26,13 @@ from PyQt5 import QtGui
|
||||
from openlp.core.state import State
|
||||
from openlp.core.api.http import register_endpoint
|
||||
from openlp.core.common.actions import ActionList
|
||||
from openlp.core.common.enum import AlertLocation
|
||||
from openlp.core.common.i18n import UiStrings, translate
|
||||
from openlp.core.common.settings import Settings
|
||||
from openlp.core.lib.db import Manager
|
||||
from openlp.core.lib.plugin import Plugin, StringContent
|
||||
from openlp.core.lib.theme import VerticalType
|
||||
from openlp.core.lib.ui import create_action
|
||||
from openlp.core.ui import AlertLocation
|
||||
from openlp.core.ui.icons import UiIcons
|
||||
from openlp.plugins.alerts.endpoint import api_alerts_endpoint, alerts_endpoint
|
||||
from openlp.plugins.alerts.forms.alertform import AlertForm
|
||||
|
@ -24,15 +24,15 @@ import logging
|
||||
from openlp.core.state import State
|
||||
from openlp.core.api.http import register_endpoint
|
||||
from openlp.core.common.actions import ActionList
|
||||
from openlp.core.common.enum import BibleSearch, LayoutStyle, DisplayStyle, LanguageSelection
|
||||
from openlp.core.common.i18n import UiStrings, translate
|
||||
from openlp.core.ui.icons import UiIcons
|
||||
from openlp.core.lib.plugin import Plugin, StringContent
|
||||
from openlp.core.lib.ui import create_action
|
||||
from openlp.plugins.bibles.endpoint import api_bibles_endpoint, bibles_endpoint
|
||||
from openlp.plugins.bibles.lib import LayoutStyle, DisplayStyle, LanguageSelection
|
||||
from openlp.plugins.bibles.lib.biblestab import BiblesTab
|
||||
from openlp.plugins.bibles.lib.manager import BibleManager
|
||||
from openlp.plugins.bibles.lib.mediaitem import BibleMediaItem, BibleSearch
|
||||
from openlp.plugins.bibles.lib.mediaitem import BibleMediaItem
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
@ -21,10 +21,11 @@
|
||||
|
||||
from PyQt5 import QtCore, QtWidgets
|
||||
|
||||
from openlp.core.common.enum import LanguageSelection
|
||||
from openlp.core.common.i18n import translate
|
||||
from openlp.core.lib.ui import create_button_box
|
||||
from openlp.core.ui.icons import UiIcons
|
||||
from openlp.plugins.bibles.lib import BibleStrings, LanguageSelection
|
||||
from openlp.plugins.bibles.lib import BibleStrings
|
||||
from openlp.plugins.bibles.lib.db import BiblesResourcesDB
|
||||
|
||||
|
||||
|
@ -36,34 +36,6 @@ REFERENCE_MATCHES = {}
|
||||
REFERENCE_SEPARATORS = {}
|
||||
|
||||
|
||||
class LayoutStyle(object):
|
||||
"""
|
||||
An enumeration for bible screen layout styles.
|
||||
"""
|
||||
VersePerSlide = 0
|
||||
VersePerLine = 1
|
||||
Continuous = 2
|
||||
|
||||
|
||||
class DisplayStyle(object):
|
||||
"""
|
||||
An enumeration for bible text bracket display styles.
|
||||
"""
|
||||
NoBrackets = 0
|
||||
Round = 1
|
||||
Curly = 2
|
||||
Square = 3
|
||||
|
||||
|
||||
class LanguageSelection(object):
|
||||
"""
|
||||
An enumeration for bible bookname language. And standard strings for use throughout the bibles plugin.
|
||||
"""
|
||||
Bible = 0
|
||||
Application = 1
|
||||
English = 2
|
||||
|
||||
|
||||
class BibleStrings(metaclass=Singleton):
|
||||
"""
|
||||
Provide standard strings for objects to use.
|
||||
|
@ -23,13 +23,13 @@ import logging
|
||||
|
||||
from PyQt5 import QtCore, QtGui, QtWidgets
|
||||
|
||||
from openlp.core.common.enum import DisplayStyle, LanguageSelection, LayoutStyle
|
||||
from openlp.core.common.i18n import UiStrings, translate
|
||||
from openlp.core.common.registry import Registry
|
||||
from openlp.core.common.settings import Settings
|
||||
from openlp.core.lib.settingstab import SettingsTab
|
||||
from openlp.core.lib.ui import find_and_set_in_combo_box
|
||||
from openlp.plugins.bibles.lib import DisplayStyle, LanguageSelection, LayoutStyle, get_reference_separator, \
|
||||
update_reference_separators
|
||||
from openlp.plugins.bibles.lib import get_reference_separator, update_reference_separators
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
@ -33,11 +33,12 @@ from sqlalchemy.orm import class_mapper, mapper, relation
|
||||
from sqlalchemy.orm.exc import UnmappedClassError
|
||||
|
||||
from openlp.core.common import clean_filename
|
||||
from openlp.core.common.enum import LanguageSelection
|
||||
from openlp.core.common.applocation import AppLocation
|
||||
from openlp.core.common.i18n import translate
|
||||
from openlp.core.lib.db import BaseModel, Manager, init_db
|
||||
from openlp.core.lib.ui import critical_error_message_box
|
||||
from openlp.plugins.bibles.lib import BibleStrings, LanguageSelection, upgrade
|
||||
from openlp.plugins.bibles.lib import BibleStrings, upgrade
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@ -307,7 +308,8 @@ class BibleDB(Manager):
|
||||
:rtype: list[int]
|
||||
"""
|
||||
log.debug('get_book_ref_id_by_localised_name("{book}", "{lang}")'.format(book=book, lang=language_selection))
|
||||
from openlp.plugins.bibles.lib import LanguageSelection, BibleStrings
|
||||
from openlp.core.common.enum import LanguageSelection
|
||||
from openlp.plugins.bibles.lib import BibleStrings
|
||||
book_names = BibleStrings().BookNames
|
||||
# escape reserved characters
|
||||
for character in RESERVED_CHARACTERS:
|
||||
|
@ -22,11 +22,12 @@ import logging
|
||||
from pathlib import Path
|
||||
|
||||
from openlp.core.common import delete_file
|
||||
from openlp.core.common.enum import LanguageSelection
|
||||
from openlp.core.common.applocation import AppLocation
|
||||
from openlp.core.common.i18n import UiStrings, translate
|
||||
from openlp.core.common.mixins import LogMixin, RegistryProperties
|
||||
from openlp.core.common.settings import Settings
|
||||
from openlp.plugins.bibles.lib import LanguageSelection, parse_reference
|
||||
from openlp.plugins.bibles.lib import parse_reference
|
||||
from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta
|
||||
|
||||
from .importers.csvbible import CSVBible
|
||||
|
@ -25,6 +25,7 @@ from enum import IntEnum, unique
|
||||
|
||||
from PyQt5 import QtCore, QtWidgets
|
||||
|
||||
from openlp.core.common.enum import BibleSearch, DisplayStyle, LayoutStyle
|
||||
from openlp.core.common.i18n import UiStrings, get_locale_key, translate
|
||||
from openlp.core.common.registry import Registry
|
||||
from openlp.core.common.settings import Settings
|
||||
@ -37,8 +38,7 @@ from openlp.core.ui.icons import UiIcons
|
||||
from openlp.core.widgets.edits import SearchEdit
|
||||
from openlp.plugins.bibles.forms.bibleimportform import BibleImportForm
|
||||
from openlp.plugins.bibles.forms.editbibleform import EditBibleForm
|
||||
from openlp.plugins.bibles.lib import DisplayStyle, LayoutStyle, get_reference_match, \
|
||||
get_reference_separator
|
||||
from openlp.plugins.bibles.lib import get_reference_match, get_reference_separator
|
||||
from openlp.plugins.bibles.lib.versereferencelist import VerseReferenceList
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@ -53,16 +53,6 @@ def get_reference_separators():
|
||||
'list': get_reference_separator('sep_l_display')}
|
||||
|
||||
|
||||
@unique
|
||||
class BibleSearch(IntEnum):
|
||||
"""
|
||||
Enumeration class for the different search types for the "Search" tab.
|
||||
"""
|
||||
Reference = 1
|
||||
Text = 2
|
||||
Combined = 3
|
||||
|
||||
|
||||
@unique
|
||||
class ResultsTab(IntEnum):
|
||||
"""
|
||||
|
@ -27,6 +27,7 @@ import logging
|
||||
|
||||
from openlp.core.state import State
|
||||
from openlp.core.api.http import register_endpoint
|
||||
from openlp.core.common.enum import CustomSearch
|
||||
from openlp.core.common.i18n import translate
|
||||
from openlp.core.lib import build_icon
|
||||
from openlp.core.lib.db import Manager
|
||||
@ -34,7 +35,7 @@ from openlp.core.lib.plugin import Plugin, StringContent
|
||||
from openlp.core.ui.icons import UiIcons
|
||||
from openlp.plugins.custom.endpoint import api_custom_endpoint, custom_endpoint
|
||||
from openlp.plugins.custom.lib.db import CustomSlide, init_schema
|
||||
from openlp.plugins.custom.lib.mediaitem import CustomMediaItem, CustomSearch
|
||||
from openlp.plugins.custom.lib.mediaitem import CustomMediaItem
|
||||
from openlp.plugins.custom.lib.customtab import CustomTab
|
||||
|
||||
|
||||
|
@ -24,6 +24,7 @@ import logging
|
||||
from PyQt5 import QtCore, QtWidgets
|
||||
from sqlalchemy.sql import and_, func, or_
|
||||
|
||||
from openlp.core.common.enum import CustomSearch
|
||||
from openlp.core.common.i18n import UiStrings, translate
|
||||
from openlp.core.common.registry import Registry
|
||||
from openlp.core.common.settings import Settings
|
||||
@ -41,14 +42,6 @@ from openlp.plugins.custom.lib.db import CustomSlide
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class CustomSearch(object):
|
||||
"""
|
||||
An enumeration for custom search methods.
|
||||
"""
|
||||
Titles = 1
|
||||
Themes = 2
|
||||
|
||||
|
||||
class CustomMediaItem(MediaManagerItem):
|
||||
"""
|
||||
This is the custom media manager item for Custom Slides.
|
||||
|
@ -228,8 +228,7 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties):
|
||||
:param media: The media
|
||||
:param target_group:
|
||||
"""
|
||||
# TODO needs to be fixed as no idea why this fails
|
||||
# media.sort(key=lambda file_path: get_natural_key(file_path.name))
|
||||
media.sort(key=lambda file_path: get_natural_key(os.path.split(str(file_path))[1]))
|
||||
file_name = translate('MediaPlugin.MediaItem', 'Live Stream')
|
||||
item_name = QtWidgets.QListWidgetItem(file_name)
|
||||
item_name.setIcon(UiIcons().video)
|
||||
@ -281,13 +280,13 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties):
|
||||
:return: The media list
|
||||
"""
|
||||
media_file_paths = Settings().value(self.settings_section + '/media files')
|
||||
media_file_paths.sort(key=lambda file_path: get_natural_key(file_path.name))
|
||||
media_file_paths.sort(key=lambda file_path: get_natural_key(os.path.split(str(file_path))[1]))
|
||||
if media_type == MediaType.Audio:
|
||||
extension = AUDIO_EXT
|
||||
else:
|
||||
extension = VIDEO_EXT
|
||||
extension = [x[1:] for x in extension]
|
||||
media = [x for x in media_file_paths if x.suffix in extension]
|
||||
media = [x for x in media_file_paths if os.path.splitext(x)[1] in extension]
|
||||
return media
|
||||
|
||||
def search(self, string, show_error):
|
||||
|
@ -28,6 +28,7 @@ from sqlalchemy.sql import and_, or_
|
||||
|
||||
from openlp.core.state import State
|
||||
from openlp.core.common.applocation import AppLocation
|
||||
from openlp.core.common.enum import SongSearch
|
||||
from openlp.core.common.i18n import UiStrings, get_natural_key, translate
|
||||
from openlp.core.common.path import create_paths
|
||||
from openlp.core.common.registry import Registry
|
||||
@ -51,21 +52,6 @@ from openlp.plugins.songs.lib.ui import SongStrings
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class SongSearch(object):
|
||||
"""
|
||||
An enumeration for song search methods.
|
||||
"""
|
||||
Entire = 1
|
||||
Titles = 2
|
||||
Lyrics = 3
|
||||
Authors = 4
|
||||
Topics = 5
|
||||
Books = 6
|
||||
Themes = 7
|
||||
Copyright = 8
|
||||
CCLInumber = 9
|
||||
|
||||
|
||||
class SongMediaItem(MediaManagerItem):
|
||||
"""
|
||||
This is the custom media manager item for Songs.
|
||||
|
@ -33,6 +33,7 @@ from PyQt5 import QtCore, QtWidgets
|
||||
from openlp.core.state import State
|
||||
from openlp.core.api.http import register_endpoint
|
||||
from openlp.core.common.actions import ActionList
|
||||
from openlp.core.common.enum import SongSearch
|
||||
from openlp.core.common.i18n import UiStrings, translate
|
||||
from openlp.core.common.registry import Registry
|
||||
from openlp.core.lib import build_icon
|
||||
@ -48,7 +49,7 @@ from openlp.plugins.songs.lib import clean_song, upgrade
|
||||
from openlp.plugins.songs.lib.db import Song, init_schema
|
||||
from openlp.plugins.songs.lib.importer import SongFormat
|
||||
from openlp.plugins.songs.lib.importers.openlp import OpenLPSongImport
|
||||
from openlp.plugins.songs.lib.mediaitem import SongMediaItem, SongSearch
|
||||
from openlp.plugins.songs.lib.mediaitem import SongMediaItem
|
||||
from openlp.plugins.songs.lib.songstab import SongsTab
|
||||
|
||||
|
||||
|
@ -24,9 +24,9 @@ Functional tests to test the Bible Manager class and related methods.
|
||||
from unittest import TestCase
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from openlp.core.common.enum import LanguageSelection
|
||||
from openlp.core.common.registry import Registry
|
||||
from openlp.core.common.settings import Settings
|
||||
from openlp.plugins.bibles.lib import LanguageSelection
|
||||
from openlp.plugins.bibles.lib.manager import BibleManager
|
||||
from tests.helpers.testmixin import TestMixin
|
||||
from tests.utils.constants import TEST_RESOURCES_PATH
|
||||
|
@ -24,9 +24,10 @@ This module contains tests for the lib submodule of the Bibles plugin.
|
||||
from unittest import TestCase
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from openlp.core.common.enum import LanguageSelection
|
||||
from openlp.core.common.registry import Registry
|
||||
from openlp.core.common.settings import Settings
|
||||
from openlp.plugins.bibles.lib import LanguageSelection, parse_reference
|
||||
from openlp.plugins.bibles.lib import parse_reference
|
||||
from openlp.plugins.bibles.lib.manager import BibleManager
|
||||
from tests.helpers.testmixin import TestMixin
|
||||
from tests.utils.constants import TEST_RESOURCES_PATH
|
||||
|
Loading…
Reference in New Issue
Block a user