Fixes, cleanups and UiStrings

Refactor plugins: icon building, settings tabs and media items

bzr-revno: 1291
This commit is contained in:
Jon Tibble 2011-02-11 13:29:17 +00:00
commit 186eec0eb3
24 changed files with 114 additions and 149 deletions

View File

@ -28,7 +28,8 @@ import logging
from PyQt4 import QtWebKit from PyQt4 import QtWebKit
from openlp.core.lib import BackgroundType, BackgroundGradientType from openlp.core.lib import BackgroundType, BackgroundGradientType, \
VerticalType
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -536,12 +537,7 @@ def build_lyrics_format_css(theme, width, height):
align = u'right' align = u'right'
else: else:
align = u'left' align = u'left'
if theme.display_vertical_align == 2: valign = VerticalType.to_string(theme.display_vertical_align)
valign = u'bottom'
elif theme.display_vertical_align == 1:
valign = u'middle'
else:
valign = u'top'
if theme.font_main_outline: if theme.font_main_outline:
left_margin = int(theme.font_main_outline_size) * 2 left_margin = int(theme.font_main_outline_size) * 2
else: else:
@ -634,13 +630,7 @@ def build_alert_css(alertTab, width):
""" """
if not alertTab: if not alertTab:
return u'' return u''
align = u'' align = VerticalType.to_string(alertTab.location)
if alertTab.location == 2:
align = u'bottom'
elif alertTab.location == 1:
align = u'middle'
else:
align = u'top'
alert = style % (width, align, alertTab.font_face, alertTab.font_size, alert = style % (width, align, alertTab.font_face, alertTab.font_size,
alertTab.font_color, alertTab.bg_color) alertTab.font_color, alertTab.bg_color)
return alert return alert

View File

@ -197,61 +197,43 @@ class MediaManagerItem(QtGui.QWidget):
""" """
Create buttons for the media item toolbar Create buttons for the media item toolbar
""" """
toolbar_actions = []
## Import Button ## ## Import Button ##
if self.hasImportIcon: if self.hasImportIcon:
import_string = self.plugin.getString(StringContent.Import) toolbar_actions.append([StringContent.Import,
self.addToolbarButton( u':/general/general_import.png', self.onImportClick])
import_string[u'title'],
import_string[u'tooltip'],
u':/general/general_import.png', self.onImportClick)
## Load Button ## ## Load Button ##
if self.hasFileIcon: if self.hasFileIcon:
load_string = self.plugin.getString(StringContent.Load) toolbar_actions.append([StringContent.Load,
self.addToolbarButton( u':/general/general_open.png', self.onFileClick])
load_string[u'title'],
load_string[u'tooltip'],
u':/general/general_open.png', self.onFileClick)
## New Button ## ## New Button ##
if self.hasNewIcon: if self.hasNewIcon:
new_string = self.plugin.getString(StringContent.New) toolbar_actions.append([StringContent.New,
self.addToolbarButton( u':/general/general_new.png', self.onNewClick])
new_string[u'title'],
new_string[u'tooltip'],
u':/general/general_new.png', self.onNewClick)
## Edit Button ## ## Edit Button ##
if self.hasEditIcon: if self.hasEditIcon:
edit_string = self.plugin.getString(StringContent.Edit) toolbar_actions.append([StringContent.Edit,
self.addToolbarButton( u':/general/general_edit.png', self.onEditClick])
edit_string[u'title'],
edit_string[u'tooltip'],
u':/general/general_edit.png', self.onEditClick)
## Delete Button ## ## Delete Button ##
if self.hasDeleteIcon: if self.hasDeleteIcon:
delete_string = self.plugin.getString(StringContent.Delete) toolbar_actions.append([StringContent.Delete,
self.addToolbarButton( u':/general/general_delete.png', self.onDeleteClick])
delete_string[u'title'],
delete_string[u'tooltip'],
u':/general/general_delete.png', self.onDeleteClick)
## Separator Line ## ## Separator Line ##
self.addToolbarSeparator() self.addToolbarSeparator()
## Preview ## ## Preview ##
preview_string = self.plugin.getString(StringContent.Preview) toolbar_actions.append([StringContent.Preview,
self.addToolbarButton( u':/general/general_preview.png', self.onPreviewClick])
preview_string[u'title'],
preview_string[u'tooltip'],
u':/general/general_preview.png', self.onPreviewClick)
## Live Button ## ## Live Button ##
live_string = self.plugin.getString(StringContent.Live) toolbar_actions.append([StringContent.Live,
self.addToolbarButton( u':/general/general_live.png', self.onLiveClick])
live_string[u'title'],
live_string[u'tooltip'],
u':/general/general_live.png', self.onLiveClick)
## Add to service Button ## ## Add to service Button ##
service_string = self.plugin.getString(StringContent.Service) toolbar_actions.append([StringContent.Service,
self.addToolbarButton( u':/general/general_add.png', self.onAddClick])
service_string[u'title'], for action in toolbar_actions:
service_string[u'tooltip'], self.addToolbarButton(
u':/general/general_add.png', self.onAddClick) self.plugin.getString(action[0])[u'title'],
self.plugin.getString(action[0])[u'tooltip'],
action[1], action[2])
def addListViewToToolBar(self): def addListViewToToolBar(self):
""" """

