From 70617e294fe1bbfffe0120400145b8dab4b5cd04 Mon Sep 17 00:00:00 2001 From: fourtf Date: Mon, 4 Jun 2018 16:34:47 +0200 Subject: [PATCH] added int setting for collapsed messages --- .../layouts/messagelayoutcontainer.cpp | 4 ++-- src/singletons/settingsmanager.cpp | 2 +- src/singletons/settingsmanager.hpp | 3 ++- src/widgets/helper/splitoverlay.hpp | 2 +- src/widgets/settingspages/appearancepage.cpp | 19 ++++++++++++++++--- 5 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/messages/layouts/messagelayoutcontainer.cpp b/src/messages/layouts/messagelayoutcontainer.cpp index 6daa3288f..58aeeca81 100644 --- a/src/messages/layouts/messagelayoutcontainer.cpp +++ b/src/messages/layouts/messagelayoutcontainer.cpp @@ -9,7 +9,7 @@ #include #define COMPACT_EMOTES_OFFSET 6 -#define MAX_UNCOLLAPSED_LINES 3 +#define MAX_UNCOLLAPSED_LINES (getApp()->settings->collpseMessagesMinLines.getValue()) namespace chatterino { namespace messages { @@ -214,7 +214,7 @@ void MessageLayoutContainer::end() bool MessageLayoutContainer::canCollapse() { - return getApp()->settings->collapseLongMessages.getValue() && + return getApp()->settings->collpseMessagesMinLines.getValue() > 0 && this->flags & Message::MessageFlags::Collapsed; } diff --git a/src/singletons/settingsmanager.cpp b/src/singletons/settingsmanager.cpp index 32fe79bdc..27bca154e 100644 --- a/src/singletons/settingsmanager.cpp +++ b/src/singletons/settingsmanager.cpp @@ -49,7 +49,7 @@ void SettingManager::initialize() [](auto, auto) { getApp()->windows->forceLayoutChannelViews(); }); this->seperateMessages.connect( [](auto, auto) { getApp()->windows->forceLayoutChannelViews(); }); - this->collapseLongMessages.connect( + this->collpseMessagesMinLines.connect( [](auto, auto) { getApp()->windows->forceLayoutChannelViews(); }); } diff --git a/src/singletons/settingsmanager.hpp b/src/singletons/settingsmanager.hpp index 4a0680329..bdb603faa 100644 --- a/src/singletons/settingsmanager.hpp +++ b/src/singletons/settingsmanager.hpp @@ -40,7 +40,8 @@ public: BoolSetting hideEmptyInput = {"/appearance/hideEmptyInputBox", false}; BoolSetting showMessageLength = {"/appearance/messages/showMessageLength", false}; BoolSetting seperateMessages = {"/appearance/messages/separateMessages", false}; - BoolSetting collapseLongMessages = {"/appearance/messages/collapseLongMessages", false}; + // BoolSetting collapseLongMessages = {"/appearance/messages/collapseLongMessages", false}; + IntSetting collpseMessagesMinLines = {"/appearance/messages/collapseMessagesMinLines", 0}; BoolSetting alternateMessageBackground = {"/appearance/messages/alternateMessageBackground", false}; BoolSetting windowTopMost = {"/appearance/windowAlwaysOnTop", false}; diff --git a/src/widgets/helper/splitoverlay.hpp b/src/widgets/helper/splitoverlay.hpp index 9dc067991..bed720b0d 100644 --- a/src/widgets/helper/splitoverlay.hpp +++ b/src/widgets/helper/splitoverlay.hpp @@ -35,8 +35,8 @@ private: class ButtonEventFilter : public QObject { - HoveredElement hoveredElement; SplitOverlay *parent; + HoveredElement hoveredElement; public: ButtonEventFilter(SplitOverlay *parent, HoveredElement hoveredElement); diff --git a/src/widgets/settingspages/appearancepage.cpp b/src/widgets/settingspages/appearancepage.cpp index 3ab1c80bd..af4f13fe2 100644 --- a/src/widgets/settingspages/appearancepage.cpp +++ b/src/widgets/settingspages/appearancepage.cpp @@ -82,8 +82,21 @@ AppearancePage::AppearancePage() messages.append(this->createCheckBox("Show badges", app->settings->showBadges)); - messages.append(this->createCheckBox("Collapse large messages (3+ lines)", - app->settings->collapseLongMessages)); + { + auto *combo = new QComboBox(this); + combo->addItems({"Never", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", + "13", "14", "15"}); + + QObject::connect(combo, &QComboBox::currentTextChanged, [](const QString &str) { + getApp()->settings->collpseMessagesMinLines = str.toInt(); + }); + + auto hbox = messages.emplace().withoutMargin(); + hbox.emplace("Collapse messages longer than"); + hbox.append(combo); + hbox.emplace("lines"); + } + messages.append(this->createCheckBox("Seperate messages", app->settings->seperateMessages)); messages.append(this->createCheckBox("Alternate message background color", app->settings->alternateMessageBackground)); @@ -130,7 +143,7 @@ AppearancePage::AppearancePage() } layout->addStretch(1); -} +} // namespace settingspages QLayout *AppearancePage::createThemeColorChanger() {