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