This commit is contained in:
Jonathan Corwin 2011-05-08 20:28:04 +01:00
commit 61b3a8e19b
9 changed files with 50 additions and 52 deletions

View File

@ -87,8 +87,8 @@ class BaseModel(object):
Creates an instance of a class and populates it, returning the instance
"""
instance = cls()
for key in kwargs:
instance.__setattr__(key, kwargs[key])
for key, value in kwargs.iteritems():
instance.__setattr__(key, value)
return instance

View File

@ -74,10 +74,10 @@ class SearchEdit(QtGui.QLineEdit):
if hasattr(self, u'menuButton'):
leftPadding = self.menuButton.width()
self.setStyleSheet(
u'QLineEdit { padding-left: %spx; padding-right: %spx; } ' % \
u'QLineEdit { padding-left: %spx; padding-right: %spx; } ' %
(leftPadding, rightPadding))
else:
self.setStyleSheet(u'QLineEdit { padding-right: %spx; } ' % \
self.setStyleSheet(u'QLineEdit { padding-right: %spx; } ' %
rightPadding)
msz = self.minimumSizeHint()
self.setMinimumSize(

View File

@ -269,11 +269,9 @@ class ServiceItem(object):
}
service_data = []
if self.service_item_type == ServiceItemType.Text:
for slide in self._raw_frames:
service_data.append(slide)
service_data = [slide for slide in self._raw_frames]
elif self.service_item_type == ServiceItemType.Image:
for slide in self._raw_frames:
service_data.append(slide[u'title'])
service_data = [slide[u'title'] for slide in self._raw_frames]
elif self.service_item_type == ServiceItemType.Command:
for slide in self._raw_frames:
service_data.append(

View File

@ -130,7 +130,7 @@ class UiStrings(object):
self.VersePerLine = translate('OpenLP.Ui', 'Verse Per Line')
self.Version = translate('OpenLP.Ui', 'Version')
self.View = translate('OpenLP.Ui', 'View')
self.ViewMode = translate('OpenLP.Ui', 'View Model')
self.ViewMode = translate('OpenLP.Ui', 'View Mode')
def add_welcome_page(parent, image):
"""

View File

@ -112,11 +112,14 @@ class Ui_DisplayTagDialog(object):
self.endTagLineEdit = QtGui.QLineEdit(self.editGroupBox)
self.endTagLineEdit.setObjectName(u'endTagLineEdit')
self.dataGridLayout.addWidget(self.endTagLineEdit, 4, 1, 1, 1)
self.updatePushButton = QtGui.QPushButton(self.editGroupBox)
self.updatePushButton.setObjectName(u'updatePushButton')
self.dataGridLayout.addWidget(self.updatePushButton, 4, 2, 1, 1)
self.savePushButton = QtGui.QPushButton(self.editGroupBox)
self.savePushButton.setObjectName(u'savePushButton')
self.dataGridLayout.addWidget(self.savePushButton, 4, 2, 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.retranslateUi(displayTagDialog)
@ -127,8 +130,8 @@ class Ui_DisplayTagDialog(object):
'Configure Display Tags'))
self.editGroupBox.setTitle(
translate('OpenLP.DisplayTagDialog', 'Edit Selection'))
self.updatePushButton.setText(
translate('OpenLP.DisplayTagDialog', 'Update'))
self.savePushButton.setText(
translate('OpenLP.DisplayTagDialog', 'Save'))
self.descriptionLabel.setText(
translate('OpenLP.DisplayTagDialog', 'Description'))
self.tagLabel.setText(translate('OpenLP.DisplayTagDialog', 'Tag'))
@ -151,4 +154,4 @@ class Ui_DisplayTagDialog(object):
self.tagTableWidget.setColumnWidth(0, 120)
self.tagTableWidget.setColumnWidth(1, 40)
self.tagTableWidget.setColumnWidth(2, 240)
self.tagTableWidget.setColumnWidth(3, 240)
self.tagTableWidget.setColumnWidth(3, 240)

View File

