openlp/openlp/plugins/songs/lib/songstab.py

114 lines
6.3 KiB
Python

# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
# --------------------------------------------------------------------------- #
# Copyright (c) 2008-2013 Raoul Snyman #
# Portions copyright (c) 2008-2013 Tim Bentley, Gerald Britton, Jonathan #
# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. #
# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, #
# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, #
# Frode Woldsund, Martin Zibricky, Patrick Zimmermann #
# --------------------------------------------------------------------------- #
# 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 #
###############################################################################
from PyQt4 import QtCore, QtGui
from openlp.core.lib import Settings, SettingsTab, translate
class SongsTab(SettingsTab):
"""
SongsTab is the Songs settings tab in the settings dialog.
"""
def setupUi(self):
"""
Set up the configuration tab UI.
"""
self.setObjectName(u'SongsTab')
SettingsTab.setupUi(self)
self.mode_group_box = QtGui.QGroupBox(self.left_column)
self.mode_group_box.setObjectName(u'mode_group_box')
self.mode_layout = QtGui.QVBoxLayout(self.mode_group_box)
self.mode_layout.setObjectName(u'mode_layout')
self.search_as_type_check_box = QtGui.QCheckBox(self.mode_group_box)
self.search_as_type_check_box.setObjectName(u'SearchAsType_check_box')
self.mode_layout.addWidget(self.search_as_type_check_box)
self.tool_bar_active_check_box = QtGui.QCheckBox(self.mode_group_box)
self.tool_bar_active_check_box.setObjectName(u'tool_bar_active_check_box')
self.mode_layout.addWidget(self.tool_bar_active_check_box)
self.update_on_edit_check_box = QtGui.QCheckBox(self.mode_group_box)
self.update_on_edit_check_box.setObjectName(u'update_on_edit_check_box')
self.mode_layout.addWidget(self.update_on_edit_check_box)
self.add_from_service_check_box = QtGui.QCheckBox(self.mode_group_box)
self.add_from_service_check_box.setObjectName(u'add_from_service_check_box')
self.mode_layout.addWidget(self.add_from_service_check_box)
self.left_layout.addWidget(self.mode_group_box)
self.left_layout.addStretch()
self.right_layout.addStretch()
self.search_as_type_check_box.stateChanged.connect(self.on_search_as_type_check_box_changed)
self.tool_bar_active_check_box.stateChanged.connect(self.on_tool_bar_active_check_box_changed)
self.update_on_edit_check_box.stateChanged.connect(self.on_update_on_edit_check_box_changed)
self.add_from_service_check_box.stateChanged.connect(self.on_add_from_service_check_box_changed)
def retranslateUi(self):
self.mode_group_box.setTitle(translate('SongsPlugin.SongsTab', 'Songs Mode'))
self.search_as_type_check_box.setText(translate('SongsPlugin.SongsTab', 'Enable search as you type'))
self.tool_bar_active_check_box.setText(translate('SongsPlugin.SongsTab',
'Display verses on live tool bar'))
self.update_on_edit_check_box.setText(translate('SongsPlugin.SongsTab', 'Update service from song edit'))
self.add_from_service_check_box.setText(translate('SongsPlugin.SongsTab',
'Import missing songs from service files'))
def on_search_as_type_check_box_changed(self, check_state):
self.song_search = (check_state == QtCore.Qt.Checked)
def on_tool_bar_active_check_box_changed(self, check_state):
self.tool_bar = (check_state == QtCore.Qt.Checked)
def on_update_on_edit_check_box_changed(self, check_state):
self.update_edit = (check_state == QtCore.Qt.Checked)
def on_add_from_service_check_box_changed(self, check_state):
self.update_load = (check_state == QtCore.Qt.Checked)
def load(self):
settings = Settings()
settings.beginGroup(self.settings_section)
self.song_search = settings.value(u'search as type')
self.tool_bar = settings.value(u'display songbar')
self.update_edit = settings.value(u'update service on edit')
self.update_load = settings.value(u'add song from service')
self.search_as_type_check_box.setChecked(self.song_search)
self.tool_bar_active_check_box.setChecked(self.tool_bar)
self.update_on_edit_check_box.setChecked(self.update_edit)
self.add_from_service_check_box.setChecked(self.update_load)
settings.endGroup()
def save(self):
settings = Settings()
settings.beginGroup(self.settings_section)
settings.setValue(u'search as type', self.song_search)
settings.setValue(u'display songbar', self.tool_bar)
settings.setValue(u'update service on edit', self.update_edit)
settings.setValue(u'add song from service', self.update_load)
settings.endGroup()
if self.tab_visited:
self.settings_form.register_post_process(u'songs_config_updated')
self.tab_visited = False