forked from openlp/openlp
About to make some big changes to the imageplugin...
bzr-revno: 332
This commit is contained in:
parent
ad48e1f4e6
commit
8816b6c2dc
@ -18,13 +18,16 @@ 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 PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
import logging
|
||||||
|
|
||||||
class ImageServiceItem():
|
class ImageServiceItem():
|
||||||
"""
|
"""
|
||||||
The service item is a base class for the plugins to use to interact with
|
The service item is a base class for the plugins to use to interact with
|
||||||
the service manager, the slide controller, and the renderer.
|
the service manager, the slide controller, and the renderer.
|
||||||
"""
|
"""
|
||||||
|
global log
|
||||||
|
log=logging.getLogger("ImageServiceItem")
|
||||||
|
log.info("ImageServiceItem loaded")
|
||||||
def __init__(self, controller):
|
def __init__(self, controller):
|
||||||
"""
|
"""
|
||||||
Init Method
|
Init Method
|
||||||
@ -58,7 +61,9 @@ class ImageServiceItem():
|
|||||||
self.slide_controller.setItem(c , 0, twi)
|
self.slide_controller.setItem(c , 0, twi)
|
||||||
twi = QtGui.QTableWidgetItem(str(nm))
|
twi = QtGui.QTableWidgetItem(str(nm))
|
||||||
self.slide_controller.setItem(c , 1, twi)
|
self.slide_controller.setItem(c , 1, twi)
|
||||||
self.slide_controller.setRowHeight(c, 20)
|
self.slide_controller.setRowHeight(c, 80)
|
||||||
|
|
||||||
|
# render the preview screen here
|
||||||
|
|
||||||
def get_parent_node(self):
|
def get_parent_node(self):
|
||||||
"""
|
"""
|
||||||
@ -66,11 +71,12 @@ class ImageServiceItem():
|
|||||||
Manager.
|
Manager.
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
def add(self, img_filename):
|
def add(self, filename):
|
||||||
"""
|
"""
|
||||||
append an image to the list
|
append an image to the list
|
||||||
"""
|
"""
|
||||||
self.imgs.append(img_filename)
|
log.info("add:"+filename)
|
||||||
|
self.imgs.append(filename)
|
||||||
|
|
||||||
def get_oos_text(self):
|
def get_oos_text(self):
|
||||||
"""
|
"""
|
||||||
@ -82,5 +88,6 @@ class ImageServiceItem():
|
|||||||
"""
|
"""
|
||||||
get text from the OOS file and setup the internal structure
|
get text from the OOS file and setup the internal structure
|
||||||
"""
|
"""
|
||||||
|
log.info("Set from OOS:"+text)
|
||||||
self.imgs=eval(text)
|
self.imgs=eval(text)
|
||||||
|
|
||||||
|
@ -84,7 +84,9 @@ class PluginManager(object):
|
|||||||
except TypeError: # xxx need to get rid of this once all plugins are up to date
|
except TypeError: # xxx need to get rid of this once all plugins are up to date
|
||||||
plugin = p()
|
plugin = p()
|
||||||
log.debug('loaded plugin' + str(p) + ' with no controllers')
|
log.debug('loaded plugin' + str(p) + ' with no controllers')
|
||||||
|
log.debug("Plugin="+str(p))
|
||||||
if plugin.check_pre_conditions():
|
if plugin.check_pre_conditions():
|
||||||
|
log.debug("Appending "+str(p))
|
||||||
plugin_objects.append(plugin)
|
plugin_objects.append(plugin)
|
||||||
self.plugins = sorted(plugin_objects, self.order_by_weight)
|
self.plugins = sorted(plugin_objects, self.order_by_weight)
|
||||||
|
|
||||||
|
@ -28,8 +28,11 @@ from openlp.core.ui import AboutForm, AlertForm, SettingsDialog, SlideController
|
|||||||
from openlp.core.lib import Plugin, MediaManagerItem, SettingsTab
|
from openlp.core.lib import Plugin, MediaManagerItem, SettingsTab
|
||||||
|
|
||||||
from openlp.core import PluginManager
|
from openlp.core import PluginManager
|
||||||
|
import logging
|
||||||
class MainWindow(object):
|
class MainWindow(object):
|
||||||
|
global log
|
||||||
|
log=logging.getLogger("MainWindow")
|
||||||
|
log.info("MainWindow loaded")
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.main_window = QtGui.QMainWindow()
|
self.main_window = QtGui.QMainWindow()
|
||||||
@ -41,6 +44,19 @@ class MainWindow(object):
|
|||||||
self.plugin_manager = PluginManager(pluginpath)
|
self.plugin_manager = PluginManager(pluginpath)
|
||||||
self.setupUi()
|
self.setupUi()
|
||||||
self.plugin_manager.find_plugins(pluginpath, self.PreviewController, self.LiveController)
|
self.plugin_manager.find_plugins(pluginpath, self.PreviewController, self.LiveController)
|
||||||
|
# hook methods have to happen after find_plugins. Find plugins needs the controllers
|
||||||
|
# hence the hooks have moved fromt srtupUI() to here
|
||||||
|
# Call the hook method to pull in import menus.
|
||||||
|
# self.plugin_manager.hook_import_menu(self.FileImportMenu)
|
||||||
|
#
|
||||||
|
# Call the hook method to pull in export menus.
|
||||||
|
# self.plugin_manager.hook_import_menu(self.FileExportMenu)
|
||||||
|
#
|
||||||
|
# This is where we will eventually get the Plugin Manager to pull in
|
||||||
|
# the media manager items.
|
||||||
|
log.info("hook media")
|
||||||
|
self.plugin_manager.hook_media_manager(self.MediaToolBox)
|
||||||
|
# End adding media manager items.
|
||||||
self.receiver = Receiver()
|
self.receiver = Receiver()
|
||||||
QtCore.QObject.connect(self.receiver.get_receiver(),QtCore.SIGNAL("openlprepaint"),self.repaint)
|
QtCore.QObject.connect(self.receiver.get_receiver(),QtCore.SIGNAL("openlprepaint"),self.repaint)
|
||||||
|
|
||||||
@ -84,14 +100,9 @@ class MainWindow(object):
|
|||||||
self.FileMenu.setObjectName("FileMenu")
|
self.FileMenu.setObjectName("FileMenu")
|
||||||
self.FileImportMenu = QtGui.QMenu(self.FileMenu)
|
self.FileImportMenu = QtGui.QMenu(self.FileMenu)
|
||||||
self.FileImportMenu.setObjectName("FileImportMenu")
|
self.FileImportMenu.setObjectName("FileImportMenu")
|
||||||
# Call the hook method to pull in import menus.
|
|
||||||
self.plugin_manager.hook_import_menu(self.FileImportMenu)
|
|
||||||
#
|
|
||||||
self.FileExportMenu = QtGui.QMenu(self.FileMenu)
|
self.FileExportMenu = QtGui.QMenu(self.FileMenu)
|
||||||
self.FileExportMenu.setObjectName("FileExportMenu")
|
self.FileExportMenu.setObjectName("FileExportMenu")
|
||||||
# Call the hook method to pull in export menus.
|
|
||||||
self.plugin_manager.hook_import_menu(self.FileExportMenu)
|
|
||||||
#
|
|
||||||
self.OptionsMenu = QtGui.QMenu(self.MenuBar)
|
self.OptionsMenu = QtGui.QMenu(self.MenuBar)
|
||||||
self.OptionsMenu.setObjectName("OptionsMenu")
|
self.OptionsMenu.setObjectName("OptionsMenu")
|
||||||
self.OptionsViewMenu = QtGui.QMenu(self.OptionsMenu)
|
self.OptionsViewMenu = QtGui.QMenu(self.OptionsMenu)
|
||||||
@ -133,10 +144,7 @@ class MainWindow(object):
|
|||||||
self.MediaToolBox = QtGui.QToolBox(self.MediaManagerContents)
|
self.MediaToolBox = QtGui.QToolBox(self.MediaManagerContents)
|
||||||
#self.MediaToolBox.setTabSpacing(0)
|
#self.MediaToolBox.setTabSpacing(0)
|
||||||
self.MediaToolBox.setObjectName("MediaToolBox")
|
self.MediaToolBox.setObjectName("MediaToolBox")
|
||||||
# This is where we will eventually get the Plugin Manager to pull in
|
|
||||||
# the media manager items.
|
|
||||||
self.plugin_manager.hook_media_manager(self.MediaToolBox)
|
|
||||||
# End adding media manager items.
|
|
||||||
self.MediaManagerLayout.addWidget(self.MediaToolBox)
|
self.MediaManagerLayout.addWidget(self.MediaToolBox)
|
||||||
self.MediaManagerDock.setWidget(self.MediaManagerContents)
|
self.MediaManagerDock.setWidget(self.MediaManagerContents)
|
||||||
self.main_window.addDockWidget(QtCore.Qt.DockWidgetArea(1), self.MediaManagerDock)
|
self.main_window.addDockWidget(QtCore.Qt.DockWidgetArea(1), self.MediaManagerDock)
|
||||||
|
@ -22,8 +22,12 @@ from PyQt4 import QtCore, QtGui
|
|||||||
from openlp.core.resources import *
|
from openlp.core.resources import *
|
||||||
from openlp.core.lib import Plugin, PluginUtils, MediaManagerItem, ImageServiceItem
|
from openlp.core.lib import Plugin, PluginUtils, MediaManagerItem, ImageServiceItem
|
||||||
#from forms import EditSongForm
|
#from forms import EditSongForm
|
||||||
|
import logging
|
||||||
|
|
||||||
class ImagePlugin(Plugin, PluginUtils):
|
class ImagePlugin(Plugin, PluginUtils):
|
||||||
|
global log
|
||||||
|
log=logging.getLogger("ImagePlugin")
|
||||||
|
log.info("Image Plugin loaded")
|
||||||
def __init__(self, preview_controller, live_controller):
|
def __init__(self, preview_controller, live_controller):
|
||||||
# Call the parent constructor
|
# Call the parent constructor
|
||||||
Plugin.__init__(self, 'Images', '1.9.0', preview_controller, live_controller)
|
Plugin.__init__(self, 'Images', '1.9.0', preview_controller, live_controller)
|
||||||
@ -35,7 +39,6 @@ class ImagePlugin(Plugin, PluginUtils):
|
|||||||
|
|
||||||
self.preview_service_item=ImageServiceItem(preview_controller)
|
self.preview_service_item=ImageServiceItem(preview_controller)
|
||||||
self.live_service_item=ImageServiceItem(live_controller)
|
self.live_service_item=ImageServiceItem(live_controller)
|
||||||
|
|
||||||
def get_media_manager_item(self):
|
def get_media_manager_item(self):
|
||||||
# Create the MediaManagerItem object
|
# Create the MediaManagerItem object
|
||||||
self.MediaManagerItem = MediaManagerItem(self.icon, 'Images')
|
self.MediaManagerItem = MediaManagerItem(self.icon, 'Images')
|
||||||
@ -62,9 +65,10 @@ class ImagePlugin(Plugin, PluginUtils):
|
|||||||
self.onImageAddClick, 'ImageAddItem')
|
self.onImageAddClick, 'ImageAddItem')
|
||||||
## Add the songlist widget ##
|
## Add the songlist widget ##
|
||||||
self.ImageListView = QtGui.QTableWidget()
|
self.ImageListView = QtGui.QTableWidget()
|
||||||
self.ImageListView.setColumnCount(2)
|
self.ImageListView.setColumnCount(3)
|
||||||
self.ImageListView.setColumnHidden(0, True)
|
self.ImageListView.setColumnHidden(0, True)
|
||||||
self.ImageListView.setColumnWidth(1, 275)
|
# self.ImageListView.setColumnWidth(1, 275)
|
||||||
|
self.ImageListView.setColumnWidth(2, 100)
|
||||||
self.ImageListView.setShowGrid(False)
|
self.ImageListView.setShowGrid(False)
|
||||||
self.ImageListView.setSortingEnabled(False)
|
self.ImageListView.setSortingEnabled(False)
|
||||||
self.ImageListView.setAlternatingRowColors(True)
|
self.ImageListView.setAlternatingRowColors(True)
|
||||||
@ -89,8 +93,10 @@ class ImagePlugin(Plugin, PluginUtils):
|
|||||||
return self.MediaManagerItem
|
return self.MediaManagerItem
|
||||||
|
|
||||||
def initialise(self):
|
def initialise(self):
|
||||||
|
log.info("Plugin Initialising")
|
||||||
list = self._load_display_list()
|
list = self._load_display_list()
|
||||||
self._load_image_list(list)
|
self._load_image_list(list)
|
||||||
|
log.info("Done")
|
||||||
|
|
||||||
def onImagesNewClick(self):
|
def onImagesNewClick(self):
|
||||||
files = QtGui.QFileDialog.getOpenFileNames(None, "Select Image(s)", self._get_last_dir(), "Images (*.jpg *.gif *.png *.bmp)")
|
files = QtGui.QFileDialog.getOpenFileNames(None, "Select Image(s)", self._get_last_dir(), "Images (*.jpg *.gif *.png *.bmp)")
|
||||||
@ -100,6 +106,7 @@ class ImagePlugin(Plugin, PluginUtils):
|
|||||||
self._save_display_list(self.ImageListView)
|
self._save_display_list(self.ImageListView)
|
||||||
|
|
||||||
def _load_image_list(self, list):
|
def _load_image_list(self, list):
|
||||||
|
h=200
|
||||||
for f in list:
|
for f in list:
|
||||||
fl , nm = os.path.split(str(f))
|
fl , nm = os.path.split(str(f))
|
||||||
c = self.ImageListView.rowCount()
|
c = self.ImageListView.rowCount()
|
||||||
@ -108,7 +115,13 @@ class ImagePlugin(Plugin, PluginUtils):
|
|||||||
self.ImageListView.setItem(c , 0, twi)
|
self.ImageListView.setItem(c , 0, twi)
|
||||||
twi = QtGui.QTableWidgetItem(str(nm))
|
twi = QtGui.QTableWidgetItem(str(nm))
|
||||||
self.ImageListView.setItem(c , 1, twi)
|
self.ImageListView.setItem(c , 1, twi)
|
||||||
self.ImageListView.setRowHeight(c, 20)
|
preview = QtGui.QPixmap(str(f))
|
||||||
|
twi = QtGui.QTableWidgetItem("")
|
||||||
|
twi.setBackground(QtGui.QBrush(QtGui.QPixmap(f).scaledToHeight(h)))
|
||||||
|
# twi.setIcon(QtGui.QIcon(preview.scaledToHeight(h)))
|
||||||
|
self.ImageListView.setItem(c , 2, twi)
|
||||||
|
self.ImageListView.setRowHeight(c, h)
|
||||||
|
|
||||||
|
|
||||||
def onImageDeleteClick(self):
|
def onImageDeleteClick(self):
|
||||||
cr = self.ImageListView.currentRow()
|
cr = self.ImageListView.currentRow()
|
||||||
@ -116,7 +129,10 @@ class ImagePlugin(Plugin, PluginUtils):
|
|||||||
self._save_display_list(self.ImageListView)
|
self._save_display_list(self.ImageListView)
|
||||||
|
|
||||||
def onImagePreviewClick(self):
|
def onImagePreviewClick(self):
|
||||||
self.preview_service_item.add(self.ImageListView.pathtofile)
|
cr = self.ImageListView.currentRow()
|
||||||
|
filename = self.ImageListView.item(cr, 0).text()
|
||||||
|
log.info("Preview "+str(filename))
|
||||||
|
self.preview_service_item.add(filename)
|
||||||
self.preview_service_item.render()
|
self.preview_service_item.render()
|
||||||
|
|
||||||
def onImageLiveClick(self):
|
def onImageLiveClick(self):
|
||||||
@ -124,3 +140,4 @@ class ImagePlugin(Plugin, PluginUtils):
|
|||||||
|
|
||||||
def onImageAddClick(self):
|
def onImageAddClick(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user