View File

@ -114,7 +114,8 @@ class Plugin(QtCore.QObject):
""" """
log.info(u'loaded') log.info(u'loaded')
def __init__(self, name, version=None, pluginHelpers=None): def __init__(self, name, version=None, pluginHelpers=None,
mediaItemClass=None, settingsTabClass=None):
""" """
This is the constructor for the plugin object. This provides an easy This is the constructor for the plugin object. This provides an easy
way for descendent plugins to populate common data. This method *must* way for descendent plugins to populate common data. This method *must*
@ -132,6 +133,12 @@ class Plugin(QtCore.QObject):
``pluginHelpers`` ``pluginHelpers``
Defaults to *None*. A list of helper objects. Defaults to *None*. A list of helper objects.
``mediaItemClass``
The class name of the plugin's media item.
``settingsTabClass``
The class name of the plugin's settings tab.
""" """
QtCore.QObject.__init__(self) QtCore.QObject.__init__(self)
self.name = name self.name = name
@ -141,6 +148,8 @@ class Plugin(QtCore.QObject):
self.version = version self.version = version
self.settingsSection = self.name.lower() self.settingsSection = self.name.lower()
self.icon = None self.icon = None
self.mediaItemClass = mediaItemClass
self.settingsTabClass = settingsTabClass
self.weight = 0 self.weight = 0
self.status = PluginStatus.Inactive self.status = PluginStatus.Inactive
# Set up logging # Set up logging
@ -199,7 +208,9 @@ class Plugin(QtCore.QObject):
Construct a MediaManagerItem object with all the buttons and things Construct a MediaManagerItem object with all the buttons and things
you need, and return it for integration into openlp.org. you need, and return it for integration into openlp.org.
""" """
pass if self.mediaItemClass:
return self.mediaItemClass(self, self, self.icon)
return None
def addImportMenuItem(self, importMenu): def addImportMenuItem(self, importMenu):
""" """
@ -230,9 +241,13 @@ class Plugin(QtCore.QObject):
def getSettingsTab(self): def getSettingsTab(self):
""" """
Create a tab for the settings window. Create a tab for the settings window to display the configurable
options for this plugin to the user.
""" """
pass if self.settingsTabClass:
return self.settingsTabClass(self.name,
self.getString(StringContent.VisibleName)[u'title'])
return None
def addToMenu(self, menubar): def addToMenu(self, menubar):
""" """

View File

@ -68,7 +68,6 @@ class RenderManager(object):
self.theme_level = u'' self.theme_level = u''
self.override_background = None self.override_background = None
self.theme_data = None self.theme_data = None
self.alertTab = None
self.force_page = False self.force_page = False
def update_display(self): def update_display(self):
@ -261,4 +260,4 @@ class RenderManager(object):
log.debug(u'calculate default %d, %d, %f', log.debug(u'calculate default %d, %d, %f',
self.width, self.height, self.screen_ratio ) self.width, self.height, self.screen_ratio )
# 90% is start of footer # 90% is start of footer
self.footer_start = int(self.height * 0.90) self.footer_start = int(self.height * 0.90)

