Head r617

This commit is contained in:
Jon Tibble 2009-10-22 14:44:24 +01:00
commit 27d92e9202
17 changed files with 520 additions and 147 deletions

View File

@ -1,61 +0,0 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
# --------------------------------------------------------------------------- #
# Copyright (c) 2008-2009 Raoul Snyman #
# Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Carsten #
# Tinggaard, Jon Tibble, Jonathan Corwin, Maikel Stuivenberg, Scott Guerrieri #
# --------------------------------------------------------------------------- #
# 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; version 2 of the License. #
# #
# 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, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
import codecs
import sys
def convert_file(inname, outname):
"""
Convert a file from another encoding into UTF-8.
``inname``
The name of the file to be opened and converted.
``outname``
The output file name.
"""
infile = codecs.open(inname, 'r', encoding='CP1252')
writefile = codecs.open(outname, 'w', encoding='utf-8')
for line in infile:
#replace the quotes with quotes
#TODO fix double quotes
#line = line.replace(u'\'\'', u'@')
writefile.write(line)
infile.close()
writefile.close()
if __name__ == '__main__':
"""
Run the conversion script.
"""
if len(sys.argv) < 2:
print 'No action specified.'
sys.exit()
print 'Uncode conversion:'
print 'Input file = ', sys.argv[1]
print 'Output file = ', sys.argv[2]
print 'Converting...'
convert_file(sys.argv[1], sys.argv[2])
print 'Done.'

296
openlp-1to2-converter.py Normal file
View File

