X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fuisupport%2Fbufferview.cpp;h=345fd7bb26bf0424029948df43fdda9e67f353b3;hb=c91b08f855152297a89ec3586792f6616acd0eb9;hp=0b3386979e51a9304ed967b0b2e8db79ec8393b7;hpb=b3ec58929bead822048a25f87f6a0d699c490b7a;p=quassel.git diff --git a/src/uisupport/bufferview.cpp b/src/uisupport/bufferview.cpp index 0b338697..345fd7bb 100644 --- a/src/uisupport/bufferview.cpp +++ b/src/uisupport/bufferview.cpp @@ -56,8 +56,8 @@ BufferView::BufferView(QWidget *parent) setSelectionMode(QAbstractItemView::ExtendedSelection); QAbstractItemDelegate *oldDelegate = itemDelegate(); - BufferViewDelegate *newDelegate = new BufferViewDelegate(this); - setItemDelegate(newDelegate); + BufferViewDelegate *tristateDelegate = new BufferViewDelegate(this); + setItemDelegate(tristateDelegate); delete oldDelegate; } @@ -468,6 +468,8 @@ BufferViewDelegate::BufferViewDelegate(QObject *parent) : QStyledItemDelegate(parent) { UiSettings s("QtUiStyle/Colors"); + _FgColorInactiveActivity = s.value("inactiveActivityFG", QVariant(QColor(Qt::gray))).value(); + _FgColorNoActivity = s.value("noActivityFG", QVariant(QColor(Qt::black))).value(); _FgColorHighlightActivity = s.value("highlightActivityFG", QVariant(QColor(Qt::magenta))).value(); _FgColorNewMessageActivity = s.value("newMessageActivityFG", QVariant(QColor(Qt::green))).value(); _FgColorOtherActivity = s.value("otherActivityFG", QVariant(QColor(Qt::darkGreen))).value(); @@ -507,24 +509,23 @@ bool BufferViewDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, c void BufferViewDelegate::initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const { QStyledItemDelegate::initStyleOption(option, index); + if(!index.isValid()) + return; + BufferInfo::ActivityLevel activity = (BufferInfo::ActivityLevel)index.data(NetworkModel::BufferActivityRole).toInt(); + QColor fgColor = _FgColorNoActivity; if(activity & BufferInfo::Highlight) { - option->palette.setColor(QPalette::Text, _FgColorHighlightActivity); - return; - } - if(activity & BufferInfo::NewMessage) { - option->palette.setColor(QPalette::Text, _FgColorNewMessageActivity); - return; - } - if(activity & BufferInfo::OtherActivity) { - option->palette.setColor(QPalette::Text, _FgColorOtherActivity); - return; + fgColor = _FgColorHighlightActivity; + } else if(activity & BufferInfo::NewMessage) { + fgColor = _FgColorNewMessageActivity; + } else if(activity & BufferInfo::OtherActivity) { + fgColor = _FgColorOtherActivity; + } else if(!index.data(NetworkModel::ItemActiveRole).toBool() || index.data(NetworkModel::UserAwayRole).toBool()) { + fgColor = _FgColorInactiveActivity; } - if(!index.data(NetworkModel::ItemActiveRole).toBool() || index.data(NetworkModel::UserAwayRole).toBool()) { - option->palette.setColor(QPalette::Text, QPalette().color(QPalette::Dark)); - } + option->palette.setColor(QPalette::Text, fgColor); }