X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Fbufferview.cpp;h=ccea4e8cb8f12d1228ad44f91fa4a1493e3ab36d;hp=0d7be090501fab4dcecdbd4631560f75f8be1ce6;hb=cdc6b6dd319564e94f4fdba47ec4c8feaa2cf8a2;hpb=ef48d209f03f02debf369ff689002f1b32165100 diff --git a/src/uisupport/bufferview.cpp b/src/uisupport/bufferview.cpp index 0d7be090..ccea4e8c 100644 --- a/src/uisupport/bufferview.cpp +++ b/src/uisupport/bufferview.cpp @@ -35,11 +35,12 @@ #include "buffersettings.h" #include "buffersyncer.h" #include "client.h" +#include "contextmenuactionprovider.h" +#include "graphicalui.h" #include "iconloader.h" #include "network.h" #include "networkmodel.h" -#include "networkmodelactionprovider.h" -#include "quasselui.h" +#include "contextmenuactionprovider.h" #include "uisettings.h" /***************************************** @@ -386,7 +387,7 @@ void BufferView::addActionsToMenu(QMenu *contextMenu, const QModelIndex &index) indexList.removeAll(index); indexList.prepend(index); - Client::mainUi()->actionProvider()->addActions(contextMenu, indexList, this, "menuActionTriggered", (bool)config()); + GraphicalUi::contextMenuActionProvider()->addActions(contextMenu, indexList, this, "menuActionTriggered", (bool)config()); } void BufferView::addFilterActions(QMenu *contextMenu, const QModelIndex &index) { @@ -403,12 +404,12 @@ void BufferView::addFilterActions(QMenu *contextMenu, const QModelIndex &index) } void BufferView::menuActionTriggered(QAction *result) { - NetworkModelActionProvider::ActionType type = (NetworkModelActionProvider::ActionType)result->data().toInt(); + ContextMenuActionProvider::ActionType type = (ContextMenuActionProvider::ActionType)result->data().toInt(); switch(type) { - case NetworkModelActionProvider::HideBufferTemporarily: + case ContextMenuActionProvider::HideBufferTemporarily: removeSelectedBuffers(); break; - case NetworkModelActionProvider::HideBufferPermanently: + case ContextMenuActionProvider::HideBufferPermanently: removeSelectedBuffers(true); break; default: @@ -464,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(); @@ -509,6 +545,9 @@ 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;