diff --git a/README.md b/README.md index 920ae84cf..ba2e9a55c 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,12 @@ Be sure to add "-j " 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 `/rapidjson/document.h` exists 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 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` diff --git a/chatterino.pro b/chatterino.pro index 1665eef0a..62a5b2c2d 100644 --- a/chatterino.pro +++ b/chatterino.pro @@ -178,7 +178,9 @@ SOURCES += \ src/providers/irc/ircchannel2.cpp \ src/util/streamlink.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 += \ src/precompiled_header.hpp \ @@ -292,7 +294,9 @@ HEADERS += \ src/providers/irc/ircserver.hpp \ src/providers/irc/ircchannel2.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.qrc diff --git a/lib/settings b/lib/settings index ad31b3886..2fa3adf42 160000 --- a/lib/settings +++ b/lib/settings @@ -1 +1 @@ -Subproject commit ad31b38866d80a17ced902476ed06da69edce3a0 +Subproject commit 2fa3adf42da988dc2a34b9b625654aa08e906d4f diff --git a/src/messages/image.cpp b/src/messages/image.cpp index 0792d8c35..c07ef71bd 100644 --- a/src/messages/image.cpp +++ b/src/messages/image.cpp @@ -30,6 +30,7 @@ Image::Image(const QString &url, qreal scale, const QString &name, const QString , scale(scale) , isLoading(false) { + util::DebugCount::increase("images"); } 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) , 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() @@ -60,6 +75,15 @@ void Image::loadImage() 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) { if (reader.read(&image)) { auto pixmap = new QPixmap(QPixmap::fromImage(image)); @@ -79,11 +103,14 @@ void Image::loadImage() if (lli->allFrames.size() > 1) { lli->animated = true; + + util::DebugCount::increase("animated images"); } lli->currentPixmap = lli->loadedPixmap; lli->isLoaded = true; + util::DebugCount::increase("loaded images"); singletons::EmoteManager::getInstance().incGeneration(); diff --git a/src/messages/image.hpp b/src/messages/image.hpp index f107ed769..f5b340e71 100644 --- a/src/messages/image.hpp +++ b/src/messages/image.hpp @@ -12,8 +12,6 @@ namespace messages { class Image : public QObject, boost::noncopyable { public: - Image() = delete; - explicit Image(const QString &_url, qreal _scale = 1, const QString &_name = "", const QString &_tooltip = "", const QMargins &_margin = QMargins(), bool isHat = false); @@ -21,6 +19,7 @@ public: explicit Image(QPixmap *_currentPixmap, qreal _scale = 1, const QString &_name = "", const QString &_tooltip = "", const QMargins &_margin = QMargins(), bool isHat = false); + ~Image(); const QPixmap *getPixmap(); qreal getScale() const; diff --git a/src/messages/layouts/messagelayout.cpp b/src/messages/layouts/messagelayout.cpp index 7da65450a..48bac932e 100644 --- a/src/messages/layouts/messagelayout.cpp +++ b/src/messages/layouts/messagelayout.cpp @@ -25,6 +25,12 @@ MessageLayout::MessageLayout(MessagePtr _message) if (_message->flags & Message::Collapsed) { this->flags &= MessageLayout::Collapsed; } + util::DebugCount::increase("message layout"); +} + +MessageLayout::~MessageLayout() +{ + util::DebugCount::decrease("message layout"); } Message *MessageLayout::getMessage() @@ -141,6 +147,7 @@ void MessageLayout::paint(QPainter &painter, int y, int messageIndex, Selection this->buffer = std::shared_ptr(pixmap); this->bufferValid = false; + util::DebugCount::increase("message drawing buffers"); } if (!this->bufferValid || !selection.isEmpty()) { @@ -215,7 +222,11 @@ void MessageLayout::invalidateBuffer() void MessageLayout::deleteBuffer() { - this->buffer = nullptr; + if (this->buffer != nullptr) { + util::DebugCount::decrease("message drawing buffers"); + + this->buffer = nullptr; + } } // Elements diff --git a/src/messages/layouts/messagelayout.hpp b/src/messages/layouts/messagelayout.hpp index 09dd2e615..82bfaea50 100644 --- a/src/messages/layouts/messagelayout.hpp +++ b/src/messages/layouts/messagelayout.hpp @@ -22,6 +22,7 @@ public: enum Flags : uint8_t { Collapsed, RequiresBufferUpdate, RequiresLayout }; MessageLayout(MessagePtr message); + ~MessageLayout(); Message *getMessage(); diff --git a/src/messages/layouts/messagelayoutcontainer.cpp b/src/messages/layouts/messagelayoutcontainer.cpp index 8ea48b456..c592b2386 100644 --- a/src/messages/layouts/messagelayoutcontainer.cpp +++ b/src/messages/layouts/messagelayoutcontainer.cpp @@ -110,9 +110,8 @@ void MessageLayoutContainer::breakLine() for (size_t i = lineStart; i < this->elements.size(); i++) { MessageLayoutElement *element = this->elements.at(i).get(); - bool isCompactEmote = - !(this->flags & Message::DisableCompactEmotes) && - (this->flags & element->getCreator().getFlags()) & MessageElement::EmoteImages; + bool isCompactEmote = !(this->flags & Message::DisableCompactEmotes) && + element->getCreator().getFlags() & MessageElement::EmoteImages; int yExtra = 0; if (isCompactEmote) { diff --git a/src/messages/layouts/messagelayoutelement.cpp b/src/messages/layouts/messagelayoutelement.cpp index cf43237c3..61147a098 100644 --- a/src/messages/layouts/messagelayoutelement.cpp +++ b/src/messages/layouts/messagelayoutelement.cpp @@ -1,5 +1,6 @@ #include "messages/layouts/messagelayoutelement.hpp" #include "messages/messageelement.hpp" +#include "util/debugcount.hpp" #include #include @@ -17,6 +18,12 @@ MessageLayoutElement::MessageLayoutElement(MessageElement &_creator, const QSize : creator(_creator) { this->rect.setSize(size); + util::DebugCount::increase("message layout elements"); +} + +MessageLayoutElement::~MessageLayoutElement() +{ + util::DebugCount::decrease("message layout elements"); } MessageElement &MessageLayoutElement::getCreator() const @@ -98,6 +105,7 @@ void ImageLayoutElement::paintAnimated(QPainter &painter, int yOffset) } if (this->image->isAnimated()) { + // qDebug() << this->image->getUrl(); auto pixmap = this->image->getPixmap(); if (pixmap != nullptr) { diff --git a/src/messages/layouts/messagelayoutelement.hpp b/src/messages/layouts/messagelayoutelement.hpp index 646c44c7f..1f98b6cd1 100644 --- a/src/messages/layouts/messagelayoutelement.hpp +++ b/src/messages/layouts/messagelayoutelement.hpp @@ -24,7 +24,7 @@ class MessageLayoutElement : boost::noncopyable { public: MessageLayoutElement(MessageElement &creator, const QSize &size); - virtual ~MessageLayoutElement() = default; + virtual ~MessageLayoutElement(); const QRect &getRect() const; MessageElement &getCreator() const; diff --git a/src/messages/message.hpp b/src/messages/message.hpp index 56afc2b52..2d3ee6970 100644 --- a/src/messages/message.hpp +++ b/src/messages/message.hpp @@ -10,10 +10,22 @@ #include #include +#include "util/debugcount.hpp" + namespace chatterino { namespace messages { struct Message { + Message() + { + util::DebugCount::increase("messages"); + } + + ~Message() + { + util::DebugCount::decrease("messages"); + } + enum MessageFlags : uint16_t { None = 0, System = (1 << 0), diff --git a/src/messages/messageelement.cpp b/src/messages/messageelement.cpp index 85b0e4e96..faf3c00bf 100644 --- a/src/messages/messageelement.cpp +++ b/src/messages/messageelement.cpp @@ -11,6 +11,12 @@ namespace messages { MessageElement::MessageElement(Flags _flags) : flags(_flags) { + util::DebugCount::increase("message elements"); +} + +MessageElement::~MessageElement() +{ + util::DebugCount::decrease("message elements"); } MessageElement *MessageElement::setLink(const Link &_link) diff --git a/src/messages/messageelement.hpp b/src/messages/messageelement.hpp index e943b0e77..2f281c121 100644 --- a/src/messages/messageelement.hpp +++ b/src/messages/messageelement.hpp @@ -110,7 +110,7 @@ public: Update_All = Update_Text | Update_Emotes | Update_Images }; - virtual ~MessageElement() = default; + virtual ~MessageElement(); MessageElement *setLink(const Link &link); MessageElement *setTooltip(const QString &tooltip); diff --git a/src/singletons/thememanager.cpp b/src/singletons/thememanager.cpp index 6f522b881..55d612122 100644 --- a/src/singletons/thememanager.cpp +++ b/src/singletons/thememanager.cpp @@ -54,9 +54,10 @@ void ThemeManager::update() void ThemeManager::actuallyUpdate(double hue, double multiplier) { 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); qreal sat = 0; @@ -66,48 +67,40 @@ void ThemeManager::actuallyUpdate(double hue, double multiplier) return QColor::fromHslF(h, s, ((l - 0.5) * multiplier) + 0.5, a); }; - //#ifdef USEWINSDK - // isLightTabs = isLight; - // QColor tabFg = isLight ? "#000" : "#fff"; - // this->windowBg = isLight ? "#fff" : getColor(0, sat, 0.9); - //#else - isLightTabs = true; - QColor tabFg = isLightTabs ? "#000" : "#fff"; - this->windowBg = "#fff"; - //#endif + /// WINDOW + { + QColor bg = this->window.background = lightWin ? "#fff" : "#444"; + QColor fg = this->window.text = lightWin ? "#000" : "#eee"; + this->window.borderFocused = lightWin ? "#ccc" : themeColor; + this->window.borderUnfocused = lightWin ? "#ccc" : themeColorNoSat; - // Ubuntu style - // TODO: add setting for this - // TabText = QColor(210, 210, 210); - // TabBackground = QColor(61, 60, 56); - // TabHoverText = QColor(210, 210, 210); - // TabHoverBackground = QColor(73, 72, 68); + // Ubuntu style + // TODO: add setting for this + // TabText = QColor(210, 210, 210); + // TabBackground = QColor(61, 60, 56); + // TabHoverText = QColor(210, 210, 210); + // TabHoverBackground = QColor(73, 72, 68); - // message (referenced later) - this->messages.textColors.caret = // - this->messages.textColors.regular = isLight ? "#000" : "#fff"; + // message (referenced later) + this->messages.textColors.caret = // + this->messages.textColors.regular = isLight ? "#000" : "#fff"; - // tabs - // text, {regular, hover, unfocused} - // this->windowBg = "#ccc"; + /// TABS + // text, {regular, hover, unfocused} - this->tabs.border = "#999"; - this->tabs.regular = {tabFg, {windowBg, blendColors(windowBg, "#999", 0.5), windowBg}}; - - this->tabs.selected = {"#fff", {themeColor, themeColor, QColor::fromHslF(hue, 0, 0.5)}}; - - this->tabs.newMessage = { - tabFg, - {QBrush(blendColors(themeColor, windowBg, 0.7), Qt::FDiagPattern), - QBrush(blendColors(themeColor, windowBg, 0.5), Qt::FDiagPattern), - QBrush(blendColors(themeColorNoSat, windowBg, 0.7), Qt::FDiagPattern)}}; - - this->tabs.highlighted = { - tabFg, - {blendColors(themeColor, windowBg, 0.7), blendColors(themeColor, windowBg, 0.5), - blendColors(themeColorNoSat, windowBg, 0.7)}}; - - // this->windowBg = "#fff"; + if (lightWin) { + this->tabs.regular = {fg, {bg, "#ccc", bg}}; + this->tabs.newMessage = {fg, {bg, "#ccc", bg}}; + this->tabs.highlighted = {fg, {bg, "#ccc", bg}}; + this->tabs.selected = {"#fff", {"#333", "#333", "#666"}}; + } else { + this->tabs.regular = {fg, {bg, "#555", bg}}; + this->tabs.newMessage = {fg, {bg, "#555", bg}}; + this->tabs.highlighted = {fg, {bg, "#555", bg}}; + // this->tabs.selected = {"#000", {themeColor, themeColor, themeColorNoSat}}; + this->tabs.selected = {"#000", {"#999", "#999", "#888"}}; + } + } // Split bool flat = isLight; diff --git a/src/singletons/thememanager.hpp b/src/singletons/thememanager.hpp index e0b67e0c9..664f97135 100644 --- a/src/singletons/thememanager.hpp +++ b/src/singletons/thememanager.hpp @@ -32,6 +32,15 @@ public: } backgrounds; }; + /// WINDOW + struct { + QColor background; + QColor text; + QColor borderUnfocused; + QColor borderFocused; + } window; + + /// TABS struct { TabColors regular; TabColors selected; @@ -40,6 +49,7 @@ public: QColor border; } tabs; + /// SPLITS struct { QColor messageSeperator; QColor background; @@ -64,6 +74,7 @@ public: } input; } splits; + /// MESSAGES struct { struct { QColor regular; @@ -85,6 +96,7 @@ public: QColor selection; } messages; + /// SCROLLBAR struct { QColor background; QColor thumb; @@ -93,14 +105,12 @@ public: // QColor highlights[3]; } scrollbars; + /// TOOLTIP struct { QColor text; QColor background; } tooltip; - QColor windowBg; - QColor windowText; - void normalizeColor(QColor &color); void update(); diff --git a/src/util/debugcount.cpp b/src/util/debugcount.cpp new file mode 100644 index 000000000..a8a454352 --- /dev/null +++ b/src/util/debugcount.cpp @@ -0,0 +1,10 @@ +#include "debugcount.hpp" + +namespace chatterino { +namespace util { + +QMap DebugCount::counts; +std::mutex DebugCount::mut; + +} // namespace util +} // namespace chatterino diff --git a/src/util/debugcount.hpp b/src/util/debugcount.hpp new file mode 100644 index 000000000..7aae6ebc1 --- /dev/null +++ b/src/util/debugcount.hpp @@ -0,0 +1,59 @@ +#pragma once + +#include +#include + +#include +#include + +namespace chatterino { +namespace util { + +class DebugCount +{ + static QMap counts; + static std::mutex mut; + +public: + static void increase(const QString &name) + { + std::lock_guard lock(mut); + + auto it = counts.find(name); + if (it == counts.end()) { + counts.insert(name, 1); + } else { + reinterpret_cast(it.value())++; + } + } + + static void decrease(const QString &name) + { + std::lock_guard lock(mut); + + auto it = counts.find(name); + if (it == counts.end()) { + counts.insert(name, -1); + } else { + reinterpret_cast(it.value())--; + } + } + + static QString getDebugText() + { + std::lock_guard 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 diff --git a/src/widgets/basewindow.cpp b/src/widgets/basewindow.cpp index cb92ddc12..950fd6790 100644 --- a/src/widgets/basewindow.cpp +++ b/src/widgets/basewindow.cpp @@ -160,12 +160,12 @@ void BaseWindow::themeRefreshEvent() { if (this->enableCustomFrame) { QPalette palette; - palette.setColor(QPalette::Background, this->themeManager.windowBg); - palette.setColor(QPalette::Foreground, this->themeManager.windowText); + palette.setColor(QPalette::Background, this->themeManager.window.background); + palette.setColor(QPalette::Foreground, this->themeManager.window.text); this->setPalette(palette); 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(); - QLinearGradient gradient(0, 0, 10, 250); - gradient.setColorAt(1, this->themeManager.tabs.selected.backgrounds.unfocused.color()); + // QLinearGradient gradient(0, 0, 10, 250); + // gradient.setColorAt(1, + // this->themeManager.tabs.selected.backgrounds.unfocused.color()); - if (windowFocused) { - gradient.setColorAt(.4, this->themeManager.tabs.selected.backgrounds.regular.color()); - } else { - gradient.setColorAt(.4, this->themeManager.tabs.selected.backgrounds.unfocused.color()); - } - painter.setPen(QPen(QBrush(gradient), 1)); + // if (windowFocused) { + // gradient.setColorAt(.4, + // this->themeManager.tabs.selected.backgrounds.regular.color()); + // } else { + // gradient.setColorAt(.4, + // 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); } diff --git a/src/widgets/helper/channelview.cpp b/src/widgets/helper/channelview.cpp index 2d12bf4d4..177ecc882 100644 --- a/src/widgets/helper/channelview.cpp +++ b/src/widgets/helper/channelview.cpp @@ -83,24 +83,36 @@ ChannelView::ChannelView(BaseWidget *parent) }); }); - this->updateTimer.setInterval(1000 / 60); - this->updateTimer.setSingleShot(true); - connect(&this->updateTimer, &QTimer::timeout, this, [this] { - if (this->updateQueued) { - this->updateQueued = false; - this->repaint(); - this->updateTimer.start(); - } - }); + // this->updateTimer.setInterval(1000 / 60); + // this->updateTimer.setSingleShot(true); + // connect(&this->updateTimer, &QTimer::timeout, this, [this] { + // if (this->updateQueued) { + // this->updateQueued = false; + // this->repaint(); + // this->updateTimer.start(); + // } + // }); this->pauseTimeout.setSingleShot(true); - auto e = new QResizeEvent(this->size(), this->size()); - this->resizeEvent(e); - delete e; + // auto e = new QResizeEvent(this->size(), this->size()); + // this->resizeEvent(e); + // delete e; + + this->scrollBar.resize(this->scrollBar.width(), height() + 1); singletons::SettingManager::getInstance().showLastMessageIndicator.connect( [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() @@ -138,7 +150,13 @@ void ChannelView::queueUpdate() void ChannelView::layoutMessages() { - this->actuallyLayoutMessages(); + if (!this->layoutCooldown->isActive()) { + this->actuallyLayoutMessages(); + + this->layoutCooldown->start(); + } else { + this->layoutQueued = true; + } } void ChannelView::actuallyLayoutMessages() diff --git a/src/widgets/helper/channelview.hpp b/src/widgets/helper/channelview.hpp index bc62fb875..0db184ac9 100644 --- a/src/widgets/helper/channelview.hpp +++ b/src/widgets/helper/channelview.hpp @@ -77,6 +77,9 @@ protected: QPoint &relativePos, int &index); private: + QTimer *layoutCooldown; + bool layoutQueued; + QTimer updateTimer; bool updateQueued = false; bool messageWasAdded = false; diff --git a/src/widgets/helper/debugpopup.cpp b/src/widgets/helper/debugpopup.cpp new file mode 100644 index 000000000..d4ecc346a --- /dev/null +++ b/src/widgets/helper/debugpopup.cpp @@ -0,0 +1,30 @@ +#include "debugpopup.hpp" + +#include "util/debugcount.hpp" + +#include +#include +#include +#include + +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 diff --git a/src/widgets/helper/debugpopup.hpp b/src/widgets/helper/debugpopup.hpp new file mode 100644 index 000000000..c9a4c7431 --- /dev/null +++ b/src/widgets/helper/debugpopup.hpp @@ -0,0 +1,15 @@ +#pragma once + +#include + +namespace chatterino { +namespace widgets { + +class DebugPopup : public QWidget +{ +public: + DebugPopup(); +}; + +} // namespace widgets +} // namespace chatterino diff --git a/src/widgets/helper/notebookbutton.cpp b/src/widgets/helper/notebookbutton.cpp index be07b2f85..eb7bf6879 100644 --- a/src/widgets/helper/notebookbutton.cpp +++ b/src/widgets/helper/notebookbutton.cpp @@ -17,11 +17,14 @@ namespace widgets { NotebookButton::NotebookButton(BaseWidget *parent) : RippleEffectButton(parent) { - setMouseEffectColor(QColor(0, 0, 0)); - this->setAcceptDrops(true); } +void NotebookButton::themeRefreshEvent() +{ + this->setMouseEffectColor(this->themeManager.tabs.regular.text); +} + void NotebookButton::paintEvent(QPaintEvent *) { QPainter painter(this); @@ -30,15 +33,14 @@ void NotebookButton::paintEvent(QPaintEvent *) QColor foreground; 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; } else { background = this->themeManager.tabs.regular.backgrounds.regular.color(); - foreground = QColor(70, 80, 80); + foreground = this->themeManager.tabs.regular.text; } painter.setPen(Qt::NoPen); - // painter.fillRect(this->rect(), background); float h = height(), w = width(); diff --git a/src/widgets/helper/notebookbutton.hpp b/src/widgets/helper/notebookbutton.hpp index a62b80026..3a53af514 100644 --- a/src/widgets/helper/notebookbutton.hpp +++ b/src/widgets/helper/notebookbutton.hpp @@ -21,6 +21,7 @@ public: NotebookButton(BaseWidget *parent); protected: + virtual void themeRefreshEvent() override; virtual void paintEvent(QPaintEvent *) override; virtual void mouseReleaseEvent(QMouseEvent *) override; virtual void dragEnterEvent(QDragEnterEvent *) override; diff --git a/src/widgets/helper/notebooktab.cpp b/src/widgets/helper/notebooktab.cpp index 21961c0af..de26c24c7 100644 --- a/src/widgets/helper/notebooktab.cpp +++ b/src/widgets/helper/notebooktab.cpp @@ -103,9 +103,13 @@ QString NotebookTab::getTitle() const void NotebookTab::setTitle(const QString &newTitle) { - this->title = newTitle.toStdString(); + auto stdTitle = newTitle.toStdString(); - this->updateSize(); + if (this->title != stdTitle) { + this->title = stdTitle; + this->updateSize(); + this->update(); + } } bool NotebookTab::isSelected() const @@ -209,13 +213,13 @@ void NotebookTab::paintEvent(QPaintEvent *) painter.fillRect(rect(), tabBackground); // draw border - painter.setPen(QPen("#ccc")); - QPainterPath path(QPointF(0, height)); - path.lineTo(0, 0); - path.lineTo(this->width() - 1, 0); - path.lineTo(this->width() - 1, this->height() - 1); - path.lineTo(0, this->height() - 1); - painter.drawPath(path); + // painter.setPen(QPen("#ccc")); + // QPainterPath path(QPointF(0, height)); + // path.lineTo(0, 0); + // path.lineTo(this->width() - 1, 0); + // path.lineTo(this->width() - 1, this->height() - 1); + // path.lineTo(0, this->height() - 1); + // painter.drawPath(path); } else { // QPainterPath path(QPointF(0, height)); // path.lineTo(8 * scale, 0); diff --git a/src/widgets/helper/titlebarbutton.cpp b/src/widgets/helper/titlebarbutton.cpp index d3b2cd34d..987cc8b34 100644 --- a/src/widgets/helper/titlebarbutton.cpp +++ b/src/widgets/helper/titlebarbutton.cpp @@ -1,5 +1,7 @@ #include "titlebarbutton.hpp" +#include "singletons/thememanager.hpp" + namespace chatterino { namespace widgets { @@ -23,8 +25,8 @@ void TitleBarButton::paintEvent(QPaintEvent *) { QPainter painter(this); - QColor color = "#000"; - QColor background = "#fff"; + QColor color = this->themeManager.window.text; + QColor background = this->themeManager.window.background; int xD = this->height() / 3; int centerX = this->width() / 2; @@ -59,7 +61,8 @@ void TitleBarButton::paintEvent(QPaintEvent *) break; } case User: { - color = QColor("#333"); + // color = QColor("#333"); + color = "#999"; painter.setRenderHint(QPainter::Antialiasing); painter.setRenderHint(QPainter::HighQualityAntialiasing); @@ -85,7 +88,8 @@ void TitleBarButton::paintEvent(QPaintEvent *) break; } case Settings: { - color = QColor("#333"); + // color = QColor("#333"); + color = "#999"; painter.setRenderHint(QPainter::Antialiasing); painter.setRenderHint(QPainter::HighQualityAntialiasing); diff --git a/src/widgets/split.cpp b/src/widgets/split.cpp index 7d6692005..7cfad2b66 100644 --- a/src/widgets/split.cpp +++ b/src/widgets/split.cpp @@ -9,6 +9,7 @@ #include "singletons/windowmanager.hpp" #include "util/streamlink.hpp" #include "util/urlfetch.hpp" +#include "widgets/helper/debugpopup.hpp" #include "widgets/helper/searchpopup.hpp" #include "widgets/helper/shortcut.hpp" #include "widgets/qualitypopup.hpp" @@ -72,6 +73,13 @@ Split::Split(SplitContainer *parent, const std::string &_uuid) // CTRL+F: Search CreateShortcut(this, "CTRL+F", &Split::doSearch); + // F12 + CreateShortcut(this, "F10", [] { + auto *popup = new DebugPopup; + popup->setAttribute(Qt::WA_DeleteOnClose); + popup->show(); + }); + // xd // CreateShortcut(this, "ALT+SHIFT+RIGHT", &Split::doIncFlexX); // CreateShortcut(this, "ALT+SHIFT+LEFT", &Split::doDecFlexX); diff --git a/src/widgets/split.hpp b/src/widgets/split.hpp index 054513b2d..38e2168bd 100644 --- a/src/widgets/split.hpp +++ b/src/widgets/split.hpp @@ -22,6 +22,10 @@ namespace widgets { class SplitContainer; +class xD +{ +}; + // Each ChatWidget consists of three sub-elements that handle their own part of the chat widget: // ChatWidgetHeader // - Responsible for rendering which channel the ChatWidget is in, and the menu in the top-left of diff --git a/src/widgets/splitcontainer.cpp b/src/widgets/splitcontainer.cpp index be45f987e..b736397aa 100644 --- a/src/widgets/splitcontainer.cpp +++ b/src/widgets/splitcontainer.cpp @@ -41,7 +41,7 @@ SplitContainer::SplitContainer(Notebook *parent, NotebookTab *_tab, const std::s this->setHidden(true); this->setAcceptDrops(true); - this->ui.parentLayout.addSpacing(2); + this->ui.parentLayout.addSpacing(1); this->ui.parentLayout.addLayout(&this->ui.hbox); this->ui.parentLayout.setMargin(0); @@ -414,7 +414,7 @@ void SplitContainer::paintEvent(QPaintEvent *) ? this->themeManager.tabs.selected.backgrounds.regular : 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)