This commit is contained in:
Tim Bentley 2011-07-14 17:24:35 +01:00
commit 9cc06d3e29
6 changed files with 48 additions and 74 deletions

View File

@ -276,31 +276,22 @@ class Ui_MainWindow(object):
u'settingsConfigureItem', u':/system/system_settings.png', u'settingsConfigureItem', u':/system/system_settings.png',
category=UiStrings().Settings) category=UiStrings().Settings)
action_list.add_category(UiStrings().Help, CategoryOrder.standardMenu) action_list.add_category(UiStrings().Help, CategoryOrder.standardMenu)
self.helpDocumentationItem = icon_action(mainWindow, self.aboutItem = shortcut_action(mainWindow, u'aboutItem',
u'helpDocumentationItem', u':/system/system_help_contents.png', [QtGui.QKeySequence(u'Ctrl+F1')], self.onAboutItemClicked,
category=None)#UiStrings().Help)
self.helpDocumentationItem.setEnabled(False)
self.helpAboutItem = shortcut_action(mainWindow, u'helpAboutItem',
[QtGui.QKeySequence(u'Ctrl+F1')], self.onHelpAboutItemClicked,
u':/system/system_about.png', category=UiStrings().Help) u':/system/system_about.png', category=UiStrings().Help)
if os.name == u'nt': if os.name == u'nt':
self.localHelpFile = os.path.join( self.localHelpFile = os.path.join(
AppLocation.get_directory(AppLocation.AppDir), 'OpenLP.chm') AppLocation.get_directory(AppLocation.AppDir), 'OpenLP.chm')
self.helpLocalHelpItem = shortcut_action( self.offlineHelpItem = shortcut_action(
mainWindow, u'helpLocalHelpItem', [QtGui.QKeySequence(u'F1')], mainWindow, u'offlineHelpItem', [QtGui.QKeySequence(u'F1')],
self.onHelpLocalHelpClicked, u':/system/system_about.png', self.onOfflineHelpClicked,
category=UiStrings().Help) u':/system/system_help_contents.png', category=UiStrings().Help)
self.helpOnlineHelpItem = shortcut_action( self.onlineHelpItem = shortcut_action(
mainWindow, u'helpOnlineHelpItem', [QtGui.QKeySequence(u'Alt+F1')], mainWindow, u'onlineHelpItem',
self.onHelpOnlineHelpClicked, u':/system/system_online_help.png', [QtGui.QKeySequence(u'Alt+F1')], self.onOnlineHelpClicked,
category=UiStrings().Help) u':/system/system_online_help.png', category=UiStrings().Help)
else: self.webSiteItem = base_action(
self.helpOnlineHelpItem = shortcut_action( mainWindow, u'webSiteItem', category=UiStrings().Help)
mainWindow, u'helpOnlineHelpItem', [QtGui.QKeySequence(u'F1')],
self.onHelpOnlineHelpClicked, u':/system/system_online_help.png',
category=UiStrings().Help)
self.helpWebSiteItem = base_action(
mainWindow, u'helpWebSiteItem', category=UiStrings().Help)
add_actions(self.fileImportMenu, add_actions(self.fileImportMenu,
(self.importThemeItem, self.importLanguageItem)) (self.importThemeItem, self.importLanguageItem))
add_actions(self.fileExportMenu, add_actions(self.fileExportMenu,
@ -333,14 +324,13 @@ class Ui_MainWindow(object):
add_actions(self.toolsMenu, (self.toolsAddToolItem, None)) add_actions(self.toolsMenu, (self.toolsAddToolItem, None))
add_actions(self.toolsMenu, (self.toolsOpenDataFolder, None)) add_actions(self.toolsMenu, (self.toolsOpenDataFolder, None))
add_actions(self.toolsMenu, [self.updateThemeImages]) add_actions(self.toolsMenu, [self.updateThemeImages])
add_actions(self.helpMenu, (self.helpDocumentationItem, None))
if os.name == u'nt': if os.name == u'nt':
add_actions(self.helpMenu, (self.helpLocalHelpItem, add_actions(self.helpMenu, (self.offlineHelpItem,
self.helpOnlineHelpItem, None, self.helpWebSiteItem, self.onlineHelpItem, None, self.webSiteItem,
self.helpAboutItem)) self.aboutItem))
else: else:
add_actions(self.helpMenu, (self.helpOnlineHelpItem, None, add_actions(self.helpMenu, (self.onlineHelpItem, None,
self.helpWebSiteItem, self.helpAboutItem)) self.webSiteItem, self.aboutItem))
add_actions(self.menuBar, (self.fileMenu.menuAction(), add_actions(self.menuBar, (self.fileMenu.menuAction(),
self.viewMenu.menuAction(), self.toolsMenu.menuAction(), self.viewMenu.menuAction(), self.toolsMenu.menuAction(),
self.settingsMenu.menuAction(), self.helpMenu.menuAction())) self.settingsMenu.menuAction(), self.helpMenu.menuAction()))
@ -355,7 +345,6 @@ class Ui_MainWindow(object):
self.toolsAddToolItem.setVisible(False) self.toolsAddToolItem.setVisible(False)
self.importLanguageItem.setVisible(False) self.importLanguageItem.setVisible(False)
self.exportLanguageItem.setVisible(False) self.exportLanguageItem.setVisible(False)
self.helpDocumentationItem.setVisible(False)
self.setLockPanel(panelLocked) self.setLockPanel(panelLocked)
def retranslateUi(self, mainWindow): def retranslateUi(self, mainWindow):
@ -456,17 +445,15 @@ class Ui_MainWindow(object):
'&Plugin List')) '&Plugin List'))
self.settingsPluginListItem.setStatusTip( self.settingsPluginListItem.setStatusTip(
translate('OpenLP.MainWindow', 'List the Plugins')) translate('OpenLP.MainWindow', 'List the Plugins'))
self.helpDocumentationItem.setText( self.aboutItem.setText(translate('OpenLP.MainWindow', '&About'))
translate('OpenLP.MainWindow', '&User Guide')) self.aboutItem.setStatusTip(
self.helpAboutItem.setText(translate('OpenLP.MainWindow', '&About'))
self.helpAboutItem.setStatusTip(
translate('OpenLP.MainWindow', 'More information about OpenLP')) translate('OpenLP.MainWindow', 'More information about OpenLP'))
if os.name == u'nt': if os.name == u'nt':
self.helpLocalHelpItem.setText( self.offlineHelpItem.setText(
translate('OpenLP.MainWindow', '&Help')) translate('OpenLP.MainWindow', '&User Guide'))
self.helpOnlineHelpItem.setText( self.onlineHelpItem.setText(
translate('OpenLP.MainWindow', '&Online Help')) translate('OpenLP.MainWindow', '&Online Help'))
self.helpWebSiteItem.setText( self.webSiteItem.setText(
translate('OpenLP.MainWindow', '&Web Site')) translate('OpenLP.MainWindow', '&Web Site'))
for item in self.languageGroup.actions(): for item in self.languageGroup.actions():
item.setText(item.objectName()) item.setText(item.objectName())
@ -555,7 +542,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
QtCore.QObject.connect(self.themeManagerDock, QtCore.QObject.connect(self.themeManagerDock,
QtCore.SIGNAL(u'visibilityChanged(bool)'), QtCore.SIGNAL(u'visibilityChanged(bool)'),
self.viewThemeManagerItem.setChecked) self.viewThemeManagerItem.setChecked)
QtCore.QObject.connect(self.helpWebSiteItem, QtCore.QObject.connect(self.webSiteItem,
QtCore.SIGNAL(u'triggered()'), self.onHelpWebSiteClicked) QtCore.SIGNAL(u'triggered()'), self.onHelpWebSiteClicked)
QtCore.QObject.connect(self.toolsOpenDataFolder, QtCore.QObject.connect(self.toolsOpenDataFolder,
QtCore.SIGNAL(u'triggered()'), self.onToolsOpenDataFolderClicked) QtCore.SIGNAL(u'triggered()'), self.onToolsOpenDataFolderClicked)
@ -762,20 +749,20 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
import webbrowser import webbrowser
webbrowser.open_new(u'http://openlp.org/') webbrowser.open_new(u'http://openlp.org/')
def onHelpLocalHelpClicked(self): def onOfflineHelpClicked(self):
""" """
Load the local OpenLP help file Load the local OpenLP help file
""" """
os.startfile(self.localHelpFile) os.startfile(self.localHelpFile)
def onHelpOnlineHelpClicked(self): def onOnlineHelpClicked(self):
""" """
Load the online OpenLP manual Load the online OpenLP manual
""" """
import webbrowser import webbrowser
webbrowser.open_new(u'http://manual.openlp.org/') webbrowser.open_new(u'http://manual.openlp.org/')
def onHelpAboutItemClicked(self): def onAboutItemClicked(self):
""" """
Show the About form Show the About form
""" """

