From 107131b98c78c3e7f4b2630f8f20453ce5400438 Mon Sep 17 00:00:00 2001 From: "Jan Alexander Steffens (heftig)" Date: Mon, 16 Jul 2018 13:19:06 +0200 Subject: [PATCH] Chat Monitor: Add option to always include own messages --- src/qtui/chatmonitorfilter.cpp | 8 ++++ src/qtui/chatmonitorfilter.h | 2 + .../settingspages/chatmonitorsettingspage.cpp | 7 ++++ .../settingspages/chatmonitorsettingspage.ui | 37 +++++++++++++++++++ 4 files changed, 54 insertions(+) diff --git a/src/qtui/chatmonitorfilter.cpp b/src/qtui/chatmonitorfilter.cpp index 969d7a3f..79cdf0a9 100644 --- a/src/qtui/chatmonitorfilter.cpp +++ b/src/qtui/chatmonitorfilter.cpp @@ -47,6 +47,7 @@ ChatMonitorFilter::ChatMonitorFilter(MessageModel *model, QObject *parent) QString buffersSettingsId = "Buffers"; QString showBacklogSettingsId = "ShowBacklog"; QString includeReadSettingsId = "IncludeRead"; + QString alwaysOwnSettingsId = "AlwaysOwn"; _showHighlights = viewSettings.value(showHighlightsSettingsId, false).toBool(); _operationMode = viewSettings.value(operationModeSettingsId, 0).toInt(); @@ -55,12 +56,14 @@ ChatMonitorFilter::ChatMonitorFilter(MessageModel *model, QObject *parent) _bufferIds << v.value(); _showBacklog = viewSettings.value(showBacklogSettingsId, true).toBool(); _includeRead = viewSettings.value(includeReadSettingsId, true).toBool(); + _alwaysOwn = viewSettings.value(alwaysOwnSettingsId, false).toBool(); viewSettings.notify(showHighlightsSettingsId, this, SLOT(showHighlightsSettingChanged(const QVariant &))); viewSettings.notify(operationModeSettingsId, this, SLOT(operationModeSettingChanged(const QVariant &))); viewSettings.notify(buffersSettingsId, this, SLOT(buffersSettingChanged(const QVariant &))); viewSettings.notify(showBacklogSettingsId, this, SLOT(showBacklogSettingChanged(const QVariant &))); viewSettings.notify(includeReadSettingsId, this, SLOT(includeReadSettingChanged(const QVariant &))); + viewSettings.notify(alwaysOwnSettingsId, this, SLOT(alwaysOwnSettingChanged(const QVariant &))); } @@ -90,6 +93,8 @@ bool ChatMonitorFilter::filterAcceptsRow(int sourceRow, const QModelIndex &sourc // ChatMonitorSettingsPage if (_showHighlights && flags & Message::Highlight) ; // pass + else if (_alwaysOwn && flags & Message::Self) + ; // pass else if (_operationMode == ChatViewSettings::OptOut && _bufferIds.contains(bufferId)) return false; else if (_operationMode == ChatViewSettings::OptIn && !_bufferIds.contains(bufferId)) @@ -187,6 +192,9 @@ void ChatMonitorFilter::showOwnMessagesSettingChanged(const QVariant &newValue) _showOwnMessages = newValue.toBool(); } +void ChatMonitorFilter::alwaysOwnSettingChanged(const QVariant &newValue) { + _alwaysOwn = newValue.toBool(); +} void ChatMonitorFilter::showHighlightsSettingChanged(const QVariant &newValue) { diff --git a/src/qtui/chatmonitorfilter.h b/src/qtui/chatmonitorfilter.h index ea115c95..beba9bc0 100644 --- a/src/qtui/chatmonitorfilter.h +++ b/src/qtui/chatmonitorfilter.h @@ -55,6 +55,7 @@ public slots: private slots: void showFieldsSettingChanged(const QVariant &newValue); void showOwnMessagesSettingChanged(const QVariant &newValue); + void alwaysOwnSettingChanged(const QVariant &newValue); void showHighlightsSettingChanged(const QVariant &newValue); void operationModeSettingChanged(const QVariant &newValue); void buffersSettingChanged(const QVariant &newValue); @@ -70,6 +71,7 @@ private slots: private: int _showFields; bool _showOwnMessages; + bool _alwaysOwn; QList _bufferIds; bool _showHighlights; int _operationMode; diff --git a/src/qtui/settingspages/chatmonitorsettingspage.cpp b/src/qtui/settingspages/chatmonitorsettingspage.cpp index 1690722b..faba1bda 100644 --- a/src/qtui/settingspages/chatmonitorsettingspage.cpp +++ b/src/qtui/settingspages/chatmonitorsettingspage.cpp @@ -63,6 +63,7 @@ ChatMonitorSettingsPage::ChatMonitorSettingsPage(QWidget *parent) connect(ui.operationMode, SIGNAL(currentIndexChanged(int)), SLOT(switchOperationMode(int))); connect(ui.showHighlights, SIGNAL(toggled(bool)), SLOT(widgetHasChanged())); connect(ui.showOwnMessages, SIGNAL(toggled(bool)), SLOT(widgetHasChanged())); + connect(ui.alwaysOwn, SIGNAL(toggled(bool)), SLOT(widgetHasChanged())); connect(ui.showBacklog, SIGNAL(toggled(bool)), SLOT(widgetHasChanged())); connect(ui.includeRead, SIGNAL(toggled(bool)), SLOT(widgetHasChanged())); } @@ -79,6 +80,7 @@ void ChatMonitorSettingsPage::defaults() settings["OperationMode"] = ChatViewSettings::OptOut; settings["ShowHighlights"] = false; settings["ShowOwnMsgs"] = false; + settings["AlwaysOwn"] = false; settings["Buffers"] = QVariant(); settings["Default"] = true; settings["ShowBacklog"] = true; @@ -99,6 +101,7 @@ void ChatMonitorSettingsPage::load() ui.operationMode->setCurrentIndex(settings["OperationMode"].toInt() - 1); ui.showHighlights->setChecked(settings["ShowHighlights"].toBool()); ui.showOwnMessages->setChecked(settings["ShowOwnMsgs"].toBool()); + ui.alwaysOwn->setChecked(settings["AlwaysOwn"].toBool()); ui.showBacklog->setChecked(settings["ShowBacklog"].toBool()); ui.includeRead->setChecked(settings["IncludeRead"].toBool()); @@ -132,6 +135,7 @@ void ChatMonitorSettingsPage::loadSettings() settings["ShowHighlights"] = chatViewSettings.value("ShowHighlights", false); settings["ShowOwnMsgs"] = chatViewSettings.value("ShowOwnMsgs", false); + settings["AlwaysOwn"] = chatViewSettings.value("AlwaysOwn", false); settings["Buffers"] = chatViewSettings.value("Buffers", QVariantList()); settings["ShowBacklog"] = chatViewSettings.value("ShowBacklog", true); settings["IncludeRead"] = chatViewSettings.value("IncludeRead", true); @@ -145,6 +149,7 @@ void ChatMonitorSettingsPage::save() chatViewSettings.setValue("OperationMode", ui.operationMode->currentIndex() + 1); chatViewSettings.setValue("ShowHighlights", ui.showHighlights->isChecked()); chatViewSettings.setValue("ShowOwnMsgs", ui.showOwnMessages->isChecked()); + chatViewSettings.setValue("AlwaysOwn", ui.alwaysOwn->isChecked()); chatViewSettings.setValue("ShowBacklog", ui.showBacklog->isChecked()); chatViewSettings.setValue("IncludeRead", ui.includeRead->isChecked()); @@ -175,6 +180,8 @@ bool ChatMonitorSettingsPage::testHasChanged() return true; if (settings["ShowOwnMsgs"].toBool() != ui.showOwnMessages->isChecked()) return true; + if (settings["AlwaysOwn"].toBool() != ui.alwaysOwn->isChecked()) + return true; if (settings["ShowBacklog"].toBool() != ui.showBacklog->isChecked()) return true; if (settings["IncludeRead"].toBool() != ui.includeRead->isChecked()) diff --git a/src/qtui/settingspages/chatmonitorsettingspage.ui b/src/qtui/settingspages/chatmonitorsettingspage.ui index 2a986057..57436a51 100644 --- a/src/qtui/settingspages/chatmonitorsettingspage.ui +++ b/src/qtui/settingspages/chatmonitorsettingspage.ui @@ -158,6 +158,36 @@ p, li { white-space: pre-wrap; } + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 16 + + + + + + + + Show own messages in chatmonitor even if the originating buffer is ignored + + + Always + + + + + @@ -215,11 +245,18 @@ p, li { white-space: pre-wrap; } activeBuffers showHighlights showOwnMessages + alwaysOwn showBacklog includeRead + + showOwnMessages + toggled(bool) + alwaysOwn + setEnabled(bool) + showBacklog toggled(bool) -- 2.20.1