Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Vilgot Fredenberg 2018-04-06 20:33:34 +02:00
commit 8dc8d94c75
No known key found for this signature in database
GPG key ID: FD58219A4C35C768
29 changed files with 339 additions and 98 deletions

View file

@ -39,6 +39,12 @@ Be sure to add "-j <number of cores\*2>" as a make argument so it will use all y
3. copy `include/rapidjson` from [rapidjson](https://github.com/miloyip/rapidjson/releases/latest) into the chatterino directory so that the file `<chatterino2 directory>/rapidjson/document.h` exists 3. copy `include/rapidjson` from [rapidjson](https://github.com/miloyip/rapidjson/releases/latest) into the chatterino directory so that the file `<chatterino2 directory>/rapidjson/document.h` exists
4. open `chatterino.pro` with QT Creator and build 4. open `chatterino.pro` with QT Creator and build
#### Ubuntu 18.04
*most likely works the same for other Debian-like distros*
1. Install dependencies (and the C++ IDE Qt Creator) `sudo apt install qtcreator qtmultimedia5-dev libqt5svg5-dev libboost-dev`
2. Install rapidjson to `/usr/local/` like this: From the Chatterino2 root folder: `sudo cp -r lib/rapidjson/include/rapidjson /usr/local/include`. If you want to install it to another place, you have to make sure it's in the chatterino.pro include path
3. open `chatterino.pro` with QT Creator and build
#### Arch Linux #### Arch Linux
install [chatterino2-git](https://aur.archlinux.org/packages/chatterino2-git/) from the aur or build manually as follows: install [chatterino2-git](https://aur.archlinux.org/packages/chatterino2-git/) from the aur or build manually as follows:
1. `sudo pacman -S qt5-base qt5-multimedia gst-plugins-ugly gst-plugins-good boost rapidjson` 1. `sudo pacman -S qt5-base qt5-multimedia gst-plugins-ugly gst-plugins-good boost rapidjson`

View file

@ -178,7 +178,9 @@ SOURCES += \
src/providers/irc/ircchannel2.cpp \ src/providers/irc/ircchannel2.cpp \
src/util/streamlink.cpp \ src/util/streamlink.cpp \
src/providers/twitch/twitchhelpers.cpp \ src/providers/twitch/twitchhelpers.cpp \
src/widgets/helper/signallabel.cpp src/widgets/helper/signallabel.cpp \
src/widgets/helper/debugpopup.cpp \
src/util/debugcount.cpp
HEADERS += \ HEADERS += \
src/precompiled_header.hpp \ src/precompiled_header.hpp \
@ -292,7 +294,9 @@ HEADERS += \
src/providers/irc/ircserver.hpp \ src/providers/irc/ircserver.hpp \
src/providers/irc/ircchannel2.hpp \ src/providers/irc/ircchannel2.hpp \
src/util/streamlink.hpp \ src/util/streamlink.hpp \
src/providers/twitch/twitchhelpers.hpp src/providers/twitch/twitchhelpers.hpp \
src/util/debugcount.hpp \
src/widgets/helper/debugpopup.hpp
RESOURCES += \ RESOURCES += \
resources/resources.qrc resources/resources.qrc

@ -1 +1 @@
Subproject commit ad31b38866d80a17ced902476ed06da69edce3a0 Subproject commit 2fa3adf42da988dc2a34b9b625654aa08e906d4f

View file

@ -30,6 +30,7 @@ Image::Image(const QString &url, qreal scale, const QString &name, const QString
, scale(scale) , scale(scale)
, isLoading(false) , isLoading(false)
{ {
util::DebugCount::increase("images");
} }
Image::Image(QPixmap *image, qreal scale, const QString &name, const QString &tooltip, Image::Image(QPixmap *image, qreal scale, const QString &name, const QString &tooltip,
@ -43,6 +44,20 @@ Image::Image(QPixmap *image, qreal scale, const QString &name, const QString &to
, isLoading(true) , isLoading(true)
, isLoaded(true) , isLoaded(true)
{ {
util::DebugCount::increase("images");
}
Image::~Image()
{
util::DebugCount::decrease("images");
if (this->isAnimated()) {
util::DebugCount::decrease("animated images");
}
if (this->isLoaded) {
util::DebugCount::decrease("loaded images");
}
} }
void Image::loadImage() void Image::loadImage()
@ -60,6 +75,15 @@ void Image::loadImage()
bool first = true; bool first = true;
// clear stuff before loading the image again
lli->allFrames.clear();
if (lli->isAnimated()) {
util::DebugCount::decrease("animated images");
}
if (lli->isLoaded) {
util::DebugCount::decrease("loaded images");
}
for (int index = 0; index < reader.imageCount(); ++index) { for (int index = 0; index < reader.imageCount(); ++index) {
if (reader.read(&image)) { if (reader.read(&image)) {
auto pixmap = new QPixmap(QPixmap::fromImage(image)); auto pixmap = new QPixmap(QPixmap::fromImage(image));
@ -79,11 +103,14 @@ void Image::loadImage()
if (lli->allFrames.size() > 1) { if (lli->allFrames.size() > 1) {
lli->animated = true; lli->animated = true;
util::DebugCount::increase("animated images");
} }
lli->currentPixmap = lli->loadedPixmap; lli->currentPixmap = lli->loadedPixmap;
lli->isLoaded = true; lli->isLoaded = true;
util::DebugCount::increase("loaded images");
singletons::EmoteManager::getInstance().incGeneration(); singletons::EmoteManager::getInstance().incGeneration();

View file

@ -12,8 +12,6 @@ namespace messages {
class Image : public QObject, boost::noncopyable class Image : public QObject, boost::noncopyable
{ {
public: public:
Image() = delete;
explicit Image(const QString &_url, qreal _scale = 1, const QString &_name = "", explicit Image(const QString &_url, qreal _scale = 1, const QString &_name = "",
const QString &_tooltip = "", const QMargins &_margin = QMargins(), const QString &_tooltip = "", const QMargins &_margin = QMargins(),
bool isHat = false); bool isHat = false);
@ -21,6 +19,7 @@ public:
explicit Image(QPixmap *_currentPixmap, qreal _scale = 1, const QString &_name = "", explicit Image(QPixmap *_currentPixmap, qreal _scale = 1, const QString &_name = "",
const QString &_tooltip = "", const QMargins &_margin = QMargins(), const QString &_tooltip = "", const QMargins &_margin = QMargins(),
bool isHat = false); bool isHat = false);
~Image();
const QPixmap *getPixmap(); const QPixmap *getPixmap();
qreal getScale() const; qreal getScale() const;

View file

@ -25,6 +25,12 @@ MessageLayout::MessageLayout(MessagePtr _message)
if (_message->flags & Message::Collapsed) { if (_message->flags & Message::Collapsed) {
this->flags &= MessageLayout::Collapsed; this->flags &= MessageLayout::Collapsed;
} }
util::DebugCount::increase("message layout");
}
MessageLayout::~MessageLayout()
{
util::DebugCount::decrease("message layout");
} }
Message *MessageLayout::getMessage() Message *MessageLayout::getMessage()
@ -141,6 +147,7 @@ void MessageLayout::paint(QPainter &painter, int y, int messageIndex, Selection
this->buffer = std::shared_ptr<QPixmap>(pixmap); this->buffer = std::shared_ptr<QPixmap>(pixmap);
this->bufferValid = false; this->bufferValid = false;
util::DebugCount::increase("message drawing buffers");
} }
if (!this->bufferValid || !selection.isEmpty()) { if (!this->bufferValid || !selection.isEmpty()) {
@ -215,7 +222,11 @@ void MessageLayout::invalidateBuffer()
void MessageLayout::deleteBuffer() void MessageLayout::deleteBuffer()
{ {
if (this->buffer != nullptr) {
util::DebugCount::decrease("message drawing buffers");
this->buffer = nullptr; this->buffer = nullptr;
}
} }
// Elements // Elements

View file

@ -22,6 +22,7 @@ public:
enum Flags : uint8_t { Collapsed, RequiresBufferUpdate, RequiresLayout }; enum Flags : uint8_t { Collapsed, RequiresBufferUpdate, RequiresLayout };
MessageLayout(MessagePtr message); MessageLayout(MessagePtr message);
~MessageLayout();
Message *getMessage(); Message *getMessage();

View file

@ -110,9 +110,8 @@ void MessageLayoutContainer::breakLine()
for (size_t i = lineStart; i < this->elements.size(); i++) { for (size_t i = lineStart; i < this->elements.size(); i++) {
MessageLayoutElement *element = this->elements.at(i).get(); MessageLayoutElement *element = this->elements.at(i).get();
bool isCompactEmote = bool isCompactEmote = !(this->flags & Message::DisableCompactEmotes) &&
!(this->flags & Message::DisableCompactEmotes) && element->getCreator().getFlags() & MessageElement::EmoteImages;
(this->flags & element->getCreator().getFlags()) & MessageElement::EmoteImages;
int yExtra = 0; int yExtra = 0;
if (isCompactEmote) { if (isCompactEmote) {

View file

@ -1,5 +1,6 @@
#include "messages/layouts/messagelayoutelement.hpp" #include "messages/layouts/messagelayoutelement.hpp"
#include "messages/messageelement.hpp" #include "messages/messageelement.hpp"
#include "util/debugcount.hpp"
#include <QDebug> #include <QDebug>
#include <QPainter> #include <QPainter>
@ -17,6 +18,12 @@ MessageLayoutElement::MessageLayoutElement(MessageElement &_creator, const QSize
: creator(_creator) : creator(_creator)
{ {
this->rect.setSize(size); this->rect.setSize(size);
util::DebugCount::increase("message layout elements");
}
MessageLayoutElement::~MessageLayoutElement()
{
util::DebugCount::decrease("message layout elements");
} }
MessageElement &MessageLayoutElement::getCreator() const MessageElement &MessageLayoutElement::getCreator() const
@ -98,6 +105,7 @@ void ImageLayoutElement::paintAnimated(QPainter &painter, int yOffset)
} }
if (this->image->isAnimated()) { if (this->image->isAnimated()) {
// qDebug() << this->image->getUrl();
auto pixmap = this->image->getPixmap(); auto pixmap = this->image->getPixmap();
if (pixmap != nullptr) { if (pixmap != nullptr) {

View file

@ -24,7 +24,7 @@ class MessageLayoutElement : boost::noncopyable
{ {
public: public:
MessageLayoutElement(MessageElement &creator, const QSize &size); MessageLayoutElement(MessageElement &creator, const QSize &size);
virtual ~MessageLayoutElement() = default; virtual ~MessageLayoutElement();
const QRect &getRect() const; const QRect &getRect() const;
MessageElement &getCreator() const; MessageElement &getCreator() const;

View file

@ -10,10 +10,22 @@
#include <memory> #include <memory>
#include <vector> #include <vector>
#include "util/debugcount.hpp"
namespace chatterino { namespace chatterino {
namespace messages { namespace messages {
struct Message { struct Message {
Message()
{
util::DebugCount::increase("messages");
}
~Message()
{
util::DebugCount::decrease("messages");
}
enum MessageFlags : uint16_t { enum MessageFlags : uint16_t {
None = 0, None = 0,
System = (1 << 0), System = (1 << 0),

View file

@ -11,6 +11,12 @@ namespace messages {
MessageElement::MessageElement(Flags _flags) MessageElement::MessageElement(Flags _flags)
: flags(_flags) : flags(_flags)
{ {
util::DebugCount::increase("message elements");
}
MessageElement::~MessageElement()
{
util::DebugCount::decrease("message elements");
} }
MessageElement *MessageElement::setLink(const Link &_link) MessageElement *MessageElement::setLink(const Link &_link)

View file

@ -110,7 +110,7 @@ public:
Update_All = Update_Text | Update_Emotes | Update_Images Update_All = Update_Text | Update_Emotes | Update_Images
}; };
virtual ~MessageElement() = default; virtual ~MessageElement();
MessageElement *setLink(const Link &link); MessageElement *setLink(const Link &link);
MessageElement *setTooltip(const QString &tooltip); MessageElement *setTooltip(const QString &tooltip);

View file

@ -54,9 +54,10 @@ void ThemeManager::update()
void ThemeManager::actuallyUpdate(double hue, double multiplier) void ThemeManager::actuallyUpdate(double hue, double multiplier)
{ {
isLight = multiplier > 0; isLight = multiplier > 0;
bool isLightTabs; bool lightWin = isLight;
QColor themeColor = QColor::fromHslF(hue, 0.5, 0.5); QColor none(0, 0, 0, 0);
QColor themeColor = QColor::fromHslF(hue, 0.43, 0.5);
QColor themeColorNoSat = QColor::fromHslF(hue, 0, 0.5); QColor themeColorNoSat = QColor::fromHslF(hue, 0, 0.5);
qreal sat = 0; qreal sat = 0;
@ -66,15 +67,12 @@ void ThemeManager::actuallyUpdate(double hue, double multiplier)
return QColor::fromHslF(h, s, ((l - 0.5) * multiplier) + 0.5, a); return QColor::fromHslF(h, s, ((l - 0.5) * multiplier) + 0.5, a);
}; };
//#ifdef USEWINSDK /// WINDOW
// isLightTabs = isLight; {
// QColor tabFg = isLight ? "#000" : "#fff"; QColor bg = this->window.background = lightWin ? "#fff" : "#444";
// this->windowBg = isLight ? "#fff" : getColor(0, sat, 0.9); QColor fg = this->window.text = lightWin ? "#000" : "#eee";
//#else this->window.borderFocused = lightWin ? "#ccc" : themeColor;
isLightTabs = true; this->window.borderUnfocused = lightWin ? "#ccc" : themeColorNoSat;
QColor tabFg = isLightTabs ? "#000" : "#fff";
this->windowBg = "#fff";
//#endif
// Ubuntu style // Ubuntu style
// TODO: add setting for this // TODO: add setting for this
@ -87,27 +85,22 @@ void ThemeManager::actuallyUpdate(double hue, double multiplier)
this->messages.textColors.caret = // this->messages.textColors.caret = //
this->messages.textColors.regular = isLight ? "#000" : "#fff"; this->messages.textColors.regular = isLight ? "#000" : "#fff";
// tabs /// TABS
// text, {regular, hover, unfocused} // text, {regular, hover, unfocused}
// this->windowBg = "#ccc";
this->tabs.border = "#999"; if (lightWin) {
this->tabs.regular = {tabFg, {windowBg, blendColors(windowBg, "#999", 0.5), windowBg}}; this->tabs.regular = {fg, {bg, "#ccc", bg}};
this->tabs.newMessage = {fg, {bg, "#ccc", bg}};
this->tabs.selected = {"#fff", {themeColor, themeColor, QColor::fromHslF(hue, 0, 0.5)}}; this->tabs.highlighted = {fg, {bg, "#ccc", bg}};
this->tabs.selected = {"#fff", {"#333", "#333", "#666"}};
this->tabs.newMessage = { } else {
tabFg, this->tabs.regular = {fg, {bg, "#555", bg}};
{QBrush(blendColors(themeColor, windowBg, 0.7), Qt::FDiagPattern), this->tabs.newMessage = {fg, {bg, "#555", bg}};
QBrush(blendColors(themeColor, windowBg, 0.5), Qt::FDiagPattern), this->tabs.highlighted = {fg, {bg, "#555", bg}};
QBrush(blendColors(themeColorNoSat, windowBg, 0.7), Qt::FDiagPattern)}}; // this->tabs.selected = {"#000", {themeColor, themeColor, themeColorNoSat}};
this->tabs.selected = {"#000", {"#999", "#999", "#888"}};
this->tabs.highlighted = { }
tabFg, }
{blendColors(themeColor, windowBg, 0.7), blendColors(themeColor, windowBg, 0.5),
blendColors(themeColorNoSat, windowBg, 0.7)}};
// this->windowBg = "#fff";
// Split // Split
bool flat = isLight; bool flat = isLight;

View file

@ -32,6 +32,15 @@ public:
} backgrounds; } backgrounds;
}; };
/// WINDOW
struct {
QColor background;
QColor text;
QColor borderUnfocused;
QColor borderFocused;
} window;
/// TABS
struct { struct {
TabColors regular; TabColors regular;
TabColors selected; TabColors selected;
@ -40,6 +49,7 @@ public:
QColor border; QColor border;
} tabs; } tabs;
/// SPLITS
struct { struct {
QColor messageSeperator; QColor messageSeperator;
QColor background; QColor background;
@ -64,6 +74,7 @@ public:
} input; } input;
} splits; } splits;
/// MESSAGES
struct { struct {
struct { struct {
QColor regular; QColor regular;
@ -85,6 +96,7 @@ public:
QColor selection; QColor selection;
} messages; } messages;
/// SCROLLBAR
struct { struct {
QColor background; QColor background;
QColor thumb; QColor thumb;
@ -93,14 +105,12 @@ public:
// QColor highlights[3]; // QColor highlights[3];
} scrollbars; } scrollbars;
/// TOOLTIP
struct { struct {
QColor text; QColor text;
QColor background; QColor background;
} tooltip; } tooltip;
QColor windowBg;
QColor windowText;
void normalizeColor(QColor &color); void normalizeColor(QColor &color);
void update(); void update();

10
src/util/debugcount.cpp Normal file
View file

@ -0,0 +1,10 @@
#include "debugcount.hpp"
namespace chatterino {
namespace util {
QMap<QString, int64_t> DebugCount::counts;
std::mutex DebugCount::mut;
} // namespace util
} // namespace chatterino

59
src/util/debugcount.hpp Normal file
View file

@ -0,0 +1,59 @@
#pragma once
#include <mutex>
#include <typeinfo>
#include <QMap>
#include <QString>
namespace chatterino {
namespace util {
class DebugCount
{
static QMap<QString, int64_t> counts;
static std::mutex mut;
public:
static void increase(const QString &name)
{
std::lock_guard<std::mutex> lock(mut);
auto it = counts.find(name);
if (it == counts.end()) {
counts.insert(name, 1);
} else {
reinterpret_cast<int64_t &>(it.value())++;
}
}
static void decrease(const QString &name)
{
std::lock_guard<std::mutex> lock(mut);
auto it = counts.find(name);
if (it == counts.end()) {
counts.insert(name, -1);
} else {
reinterpret_cast<int64_t &>(it.value())--;
}
}
static QString getDebugText()
{
std::lock_guard<std::mutex> lock(mut);
QString text;
for (auto it = counts.begin(); it != counts.end(); it++) {
text += it.key() + ": " + QString::number(it.value()) + "\n";
}
return text;
}
QString toString()
{
}
};
} // namespace util
} // namespace chatterino

View file

@ -160,12 +160,12 @@ void BaseWindow::themeRefreshEvent()
{ {
if (this->enableCustomFrame) { if (this->enableCustomFrame) {
QPalette palette; QPalette palette;
palette.setColor(QPalette::Background, this->themeManager.windowBg); palette.setColor(QPalette::Background, this->themeManager.window.background);
palette.setColor(QPalette::Foreground, this->themeManager.windowText); palette.setColor(QPalette::Foreground, this->themeManager.window.text);
this->setPalette(palette); this->setPalette(palette);
for (RippleEffectButton *button : this->buttons) { for (RippleEffectButton *button : this->buttons) {
button->setMouseEffectColor(this->themeManager.windowText); button->setMouseEffectColor(this->themeManager.window.text);
} }
} }
} }
@ -408,15 +408,22 @@ void BaseWindow::paintEvent(QPaintEvent *event)
bool windowFocused = this->window() == QApplication::activeWindow(); bool windowFocused = this->window() == QApplication::activeWindow();
QLinearGradient gradient(0, 0, 10, 250); // QLinearGradient gradient(0, 0, 10, 250);
gradient.setColorAt(1, this->themeManager.tabs.selected.backgrounds.unfocused.color()); // gradient.setColorAt(1,
// this->themeManager.tabs.selected.backgrounds.unfocused.color());
if (windowFocused) { // if (windowFocused) {
gradient.setColorAt(.4, this->themeManager.tabs.selected.backgrounds.regular.color()); // gradient.setColorAt(.4,
} else { // this->themeManager.tabs.selected.backgrounds.regular.color());
gradient.setColorAt(.4, this->themeManager.tabs.selected.backgrounds.unfocused.color()); // } else {
} // gradient.setColorAt(.4,
painter.setPen(QPen(QBrush(gradient), 1)); // this->themeManager.tabs.selected.backgrounds.unfocused.color());
// }
// painter.setPen(QPen(QBrush(gradient), 1));
QColor &border = windowFocused ? this->themeManager.window.borderFocused
: this->themeManager.window.borderUnfocused;
painter.setPen(QPen(QBrush(border), 1));
painter.drawRect(0, 0, this->width() - 1, this->height() - 1); painter.drawRect(0, 0, this->width() - 1, this->height() - 1);
} }

View file

@ -83,24 +83,36 @@ ChannelView::ChannelView(BaseWidget *parent)
}); });
}); });
this->updateTimer.setInterval(1000 / 60); // this->updateTimer.setInterval(1000 / 60);
this->updateTimer.setSingleShot(true); // this->updateTimer.setSingleShot(true);
connect(&this->updateTimer, &QTimer::timeout, this, [this] { // connect(&this->updateTimer, &QTimer::timeout, this, [this] {
if (this->updateQueued) { // if (this->updateQueued) {
this->updateQueued = false; // this->updateQueued = false;
this->repaint(); // this->repaint();
this->updateTimer.start(); // this->updateTimer.start();
} // }
}); // });
this->pauseTimeout.setSingleShot(true); this->pauseTimeout.setSingleShot(true);
auto e = new QResizeEvent(this->size(), this->size()); // auto e = new QResizeEvent(this->size(), this->size());
this->resizeEvent(e); // this->resizeEvent(e);
delete e; // delete e;
this->scrollBar.resize(this->scrollBar.width(), height() + 1);
singletons::SettingManager::getInstance().showLastMessageIndicator.connect( singletons::SettingManager::getInstance().showLastMessageIndicator.connect(
[this](auto, auto) { this->update(); }, this->managedConnections); [this](auto, auto) { this->update(); }, this->managedConnections);
this->layoutCooldown = new QTimer(this);
this->layoutCooldown->setSingleShot(true);
this->layoutCooldown->setInterval(66);
QObject::connect(this->layoutCooldown, &QTimer::timeout, [this] {
if (this->layoutQueued) {
this->layoutMessages();
}
});
} }
ChannelView::~ChannelView() ChannelView::~ChannelView()
@ -138,7 +150,13 @@ void ChannelView::queueUpdate()
void ChannelView::layoutMessages() void ChannelView::layoutMessages()
{ {
if (!this->layoutCooldown->isActive()) {
this->actuallyLayoutMessages(); this->actuallyLayoutMessages();
this->layoutCooldown->start();
} else {
this->layoutQueued = true;
}
} }
void ChannelView::actuallyLayoutMessages() void ChannelView::actuallyLayoutMessages()

View file

@ -77,6 +77,9 @@ protected:
QPoint &relativePos, int &index); QPoint &relativePos, int &index);
private: private:
QTimer *layoutCooldown;
bool layoutQueued;
QTimer updateTimer; QTimer updateTimer;
bool updateQueued = false; bool updateQueued = false;
bool messageWasAdded = false; bool messageWasAdded = false;

View file

@ -0,0 +1,30 @@
#include "debugpopup.hpp"
#include "util/debugcount.hpp"
#include <QFontDatabase>
#include <QHBoxLayout>
#include <QLabel>
#include <QTimer>
namespace chatterino {
namespace widgets {
DebugPopup::DebugPopup()
{
auto *layout = new QHBoxLayout(this);
auto *text = new QLabel(this);
auto *timer = new QTimer(this);
timer->setInterval(1000);
QObject::connect(timer, &QTimer::timeout,
[text] { text->setText(util::DebugCount::getDebugText()); });
timer->start();
text->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
layout->addWidget(text);
}
} // namespace widgets
} // namespace chatterino

View file

@ -0,0 +1,15 @@
#pragma once
#include <QWindow>
namespace chatterino {
namespace widgets {
class DebugPopup : public QWidget
{
public:
DebugPopup();
};
} // namespace widgets
} // namespace chatterino

View file

@ -17,11 +17,14 @@ namespace widgets {
NotebookButton::NotebookButton(BaseWidget *parent) NotebookButton::NotebookButton(BaseWidget *parent)
: RippleEffectButton(parent) : RippleEffectButton(parent)
{ {
setMouseEffectColor(QColor(0, 0, 0));
this->setAcceptDrops(true); this->setAcceptDrops(true);
} }
void NotebookButton::themeRefreshEvent()
{
this->setMouseEffectColor(this->themeManager.tabs.regular.text);
}
void NotebookButton::paintEvent(QPaintEvent *) void NotebookButton::paintEvent(QPaintEvent *)
{ {
QPainter painter(this); QPainter painter(this);
@ -30,15 +33,14 @@ void NotebookButton::paintEvent(QPaintEvent *)
QColor foreground; QColor foreground;
if (mouseDown || mouseOver) { if (mouseDown || mouseOver) {
background = this->themeManager.tabs.regular.backgrounds.regular.color(); background = this->themeManager.tabs.regular.backgrounds.hover.color();
foreground = this->themeManager.tabs.regular.text; foreground = this->themeManager.tabs.regular.text;
} else { } else {
background = this->themeManager.tabs.regular.backgrounds.regular.color(); background = this->themeManager.tabs.regular.backgrounds.regular.color();
foreground = QColor(70, 80, 80); foreground = this->themeManager.tabs.regular.text;
} }
painter.setPen(Qt::NoPen); painter.setPen(Qt::NoPen);
// painter.fillRect(this->rect(), background);
float h = height(), w = width(); float h = height(), w = width();

View file

@ -21,6 +21,7 @@ public:
NotebookButton(BaseWidget *parent); NotebookButton(BaseWidget *parent);
protected: protected:
virtual void themeRefreshEvent() override;
virtual void paintEvent(QPaintEvent *) override; virtual void paintEvent(QPaintEvent *) override;
virtual void mouseReleaseEvent(QMouseEvent *) override; virtual void mouseReleaseEvent(QMouseEvent *) override;
virtual void dragEnterEvent(QDragEnterEvent *) override; virtual void dragEnterEvent(QDragEnterEvent *) override;

View file

@ -103,9 +103,13 @@ QString NotebookTab::getTitle() const
void NotebookTab::setTitle(const QString &newTitle) void NotebookTab::setTitle(const QString &newTitle)
{ {
this->title = newTitle.toStdString(); auto stdTitle = newTitle.toStdString();
if (this->title != stdTitle) {
this->title = stdTitle;
this->updateSize(); this->updateSize();
this->update();
}
} }
bool NotebookTab::isSelected() const bool NotebookTab::isSelected() const
@ -209,13 +213,13 @@ void NotebookTab::paintEvent(QPaintEvent *)
painter.fillRect(rect(), tabBackground); painter.fillRect(rect(), tabBackground);
// draw border // draw border
painter.setPen(QPen("#ccc")); // painter.setPen(QPen("#ccc"));
QPainterPath path(QPointF(0, height)); // QPainterPath path(QPointF(0, height));
path.lineTo(0, 0); // path.lineTo(0, 0);
path.lineTo(this->width() - 1, 0); // path.lineTo(this->width() - 1, 0);
path.lineTo(this->width() - 1, this->height() - 1); // path.lineTo(this->width() - 1, this->height() - 1);
path.lineTo(0, this->height() - 1); // path.lineTo(0, this->height() - 1);
painter.drawPath(path); // painter.drawPath(path);
} else { } else {
// QPainterPath path(QPointF(0, height)); // QPainterPath path(QPointF(0, height));
// path.lineTo(8 * scale, 0); // path.lineTo(8 * scale, 0);

View file

@ -1,5 +1,7 @@
#include "titlebarbutton.hpp" #include "titlebarbutton.hpp"
#include "singletons/thememanager.hpp"
namespace chatterino { namespace chatterino {
namespace widgets { namespace widgets {
@ -23,8 +25,8 @@ void TitleBarButton::paintEvent(QPaintEvent *)
{ {
QPainter painter(this); QPainter painter(this);
QColor color = "#000"; QColor color = this->themeManager.window.text;
QColor background = "#fff"; QColor background = this->themeManager.window.background;
int xD = this->height() / 3; int xD = this->height() / 3;
int centerX = this->width() / 2; int centerX = this->width() / 2;
@ -59,7 +61,8 @@ void TitleBarButton::paintEvent(QPaintEvent *)
break; break;
} }
case User: { case User: {
color = QColor("#333"); // color = QColor("#333");
color = "#999";
painter.setRenderHint(QPainter::Antialiasing); painter.setRenderHint(QPainter::Antialiasing);
painter.setRenderHint(QPainter::HighQualityAntialiasing); painter.setRenderHint(QPainter::HighQualityAntialiasing);
@ -85,7 +88,8 @@ void TitleBarButton::paintEvent(QPaintEvent *)
break; break;
} }
case Settings: { case Settings: {
color = QColor("#333"); // color = QColor("#333");
color = "#999";
painter.setRenderHint(QPainter::Antialiasing); painter.setRenderHint(QPainter::Antialiasing);
painter.setRenderHint(QPainter::HighQualityAntialiasing); painter.setRenderHint(QPainter::HighQualityAntialiasing);

View file

@ -9,6 +9,7 @@
#include "singletons/windowmanager.hpp" #include "singletons/windowmanager.hpp"
#include "util/streamlink.hpp" #include "util/streamlink.hpp"
#include "util/urlfetch.hpp" #include "util/urlfetch.hpp"
#include "widgets/helper/debugpopup.hpp"
#include "widgets/helper/searchpopup.hpp" #include "widgets/helper/searchpopup.hpp"
#include "widgets/helper/shortcut.hpp" #include "widgets/helper/shortcut.hpp"
#include "widgets/qualitypopup.hpp" #include "widgets/qualitypopup.hpp"
@ -72,6 +73,13 @@ Split::Split(SplitContainer *parent, const std::string &_uuid)
// CTRL+F: Search // CTRL+F: Search
CreateShortcut(this, "CTRL+F", &Split::doSearch); CreateShortcut(this, "CTRL+F", &Split::doSearch);
// F12
CreateShortcut(this, "F10", [] {
auto *popup = new DebugPopup;
popup->setAttribute(Qt::WA_DeleteOnClose);
popup->show();
});
// xd // xd
// CreateShortcut(this, "ALT+SHIFT+RIGHT", &Split::doIncFlexX); // CreateShortcut(this, "ALT+SHIFT+RIGHT", &Split::doIncFlexX);
// CreateShortcut(this, "ALT+SHIFT+LEFT", &Split::doDecFlexX); // CreateShortcut(this, "ALT+SHIFT+LEFT", &Split::doDecFlexX);

View file

@ -22,6 +22,10 @@ namespace widgets {
class SplitContainer; class SplitContainer;
class xD
{
};
// Each ChatWidget consists of three sub-elements that handle their own part of the chat widget: // Each ChatWidget consists of three sub-elements that handle their own part of the chat widget:
// ChatWidgetHeader // ChatWidgetHeader
// - Responsible for rendering which channel the ChatWidget is in, and the menu in the top-left of // - Responsible for rendering which channel the ChatWidget is in, and the menu in the top-left of

View file

@ -41,7 +41,7 @@ SplitContainer::SplitContainer(Notebook *parent, NotebookTab *_tab, const std::s
this->setHidden(true); this->setHidden(true);
this->setAcceptDrops(true); this->setAcceptDrops(true);
this->ui.parentLayout.addSpacing(2); this->ui.parentLayout.addSpacing(1);
this->ui.parentLayout.addLayout(&this->ui.hbox); this->ui.parentLayout.addLayout(&this->ui.hbox);
this->ui.parentLayout.setMargin(0); this->ui.parentLayout.setMargin(0);
@ -414,7 +414,7 @@ void SplitContainer::paintEvent(QPaintEvent *)
? this->themeManager.tabs.selected.backgrounds.regular ? this->themeManager.tabs.selected.backgrounds.regular
: this->themeManager.tabs.selected.backgrounds.unfocused); : this->themeManager.tabs.selected.backgrounds.unfocused);
painter.fillRect(0, 0, width(), 2, accentColor); painter.fillRect(0, 0, width(), 1, accentColor);
} }
void SplitContainer::showEvent(QShowEvent *event) void SplitContainer::showEvent(QShowEvent *event)