@ -54,10 +54,12 @@ class DisplayTagForm(QtGui.QDialog, Ui_DisplayTagDialog):
QtCore.SIGNAL(u'pressed()'), self.onDefaultPushed)
QtCore.QObject.connect(self.newPushButton,
QtCore.SIGNAL(u'pressed()'), self.onNewPushed)
QtCore.QObject.connect(self.updatePushButton,
QtCore.SIGNAL(u'pressed()'), self.onUpdatePushed)
QtCore.QObject.connect(self.savePushButton,
QtCore.SIGNAL(u'pressed()'), self.onSavedPushed)
QtCore.QObject.connect(self.deletePushButton,
QtCore.SIGNAL(u'pressed()'), self.onDeletePushed)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'rejected()'),
self.close)
def exec_(self):
"""
@ -87,30 +89,6 @@ class DisplayTagForm(QtGui.QDialog, Ui_DisplayTagDialog):
for t in user_tags:
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):
"""
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.startTagLineEdit.setEnabled(False)
self.endTagLineEdit.setEnabled(False)
self.updatePushButton.setEnabled(False)
self.savePushButton.setEnabled(False)
self.deletePushButton.setEnabled(False)
else:
self.descriptionLineEdit.setEnabled(True)
self.tagLineEdit.setEnabled(True)
self.startTagLineEdit.setEnabled(True)
self.endTagLineEdit.setEnabled(True)
self.updatePushButton.setEnabled(True)
self.savePushButton.setEnabled(True)
self.deletePushButton.setEnabled(True)
def onNewPushed(self):
@ -174,9 +152,9 @@ class DisplayTagForm(QtGui.QDialog, Ui_DisplayTagDialog):
self.selected = -1
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()
if self.selected != -1:
@ -197,6 +175,17 @@ class DisplayTagForm(QtGui.QDialog, Ui_DisplayTagDialog):
html[u'end tag'] = u'{/%s}' % tag
self.selected = -1
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):
"""
@ -205,7 +194,7 @@ class DisplayTagForm(QtGui.QDialog, Ui_DisplayTagDialog):
self.tagTableWidget.clearContents()
self.tagTableWidget.setRowCount(0)
self.newPushButton.setEnabled(True)
self.updatePushButton.setEnabled(False)
self.savePushButton.setEnabled(False)
self.deletePushButton.setEnabled(False)
for linenumber, html in enumerate(DisplayTags.get_html_tags()):
self.tagTableWidget.setRowCount(

View File

@ -130,9 +130,12 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog):
file.close()
file = open(filename, u'wb')
file.write(report.encode(u'utf-8'))
file.close()
finally:
file.close()
except IOError:
log.exception(u'Failed to write crash report')
finally:
file.close()
def onSendReportButtonPressed(self):
"""
@ -185,4 +188,5 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog):
def __buttonState(self, state):
self.saveReportButton.setEnabled(state)
self.sendReportButton.setEnabled(state)
self.sendReportButton.setEnabled(state)

View File

@ -38,7 +38,7 @@ from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, \
ThemeManager, SlideController, PluginForm, MediaDockManager, \
ShortcutListForm, DisplayTagForm
from openlp.core.utils import AppLocation, add_actions, LanguageManager, \
get_application_version
get_application_version, delete_file
from openlp.core.utils.actions import ActionList, CategoryOrder
log = logging.getLogger(__name__)
@ -657,8 +657,10 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
plugin.firstTime()
Receiver.send_message(u'openlp_process_events')
temp_dir = os.path.join(unicode(gettempdir()), u'openlp')
if not os.path.exists(temp_dir):
return
for filename in os.listdir(temp_dir):
os.remove(os.path.join(temp_dir, filename))
delete_file(os.path.join(temp_dir, filename))
os.removedirs(temp_dir)
def blankCheck(self):

View File

@ -229,12 +229,14 @@ class SongsPlugin(Plugin):
If the first time wizard has run, this function is run to import all the
new songs into the database.
"""
self.onToolsReindexItemTriggered()
db_dir = unicode(os.path.join(gettempdir(), u'openlp'))
if not os.path.exists(db_dir):
return
song_dbs = []
for sfile in os.listdir(db_dir):
if sfile.startswith(u'songs_') and sfile.endswith(u'.sqlite'):
song_dbs.append(os.path.join(db_dir, sfile))
self.onToolsReindexItemTriggered()
if len(song_dbs) == 0:
return
progress = QtGui.QProgressDialog(self.formparent)