Commit 35de0411 authored by Dan Pascu's avatar Dan Pascu

Switched to Qt5

parent a064ccd0
......@@ -4,6 +4,13 @@ import os
import sys
from application import log
def except_hook(exception_type, exception_value, traceback):
sys.__excepthook__(exception_type, exception_value, traceback)
sys.excepthook = except_hook # pyqt5 (>=5.5) will abort if an exception happens in python code when called from Qt, unless we define this
log.level.current = log.level.WARNING
frozen = hasattr(sys, 'frozen')
......
import os
import sys
import sip
sip.setapi('QString', 2)
sip.setapi('QVariant', 2)
from PyQt4.QtCore import Qt, QEvent
from PyQt4.QtGui import QApplication, QMessageBox
QApplication.setAttribute(Qt.AA_X11InitThreads, True)
from PyQt5.QtCore import Qt, QEvent
from PyQt5.QtWidgets import QApplication, QMessageBox
from application import log
from application.notification import IObserver, NotificationCenter, NotificationData
......
from PyQt4 import uic
from PyQt5 import uic
from blink import __date__, __version__
from blink.resources import Resources
......
import cjson
import os
import re
import sys
import urllib
import urllib2
from collections import defaultdict
from PyQt4 import uic
from PyQt4.QtCore import Qt, QAbstractListModel, QModelIndex, QUrl
from PyQt4.QtGui import QAction, QButtonGroup, QComboBox, QIcon, QMenu, QMovie, QSortFilterProxyModel
from PyQt4.QtNetwork import QNetworkAccessManager
from PyQt4.QtWebKit import QWebView
from PyQt5 import uic
from PyQt5.QtCore import Qt, QAbstractListModel, QModelIndex, QSortFilterProxyModel, QUrl, QUrlQuery
from PyQt5.QtGui import QIcon, QMovie
from PyQt5.QtNetwork import QNetworkAccessManager
from PyQt5.QtWebKitWidgets import QWebView
from PyQt5.QtWidgets import QAction, QButtonGroup, QComboBox, QMenu
import cjson
from application.notification import IObserver, NotificationCenter
from application.python import Null
from application.system import makedirs
from collections import defaultdict
from gnutls.crypto import X509Certificate, X509PrivateKey
from gnutls.errors import GNUTLSError
from zope.interface import implements
......@@ -609,7 +610,7 @@ class ServerToolsWebView(QWebView):
self.last_error = None
def _SH_URLChanged(self, url):
query_items = dict(url.queryItems())
query_items = dict(QUrlQuery(url).queryItems())
self.tab = query_items.get('tab') or self.tab
self.task = query_items.get('task') or self.task
......@@ -618,8 +619,10 @@ class ServerToolsWebView(QWebView):
self.task = task
self.account = account
url = QUrl(account.server.settings_url)
url_query = QUrlQuery()
for name, value in self.query_items:
url.addQueryItem(name, value)
url_query.addQueryItem(name, value)
url.setQuery(url_query)
self.load(url)
......
......@@ -5,11 +5,13 @@ import locale
import os
import re
from PyQt4 import uic
from PyQt4.QtCore import Qt, QBuffer, QEasingCurve, QEvent, QPoint, QPointF, QPropertyAnimation, QRect, QRectF, QSettings, QSize, QSizeF, QTimer, QUrl, pyqtSignal
from PyQt4.QtGui import QApplication, QDesktopServices, QAction, QImageReader, QKeyEvent, QLabel, QListView, QMenu, QTextCursor, QTextDocument, QTextEdit, QToolButton
from PyQt4.QtGui import QBrush, QColor, QIcon, QLinearGradient, QPainter, QPalette, QPen, QPixmap, QPolygonF, QStyle, QStyleOption, QStylePainter, QTextCharFormat
from PyQt4.QtWebKit import QWebPage, QWebSettings, QWebView
from PyQt5 import uic
from PyQt5.QtCore import Qt, QBuffer, QEasingCurve, QEvent, QPoint, QPointF, QPropertyAnimation, QRect, QRectF, QSettings, QSize, QSizeF, QTimer, QUrl, pyqtSignal
from PyQt5.QtGui import QBrush, QColor, QIcon, QImageReader, QKeyEvent, QLinearGradient, QPainter, QPalette, QPen, QPixmap, QPolygonF, QTextCharFormat, QTextCursor, QTextDocument
from PyQt5.QtGui import QDesktopServices
from PyQt5.QtWebKit import QWebSettings
from PyQt5.QtWebKitWidgets import QWebPage, QWebView
from PyQt5.QtWidgets import QApplication, QAction, QLabel, QListView, QMenu, QStyle, QStyleOption, QStylePainter, QTextEdit, QToolButton
from abc import ABCMeta, abstractmethod
from application.notification import IObserver, NotificationCenter, ObserverWeakrefProxy
......@@ -1311,7 +1313,7 @@ class VideoWidget(VideoSurface, ui_class):
start_geometry = start_rect.translated(self.mapToGlobal(QPoint(0, 0)))
final_geometry = final_rect.translated(screen_area.topRight() - final_rect.topRight() + QPoint(-10, 10))
pixmap = QPixmap.grabWidget(self)
pixmap = self.grab()
self.no_flicker_widget.resize(pixmap.size())
self.no_flicker_widget.setPixmap(pixmap)
self.no_flicker_widget.setGeometry(self.rect().translated(self.mapToGlobal(QPoint(0, 0))))
......@@ -1374,7 +1376,7 @@ class VideoWidget(VideoSurface, ui_class):
def _SH_DetachAnimationFinished(self):
if self.detach_animation.direction() == QPropertyAnimation.Backward:
pixmap = QPixmap.grabWidget(self)
pixmap = self.grab()
self.no_flicker_widget.resize(pixmap.size())
self.no_flicker_widget.setPixmap(pixmap)
self.no_flicker_widget.setGeometry(self.geometry())
......
......@@ -6,13 +6,13 @@ import re
import socket
import sys
from PyQt4 import uic
from PyQt4.QtCore import Qt, QAbstractListModel, QAbstractTableModel, QEasingCurve, QModelIndex, QPropertyAnimation, pyqtSignal
from PyQt4.QtCore import QByteArray, QEvent, QMimeData, QPointF, QRectF, QRect, QSize, QTimer, QUrl
from PyQt4.QtGui import QBrush, QColor, QIcon, QLinearGradient, QPainter, QPainterPath, QPalette, QPen, QPixmap, QPolygonF, QStyle
from PyQt4.QtGui import QAction, QMenu, QKeyEvent, QMouseEvent, QSortFilterProxyModel, QItemDelegate, QStyledItemDelegate
from PyQt4.QtGui import QApplication, QButtonGroup, QComboBox, QFileDialog, QHBoxLayout, QListView, QRadioButton, QTableView, QWidget
from PyQt4.QtWebKit import QWebView
from PyQt5 import uic
from PyQt5.QtCore import Qt, QAbstractListModel, QAbstractTableModel, QEasingCurve, QModelIndex, QPropertyAnimation, QSortFilterProxyModel
from PyQt5.QtCore import QByteArray, QEvent, QMimeData, QPointF, QRectF, QRect, QSize, QTimer, QUrl, pyqtSignal
from PyQt5.QtGui import QBrush, QColor, QIcon, QKeyEvent, QLinearGradient, QMouseEvent, QPainter, QPainterPath, QPalette, QPen, QPixmap, QPolygonF
from PyQt5.QtWebKitWidgets import QWebView
from PyQt5.QtWidgets import QAction, QApplication, QItemDelegate, QStyledItemDelegate, QStyle
from PyQt5.QtWidgets import QButtonGroup, QComboBox, QFileDialog, QHBoxLayout, QListView, QMenu, QRadioButton, QTableView, QWidget
from application import log
from application.notification import IObserver, NotificationCenter, NotificationData, ObserverWeakrefProxy
......@@ -3325,8 +3325,10 @@ class ContactListView(QListView):
event.setDropAction(Qt.MoveAction)
model = self.model()
mime_data = event.mimeData()
for mime_type in model.accepted_mime_types:
if event.provides(mime_type):
if mime_data.hasFormat(mime_type):
self.viewport().update(self.visualRect(self.drop_indicator_index))
self.drop_indicator_index = QModelIndex()
index = self.indexAt(event.pos())
......@@ -3444,11 +3446,9 @@ class ContactListView(QListView):
def _AH_SendFiles(self):
session_manager = SessionManager()
files = QFileDialog.getOpenFileNames(self, u'Select File(s)', session_manager.send_file_directory, u'Any file (*.*)')
if files:
contact = self.selectionModel().selectedIndexes()[0].data(Qt.UserRole)
for filename in files:
session_manager.send_file(contact, contact.uri, filename)
contact = self.selectionModel().selectedIndexes()[0].data(Qt.UserRole)
for filename in QFileDialog.getOpenFileNames(self, u'Select File(s)', session_manager.send_file_directory, u'Any file (*.*)')[0]:
session_manager.send_file(contact, contact.uri, filename)
def _AH_RequestScreen(self):
contact = self.selectionModel().selectedIndexes()[0].data(Qt.UserRole)
......@@ -3746,8 +3746,10 @@ class ContactSearchListView(QListView):
def dragMoveEvent(self, event):
super(ContactSearchListView, self).dragMoveEvent(event)
mime_data = event.mimeData()
for mime_type in self.model().accepted_mime_types:
if event.provides(mime_type):
if mime_data.hasFormat(mime_type):
self.viewport().update(self.visualRect(self.drop_indicator_index))
self.drop_indicator_index = QModelIndex()
index = self.indexAt(event.pos())
......@@ -3834,11 +3836,9 @@ class ContactSearchListView(QListView):
def _AH_SendFiles(self):
session_manager = SessionManager()
files = QFileDialog.getOpenFileNames(self, u'Select File(s)', session_manager.send_file_directory, u'Any file (*.*)')
if files:
contact = self.selectionModel().selectedIndexes()[0].data(Qt.UserRole)
for filename in files:
session_manager.send_file(contact, contact.uri, filename)
contact = self.selectionModel().selectedIndexes()[0].data(Qt.UserRole)
for filename in QFileDialog.getOpenFileNames(self, u'Select File(s)', session_manager.send_file_directory, u'Any file (*.*)')[0]:
session_manager.send_file(contact, contact.uri, filename)
def _AH_RequestScreen(self):
contact = self.selectionModel().selectedIndexes()[0].data(Qt.UserRole)
......@@ -4061,9 +4061,12 @@ class ContactDetailView(QListView):
def dragMoveEvent(self, event):
super(ContactDetailView, self).dragMoveEvent(event)
model = self.model()
mime_data = event.mimeData()
for mime_type in model.accepted_mime_types:
if event.provides(mime_type):
if mime_data.hasFormat(mime_type):
self.viewport().update(self.visualRect(self.drop_indicator_index))
self.drop_indicator_index = QModelIndex()
index = self.indexAt(event.pos())
......@@ -4135,17 +4138,15 @@ class ContactDetailView(QListView):
def _AH_SendFiles(self):
session_manager = SessionManager()
files = QFileDialog.getOpenFileNames(self, u'Select File(s)', session_manager.send_file_directory, u'Any file (*.*)')
if files:
contact = self.contact_list.selectionModel().selectedIndexes()[0].data(Qt.UserRole)
selected_indexes = self.selectionModel().selectedIndexes()
item = selected_indexes[0].data(Qt.UserRole) if selected_indexes else None
if isinstance(item, ContactURI):
selected_uri = item.uri
else:
selected_uri = contact.uri
for filename in files:
session_manager.send_file(contact, selected_uri, filename)
contact = self.contact_list.selectionModel().selectedIndexes()[0].data(Qt.UserRole)
selected_indexes = self.selectionModel().selectedIndexes()
item = selected_indexes[0].data(Qt.UserRole) if selected_indexes else None
if isinstance(item, ContactURI):
selected_uri = item.uri
else:
selected_uri = contact.uri
for filename in QFileDialog.getOpenFileNames(self, u'Select File(s)', session_manager.send_file_directory, u'Any file (*.*)')[0]:
session_manager.send_file(contact, selected_uri, filename)
def _AH_RequestScreen(self):
contact = self.contact_list.selectionModel().selectedIndexes()[0].data(Qt.UserRole)
......@@ -4445,7 +4446,7 @@ class ContactURIModel(QAbstractTableModel):
for row in range(len(items)):
self.table_view.openPersistentEditor(self.index(row, ContactURIModel.TypeColumn))
self.table_view.openPersistentEditor(self.index(row, ContactURIModel.DefaultColumn))
self.table_view.horizontalHeader().setResizeMode(ContactURIModel.AddressColumn, self.table_view.horizontalHeader().Stretch)
self.table_view.horizontalHeader().setSectionResizeMode(ContactURIModel.AddressColumn, self.table_view.horizontalHeader().Stretch)
def init_with_contact(self, contact):
items = [ContactURIItem(uri.id, uri.uri, uri.type, default=uri is contact.uris.default) for uri in contact.uris]
......@@ -4458,7 +4459,7 @@ class ContactURIModel(QAbstractTableModel):
for row in range(len(items)):
self.table_view.openPersistentEditor(self.index(row, ContactURIModel.TypeColumn))
self.table_view.openPersistentEditor(self.index(row, ContactURIModel.DefaultColumn))
self.table_view.horizontalHeader().setResizeMode(ContactURIModel.AddressColumn, self.table_view.horizontalHeader().Stretch)
self.table_view.horizontalHeader().setSectionResizeMode(ContactURIModel.AddressColumn, self.table_view.horizontalHeader().Stretch)
def update_from_contact(self, contact):
added_items = [item for item in self.items if item.id is None and not item.ghost]
......@@ -4480,7 +4481,7 @@ class ContactURIModel(QAbstractTableModel):
for row in range(len(items)):
self.table_view.openPersistentEditor(self.index(row, ContactURIModel.TypeColumn))
self.table_view.openPersistentEditor(self.index(row, ContactURIModel.DefaultColumn))
self.table_view.horizontalHeader().setResizeMode(ContactURIModel.AddressColumn, self.table_view.horizontalHeader().Stretch)
self.table_view.horizontalHeader().setSectionResizeMode(ContactURIModel.AddressColumn, self.table_view.horizontalHeader().Stretch)
def reset(self):
self.beginResetModel()
......@@ -4510,7 +4511,7 @@ class ContactURITableView(QTableView):
self.setItemDelegate(ContactURIDelegate(self))
self.context_menu = QMenu(self)
self.context_menu.addAction(QAction("Delete", self, triggered=self._AH_DeleteSelection))
self.horizontalHeader().setResizeMode(self.horizontalHeader().ResizeToContents)
self.horizontalHeader().setSectionResizeMode(self.horizontalHeader().ResizeToContents)
def selectionChanged(self, selected, deselected):
super(ContactURITableView, self).selectionChanged(selected, deselected)
......
from PyQt4.QtCore import QEvent
from PyQt5.QtCore import QEvent
from application.python.descriptor import classproperty
......
import os
from PyQt4 import uic
from PyQt4.QtCore import Qt, QUrl
from PyQt4.QtGui import QAction, QDesktopServices, QMenu
from PyQt5 import uic
from PyQt5.QtCore import Qt, QUrl
from PyQt5.QtGui import QDesktopServices
from PyQt5.QtWidgets import QAction, QMenu
from application.notification import IObserver, NotificationCenter
from application.python import Null
......
......@@ -3,7 +3,7 @@ import bisect
import cPickle as pickle
import re
from PyQt4.QtGui import QIcon
from PyQt5.QtGui import QIcon
from application.notification import IObserver, NotificationCenter
from application.python import Null
......
......@@ -4,10 +4,10 @@ import os
from functools import partial
from PyQt4 import uic
from PyQt4.QtCore import Qt, QSettings, QUrl
from PyQt4.QtGui import QAction, QActionGroup, QDesktopServices, QMenu, QShortcut
from PyQt4.QtGui import QApplication, QFileDialog, QIcon, QStyle, QStyleOptionComboBox, QStyleOptionFrameV2, QSystemTrayIcon
from PyQt5 import uic
from PyQt5.QtCore import Qt, QSettings, QUrl
from PyQt5.QtGui import QDesktopServices, QIcon
from PyQt5.QtWidgets import QAction, QActionGroup, QApplication, QFileDialog, QMenu, QShortcut, QStyle, QStyleOptionComboBox, QStyleOptionFrame, QSystemTrayIcon
from application.notification import IObserver, NotificationCenter
from application.python import Null, limit
......@@ -227,7 +227,7 @@ class MainWindow(base_class, ui_class):
# adjust search box height depending on theme as the value set in designer isn't suited for all themes
search_box = self.search_box
option = QStyleOptionFrameV2()
option = QStyleOptionFrame()
search_box.initStyleOption(option)
frame_width = search_box.style().pixelMetric(QStyle.PM_DefaultFrameWidth, option, search_box)
if frame_width < 4:
......@@ -476,7 +476,7 @@ class MainWindow(base_class, ui_class):
blink_settings.save()
def _SH_AccountStateClicked(self, checked):
filename = QFileDialog.getOpenFileName(self, u'Select Icon', self.last_icon_directory, u"Images (*.png *.tiff *.jpg *.xmp *.svg)")
filename = QFileDialog.getOpenFileName(self, u'Select Icon', self.last_icon_directory, u"Images (*.png *.tiff *.jpg *.xmp *.svg)")[0]
if filename:
self.last_icon_directory = os.path.dirname(filename)
filename = filename if os.path.realpath(filename) != os.path.realpath(self.default_icon_path) else None
......@@ -845,19 +845,19 @@ class MainWindow(base_class, ui_class):
def _NH_SIPAccountManagerDidAddAccount(self, notification):
account = notification.data.account
action = QAction(account.id if account is not BonjourAccount() else u'Bonjour', None)
action = self.accounts_menu.addAction(account.id if account is not BonjourAccount() else u'Bonjour')
action.setEnabled(True if account is not BonjourAccount() else BonjourAccount.mdns_available)
action.setCheckable(True)
action.setChecked(account.enabled)
action.setData(account)
action.triggered.connect(partial(self._AH_AccountActionTriggered, action))
self.accounts_menu.addAction(action)
action = QAction(self.mwi_icons[0], account.id, None)
action = self.voicemail_menu.addAction(self.mwi_icons[0], account.id)
action.setVisible(False if account is BonjourAccount() else account.enabled and account.message_summary.enabled)
action.setEnabled(False if account is BonjourAccount() else account.voicemail_uri is not None)
action.setData(account)
action.triggered.connect(partial(self._AH_VoicemailActionTriggered, action))
self.voicemail_menu.addAction(action)
def _NH_SIPAccountManagerDidRemoveAccount(self, notification):
account = notification.data.account
......
......@@ -2,9 +2,10 @@
import os
import urlparse
from PyQt4 import uic
from PyQt4.QtCore import Qt, QEvent, QRegExp
from PyQt4.QtGui import QActionGroup, QButtonGroup, QFileDialog, QFont, QListView, QListWidgetItem, QMessageBox, QRegExpValidator, QSpinBox, QStyle, QStyleOptionComboBox, QStyledItemDelegate, QValidator
from PyQt5 import uic
from PyQt5.QtCore import Qt, QEvent, QRegExp
from PyQt5.QtGui import QFont, QRegExpValidator, QValidator
from PyQt5.QtWidgets import QActionGroup, QButtonGroup, QFileDialog, QListView, QListWidgetItem, QMessageBox, QSpinBox, QStyle, QStyleOptionComboBox, QStyledItemDelegate
from application import log
from application.notification import IObserver, NotificationCenter
......@@ -1285,7 +1286,7 @@ class PreferencesWindow(base_class, ui_class):
# TODO: open the file selection dialog in non-modal mode (and the error messages boxes as well). -Dan
account = self.selected_account
directory = os.path.dirname(account.tls.certificate.normalized) if account.tls.certificate else Path('~').normalized
cert_path = QFileDialog.getOpenFileName(self, u'Select Certificate File', directory, u"TLS certificates (*.crt *.pem)") or None
cert_path = QFileDialog.getOpenFileName(self, u'Select Certificate File', directory, u"TLS certificates (*.crt *.pem)")[0] or None
if cert_path is not None:
cert_path = os.path.normpath(cert_path)
if cert_path != account.tls.certificate:
......@@ -1643,7 +1644,7 @@ class PreferencesWindow(base_class, ui_class):
# TODO: open the file selection dialog in non-modal mode (and the error messages boxes as well). -Dan
settings = SIPSimpleSettings()
directory = os.path.dirname(settings.tls.ca_list.normalized) if settings.tls.ca_list else Path('~').normalized
ca_path = QFileDialog.getOpenFileName(self, u'Select Certificate Authority File', directory, u"TLS certificates (*.crt *.pem)") or None
ca_path = QFileDialog.getOpenFileName(self, u'Select Certificate Authority File', directory, u"TLS certificates (*.crt *.pem)")[0] or None
if ca_path is not None:
ca_path = os.path.normpath(ca_path)
if ca_path != settings.tls.ca_list:
......
......@@ -5,8 +5,8 @@ import re
import socket
import uuid
from PyQt4 import uic
from PyQt4.QtCore import Qt, QTimer
from PyQt5 import uic
from PyQt5.QtCore import Qt, QTimer
from application.notification import IObserver, NotificationCenter, NotificationData
from application.python import Null, limit
......@@ -24,7 +24,7 @@ from sipsimple.account.bonjour import BonjourPresenceState
from sipsimple.account.xcap import Icon, OfflineStatus
from sipsimple.configuration.settings import SIPSimpleSettings
from sipsimple.payloads import caps, pidf, prescontent, rpid
from sipsimple.payloads import cipid; cipid # needs to be imported to register its namespace and extensions
from sipsimple.payloads import cipid
from sipsimple.threading.green import run_in_green_thread
from sipsimple.util import ISOTimestamp
......@@ -33,6 +33,8 @@ from blink.configuration.settings import BlinkSettings
from blink.resources import IconManager, Resources
from blink.util import run_in_gui_thread
del cipid # this only needs to be imported to register its namespace and extensions
__all__ = ['PresenceManager', 'PendingWatcherDialog']
......
......@@ -7,8 +7,8 @@ import os
import platform
import sys
from PyQt4.QtCore import Qt, QBuffer
from PyQt4.QtGui import QIcon, QPixmap
from PyQt5.QtCore import Qt, QBuffer
from PyQt5.QtGui import QIcon, QPixmap
from application.python.descriptor import classproperty
from application.python.types import Singleton
......
from sip import voidptr
from PyQt4.QtCore import QThread
from PyQt4.QtGui import QImage
from PyQt5.QtCore import QThread
from PyQt5.QtGui import QImage
from application.notification import NotificationCenter, NotificationData
......
from PyQt4.QtCore import QObject, QSize, QSocketNotifier, QThread, pyqtSignal
from PyQt4.QtGui import QApplication
from PyQt5.QtCore import QObject, QSize, QSocketNotifier, QThread, pyqtSignal
from PyQt5.QtWidgets import QApplication
from application.notification import NotificationCenter
from application.python import Null
......
......@@ -4,9 +4,10 @@ from __future__ import division
import os
import platform
from PyQt4 import uic
from PyQt4.QtCore import Qt, QEasingCurve, QEvent, QPoint, QPropertyAnimation, QRect, QTimer, QUrl
from PyQt4.QtGui import QApplication, QDesktopServices, QFrame, QIcon, QImage, QMenu, QPainter, QStyle, QStyleOption, QStylePainter, QTransform, QWidget, qRgb
from PyQt5 import uic
from PyQt5.QtCore import Qt, QEasingCurve, QEvent, QPoint, QPropertyAnimation, QRect, QTimer, QUrl
from PyQt5.QtGui import QDesktopServices, QIcon, QImage, QPainter, QTransform, qRgb
from PyQt5.QtWidgets import QApplication, QFrame, QMenu, QStyle, QStyleOption, QStylePainter, QWidget
from application.system import makedirs
from collections import defaultdict
......@@ -510,7 +511,7 @@ class ScreensharingToolbox(base_class, ui_class):
def paintEvent(self, event): # make the widget style aware
option = QStyleOption()
option.init(self)
option.initFrom(self)
painter = QStylePainter(self)
painter.drawPrimitive(QStyle.PE_Widget, option)
......
......@@ -15,10 +15,11 @@ from enum import Enum
from itertools import chain
from operator import attrgetter
from PyQt4 import uic
from PyQt4.QtCore import Qt, QAbstractListModel, QByteArray, QEasingCurve, QEvent, QMimeData, QModelIndex, QObject, QPointF, QProcess, QPropertyAnimation, QRect, QRectF, QSize, QTimer, QUrl, pyqtSignal
from PyQt4.QtGui import QBrush, QColor, QDialog, QDrag, QIcon, QLabel, QLinearGradient, QListView, QMenu, QPainter, QPainterPath, QPalette, QPen, QPixmap, QPolygonF, QShortcut
from PyQt4.QtGui import QApplication, QDesktopServices, QStyle, QStyledItemDelegate, QStyleOption
from PyQt5 import uic
from PyQt5.QtCore import Qt, QAbstractListModel, QEasingCurve, QModelIndex, QObject, QProcess, QPropertyAnimation, pyqtSignal
from PyQt5.QtCore import QByteArray, QEvent, QMimeData, QPointF, QRect, QRectF, QSize, QTimer, QUrl
from PyQt5.QtGui import QBrush, QColor, QDesktopServices, QDrag, QIcon, QLinearGradient, QPainter, QPainterPath, QPalette, QPen, QPixmap, QPolygonF
from PyQt5.QtWidgets import QApplication, QDialog, QLabel, QListView, QMenu, QShortcut, QStyle, QStyledItemDelegate, QStyleOption
from application import log
from application.notification import IObserver, NotificationCenter, NotificationData, ObserverWeakrefProxy
......@@ -2642,13 +2643,6 @@ class AudioSessionModel(QAbstractListModel):
session.widget.mute_button.show()
# workaround class because passing context to the QShortcut constructor segfaults (fixed upstreams on 09-Apr-2013) -Dan
class QShortcut(QShortcut):
def __init__(self, key, parent, member=None, ambiguousMember=None, context=Qt.WindowShortcut):
super(QShortcut, self).__init__(key, parent, member, ambiguousMember)
self.setContext(context)
class AudioSessionListView(QListView):
implements(IObserver)
......@@ -2798,12 +2792,13 @@ class AudioSessionListView(QListView):
super(AudioSessionListView, self).dragMoveEvent(event)
model = self.model()
mime_data = event.mimeData()
for session in model.sessions:
session.widget.drop_indicator = False
for mime_type in model.accepted_mime_types:
if event.provides(mime_type):
if mime_data.hasFormat(mime_type):
index = self.indexAt(event.pos())
rect = self.visualRect(index)
session = index.data(Qt.UserRole)
......@@ -3254,7 +3249,7 @@ class ChatSessionDelegate(QStyledItemDelegate, ColorHelperMixin):
session.widget.setFixedSize(option.rect.size())
painter.save()
painter.drawPixmap(option.rect, QPixmap.grabWidget(session.widget))
painter.drawPixmap(option.rect, session.widget.grab())
if option.state & QStyle.State_MouseOver:
self.drawSessionIndicators(session, option, painter, session.widget)
if 0 and (option.state & QStyle.State_MouseOver):
......@@ -3579,9 +3574,12 @@ class ChatSessionListView(QListView):
def dragMoveEvent(self, event):
super(ChatSessionListView, self).dragMoveEvent(event)
model = self.model()
mime_data = event.mimeData()
for mime_type in model.accepted_mime_types:
if event.provides(mime_type):
if mime_data.hasFormat(mime_type):
self.viewport().update(self.visualRect(self.drop_indicator_index))
self.drop_indicator_index = QModelIndex()
index = self.indexAt(event.pos())
......@@ -4480,7 +4478,7 @@ class FileTransferDelegate(QStyledItemDelegate):
item.widget.state_indicator.show_cancel_button = False
item.widget.setFixedSize(option.rect.size())
painter.drawPixmap(option.rect, QPixmap.grabWidget(item.widget))
painter.drawPixmap(option.rect, item.widget.grab())
def sizeHint(self, option, index):
return index.data(Qt.SizeHintRole)
......@@ -4726,7 +4724,7 @@ class ConferenceParticipantDelegate(QStyledItemDelegate, ColorHelperMixin):
participant.widget.setFixedSize(option.rect.size())
painter.save()
painter.drawPixmap(option.rect, QPixmap.grabWidget(participant.widget))
painter.drawPixmap(option.rect, participant.widget.grab())
if (option.state & QStyle.State_MouseOver) and participant.widget.isEnabled():
self.drawRemoveIndicator(participant, option, painter, participant.widget)
if 0 and (option.state & QStyle.State_MouseOver):
......@@ -4999,9 +4997,12 @@ class ConferenceParticipantListView(QListView, ColorHelperMixin):
def dragMoveEvent(self, event):
super(ConferenceParticipantListView, self).dragMoveEvent(event)
model = self.model()
mime_data = event.mimeData()
for mime_type in model.accepted_mime_types:
if event.provides(mime_type):
if mime_data.hasFormat(mime_type):
handler = getattr(self, '_DH_%s' % mime_type.replace('/', ' ').replace('-', ' ').title().replace(' ', ''))
handler(event)
self.viewport().update()
......
from PyQt4.QtCore import QObject, QThread, QTimer
from PyQt4.QtGui import QApplication
from PyQt5.QtCore import QObject, QThread, QTimer
from PyQt5.QtWidgets import QApplication
from application.python.decorator import decorator, preserve_signature
from application.python.descriptor import classproperty
from application.python.types import Singleton
......
from PyQt4.QtCore import Qt, QLineF, QPointF, QRectF, QSize, QTimer, pyqtSignal, pyqtSignature
from PyQt4.QtGui import QAction, QBrush, QColor, QCommonStyle, QLinearGradient, QIcon, QMenu, QPainter, QPainterPath, QPalette, QPen, QPixmap
from PyQt4.QtGui import QPolygonF, QPushButton, QStyle, QStyleOptionToolButton, QStylePainter, QToolButton
from PyQt5.QtCore import Qt, QLineF, QPointF, QRectF, QSize, QTimer, pyqtSignal
from PyQt5.QtGui import QBrush, QColor, QLinearGradient, QIcon, QPainter, QPainterPath, QPalette, QPen, QPixmap, QPolygonF
from PyQt5.QtWidgets import QAction, QCommonStyle, QMenu, QPushButton, QStyle, QStyleOptionToolButton, QStylePainter, QToolButton
from blink.resources import Resources
from blink.widgets.color import ColorScheme, ColorUtils, ColorHelperMixin
......@@ -379,7 +379,6 @@ class StateButtonStyle(QCommonStyle, ColorHelperMixin):
_pixel_metrics = {QStyle.PM_MenuButtonIndicator: 11, QStyle.PM_DefaultFrameWidth: 3, QStyle.PM_ButtonMargin: 1, QStyle.PM_ButtonShiftHorizontal: 0, QStyle.PM_ButtonShiftVertical: 0,
QStyle.PM_ButtonIconSize: 32}
@pyqtSignature("polish(QWidget*)")
def polish(self, widget):
widget.setAttribute(Qt.WA_Hover)
super(StateButtonStyle, self).polish(widget)
......
from PyQt4.QtCore import Qt
from PyQt4.QtGui import QColor
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QColor
from application.python import limit
from application.python.decorator import decorator, preserve_signature
from math import fmod, isnan
......
from PyQt4.QtCore import QEasingCurve, QParallelAnimationGroup, QPropertyAnimation, QPoint, pyqtSignal
from PyQt4.QtGui import QStackedWidget
from PyQt5.QtCore import QEasingCurve, QParallelAnimationGroup, QPropertyAnimation, QPoint, pyqtSignal
from PyQt5.QtWidgets import QStackedWidget
from blink.widgets.util import QtDynamicProperty
......
from PyQt4.QtCore import Qt, QEvent, QPoint, QRect, QSize
from PyQt4.QtGui import QColor, QFrame, QPainter, QPixmap
from PyQt5.QtCore import Qt, QEvent, QPoint, QRect, QSize
from PyQt5.QtGui import QColor, QPainter, QPixmap
from PyQt5.QtWidgets import QFrame
from blink.resources import Resources
from blink.widgets.util import QtDynamicProperty
......
from PyQt4.QtCore import Qt, QLine, QPointF, QMetaObject, pyqtSignal
from PyQt4.QtGui import QColor, QLinearGradient, QPainterPath, QPen, QPolygonF, QStyle, QStyleOption, QStylePainter, QWidget
from PyQt5.QtCore import Qt, QLineF, QPointF, QMetaObject, pyqtSignal
from PyQt5.QtGui import QColor, QLinearGradient, QPainterPath, QPen, QPolygonF
from PyQt5.QtWidgets import QStyle, QStyleOption, QStylePainter, QWidget
from abc import ABCMeta, abstractmethod
from application.python import limit
......@@ -185,7 +186,7 @@ class GraphWidget(QWidget, ColorHelperMixin):
brush_color = self.color_with_alpha(graph.color, self.fillTransparency)
dataset = islice(reversed(graph.data), graph_width)
if self.graphStyle == self.BarStyle:
lines = [QLine(x*self.horizontalPixelsPerUnit, 0, x*self.horizontalPixelsPerUnit, y*height_scaling) for x, y in enumerate(dataset)]
lines = [QLineF(x*self.horizontalPixelsPerUnit, 0, x*self.horizontalPixelsPerUnit, y*height_scaling) for x, y in enumerate(dataset)]
painter.setPen(QPen(pen_color, self.lineThickness))
painter.drawLines(lines)
else:
......
......@@ -2,8 +2,9 @@
import os
from datetime import timedelta
from PyQt4.QtCore import Qt, QEvent
from PyQt4.QtGui import QAction, QBrush, QColor, QFileDialog, QFontMetrics, QIcon, QLabel, QLinearGradient, QMenu, QPainter, QPalette, QPen
from PyQt5.QtCore import Qt, QEvent
from PyQt5.QtGui import QBrush, QColor, QFontMetrics, QIcon, QLinearGradient, QPainter, QPalette, QPen
from PyQt5.QtWidgets import QAction, QFileDialog, QLabel, QMenu
from application.python.types import MarkerType
......@@ -106,7 +107,7 @@ class IconSelector(QLabel):
super(IconSelector, self).mouseReleaseEvent(event)
def _SH_ChangeIconActionTriggered(self):
filename = QFileDialog.getOpenFileName(self, u'Select Icon', self.last_icon_directory, u"Images (*.png *.tiff *.jpg *.xmp *.svg)")
filename = QFileDialog.getOpenFileName(self, u'Select Icon', self.last_icon_directory, u"Images (*.png *.tiff *.jpg *.xmp *.svg)")[0]
if filename:
self.filename = filename
......
import re
from PyQt4.QtCore import Qt, QEvent, pyqtSignal
from PyQt4.QtGui import QAbstractButton, QLineEdit, QBoxLayout, QHBoxLayout, QLabel, QLayout, QPainter, QPalette, QPixmap, QSpacerItem, QSizePolicy, QStyle, QWidget, QStyleOptionFrameV2
from PyQt5.QtCore import Qt, QEvent, pyqtSignal
from PyQt5.QtGui import QPainter, QPalette, QPixmap
from PyQt5.QtWidgets import QAbstractButton, QLineEdit, QBoxLayout, QHBoxLayout, QLabel, QLayout, QSizePolicy, QSpacerItem, QStyle, QStyleOptionFrame, QWidget
from blink.resources import Resources
from blink.widgets.util import QtDynamicProperty
......@@ -15,7 +16,7 @@ class SideWidget(QWidget):
sizeHintChanged = pyqtSignal()
def __init__(self, parent=None):
QWidget.__init__(self, parent)
super(SideWidget, self).__init__(parent)
def event(self, event):
if event.type() == QEvent.LayoutRequest:
......@@ -28,7 +29,7 @@ class LineEdit(QLineEdit):
widgetSpacing = QtDynamicProperty('widgetSpacing', int)
def __init__(self, parent=None, contents=u""):
QLineEdit.__init__(self, contents, parent)
super(LineEdit, self).__init__(contents, parent)
box_direction = QBoxLayout.RightToLeft if self.isRightToLeft() else QBoxLayout.LeftToRight
self.inactiveText = u""
self.left_widget = SideWidget(self)
......@@ -60,7 +61,7 @@ class LineEdit(QLineEdit):
self._update_side_widget_locations()
def _update_side_widget_locations(self):
option = QStyleOptionFrameV2()
option = QStyleOptionFrame()
self.initStyleOption(option)
spacing = self.right_layout.spacing()
text_rect = self.style().subElementRect(QStyle.SE_LineEditContents, option, self)
......@@ -100,7 +101,7 @@ class LineEdit(QLineEdit):
def paintEvent(self, event):
QLineEdit.paintEvent(self, event)
if not self.hasFocus() and not self.text() and self.inactiveText:
options = QStyleOptionFrameV2()
options = QStyleOptionFrame()
self.initStyleOption(options)
text_rect = self.style().subElementRect(QStyle.SE_LineEditContents, options, self)
text_rect.adjust(self.left_margin+2, 0, -self.right_margin, 0)
......@@ -139,7 +140,7 @@ class ValidatingLineEdit(LineEdit):
self.invalid_entry_label.setObjectName('invalid_entry_label')
self.invalid_entry_label.hide()
self.addTailWidget(self.invalid_entry_label)
option = QStyleOptionFrameV2()
option = QStyleOptionFrame()
self.initStyleOption(option)
frame_width = self.style().pixelMetric(QStyle.PM_DefaultFrameWidth, option, self)
self.setMinimumHeight(self.invalid_entry_label.minimumHeight() + 2 + 2*frame_width)
......@@ -187,7 +188,7 @@ class ValidatingLineEdit(LineEdit):
class SearchIcon(QWidget):
def __init__(self, parent=None, size=16):
QWidget.__init__(self, parent)
super(SearchIcon, self).__init__(parent)
self.setFocusPolicy(Qt.NoFocus)
self.setVisible(True)
self.setMinimumSize(size+2, size+2)
......@@ -207,7 +208,7 @@ class SearchIcon(QWidget):
class ClearButton(QAbstractButton):
def __init__(self, parent=None, size=16):
QAbstractButton.__init__(self, parent)
super(ClearButton, self).__init__(parent)
self.setCursor(Qt.ArrowCursor)
self.setFocusPolicy(Qt.NoFocus)
self.setToolTip(u"Clear")
......@@ -260,12 +261,12 @@ class ClearButton(QAbstractButton):
class SearchBox(LineEdit):
def __init__(self, parent=None):
LineEdit.__init__(self, parent=parent)
super(SearchBox, self).__init__(parent=parent)
self.search_icon = SearchIcon(self)
self.clear_button = ClearButton(self)
self.addHeadWidget(self.search_icon)
self.addTailWidget(self.clear_button)
option = QStyleOptionFrameV2()
option = QStyleOptionFrame()
self.initStyleOption(option)
frame_width = self.style().pixelMetric(QStyle.PM_DefaultFrameWidth, option, self)
widgets_height = max(self.search_icon.minimumHeight(), self.clear_button.minimumHeight())
......@@ -289,10 +290,10 @@ class LocationBar(LineEdit):
locationCleared = pyqtSignal()
def __init__(self, parent=None):
LineEdit.__init__(self, parent=parent)
super(LocationBar, self).__init__(parent=parent)
self.clear_button = ClearButton(self)
self.addTailWidget(self.clear_button)
option = QStyleOptionFrameV2()
option = QStyleOptionFrame()
self.initStyleOption(option)
frame_width = self.style().pixelMetric(QStyle.PM_DefaultFrameWidth, option, self)
widgets_height = self.clear_button.minimumHeight()
......
import re
from PyQt4 import uic
from PyQt4.QtCore import Qt, pyqtSignal
from PyQt4.QtGui import QStyle, QStyleOption, QStylePainter
from PyQt5 import uic
from PyQt5.QtCore import Qt, pyqtSignal
from PyQt5.QtWidgets import QStyle, QStyleOption, QStylePainter
from blink.resources import Resources
from blink.sessions import SMPVerification
......
from PyQt4.QtCore import QPyNullVariant
__all__ = ['QtDynamicProperty', 'ContextMenuActions']
......@@ -13,10 +11,7 @@ class QtDynamicProperty(object):
def __get__(self, instance, owner):
if instance is None:
return self
value = instance.property(self.name)
if isinstance(value, QPyNullVariant):
value = self.type()
return value
return instance.property(self.name)
def __set__(self, obj, value):
if value is not None and not isinstance(value, self.type):
......
from __future__ import division
from PyQt4.QtCore import Qt, QMetaObject, QPoint, QRect, QTimer, pyqtSignal
from PyQt4.QtGui import QColor, QCursor, QIcon, QImage, QPainter, QPixmap, QTransform, QWidget
from PyQt5.QtCore import Qt, QMetaObject, QPoint, QRect, QTimer, pyqtSignal
from PyQt5.QtGui import QColor, QCursor, QIcon, QImage, QPainter, QPixmap, QTransform
from PyQt5.QtWidgets import QWidget
from application.python.types import MarkerType
from math import ceil
......
from PyQt4 import uic
from PyQt4.QtCore import Qt, pyqtSignal
from PyQt4.QtGui import QStyle, QStyleOption, QStylePainter
from PyQt5 import uic
from PyQt5.QtCore import Qt, pyqtSignal
from PyQt5.QtWidgets import QStyle, QStyleOption, QStylePainter
from blink.resources import Resources
......
......@@ -18,7 +18,9 @@ Depends: ${python:Depends}, ${shlibs:Depends}, ${misc:Depends},
python-googleapi,
python-lxml,
python-oauth2client,
python-qt4 (>= 4.7),
python-pyqt5,
python-pyqt5.qtsvg,
python-pyqt5.qtwebkit,
python-sipsimple (>= 3.0.0),
python-twisted-core,
python-zope.interface,
......
#!/usr/bin/python
from PyQt4.QtCore import QUrl
from PyQt4.QtGui import QApplication
from PyQt4.QtWebKit import QWebView, QWebSettings
from PyQt5.QtCore import QUrl
from PyQt5.QtWebKit import QWebSettings
from PyQt5.QtWebKitWidgets import QWebView
from PyQt5.QtWidgets import QApplication
app = QApplication([])
view = QWebView()
......
#!/usr/bin/python
from PyQt4.QtCore import QUrl
from PyQt4.QtGui import QApplication
from PyQt4.QtWebKit import QWebView, QWebSettings
from PyQt5.QtCore import QUrl
from PyQt5.QtWebKit import QWebSettings
from PyQt5.QtWebKitWidgets import QWebView
from PyQt5.QtWidgets import QApplication
app = QApplication([])
view = QWebView()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment