Update Display Tags UI

bzr-revno: 1526
This commit is contained in:
Tim Bentley 2011-05-08 15:13:33 +01:00
commit 1850d8f483
2 changed files with 30 additions and 38 deletions

View File

@ -112,11 +112,14 @@ class Ui_DisplayTagDialog(object):
self.endTagLineEdit = QtGui.QLineEdit(self.editGroupBox) self.endTagLineEdit = QtGui.QLineEdit(self.editGroupBox)
self.endTagLineEdit.setObjectName(u'endTagLineEdit') self.endTagLineEdit.setObjectName(u'endTagLineEdit')
self.dataGridLayout.addWidget(self.endTagLineEdit, 4, 1, 1, 1) self.dataGridLayout.addWidget(self.endTagLineEdit, 4, 1, 1, 1)
self.updatePushButton = QtGui.QPushButton(self.editGroupBox) self.savePushButton = QtGui.QPushButton(self.editGroupBox)
self.updatePushButton.setObjectName(u'updatePushButton') self.savePushButton.setObjectName(u'savePushButton')
self.dataGridLayout.addWidget(self.updatePushButton, 4, 2, 1, 1) self.dataGridLayout.addWidget(self.savePushButton, 4, 2, 1, 1)
self.listdataGridLayout.addWidget(self.editGroupBox, 2, 0, 1, 1) self.listdataGridLayout.addWidget(self.editGroupBox, 2, 0, 1, 1)
self.buttonBox = create_accept_reject_button_box(displayTagDialog) self.buttonBox = QtGui.QDialogButtonBox(displayTagDialog)
closeButton = QtGui.QDialogButtonBox.Close
self.buttonBox.setObjectName('displayTagDialogButtonBox')
self.buttonBox.setStandardButtons(closeButton)
self.listdataGridLayout.addWidget(self.buttonBox, 3, 0, 1, 1) self.listdataGridLayout.addWidget(self.buttonBox, 3, 0, 1, 1)
self.retranslateUi(displayTagDialog) self.retranslateUi(displayTagDialog)
@ -127,8 +130,8 @@ class Ui_DisplayTagDialog(object):
'Configure Display Tags')) 'Configure Display Tags'))
self.editGroupBox.setTitle( self.editGroupBox.setTitle(
translate('OpenLP.DisplayTagDialog', 'Edit Selection')) translate('OpenLP.DisplayTagDialog', 'Edit Selection'))
self.updatePushButton.setText( self.savePushButton.setText(
translate('OpenLP.DisplayTagDialog', 'Update')) translate('OpenLP.DisplayTagDialog', 'Save'))
self.descriptionLabel.setText( self.descriptionLabel.setText(
translate('OpenLP.DisplayTagDialog', 'Description')) translate('OpenLP.DisplayTagDialog', 'Description'))
self.tagLabel.setText(translate('OpenLP.DisplayTagDialog', 'Tag')) self.tagLabel.setText(translate('OpenLP.DisplayTagDialog', 'Tag'))

View File

