added int setting for collapsed messages

This commit is contained in:
fourtf 2018-06-04 16:34:47 +02:00
parent 7ad4e36dbb
commit 70617e294f
5 changed files with 22 additions and 8 deletions

View file

@ -9,7 +9,7 @@
#include <QPainter> #include <QPainter>
#define COMPACT_EMOTES_OFFSET 6 #define COMPACT_EMOTES_OFFSET 6
#define MAX_UNCOLLAPSED_LINES 3 #define MAX_UNCOLLAPSED_LINES (getApp()->settings->collpseMessagesMinLines.getValue())
namespace chatterino { namespace chatterino {
namespace messages { namespace messages {
@ -214,7 +214,7 @@ void MessageLayoutContainer::end()
bool MessageLayoutContainer::canCollapse() bool MessageLayoutContainer::canCollapse()
{ {
return getApp()->settings->collapseLongMessages.getValue() && return getApp()->settings->collpseMessagesMinLines.getValue() > 0 &&
this->flags & Message::MessageFlags::Collapsed; this->flags & Message::MessageFlags::Collapsed;
} }

View file

@ -49,7 +49,7 @@ void SettingManager::initialize()
[](auto, auto) { getApp()->windows->forceLayoutChannelViews(); }); [](auto, auto) { getApp()->windows->forceLayoutChannelViews(); });
this->seperateMessages.connect( this->seperateMessages.connect(
[](auto, auto) { getApp()->windows->forceLayoutChannelViews(); }); [](auto, auto) { getApp()->windows->forceLayoutChannelViews(); });
this->collapseLongMessages.connect( this->collpseMessagesMinLines.connect(
[](auto, auto) { getApp()->windows->forceLayoutChannelViews(); }); [](auto, auto) { getApp()->windows->forceLayoutChannelViews(); });
} }

View file

@ -40,7 +40,8 @@ public:
BoolSetting hideEmptyInput = {"/appearance/hideEmptyInputBox", false}; BoolSetting hideEmptyInput = {"/appearance/hideEmptyInputBox", false};
BoolSetting showMessageLength = {"/appearance/messages/showMessageLength", false}; BoolSetting showMessageLength = {"/appearance/messages/showMessageLength", false};
BoolSetting seperateMessages = {"/appearance/messages/separateMessages", 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", BoolSetting alternateMessageBackground = {"/appearance/messages/alternateMessageBackground",
false}; false};
BoolSetting windowTopMost = {"/appearance/windowAlwaysOnTop", false}; BoolSetting windowTopMost = {"/appearance/windowAlwaysOnTop", false};

View file

@ -35,8 +35,8 @@ private:
class ButtonEventFilter : public QObject class ButtonEventFilter : public QObject
{ {
HoveredElement hoveredElement;
SplitOverlay *parent; SplitOverlay *parent;
HoveredElement hoveredElement;
public: public:
ButtonEventFilter(SplitOverlay *parent, HoveredElement hoveredElement); ButtonEventFilter(SplitOverlay *parent, HoveredElement hoveredElement);

View file

@ -82,8 +82,21 @@ AppearancePage::AppearancePage()
messages.append(this->createCheckBox("Show badges", app->settings->showBadges)); 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<QHBoxLayout>().withoutMargin();
hbox.emplace<QLabel>("Collapse messages longer than");
hbox.append(combo);
hbox.emplace<QLabel>("lines");
}
messages.append(this->createCheckBox("Seperate messages", app->settings->seperateMessages)); messages.append(this->createCheckBox("Seperate messages", app->settings->seperateMessages));
messages.append(this->createCheckBox("Alternate message background color", messages.append(this->createCheckBox("Alternate message background color",
app->settings->alternateMessageBackground)); app->settings->alternateMessageBackground));
@ -130,7 +143,7 @@ AppearancePage::AppearancePage()
} }
layout->addStretch(1); layout->addStretch(1);
} } // namespace settingspages
QLayout *AppearancePage::createThemeColorChanger() QLayout *AppearancePage::createThemeColorChanger()
{ {