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 os
|
||||
try:
|
||||
import sqlite
|
||||
except:
|
||||
try:
|
||||
import pysqlite2
|
||||
except:
|
||||
print 'No Sqlite2 package available'
|
||||
import sqlite
|
||||
import sqlite3
|
||||
import re
|
||||
from optparse import OptionParser
|
||||
|
@ -110,12 +110,21 @@ def contextMenuAction(base, icon, text, slot):
|
||||
Utility method to help build context menus for plugins
|
||||
"""
|
||||
action = QtGui.QAction(text, base)
|
||||
action.setIcon(buildIcon(icon))
|
||||
if icon is not None:
|
||||
action.setIcon(buildIcon(icon))
|
||||
QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered()'), slot)
|
||||
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):
|
||||
action = QtGui.QAction("", base)
|
||||
action = QtGui.QAction(u'', base)
|
||||
action.setSeparator(True)
|
||||
return action
|
||||
|
||||
|
@ -30,7 +30,7 @@ import zipfile
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
from openlp.core.lib import PluginConfig, OpenLPToolbar, ServiceItem, \
|
||||
ServiceType, contextMenuAction, contextMenuSeparator, Receiver
|
||||
ServiceType, contextMenuAction, contextMenuSeparator, Receiver, contextMenu
|
||||
|
||||
class ServiceManagerList(QtGui.QTreeWidget):
|
||||
|
||||
@ -168,6 +168,12 @@ class ServiceManager(QtGui.QWidget):
|
||||
self.ServiceManagerList.addAction(contextMenuAction(
|
||||
self.ServiceManagerList, ':/services/service_delete',
|
||||
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)
|
||||
# Add the bottom toolbar
|
||||
self.OrderToolbar = OpenLPToolbar(self)
|
||||
@ -599,12 +605,17 @@ class ServiceManager(QtGui.QWidget):
|
||||
|
||||
``theme_list``
|
||||
A list of current themes to be displayed
|
||||
|
||||
"""
|
||||
self.ThemeComboBox.clear()
|
||||
self.ThemeMenu.clear()
|
||||
self.ThemeComboBox.addItem(u'')
|
||||
for theme in theme_list:
|
||||
self.ThemeComboBox.addItem(theme)
|
||||
action = contextMenuAction(
|
||||
self.ServiceManagerList,
|
||||
None,
|
||||
theme , self.onThemeChangeAction)
|
||||
self.ThemeMenu.addAction(action)
|
||||
id = self.ThemeComboBox.findText(self.service_theme,
|
||||
QtCore.Qt.MatchExactly)
|
||||
# Not Found
|
||||
@ -614,3 +625,9 @@ class ServiceManager(QtGui.QWidget):
|
||||
self.ThemeComboBox.setCurrentIndex(id)
|
||||
self.parent.RenderManager.set_service_theme(self.service_theme)
|
||||
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
|
||||
theme = unicode(item.data(QtCore.Qt.UserRole).toString())
|
||||
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) )
|
||||
path = unicode(path)
|
||||
if path != u'':
|
||||
|
@ -160,6 +160,7 @@ class AuditPlugin(Plugin):
|
||||
self.auditdeleteform.exec_()
|
||||
|
||||
def onAuditReport(self):
|
||||
self.auditdetailform.initialise()
|
||||
self.auditdetailform.exec_()
|
||||
|
||||
def about(self):
|
||||
|
@ -37,41 +37,86 @@ class AuditDetailForm(QtGui.QDialog, Ui_AuditDetailDialog):
|
||||
QtGui.QDialog.__init__(self, None)
|
||||
self.parent = parent
|
||||
self.setupUi(self)
|
||||
self.initialise()
|
||||
|
||||
def initialise(self):
|
||||
self.firstService = \
|
||||
int(self.parent.config.get_config(u'first service', QtCore.Qt.Checked))
|
||||
self.secondService = \
|
||||
int(self.parent.config.get_config(u'second service', QtCore.Qt.Checked))
|
||||
self.FirstCheckBox.setCheckState(
|
||||
int(self.parent.config.get_config(u'first service', QtCore.Qt.Checked)))
|
||||
self.SecondCheckBox.setCheckState(
|
||||
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()
|
||||
|
||||
def changeFirstService(self, value):
|
||||
self.firstService = value
|
||||
self.parent.config.set_config(u'first service', value)
|
||||
self.resetWindow()
|
||||
|
||||
def changeSecondService(self, value):
|
||||
self.secondService = value
|
||||
self.parent.config.set_config(u'second service', value)
|
||||
self.resetWindow()
|
||||
|
||||
def changeThirdService(self, value):
|
||||
pass
|
||||
self.parent.config.set_config(u'third service', value)
|
||||
self.resetWindow()
|
||||
|
||||
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):
|
||||
if self.firstService == QtCore.Qt.Unchecked:
|
||||
if self.FirstCheckBox.checkState() == QtCore.Qt.Unchecked:
|
||||
self.FirstFromTimeEdit.setEnabled(False)
|
||||
self.FirstToTimeEdit.setEnabled(False)
|
||||
else:
|
||||
self.FirstFromTimeEdit.setEnabled(True)
|
||||
self.FirstToTimeEdit.setEnabled(True)
|
||||
if self.secondService == QtCore.Qt.Unchecked:
|
||||
if self.SecondCheckBox.checkState() == QtCore.Qt.Unchecked:
|
||||
self.SecondFromTimeEdit.setEnabled(False)
|
||||
self.SecondToTimeEdit.setEnabled(False)
|
||||
else:
|
||||
self.SecondFromTimeEdit.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.indexOf(self.ThemeTab),
|
||||
self.trUtf8(u'Theme, Copyright Info && Comments'))
|
||||
|
||||
|
@ -93,6 +93,11 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
QtCore.SIGNAL(u'lostFocus()'), self.onCommentsEditLostFocus)
|
||||
QtCore.QObject.connect(self.VerseOrderEdit,
|
||||
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
|
||||
self.songmanager = songmanager
|
||||
self.verse_form = EditVerseForm()
|
||||
@ -391,14 +396,26 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
self.loadBooks()
|
||||
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):
|
||||
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()
|
||||
if not valid:
|
||||
QtGui.QMessageBox.critical(
|
||||
self, self.trUtf8(u'Error'), message,
|
||||
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
|
||||
return
|
||||
return False
|
||||
self.song.title = unicode(self.TitleEditItem.displayText())
|
||||
self.song.copyright = unicode(self.CopyrightEditItem.displayText())
|
||||
self.song.search_title = unicode(self.TitleEditItem.displayText()) + \
|
||||
@ -408,10 +425,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
self.processLyrics()
|
||||
self.processTitle()
|
||||
self.songmanager.save_song(self.song)
|
||||
if self.title_change:
|
||||
Receiver().send_message(u'load_song_list')
|
||||
Receiver().send_message(u'preview_song')
|
||||
self.close()
|
||||
return True
|
||||
|
||||
def processLyrics(self):
|
||||
log.debug(u'processLyrics')
|
||||
|
Loading…
Reference in New Issue
Block a user