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
|
||||
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
|
||||
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):
|
||||
app_data = ConfigHelper.get_data_path()
|
||||
safe_name = self.section.replace(' ', '-')
|
||||
plugin_data = self.get_config('data path', safe_name)
|
||||
app_data = ConfigHelper.get_data_path()
|
||||
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)
|
||||
|
||||
if not os.path.exists(path):
|
||||
|
@ -62,7 +63,7 @@ class PluginConfig(object):
|
|||
return 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):
|
||||
returnfiles = []
|
||||
|
@ -88,7 +89,7 @@ class PluginConfig(object):
|
|||
"""
|
||||
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:
|
||||
list_count = int(list_count)
|
||||
else:
|
||||
|
@ -96,7 +97,7 @@ class PluginConfig(object):
|
|||
list = []
|
||||
if list_count > 0:
|
||||
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)
|
||||
return list
|
||||
|
||||
|
@ -104,24 +105,24 @@ class PluginConfig(object):
|
|||
"""
|
||||
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)
|
||||
self.set_config('%s count' % new_count)
|
||||
self.set_config(u'%s count' % name, 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:
|
||||
# Tidy up any old list itrms if list is smaller now
|
||||
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):
|
||||
"""
|
||||
Read the last directory used for plugin
|
||||
"""
|
||||
if num is not None:
|
||||
name = 'last directory %d' % num
|
||||
name = u'last directory %d' % num
|
||||
else:
|
||||
name = 'last directory'
|
||||
name = u'last directory'
|
||||
last_dir = self.get_config(name)
|
||||
if last_dir is None:
|
||||
last_dir = ''
|
||||
|
@ -132,7 +133,7 @@ class PluginConfig(object):
|
|||
Save the last directory used for plugin
|
||||
"""
|
||||
if num is not None:
|
||||
name = 'last directory %d' % num
|
||||
name = u'last directory %d' % num
|
||||
else:
|
||||
name = 'last directory'
|
||||
name = u'last 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
|
||||
"""
|
||||
import os
|
||||
import sys
|
||||
from ConfigParser import SafeConfigParser
|
||||
from openlp.core.utils import Registry
|
||||
|
||||
|
@ -54,7 +55,7 @@ class LinRegistry(Registry):
|
|||
Set a single value in the registry.
|
||||
"""
|
||||
try :
|
||||
self.config.set(section, key, value)
|
||||
self.config.set(section, key, str(value))
|
||||
return self._save()
|
||||
except:
|
||||
return False
|
||||
|
|
|
@ -51,7 +51,7 @@ class BiblePlugin(Plugin, PluginUtils):
|
|||
return self.bibles_tab
|
||||
|
||||
def get_media_manager_item(self):
|
||||
# Create the MediaManagerItem object
|
||||
# Create the BibleManagerItem object
|
||||
self.media_item = BibleMediaItem(self, self.icon, 'Bible Verses')
|
||||
return self.media_item
|
||||
|
||||
|
|
|
@ -22,19 +22,19 @@ import logging
|
|||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.resources import *
|
||||
from openlp.core.lib import Plugin, MediaManagerItem
|
||||
from openlp.core.lib import Plugin
|
||||
from forms import EditCustomForm
|
||||
from openlp.plugins.custom.lib import CustomManager, CustomTab, CustomMediaItem
|
||||
|
||||
class CustomPlugin(Plugin):
|
||||
|
||||
global log
|
||||
log=logging.getLogger("CustomPlugin")
|
||||
log.info("Custom Plugin loaded")
|
||||
log=logging.getLogger(u'CustomPlugin')
|
||||
log.info(u'Custom Plugin loaded')
|
||||
|
||||
def __init__(self):
|
||||
# Call the parent constructor
|
||||
Plugin.__init__(self, 'Custom', '1.9.0')
|
||||
Plugin.__init__(self, u'Custom', u'1.9.0')
|
||||
self.weight = -5
|
||||
self.custommanager = CustomManager(self.config)
|
||||
self.edit_custom_form = EditCustomForm(self.custommanager)
|
||||
|
@ -44,8 +44,8 @@ class CustomPlugin(Plugin):
|
|||
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||
|
||||
def get_media_manager_item(self):
|
||||
# Create the MediaManagerItem object
|
||||
self.media_item = CustomMediaItem(self, self.icon, 'Custom Slides')
|
||||
# Create the CustomManagerItem object
|
||||
self.media_item = CustomMediaItem(self, self.icon, u'Custom Slides')
|
||||
return self.media_item
|
||||
|
||||
def get_settings_tab(self):
|
||||
|
|
|
@ -34,8 +34,8 @@ class CustomManager():
|
|||
"""
|
||||
|
||||
global log
|
||||
log=logging.getLogger('CustomManager')
|
||||
log.info('Custom manager loaded')
|
||||
log=logging.getLogger(u'CustomManager')
|
||||
log.info(u'Custom manager loaded')
|
||||
|
||||
def __init__(self, config):
|
||||
"""
|
||||
|
@ -43,7 +43,7 @@ class CustomManager():
|
|||
don't exist.
|
||||
"""
|
||||
self.config = config
|
||||
log.debug('Custom Initialising')
|
||||
log.debug(u'Custom Initialising')
|
||||
self.db_url = u''
|
||||
db_type = self.config.get_config(u'db type', u'sqlite')
|
||||
if db_type == u'sqlite':
|
||||
|
@ -59,7 +59,7 @@ class CustomManager():
|
|||
if not custom_slide_table.exists():
|
||||
metadata.create_all()
|
||||
|
||||
log.debug('Custom Initialised')
|
||||
log.debug(u'Custom Initialised')
|
||||
#
|
||||
# def process_dialog(self, dialogobject):
|
||||
# self.dialogobject = dialogobject
|
||||
|
@ -74,14 +74,14 @@ class CustomManager():
|
|||
"""
|
||||
Saves a song to the database
|
||||
"""
|
||||
log.debug('Custom Slide added')
|
||||
log.debug(u'Custom Slide added')
|
||||
try:
|
||||
self.session.add(customslide)
|
||||
self.session.commit()
|
||||
log.debug('Custom Slide saved')
|
||||
log.debug(u'Custom Slide saved')
|
||||
return True
|
||||
except:
|
||||
log.debug('Custom Slide failed')
|
||||
log.debug(u'Custom Slide failed')
|
||||
return False
|
||||
|
||||
def get_custom(self, id=None):
|
||||
|
|
|
@ -32,8 +32,8 @@ class CustomMediaItem(MediaManagerItem):
|
|||
This is the custom media manager item for Custom Slides.
|
||||
"""
|
||||
global log
|
||||
log=logging.getLogger("CustomMediaItem")
|
||||
log.info("Custom Media Item loaded")
|
||||
log=logging.getLogger(u'CustomMediaItem')
|
||||
log.info(u'Custom Media Item loaded')
|
||||
|
||||
def __init__(self, parent, icon, title):
|
||||
MediaManagerItem.__init__(self, parent, icon, title)
|
||||
|
@ -44,45 +44,44 @@ class CustomMediaItem(MediaManagerItem):
|
|||
# Create buttons for the toolbar
|
||||
## New Custom Button ##
|
||||
self.addToolbarButton(
|
||||
translate('CustomMediaItem','New Custom Item'),
|
||||
translate('CustomMediaItem','Add a new Custom Item'),
|
||||
translate('CustomMediaItem',u'New Custom Item'),
|
||||
translate('CustomMediaItem',u'Add a new Custom Item'),
|
||||
':/custom/custom_new.png', self.onCustomNewClick, 'CustomNewItem')
|
||||
## Edit Custom Button ##
|
||||
self.addToolbarButton(
|
||||
translate('CustomMediaItem','Edit Custom Item'),
|
||||
translate('CustomMediaItem','Edit the selected Custom Item'),
|
||||
translate('CustomMediaItem',u'Edit Custom Item'),
|
||||
translate('CustomMediaItem',u'Edit the selected Custom Item'),
|
||||
':/custom/custom_edit.png', self.onCustomEditClick, 'CustomEditItem')
|
||||
## Delete Custom Button ##
|
||||
self.addToolbarButton(
|
||||
translate('CustomMediaItem','Delete Custom Item'),
|
||||
translate('CustomMediaItem','Delete the selected Custom Item'),
|
||||
translate('CustomMediaItem',u'Delete Custom Item'),
|
||||
translate('CustomMediaItem',u'Delete the selected Custom Item'),
|
||||
':/custom/custom_delete.png', self.onCustomDeleteClick, 'CustomDeleteItem')
|
||||
## Separator Line ##
|
||||
self.addToolbarSeparator()
|
||||
## Preview Custom Button ##
|
||||
self.addToolbarButton(
|
||||
translate('CustomMediaItem','Preview Custom Item'),
|
||||
translate('CustomMediaItem','Preview the selected Custom Item'),
|
||||
translate('CustomMediaItem',u'Preview Custom Item'),
|
||||
translate('CustomMediaItem',u'Preview the selected Custom Item'),
|
||||
':/system/system_preview.png', self.onCustomPreviewClick, 'CustomPreviewItem')
|
||||
## Live Custom Button ##
|
||||
self.addToolbarButton(
|
||||
translate('CustomMediaItem','Go Live'),
|
||||
translate('CustomMediaItem', 'Send the selected Custom live'),
|
||||
translate('CustomMediaItem',u'Go Live'),
|
||||
translate('CustomMediaItem', u'Send the selected Custom live'),
|
||||
':/system/system_live.png', self.onCustomLiveClick, 'CustomLiveItem')
|
||||
## Add Custom Button ##
|
||||
self.addToolbarButton(
|
||||
translate('CustomMediaItem','Add Custom To Service'),
|
||||
translate('CustomMediaItem','Add the selected Custom(s) to the service'),
|
||||
translate('CustomMediaItem',u'Add Custom To Service'),
|
||||
translate('CustomMediaItem',u'Add the selected Custom(s) to the service'),
|
||||
':/system/system_add.png', self.onCustomAddClick, 'CustomAddItem')
|
||||
## Add the Customlist widget ##
|
||||
# Create the tab widget
|
||||
# Add the Customlist widget
|
||||
self.CustomWidget = QtGui.QWidget(self)
|
||||
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.CustomWidget.sizePolicy().hasHeightForWidth())
|
||||
self.CustomWidget.setSizePolicy(sizePolicy)
|
||||
self.CustomWidget.setObjectName('CustomWidget')
|
||||
self.CustomWidget.setObjectName(u'CustomWidget')
|
||||
|
||||
# self.SearchLayout = QtGui.QGridLayout(self.CustomWidget)
|
||||
# self.SearchLayout.setObjectName('SearchLayout')
|
||||
|
@ -129,13 +128,13 @@ class CustomMediaItem(MediaManagerItem):
|
|||
self.CustomListView.addAction(self.contextMenuSeparator(self.CustomListView))
|
||||
self.CustomListView.addAction(self.contextMenuAction(
|
||||
self.CustomListView, ':/system/system_preview.png',
|
||||
"&Preview Custom", self.onCustomPreviewClick))
|
||||
translate('CustomMediaItem',u'&Preview Custom'), self.onCustomPreviewClick))
|
||||
self.CustomListView.addAction(self.contextMenuAction(
|
||||
self.CustomListView, ':/system/system_live.png',
|
||||
"&Show Live", self.onCustomLiveClick))
|
||||
translate('CustomMediaItem',u'&Show Live'), self.onCustomLiveClick))
|
||||
self.CustomListView.addAction(self.contextMenuAction(
|
||||
self.CustomListView, ':/system/system_add.png',
|
||||
"&Add to Service", self.onCustomEditClick))
|
||||
translate('CustomMediaItem',u'&Add to Service'), self.onCustomEditClick))
|
||||
|
||||
# def retranslateUi(self):
|
||||
# self.ClearTextButton.setText(translate('CustomMediaItem', u'Clear'))
|
||||
|
@ -166,9 +165,6 @@ class CustomMediaItem(MediaManagerItem):
|
|||
search_results = self.Custommanager.search_Custom_lyrics(search_keywords)
|
||||
self._display_results(search_results)
|
||||
|
||||
def onCustomSelected(self, item):
|
||||
print item
|
||||
|
||||
def onCustomNewClick(self):
|
||||
self.parent.edit_custom_form.loadCustom(0)
|
||||
self.parent.edit_custom_form.exec_()
|
||||
|
@ -182,7 +178,6 @@ class CustomMediaItem(MediaManagerItem):
|
|||
self.initialise()
|
||||
|
||||
def onCustomDeleteClick(self):
|
||||
print 'delete pressed'
|
||||
indexes = self.CustomListView.selectedIndexes()
|
||||
for index in indexes:
|
||||
id = self.CustomListData.getId(index)
|
||||
|
@ -197,24 +192,3 @@ class CustomMediaItem(MediaManagerItem):
|
|||
|
||||
def onCustomAddClick(self):
|
||||
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.
|
||||
"""
|
||||
global log
|
||||
log=logging.getLogger("ImageMediaItem")
|
||||
log.info("Image Media Item loaded")
|
||||
log=logging.getLogger(u'ImageMediaItem')
|
||||
log.info(u'Image Media Item loaded')
|
||||
|
||||
def __init__(self, parent, icon, title):
|
||||
MediaManagerItem.__init__(self, parent, icon, title)
|
||||
|
@ -109,13 +109,13 @@ class ImageMediaItem(MediaManagerItem):
|
|||
files = QtGui.QFileDialog.getOpenFileNames(None,
|
||||
translate('ImageMediaItem', u'Select Image(s)'),
|
||||
self.parent.config.get_last_dir(),
|
||||
"Images (*.jpg *.gif *.png *.bmp)")
|
||||
log.info("New image(s)", str(files))
|
||||
u'Images (*.jpg *.gif *.png *.bmp)')
|
||||
log.info(u'New image(s)', str(files))
|
||||
if len(files) > 0:
|
||||
self.loadImageList(files)
|
||||
dir, filename = os.path.split(str(files[0]))
|
||||
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):
|
||||
for image in list:
|
||||
|
@ -126,14 +126,13 @@ class ImageMediaItem(MediaManagerItem):
|
|||
for index in indexes:
|
||||
current_row = int(index.row())
|
||||
self.ImageListData.removeRow(current_row)
|
||||
|
||||
self._save_display_list(self.ImageListData.get_file_list())
|
||||
self.parent.config.set_list(u'images', self.ImageListData.getFileList())
|
||||
|
||||
def onImageClick(self, where):
|
||||
indexes = self.ImageListView.selectedIndexes()
|
||||
for index in indexes:
|
||||
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.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
|
||||
"""
|
||||
|
||||
from filelistdata import FileListData
|
||||
from videotab import VideoTab
|
||||
from mediaitem import VideoMediaItem
|
||||
|
||||
__all__ = ['VideoTab', 'VideoMediaItem']
|
||||
__all__ = ['VideoTab', 'VideoMediaItem', 'FileListData']
|
||||
|
|
|
@ -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.plugins.videos.lib import VideoTab
|
||||
from openlp.plugins.videos.lib import FileListData
|
||||
|
||||
class VideoMediaItem(MediaManagerItem):
|
||||
"""
|
||||
This is the custom media manager item for Custom Slides.
|
||||
"""
|
||||
global log
|
||||
log=logging.getLogger("CustomMediaItem")
|
||||
log.info("Custom Media Item loaded")
|
||||
log=logging.getLogger(u'VideoMediaItem')
|
||||
log.info(u'Video Media Item loaded')
|
||||
|
||||
def __init__(self, parent, icon, title):
|
||||
MediaManagerItem.__init__(self, parent, icon, title)
|
||||
|
@ -44,79 +45,96 @@ class VideoMediaItem(MediaManagerItem):
|
|||
self.addToolbar()
|
||||
# Create buttons for the toolbar
|
||||
## 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')
|
||||
## 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')
|
||||
## Separator Line ##
|
||||
self.addToolbarSeparator()
|
||||
## 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')
|
||||
## 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')
|
||||
## Add Song Button ##
|
||||
self.addToolbarButton('Add Video To Service',
|
||||
'Add the selected video(s) to the service', ':/system/system_add.png',
|
||||
self.onVideoAddClick, 'VideoAddItem')
|
||||
self.addToolbarButton(
|
||||
translate('VideoMediaItem',u'Add Video To Service'),
|
||||
translate('VideoMediaItem',u'Add the selected video(s) to the service'),
|
||||
':/system/system_add.png',self.onVideoAddClick, 'VideoAddItem')
|
||||
## Add the videolist widget ##
|
||||
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 = QtGui.QListView()
|
||||
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.VideoListData = FileListData()
|
||||
self.VideoListView.setModel(self.VideoListData)
|
||||
|
||||
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
|
||||
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, ':/system/system_live.png', "&Show Live", self.onVideoLiveClick))
|
||||
self.VideoListView.addAction(self.contextMenuAction(self.VideoListView, ':/system/system_add.png', "&Add to Service", self.onVideoAddClick))
|
||||
self.VideoListView.addAction(self.contextMenuAction(
|
||||
self.VideoListView, ':/system/system_preview.png',
|
||||
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):
|
||||
list = self.parent.config.load_list('videos')
|
||||
list = self.parent.config.load_list(u'videos')
|
||||
self.loadVideoList(list)
|
||||
|
||||
def onVideoNewClick(self):
|
||||
files = QtGui.QFileDialog.getOpenFileNames(None, "Select Image(s)",
|
||||
self.parent.config.get_last_dir(), "Images (*.avi *.mpeg)")
|
||||
files = QtGui.QFileDialog.getOpenFileNames(None,
|
||||
translate('VideoMediaItem', u'Select Video(s)'),
|
||||
self.parent.config.get_last_dir(), u'Images (*.avi *.mpeg)')
|
||||
if len(files) > 0:
|
||||
self.loadVideoList(files)
|
||||
print files[0]
|
||||
dir, filename = os.path.split(str(files[0]))
|
||||
print dir , filename
|
||||
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):
|
||||
filelist = [item[0] for item in self.VideoListView];
|
||||
return filelist
|
||||
|
||||
def loadVideoList(self, list):
|
||||
for f in list:
|
||||
file_path , file_name = os.path.split(str(f))
|
||||
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)
|
||||
|
||||
for files in list:
|
||||
self.VideoListData.addRow(files)
|
||||
|
||||
def onVideoDeleteClick(self):
|
||||
cr = self.VideoListView.currentRow()
|
||||
self.VideoListView.removeRow(int(cr))
|
||||
self._save_display_list(self.VideoListView)
|
||||
indexes = self.VideoListView.selectedIndexes()
|
||||
for index in indexes:
|
||||
current_row = int(index.row())
|
||||
self.VideoListData.removeRow(current_row)
|
||||
self.parent.config.set_list(u'videos', self.VideoListData.getFileList())
|
||||
|
||||
def onVideoPreviewClick(self):
|
||||
pass
|
||||
|
|
|
@ -71,9 +71,9 @@ class VideoTab(SettingsTab):
|
|||
self.use_vmr_mode = True
|
||||
|
||||
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 :
|
||||
self.UseVMRCheckBox.setChecked(True)
|
||||
|
||||
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