mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
8dc8d94c75
29 changed files with 339 additions and 98 deletions
|
@ -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
|
||||
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`
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit ad31b38866d80a17ced902476ed06da69edce3a0
|
||||
Subproject commit 2fa3adf42da988dc2a34b9b625654aa08e906d4f
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<QPixmap>(pixmap);
|
||||
this->bufferValid = false;
|
||||
util::DebugCount::increase("message drawing buffers");
|
||||
}
|
||||
|
||||
if (!this->bufferValid || !selection.isEmpty()) {
|
||||
|
@ -215,8 +222,12 @@ void MessageLayout::invalidateBuffer()
|
|||
|
||||
void MessageLayout::deleteBuffer()
|
||||
{
|
||||
if (this->buffer != nullptr) {
|
||||
util::DebugCount::decrease("message drawing buffers");
|
||||
|
||||
this->buffer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
// Elements
|
||||
// assert(QThread::currentThread() == QApplication::instance()->thread());
|
||||
|
|
|
@ -22,6 +22,7 @@ public:
|
|||
enum Flags : uint8_t { Collapsed, RequiresBufferUpdate, RequiresLayout };
|
||||
|
||||
MessageLayout(MessagePtr message);
|
||||
~MessageLayout();
|
||||
|
||||
Message *getMessage();
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "messages/layouts/messagelayoutelement.hpp"
|
||||
#include "messages/messageelement.hpp"
|
||||
#include "util/debugcount.hpp"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QPainter>
|
||||
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -10,10 +10,22 @@
|
|||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#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),
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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,15 +67,12 @@ 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
|
||||
|
@ -87,27 +85,22 @@ void ThemeManager::actuallyUpdate(double hue, double multiplier)
|
|||
this->messages.textColors.caret = //
|
||||
this->messages.textColors.regular = isLight ? "#000" : "#fff";
|
||||
|
||||
// tabs
|
||||
/// TABS
|
||||
// text, {regular, hover, unfocused}
|
||||
// this->windowBg = "#ccc";
|
||||
|
||||
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;
|
||||
|
|
|
@ -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();
|
||||
|
|
10
src/util/debugcount.cpp
Normal file
10
src/util/debugcount.cpp
Normal 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
59
src/util/debugcount.hpp
Normal 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
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
if (!this->layoutCooldown->isActive()) {
|
||||
this->actuallyLayoutMessages();
|
||||
|
||||
this->layoutCooldown->start();
|
||||
} else {
|
||||
this->layoutQueued = true;
|
||||
}
|
||||
}
|
||||
|
||||
void ChannelView::actuallyLayoutMessages()
|
||||
|
|
|
@ -77,6 +77,9 @@ protected:
|
|||
QPoint &relativePos, int &index);
|
||||
|
||||
private:
|
||||
QTimer *layoutCooldown;
|
||||
bool layoutQueued;
|
||||
|
||||
QTimer updateTimer;
|
||||
bool updateQueued = false;
|
||||
bool messageWasAdded = false;
|
||||
|
|
30
src/widgets/helper/debugpopup.cpp
Normal file
30
src/widgets/helper/debugpopup.cpp
Normal 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
|
15
src/widgets/helper/debugpopup.hpp
Normal file
15
src/widgets/helper/debugpopup.hpp
Normal file
|
@ -0,0 +1,15 @@
|
|||
#pragma once
|
||||
|
||||
#include <QWindow>
|
||||
|
||||
namespace chatterino {
|
||||
namespace widgets {
|
||||
|
||||
class DebugPopup : public QWidget
|
||||
{
|
||||
public:
|
||||
DebugPopup();
|
||||
};
|
||||
|
||||
} // namespace widgets
|
||||
} // namespace chatterino
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -103,9 +103,13 @@ QString NotebookTab::getTitle() const
|
|||
|
||||
void NotebookTab::setTitle(const QString &newTitle)
|
||||
{
|
||||
this->title = newTitle.toStdString();
|
||||
auto stdTitle = newTitle.toStdString();
|
||||
|
||||
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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue