Adding support for PySide's naming scheme
authorEd Page <eopage@byu.net>
Sat, 19 Mar 2011 11:34:42 +0000 (06:34 -0500)
committerEd Page <eopage@byu.net>
Tue, 19 Apr 2011 23:49:32 +0000 (18:49 -0500)
13 files changed:
src/alarm_handler.py
src/call_handler.py
src/dialcentral_qt.py
src/dialogs.py
src/gv_views.py
src/session.py
src/stream_handler.py
src/util/qore_utils.py
src/util/qt_compat.py [new file with mode: 0644]
src/util/qtpie.py
src/util/qtpieboard.py
src/util/qui_utils.py
src/util/qwrappers.py

index ddcd955..a79f992 100644 (file)
@@ -6,7 +6,8 @@ import datetime
 import ConfigParser
 import logging
 
-from PyQt4 import QtCore
+import util.qt_compat as qt_compat
+QtCore = qt_compat.QtCore
 import dbus
 
 
index b90e109..9b9c47d 100644 (file)
@@ -5,7 +5,8 @@ from __future__ import division
 
 import logging
 
-from PyQt4 import QtCore
+import util.qt_compat as qt_compat
+QtCore = qt_compat.QtCore
 import dbus
 try:
        import telepathy as _telepathy
@@ -31,7 +32,7 @@ class _FakeSignaller(object):
 
 class _MissedCallWatcher(QtCore.QObject):
 
-       callMissed = QtCore.pyqtSignal()
+       callMissed = qt_compat.Signal()
 
        def __init__(self):
                QtCore.QObject.__init__(self)
@@ -107,7 +108,7 @@ class _MissedCallWatcher(QtCore.QObject):
 
 class _DummyMissedCallWatcher(QtCore.QObject):
 
-       callMissed = QtCore.pyqtSignal()
+       callMissed = qt_compat.Signal()
 
        def __init__(self):
                QtCore.QObject.__init__(self)
index 1377bd2..4bf128a 100755 (executable)
@@ -10,8 +10,9 @@ import functools
 import logging
 import logging.handlers
 
-from PyQt4 import QtGui
-from PyQt4 import QtCore
+import util.qt_compat as qt_compat
+QtCore = qt_compat.QtCore
+QtGui = qt_compat.import_module("QtGui")
 
 import constants
 import alarm_handler
@@ -126,8 +127,8 @@ class Dialcentral(qwrappers.ApplicationWrapper):
        def _new_main_window(self):
                return MainWindow(None, self)
 
-       @QtCore.pyqtSlot()
-       @QtCore.pyqtSlot(bool)
+       @qt_compat.Slot()
+       @qt_compat.Slot(bool)
        @misc_utils.log_exception(_moduleLogger)
        def _on_about(self, checked = True):
                with qui_utils.notify_error(self._errorLog):
@@ -603,7 +604,7 @@ class MainWindow(qwrappers.WindowWrapper):
                else:
                        _moduleLogger.info("Unknown response")
 
-       @QtCore.pyqtSlot()
+       @qt_compat.Slot()
        @misc_utils.log_exception(_moduleLogger)
        def _on_new_message_alert(self):
                with qui_utils.notify_error(self._errorLog):
@@ -613,19 +614,19 @@ class MainWindow(qwrappers.WindowWrapper):
                                else:
                                        self._app.ledHandler.on()
 
-       @QtCore.pyqtSlot()
+       @qt_compat.Slot()
        @misc_utils.log_exception(_moduleLogger)
        def _on_call_missed(self):
                with qui_utils.notify_error(self._errorLog):
                        self._session.update_messages(self._session.MESSAGE_VOICEMAILS, force=True)
 
-       @QtCore.pyqtSlot(str)
+       @qt_compat.Slot(str)
        @misc_utils.log_exception(_moduleLogger)
        def _on_session_error(self, message):
                with qui_utils.notify_error(self._errorLog):
                        self._errorLog.push_error(message)
 
-       @QtCore.pyqtSlot()
+       @qt_compat.Slot()
        @misc_utils.log_exception(_moduleLogger)
        def _on_login(self):
                with qui_utils.notify_error(self._errorLog):
