2008-11-28 14:05:41 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
|
|
|
|
2009-09-08 19:58:05 +00:00
|
|
|
###############################################################################
|
|
|
|
# OpenLP - Open Source Lyrics Projection #
|
|
|
|
# --------------------------------------------------------------------------- #
|
2010-12-26 11:04:47 +00:00
|
|
|
# Copyright (c) 2008-2011 Raoul Snyman #
|
|
|
|
# Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael #
|
2011-02-24 05:47:38 +00:00
|
|
|
# Gorven, Scott Guerrieri, Meinert Jordan, Armin Köhler, Andreas Preikschat, #
|
|
|
|
# Christian Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon #
|
|
|
|
# Tibble, Carsten Tinggaard, Frode Woldsund #
|
2009-09-08 19:58:05 +00:00
|
|
|
# --------------------------------------------------------------------------- #
|
|
|
|
# This program is free software; you can redistribute it and/or modify it #
|
|
|
|
# under the terms of the GNU General Public License as published by the Free #
|
|
|
|
# Software Foundation; version 2 of the License. #
|
|
|
|
# #
|
|
|
|
# This program is distributed in the hope that it will be useful, but WITHOUT #
|
|
|
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
|
|
|
|
# more details. #
|
|
|
|
# #
|
|
|
|
# You should have received a copy of the GNU General Public License along #
|
|
|
|
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
|
|
|
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
|
|
|
###############################################################################
|
2010-06-10 21:30:50 +00:00
|
|
|
"""
|
|
|
|
The :mod:`settingsform` provides a user interface for the OpenLP settings
|
|
|
|
"""
|
2009-02-28 23:19:45 +00:00
|
|
|
import logging
|
2008-11-28 14:05:41 +00:00
|
|
|
|
2009-09-25 00:43:42 +00:00
|
|
|
from PyQt4 import QtGui
|
2008-11-28 14:05:41 +00:00
|
|
|
|
2010-09-04 19:40:28 +00:00
|
|
|
from openlp.core.lib import Receiver
|
2011-02-20 20:34:33 +00:00
|
|
|
from openlp.core.ui import AdvancedTab, GeneralTab, ThemesTab
|
2009-02-28 23:19:45 +00:00
|
|
|
from settingsdialog import Ui_SettingsDialog
|
|
|
|
|
2010-03-04 22:09:03 +00:00
|
|
|
log = logging.getLogger(__name__)
|
2009-02-28 23:19:45 +00:00
|
|
|
|
2009-05-01 11:50:09 +00:00
|
|
|
class SettingsForm(QtGui.QDialog, Ui_SettingsDialog):
|
2010-06-10 21:30:50 +00:00
|
|
|
"""
|
|
|
|
Provide the form to manipulate the settings for OpenLP
|
|
|
|
"""
|
2010-04-02 18:12:54 +00:00
|
|
|
def __init__(self, screens, mainWindow, parent=None):
|
2010-06-10 21:30:50 +00:00
|
|
|
"""
|
|
|
|
Initialise the settings form
|
|
|
|
"""
|
2009-10-19 14:56:44 +00:00
|
|
|
QtGui.QDialog.__init__(self, parent)
|
2009-02-28 23:19:45 +00:00
|
|
|
self.setupUi(self)
|
|
|
|
# General tab
|
2011-02-20 15:35:52 +00:00
|
|
|
generalTab = GeneralTab(screens)
|
|
|
|
self.addTab(u'General', generalTab)
|
2009-03-23 19:17:07 +00:00
|
|
|
# Themes tab
|
2011-02-20 15:35:52 +00:00
|
|
|
themesTab = ThemesTab(mainWindow)
|
|
|
|
self.addTab(u'Themes', themesTab)
|
2010-07-09 21:32:32 +00:00
|
|
|
# Advanced tab
|
2011-02-20 15:35:52 +00:00
|
|
|
advancedTab = AdvancedTab()
|
|
|
|
self.addTab(u'Advanced', advancedTab)
|
2009-02-28 23:19:45 +00:00
|
|
|
|
2010-03-14 23:22:44 +00:00
|
|
|
def addTab(self, name, tab):
|
2010-06-10 21:30:50 +00:00
|
|
|
"""
|
|
|
|
Add a tab to the form
|
|
|
|
"""
|
2009-10-28 21:52:13 +00:00
|
|
|
log.info(u'Adding %s tab' % tab.tabTitle)
|
2010-07-14 20:37:54 +00:00
|
|
|
self.settingsTabWidget.addTab(tab, tab.tabTitleVisible)
|
2009-10-03 19:02:40 +00:00
|
|
|
|
2009-10-10 04:56:06 +00:00
|
|
|
def insertTab(self, tab, location):
|
2010-06-10 21:30:50 +00:00
|
|
|
"""
|
|
|
|
Add a tab to the form at a specific location
|
|
|
|
"""
|
2009-10-28 21:52:13 +00:00
|
|
|
log.debug(u'Inserting %s tab' % tab.tabTitle)
|
2011-02-20 15:35:52 +00:00
|
|
|
# 14 : There are 3 tables currently and locations starts at -10
|
2010-07-14 20:37:54 +00:00
|
|
|
self.settingsTabWidget.insertTab(
|
2011-02-20 15:35:52 +00:00
|
|
|
location + 14, tab, tab.tabTitleVisible)
|
2009-10-03 19:02:40 +00:00
|
|
|
|
2010-09-15 17:55:27 +00:00
|
|
|
def removeTab(self, tab):
|
2010-06-10 21:30:50 +00:00
|
|
|
"""
|
|
|
|
Remove a tab from the form
|
|
|
|
"""
|
2010-09-15 17:55:27 +00:00
|
|
|
log.debug(u'remove %s tab' % tab.tabTitleVisible)
|
2010-07-14 21:28:20 +00:00
|
|
|
for tabIndex in range(0, self.settingsTabWidget.count()):
|
|
|
|
if self.settingsTabWidget.widget(tabIndex):
|
2010-09-29 21:06:59 +00:00
|
|
|
if self.settingsTabWidget.widget(tabIndex).tabTitleVisible == \
|
|
|
|
tab.tabTitleVisible:
|
2010-07-14 21:28:20 +00:00
|
|
|
self.settingsTabWidget.removeTab(tabIndex)
|
2008-11-28 14:05:41 +00:00
|
|
|
|
2009-03-01 20:21:57 +00:00
|
|
|
def accept(self):
|
2010-06-10 21:30:50 +00:00
|
|
|
"""
|
|
|
|
Process the form saving the settings
|
|
|
|
"""
|
2010-07-14 21:28:20 +00:00
|
|
|
for tabIndex in range(0, self.settingsTabWidget.count()):
|
|
|
|
self.settingsTabWidget.widget(tabIndex).save()
|
2010-09-04 19:40:28 +00:00
|
|
|
# Must go after all settings are save
|
|
|
|
Receiver.send_message(u'config_updated')
|
2009-08-06 13:17:36 +00:00
|
|
|
return QtGui.QDialog.accept(self)
|
2009-08-29 07:17:56 +00:00
|
|
|
|
2010-12-23 17:42:28 +00:00
|
|
|
def reject(self):
|
|
|
|
"""
|
|
|
|
Process the form saving the settings
|
|
|
|
"""
|
|
|
|
for tabIndex in range(0, self.settingsTabWidget.count()):
|
|
|
|
self.settingsTabWidget.widget(tabIndex).cancel()
|
|
|
|
return QtGui.QDialog.reject(self)
|
|
|
|
|
2009-08-29 07:17:56 +00:00
|
|
|
def postSetUp(self):
|
2010-06-10 21:30:50 +00:00
|
|
|
"""
|
|
|
|
Run any post-setup code for the tabs on the form
|
|
|
|
"""
|
2010-07-14 21:28:20 +00:00
|
|
|
for tabIndex in range(0, self.settingsTabWidget.count()):
|
2011-01-06 20:34:46 +00:00
|
|
|
self.settingsTabWidget.widget(tabIndex).postSetUp()
|