@ -0,0 +1,296 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import os
import sqlite
import sqlite3
import re
from optparse import OptionParser
from traceback import format_tb as get_traceback
# Some global options to be used throughout the import process
dirty_chars = re.compile(r'\W ', re.UNICODE)
verbose = False
debug = False
old_cursor = None
new_cursor = None
# SQL create statments
create_statements = [
(u'table "authors"', u"""CREATE TABLE authors (
id INTEGER NOT NULL,
first_name VARCHAR(128),
last_name VARCHAR(128),
display_name VARCHAR(255) NOT NULL,
PRIMARY KEY (id)
)"""),
(u'table "song_books"', u"""CREATE TABLE song_books (
id INTEGER NOT NULL,
name VARCHAR(128) NOT NULL,
publisher VARCHAR(128),
PRIMARY KEY (id)
)"""),
(u'table "songs"', u"""CREATE TABLE songs (
id INTEGER NOT NULL,
song_book_id INTEGER,
title VARCHAR(255) NOT NULL,
lyrics TEXT NOT NULL,
verse_order VARCHAR(128),
copyright VARCHAR(255),
comments TEXT,
ccli_number VARCHAR(64),
song_number VARCHAR(64),
theme_name VARCHAR(128),
search_title VARCHAR(255) NOT NULL,
search_lyrics TEXT NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY(song_book_id) REFERENCES song_books (id)
)"""),
(u'table "topics"', u"""CREATE TABLE topics (
id INTEGER NOT NULL,
name VARCHAR(128) NOT NULL,
PRIMARY KEY (id)
)"""),
(u'index "ix_songs_search_lyrics"',
u"""CREATE INDEX ix_songs_search_lyrics ON songs (search_lyrics)"""),
(u'index "ix_songs_search_title',
u"""CREATE INDEX ix_songs_search_title ON songs (search_title)"""),
(u'table "authors_songs"', u"""CREATE TABLE authors_songs (
author_id INTEGER NOT NULL,
song_id INTEGER NOT NULL,
PRIMARY KEY (author_id, song_id),
FOREIGN KEY(author_id) REFERENCES authors (id),
FOREIGN KEY(song_id) REFERENCES songs (id)
)"""),
(u'table "songs_topics"', u"""CREATE TABLE songs_topics (
song_id INTEGER NOT NULL,
topic_id INTEGER NOT NULL,
PRIMARY KEY (song_id, topic_id),
FOREIGN KEY(song_id) REFERENCES songs (id),
FOREIGN KEY(topic_id) REFERENCES topics (id)
)""")
]
def clean_string(dirty):
return dirty_chars.sub(u'', dirty.replace(u'\r\n', ' ').replace(u'\n', ' '))
def display_sql(sql, params):
prepared_params = []
for param in params:
if isinstance(param, basestring):
prepared_params.append(u'"%s"' % param)
elif isinstance(param, (int, long)):
prepared_params.append(u'%d' % param)
elif isinstance(param, (float, complex)):
prepared_params.append(u'%f' % param)
else:
prepared_params.append(u'"%s"' % str(param))
for prepared_param in prepared_params:
sql = sql.replace(u'?', prepared_param, 1)
return sql
def create_database():
global new_cursor, create_statements
if debug or verbose:
print 'Creating new database:'
else:
print 'Creating new database...',
for statement_type, sql_create in create_statements:
if debug:
print '... ', sql_create.replace('\n', ' ').replace(' ', ' ')
elif verbose:
print '... creating %s...' % statement_type,
new_cursor.execute(sql_create)
if verbose and not debug:
print 'done.'
if not verbose and not debug:
print 'done.'
def import_songs():
global old_cursor, new_cursor, debug, verbose
if debug or verbose:
print 'Importing authors:'
else:
print 'Importing authors...',
if debug:
print '... SELECT authorid AS id, authorname AS displayname FROM authors'
elif verbose:
print '... fetching authors from old database...',
old_cursor.execute(u'SELECT authorid AS id, authorname AS displayname FROM authors')
rows = old_cursor.fetchall()
if not debug and verbose:
print 'done.'
author_map = {}
for row in rows:
display_name = unicode(row[1], u'cp1252')
names = display_name.split(u' ')
first_name = names[0]
last_name = u' '.join(names[1:])
if last_name is None:
last_name = u''
sql_insert = u'INSERT INTO authors '\
'(id, first_name, last_name, display_name) '\
'VALUES (NULL, ?, ?, ?)'
sql_params = (first_name, last_name, display_name)
if debug:
print '...', display_sql(sql_insert, sql_params)
elif verbose:
print '... importing "%s"' % display_name
new_cursor.execute(sql_insert, sql_params)
author_map[row[0]] = new_cursor.lastrowid
if debug:
print ' >>> authors.authorid =', row[0], 'authors.id =', author_map[row[0]]
if not verbose and not debug:
print 'done.'
if debug or verbose:
print 'Importing songs:'
else:
print 'Importing songs...',
if debug:
print '... SELECT songid AS id, songtitle AS title, lyrics || \'\' AS lyrics, copyrightinfo AS copyright FROM songs...',
elif verbose:
print '... fetching songs from old database...',
old_cursor.execute(u'SELECT songid AS id, songtitle AS title, lyrics || \'\' AS lyrics, copyrightinfo AS copyright FROM songs')
rows = old_cursor.fetchall()
if debug or verbose:
print 'done.'
song_map = {}
xml_lyrics_template = u'<?xml version="1.0" encoding="utf-8"?><song version="1.0"><lyrics language="en">%s</lyrics></song>'
xml_verse_template = u'<verse label="%d" type="Verse"><![CDATA[%s]]></verse>'
for row in rows:
clean_title = unicode(row[1], u'cp1252')
clean_lyrics = unicode(row[2], u'cp1252')
clean_copyright = unicode(row[3], u'cp1252')
verse_order = u''
text_lyrics = clean_lyrics.split(u'\n\n')
xml_verse = u''
for line, verse in enumerate(text_lyrics):
if not verse:
continue
xml_verse += (xml_verse_template % (line + 1, verse))
verse_order += '%d ' % (line + 1)
xml_lyrics = xml_lyrics_template % xml_verse
search_title = clean_string(clean_title)
search_lyrics = clean_string(clean_lyrics)
sql_insert = u'INSERT INTO songs '\
'(id, song_book_id, title, lyrics, verse_order, copyright, search_title, search_lyrics) '\
'VALUES (NULL, 0, ?, ?, ?, ?, ?, ?)'
sql_params = (clean_title, xml_lyrics, verse_order, clean_copyright, clean_title, clean_lyrics)
if debug:
print '...', display_sql(sql_insert, (sql_params[0], u'%s...' % clean_lyrics[:7], sql_params[2], sql_params[3], sql_params[4], u'%s...' % search_lyrics[:7]))
elif verbose:
print '... importing "%s"' % clean_title
new_cursor.execute(sql_insert, sql_params)
song_map[row[0]] = new_cursor.lastrowid
if debug:
print ' >>> songs.songid =', row[0], 'songs.id =', song_map[row[0]]
if not verbose and not debug:
print 'done.'
if debug or verbose:
print 'Importing song-to-author mapping:'
else:
print 'Importing song-to-author mapping...',
if debug:
print '... SELECT authorid AS author_id, songid AS song_id FROM songauthors'
elif verbose:
print '... fetching song-to-author mapping from old database...',
old_cursor.execute(u'SELECT authorid AS author_id, songid AS song_id FROM songauthors')
rows = old_cursor.fetchall()
if not debug and verbose:
print 'done.'
for row in rows:
sql_insert = u'INSERT INTO authors_songs '\
'(author_id, song_id) '\
'VALUES (?, ?)'
sql_params = (author_map[row[0]], song_map[row[1]])
if debug:
print '... ', display_sql(sql_insert, sql_params)
elif verbose:
print '... Author %d (was %d) => Song %d (was %d)'\
% (int(row[0]), author_map[row[0]],
int(row[1]), song_map[row[1]])
new_cursor.execute(sql_insert, sql_params)
if not verbose and not debug:
print 'done.'
def main(old_db, new_db):
global old_cursor, new_cursor, debug
old_connection = None
new_connection = None
try:
old_connection = sqlite.connect(old_db)
except:
if debug:
errormsg = '\n' + ''.join(get_traceback(sys.exc_info()[2]))\
+ str(sys.exc_info()[1])
else:
errormsg = sys.exc_info()[1]
print 'There was a problem connecting to the old database:', errormsg
return 1
try:
new_connection = sqlite3.connect(new_db)
except:
if debug:
errormsg = '\n' + ''.join(get_traceback(sys.exc_info()[2]))\
+ str(sys.exc_info()[1])
else:
errormsg = sys.exc_info()[1]
print 'There was a problem creating the new database:', errormsg
return 1
old_cursor = old_connection.cursor()
new_cursor = new_connection.cursor()
try:
create_database()
except:
if debug:
errormsg = '\n' + ''.join(get_traceback(sys.exc_info()[2]))\
+ str(sys.exc_info()[1])
else:
errormsg = sys.exc_info()[1]
print 'There was a problem creating the database:', errormsg
return 1
try:
import_songs()
new_connection.commit()
except:
new_connection.rollback()
if debug:
errormsg = '\n' + ''.join(get_traceback(sys.exc_info()[2]))\
+ str(sys.exc_info()[1])
else:
errormsg = sys.exc_info()[1]
print 'There was a problem importing songs:', errormsg
return 1
print 'Import complete.'
if __name__ == u'__main__':
option_parser = OptionParser(usage='Usage: %prog [options] OLDDATABASE NEWDATABASE')
option_parser.add_option('-o', '--overwrite', dest='overwrite', default=False,
action=u'store_true', help='Overwrite database file if it already exists.')
option_parser.add_option('-v', '--verbose', dest='verbose', default=False,
action=u'store_true', help='Outputs additional progress data.')
option_parser.add_option('-d', '--debug', dest='debug', default=False,
action=u'store_true', help='Outputs raw SQL statements (overrides verbose).')
options, arguments = option_parser.parse_args()
if len(arguments) < 2:
if len(arguments) == 0:
option_parser.error('Please specify an old database and a new database.')
else:
option_parser.error('Please specify a new database.')
old_db = os.path.abspath(arguments[0])
new_db = os.path.abspath(arguments[1])
if not os.path.isfile(old_db):
option_parser.error('Old database file ("%s") is not a file.' % old_db)
if not os.path.exists(old_db):
option_parser.error('Old database file ("%s") does not exist.' % old_db)
if os.path.exists(new_db):
if not options.overwrite:
option_parser.error('New database file ("%s") exists. If you want to overwrite it, specify the --overwrite option.' % new_db)
else:
if not os.path.isfile(new_db):
option_parser.error('New database file ("%s") is not a file.' % new_db)
os.unlink(new_db)
verbose = options.verbose
debug = options.debug
main(old_db, new_db)