@@ -646,7 +647,7 @@ class MainWindow(qwrappers.WindowWrapper):
                                        self._callHandler.callMissed.connect(self._voicemailRefreshDelay.start)
                                self._callHandler.start()
 
-       @QtCore.pyqtSlot()
+       @qt_compat.Slot()
        @misc_utils.log_exception(_moduleLogger)
        def _on_logout(self):
                with qui_utils.notify_error(self._errorLog):
@@ -655,7 +656,7 @@ class MainWindow(qwrappers.WindowWrapper):
                        if self._callHandler is not None:
                                self._callHandler.stop()
 
-       @QtCore.pyqtSlot()
+       @qt_compat.Slot()
        @misc_utils.log_exception(_moduleLogger)
        def _on_app_alert(self):
                with qui_utils.notify_error(self._errorLog):
@@ -667,7 +668,7 @@ class MainWindow(qwrappers.WindowWrapper):
                                }[(self._app.notifyOnSms, self._app.notifyOnVoicemail)]
                                self._session.update_messages(messageType, force=True)
 
-       @QtCore.pyqtSlot()
+       @qt_compat.Slot()
        @misc_utils.log_exception(_moduleLogger)
        def _on_recipients_changed(self):
                with qui_utils.notify_error(self._errorLog):
@@ -685,14 +686,14 @@ class MainWindow(qwrappers.WindowWrapper):
        def _on_child_close(self, obj = None):
                self._smsEntryDialog = None
 
-       @QtCore.pyqtSlot()
-       @QtCore.pyqtSlot(bool)
+       @qt_compat.Slot()
+       @qt_compat.Slot(bool)
        @misc_utils.log_exception(_moduleLogger)
        def _on_login_requested(self, checked = True):
                with qui_utils.notify_error(self._errorLog):
                        self._prompt_for_login()
 
-       @QtCore.pyqtSlot(int)
+       @qt_compat.Slot(int)
        @misc_utils.log_exception(_moduleLogger)
        def _on_tab_changed(self, index):
                with qui_utils.notify_error(self._errorLog):
@@ -701,22 +702,22 @@ class MainWindow(qwrappers.WindowWrapper):
                        if self._app.alarmHandler.alarmType == self._app.alarmHandler.ALARM_APPLICATION:
                                self._app.ledHandler.off()
 
-       @QtCore.pyqtSlot()
-       @QtCore.pyqtSlot(bool)
+       @qt_compat.Slot()
+       @qt_compat.Slot(bool)
        @misc_utils.log_exception(_moduleLogger)
        def _on_refresh(self, checked = True):
                with qui_utils.notify_error(self._errorLog):
                        self._tabsContents[self._currentTab].refresh(force=True)
 
-       @QtCore.pyqtSlot()
-       @QtCore.pyqtSlot(bool)
+       @qt_compat.Slot()
+       @qt_compat.Slot(bool)
        @misc_utils.log_exception(_moduleLogger)
        def _on_refresh_connection(self, checked = True):
                with qui_utils.notify_error(self._errorLog):
                        self._session.refresh_connection()
 
-       @QtCore.pyqtSlot()
-       @QtCore.pyqtSlot(bool)
+       @qt_compat.Slot()
+       @qt_compat.Slot(bool)
        @misc_utils.log_exception(_moduleLogger)
        def _on_import(self, checked = True):
                with qui_utils.notify_error(self._errorLog):
@@ -729,8 +730,8 @@ class MainWindow(qwrappers.WindowWrapper):
                        if self._tabsContents[self.CONTACTS_TAB].has_child:
                                self._tabsContents[self.CONTACTS_TAB].child.update_addressbooks()
 
-       @QtCore.pyqtSlot()
-       @QtCore.pyqtSlot(bool)
+       @qt_compat.Slot()
+       @qt_compat.Slot(bool)
        @misc_utils.log_exception(_moduleLogger)
        def _on_account(self, checked = True):
                with qui_utils.notify_error(self._errorLog):
index 2feb6a2..f9f8226 100644 (file)
@@ -7,8 +7,9 @@ import functools
 import copy
 import logging
 