View File

@ -164,6 +164,7 @@ class BackgroundGradientType(object):
elif type_string == u'leftBottom': elif type_string == u'leftBottom':
return BackgroundGradientType.LeftBottom return BackgroundGradientType.LeftBottom
class HorizontalType(object): class HorizontalType(object):
""" """
Type enumeration for horizontal alignment. Type enumeration for horizontal alignment.
@ -172,6 +173,19 @@ class HorizontalType(object):
Center = 1 Center = 1
Right = 2 Right = 2
@staticmethod
def to_string(horizontal_type):
"""
Return a string representation of a horizontal type.
"""
if horizontal_type == Horizontal.Right:
return u'right'
elif horizontal_type == Horizontal.Center:
return u'center'
else:
return u'left'
class VerticalType(object): class VerticalType(object):
""" """
Type enumeration for vertical alignment. Type enumeration for vertical alignment.
@ -180,6 +194,19 @@ class VerticalType(object):
Middle = 1 Middle = 1
Bottom = 2 Bottom = 2
@staticmethod
def to_string(vertical_type):
"""
Return a string representation of a vertical type.
"""
if vertical_type == VerticalType.Bottom:
return u'bottom'
elif vertical_type == VerticalType.Middle:
return u'middle'
else:
return u'top'
BOOLEAN_LIST = [u'bold', u'italics', u'override', u'outline', u'shadow', BOOLEAN_LIST = [u'bold', u'italics', u'override', u'outline', u'shadow',
u'slide_transition'] u'slide_transition']

View File

@ -64,12 +64,14 @@ class UiStrings(object):
New = translate('OpenLP.Ui', 'New') New = translate('OpenLP.Ui', 'New')
NewType = unicode(translate('OpenLP.Ui', 'New %s')) NewType = unicode(translate('OpenLP.Ui', 'New %s'))
OLPV2 = translate('OpenLP.Ui', 'OpenLP 2.0') OLPV2 = translate('OpenLP.Ui', 'OpenLP 2.0')
OpenType = unicode(translate('OpenLP.Ui', 'Open %s'))
Preview = translate('OpenLP.Ui', 'Preview') Preview = translate('OpenLP.Ui', 'Preview')
PreviewSelect = unicode(translate('OpenLP.Ui', 'Preview the selected %s.')) PreviewSelect = unicode(translate('OpenLP.Ui', 'Preview the selected %s.'))
ReplaceBG = translate('OpenLP.Ui', 'Replace Background') ReplaceBG = translate('OpenLP.Ui', 'Replace Background')
ReplaceLiveBG = translate('OpenLP.Ui', 'Replace Live Background') ReplaceLiveBG = translate('OpenLP.Ui', 'Replace Live Background')
ResetBG = translate('OpenLP.Ui', 'Reset Background') ResetBG = translate('OpenLP.Ui', 'Reset Background')
ResetLiveBG = translate('OpenLP.Ui', 'Reset Live Background') ResetLiveBG = translate('OpenLP.Ui', 'Reset Live Background')
SaveType = unicode(translate('OpenLP.Ui', 'Save %s'))
SendSelectLive = unicode(translate('OpenLP.Ui', SendSelectLive = unicode(translate('OpenLP.Ui',
'Send the selected %s live.')) 'Send the selected %s live.'))
Service = translate('OpenLP.Ui', 'Service') Service = translate('OpenLP.Ui', 'Service')

View File

@ -65,7 +65,6 @@ class MainDisplay(DisplayWidget):
self.parent = parent self.parent = parent
self.screens = screens self.screens = screens
self.isLive = live self.isLive = live
self.alertTab = None
self.hideMode = None self.hideMode = None
self.override = {} self.override = {}
mainIcon = build_icon(u':/icon/openlp-logo-16x16.png') mainIcon = build_icon(u':/icon/openlp-logo-16x16.png')

View File