View File

@ -53,6 +53,7 @@ APPLICATION_VERSION = {}
IMAGES_FILTER = None IMAGES_FILTER = None
UNO_CONNECTION_TYPE = u'pipe' UNO_CONNECTION_TYPE = u'pipe'
#UNO_CONNECTION_TYPE = u'socket' #UNO_CONNECTION_TYPE = u'socket'
VERSION_SPLITTER = re.compile(r'([0-9]+).([0-9]+).([0-9]+)(?:-bzr([0-9]+))?')
class VersionThread(QtCore.QThread): class VersionThread(QtCore.QThread):
""" """
@ -61,8 +62,6 @@ class VersionThread(QtCore.QThread):
""" """
def __init__(self, parent): def __init__(self, parent):
QtCore.QThread.__init__(self, parent) QtCore.QThread.__init__(self, parent)
self.version_splitter = re.compile(
r'([0-9]+).([0-9]+).([0-9]+)(?:-bzr([0-9]+))?')
def run(self): def run(self):
""" """
@ -73,7 +72,7 @@ class VersionThread(QtCore.QThread):
version = check_latest_version(app_version) version = check_latest_version(app_version)
remote_version = {} remote_version = {}
local_version = {} local_version = {}
match = self.version_splitter.match(version) match = VERSION_SPLITTER.match(version)
if match: if match:
remote_version[u'major'] = int(match.group(1)) remote_version[u'major'] = int(match.group(1))
remote_version[u'minor'] = int(match.group(2)) remote_version[u'minor'] = int(match.group(2))
@ -82,7 +81,7 @@ class VersionThread(QtCore.QThread):
remote_version[u'revision'] = int(match.group(4)) remote_version[u'revision'] = int(match.group(4))
else: else:
return return
match = self.version_splitter.match(app_version[u'full']) match = VERSION_SPLITTER.match(app_version[u'full'])
if match: if match:
local_version[u'major'] = int(match.group(1)) local_version[u'major'] = int(match.group(1))
local_version[u'minor'] = int(match.group(2)) local_version[u'minor'] = int(match.group(2))

View File

@ -27,8 +27,7 @@
The bible import functions for OpenLP The bible import functions for OpenLP
""" """
import logging import logging
import os.path import os
import re
import shutil import shutil
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
@ -70,8 +69,7 @@ class BibleUpgradeForm(OpenLPWizard):
self.mediaItem = bibleplugin.mediaItem self.mediaItem = bibleplugin.mediaItem
self.suffix = u'.sqlite' self.suffix = u'.sqlite'
self.settingsSection = u'bibles' self.settingsSection = u'bibles'
self.path = AppLocation.get_section_data_path( self.path = AppLocation.get_section_data_path(self.settingsSection)
self.settingsSection)
self.files = self.manager.old_bible_databases self.files = self.manager.old_bible_databases
self.success = {} self.success = {}
self.newbibles = {} self.newbibles = {}

View File

@ -37,6 +37,8 @@ from editversedialog import Ui_EditVerseDialog
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
VERSE_REGEX = re.compile(r'---\[(.+):\D*(\d*)\D*.*\]---')
class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog): class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog):
""" """
This is the form that is used to edit the verses of the song. This is the form that is used to edit the verses of the song.
@ -60,7 +62,6 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog):
QtCore.QObject.connect(self.verseTypeComboBox, QtCore.QObject.connect(self.verseTypeComboBox,
QtCore.SIGNAL(u'currentIndexChanged(int)'), QtCore.SIGNAL(u'currentIndexChanged(int)'),
self.onVerseTypeComboBoxChanged) self.onVerseTypeComboBoxChanged)
self.verse_regex = re.compile(r'---\[(.+):\D*(\d*)\D*.*\]---')
def contextMenu(self, point): def contextMenu(self, point):
item = self.serviceManagerList.itemAt(point) item = self.serviceManagerList.itemAt(point)
@ -105,7 +106,7 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog):
if position == -1: if position == -1:
return return
text = text[:position + 4] text = text[:position + 4]
match = self.verse_regex.match(text) match = VERSE_REGEX.match(text)
if match: if match:
verse_tag = match.group(1) verse_tag = match.group(1)
try: try:
@ -136,7 +137,7 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog):
if position == -1: if position == -1:
return return
text = text[:position + 4] text = text[:position + 4]
match = self.verse_regex.match(text) match = VERSE_REGEX.match(text)
if match: if match:
verse_type = match.group(1) verse_type = match.group(1)
verse_type_index = VerseType.from_loose_input(verse_type) verse_type_index = VerseType.from_loose_input(verse_type)

