openlp/openlp/core/lib/settingsmanager.py

59 lines
3.0 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 #
###############################################################################
2010-04-26 16:41:31 +00:00
from PyQt4 import QtCore
class SettingsManager(object):
2009-07-08 17:18:48 +00:00
"""
Class to control the size of the UI components so they size correctly.
This class is created by the main window and then calculates the size of
individual components.
2009-07-08 17:18:48 +00:00
"""
def __init__(self, screen):
2010-04-26 16:41:31 +00:00
self.settings = QtCore.QSettings()
self.screen = screen.current
self.width = self.screen[u'size'].width()
self.height = self.screen[u'size'].height()
self.mainwindow_height = self.height * 0.8
mainwindow_docbars = self.width / 5
self.mainwindow_left = 0
self.mainwindow_right = 0
if mainwindow_docbars > 300:
self.mainwindow_left = 300
self.mainwindow_right = 300
else:
self.mainwindow_left = mainwindow_docbars
self.mainwindow_right = mainwindow_docbars
self.slidecontroller = (self.width - (
self.mainwindow_left + self.mainwindow_right) - 100 ) / 2
2009-09-07 19:14:01 +00:00
self.slidecontroller_image = self.slidecontroller - 50
2010-04-26 16:41:31 +00:00
self.showPreviewPanel = self.settings.value(
u'user interface/preview panel', True).toBool()
def togglePreviewPanel(self, isVisible):
2010-04-26 16:41:31 +00:00
self.settings.setValue(u'user interface/preview panel',
QtCore.QVariant(isVisible))