X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fqtui%2Fsettingspages%2Fchatmonitorsettingspage.cpp;h=5af07e3eb393e9969377cacf8acd00f49577c737;hb=c01c1ad4823a3e49c9526c19560dd5ce4fe30cb8;hp=bf546b1d0963554f8a0055eca707e13276374d95;hpb=6eefdfc697067d184a589fc8a231b16316c09106;p=quassel.git diff --git a/src/qtui/settingspages/chatmonitorsettingspage.cpp b/src/qtui/settingspages/chatmonitorsettingspage.cpp index bf546b1d..5af07e3e 100644 --- a/src/qtui/settingspages/chatmonitorsettingspage.cpp +++ b/src/qtui/settingspages/chatmonitorsettingspage.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2018 by the Quassel Project * + * Copyright (C) 2005-2020 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -20,18 +20,22 @@ #include "chatmonitorsettingspage.h" -#include "client.h" -#include "icon.h" -#include "networkmodel.h" -#include "bufferviewconfig.h" +#include +#include + +#include "backlogrequester.h" +#include "backlogsettings.h" #include "buffermodel.h" #include "bufferview.h" +#include "bufferviewconfig.h" #include "bufferviewfilter.h" #include "chatviewsettings.h" +#include "client.h" +#include "icon.h" +#include "networkmodel.h" +#include "util.h" -#include - -ChatMonitorSettingsPage::ChatMonitorSettingsPage(QWidget *parent) +ChatMonitorSettingsPage::ChatMonitorSettingsPage(QWidget* parent) : SettingsPage(tr("Interface"), tr("Chat Monitor"), parent) { ui.setupUi(this); @@ -66,15 +70,17 @@ ChatMonitorSettingsPage::ChatMonitorSettingsPage(QWidget *parent) connect(ui.alwaysOwn, &QAbstractButton::toggled, this, &ChatMonitorSettingsPage::widgetHasChanged); connect(ui.showBacklog, &QAbstractButton::toggled, this, &ChatMonitorSettingsPage::widgetHasChanged); connect(ui.includeRead, &QAbstractButton::toggled, this, &ChatMonitorSettingsPage::widgetHasChanged); -} + // AsNeededBacklogRequester conflicts with showing backlog in Chat Monitor + BacklogSettings backlogSettings; + backlogSettings.initAndNotify("RequesterType", this, &ChatMonitorSettingsPage::setRequesterType, BacklogRequester::AsNeeded); +} bool ChatMonitorSettingsPage::hasDefaults() const { return true; } - void ChatMonitorSettingsPage::defaults() { // NOTE: Whenever changing defaults here, also update ChatMonitorFilter::ChatMonitorFilter() @@ -92,7 +98,6 @@ void ChatMonitorSettingsPage::defaults() widgetHasChanged(); } - void ChatMonitorSettingsPage::load() { if (settings.contains("Default")) @@ -114,31 +119,29 @@ void ChatMonitorSettingsPage::load() if (!settings["Buffers"].toList().isEmpty()) { QList bufferIdsFromConfig; // remove all active buffers from the available config - foreach(QVariant v, settings["Buffers"].toList()) { + foreach (QVariant v, settings["Buffers"].toList()) { bufferIdsFromConfig << v.value(); allBufferIds.removeAll(v.value()); } Client::networkModel()->sortBufferIds(bufferIdsFromConfig); - _configActive->initSetBufferList(bufferIdsFromConfig); + _configActive->setBufferList(bufferIdsFromConfig); } ui.activeBuffers->setFilteredModel(Client::bufferModel(), _configActive); Client::networkModel()->sortBufferIds(allBufferIds); - _configAvailable->initSetBufferList(allBufferIds); + _configAvailable->setBufferList(allBufferIds); ui.availableBuffers->setFilteredModel(Client::bufferModel(), _configAvailable); setChangedState(false); } - void ChatMonitorSettingsPage::loadSettings() { // NOTE: Whenever changing defaults here, also update ChatMonitorFilter::ChatMonitorFilter() // and ChatMonitorSettingsPage::defaults() to match ChatViewSettings chatViewSettings("ChatMonitor"); - settings["OperationMode"] = (ChatViewSettings::OperationMode) - chatViewSettings.value("OperationMode", ChatViewSettings::OptOut).toInt(); + settings["OperationMode"] = (ChatViewSettings::OperationMode)chatViewSettings.value("OperationMode", ChatViewSettings::OptOut).toInt(); settings["ShowHighlights"] = chatViewSettings.value("ShowHighlights", false); settings["ShowOwnMsgs"] = chatViewSettings.value("ShowOwnMsgs", true); settings["AlwaysOwn"] = chatViewSettings.value("AlwaysOwn", false); @@ -147,7 +150,6 @@ void ChatMonitorSettingsPage::loadSettings() settings["IncludeRead"] = chatViewSettings.value("IncludeRead", false); } - void ChatMonitorSettingsPage::save() { ChatViewSettings chatViewSettings("ChatMonitor"); @@ -161,8 +163,8 @@ void ChatMonitorSettingsPage::save() // save list of active buffers QVariantList saveableBufferIdList; - foreach(BufferId id, _configActive->bufferList()) { - saveableBufferIdList << QVariant::fromValue(id); + foreach (BufferId id, _configActive->bufferList()) { + saveableBufferIdList << QVariant::fromValue(id); } chatViewSettings.setValue("Buffers", saveableBufferIdList); @@ -170,14 +172,13 @@ void ChatMonitorSettingsPage::save() setChangedState(false); } - void ChatMonitorSettingsPage::widgetHasChanged() { bool changed = testHasChanged(); - if (changed != hasChanged()) setChangedState(changed); + if (changed != hasChanged()) + setChangedState(changed); } - bool ChatMonitorSettingsPage::testHasChanged() { if (settings["OperationMode"].toInt() != ui.operationMode->currentIndex() + 1) @@ -196,29 +197,28 @@ bool ChatMonitorSettingsPage::testHasChanged() if (_configActive->bufferList().count() != settings["Buffers"].toList().count()) return true; - QSet uiBufs = _configActive->bufferList().toSet(); + QSet uiBufs = toQSet(_configActive->bufferList()); QSet settingsBufs; - foreach(QVariant v, settings["Buffers"].toList()) - settingsBufs << v.value(); + foreach (QVariant v, settings["Buffers"].toList()) + settingsBufs << v.value(); if (uiBufs != settingsBufs) return true; return false; } - -//TODO: - support drag 'n drop +// TODO: - support drag 'n drop // - adding of complete networks(?) /* toggleBuffers takes each a bufferView and its config for "input" and "output". Any selected item will be moved over from the input to the output bufferview. */ -void ChatMonitorSettingsPage::toggleBuffers(BufferView *inView, BufferViewConfig *inCfg, BufferView *outView, BufferViewConfig *outCfg) +void ChatMonitorSettingsPage::toggleBuffers(BufferView* inView, BufferViewConfig* inCfg, BufferView* outView, BufferViewConfig* outCfg) { // Fill QMap with selected items ordered by selection row - QMap > selectedBuffers; - foreach(QModelIndex index, inView->selectionModel()->selectedIndexes()) { + QMap> selectedBuffers; + foreach (QModelIndex index, inView->selectionModel()->selectedIndexes()) { BufferId inBufferId = index.data(NetworkModel::BufferIdRole).value(); if (index.data(NetworkModel::ItemTypeRole) == NetworkModel::NetworkItemType) { // TODO: @@ -238,12 +238,12 @@ void ChatMonitorSettingsPage::toggleBuffers(BufferView *inView, BufferViewConfig This can probably be removed whenever BufferViewConfig::bulkAdd or something like that is available. */ - qobject_cast(outView->model())->setConfig(nullptr); - qobject_cast(inView->model())->setConfig(nullptr); + qobject_cast(outView->model())->setConfig(nullptr); + qobject_cast(inView->model())->setConfig(nullptr); // actually move the ids - foreach(QList list, selectedBuffers) { - foreach(BufferId buffer, list) { + foreach (QList list, selectedBuffers) { + foreach (BufferId buffer, list) { outCfg->addBuffer(buffer, 0); inCfg->removeBuffer(buffer); } @@ -255,7 +255,6 @@ void ChatMonitorSettingsPage::toggleBuffers(BufferView *inView, BufferViewConfig widgetHasChanged(); } - void ChatMonitorSettingsPage::on_activateBuffer_clicked() { if (ui.availableBuffers->currentIndex().isValid() && ui.availableBuffers->selectionModel()->hasSelection()) { @@ -264,7 +263,6 @@ void ChatMonitorSettingsPage::on_activateBuffer_clicked() } } - void ChatMonitorSettingsPage::on_deactivateBuffer_clicked() { if (ui.activeBuffers->currentIndex().isValid() && ui.activeBuffers->selectionModel()->hasSelection()) { @@ -273,7 +271,6 @@ void ChatMonitorSettingsPage::on_deactivateBuffer_clicked() } } - /* switchOperationMode gets called on combobox signal currentIndexChanged. modeIndex is the row id in combobox itemlist @@ -289,3 +286,34 @@ void ChatMonitorSettingsPage::switchOperationMode(int idx) } widgetHasChanged(); } + +void ChatMonitorSettingsPage::setRequesterType(const QVariant& v) +{ + bool usingAsNeededRequester = (v.toInt() == BacklogRequester::AsNeeded); + ui.showBacklogUnavailableDetails->setVisible(usingAsNeededRequester); + if (usingAsNeededRequester) { + ui.showBacklog->setText(tr("Show messages from backlog (not available)")); + } + else { + ui.showBacklog->setText(tr("Show messages from backlog")); + } +} + +void ChatMonitorSettingsPage::on_showBacklogUnavailableDetails_clicked() +{ + // Explain that backlog fetching is disabled, so backlog messages won't show up + // + // Technically, backlog messages *will* show up once fetched, e.g. after clicking on a buffer. + // This might be too trivial of a detail to warrant explaining, though. + QMessageBox::information(this, + tr("Messages from backlog are not fetched"), + QString("

%1

%2

") + .arg(tr("No initial backlog will be fetched when using the backlog request method of %1.") + .arg(tr("Only fetch when needed").replace(" ", " ")), + tr("Configure this in the %1 settings page.") + .arg(tr("Backlog Fetching").replace(" ", " ")) + ) + ); + // Re-use translations of "Only fetch when needed" and "Backlog Fetching" as this is a + // word-for-word reference, forcing all spaces to be non-breaking +}