forked from openlp/openlp
Move adding shortcuts to __default_dict__ into __init__ to avoid having QKeySequences being run before a QApplication is created and crashing
This commit is contained in:
parent
b858b0b103
commit
86c4acab9c
@ -26,7 +26,7 @@ import datetime
|
||||
import logging
|
||||
import os
|
||||
|
||||
from PyQt5 import QtCore, QtGui
|
||||
from PyQt5 import QtCore, QtGui, QtWidgets
|
||||
|
||||
from openlp.core.common import ThemeLevel, SlideLimits, UiStrings, is_win, is_linux
|
||||
|
||||
@ -170,6 +170,80 @@ class Settings(QtCore.QSettings):
|
||||
'SettingsImport/Make_Changes': 'At_Own_RISK',
|
||||
'SettingsImport/type': 'OpenLP_settings_export',
|
||||
'SettingsImport/version': '',
|
||||
'themes/global theme': '',
|
||||
'themes/last directory': '',
|
||||
'themes/last directory export': '',
|
||||
'themes/last directory import': '',
|
||||
'themes/theme level': ThemeLevel.Song,
|
||||
'themes/wrap footer': False,
|
||||
'user interface/live panel': True,
|
||||
'user interface/live splitter geometry': QtCore.QByteArray(),
|
||||
'user interface/lock panel': False,
|
||||
'user interface/main window geometry': QtCore.QByteArray(),
|
||||
'user interface/main window position': QtCore.QPoint(0, 0),
|
||||
'user interface/main window splitter geometry': QtCore.QByteArray(),
|
||||
'user interface/main window state': QtCore.QByteArray(),
|
||||
'user interface/preview panel': True,
|
||||
'user interface/preview splitter geometry': QtCore.QByteArray(),
|
||||
'projector/db type': 'sqlite',
|
||||
'projector/db username': '',
|
||||
'projector/db password': '',
|
||||
'projector/db hostname': '',
|
||||
'projector/db database': '',
|
||||
'projector/enable': True,
|
||||
'projector/connect on start': False,
|
||||
'projector/last directory import': '',
|
||||
'projector/last directory export': '',
|
||||
'projector/poll time': 20, # PJLink timeout is 30 seconds
|
||||
'projector/socket timeout': 5, # 5 second socket timeout
|
||||
'projector/source dialog type': 0 # Source select dialog box type
|
||||
}
|
||||
__file_path__ = ''
|
||||
__obsolete_settings__ = [
|
||||
# Changed during 2.2.x development.
|
||||
# ('advanced/stylesheet fix', '', []),
|
||||
# ('general/recent files', 'core/recent files', [(recent_files_conv, None)]),
|
||||
('songs/search as type', 'advanced/search as type', []),
|
||||
('media/players', 'media/players_temp', [(media_players_conv, None)]), # Convert phonon to system
|
||||
('media/players_temp', 'media/players', []) # Move temp setting from above to correct setting
|
||||
]
|
||||
|
||||
@staticmethod
|
||||
def extend_default_settings(default_values):
|
||||
"""
|
||||
Static method to merge the given ``default_values`` with the ``Settings.__default_settings__``.
|
||||
|
||||
:param default_values: A dict with setting keys and their default values.
|
||||
"""
|
||||
Settings.__default_settings__.update(default_values)
|
||||
|
||||
@staticmethod
|
||||
def set_filename(ini_file):
|
||||
"""
|
||||
Sets the complete path to an Ini file to be used by Settings objects.
|
||||
|
||||
Does not affect existing Settings objects.
|
||||
"""
|
||||
Settings.__file_path__ = ini_file
|
||||
|
||||
@staticmethod
|
||||
def set_up_default_values():
|
||||
"""
|
||||
This static method is called on start up. It is used to perform any operation on the __default_settings__ dict.
|
||||
"""
|
||||
# Make sure the string is translated (when building the dict the string is not translated because the translate
|
||||
# function was not set up as this stage).
|
||||
Settings.__default_settings__['advanced/default service name'] = UiStrings().DefaultServiceName
|
||||
|
||||
def __init__(self, *args):
|
||||
"""
|
||||
Constructor which checks if this should be a native settings object, or an INI file.
|
||||
"""
|
||||
if not args and Settings.__file_path__ and Settings.defaultFormat() == Settings.IniFormat:
|
||||
QtCore.QSettings.__init__(self, Settings.__file_path__, Settings.IniFormat)
|
||||
else:
|
||||
QtCore.QSettings.__init__(self, *args)
|
||||
Settings.__default_settings__.update({
|
||||
'shortcuts/aboutItem': [QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_F1)],
|
||||
'shortcuts/addToService': [],
|
||||
'shortcuts/audioPauseItem': [],
|
||||
@ -319,80 +393,8 @@ class Settings(QtCore.QSettings):
|
||||
'shortcuts/viewPreviewPanel': [QtGui.QKeySequence(QtCore.Qt.Key_F11)],
|
||||
'shortcuts/viewLivePanel': [QtGui.QKeySequence(QtCore.Qt.Key_F12)],
|
||||
'shortcuts/viewServiceManagerItem': [QtGui.QKeySequence(QtCore.Qt.Key_F9)],
|
||||
'shortcuts/webSiteItem': [],
|
||||
'themes/global theme': '',
|
||||
'themes/last directory': '',
|
||||
'themes/last directory export': '',
|
||||
'themes/last directory import': '',
|
||||
'themes/theme level': ThemeLevel.Song,
|
||||
'themes/wrap footer': False,
|
||||
'user interface/live panel': True,
|
||||
'user interface/live splitter geometry': QtCore.QByteArray(),
|
||||
'user interface/lock panel': False,
|
||||
'user interface/main window geometry': QtCore.QByteArray(),
|
||||
'user interface/main window position': QtCore.QPoint(0, 0),
|
||||
'user interface/main window splitter geometry': QtCore.QByteArray(),
|
||||
'user interface/main window state': QtCore.QByteArray(),
|
||||
'user interface/preview panel': True,
|
||||
'user interface/preview splitter geometry': QtCore.QByteArray(),
|
||||
'projector/db type': 'sqlite',
|
||||
'projector/db username': '',
|
||||
'projector/db password': '',
|
||||
'projector/db hostname': '',
|
||||
'projector/db database': '',
|
||||
'projector/enable': True,
|
||||
'projector/connect on start': False,
|
||||
'projector/last directory import': '',
|
||||
'projector/last directory export': '',
|
||||
'projector/poll time': 20, # PJLink timeout is 30 seconds
|
||||
'projector/socket timeout': 5, # 5 second socket timeout
|
||||
'projector/source dialog type': 0 # Source select dialog box type
|
||||
}
|
||||
__file_path__ = ''
|
||||
__obsolete_settings__ = [
|
||||
# Changed during 2.2.x development.
|
||||
# ('advanced/stylesheet fix', '', []),
|
||||
# ('general/recent files', 'core/recent files', [(recent_files_conv, None)]),
|
||||
('songs/search as type', 'advanced/search as type', []),
|
||||
('media/players', 'media/players_temp', [(media_players_conv, None)]), # Convert phonon to system
|
||||
('media/players_temp', 'media/players', []) # Move temp setting from above to correct setting
|
||||
]
|
||||
|
||||
@staticmethod
|
||||
def extend_default_settings(default_values):
|
||||
"""
|
||||
Static method to merge the given ``default_values`` with the ``Settings.__default_settings__``.
|
||||
|
||||
:param default_values: A dict with setting keys and their default values.
|
||||
"""
|
||||
Settings.__default_settings__.update(default_values)
|
||||
|
||||
@staticmethod
|
||||
def set_filename(ini_file):
|
||||
"""
|
||||
Sets the complete path to an Ini file to be used by Settings objects.
|
||||
|
||||
Does not affect existing Settings objects.
|
||||
"""
|
||||
Settings.__file_path__ = ini_file
|
||||
|
||||
@staticmethod
|
||||
def set_up_default_values():
|
||||
"""
|
||||
This static method is called on start up. It is used to perform any operation on the __default_settings__ dict.
|
||||
"""
|
||||
# Make sure the string is translated (when building the dict the string is not translated because the translate
|
||||
# function was not set up as this stage).
|
||||
Settings.__default_settings__['advanced/default service name'] = UiStrings().DefaultServiceName
|
||||
|
||||
def __init__(self, *args):
|
||||
"""
|
||||
Constructor which checks if this should be a native settings object, or an INI file.
|
||||
"""
|
||||
if not args and Settings.__file_path__ and Settings.defaultFormat() == Settings.IniFormat:
|
||||
QtCore.QSettings.__init__(self, Settings.__file_path__, Settings.IniFormat)
|
||||
else:
|
||||
QtCore.QSettings.__init__(self, *args)
|
||||
'shortcuts/webSiteItem': []
|
||||
})
|
||||
|
||||
def get_default_value(self, key):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user