forked from openlp/openlp
Show service and song text. Click on service item/song verse to go live
This commit is contained in:
parent
3d6dc75c23
commit
f4cc91f529
@ -191,6 +191,8 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
QtCore.SIGNAL(u'servicemanager_next_item'), self.nextItem)
|
QtCore.SIGNAL(u'servicemanager_next_item'), self.nextItem)
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||||
QtCore.SIGNAL(u'servicemanager_previous_item'), self.previousItem)
|
QtCore.SIGNAL(u'servicemanager_previous_item'), self.previousItem)
|
||||||
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||||
|
QtCore.SIGNAL(u'servicemanager_set_item'), self.onSetItem)
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||||
QtCore.SIGNAL(u'servicemanager_list_request'), self.listRequest)
|
QtCore.SIGNAL(u'servicemanager_list_request'), self.listRequest)
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||||
@ -315,6 +317,21 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
prevItem = serviceIterator.value()
|
prevItem = serviceIterator.value()
|
||||||
serviceIterator += 1
|
serviceIterator += 1
|
||||||
|
|
||||||
|
def onSetItem(self, message):
|
||||||
|
"""
|
||||||
|
Called by a signal to select a specific item
|
||||||
|
"""
|
||||||
|
self.setItem(int(message[0]))
|
||||||
|
|
||||||
|
def setItem(self, index):
|
||||||
|
"""
|
||||||
|
Makes a specific item in the service live
|
||||||
|
"""
|
||||||
|
if index >= 0 and index < self.ServiceManagerList.topLevelItemCount:
|
||||||
|
item = self.ServiceManagerList.topLevelItem(index)
|
||||||
|
self.ServiceManagerList.setCurrentItem(item)
|
||||||
|
self.makeLive()
|
||||||
|
|
||||||
def onMoveSelectionUp(self):
|
def onMoveSelectionUp(self):
|
||||||
"""
|
"""
|
||||||
Moves the selection up the window
|
Moves the selection up the window
|
||||||
@ -877,7 +894,17 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
|
|
||||||
def listRequest(self, message=None):
|
def listRequest(self, message=None):
|
||||||
data = []
|
data = []
|
||||||
|
curindex, count = self.findServiceItem()
|
||||||
|
if curindex >= 0 and curindex < len(self.serviceItems):
|
||||||
|
curitem = self.serviceItems[curindex]
|
||||||
|
else:
|
||||||
|
curitem = None
|
||||||
for item in self.serviceItems:
|
for item in self.serviceItems:
|
||||||
service_item = item[u'service_item']
|
service_item = item[u'service_item']
|
||||||
data.append([service_item.title])
|
data_item = {}
|
||||||
|
data_item[u'title'] = unicode(service_item.title)
|
||||||
|
data_item[u'plugin'] = unicode(service_item.name)
|
||||||
|
data_item[u'notes'] = unicode(service_item.notes)
|
||||||
|
data_item[u'selected'] = (item == curitem)
|
||||||
|
data.append(data_item)
|
||||||
Receiver.send_message(u'servicemanager_list_response', data)
|
Receiver.send_message(u'servicemanager_list_response', data)
|
||||||
|
@ -341,6 +341,12 @@ class SlideController(QtGui.QWidget):
|
|||||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||||
QtCore.SIGNAL(u'slidecontroller_%s_change' % self.type_prefix),
|
QtCore.SIGNAL(u'slidecontroller_%s_change' % self.type_prefix),
|
||||||
self.onSlideChange)
|
self.onSlideChange)
|
||||||
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||||
|
QtCore.SIGNAL(u'slidecontroller_%s_set' % self.type_prefix),
|
||||||
|
self.onSlideSelectedIndex)
|
||||||
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||||
|
QtCore.SIGNAL(u'slidecontroller_%s_text_request' % self.type_prefix),
|
||||||
|
self.onTextRequest)
|
||||||
QtCore.QObject.connect(self.Splitter,
|
QtCore.QObject.connect(self.Splitter,
|
||||||
QtCore.SIGNAL(u'splitterMoved(int, int)'), self.trackSplitter)
|
QtCore.SIGNAL(u'splitterMoved(int, int)'), self.trackSplitter)
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||||
@ -565,6 +571,25 @@ class SlideController(QtGui.QWidget):
|
|||||||
[serviceItem])
|
[serviceItem])
|
||||||
log.log(15, u'Display Rendering took %4s' % (time.time() - before))
|
log.log(15, u'Display Rendering took %4s' % (time.time() - before))
|
||||||
|
|
||||||
|
def onTextRequest(self):
|
||||||
|
"""
|
||||||
|
Return the text for the current item in controller
|
||||||
|
"""
|
||||||
|
data = []
|
||||||
|
for framenumber, frame in enumerate(self.serviceItem.get_frames()):
|
||||||
|
data_item = {}
|
||||||
|
if self.serviceItem.is_text():
|
||||||
|
data_item[u'tag'] = unicode(frame[u'verseTag'])
|
||||||
|
data_item[u'text'] = unicode(frame[u'text'])
|
||||||
|
else:
|
||||||
|
data_item[u'tag'] = unicode(framenumber)
|
||||||
|
data_item[u'text'] = u''
|
||||||
|
data_item[u'selected'] = \
|
||||||
|
(self.PreviewListWidget.currentRow() == framenumber)
|
||||||
|
data.append(data_item)
|
||||||
|
Receiver.send_message(u'slidecontroller_%s_text_response' % self.type_prefix,
|
||||||
|
data)
|
||||||
|
|
||||||
#Screen event methods
|
#Screen event methods
|
||||||
def onSlideSelectedFirst(self):
|
def onSlideSelectedFirst(self):
|
||||||
"""
|
"""
|
||||||
@ -580,6 +605,21 @@ class SlideController(QtGui.QWidget):
|
|||||||
self.PreviewListWidget.selectRow(0)
|
self.PreviewListWidget.selectRow(0)
|
||||||
self.onSlideSelected()
|
self.onSlideSelected()
|
||||||
|
|
||||||
|
def onSlideSelectedIndex(self, message):
|
||||||
|
"""
|
||||||
|
Go to the requested slide
|
||||||
|
"""
|
||||||
|
index = int(message[0])
|
||||||
|
if not self.serviceItem:
|
||||||
|
return
|
||||||
|
Receiver.send_message(u'%s_slide' % self.serviceItem.name.lower(),
|
||||||
|
[self.serviceItem, self.isLive, index])
|
||||||
|
if self.serviceItem.is_command():
|
||||||
|
self.updatePreview()
|
||||||
|
else:
|
||||||
|
self.PreviewListWidget.selectRow(index)
|
||||||
|
self.onSlideSelected()
|
||||||
|
|
||||||
def onBlankDisplay(self, force=False):
|
def onBlankDisplay(self, force=False):
|
||||||
"""
|
"""
|
||||||
Handle the blank screen button
|
Handle the blank screen button
|
||||||
|
@ -235,6 +235,7 @@ class MessageListener(object):
|
|||||||
|
|
||||||
def slide(self, message):
|
def slide(self, message):
|
||||||
isLive, item = self.decode_message(message)
|
isLive, item = self.decode_message(message)
|
||||||
|
slide = message[2]
|
||||||
if isLive:
|
if isLive:
|
||||||
self.liveHandler.slide(slide, live)
|
self.liveHandler.slide(slide, live)
|
||||||
else:
|
else:
|
||||||
|
@ -47,13 +47,15 @@ class HttpServer(object):
|
|||||||
|
|
||||||
def start_tcp(self):
|
def start_tcp(self):
|
||||||
log.debug(u'Start TCP server')
|
log.debug(u'Start TCP server')
|
||||||
port = self.parent.config.get_config(u'remote port', 4316)
|
port = QtCore.QSettings().value(
|
||||||
|
self.parent.settings_section + u'/remote port',
|
||||||
|
QtCore.QVariant(4316)).toInt()[0]
|
||||||
self.server = QtNetwork.QTcpServer()
|
self.server = QtNetwork.QTcpServer()
|
||||||
self.server.listen(QtNetwork.QHostAddress(QtNetwork.QHostAddress.Any),
|
self.server.listen(QtNetwork.QHostAddress(QtNetwork.QHostAddress.Any),
|
||||||
int(port))
|
port)
|
||||||
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 %s' % port)
|
log.debug(u'TCP listening on port %d' % port)
|
||||||
|
|
||||||
def new_connection(self):
|
def new_connection(self):
|
||||||
log.debug(u'new http connection')
|
log.debug(u'new http connection')
|
||||||
@ -70,7 +72,10 @@ class HttpServer(object):
|
|||||||
self.server.close()
|
self.server.close()
|
||||||
|
|
||||||
class HttpConnection(object):
|
class HttpConnection(object):
|
||||||
|
"""
|
||||||
|
A single connection, this handles communication between the server
|
||||||
|
and the client
|
||||||
|
"""
|
||||||
def __init__(self, parent, socket):
|
def __init__(self, parent, socket):
|
||||||
log.debug(u'Initialise HttpConnection: %s' %
|
log.debug(u'Initialise HttpConnection: %s' %
|
||||||
socket.peerAddress().toString())
|
socket.peerAddress().toString())
|
||||||
@ -115,47 +120,96 @@ class HttpConnection(object):
|
|||||||
|
|
||||||
function send_event(eventname, data){
|
function send_event(eventname, data){
|
||||||
var req = new XMLHttpRequest();
|
var req = new XMLHttpRequest();
|
||||||
url = 'send/' + eventname;
|
req.onreadystatechange = function() {
|
||||||
|
if(req.readyState==4 && req.status==200)
|
||||||
|
response(eventname, req.responseText);
|
||||||
|
}
|
||||||
|
var url = '';
|
||||||
|
if(eventname.substr(-8) == '_request')
|
||||||
|
url = 'request';
|
||||||
|
else
|
||||||
|
url = 'send';
|
||||||
|
url += '/' + eventname;
|
||||||
if(data!=null)
|
if(data!=null)
|
||||||
url += '?q=' + escape(data);
|
url += '?q=' + escape(data);
|
||||||
req.open('GET', url, true);
|
req.open('GET', url, true);
|
||||||
req.send();
|
req.send();
|
||||||
}
|
}
|
||||||
function get_service(){
|
function response(eventname, text){
|
||||||
var req = new XMLHttpRequest();
|
switch(eventname){
|
||||||
req.onreadystatechange = function() {
|
case 'servicemanager_list_request':
|
||||||
if(req.readyState==4 && req.status==200){
|
var data = eval('(' + text + ')');
|
||||||
data = eval('(' + req.responseText + ')');
|
var html = '<table>';
|
||||||
html = '<table>';
|
|
||||||
for(row in data){
|
for(row in data){
|
||||||
html += '<tr><td>' + data[row][0] + '</td></tr>';
|
html += '<tr onclick="send_event('
|
||||||
|
html += "'servicemanager_set_item', " + row + ')"';
|
||||||
|
if(data[row]['selected'])
|
||||||
|
html += ' style="font-weight: bold"';
|
||||||
|
html += '>'
|
||||||
|
html += '<td>' + (parseInt(row)+1) + '</td>'
|
||||||
|
html += '<td>' + data[row]['title'] + '</td>'
|
||||||
|
html += '<td>' + data[row]['plugin'] + '</td>'
|
||||||
|
html += '<td>' + data[row]['notes'] + '</td>'
|
||||||
|
html += '</tr>';
|
||||||
}
|
}
|
||||||
html += '</table>';
|
html += '</table>';
|
||||||
service = document.getElementById('service');
|
document.getElementById('service').innerHTML = html;
|
||||||
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>';
|
||||||
|
for(row in data){
|
||||||
|
html += '<tr onclick="send_event('
|
||||||
|
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 += '</table>';
|
||||||
|
document.getElementById('currentitem').innerHTML = html;
|
||||||
|
break;
|
||||||
|
case 'slidecontroller_live_next':
|
||||||
|
case 'slidecontroller_live_previous':
|
||||||
|
case 'slidecontroller_live_set':
|
||||||
|
send_event("slidecontroller_live_text_request");
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
req.open('GET', 'request/servicemanager_list_request', true);
|
|
||||||
req.send();
|
|
||||||
}
|
}
|
||||||
|
send_event("servicemanager_list_request");
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>OpenLP Controller</h1>
|
<h1>OpenLP Controller</h1>
|
||||||
<input type='button' value='<- Previous Slide' onclick='send_event("slidecontroller_live_previous");'>
|
<input type='button' value='<- Previous Slide'
|
||||||
<input type='button' value='Next Slide ->' onclick='send_event("slidecontroller_live_next");'>
|
onclick='send_event("slidecontroller_live_previous");' />
|
||||||
|
<input type='button' value='Next Slide ->'
|
||||||
|
onclick='send_event("slidecontroller_live_next");' />
|
||||||
<br>
|
<br>
|
||||||
<input type='button' value='<- Previous Item' onclick='send_event("servicemanager_previous_item");'>
|
<input type='button' value='<- Previous Item'
|
||||||
<input type='button' value='Next Item ->' onclick='send_event("servicemanager_next_item");'>
|
onclick='send_event("servicemanager_previous_item");' />
|
||||||
<br>
|
<input type='button' value='Next Item ->'
|
||||||
<label>Alert text</label><input id='alert' type='text'>
|
onclick='send_event("servicemanager_next_item");' />
|
||||||
|
<br/>
|
||||||
|
<label>Alert text</label><input id='alert' type='text' />
|
||||||
<input type='button' value='Send'
|
<input type='button' value='Send'
|
||||||
onclick='send_event("alerts_text",
|
onclick='send_event("alerts_text",
|
||||||
document.getElementById("alert").value);'>
|
document.getElementById("alert").value);' />
|
||||||
<br>
|
<br/>
|
||||||
<input type='button' value='Order of service' onclick='get_service();'>
|
<input type='button' value='Order of service'
|
||||||
<div id='service'>
|
onclick='send_event("servicemanager_list_request");'>
|
||||||
</div>
|
<div id='service'></div>
|
||||||
|
<input type='button' value='Current item'
|
||||||
|
onclick='send_event("slidecontroller_live_text_request");'>
|
||||||
|
<div id='currentitem'></div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user