Use standards for Qt imports

This commit is contained in:
Jon Tibble 2009-09-29 13:51:38 +01:00
parent 1a7ad33bf9
commit b2827d4e25
9 changed files with 47 additions and 49 deletions

View File

@ -28,8 +28,7 @@ import logging
from logging.handlers import RotatingFileHandler from logging.handlers import RotatingFileHandler
from optparse import OptionParser from optparse import OptionParser
from PyQt4.QtCore import QObject, SIGNAL from PyQt4 import QtCore, QtGui
from PyQt4.QtGui import QApplication
from openlp.core.lib import Receiver, str_to_bool from openlp.core.lib import Receiver, str_to_bool
from openlp.core.resources import qInitResources from openlp.core.resources import qInitResources
@ -38,7 +37,7 @@ from openlp.core.utils import ConfigHelper
log = logging.getLogger() log = logging.getLogger()
class OpenLP(QApplication): class OpenLP(QtGui.QApplication):
""" """
The core application class. This class inherits from Qt's QApplication The core application class. This class inherits from Qt's QApplication
class in order to provide the core of the application. class in order to provide the core of the application.
@ -56,8 +55,8 @@ class OpenLP(QApplication):
except: except:
pass pass
#provide a listener for widgets to reqest a screen update. #provide a listener for widgets to reqest a screen update.
QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
SIGNAL(u'process_events'), self.processEvents) QtCore.SIGNAL(u'process_events'), self.processEvents)
self.setApplicationName(u'OpenLP') self.setApplicationName(u'OpenLP')
self.setApplicationVersion(u'1.9.0') self.setApplicationVersion(u'1.9.0')
show_splash = str_to_bool(ConfigHelper.get_registry().get_value( show_splash = str_to_bool(ConfigHelper.get_registry().get_value(

View File

@ -29,8 +29,7 @@ OpenLP work.
import types import types
from PyQt4.QtCore import QObject, SIGNAL from PyQt4 import QtCore, QtGui
from PyQt4.QtGui import QAction, QIcon, QImage, QPixmap, QApplication as QApp
def translate(context, text): def translate(context, text):
""" """
@ -45,7 +44,8 @@ def translate(context, text):
``text`` ``text``
The text to put into the translation tables for translation. The text to put into the translation tables for translation.
""" """
return QApp.translate(context, text, None, QApp.UnicodeUTF8) return QtGui.QApplication.translate(
context, text, None, QtGui.QApplication.UnicodeUTF8)
def file_to_xml(xmlfile): def file_to_xml(xmlfile):
""" """
@ -79,31 +79,33 @@ def buildIcon(icon):
``:/resource/file.png``, or a file location like ``/path/to/file.png``. ``:/resource/file.png``, or a file location like ``/path/to/file.png``.
""" """
ButtonIcon = None ButtonIcon = None
if type(icon) is QIcon: if type(icon) is QtGui.QIcon:
ButtonIcon = icon ButtonIcon = icon
elif type(icon) is types.StringType or type(icon) is types.UnicodeType: elif type(icon) is types.StringType or type(icon) is types.UnicodeType:
ButtonIcon = QIcon() ButtonIcon = QtGui.QIcon()
if icon.startswith(u':/'): if icon.startswith(u':/'):
ButtonIcon.addPixmap(QPixmap(icon), QIcon.Normal, QIcon.Off) ButtonIcon.addPixmap(
QtGui.QPixmap(icon), QtGui.QIcon.Normal, QtGui.QIcon.Off)
else: else:
ButtonIcon.addPixmap(QPixmap.fromImage(QImage(icon)), ButtonIcon.addPixmap(QtGui.QPixmap.fromImage(QtGui.QImage(icon)),
QIcon.Normal, QIcon.Off) QtGui.QIcon.Normal, QtGui.QIcon.Off)
elif type(icon) is QImage: elif type(icon) is QtGui.QImage:
ButtonIcon = QIcon() ButtonIcon = QtGui.QIcon()
ButtonIcon.addPixmap(QPixmap.fromImage(icon), QIcon.Normal, QIcon.Off) ButtonIcon.addPixmap(
QtGui.QPixmap.fromImage(icon), QtGui.QIcon.Normal, QtGui.QIcon.Off)
return ButtonIcon return ButtonIcon
def contextMenuAction(base, icon, text, slot): def contextMenuAction(base, icon, text, slot):
""" """
Utility method to help build context menus for plugins Utility method to help build context menus for plugins
""" """
action = QAction(text, base) action = QtGui.QAction(text, base)
action.setIcon(buildIcon(icon)) action.setIcon(buildIcon(icon))
QObject.connect(action, SIGNAL(u'triggered()'), slot) QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered()'), slot)
return action return action
def contextMenuSeparator(base): def contextMenuSeparator(base):
action = QAction("", base) action = QtGui.QAction("", base)
action.setSeparator(True) action.setSeparator(True)
return action return action

View File

@ -22,18 +22,17 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
from PyQt4.QtCore import QMimeData, Qt from PyQt4 import QtCore, QtGui
from PyQt4.QtGui import QDrag, QListWidget
from openlp.core.lib.toolbar import * from openlp.core.lib.toolbar import *
class BaseListWithDnD(QListWidget): class BaseListWithDnD(QtGui.QListWidget):
""" """
Please put a short description of what this class does in here. Please put a short description of what this class does in here.
""" """
def __init__(self, parent=None): def __init__(self, parent=None):
QListWidget.__init__(self, parent) QtGui.QListWidget.__init__(self, parent)
# this must be set by the class which is inheriting # this must be set by the class which is inheriting
assert(self.PluginName) assert(self.PluginName)
@ -43,10 +42,10 @@ class BaseListWithDnD(QListWidget):
as the recipient will use events to request the data move as the recipient will use events to request the data move
just tell it what plugin to call just tell it what plugin to call
""" """
if event.buttons() != Qt.LeftButton: if event.buttons() != QtCore.Qt.LeftButton:
return return
drag = QDrag(self) drag = QtGui.QDrag(self)
mimeData = QMimeData() mimeData = QtCore.QMimeData()
drag.setMimeData(mimeData) drag.setMimeData(mimeData)
mimeData.setText(self.PluginName) mimeData.setText(self.PluginName)
dropAction = drag.start(Qt.CopyAction) dropAction = drag.start(QtCore.Qt.CopyAction)

View File

@ -24,9 +24,9 @@
import logging import logging
from PyQt4.QtGui import QDockWidget from PyQt4 import QtGui
class OpenLPDockWidget(QDockWidget): class OpenLPDockWidget(QtGui.QDockWidget):
""" """
Custom DockWidget class to handle events Custom DockWidget class to handle events
""" """
@ -34,7 +34,7 @@ class OpenLPDockWidget(QDockWidget):
""" """
Initialise the DockWidget Initialise the DockWidget
""" """
QDockWidget.__init__(self, parent) QtGui.QDockWidget.__init__(self, parent)
self.parent = parent self.parent = parent
if name is not None: if name is not None:
self.setObjectName(name) self.setObjectName(name)

View File

@ -24,9 +24,9 @@
import logging import logging
from PyQt4.QtCore import QObject, SIGNAL from PyQt4 import QtCore
class EventReceiver(QObject): class EventReceiver(QtCore.QObject):
""" """
Class to allow events to be passed from different parts of the Class to allow events to be passed from different parts of the
system. This is a private class and should not be used directly system. This is a private class and should not be used directly
@ -91,7 +91,7 @@ class EventReceiver(QObject):
""" """
Initialise the event receiver, calling the parent constructor. Initialise the event receiver, calling the parent constructor.
""" """
QObject.__init__(self) QtCore.QObject.__init__(self)
def send_message(self, event, msg=None): def send_message(self, event, msg=None):
""" """
@ -104,7 +104,7 @@ class EventReceiver(QObject):
Defaults to *None*. The message to send with the event. Defaults to *None*. The message to send with the event.
""" """
log.debug(u'Event %s passed with payload %s' % (event, msg)) log.debug(u'Event %s passed with payload %s' % (event, msg))
self.emit(SIGNAL(event), msg) self.emit(QtCore.SIGNAL(event), msg)
class Receiver(): class Receiver():

View File

@ -23,8 +23,7 @@
############################################################################### ###############################################################################
import logging import logging
from PyQt4 import QtCore
from PyQt4.QtCore import QObject, SIGNAL
from openlp.core.lib import PluginConfig, Receiver from openlp.core.lib import PluginConfig, Receiver
@ -138,8 +137,8 @@ class Plugin(object):
self.render_manager = plugin_helpers[u'render'] self.render_manager = plugin_helpers[u'render']
self.service_manager = plugin_helpers[u'service'] self.service_manager = plugin_helpers[u'service']
self.settings = plugin_helpers[u'settings'] self.settings = plugin_helpers[u'settings']
QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
SIGNAL(u'%s_add_service_item'% self.name), self.process_add_service_event) QtCore.SIGNAL(u'%s_add_service_item'% self.name), self.process_add_service_event)
def check_pre_conditions(self): def check_pre_conditions(self):
""" """

View File

@ -22,11 +22,11 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
from PyQt4.QtGui import QWidget from PyQt4 import QtGui
from openlp.core.lib import PluginConfig from openlp.core.lib import PluginConfig
class SettingsTab(QWidget): class SettingsTab(QtGui.QWidget):
""" """
SettingsTab is a helper widget for plugins to define Tabs for the settings SettingsTab is a helper widget for plugins to define Tabs for the settings
dialog. dialog.
@ -43,7 +43,7 @@ class SettingsTab(QWidget):
Defaults to *None*. This is the section in the configuration file Defaults to *None*. This is the section in the configuration file
to write to when the ``save`` method is called. to write to when the ``save`` method is called.
""" """
QWidget.__init__(self) QtGui.QWidget.__init__(self)
self.tabTitle = title self.tabTitle = title
self.setupUi() self.setupUi()
self.retranslateUi() self.retranslateUi()

View File

@ -24,12 +24,11 @@
import logging import logging
from PyQt4.QtGui import QToolBar, QIcon from PyQt4 import QtCore, QtGui
from PyQt4.QtCore import QSize
from openlp.core.lib import buildIcon from openlp.core.lib import buildIcon
class OpenLPToolbar(QToolBar): class OpenLPToolbar(QtGui.QToolBar):
""" """
Lots of toolbars around the place, so it makes sense to have a common way Lots of toolbars around the place, so it makes sense to have a common way
to manage them. This is the base toolbar class. to manage them. This is the base toolbar class.
@ -38,10 +37,10 @@ class OpenLPToolbar(QToolBar):
""" """
Initialise the toolbar. Initialise the toolbar.
""" """
QToolBar.__init__(self, None) QtGui.QToolBar.__init__(self, None)
# useful to be able to reuse button icons... # useful to be able to reuse button icons...
self.icons = {} self.icons = {}
self.setIconSize(QSize(20, 20)) self.setIconSize(QtCore.QSize(20, 20))
self.actions = {} self.actions = {}
self.log = logging.getLogger(u'OpenLPToolbar') self.log = logging.getLogger(u'OpenLPToolbar')
self.log.debug(u'Init done') self.log.debug(u'Init done')
@ -105,7 +104,7 @@ class OpenLPToolbar(QToolBar):
return self.icons[title] return self.icons[title]
else: else:
self.log.error(u'getIconFromTitle - no icon for %s' % title) self.log.error(u'getIconFromTitle - no icon for %s' % title)
return QIcon() return QtGui.QIcon()
def makeWidgetsInvisible(self, widgets): def makeWidgetsInvisible(self, widgets):
""" """

View File

@ -25,7 +25,7 @@
import types import types
from xml.etree.ElementTree import ElementTree, XML from xml.etree.ElementTree import ElementTree, XML
from PyQt4.QtGui import QColor from PyQt4 import QtGui
DelphiColors={"clRed":0xFF0000, DelphiColors={"clRed":0xFF0000,
"clBlue":0x0000FF, "clBlue":0x0000FF,
@ -135,7 +135,7 @@ class Theme(object):
if (element.tag.find(u'Color') > 0 or if (element.tag.find(u'Color') > 0 or
(element.tag.find(u'BackgroundParameter') == 0 and type(val) == type(0))): (element.tag.find(u'BackgroundParameter') == 0 and type(val) == type(0))):
# convert to a wx.Colour # convert to a wx.Colour
val = QColor((val>>16) & 0xFF, (val>>8)&0xFF, val&0xFF) val = QtGui.QColor((val>>16) & 0xFF, (val>>8)&0xFF, val&0xFF)
setattr(self, element.tag, val) setattr(self, element.tag, val)
def __str__(self): def __str__(self):