From 065c204bd2d88d5e1695aee782e44774469fecf3 Mon Sep 17 00:00:00 2001 From: Fedja Beader Date: Thu, 16 May 2024 15:08:42 +0200 Subject: Switch "show chat history" into a line limit field and considerably raise default (5->100). --- src/defaults.cpp | 2 +- src/gui/widgets/tabs/chat/chattab.cpp | 10 ++++++---- src/gui/widgets/tabs/chat/chattab.h | 3 ++- src/gui/widgets/tabs/setup_chat.cpp | 9 +++++---- 4 files changed, 14 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/defaults.cpp b/src/defaults.cpp index 32084a1b5..eae83e1ab 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -232,7 +232,7 @@ void setConfigDefaults(Configuration &cfg) AddDEF("allowCommandsInChatTabs", true); AddDEF("serverMsgInDebug", true); AddDEF("hideShopMessages", true); - AddDEF("showChatHistory", true); + AddDEF("loadChatHistoryLines", 100); AddDEF("chatMaxLinesLimit", 100); AddDEF("chatColor", 0); AddDEF("showJob", true); diff --git a/src/gui/widgets/tabs/chat/chattab.cpp b/src/gui/widgets/tabs/chat/chattab.cpp index 9809287d2..3773df55f 100644 --- a/src/gui/widgets/tabs/chat/chattab.cpp +++ b/src/gui/widgets/tabs/chat/chattab.cpp @@ -98,8 +98,9 @@ ChatTab::ChatTab(const Widget2 *const widget, chatWindow->addTab(this); mTextOutput->updateSize(true); - if (config.getBoolValue("showChatHistory")) - loadFromLogFile(logName); + const int maxLines = config.getIntValue("loadChatHistoryLines"); + if (maxLines > 0) + loadFromLogFile(logName, maxLines); } ChatTab::~ChatTab() @@ -513,12 +514,13 @@ void ChatTab::addRow(std::string &line) false); } -void ChatTab::loadFromLogFile(const std::string &name) +void ChatTab::loadFromLogFile(const std::string &name, + const unsigned maxLines) { if (chatLogger != nullptr) { std::list list; - chatLogger->loadLast(name, list, 5); + chatLogger->loadLast(name, list, maxLines); std::list::const_iterator i = list.begin(); while (i != list.end()) { diff --git a/src/gui/widgets/tabs/chat/chattab.h b/src/gui/widgets/tabs/chat/chattab.h index 7a3774fc2..7aeeeebdb 100644 --- a/src/gui/widgets/tabs/chat/chattab.h +++ b/src/gui/widgets/tabs/chat/chattab.h @@ -153,7 +153,8 @@ class ChatTab notfinal : public Tab bool hasRows() const A_WARN_UNUSED { return mTextOutput->hasRows(); } - void loadFromLogFile(const std::string &name); + void loadFromLogFile(const std::string &name, + const unsigned maxLines); bool getAllowHighlight() const noexcept2 A_WARN_UNUSED { return mAllowHightlight; } diff --git a/src/gui/widgets/tabs/setup_chat.cpp b/src/gui/widgets/tabs/setup_chat.cpp index f42f34c5a..ae9043962 100644 --- a/src/gui/widgets/tabs/setup_chat.cpp +++ b/src/gui/widgets/tabs/setup_chat.cpp @@ -148,11 +148,12 @@ Setup_Chat::Setup_Chat(const Widget2 *const widget) : MainConfig_true); // TRANSLATORS: settings option - new SetupItemCheckBox(_("Show chat history"), + new SetupItemIntTextField(_("Show chat history lines"), // TRANSLATORS: settings description - _("If this setting enabled, client will load old chat tabs content " - "from logs on startup instead of starting with empty chat tabs."), - "showChatHistory", this, "showChatHistoryEvent", + _("If this number is set to above 0, the client will load old chat" + " tabs content from logs on startup instead of starting with empty" + " chat tabs."), + "loadChatHistoryLines", this, "loadChatHistoryLinesEvent", 0, 10000, MainConfig_true); // TRANSLATORS: settings option -- cgit v1.2.3-70-g09d2