diff --git a/src/controllers/highlights/highlightmodel.cpp b/src/controllers/highlights/highlightmodel.cpp index b32df7e0f..971e9fd8c 100644 --- a/src/controllers/highlights/highlightmodel.cpp +++ b/src/controllers/highlights/highlightmodel.cpp @@ -12,26 +12,8 @@ namespace highlights { HighlightModel::HighlightModel(QObject *parent) : util::SignalVectorModel(4, parent) { - // auto app = getApp(); - - // std::vector row = this->createRow(); - - // util::setBoolItem(row[0], app->settings->enableHighlightsSelf.getValue(), true, false); - // util::setBoolItem(row[1], app->settings->enableHighlightsSelf.getValue(), true, false); - // util::setBoolItem(row[2], app->settings->enableHighlightsSelf.getValue(), true, false); - // row[0]->setData("Your name (automatic)", Qt::DisplayRole); - - // this->insertCustomRow(row, 0); } -// app->settings->highlightProperties.setValue(phrases); -// app->settings->enableHighlightsSelf.setValue( -// model->item(0, 0)->data(Qt::CheckStateRole).toBool()); -// app->settings->enableHighlightTaskbar.setValue( -// model->item(0, 1)->data(Qt::CheckStateRole).toBool()); -// app->settings->enableHighlightSound.setValue( -// model->item(0, 2)->data(Qt::CheckStateRole).toBool()); - // turn a vector item into a model row HighlightPhrase HighlightModel::getItemFromRow(std::vector &row) { diff --git a/src/messages/layouts/messagelayout.cpp b/src/messages/layouts/messagelayout.cpp index 1702b6e30..961511148 100644 --- a/src/messages/layouts/messagelayout.cpp +++ b/src/messages/layouts/messagelayout.cpp @@ -167,6 +167,12 @@ void MessageLayout::paint(QPainter &painter, int y, int messageIndex, Selection this->container.paintSelection(painter, messageIndex, selection, y); } + // draw message seperation line + if (app->settings->seperateMessages.getValue()) { + painter.fillRect(0, y + this->container.getHeight() - 1, this->container.getWidth(), 1, + app->themes->splits.messageSeperator); + } + // draw last read message line if (isLastReadMessage) { QColor color = isWindowFocused ? app->themes->tabs.selected.backgrounds.regular.color() @@ -190,9 +196,16 @@ void MessageLayout::updateBuffer(QPixmap *buffer, int messageIndex, Selection &s painter.setRenderHint(QPainter::SmoothPixmapTransform); // draw background - painter.fillRect(buffer->rect(), this->message->flags & Message::Highlighted - ? app->themes->messages.backgrounds.highlighted - : app->themes->messages.backgrounds.regular); + QColor backgroundColor; + if (this->message->flags & Message::Highlighted) { + backgroundColor = app->themes->messages.backgrounds.highlighted; + } else if (app->settings->alternateMessageBackground.getValue() && + this->flags & MessageLayout::AlternateBackground) { + backgroundColor = app->themes->messages.backgrounds.alternate; + } else { + backgroundColor = app->themes->messages.backgrounds.regular; + } + painter.fillRect(buffer->rect(), backgroundColor); // draw message this->container.paintElements(painter); diff --git a/src/messages/layouts/messagelayout.hpp b/src/messages/layouts/messagelayout.hpp index 1d1fcbd48..76878c07a 100644 --- a/src/messages/layouts/messagelayout.hpp +++ b/src/messages/layouts/messagelayout.hpp @@ -19,7 +19,11 @@ namespace layouts { class MessageLayout : boost::noncopyable { public: - enum Flags : uint8_t { RequiresBufferUpdate = 1 << 1, RequiresLayout = 1 << 2 }; + enum Flags : uint8_t { + RequiresBufferUpdate = 1 << 1, + RequiresLayout = 1 << 2, + AlternateBackground = 1 << 3 + }; MessageLayout(MessagePtr message); ~MessageLayout(); diff --git a/src/singletons/settingsmanager.hpp b/src/singletons/settingsmanager.hpp index 3df59463f..3ba4653fe 100644 --- a/src/singletons/settingsmanager.hpp +++ b/src/singletons/settingsmanager.hpp @@ -40,6 +40,8 @@ public: BoolSetting hideEmptyInput = {"/appearance/hideEmptyInputBox", false}; BoolSetting showMessageLength = {"/appearance/messages/showMessageLength", false}; BoolSetting seperateMessages = {"/appearance/messages/separateMessages", false}; + BoolSetting alternateMessageBackground = {"/appearance/messages/alternateMessageBackground", + false}; BoolSetting windowTopMost = {"/appearance/windowAlwaysOnTop", false}; BoolSetting showTabCloseButton = {"/appearance/showTabCloseButton", true}; BoolSetting hidePreferencesButton = {"/appearance/hidePreferencesButton", false}; diff --git a/src/singletons/thememanager.cpp b/src/singletons/thememanager.cpp index c9d42c5fb..936ba8d1f 100644 --- a/src/singletons/thememanager.cpp +++ b/src/singletons/thememanager.cpp @@ -116,7 +116,7 @@ void ThemeManager::actuallyUpdate(double hue, double multiplier) // Split bool flat = isLight; - this->splits.messageSeperator = isLight ? QColor(127, 127, 127) : QColor(80, 80, 80); + this->splits.messageSeperator = isLight ? QColor(127, 127, 127) : QColor(60, 60, 60); this->splits.background = getColor(0, sat, 1); this->splits.dropPreview = getColor(hue, 0.5, 0.5, 0.6); // this->splits.border @@ -140,6 +140,7 @@ void ThemeManager::actuallyUpdate(double hue, double multiplier) this->messages.textColors.system = QColor(140, 127, 127); this->messages.backgrounds.regular = splits.background; + this->messages.backgrounds.alternate = getColor(0, sat, 0.96); this->messages.backgrounds.highlighted = blendColors(themeColor, this->messages.backgrounds.regular, 0.8); // this->messages.backgrounds.resub diff --git a/src/singletons/thememanager.hpp b/src/singletons/thememanager.hpp index 65bad368b..a44a2a364 100644 --- a/src/singletons/thememanager.hpp +++ b/src/singletons/thememanager.hpp @@ -86,6 +86,7 @@ public: struct { QColor regular; + QColor alternate; QColor highlighted; // QColor resub; // QColor whisper; diff --git a/src/widgets/helper/channelview.cpp b/src/widgets/helper/channelview.cpp index 79167ac24..be188c913 100644 --- a/src/widgets/helper/channelview.cpp +++ b/src/widgets/helper/channelview.cpp @@ -356,6 +356,11 @@ void ChannelView::setChannel(ChannelPtr newChannel) auto messageRef = new MessageLayout(message); + if (this->lastMessageHasAlternateBackground) { + messageRef->flags |= MessageLayout::AlternateBackground; + } + this->lastMessageHasAlternateBackground = !this->lastMessageHasAlternateBackground; + if (this->messages.pushBack(MessageLayoutPtr(messageRef), deleted)) { if (!this->paused) { if (this->scrollBar.isAtBottom()) { diff --git a/src/widgets/helper/channelview.hpp b/src/widgets/helper/channelview.hpp index dff02c039..02c74f730 100644 --- a/src/widgets/helper/channelview.hpp +++ b/src/widgets/helper/channelview.hpp @@ -85,6 +85,7 @@ private: QTimer updateTimer; bool updateQueued = false; bool messageWasAdded = false; + bool lastMessageHasAlternateBackground = false; bool paused = false; QTimer pauseTimeout; boost::optional overrideFlags; diff --git a/src/widgets/settingspages/appearancepage.cpp b/src/widgets/settingspages/appearancepage.cpp index 783dc6e44..6139e28d4 100644 --- a/src/widgets/settingspages/appearancepage.cpp +++ b/src/widgets/settingspages/appearancepage.cpp @@ -1,6 +1,7 @@ #include "appearancepage.hpp" #include "application.hpp" +#include "singletons/windowmanager.hpp" #include "util/layoutcreator.hpp" #include "util/removescrollareabackground.hpp" @@ -76,9 +77,22 @@ AppearancePage::AppearancePage() } messages.append(this->createCheckBox("Show badges", app->settings->showBadges)); - auto checkbox = this->createCheckBox("Seperate messages", app->settings->seperateMessages); - checkbox->setEnabled(false); - messages.append(checkbox); + { + auto checkbox = + this->createCheckBox("Seperate messages", app->settings->seperateMessages); + messages.append(checkbox); + QObject::connect(checkbox, &QCheckBox::toggled, + [](bool) { getApp()->windows->repaintVisibleChatWidgets(); }); + } + { + auto checkbox = this->createCheckBox("Alternate message background color", + app->settings->alternateMessageBackground); + messages.append(checkbox); + QObject::connect(checkbox, &QCheckBox::toggled, [](bool) { + getApp()->fonts->incGeneration(); // fourtf: hacky solution + getApp()->windows->repaintVisibleChatWidgets(); + }); + } messages.append(this->createCheckBox("Show message length while typing", app->settings->showMessageLength));