forked from openlp/openlp
Save and preview + dynamic theme changing
bzr-revno: 627
This commit is contained in:
commit
680dc1e128
@ -25,13 +25,7 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
try:
|
|
||||||
import sqlite
|
import sqlite
|
||||||
except:
|
|
||||||
try:
|
|
||||||
import pysqlite2
|
|
||||||
except:
|
|
||||||
print 'No Sqlite2 package available'
|
|
||||||
import sqlite3
|
import sqlite3
|
||||||
import re
|
import re
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
@ -110,12 +110,21 @@ def contextMenuAction(base, icon, text, slot):
|
|||||||
Utility method to help build context menus for plugins
|
Utility method to help build context menus for plugins
|
||||||
"""
|
"""
|
||||||
action = QtGui.QAction(text, base)
|
action = QtGui.QAction(text, base)
|
||||||
|
if icon is not None:
|
||||||
action.setIcon(buildIcon(icon))
|
action.setIcon(buildIcon(icon))
|
||||||
QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered()'), slot)
|
QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered()'), slot)
|
||||||
return action
|
return action
|
||||||
|
|
||||||
|
def contextMenu(base, icon, text):
|
||||||
|
"""
|
||||||
|
Utility method to help build context menus for plugins
|
||||||
|
"""
|
||||||
|
action = QtGui.QMenu(text, base)
|
||||||
|
action.setIcon(buildIcon(icon))
|
||||||
|
return action
|
||||||
|
|
||||||
def contextMenuSeparator(base):
|
def contextMenuSeparator(base):
|
||||||
action = QtGui.QAction("", base)
|
action = QtGui.QAction(u'', base)
|
||||||
action.setSeparator(True)
|
action.setSeparator(True)
|
||||||
return action
|
return action
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ import zipfile
|
|||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
from openlp.core.lib import PluginConfig, OpenLPToolbar, ServiceItem, \
|
from openlp.core.lib import PluginConfig, OpenLPToolbar, ServiceItem, \
|
||||||
ServiceType, contextMenuAction, contextMenuSeparator, Receiver
|
ServiceType, contextMenuAction, contextMenuSeparator, Receiver, contextMenu
|
||||||
|
|
||||||
class ServiceManagerList(QtGui.QTreeWidget):
|
class ServiceManagerList(QtGui.QTreeWidget):
|
||||||
|
|
||||||
@ -168,6 +168,12 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
self.ServiceManagerList.addAction(contextMenuAction(
|
self.ServiceManagerList.addAction(contextMenuAction(
|
||||||
self.ServiceManagerList, ':/services/service_delete',
|
self.ServiceManagerList, ':/services/service_delete',
|
||||||
self.trUtf8(u'&Remove from Service'), self.onDeleteFromService))
|
self.trUtf8(u'&Remove from Service'), self.onDeleteFromService))
|
||||||
|
self.ServiceManagerList.addAction(contextMenuSeparator(
|
||||||
|
self.ServiceManagerList))
|
||||||
|
self.ThemeMenu = contextMenu(
|
||||||
|
self.ServiceManagerList, '',
|
||||||
|
self.trUtf8(u'&Change Item Theme'))
|
||||||
|
self.ServiceManagerList.addAction(self.ThemeMenu.menuAction())
|
||||||
self.Layout.addWidget(self.ServiceManagerList)
|
self.Layout.addWidget(self.ServiceManagerList)
|
||||||
# Add the bottom toolbar
|
# Add the bottom toolbar
|
||||||
self.OrderToolbar = OpenLPToolbar(self)
|
self.OrderToolbar = OpenLPToolbar(self)
|
||||||
@ -599,12 +605,17 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
|
|
||||||
``theme_list``
|
``theme_list``
|
||||||
A list of current themes to be displayed
|
A list of current themes to be displayed
|
||||||
|
|
||||||
"""
|
"""
|
||||||
self.ThemeComboBox.clear()
|
self.ThemeComboBox.clear()
|
||||||
|
self.ThemeMenu.clear()
|
||||||
self.ThemeComboBox.addItem(u'')
|
self.ThemeComboBox.addItem(u'')
|
||||||
for theme in theme_list:
|
for theme in theme_list:
|
||||||
self.ThemeComboBox.addItem(theme)
|
self.ThemeComboBox.addItem(theme)
|
||||||
|
action = contextMenuAction(
|
||||||
|
self.ServiceManagerList,
|
||||||
|
None,
|
||||||
|
theme , self.onThemeChangeAction)
|
||||||
|
self.ThemeMenu.addAction(action)
|
||||||
id = self.ThemeComboBox.findText(self.service_theme,
|
id = self.ThemeComboBox.findText(self.service_theme,
|
||||||
QtCore.Qt.MatchExactly)
|
QtCore.Qt.MatchExactly)
|
||||||
# Not Found
|
# Not Found
|
||||||
@ -614,3 +625,9 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
self.ThemeComboBox.setCurrentIndex(id)
|
self.ThemeComboBox.setCurrentIndex(id)
|
||||||
self.parent.RenderManager.set_service_theme(self.service_theme)
|
self.parent.RenderManager.set_service_theme(self.service_theme)
|
||||||
self.regenerateServiceItems()
|
self.regenerateServiceItems()
|
||||||
|
|
||||||
|
def onThemeChangeAction(self):
|
||||||
|
theme = unicode(self.sender().text())
|
||||||
|
item, count = self.findServiceItem()
|
||||||
|
self.serviceItems[item][u'data'].theme = theme
|
||||||
|
self.regenerateServiceItems()
|
||||||
|
@ -198,7 +198,7 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
return
|
return
|
||||||
theme = unicode(item.data(QtCore.Qt.UserRole).toString())
|
theme = unicode(item.data(QtCore.Qt.UserRole).toString())
|
||||||
path = QtGui.QFileDialog.getExistingDirectory(self,
|
path = QtGui.QFileDialog.getExistingDirectory(self,
|
||||||
self.trUtf8(u'Save Theme - (%s)') % theme,
|
unicode(self.trUtf8(u'Save Theme - (%s)')) % theme,
|
||||||
self.config.get_last_dir(1) )
|
self.config.get_last_dir(1) )
|
||||||
path = unicode(path)
|
path = unicode(path)
|
||||||
if path != u'':
|
if path != u'':
|
||||||
|
@ -160,6 +160,7 @@ class AuditPlugin(Plugin):
|
|||||||
self.auditdeleteform.exec_()
|
self.auditdeleteform.exec_()
|
||||||
|
|
||||||
def onAuditReport(self):
|
def onAuditReport(self):
|
||||||
|
self.auditdetailform.initialise()
|
||||||
self.auditdetailform.exec_()
|
self.auditdetailform.exec_()
|
||||||
|
|
||||||
def about(self):
|
def about(self):
|
||||||
|
@ -37,41 +37,86 @@ class AuditDetailForm(QtGui.QDialog, Ui_AuditDetailDialog):
|
|||||||
QtGui.QDialog.__init__(self, None)
|
QtGui.QDialog.__init__(self, None)
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
self.initialise()
|
|
||||||
|
|
||||||
def initialise(self):
|
def initialise(self):
|
||||||
self.firstService = \
|
self.FirstCheckBox.setCheckState(
|
||||||
int(self.parent.config.get_config(u'first service', QtCore.Qt.Checked))
|
int(self.parent.config.get_config(u'first service', QtCore.Qt.Checked)))
|
||||||
self.secondService = \
|
self.SecondCheckBox.setCheckState(
|
||||||
int(self.parent.config.get_config(u'second service', QtCore.Qt.Checked))
|
int(self.parent.config.get_config(u'second service', QtCore.Qt.Checked)))
|
||||||
|
self.ThirdCheckBox.setCheckState(
|
||||||
|
int(self.parent.config.get_config(u'third service', QtCore.Qt.Checked)))
|
||||||
|
year = QtCore.QDate().currentDate().year()
|
||||||
|
if QtCore.QDate().currentDate().month() < 9:
|
||||||
|
year -= 1
|
||||||
|
toDate = QtCore.QDate(year, 8, 31)
|
||||||
|
fromDate = QtCore.QDate(year - 1, 9, 1)
|
||||||
|
self.FromDateEdit.setDate(fromDate)
|
||||||
|
self.ToDateEdit.setDate(toDate)
|
||||||
|
self.FileLineEdit.setText(self.parent.config.get_last_dir(1))
|
||||||
self.resetWindow()
|
self.resetWindow()
|
||||||
|
|
||||||
def changeFirstService(self, value):
|
def changeFirstService(self, value):
|
||||||
self.firstService = value
|
|
||||||
self.parent.config.set_config(u'first service', value)
|
self.parent.config.set_config(u'first service', value)
|
||||||
self.resetWindow()
|
self.resetWindow()
|
||||||
|
|
||||||
def changeSecondService(self, value):
|
def changeSecondService(self, value):
|
||||||
self.secondService = value
|
|
||||||
self.parent.config.set_config(u'second service', value)
|
self.parent.config.set_config(u'second service', value)
|
||||||
self.resetWindow()
|
self.resetWindow()
|
||||||
|
|
||||||
def changeThirdService(self, value):
|
def changeThirdService(self, value):
|
||||||
pass
|
self.parent.config.set_config(u'third service', value)
|
||||||
|
self.resetWindow()
|
||||||
|
|
||||||
def defineOutputLocation(self):
|
def defineOutputLocation(self):
|
||||||
pass
|
path = QtGui.QFileDialog.getExistingDirectory(self,
|
||||||
|
self.trUtf8(u'Output File Location'),
|
||||||
|
self.parent.config.get_last_dir(1) )
|
||||||
|
path = unicode(path)
|
||||||
|
if path != u'':
|
||||||
|
self.parent.config.set_last_dir(path, 1)
|
||||||
|
self.FileLineEdit.setText(path)
|
||||||
|
|
||||||
def resetWindow(self):
|
def resetWindow(self):
|
||||||
if self.firstService == QtCore.Qt.Unchecked:
|
if self.FirstCheckBox.checkState() == QtCore.Qt.Unchecked:
|
||||||
self.FirstFromTimeEdit.setEnabled(False)
|
self.FirstFromTimeEdit.setEnabled(False)
|
||||||
self.FirstToTimeEdit.setEnabled(False)
|
self.FirstToTimeEdit.setEnabled(False)
|
||||||
else:
|
else:
|
||||||
self.FirstFromTimeEdit.setEnabled(True)
|
self.FirstFromTimeEdit.setEnabled(True)
|
||||||
self.FirstToTimeEdit.setEnabled(True)
|
self.FirstToTimeEdit.setEnabled(True)
|
||||||
if self.secondService == QtCore.Qt.Unchecked:
|
if self.SecondCheckBox.checkState() == QtCore.Qt.Unchecked:
|
||||||
self.SecondFromTimeEdit.setEnabled(False)
|
self.SecondFromTimeEdit.setEnabled(False)
|
||||||
self.SecondToTimeEdit.setEnabled(False)
|
self.SecondToTimeEdit.setEnabled(False)
|
||||||
else:
|
else:
|
||||||
self.SecondFromTimeEdit.setEnabled(True)
|
self.SecondFromTimeEdit.setEnabled(True)
|
||||||
self.SecondToTimeEdit.setEnabled(True)
|
self.SecondToTimeEdit.setEnabled(True)
|
||||||
|
if self.ThirdCheckBox.checkState() == QtCore.Qt.Unchecked:
|
||||||
|
self.ThirdFromTimeEdit.setEnabled(False)
|
||||||
|
self.ThirdToTimeEdit.setEnabled(False)
|
||||||
|
else:
|
||||||
|
self.ThirdFromTimeEdit.setEnabled(True)
|
||||||
|
self.ThirdToTimeEdit.setEnabled(True)
|
||||||
|
|
||||||
|
def accept(self):
|
||||||
|
print self.DetailedReport.isChecked()
|
||||||
|
print self.SummaryReport.isChecked()
|
||||||
|
print self.FromDateEdit.date()
|
||||||
|
print self.ToDateEdit.date()
|
||||||
|
if self.DetailedReport.isChecked():
|
||||||
|
self.detailedReport()
|
||||||
|
else:
|
||||||
|
self.summaryReport()
|
||||||
|
self.close()
|
||||||
|
|
||||||
|
def detailedReport(self):
|
||||||
|
print "detailed"
|
||||||
|
filename = u'audit_det_%s_%s.txt' % \
|
||||||
|
(self.FromDateEdit.date().toString(u'ddMMyyyy'),
|
||||||
|
self.ToDateEdit.date().toString(u'ddMMyyyy'))
|
||||||
|
print filename
|
||||||
|
|
||||||
|
def summaryReport(self):
|
||||||
|
print "summary"
|
||||||
|
filename = u'audit_sum_%s_%s.txt' % \
|
||||||
|
(self.FromDateEdit.date().toString(u'ddMMyyyy'),
|
||||||
|
self.ToDateEdit.date().toString(u'ddMMyyyy'))
|
||||||
|
print filename
|
||||||
|
@ -447,4 +447,3 @@ class Ui_EditSongDialog(object):
|
|||||||
self.SongTabWidget.setTabText(
|
self.SongTabWidget.setTabText(
|
||||||
self.SongTabWidget.indexOf(self.ThemeTab),
|
self.SongTabWidget.indexOf(self.ThemeTab),
|
||||||
self.trUtf8(u'Theme, Copyright Info && Comments'))
|
self.trUtf8(u'Theme, Copyright Info && Comments'))
|
||||||
|
|
||||||
|
@ -93,6 +93,11 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
QtCore.SIGNAL(u'lostFocus()'), self.onCommentsEditLostFocus)
|
QtCore.SIGNAL(u'lostFocus()'), self.onCommentsEditLostFocus)
|
||||||
QtCore.QObject.connect(self.VerseOrderEdit,
|
QtCore.QObject.connect(self.VerseOrderEdit,
|
||||||
QtCore.SIGNAL(u'lostFocus()'), self.onVerseOrderEditLostFocus)
|
QtCore.SIGNAL(u'lostFocus()'), self.onVerseOrderEditLostFocus)
|
||||||
|
previewButton = QtGui.QPushButton()
|
||||||
|
previewButton.setText(self.trUtf8(u'Save & Preview'))
|
||||||
|
self.ButtonBox.addButton(previewButton, QtGui.QDialogButtonBox.ActionRole)
|
||||||
|
QtCore.QObject.connect(self.ButtonBox,
|
||||||
|
QtCore.SIGNAL(u'clicked(QAbstractButton*)'), self.onPreview)
|
||||||
# Create other objects and forms
|
# Create other objects and forms
|
||||||
self.songmanager = songmanager
|
self.songmanager = songmanager
|
||||||
self.verse_form = EditVerseForm()
|
self.verse_form = EditVerseForm()
|
||||||
@ -391,14 +396,26 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
self.loadBooks()
|
self.loadBooks()
|
||||||
self.loadTopics()
|
self.loadTopics()
|
||||||
|
|
||||||
|
def onPreview(self, button):
|
||||||
|
log.debug(u'onPreview')
|
||||||
|
if button.text() == self.trUtf8(u'Save & Preview') and self.saveSong():
|
||||||
|
Receiver().send_message(u'preview_song')
|
||||||
|
|
||||||
def accept(self):
|
def accept(self):
|
||||||
log.debug(u'accept')
|
log.debug(u'accept')
|
||||||
|
if self.saveSong():
|
||||||
|
if self.title_change:
|
||||||
|
Receiver().send_message(u'load_song_list')
|
||||||
|
Receiver().send_message(u'preview_song')
|
||||||
|
self.close()
|
||||||
|
|
||||||
|
def saveSong(self):
|
||||||
valid, message = self._validate_song()
|
valid, message = self._validate_song()
|
||||||
if not valid:
|
if not valid:
|
||||||
QtGui.QMessageBox.critical(
|
QtGui.QMessageBox.critical(
|
||||||
self, self.trUtf8(u'Error'), message,
|
self, self.trUtf8(u'Error'), message,
|
||||||
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
|
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
|
||||||
return
|
return False
|
||||||
self.song.title = unicode(self.TitleEditItem.displayText())
|
self.song.title = unicode(self.TitleEditItem.displayText())
|
||||||
self.song.copyright = unicode(self.CopyrightEditItem.displayText())
|
self.song.copyright = unicode(self.CopyrightEditItem.displayText())
|
||||||
self.song.search_title = unicode(self.TitleEditItem.displayText()) + \
|
self.song.search_title = unicode(self.TitleEditItem.displayText()) + \
|
||||||
@ -408,10 +425,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
self.processLyrics()
|
self.processLyrics()
|
||||||
self.processTitle()
|
self.processTitle()
|
||||||
self.songmanager.save_song(self.song)
|
self.songmanager.save_song(self.song)
|
||||||
if self.title_change:
|
return True
|
||||||
Receiver().send_message(u'load_song_list')
|
|
||||||
Receiver().send_message(u'preview_song')
|
|
||||||
self.close()
|
|
||||||
|
|
||||||
def processLyrics(self):
|
def processLyrics(self):
|
||||||
log.debug(u'processLyrics')
|
log.debug(u'processLyrics')
|
||||||
|
Loading…
Reference in New Issue
Block a user