View File

@ -47,7 +47,15 @@ QMainWindow::separator
QDockWidget::title
{
border: none;
padding-left: 2px;
padding-left: 5px;
padding-top: 3px;
}
QToolBar
{
border: none;
margin: 0;
padding: 0;
}
"""

View File

@ -136,4 +136,4 @@ class OpenLPToolbar(QtGui.QToolBar):
pushButton.setCheckable(True)
pushButton.setFlat(True)
self.addWidget(pushButton)
return pushButton
return pushButton

View File

@ -173,7 +173,7 @@ class GeneralTab(SettingsTab):
self.MonitorComboBox.addItem(screen_name)
# Get the configs
self.MonitorNumber = int(self.config.get_config(u'Monitor', u'0'))
self.Warning = str_to_bool(self.config.get_config(u'Warning', u'False'))
self.Warning = str_to_bool(self.config.get_config(u'Blank Warning', u'False'))
self.AutoOpen = str_to_bool(self.config.get_config(u'Auto Open', u'False'))
self.ShowSplash = str_to_bool(self.config.get_config(u'show splash', u'True'))
self.CCLNumber = unicode(self.config.get_config(u'CCL Number', u'XXX'))
@ -190,7 +190,7 @@ class GeneralTab(SettingsTab):
def save(self):
self.config.set_config(u'Monitor', self.MonitorNumber)
self.config.set_config(u'Warning', self.Warning)
self.config.set_config(u'Blank Warning', self.Warning)
self.config.set_config(u'Auto Open', self.AutoOpen)
self.config.set_config(u'show splash', self.ShowSplash)
self.config.set_config(u'CCL Number', self.CCLNumber)

View File

@ -193,6 +193,7 @@ class MainDisplay(DisplayLabel):
self.displayBlank = False
if self.frame is not None:
self.frameView(self.frame)
self.parent.generalConfig.set_config(u'Screen Blank',self.displayBlank)
def displayAlert(self, text=u''):
"""

View File

@ -32,13 +32,13 @@ from openlp.core.ui import AboutForm, SettingsForm, AlertForm, \
PluginForm, MediaDockManager
from openlp.core.lib import translate, RenderManager, PluginConfig, \
OpenLPDockWidget, SettingsManager, PluginManager, Receiver, \
buildIcon
buildIcon, str_to_bool
from openlp.core.utils import check_latest_version
media_manager_style = """
QToolBox::tab {
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 palette(midlight), stop: 1.0 palette(dark));
stop: 0 palette(midlight), stop: 1.0 palette(mid));
border-width: 1px;
border-style: outset;
border-color: palette(midlight);
@ -46,7 +46,7 @@ media_manager_style = """
}
QToolBox::tab:selected {
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 palette(light), stop: 1.0 palette(dark));
stop: 0 palette(light), stop: 1.0 palette(mid));
border-color: palette(light);
}
"""
@ -540,7 +540,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
self.ThemeManagerContents.loadThemes()
log.info(u'Load data from Settings')
self.settingsForm.postSetUp()
self.versionCheck()
def versionCheck(self):
applicationVersion = self.generalConfig.get_config(u'Application version', u'1.9.0-595')
@ -569,7 +568,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
monitor_exists = True
if not monitor_exists:
screen_number = 0
return screen_number
def show(self):
@ -580,6 +578,17 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
screen_number = self.getMonitorNumber()
self.mainDisplay.setup(screen_number)
self.setFocus()
self.versionCheck()
if str_to_bool(self.generalConfig.get_config(u'Auto Open', False)):
self.ServiceManagerContents.onLoadService(True)
if str_to_bool(self.generalConfig.get_config(u'Screen Blank', False)) \
and str_to_bool(self.generalConfig.get_config(u'Blank Warning', False)):
QtGui.QMessageBox.question(None,
translate(u'mainWindow', u'OpenLP Main Display Blanked'),
translate(u'mainWindow', u'The Main Display has been blanked out'),
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok),
QtGui.QMessageBox.Ok)
self.LiveController.blackPushButton.setChecked(True)
def onHelpAboutItemClicked(self):
"""

