Commit 4a4c1cf7 authored by Dan Pascu's avatar Dan Pascu

Use API level 2 for QString for better python integration

parent 9376ce46
......@@ -10,14 +10,17 @@ __date__ = 'October 26th, 2012'
import os
import sys
from collections import defaultdict
import sip
import cjson
sip.setapi('QString', 2)
from PyQt4.QtGui import QApplication
from application import log
from application.notification import IObserver, NotificationCenter, NotificationData
from application.python import Null
from application.system import host, makedirs, unlink
from collections import defaultdict
from eventlib import api
from gnutls.crypto import X509Certificate, X509PrivateKey
from gnutls.errors import GNUTLSError
......
......@@ -295,44 +295,44 @@ class AddAccountDialog(base_class, ui_class):
def _get_display_name(self):
if self.panel_view.currentWidget() is self.add_account_panel:
return unicode(self.display_name_editor.text())
return self.display_name_editor.text()
else:
return unicode(self.name_editor.text())
return self.name_editor.text()
def _set_display_name(self, value):
self.display_name_editor.setText(value)
self.name_editor.setText(value)
def _get_username(self):
return unicode(self.username_editor.text())
return self.username_editor.text()
def _set_username(self, value):
self.username_editor.setText(value)
def _get_sip_address(self):
return unicode(self.sip_address_editor.text())
return self.sip_address_editor.text()
def _set_sip_address(self, value):
self.sip_address_editor.setText(value)
def _get_password(self):
if self.panel_view.currentWidget() is self.add_account_panel:
return unicode(self.password_editor.text())
return self.password_editor.text()
else:
return unicode(self.new_password_editor.text())
return self.new_password_editor.text()
def _set_password(self, value):
self.password_editor.setText(value)
self.new_password_editor.setText(value)
def _get_verify_password(self):
return unicode(self.verify_password_editor.text())
return self.verify_password_editor.text()
def _set_verify_password(self, value):
self.verify_password_editor.setText(value)
def _get_email_address(self):
return unicode(self.email_address_editor.text())
return self.email_address_editor.text()
def _set_email_address(self, value):
self.email_address_editor.setText(value)
......@@ -372,7 +372,7 @@ class AddAccountDialog(base_class, ui_class):
self.accept_button.setEnabled(all(input.text_valid for input in inputs))
def _SH_PasswordTextChanged(self, text):
self.verify_password_editor.regexp = re.compile(u'^%s$' % re.escape(unicode(text)))
self.verify_password_editor.regexp = re.compile(u'^%s$' % re.escape(text))
def _SH_ValidityStatusChanged(self):
red = '#cc0000'
......@@ -590,7 +590,7 @@ class ServerToolsWebView(QWebView):
self.last_error = None
def _SH_URLChanged(self, url):
query_items = dict((unicode(name), unicode(value)) for name, value in url.queryItems())
query_items = dict(url.queryItems())
self.tab = query_items.get('tab') or self.tab
self.task = query_items.get('task') or self.task
......
......@@ -13,7 +13,7 @@ import socket
import sys
from PyQt4 import uic
from PyQt4.QtCore import Qt, QAbstractListModel, QByteArray, QEvent, QMimeData, QModelIndex, QPointF, QRectF, QRegExp, QSize, QStringList, pyqtSignal
from PyQt4.QtCore import Qt, QAbstractListModel, QByteArray, QEvent, QMimeData, QModelIndex, QPointF, QRectF, QRegExp, QSize, pyqtSignal
from PyQt4.QtGui import QBrush, QColor, QLinearGradient, QPainter, QPainterPath, QPalette, QPen, QPixmap, QPolygonF, QStyle
from PyQt4.QtGui import QAction, QKeyEvent, QListView, QMenu, QMouseEvent, QRegExpValidator, QSortFilterProxyModel, QStyledItemDelegate
......@@ -108,7 +108,7 @@ class ContactGroup(object):
@updates_contacts_db
def _name_changed(self):
self.name = unicode(self.widget.name_editor.text())
self.name = self.widget.name_editor.text()
def _get_widget(self):
return self.__dict__['widget']
......@@ -533,9 +533,9 @@ class GoogleContactsDialog(base_class, ui_class):
@run_in_green_thread
def _authorize_google_account(self):
red = '#cc0000'
captcha_response = unicode(self.captcha_editor.text()) if self.captcha_token else None
username = unicode(self.username_editor.text())
password = unicode(self.password_editor.text())
captcha_response = self.captcha_editor.text() if self.captcha_token else None
username = self.username_editor.text()
password = self.password_editor.text()
client = ContactsClient()
try:
client.client_login(email=username, password=password, source='Blink', captcha_token=self.captcha_token, captcha_response=captcha_response)
......@@ -640,7 +640,7 @@ class ContactGroupWidget(base_class, ui_class):
return self.name_view.currentWidget() is self.editor_widget
def _get_name(self):
return unicode(self.name_label.text())
return self.name_label.text()
def _set_name(self, value):
self.name_label.setText(value)
......@@ -935,7 +935,7 @@ class ContactModel(QAbstractListModel):
return Qt.CopyAction | Qt.MoveAction
def mimeTypes(self):
return QStringList(['application/x-blink-contact-list'])
return ['application/x-blink-contact-list']
def mimeData(self, indexes):
mime_data = QMimeData()
......@@ -1369,7 +1369,7 @@ class ContactSearchModel(QSortFilterProxyModel):
item = source_model.data(source_index, Qt.DisplayRole)
if isinstance(item, ContactGroup):
return False
search_tokens = unicode(self.filterRegExp().pattern()).lower().split()
search_tokens = self.filterRegExp().pattern().lower().split()
searched_item = unicode(item).lower()
return all(token in searched_item for token in search_tokens)
......@@ -1382,7 +1382,7 @@ class ContactSearchModel(QSortFilterProxyModel):
return Qt.CopyAction
def mimeTypes(self):
return QStringList(['application/x-blink-contact-list'])
return ['application/x-blink-contact-list']
def mimeData(self, indexes):
mime_data = QMimeData()
......@@ -2067,11 +2067,11 @@ class ContactEditorDialog(base_class, ui_class):
@updates_contacts_db
def process_contact(self):
contact_model = self.parent().contact_model
uri = unicode(self.sip_address_editor.text())
name = unicode(self.display_name_editor.text())
uri = self.sip_address_editor.text()
name = self.display_name_editor.text()
image = IconCache().store(self.icon_selector.filename)
preferred_media = unicode(self.preferred_media.currentText())
sip_aliases = [alias.strip() for alias in unicode(self.sip_aliases_editor.text()).split(u';')]
preferred_media = self.preferred_media.currentText()
sip_aliases = [alias.strip() for alias in self.sip_aliases_editor.text().split(u';')]
group_index = self.group.currentIndex()
group_name = self.group.currentText()
if group_name != self.group.itemText(group_index):
......@@ -2080,7 +2080,7 @@ class ContactEditorDialog(base_class, ui_class):
if index >= 0:
group = self.group.itemData(index).toPyObject()
else:
group = ContactGroup(unicode(group_name))
group = ContactGroup(group_name)
else:
group = self.group.itemData(group_index).toPyObject()
if self.edited_contact is None:
......
......@@ -381,7 +381,7 @@ class MainWindow(base_class, ui_class):
list_view = self.contact_list if self.contacts_view.currentWidget() is self.contact_list_panel else self.search_list
selected_indexes = list_view.selectionModel().selectedIndexes()
contact = list_view.model().data(selected_indexes[0]) if selected_indexes else Null
address = contact.uri or unicode(self.search_box.text())
address = contact.uri or self.search_box.text()
name = contact.name or None
session_manager = SessionManager()
session_manager.start_call(name, address, contact=contact, account=BonjourAccount() if isinstance(contact, BonjourNeighbour) else None)
......@@ -403,13 +403,13 @@ class MainWindow(base_class, ui_class):
self.enable_call_buttons(account_manager.default_account is not None and len(selected_items)==1 and isinstance(self.contact_model.data(selected_items[0]), Contact))
def _SH_ContactModelAddedItems(self, items):
if self.search_box.text().isEmpty():
if not self.search_box.text():
return
active_widget = self.search_list_panel if self.contact_search_model.rowCount() else self.not_found_panel
self.search_view.setCurrentWidget(active_widget)
def _SH_ContactModelRemovedItems(self, items):
if self.search_box.text().isEmpty():
if not self.search_box.text():
return
if any(type(item) is Contact for item in items) and self.contact_search_model.rowCount() == 0:
self.search_box.clear()
......@@ -421,7 +421,7 @@ class MainWindow(base_class, ui_class):
self.display_name.clearFocus()
index = self.identity.currentIndex()
if index != -1:
name = unicode(self.display_name.text())
name = self.display_name.text()
account = self.identity.itemData(index).toPyObject().account
account.display_name = name if name else None
account.save()
......@@ -459,7 +459,7 @@ class MainWindow(base_class, ui_class):
SIPApplication.voice_audio_bridge.mixer.muted = muted
def _SH_SearchBoxReturnPressed(self):
address = unicode(self.search_box.text())
address = self.search_box.text()
if address:
session_manager = SessionManager()
session_manager.start_call(None, address)
......@@ -469,17 +469,16 @@ class MainWindow(base_class, ui_class):
account_manager = AccountManager()
if text:
self.switch_view_button.view = SwitchViewButton.ContactView
if self.contacts_view.currentWidget() is not self.search_panel:
self.search_list.selectionModel().clearSelection()
self.contacts_view.setCurrentWidget(self.search_panel)
self.search_view.setCurrentWidget(self.search_list_panel if self.contact_search_model.rowCount() else self.not_found_panel)
selected_items = self.search_list.selectionModel().selectedIndexes()
self.enable_call_buttons(account_manager.default_account is not None and len(selected_items)<=1)
else:
self.contacts_view.setCurrentWidget(self.contact_list_panel)
selected_items = self.contact_list.selectionModel().selectedIndexes()
self.enable_call_buttons(account_manager.default_account is not None and len(selected_items)==1 and type(self.contact_model.data(selected_items[0])) is Contact)
active_widget = self.contact_list_panel if text.isEmpty() else self.search_panel
if active_widget is self.search_panel and self.contacts_view.currentWidget() is not self.search_panel:
self.search_list.selectionModel().clearSelection()
self.contacts_view.setCurrentWidget(active_widget)
active_widget = self.search_list_panel if self.contact_search_model.rowCount() else self.not_found_panel
self.search_view.setCurrentWidget(active_widget)
def _SH_SearchListSelectionChanged(self, selected, deselected):
account_manager = AccountManager()
......
......@@ -40,9 +40,7 @@ class IDDPrefixValidator(QRegExpValidator):
super(IDDPrefixValidator, self).__init__(QRegExp(u'[0-9+*#]+'), parent)
def fixup(self, input):
if input.isEmpty():
input.append(u'+')
return super(IDDPrefixValidator, self).fixup(input)
return super(IDDPrefixValidator, self).fixup(input or u'+')
class PrefixValidator(QRegExpValidator):
......@@ -50,9 +48,7 @@ class PrefixValidator(QRegExpValidator):
super(PrefixValidator, self).__init__(QRegExp(u'(None|[0-9+*#]+)'), parent)
def fixup(self, input):
if input.isEmpty():
input.append(u'None')
return super(PrefixValidator, self).fixup(input)
return super(PrefixValidator, self).fixup(input or u'None')
class HostnameValidator(QRegExpValidator):
......@@ -67,7 +63,7 @@ class SIPAddressValidator(QRegExpValidator):
def fixup(self, input):
if input and '@' not in input:
preferences_window = self.parent()
input.append(u'@%s' % preferences_window.selected_account.id.domain)
input += u'@%s' % preferences_window.selected_account.id.domain
return super(SIPAddressValidator, self).fixup(input)
......@@ -78,25 +74,25 @@ class WebURLValidator(QRegExpValidator):
class XCAPRootValidator(WebURLValidator):
def fixup(self, input):
url = urlparse.urlparse(unicode(input))
url = urlparse.urlparse(input)
if not (url.scheme and url.netloc):
input.clear()
input = u''
return super(XCAPRootValidator, self).fixup(input)
def validate(self, input, pos):
state, pos = super(XCAPRootValidator, self).validate(input, pos)
state, input, pos = super(XCAPRootValidator, self).validate(input, pos)
if state == QValidator.Acceptable:
if input and input[-1] in ('?', ';', '&'):
if input.endswith(('?', ';', '&')):
state = QValidator.Invalid
else:
url = urlparse.urlparse(unicode(input))
url = urlparse.urlparse(input)
if url.params or url.query or url.fragment:
state = QValidator.Invalid
elif url.port is not None:
port = int(url.port)
if not (0 < port <= 65535):
state = QValidator.Invalid
return state, pos
return state, input, pos
# Custom widgets used in preferences.ui
......@@ -122,14 +118,14 @@ class SIPPortEditor(QSpinBox):
return super(SIPPortEditor, self).stepBy(steps)
def validate(self, input, pos):
state, pos = super(SIPPortEditor, self).validate(input, pos)
state, input, pos = super(SIPPortEditor, self).validate(input, pos)
if state == QValidator.Acceptable:
value = int(input)
if 0 < value < 1024:
state = QValidator.Intermediate
elif value == self.sibling.value() != 0:
state = QValidator.Intermediate
return state, pos
return state, input, pos
class AccountListView(QListView):
......@@ -308,10 +304,10 @@ class PreferencesWindow(base_class, ui_class):
self.section_group.addAction(action)
for index in xrange(self.idd_prefix_button.count()):
text = unicode(self.idd_prefix_button.itemText(index))
text = self.idd_prefix_button.itemText(index)
self.idd_prefix_button.setItemData(index, QVariant(None if text == "+" else text))
for index in xrange(self.prefix_button.count()):
text = unicode(self.prefix_button.itemText(index))
text = self.prefix_button.itemText(index)
self.prefix_button.setItemData(index, QVariant(None if text == "None" else text))
self.voicemail_uri_editor.setValidator(SIPAddressValidator(self))
......@@ -392,14 +388,14 @@ class PreferencesWindow(base_class, ui_class):
def account_msrp_relay(self):
host = self.msrp_relay_host_editor.text()
port = self.msrp_relay_port.value()
transport = str(self.msrp_relay_transport_button.currentText()).lower()
transport = self.msrp_relay_transport_button.currentText().lower()
return MSRPRelayAddress(host, port, transport) if host else None
@property
def account_outbound_proxy(self):
host = self.outbound_proxy_host_editor.text()
port = self.outbound_proxy_port.value()
transport = str(self.outbound_proxy_transport_button.currentText()).lower()
transport = self.outbound_proxy_transport_button.currentText().lower()
return SIPProxyAddress(host, port, transport) if host else None
@property
......@@ -768,14 +764,14 @@ class PreferencesWindow(base_class, ui_class):
def _SH_DisplayNameEditorEditingFinished(self):
account = self.selected_account
display_name = unicode(self.display_name_editor.text()) or None
display_name = self.display_name_editor.text() or None
if account.display_name != display_name:
account.display_name = display_name
account.save()
def _SH_PasswordEditorEditingFinished(self):
account = self.selected_account
password = unicode(self.password_editor.text())
password = self.password_editor.text()
if account.auth.password != password:
account.auth.password = password
account.save()
......@@ -785,23 +781,23 @@ class PreferencesWindow(base_class, ui_class):
if not self.load_in_progress:
account = self.selected_account
items = [self.account_audio_codecs_list.item(row) for row in xrange(self.account_audio_codecs_list.count())]
account.rtp.audio_codec_list = [str(item.text()) for item in items if item.checkState()==Qt.Checked]
account.rtp.audio_codec_order = [str(item.text()) for item in items]
account.rtp.audio_codec_list = [item.text() for item in items if item.checkState()==Qt.Checked]
account.rtp.audio_codec_order = [item.text() for item in items]
account.save()
def _SH_AccountAudioCodecsListModelRowsInserted(self, parent, start, end):
if not self.load_in_progress:
account = self.selected_account
items = [self.account_audio_codecs_list.item(row) for row in xrange(self.account_audio_codecs_list.count())]
account.rtp.audio_codec_order = [str(item.text()) for item in items]
account.rtp.audio_codec_list = [str(item.text()) for item in items if item.checkState()==Qt.Checked]
account.rtp.audio_codec_order = [item.text() for item in items]
account.rtp.audio_codec_list = [item.text() for item in items if item.checkState()==Qt.Checked]
account.save()
def _SH_AccountAudioCodecsListModelRowsMoved(self, source_parent, source_start, source_end, dest_parent, dest_row):
account = self.selected_account
items = [self.account_audio_codecs_list.item(row) for row in xrange(self.account_audio_codecs_list.count())]
account.rtp.audio_codec_order = [str(item.text()) for item in items]
account.rtp.audio_codec_list = [str(item.text()) for item in items if item.checkState()==Qt.Checked]
account.rtp.audio_codec_order = [item.text() for item in items]
account.rtp.audio_codec_list = [item.text() for item in items if item.checkState()==Qt.Checked]
account.save()
def _SH_ResetAudioCodecsButtonClicked(self, checked):
......@@ -830,7 +826,7 @@ class PreferencesWindow(base_class, ui_class):
def _SH_SRTPEncryptionButtonActivated(self, text):
account = self.selected_account
account.rtp.srtp_encryption = str(text)
account.rtp.srtp_encryption = text
account.save()
# Account server settings
......@@ -863,7 +859,7 @@ class PreferencesWindow(base_class, ui_class):
def _SH_AuthUsernameEditorEditingFinished(self):
account = self.selected_account
auth_username = unicode(self.auth_username_editor.text()) or None
auth_username = self.auth_username_editor.text() or None
if account.auth.username != auth_username:
account.auth.username = auth_username
account.save()
......@@ -897,28 +893,28 @@ class PreferencesWindow(base_class, ui_class):
def _SH_VoicemailURIEditorEditingFinished(self):
account = self.selected_account
voicemail_uri = unicode(self.voicemail_uri_editor.text()) or None
voicemail_uri = self.voicemail_uri_editor.text() or None
if account.message_summary.voicemail_uri != voicemail_uri:
account.message_summary.voicemail_uri = voicemail_uri
account.save()
def _SH_XCAPRootEditorEditingFinished(self):
account = self.selected_account
xcap_root = unicode(self.xcap_root_editor.text()) or None
xcap_root = self.xcap_root_editor.text() or None
if account.xcap.xcap_root != xcap_root:
account.xcap.xcap_root = xcap_root
account.save()
def _SH_ServerToolsURLEditorEditingFinished(self):
account = self.selected_account
url = unicode(self.server_tools_url_editor.text()) or None
url = self.server_tools_url_editor.text() or None
if account.server.settings_url != url:
account.server.settings_url = url
account.save()
def _SH_ConferenceServerEditorEditingFinished(self):
account = self.selected_account
server = unicode(self.conference_server_editor.text()) or None
server = self.conference_server_editor.text() or None
if account.server.conference_server != server:
account.server.conference_server = server
account.save()
......@@ -931,7 +927,7 @@ class PreferencesWindow(base_class, ui_class):
def _SH_MSRPTransportButtonActivated(self, text):
account = self.selected_account
account.msrp.transport = str(text).lower()
account.msrp.transport = text.lower()
account.save()
# Account advanced settings
......@@ -960,7 +956,7 @@ class PreferencesWindow(base_class, ui_class):
def _SH_IDDPrefixButtonActivated(self, text):
self._update_pstn_example_label()
account = self.selected_account
idd_prefix = None if text=='+' else str(text)
idd_prefix = None if text=='+' else text
if account.pstn.idd_prefix != idd_prefix:
account.pstn.idd_prefix = idd_prefix
account.save()
......@@ -968,7 +964,7 @@ class PreferencesWindow(base_class, ui_class):
def _SH_PrefixButtonActivated(self, text):
self._update_pstn_example_label()
account = self.selected_account
prefix = None if text=='None' else str(text)
prefix = None if text=='None' else text
if account.pstn.prefix != prefix:
account.pstn.prefix = prefix
account.save()
......@@ -982,7 +978,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 os.path.expanduser('~')
cert_path = unicode(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)") or None
if cert_path is not None:
cert_path = os.path.normpath(cert_path)
if cert_path != account.tls.certificate:
......@@ -1025,7 +1021,7 @@ class PreferencesWindow(base_class, ui_class):
def _SH_AudioSampleRateButtonActivated(self, text):
settings = SIPSimpleSettings()
settings.audio.sample_rate = str(text)
settings.audio.sample_rate = text
settings.save()
def _SH_EnableEchoCancellingButtonClicked(self, checked):
......@@ -1038,22 +1034,22 @@ class PreferencesWindow(base_class, ui_class):
if not self.load_in_progress:
settings = SIPSimpleSettings()
item_iterator = (self.audio_codecs_list.item(row) for row in xrange(self.audio_codecs_list.count()))
settings.rtp.audio_codec_list = [str(item.text()) for item in item_iterator if item.checkState()==Qt.Checked]
settings.rtp.audio_codec_list = [item.text() for item in item_iterator if item.checkState()==Qt.Checked]
settings.save()
def _SH_AudioCodecsListModelRowsInserted(self, parent, start, end):
if not self.load_in_progress:
settings = SIPSimpleSettings()
items = [self.audio_codecs_list.item(row) for row in xrange(self.audio_codecs_list.count())]
settings.rtp.audio_codec_order = [str(item.text()) for item in items]
settings.rtp.audio_codec_list = [str(item.text()) for item in items if item.checkState()==Qt.Checked]
settings.rtp.audio_codec_order = [item.text() for item in items]
settings.rtp.audio_codec_list = [item.text() for item in items if item.checkState()==Qt.Checked]
settings.save()
def _SH_AudioCodecsListModelRowsMoved(self, source_parent, source_start, source_end, dest_parent, dest_row):
settings = SIPSimpleSettings()
items = [self.audio_codecs_list.item(row) for row in xrange(self.audio_codecs_list.count())]
settings.rtp.audio_codec_order = [str(item.text()) for item in items]
settings.rtp.audio_codec_list = [str(item.text()) for item in items if item.checkState()==Qt.Checked]
settings.rtp.audio_codec_order = [item.text() for item in items]
settings.rtp.audio_codec_list = [item.text() for item in items if item.checkState()==Qt.Checked]
settings.save()
# Answering machine signal handlers
......@@ -1107,7 +1103,7 @@ class PreferencesWindow(base_class, ui_class):
# TODO: open the file selection dialog in non-modal mode. Same for the one for TLS CA list and the IconSelector from contacts. -Dan
settings = SIPSimpleSettings()
directory = settings.file_transfer.directory or os.path.expanduser('~')
directory = unicode(QFileDialog.getExistingDirectory(self, u'Select Download Directory', directory)) or None
directory = QFileDialog.getExistingDirectory(self, u'Select Download Directory', directory) or None
if directory is not None:
directory = os.path.normpath(directory)
if directory != settings.file_transfer.directory:
......@@ -1249,7 +1245,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 os.path.expanduser('~')
ca_path = unicode(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)") or None
if ca_path is not None:
ca_path = os.path.normpath(ca_path)
if ca_path != settings.tls.ca_list:
......
......@@ -15,7 +15,7 @@ from functools import partial
from itertools import chain, izip, repeat
from PyQt4 import uic
from PyQt4.QtCore import Qt, QAbstractListModel, QByteArray, QEvent, QMimeData, QModelIndex, QObject, QSize, QStringList, QTimer, pyqtSignal
from PyQt4.QtCore import Qt, QAbstractListModel, QByteArray, QEvent, QMimeData, QModelIndex, QObject, QSize, QTimer, pyqtSignal
from PyQt4.QtGui import QApplication, QBrush, QColor, QDrag, QLinearGradient, QListView, QPainter, QPen, QPixmap, QShortcut, QStyledItemDelegate
from application.notification import IObserver, NotificationCenter
......@@ -999,7 +999,7 @@ class SessionModel(QAbstractListModel):
return Qt.CopyAction | Qt.MoveAction
def mimeTypes(self):
return QStringList(['application/x-blink-session-list'])
return ['application/x-blink-session-list']
def mimeData(self, indexes):
mime_data = QMimeData()
......
......@@ -40,7 +40,7 @@ class IconSelector(QLabel):
def mouseReleaseEvent(self, event):
if event.button() == Qt.LeftButton and self.rect().contains(event.pos()):
filename = unicode(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)")
if filename:
self.last_icon_directory = os.path.dirname(filename)
self.filename = filename if os.path.realpath(filename) != os.path.realpath(Resources.get(self.default_icon)) else None
......
......@@ -100,7 +100,7 @@ class LineEdit(QLineEdit):
def paintEvent(self, event):
QLineEdit.paintEvent(self, event)
if not self.hasFocus() and self.text().isEmpty() and self.inactiveText:
if not self.hasFocus() and not self.text() and self.inactiveText:
options = QStyleOptionFrameV2()
self.initStyleOption(options)
text_rect = self.style().subElementRect(QStyle.SE_LineEditContents, options, self)
......@@ -168,7 +168,7 @@ class ValidatingLineEdit(LineEdit):
self._validate()
def _validate(self):
text = unicode(self.text())
text = self.text()
text_correct = self.regexp.search(text) is not None
text_allowed = text not in self.exceptions
if self.text_correct != text_correct or self.text_allowed != text_allowed:
......@@ -277,7 +277,7 @@ class SearchBox(LineEdit):
self.inactiveText = u"Search"
def _SH_TextChanged(self, text):
self.clear_button.setVisible(not text.isEmpty())
self.clear_button.setVisible(bool(text))
class LocationBar(LineEdit):
......@@ -301,6 +301,6 @@ class LocationBar(LineEdit):
self.locationCleared.emit()
def _SH_TextChanged(self, text):
self.clear_button.setVisible(not text.isEmpty())
self.clear_button.setVisible(bool(text))
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