View File

@ -73,6 +73,8 @@ from openlp.core.utils import get_application_version
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
CHORD_REGEX = re.compile(u'<chord name=".*?"/>')
class SongXML(object): class SongXML(object):
""" """
This class builds and parses the XML used to describe songs. This class builds and parses the XML used to describe songs.
@ -234,7 +236,6 @@ class OpenLyrics(object):
IMPLEMENTED_VERSION = u'0.7' IMPLEMENTED_VERSION = u'0.7'
def __init__(self, manager): def __init__(self, manager):
self.manager = manager self.manager = manager
self.chord_regex = re.compile(u'<chord name=".*?"/>')
def song_to_xml(self, song): def song_to_xml(self, song):
""" """
@ -319,7 +320,7 @@ class OpenLyrics(object):
if xml[:5] == u'<?xml': if xml[:5] == u'<?xml':
xml = xml[38:] xml = xml[38:]
# Remove chords from xml. # Remove chords from xml.
xml = self.chord_regex.sub(u'', xml) xml = CHORD_REGEX.sub(u'', xml)
song_xml = objectify.fromstring(xml) song_xml = objectify.fromstring(xml)
if hasattr(song_xml, u'properties'): if hasattr(song_xml, u'properties'):
properties = song_xml.properties properties = song_xml.properties

View File