-from PyQt4 import QtGui
-from PyQt4 import QtCore
+import util.qt_compat as qt_compat
+QtCore = qt_compat.QtCore
+QtGui = qt_compat.import_module("QtGui")
 
 import constants
 from util import qwrappers
@@ -80,8 +81,8 @@ class CredentialsDialog(object):
                except RuntimeError:
                        _moduleLogger.exception("Oh well")
 
-       @QtCore.pyqtSlot()
-       @QtCore.pyqtSlot(bool)
+       @qt_compat.Slot()
+       @qt_compat.Slot(bool)
        @misc_utils.log_exception(_moduleLogger)
        def _on_close_window(self, checked = True):
                with qui_utils.notify_error(self._app.errorLog):
@@ -141,8 +142,8 @@ class AboutDialog(object):
                except RuntimeError:
                        _moduleLogger.exception("Oh well")
 
-       @QtCore.pyqtSlot()
-       @QtCore.pyqtSlot(bool)
+       @qt_compat.Slot()
+       @qt_compat.Slot(bool)
        @misc_utils.log_exception(_moduleLogger)
        def _on_close_window(self, checked = True):
                with qui_utils.notify_error(self._app.errorLog):
@@ -402,22 +403,22 @@ class AccountDialog(object):
                        self._voicemailNotificationButton.setChecked(False)
                        self._smsNotificationButton.setChecked(False)
 
-       @QtCore.pyqtSlot(int)
+       @qt_compat.Slot(int)
        @misc_utils.log_exception(_moduleLogger)
        def _on_notification_change(self, index):
                with qui_utils.notify_error(self._app.errorLog):
                        self._update_notification_state()
 
-       @QtCore.pyqtSlot()
-       @QtCore.pyqtSlot(bool)
+       @qt_compat.Slot()
+       @qt_compat.Slot(bool)
        @misc_utils.log_exception(_moduleLogger)
        def _on_clear(self, checked = False):
                with qui_utils.notify_error(self._app.errorLog):
                        self._doClear = True
                        self._dialog.accept()
 
-       @QtCore.pyqtSlot()
-       @QtCore.pyqtSlot(bool)
+       @qt_compat.Slot()
+       @qt_compat.Slot(bool)
        @misc_utils.log_exception(_moduleLogger)
        def _on_close_window(self, checked = True):
                with qui_utils.notify_error(self._app.errorLog):
@@ -481,7 +482,7 @@ class ContactList(object):
                        )
                        callback.__name__ = "thanks partials for not having names and pyqt for requiring them"
                        numberSelector.activated.connect(
-                               QtCore.pyqtSlot(int)(callback)
+                               qt_compat.Slot(int)(callback)
                        )
 
                        if self._closeIcon is self._SENTINEL_ICON:
@@ -767,13 +768,13 @@ class VoicemailPlayer(object):
                        self._session.download_voicemail(messageId)
                        self._hide()
 
-       @QtCore.pyqtSlot()
+       @qt_compat.Slot()
        @misc_utils.log_exception(_moduleLogger)
        def _on_recipients_changed(self):
                with qui_utils.notify_error(self._app.errorLog):
                        self._update_state()
 
-       @QtCore.pyqtSlot(str, str)
+       @qt_compat.Slot(str, str)
        @misc_utils.log_exception(_moduleLogger)
        def _on_voicemail_downloaded(self, messageId, filepath):
                with qui_utils.notify_error(self._app.errorLog):
@@ -1032,7 +1033,7 @@ class SMSEntryWindow(qwrappers.WindowWrapper):
                        self._session.draft.message = message
                        self._session.draft.call()
 
-       @QtCore.pyqtSlot()
+       @qt_compat.Slot()
        @misc_utils.log_exception(_moduleLogger)
        def _on_cancel_clicked(self, message):
                with qui_utils.notify_error(self._app.errorLog):
@@ -1051,7 +1052,7 @@ class SMSEntryWindow(qwrappers.WindowWrapper):
                        number = numbers[index][0]
                        self._session.draft.set_selected_number(cid, number)
 
-       @QtCore.pyqtSlot()
+       @qt_compat.Slot()
        @misc_utils.log_exception(_moduleLogger)
        def _on_refresh_history(self):
                with qui_utils.notify_error(self._app.errorLog):
