forked from openlp/openlp
Bug fixes to handle window events with no selection
Comment and file cleanups Add extra filter to file list ServiceManager record movements and changes to OOS to allow for files to be stored
This commit is contained in:
parent
81a1136d15
commit
a95b55f905
@ -20,9 +20,8 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
import logging
|
||||
import os, os.path
|
||||
import sys
|
||||
#from copy import copy
|
||||
|
||||
from PyQt4 import QtGui, QtCore, Qt
|
||||
from PyQt4 import QtGui, QtCore
|
||||
|
||||
class Renderer:
|
||||
"""
|
||||
@ -36,7 +35,6 @@ class Renderer:
|
||||
def __init__(self):
|
||||
self._rect = None
|
||||
self._debug = 0
|
||||
#self.words = None
|
||||
self._right_margin = 64 # the amount of right indent
|
||||
self._shadow_offset = 5
|
||||
self._outline_offset = 2
|
||||
@ -140,7 +138,7 @@ class Renderer:
|
||||
# reset the frame. first time do not worry about what you paint on.
|
||||
#self._frame = QtGui.QPixmap(self._frame.width(), self._frame.height()) #(self._bg_frame)
|
||||
#self._frame.fill(QtCore.Qt.transparent)
|
||||
# reset the frame. first time do not worrk about what you paint on.
|
||||
# reset the frame. first time do not worry about what you paint on.
|
||||
self._frame = QtGui.QImage(self._bg_frame)
|
||||
x, y = self._correctAlignment(self._rect, bbox)
|
||||
bbox = self._render_lines_unaligned(lines, False, (x, y), True)
|
||||
|
@ -21,9 +21,8 @@ import logging
|
||||
import os, os.path
|
||||
import sys
|
||||
|
||||
from datetime import *
|
||||
from PyQt4 import QtGui, QtCore, Qt
|
||||
from renderer import Renderer
|
||||
from PyQt4 import QtGui, QtCore
|
||||
from renderer import Renderer
|
||||
|
||||
import sys
|
||||
import linecache
|
||||
|
@ -113,25 +113,47 @@ class ServiceManager(QtGui.QWidget):
|
||||
"""
|
||||
Move the current ServiceItem to the top of the list
|
||||
"""
|
||||
pass
|
||||
item, count = self.findServiceItem()
|
||||
if item < len(self.serviceItems) and item is not -1:
|
||||
temp = self.serviceItems[item]
|
||||
self.serviceItems.remove(self.serviceItems[item])
|
||||
self.serviceItems.insert(0, temp)
|
||||
self.repaintServiceList()
|
||||
|
||||
def onServiceUp(self):
|
||||
"""
|
||||
Move the current ServiceItem up in the list
|
||||
Note move up means move to top of area ie 0.
|
||||
"""
|
||||
pass
|
||||
item, count = self.findServiceItem()
|
||||
if item > 0:
|
||||
temp = self.serviceItems[item]
|
||||
self.serviceItems.remove(self.serviceItems[item])
|
||||
self.serviceItems.insert(item - 1, temp)
|
||||
self.repaintServiceList()
|
||||
|
||||
def onServiceDown(self):
|
||||
"""
|
||||
Move the current ServiceItem down in the list
|
||||
Note move down means move to bottom of area i.e len().
|
||||
"""
|
||||
pass
|
||||
item, count = self.findServiceItem()
|
||||
if item < len(self.serviceItems) and item is not -1:
|
||||
temp = self.serviceItems[item]
|
||||
self.serviceItems.remove(self.serviceItems[item])
|
||||
self.serviceItems.insert(item + 1, temp)
|
||||
self.repaintServiceList()
|
||||
|
||||
def onServiceEnd(self):
|
||||
"""
|
||||
Move the current ServiceItem to the bottom of the list
|
||||
"""
|
||||
pass
|
||||
item, count = self.findServiceItem()
|
||||
if item < len(self.serviceItems) and item is not -1:
|
||||
temp = self.serviceItems[item]
|
||||
self.serviceItems.remove(self.serviceItems[item])
|
||||
self.serviceItems.insert(len(self.serviceItems), temp)
|
||||
self.repaintServiceList()
|
||||
|
||||
def onNewService(self):
|
||||
"""
|
||||
@ -144,7 +166,32 @@ class ServiceManager(QtGui.QWidget):
|
||||
"""
|
||||
Remove the current ServiceItem from the list
|
||||
"""
|
||||
pass
|
||||
item, count = self.findServiceItem()
|
||||
if item is not -1:
|
||||
self.serviceItems.remove(self.serviceItems[item])
|
||||
self.repaintServiceList()
|
||||
|
||||
def repaintServiceList(self):
|
||||
#Correct order of idems in array
|
||||
count = 1
|
||||
for item in self.serviceItems:
|
||||
item[u'order'] = count
|
||||
count += 1
|
||||
#Repaint the screen
|
||||
self.ServiceManagerList.clear()
|
||||
for item in self.serviceItems:
|
||||
serviceitem = item[u'data']
|
||||
treewidgetitem = QtGui.QTreeWidgetItem(self.ServiceManagerList)
|
||||
treewidgetitem.setText(0,serviceitem.title)
|
||||
treewidgetitem.setIcon(0,serviceitem.iconic_representation)
|
||||
treewidgetitem.setData(0, QtCore.Qt.UserRole, QtCore.QVariant(item[u'order']))
|
||||
count = 0
|
||||
for frame in serviceitem.frames:
|
||||
treewidgetitem1 = QtGui.QTreeWidgetItem(treewidgetitem)
|
||||
text = frame[u'title']
|
||||
treewidgetitem1.setText(0,text[:40])
|
||||
treewidgetitem1.setData(0, QtCore.Qt.UserRole,QtCore.QVariant(count))
|
||||
count = count + 1
|
||||
|
||||
def onSaveService(self):
|
||||
"""
|
||||
@ -233,11 +280,10 @@ class ServiceManager(QtGui.QWidget):
|
||||
pos = 0
|
||||
count = 0
|
||||
for item in items:
|
||||
childCount = item.childCount()
|
||||
if childCount >= 1:
|
||||
parentitem = item.parent()
|
||||
if parentitem is None:
|
||||
pos = item.data(0, QtCore.Qt.UserRole).toInt()[0]
|
||||
else:
|
||||
parentitem = item.parent()
|
||||
pos = parentitem.data(0, QtCore.Qt.UserRole).toInt()[0]
|
||||
count = item.data(0, QtCore.Qt.UserRole).toInt()[0]
|
||||
#adjuest for zero based arrays
|
||||
@ -274,4 +320,4 @@ class ServiceManager(QtGui.QWidget):
|
||||
id = 0
|
||||
self.service_theme = u''
|
||||
self.ThemeComboBox.setCurrentIndex(id)
|
||||
self.parent.RenderManager.set_service_theme(self.service_theme)
|
||||
self.parent.RenderManager.set_service_theme(self.service_theme)
|
||||
|
@ -142,17 +142,20 @@ class CustomMediaItem(MediaManagerItem):
|
||||
|
||||
def onCustomEditClick(self):
|
||||
item = self.CustomListWidget.currentItem()
|
||||
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
self.parent.edit_custom_form.loadCustom(item_id)
|
||||
self.parent.edit_custom_form.exec_()
|
||||
self.initialise()
|
||||
item = self.CustomListWidget.currentItem()
|
||||
if item is not None:
|
||||
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
self.parent.edit_custom_form.loadCustom(item_id)
|
||||
self.parent.edit_custom_form.exec_()
|
||||
self.initialise()
|
||||
|
||||
def onCustomDeleteClick(self):
|
||||
item = self.CustomListWidget.currentItem()
|
||||
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
self.parent.custommanager.delete_custom(item_id)
|
||||
row = self.CustomListWidget.row(item)
|
||||
self.CustomListWidget.takeItem(row)
|
||||
if item is not None:
|
||||
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
self.parent.custommanager.delete_custom(item_id)
|
||||
row = self.CustomListWidget.row(item)
|
||||
self.CustomListWidget.takeItem(row)
|
||||
|
||||
def onCustomPreviewClick(self):
|
||||
log.debug(u'Custom Preview Requested')
|
||||
|
@ -1,113 +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 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
|
||||
from PyQt4 import QtCore, QtGui
|
||||
from openlp.core.lib import ServiceItem
|
||||
from listwithpreviews import ListWithPreviews
|
||||
|
||||
class ImageServiceItem(ServiceItem):
|
||||
"""
|
||||
The service item is a base class for the plugins to use to interact with
|
||||
* the service manager (and hence the OOS disk files),
|
||||
* the slide controller(s - both preview and live)
|
||||
* and the renderer - which produces the
|
||||
main screen
|
||||
the preview preview and
|
||||
the live preview
|
||||
|
||||
The image plugin passes one of these to the preview/live when requested
|
||||
The preview/live controllers keep hold of it
|
||||
The service manager has one in its service structure for each Image item in the OOS
|
||||
When something goes live/previews -
|
||||
it simply tells the slide controller to use it???
|
||||
|
||||
It contains 1 or more images
|
||||
|
||||
"""
|
||||
global log
|
||||
log=logging.getLogger(u'ImageServiceItem')
|
||||
log.info(u'ImageServiceItem loaded')
|
||||
def __init__(self, controller):
|
||||
"""
|
||||
Init Method
|
||||
"""
|
||||
log.info(u'init')
|
||||
self.imgs=ListWithPreviews()
|
||||
# self.slide_controller=controller
|
||||
# self.slide_controller.ControllerContents=QtGui.QListView()
|
||||
# c=self.slide_controller.ControllerContents
|
||||
# c.uniformItemSizes=True
|
||||
# c.setModel(self.imgs)
|
||||
# c.setGeometry(0,0,200,200)
|
||||
|
||||
def render(self):
|
||||
"""
|
||||
The render method is what the plugin uses to render its meda to the
|
||||
screen.
|
||||
"""
|
||||
# render the "image chooser first"
|
||||
# for f in self.imgs:
|
||||
# fl , nm = os.path.split(unicode(f))
|
||||
# c = self.slide_controller.rowCount()
|
||||
# self.slide_controller.setRowCount(c+1)
|
||||
# twi = QtGui.QTableWidgetItem(unicode(f))
|
||||
# self.slide_controller.setItem(c , 0, twi)
|
||||
# twi = QtGui.QTableWidgetItem(unicode(nm))
|
||||
# self.slide_controller.setItem(c , 1, twi)
|
||||
# self.slide_controller.setRowHeight(c, 80)
|
||||
|
||||
# render the preview screen here
|
||||
|
||||
def get_parent_node(self):
|
||||
"""
|
||||
This method returns a parent node to be inserted into the Service
|
||||
Manager.
|
||||
"""
|
||||
pass
|
||||
def add(self, data):
|
||||
"""
|
||||
append an image to the list
|
||||
"""
|
||||
if type(data)==type(u'string'):
|
||||
log.info(u'add filename:'+data)
|
||||
self.imgs.addRow(data)
|
||||
else: # it's another service item to be merged in
|
||||
log.info(u'add Item...'+unicode(data))
|
||||
for filename in data.get_file_list():
|
||||
self.add(filename)
|
||||
|
||||
|
||||
def get_oos_text(self):
|
||||
"""
|
||||
Turn the image list into a set of filenames for storage in the oos file
|
||||
"""
|
||||
log.info(u'Get oos text')
|
||||
log.info(unicode(self.imgs))
|
||||
# log.info(unicode(self.imgs.get_file_list()))
|
||||
return '\n'.join(self.imgs.get_file_list())
|
||||
|
||||
def set_from_oos(self, text):
|
||||
"""
|
||||
get text from the OOS file and setup the internal structure
|
||||
"""
|
||||
log.info(u'Set from OOS:'+text)
|
||||
files=text.split(u'\n')
|
||||
for f in files:
|
||||
self.imgs.addRow(f)
|
@ -5,11 +5,11 @@ 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
|
||||
This program is free software; you can rediunicodeibute 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
|
||||
This program is diunicodeibuted 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.
|
||||
|
||||
@ -21,10 +21,9 @@ import os
|
||||
import logging
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
|
||||
class ListWithPreviews(QtCore.QAbstractListModel):
|
||||
"""
|
||||
An abstract list of strings and the preview icon to go with them
|
||||
An abstract list of unicodeings and the preview icon to go with them
|
||||
"""
|
||||
global log
|
||||
log = logging.getLogger(u'ListWithPreviews')
|
||||
@ -32,7 +31,8 @@ class ListWithPreviews(QtCore.QAbstractListModel):
|
||||
|
||||
def __init__(self):
|
||||
QtCore.QAbstractListModel.__init__(self)
|
||||
self.items = [] # will be a list of (full filename, QPixmap, shortname) tuples
|
||||
# will be a list of (full filename, QPixmap, shortname) tuples
|
||||
self.items = []
|
||||
self.rowheight = 50
|
||||
self.maximagewidth = self.rowheight*16/9.0;
|
||||
|
||||
@ -41,10 +41,10 @@ class ListWithPreviews(QtCore.QAbstractListModel):
|
||||
|
||||
def insertRow(self, row, filename):
|
||||
self.beginInsertRows(QtCore.QModelIndex(),row,row)
|
||||
log.info(u'insert row %d:%s'% (row,filename))
|
||||
#log.info(u'insert row %d:%s' % (row,filename))
|
||||
# get short filename to display next to image
|
||||
(prefix, shortfilename) = os.path.split(unicode(filename))
|
||||
log.info(u'shortfilename=%s'% (shortfilename))
|
||||
#log.info(u'shortfilename=%s' % (shortfilename))
|
||||
# create a preview image
|
||||
if os.path.exists(filename):
|
||||
preview = QtGui.QPixmap(unicode(filename))
|
||||
|
@ -122,7 +122,7 @@ class ImageMediaItem(MediaManagerItem):
|
||||
files = QtGui.QFileDialog.getOpenFileNames(None,
|
||||
translate(u'ImageMediaItem', u'Select Image(s)'),
|
||||
self.parent.config.get_last_dir(),
|
||||
u'Images (*.jpg *.gif *.png *.bmp)')
|
||||
u'Images (*.jpg *jpeg *.gif *.png *.bmp)')
|
||||
log.info(u'New image(s)', unicode(files))
|
||||
if len(files) > 0:
|
||||
self.loadImageList(files)
|
||||
@ -169,4 +169,4 @@ class ImageMediaItem(MediaManagerItem):
|
||||
service_item = ServiceItem(self.parent)
|
||||
service_item.addIcon(u':/media/media_image.png')
|
||||
self.generateSlideData(service_item)
|
||||
self.parent.service_manager.addServiceItem(service_item)
|
||||
self.parent.service_manager.addServiceItem(service_item)
|
||||
|
@ -209,16 +209,18 @@ class SongMediaItem(MediaManagerItem):
|
||||
|
||||
def onSongEditClick(self):
|
||||
item = self.SongListWidget.currentItem()
|
||||
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
self.edit_song_form.loadSong(item_id)
|
||||
self.edit_song_form.exec_()
|
||||
if item is not None:
|
||||
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
self.edit_song_form.loadSong(item_id)
|
||||
self.edit_song_form.exec_()
|
||||
|
||||
def onSongDeleteClick(self):
|
||||
item = self.SongListWidget.currentItem()
|
||||
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
self.parent.songmanager.delete_song(item_id)
|
||||
row = self.SongListWidget.row(item)
|
||||
self.SongListWidget.takeItem(row)
|
||||
if item is not None:
|
||||
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
self.parent.songmanager.delete_song(item_id)
|
||||
row = self.SongListWidget.row(item)
|
||||
self.SongListWidget.takeItem(row)
|
||||
|
||||
def onSongPreviewClick(self):
|
||||
service_item = ServiceItem(self.parent)
|
||||
|
Loading…
Reference in New Issue
Block a user