forked from openlp/openlp
update browser if slide changes
This commit is contained in:
parent
970d66d4ad
commit
72fa923937
@ -65,11 +65,23 @@ class EventReceiver(QtCore.QObject):
|
||||
``slidecontroller_{live|preview}_last``
|
||||
Moves to the last slide
|
||||
|
||||
``slidecontroller_{live|preview}_set``
|
||||
Moves to a specific slide, by index
|
||||
|
||||
``slidecontroller_{live|preview}_started``
|
||||
Broadcasts that an item has been made live/previewed
|
||||
|
||||
``slidecontroller_{live|preview}_change``
|
||||
Informs the slidecontroller that a slide change has occurred
|
||||
Informs the slidecontroller that a slide change has occurred and to
|
||||
update itself
|
||||
|
||||
``slidecontroller_{live|preview}_changed``
|
||||
Broadcasts that the slidecontroller has changed the current slide
|
||||
|
||||
``slidecontroller_{live|preview}_text_request``
|
||||
Request the text for the current item in the controller
|
||||
Returns a slidecontroller_{live|preview}_text_response with an
|
||||
array of dictionaries with the tag and verse text
|
||||
|
||||
``slidecontroller_live_spin_delay``
|
||||
Pushes out the loop delay
|
||||
@ -77,9 +89,19 @@ class EventReceiver(QtCore.QObject):
|
||||
``slidecontroller_live_stop_loop``
|
||||
Stop the loop on the main display
|
||||
|
||||
``servicecontroller_next_item``
|
||||
``servicemanager_previous_item``
|
||||
Display the previous item in the service
|
||||
|
||||
``servicemanager_next_item``
|
||||
Display the next item in the service
|
||||
|
||||
``servicemanager_set_item``
|
||||
Go live on a specific item, by index
|
||||
|
||||
``servicemanager_list_request``
|
||||
Request the service list. Responds with servicemanager_list_response
|
||||
containing a array of dictionaries
|
||||
|
||||
``maindisplay_blank``
|
||||
Blank the maindisplay window
|
||||
|
||||
|
@ -565,9 +565,7 @@ class SlideController(QtGui.QWidget):
|
||||
self.enableToolBar(serviceItem)
|
||||
self.onSlideSelected()
|
||||
self.PreviewListWidget.setFocus()
|
||||
Receiver.send_message(u'%s_%s_started' %
|
||||
(self.serviceItem.name.lower(),
|
||||
'live' if self.isLive else 'preview'),
|
||||
Receiver.send_message(u'slidecontroller_%s_started' % self.type_prefix,
|
||||
[serviceItem])
|
||||
log.log(15, u'Display Rendering took %4s' % (time.time() - before))
|
||||
|
||||
@ -576,6 +574,7 @@ class SlideController(QtGui.QWidget):
|
||||
Return the text for the current item in controller
|
||||
"""
|
||||
data = []
|
||||
if self.serviceItem:
|
||||
for framenumber, frame in enumerate(self.serviceItem.get_frames()):
|
||||
data_item = {}
|
||||
if self.serviceItem.is_text():
|
||||
@ -587,8 +586,8 @@ class SlideController(QtGui.QWidget):
|
||||
data_item[u'selected'] = \
|
||||
(self.PreviewListWidget.currentRow() == framenumber)
|
||||
data.append(data_item)
|
||||
Receiver.send_message(u'slidecontroller_%s_text_response' % self.type_prefix,
|
||||
data)
|
||||
Receiver.send_message(u'slidecontroller_%s_text_response'
|
||||
% self.type_prefix, data)
|
||||
|
||||
#Screen event methods
|
||||
def onSlideSelectedFirst(self):
|
||||
@ -699,6 +698,8 @@ class SlideController(QtGui.QWidget):
|
||||
if self.isLive:
|
||||
self.mainDisplay.frameView(frame, True)
|
||||
self.selectedRow = row
|
||||
Receiver.send_message(u'slidecontroller_%s_changed' % self.type_prefix,
|
||||
row)
|
||||
|
||||
def onSlideChange(self, row):
|
||||
"""
|
||||
@ -706,6 +707,8 @@ class SlideController(QtGui.QWidget):
|
||||
"""
|
||||
self.PreviewListWidget.selectRow(row)
|
||||
self.updatePreview()
|
||||
Receiver.send_message(u'slidecontroller_%s_changed' % self.type_prefix,
|
||||
row)
|
||||
|
||||
def updatePreview(self):
|
||||
rm = self.parent.RenderManager
|
||||
|
@ -43,6 +43,8 @@ class HttpServer(object):
|
||||
log.debug(u'Initialise httpserver')
|
||||
self.parent = parent
|
||||
self.connections = []
|
||||
self.current_item = None
|
||||
self.current_slide = None
|
||||
self.start_tcp()
|
||||
|
||||
def start_tcp(self):
|
||||
@ -53,10 +55,29 @@ class HttpServer(object):
|
||||
self.server = QtNetwork.QTcpServer()
|
||||
self.server.listen(QtNetwork.QHostAddress(QtNetwork.QHostAddress.Any),
|
||||
port)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'slidecontroller_live_changed'),
|
||||
self.slide_change)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'slidecontroller_live_started'),
|
||||
self.item_change)
|
||||
QtCore.QObject.connect(self.server,
|
||||
QtCore.SIGNAL(u'newConnection()'), self.new_connection)
|
||||
log.debug(u'TCP listening on port %d' % port)
|
||||
|
||||
def slide_change(self, row):
|
||||
self.current_slide = row
|
||||
self.send_poll()
|
||||
|
||||
def item_change(self, items):
|
||||
self.current_item = items[0].title
|
||||
self.send_poll()
|
||||
|
||||
def send_poll(self):
|
||||
Receiver.send_message(u'remote_poll_response',
|
||||
{'slide': self.current_slide,
|
||||
'item': self.current_item})
|
||||
|
||||
def new_connection(self):
|
||||
log.debug(u'new http connection')
|
||||
socket = self.server.nextPendingConnection()
|
||||
@ -121,8 +142,8 @@ class HttpConnection(object):
|
||||
function send_event(eventname, data){
|
||||
var req = new XMLHttpRequest();
|
||||
req.onreadystatechange = function() {
|
||||
if(req.readyState==4 && req.status==200)
|
||||
response(eventname, req.responseText);
|
||||
if(req.readyState==4)
|
||||
response(eventname, req);
|
||||
}
|
||||
var url = '';
|
||||
if(eventname.substr(-8) == '_request')
|
||||
@ -135,7 +156,20 @@ function send_event(eventname, data){
|
||||
req.open('GET', url, true);
|
||||
req.send();
|
||||
}
|
||||
function response(eventname, text){
|
||||
function failed_response(eventname, req){
|
||||
switch(eventname){
|
||||
case 'remote_poll_request':
|
||||
if(req.status==408)
|
||||
send_event("remote_poll_request");
|
||||
break;
|
||||
}
|
||||
}
|
||||
function response(eventname, req){
|
||||
if(req.status!=200){
|
||||
failed_response(eventname, req);
|
||||
return;
|
||||
}
|
||||
text = req.responseText;
|
||||
switch(eventname){
|
||||
case 'servicemanager_list_request':
|
||||
var data = eval('(' + text + ')');
|
||||
@ -155,11 +189,6 @@ function response(eventname, text){
|
||||
html += '</table>';
|
||||
document.getElementById('service').innerHTML = html;
|
||||
break;
|
||||
case 'servicemanager_previous_item':
|
||||
case 'servicemanager_next_item':
|
||||
case 'servicemanager_set_item':
|
||||
send_event("servicemanager_list_request");
|
||||
break;
|
||||
case 'slidecontroller_live_text_request':
|
||||
var data = eval('(' + text + ')');
|
||||
var html = '<table>';
|
||||
@ -168,23 +197,24 @@ function response(eventname, text){
|
||||
html += "'slidecontroller_live_set', " + row + ')"';
|
||||
if(data[row]['selected'])
|
||||
html += ' style="font-weight: bold"';
|
||||
html += '>'
|
||||
html += '<td>' + data[row]['tag'] + '</td>'
|
||||
html += '<td>' + data[row]['text'] + '</td>'
|
||||
html += '</tr>';
|
||||
html += '>';
|
||||
html += '<td>' + data[row]['tag'] + '</td>';
|
||||
html += '<td>' + data[row]['text'].replace(/\\n/g, '<br>');
|
||||
html += '</td></tr>';
|
||||
}
|
||||
html += '</table>';
|
||||
document.getElementById('currentitem').innerHTML = html;
|
||||
break;
|
||||
case 'slidecontroller_live_next':
|
||||
case 'slidecontroller_live_previous':
|
||||
case 'slidecontroller_live_set':
|
||||
case 'remote_poll_request':
|
||||
send_event("remote_poll_request");
|
||||
send_event("servicemanager_list_request");
|
||||
send_event("slidecontroller_live_text_request");
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
send_event("servicemanager_list_request");
|
||||
send_event("slidecontroller_live_text_request");
|
||||
send_event("remote_poll_request");
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
@ -239,6 +269,9 @@ send_event("servicemanager_list_request");
|
||||
self.timer.setSingleShot(True)
|
||||
QtCore.QObject.connect(self.timer,
|
||||
QtCore.SIGNAL(u'timeout()'), self.timeout)
|
||||
if event == 'remote_poll_request':
|
||||
self.timer.start(60000)
|
||||
else:
|
||||
self.timer.start(10000)
|
||||
if params:
|
||||
Receiver.send_message(event, params)
|
||||
|
@ -108,7 +108,7 @@ class SongUsagePlugin(Plugin):
|
||||
log.info(u'SongUsage Initialising')
|
||||
Plugin.initialise(self)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'slidecontroller_live_started'),
|
||||
QtCore.SIGNAL(u'songs_live_started'),
|
||||
self.onReceiveSongUsage)
|
||||
self.SongUsageActive = QtCore.QSettings().value(
|
||||
self.settings_section + u'/active',
|
||||
|
Loading…
Reference in New Issue
Block a user