summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFedja Beader <fedja@protonmail.ch>2024-05-16 15:08:42 +0200
committerFedja Beader <fedja@protonmail.ch>2024-05-29 21:39:28 +0000
commit065c204bd2d88d5e1695aee782e44774469fecf3 (patch)
tree6e1b75d17aa67047ab1423b5910f4a07d1115d72 /src
parente5957be971758eaa33c92e92a1fec47cbd001ca2 (diff)
downloadmv-065c204bd2d88d5e1695aee782e44774469fecf3.tar.gz
mv-065c204bd2d88d5e1695aee782e44774469fecf3.tar.bz2
mv-065c204bd2d88d5e1695aee782e44774469fecf3.tar.xz
mv-065c204bd2d88d5e1695aee782e44774469fecf3.zip
Switch "show chat history" into a line limit field and considerably
raise default (5->100).
Diffstat (limited to 'src')
-rw-r--r--src/defaults.cpp2
-rw-r--r--src/gui/widgets/tabs/chat/chattab.cpp10
-rw-r--r--src/gui/widgets/tabs/chat/chattab.h3
-rw-r--r--src/gui/widgets/tabs/setup_chat.cpp9
4 files changed, 14 insertions, 10 deletions
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<std::string> list;
- chatLogger->loadLast(name, list, 5);
+ chatLogger->loadLast(name, list, maxLines);
std::list<std::string>::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