@ -74,44 +74,38 @@ OPTIONAL_MODULES = [
('sqlite', ' (SQLite 2 support)'), ('sqlite', ' (SQLite 2 support)'),
('MySQLdb', ' (MySQL support)'), ('MySQLdb', ' (MySQL support)'),
('psycopg2', ' (PostgreSQL support)'), ('psycopg2', ' (PostgreSQL support)'),
] ]
w = sys.stdout.write w = sys.stdout.write
def check_vers(version, required, text): def check_vers(version, required, text):
if type(version) is str: if type(version) is str:
version = version.split('.') version = version.split('.')
version = [int(x) for x in version] version = map(int, version)
if type(required) is str: if type(required) is str:
required = required.split('.') required = required.split('.')
required = [int(x) for x in required] required = map(int, required)
w(' %s >= %s ... ' % (text, '.'.join([str(x) for x in required]))) w(' %s >= %s ... ' % (text, '.'.join(map(str, required))))
if version >= required: if version >= required:
w('.'.join([str(x) for x in version]) + os.linesep) w('.'.join(map(str, version)) + os.linesep)
return True return True
else: else:
w('FAIL' + os.linesep) w('FAIL' + os.linesep)
return False return False
def print_vers_fail(required, text): def print_vers_fail(required, text):
print(' %s >= %s ... FAIL' % (text, required)) print(' %s >= %s ... FAIL' % (text, required))
def verify_python(): def verify_python():
if not check_vers(list(sys.version_info), VERS['Python'], text='Python'): if not check_vers(list(sys.version_info), VERS['Python'], text='Python'):
exit(1) exit(1)
def verify_versions(): def verify_versions():
print('Verifying version of modules...') print('Verifying version of modules...')
try: try:
from PyQt4 import QtCore from PyQt4 import QtCore
check_vers(QtCore.PYQT_VERSION_STR, VERS['PyQt4'], check_vers(QtCore.PYQT_VERSION_STR, VERS['PyQt4'], 'PyQt4')
'PyQt4') check_vers(QtCore.qVersion(), VERS['Qt4'], 'Qt4')
check_vers(QtCore.qVersion(), VERS['Qt4'],
'Qt4')
except ImportError: except ImportError:
print_vers_fail(VERS['PyQt4'], 'PyQt4') print_vers_fail(VERS['PyQt4'], 'PyQt4')
print_vers_fail(VERS['Qt4'], 'Qt4') print_vers_fail(VERS['Qt4'], 'Qt4')
@ -126,7 +120,6 @@ def verify_versions():
except ImportError: except ImportError:
print_vers_fail(VERS['enchant'], 'enchant') print_vers_fail(VERS['enchant'], 'enchant')
def check_module(mod, text='', indent=' '): def check_module(mod, text='', indent=' '):
space = (30 - len(mod) - len(text)) * ' ' space = (30 - len(mod) - len(text)) * ' '
w(indent + '%s%s... ' % (mod, text) + space) w(indent + '%s%s... ' % (mod, text) + space)
@ -137,7 +130,6 @@ def check_module(mod, text='', indent=' '):
w('FAIL') w('FAIL')
w(os.linesep) w(os.linesep)
def verify_pyenchant(): def verify_pyenchant():
w('Enchant (spell checker)... ') w('Enchant (spell checker)... ')
try: try:
@ -150,14 +142,13 @@ def verify_pyenchant():
except ImportError: except ImportError:
w('FAIL' + os.linesep) w('FAIL' + os.linesep)
def verify_pyqt(): def verify_pyqt():
w('Qt4 image formats... ') w('Qt4 image formats... ')
try: try:
from PyQt4 import QtGui from PyQt4 import QtGui
read_f = ', '.join([unicode(format).lower() \ read_f = ', '.join([unicode(format).lower()
for format in QtGui.QImageReader.supportedImageFormats()]) for format in QtGui.QImageReader.supportedImageFormats()])
write_f= ', '.join([unicode(format).lower() \ write_f = ', '.join([unicode(format).lower()
for format in QtGui.QImageWriter.supportedImageFormats()]) for format in QtGui.QImageWriter.supportedImageFormats()])
w(os.linesep) w(os.linesep)
print(' read: %s' % read_f) print(' read: %s' % read_f)
@ -165,9 +156,7 @@ def verify_pyqt():
except ImportError: except ImportError:
w('FAIL' + os.linesep) w('FAIL' + os.linesep)
def main(): def main():
verify_python() verify_python()
print('Checking for modules...') print('Checking for modules...')
@ -187,6 +176,5 @@ def main():
verify_pyqt() verify_pyqt()
verify_pyenchant() verify_pyenchant()
if __name__ == u'__main__': if __name__ == u'__main__':
main() main()