View File

@ -24,7 +24,7 @@
import logging
log = logging.getLogger(u'media_dockManager')
log = logging.getLogger(u'MediaDockManager')
class MediaDockManager(object):

View File

@ -420,16 +420,19 @@ class ServiceManager(QtGui.QWidget):
def onQuickSaveService(self):
self.onSaveService(True)
def onLoadService(self):
def onLoadService(self, lastService = False):
"""
Load an existing service from disk and rebuild the serviceitems. All
files retrieved from the zip file are placed in a temporary directory
and will only be used for this service.
"""
filename = QtGui.QFileDialog.getOpenFileName(self,
translate(u'ThemeManager', u'Open Service'),
self.config.get_last_dir(),
u'Services (*.osz)')
if lastService:
filename = self.config.get_last_dir()
else:
filename = QtGui.QFileDialog.getOpenFileName(self,
translate(u'ThemeManager', u'Open Service'),
self.config.get_last_dir(),
u'Services (*.osz)')
filename = unicode(filename)
name = filename.split(os.path.sep)
if filename != u'':

View File

@ -28,6 +28,14 @@ import time
from PyQt4 import QtCore, QtGui
from openlp.core.lib import OpenLPToolbar, translate, Receiver, ServiceType
label_stylesheet = u"""
QTableWidget::item:selected
{
background-color: %s;
}
"""
class SlideList(QtGui.QTableWidget):
"""
Customised version of QTableWidget which can respond to keyboard
@ -36,6 +44,12 @@ class SlideList(QtGui.QTableWidget):
def __init__(self, parent=None, name=None):
QtGui.QTableWidget.__init__(self, parent.Controller)
self.parent = parent
text_color = QtGui.QApplication.palette().color(QtGui.QPalette.Base)
if text_color.value() > 128:
text_color = text_color.darker(120).name()
else:
text_color = text_color.lighter(120).name()
self.setStyleSheet(label_stylesheet % text_color)
def keyPressEvent(self, event):
if type(event) == QtGui.QKeyEvent:
@ -303,18 +317,20 @@ class SlideController(QtGui.QWidget):
self.PreviewListWidget.rowCount() + 1)
item = QtGui.QTableWidgetItem()
label = QtGui.QLabel()
label.setMargin(8)
label.setMargin(4)
#It is a Image
if frame[u'text'] is None:
pixmap = self.parent.RenderManager.resize_image(frame[u'image'])
label.setScaledContents(True)
label.setPixmap(QtGui.QPixmap.fromImage(pixmap))
slide_height = self.settingsmanager.slidecontroller_image * \
self.parent.RenderManager.screen_ratio
else:
label.setText(frame[u'text'])
label.setAlignment(QtCore.Qt.AlignHCenter)
slide_height = label.sizeHint().height()
self.PreviewListWidget.setCellWidget(framenumber, 0, label)
self.PreviewListWidget.setItem(framenumber, 0, item)
slide_height = self.settingsmanager.slidecontroller_image * \
self.parent.RenderManager.screen_ratio
self.PreviewListWidget.setRowHeight(framenumber, slide_height)
self.PreviewListWidget.setColumnWidth(
0, self.PreviewListWidget.viewport().size().width())

View File

@ -170,12 +170,12 @@ class MigrateSongs():
else:
author = self.session.query(Author).get(bb[0])
song.authors.append(author)
try:
self.session.add(song)
self.session.commit()
except:
self.session.rollback()
print u'Errow thrown = ', sys.exc_info()[1]
try:
self.session.add(song)
self.session.commit()
except:
self.session.rollback()
print u'Error thrown = ', sys.exc_info()[1]
def _v1_9_0_cleanup(self, database):
self.display.sub_output(u'Update Internal Data ' + database)

View File

@ -77,113 +77,135 @@ class BibleMediaItem(MediaManagerItem):
# Add the Quick Search tab
self.QuickTab = QtGui.QWidget()
self.QuickTab.setObjectName(u'QuickTab')
self.QuickVerticalLayout = QtGui.QVBoxLayout(self.QuickTab)
self.QuickVerticalLayout.setObjectName("verticalLayout")
self.QuickLayout = QtGui.QGridLayout()
self.QuickLayout.setMargin(0)
self.QuickLayout = QtGui.QGridLayout(self.QuickTab)
self.QuickLayout.setMargin(2)
self.QuickLayout.setSpacing(4)
self.QuickLayout.setVerticalSpacing(4)
self.QuickLayout.setObjectName(u'QuickLayout')
self.QuickVersionLabel = QtGui.QLabel(self.QuickTab)
self.QuickVersionLabel.setObjectName(u'QuickVersionLabel')
self.QuickLayout.addWidget(self.QuickVersionLabel, 0, 0, 1, 1)
self.QuickVersionComboBox = QtGui.QComboBox(self.QuickTab)
self.QuickVersionComboBox.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToMinimumContentsLength)
self.QuickVersionComboBox.setObjectName(u'VersionComboBox')
self.QuickLayout.addWidget(self.QuickVersionComboBox, 0, 1, 1, 2)
self.QuickSearchLabel = QtGui.QLabel(self.QuickTab)
self.QuickSearchLabel.setObjectName(u'QuickSearchLabel')
self.QuickLayout.addWidget(self.QuickSearchLabel, 1, 0, 1, 1)
self.QuickSearchComboBox = QtGui.QComboBox(self.QuickTab)
self.QuickSearchComboBox.setObjectName(u'SearchComboBox')
self.QuickLayout.addWidget(self.QuickSearchComboBox, 1, 1, 1, 2)
self.QuickSecondVersionLabel = QtGui.QLabel(self.QuickTab)
self.QuickSecondVersionLabel.setObjectName(u'QuickSecondVersionLabel')
self.QuickLayout.addWidget(self.QuickSecondVersionLabel, 1, 0, 1, 1)
self.QuickSecondBibleComboBox = QtGui.QComboBox(self.QuickTab)
self.QuickSecondBibleComboBox.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToMinimumContentsLength)
self.QuickSecondBibleComboBox.setObjectName(u'SecondBible')
self.QuickLayout.addWidget(self.QuickSecondBibleComboBox, 1, 1, 1, 2)
self.QuickSearchLabel = QtGui.QLabel(self.QuickTab)
self.QuickSearchLabel.setObjectName(u'QuickSearchLabel')
self.QuickLayout.addWidget(self.QuickSearchLabel, 2, 0, 1, 1)
self.QuickSearchComboBox = QtGui.QComboBox(self.QuickTab)
self.QuickSearchComboBox.setObjectName(u'SearchComboBox')
self.QuickLayout.addWidget(self.QuickSearchComboBox, 2, 1, 1, 2)
self.QuickSearchLabel = QtGui.QLabel(self.QuickTab)
self.QuickSearchLabel.setObjectName(u'QuickSearchLabel')
self.QuickLayout.addWidget(self.QuickSearchLabel, 3, 0, 1, 1)
self.QuickSearchEdit = QtGui.QLineEdit(self.QuickTab)
self.QuickSearchEdit.setObjectName(u'QuickSearchEdit')
self.QuickLayout.addWidget(self.QuickSearchEdit, 2, 1, 1, 2)
self.QuickSearchButton = QtGui.QPushButton(self.QuickTab)
self.QuickSearchButton.setObjectName(u'QuickSearchButton')
self.QuickLayout.addWidget(self.QuickSearchButton, 3, 2, 1, 1)
self.QuickLayout.addWidget(self.QuickSearchEdit, 3, 1, 1, 2)
self.QuickClearLabel = QtGui.QLabel(self.QuickTab)
self.QuickClearLabel.setObjectName(u'QuickSearchLabel')
self.QuickLayout.addWidget(self.QuickClearLabel, 3, 0, 1, 1)
self.QuickLayout.addWidget(self.QuickClearLabel, 4, 0, 1, 1)
self.ClearQuickSearchComboBox = QtGui.QComboBox(self.QuickTab)
self.ClearQuickSearchComboBox.setObjectName(u'ClearQuickSearchComboBox')
self.QuickLayout.addWidget(self.ClearQuickSearchComboBox, 3, 1, 1, 1)
self.QuickVerticalLayout.addLayout(self.QuickLayout)
self.QuickSecondBibleComboBox = QtGui.QComboBox(self.QuickTab)
self.QuickSecondBibleComboBox.setObjectName(u'SecondBible')
self.QuickVerticalLayout.addWidget(self.QuickSecondBibleComboBox)
self.QuickLayout.addWidget(self.ClearQuickSearchComboBox, 4, 1, 1, 2)
self.QuickSearchButtonLayout = QtGui.QHBoxLayout()
self.QuickSearchButtonLayout.setMargin(0)
self.QuickSearchButtonLayout.setSpacing(0)
self.QuickSearchButtonLayout.setObjectName(u'QuickSearchButtonLayout')
self.QuickSearchButtonSpacer = QtGui.QSpacerItem(40, 20,
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.QuickSearchButtonLayout.addItem(self.QuickSearchButtonSpacer)
self.QuickSearchButton = QtGui.QPushButton(self.QuickTab)
self.QuickSearchButton.setObjectName(u'QuickSearchButton')
self.QuickSearchButtonLayout.addWidget(self.QuickSearchButton)
self.QuickLayout.addLayout(self.QuickSearchButtonLayout, 5, 0, 1, 3)
self.QuickMessage = QtGui.QLabel(self.QuickTab)
self.QuickMessage.setObjectName(u'QuickMessage')
self.QuickVerticalLayout.addWidget(self.QuickMessage)
self.QuickLayout.addWidget(self.QuickMessage, 6, 0, 1, 3)
self.SearchTabWidget.addTab(self.QuickTab, 'Quick')
QuickSpacerItem = QtGui.QSpacerItem(20, 35, QtGui.QSizePolicy.Minimum,
QtGui.QSizePolicy.Expanding)
self.QuickLayout.addItem(QuickSpacerItem, 4, 2, 1, 1)
self.QuickLayout.addItem(QuickSpacerItem, 6, 2, 1, 1)
# Add the Advanced Search tab
self.AdvancedTab = QtGui.QWidget()
self.AdvancedTab.setObjectName(u'AdvancedTab')
self.AdvancedVerticalLayout = QtGui.QVBoxLayout(self.AdvancedTab)
self.AdvancedVerticalLayout.setObjectName("verticalLayout")
self.AdvancedLayout = QtGui.QGridLayout()
self.AdvancedLayout.setMargin(0)
self.AdvancedLayout = QtGui.QGridLayout(self.AdvancedTab)
self.AdvancedLayout.setMargin(2)
self.AdvancedLayout.setSpacing(4)
self.AdvancedLayout.setVerticalSpacing(4)
self.AdvancedLayout.setObjectName(u'AdvancedLayout')
self.AdvancedVersionLabel = QtGui.QLabel(self.AdvancedTab)
self.AdvancedVersionLabel.setObjectName(u'AdvancedVersionLabel')
self.AdvancedLayout.addWidget(self.AdvancedVersionLabel, 0, 0, 1, 1)
self.AdvancedVersionComboBox = QtGui.QComboBox(self.AdvancedTab)
self.AdvancedVersionComboBox.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToMinimumContentsLength)
self.AdvancedVersionComboBox.setObjectName(u'AdvancedVersionComboBox')
self.AdvancedLayout.addWidget(self.AdvancedVersionComboBox, 0, 2, 1, 2)
self.AdvancedLayout.addWidget(self.AdvancedVersionComboBox, 0, 1, 1, 2)
self.AdvancedSecondBibleLabel = QtGui.QLabel(self.AdvancedTab)
self.AdvancedSecondBibleLabel.setObjectName(u'AdvancedSecondBibleLabel')
self.AdvancedLayout.addWidget(self.AdvancedSecondBibleLabel, 1, 0, 1, 1)
self.AdvancedSecondBibleComboBox = QtGui.QComboBox(self.AdvancedTab)
self.AdvancedSecondBibleComboBox.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToMinimumContentsLength)
self.AdvancedSecondBibleComboBox.setObjectName(u'AdvancedSecondBibleComboBox')
self.AdvancedLayout.addWidget(self.AdvancedSecondBibleComboBox, 1, 1, 1, 2)
self.AdvancedBookLabel = QtGui.QLabel(self.AdvancedTab)
self.AdvancedBookLabel.setObjectName(u'AdvancedBookLabel')
self.AdvancedLayout.addWidget(self.AdvancedBookLabel, 1, 0, 1, 1)
self.AdvancedLayout.addWidget(self.AdvancedBookLabel, 2, 0, 1, 1)
self.AdvancedBookComboBox = QtGui.QComboBox(self.AdvancedTab)
self.AdvancedBookComboBox.setObjectName(u'AdvancedBookComboBox')
self.AdvancedLayout.addWidget(self.AdvancedBookComboBox, 1, 2, 1, 2)
self.AdvancedLayout.addWidget(self.AdvancedBookComboBox, 2, 1, 1, 2)
self.AdvancedChapterLabel = QtGui.QLabel(self.AdvancedTab)
self.AdvancedChapterLabel.setObjectName(u'AdvancedChapterLabel')
self.AdvancedLayout.addWidget(self.AdvancedChapterLabel, 2, 2, 1, 1)
self.AdvancedLayout.addWidget(self.AdvancedChapterLabel, 3, 1, 1, 1)
self.AdvancedVerseLabel = QtGui.QLabel(self.AdvancedTab)
self.AdvancedVerseLabel.setObjectName(u'AdvancedVerseLabel')
self.AdvancedLayout.addWidget(self.AdvancedVerseLabel, 2, 3, 1, 1)
self.AdvancedLayout.addWidget(self.AdvancedVerseLabel, 3, 2, 1, 1)
self.AdvancedFromLabel = QtGui.QLabel(self.AdvancedTab)
self.AdvancedFromLabel.setObjectName(u'AdvancedFromLabel')
self.AdvancedLayout.addWidget(self.AdvancedFromLabel, 3, 0, 1, 1)
self.AdvancedToLabel = QtGui.QLabel(self.AdvancedTab)
self.AdvancedToLabel.setObjectName(u'AdvancedToLabel')
self.AdvancedLayout.addWidget(self.AdvancedToLabel, 4, 0, 1, 1)
self.AdvancedLayout.addWidget(self.AdvancedFromLabel, 4, 0, 1, 1)
self.AdvancedFromChapter = QtGui.QComboBox(self.AdvancedTab)
self.AdvancedFromChapter.setObjectName(u'AdvancedFromChapter')
self.AdvancedLayout.addWidget(self.AdvancedFromChapter, 3, 2, 1, 1)
self.AdvancedLayout.addWidget(self.AdvancedFromChapter, 4, 1, 1, 1)
self.AdvancedFromVerse = QtGui.QComboBox(self.AdvancedTab)
self.AdvancedFromVerse.setObjectName(u'AdvancedFromVerse')
self.AdvancedLayout.addWidget(self.AdvancedFromVerse, 3, 3, 1, 1)
self.AdvancedLayout.addWidget(self.AdvancedFromVerse, 4, 2, 1, 1)
self.AdvancedToLabel = QtGui.QLabel(self.AdvancedTab)
self.AdvancedToLabel.setObjectName(u'AdvancedToLabel')
self.AdvancedLayout.addWidget(self.AdvancedToLabel, 5, 0, 1, 1)
self.AdvancedToChapter = QtGui.QComboBox(self.AdvancedTab)
self.AdvancedToChapter.setObjectName(u'AdvancedToChapter')
self.AdvancedLayout.addWidget(self.AdvancedToChapter, 4, 2, 1, 1)
self.AdvancedLayout.addWidget(self.AdvancedToChapter, 5, 1, 1, 1)
self.AdvancedToVerse = QtGui.QComboBox(self.AdvancedTab)
self.AdvancedToVerse.setObjectName(u'AdvancedToVerse')
self.AdvancedLayout.addWidget(self.AdvancedToVerse, 4, 3, 1, 1)
self.AdvancedLayout.addWidget(self.AdvancedToVerse, 5, 2, 1, 1)
self.AdvancedClearLabel = QtGui.QLabel(self.QuickTab)
self.AdvancedClearLabel.setObjectName(u'QuickSearchLabel')
self.AdvancedLayout.addWidget(self.AdvancedClearLabel, 5, 0, 1, 1)
self.AdvancedLayout.addWidget(self.AdvancedClearLabel, 6, 0, 1, 1)
self.ClearAdvancedSearchComboBox = QtGui.QComboBox(self.QuickTab)
self.ClearAdvancedSearchComboBox.setObjectName(
u'ClearAdvancedSearchComboBox')
self.AdvancedLayout.addWidget(
self.ClearAdvancedSearchComboBox, 5, 2, 1, 2)
self.ClearAdvancedSearchComboBox, 6, 1, 1, 2)
self.AdvancedSearchButtonLayout = QtGui.QHBoxLayout()
self.AdvancedSearchButtonLayout.setMargin(0)
self.AdvancedSearchButtonLayout.setSpacing(0)
self.AdvancedSearchButtonLayout.setObjectName(u'AdvancedSearchButtonLayout')
self.AdvancedSearchButtonSpacer = QtGui.QSpacerItem(40, 20,
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.AdvancedSearchButtonLayout.addItem(self.AdvancedSearchButtonSpacer)
self.AdvancedSearchButton = QtGui.QPushButton(self.AdvancedTab)
self.AdvancedSearchButton.setObjectName(u'AdvancedSearchButton')
self.AdvancedLayout.addWidget(self.AdvancedSearchButton, 6, 3, 1, 1)
self.AdvancedVerticalLayout.addLayout(self.AdvancedLayout)
self.AdvancedSecondBibleComboBox = QtGui.QComboBox(self.AdvancedTab)
self.AdvancedSecondBibleComboBox.setObjectName(u'SecondBible')
self.AdvancedVerticalLayout.addWidget(self.AdvancedSecondBibleComboBox)
self.AdvancedMessage = QtGui.QLabel(self.QuickTab)
self.AdvancedSearchButtonLayout.addWidget(self.AdvancedSearchButton)
self.AdvancedLayout.addLayout(self.AdvancedSearchButtonLayout, 7, 0, 1, 3)
self.AdvancedMessage = QtGui.QLabel(self.AdvancedTab)
self.AdvancedMessage.setObjectName(u'AdvancedMessage')
self.AdvancedVerticalLayout.addWidget(self.AdvancedMessage)
self.AdvancedLayout.addWidget(self.AdvancedMessage, 8, 0, 1, 3)
self.SearchTabWidget.addTab(self.AdvancedTab, u'Advanced')
# Add the search tab widget to the page layout
self.PageLayout.addWidget(self.SearchTabWidget)
@ -209,16 +231,22 @@ class BibleMediaItem(MediaManagerItem):
def configUpdated(self):
if str_to_bool(
self.parent.config.get_config(u'dual bibles', u'False')):
self.AdvancedSecondBibleLabel.setVisible(True)
self.AdvancedSecondBibleComboBox.setVisible(True)
self.QuickSecondVersionLabel.setVisible(True)
self.QuickSecondBibleComboBox.setVisible(True)
else:
self.AdvancedSecondBibleLabel.setVisible(False)
self.AdvancedSecondBibleComboBox.setVisible(False)
self.QuickSecondVersionLabel.setVisible(False)
self.QuickSecondBibleComboBox.setVisible(False)
def retranslateUi(self):
log.debug(u'retranslateUi')
self.QuickVersionLabel.setText(
translate(u'BibleMediaItem', u'Version:'))
self.QuickSecondVersionLabel.setText(
translate(u'BibleMediaItem', u'Dual:'))
self.QuickSearchLabel.setText(
translate(u'BibleMediaItem', u'Search Type:'))
self.QuickSearchLabel.setText(translate(u'BibleMediaItem', u'Find:'))
@ -226,6 +254,8 @@ class BibleMediaItem(MediaManagerItem):
self.QuickClearLabel.setText(translate(u'BibleMediaItem', u'Results:'))
self.AdvancedVersionLabel.setText(
translate(u'BibleMediaItem', u'Version:'))
self.AdvancedSecondBibleLabel.setText(
translate(u'BibleMediaItem', u'Dual:'))
self.AdvancedBookLabel.setText(translate(u'BibleMediaItem', u'Book:'))
self.AdvancedChapterLabel.setText(
translate(u'BibleMediaItem', u'Chapter:'))

View File

@ -74,8 +74,7 @@ class MessageListener(object):
return
if not self.controller.is_loaded():
self.controller.load_presentation(self.controller.filepath)
else:
self.controller.start_presentation()
self.controller.start_presentation()
if self.controller.slidenumber > 1:
self.controller.goto_slide(self.controller.slidenumber)

View File

@ -198,6 +198,8 @@ class PresentationController(object):
recent than the powerpoint
"""
lastimage = self.get_slide_preview_file(self.get_slide_count())
if lastimage is None:
return False
if not os.path.isfile(lastimage):
return False
imgdate = os.stat(lastimage).st_mtime