@@ -1062,14 +1063,14 @@ class SMSEntryWindow(qwrappers.WindowWrapper):
                        (cid, ) = self._session.draft.get_contacts()
                        self._update_history(cid)
 
-       @QtCore.pyqtSlot()
+       @qt_compat.Slot()
        @misc_utils.log_exception(_moduleLogger)
        def _on_recipients_changed(self):
                with qui_utils.notify_error(self._app.errorLog):
                        self._update_target_fields()
                        self._update_button_state()
 
-       @QtCore.pyqtSlot()
+       @qt_compat.Slot()
        @misc_utils.log_exception(_moduleLogger)
        def _on_op_started(self):
                with qui_utils.notify_error(self._app.errorLog):
@@ -1078,13 +1079,13 @@ class SMSEntryWindow(qwrappers.WindowWrapper):
                        self._dialButton.setVisible(False)
                        self.show()
 
-       @QtCore.pyqtSlot()
+       @qt_compat.Slot()
        @misc_utils.log_exception(_moduleLogger)
        def _on_calling_started(self):
                with qui_utils.notify_error(self._app.errorLog):
                        self._cancelButton.setVisible(True)
 
-       @QtCore.pyqtSlot()
+       @qt_compat.Slot()
        @misc_utils.log_exception(_moduleLogger)
        def _on_op_finished(self):
                with qui_utils.notify_error(self._app.errorLog):
@@ -1096,7 +1097,7 @@ class SMSEntryWindow(qwrappers.WindowWrapper):
                        self.close()
                        self.destroy()
 
-       @QtCore.pyqtSlot()
+       @qt_compat.Slot()
        @misc_utils.log_exception(_moduleLogger)
        def _on_op_error(self, message):
                with qui_utils.notify_error(self._app.errorLog):
@@ -1107,21 +1108,21 @@ class SMSEntryWindow(qwrappers.WindowWrapper):
 
                        self._errorLog.push_error(message)
 
-       @QtCore.pyqtSlot()
+       @qt_compat.Slot()
        @misc_utils.log_exception(_moduleLogger)
        def _on_letter_count_changed(self):
                with qui_utils.notify_error(self._app.errorLog):
                        self._update_letter_count()
                        self._update_button_state()
 
-       @QtCore.pyqtSlot()
+       @qt_compat.Slot()
        @misc_utils.log_exception(_moduleLogger)
        def _on_window_resized(self, checked = True):
                with qui_utils.notify_error(self._app.errorLog):
                        self._scroll_to_bottom()
 
-       @QtCore.pyqtSlot()
-       @QtCore.pyqtSlot(bool)
+       @qt_compat.Slot()
+       @qt_compat.Slot(bool)
        @misc_utils.log_exception(_moduleLogger)
        def _on_close_window(self, checked = True):
                with qui_utils.notify_error(self._app.errorLog):
index 39f0443..ab3fad4 100644 (file)
@@ -8,8 +8,9 @@ import string
 import itertools
 import logging
 
-from PyQt4 import QtGui
-from PyQt4 import QtCore
+import util.qt_compat as qt_compat
+QtCore = qt_compat.QtCore
+QtGui = qt_compat.import_module("QtGui")
 
 from util import qtpie
 from util import qui_utils
@@ -159,8 +160,8 @@ class Dialpad(object):
                with qui_utils.notify_error(self._errorLog):
                        self._entry.clear()
 
-       @QtCore.pyqtSlot()
-       @QtCore.pyqtSlot(bool)
+       @qt_compat.Slot()
+       @qt_compat.Slot(bool)
        @misc_utils.log_exception(_moduleLogger)
        def _on_sms_clicked(self, checked = False):
                with qui_utils.notify_error(self._errorLog):
@@ -173,8 +174,8 @@ class Dialpad(object):
                        numbersWithDescriptions = [(number, "")]
                        self._session.draft.add_contact(contactId, None, title, description, numbersWithDescriptions)
 
-       @QtCore.pyqtSlot()
-       @QtCore.pyqtSlot(bool)
+       @qt_compat.Slot()
+       @qt_compat.Slot(bool)
        @misc_utils.log_exception(_moduleLogger)
        def _on_call_clicked(self, checked = False):
                with qui_utils.notify_error(self._errorLog):
