Clean up custom plugin dialog

This commit is contained in:
Tim Bentley 2010-04-08 20:46:50 +01:00
parent b9630907a8
commit 141a9b4358
3 changed files with 89 additions and 25 deletions

View File

@ -24,13 +24,14 @@
############################################################################### ###############################################################################
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import build_icon
class Ui_customEditDialog(object): class Ui_customEditDialog(object):
def setupUi(self, customEditDialog): def setupUi(self, customEditDialog):
customEditDialog.setObjectName(u'customEditDialog') customEditDialog.setObjectName(u'customEditDialog')
customEditDialog.resize(590, 541) customEditDialog.resize(590, 541)
icon = build_icon(u':/icon/openlp.org-icon-32.bmp') icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(u':/icon/openlp.org-icon-32.bmp'),
QtGui.QIcon.Normal, QtGui.QIcon.Off)
customEditDialog.setWindowIcon(icon) customEditDialog.setWindowIcon(icon)
self.gridLayout = QtGui.QGridLayout(customEditDialog) self.gridLayout = QtGui.QGridLayout(customEditDialog)
self.gridLayout.setObjectName(u'gridLayout') self.gridLayout.setObjectName(u'gridLayout')
@ -52,15 +53,19 @@ class Ui_customEditDialog(object):
self.verticalLayout = QtGui.QVBoxLayout() self.verticalLayout = QtGui.QVBoxLayout()
self.verticalLayout.setObjectName(u'verticalLayout') self.verticalLayout.setObjectName(u'verticalLayout')
self.UpButton = QtGui.QPushButton(customEditDialog) self.UpButton = QtGui.QPushButton(customEditDialog)
icon1 = build_icon(u':/services/service_up.png') icon1 = QtGui.QIcon()
icon1.addPixmap(QtGui.QPixmap(u':/services/service_up.png'),
QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.UpButton.setIcon(icon1) self.UpButton.setIcon(icon1)
self.UpButton.setObjectName(u'UpButton') self.UpButton.setObjectName(u'UpButton')
self.verticalLayout.addWidget(self.UpButton) self.verticalLayout.addWidget(self.UpButton)
spacerItem = QtGui.QSpacerItem(20, 128, spacerItem = QtGui.QSpacerItem(20, 128, QtGui.QSizePolicy.Minimum,
QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) QtGui.QSizePolicy.Expanding)
self.verticalLayout.addItem(spacerItem) self.verticalLayout.addItem(spacerItem)
self.DownButton = QtGui.QPushButton(customEditDialog) self.DownButton = QtGui.QPushButton(customEditDialog)
icon2 = build_icon(u':/services/service_down.png') icon2 = QtGui.QIcon()
icon2.addPixmap(QtGui.QPixmap(u':/services/service_down.png'),
QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.DownButton.setIcon(icon2) self.DownButton.setIcon(icon2)
self.DownButton.setObjectName(u'DownButton') self.DownButton.setObjectName(u'DownButton')
self.verticalLayout.addWidget(self.DownButton) self.verticalLayout.addWidget(self.DownButton)
@ -97,6 +102,9 @@ class Ui_customEditDialog(object):
self.ClearButton = QtGui.QPushButton(self.ButtonWidge) self.ClearButton = QtGui.QPushButton(self.ButtonWidge)
self.ClearButton.setObjectName(u'ClearButton') self.ClearButton.setObjectName(u'ClearButton')
self.verticalLayout_2.addWidget(self.ClearButton) self.verticalLayout_2.addWidget(self.ClearButton)
self.SplitButton = QtGui.QPushButton(self.ButtonWidge)
self.SplitButton.setObjectName(u'SplitButton')
self.verticalLayout_2.addWidget(self.SplitButton)
spacerItem1 = QtGui.QSpacerItem(20, 40, spacerItem1 = QtGui.QSpacerItem(20, 40,
QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.verticalLayout_2.addItem(spacerItem1) self.verticalLayout_2.addItem(spacerItem1)
@ -121,16 +129,15 @@ class Ui_customEditDialog(object):
self.horizontalLayout_2.addWidget(self.CreditEdit) self.horizontalLayout_2.addWidget(self.CreditEdit)
self.gridLayout.addLayout(self.horizontalLayout_2, 4, 0, 1, 1) self.gridLayout.addLayout(self.horizontalLayout_2, 4, 0, 1, 1)
self.buttonBox = QtGui.QDialogButtonBox(customEditDialog) self.buttonBox = QtGui.QDialogButtonBox(customEditDialog)
self.buttonBox.setStandardButtons( self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Save)
QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Save)
self.buttonBox.setObjectName(u'buttonBox') self.buttonBox.setObjectName(u'buttonBox')
self.gridLayout.addWidget(self.buttonBox, 5, 0, 1, 1) self.gridLayout.addWidget(self.buttonBox, 5, 0, 1, 1)
self.retranslateUi(customEditDialog) self.retranslateUi(customEditDialog)
QtCore.QObject.connect(self.buttonBox, QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'accepted()'),
QtCore.SIGNAL(u'rejected()'), customEditDialog.closePressed) customEditDialog.accept)
QtCore.QObject.connect(self.buttonBox, QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'rejected()'),
QtCore.SIGNAL(u'accepted()'), customEditDialog.accept) customEditDialog.closePressed)
QtCore.QMetaObject.connectSlotsByName(customEditDialog) QtCore.QMetaObject.connectSlotsByName(customEditDialog)
customEditDialog.setTabOrder(self.TitleEdit, self.VerseTextEdit) customEditDialog.setTabOrder(self.TitleEdit, self.VerseTextEdit)
customEditDialog.setTabOrder(self.VerseTextEdit, self.AddButton) customEditDialog.setTabOrder(self.VerseTextEdit, self.AddButton)
@ -143,12 +150,11 @@ class Ui_customEditDialog(object):
customEditDialog.setTabOrder(self.CreditEdit, self.UpButton) customEditDialog.setTabOrder(self.CreditEdit, self.UpButton)
customEditDialog.setTabOrder(self.UpButton, self.DownButton) customEditDialog.setTabOrder(self.UpButton, self.DownButton)
customEditDialog.setTabOrder(self.DownButton, self.ThemeComboBox) customEditDialog.setTabOrder(self.DownButton, self.ThemeComboBox)
customEditDialog.setTabOrder(self.ThemeComboBox, self.buttonBox)
def retranslateUi(self, customEditDialog): def retranslateUi(self, customEditDialog):
customEditDialog.setWindowTitle(self.trUtf8('Edit Custom Slides'))
self.UpButton.setToolTip(self.trUtf8('Move slide Up 1')) self.UpButton.setToolTip(self.trUtf8('Move slide Up 1'))
self.DownButton.setToolTip(self.trUtf8('Move slide down 1')) self.DownButton.setToolTip(self.trUtf8('Move slide down 1'))
customEditDialog.setWindowTitle(self.trUtf8('Edit Custom Slides'))
self.TitleLabel.setText(self.trUtf8('Title:')) self.TitleLabel.setText(self.trUtf8('Title:'))
self.AddButton.setText(self.trUtf8('Add New')) self.AddButton.setText(self.trUtf8('Add New'))
self.AddButton.setToolTip(self.trUtf8('Add new slide at bottom')) self.AddButton.setToolTip(self.trUtf8('Add new slide at bottom'))
@ -162,6 +168,7 @@ class Ui_customEditDialog(object):
self.DeleteButton.setToolTip(self.trUtf8('Delete selected slide')) self.DeleteButton.setToolTip(self.trUtf8('Delete selected slide'))
self.ClearButton.setText(self.trUtf8('Clear')) self.ClearButton.setText(self.trUtf8('Clear'))
self.ClearButton.setToolTip(self.trUtf8('Clear edit area')) self.ClearButton.setToolTip(self.trUtf8('Clear edit area'))
self.SplitButton.setText(self.trUtf8('Split Slide'))
self.SplitButton.setToolTip(self.trUtf8('Add slide split'))
self.ThemeLabel.setText(self.trUtf8('Theme:')) self.ThemeLabel.setText(self.trUtf8('Theme:'))
self.ThemeComboBox.setToolTip(self.trUtf8('Set Theme for Slides'))
self.CreditLabel.setText(self.trUtf8('Credits:')) self.CreditLabel.setText(self.trUtf8('Credits:'))