View File

@ -68,6 +68,7 @@ class SongMediaItem(MediaManagerItem):
u'Maintain the lists of authors, topics and books'),
':/songs/song_maintenance.png', self.onSongMaintenanceClick,
'SongMaintenanceItem')
self.PageLayout.setSpacing(4)
self.SearchLayout = QtGui.QFormLayout()
self.SearchLayout.setMargin(0)
self.SearchLayout.setSpacing(4)

View File

@ -26,17 +26,31 @@
import os
import logging
import time
import subprocess
import codecs
import sys
from datetime import date
if os.name == u'nt':
import win32api
import win32con
from win32com.client import Dispatch
from openlp.migration.display import *
from openlp.migration.migratefiles import *
from openlp.migration.migratebibles import *
from openlp.migration.migratesongs import *
###############################################################################
# For Windows, requires SQLite ODBC Driver to be installed
# (uses sqlite.exe and sqlite3.exe)
# http://www.ch-werner.de/sqliteodbc/
###############################################################################
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
datefmt='%m-%d %H:%M',
filename='openlp-migration.log',
filemode='w')
format=u'%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
datefmt=u'%m-%d %H:%M',
filename=u'openlp-migration.log',
filemode=u'w')
class Migration(object):
"""
@ -62,15 +76,75 @@ class Migration(object):
"""
Move the log file to a new location.
"""
fname = 'openlp-migration.log'
fname = u'openlp-migration.log'
c = os.path.splitext(fname)
b = (c[0]+'-'+ unicode(self.stime) + c[1])
self.display.output(u'Logfile " +b + " generated')
self.display.output(u'Logfile ' + b + u' generated')
self.display.output(u'Migration Utility Finished ')
os.rename(fname, b)
def convert_file(self, inname, outname):
"""
Convert a file from another encoding into UTF-8.
if __name__ == '__main__':
``inname``
The name of the file to be opened and converted.
``outname``
The output file name.
"""
infile = codecs.open(inname, u'r', encoding=u'CP1252')
writefile = codecs.open(outname, u'w', encoding=u'utf-8')
for line in infile:
writefile.write(line)
infile.close()
writefile.close()
def convert_sqlite2_to_3(self, olddb, newdb):
if os.name == u'nt':
# we can't make this a raw unicode string as the \U within it causes much confusion
hKey = win32api.RegOpenKey(win32con.HKEY_LOCAL_MACHINE, u'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\SQLite ODBC Driver')
value, type = win32api.RegQueryValueEx (hKey, u'UninstallString')
sqlitepath, temp = os.path.split(value)
sqliteexe = os.path.join(sqlitepath, u'sqlite.exe')
else:
sqliteexe = u'sqlite'
cmd = u'%s "%s" .dump' % (sqliteexe, olddb)
if os.name == u'nt':
subprocess.call(cmd, stdout=open(u'sqlite.dmp', u'w'))
else:
subprocess.call(cmd, stdout=open(u'sqlite.dmp', u'w'), shell=True)
self.convert_file(u'sqlite.dmp', u'sqlite3.dmp')
if os.name == u'nt':
sqlite3exe = os.path.join(sqlitepath, u'sqlite3.exe')
else:
sqlite3exe = u'sqlite3'
if os.path.isfile(newdb):
saveddb = newdb + self.stime
os.rename(newdb, saveddb)
cmd = '%s "%s"' % (sqlite3exe, newdb)
if os.name == u'nt':
subprocess.call(cmd, stdin=open(u'sqlite3.dmp', u'r'))
else:
subprocess.call(cmd, stdin=open(u'sqlite3.dmp', u'r'), shell=True)
os.remove(u'sqlite.dmp')
os.remove(u'sqlite3.dmp')
if __name__ == u'__main__':
mig = Migration()
config = PluginConfig(u'Songs')
newpath = config.get_data_path()
if os.name == u'nt':
if not os.path.isdir(newpath):
os.makedirs(newpath)
ALL_USERS_APPLICATION_DATA = 35
shell = Dispatch(u'Shell.Application')
folder = shell.Namespace(ALL_USERS_APPLICATION_DATA)
folderitem = folder.Self
olddb = os.path.join(folderitem.path, u'openlp.org', u'Data', u'songs.olp')
else:
olddb = os.path.join(newpath, u'songs.olp')
newdb = os.path.join(newpath, u'songs.sqlite')
mig.convert_sqlite2_to_3(olddb, newdb)
mig.process()
#mig.move_log_file()

View File

@ -1,5 +0,0 @@
/usr/bin/sqlite ~/.local/share/openlp/songs/songs.olp .dump > ~/.local/share/openlp/songs/songs.dmp
./cnvdb.py ~/.local/share/openlp/songs/songs.dmp ~/.local/share/openlp/songs/songs.dmp2
rm ~/.local/share/openlp/songs/songs.sqlite
sqlite3 ~/.local/share/openlp/songs/songs.sqlite < ~/.local/share/openlp/songs/songs.dmp2
./openlpcnv.pyw