@@ -405,26 +406,26 @@ class History(object):
                        self._categoryManager.add_row(event["time"], row)
                self._itemView.expandAll()
 
-       @QtCore.pyqtSlot(str)
+       @qt_compat.Slot(str)
        @misc_utils.log_exception(_moduleLogger)
        def _on_filter_changed(self, newItem):
                with qui_utils.notify_error(self._errorLog):
                        self._selectedFilter = str(newItem)
                        self._populate_items()
 
-       @QtCore.pyqtSlot()
+       @qt_compat.Slot()
        @misc_utils.log_exception(_moduleLogger)
        def _on_history_updated(self):
                with qui_utils.notify_error(self._errorLog):
                        self._populate_items()
 
-       @QtCore.pyqtSlot()
+       @qt_compat.Slot()
        @misc_utils.log_exception(_moduleLogger)
        def _on_refresh_clicked(self, arg = None):
                with qui_utils.notify_error(self._errorLog):
                        self.refresh(force=True)
 
-       @QtCore.pyqtSlot(QtCore.QModelIndex)
+       @qt_compat.Slot(QtCore.QModelIndex)
        @misc_utils.log_exception(_moduleLogger)
        def _on_row_activated(self, index):
                with qui_utils.notify_error(self._errorLog):
@@ -658,33 +659,33 @@ class Messages(object):
                        self._categoryManager.add_row(item["time"], row)
                self._itemView.expandAll()
 
-       @QtCore.pyqtSlot(str)
+       @qt_compat.Slot(str)
        @misc_utils.log_exception(_moduleLogger)
        def _on_type_filter_changed(self, newItem):
                with qui_utils.notify_error(self._errorLog):
                        self._selectedTypeFilter = str(newItem)
                        self._populate_items()
 
-       @QtCore.pyqtSlot(str)
+       @qt_compat.Slot(str)
        @misc_utils.log_exception(_moduleLogger)
        def _on_status_filter_changed(self, newItem):
                with qui_utils.notify_error(self._errorLog):
                        self._selectedStatusFilter = str(newItem)
                        self._populate_items()
 
-       @QtCore.pyqtSlot()
+       @qt_compat.Slot()
        @misc_utils.log_exception(_moduleLogger)
        def _on_refresh_clicked(self, arg = None):
                with qui_utils.notify_error(self._errorLog):
                        self.refresh(force=True)
 
-       @QtCore.pyqtSlot()
+       @qt_compat.Slot()
        @misc_utils.log_exception(_moduleLogger)
        def _on_messages_updated(self):
                with qui_utils.notify_error(self._errorLog):
                        self._populate_items()
 
-       @QtCore.pyqtSlot(QtCore.QModelIndex)
+       @qt_compat.Slot(QtCore.QModelIndex)
        @misc_utils.log_exception(_moduleLogger)
        def _on_row_activated(self, index):
                with qui_utils.notify_error(self._errorLog):
@@ -713,7 +714,7 @@ class Messages(object):
                        numbersWithDescriptions = [(number, "")]
                        self._session.draft.add_contact(contactId, messageId, title, description, numbersWithDescriptions)
 
-       @QtCore.pyqtSlot(QtCore.QModelIndex)
+       @qt_compat.Slot(QtCore.QModelIndex)
        @misc_utils.log_exception(_moduleLogger)
        def _on_column_resized(self, index, oldSize, newSize):
                self._htmlDelegate.setWidth(newSize, self._itemStore)
@@ -895,7 +896,7 @@ class Contacts(object):
                contacts.sort(key=lambda contact: contact["name"].lower())
                return contacts
 
-       @QtCore.pyqtSlot(str)
+       @qt_compat.Slot(str)
        @misc_utils.log_exception(_moduleLogger)
        def _on_filter_changed(self, newItem):
                with qui_utils.notify_error(self._errorLog):
@@ -903,19 +904,19 @@ class Contacts(object):
                        self.refresh(force=False)
                        self._populate_items()
 
-       @QtCore.pyqtSlot()
+       @qt_compat.Slot()
        @misc_utils.log_exception(_moduleLogger)
        def _on_refresh_clicked(self, arg = None):
                with qui_utils.notify_error(self._errorLog):
                        self.refresh(force=True)
 
-       @QtCore.pyqtSlot()
+       @qt_compat.Slot()
        @misc_utils.log_exception(_moduleLogger)
        def _on_contacts_updated(self):
                with qui_utils.notify_error(self._errorLog):
                        self._populate_items()
 
-       @QtCore.pyqtSlot(QtCore.QModelIndex)
+       @qt_compat.Slot(QtCore.QModelIndex)
        @misc_utils.log_exception(_moduleLogger)
        def _on_row_activated(self, index):
                with qui_utils.notify_error(self._errorLog):
index f2fae9a..4b8a4bf 100644 (file)
@@ -12,7 +12,8 @@ try:
 except ImportError:
        import pickle
 
-from PyQt4 import QtCore
+import util.qt_compat as qt_compat
+QtCore = qt_compat.QtCore
 
 from util import qore_utils
 from util import qui_utils
@@ -37,15 +38,15 @@ class _DraftContact(object):
 
 class Draft(QtCore.QObject):
 
-       sendingMessage = QtCore.pyqtSignal()
-       sentMessage = QtCore.pyqtSignal()
-       calling = QtCore.pyqtSignal()
-       called = QtCore.pyqtSignal()
-       cancelling = QtCore.pyqtSignal()
-       cancelled = QtCore.pyqtSignal()
-       error = QtCore.pyqtSignal(str)
+       sendingMessage = qt_compat.Signal()
+       sentMessage = qt_compat.Signal()
+       calling = qt_compat.Signal()
+       called = qt_compat.Signal()
+       cancelling = qt_compat.Signal()
+       cancelled = qt_compat.Signal()
+       error = qt_compat.Signal(str)
 
-       recipientsChanged = QtCore.pyqtSignal()
+       recipientsChanged = qt_compat.Signal()
 
        def __init__(self, pool, backend, errorLog):
                QtCore.QObject.__init__(self)
@@ -198,19 +199,19 @@ class Session(QtCore.QObject):
 
        # @todo Somehow add support for csv contacts
 
-       stateChange = QtCore.pyqtSignal(str)
-       loggedOut = QtCore.pyqtSignal()
-       loggedIn = QtCore.pyqtSignal()
-       callbackNumberChanged = QtCore.pyqtSignal(str)
+       stateChange = qt_compat.Signal(str)
+       loggedOut = qt_compat.Signal()
+       loggedIn = qt_compat.Signal()
+       callbackNumberChanged = qt_compat.Signal(str)
 
-       accountUpdated = QtCore.pyqtSignal()
-       messagesUpdated = QtCore.pyqtSignal()
-       newMessages = QtCore.pyqtSignal()
-       historyUpdated = QtCore.pyqtSignal()
-       dndStateChange = QtCore.pyqtSignal(bool)
-       voicemailAvailable = QtCore.pyqtSignal(str, str)
+       accountUpdated = qt_compat.Signal()
+       messagesUpdated = qt_compat.Signal()
+       newMessages = qt_compat.Signal()
+       historyUpdated = qt_compat.Signal()
+       dndStateChange = qt_compat.Signal(bool)
+       voicemailAvailable = qt_compat.Signal(str, str)
 
-       error = QtCore.pyqtSignal(str)
+       error = qt_compat.Signal(str)
 
        LOGGEDOUT_STATE = "logged out"
        LOGGINGIN_STATE = "logging in"
index 148a69a..3c0c9e3 100644 (file)
@@ -5,7 +5,8 @@ from __future__ import division
 
 import logging
 
-from PyQt4 import QtCore
+import util.qt_compat as qt_compat
+QtCore = qt_compat.QtCore
 
 import util.misc as misc_utils
 try:
@@ -25,9 +26,9 @@ _moduleLogger = logging.getLogger(__name__)
 
 class StreamToken(QtCore.QObject):
 
-       stateChange = QtCore.pyqtSignal(str)
-       invalidated = QtCore.pyqtSignal()
-       error = QtCore.pyqtSignal(str)
+       stateChange = qt_compat.Signal(str)
+       invalidated = qt_compat.Signal()
+       error = qt_compat.Signal(str)
 
        STATE_PLAY = stream.Stream.STATE_PLAY
        STATE_PAUSE = stream.Stream.STATE_PAUSE
index c86cfbc..e9b8c49 100644 (file)
@@ -1,6 +1,7 @@
 import logging
 
-from PyQt4 import QtCore
+import qt_compat
+QtCore = qt_compat.QtCore
 
 import misc
 
@@ -28,7 +29,7 @@ class _ParentThread(QtCore.QObject):
                QtCore.QObject.__init__(self)
                self._pool = pool
 
-       @QtCore.pyqtSlot(object)
+       @qt_compat.Slot(object)
        @misc.log_exception(_moduleLogger)
        def _on_task_complete(self, taskResult):
                on_success, on_error, isError, result = taskResult
@@ -46,13 +47,13 @@ class _ParentThread(QtCore.QObject):
 
 class _WorkerThread(QtCore.QObject):
 
-       taskComplete  = QtCore.pyqtSignal(object)
+       taskComplete  = qt_compat.Signal(object)
 
        def __init__(self, pool):
                QtCore.QObject.__init__(self)
                self._pool = pool
 
-       @QtCore.pyqtSlot(object)
+       @qt_compat.Slot(object)
        @misc.log_exception(_moduleLogger)
        def _on_task_added(self, task):
                if not self._pool._isRunning:
@@ -71,7 +72,7 @@ class _WorkerThread(QtCore.QObject):
                taskResult = on_success, on_error, isError, result
                self.taskComplete.emit(taskResult)
 
-       @QtCore.pyqtSlot()
+       @qt_compat.Slot()
        @misc.log_exception(_moduleLogger)
        def _on_stop_requested(self):
                self._pool._thread.quit()
@@ -79,8 +80,8 @@ class _WorkerThread(QtCore.QObject):
 
 class AsyncPool(QtCore.QObject):
 
-       _addTask = QtCore.pyqtSignal(object)
-       _stopPool = QtCore.pyqtSignal()
+       _addTask = qt_compat.Signal(object)
+       _stopPool = qt_compat.Signal()
 
        def __init__(self):
                QtCore.QObject.__init__(self)
diff --git a/src/util/qt_compat.py b/src/util/qt_compat.py
new file mode 100644 (file)
index 0000000..066e339
--- /dev/null
@@ -0,0 +1,42 @@
+#!/usr/bin/env python
+
+from __future__ import with_statement
+from __future__ import division
+
+try:
+       import PySide.QtCore as _QtCore
+       QtCore = _QtCore
+       USES_PYSIDE = True
+except ImportError:
+       import PyQt4.QtCore as _QtCore
+       QtCore = _QtCore
+       USES_PYSIDE = False
+
+
+def _pyside_import_module(moduleName):
+       pyside = __import__('PySide', globals(), locals(), [moduleName], -1)
+       return getattr(pyside, moduleName)
+
+
+def _pyqt4_import_module(moduleName):
+       pyside = __import__('PyQt4', globals(), locals(), [moduleName], -1)
+       return getattr(pyside, moduleName)
+
+
+if USES_PYSIDE:
+       import_module = _pyside_import_module
+
+       Signal = QtCore.Signal
+       Slot = QtCore.Slot
+       Property = QtCore.Property
+else:
+       import_module = _pyqt4_import_module
+
+       Signal = QtCore.pyqtSignal
+       Slot = QtCore.pyqtSlot
+       Property = QtCore.pyqtProperty
+
+
+if __name__ == "__main__":
+       pass
+
index c23e512..6b77d5d 100755 (executable)
@@ -3,8 +3,9 @@
 import math
 import logging
 
-from PyQt4 import QtGui
-from PyQt4 import QtCore
+import qt_compat
+QtCore = qt_compat.QtCore
+QtGui = qt_compat.import_module("QtGui")
 
 import misc as misc_utils
 
@@ -496,11 +497,11 @@ class QPieDisplay(QtGui.QWidget):
 
 class QPieButton(QtGui.QWidget):
 
