forked from openlp/openlp
Remove unused stuff
Add more bits to ImageSlideController bar Clean up ThemeManager Add OOS saving bzr-revno: 483
This commit is contained in:
commit
0194e903f2
2
cnvdb.py
2
cnvdb.py
@ -31,7 +31,7 @@ class Convert():
|
|||||||
writefile = codecs.open(outname, 'w', encoding='utf-8')
|
writefile = codecs.open(outname, 'w', encoding='utf-8')
|
||||||
for line in infile:
|
for line in infile:
|
||||||
#replace the quotes with quotes
|
#replace the quotes with quotes
|
||||||
line, replace("''", "'")
|
line = line.replace(u'\'\'', u'\'')
|
||||||
writefile.write(line)
|
writefile.write(line)
|
||||||
infile.close()
|
infile.close()
|
||||||
writefile.close()
|
writefile.close()
|
||||||
|
@ -102,7 +102,6 @@ class Plugin(object):
|
|||||||
self.render_manager = plugin_helpers[u'render']
|
self.render_manager = plugin_helpers[u'render']
|
||||||
self.service_manager = plugin_helpers[u'service']
|
self.service_manager = plugin_helpers[u'service']
|
||||||
self.settings = plugin_helpers[u'settings']
|
self.settings = plugin_helpers[u'settings']
|
||||||
self.slideManager = plugin_helpers[u'slideManager']
|
|
||||||
self.dnd_id=None
|
self.dnd_id=None
|
||||||
|
|
||||||
def check_pre_conditions(self):
|
def check_pre_conditions(self):
|
||||||
|
@ -18,7 +18,6 @@ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
|||||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
"""
|
"""
|
||||||
from slidecontroller import MasterToolbar
|
from slidecontroller import MasterToolbar
|
||||||
from slidecontrollermanager import SlideControllerManager
|
|
||||||
from maindisplay import MainDisplay
|
from maindisplay import MainDisplay
|
||||||
from amendthemeform import AmendThemeForm
|
from amendthemeform import AmendThemeForm
|
||||||
from slidecontroller import SlideController
|
from slidecontroller import SlideController
|
||||||
|
@ -128,9 +128,7 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
|||||||
unicode(self.theme.display_outline), unicode(self.theme.display_outline_color),
|
unicode(self.theme.display_outline), unicode(self.theme.display_outline_color),
|
||||||
unicode(self.theme.display_horizontalAlign), unicode(self.theme.display_verticalAlign),
|
unicode(self.theme.display_horizontalAlign), unicode(self.theme.display_verticalAlign),
|
||||||
unicode(self.theme.display_wrapStyle))
|
unicode(self.theme.display_wrapStyle))
|
||||||
|
|
||||||
theme = new_theme.extract_xml()
|
theme = new_theme.extract_xml()
|
||||||
|
|
||||||
self.thememanager.saveTheme(theme_name, theme, save_from, save_to)
|
self.thememanager.saveTheme(theme_name, theme, save_from, save_to)
|
||||||
return QtGui.QDialog.accept(self)
|
return QtGui.QDialog.accept(self)
|
||||||
|
|
||||||
@ -526,4 +524,4 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
|||||||
def previewTheme(self, theme):
|
def previewTheme(self, theme):
|
||||||
if self.allowPreview:
|
if self.allowPreview:
|
||||||
frame = self.thememanager.generateImage(theme)
|
frame = self.thememanager.generateImage(theme)
|
||||||
self.ThemePreview.setPixmap(QtGui.QPixmap.fromImage(frame))
|
self.ThemePreview.setPixmap(QtGui.QPixmap.fromImage(frame))
|
||||||
|
@ -23,7 +23,7 @@ import logging
|
|||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.ui import AboutForm, SettingsForm, AlertForm, ServiceManager, \
|
from openlp.core.ui import AboutForm, SettingsForm, AlertForm, ServiceManager, \
|
||||||
ThemeManager, MainDisplay, SlideController, SlideControllerManager
|
ThemeManager, MainDisplay, SlideController
|
||||||
from openlp.core.lib import translate, Plugin, MediaManagerItem, SettingsTab, \
|
from openlp.core.lib import translate, Plugin, MediaManagerItem, SettingsTab, \
|
||||||
EventManager, RenderManager, PluginConfig
|
EventManager, RenderManager, PluginConfig
|
||||||
from openlp.core import PluginManager
|
from openlp.core import PluginManager
|
||||||
@ -41,6 +41,7 @@ class MainWindow(object):
|
|||||||
This constructor sets up the interface, the various managers, and the
|
This constructor sets up the interface, the various managers, and the
|
||||||
plugins.
|
plugins.
|
||||||
"""
|
"""
|
||||||
|
self.oosNotSaved = False
|
||||||
self.mainWindow = QtGui.QMainWindow()
|
self.mainWindow = QtGui.QMainWindow()
|
||||||
self.mainWindow.__class__.closeEvent = self.onCloseEvent
|
self.mainWindow.__class__.closeEvent = self.onCloseEvent
|
||||||
self.mainDisplay = MainDisplay(None, screens)
|
self.mainDisplay = MainDisplay(None, screens)
|
||||||
@ -50,7 +51,6 @@ class MainWindow(object):
|
|||||||
self.alertForm = AlertForm(self)
|
self.alertForm = AlertForm(self)
|
||||||
self.aboutForm = AboutForm()
|
self.aboutForm = AboutForm()
|
||||||
self.settingsForm = SettingsForm(self.screenList, self)
|
self.settingsForm = SettingsForm(self.screenList, self)
|
||||||
self.slideControllerManager = SlideControllerManager(self)
|
|
||||||
# Set up the path with plugins
|
# Set up the path with plugins
|
||||||
pluginpath = os.path.split(os.path.abspath(__file__))[0]
|
pluginpath = os.path.split(os.path.abspath(__file__))[0]
|
||||||
pluginpath = os.path.abspath(
|
pluginpath = os.path.abspath(
|
||||||
@ -73,7 +73,6 @@ class MainWindow(object):
|
|||||||
self.plugin_helpers[u'render'] = self.RenderManager
|
self.plugin_helpers[u'render'] = self.RenderManager
|
||||||
self.plugin_helpers[u'service'] = self.ServiceManagerContents
|
self.plugin_helpers[u'service'] = self.ServiceManagerContents
|
||||||
self.plugin_helpers[u'settings'] = self.settingsForm
|
self.plugin_helpers[u'settings'] = self.settingsForm
|
||||||
self.plugin_helpers[u'slideManager'] = self.slideControllerManager
|
|
||||||
self.plugin_manager.find_plugins(pluginpath, self.plugin_helpers,
|
self.plugin_manager.find_plugins(pluginpath, self.plugin_helpers,
|
||||||
self.EventManager)
|
self.EventManager)
|
||||||
# hook methods have to happen after find_plugins. Find plugins needs the
|
# hook methods have to happen after find_plugins. Find plugins needs the
|
||||||
@ -129,8 +128,46 @@ class MainWindow(object):
|
|||||||
"""
|
"""
|
||||||
Hook to close the main window and display windows on exit
|
Hook to close the main window and display windows on exit
|
||||||
"""
|
"""
|
||||||
self.mainDisplay.close()
|
if self.oosNotSaved == True:
|
||||||
event.accept()
|
box = QtGui.QMessageBox()
|
||||||
|
box.setWindowTitle(translate(u'mainWindow', u'Question?'))
|
||||||
|
box.setText(translate(u'mainWindow', u'Save changes to Order of Service?'))
|
||||||
|
box.setIcon(QtGui.QMessageBox.Question)
|
||||||
|
box.setStandardButtons(QtGui.QMessageBox.Save | QtGui.QMessageBox.Discard | QtGui.QMessageBox.Cancel);
|
||||||
|
box.setDefaultButton(QtGui.QMessageBox.Save);
|
||||||
|
ret = box.exec_()
|
||||||
|
if ret == QtGui.QMessageBox.Save:
|
||||||
|
self.ServiceManagerContents.onSaveService()
|
||||||
|
self.mainDisplay.close()
|
||||||
|
event.accept()
|
||||||
|
elif ret == QtGui.QMessageBox.Discard:
|
||||||
|
self.mainDisplay.close()
|
||||||
|
event.accept()
|
||||||
|
else:
|
||||||
|
event.ignore()
|
||||||
|
else:
|
||||||
|
self.mainDisplay.close()
|
||||||
|
event.accept()
|
||||||
|
|
||||||
|
def OosChanged(self, reset = False, oosName = None):
|
||||||
|
"""
|
||||||
|
Hook to change the title if the OOS has been changed
|
||||||
|
reset - tells if the OOS has been cleared or saved
|
||||||
|
oosName - is the name of the OOS (if it has one)
|
||||||
|
"""
|
||||||
|
if reset == True:
|
||||||
|
self.oosNotSaved = False
|
||||||
|
if oosName is None:
|
||||||
|
title = self.mainTitle
|
||||||
|
else:
|
||||||
|
title = self.mainTitle + u' - (' + oosName + u')'
|
||||||
|
else:
|
||||||
|
self.oosNotSaved = True
|
||||||
|
if oosName is None:
|
||||||
|
title = self.mainTitle + u' - *'
|
||||||
|
else:
|
||||||
|
title = self.mainTitle + u' - *(' + oosName + u')'
|
||||||
|
self.mainWindow.setWindowTitle(title)
|
||||||
|
|
||||||
def setupUi(self):
|
def setupUi(self):
|
||||||
"""
|
"""
|
||||||
@ -411,7 +448,8 @@ class MainWindow(object):
|
|||||||
"""
|
"""
|
||||||
Set up the translation system
|
Set up the translation system
|
||||||
"""
|
"""
|
||||||
self.mainWindow.setWindowTitle(translate(u'mainWindow', u'OpenLP 2.0'))
|
self.mainTitle = translate(u'mainWindow', u'OpenLP 2.0')
|
||||||
|
self.mainWindow.setWindowTitle(self.mainTitle)
|
||||||
self.FileMenu.setTitle(translate(u'mainWindow', u'&File'))
|
self.FileMenu.setTitle(translate(u'mainWindow', u'&File'))
|
||||||
self.FileImportMenu.setTitle(translate(u'mainWindow', u'&Import'))
|
self.FileImportMenu.setTitle(translate(u'mainWindow', u'&Import'))
|
||||||
self.FileExportMenu.setTitle(translate(u'mainWindow', u'&Export'))
|
self.FileExportMenu.setTitle(translate(u'mainWindow', u'&Export'))
|
||||||
|
@ -63,6 +63,7 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
QtGui.QWidget.__init__(self)
|
QtGui.QWidget.__init__(self)
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.serviceItems = []
|
self.serviceItems = []
|
||||||
|
self.serviceName = u''
|
||||||
self.Layout = QtGui.QVBoxLayout(self)
|
self.Layout = QtGui.QVBoxLayout(self)
|
||||||
self.Layout.setSpacing(0)
|
self.Layout.setSpacing(0)
|
||||||
self.Layout.setMargin(0)
|
self.Layout.setMargin(0)
|
||||||
@ -151,6 +152,7 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
self.serviceItems.remove(self.serviceItems[item])
|
self.serviceItems.remove(self.serviceItems[item])
|
||||||
self.serviceItems.insert(0, temp)
|
self.serviceItems.insert(0, temp)
|
||||||
self.repaintServiceList()
|
self.repaintServiceList()
|
||||||
|
self.parent.OosChanged(False, self.serviceName)
|
||||||
|
|
||||||
def onServiceUp(self):
|
def onServiceUp(self):
|
||||||
"""
|
"""
|
||||||
@ -163,6 +165,7 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
self.serviceItems.remove(self.serviceItems[item])
|
self.serviceItems.remove(self.serviceItems[item])
|
||||||
self.serviceItems.insert(item - 1, temp)
|
self.serviceItems.insert(item - 1, temp)
|
||||||
self.repaintServiceList()
|
self.repaintServiceList()
|
||||||
|
self.parent.OosChanged(False, self.serviceName)
|
||||||
|
|
||||||
def onServiceDown(self):
|
def onServiceDown(self):
|
||||||
"""
|
"""
|
||||||
@ -175,6 +178,7 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
self.serviceItems.remove(self.serviceItems[item])
|
self.serviceItems.remove(self.serviceItems[item])
|
||||||
self.serviceItems.insert(item + 1, temp)
|
self.serviceItems.insert(item + 1, temp)
|
||||||
self.repaintServiceList()
|
self.repaintServiceList()
|
||||||
|
self.parent.OosChanged(False, self.serviceName)
|
||||||
|
|
||||||
def onServiceEnd(self):
|
def onServiceEnd(self):
|
||||||
"""
|
"""
|
||||||
@ -186,6 +190,7 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
self.serviceItems.remove(self.serviceItems[item])
|
self.serviceItems.remove(self.serviceItems[item])
|
||||||
self.serviceItems.insert(len(self.serviceItems), temp)
|
self.serviceItems.insert(len(self.serviceItems), temp)
|
||||||
self.repaintServiceList()
|
self.repaintServiceList()
|
||||||
|
self.parent.OosChanged(False, self.serviceName)
|
||||||
|
|
||||||
def onNewService(self):
|
def onNewService(self):
|
||||||
"""
|
"""
|
||||||
@ -193,6 +198,8 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
"""
|
"""
|
||||||
self.ServiceManagerList.clear()
|
self.ServiceManagerList.clear()
|
||||||
self.serviceItems = []
|
self.serviceItems = []
|
||||||
|
self.serviceName = u''
|
||||||
|
self.parent.OosChanged(True, self.serviceName)
|
||||||
|
|
||||||
def onDeleteFromService(self):
|
def onDeleteFromService(self):
|
||||||
"""
|
"""
|
||||||
@ -202,6 +209,7 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
if item is not -1:
|
if item is not -1:
|
||||||
self.serviceItems.remove(self.serviceItems[item])
|
self.serviceItems.remove(self.serviceItems[item])
|
||||||
self.repaintServiceList()
|
self.repaintServiceList()
|
||||||
|
self.parent.OosChanged(False, self.serviceName)
|
||||||
|
|
||||||
def repaintServiceList(self):
|
def repaintServiceList(self):
|
||||||
#Correct order of idems in array
|
#Correct order of idems in array
|
||||||
@ -252,6 +260,7 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
os.remove(servicefile)
|
os.remove(servicefile)
|
||||||
except:
|
except:
|
||||||
pass #if not present do not worry
|
pass #if not present do not worry
|
||||||
|
self.parent.OosChanged(True, self.serviceName)
|
||||||
|
|
||||||
def onLoadService(self):
|
def onLoadService(self):
|
||||||
"""
|
"""
|
||||||
@ -260,6 +269,7 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
filename = QtGui.QFileDialog.getOpenFileName(self, u'Open Order of Service',self.config.get_last_dir(),
|
filename = QtGui.QFileDialog.getOpenFileName(self, u'Open Order of Service',self.config.get_last_dir(),
|
||||||
u'Services (*.oos)')
|
u'Services (*.oos)')
|
||||||
filename = unicode(filename)
|
filename = unicode(filename)
|
||||||
|
name = filename.split(os.path.sep)
|
||||||
if filename != u'':
|
if filename != u'':
|
||||||
self.config.set_last_dir(filename)
|
self.config.set_last_dir(filename)
|
||||||
zip = zipfile.ZipFile(unicode(filename))
|
zip = zipfile.ZipFile(unicode(filename))
|
||||||
@ -279,7 +289,6 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
f.close()
|
f.close()
|
||||||
self.onNewService()
|
self.onNewService()
|
||||||
for item in items:
|
for item in items:
|
||||||
#print item
|
|
||||||
serviceitem = ServiceItem()
|
serviceitem = ServiceItem()
|
||||||
serviceitem.RenderManager = self.parent.RenderManager
|
serviceitem.RenderManager = self.parent.RenderManager
|
||||||
serviceitem.set_from_oos(item, self.servicePath )
|
serviceitem.set_from_oos(item, self.servicePath )
|
||||||
@ -287,7 +296,10 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
try:
|
try:
|
||||||
os.remove(p_file)
|
os.remove(p_file)
|
||||||
except:
|
except:
|
||||||
pass #if not present do not worry
|
#if not present do not worry
|
||||||
|
pass
|
||||||
|
self.serviceName = name[len(name) - 1]
|
||||||
|
self.parent.OosChanged(True, self.serviceName)
|
||||||
|
|
||||||
def onThemeComboBoxSelected(self, currentIndex):
|
def onThemeComboBoxSelected(self, currentIndex):
|
||||||
"""
|
"""
|
||||||
@ -323,6 +335,7 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
treewidgetitem1.setText(0,text[:40])
|
treewidgetitem1.setText(0,text[:40])
|
||||||
treewidgetitem1.setData(0, QtCore.Qt.UserRole,QtCore.QVariant(count))
|
treewidgetitem1.setData(0, QtCore.Qt.UserRole,QtCore.QVariant(count))
|
||||||
count = count + 1
|
count = count + 1
|
||||||
|
self.parent.OosChanged(False, self.serviceName)
|
||||||
|
|
||||||
def makePreview(self):
|
def makePreview(self):
|
||||||
"""
|
"""
|
||||||
|
@ -183,7 +183,7 @@ class SlideController(QtGui.QWidget):
|
|||||||
|
|
||||||
class MasterToolbar(QtCore.QObject):
|
class MasterToolbar(QtCore.QObject):
|
||||||
"""
|
"""
|
||||||
Class from which all tollbars should extend
|
Class from which all toolbars should extend
|
||||||
"""
|
"""
|
||||||
def __init__(self, isLive):
|
def __init__(self, isLive):
|
||||||
self.Toolbar = None
|
self.Toolbar = None
|
||||||
@ -232,6 +232,13 @@ class MasterToolbar(QtCore.QObject):
|
|||||||
translate(u'SlideController', u'Close Screen'),
|
translate(u'SlideController', u'Close Screen'),
|
||||||
self.onBlankScreen)
|
self.onBlankScreen)
|
||||||
|
|
||||||
|
def serviceLoaded(self):
|
||||||
|
"""
|
||||||
|
method to allow toolbars to know when the service item
|
||||||
|
is fully in place
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
def onSlideSelectedFirst(self):
|
def onSlideSelectedFirst(self):
|
||||||
"""
|
"""
|
||||||
Go to the first slide.
|
Go to the first slide.
|
||||||
@ -325,3 +332,4 @@ class MasterToolbar(QtCore.QObject):
|
|||||||
else:
|
else:
|
||||||
self.PreviewListWidget.selectRow(slideno)
|
self.PreviewListWidget.selectRow(slideno)
|
||||||
self.onSlideSelected()
|
self.onSlideSelected()
|
||||||
|
self.serviceLoaded()
|
||||||
|
@ -1,52 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
|
||||||
"""
|
|
||||||
OpenLP - Open Source Lyrics Projection
|
|
||||||
Copyright (c) 2008 Raoul Snyman
|
|
||||||
Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley,
|
|
||||||
|
|
||||||
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 logging
|
|
||||||
import os
|
|
||||||
|
|
||||||
class SlideControllerManager():
|
|
||||||
"""
|
|
||||||
This class controls which SlideController is availabe to the
|
|
||||||
main window
|
|
||||||
"""
|
|
||||||
global log
|
|
||||||
log = logging.getLogger(u'SlideControllerManager')
|
|
||||||
|
|
||||||
def __init__(self, parent):
|
|
||||||
"""
|
|
||||||
Set up the Slide Controller. Manager
|
|
||||||
"""
|
|
||||||
self.parent = parent
|
|
||||||
self.live = {}
|
|
||||||
self.preview = {}
|
|
||||||
|
|
||||||
def add_controllers(self, handle, preview, live):
|
|
||||||
self.live[handle] = live
|
|
||||||
self.preview[handle] = preview
|
|
||||||
print self.live
|
|
||||||
|
|
||||||
def getPreviewController(self, handle):
|
|
||||||
return self.preview[handle]
|
|
||||||
|
|
||||||
def getLiveController(self, handle):
|
|
||||||
print "---"
|
|
||||||
print self.live
|
|
||||||
print handle
|
|
||||||
print self.live[handle]
|
|
||||||
return self.live[handle]
|
|
@ -21,109 +21,16 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import zipfile
|
import zipfile
|
||||||
import shutil
|
import shutil
|
||||||
|
import logging
|
||||||
|
|
||||||
from time import sleep
|
|
||||||
from xml.etree.ElementTree import ElementTree, XML
|
from xml.etree.ElementTree import ElementTree, XML
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.ui import AmendThemeForm, ServiceManager
|
from openlp.core.ui import AmendThemeForm, ServiceManager
|
||||||
from openlp.core.theme import Theme
|
from openlp.core.theme import Theme
|
||||||
from openlp.core.lib import Event, EventType, EventManager, OpenLPToolbar, ThemeXML, Renderer, translate, file_to_xml
|
from openlp.core.lib import Event, EventType, EventManager, OpenLPToolbar, ThemeXML, Renderer, translate, file_to_xml, buildIcon
|
||||||
from openlp.core.utils import ConfigHelper
|
from openlp.core.utils import ConfigHelper
|
||||||
|
|
||||||
import logging
|
|
||||||
|
|
||||||
class ThemeData(QtCore.QAbstractListModel):
|
|
||||||
"""
|
|
||||||
Tree of items for an order of Theme.
|
|
||||||
Includes methods for reading and writing the contents to an OOS file
|
|
||||||
Root contains a list of ThemeItems
|
|
||||||
"""
|
|
||||||
global log
|
|
||||||
log = logging.getLogger(u'ThemeData')
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
QtCore.QAbstractListModel.__init__(self)
|
|
||||||
self.items = []
|
|
||||||
self.rowheight = 50
|
|
||||||
self.maximagewidth = self.rowheight * 16 / 9.0;
|
|
||||||
log.info(u'Starting')
|
|
||||||
|
|
||||||
def clearItems(self):
|
|
||||||
self.items = []
|
|
||||||
|
|
||||||
def rowCount(self, parent):
|
|
||||||
return len(self.items)
|
|
||||||
|
|
||||||
def insertRow(self, row, filename):
|
|
||||||
self.beginInsertRows(QtCore.QModelIndex(), row, row)
|
|
||||||
log.debug(u'insert row %d:%s' % (row, filename))
|
|
||||||
(prefix, shortfilename) = os.path.split(unicode(filename))
|
|
||||||
log.debug(u'shortfilename = %s' % shortfilename)
|
|
||||||
theme = shortfilename.split(u'.')
|
|
||||||
# create a preview image
|
|
||||||
if os.path.exists(filename):
|
|
||||||
preview = QtGui.QImage(unicode(filename))
|
|
||||||
width = self.maximagewidth
|
|
||||||
height = self.rowheight
|
|
||||||
preview = preview.scaled(width, height, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation)
|
|
||||||
realwidth = preview.width()
|
|
||||||
realheight = preview.height()
|
|
||||||
# and move it to the centre of the preview space
|
|
||||||
pixmap = QtGui.QImage(width, height, QtGui.QImage.Format_ARGB32_Premultiplied)
|
|
||||||
pixmap.fill(QtCore.Qt.black)
|
|
||||||
painter = QtGui.QPainter(pixmap)
|
|
||||||
painter.drawImage((width - realwidth) / 2, (height - realheight) / 2, preview)
|
|
||||||
else:
|
|
||||||
width = self.maximagewidth
|
|
||||||
height = self.rowheight
|
|
||||||
pixmap = QtGui.QImage(width, height, QtGui.QImage.Format_ARGB32_Premultiplied)
|
|
||||||
pixmap.fill(QtCore.Qt.black)
|
|
||||||
# finally create the row
|
|
||||||
self.items.insert(row, (filename, pixmap, shortfilename, theme[0]))
|
|
||||||
log.debug(u'Items: %s' % self.items)
|
|
||||||
self.endInsertRows()
|
|
||||||
|
|
||||||
def removeRow(self, row):
|
|
||||||
self.beginRemoveRows(QtCore.QModelIndex(), row, row)
|
|
||||||
self.items.pop(row)
|
|
||||||
self.endRemoveRows()
|
|
||||||
|
|
||||||
def addRow(self, item):
|
|
||||||
self.insertRow(len(self.items), item)
|
|
||||||
|
|
||||||
def data(self, index, role):
|
|
||||||
row = index.row()
|
|
||||||
if row > len(self.items):
|
|
||||||
# if the last row is selected and deleted, we then get called with an empty row!
|
|
||||||
return QtCore.QVariant()
|
|
||||||
if role == QtCore.Qt.DisplayRole:
|
|
||||||
retval = self.items[row][3]
|
|
||||||
elif role == QtCore.Qt.DecorationRole:
|
|
||||||
retval = self.items[row][1]
|
|
||||||
else:
|
|
||||||
retval = QtCore.QVariant()
|
|
||||||
if type(retval) is not type(QtCore.QVariant):
|
|
||||||
return QtCore.QVariant(retval)
|
|
||||||
else:
|
|
||||||
return retval
|
|
||||||
|
|
||||||
def __iter__(self):
|
|
||||||
for item in self.items:
|
|
||||||
yield item
|
|
||||||
|
|
||||||
def getValue(self, index):
|
|
||||||
row = index.row()
|
|
||||||
return self.items[row]
|
|
||||||
|
|
||||||
def getItem(self, row):
|
|
||||||
log.info(u'Get Item:%d -> %s' % (row, unicode(self.items)))
|
|
||||||
return self.items[row]
|
|
||||||
|
|
||||||
def getList(self):
|
|
||||||
filelist = [item[3] for item in self.items]
|
|
||||||
return filelist
|
|
||||||
|
|
||||||
class ThemeManager(QtGui.QWidget):
|
class ThemeManager(QtGui.QWidget):
|
||||||
"""
|
"""
|
||||||
Manages the orders of Theme.
|
Manages the orders of Theme.
|
||||||
@ -157,13 +64,10 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
translate(u'ThemeManager', u'Export a theme'), self.onExportTheme)
|
translate(u'ThemeManager', u'Export a theme'), self.onExportTheme)
|
||||||
self.ThemeWidget = QtGui.QWidgetAction(self.Toolbar)
|
self.ThemeWidget = QtGui.QWidgetAction(self.Toolbar)
|
||||||
self.Layout.addWidget(self.Toolbar)
|
self.Layout.addWidget(self.Toolbar)
|
||||||
|
self.ThemeListWidget = QtGui.QListWidget(self)
|
||||||
self.ThemeListView = QtGui.QListView(self)
|
self.ThemeListWidget.setAlternatingRowColors(True)
|
||||||
self.themeData = ThemeData()
|
self.ThemeListWidget.setIconSize(QtCore.QSize(88,50))
|
||||||
self.ThemeListView.setModel(self.themeData)
|
self.Layout.addWidget(self.ThemeListWidget)
|
||||||
self.ThemeListView.setAlternatingRowColors(True)
|
|
||||||
self.Layout.addWidget(self.ThemeListView)
|
|
||||||
|
|
||||||
self.themelist = []
|
self.themelist = []
|
||||||
self.path = os.path.join(ConfigHelper.get_data_path(), u'themes')
|
self.path = os.path.join(ConfigHelper.get_data_path(), u'themes')
|
||||||
self.checkThemesExists(self.path)
|
self.checkThemesExists(self.path)
|
||||||
@ -174,21 +78,18 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
self.amendThemeForm.exec_()
|
self.amendThemeForm.exec_()
|
||||||
|
|
||||||
def onEditTheme(self):
|
def onEditTheme(self):
|
||||||
items = self.ThemeListView.selectedIndexes()
|
item = self.ThemeListWidget.currentItem()
|
||||||
if len(items) > 0:
|
if item is not None:
|
||||||
for item in items:
|
self.amendThemeForm.loadTheme(unicode(item.text()))
|
||||||
data = self.themeData.getValue(item)
|
|
||||||
self.amendThemeForm.loadTheme(data[3])
|
|
||||||
self.amendThemeForm.exec_()
|
self.amendThemeForm.exec_()
|
||||||
|
|
||||||
def onDeleteTheme(self):
|
def onDeleteTheme(self):
|
||||||
items = self.ThemeListView.selectedIndexes()
|
item = self.ThemeListWidget.currentItem()
|
||||||
if len(items) > 0:
|
if item is not None:
|
||||||
theme = u''
|
theme = unicode(item.text())
|
||||||
for item in items:
|
|
||||||
data = self.themeData.getValue(item)
|
|
||||||
theme = data[3]
|
|
||||||
th = theme + u'.png'
|
th = theme + u'.png'
|
||||||
|
row = self.ThemeListWidget.row(item)
|
||||||
|
self.ThemeListWidget.takeItem(row)
|
||||||
try:
|
try:
|
||||||
os.remove(os.path.join(self.path, th))
|
os.remove(os.path.join(self.path, th))
|
||||||
except:
|
except:
|
||||||
@ -199,8 +100,6 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
except:
|
except:
|
||||||
#if not present do not worry
|
#if not present do not worry
|
||||||
pass
|
pass
|
||||||
self.themeData.clearItems()
|
|
||||||
self.loadThemes()
|
|
||||||
|
|
||||||
def onExportTheme(self):
|
def onExportTheme(self):
|
||||||
pass
|
pass
|
||||||
@ -213,24 +112,37 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
if len(files) > 0:
|
if len(files) > 0:
|
||||||
for file in files:
|
for file in files:
|
||||||
self.unzipTheme(file, self.path)
|
self.unzipTheme(file, self.path)
|
||||||
self.themeData.clearItems()
|
|
||||||
self.loadThemes()
|
self.loadThemes()
|
||||||
|
|
||||||
def loadThemes(self):
|
def loadThemes(self):
|
||||||
|
"""
|
||||||
|
Loads the theme lists and triggers updates accross
|
||||||
|
the whole system using direct calls or core functions
|
||||||
|
and events for the plugins.
|
||||||
|
The plugins will call back in to get the real list if they want it.
|
||||||
|
"""
|
||||||
log.debug(u'Load themes from dir')
|
log.debug(u'Load themes from dir')
|
||||||
|
self.themelist = []
|
||||||
|
self.ThemeListWidget.clear()
|
||||||
for root, dirs, files in os.walk(self.path):
|
for root, dirs, files in os.walk(self.path):
|
||||||
for name in files:
|
for name in files:
|
||||||
if name.endswith(u'.png'):
|
if name.endswith(u'.png'):
|
||||||
#check to see file is in route directory
|
#check to see file is in theme root directory
|
||||||
theme = os.path.join(self.path, name)
|
theme = os.path.join(self.path, name)
|
||||||
if os.path.exists(theme):
|
if os.path.exists(theme):
|
||||||
self.themeData.addRow(theme)
|
(path, filename) = os.path.split(unicode(file))
|
||||||
|
textName = os.path.splitext(name)[0]
|
||||||
|
item_name = QtGui.QListWidgetItem(textName)
|
||||||
|
item_name.setIcon(buildIcon(theme))
|
||||||
|
item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(textName))
|
||||||
|
self.ThemeListWidget.addItem(item_name)
|
||||||
|
self.themelist.append(textName)
|
||||||
self.parent.EventManager.post_event(Event(EventType.ThemeListChanged))
|
self.parent.EventManager.post_event(Event(EventType.ThemeListChanged))
|
||||||
self.parent.ServiceManagerContents.updateThemeList(self.getThemes())
|
self.parent.ServiceManagerContents.updateThemeList(self.getThemes())
|
||||||
self.parent.settingsForm.ThemesTab.updateThemeList(self.getThemes())
|
self.parent.settingsForm.ThemesTab.updateThemeList(self.getThemes())
|
||||||
|
|
||||||
def getThemes(self):
|
def getThemes(self):
|
||||||
return self.themeData.getList()
|
return self.themelist
|
||||||
|
|
||||||
def getThemeData(self, themename):
|
def getThemeData(self, themename):
|
||||||
log.debug(u'getthemedata for theme %s', themename)
|
log.debug(u'getthemedata for theme %s', themename)
|
||||||
@ -337,6 +249,10 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
return newtheme.extract_xml()
|
return newtheme.extract_xml()
|
||||||
|
|
||||||
def saveTheme(self, name, theme_xml, image_from, image_to) :
|
def saveTheme(self, name, theme_xml, image_from, image_to) :
|
||||||
|
"""
|
||||||
|
Called by thememaintenance Dialog to save the theme
|
||||||
|
and to trigger the reload of the theme list
|
||||||
|
"""
|
||||||
log.debug(u'saveTheme %s %s', name, theme_xml)
|
log.debug(u'saveTheme %s %s', name, theme_xml)
|
||||||
theme_dir = os.path.join(self.path, name)
|
theme_dir = os.path.join(self.path, name)
|
||||||
if os.path.exists(theme_dir) == False:
|
if os.path.exists(theme_dir) == False:
|
||||||
@ -348,7 +264,6 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
if image_from is not None and image_from != image_to:
|
if image_from is not None and image_from != image_to:
|
||||||
shutil.copyfile(image_from, image_to)
|
shutil.copyfile(image_from, image_to)
|
||||||
self.generateAndSaveImage(self.path, name, theme_xml)
|
self.generateAndSaveImage(self.path, name, theme_xml)
|
||||||
self.themeData.clearItems()
|
|
||||||
self.loadThemes()
|
self.loadThemes()
|
||||||
|
|
||||||
def generateAndSaveImage(self, dir, name, theme_xml):
|
def generateAndSaveImage(self, dir, name, theme_xml):
|
||||||
@ -357,7 +272,6 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
theme.parse(theme_xml)
|
theme.parse(theme_xml)
|
||||||
theme.extend_image_filename(dir)
|
theme.extend_image_filename(dir)
|
||||||
frame = self.generateImage(theme)
|
frame = self.generateImage(theme)
|
||||||
#im = frame.toImage()
|
|
||||||
samplepathname = os.path.join(self.path, name + u'.png')
|
samplepathname = os.path.join(self.path, name + u'.png')
|
||||||
if os.path.exists(samplepathname):
|
if os.path.exists(samplepathname):
|
||||||
os.unlink(samplepathname)
|
os.unlink(samplepathname)
|
||||||
@ -365,6 +279,9 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
log.debug(u'Theme image written to %s', samplepathname)
|
log.debug(u'Theme image written to %s', samplepathname)
|
||||||
|
|
||||||
def generateImage(self, themedata):
|
def generateImage(self, themedata):
|
||||||
|
"""
|
||||||
|
Call the RenderManager to build a Sample Image
|
||||||
|
"""
|
||||||
log.debug(u'generateImage %s ', themedata)
|
log.debug(u'generateImage %s ', themedata)
|
||||||
frame = self.parent.RenderManager.generate_preview(themedata)
|
frame = self.parent.RenderManager.generate_preview(themedata)
|
||||||
return frame
|
return frame
|
||||||
|
@ -494,7 +494,7 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
if end_verse == '':
|
if end_verse == '':
|
||||||
end_verse = 99
|
end_verse = 99
|
||||||
if start_chapter == '':
|
if start_chapter == '':
|
||||||
message = u'No chapter found for search'
|
message = u'No chapter found for search criteria'
|
||||||
#print 'message = ' + unicode(message)
|
#print 'message = ' + unicode(message)
|
||||||
#print 'search = ' + unicode(original)
|
#print 'search = ' + unicode(original)
|
||||||
#print 'results = ' + unicode(book) + ' @ '+ unicode(start_chapter)+' @ '+ unicode(end_chapter)+' @ '+ unicode(start_verse)+ ' @ '+ unicode(end_verse)
|
#print 'results = ' + unicode(book) + ' @ '+ unicode(start_chapter)+' @ '+ unicode(end_chapter)+' @ '+ unicode(start_verse)+ ' @ '+ unicode(end_verse)
|
||||||
|
@ -74,14 +74,26 @@ class ImageToolbar(MasterToolbar):
|
|||||||
u':/media/media_stop.png',
|
u':/media/media_stop.png',
|
||||||
translate(u'SlideController', u'Stop continuous loop'),
|
translate(u'SlideController', u'Stop continuous loop'),
|
||||||
self.onStopLoop)
|
self.onStopLoop)
|
||||||
|
self.Toolbar.addSeparator()
|
||||||
|
self.DelaySpinBox = QtGui.QSpinBox(self.Toolbar)
|
||||||
|
self.SpinWidget = QtGui.QWidgetAction(self.Toolbar)
|
||||||
|
self.SpinWidget.setDefaultWidget(self.DelaySpinBox)
|
||||||
|
self.Toolbar.addAction(self.SpinWidget)
|
||||||
|
#self.Layout.addWidget(self.Toolbar)
|
||||||
self.Toolbar.setSizePolicy(sizeToolbarPolicy)
|
self.Toolbar.setSizePolicy(sizeToolbarPolicy)
|
||||||
|
self.DelaySpinBox.setSuffix(translate(u'ImageSlideController', u's'))
|
||||||
|
|
||||||
|
def serviceLoaded(self):
|
||||||
|
self.DelaySpinBox.setValue(self.parent.parent.ImageTab.loop_delay)
|
||||||
|
if self.PreviewListWidget.rowCount() == 1:
|
||||||
|
self.DelaySpinBox.setEnabled(False)
|
||||||
|
|
||||||
def onStartLoop(self):
|
def onStartLoop(self):
|
||||||
"""
|
"""
|
||||||
Go to the last slide.
|
Go to the last slide.
|
||||||
"""
|
"""
|
||||||
delay = self.parent.parent.ImageTab.loop_delay
|
if self.PreviewListWidget.rowCount() > 1:
|
||||||
self.timer_id = self.startTimer(delay * 1000)
|
self.timer_id = self.startTimer(int(self.TimeoutSpinBox.value()) * 1000)
|
||||||
|
|
||||||
def onStopLoop(self):
|
def onStopLoop(self):
|
||||||
"""
|
"""
|
||||||
@ -92,4 +104,3 @@ class ImageToolbar(MasterToolbar):
|
|||||||
def timerEvent(self, event):
|
def timerEvent(self, event):
|
||||||
if event.timerId() == self.timer_id:
|
if event.timerId() == self.timer_id:
|
||||||
self.onSlideSelectedNext()
|
self.onSlideSelectedNext()
|
||||||
|
|
||||||
|
@ -49,7 +49,6 @@ class ImageTab(SettingsTab):
|
|||||||
self.TimeoutSpacer = QtGui.QSpacerItem(147, 20,
|
self.TimeoutSpacer = QtGui.QSpacerItem(147, 20,
|
||||||
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
||||||
self.TimeoutLayout.addItem(self.TimeoutSpacer)
|
self.TimeoutLayout.addItem(self.TimeoutSpacer)
|
||||||
|
|
||||||
self.ImageLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.ImageModeGroupBox)
|
self.ImageLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.ImageModeGroupBox)
|
||||||
# Signals and slots
|
# Signals and slots
|
||||||
QtCore.QObject.connect(self.TimeoutSpinBox,
|
QtCore.QObject.connect(self.TimeoutSpinBox,
|
||||||
@ -57,6 +56,7 @@ class ImageTab(SettingsTab):
|
|||||||
|
|
||||||
def retranslateUi(self):
|
def retranslateUi(self):
|
||||||
self.TimeoutLabel.setText(translate(u'ImageTab', u'Slide Loop Delay:'))
|
self.TimeoutLabel.setText(translate(u'ImageTab', u'Slide Loop Delay:'))
|
||||||
|
self.TimeoutSpinBox.setSuffix(translate(u'ImageTab', u's'))
|
||||||
|
|
||||||
def onTimeoutSpinBoxChanged(self):
|
def onTimeoutSpinBoxChanged(self):
|
||||||
self.loop_delay = self.TimeoutSpinBox.value()
|
self.loop_delay = self.TimeoutSpinBox.value()
|
||||||
|
Loading…
Reference in New Issue
Block a user