View File

@ -68,6 +68,8 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
QtCore.SIGNAL(u'pressed()'), self.onUpButtonPressed) QtCore.SIGNAL(u'pressed()'), self.onUpButtonPressed)
QtCore.QObject.connect(self.DownButton, QtCore.QObject.connect(self.DownButton,
QtCore.SIGNAL(u'pressed()'), self.onDownButtonPressed) QtCore.SIGNAL(u'pressed()'), self.onDownButtonPressed)
QtCore.QObject.connect(self.SplitButton,
QtCore.SIGNAL(u'pressed()'), self.onSplitButtonPressed)
QtCore.QObject.connect(self.VerseListView, QtCore.QObject.connect(self.VerseListView,
QtCore.SIGNAL(u'itemDoubleClicked(QListWidgetItem*)'), QtCore.SIGNAL(u'itemDoubleClicked(QListWidgetItem*)'),
self.onVerseListViewSelected) self.onVerseListViewSelected)
@ -94,6 +96,7 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
self.EditAllButton.setEnabled(True) self.EditAllButton.setEnabled(True)
self.SaveButton.setEnabled(False) self.SaveButton.setEnabled(False)
self.ClearButton.setEnabled(False) self.ClearButton.setEnabled(False)
self.SplitButton.setEnabled(False)
self.TitleEdit.setText(u'') self.TitleEdit.setText(u'')
self.CreditEdit.setText(u'') self.CreditEdit.setText(u'')
self.VerseTextEdit.clear() self.VerseTextEdit.clear()
@ -202,12 +205,14 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
def onEditAllButtonPressed(self): def onEditAllButtonPressed(self):
self.editAll = True self.editAll = True
self.AddButton.setEnabled(False) self.AddButton.setEnabled(False)
self.SplitButton.setEnabled(True)
if self.VerseListView.count() > 0: if self.VerseListView.count() > 0:
verse_list = u'' verse_list = u''
for row in range(0, self.VerseListView.count()): for row in range(0, self.VerseListView.count()):
item = self.VerseListView.item(row) item = self.VerseListView.item(row)
verse_list += item.text() verse_list += item.text()
verse_list += u'\n---\n' if row != self.VerseListView.count() - 1:
verse_list += u'\n[---]\n'
self.editText(verse_list) self.editText(verse_list)
def editText(self, text): def editText(self, text):
@ -222,7 +227,7 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
def onSaveButtonPressed(self): def onSaveButtonPressed(self):
if self.editAll: if self.editAll:
self.VerseListView.clear() self.VerseListView.clear()
for row in unicode(self.VerseTextEdit.toPlainText()).split(u'\n---\n'): for row in unicode(self.VerseTextEdit.toPlainText()).split(u'\n[---]\n'):
self.VerseListView.addItem(row) self.VerseListView.addItem(row)
else: else:
self.VerseListView.currentItem().setText( self.VerseListView.currentItem().setText(
@ -241,8 +246,15 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
self.SaveButton.setEnabled(False) self.SaveButton.setEnabled(False)
self.EditButton.setEnabled(False) self.EditButton.setEnabled(False)
self.EditAllButton.setEnabled(True) self.EditAllButton.setEnabled(True)
self.SplitButton.setEnabled(False)
self.VerseTextEdit.clear() self.VerseTextEdit.clear()
def onSplitButtonPressed(self):
if self.VerseTextEdit.textCursor().columnNumber() != 0:
self.VerseTextEdit.insertPlainText(u'\n')
self.VerseTextEdit.insertPlainText(u'[---]\n' )
self.VerseTextEdit.setFocus()
def onDeleteButtonPressed(self): def onDeleteButtonPressed(self):
self.VerseListView.takeItem(self.VerseListView.currentRow()) self.VerseListView.takeItem(self.VerseListView.currentRow())
self.EditButton.setEnabled(False) self.EditButton.setEnabled(False)
@ -258,5 +270,5 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
return False, self.trUtf8('You need to enter a slide') return False, self.trUtf8('You need to enter a slide')
if self.VerseTextEdit.toPlainText(): if self.VerseTextEdit.toPlainText():
self.VerseTextEdit.setFocus() self.VerseTextEdit.setFocus()
return False, self.trUtf8('You have unsaved data') return False, self.trUtf8('You have unsaved data, please save or clear')
return True, u'' return True, u''

View File

@ -46,7 +46,7 @@
<item> <item>
<widget class="QPushButton" name="UpButton"> <widget class="QPushButton" name="UpButton">
<property name="toolTip"> <property name="toolTip">
<string extracomment="Move selected slide up one"/> <string extracomment="Move slide up 1"/>
</property> </property>
<property name="text"> <property name="text">
<string/> <string/>
@ -73,7 +73,7 @@
<item> <item>
<widget class="QPushButton" name="DownButton"> <widget class="QPushButton" name="DownButton">
<property name="toolTip"> <property name="toolTip">
<string extracomment="Move selected slide down one"/> <string extracomment="Move slide down 1"/>
</property> </property>
<property name="text"> <property name="text">
<string/> <string/>
@ -106,7 +106,7 @@
<item> <item>
<widget class="QPushButton" name="AddButton"> <widget class="QPushButton" name="AddButton">
<property name="toolTip"> <property name="toolTip">
<string extracomment="Adds a new slide at bottom of list"/> <string extracomment="Adds a new slide at bottom"/>
</property> </property>
<property name="text"> <property name="text">
<string>Add New</string> <string>Add New</string>
@ -136,7 +136,7 @@
<item> <item>
<widget class="QPushButton" name="SaveButton"> <widget class="QPushButton" name="SaveButton">
<property name="toolTip"> <property name="toolTip">
<string extracomment="Save changed slide"/> <string extracomment="Replace edited slide"/>
</property> </property>
<property name="text"> <property name="text">
<string>Save</string> <string>Save</string>
@ -163,6 +163,16 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QPushButton" name="SplitButton">
<property name="toolTip">
<string extracomment="Add new slide split"/>
</property>
<property name="text">
<string>Split Slide</string>
</property>
</widget>
</item>
<item> <item>
<spacer name="ButtonSpacer"> <spacer name="ButtonSpacer">
<property name="orientation"> <property name="orientation">
@ -216,8 +226,11 @@
</item> </item>
<item row="5" column="0"> <item row="5" column="0">
<widget class="QDialogButtonBox" name="buttonBox"> <widget class="QDialogButtonBox" name="buttonBox">
<property name="toolTip">
<string extracomment="Edit dialog"/>
</property>
<property name="standardButtons"> <property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> <set>QDialogButtonBox::Cancel|QDialogButtonBox::Save</set>
</property> </property>
</widget> </widget>
</item> </item>
@ -236,12 +249,44 @@
<tabstop>UpButton</tabstop> <tabstop>UpButton</tabstop>
<tabstop>DownButton</tabstop> <tabstop>DownButton</tabstop>
<tabstop>ThemeComboBox</tabstop> <tabstop>ThemeComboBox</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops> </tabstops>
<resources> <resources>
<include location="../images/openlp-2.qrc"/> <include location="../images/openlp-2.qrc"/>
</resources> </resources>
<connections/> <connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>customEditDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>294</x>
<y>524</y>
</hint>
<hint type="destinationlabel">
<x>294</x>
<y>270</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>customEditDialog</receiver>
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>294</x>
<y>524</y>
</hint>
<hint type="destinationlabel">
<x>294</x>
<y>270</y>
</hint>
</hints>
</connection>
</connections>
<slots> <slots>
<slot>accept()</slot> <slot>accept()</slot>
<slot>rejected()</slot> <slot>rejected()</slot>