@ -324,14 +324,12 @@ class Ui_MainWindow(object):
UiStrings.CreateANew % UiStrings.Service.toLower()) UiStrings.CreateANew % UiStrings.Service.toLower())
self.FileNewItem.setShortcut(translate('OpenLP.MainWindow', 'Ctrl+N')) self.FileNewItem.setShortcut(translate('OpenLP.MainWindow', 'Ctrl+N'))
self.FileOpenItem.setText(translate('OpenLP.MainWindow', '&Open')) self.FileOpenItem.setText(translate('OpenLP.MainWindow', '&Open'))
self.FileOpenItem.setToolTip( self.FileOpenItem.setToolTip(UiStrings.OpenType % UiStrings.Service)
translate('OpenLP.MainWindow', 'Open Service'))
self.FileOpenItem.setStatusTip( self.FileOpenItem.setStatusTip(
translate('OpenLP.MainWindow', 'Open an existing service.')) translate('OpenLP.MainWindow', 'Open an existing service.'))
self.FileOpenItem.setShortcut(translate('OpenLP.MainWindow', 'Ctrl+O')) self.FileOpenItem.setShortcut(translate('OpenLP.MainWindow', 'Ctrl+O'))
self.FileSaveItem.setText(translate('OpenLP.MainWindow', '&Save')) self.FileSaveItem.setText(translate('OpenLP.MainWindow', '&Save'))
self.FileSaveItem.setToolTip( self.FileSaveItem.setToolTip(UiStrings.SaveType % UiStrings.Service)
translate('OpenLP.MainWindow', 'Save Service'))
self.FileSaveItem.setStatusTip( self.FileSaveItem.setStatusTip(
translate('OpenLP.MainWindow', 'Save the current service to disk.')) translate('OpenLP.MainWindow', 'Save the current service to disk.'))
self.FileSaveItem.setShortcut(translate('OpenLP.MainWindow', 'Ctrl+S')) self.FileSaveItem.setShortcut(translate('OpenLP.MainWindow', 'Ctrl+S'))

View File

@ -100,12 +100,12 @@ class ServiceManager(QtGui.QWidget):
UiStrings.CreateANew % UiStrings.Service.toLower(), UiStrings.CreateANew % UiStrings.Service.toLower(),
self.onNewServiceClicked) self.onNewServiceClicked)
self.toolbar.addToolbarButton( self.toolbar.addToolbarButton(
translate('OpenLP.ServiceManager', 'Open Service'), UiStrings.OpenType % UiStrings.Service,
u':/general/general_open.png', u':/general/general_open.png',
translate('OpenLP.ServiceManager', 'Load an existing service'), translate('OpenLP.ServiceManager', 'Load an existing service'),
self.onLoadServiceClicked) self.onLoadServiceClicked)
self.toolbar.addToolbarButton( self.toolbar.addToolbarButton(
translate('OpenLP.ServiceManager', 'Save Service'), UiStrings.SaveType % UiStrings.Service,
u':/general/general_save.png', u':/general/general_save.png',
translate('OpenLP.ServiceManager', 'Save this service'), translate('OpenLP.ServiceManager', 'Save this service'),
self.saveFile) self.saveFile)
@ -465,7 +465,7 @@ class ServiceManager(QtGui.QWidget):
save the file. save the file.
""" """
fileName = unicode(QtGui.QFileDialog.getSaveFileName(self.mainwindow, fileName = unicode(QtGui.QFileDialog.getSaveFileName(self.mainwindow,
translate('OpenLP.ServiceManager', 'Save Service'), UiStrings.SaveType % UiStrings.Service,
SettingsManager.get_last_dir( SettingsManager.get_last_dir(
self.mainwindow.serviceSettingsSection), self.mainwindow.serviceSettingsSection),
translate('OpenLP.ServiceManager', 'OpenLP Service Files (*.osz)'))) translate('OpenLP.ServiceManager', 'OpenLP Service Files (*.osz)')))

View File

@ -415,7 +415,6 @@ class SlideController(QtGui.QWidget):
# rebuild display as screen size changed # rebuild display as screen size changed
self.display = MainDisplay(self, self.screens, self.isLive) self.display = MainDisplay(self, self.screens, self.isLive)
self.display.imageManager = self.parent.renderManager.image_manager self.display.imageManager = self.parent.renderManager.image_manager
self.display.alertTab = self.alertTab
self.display.setup() self.display.setup()
if self.isLive: if self.isLive:
self.__addActionsToWidget(self.display) self.__addActionsToWidget(self.display)