@ -54,10 +54,12 @@ class DisplayTagForm(QtGui.QDialog, Ui_DisplayTagDialog):
QtCore.SIGNAL(u'pressed()'), self.onDefaultPushed) QtCore.SIGNAL(u'pressed()'), self.onDefaultPushed)
QtCore.QObject.connect(self.newPushButton, QtCore.QObject.connect(self.newPushButton,
QtCore.SIGNAL(u'pressed()'), self.onNewPushed) QtCore.SIGNAL(u'pressed()'), self.onNewPushed)
QtCore.QObject.connect(self.updatePushButton, QtCore.QObject.connect(self.savePushButton,
QtCore.SIGNAL(u'pressed()'), self.onUpdatePushed) QtCore.SIGNAL(u'pressed()'), self.onSavedPushed)
QtCore.QObject.connect(self.deletePushButton, QtCore.QObject.connect(self.deletePushButton,
QtCore.SIGNAL(u'pressed()'), self.onDeletePushed) QtCore.SIGNAL(u'pressed()'), self.onDeletePushed)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'rejected()'),
self.close)
def exec_(self): def exec_(self):
""" """
@ -87,30 +89,6 @@ class DisplayTagForm(QtGui.QDialog, Ui_DisplayTagDialog):
for t in user_tags: for t in user_tags:
DisplayTags.add_html_tag(t) DisplayTags.add_html_tag(t)
def accept(self):
"""
Save Custom tags in a pickle .
"""
temp = []
for tag in DisplayTags.get_html_tags():
if not tag[u'protected']:
temp.append(tag)
if temp:
ctemp = cPickle.dumps(temp)
QtCore.QSettings().setValue(u'displayTags/html_tags',
QtCore.QVariant(ctemp))
else:
QtCore.QSettings().setValue(u'displayTags/html_tags',
QtCore.QVariant(u''))
return QtGui.QDialog.accept(self)
def reject(self):
"""
Reset Custom tags from Settings.
"""
self._resetTable()
return QtGui.QDialog.reject(self)
def onRowSelected(self): def onRowSelected(self):
""" """
Table Row selected so display items and set field state. Table Row selected so display items and set field state.
@ -127,14 +105,14 @@ class DisplayTagForm(QtGui.QDialog, Ui_DisplayTagDialog):
self.tagLineEdit.setEnabled(False) self.tagLineEdit.setEnabled(False)
self.startTagLineEdit.setEnabled(False) self.startTagLineEdit.setEnabled(False)
self.endTagLineEdit.setEnabled(False) self.endTagLineEdit.setEnabled(False)
self.updatePushButton.setEnabled(False) self.savePushButton.setEnabled(False)
self.deletePushButton.setEnabled(False) self.deletePushButton.setEnabled(False)
else: else:
self.descriptionLineEdit.setEnabled(True) self.descriptionLineEdit.setEnabled(True)
self.tagLineEdit.setEnabled(True) self.tagLineEdit.setEnabled(True)
self.startTagLineEdit.setEnabled(True) self.startTagLineEdit.setEnabled(True)
self.endTagLineEdit.setEnabled(True) self.endTagLineEdit.setEnabled(True)
self.updatePushButton.setEnabled(True) self.savePushButton.setEnabled(True)
self.deletePushButton.setEnabled(True) self.deletePushButton.setEnabled(True)
def onNewPushed(self): def onNewPushed(self):
@ -174,9 +152,9 @@ class DisplayTagForm(QtGui.QDialog, Ui_DisplayTagDialog):
self.selected = -1 self.selected = -1
self._resetTable() self._resetTable()
def onUpdatePushed(self): def onSavedPushed(self):
""" """
Update Custom Tag details if not duplicate. Update Custom Tag details if not duplicate and save the data.
""" """
html_expands = DisplayTags.get_html_tags() html_expands = DisplayTags.get_html_tags()
if self.selected != -1: if self.selected != -1:
@ -197,6 +175,17 @@ class DisplayTagForm(QtGui.QDialog, Ui_DisplayTagDialog):
html[u'end tag'] = u'{/%s}' % tag html[u'end tag'] = u'{/%s}' % tag
self.selected = -1 self.selected = -1
self._resetTable() self._resetTable()
temp = []
for tag in DisplayTags.get_html_tags():
if not tag[u'protected']:
temp.append(tag)
if temp:
ctemp = cPickle.dumps(temp)
QtCore.QSettings().setValue(u'displayTags/html_tags',
QtCore.QVariant(ctemp))
else:
QtCore.QSettings().setValue(u'displayTags/html_tags',
QtCore.QVariant(u''))
def _resetTable(self): def _resetTable(self):
""" """
@ -205,7 +194,7 @@ class DisplayTagForm(QtGui.QDialog, Ui_DisplayTagDialog):
self.tagTableWidget.clearContents() self.tagTableWidget.clearContents()
self.tagTableWidget.setRowCount(0) self.tagTableWidget.setRowCount(0)
self.newPushButton.setEnabled(True) self.newPushButton.setEnabled(True)
self.updatePushButton.setEnabled(False) self.savePushButton.setEnabled(False)
self.deletePushButton.setEnabled(False) self.deletePushButton.setEnabled(False)
for linenumber, html in enumerate(DisplayTags.get_html_tags()): for linenumber, html in enumerate(DisplayTags.get_html_tags()):
self.tagTableWidget.setRowCount( self.tagTableWidget.setRowCount(