Allow the stageview time to be formatted between 12 and 24 hours

Fixes: https://launchpad.net/bugs/863841
This commit is contained in:
Tim Bentley 2011-10-01 17:34:09 +05:30
parent 128b6b80bf
commit 648c5159a1
3 changed files with 27 additions and 4 deletions

View File

@ -121,11 +121,11 @@ window.OpenLP = {
$("#nextslide").html(text); $("#nextslide").html(text);
} }
}, },
updateClock: function() { updateClock: function(data) {
var div = $("#clock"); var div = $("#clock");
var t = new Date(); var t = new Date();
var h = t.getHours(); var h = t.getHours();
if (h > 12) if (data.results.twelve && h > 12)
h = h - 12; h = h - 12;
var m = t.getMinutes(); var m = t.getMinutes();
if (m < 10) if (m < 10)
@ -136,7 +136,7 @@ window.OpenLP = {
$.getJSON( $.getJSON(
"/api/poll", "/api/poll",
function (data, status) { function (data, status) {
OpenLP.updateClock(); OpenLP.updateClock(data);
if (OpenLP.currentItem != data.results.item) { if (OpenLP.currentItem != data.results.item) {
OpenLP.currentItem = data.results.item; OpenLP.currentItem = data.results.item;
OpenLP.loadSlides(); OpenLP.loadSlides();

View File

@ -397,7 +397,9 @@ class HttpConnection(object):
result = { result = {
u'slide': self.parent.current_slide or 0, u'slide': self.parent.current_slide or 0,
u'item': self.parent.current_item._uuid \ u'item': self.parent.current_item._uuid \
if self.parent.current_item else u'' if self.parent.current_item else u'',
u'twelve':QtCore.QSettings().value(
u'remotes/twelve hour', QtCore.QVariant(True)).toBool()
} }
return HttpResponse(json.dumps({u'results': result}), return HttpResponse(json.dumps({u'results': result}),
{u'Content-Type': u'application/json'}) {u'Content-Type': u'application/json'})

View File

@ -57,6 +57,9 @@ class RemoteTab(SettingsTab):
QtCore.QObject.connect(self.addressEdit, QtCore.QObject.connect(self.addressEdit,
QtCore.SIGNAL(u'textChanged(const QString&)'), self.setUrls) QtCore.SIGNAL(u'textChanged(const QString&)'), self.setUrls)
self.serverSettingsLayout.addRow(self.addressLabel, self.addressEdit) self.serverSettingsLayout.addRow(self.addressLabel, self.addressEdit)
self.twelveHourCheckBox = QtGui.QCheckBox(self.serverSettingsGroupBox)
self.twelveHourCheckBox.setObjectName(u'twelveHourCheckBox')
self.serverSettingsLayout.addRow(self.twelveHourCheckBox)
self.portLabel = QtGui.QLabel(self.serverSettingsGroupBox) self.portLabel = QtGui.QLabel(self.serverSettingsGroupBox)
self.portLabel.setObjectName(u'portLabel') self.portLabel.setObjectName(u'portLabel')
self.portSpinBox = QtGui.QSpinBox(self.serverSettingsGroupBox) self.portSpinBox = QtGui.QSpinBox(self.serverSettingsGroupBox)
@ -80,6 +83,9 @@ class RemoteTab(SettingsTab):
self.leftLayout.addWidget(self.serverSettingsGroupBox) self.leftLayout.addWidget(self.serverSettingsGroupBox)
self.leftLayout.addStretch() self.leftLayout.addStretch()
self.rightLayout.addStretch() self.rightLayout.addStretch()
QtCore.QObject.connect(self.twelveHourCheckBox,
QtCore.SIGNAL(u'stateChanged(int)'),
self.onTwelveHourCheckBoxChanged)
def retranslateUi(self): def retranslateUi(self):
self.serverSettingsGroupBox.setTitle( self.serverSettingsGroupBox.setTitle(
@ -92,6 +98,9 @@ class RemoteTab(SettingsTab):
'Remote URL:')) 'Remote URL:'))
self.stageUrlLabel.setText(translate('RemotePlugin.RemoteTab', self.stageUrlLabel.setText(translate('RemotePlugin.RemoteTab',
'Stage view URL:')) 'Stage view URL:'))
self.twelveHourCheckBox.setText(
translate('RemotePlugin.RemoteTab',
'Display stage time in 12hr format'))
def setUrls(self): def setUrls(self):
ipAddress = u'localhost' ipAddress = u'localhost'
@ -123,6 +132,10 @@ class RemoteTab(SettingsTab):
self.addressEdit.setText( self.addressEdit.setText(
QtCore.QSettings().value(self.settingsSection + u'/ip address', QtCore.QSettings().value(self.settingsSection + u'/ip address',
QtCore.QVariant(ZERO_URL)).toString()) QtCore.QVariant(ZERO_URL)).toString())
self.twelveHour = QtCore.QSettings().value(
self.settingsSection + u'/twelve hour',
QtCore.QVariant(True)).toBool()
self.twelveHourCheckBox.setChecked(self.twelveHour)
self.setUrls() self.setUrls()
def save(self): def save(self):
@ -130,3 +143,11 @@ class RemoteTab(SettingsTab):
QtCore.QVariant(self.portSpinBox.value())) QtCore.QVariant(self.portSpinBox.value()))
QtCore.QSettings().setValue(self.settingsSection + u'/ip address', QtCore.QSettings().setValue(self.settingsSection + u'/ip address',
QtCore.QVariant(self.addressEdit.text())) QtCore.QVariant(self.addressEdit.text()))
QtCore.QSettings().setValue(self.settingsSection + u'/twelve hour',
QtCore.QVariant(self.twelveHour))
def onTwelveHourCheckBoxChanged(self, check_state):
self.twelveHour = False
# we have a set value convert to True/False
if check_state == QtCore.Qt.Checked:
self.twelveHour = True