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.QObject.connect(Receiver.get_receiver(),
|
||||
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.SIGNAL(u'servicemanager_list_request'), self.listRequest)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
@ -315,6 +317,21 @@ class ServiceManager(QtGui.QWidget):
|
||||
prevItem = serviceIterator.value()
|
||||
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):
|
||||
"""
|
||||
Moves the selection up the window
|
||||
@ -877,7 +894,17 @@ class ServiceManager(QtGui.QWidget):
|
||||
|
||||
def listRequest(self, message=None):
|
||||
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:
|
||||
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)
|
||||
|
@ -341,6 +341,12 @@ class SlideController(QtGui.QWidget):
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'slidecontroller_%s_change' % self.type_prefix),
|
||||
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.SIGNAL(u'splitterMoved(int, int)'), self.trackSplitter)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
@ -565,6 +571,25 @@ class SlideController(QtGui.QWidget):
|
||||
[serviceItem])
|
||||
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
|
||||
def onSlideSelectedFirst(self):
|
||||
"""
|
||||
@ -580,6 +605,21 @@ class SlideController(QtGui.QWidget):
|
||||
self.PreviewListWidget.selectRow(0)
|
||||
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):
|
||||
"""
|
||||
Handle the blank screen button
|
||||
|
@ -235,6 +235,7 @@ class MessageListener(object):
|
||||
|
||||
def slide(self, message):
|
||||
isLive, item = self.decode_message(message)
|
||||
slide = message[2]
|
||||
if isLive:
|
||||
self.liveHandler.slide(slide, live)
|
||||
else:
|
||||
|
@ -47,13 +47,15 @@ class HttpServer(object):
|
||||
|
||||
def start_tcp(self):
|
||||
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.listen(QtNetwork.QHostAddress(QtNetwork.QHostAddress.Any),
|
||||
int(port))
|
||||
port)
|
||||
QtCore.QObject.connect(self.server,
|
||||
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):
|
||||
log.debug(u'new http connection')
|
||||
@ -70,7 +72,10 @@ class HttpServer(object):
|
||||
self.server.close()
|
||||
|
||||
class HttpConnection(object):
|
||||
|
||||
"""
|
||||
A single connection, this handles communication between the server
|
||||
and the client
|
||||
"""
|
||||
def __init__(self, parent, socket):
|
||||
log.debug(u'Initialise HttpConnection: %s' %
|
||||
socket.peerAddress().toString())
|
||||
@ -115,47 +120,96 @@ class HttpConnection(object):
|
||||
|
||||
function send_event(eventname, data){
|
||||
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)
|
||||
url += '?q=' + escape(data);
|
||||
req.open('GET', url, true);
|
||||
req.send();
|
||||
}
|
||||
function get_service(){
|
||||
var req = new XMLHttpRequest();
|
||||
req.onreadystatechange = function() {
|
||||
if(req.readyState==4 && req.status==200){
|
||||
data = eval('(' + req.responseText + ')');
|
||||
html = '<table>';
|
||||
function response(eventname, text){
|
||||
switch(eventname){
|
||||
case 'servicemanager_list_request':
|
||||
var data = eval('(' + text + ')');
|
||||
var html = '<table>';
|
||||
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>';
|
||||
service = document.getElementById('service');
|
||||
service.innerHTML = html;
|
||||
}
|
||||
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>';
|
||||
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>
|
||||
</head>
|
||||
<body>
|
||||
<h1>OpenLP Controller</h1>
|
||||
<input type='button' value='<- Previous Slide' onclick='send_event("slidecontroller_live_previous");'>
|
||||
<input type='button' value='Next Slide ->' onclick='send_event("slidecontroller_live_next");'>
|
||||
<input type='button' value='<- Previous Slide'
|
||||
onclick='send_event("slidecontroller_live_previous");' />
|
||||
<input type='button' value='Next Slide ->'
|
||||
onclick='send_event("slidecontroller_live_next");' />
|
||||
<br>
|
||||
<input type='button' value='<- Previous Item' onclick='send_event("servicemanager_previous_item");'>
|
||||
<input type='button' value='Next Item ->' onclick='send_event("servicemanager_next_item");'>
|
||||
<br>
|
||||
<label>Alert text</label><input id='alert' type='text'>
|
||||
<input type='button' value='<- Previous Item'
|
||||
onclick='send_event("servicemanager_previous_item");' />
|
||||
<input type='button' value='Next Item ->'
|
||||
onclick='send_event("servicemanager_next_item");' />
|
||||
<br/>
|
||||
<label>Alert text</label><input id='alert' type='text' />
|
||||
<input type='button' value='Send'
|
||||
onclick='send_event("alerts_text",
|
||||
document.getElementById("alert").value);'>
|
||||
<br>
|
||||
<input type='button' value='Order of service' onclick='get_service();'>
|
||||
<div id='service'>
|
||||
</div>
|
||||
document.getElementById("alert").value);' />
|
||||
<br/>
|
||||
<input type='button' value='Order of service'
|
||||
onclick='send_event("servicemanager_list_request");'>
|
||||
<div id='service'></div>
|
||||
<input type='button' value='Current item'
|
||||
onclick='send_event("slidecontroller_live_text_request");'>
|
||||
<div id='currentitem'></div>
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user