More unified colors in foldertree and messagelists

Some parts still not colored in a unified way.
Fixes #84
This commit is contained in:
mailchuck 2015-10-31 10:12:12 +01:00 committed by Peter Surda
parent 6383f48ef2
commit 9abc937cb3
3 changed files with 33 additions and 13 deletions

View File

@ -921,6 +921,7 @@ class MyForm(QtGui.QMainWindow):
toAddressItem.setToolTip(unicode(acct.toLabel, 'utf-8'))
toAddressItem.setIcon(avatarize(toAddress))
toAddressItem.setData(Qt.UserRole, str(toAddress))
toAddressItem.setTextColor(AccountColor(toAddress).accountColor())
toAddressItem.setFlags(
QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
tableWidget.setItem(0, 0, toAddressItem)
@ -929,6 +930,7 @@ class MyForm(QtGui.QMainWindow):
fromAddressItem.setToolTip(unicode(acct.fromLabel, 'utf-8'))
fromAddressItem.setIcon(avatarize(fromAddress))
fromAddressItem.setData(Qt.UserRole, str(fromAddress))
fromAddressItem.setTextColor(AccountColor(fromAddress).accountColor())
fromAddressItem.setFlags(
QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
tableWidget.setItem(0, 1, fromAddressItem)
@ -1058,10 +1060,7 @@ class MyForm(QtGui.QMainWindow):
if not read:
to_item.setFont(font)
to_item.setData(Qt.UserRole, str(toAddress))
if shared.safeConfigGetBoolean(toAddress, 'mailinglist'):
to_item.setTextColor(QtGui.QColor(137, 04, 177)) # magenta
if shared.safeConfigGetBoolean(str(toAddress), 'chan'):
to_item.setTextColor(QtGui.QColor(216, 119, 0)) # orange
to_item.setTextColor(AccountColor(toAddress).accountColor())
to_item.setIcon(avatarize(toAddress))
tableWidget.setItem(0, 0, to_item)
# from
@ -1072,8 +1071,7 @@ class MyForm(QtGui.QMainWindow):
if not read:
from_item.setFont(font)
from_item.setData(Qt.UserRole, str(fromAddress))
if shared.safeConfigGetBoolean(str(fromAddress), 'chan'):
from_item.setTextColor(QtGui.QColor(216, 119, 0)) # orange
from_item.setTextColor(AccountColor(fromAddress).accountColor())
from_item.setIcon(avatarize(fromAddress))
tableWidget.setItem(0, 1, from_item)
# subject

View File

@ -6,6 +6,7 @@ import sys
import inspect
from helper_sql import *
from addresses import decodeAddress
from foldertree import AccountMixin
from pyelliptic.openssl import OpenSSL
from utils import str_broadcast_subscribers
import time
@ -41,6 +42,24 @@ def accountClass(address):
# no gateway
return BMAccount(address)
class AccountColor(AccountMixin):
def __init__(self, address, type = None):
self.isEnabled = True
self.address = address
if type is None:
if shared.safeConfigGetBoolean(self.address, 'mailinglist'):
self.type = "mailinglist"
elif shared.safeConfigGetBoolean(self.address, 'chan'):
self.type = "chan"
elif sqlQuery(
'''select label from subscriptions where address=?''', self.address):
self.type = 'subscription'
else:
self.type = "normal"
else:
self.type = type
class BMAccount(object):
def __init__(self, address = None):
self.address = address

View File

@ -6,13 +6,16 @@ import shared
class AccountMixin (object):
def accountColor (self):
if not self.isEnabled:
return QtGui.QBrush(QtGui.QColor(128, 128, 128))
return QtGui.QColor(128, 128, 128)
elif self.type == "chan":
return QtGui.QBrush(QtGui.QColor(216, 119, 0))
return QtGui.QColor(216, 119, 0)
elif self.type == "mailinglist" or self.type == "subscription":
return QtGui.QBrush(QtGui.QColor(137, 04, 177))
return QtGui.QColor(137, 04, 177)
else:
return QtGui.QBrush(QtGui.QApplication.palette().text().color())
return QtGui.QApplication.palette().text().color()
def accountBrush(self):
return QtGui.QBrush(self.accountColor())
def setAddress(self, address):
self.address = str(address)
@ -121,7 +124,7 @@ class Ui_AddressWidget(QtGui.QTreeWidgetItem, AccountMixin):
self.setFont(0, font)
#set text color
brush = self.accountColor()
brush = self.accountBrush()
brush.setStyle(QtCore.Qt.NoBrush)
self.setForeground(0, brush)
@ -204,7 +207,7 @@ class Ui_SubscriptionWidget(Ui_AddressWidget, AccountMixin):
self.setFont(0, font)
#set text color
brush = self.accountColor()
brush = self.accountBrush()
brush.setStyle(QtCore.Qt.NoBrush)
self.setForeground(0, brush)
@ -246,7 +249,7 @@ class Ui_AddressBookWidgetItem(QtGui.QTableWidgetItem, AccountMixin):
except:
self.type = 0
self.setEnabled(True)
brush = self.accountColor()
brush = self.accountBrush()
brush.setStyle(QtCore.Qt.NoBrush)
self.setForeground(brush)