X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Fbufferview.cpp;h=ccea4e8cb8f12d1228ad44f91fa4a1493e3ab36d;hp=8fbbdd349e66f8e72acbd6d2181f36c093725fcd;hb=cdc6b6dd319564e94f4fdba47ec4c8feaa2cf8a2;hpb=d37bdc91c5474603e1417c2cd9c40c02e1ad5ee6 diff --git a/src/uisupport/bufferview.cpp b/src/uisupport/bufferview.cpp index 8fbbdd34..ccea4e8c 100644 --- a/src/uisupport/bufferview.cpp +++ b/src/uisupport/bufferview.cpp @@ -465,9 +465,44 @@ QSize BufferView::sizeHint() const { // **************************************** // BufferViewDelgate // **************************************** +class ColorsChangedEvent : public QEvent { +public: + ColorsChangedEvent() : QEvent(QEvent::User) {}; +}; + BufferViewDelegate::BufferViewDelegate(QObject *parent) - : QStyledItemDelegate(parent) + : QStyledItemDelegate(parent), + _updateColors(false) { + loadColors(); + + UiSettings s("QtUiStyle/Colors"); + s.notify("inactiveActivityFG", this, SLOT(colorsChanged())); + s.notify("noActivityFG", this, SLOT(colorsChanged())); + s.notify("highlightActivityFG", this, SLOT(colorsChanged())); + s.notify("newMessageActivityFG", this, SLOT(colorsChanged())); + s.notify("otherActivityFG", this, SLOT(colorsChanged())); +} + +void BufferViewDelegate::colorsChanged() { + // avoid mutliple unneded reloads of all colors + if(_updateColors) + return; + _updateColors = true; + QCoreApplication::postEvent(this, new ColorsChangedEvent()); +} + +void BufferViewDelegate::customEvent(QEvent *event) { + if(event->type() != QEvent::User) + return; + + loadColors(); + _updateColors = false; + + event->accept(); +} + +void BufferViewDelegate::loadColors() { UiSettings s("QtUiStyle/Colors"); _FgColorInactiveActivity = s.value("inactiveActivityFG", QVariant(QColor(Qt::gray))).value(); _FgColorNoActivity = s.value("noActivityFG", QVariant(QColor(Qt::black))).value();