View File

@ -34,7 +34,8 @@ from PyQt4 import QtCore, QtGui
from openlp.core.lib import OpenLPToolbar, ThemeXML, get_text_file_string, \ from openlp.core.lib import OpenLPToolbar, ThemeXML, get_text_file_string, \
build_icon, Receiver, SettingsManager, translate, check_item_selected, \ build_icon, Receiver, SettingsManager, translate, check_item_selected, \
BackgroundType, BackgroundGradientType, check_directory_exists BackgroundType, BackgroundGradientType, check_directory_exists, \
VerticalType
from openlp.core.lib.ui import UiStrings, critical_error_message_box from openlp.core.lib.ui import UiStrings, critical_error_message_box
from openlp.core.theme import Theme from openlp.core.theme import Theme
from openlp.core.ui import FileRenameForm, ThemeForm from openlp.core.ui import FileRenameForm, ThemeForm
@ -762,11 +763,11 @@ class ThemeManager(QtGui.QWidget):
newtheme.font_main_outline = True newtheme.font_main_outline = True
newtheme.font_main_outline_color = \ newtheme.font_main_outline_color = \
unicode(theme.OutlineColor.name()) unicode(theme.OutlineColor.name())
vAlignCorrection = 0 vAlignCorrection = VerticalType.Top
if theme.VerticalAlign == 2: if theme.VerticalAlign == 2:
vAlignCorrection = 1 vAlignCorrection = VerticalType.Middle
elif theme.VerticalAlign == 1: elif theme.VerticalAlign == 1:
vAlignCorrection = 2 vAlignCorrection = VerticalType.Bottom
newtheme.display_horizontal_align = theme.HorizontalAlign newtheme.display_horizontal_align = theme.HorizontalAlign
newtheme.display_vertical_align = vAlignCorrection newtheme.display_vertical_align = vAlignCorrection
return newtheme.extract_xml() return newtheme.extract_xml()

View File

@ -27,11 +27,12 @@
The :mod:``wizard`` module provides generic wizard tools for OpenLP. The :mod:``wizard`` module provides generic wizard tools for OpenLP.
""" """
import logging import logging
import os
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import build_icon, Receiver from openlp.core.lib import build_icon, Receiver, SettingsManager
from openlp.core.lib.ui import add_welcome_page from openlp.core.lib.ui import UiStrings, add_welcome_page
log = logging.getLogger(__name__) log = logging.getLogger(__name__)

View File

@ -40,21 +40,14 @@ class AlertsPlugin(Plugin):
log.info(u'Alerts Plugin loaded') log.info(u'Alerts Plugin loaded')
def __init__(self, plugin_helpers): def __init__(self, plugin_helpers):
Plugin.__init__(self, u'Alerts', u'1.9.4', plugin_helpers) Plugin.__init__(self, u'Alerts', u'1.9.4', plugin_helpers,
settingsTabClass=AlertsTab)
self.weight = -3 self.weight = -3
self.icon = build_icon(u':/plugins/plugin_alerts.png') self.icon = build_icon(u':/plugins/plugin_alerts.png')
self.alertsmanager = AlertsManager(self) self.alertsmanager = AlertsManager(self)
self.manager = Manager(u'alerts', init_schema) self.manager = Manager(u'alerts', init_schema)
self.visible_name = self.getString(StringContent.VisibleName)
self.alertForm = AlertForm(self) self.alertForm = AlertForm(self)
def getSettingsTab(self):
"""
Return the settings tab for the Alerts plugin
"""
self.alertsTab = AlertsTab(self, self.visible_name[u'title'])
return self.alertsTab
def addToolsMenuItem(self, tools_menu): def addToolsMenuItem(self, tools_menu):
""" """
Give the alerts plugin the opportunity to add items to the Give the alerts plugin the opportunity to add items to the
@ -81,7 +74,7 @@ class AlertsPlugin(Plugin):
log.info(u'Alerts Initialising') log.info(u'Alerts Initialising')
Plugin.initialise(self) Plugin.initialise(self)
self.toolsAlertItem.setVisible(True) self.toolsAlertItem.setVisible(True)
self.liveController.alertTab = self.alertsTab self.liveController.alertTab = self.settings_tab
def finalise(self): def finalise(self):
""" """

