forked from openlp/openlp
Add drag and drop to customplugin and expand it on servicemanager.py
Replace MVC in servicemanager.py Add Event processing to trigger plugin to pust item to service manager
This commit is contained in:
parent
643be2ca5e
commit
a7d1ba85ed
@ -35,6 +35,7 @@ class EventType(object):
|
||||
AfterLoadService = 2
|
||||
BeforeSaveService = 3
|
||||
AfterSaveService = 4
|
||||
LoadServiceItem = 5
|
||||
# Preview events
|
||||
PreviewBeforeLoad = 11
|
||||
PreviewAfterLoad = 12
|
||||
|
@ -279,8 +279,6 @@ class Renderer:
|
||||
brx=x
|
||||
bry=y
|
||||
for line in lines:
|
||||
#if (line == ''):
|
||||
# continue
|
||||
# render after current bottom, but at original left edge
|
||||
# keep track of right edge to see which is biggest
|
||||
(thisx, bry) = self._render_single_line(line, footer, (x,bry))
|
||||
@ -402,10 +400,9 @@ class Renderer:
|
||||
def _get_extent_and_render(self, line, footer, tlcorner=(0,0), draw=False, color=None):
|
||||
"""Find bounding box of text - as render_single_line.
|
||||
If draw is set, actually draw the text to the current DC as well
|
||||
|
||||
return width and height of text as a tuple (w,h)"""
|
||||
# setup defaults
|
||||
log.debug(u'_get_extent_and_render %s %s %s ', [line], tlcorner, draw)
|
||||
#log.debug(u'_get_extent_and_render %s %s %s ', [line], tlcorner, draw)
|
||||
p=QtGui.QPainter()
|
||||
p.begin(self._paint)
|
||||
# 'twould be more efficient to set this once when theme changes
|
||||
|
@ -113,5 +113,9 @@ class RenderManager:
|
||||
log.debug(u'calculate default %s' , screen)
|
||||
self.width = screen.width()
|
||||
self.height = screen.height()
|
||||
if self.width > 1024:
|
||||
self.width = 1024
|
||||
if self.height > 768:
|
||||
self.height = 768
|
||||
log.debug(u'calculate default %d,%d' , self.width, self.height)
|
||||
self.footer_start = int(self.height*0.95) # 95% is start of footer
|
||||
|
@ -44,7 +44,6 @@ class ServiceItem():
|
||||
self.items = []
|
||||
self.iconic_representation = None
|
||||
self.raw_slides = None
|
||||
self.format_slides = []
|
||||
self.frames = []
|
||||
self.raw_footer = None
|
||||
self.theme = None
|
||||
@ -74,11 +73,11 @@ class ServiceItem():
|
||||
else:
|
||||
self.render_manager.set_override_theme(self.theme)
|
||||
log.debug(u'Formatting slides')
|
||||
for slide in self.raw_slides:
|
||||
self.format_slides.append(self.render_manager.format_slide(slide, False))
|
||||
log.debug(u'Rendering slides')
|
||||
for slide in self.format_slides:
|
||||
self.frames.append(self.render_manager.generate_slide(slide, self.raw_footer))
|
||||
if len(self.frames) == 0 :
|
||||
for slide in self.raw_slides:
|
||||
formated = self.render_manager.format_slide(slide, False)
|
||||
frame = self.render_manager.generate_slide(slide, self.raw_footer)
|
||||
self.frames.append({u'formatted': formated, u'image': frame})
|
||||
|
||||
|
||||
def get_parent_node(self):
|
||||
|
@ -92,6 +92,7 @@ class MainWindow(object):
|
||||
self.ThemeManagerContents.eventManager = self.EventManager
|
||||
self.ThemeManagerContents.renderManager = self.RenderManager
|
||||
self.ServiceManagerContents.renderManager = self.RenderManager
|
||||
self.ServiceManagerContents.eventManager = self.EventManager
|
||||
self.ThemeManagerContents.serviceManager = self.ServiceManagerContents
|
||||
self.ThemeManagerContents.loadThemes()
|
||||
|
||||
|
@ -18,24 +18,20 @@ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
"""
|
||||
import os
|
||||
import logging
|
||||
|
||||
from time import sleep
|
||||
from copy import deepcopy
|
||||
|
||||
from PyQt4.QtCore import *
|
||||
from PyQt4.QtGui import *
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
# from openlp.core.resources import *
|
||||
# from openlp.core.ui import AboutForm, AlertForm, SettingsForm, SlideController
|
||||
from openlp.core.lib import OpenLPToolbar
|
||||
from openlp.core.lib import ServiceItem
|
||||
from openlp.core.lib import RenderManager
|
||||
from openlp.core import translate
|
||||
from openlp.core.lib import Event, EventType, EventManager
|
||||
|
||||
# from openlp.core import PluginManager
|
||||
import logging
|
||||
|
||||
class ServiceData(QAbstractItemModel):
|
||||
class ServiceData(QtCore.QAbstractItemModel):
|
||||
"""
|
||||
Tree of items for an order of service.
|
||||
Includes methods for reading and writing the contents to an OOS file
|
||||
@ -44,62 +40,62 @@ class ServiceData(QAbstractItemModel):
|
||||
global log
|
||||
log=logging.getLogger(u'ServiceData')
|
||||
def __init__(self):
|
||||
QAbstractItemModel.__init__(self)
|
||||
QtCore.QAbstractItemModel.__init__(self)
|
||||
self.items=[]
|
||||
log.info("Starting")
|
||||
|
||||
def clearItems(self):
|
||||
self.items = []
|
||||
|
||||
def columnCount(self, parent):
|
||||
def columnCount(self, parent=None):
|
||||
return 1; # always only a single column (for now)
|
||||
|
||||
def rowCount(self, parent):
|
||||
def rowCount(self, parent=None):
|
||||
return len(self.items)
|
||||
|
||||
def insertRow(self, row, service_item):
|
||||
self.beginInsertRows(QModelIndex(),row,row)
|
||||
self.beginInsertRows(QtCore.QModelIndex(),row,row)
|
||||
log.info("insert row %s:%s" % (row,service_item))
|
||||
self.items.insert(row, service_item)
|
||||
log.info("Items: %s" % self.items)
|
||||
self.endInsertRows()
|
||||
|
||||
def removeRow(self, row):
|
||||
self.beginRemoveRows(QModelIndex(), row,row)
|
||||
self.beginRemoveRows(QtCore.QModelIndex(), row,row)
|
||||
self.items.pop(row)
|
||||
self.endRemoveRows()
|
||||
|
||||
def addRow(self, item):
|
||||
self.insertRow(len(self.items), item)
|
||||
def addRow(self, service_item):
|
||||
self.insertRow(len(self.items), service_item)
|
||||
|
||||
def index(self, row, col, parent = QModelIndex()):
|
||||
def index(self, row, col, parent = QtCore.QModelIndex()):
|
||||
return self.createIndex(row,col)
|
||||
|
||||
def parent(self, index=QModelIndex()):
|
||||
return QModelIndex() # no children as yet
|
||||
def parent(self, index=QtCore.QModelIndex()):
|
||||
return QtCore.QModelIndex() # no children as yet
|
||||
|
||||
def data(self, index, role):
|
||||
"""
|
||||
Called by the service manager to draw us in the service window
|
||||
"""
|
||||
log.debug(u'data %s %d', index, role)
|
||||
row=index.row()
|
||||
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 QVariant()
|
||||
item=self.items[row]
|
||||
if role==Qt.DisplayRole:
|
||||
return QtCore.QVariant()
|
||||
item = self.items[row]
|
||||
if role == QtCore.Qt.DisplayRole:
|
||||
retval= item.title + u':' + item.shortname
|
||||
elif role == Qt.DecorationRole:
|
||||
elif role == QtCore.Qt.DecorationRole:
|
||||
retval = item.iconic_representation
|
||||
elif role == Qt.ToolTipRole:
|
||||
retval= None
|
||||
elif role == QtCore.Qt.ToolTipRole:
|
||||
retval = None
|
||||
else:
|
||||
retval= None
|
||||
retval = None
|
||||
if retval == None:
|
||||
retval=QVariant()
|
||||
retval = QtCore.QVariant()
|
||||
# log.info("Returning"+ str(retval))
|
||||
if type(retval) is not type(QVariant):
|
||||
return QVariant(retval)
|
||||
if type(retval) is not type(QtCore.QVariant):
|
||||
return QtCore.QVariant(retval)
|
||||
else:
|
||||
return retval
|
||||
|
||||
@ -112,7 +108,7 @@ class ServiceData(QAbstractItemModel):
|
||||
return self.items[row]
|
||||
|
||||
|
||||
class ServiceManager(QWidget):
|
||||
class ServiceManager(QtGui.QWidget):
|
||||
|
||||
"""Manages the orders of service. Currently this involves taking
|
||||
text strings from plugins and adding them to an OOS file. In
|
||||
@ -124,48 +120,52 @@ class ServiceManager(QWidget):
|
||||
log=logging.getLogger(u'ServiceManager')
|
||||
|
||||
def __init__(self, parent):
|
||||
QWidget.__init__(self)
|
||||
QtGui.QWidget.__init__(self)
|
||||
self.parent=parent
|
||||
self.Layout = QVBoxLayout(self)
|
||||
self.Layout = QtGui.QVBoxLayout(self)
|
||||
self.Layout.setSpacing(0)
|
||||
self.Layout.setMargin(0)
|
||||
self.Toolbar = OpenLPToolbar(self)
|
||||
self.Toolbar.addToolbarButton("Move to top", ":/services/service_top.png",
|
||||
translate(u'ServiceManager', u'Move to start'), self.onServiceTop)
|
||||
self.Toolbar.addToolbarButton("Move up", ":/services/service_up.png",
|
||||
self.Toolbar.addToolbarButton(u'Move to top', u':/services/service_top.png',
|
||||
translate(u'ServiceManager', u'Move to top'), self.onServiceTop)
|
||||
self.Toolbar.addToolbarButton(u'Move up', u':/services/service_up.png',
|
||||
translate(u'ServiceManager', u'Move up order'), self.onServiceUp)
|
||||
self.Toolbar.addToolbarButton("Move down", ":/services/service_down.png",
|
||||
self.Toolbar.addToolbarButton(u'Move down', u':/services/service_down.png',
|
||||
translate(u'ServiceManager', u'Move down order'), self.onServiceDown)
|
||||
self.Toolbar.addToolbarButton("Move to bottom", ":/services/service_bottom.png",
|
||||
self.Toolbar.addToolbarButton(u'Move to bottom', u':/services/service_bottom.png',
|
||||
translate(u'ServiceManager', u'Move to end'), self.onServiceEnd)
|
||||
self.Toolbar.addSeparator()
|
||||
self.Toolbar.addToolbarButton("New Service", ":/services/service_new.png",
|
||||
self.Toolbar.addToolbarButton(u'New Service', u':/services/service_new.png',
|
||||
translate(u'ServiceManager', u'Create a new Service'), self.onNewService)
|
||||
self.Toolbar.addToolbarButton("Delete From Service", ":/services/service_delete.png",
|
||||
self.Toolbar.addToolbarButton(u'Delete From Service', u':/services/service_delete.png',
|
||||
translate(u'ServiceManager', u'Delete From Service'), self.onDeleteFromService)
|
||||
self.Toolbar.addSeparator()
|
||||
self.Toolbar.addToolbarButton("Save Service", ":/services/service_save.png",
|
||||
self.Toolbar.addToolbarButton(u'Save Service', u':/services/service_save.png',
|
||||
translate(u'ServiceManager', u'Save Service'), self.onSaveService)
|
||||
self.Toolbar.addToolbarButton("Load Service", ":/services/service_open.png",
|
||||
self.Toolbar.addToolbarButton(u'Load Service', u':/services/service_open.png',
|
||||
translate(u'ServiceManager', u'Load Existing'), self.onLoadService)
|
||||
|
||||
self.Toolbar.addSeparator()
|
||||
self.ThemeComboBox = QComboBox(self.Toolbar)
|
||||
self.ThemeComboBox.setSizeAdjustPolicy(QComboBox.AdjustToContents)
|
||||
self.ThemeWidget = QWidgetAction(self.Toolbar)
|
||||
self.ThemeComboBox = QtGui.QComboBox(self.Toolbar)
|
||||
self.ThemeComboBox.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents)
|
||||
self.ThemeWidget = QtGui.QWidgetAction(self.Toolbar)
|
||||
self.ThemeWidget.setDefaultWidget(self.ThemeComboBox)
|
||||
self.Toolbar.addAction(self.ThemeWidget)
|
||||
|
||||
self.Layout.addWidget(self.Toolbar)
|
||||
|
||||
self.TreeView = QTreeView(self)
|
||||
self.service_data=ServiceData()
|
||||
self.TreeView.setModel(self.service_data)
|
||||
self.TreeView.setAlternatingRowColors(True)
|
||||
self.Layout.addWidget(self.TreeView)
|
||||
self.serviceManagerList = QtGui.QTreeWidget(self)
|
||||
self.serviceManagerList.setEditTriggers(QtGui.QAbstractItemView.CurrentChanged|QtGui.QAbstractItemView.DoubleClicked|QtGui.QAbstractItemView.EditKeyPressed)
|
||||
self.serviceManagerList.setDragDropMode(QtGui.QAbstractItemView.DragDrop)
|
||||
self.serviceManagerList.setAlternatingRowColors(True)
|
||||
self.serviceManagerList.setObjectName("serviceManagerList")
|
||||
self.serviceManagerList .__class__.dragEnterEvent=self.dragEnterEvent
|
||||
self.serviceManagerList .__class__.dragMoveEvent=self.dragEnterEvent
|
||||
self.serviceManagerList .__class__.dropEvent =self.dropEvent
|
||||
|
||||
QObject.connect(self.ThemeComboBox,
|
||||
SIGNAL("activated(int)"), self.onThemeComboBoxSelected)
|
||||
self.Layout.addWidget(self.serviceManagerList)
|
||||
|
||||
QtCore.QObject.connect(self.ThemeComboBox,
|
||||
QtCore.SIGNAL("activated(int)"), self.onThemeComboBoxSelected)
|
||||
|
||||
def onServiceTop(self):
|
||||
pass
|
||||
@ -191,40 +191,36 @@ class ServiceManager(QWidget):
|
||||
def onLoadService(self):
|
||||
Pass
|
||||
|
||||
|
||||
|
||||
|
||||
def onThemeComboBoxSelected(self, currentIndex):
|
||||
self.renderManager.default_theme = self.ThemeComboBox.currentText()
|
||||
|
||||
def addServiceItem(self, item):
|
||||
"""Adds service item"""
|
||||
log.info("addServiceItem")
|
||||
indexes=self.TreeView.selectedIndexes()
|
||||
assert len(indexes) <= 1 # can only have one selected index in this view
|
||||
if indexes == []:
|
||||
log.info("No row")
|
||||
row = None
|
||||
selected_item = None
|
||||
else:
|
||||
row=indexes[0].row()
|
||||
# if currently selected is of correct type, add it to it
|
||||
log.info("row:%d"%row)
|
||||
selected_item=self.service_data.item(row)
|
||||
treewidgetitem = QtGui.QTreeWidgetItem(self.serviceManagerList)
|
||||
treewidgetitem.setText(0,item.title + u':' + item.shortname)
|
||||
treewidgetitem.setIcon(0,item.iconic_representation)
|
||||
treewidgetitem.setExpanded(True)
|
||||
item.render()
|
||||
for frame in item.frames:
|
||||
treewidgetitem1 = QtGui.QTreeWidgetItem(treewidgetitem)
|
||||
text = frame[u'formatted'][0]
|
||||
treewidgetitem1.setText(0,text[:10])
|
||||
#treewidgetitem1.setIcon(0,frame[u'image'])
|
||||
|
||||
if type(selected_item) == type(item):
|
||||
log.info("Add to existing item")
|
||||
selected_item.add(item)
|
||||
else:
|
||||
log.info("Create new item")
|
||||
if row is None:
|
||||
self.service_data.addRow(item)
|
||||
else:
|
||||
self.service_data.insertRow(row+1, item)
|
||||
def dragEnterEvent(self, event):
|
||||
"""
|
||||
Accept Drag events
|
||||
"""
|
||||
event.accept()
|
||||
|
||||
def removeServiceItem(self):
|
||||
"""Remove currently selected item"""
|
||||
pass
|
||||
def dropEvent(self, event):
|
||||
"""
|
||||
Handle the release of the event and trigger the plugin
|
||||
to add the data
|
||||
"""
|
||||
link=event.mimeData()
|
||||
if link.hasText():
|
||||
plugin = event.mimeData().text()
|
||||
self.eventManager.post_event(Event(EventType.LoadServiceItem, plugin))
|
||||
|
||||
def oos_as_text(self):
|
||||
text=[]
|
||||
@ -247,6 +243,9 @@ class ServiceManager(QWidget):
|
||||
oosfile.close()
|
||||
|
||||
def updateThemeList(self, theme_list):
|
||||
"""
|
||||
Called from ThemeManager when the Themes have changed
|
||||
"""
|
||||
self.ThemeComboBox.clear()
|
||||
for theme in theme_list:
|
||||
self.ThemeComboBox.addItem(theme)
|
||||
|
@ -20,13 +20,12 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
import logging
|
||||
import os
|
||||
|
||||
from PyQt4.QtCore import *
|
||||
from PyQt4.QtGui import *
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import OpenLPToolbar
|
||||
from openlp.core import translate
|
||||
|
||||
class SlideData(QAbstractListModel):
|
||||
class SlideData(QtCore.QAbstractListModel):
|
||||
"""
|
||||
Tree of items for an order of Theme.
|
||||
Includes methods for reading and writing the contents to an OOS file
|
||||
@ -36,7 +35,7 @@ class SlideData(QAbstractListModel):
|
||||
log=logging.getLogger(u'SlideData')
|
||||
|
||||
def __init__(self):
|
||||
QAbstractListModel.__init__(self)
|
||||
QtCore.QAbstractListModel.__init__(self)
|
||||
self.items=[]
|
||||
self.rowheight=50
|
||||
self.maximagewidth=self.rowheight*16/9.0;
|
||||
@ -52,16 +51,16 @@ class SlideData(QAbstractListModel):
|
||||
return len(self.items)
|
||||
|
||||
def insertRow(self, row, frame):
|
||||
self.beginInsertRows(QModelIndex(),row,row)
|
||||
self.beginInsertRows(QtCore.QModelIndex(),row,row)
|
||||
log.info(u'insert row %d' % row)
|
||||
# create a preview image
|
||||
frame1 = frame.scaled(QSize(350,260))
|
||||
frame1 = frame.scaled(QtCore.QSize(350,260))
|
||||
self.items.insert(row,(frame1))
|
||||
log.info(u'Items: %s' % self.items)
|
||||
self.endInsertRows()
|
||||
|
||||
def removeRow(self, row):
|
||||
self.beginRemoveRows(QModelIndex(), row,row)
|
||||
self.beginRemoveRows(QtCore.QModelIndex(), row,row)
|
||||
self.items.pop(row)
|
||||
self.endRemoveRows()
|
||||
|
||||
@ -71,16 +70,16 @@ class SlideData(QAbstractListModel):
|
||||
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 QVariant()
|
||||
return QtCore.QVariant()
|
||||
# if role==Qt.DisplayRole:
|
||||
# retval= self.items[row][1]
|
||||
if role == Qt.DecorationRole:
|
||||
if role == QtCore.Qt.DecorationRole:
|
||||
retval= self.items[row]#[0]
|
||||
else:
|
||||
retval= QVariant()
|
||||
retval= QtCore.QVariant()
|
||||
# log.info("Returning"+ str(retval))
|
||||
if type(retval) is not type(QVariant):
|
||||
return QVariant(retval)
|
||||
if type(retval) is not type(QtCore.QVariant):
|
||||
return QtCore.QVariant(retval)
|
||||
else:
|
||||
return retval
|
||||
|
||||
@ -101,75 +100,75 @@ class SlideData(QAbstractListModel):
|
||||
return filelist
|
||||
|
||||
|
||||
class SlideController(QWidget):
|
||||
class SlideController(QtGui.QWidget):
|
||||
global log
|
||||
log=logging.getLogger(u'SlideController')
|
||||
|
||||
def __init__(self, control_splitter, isLive):
|
||||
QWidget.__init__(self)
|
||||
QtGui.QWidget.__init__(self)
|
||||
self.isLive = isLive
|
||||
self.Panel = QWidget(control_splitter)
|
||||
self.Splitter = QSplitter(self.Panel)
|
||||
self.Splitter.setOrientation(Qt.Vertical)
|
||||
self.Panel = QtGui.QWidget(control_splitter)
|
||||
self.Splitter = QtGui.QSplitter(self.Panel)
|
||||
self.Splitter.setOrientation(QtCore.Qt.Vertical)
|
||||
|
||||
self.PanelLayout = QVBoxLayout(self.Panel)
|
||||
self.PanelLayout = QtGui.QVBoxLayout(self.Panel)
|
||||
self.PanelLayout.addWidget(self.Splitter)
|
||||
self.PanelLayout.setSpacing(50)
|
||||
self.PanelLayout.setMargin(0)
|
||||
|
||||
self.Controller = QScrollArea(self.Splitter)
|
||||
self.Controller = QtGui.QScrollArea(self.Splitter)
|
||||
self.Controller.setWidgetResizable(True)
|
||||
|
||||
self.PreviewListView = QListView(self.Splitter)
|
||||
self.PreviewListView = QtGui.QListView(self.Splitter)
|
||||
self.PreviewListView.setAlternatingRowColors(True)
|
||||
self.PreviewListData = SlideData()
|
||||
self.PreviewListView.setModel(self.PreviewListData)
|
||||
|
||||
self.Controller.setGeometry(QRect(0, 0, 828, 536))
|
||||
self.Controller.setGeometry(QtCore.QRect(0, 0, 828, 536))
|
||||
self.Controller.setWidget(self.PreviewListView)
|
||||
|
||||
self.Toolbar = OpenLPToolbar(self.Splitter)
|
||||
sizeToolbarPolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
|
||||
sizeToolbarPolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
|
||||
sizeToolbarPolicy.setHorizontalStretch(0)
|
||||
sizeToolbarPolicy.setVerticalStretch(0)
|
||||
sizeToolbarPolicy.setHeightForWidth(self.Toolbar.sizePolicy().hasHeightForWidth())
|
||||
|
||||
if self.isLive:
|
||||
self.Toolbar.addToolbarButton("First Slide", ":/slides/slide_first.png",
|
||||
self.Toolbar.addToolbarButton(u'First Slide', u':/slides/slide_first.png',
|
||||
translate(u'SlideController', u'Move to first'), self.onSlideSelectedFirst)
|
||||
self.Toolbar.addToolbarButton("Last Slide", ":/slides/slide_previous.png",
|
||||
self.Toolbar.addToolbarButton(u'Last Slide', u':/slides/slide_previous.png',
|
||||
translate(u'SlideController', u'Move to previous'), self.onSlideSelectedPrevious)
|
||||
self.Toolbar.addToolbarButton("First Slide", ":/slides/slide_next.png",
|
||||
self.Toolbar.addToolbarButton(u'First Slide', u':/slides/slide_next.png',
|
||||
translate(u'SlideController', u'Move to next'), self.onSlideSelectedNext)
|
||||
if self.isLive:
|
||||
self.Toolbar.addToolbarButton("Last Slide", ":/slides/slide_last.png",
|
||||
self.Toolbar.addToolbarButton(u'Last Slide', u':/slides/slide_last.png',
|
||||
translate(u'SlideController', u'Move to last'), self.onSlideSelectedLast)
|
||||
self.Toolbar.addSeparator()
|
||||
self.Toolbar.addToolbarButton("Close Sscreen", ":/slides/slide_close.png",
|
||||
self.Toolbar.addToolbarButton(u'Close Sscreen', u':/slides/slide_close.png',
|
||||
translate(u'SlideController', u'Close Screen'), self.onBlankScreen)
|
||||
|
||||
self.Toolbar.setSizePolicy(sizeToolbarPolicy)
|
||||
|
||||
self.SlidePreview = QLabel(self.Splitter)
|
||||
sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
|
||||
self.SlidePreview = QtGui.QLabel(self.Splitter)
|
||||
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.SlidePreview.sizePolicy().hasHeightForWidth())
|
||||
self.SlidePreview.setSizePolicy(sizePolicy)
|
||||
self.SlidePreview.setMinimumSize(QSize(250, 190))
|
||||
self.SlidePreview.setFrameShape(QFrame.WinPanel)
|
||||
self.SlidePreview.setFrameShadow(QFrame.Sunken)
|
||||
self.SlidePreview.setMinimumSize(QtCore.QSize(250, 190))
|
||||
self.SlidePreview.setFrameShape(QtGui.QFrame.WinPanel)
|
||||
self.SlidePreview.setFrameShadow(QtGui.QFrame.Sunken)
|
||||
self.SlidePreview.setLineWidth(1)
|
||||
self.SlidePreview.setScaledContents(True)
|
||||
self.SlidePreview.setObjectName("SlidePreview")
|
||||
self.SlidePreview.setObjectName(u'SlidePreview')
|
||||
|
||||
QObject.connect(self.PreviewListView,
|
||||
SIGNAL("clicked(QModelIndex)"), self.onSlideSelected)
|
||||
QtCore.QObject.connect(self.PreviewListView,
|
||||
QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onSlideSelected)
|
||||
|
||||
def onSlideSelectedFirst(self):
|
||||
row = self.PreviewListData.createIndex(0, 0)
|
||||
if row.isValid():
|
||||
self.PreviewListView.selectionModel().setCurrentIndex(row, QItemSelectionModel.SelectCurrent)
|
||||
self.PreviewListView.selectionModel().setCurrentIndex(row, QtGui.QItemSelectionModel.SelectCurrent)
|
||||
self.onSlideSelected(row)
|
||||
|
||||
def onSlideSelectedNext(self):
|
||||
@ -182,7 +181,7 @@ class SlideController(QWidget):
|
||||
rowNumber = index.row() + 1
|
||||
row = self.PreviewListData.createIndex(rowNumber , 0)
|
||||
if row.isValid():
|
||||
self.PreviewListView.selectionModel().setCurrentIndex(row, QItemSelectionModel.SelectCurrent)
|
||||
self.PreviewListView.selectionModel().setCurrentIndex(row, QtGui.QItemSelectionModel.SelectCurrent)
|
||||
self.onSlideSelected(row)
|
||||
|
||||
|
||||
@ -196,13 +195,13 @@ class SlideController(QWidget):
|
||||
rowNumber = index.row() - 1
|
||||
row = self.PreviewListData.createIndex(rowNumber , 0)
|
||||
if row.isValid():
|
||||
self.PreviewListView.selectionModel().setCurrentIndex(row, QItemSelectionModel.SelectCurrent)
|
||||
self.PreviewListView.selectionModel().setCurrentIndex(row, QtGui.QItemSelectionModel.SelectCurrent)
|
||||
self.onSlideSelected(row)
|
||||
|
||||
def onSlideSelectedLast(self):
|
||||
row = self.PreviewListData.createIndex(self.PreviewListData.rowCount() - 1 , 0)
|
||||
if row.isValid():
|
||||
self.PreviewListView.selectionModel().setCurrentIndex(row, QItemSelectionModel.SelectCurrent)
|
||||
self.PreviewListView.selectionModel().setCurrentIndex(row, QtGui.QItemSelectionModel.SelectCurrent)
|
||||
self.onSlideSelected(row)
|
||||
|
||||
def onBlankScreen(self):
|
||||
@ -227,7 +226,7 @@ class SlideController(QWidget):
|
||||
|
||||
row = self.PreviewListData.createIndex(0, 0)
|
||||
if row.isValid():
|
||||
self.PreviewListView.selectionModel().setCurrentIndex(row, QItemSelectionModel.SelectCurrent)
|
||||
self.PreviewListView.selectionModel().setCurrentIndex(row, QtGui.QItemSelectionModel.SelectCurrent)
|
||||
self.onSlideSelected(row)
|
||||
|
||||
def render(self):
|
||||
|
@ -25,7 +25,7 @@ from PyQt4.QtGui import *
|
||||
mypath=os.path.split(os.path.abspath(__file__))[0]
|
||||
sys.path.insert(0,(os.path.join(mypath, '..','..', '..','..')))
|
||||
from openlp.core.ui import ServiceManager
|
||||
from openlp.plugins.images import ImageServiceItem
|
||||
from openlp.plugins.images.lib import ImageServiceItem
|
||||
|
||||
import logging
|
||||
logging.basicConfig(filename="test_service_manager.log",level=logging.INFO, filemode="w")
|
||||
|
@ -60,3 +60,6 @@ class CustomPlugin(Plugin):
|
||||
if event.event_type == EventType.ThemeListChanged:
|
||||
log.debug(u'New Theme request received')
|
||||
self.edit_custom_form.loadThemes(self.theme_manager.getThemes())
|
||||
if event.event_type == EventType.LoadServiceItem and event.payload == 'Custom':
|
||||
log.debug(u'Load Service Item received')
|
||||
self.media_item.onCustomAddClick()
|
||||
|
@ -109,6 +109,8 @@ class CustomMediaItem(MediaManagerItem):
|
||||
self.CustomListView.setAlternatingRowColors(True)
|
||||
self.CustomListData = TextListData()
|
||||
self.CustomListView.setModel(self.CustomListData)
|
||||
self.CustomListView.setDragEnabled(True)
|
||||
self.CustomListView .__class__.mouseMoveEvent =self.onMouseMoveEvent
|
||||
|
||||
self.PageLayout.addWidget(self.CustomListView)
|
||||
|
||||
@ -233,3 +235,27 @@ class CustomMediaItem(MediaManagerItem):
|
||||
service_item.title = title
|
||||
service_item.raw_slides = raw_slides
|
||||
service_item.raw_footer = raw_footer
|
||||
|
||||
def onMouseMoveEvent(self, event):
|
||||
"""
|
||||
Drag and drop eventDo not care what data is selected
|
||||
as the recepient will use events to request the data move
|
||||
just tell it what plugin to call
|
||||
"""
|
||||
if event.buttons() != QtCore.Qt.LeftButton:
|
||||
return
|
||||
|
||||
items = self.CustomListView.selectedIndexes()
|
||||
if items == []:
|
||||
return
|
||||
|
||||
drag = QtGui.QDrag(self)
|
||||
mimeData = QtCore.QMimeData()
|
||||
drag.setMimeData(mimeData)
|
||||
for item in items:
|
||||
mimeData.setText(u'Custom')
|
||||
|
||||
dropAction = drag.start(QtCore.Qt.CopyAction)
|
||||
|
||||
if dropAction == QtCore.Qt.CopyAction:
|
||||
self.close()
|
||||
|
@ -19,5 +19,5 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
"""
|
||||
|
||||
from imageplugin import ImagePlugin
|
||||
from imageserviceitem import ImageServiceItem
|
||||
#from imageserviceitem import ImageServiceItem
|
||||
|
||||
|
@ -100,7 +100,7 @@ class ImageServiceItem(ServiceItem):
|
||||
"""
|
||||
log.info("Get oos text")
|
||||
log.info(str(self.imgs))
|
||||
log.info(str(self.imgs.get_file_list()))
|
||||
# log.info(str(self.imgs.get_file_list()))
|
||||
return '\n'.join(self.imgs.get_file_list())
|
||||
|
||||
def set_from_oos(self, text):
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user