Add feature to select channels to log (#4302)

* Add checkbox for custom logging and table with channels to log on Logs page

* Add checkbox to enable and disable logging per channel

* Return from addMessage before logging if custom logging enabled and channel does not have logging enabled

* Use clang-format to fix formatting

* Add CHANGELOG.md entry

* Resolve PR comments

* Remove toggle for channels so any channel listed will be logged

* Move Only log channels listed below checkbox to just above table

* Fix formatting

* Re-order changelog

* ChannelLog constructor: Copy & move instead of const ref & copy

* ChannelLog::createEmpty: Curly brace initialize instead of repeating
name

* ChannelLog toString & createEmpty: nodiscard

* Use COUNT paradigm in model column

* Remove ChanneLoggingModel source file comments

* Use Column::Channel in getRowFromItem

* Rename `getItemFromRow` parameter and mark it as unused

* Curly brace initialize ChannelLog

* private & friend class the model

* Filter out channels to log using a set instead of iterating over a vector every time a message comes in

* Rename `ChannelLog::channel` member to `ChannelLog::channelName`

Also made it private

* mini comment on ChannelLog

Co-authored-by: Felanbird <41973452+Felanbird@users.noreply.github.com>
Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
askepticaldreamer
2023-01-15 03:47:22 -08:00
committed by GitHub
parent a567cc5ae7
commit 4c782ce90c
11 changed files with 225 additions and 6 deletions
+35 -3
View File
@@ -1,6 +1,7 @@
#include "ModerationPage.hpp"
#include "Application.hpp"
#include "controllers/logging/ChannelLoggingModel.hpp"
#include "controllers/moderationactions/ModerationAction.hpp"
#include "controllers/moderationactions/ModerationActionModel.hpp"
#include "singletons/Logging.hpp"
@@ -69,8 +70,10 @@ ModerationPage::ModerationPage()
auto logs = tabs.appendTab(new QVBoxLayout, "Logs");
{
logs.append(this->createCheckBox("Enable logging",
getSettings()->enableLogging));
QCheckBox *enableLogging = this->createCheckBox(
"Enable logging", getSettings()->enableLogging);
logs.append(enableLogging);
auto logsPathLabel = logs.emplace<QLabel>();
// Logs (copied from LoggingMananger)
@@ -105,7 +108,6 @@ ModerationPage::ModerationPage()
});
buttons->addStretch();
logs->addStretch(1);
// Show how big (size-wise) the logs are
auto logsPathSizeLabel = logs.emplace<QLabel>();
@@ -140,6 +142,36 @@ ModerationPage::ModerationPage()
}));
});
QCheckBox *onlyLogListedChannels =
this->createCheckBox("Only log channels listed below",
getSettings()->onlyLogListedChannels);
onlyLogListedChannels->setEnabled(getSettings()->enableLogging);
logs.append(onlyLogListedChannels);
// Select event
QObject::connect(
enableLogging, &QCheckBox::stateChanged, this,
[enableLogging, onlyLogListedChannels]() mutable {
onlyLogListedChannels->setEnabled(enableLogging->isChecked());
});
EditableModelView *view =
logs.emplace<EditableModelView>(
(new ChannelLoggingModel(nullptr))
->initialized(&getSettings()->loggedChannels))
.getElement();
view->setTitles({"Twitch channels"});
view->getTableView()->horizontalHeader()->setSectionResizeMode(
QHeaderView::Fixed);
view->getTableView()->horizontalHeader()->setSectionResizeMode(
0, QHeaderView::Stretch);
view->addButtonPressed.connect([] {
getSettings()->loggedChannels.append(ChannelLog("channel"));
});
} // logs end
auto modMode = tabs.appendTab(new QVBoxLayout, "Moderation buttons");