View File

@ -84,7 +84,7 @@ class AlertsManager(QtCore.QObject):
if len(self.alertList) == 0: if len(self.alertList) == 0:
return return
text = self.alertList.pop(0) text = self.alertList.pop(0)
alertTab = self.parent.alertsTab alertTab = self.parent.settings_tab
self.parent.liveController.display.alert(text) self.parent.liveController.display.alert(text)
# Check to see if we have a timer running. # Check to see if we have a timer running.
if self.timer_id == 0: if self.timer_id == 0:
@ -103,4 +103,4 @@ class AlertsManager(QtCore.QObject):
self.parent.liveController.display.alert(u'') self.parent.liveController.display.alert(u'')
self.killTimer(self.timer_id) self.killTimer(self.timer_id)
self.timer_id = 0 self.timer_id = 0
self.generateAlert() self.generateAlert()

View File

@ -33,10 +33,8 @@ class AlertsTab(SettingsTab):
""" """
AlertsTab is the alerts settings tab in the settings dialog. AlertsTab is the alerts settings tab in the settings dialog.
""" """
def __init__(self, parent, visible_title): def __init__(self, name, visible_title):
self.parent = parent SettingsTab.__init__(self, name, visible_title)
self.manager = parent.manager
SettingsTab.__init__(self, parent.name, visible_title)
def setupUi(self): def setupUi(self):
self.setObjectName(u'AlertsTab') self.setObjectName(u'AlertsTab')

View File

@ -38,7 +38,8 @@ class BiblePlugin(Plugin):
log.info(u'Bible Plugin loaded') log.info(u'Bible Plugin loaded')
def __init__(self, plugin_helpers): def __init__(self, plugin_helpers):
Plugin.__init__(self, u'Bibles', u'1.9.4', plugin_helpers) Plugin.__init__(self, u'Bibles', u'1.9.4', plugin_helpers,
BibleMediaItem, BiblesTab)
self.weight = -9 self.weight = -9
self.icon_path = u':/plugins/plugin_bibles.png' self.icon_path = u':/plugins/plugin_bibles.png'
self.icon = build_icon(self.icon_path) self.icon = build_icon(self.icon_path)
@ -62,14 +63,6 @@ class BiblePlugin(Plugin):
self.importBibleItem.setVisible(False) self.importBibleItem.setVisible(False)
self.exportBibleItem.setVisible(False) self.exportBibleItem.setVisible(False)
def getSettingsTab(self):
visible_name = self.getString(StringContent.VisibleName)
return BiblesTab(self.name, visible_name[u'title'])
def getMediaManagerItem(self):
# Create the BibleManagerItem object.
return BibleMediaItem(self, self, self.icon)
def addImportMenuItem(self, import_menu): def addImportMenuItem(self, import_menu):
self.importBibleItem = QtGui.QAction(import_menu) self.importBibleItem = QtGui.QAction(import_menu)
self.importBibleItem.setObjectName(u'importBibleItem') self.importBibleItem.setObjectName(u'importBibleItem')

View File

@ -33,9 +33,9 @@ import os.path
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import Receiver, SettingsManager, translate from openlp.core.lib import Receiver, translate
from openlp.core.lib.db import delete_database from openlp.core.lib.db import delete_database
from openlp.core.lib.ui import UiStrings, critical_error_message_box from openlp.core.lib.ui import critical_error_message_box
from openlp.core.ui.wizard import OpenLPWizard from openlp.core.ui.wizard import OpenLPWizard
from openlp.core.utils import AppLocation, string_is_unicode from openlp.core.utils import AppLocation, string_is_unicode
from openlp.plugins.bibles.lib.manager import BibleFormat from openlp.plugins.bibles.lib.manager import BibleFormat

View File

