mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
improve "last message read" indicator (#802)
This commit is contained in:
parent
54c1efe531
commit
a584259785
5 changed files with 77 additions and 5 deletions
|
@ -183,10 +183,15 @@ void MessageLayout::paint(QPainter &painter, int width, int y, int messageIndex,
|
||||||
|
|
||||||
// draw last read message line
|
// draw last read message line
|
||||||
if (isLastReadMessage) {
|
if (isLastReadMessage) {
|
||||||
QColor color =
|
QColor color;
|
||||||
isWindowFocused
|
if (getSettings()->lastMessageColor != "") {
|
||||||
? app->themes->tabs.selected.backgrounds.regular.color()
|
color = QColor(getSettings()->lastMessageColor.getValue());
|
||||||
: app->themes->tabs.selected.backgrounds.unfocused.color();
|
} else {
|
||||||
|
color =
|
||||||
|
isWindowFocused
|
||||||
|
? app->themes->tabs.selected.backgrounds.regular.color()
|
||||||
|
: app->themes->tabs.selected.backgrounds.unfocused.color();
|
||||||
|
}
|
||||||
|
|
||||||
QBrush brush(color, static_cast<Qt::BrushStyle>(
|
QBrush brush(color, static_cast<Qt::BrushStyle>(
|
||||||
getSettings()->lastMessagePattern.getValue()));
|
getSettings()->lastMessagePattern.getValue()));
|
||||||
|
|
|
@ -33,6 +33,8 @@ public:
|
||||||
"/appearance/messages/showLastMessageIndicator", false};
|
"/appearance/messages/showLastMessageIndicator", false};
|
||||||
IntSetting lastMessagePattern = {"/appearance/messages/lastMessagePattern",
|
IntSetting lastMessagePattern = {"/appearance/messages/lastMessagePattern",
|
||||||
Qt::VerPattern};
|
Qt::VerPattern};
|
||||||
|
QStringSetting lastMessageColor = {"/appearance/messages/lastMessageColor",
|
||||||
|
""};
|
||||||
BoolSetting showEmptyInput = {"/appearance/showEmptyInputBox", true};
|
BoolSetting showEmptyInput = {"/appearance/showEmptyInputBox", true};
|
||||||
BoolSetting showMessageLength = {"/appearance/messages/showMessageLength",
|
BoolSetting showMessageLength = {"/appearance/messages/showMessageLength",
|
||||||
false};
|
false};
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include "widgets/helper/NotebookButton.hpp"
|
#include "widgets/helper/NotebookButton.hpp"
|
||||||
#include "widgets/helper/NotebookTab.hpp"
|
#include "widgets/helper/NotebookTab.hpp"
|
||||||
#include "widgets/helper/Shortcut.hpp"
|
#include "widgets/helper/Shortcut.hpp"
|
||||||
|
#include "widgets/splits/Split.hpp"
|
||||||
#include "widgets/splits/SplitContainer.hpp"
|
#include "widgets/splits/SplitContainer.hpp"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
@ -490,4 +491,17 @@ SplitContainer *SplitNotebook::getOrAddSelectedPage()
|
||||||
: this->addPage();
|
: this->addPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SplitNotebook::select(QWidget *page)
|
||||||
|
{
|
||||||
|
if (auto selectedPage = this->getSelectedPage()) {
|
||||||
|
if (auto splitContainer =
|
||||||
|
dynamic_cast<SplitContainer *>(selectedPage)) {
|
||||||
|
for (auto split : splitContainer->getSplits()) {
|
||||||
|
split->updateLastReadMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this->Notebook::select(page);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -30,7 +30,7 @@ public:
|
||||||
void removeCurrentPage();
|
void removeCurrentPage();
|
||||||
|
|
||||||
int indexOf(QWidget *page) const;
|
int indexOf(QWidget *page) const;
|
||||||
void select(QWidget *page);
|
virtual void select(QWidget *page);
|
||||||
void selectIndex(int index);
|
void selectIndex(int index);
|
||||||
void selectNextTab();
|
void selectNextTab();
|
||||||
void selectPreviousTab();
|
void selectPreviousTab();
|
||||||
|
@ -90,6 +90,7 @@ public:
|
||||||
|
|
||||||
SplitContainer *addPage(bool select = false);
|
SplitContainer *addPage(bool select = false);
|
||||||
SplitContainer *getOrAddSelectedPage();
|
SplitContainer *getOrAddSelectedPage();
|
||||||
|
void select(QWidget *page) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void addCustomButtons();
|
void addCustomButtons();
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include "widgets/helper/ChannelView.hpp"
|
#include "widgets/helper/ChannelView.hpp"
|
||||||
#include "widgets/helper/Line.hpp"
|
#include "widgets/helper/Line.hpp"
|
||||||
|
|
||||||
|
#include <QColorDialog>
|
||||||
#include <QFontDialog>
|
#include <QFontDialog>
|
||||||
#include <QFormLayout>
|
#include <QFormLayout>
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
|
@ -351,11 +352,60 @@ void LookPage::addLastReadMessageIndicatorPatternSelector(
|
||||||
}();
|
}();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// color picker
|
||||||
|
|
||||||
|
QLabel *colorPreview = new QLabel();
|
||||||
|
|
||||||
|
auto updatePreviewColor = [colorPreview](QColor newColor) {
|
||||||
|
QPixmap pixmap(16, 16);
|
||||||
|
pixmap.fill(QColor(0, 0, 0, 255));
|
||||||
|
|
||||||
|
QPainter painter(&pixmap);
|
||||||
|
QBrush brush(newColor);
|
||||||
|
painter.fillRect(1, 1, pixmap.width() - 2, pixmap.height() - 2, brush);
|
||||||
|
colorPreview->setPixmap(pixmap);
|
||||||
|
};
|
||||||
|
|
||||||
|
auto getCurrentColor = []() {
|
||||||
|
return getSettings()->lastMessageColor != ""
|
||||||
|
? QColor(getSettings()->lastMessageColor.getValue())
|
||||||
|
: getApp()
|
||||||
|
->themes->tabs.selected.backgrounds.regular.color();
|
||||||
|
};
|
||||||
|
|
||||||
|
updatePreviewColor(getCurrentColor());
|
||||||
|
|
||||||
|
QPushButton *button = new QPushButton("Select Color");
|
||||||
|
button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Policy::Fixed);
|
||||||
|
|
||||||
|
QObject::connect(
|
||||||
|
button, &QPushButton::clicked, [updatePreviewColor, getCurrentColor]() {
|
||||||
|
QColor newColor = QColorDialog::getColor(getCurrentColor());
|
||||||
|
if (newColor.isValid()) {
|
||||||
|
updatePreviewColor(newColor);
|
||||||
|
getSettings()->lastMessageColor = newColor.name();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
QPushButton *resetButton = new QPushButton("Reset Color");
|
||||||
|
resetButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Policy::Fixed);
|
||||||
|
|
||||||
|
QObject::connect(
|
||||||
|
resetButton, &QPushButton::clicked, [updatePreviewColor]() {
|
||||||
|
QColor defaultColor =
|
||||||
|
getApp()->themes->tabs.selected.backgrounds.regular.color();
|
||||||
|
updatePreviewColor(defaultColor);
|
||||||
|
getSettings()->lastMessageColor = "";
|
||||||
|
});
|
||||||
|
|
||||||
// layout
|
// layout
|
||||||
auto hbox = layout.emplace<QHBoxLayout>().withoutMargin();
|
auto hbox = layout.emplace<QHBoxLayout>().withoutMargin();
|
||||||
hbox.append(this->createCheckBox(LAST_MSG,
|
hbox.append(this->createCheckBox(LAST_MSG,
|
||||||
getSettings()->showLastMessageIndicator));
|
getSettings()->showLastMessageIndicator));
|
||||||
hbox.append(combo);
|
hbox.append(combo);
|
||||||
|
hbox.append(colorPreview);
|
||||||
|
hbox.append(button);
|
||||||
|
hbox.append(resetButton);
|
||||||
hbox->addStretch(1);
|
hbox->addStretch(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue