forked from openlp/openlp
Add start of tab and update poll
This commit is contained in:
parent
caacb7df88
commit
a1f9029d25
|
@ -46,7 +46,9 @@ class Poller(RegistryProperties):
|
|||
'display': self.live_controller.desktop_screen.isChecked(),
|
||||
'version': 3,
|
||||
'isSecure': Settings().value('api/authentication enabled'),
|
||||
'isAuthorised': False
|
||||
'isAuthorised': False,
|
||||
'isStagedActive': self.plugin_manager.get_plugin_by_name('remotes').is_stage_active(),
|
||||
'isLiveActive': self.plugin_manager.get_plugin_by_name('remotes').is_live_active()
|
||||
}
|
||||
|
||||
def poll(self):
|
||||
|
|
|
@ -215,6 +215,7 @@ def url_get_file(callback, url, f_path, sha256=None):
|
|||
block_count = 0
|
||||
block_size = 4096
|
||||
retries = 0
|
||||
log.debug("url_get_file: " + url)
|
||||
while True:
|
||||
try:
|
||||
filename = open(f_path, "wb")
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2016 OpenLP Developers #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# 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 #
|
||||
###############################################################################
|
||||
|
||||
from .remotestab import RemotesTab
|
|
@ -0,0 +1,108 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2016 OpenLP Developers #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# 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 #
|
||||
###############################################################################
|
||||
|
||||
from PyQt5 import QtGui, QtWidgets
|
||||
|
||||
from openlp.core.common import Settings, UiStrings, translate
|
||||
from openlp.core.lib import SettingsTab
|
||||
from openlp.core.lib.ui import create_valign_selection_widgets
|
||||
from openlp.core.ui.lib.colorbutton import ColorButton
|
||||
|
||||
|
||||
class RemotesTab(SettingsTab):
|
||||
"""
|
||||
Remotes is the alerts settings tab in the settings dialog.
|
||||
"""
|
||||
def __init__(self, parent, name, visible_title, icon_path):
|
||||
super(RemotesTab, self).__init__(parent, name, visible_title, icon_path)
|
||||
|
||||
def setupUi(self):
|
||||
self.setObjectName('Remotes')
|
||||
super(RemotesTab, self).setupUi()
|
||||
self.web_group_box = QtWidgets.QGroupBox(self.left_column)
|
||||
self.web_group_box.setObjectName('web_group_box')
|
||||
self.web_layout = QtWidgets.QFormLayout(self.web_group_box)
|
||||
self.web_layout.setObjectName('web_layout')
|
||||
|
||||
self.web_color_label = QtWidgets.QLabel(self.web_group_box)
|
||||
self.web_color_label.setObjectName('font_color_label')
|
||||
self.color_layout = QtWidgets.QHBoxLayout()
|
||||
self.color_layout.setObjectName('color_layout')
|
||||
self.web_color_button = ColorButton(self.web_group_box)
|
||||
self.web_color_button.setObjectName('font_color_button')
|
||||
self.color_layout.addWidget(self.web_color_button)
|
||||
self.color_layout.addSpacing(20)
|
||||
|
||||
self.left_layout.addWidget(self.web_group_box)
|
||||
self.left_layout.addStretch()
|
||||
# Signals and slots
|
||||
#self.background_color_button.colorChanged.connect(self.on_background_color_changed)
|
||||
#self.web_color_button.colorChanged.connect(self.on_font_color_changed)
|
||||
#self.web_combo_box.activated.connect(self.on_font_combo_box_clicked)
|
||||
|
||||
def retranslateUi(self):
|
||||
self.web_group_box.setTitle(translate('RemotePlugin.Interface', 'Web Interface'))
|
||||
#self.web_label.setText(translate('RemotePlugin.Remotes', 'Font name:'))
|
||||
self.web_color_label.setText(translate('AlertsPlugin.Remotes', 'Font color:'))
|
||||
#self.background_color_label.setText(UiStrings().BackgroundColorColon)
|
||||
|
||||
def load(self):
|
||||
"""
|
||||
Load the settings into the UI.
|
||||
"""
|
||||
pass
|
||||
|
||||
def save(self):
|
||||
"""
|
||||
Save the changes on exit of the Settings dialog.
|
||||
"""
|
||||
settings = Settings()
|
||||
settings.beginGroup(self.settings_section)
|
||||
# Check value has changed as no event handles this field
|
||||
if settings.value('location') != self.vertical_combo_box.currentIndex():
|
||||
self.changed = True
|
||||
settings.setValue('background color', self.background_color)
|
||||
settings.setValue('font color', self.web_color)
|
||||
settings.setValue('font size', self.web_size)
|
||||
self.web_face = self.web_combo_box.currentFont().family()
|
||||
settings.setValue('font face', self.web_face)
|
||||
settings.setValue('timeout', self.timeout)
|
||||
self.location = self.vertical_combo_box.currentIndex()
|
||||
settings.setValue('location', self.location)
|
||||
settings.endGroup()
|
||||
if self.changed:
|
||||
self.settings_form.register_post_process('update_display_css')
|
||||
self.plugin_manager.get_plugin_by_name('remotes').reset_cache()
|
||||
self.changed = False
|
||||
|
||||
def update_display(self):
|
||||
"""
|
||||
Update the preview display after changes have been made,
|
||||
"""
|
||||
font = QtGui.QFont()
|
||||
font.setFamily(self.web_combo_box.currentFont().family())
|
||||
font.setBold(True)
|
||||
font.setPointSize(self.web_size)
|
||||
self.web_preview.setFont(font)
|
||||
self.web_preview.setStyleSheet('background-color: {back}; color: {front}'.format(back=self.background_color,
|
||||
front=self.web_color))
|
||||
self.changed = True
|
|
@ -24,7 +24,9 @@ import logging
|
|||
|
||||
from openlp.core.api.http import register_endpoint
|
||||
from openlp.core.common import OpenLPMixin
|
||||
from openlp.core.common.httputils import get_web_page
|
||||
from openlp.core.lib import Plugin, StringContent, translate, build_icon
|
||||
from openlp.plugins.remotes.lib import RemotesTab
|
||||
from openlp.plugins.remotes.endpoint import remote_endpoint
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
@ -37,10 +39,12 @@ class RemotesPlugin(Plugin, OpenLPMixin):
|
|||
"""
|
||||
remotes constructor
|
||||
"""
|
||||
super(RemotesPlugin, self).__init__('remotes', {})
|
||||
super(RemotesPlugin, self).__init__('remotes', {}, settings_tab_class=RemotesTab)
|
||||
self.icon_path = ':/plugins/plugin_remote.png'
|
||||
self.icon = build_icon(self.icon_path)
|
||||
self.weight = -1
|
||||
self.live_cache = None
|
||||
self.stage_cache = None
|
||||
register_endpoint(remote_endpoint)
|
||||
|
||||
@staticmethod
|
||||
|
@ -48,9 +52,10 @@ class RemotesPlugin(Plugin, OpenLPMixin):
|
|||
"""
|
||||
Information about this plugin
|
||||
"""
|
||||
about_text = translate('RemotePlugin', '<strong>Remote Plugin</strong>'
|
||||
'<br />The remote plugin provides the ability develop web based '
|
||||
'interfaces using openlp web services')
|
||||
about_text = translate('RemotePlugin', '<strong>Web Interface</strong>'
|
||||
'<br />The web interface plugin provides the ability develop web based '
|
||||
'interfaces using openlp web services. \nPredefined interfaces can be '
|
||||
'download as well as custom developed interfaces')
|
||||
return about_text
|
||||
|
||||
def set_plugin_text_strings(self):
|
||||
|
@ -59,10 +64,50 @@ class RemotesPlugin(Plugin, OpenLPMixin):
|
|||
"""
|
||||
# Name PluginList
|
||||
self.text_strings[StringContent.Name] = {
|
||||
'singular': translate('RemotePlugin', 'Remote', 'name singular'),
|
||||
'plural': translate('RemotePlugin', 'Remotes', 'name plural')
|
||||
'singular': translate('RemotePlugin', 'Web Interface', 'name singular'),
|
||||
'plural': translate('RemotePlugin', 'Web Interface', 'name plural')
|
||||
}
|
||||
# Name for MediaDockManager, SettingsManager
|
||||
self.text_strings[StringContent.VisibleName] = {
|
||||
'title': translate('RemotePlugin', 'Remote', 'container title')
|
||||
'title': translate('RemotePlugin', 'Web Remote', 'container title')
|
||||
}
|
||||
|
||||
def reset_cache(self):
|
||||
"""
|
||||
Reset the caches as the web has changed
|
||||
:return:
|
||||
"""
|
||||
self.stage_cache = None
|
||||
self.live_cache = None
|
||||
|
||||
def is_stage_active(self):
|
||||
"""
|
||||
Is stage active - call it and see buy only once
|
||||
:return: if stage is active or not
|
||||
"""
|
||||
if self.stage_cache is None:
|
||||
try:
|
||||
page = get_web_page("http://localhost:4316/stage")
|
||||
except:
|
||||
page = None
|
||||
if page:
|
||||
self.stage_cache = True
|
||||
else:
|
||||
self.stage_cache = False
|
||||
return self.stage_cache
|
||||
|
||||
def is_live_active(self):
|
||||
"""
|
||||
Is main active - call it and see buy only once
|
||||
:return: if stage is active or not
|
||||
"""
|
||||
if self.live_cache is None:
|
||||
try:
|
||||
page = get_web_page("http://localhost:4316/main")
|
||||
except:
|
||||
page = None
|
||||
if page:
|
||||
self.live_cache = True
|
||||
else:
|
||||
self.live_cache = False
|
||||
return self.live_cache
|
||||
|
|
Loading…
Reference in New Issue