@ -48,21 +48,14 @@ class CustomPlugin(Plugin):
log.info(u'Custom Plugin loaded') log.info(u'Custom Plugin loaded')
def __init__(self, plugin_helpers): def __init__(self, plugin_helpers):
Plugin.__init__(self, u'Custom', u'1.9.4', plugin_helpers) Plugin.__init__(self, u'Custom', u'1.9.4', plugin_helpers,
CustomMediaItem, CustomTab)
self.weight = -5 self.weight = -5
self.manager = Manager(u'custom', init_schema) self.manager = Manager(u'custom', init_schema)
self.edit_custom_form = EditCustomForm(self.manager) self.edit_custom_form = EditCustomForm(self.manager)
self.icon_path = u':/plugins/plugin_custom.png' self.icon_path = u':/plugins/plugin_custom.png'
self.icon = build_icon(self.icon_path) self.icon = build_icon(self.icon_path)
def getSettingsTab(self):
visible_name = self.getString(StringContent.VisibleName)
return CustomTab(self.name, visible_name[u'title'])
def getMediaManagerItem(self):
# Create the ManagerItem object
return CustomMediaItem(self, self, self.icon)
def about(self): def about(self):
about_text = translate('CustomPlugin', '<strong>Custom Plugin</strong>' about_text = translate('CustomPlugin', '<strong>Custom Plugin</strong>'
'<br />The custom plugin provides the ability to set up custom ' '<br />The custom plugin provides the ability to set up custom '

View File

@ -35,15 +35,12 @@ class ImagePlugin(Plugin):
log.info(u'Image Plugin loaded') log.info(u'Image Plugin loaded')
def __init__(self, plugin_helpers): def __init__(self, plugin_helpers):
Plugin.__init__(self, u'Images', u'1.9.4', plugin_helpers) Plugin.__init__(self, u'Images', u'1.9.4', plugin_helpers,
ImageMediaItem)
self.weight = -7 self.weight = -7
self.icon_path = u':/plugins/plugin_images.png' self.icon_path = u':/plugins/plugin_images.png'
self.icon = build_icon(self.icon_path) self.icon = build_icon(self.icon_path)
def getMediaManagerItem(self):
# Create the MediaManagerItem object.
return ImageMediaItem(self, self, self.icon)
def about(self): def about(self):
about_text = translate('ImagePlugin', '<strong>Image Plugin</strong>' about_text = translate('ImagePlugin', '<strong>Image Plugin</strong>'
'<br />The image plugin provides displaying of images.<br />One ' '<br />The image plugin provides displaying of images.<br />One '

View File

@ -138,6 +138,7 @@ class MediaMediaItem(MediaManagerItem):
return False return False
def initialise(self): def initialise(self):
self.listView.clear()
self.listView.setIconSize(QtCore.QSize(88, 50)) self.listView.setIconSize(QtCore.QSize(88, 50))
self.loadList(SettingsManager.load_list(self.settingsSection, self.loadList(SettingsManager.load_list(self.settingsSection,
self.settingsSection)) self.settingsSection))

View File

@ -32,8 +32,8 @@ class MediaTab(SettingsTab):
""" """
MediaTab is the Media settings tab in the settings dialog. MediaTab is the Media settings tab in the settings dialog.
""" """
def __init__(self, title): def __init__(self, title, visible_title):
SettingsTab.__init__(self, title) SettingsTab.__init__(self, title, visible_title)
def setupUi(self): def setupUi(self):
self.setObjectName(u'MediaTab') self.setObjectName(u'MediaTab')
@ -53,9 +53,8 @@ class MediaTab(SettingsTab):
self.onUsePhononCheckBoxChanged) self.onUsePhononCheckBoxChanged)
def retranslateUi(self): def retranslateUi(self):
self.tabTitleVisible = translate('MediaPlugin.MediaTab', 'Media') self.mediaModeGroupBox.setTitle(
self.mediaModeGroupBox.setTitle(translate('MediaPlugin.MediaTab', translate('MediaPlugin.MediaTab', 'Media Display'))
'Media Display'))
self.usePhononCheckBox.setText( self.usePhononCheckBox.setText(
translate('MediaPlugin.MediaTab', 'Use Phonon for video playback')) translate('MediaPlugin.MediaTab', 'Use Phonon for video playback'))

View File

@ -38,7 +38,8 @@ class MediaPlugin(Plugin):
log.info(u'%s MediaPlugin loaded', __name__) log.info(u'%s MediaPlugin loaded', __name__)
def __init__(self, plugin_helpers): def __init__(self, plugin_helpers):
Plugin.__init__(self, u'Media', u'1.9.4', plugin_helpers) Plugin.__init__(self, u'Media', u'1.9.4', plugin_helpers,
MediaMediaItem, MediaTab)
self.weight = -6 self.weight = -6
self.icon_path = u':/plugins/plugin_media.png' self.icon_path = u':/plugins/plugin_media.png'
self.icon = build_icon(self.icon_path) self.icon = build_icon(self.icon_path)
@ -75,13 +76,6 @@ class MediaPlugin(Plugin):
mimetype = u'' mimetype = u''
return list, mimetype return list, mimetype
def getSettingsTab(self):
return MediaTab(self.name)
def getMediaManagerItem(self):
# Create the MediaManagerItem object.
return MediaMediaItem(self, self, self.icon)
def about(self): def about(self):
about_text = translate('MediaPlugin', '<strong>Media Plugin</strong>' about_text = translate('MediaPlugin', '<strong>Media Plugin</strong>'
'<br />The media plugin provides playback of audio and video.') '<br />The media plugin provides playback of audio and video.')

View File

@ -38,7 +38,8 @@ class RemotesPlugin(Plugin):
""" """
remotes constructor remotes constructor
""" """
Plugin.__init__(self, u'Remotes', u'1.9.4', plugin_helpers) Plugin.__init__(self, u'Remotes', u'1.9.4', plugin_helpers,
settingsTabClass=RemoteTab)
self.icon = build_icon(u':/plugins/plugin_remote.png') self.icon = build_icon(u':/plugins/plugin_remote.png')
self.weight = -1 self.weight = -1
self.server = None self.server = None
@ -61,13 +62,6 @@ class RemotesPlugin(Plugin):
if self.server: if self.server:
self.server.close() self.server.close()
def getSettingsTab(self):
"""
Create the settings Tab
"""
visible_name = self.getString(StringContent.VisibleName)
return RemoteTab(self.name, visible_name[u'title'])
def about(self): def about(self):
""" """
Information about this plugin Information about this plugin

View File

@ -51,17 +51,14 @@ class SongsPlugin(Plugin):
""" """
Create and set up the Songs plugin. Create and set up the Songs plugin.
""" """
Plugin.__init__(self, u'Songs', u'1.9.4', plugin_helpers) Plugin.__init__(self, u'Songs', u'1.9.4', plugin_helpers,
SongMediaItem, SongsTab)
self.weight = -10 self.weight = -10
self.manager = Manager(u'songs', init_schema) self.manager = Manager(u'songs', init_schema)
self.icon_path = u':/plugins/plugin_songs.png' self.icon_path = u':/plugins/plugin_songs.png'
self.icon = build_icon(self.icon_path) self.icon = build_icon(self.icon_path)
self.whitespace = re.compile(r'\W+', re.UNICODE) self.whitespace = re.compile(r'\W+', re.UNICODE)
def getSettingsTab(self):
visible_name = self.getString(StringContent.VisibleName)
return SongsTab(self.name, visible_name[u'title'])
def initialise(self): def initialise(self):
log.info(u'Songs Initialising') log.info(u'Songs Initialising')
Plugin.initialise(self) Plugin.initialise(self)
@ -69,13 +66,6 @@ class SongsPlugin(Plugin):
self.mediaItem.displayResultsSong( self.mediaItem.displayResultsSong(
self.manager.get_all_objects(Song, order_by_ref=Song.search_title)) self.manager.get_all_objects(Song, order_by_ref=Song.search_title))
def getMediaManagerItem(self):
"""
Create the MediaManagerItem object, which is displaed in the
Media Manager.
"""
return SongMediaItem(self, self, self.icon)
def addImportMenuItem(self, import_menu): def addImportMenuItem(self, import_menu):
""" """
Give the Songs plugin the opportunity to add items to the Give the Songs plugin the opportunity to add items to the