Commit 409f9506 authored by Tijmen de Mes's avatar Tijmen de Mes

Updated syntax

parent 95ab0e91
...@@ -487,7 +487,7 @@ class GoogleContactIconRetriever(object): ...@@ -487,7 +487,7 @@ class GoogleContactIconRetriever(object):
http = self.credentials.authorize(Http(timeout=5)) http = self.credentials.authorize(Http(timeout=5))
try: try:
if icon.url is not None: if icon.url is not None:
response, content = http.request(icon.url+'?size={}'.format(IconManager.max_size)) response, content = http.request(icon.url + '?size={}'.format(IconManager.max_size))
else: else:
response = content = None response = content = None
except (HttpLib2Error, socket.error) as e: except (HttpLib2Error, socket.error) as e:
...@@ -740,6 +740,7 @@ class GoogleAuthorizationView(QWebView): ...@@ -740,6 +740,7 @@ class GoogleAuthorizationView(QWebView):
self.finished.emit() self.finished.emit()
self.accepted.emit(params['code'], self.email) self.accepted.emit(params['code'], self.email)
class GoogleAuthorizationStorage(Storage): class GoogleAuthorizationStorage(Storage):
def __init__(self, filename): def __init__(self, filename):
self._directory = os.path.dirname(filename) self._directory = os.path.dirname(filename)
...@@ -1200,7 +1201,7 @@ class Group(object): ...@@ -1200,7 +1201,7 @@ class Group(object):
def _name_changed(self): def _name_changed(self):
if self.settings.save is Null: if self.settings.save is Null:
del self.settings.save # re-enable saving after the name was provided del self.settings.save # re-enable saving after the name was provided
self.settings.name = self.widget.name_editor.text() self.settings.name = self.widget.name_editor.text()
self.settings.save() self.settings.save()
...@@ -1767,14 +1768,14 @@ class GroupWidget(base_class, ui_class): ...@@ -1767,14 +1768,14 @@ class GroupWidget(base_class, ui_class):
painter.setPen(QPen(QBrush(QColor('#dc3169')), 2.0)) painter.setPen(QPen(QBrush(QColor('#dc3169')), 2.0))
if self.drop_indicator is ContactListView.AboveItem: if self.drop_indicator is ContactListView.AboveItem:
line_rect = QRectF(rect.adjusted(18, 0, 0, 5-rect.height())) line_rect = QRectF(rect.adjusted(18, 0, 0, 5 - rect.height()))
arc_rect = line_rect.adjusted(-5, -3, -line_rect.width(), -3) arc_rect = line_rect.adjusted(-5, -3, -line_rect.width(), -3)
path = QPainterPath(line_rect.topRight()) path = QPainterPath(line_rect.topRight())
path.lineTo(line_rect.topLeft()) path.lineTo(line_rect.topLeft())
path.arcTo(arc_rect, 0, -180) path.arcTo(arc_rect, 0, -180)
painter.drawPath(path) painter.drawPath(path)
elif self.drop_indicator is ContactListView.BelowItem: elif self.drop_indicator is ContactListView.BelowItem:
line_rect = QRectF(rect.adjusted(18, rect.height()-5, 0, 0)) line_rect = QRectF(rect.adjusted(18, rect.height() - 5, 0, 0))
arc_rect = line_rect.adjusted(-5, 2, -line_rect.width(), 2) arc_rect = line_rect.adjusted(-5, 2, -line_rect.width(), 2)
path = QPainterPath(line_rect.bottomRight()) path = QPainterPath(line_rect.bottomRight())
path.lineTo(line_rect.bottomLeft()) path.lineTo(line_rect.bottomLeft())
...@@ -1910,8 +1911,8 @@ class ContactDelegate(QStyledItemDelegate, ColorHelperMixin): ...@@ -1910,8 +1911,8 @@ class ContactDelegate(QStyledItemDelegate, ColorHelperMixin):
base_contrast_color = self.calc_light_color(background_color) base_contrast_color = self.calc_light_color(background_color)
gradient = QLinearGradient(0, 0, 1, 0) gradient = QLinearGradient(0, 0, 1, 0)
gradient.setCoordinateMode(QLinearGradient.ObjectBoundingMode) gradient.setCoordinateMode(QLinearGradient.ObjectBoundingMode)
gradient.setColorAt(0.0, self.color_with_alpha(base_contrast_color, 0.3*255)) gradient.setColorAt(0.0, self.color_with_alpha(base_contrast_color, 0.3 * 255))
gradient.setColorAt(1.0, self.color_with_alpha(base_contrast_color, 0.8*255)) gradient.setColorAt(1.0, self.color_with_alpha(base_contrast_color, 0.8 * 255))
contrast_color = QBrush(gradient) contrast_color = QBrush(gradient)
else: else:
# foreground_color = option.palette.color(QPalette.Normal, QPalette.WindowText) # foreground_color = option.palette.color(QPalette.Normal, QPalette.WindowText)
...@@ -2036,7 +2037,7 @@ class ContactDetailDelegate(QStyledItemDelegate, ColorHelperMixin): ...@@ -2036,7 +2037,7 @@ class ContactDetailDelegate(QStyledItemDelegate, ColorHelperMixin):
text_color = option.palette.color(color_group, QPalette.HighlightedText if option.state & QStyle.State_Selected else QPalette.Text) text_color = option.palette.color(color_group, QPalette.HighlightedText if option.state & QStyle.State_Selected else QPalette.Text)
text_width = text_rect.width() text_width = text_rect.width()
if option.fontMetrics.width(contact_uri.uri.uri) > text_width: if option.fontMetrics.width(contact_uri.uri.uri) > text_width:
fade_start = 1 - 50.0/text_width if text_width > 50 else 0.0 fade_start = 1 - 50.0 / text_width if text_width > 50 else 0.0
gradient = QLinearGradient(text_rect.x(), 0, text_rect.right(), 0) gradient = QLinearGradient(text_rect.x(), 0, text_rect.right(), 0)
gradient.setColorAt(fade_start, text_color) gradient.setColorAt(fade_start, text_color)
gradient.setColorAt(1.0, Qt.transparent) gradient.setColorAt(1.0, Qt.transparent)
...@@ -2057,8 +2058,8 @@ class ContactDetailDelegate(QStyledItemDelegate, ColorHelperMixin): ...@@ -2057,8 +2058,8 @@ class ContactDetailDelegate(QStyledItemDelegate, ColorHelperMixin):
base_contrast_color = self.calc_light_color(background_color) base_contrast_color = self.calc_light_color(background_color)
gradient = QLinearGradient(0, 0, 1, 0) gradient = QLinearGradient(0, 0, 1, 0)
gradient.setCoordinateMode(QLinearGradient.ObjectBoundingMode) gradient.setCoordinateMode(QLinearGradient.ObjectBoundingMode)
gradient.setColorAt(0.0, self.color_with_alpha(base_contrast_color, 0.3*255)) gradient.setColorAt(0.0, self.color_with_alpha(base_contrast_color, 0.3 * 255))
gradient.setColorAt(1.0, self.color_with_alpha(base_contrast_color, 0.8*255)) gradient.setColorAt(1.0, self.color_with_alpha(base_contrast_color, 0.8 * 255))
contrast_color = QBrush(gradient) contrast_color = QBrush(gradient)
else: else:
foreground_color = widget.palette().color(QPalette.Normal, widget.foregroundRole()) foreground_color = widget.palette().color(QPalette.Normal, widget.foregroundRole())
...@@ -2120,12 +2121,12 @@ class ContactDetailDelegate(QStyledItemDelegate, ColorHelperMixin): ...@@ -2120,12 +2121,12 @@ class ContactDetailDelegate(QStyledItemDelegate, ColorHelperMixin):
painter.setRenderHint(QPainter.Antialiasing) painter.setRenderHint(QPainter.Antialiasing)
painter.setPen(contrast_pen) painter.setPen(contrast_pen)
painter.translate(0, offset) painter.translate(0, offset)
painter.drawLine(x+9, y, x+3, y+7) painter.drawLine(x + 9, y, x + 3, y + 7)
painter.drawLine(x, y+4, x+3, y+7) painter.drawLine(x, y + 4, x + 3, y + 7)
painter.setPen(pen) painter.setPen(pen)
painter.translate(0, -offset) painter.translate(0, -offset)
painter.drawLine(x+9, y, x+3, y+7) painter.drawLine(x + 9, y, x + 3, y + 7)
painter.drawLine(x, y+4, x+3, y+7) painter.drawLine(x, y + 4, x + 3, y + 7)
painter.restore() painter.restore()
def paint(self, painter, option, index): def paint(self, painter, option, index):
...@@ -2414,15 +2415,15 @@ class ContactModel(QAbstractListModel): ...@@ -2414,15 +2415,15 @@ class ContactModel(QAbstractListModel):
if drop_position is self.contact_list.AboveItem: if drop_position is self.contact_list.AboveItem:
position = self.items.index(drop_group) position = self.items.index(drop_group)
else: else:
position = len(self.items) if drop_group is groups[-1] else self.items.index(groups[groups.index(drop_group)+1]) position = len(self.items) if drop_group is groups[-1] else self.items.index(groups[groups.index(drop_group) + 1])
self.beginInsertRows(QModelIndex(), position, position+len(items)-1) self.beginInsertRows(QModelIndex(), position, position + len(items) - 1)
self.items[position:position] = items self.items[position:position] = items
self.endInsertRows() self.endInsertRows()
for index, item in enumerate(items): for index, item in enumerate(items):
if isinstance(item, Group): if isinstance(item, Group):
self.contact_list.openPersistentEditor(self.index(position+index)) self.contact_list.openPersistentEditor(self.index(position + index))
else: else:
self.contact_list.setRowHidden(position+index, item.group.collapsed) self.contact_list.setRowHidden(position + index, item.group.collapsed)
bonjour_group = self.bonjour_group bonjour_group = self.bonjour_group
if bonjour_group in moved_groups: if bonjour_group in moved_groups:
bonjour_group.relocation_info = None bonjour_group.relocation_info = None
...@@ -2589,7 +2590,7 @@ class ContactModel(QAbstractListModel): ...@@ -2589,7 +2590,7 @@ class ContactModel(QAbstractListModel):
groups = self.items[GroupList] groups = self.items[GroupList]
bonjour_group = self.bonjour_group bonjour_group = self.bonjour_group
try: try:
bonjour_group.relocation_info = RelocationInfo(successor=groups[groups.index(bonjour_group)+1]) bonjour_group.relocation_info = RelocationInfo(successor=groups[groups.index(bonjour_group) + 1])
except IndexError: except IndexError:
bonjour_group.relocation_info = RelocationInfo(successor=None) bonjour_group.relocation_info = RelocationInfo(successor=None)
if bonjour_group is not groups[0]: if bonjour_group is not groups[0]:
...@@ -2603,7 +2604,7 @@ class ContactModel(QAbstractListModel): ...@@ -2603,7 +2604,7 @@ class ContactModel(QAbstractListModel):
groups = self.items[GroupList] groups = self.items[GroupList]
bonjour_group = self.bonjour_group bonjour_group = self.bonjour_group
try: try:
bonjour_group.relocation_info = RelocationInfo(successor=groups[groups.index(bonjour_group)+1]) bonjour_group.relocation_info = RelocationInfo(successor=groups[groups.index(bonjour_group) + 1])
except IndexError: except IndexError:
bonjour_group.relocation_info = RelocationInfo(successor=None) bonjour_group.relocation_info = RelocationInfo(successor=None)
if bonjour_group is not groups[0]: if bonjour_group is not groups[0]:
...@@ -2633,7 +2634,7 @@ class ContactModel(QAbstractListModel): ...@@ -2633,7 +2634,7 @@ class ContactModel(QAbstractListModel):
for index in sorted(indexes): for index in sorted(indexes):
if start is None: if start is None:
start = index start = index
elif index-last>1: elif index - last > 1:
yield (start, last) yield (start, last)
start = index start = index
last = index last = index
...@@ -2648,7 +2649,7 @@ class ContactModel(QAbstractListModel): ...@@ -2648,7 +2649,7 @@ class ContactModel(QAbstractListModel):
for index in reversed(sorted(indexes)): for index in reversed(sorted(indexes)):
if end is None: if end is None:
end = index end = index
elif last-index>1: elif last - index > 1:
yield (last, end) yield (last, end)
end = index end = index
last = index last = index
...@@ -2697,13 +2698,13 @@ class ContactModel(QAbstractListModel): ...@@ -2697,13 +2698,13 @@ class ContactModel(QAbstractListModel):
def _find_contact_move_point(self, contact): def _find_contact_move_point(self, contact):
position = self.items.index(contact) position = self.items.index(contact)
prev_item = self.items[position-1] if position>0 else None prev_item = self.items[position - 1] if position > 0 else None
next_item = self.items[position+1] if position+1<len(self.items) else None next_item = self.items[position + 1] if position + 1 < len(self.items) else None
prev_ok = prev_item is None or isinstance(prev_item, Group) or prev_item <= contact prev_ok = prev_item is None or isinstance(prev_item, Group) or prev_item <= contact
next_ok = next_item is None or isinstance(next_item, Group) or next_item >= contact next_ok = next_item is None or isinstance(next_item, Group) or next_item >= contact
if prev_ok and next_ok: if prev_ok and next_ok:
return None return None
for position in range(self.items.index(contact.group)+1, len(self.items)): for position in range(self.items.index(contact.group) + 1, len(self.items)):
item = self.items[position] item = self.items[position]
if isinstance(item, Group) or item > contact: if isinstance(item, Group) or item > contact:
break break
...@@ -2712,7 +2713,7 @@ class ContactModel(QAbstractListModel): ...@@ -2712,7 +2713,7 @@ class ContactModel(QAbstractListModel):
return position return position
def _find_contact_insertion_point(self, contact): def _find_contact_insertion_point(self, contact):
for position in range(self.items.index(contact.group)+1, len(self.items)): for position in range(self.items.index(contact.group) + 1, len(self.items)):
item = self.items[position] item = self.items[position]
if isinstance(item, Group) or item > contact: if isinstance(item, Group) or item > contact:
break break
...@@ -2758,8 +2759,8 @@ class ContactModel(QAbstractListModel): ...@@ -2758,8 +2759,8 @@ class ContactModel(QAbstractListModel):
start = self.items.index(group) start = self.items.index(group)
end = start + len(self.items[GroupContacts, group]) end = start + len(self.items[GroupContacts, group])
self.beginRemoveRows(QModelIndex(), start, end) self.beginRemoveRows(QModelIndex(), start, end)
items = self.items[start:end+1] items = self.items[start:end + 1]
del self.items[start:end+1] del self.items[start:end + 1]
self.endRemoveRows() self.endRemoveRows()
return items return items
...@@ -2770,8 +2771,8 @@ class ContactModel(QAbstractListModel): ...@@ -2770,8 +2771,8 @@ class ContactModel(QAbstractListModel):
rows.update(row for row, item in enumerate(self.items) if isinstance(item, Contact) and item.group in removed_groups) rows.update(row for row, item in enumerate(self.items) if isinstance(item, Contact) and item.group in removed_groups)
for start, end in self.reversed_range_iterator(rows): for start, end in self.reversed_range_iterator(rows):
self.beginRemoveRows(QModelIndex(), start, end) self.beginRemoveRows(QModelIndex(), start, end)
items[0:0] = self.items[start:end+1] items[0:0] = self.items[start:end + 1]
del self.items[start:end+1] del self.items[start:end + 1]
self.endRemoveRows() self.endRemoveRows()
return items return items
...@@ -2819,11 +2820,11 @@ class ContactModel(QAbstractListModel): ...@@ -2819,11 +2820,11 @@ class ContactModel(QAbstractListModel):
def moveGroup(self, group, successor): def moveGroup(self, group, successor):
groups = self.items[GroupList] groups = self.items[GroupList]
if group not in groups or groups.index(group)+1 == (groups.index(successor) if successor in groups else len(groups)): if group not in groups or groups.index(group) + 1 == (groups.index(successor) if successor in groups else len(groups)):
return return
items = self._pop_group(group) items = self._pop_group(group)
position = self.items.index(successor) if successor in groups else len(self.items) position = self.items.index(successor) if successor in groups else len(self.items)
self.beginInsertRows(QModelIndex(), position, position+len(items)-1) self.beginInsertRows(QModelIndex(), position, position + len(items) - 1)
self.items[position:position] = items self.items[position:position] = items
self.endInsertRows() self.endInsertRows()
self.contact_list.openPersistentEditor(self.index(position)) self.contact_list.openPersistentEditor(self.index(position))
...@@ -3077,13 +3078,13 @@ class ContactDetailModel(QAbstractListModel): ...@@ -3077,13 +3078,13 @@ class ContactDetailModel(QAbstractListModel):
def _NH_AddressbookContactDidChange(self, notification): def _NH_AddressbookContactDidChange(self, notification):
if notification.sender is self.contact and 'uris' in notification.data.modified: if notification.sender is self.contact and 'uris' in notification.data.modified:
modified_uris = notification.data.modified['uris'] modified_uris = notification.data.modified['uris']
for row in sorted((row for row, item in enumerate(self.items) if row>0 and item.uri in modified_uris.removed), reverse=True): for row in sorted((row for row, item in enumerate(self.items) if row > 0 and item.uri in modified_uris.removed), reverse=True):
self.beginRemoveRows(QModelIndex(), row, row) self.beginRemoveRows(QModelIndex(), row, row)
del self.items[row] del self.items[row]
self.endRemoveRows() self.endRemoveRows()
if modified_uris.added: if modified_uris.added:
position = len(self.items) position = len(self.items)
self.beginInsertRows(QModelIndex(), position, position+len(modified_uris.added)-1) self.beginInsertRows(QModelIndex(), position, position + len(modified_uris.added) - 1)
self.items += [ContactURI(notification.sender, uri) for uri in modified_uris.added] self.items += [ContactURI(notification.sender, uri) for uri in modified_uris.added]
self.endInsertRows() self.endInsertRows()
...@@ -3093,16 +3094,16 @@ class ContactDetailModel(QAbstractListModel): ...@@ -3093,16 +3094,16 @@ class ContactDetailModel(QAbstractListModel):
added_uris = [uri for uri in self.contact.uris if uri not in old_uris] added_uris = [uri for uri in self.contact.uris if uri not in old_uris]
removed_uris = old_uris.difference(self.contact.uris) removed_uris = old_uris.difference(self.contact.uris)
modified_uris = old_uris.difference(removed_uris) modified_uris = old_uris.difference(removed_uris)
for row in sorted((row for row, item in enumerate(self.items) if row>0 and item.uri in removed_uris), reverse=True): for row in sorted((row for row, item in enumerate(self.items) if row > 0 and item.uri in removed_uris), reverse=True):
self.beginRemoveRows(QModelIndex(), row, row) self.beginRemoveRows(QModelIndex(), row, row)
del self.items[row] del self.items[row]
self.endRemoveRows() self.endRemoveRows()
if added_uris: if added_uris:
position = len(self.items) position = len(self.items)
self.beginInsertRows(QModelIndex(), position, position+len(added_uris)-1) self.beginInsertRows(QModelIndex(), position, position + len(added_uris) - 1)
self.items += [ContactURI(self.contact, uri) for uri in added_uris] self.items += [ContactURI(self.contact, uri) for uri in added_uris]
self.endInsertRows() self.endInsertRows()
for row in (row for row, item in enumerate(self.items) if row>0 and item.uri in modified_uris): for row in (row for row, item in enumerate(self.items) if row > 0 and item.uri in modified_uris):
index = self.index(row) index = self.index(row)
self.dataChanged.emit(index, index) self.dataChanged.emit(index, index)
...@@ -3388,11 +3389,11 @@ class ContactListView(QListView): ...@@ -3388,11 +3389,11 @@ class ContactListView(QListView):
has_blink_contacts = 'application/x-blink-contact-list' in provided_mime_types has_blink_contacts = 'application/x-blink-contact-list' in provided_mime_types
has_blink_groups = 'application/x-blink-group-list' in provided_mime_types has_blink_groups = 'application/x-blink-group-list' in provided_mime_types
if not acceptable_mime_types: if not acceptable_mime_types:
event.ignore() # no acceptable mime types found event.ignore() # no acceptable mime types found
elif has_blink_contacts and has_blink_groups: elif has_blink_contacts and has_blink_groups:
event.ignore() # we can't handle drops for both groups and contacts at the same time event.ignore() # we can't handle drops for both groups and contacts at the same time
elif event_source is not self and (has_blink_contacts or has_blink_groups): elif event_source is not self and (has_blink_contacts or has_blink_groups):
event.ignore() # we don't handle drops for blink contacts or groups from other sources event.ignore() # we don't handle drops for blink contacts or groups from other sources
else: else:
if event_source is self: if event_source is self:
event.setDropAction(Qt.MoveAction) event.setDropAction(Qt.MoveAction)
...@@ -3577,17 +3578,17 @@ class ContactListView(QListView): ...@@ -3577,17 +3578,17 @@ class ContactListView(QListView):
rect.setTop(self.visualRect(model.index(model.items.index(groups[-1]))).bottom()) rect.setTop(self.visualRect(model.index(model.items.index(groups[-1]))).bottom())
elif isinstance(item, Group): elif isinstance(item, Group):
index = groups.index(item) index = groups.index(item)
rect.setHeight(rect.height()/2) rect.setHeight(rect.height() / 2)
if rect.contains(event.pos()): if rect.contains(event.pos()):
drop_groups = (groups[index-1], groups[index]) if index>0 else (Null, groups[index]) drop_groups = (groups[index - 1], groups[index]) if index > 0 else (Null, groups[index])
else: else:
drop_groups = (groups[index], groups[index+1]) if index<len(groups)-1 else (groups[index], Null) drop_groups = (groups[index], groups[index + 1]) if index < len(groups) - 1 else (groups[index], Null)
rect.translate(0, rect.height()) rect.translate(0, rect.height())
selected_rows = sorted(index.row() for index in self.selectionModel().selectedIndexes() if model.items[index.row()].movable) selected_rows = sorted(index.row() for index in self.selectionModel().selectedIndexes() if model.items[index.row()].movable)
if selected_rows: if selected_rows:
first = groups.index(model.items[selected_rows[0]]) first = groups.index(model.items[selected_rows[0]])
last = groups.index(model.items[selected_rows[-1]]) last = groups.index(model.items[selected_rows[-1]])
contiguous_selection = len(selected_rows) == last-first+1 contiguous_selection = len(selected_rows) == last - first + 1
else: else:
contiguous_selection = False contiguous_selection = False
selected_groups = set(model.items[row] for row in selected_rows) selected_groups = set(model.items[row] for row in selected_rows)
...@@ -3623,7 +3624,7 @@ class ContactListView(QListView): ...@@ -3623,7 +3624,7 @@ class ContactListView(QListView):
model = self.model() model = self.model()
if not index.isValid(): if not index.isValid():
rect = self.viewport().rect() rect = self.viewport().rect()
rect.setTop(self.visualRect(model.index(len(model.items)-1)).bottom()) rect.setTop(self.visualRect(model.index(len(model.items) - 1)).bottom())
if isinstance(item, Contact): if isinstance(item, Contact):
event.accept(rect) event.accept(rect)
self.drop_indicator_index = index self.drop_indicator_index = index
...@@ -3965,7 +3966,7 @@ class ContactSearchListView(QListView): ...@@ -3965,7 +3966,7 @@ class ContactSearchListView(QListView):
else: else:
model = self.model() model = self.model()
rect = self.viewport().rect() rect = self.viewport().rect()
rect.setTop(self.visualRect(model.index(model.rowCount()-1, 0)).bottom()) rect.setTop(self.visualRect(model.index(model.rowCount() - 1, 0)).bottom())
event.ignore(rect) event.ignore(rect)
def _SH_DoubleClicked(self, index): def _SH_DoubleClicked(self, index):
...@@ -4302,7 +4303,7 @@ class ContactDetailView(QListView): ...@@ -4302,7 +4303,7 @@ class ContactDetailView(QListView):
else: else:
model = self.model() model = self.model()
rect = self.viewport().rect() rect = self.viewport().rect()
rect.setTop(self.visualRect(model.index(model.rowCount()-1, 0)).bottom()) rect.setTop(self.visualRect(model.index(model.rowCount() - 1, 0)).bottom())
event.accept(rect) event.accept(rect)
def _SH_AnimationFinished(self): def _SH_AnimationFinished(self):
...@@ -4456,7 +4457,7 @@ class ContactURIDelegate(QItemDelegate): ...@@ -4456,7 +4457,7 @@ class ContactURIDelegate(QItemDelegate):
text_margin = option.widget.style().pixelMetric(QStyle.PM_FocusFrameHMargin, None, option.widget) + 1 text_margin = option.widget.style().pixelMetric(QStyle.PM_FocusFrameHMargin, None, option.widget) + 1
text_rect = rect.adjusted(text_margin, 0, -text_margin, 0) # remove width padding text_rect = rect.adjusted(text_margin, 0, -text_margin, 0) # remove width padding
width = text_rect.width() width = text_rect.width()
fade_start = 1 - 50.0/width if width > 50 else 0.0 fade_start = 1 - 50.0 / width if width > 50 else 0.0
gradient = QLinearGradient(0, 0, width, 0) gradient = QLinearGradient(0, 0, width, 0)
gradient.setColorAt(fade_start, option.palette.color(color_group, QPalette.HighlightedText if option.state & QStyle.State_Selected else QPalette.Text)) gradient.setColorAt(fade_start, option.palette.color(color_group, QPalette.HighlightedText if option.state & QStyle.State_Selected else QPalette.Text))
gradient.setColorAt(1.0, Qt.transparent) gradient.setColorAt(1.0, Qt.transparent)
...@@ -4849,7 +4850,7 @@ class URIUtils(object): ...@@ -4849,7 +4850,7 @@ class URIUtils(object):
if contact_user.endswith(number): if contact_user.endswith(number):
ratio = len(number) * 100 / len(contact_user) ratio = len(number) * 100 / len(contact_user)
if ratio >= 50: if ratio >= 50:
heappush(matched_numbers, (100-ratio, next(counter), contact, contact_uri)) heappush(matched_numbers, (100 - ratio, next(counter), contact, contact_uri))
if matched_numbers: if matched_numbers:
return matched_numbers[0][2:] # ratio, index, contact, uri return matched_numbers[0][2:] # ratio, index, contact, uri
......
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