4
4
###############################################################################
5
5
# OpenLP - Open Source Lyrics Projection #
6
6
# --------------------------------------------------------------------------- #
7
# Copyright (c) 2008-2018 OpenLP Developers #
7
# Copyright (c) 2008-2019 OpenLP Developers #
8
8
# --------------------------------------------------------------------------- #
9
9
# This program is free software; you can redistribute it and/or modify it #
10
10
# under the terms of the GNU General Public License as published by the Free #
27
27
from PyQt5 import QtCore, QtWidgets
29
from openlp.core.state import State
29
30
from openlp.core.common.i18n import translate
30
31
from openlp.core.common.mixins import RegistryProperties
31
from openlp.core.lib import PluginStatus
32
from openlp.core.lib.plugin import PluginStatus
32
33
from openlp.core.ui.plugindialog import Ui_PluginViewDialog
34
36
log = logging.getLogger(__name__)
45
47
super(PluginForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint |
46
48
QtCore.Qt.WindowCloseButtonHint)
47
49
self.active_plugin = None
48
self.programatic_change = False
50
self.programmatic_change = False
51
53
self._clear_details()
52
54
# Right, now let's put some signals and slots together!
58
60
Load the plugin details into the screen
60
62
self.plugin_list_widget.clear()
61
self.programatic_change = True
63
self.programmatic_change = True
62
64
self._clear_details()
63
self.programatic_change = True
65
self.programmatic_change = True
64
66
plugin_list_width = 0
65
for plugin in self.plugin_manager.plugins:
66
item = QtWidgets.QListWidgetItem(self.plugin_list_widget)
67
# We do this just to make 100% sure the status is an integer as
68
# sometimes when it's loaded from the config, it isn't cast to int.
69
plugin.status = int(plugin.status)
70
# Set the little status text in brackets next to the plugin name.
71
if plugin.status == PluginStatus.Disabled:
72
status_text = translate('OpenLP.PluginForm', '{name} (Disabled)')
73
elif plugin.status == PluginStatus.Active:
74
status_text = translate('OpenLP.PluginForm', '{name} (Active)')
76
# PluginStatus.Inactive
77
status_text = translate('OpenLP.PluginForm', '{name} (Inactive)')
78
item.setText(status_text.format(name=plugin.name_strings['singular']))
79
# If the plugin has an icon, set it!
81
item.setIcon(plugin.icon)
82
self.plugin_list_widget.addItem(item)
83
plugin_list_width = max(plugin_list_width, self.fontMetrics().width(
84
translate('OpenLP.PluginForm', '{name} (Inactive)').format(name=plugin.name_strings['singular'])))
67
for plugin in State().list_plugins():
69
item = QtWidgets.QListWidgetItem(self.plugin_list_widget)
70
# We do this just to make 100% sure the status is an integer as
71
# sometimes when it's loaded from the config, it isn't cast to int.
72
plugin.status = int(plugin.status)
73
# Set the little status text in brackets next to the plugin name.
74
if plugin.status == PluginStatus.Disabled:
75
status_text = translate('OpenLP.PluginForm', '{name} (Disabled)')
76
elif plugin.status == PluginStatus.Active:
77
status_text = translate('OpenLP.PluginForm', '{name} (Active)')
79
# PluginStatus.Inactive
80
status_text = translate('OpenLP.PluginForm', '{name} (Inactive)')
81
item.setText(status_text.format(name=plugin.name_strings['singular']))
82
# If the plugin has an icon, set it!
84
item.setIcon(plugin.icon)
85
self.plugin_list_widget.addItem(item)
86
plugin_list_width = max(plugin_list_width, self.fontMetrics().width(
87
translate('OpenLP.PluginForm', '{name} (Inactive)').format(name=plugin.name_strings['singular'])))
85
88
self.plugin_list_widget.setFixedWidth(plugin_list_width + self.plugin_list_widget.iconSize().width() + 48)
87
90
def _clear_details(self):
99
102
log.debug('PluginStatus: {status}'.format(status=str(self.active_plugin.status)))
100
103
self.about_text_browser.setHtml(self.active_plugin.about())
101
self.programatic_change = True
104
self.programmatic_change = True
102
105
if self.active_plugin.status != PluginStatus.Disabled:
103
106
self.status_checkbox.setChecked(self.active_plugin.status == PluginStatus.Active)
104
107
self.status_checkbox.setEnabled(True)
106
109
self.status_checkbox.setChecked(False)
107
110
self.status_checkbox.setEnabled(False)
108
self.programatic_change = False
111
self.programmatic_change = False
110
113
def on_plugin_list_widget_selection_changed(self):