openlp/openlp/core/ui/settingsform.py

75 lines
3.5 KiB
Python
Raw Normal View History

# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
# --------------------------------------------------------------------------- #
2009-12-31 12:52:01 +00:00
# Copyright (c) 2008-2010 Raoul Snyman #
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
2010-03-21 23:58:01 +00:00
# Gorven, Scott Guerrieri, Christian Richter, Maikel Stuivenberg, Martin #
# Thompson, Jon Tibble, Carsten Tinggaard #
# --------------------------------------------------------------------------- #
# 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 #
###############################################################################
import logging
2009-09-25 00:43:42 +00:00
from PyQt4 import QtGui
2010-04-27 19:59:44 +00:00
from openlp.core.ui import GeneralTab, ThemesTab, DisplayTab
from settingsdialog import Ui_SettingsDialog
2010-03-04 22:09:03 +00:00
log = logging.getLogger(__name__)
2009-05-01 11:50:09 +00:00
class SettingsForm(QtGui.QDialog, Ui_SettingsDialog):
2010-04-02 18:12:54 +00:00
def __init__(self, screens, mainWindow, parent=None):
2009-10-19 14:56:44 +00:00
QtGui.QDialog.__init__(self, parent)
self.setupUi(self)
# General tab
2010-04-02 18:12:54 +00:00
self.GeneralTab = GeneralTab(screens)
self.addTab(u'General', self.GeneralTab)
# Themes tab
self.ThemesTab = ThemesTab(mainWindow)
self.addTab(u'Themes', self.ThemesTab)
2010-04-27 19:59:44 +00:00
# Display tab
self.DisplayTab = DisplayTab(screens)
self.addTab(u'Display', self.DisplayTab)
2010-03-14 23:22:44 +00:00
def addTab(self, name, tab):
2009-10-28 21:52:13 +00:00
log.info(u'Adding %s tab' % tab.tabTitle)
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):
2009-10-28 21:52:13 +00:00
log.debug(u'Inserting %s tab' % tab.tabTitle)
2009-10-29 06:24:53 +00:00
#13 : There are 3 tables currently and locations starts at -10
2009-11-03 18:14:25 +00:00
self.SettingsTabWidget.insertTab(
location + 13, tab, tab.tabTitleVisible)
2009-10-03 19:02:40 +00:00
def removeTab(self, name):
log.debug(u'remove %s tab' % name)
for tab_index in range(0, self.SettingsTabWidget.count()):
2009-11-03 18:14:25 +00:00
if self.SettingsTabWidget.widget(tab_index):
2009-10-28 21:52:13 +00:00
if self.SettingsTabWidget.widget(tab_index).tabTitle == name:
2009-10-10 04:56:06 +00:00
self.SettingsTabWidget.removeTab(tab_index)
def accept(self):
2009-08-06 13:17:36 +00:00
for tab_index in range(0, self.SettingsTabWidget.count()):
self.SettingsTabWidget.widget(tab_index).save()
2009-08-06 13:17:36 +00:00
return QtGui.QDialog.accept(self)
2009-08-29 07:17:56 +00:00
def postSetUp(self):
for tab_index in range(0, self.SettingsTabWidget.count()):
2010-02-11 18:39:28 +00:00
self.SettingsTabWidget.widget(tab_index).postSetUp()