Commit 532df739 authored by Dan Pascu's avatar Dan Pascu

Improved painting contact and session markers over all types of backgrounds

parent 7c716280
......@@ -7,7 +7,7 @@ import os
from PyQt4 import uic
from PyQt4.QtCore import Qt, QEasingCurve, QEvent, QPointF, QPropertyAnimation, QRect, QSettings, QTimer, pyqtSignal
from PyQt4.QtGui import QAction, QColor, QDesktopServices, QIcon, QListView, QMenu, QPainter, QPalette, QPen, QPolygonF, QTextCursor, QTextDocument, QTextEdit
from PyQt4.QtGui import QAction, QBrush, QColor, QDesktopServices, QIcon, QLinearGradient, QListView, QMenu, QPainter, QPalette, QPen, QPolygonF, QTextCursor, QTextDocument, QTextEdit
from PyQt4.QtWebKit import QWebPage, QWebSettings, QWebView
from abc import ABCMeta, abstractmethod
......@@ -982,15 +982,22 @@ class ChatWindow(base_class, ui_class, ColorHelperMixin):
pen_thickness = 1.6
color = palette.color(QPalette.Normal, QPalette.WindowText)
if self.state_label.state in ('available', 'away', 'busy', 'offline'):
window_color = self.state_label.state_colors[self.state_label.state]
if self.state_label.state is not None:
background_color = self.state_label.state_colors[self.state_label.state]
base_contrast_color = self.calc_light_color(background_color)
gradient = QLinearGradient(0, 0, 1, 0)
gradient.setCoordinateMode(QLinearGradient.ObjectBoundingMode)
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))
contrast_color = QBrush(gradient)
else:
window_color = palette.color(QPalette.Window)
background_color = self.background_color(window_color, 0.5)
background_color = palette.color(QPalette.Window)
contrast_color = self.calc_light_color(background_color)
foreground_color = palette.color(QPalette.Normal, QPalette.WindowText)
line_color = self.deco_color(background_color, foreground_color)
pen = QPen(self.deco_color(background_color, color), pen_thickness, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin)
contrast_pen = QPen(self.calc_light_color(background_color), pen_thickness, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin)
pen = QPen(line_color, pen_thickness, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin)
contrast_pen = QPen(contrast_color, pen_thickness, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin)
# draw the expansion indicator at the bottom (works best with a state_label of width 14)
arrow_rect = QRect(0, 0, 14, 14)
......
......@@ -1732,8 +1732,11 @@ class ContactDelegate(QStyledItemDelegate, ColorHelperMixin):
self.contact_selected_widget = ContactWidget(None)
self.contact_oddline_widget.setBackgroundRole(QPalette.Base)
self.contact_oddline_widget.setForegroundRole(QPalette.WindowText)
self.contact_evenline_widget.setBackgroundRole(QPalette.AlternateBase)
self.contact_evenline_widget.setForegroundRole(QPalette.WindowText)
self.contact_selected_widget.setBackgroundRole(QPalette.Highlight)
self.contact_selected_widget.setForegroundRole(QPalette.HighlightedText)
self.contact_selected_widget.name_label.setForegroundRole(QPalette.HighlightedText)
self.contact_selected_widget.info_label.setForegroundRole(QPalette.HighlightedText)
......@@ -1815,31 +1818,45 @@ class ContactDelegate(QStyledItemDelegate, ColorHelperMixin):
painter.restore()
def drawExpansionIndicator(self, contact, option, painter, widget):
pen_thickness = 1.6
if contact.state is not None:
foreground_color = option.palette.color(QPalette.Normal, QPalette.WindowText)
background_color = widget.state_label.state_colors[contact.state]
base_contrast_color = self.calc_light_color(background_color)
gradient = QLinearGradient(0, 0, 1, 0)
gradient.setCoordinateMode(QLinearGradient.ObjectBoundingMode)
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))
contrast_color = QBrush(gradient)
else:
#foreground_color = option.palette.color(QPalette.Normal, QPalette.WindowText)
#background_color = option.palette.color(QPalette.Window)
foreground_color = widget.palette().color(QPalette.Normal, widget.foregroundRole())
background_color = widget.palette().color(widget.backgroundRole())
contrast_color = self.calc_light_color(background_color)
line_color = self.deco_color(background_color, foreground_color)
pen = QPen(line_color, pen_thickness, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin)
contrast_pen = QPen(contrast_color, pen_thickness, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin)
# this fits best with a state_label of width 14
arrow_rect = QRect(0, 0, 14, 14)
arrow_rect.moveBottomRight(widget.state_label.geometry().bottomRight())
arrow_rect.translate(option.rect.topLeft())
text_color = option.palette.color(QPalette.Normal, QPalette.WindowText)
if contact.state in ('available', 'away', 'busy'):
window_color = widget.state_label.state_colors[contact.state]
else:
window_color = option.palette.color(QPalette.Window)
background_color = self.background_color(window_color, 0.5)
arrow = QPolygonF([QPointF(-3, -1.5), QPointF(0.5, 2.5), QPointF(4, -1.5)])
arrow.translate(1, 1)
pen_thickness = 1.6
painter.save()
painter.setRenderHint(QPainter.Antialiasing, True)
painter.setCompositionMode(QPainter.CompositionMode_SourceOver)
painter.translate(arrow_rect.center())
painter.translate(0, +1)
painter.setPen(QPen(self.calc_light_color(background_color), pen_thickness, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin))
painter.setPen(contrast_pen)
painter.drawPolyline(arrow)
painter.translate(0, -1)
painter.setPen(QPen(self.deco_color(background_color, text_color), pen_thickness, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin))
painter.setPen(pen)
painter.drawPolyline(arrow)
painter.restore()
......@@ -1946,31 +1963,43 @@ class ContactDetailDelegate(QStyledItemDelegate, ColorHelperMixin):
painter.restore()
def drawCollapseIndicator(self, contact, option, painter, widget):
pen_thickness = 1.6
if contact.state is not None:
foreground_color = option.palette.color(QPalette.Normal, QPalette.WindowText)
background_color = widget.state_label.state_colors[contact.state]
base_contrast_color = self.calc_light_color(background_color)
gradient = QLinearGradient(0, 0, 1, 0)
gradient.setCoordinateMode(QLinearGradient.ObjectBoundingMode)
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))
contrast_color = QBrush(gradient)
else:
foreground_color = widget.palette().color(QPalette.Normal, widget.foregroundRole())
background_color = widget.palette().color(widget.backgroundRole())
contrast_color = self.calc_light_color(background_color)
line_color = self.deco_color(background_color, foreground_color)
pen = QPen(line_color, pen_thickness, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin)
contrast_pen = QPen(contrast_color, pen_thickness, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin)
# this fits best with a state_label of width 14
arrow_rect = QRect(0, 0, 14, 14)
arrow_rect.moveBottomRight(widget.state_label.geometry().bottomRight())
arrow_rect.translate(option.rect.topLeft())
text_color = option.palette.color(QPalette.Normal, QPalette.WindowText)
if contact.state in ('available', 'away', 'busy'):
window_color = widget.state_label.state_colors[contact.state]
else:
window_color = option.palette.color(QPalette.Window)
background_color = self.background_color(window_color, 0.5)
arrow = QPolygonF([QPointF(3, 1.5), QPointF(-0.5, -2.5), QPointF(-4, 1.5)])
arrow.translate(2, 1)
pen_thickness = 1.6
painter.save()
painter.setRenderHint(QPainter.Antialiasing, True)
painter.setCompositionMode(QPainter.CompositionMode_SourceOver)
painter.translate(arrow_rect.center())
painter.translate(0, +1)
painter.setPen(QPen(self.calc_light_color(background_color), pen_thickness, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin))
painter.setPen(contrast_pen)
painter.drawPolyline(arrow)
painter.translate(0, -1)
painter.setPen(QPen(self.deco_color(background_color, text_color), pen_thickness, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin))
painter.setPen(pen)
painter.drawPolyline(arrow)
painter.restore()
......
......@@ -1230,6 +1230,7 @@ class ConferenceParticipantWidget(base_class, ui_class):
self.palettes.standard.setColor(QPalette.Window, self.palettes.standard.color(QPalette.Base)) # We modify the palettes because only the Oxygen theme honors the BackgroundRole if set
self.palettes.alternate.setColor(QPalette.Window, self.palettes.standard.color(QPalette.AlternateBase)) # AlternateBase set to #f0f4ff or #e0e9ff by designer
self.palettes.selected.setColor(QPalette.Window, self.palettes.standard.color(QPalette.Highlight)) # #0066cc #0066d5 #0066dd #0066aa (0, 102, 170) '#256182' (37, 97, 130), #2960a8 (41, 96, 168), '#2d6bbc' (45, 107, 188), '#245897' (36, 88, 151) #0044aa #0055d4
self.setBackgroundRole(QPalette.Window)
self.display_mode = self.StandardDisplayMode
self.hold_icon.installEventFilter(self)
self.is_composing_icon.installEventFilter(self)
......@@ -1254,14 +1255,17 @@ class ConferenceParticipantWidget(base_class, ui_class):
return
if new_mode is self.StandardDisplayMode:
self.setPalette(self.palettes.standard)
self.setForegroundRole(QPalette.WindowText)
self.name_label.setForegroundRole(QPalette.WindowText)
self.info_label.setForegroundRole(QPalette.Dark)
elif new_mode is self.AlternateDisplayMode:
self.setPalette(self.palettes.alternate)
self.setForegroundRole(QPalette.WindowText)
self.name_label.setForegroundRole(QPalette.WindowText)
self.info_label.setForegroundRole(QPalette.Dark)
elif new_mode is self.SelectedDisplayMode:
self.setPalette(self.palettes.selected)
self.setForegroundRole(QPalette.HighlightedText)
self.name_label.setForegroundRole(QPalette.HighlightedText)
self.info_label.setForegroundRole(QPalette.HighlightedText)
......@@ -1329,15 +1333,23 @@ class ConferenceParticipantDelegate(QStyledItemDelegate, ColorHelperMixin):
def drawRemoveIndicator(self, participant, option, painter, widget):
pen_thickness = 1.6
color = option.palette.color(QPalette.Normal, QPalette.WindowText)
if widget.state_label.state in ('available', 'away', 'busy', 'offline'):
window_color = widget.state_label.state_colors[widget.state_label.state]
if widget.state_label.state is not None:
foreground_color = option.palette.color(QPalette.Normal, QPalette.WindowText)
background_color = widget.state_label.state_colors[widget.state_label.state]
base_contrast_color = self.calc_light_color(background_color)
gradient = QLinearGradient(0, 0, 1, 0)
gradient.setCoordinateMode(QLinearGradient.ObjectBoundingMode)
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))
contrast_color = QBrush(gradient)
else:
window_color = option.palette.color(QPalette.Window)
background_color = self.background_color(window_color, 0.5)
foreground_color = widget.palette().color(QPalette.Normal, widget.foregroundRole())
background_color = widget.palette().color(widget.backgroundRole())
contrast_color = self.calc_light_color(background_color)
line_color = self.deco_color(background_color, foreground_color)
pen = QPen(self.deco_color(background_color, color), pen_thickness, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin)
contrast_pen = QPen(self.calc_light_color(background_color), pen_thickness, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin)
pen = QPen(line_color, pen_thickness, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin)
contrast_pen = QPen(contrast_color, pen_thickness, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin)
# draw the remove indicator at the top (works best with a state_label of width 14)
cross_rect = QRect(0, 0, 14, 14)
......@@ -3056,6 +3068,7 @@ class ChatSessionWidget(base_class, ui_class):
self.palettes.standard.setColor(QPalette.Window, self.palettes.standard.color(QPalette.Base)) # We modify the palettes because only the Oxygen theme honors the BackgroundRole if set
self.palettes.alternate.setColor(QPalette.Window, self.palettes.standard.color(QPalette.AlternateBase)) # AlternateBase set to #f0f4ff or #e0e9ff by designer
self.palettes.selected.setColor(QPalette.Window, self.palettes.standard.color(QPalette.Highlight)) # #0066cc #0066d5 #0066dd #0066aa (0, 102, 170) '#256182' (37, 97, 130), #2960a8 (41, 96, 168), '#2d6bbc' (45, 107, 188), '#245897' (36, 88, 151) #0044aa #0055d4
self.setBackgroundRole(QPalette.Window)
self.display_mode = self.StandardDisplayMode
self.hold_icon.installEventFilter(self)
self.is_composing_icon.installEventFilter(self)
......@@ -3080,14 +3093,17 @@ class ChatSessionWidget(base_class, ui_class):
return
if new_mode is self.StandardDisplayMode:
self.setPalette(self.palettes.standard)
self.setForegroundRole(QPalette.WindowText)
self.name_label.setForegroundRole(QPalette.WindowText)
self.info_label.setForegroundRole(QPalette.Dark)
elif new_mode is self.AlternateDisplayMode:
self.setPalette(self.palettes.alternate)
self.setForegroundRole(QPalette.WindowText)
self.name_label.setForegroundRole(QPalette.WindowText)
self.info_label.setForegroundRole(QPalette.Dark)
elif new_mode is self.SelectedDisplayMode:
self.setPalette(self.palettes.selected)
self.setForegroundRole(QPalette.HighlightedText)
self.name_label.setForegroundRole(QPalette.HighlightedText)
self.info_label.setForegroundRole(QPalette.HighlightedText)
......@@ -3174,15 +3190,25 @@ class ChatSessionDelegate(QStyledItemDelegate, ColorHelperMixin):
def drawSessionIndicators(self, session, option, painter, widget):
pen_thickness = 1.6
color = option.palette.color(QPalette.Normal, QPalette.WindowText)
if widget.state_label.state in ('available', 'away', 'busy', 'offline'):
window_color = widget.state_label.state_colors[widget.state_label.state]
if widget.state_label.state is not None:
foreground_color = option.palette.color(QPalette.Normal, QPalette.WindowText)
background_color = widget.state_label.state_colors[widget.state_label.state]
base_contrast_color = self.calc_light_color(background_color)
gradient = QLinearGradient(0, 0, 1, 0)
gradient.setCoordinateMode(QLinearGradient.ObjectBoundingMode)
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))
contrast_color = QBrush(gradient)
else:
window_color = option.palette.color(QPalette.Window)
background_color = self.background_color(window_color, 0.5)
pen = QPen(self.deco_color(background_color, color), pen_thickness, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin)
contrast_pen = QPen(self.calc_light_color(background_color), pen_thickness, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin)
#foreground_color = option.palette.color(QPalette.Normal, QPalette.WindowText)
#background_color = option.palette.color(QPalette.Window)
foreground_color = widget.palette().color(QPalette.Normal, widget.foregroundRole())
background_color = widget.palette().color(widget.backgroundRole())
contrast_color = self.calc_light_color(background_color)
line_color = self.deco_color(background_color, foreground_color)
pen = QPen(line_color, pen_thickness, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin)
contrast_pen = QPen(contrast_color, pen_thickness, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin)
# draw the expansion indicator at the bottom (works best with a state_label of width 14)
arrow_rect = QRect(0, 0, 14, 14)
......
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