forked from openlp/openlp
Big cleanup.
Custom and Video Plugins up to latest standard (MVC) Config now working with new handles Video and Images. Moved strings from "" to u'' where found. bzr-revno: 421
This commit is contained in:
parent
0d33ba5668
commit
e99239ef12
@ -3,7 +3,7 @@
|
|||||||
"""
|
"""
|
||||||
OpenLP - Open Source Lyrics Projection
|
OpenLP - Open Source Lyrics Projection
|
||||||
Copyright (c) 2008 Raoul Snyman
|
Copyright (c) 2008 Raoul Snyman
|
||||||
Portions copyright (c) 2008 Martin Thompson, Tim Bentley
|
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 redistribute it and/or modify it under
|
||||||
the terms of the GNU General Public License as published by the Free Software
|
the terms of the GNU General Public License as published by the Free Software
|
||||||
@ -52,8 +52,9 @@ class PluginConfig(object):
|
|||||||
|
|
||||||
def get_data_path(self):
|
def get_data_path(self):
|
||||||
app_data = ConfigHelper.get_data_path()
|
app_data = ConfigHelper.get_data_path()
|
||||||
safe_name = self.section.replace(' ', '-')
|
app_data = ConfigHelper.get_data_path()
|
||||||
plugin_data = self.get_config('data path', safe_name)
|
safe_name = self.section.replace(u' ',u'-')
|
||||||
|
plugin_data = self.get_config(u'data path', safe_name)
|
||||||
path = os.path.join(app_data, plugin_data)
|
path = os.path.join(app_data, plugin_data)
|
||||||
|
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
@ -62,7 +63,7 @@ class PluginConfig(object):
|
|||||||
return path
|
return path
|
||||||
|
|
||||||
def set_data_path(self, path):
|
def set_data_path(self, path):
|
||||||
return self.set_config('data path', os.path.basename(path))
|
return self.set_config(u'data path', os.path.basename(path))
|
||||||
|
|
||||||
def get_files(self, suffix=None):
|
def get_files(self, suffix=None):
|
||||||
returnfiles = []
|
returnfiles = []
|
||||||
@ -88,7 +89,7 @@ class PluginConfig(object):
|
|||||||
"""
|
"""
|
||||||
Load a list from the config file
|
Load a list from the config file
|
||||||
"""
|
"""
|
||||||
list_count = self.get_config('%s count' % name)
|
list_count = self.get_config(u'%s count' % name)
|
||||||
if list_count is not None:
|
if list_count is not None:
|
||||||
list_count = int(list_count)
|
list_count = int(list_count)
|
||||||
else:
|
else:
|
||||||
@ -96,7 +97,7 @@ class PluginConfig(object):
|
|||||||
list = []
|
list = []
|
||||||
if list_count > 0:
|
if list_count > 0:
|
||||||
for counter in range(0 , list_count):
|
for counter in range(0 , list_count):
|
||||||
item = str(self.get_config('%s %d' % (name, counter)))
|
item = str(self.get_config(u'%s %d' % (name, counter)))
|
||||||
list.append(item)
|
list.append(item)
|
||||||
return list
|
return list
|
||||||
|
|
||||||
@ -104,24 +105,24 @@ class PluginConfig(object):
|
|||||||
"""
|
"""
|
||||||
Save a list to the config file
|
Save a list to the config file
|
||||||
"""
|
"""
|
||||||
old_count = int(self.get_config('%s count' % name))
|
old_count = int(self.get_config(u'%s count' % name, int(0)))
|
||||||
new_count = len(list)
|
new_count = len(list)
|
||||||
self.set_config('%s count' % new_count)
|
self.set_config(u'%s count' % name, new_count)
|
||||||
for counter in range (0, new_count):
|
for counter in range (0, new_count):
|
||||||
self.set_config('%s %d' % (name, counter), list[counter])
|
self.set_config(u'%s %d' % (name, counter), list[counter-1])
|
||||||
if old_count > new_count:
|
if old_count > new_count:
|
||||||
# Tidy up any old list itrms if list is smaller now
|
# Tidy up any old list itrms if list is smaller now
|
||||||
for counter in range(new_count, old_count):
|
for counter in range(new_count, old_count):
|
||||||
self.delete_config('%s %d' % (name, counter))
|
self.delete_config(u'%s %d' % (name, counter))
|
||||||
|
|
||||||
def get_last_dir(self, num=None):
|
def get_last_dir(self, num=None):
|
||||||
"""
|
"""
|
||||||
Read the last directory used for plugin
|
Read the last directory used for plugin
|
||||||
"""
|
"""
|
||||||
if num is not None:
|
if num is not None:
|
||||||
name = 'last directory %d' % num
|
name = u'last directory %d' % num
|
||||||
else:
|
else:
|
||||||
name = 'last directory'
|
name = u'last directory'
|
||||||
last_dir = self.get_config(name)
|
last_dir = self.get_config(name)
|
||||||
if last_dir is None:
|
if last_dir is None:
|
||||||
last_dir = ''
|
last_dir = ''
|
||||||
@ -132,7 +133,7 @@ class PluginConfig(object):
|
|||||||
Save the last directory used for plugin
|
Save the last directory used for plugin
|
||||||
"""
|
"""
|
||||||
if num is not None:
|
if num is not None:
|
||||||
name = 'last directory %d' % num
|
name = u'last directory %d' % num
|
||||||
else:
|
else:
|
||||||
name = 'last directory'
|
name = u'last directory'
|
||||||
self.set_config(name, directory)
|
self.set_config(name, directory)
|
||||||
|
@ -18,6 +18,7 @@ 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
|
||||||
"""
|
"""
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
from ConfigParser import SafeConfigParser
|
from ConfigParser import SafeConfigParser
|
||||||
from openlp.core.utils import Registry
|
from openlp.core.utils import Registry
|
||||||
|
|
||||||
@ -54,7 +55,7 @@ class LinRegistry(Registry):
|
|||||||
Set a single value in the registry.
|
Set a single value in the registry.
|
||||||
"""
|
"""
|
||||||
try :
|
try :
|
||||||
self.config.set(section, key, value)
|
self.config.set(section, key, str(value))
|
||||||
return self._save()
|
return self._save()
|
||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
|
@ -51,7 +51,7 @@ class BiblePlugin(Plugin, PluginUtils):
|
|||||||
return self.bibles_tab
|
return self.bibles_tab
|
||||||
|
|
||||||
def get_media_manager_item(self):
|
def get_media_manager_item(self):
|
||||||
# Create the MediaManagerItem object
|
# Create the BibleManagerItem object
|
||||||
self.media_item = BibleMediaItem(self, self.icon, 'Bible Verses')
|
self.media_item = BibleMediaItem(self, self.icon, 'Bible Verses')
|
||||||
return self.media_item
|
return self.media_item
|
||||||
|
|
||||||
|
@ -22,19 +22,19 @@ import logging
|
|||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.resources import *
|
from openlp.core.resources import *
|
||||||
from openlp.core.lib import Plugin, MediaManagerItem
|
from openlp.core.lib import Plugin
|
||||||
from forms import EditCustomForm
|
from forms import EditCustomForm
|
||||||
from openlp.plugins.custom.lib import CustomManager, CustomTab, CustomMediaItem
|
from openlp.plugins.custom.lib import CustomManager, CustomTab, CustomMediaItem
|
||||||
|
|
||||||
class CustomPlugin(Plugin):
|
class CustomPlugin(Plugin):
|
||||||
|
|
||||||
global log
|
global log
|
||||||
log=logging.getLogger("CustomPlugin")
|
log=logging.getLogger(u'CustomPlugin')
|
||||||
log.info("Custom Plugin loaded")
|
log.info(u'Custom Plugin loaded')
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
# Call the parent constructor
|
# Call the parent constructor
|
||||||
Plugin.__init__(self, 'Custom', '1.9.0')
|
Plugin.__init__(self, u'Custom', u'1.9.0')
|
||||||
self.weight = -5
|
self.weight = -5
|
||||||
self.custommanager = CustomManager(self.config)
|
self.custommanager = CustomManager(self.config)
|
||||||
self.edit_custom_form = EditCustomForm(self.custommanager)
|
self.edit_custom_form = EditCustomForm(self.custommanager)
|
||||||
@ -44,8 +44,8 @@ class CustomPlugin(Plugin):
|
|||||||
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||||
|
|
||||||
def get_media_manager_item(self):
|
def get_media_manager_item(self):
|
||||||
# Create the MediaManagerItem object
|
# Create the CustomManagerItem object
|
||||||
self.media_item = CustomMediaItem(self, self.icon, 'Custom Slides')
|
self.media_item = CustomMediaItem(self, self.icon, u'Custom Slides')
|
||||||
return self.media_item
|
return self.media_item
|
||||||
|
|
||||||
def get_settings_tab(self):
|
def get_settings_tab(self):
|
||||||
|
@ -34,8 +34,8 @@ class CustomManager():
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
global log
|
global log
|
||||||
log=logging.getLogger('CustomManager')
|
log=logging.getLogger(u'CustomManager')
|
||||||
log.info('Custom manager loaded')
|
log.info(u'Custom manager loaded')
|
||||||
|
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
"""
|
"""
|
||||||
@ -43,7 +43,7 @@ class CustomManager():
|
|||||||
don't exist.
|
don't exist.
|
||||||
"""
|
"""
|
||||||
self.config = config
|
self.config = config
|
||||||
log.debug('Custom Initialising')
|
log.debug(u'Custom Initialising')
|
||||||
self.db_url = u''
|
self.db_url = u''
|
||||||
db_type = self.config.get_config(u'db type', u'sqlite')
|
db_type = self.config.get_config(u'db type', u'sqlite')
|
||||||
if db_type == u'sqlite':
|
if db_type == u'sqlite':
|
||||||
@ -59,7 +59,7 @@ class CustomManager():
|
|||||||
if not custom_slide_table.exists():
|
if not custom_slide_table.exists():
|
||||||
metadata.create_all()
|
metadata.create_all()
|
||||||
|
|
||||||
log.debug('Custom Initialised')
|
log.debug(u'Custom Initialised')
|
||||||
#
|
#
|
||||||
# def process_dialog(self, dialogobject):
|
# def process_dialog(self, dialogobject):
|
||||||
# self.dialogobject = dialogobject
|
# self.dialogobject = dialogobject
|
||||||
@ -74,14 +74,14 @@ class CustomManager():
|
|||||||
"""
|
"""
|
||||||
Saves a song to the database
|
Saves a song to the database
|
||||||
"""
|
"""
|
||||||
log.debug('Custom Slide added')
|
log.debug(u'Custom Slide added')
|
||||||
try:
|
try:
|
||||||
self.session.add(customslide)
|
self.session.add(customslide)
|
||||||
self.session.commit()
|
self.session.commit()
|
||||||
log.debug('Custom Slide saved')
|
log.debug(u'Custom Slide saved')
|
||||||
return True
|
return True
|
||||||
except:
|
except:
|
||||||
log.debug('Custom Slide failed')
|
log.debug(u'Custom Slide failed')
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def get_custom(self, id=None):
|
def get_custom(self, id=None):
|
||||||
|
@ -32,8 +32,8 @@ class CustomMediaItem(MediaManagerItem):
|
|||||||
This is the custom media manager item for Custom Slides.
|
This is the custom media manager item for Custom Slides.
|
||||||
"""
|
"""
|
||||||
global log
|
global log
|
||||||
log=logging.getLogger("CustomMediaItem")
|
log=logging.getLogger(u'CustomMediaItem')
|
||||||
log.info("Custom Media Item loaded")
|
log.info(u'Custom Media Item loaded')
|
||||||
|
|
||||||
def __init__(self, parent, icon, title):
|
def __init__(self, parent, icon, title):
|
||||||
MediaManagerItem.__init__(self, parent, icon, title)
|
MediaManagerItem.__init__(self, parent, icon, title)
|
||||||
@ -44,45 +44,44 @@ class CustomMediaItem(MediaManagerItem):
|
|||||||
# Create buttons for the toolbar
|
# Create buttons for the toolbar
|
||||||
## New Custom Button ##
|
## New Custom Button ##
|
||||||
self.addToolbarButton(
|
self.addToolbarButton(
|
||||||
translate('CustomMediaItem','New Custom Item'),
|
translate('CustomMediaItem',u'New Custom Item'),
|
||||||
translate('CustomMediaItem','Add a new Custom Item'),
|
translate('CustomMediaItem',u'Add a new Custom Item'),
|
||||||
':/custom/custom_new.png', self.onCustomNewClick, 'CustomNewItem')
|
':/custom/custom_new.png', self.onCustomNewClick, 'CustomNewItem')
|
||||||
## Edit Custom Button ##
|
## Edit Custom Button ##
|
||||||
self.addToolbarButton(
|
self.addToolbarButton(
|
||||||
translate('CustomMediaItem','Edit Custom Item'),
|
translate('CustomMediaItem',u'Edit Custom Item'),
|
||||||
translate('CustomMediaItem','Edit the selected Custom Item'),
|
translate('CustomMediaItem',u'Edit the selected Custom Item'),
|
||||||
':/custom/custom_edit.png', self.onCustomEditClick, 'CustomEditItem')
|
':/custom/custom_edit.png', self.onCustomEditClick, 'CustomEditItem')
|
||||||
## Delete Custom Button ##
|
## Delete Custom Button ##
|
||||||
self.addToolbarButton(
|
self.addToolbarButton(
|
||||||
translate('CustomMediaItem','Delete Custom Item'),
|
translate('CustomMediaItem',u'Delete Custom Item'),
|
||||||
translate('CustomMediaItem','Delete the selected Custom Item'),
|
translate('CustomMediaItem',u'Delete the selected Custom Item'),
|
||||||
':/custom/custom_delete.png', self.onCustomDeleteClick, 'CustomDeleteItem')
|
':/custom/custom_delete.png', self.onCustomDeleteClick, 'CustomDeleteItem')
|
||||||
## Separator Line ##
|
## Separator Line ##
|
||||||
self.addToolbarSeparator()
|
self.addToolbarSeparator()
|
||||||
## Preview Custom Button ##
|
## Preview Custom Button ##
|
||||||
self.addToolbarButton(
|
self.addToolbarButton(
|
||||||
translate('CustomMediaItem','Preview Custom Item'),
|
translate('CustomMediaItem',u'Preview Custom Item'),
|
||||||
translate('CustomMediaItem','Preview the selected Custom Item'),
|
translate('CustomMediaItem',u'Preview the selected Custom Item'),
|
||||||
':/system/system_preview.png', self.onCustomPreviewClick, 'CustomPreviewItem')
|
':/system/system_preview.png', self.onCustomPreviewClick, 'CustomPreviewItem')
|
||||||
## Live Custom Button ##
|
## Live Custom Button ##
|
||||||
self.addToolbarButton(
|
self.addToolbarButton(
|
||||||
translate('CustomMediaItem','Go Live'),
|
translate('CustomMediaItem',u'Go Live'),
|
||||||
translate('CustomMediaItem', 'Send the selected Custom live'),
|
translate('CustomMediaItem', u'Send the selected Custom live'),
|
||||||
':/system/system_live.png', self.onCustomLiveClick, 'CustomLiveItem')
|
':/system/system_live.png', self.onCustomLiveClick, 'CustomLiveItem')
|
||||||
## Add Custom Button ##
|
## Add Custom Button ##
|
||||||
self.addToolbarButton(
|
self.addToolbarButton(
|
||||||
translate('CustomMediaItem','Add Custom To Service'),
|
translate('CustomMediaItem',u'Add Custom To Service'),
|
||||||
translate('CustomMediaItem','Add the selected Custom(s) to the service'),
|
translate('CustomMediaItem',u'Add the selected Custom(s) to the service'),
|
||||||
':/system/system_add.png', self.onCustomAddClick, 'CustomAddItem')
|
':/system/system_add.png', self.onCustomAddClick, 'CustomAddItem')
|
||||||
## Add the Customlist widget ##
|
# Add the Customlist widget
|
||||||
# Create the tab widget
|
|
||||||
self.CustomWidget = QtGui.QWidget(self)
|
self.CustomWidget = QtGui.QWidget(self)
|
||||||
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
||||||
sizePolicy.setHorizontalStretch(0)
|
sizePolicy.setHorizontalStretch(0)
|
||||||
sizePolicy.setVerticalStretch(0)
|
sizePolicy.setVerticalStretch(0)
|
||||||
sizePolicy.setHeightForWidth(self.CustomWidget.sizePolicy().hasHeightForWidth())
|
sizePolicy.setHeightForWidth(self.CustomWidget.sizePolicy().hasHeightForWidth())
|
||||||
self.CustomWidget.setSizePolicy(sizePolicy)
|
self.CustomWidget.setSizePolicy(sizePolicy)
|
||||||
self.CustomWidget.setObjectName('CustomWidget')
|
self.CustomWidget.setObjectName(u'CustomWidget')
|
||||||
|
|
||||||
# self.SearchLayout = QtGui.QGridLayout(self.CustomWidget)
|
# self.SearchLayout = QtGui.QGridLayout(self.CustomWidget)
|
||||||
# self.SearchLayout.setObjectName('SearchLayout')
|
# self.SearchLayout.setObjectName('SearchLayout')
|
||||||
@ -129,13 +128,13 @@ class CustomMediaItem(MediaManagerItem):
|
|||||||
self.CustomListView.addAction(self.contextMenuSeparator(self.CustomListView))
|
self.CustomListView.addAction(self.contextMenuSeparator(self.CustomListView))
|
||||||
self.CustomListView.addAction(self.contextMenuAction(
|
self.CustomListView.addAction(self.contextMenuAction(
|
||||||
self.CustomListView, ':/system/system_preview.png',
|
self.CustomListView, ':/system/system_preview.png',
|
||||||
"&Preview Custom", self.onCustomPreviewClick))
|
translate('CustomMediaItem',u'&Preview Custom'), self.onCustomPreviewClick))
|
||||||
self.CustomListView.addAction(self.contextMenuAction(
|
self.CustomListView.addAction(self.contextMenuAction(
|
||||||
self.CustomListView, ':/system/system_live.png',
|
self.CustomListView, ':/system/system_live.png',
|
||||||
"&Show Live", self.onCustomLiveClick))
|
translate('CustomMediaItem',u'&Show Live'), self.onCustomLiveClick))
|
||||||
self.CustomListView.addAction(self.contextMenuAction(
|
self.CustomListView.addAction(self.contextMenuAction(
|
||||||
self.CustomListView, ':/system/system_add.png',
|
self.CustomListView, ':/system/system_add.png',
|
||||||
"&Add to Service", self.onCustomEditClick))
|
translate('CustomMediaItem',u'&Add to Service'), self.onCustomEditClick))
|
||||||
|
|
||||||
# def retranslateUi(self):
|
# def retranslateUi(self):
|
||||||
# self.ClearTextButton.setText(translate('CustomMediaItem', u'Clear'))
|
# self.ClearTextButton.setText(translate('CustomMediaItem', u'Clear'))
|
||||||
@ -166,9 +165,6 @@ class CustomMediaItem(MediaManagerItem):
|
|||||||
search_results = self.Custommanager.search_Custom_lyrics(search_keywords)
|
search_results = self.Custommanager.search_Custom_lyrics(search_keywords)
|
||||||
self._display_results(search_results)
|
self._display_results(search_results)
|
||||||
|
|
||||||
def onCustomSelected(self, item):
|
|
||||||
print item
|
|
||||||
|
|
||||||
def onCustomNewClick(self):
|
def onCustomNewClick(self):
|
||||||
self.parent.edit_custom_form.loadCustom(0)
|
self.parent.edit_custom_form.loadCustom(0)
|
||||||
self.parent.edit_custom_form.exec_()
|
self.parent.edit_custom_form.exec_()
|
||||||
@ -182,7 +178,6 @@ class CustomMediaItem(MediaManagerItem):
|
|||||||
self.initialise()
|
self.initialise()
|
||||||
|
|
||||||
def onCustomDeleteClick(self):
|
def onCustomDeleteClick(self):
|
||||||
print 'delete pressed'
|
|
||||||
indexes = self.CustomListView.selectedIndexes()
|
indexes = self.CustomListView.selectedIndexes()
|
||||||
for index in indexes:
|
for index in indexes:
|
||||||
id = self.CustomListData.getId(index)
|
id = self.CustomListData.getId(index)
|
||||||
@ -197,24 +192,3 @@ class CustomMediaItem(MediaManagerItem):
|
|||||||
|
|
||||||
def onCustomAddClick(self):
|
def onCustomAddClick(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _display_results(self, searchresults):
|
|
||||||
log.debug("_search results")
|
|
||||||
self.CustomListView.clear() # clear the results
|
|
||||||
self.CustomListView.setHorizontalHeaderLabels(QtCore.QStringList(['', u'Custom Name']))
|
|
||||||
self.CustomListView.horizontalHeader().setVisible(False)
|
|
||||||
self.CustomListView.verticalHeader().setVisible(False)
|
|
||||||
self.CustomListView.setRowCount(0)
|
|
||||||
#log.debug("Records returned from search %s", len(searchresults))
|
|
||||||
for Custom in searchresults:
|
|
||||||
for author in Custom.authors:
|
|
||||||
c = self.CustomListView.rowCount()
|
|
||||||
self.CustomListView.setRowCount(c + 1)
|
|
||||||
Custom_index = QtGui.QTableWidgetItem(str(Custom.id))
|
|
||||||
self.CustomListView.setItem(c , 0, Custom_index)
|
|
||||||
Custom_detail = QtGui.QTableWidgetItem(u'%s (%s)' % (str(Custom.title), str(author.display_name)))
|
|
||||||
self.CustomListView.setItem(c , 1, Custom_detail)
|
|
||||||
#twi = QtGui.QTableWidgetItem()
|
|
||||||
#self.CustomListView.setItem(c , 2, twi)
|
|
||||||
self.CustomListView.setRowHeight(c, 20)
|
|
||||||
|
|
||||||
|
@ -33,8 +33,8 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
This is the custom media manager item for images.
|
This is the custom media manager item for images.
|
||||||
"""
|
"""
|
||||||
global log
|
global log
|
||||||
log=logging.getLogger("ImageMediaItem")
|
log=logging.getLogger(u'ImageMediaItem')
|
||||||
log.info("Image Media Item loaded")
|
log.info(u'Image Media Item loaded')
|
||||||
|
|
||||||
def __init__(self, parent, icon, title):
|
def __init__(self, parent, icon, title):
|
||||||
MediaManagerItem.__init__(self, parent, icon, title)
|
MediaManagerItem.__init__(self, parent, icon, title)
|
||||||
@ -109,13 +109,13 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
files = QtGui.QFileDialog.getOpenFileNames(None,
|
files = QtGui.QFileDialog.getOpenFileNames(None,
|
||||||
translate('ImageMediaItem', u'Select Image(s)'),
|
translate('ImageMediaItem', u'Select Image(s)'),
|
||||||
self.parent.config.get_last_dir(),
|
self.parent.config.get_last_dir(),
|
||||||
"Images (*.jpg *.gif *.png *.bmp)")
|
u'Images (*.jpg *.gif *.png *.bmp)')
|
||||||
log.info("New image(s)", str(files))
|
log.info(u'New image(s)', str(files))
|
||||||
if len(files) > 0:
|
if len(files) > 0:
|
||||||
self.loadImageList(files)
|
self.loadImageList(files)
|
||||||
dir, filename = os.path.split(str(files[0]))
|
dir, filename = os.path.split(str(files[0]))
|
||||||
self.parent.config.set_last_dir(dir)
|
self.parent.config.set_last_dir(dir)
|
||||||
self.parent.config.set_list('images', self.ImageListData.getFileList())
|
self.parent.config.set_list(u'images', self.ImageListData.getFileList())
|
||||||
|
|
||||||
def loadImageList(self, list):
|
def loadImageList(self, list):
|
||||||
for image in list:
|
for image in list:
|
||||||
@ -126,14 +126,13 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
for index in indexes:
|
for index in indexes:
|
||||||
current_row = int(index.row())
|
current_row = int(index.row())
|
||||||
self.ImageListData.removeRow(current_row)
|
self.ImageListData.removeRow(current_row)
|
||||||
|
self.parent.config.set_list(u'images', self.ImageListData.getFileList())
|
||||||
self._save_display_list(self.ImageListData.get_file_list())
|
|
||||||
|
|
||||||
def onImageClick(self, where):
|
def onImageClick(self, where):
|
||||||
indexes = self.ImageListView.selectedIndexes()
|
indexes = self.ImageListView.selectedIndexes()
|
||||||
for index in indexes:
|
for index in indexes:
|
||||||
filename = self.ImageListData.getFilename(index)
|
filename = self.ImageListData.getFilename(index)
|
||||||
log.info("Click %s:%s"%(str(where), filename))
|
log.info(u'Click %s:%s'%(str(where), filename))
|
||||||
where.add(filename)
|
where.add(filename)
|
||||||
where.render()
|
where.render()
|
||||||
|
|
||||||
|
@ -18,7 +18,8 @@ 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 filelistdata import FileListData
|
||||||
from videotab import VideoTab
|
from videotab import VideoTab
|
||||||
from mediaitem import VideoMediaItem
|
from mediaitem import VideoMediaItem
|
||||||
|
|
||||||
__all__ = ['VideoTab', 'VideoMediaItem']
|
__all__ = ['VideoTab', 'VideoMediaItem', 'FileListData']
|
||||||
|
82
openlp/plugins/videos/lib/filelistdata.py
Normal file
82
openlp/plugins/videos/lib/filelistdata.py
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
# -*- 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 os
|
||||||
|
import logging
|
||||||
|
from PyQt4.QtCore import *
|
||||||
|
from PyQt4.QtGui import *
|
||||||
|
|
||||||
|
class FileListData(QAbstractListModel):
|
||||||
|
"""
|
||||||
|
An abstract list of strings and the preview icon to go with them
|
||||||
|
"""
|
||||||
|
global log
|
||||||
|
log=logging.getLogger(u'FileListData')
|
||||||
|
log.info(u'started')
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
QAbstractListModel.__init__(self)
|
||||||
|
self.items=[] # will be a list of (full filename shortname) tuples
|
||||||
|
|
||||||
|
def rowCount(self, parent):
|
||||||
|
return len(self.items)
|
||||||
|
|
||||||
|
def insertRow(self, row, filename):
|
||||||
|
self.beginInsertRows(QModelIndex(),row,row)
|
||||||
|
log.info("insert row %d:%s"%(row,filename))
|
||||||
|
# get short filename to display next to image
|
||||||
|
(prefix, shortfilename) = os.path.split(str(filename))
|
||||||
|
log.info("shortfilename=%s"%(shortfilename))
|
||||||
|
# create a preview image
|
||||||
|
self.items.insert(row, (filename, shortfilename))
|
||||||
|
self.endInsertRows()
|
||||||
|
|
||||||
|
def removeRow(self, row):
|
||||||
|
self.beginRemoveRows(QModelIndex(), row,row)
|
||||||
|
self.items.pop(row)
|
||||||
|
self.endRemoveRows()
|
||||||
|
|
||||||
|
def addRow(self, filename):
|
||||||
|
self.insertRow(len(self.items), filename)
|
||||||
|
|
||||||
|
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()
|
||||||
|
if role==Qt.DisplayRole:
|
||||||
|
retval= self.items[row][1]
|
||||||
|
# elif role == Qt.DecorationRole:
|
||||||
|
# retval= self.items[row][1]
|
||||||
|
elif role == Qt.ToolTipRole:
|
||||||
|
retval= self.items[row][0]
|
||||||
|
else:
|
||||||
|
retval= QVariant()
|
||||||
|
# log.info("Returning"+ str(retval))
|
||||||
|
if type(retval) is not type(QVariant):
|
||||||
|
return QVariant(retval)
|
||||||
|
else:
|
||||||
|
return retval
|
||||||
|
|
||||||
|
def getFileList(self):
|
||||||
|
filelist = [item[0] for item in self.items];
|
||||||
|
return filelist
|
||||||
|
|
||||||
|
def getFilename(self, index):
|
||||||
|
row = index.row()
|
||||||
|
return self.items[row][0]
|
@ -27,14 +27,15 @@ from openlp.core.lib import MediaManagerItem
|
|||||||
from openlp.core.resources import *
|
from openlp.core.resources import *
|
||||||
|
|
||||||
from openlp.plugins.videos.lib import VideoTab
|
from openlp.plugins.videos.lib import VideoTab
|
||||||
|
from openlp.plugins.videos.lib import FileListData
|
||||||
|
|
||||||
class VideoMediaItem(MediaManagerItem):
|
class VideoMediaItem(MediaManagerItem):
|
||||||
"""
|
"""
|
||||||
This is the custom media manager item for Custom Slides.
|
This is the custom media manager item for Custom Slides.
|
||||||
"""
|
"""
|
||||||
global log
|
global log
|
||||||
log=logging.getLogger("CustomMediaItem")
|
log=logging.getLogger(u'VideoMediaItem')
|
||||||
log.info("Custom Media Item loaded")
|
log.info(u'Video Media Item loaded')
|
||||||
|
|
||||||
def __init__(self, parent, icon, title):
|
def __init__(self, parent, icon, title):
|
||||||
MediaManagerItem.__init__(self, parent, icon, title)
|
MediaManagerItem.__init__(self, parent, icon, title)
|
||||||
@ -44,79 +45,96 @@ class VideoMediaItem(MediaManagerItem):
|
|||||||
self.addToolbar()
|
self.addToolbar()
|
||||||
# Create buttons for the toolbar
|
# Create buttons for the toolbar
|
||||||
## New Song Button ##
|
## New Song Button ##
|
||||||
self.addToolbarButton('New Video', 'Load videos into openlp.org',
|
self.addToolbarButton(
|
||||||
|
translate('VideoMediaItem',u'New Video'),
|
||||||
|
translate('VideoMediaItem',u'Load videos into openlp.org'),
|
||||||
':/videos/video_load.png', self.onVideoNewClick, 'VideoNewItem')
|
':/videos/video_load.png', self.onVideoNewClick, 'VideoNewItem')
|
||||||
## Delete Song Button ##
|
## Delete Song Button ##
|
||||||
self.addToolbarButton('Delete Video', 'Delete the selected video',
|
self.addToolbarButton(
|
||||||
|
translate('VideoMediaItem',u'Delete Video'),
|
||||||
|
translate('VideoMediaItem',u'Delete the selected video'),
|
||||||
':/videos/video_delete.png', self.onVideoDeleteClick, 'VideoDeleteItem')
|
':/videos/video_delete.png', self.onVideoDeleteClick, 'VideoDeleteItem')
|
||||||
## Separator Line ##
|
## Separator Line ##
|
||||||
self.addToolbarSeparator()
|
self.addToolbarSeparator()
|
||||||
## Preview Song Button ##
|
## Preview Song Button ##
|
||||||
self.addToolbarButton('Preview Video', 'Preview the selected video',
|
self.addToolbarButton(
|
||||||
|
translate('VideoMediaItem',u'Preview Video'),
|
||||||
|
translate('VideoMediaItem',u'Preview the selected video'),
|
||||||
':/system/system_preview.png', self.onVideoPreviewClick, 'VideoPreviewItem')
|
':/system/system_preview.png', self.onVideoPreviewClick, 'VideoPreviewItem')
|
||||||
## Live Song Button ##
|
## Live Song Button ##
|
||||||
self.addToolbarButton('Go Live', 'Send the selected video live',
|
self.addToolbarButton(
|
||||||
|
translate('VideoMediaItem',u'Go Live'),
|
||||||
|
translate('VideoMediaItem',u'Send the selected video live'),
|
||||||
':/system/system_live.png', self.onVideoLiveClick, 'VideoLiveItem')
|
':/system/system_live.png', self.onVideoLiveClick, 'VideoLiveItem')
|
||||||
## Add Song Button ##
|
## Add Song Button ##
|
||||||
self.addToolbarButton('Add Video To Service',
|
self.addToolbarButton(
|
||||||
'Add the selected video(s) to the service', ':/system/system_add.png',
|
translate('VideoMediaItem',u'Add Video To Service'),
|
||||||
self.onVideoAddClick, 'VideoAddItem')
|
translate('VideoMediaItem',u'Add the selected video(s) to the service'),
|
||||||
|
':/system/system_add.png',self.onVideoAddClick, 'VideoAddItem')
|
||||||
## Add the videolist widget ##
|
## Add the videolist widget ##
|
||||||
self.VideoListView = QtGui.QTableWidget()
|
|
||||||
self.VideoListView.setColumnCount(2)
|
self.VideoListView = QtGui.QListView()
|
||||||
self.VideoListView.setColumnHidden(0, True)
|
|
||||||
self.VideoListView.setColumnWidth(1, 275)
|
|
||||||
self.VideoListView.setShowGrid(False)
|
|
||||||
self.VideoListView.setSortingEnabled(False)
|
|
||||||
self.VideoListView.setAlternatingRowColors(True)
|
self.VideoListView.setAlternatingRowColors(True)
|
||||||
self.VideoListView.verticalHeader().setVisible(False)
|
self.VideoListData = FileListData()
|
||||||
self.VideoListView.horizontalHeader().setVisible(False)
|
self.VideoListView.setModel(self.VideoListData)
|
||||||
self.VideoListView.setAlternatingRowColors(True)
|
|
||||||
self.VideoListView.setGeometry(QtCore.QRect(10, 100, 256, 591))
|
|
||||||
self.VideoListView.setObjectName("VideoListView")
|
|
||||||
self.PageLayout.addWidget(self.VideoListView)
|
self.PageLayout.addWidget(self.VideoListView)
|
||||||
|
|
||||||
|
# self.VideoListView = QtGui.QTableWidget()
|
||||||
|
# self.VideoListView.setColumnCount(2)
|
||||||
|
# self.VideoListView.setColumnHidden(0, True)
|
||||||
|
# self.VideoListView.setColumnWidth(1, 275)
|
||||||
|
# self.VideoListView.setShowGrid(False)
|
||||||
|
# self.VideoListView.setSortingEnabled(False)
|
||||||
|
# self.VideoListView.setAlternatingRowColors(True)
|
||||||
|
# self.VideoListView.verticalHeader().setVisible(False)
|
||||||
|
# self.VideoListView.horizontalHeader().setVisible(False)
|
||||||
|
# self.VideoListView.setAlternatingRowColors(True)
|
||||||
|
# self.VideoListView.setGeometry(QtCore.QRect(10, 100, 256, 591))
|
||||||
|
# self.VideoListView.setObjectName("VideoListView")
|
||||||
|
# self.PageLayout.addWidget(self.VideoListView)
|
||||||
|
|
||||||
#define and add the context menu
|
#define and add the context menu
|
||||||
self.VideoListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
|
self.VideoListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
|
||||||
|
|
||||||
self.VideoListView.addAction(self.contextMenuAction(self.VideoListView, ':/system/system_preview.png', "&Preview Video", self.onVideoPreviewClick))
|
self.VideoListView.addAction(self.contextMenuAction(
|
||||||
self.VideoListView.addAction(self.contextMenuAction(self.VideoListView, ':/system/system_live.png', "&Show Live", self.onVideoLiveClick))
|
self.VideoListView, ':/system/system_preview.png',
|
||||||
self.VideoListView.addAction(self.contextMenuAction(self.VideoListView, ':/system/system_add.png', "&Add to Service", self.onVideoAddClick))
|
translate('VideoMediaItem',u'&Preview Video'), self.onVideoPreviewClick))
|
||||||
|
self.VideoListView.addAction(self.contextMenuAction(
|
||||||
|
self.VideoListView, ':/system/system_live.png',
|
||||||
|
translate('VideoMediaItem',u'&Show Live'), self.onVideoLiveClick))
|
||||||
|
self.VideoListView.addAction(self.contextMenuAction(
|
||||||
|
self.VideoListView, ':/system/system_add.png',
|
||||||
|
translate('VideoMediaItem',u'&Add to Service'), self.onVideoAddClick))
|
||||||
|
|
||||||
def initialise(self):
|
def initialise(self):
|
||||||
list = self.parent.config.load_list('videos')
|
list = self.parent.config.load_list(u'videos')
|
||||||
self.loadVideoList(list)
|
self.loadVideoList(list)
|
||||||
|
|
||||||
def onVideoNewClick(self):
|
def onVideoNewClick(self):
|
||||||
files = QtGui.QFileDialog.getOpenFileNames(None, "Select Image(s)",
|
files = QtGui.QFileDialog.getOpenFileNames(None,
|
||||||
self.parent.config.get_last_dir(), "Images (*.avi *.mpeg)")
|
translate('VideoMediaItem', u'Select Video(s)'),
|
||||||
|
self.parent.config.get_last_dir(), u'Images (*.avi *.mpeg)')
|
||||||
if len(files) > 0:
|
if len(files) > 0:
|
||||||
self.loadVideoList(files)
|
self.loadVideoList(files)
|
||||||
print files[0]
|
|
||||||
dir, filename = os.path.split(str(files[0]))
|
dir, filename = os.path.split(str(files[0]))
|
||||||
print dir , filename
|
|
||||||
self.parent.config.set_last_dir(dir)
|
self.parent.config.set_last_dir(dir)
|
||||||
#self.parent.config.set_list('videos', self.getFileList())
|
self.parent.config.set_list(u'videos', self.VideoListData.getFileList())
|
||||||
|
|
||||||
def getFileList(self):
|
def getFileList(self):
|
||||||
filelist = [item[0] for item in self.VideoListView];
|
filelist = [item[0] for item in self.VideoListView];
|
||||||
return filelist
|
return filelist
|
||||||
|
|
||||||
def loadVideoList(self, list):
|
def loadVideoList(self, list):
|
||||||
for f in list:
|
for files in list:
|
||||||
file_path , file_name = os.path.split(str(f))
|
self.VideoListData.addRow(files)
|
||||||
count = self.VideoListView.rowCount()
|
|
||||||
self.VideoListView.setRowCount(count+1)
|
|
||||||
row_item = QtGui.QTableWidgetItem(str(f))
|
|
||||||
self.VideoListView.setItem(count , 0, row_item)
|
|
||||||
row_item = QtGui.QTableWidgetItem(str(file_name))
|
|
||||||
self.VideoListView.setItem(count , 1, row_item)
|
|
||||||
self.VideoListView.setRowHeight(count, 20)
|
|
||||||
|
|
||||||
def onVideoDeleteClick(self):
|
def onVideoDeleteClick(self):
|
||||||
cr = self.VideoListView.currentRow()
|
indexes = self.VideoListView.selectedIndexes()
|
||||||
self.VideoListView.removeRow(int(cr))
|
for index in indexes:
|
||||||
self._save_display_list(self.VideoListView)
|
current_row = int(index.row())
|
||||||
|
self.VideoListData.removeRow(current_row)
|
||||||
|
self.parent.config.set_list(u'videos', self.VideoListData.getFileList())
|
||||||
|
|
||||||
def onVideoPreviewClick(self):
|
def onVideoPreviewClick(self):
|
||||||
pass
|
pass
|
||||||
|
@ -71,9 +71,9 @@ class VideoTab(SettingsTab):
|
|||||||
self.use_vmr_mode = True
|
self.use_vmr_mode = True
|
||||||
|
|
||||||
def load(self):
|
def load(self):
|
||||||
self.use_vmr_mode = self.convertStringToBoolean(self.config.get_config('use mode layout', u'False'))
|
self.use_vmr_mode = self.convertStringToBoolean(self.config.get_config(u'use mode layout', u'False'))
|
||||||
if self.use_vmr_mode :
|
if self.use_vmr_mode :
|
||||||
self.UseVMRCheckBox.setChecked(True)
|
self.UseVMRCheckBox.setChecked(True)
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
self.config.set_config('use mode layout', str(self.use_vmr_mode))
|
self.config.set_config(u'use mode layout', str(self.use_vmr_mode))
|
||||||
|
Loading…
Reference in New Issue
Block a user