-       activated = QtCore.pyqtSignal(int)
-       highlighted = QtCore.pyqtSignal(int)
-       canceled = QtCore.pyqtSignal()
-       aboutToShow = QtCore.pyqtSignal()
-       aboutToHide = QtCore.pyqtSignal()
+       activated = qt_compat.Signal(int)
+       highlighted = qt_compat.Signal(int)
+       canceled = qt_compat.Signal()
+       aboutToShow = qt_compat.Signal()
+       aboutToHide = qt_compat.Signal()
 
        BUTTON_RADIUS = 24
        DELAY = 250
@@ -778,11 +779,11 @@ class QPieButton(QtGui.QWidget):
 
 class QPieMenu(QtGui.QWidget):
 
-       activated = QtCore.pyqtSignal(int)
-       highlighted = QtCore.pyqtSignal(int)
-       canceled = QtCore.pyqtSignal()
-       aboutToShow = QtCore.pyqtSignal()
-       aboutToHide = QtCore.pyqtSignal()
+       activated = qt_compat.Signal(int)
+       highlighted = qt_compat.Signal(int)
+       canceled = qt_compat.Signal()
+       aboutToShow = qt_compat.Signal()
+       aboutToHide = qt_compat.Signal()
 
        def __init__(self, parent = None):
                QtGui.QWidget.__init__(self, parent)
index c7094f4..50ae9ae 100755 (executable)
@@ -6,7 +6,8 @@ from __future__ import division
 import os
 import warnings
 
-from PyQt4 import QtGui
+import qt_compat
+QtGui = qt_compat.import_module("QtGui")
 
 import qtpie
 
index 0e6e768..0d1fd6a 100644 (file)
@@ -3,8 +3,9 @@ import contextlib
 import datetime
 import logging
 
-from PyQt4 import QtCore
-from PyQt4 import QtGui
+import qt_compat
+QtCore = qt_compat.QtCore
+QtGui = qt_compat.import_module("QtGui")
 
 import misc
 
@@ -54,8 +55,8 @@ class ErrorMessage(object):
 
 class QErrorLog(QtCore.QObject):
 
-       messagePushed = QtCore.pyqtSignal()
-       messagePopped = QtCore.pyqtSignal()
+       messagePushed = qt_compat.Signal()
+       messagePopped = qt_compat.Signal()
 
        def __init__(self):
                QtCore.QObject.__init__(self)
@@ -166,18 +167,18 @@ class ErrorDisplay(object):
                self._severityLabel.setPixmap(self._icons[error.level])
                self._widget.show()
 
-       @QtCore.pyqtSlot()
-       @QtCore.pyqtSlot(bool)
+       @qt_compat.Slot()
+       @qt_compat.Slot(bool)
        @misc.log_exception(_moduleLogger)
        def _on_close(self, checked = False):
                self._errorLog.pop()
 
-       @QtCore.pyqtSlot()
+       @qt_compat.Slot()
        @misc.log_exception(_moduleLogger)
        def _on_message_pushed(self):
                self._show_error()
 
-       @QtCore.pyqtSlot()
+       @qt_compat.Slot()
        @misc.log_exception(_moduleLogger)
        def _on_message_popped(self):
                if len(self._errorLog) == 0:
@@ -264,10 +265,10 @@ class QHtmlDelegate(QtGui.QStyledItemDelegate):
 
 class QSignalingMainWindow(QtGui.QMainWindow):
 
-       closed = QtCore.pyqtSignal()
-       hidden = QtCore.pyqtSignal()
-       shown = QtCore.pyqtSignal()
-       resized = QtCore.pyqtSignal()
+       closed = qt_compat.Signal()
+       hidden = qt_compat.Signal()
+       shown = qt_compat.Signal()
+       resized = qt_compat.Signal()
 
        def __init__(self, *args, **kwd):
                QtGui.QMainWindow.__init__(*((self, )+args), **kwd)
index cc458bf..7e6265b 100644 (file)
@@ -5,8 +5,9 @@ from __future__ import division
 
 import logging
 
-from PyQt4 import QtGui
-from PyQt4 import QtCore
+import qt_compat
+QtCore = qt_compat.QtCore
+QtGui = qt_compat.import_module("QtGui")
 
 from util import qui_utils
 from util import misc as misc_utils