# -*- coding: utf-8 -*- # vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # # Copyright (c) 2008-2010 Raoul Snyman # # Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # # 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 # ############################################################################### """ Provide common toolbar handling for OpenLP """ import logging from PyQt4 import QtCore, QtGui from openlp.core.lib import build_icon log = logging.getLogger(__name__) class OpenLPToolbar(QtGui.QToolBar): """ Lots of toolbars around the place, so it makes sense to have a common way to manage them. This is the base toolbar class. """ def __init__(self, parent): """ Initialise the toolbar. """ QtGui.QToolBar.__init__(self, parent) # useful to be able to reuse button icons... self.icons = {} self.setIconSize(QtCore.QSize(20, 20)) self.actions = {} log.debug(u'Init done') def addToolbarButton(self, title, icon, tooltip=None, slot=None, checkable=False): """ A method to help developers easily add a button to the toolbar. ``title`` The title of the button. ``icon`` The icon of the button. This can be an instance of QIcon, or a string cotaining either the absolute path to the image, or an internal resource path starting with ':/'. ``tooltip`` A hint or tooltip for this button. ``slot`` The method to run when this button is clicked. ``objectname`` The name of the object, as used in `