mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
added basic alternating messages backgrounds
This commit is contained in:
parent
12766f3b60
commit
34a58021bc
9 changed files with 49 additions and 26 deletions
|
@ -12,26 +12,8 @@ namespace highlights {
|
||||||
HighlightModel::HighlightModel(QObject *parent)
|
HighlightModel::HighlightModel(QObject *parent)
|
||||||
: util::SignalVectorModel<HighlightPhrase>(4, parent)
|
: util::SignalVectorModel<HighlightPhrase>(4, parent)
|
||||||
{
|
{
|
||||||
// auto app = getApp();
|
|
||||||
|
|
||||||
// std::vector<QStandardItem *> 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
|
// turn a vector item into a model row
|
||||||
HighlightPhrase HighlightModel::getItemFromRow(std::vector<QStandardItem *> &row)
|
HighlightPhrase HighlightModel::getItemFromRow(std::vector<QStandardItem *> &row)
|
||||||
{
|
{
|
||||||
|
|
|
@ -167,6 +167,12 @@ void MessageLayout::paint(QPainter &painter, int y, int messageIndex, Selection
|
||||||
this->container.paintSelection(painter, messageIndex, selection, y);
|
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
|
// draw last read message line
|
||||||
if (isLastReadMessage) {
|
if (isLastReadMessage) {
|
||||||
QColor color = isWindowFocused ? app->themes->tabs.selected.backgrounds.regular.color()
|
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);
|
painter.setRenderHint(QPainter::SmoothPixmapTransform);
|
||||||
|
|
||||||
// draw background
|
// draw background
|
||||||
painter.fillRect(buffer->rect(), this->message->flags & Message::Highlighted
|
QColor backgroundColor;
|
||||||
? app->themes->messages.backgrounds.highlighted
|
if (this->message->flags & Message::Highlighted) {
|
||||||
: app->themes->messages.backgrounds.regular);
|
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
|
// draw message
|
||||||
this->container.paintElements(painter);
|
this->container.paintElements(painter);
|
||||||
|
|
|
@ -19,7 +19,11 @@ namespace layouts {
|
||||||
class MessageLayout : boost::noncopyable
|
class MessageLayout : boost::noncopyable
|
||||||
{
|
{
|
||||||
public:
|
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(MessagePtr message);
|
||||||
~MessageLayout();
|
~MessageLayout();
|
||||||
|
|
|
@ -40,6 +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 alternateMessageBackground = {"/appearance/messages/alternateMessageBackground",
|
||||||
|
false};
|
||||||
BoolSetting windowTopMost = {"/appearance/windowAlwaysOnTop", false};
|
BoolSetting windowTopMost = {"/appearance/windowAlwaysOnTop", false};
|
||||||
BoolSetting showTabCloseButton = {"/appearance/showTabCloseButton", true};
|
BoolSetting showTabCloseButton = {"/appearance/showTabCloseButton", true};
|
||||||
BoolSetting hidePreferencesButton = {"/appearance/hidePreferencesButton", false};
|
BoolSetting hidePreferencesButton = {"/appearance/hidePreferencesButton", false};
|
||||||
|
|
|
@ -116,7 +116,7 @@ void ThemeManager::actuallyUpdate(double hue, double multiplier)
|
||||||
// Split
|
// Split
|
||||||
bool flat = isLight;
|
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.background = getColor(0, sat, 1);
|
||||||
this->splits.dropPreview = getColor(hue, 0.5, 0.5, 0.6);
|
this->splits.dropPreview = getColor(hue, 0.5, 0.5, 0.6);
|
||||||
// this->splits.border
|
// this->splits.border
|
||||||
|
@ -140,6 +140,7 @@ void ThemeManager::actuallyUpdate(double hue, double multiplier)
|
||||||
this->messages.textColors.system = QColor(140, 127, 127);
|
this->messages.textColors.system = QColor(140, 127, 127);
|
||||||
|
|
||||||
this->messages.backgrounds.regular = splits.background;
|
this->messages.backgrounds.regular = splits.background;
|
||||||
|
this->messages.backgrounds.alternate = getColor(0, sat, 0.96);
|
||||||
this->messages.backgrounds.highlighted =
|
this->messages.backgrounds.highlighted =
|
||||||
blendColors(themeColor, this->messages.backgrounds.regular, 0.8);
|
blendColors(themeColor, this->messages.backgrounds.regular, 0.8);
|
||||||
// this->messages.backgrounds.resub
|
// this->messages.backgrounds.resub
|
||||||
|
|
|
@ -86,6 +86,7 @@ public:
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
QColor regular;
|
QColor regular;
|
||||||
|
QColor alternate;
|
||||||
QColor highlighted;
|
QColor highlighted;
|
||||||
// QColor resub;
|
// QColor resub;
|
||||||
// QColor whisper;
|
// QColor whisper;
|
||||||
|
|
|
@ -356,6 +356,11 @@ void ChannelView::setChannel(ChannelPtr newChannel)
|
||||||
|
|
||||||
auto messageRef = new MessageLayout(message);
|
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->messages.pushBack(MessageLayoutPtr(messageRef), deleted)) {
|
||||||
if (!this->paused) {
|
if (!this->paused) {
|
||||||
if (this->scrollBar.isAtBottom()) {
|
if (this->scrollBar.isAtBottom()) {
|
||||||
|
|
|
@ -85,6 +85,7 @@ private:
|
||||||
QTimer updateTimer;
|
QTimer updateTimer;
|
||||||
bool updateQueued = false;
|
bool updateQueued = false;
|
||||||
bool messageWasAdded = false;
|
bool messageWasAdded = false;
|
||||||
|
bool lastMessageHasAlternateBackground = false;
|
||||||
bool paused = false;
|
bool paused = false;
|
||||||
QTimer pauseTimeout;
|
QTimer pauseTimeout;
|
||||||
boost::optional<messages::MessageElement::Flags> overrideFlags;
|
boost::optional<messages::MessageElement::Flags> overrideFlags;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "appearancepage.hpp"
|
#include "appearancepage.hpp"
|
||||||
|
|
||||||
#include "application.hpp"
|
#include "application.hpp"
|
||||||
|
#include "singletons/windowmanager.hpp"
|
||||||
#include "util/layoutcreator.hpp"
|
#include "util/layoutcreator.hpp"
|
||||||
#include "util/removescrollareabackground.hpp"
|
#include "util/removescrollareabackground.hpp"
|
||||||
|
|
||||||
|
@ -76,9 +77,22 @@ AppearancePage::AppearancePage()
|
||||||
}
|
}
|
||||||
|
|
||||||
messages.append(this->createCheckBox("Show badges", app->settings->showBadges));
|
messages.append(this->createCheckBox("Show badges", app->settings->showBadges));
|
||||||
auto checkbox = this->createCheckBox("Seperate messages", app->settings->seperateMessages);
|
{
|
||||||
checkbox->setEnabled(false);
|
auto checkbox =
|
||||||
messages.append(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",
|
messages.append(this->createCheckBox("Show message length while typing",
|
||||||
app->settings->showMessageLength));
|
app->settings->showMessageLength));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue