Merge branch 'master' into apa-notification-on-live
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#include "RippleEffectButton.hpp"
|
||||
#include "Button.hpp"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
@@ -10,11 +10,11 @@
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
RippleEffectButton::RippleEffectButton(BaseWidget *parent)
|
||||
Button::Button(BaseWidget *parent)
|
||||
: BaseWidget(parent)
|
||||
{
|
||||
connect(&effectTimer_, &QTimer::timeout, this,
|
||||
&RippleEffectButton::onMouseEffectTimeout);
|
||||
&Button::onMouseEffectTimeout);
|
||||
|
||||
this->effectTimer_.setInterval(20);
|
||||
this->effectTimer_.start();
|
||||
@@ -22,64 +22,64 @@ RippleEffectButton::RippleEffectButton(BaseWidget *parent)
|
||||
this->setMouseTracking(true);
|
||||
}
|
||||
|
||||
void RippleEffectButton::setMouseEffectColor(boost::optional<QColor> color)
|
||||
void Button::setMouseEffectColor(boost::optional<QColor> color)
|
||||
{
|
||||
this->mouseEffectColor_ = color;
|
||||
}
|
||||
|
||||
void RippleEffectButton::setPixmap(const QPixmap &_pixmap)
|
||||
void Button::setPixmap(const QPixmap &_pixmap)
|
||||
{
|
||||
this->pixmap_ = _pixmap;
|
||||
this->update();
|
||||
}
|
||||
|
||||
const QPixmap &RippleEffectButton::getPixmap() const
|
||||
const QPixmap &Button::getPixmap() const
|
||||
{
|
||||
return this->pixmap_;
|
||||
}
|
||||
|
||||
void RippleEffectButton::setDim(bool value)
|
||||
void Button::setDim(bool value)
|
||||
{
|
||||
this->dimPixmap_ = value;
|
||||
|
||||
this->update();
|
||||
}
|
||||
|
||||
bool RippleEffectButton::getDim() const
|
||||
bool Button::getDim() const
|
||||
{
|
||||
return this->dimPixmap_;
|
||||
}
|
||||
|
||||
void RippleEffectButton::setEnable(bool value)
|
||||
void Button::setEnable(bool value)
|
||||
{
|
||||
this->enabled_ = value;
|
||||
|
||||
this->update();
|
||||
}
|
||||
|
||||
bool RippleEffectButton::getEnable() const
|
||||
bool Button::getEnable() const
|
||||
{
|
||||
return this->enabled_;
|
||||
}
|
||||
|
||||
qreal RippleEffectButton::getCurrentDimAmount() const
|
||||
qreal Button::getCurrentDimAmount() const
|
||||
{
|
||||
return this->dimPixmap_ && !this->mouseOver_ ? 0.7 : 1;
|
||||
}
|
||||
|
||||
void RippleEffectButton::setBorderColor(const QColor &color)
|
||||
void Button::setBorderColor(const QColor &color)
|
||||
{
|
||||
this->borderColor_ = color;
|
||||
|
||||
this->update();
|
||||
}
|
||||
|
||||
const QColor &RippleEffectButton::getBorderColor() const
|
||||
const QColor &Button::getBorderColor() const
|
||||
{
|
||||
return this->borderColor_;
|
||||
}
|
||||
|
||||
void RippleEffectButton::setMenu(std::unique_ptr<QMenu> menu)
|
||||
void Button::setMenu(std::unique_ptr<QMenu> menu)
|
||||
{
|
||||
this->menu_ = std::move(menu);
|
||||
|
||||
@@ -93,7 +93,7 @@ void RippleEffectButton::setMenu(std::unique_ptr<QMenu> menu)
|
||||
}));
|
||||
}
|
||||
|
||||
void RippleEffectButton::paintEvent(QPaintEvent *)
|
||||
void Button::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QPainter painter(this);
|
||||
|
||||
@@ -126,7 +126,7 @@ void RippleEffectButton::paintEvent(QPaintEvent *)
|
||||
}
|
||||
}
|
||||
|
||||
void RippleEffectButton::fancyPaint(QPainter &painter)
|
||||
void Button::fancyPaint(QPainter &painter)
|
||||
{
|
||||
if (!this->enabled_) {
|
||||
return;
|
||||
@@ -169,17 +169,17 @@ void RippleEffectButton::fancyPaint(QPainter &painter)
|
||||
}
|
||||
}
|
||||
|
||||
void RippleEffectButton::enterEvent(QEvent *)
|
||||
void Button::enterEvent(QEvent *)
|
||||
{
|
||||
this->mouseOver_ = true;
|
||||
}
|
||||
|
||||
void RippleEffectButton::leaveEvent(QEvent *)
|
||||
void Button::leaveEvent(QEvent *)
|
||||
{
|
||||
this->mouseOver_ = false;
|
||||
}
|
||||
|
||||
void RippleEffectButton::mousePressEvent(QMouseEvent *event)
|
||||
void Button::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (!this->enabled_) {
|
||||
return;
|
||||
@@ -197,10 +197,12 @@ void RippleEffectButton::mousePressEvent(QMouseEvent *event)
|
||||
|
||||
if (this->menu_ && !this->menuVisible_) {
|
||||
QTimer::singleShot(80, this, [this] { this->showMenu(); });
|
||||
this->mouseDown_ = false;
|
||||
this->mouseOver_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
void RippleEffectButton::mouseReleaseEvent(QMouseEvent *event)
|
||||
void Button::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if (!this->enabled_) {
|
||||
return;
|
||||
@@ -217,7 +219,7 @@ void RippleEffectButton::mouseReleaseEvent(QMouseEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
void RippleEffectButton::mouseMoveEvent(QMouseEvent *event)
|
||||
void Button::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (!this->enabled_) {
|
||||
return;
|
||||
@@ -228,7 +230,7 @@ void RippleEffectButton::mouseMoveEvent(QMouseEvent *event)
|
||||
this->update();
|
||||
}
|
||||
|
||||
void RippleEffectButton::onMouseEffectTimeout()
|
||||
void Button::onMouseEffectTimeout()
|
||||
{
|
||||
bool performUpdate = false;
|
||||
|
||||
@@ -272,7 +274,7 @@ void RippleEffectButton::onMouseEffectTimeout()
|
||||
}
|
||||
}
|
||||
|
||||
void RippleEffectButton::showMenu()
|
||||
void Button::showMenu()
|
||||
{
|
||||
if (!this->menu_) return;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
class RippleEffectButton : public BaseWidget
|
||||
class Button : public BaseWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -28,7 +28,7 @@ class RippleEffectButton : public BaseWidget
|
||||
};
|
||||
|
||||
public:
|
||||
RippleEffectButton(BaseWidget *parent);
|
||||
Button(BaseWidget *parent = nullptr);
|
||||
|
||||
void setMouseEffectColor(boost::optional<QColor> color);
|
||||
void setPixmap(const QPixmap &pixmap_);
|
||||
+184
-202
@@ -1,19 +1,25 @@
|
||||
#include "ChannelView.hpp"
|
||||
|
||||
#include "Application.hpp"
|
||||
#include "common/Common.hpp"
|
||||
#include "debug/Benchmark.hpp"
|
||||
#include "debug/Log.hpp"
|
||||
#include "messages/Emote.hpp"
|
||||
#include "messages/LimitedQueueSnapshot.hpp"
|
||||
#include "messages/Message.hpp"
|
||||
#include "messages/MessageElement.hpp"
|
||||
#include "messages/layouts/MessageLayout.hpp"
|
||||
#include "providers/twitch/TwitchChannel.hpp"
|
||||
#include "messages/layouts/MessageLayoutElement.hpp"
|
||||
#include "providers/twitch/TwitchServer.hpp"
|
||||
#include "singletons/Settings.hpp"
|
||||
#include "singletons/Theme.hpp"
|
||||
#include "singletons/WindowManager.hpp"
|
||||
#include "util/DistanceBetweenPoints.hpp"
|
||||
#include "widgets/Scrollbar.hpp"
|
||||
#include "widgets/TooltipWidget.hpp"
|
||||
#include "widgets/dialogs/UserInfoPopup.hpp"
|
||||
#include "widgets/helper/EffectLabel.hpp"
|
||||
#include "widgets/splits/Split.hpp"
|
||||
|
||||
#include <QClipboard>
|
||||
@@ -34,132 +40,73 @@
|
||||
|
||||
namespace chatterino {
|
||||
namespace {
|
||||
void addEmoteContextMenuItems(const Emote &emote,
|
||||
MessageElementFlags creatorFlags, QMenu &menu)
|
||||
{
|
||||
auto openAction = menu.addAction("Open");
|
||||
auto openMenu = new QMenu;
|
||||
openAction->setMenu(openMenu);
|
||||
void addEmoteContextMenuItems(const Emote &emote,
|
||||
MessageElementFlags creatorFlags, QMenu &menu)
|
||||
{
|
||||
auto openAction = menu.addAction("Open");
|
||||
auto openMenu = new QMenu;
|
||||
openAction->setMenu(openMenu);
|
||||
|
||||
auto copyAction = menu.addAction("Copy");
|
||||
auto copyMenu = new QMenu;
|
||||
copyAction->setMenu(copyMenu);
|
||||
auto copyAction = menu.addAction("Copy");
|
||||
auto copyMenu = new QMenu;
|
||||
copyAction->setMenu(copyMenu);
|
||||
|
||||
// see if the QMenu actually gets destroyed
|
||||
QObject::connect(openMenu, &QMenu::destroyed, [] {
|
||||
QMessageBox(QMessageBox::Information, "xD", "the menu got deleted")
|
||||
.exec();
|
||||
});
|
||||
// see if the QMenu actually gets destroyed
|
||||
QObject::connect(openMenu, &QMenu::destroyed, [] {
|
||||
QMessageBox(QMessageBox::Information, "xD", "the menu got deleted")
|
||||
.exec();
|
||||
});
|
||||
|
||||
// Add copy and open links for 1x, 2x, 3x
|
||||
auto addImageLink = [&](const ImagePtr &image, char scale) {
|
||||
if (!image->isEmpty()) {
|
||||
copyMenu->addAction(
|
||||
QString(scale) + "x link", [url = image->url()] {
|
||||
QApplication::clipboard()->setText(url.string);
|
||||
});
|
||||
openMenu->addAction(
|
||||
QString(scale) + "x link", [url = image->url()] {
|
||||
QDesktopServices::openUrl(QUrl(url.string));
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
addImageLink(emote.images.getImage1(), '1');
|
||||
addImageLink(emote.images.getImage2(), '2');
|
||||
addImageLink(emote.images.getImage3(), '3');
|
||||
|
||||
// Copy and open emote page link
|
||||
auto addPageLink = [&](const QString &name) {
|
||||
copyMenu->addSeparator();
|
||||
openMenu->addSeparator();
|
||||
|
||||
// Add copy and open links for 1x, 2x, 3x
|
||||
auto addImageLink = [&](const ImagePtr &image, char scale) {
|
||||
if (!image->empty()) {
|
||||
copyMenu->addAction(
|
||||
QString(scale) + "x link", [url = image->url()] {
|
||||
QApplication::clipboard()->setText(url.string);
|
||||
"Copy " + name + " emote link", [url = emote.homePage] {
|
||||
QApplication::clipboard()->setText(url.string); //
|
||||
});
|
||||
openMenu->addAction(QString(scale) + "x link",
|
||||
[url = image->url()] {
|
||||
QDesktopServices::openUrl(QUrl(url.string));
|
||||
});
|
||||
openMenu->addAction(
|
||||
"Open " + name + " emote link", [url = emote.homePage] {
|
||||
QDesktopServices::openUrl(QUrl(url.string)); //
|
||||
});
|
||||
};
|
||||
|
||||
if (creatorFlags.has(MessageElementFlag::BttvEmote)) {
|
||||
addPageLink("BTTV");
|
||||
} else if (creatorFlags.has(MessageElementFlag::FfzEmote)) {
|
||||
addPageLink("FFZ");
|
||||
}
|
||||
};
|
||||
|
||||
addImageLink(emote.images.getImage1(), '1');
|
||||
addImageLink(emote.images.getImage2(), '2');
|
||||
addImageLink(emote.images.getImage3(), '3');
|
||||
|
||||
// Copy and open emote page link
|
||||
auto addPageLink = [&](const QString &name) {
|
||||
copyMenu->addSeparator();
|
||||
openMenu->addSeparator();
|
||||
|
||||
copyMenu->addAction(
|
||||
"Copy " + name + " emote link", [url = emote.homePage] {
|
||||
QApplication::clipboard()->setText(url.string); //
|
||||
});
|
||||
openMenu->addAction("Open " + name + " emote link",
|
||||
[url = emote.homePage] {
|
||||
QDesktopServices::openUrl(QUrl(url.string)); //
|
||||
});
|
||||
};
|
||||
|
||||
if (creatorFlags.has(MessageElementFlag::BttvEmote)) {
|
||||
addPageLink("BTTV");
|
||||
} else if (creatorFlags.has(MessageElementFlag::FfzEmote)) {
|
||||
addPageLink("FFZ");
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
ChannelView::ChannelView(BaseWidget *parent)
|
||||
: BaseWidget(parent)
|
||||
, scrollBar_(this)
|
||||
, scrollBar_(new Scrollbar(this))
|
||||
{
|
||||
auto app = getApp();
|
||||
|
||||
this->setMouseTracking(true);
|
||||
|
||||
this->connections_.push_back(app->windows->wordFlagsChanged.connect([this] {
|
||||
this->layoutMessages();
|
||||
this->update();
|
||||
}));
|
||||
|
||||
this->scrollBar_.getCurrentValueChanged().connect([this] {
|
||||
// Whenever the scrollbar value has been changed, re-render the
|
||||
// ChatWidgetView
|
||||
this->actuallyLayoutMessages(true);
|
||||
|
||||
// if (!this->isPaused()) {
|
||||
this->goToBottom_->setVisible(this->enableScrollingToBottom_ &&
|
||||
this->scrollBar_.isVisible() &&
|
||||
!this->scrollBar_.isAtBottom());
|
||||
// }
|
||||
|
||||
this->queueUpdate();
|
||||
});
|
||||
|
||||
this->scrollBar_.getDesiredValueChanged().connect([this] {
|
||||
this->pausedByScrollingUp_ = !this->scrollBar_.isAtBottom();
|
||||
});
|
||||
|
||||
this->connections_.push_back(app->windows->repaintGifs.connect([&] {
|
||||
this->queueUpdate(); //
|
||||
}));
|
||||
|
||||
this->connections_.push_back(
|
||||
app->windows->layout.connect([&](Channel *channel) {
|
||||
if (channel == nullptr || this->channel_.get() == channel) {
|
||||
this->layoutMessages();
|
||||
}
|
||||
}));
|
||||
|
||||
this->goToBottom_ = new RippleEffectLabel(this, 0);
|
||||
this->goToBottom_->setStyleSheet(
|
||||
"background-color: rgba(0,0,0,0.66); color: #FFF;");
|
||||
this->goToBottom_->getLabel().setText("More messages below");
|
||||
this->goToBottom_->setVisible(false);
|
||||
|
||||
this->connections_.emplace_back(app->fonts->fontChanged.connect([this] {
|
||||
this->layoutMessages(); //
|
||||
}));
|
||||
|
||||
QObject::connect(this->goToBottom_, &RippleEffectLabel::clicked, this, [=] {
|
||||
QTimer::singleShot(180, [=] {
|
||||
this->scrollBar_.scrollToBottom(
|
||||
app->settings->enableSmoothScrollingNewMessages.getValue());
|
||||
});
|
||||
});
|
||||
|
||||
// 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->initializeLayout();
|
||||
this->initializeScrollbar();
|
||||
this->initializeSignals();
|
||||
|
||||
this->pauseTimeout_.setSingleShot(true);
|
||||
QObject::connect(&this->pauseTimeout_, &QTimer::timeout, [this] {
|
||||
@@ -168,31 +115,67 @@ ChannelView::ChannelView(BaseWidget *parent)
|
||||
this->layoutMessages();
|
||||
});
|
||||
|
||||
app->settings->showLastMessageIndicator.connect(
|
||||
[this](auto, auto) {
|
||||
this->update(); //
|
||||
},
|
||||
this->connections_);
|
||||
|
||||
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();
|
||||
this->layoutQueued_ = false;
|
||||
}
|
||||
});
|
||||
|
||||
QShortcut *shortcut = new QShortcut(QKeySequence("Ctrl+C"), this);
|
||||
auto shortcut = new QShortcut(QKeySequence("Ctrl+C"), this);
|
||||
QObject::connect(shortcut, &QShortcut::activated, [this] {
|
||||
QGuiApplication::clipboard()->setText(this->getSelectedText());
|
||||
});
|
||||
}
|
||||
|
||||
ChannelView::~ChannelView()
|
||||
void ChannelView::initializeLayout()
|
||||
{
|
||||
this->goToBottom_ = new EffectLabel(this, 0);
|
||||
this->goToBottom_->setStyleSheet(
|
||||
"background-color: rgba(0,0,0,0.66); color: #FFF;");
|
||||
this->goToBottom_->getLabel().setText("More messages below");
|
||||
this->goToBottom_->setVisible(false);
|
||||
|
||||
QObject::connect(this->goToBottom_, &EffectLabel::clicked, this, [=] {
|
||||
QTimer::singleShot(180, [=] {
|
||||
this->scrollBar_->scrollToBottom(
|
||||
getSettings()->enableSmoothScrollingNewMessages.getValue());
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
void ChannelView::initializeScrollbar()
|
||||
{
|
||||
this->scrollBar_->getCurrentValueChanged().connect([this] {
|
||||
this->actuallyLayoutMessages(true);
|
||||
|
||||
this->goToBottom_->setVisible(this->enableScrollingToBottom_ &&
|
||||
this->scrollBar_->isVisible() &&
|
||||
!this->scrollBar_->isAtBottom());
|
||||
|
||||
this->queueUpdate();
|
||||
});
|
||||
|
||||
this->scrollBar_->getDesiredValueChanged().connect([this] {
|
||||
this->pausedByScrollingUp_ = !this->scrollBar_->isAtBottom();
|
||||
});
|
||||
}
|
||||
|
||||
void ChannelView::initializeSignals()
|
||||
{
|
||||
this->connections_.push_back(
|
||||
getApp()->windows->wordFlagsChanged.connect([this] {
|
||||
this->layoutMessages();
|
||||
this->update();
|
||||
}));
|
||||
|
||||
getSettings()->showLastMessageIndicator.connect(
|
||||
[this](auto, auto) { this->update(); }, this->connections_);
|
||||
|
||||
connections_.push_back(
|
||||
getApp()->windows->repaintGifs.connect([&] { this->queueUpdate(); }));
|
||||
|
||||
connections_.push_back(
|
||||
getApp()->windows->layout.connect([&](Channel *channel) {
|
||||
if (channel == nullptr || this->channel_.get() == channel)
|
||||
this->layoutMessages();
|
||||
}));
|
||||
|
||||
connections_.push_back(getApp()->fonts->fontChanged.connect(
|
||||
[this] { this->layoutMessages(); }));
|
||||
}
|
||||
|
||||
void ChannelView::themeChangedEvent()
|
||||
@@ -228,14 +211,12 @@ void ChannelView::layoutMessages()
|
||||
|
||||
void ChannelView::actuallyLayoutMessages(bool causedByScrollbar)
|
||||
{
|
||||
// BenchmarkGuard benchmark("layout messages");
|
||||
|
||||
auto app = getApp();
|
||||
// BenchmarkGuard benchmark("layout");
|
||||
|
||||
auto messagesSnapshot = this->getMessagesSnapshot();
|
||||
|
||||
if (messagesSnapshot.getLength() == 0) {
|
||||
this->scrollBar_.setVisible(false);
|
||||
this->scrollBar_->setVisible(false);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -248,9 +229,9 @@ void ChannelView::actuallyLayoutMessages(bool causedByScrollbar)
|
||||
// The scrollbar was not visible
|
||||
// The scrollbar was visible and at the bottom
|
||||
this->showingLatestMessages_ =
|
||||
this->scrollBar_.isAtBottom() || !this->scrollBar_.isVisible();
|
||||
this->scrollBar_->isAtBottom() || !this->scrollBar_->isVisible();
|
||||
|
||||
size_t start = size_t(this->scrollBar_.getCurrentValue());
|
||||
size_t start = size_t(this->scrollBar_->getCurrentValue());
|
||||
int layoutWidth = this->getLayoutWidth();
|
||||
|
||||
MessageElementFlags flags = this->getFlags();
|
||||
@@ -258,7 +239,7 @@ void ChannelView::actuallyLayoutMessages(bool causedByScrollbar)
|
||||
// layout the visible messages in the view
|
||||
if (messagesSnapshot.getLength() > start) {
|
||||
int y = int(-(messagesSnapshot[start]->getHeight() *
|
||||
(fmod(this->scrollBar_.getCurrentValue(), 1))));
|
||||
(fmod(this->scrollBar_->getCurrentValue(), 1))));
|
||||
|
||||
for (size_t i = start; i < messagesSnapshot.getLength(); ++i) {
|
||||
auto message = messagesSnapshot[i];
|
||||
@@ -285,8 +266,9 @@ void ChannelView::actuallyLayoutMessages(bool causedByScrollbar)
|
||||
h -= message->getHeight();
|
||||
|
||||
if (h < 0) {
|
||||
this->scrollBar_.setLargeChange((messagesSnapshot.getLength() - i) +
|
||||
qreal(h) / message->getHeight());
|
||||
this->scrollBar_->setLargeChange(
|
||||
(messagesSnapshot.getLength() - i) +
|
||||
qreal(h) / message->getHeight());
|
||||
// this->scrollBar.setDesiredValue(this->scrollBar.getDesiredValue());
|
||||
|
||||
showScrollbar = true;
|
||||
@@ -294,22 +276,22 @@ void ChannelView::actuallyLayoutMessages(bool causedByScrollbar)
|
||||
}
|
||||
}
|
||||
|
||||
this->scrollBar_.setVisible(showScrollbar);
|
||||
this->scrollBar_->setVisible(showScrollbar);
|
||||
|
||||
if (!showScrollbar && !causedByScrollbar) {
|
||||
this->scrollBar_.setDesiredValue(0);
|
||||
this->scrollBar_->setDesiredValue(0);
|
||||
}
|
||||
|
||||
this->scrollBar_.setMaximum(messagesSnapshot.getLength());
|
||||
this->scrollBar_->setMaximum(messagesSnapshot.getLength());
|
||||
|
||||
// If we were showing the latest messages and the scrollbar now wants to be
|
||||
// rendered, scroll to bottom
|
||||
if (this->enableScrollingToBottom_ && this->showingLatestMessages_ &&
|
||||
showScrollbar) {
|
||||
if (!this->isPaused()) {
|
||||
this->scrollBar_.scrollToBottom(
|
||||
this->scrollBar_->scrollToBottom(
|
||||
// this->messageWasAdded &&
|
||||
app->settings->enableSmoothScrollingNewMessages.getValue());
|
||||
getSettings()->enableSmoothScrollingNewMessages.getValue());
|
||||
}
|
||||
this->messageWasAdded_ = false;
|
||||
}
|
||||
@@ -332,7 +314,7 @@ void ChannelView::clearMessages()
|
||||
|
||||
Scrollbar &ChannelView::getScrollBar()
|
||||
{
|
||||
return this->scrollBar_;
|
||||
return *this->scrollBar_;
|
||||
}
|
||||
|
||||
QString ChannelView::getSelectedText()
|
||||
@@ -401,7 +383,7 @@ const boost::optional<MessageElementFlags> &ChannelView::getOverrideFlags()
|
||||
|
||||
LimitedQueueSnapshot<MessageLayoutPtr> ChannelView::getMessagesSnapshot()
|
||||
{
|
||||
if (!this->isPaused() /*|| this->scrollBar_.isVisible()*/) {
|
||||
if (!this->isPaused() /*|| this->scrollBar_->isVisible()*/) {
|
||||
this->snapshot_ = this->messages.getSnapshot();
|
||||
}
|
||||
|
||||
@@ -436,10 +418,10 @@ void ChannelView::setChannel(ChannelPtr newChannel)
|
||||
if (this->messages.pushBack(MessageLayoutPtr(messageRef),
|
||||
deleted)) {
|
||||
// if (!this->isPaused()) {
|
||||
if (this->scrollBar_.isAtBottom()) {
|
||||
this->scrollBar_.scrollToBottom();
|
||||
if (this->scrollBar_->isAtBottom()) {
|
||||
this->scrollBar_->scrollToBottom();
|
||||
} else {
|
||||
this->scrollBar_.offset(-1);
|
||||
this->scrollBar_->offset(-1);
|
||||
}
|
||||
// }
|
||||
}
|
||||
@@ -454,7 +436,7 @@ void ChannelView::setChannel(ChannelPtr newChannel)
|
||||
}
|
||||
}
|
||||
|
||||
this->scrollBar_.addHighlight(message->getScrollBarHighlight());
|
||||
this->scrollBar_->addHighlight(message->getScrollBarHighlight());
|
||||
|
||||
this->messageWasAdded_ = true;
|
||||
this->layoutMessages();
|
||||
@@ -472,10 +454,10 @@ void ChannelView::setChannel(ChannelPtr newChannel)
|
||||
|
||||
if (!this->isPaused()) {
|
||||
if (this->messages.pushFront(messageRefs).size() > 0) {
|
||||
if (this->scrollBar_.isAtBottom()) {
|
||||
this->scrollBar_.scrollToBottom();
|
||||
if (this->scrollBar_->isAtBottom()) {
|
||||
this->scrollBar_->scrollToBottom();
|
||||
} else {
|
||||
this->scrollBar_.offset(qreal(messages.size()));
|
||||
this->scrollBar_->offset(qreal(messages.size()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -487,7 +469,7 @@ void ChannelView::setChannel(ChannelPtr newChannel)
|
||||
messages.at(i)->getScrollBarHighlight());
|
||||
}
|
||||
|
||||
this->scrollBar_.addHighlightsAtStart(highlights);
|
||||
this->scrollBar_->addHighlightsAtStart(highlights);
|
||||
|
||||
this->messageWasAdded_ = true;
|
||||
this->layoutMessages();
|
||||
@@ -515,7 +497,7 @@ void ChannelView::setChannel(ChannelPtr newChannel)
|
||||
MessageLayoutPtr newItem(new MessageLayout(replacement));
|
||||
auto snapshot = this->messages.getSnapshot();
|
||||
if (index >= snapshot.getLength()) {
|
||||
Log("Tried to replace out of bounds message. Index: {}. "
|
||||
log("Tried to replace out of bounds message. Index: {}. "
|
||||
"Length: {}",
|
||||
index, snapshot.getLength());
|
||||
return;
|
||||
@@ -526,7 +508,7 @@ void ChannelView::setChannel(ChannelPtr newChannel)
|
||||
newItem->flags.set(MessageLayoutFlag::AlternateBackground);
|
||||
}
|
||||
|
||||
this->scrollBar_.replaceHighlight(
|
||||
this->scrollBar_->replaceHighlight(
|
||||
index, replacement->getScrollBarHighlight());
|
||||
|
||||
this->messages.replaceItem(message, newItem);
|
||||
@@ -594,12 +576,12 @@ void ChannelView::updateLastReadMessage()
|
||||
|
||||
void ChannelView::resizeEvent(QResizeEvent *)
|
||||
{
|
||||
this->scrollBar_.setGeometry(this->width() - this->scrollBar_.width(), 0,
|
||||
this->scrollBar_.width(), this->height());
|
||||
this->scrollBar_->setGeometry(this->width() - this->scrollBar_->width(), 0,
|
||||
this->scrollBar_->width(), this->height());
|
||||
|
||||
this->goToBottom_->setGeometry(0, this->height() - 32, this->width(), 32);
|
||||
|
||||
this->scrollBar_.raise();
|
||||
this->scrollBar_->raise();
|
||||
|
||||
this->layoutMessages();
|
||||
|
||||
@@ -656,15 +638,15 @@ bool ChannelView::isPaused()
|
||||
void ChannelView::updatePauseStatus()
|
||||
{
|
||||
if (this->isPaused()) {
|
||||
this->scrollBar_.pauseHighlights();
|
||||
this->scrollBar_->pauseHighlights();
|
||||
} else {
|
||||
this->scrollBar_.unpauseHighlights();
|
||||
this->scrollBar_->unpauseHighlights();
|
||||
}
|
||||
}
|
||||
|
||||
void ChannelView::paintEvent(QPaintEvent * /*event*/)
|
||||
{
|
||||
// BenchmarkGuard benchmark("paint event");
|
||||
// BenchmarkGuard benchmark("paint");
|
||||
|
||||
QPainter painter(this);
|
||||
|
||||
@@ -678,18 +660,16 @@ void ChannelView::paintEvent(QPaintEvent * /*event*/)
|
||||
// such as the grey overlay when a message is disabled
|
||||
void ChannelView::drawMessages(QPainter &painter)
|
||||
{
|
||||
auto app = getApp();
|
||||
|
||||
auto messagesSnapshot = this->getMessagesSnapshot();
|
||||
|
||||
size_t start = size_t(this->scrollBar_.getCurrentValue());
|
||||
size_t start = size_t(this->scrollBar_->getCurrentValue());
|
||||
|
||||
if (start >= messagesSnapshot.getLength()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int y = int(-(messagesSnapshot[start].get()->getHeight() *
|
||||
(fmod(this->scrollBar_.getCurrentValue(), 1))));
|
||||
(fmod(this->scrollBar_->getCurrentValue(), 1))));
|
||||
|
||||
MessageLayout *end = nullptr;
|
||||
bool windowFocused = this->window() == QApplication::activeWindow();
|
||||
@@ -698,7 +678,7 @@ void ChannelView::drawMessages(QPainter &painter)
|
||||
MessageLayout *layout = messagesSnapshot[i].get();
|
||||
|
||||
bool isLastMessage = false;
|
||||
if (app->settings->showLastMessageIndicator) {
|
||||
if (getSettings()->showLastMessageIndicator) {
|
||||
isLastMessage = this->lastReadMessage_.get() == layout;
|
||||
}
|
||||
|
||||
@@ -760,12 +740,10 @@ void ChannelView::wheelEvent(QWheelEvent *event)
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->scrollBar_.isVisible()) {
|
||||
auto app = getApp();
|
||||
if (this->scrollBar_->isVisible()) {
|
||||
float mouseMultiplier = getSettings()->mouseScrollMultiplier;
|
||||
|
||||
float mouseMultiplier = app->settings->mouseScrollMultiplier;
|
||||
|
||||
qreal desired = this->scrollBar_.getDesiredValue();
|
||||
qreal desired = this->scrollBar_->getDesiredValue();
|
||||
qreal delta = event->delta() * qreal(1.5) * mouseMultiplier;
|
||||
|
||||
auto snapshot = this->getMessagesSnapshot();
|
||||
@@ -823,7 +801,7 @@ void ChannelView::wheelEvent(QWheelEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
this->scrollBar_.setDesiredValue(desired, true);
|
||||
this->scrollBar_->setDesiredValue(desired, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -848,9 +826,7 @@ void ChannelView::mouseMoveEvent(QMouseEvent *event)
|
||||
return;
|
||||
}
|
||||
|
||||
auto app = getApp();
|
||||
|
||||
if (app->settings->pauseChatHover.getValue()) {
|
||||
if (getSettings()->pauseChatHover.getValue()) {
|
||||
this->pause(CHAT_HOVER_PAUSE_DURATION);
|
||||
}
|
||||
|
||||
@@ -915,8 +891,6 @@ void ChannelView::mouseMoveEvent(QMouseEvent *event)
|
||||
|
||||
void ChannelView::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
auto app = getApp();
|
||||
|
||||
this->mouseDown.invoke(event);
|
||||
|
||||
std::shared_ptr<MessageLayout> layout;
|
||||
@@ -953,7 +927,7 @@ void ChannelView::mousePressEvent(QMouseEvent *event)
|
||||
return;
|
||||
}
|
||||
|
||||
if (app->settings->linksDoubleClickOnly.getValue()) {
|
||||
if (getSettings()->linksDoubleClickOnly.getValue()) {
|
||||
this->pause(200);
|
||||
}
|
||||
|
||||
@@ -1058,19 +1032,28 @@ void ChannelView::handleMouseClick(QMouseEvent *event,
|
||||
}
|
||||
|
||||
auto &link = hoveredElement->getLink();
|
||||
if (!getApp()->settings->linksDoubleClickOnly) {
|
||||
if (!getSettings()->linksDoubleClickOnly) {
|
||||
this->handleLinkClick(event, link, layout);
|
||||
}
|
||||
|
||||
// Invoke to signal from EmotePopup.
|
||||
if (link.type == Link::InsertText) {
|
||||
this->linkClicked.invoke(link);
|
||||
}
|
||||
} break;
|
||||
case Qt::RightButton: {
|
||||
|
||||
auto insertText = [=](QString text) {
|
||||
if (auto split = dynamic_cast<Split *>(this->parentWidget())) {
|
||||
split->insertTextToInput(text);
|
||||
}
|
||||
};
|
||||
|
||||
auto &link = hoveredElement->getLink();
|
||||
if (link.type == Link::UserInfo) {
|
||||
Split *split = dynamic_cast<Split *>(this->parentWidget());
|
||||
if (split != nullptr) {
|
||||
split->insertTextToInput("@" + link.value + ", ");
|
||||
}
|
||||
insertText("@" + link.value + ", ");
|
||||
} else if (link.type == Link::UserWhisper) {
|
||||
insertText("/w " + link.value + " ");
|
||||
} else {
|
||||
this->addContextMenuItems(hoveredElement, layout);
|
||||
}
|
||||
@@ -1123,17 +1106,18 @@ void ChannelView::addContextMenuItems(
|
||||
|
||||
menu->addAction("Copy message", [layout] {
|
||||
QString copyString;
|
||||
layout->addSelectionText(copyString);
|
||||
layout->addSelectionText(copyString, 0, INT_MAX,
|
||||
CopyMode::OnlyTextAndEmotes);
|
||||
|
||||
QGuiApplication::clipboard()->setText(copyString);
|
||||
});
|
||||
|
||||
// menu->addAction("Quote message", [layout] {
|
||||
// QString copyString;
|
||||
// layout->addSelectionText(copyString);
|
||||
menu->addAction("Copy full message", [layout] {
|
||||
QString copyString;
|
||||
layout->addSelectionText(copyString);
|
||||
|
||||
// // insert into input
|
||||
// });
|
||||
QGuiApplication::clipboard()->setText(copyString);
|
||||
});
|
||||
|
||||
menu->popup(QCursor::pos());
|
||||
menu->raise();
|
||||
@@ -1143,9 +1127,7 @@ void ChannelView::addContextMenuItems(
|
||||
|
||||
void ChannelView::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
{
|
||||
auto app = getApp();
|
||||
|
||||
if (app->settings->linksDoubleClickOnly) {
|
||||
if (getSettings()->linksDoubleClickOnly) {
|
||||
std::shared_ptr<MessageLayout> layout;
|
||||
QPoint relativePos;
|
||||
int messageIndex;
|
||||
@@ -1188,6 +1170,7 @@ void ChannelView::handleLinkClick(QMouseEvent *event, const Link &link,
|
||||
}
|
||||
|
||||
switch (link.type) {
|
||||
case Link::UserWhisper:
|
||||
case Link::UserInfo: {
|
||||
auto user = link.value;
|
||||
|
||||
@@ -1200,19 +1183,18 @@ void ChannelView::handleLinkClick(QMouseEvent *event, const Link &link,
|
||||
userPopup->show();
|
||||
|
||||
qDebug() << "Clicked " << user << "s message";
|
||||
break;
|
||||
}
|
||||
|
||||
} break;
|
||||
|
||||
case Link::Url: {
|
||||
QDesktopServices::openUrl(QUrl(link.value));
|
||||
break;
|
||||
}
|
||||
} break;
|
||||
|
||||
case Link::UserAction: {
|
||||
QString value = link.value;
|
||||
value.replace("{user}", layout->getMessage()->loginName);
|
||||
this->channel_->sendMessage(value);
|
||||
}
|
||||
} break;
|
||||
|
||||
default:;
|
||||
}
|
||||
@@ -1224,14 +1206,14 @@ bool ChannelView::tryGetMessageAt(QPoint p,
|
||||
{
|
||||
auto messagesSnapshot = this->getMessagesSnapshot();
|
||||
|
||||
size_t start = this->scrollBar_.getCurrentValue();
|
||||
size_t start = this->scrollBar_->getCurrentValue();
|
||||
|
||||
if (start >= messagesSnapshot.getLength()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int y = -(messagesSnapshot[start]->getHeight() *
|
||||
(fmod(this->scrollBar_.getCurrentValue(), 1)));
|
||||
(fmod(this->scrollBar_->getCurrentValue(), 1)));
|
||||
|
||||
for (size_t i = start; i < messagesSnapshot.getLength(); ++i) {
|
||||
auto message = messagesSnapshot[i];
|
||||
@@ -1251,7 +1233,7 @@ bool ChannelView::tryGetMessageAt(QPoint p,
|
||||
|
||||
int ChannelView::getLayoutWidth() const
|
||||
{
|
||||
if (this->scrollBar_.isVisible())
|
||||
if (this->scrollBar_->isVisible())
|
||||
return int(this->width() - 8 * this->getScale());
|
||||
|
||||
return this->width();
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "common/Channel.hpp"
|
||||
#include "messages/Image.hpp"
|
||||
#include "common/FlagsEnum.hpp"
|
||||
#include "messages/LimitedQueue.hpp"
|
||||
#include "messages/LimitedQueueSnapshot.hpp"
|
||||
#include "messages/MessageElement.hpp"
|
||||
#include "messages/Selection.hpp"
|
||||
#include "messages/layouts/MessageLayout.hpp"
|
||||
#include "widgets/BaseWidget.hpp"
|
||||
#include "widgets/Scrollbar.hpp"
|
||||
#include "widgets/helper/RippleEffectLabel.hpp"
|
||||
|
||||
#include <QPaintEvent>
|
||||
#include <QScroller>
|
||||
@@ -20,14 +16,28 @@
|
||||
#include <unordered_set>
|
||||
|
||||
namespace chatterino {
|
||||
enum class HighlightState;
|
||||
|
||||
class ChannelView : public BaseWidget
|
||||
class Channel;
|
||||
using ChannelPtr = std::shared_ptr<Channel>;
|
||||
|
||||
class MessageLayout;
|
||||
using MessageLayoutPtr = std::shared_ptr<MessageLayout>;
|
||||
|
||||
enum class MessageElementFlag;
|
||||
using MessageElementFlags = FlagsEnum<MessageElementFlag>;
|
||||
|
||||
class Scrollbar;
|
||||
class EffectLabel;
|
||||
struct Link;
|
||||
class MessageLayoutElement;
|
||||
|
||||
class ChannelView final : public BaseWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ChannelView(BaseWidget *parent = nullptr);
|
||||
virtual ~ChannelView() override;
|
||||
|
||||
void queueUpdate();
|
||||
Scrollbar &getScrollBar();
|
||||
@@ -77,6 +87,14 @@ protected:
|
||||
QPoint &relativePos, int &index);
|
||||
|
||||
private:
|
||||
void initializeLayout();
|
||||
void initializeScrollbar();
|
||||
void initializeSignals();
|
||||
|
||||
// void messageAppended(MessagePtr &message);
|
||||
// void messageAddedAtStart(std::vector<MessagePtr> &messages);
|
||||
// void messageRemoveFromStart(MessagePtr &message);
|
||||
|
||||
void updatePauseStatus();
|
||||
void detachChannel();
|
||||
void actuallyLayoutMessages(bool causedByScollbar = false);
|
||||
@@ -114,8 +132,8 @@ private:
|
||||
|
||||
ChannelPtr channel_;
|
||||
|
||||
Scrollbar scrollBar_;
|
||||
RippleEffectLabel *goToBottom_;
|
||||
Scrollbar *scrollBar_;
|
||||
EffectLabel *goToBottom_;
|
||||
|
||||
// This variable can be used to decide whether or not we should render the
|
||||
// "Show latest messages" button
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "widgets/helper/RippleEffectLabel.hpp"
|
||||
#include "widgets/helper/EffectLabel.hpp"
|
||||
#include "singletons/Theme.hpp"
|
||||
#include "widgets/splits/SplitHeader.hpp"
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
RippleEffectLabel::RippleEffectLabel(BaseWidget *parent, int spacing)
|
||||
: RippleEffectButton(parent)
|
||||
EffectLabel::EffectLabel(BaseWidget *parent, int spacing)
|
||||
: Button(parent)
|
||||
, label_(this)
|
||||
{
|
||||
setLayout(&this->hbox_);
|
||||
@@ -21,8 +21,8 @@ RippleEffectLabel::RippleEffectLabel(BaseWidget *parent, int spacing)
|
||||
this->hbox_.addSpacing(spacing);
|
||||
}
|
||||
|
||||
RippleEffectLabel2::RippleEffectLabel2(BaseWidget *parent, int padding)
|
||||
: RippleEffectButton(parent)
|
||||
EffectLabel2::EffectLabel2(BaseWidget *parent, int padding)
|
||||
: Button(parent)
|
||||
, label_(this)
|
||||
{
|
||||
auto *hbox = new QHBoxLayout(this);
|
||||
@@ -37,7 +37,7 @@ RippleEffectLabel2::RippleEffectLabel2(BaseWidget *parent, int padding)
|
||||
// hbox.addSpacing(spacing);
|
||||
}
|
||||
|
||||
Label &RippleEffectLabel2::getLabel()
|
||||
Label &EffectLabel2::getLabel()
|
||||
{
|
||||
return this->label_;
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include "widgets/BaseWidget.hpp"
|
||||
#include "widgets/Label.hpp"
|
||||
#include "widgets/helper/RippleEffectButton.hpp"
|
||||
#include "widgets/helper/Button.hpp"
|
||||
#include "widgets/helper/SignalLabel.hpp"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
@@ -12,10 +12,10 @@
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
class RippleEffectLabel : public RippleEffectButton
|
||||
class EffectLabel : public Button
|
||||
{
|
||||
public:
|
||||
explicit RippleEffectLabel(BaseWidget *parent = nullptr, int spacing = 6);
|
||||
explicit EffectLabel(BaseWidget *parent = nullptr, int spacing = 6);
|
||||
|
||||
SignalLabel &getLabel()
|
||||
{
|
||||
@@ -27,10 +27,10 @@ private:
|
||||
SignalLabel label_;
|
||||
};
|
||||
|
||||
class RippleEffectLabel2 : public RippleEffectButton
|
||||
class EffectLabel2 : public Button
|
||||
{
|
||||
public:
|
||||
explicit RippleEffectLabel2(BaseWidget *parent = nullptr, int padding = 6);
|
||||
explicit EffectLabel2(BaseWidget *parent = nullptr, int padding = 6);
|
||||
|
||||
Label &getLabel();
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#include "widgets/helper/NotebookButton.hpp"
|
||||
#include "singletons/Theme.hpp"
|
||||
#include "widgets/Notebook.hpp"
|
||||
#include "widgets/helper/RippleEffectButton.hpp"
|
||||
#include "widgets/helper/Button.hpp"
|
||||
#include "widgets/splits/Split.hpp"
|
||||
#include "widgets/splits/SplitContainer.hpp"
|
||||
|
||||
#include <QMouseEvent>
|
||||
@@ -14,7 +15,7 @@
|
||||
namespace chatterino {
|
||||
|
||||
NotebookButton::NotebookButton(Notebook *parent)
|
||||
: RippleEffectButton(parent)
|
||||
: Button(parent)
|
||||
, parent_(parent)
|
||||
{
|
||||
this->setAcceptDrops(true);
|
||||
@@ -122,7 +123,7 @@ void NotebookButton::paintEvent(QPaintEvent *event)
|
||||
default:;
|
||||
}
|
||||
|
||||
RippleEffectButton::paintEvent(event);
|
||||
Button::paintEvent(event);
|
||||
}
|
||||
|
||||
void NotebookButton::mouseReleaseEvent(QMouseEvent *event)
|
||||
@@ -135,7 +136,7 @@ void NotebookButton::mouseReleaseEvent(QMouseEvent *event)
|
||||
emit clicked();
|
||||
}
|
||||
|
||||
RippleEffectButton::mouseReleaseEvent(event);
|
||||
Button::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
void NotebookButton::dragEnterEvent(QDragEnterEvent *event)
|
||||
@@ -149,7 +150,7 @@ void NotebookButton::dragEnterEvent(QDragEnterEvent *event)
|
||||
auto e = new QMouseEvent(QMouseEvent::MouseButtonPress,
|
||||
QPointF(this->width() / 2, this->height() / 2),
|
||||
Qt::LeftButton, Qt::LeftButton, 0);
|
||||
RippleEffectButton::mousePressEvent(e);
|
||||
Button::mousePressEvent(e);
|
||||
delete e;
|
||||
}
|
||||
|
||||
@@ -161,7 +162,7 @@ void NotebookButton::dragLeaveEvent(QDragLeaveEvent *)
|
||||
auto e = new QMouseEvent(QMouseEvent::MouseButtonRelease,
|
||||
QPointF(this->width() / 2, this->height() / 2),
|
||||
Qt::LeftButton, Qt::LeftButton, 0);
|
||||
RippleEffectButton::mouseReleaseEvent(e);
|
||||
Button::mouseReleaseEvent(e);
|
||||
delete e;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "RippleEffectButton.hpp"
|
||||
#include "Button.hpp"
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace chatterino {
|
||||
|
||||
class Notebook;
|
||||
|
||||
class NotebookButton : public RippleEffectButton
|
||||
class NotebookButton : public Button
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "Application.hpp"
|
||||
#include "common/Common.hpp"
|
||||
#include "debug/Log.hpp"
|
||||
#include "singletons/Fonts.hpp"
|
||||
#include "singletons/Settings.hpp"
|
||||
#include "singletons/Theme.hpp"
|
||||
#include "util/Clamp.hpp"
|
||||
@@ -10,6 +11,7 @@
|
||||
#include "widgets/Notebook.hpp"
|
||||
#include "widgets/dialogs/SettingsDialog.hpp"
|
||||
#include "widgets/dialogs/TextInputDialog.hpp"
|
||||
#include "widgets/splits/SplitContainer.hpp"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
@@ -21,7 +23,7 @@
|
||||
namespace chatterino {
|
||||
|
||||
NotebookTab::NotebookTab(Notebook *notebook)
|
||||
: RippleEffectButton(notebook)
|
||||
: Button(notebook)
|
||||
, positionChangedAnimation_(this, "pos")
|
||||
, notebook_(notebook)
|
||||
, menu_(this)
|
||||
@@ -33,7 +35,7 @@ NotebookTab::NotebookTab(Notebook *notebook)
|
||||
this->positionChangedAnimation_.setEasingCurve(
|
||||
QEasingCurve(QEasingCurve::InCubic));
|
||||
|
||||
app->settings->showTabCloseButton.connect(
|
||||
getSettings()->showTabCloseButton.connect(
|
||||
boost::bind(&NotebookTab::hideTabXChanged, this, _1),
|
||||
this->managedConnections_);
|
||||
|
||||
@@ -286,7 +288,7 @@ void NotebookTab::paintEvent(QPaintEvent *)
|
||||
painter.setPen(colors.text);
|
||||
|
||||
// set area for text
|
||||
int rectW = (!app->settings->showTabCloseButton ? 0 : int(16 * scale));
|
||||
int rectW = (!getSettings()->showTabCloseButton ? 0 : int(16 * scale));
|
||||
QRect rect(0, 0, this->width() - rectW, height);
|
||||
|
||||
// draw text
|
||||
@@ -341,7 +343,7 @@ void NotebookTab::paintEvent(QPaintEvent *)
|
||||
|
||||
bool NotebookTab::hasXButton()
|
||||
{
|
||||
return getApp()->settings->showTabCloseButton &&
|
||||
return getSettings()->showTabCloseButton &&
|
||||
this->notebook_->getAllowUserTabManagement();
|
||||
}
|
||||
|
||||
@@ -406,7 +408,7 @@ void NotebookTab::enterEvent(QEvent *event)
|
||||
|
||||
this->update();
|
||||
|
||||
RippleEffectButton::enterEvent(event);
|
||||
Button::enterEvent(event);
|
||||
}
|
||||
|
||||
void NotebookTab::leaveEvent(QEvent *event)
|
||||
@@ -416,7 +418,7 @@ void NotebookTab::leaveEvent(QEvent *event)
|
||||
|
||||
this->update();
|
||||
|
||||
RippleEffectButton::leaveEvent(event);
|
||||
Button::leaveEvent(event);
|
||||
}
|
||||
|
||||
void NotebookTab::dragEnterEvent(QDragEnterEvent *event)
|
||||
@@ -434,7 +436,7 @@ void NotebookTab::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
auto app = getApp();
|
||||
|
||||
if (app->settings->showTabCloseButton &&
|
||||
if (getSettings()->showTabCloseButton &&
|
||||
this->notebook_->getAllowUserTabManagement()) //
|
||||
{
|
||||
bool overX = this->getXRect().contains(event->pos());
|
||||
@@ -461,7 +463,7 @@ void NotebookTab::mouseMoveEvent(QMouseEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
RippleEffectButton::mouseMoveEvent(event);
|
||||
Button::mouseMoveEvent(event);
|
||||
}
|
||||
|
||||
QRect NotebookTab::getXRect()
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include "common/Common.hpp"
|
||||
#include "widgets/BaseWidget.hpp"
|
||||
#include "widgets/helper/RippleEffectButton.hpp"
|
||||
#include "widgets/helper/Button.hpp"
|
||||
|
||||
#include <QMenu>
|
||||
#include <QPropertyAnimation>
|
||||
@@ -17,7 +17,7 @@ namespace chatterino {
|
||||
class Notebook;
|
||||
class SplitContainer;
|
||||
|
||||
class NotebookTab : public RippleEffectButton
|
||||
class NotebookTab : public Button
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ void ResizingTextEdit::keyPressEvent(QKeyEvent *event)
|
||||
// First type pressing tab after modifying a message, we refresh our
|
||||
// completion model
|
||||
this->completer_->setModel(completionModel);
|
||||
completionModel->refresh();
|
||||
completionModel->refresh(currentCompletionPrefix);
|
||||
this->completionInProgress_ = true;
|
||||
this->completer_->setCompletionPrefix(currentCompletionPrefix);
|
||||
this->completer_->complete();
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
class ScrollbarHighlight
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "common/Channel.hpp"
|
||||
#include "messages/Message.hpp"
|
||||
#include "widgets/helper/ChannelView.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "messages/LimitedQueueSnapshot.hpp"
|
||||
#include "messages/Message.hpp"
|
||||
#include "widgets/BaseWindow.hpp"
|
||||
|
||||
#include <memory>
|
||||
@@ -13,6 +12,9 @@ namespace chatterino {
|
||||
class Channel;
|
||||
class ChannelView;
|
||||
|
||||
struct Message;
|
||||
using MessagePtr = std::shared_ptr<const Message>;
|
||||
|
||||
class SearchPopup : public BaseWindow
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -5,16 +5,16 @@
|
||||
namespace chatterino {
|
||||
|
||||
TitleBarButton::TitleBarButton()
|
||||
: RippleEffectButton(nullptr)
|
||||
: Button(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
TitleBarButton::Style TitleBarButton::getButtonStyle() const
|
||||
TitleBarButtonStyle TitleBarButton::getButtonStyle() const
|
||||
{
|
||||
return this->style_;
|
||||
}
|
||||
|
||||
void TitleBarButton::setButtonStyle(Style _style)
|
||||
void TitleBarButton::setButtonStyle(TitleBarButtonStyle _style)
|
||||
{
|
||||
this->style_ = _style;
|
||||
this->update();
|
||||
@@ -35,16 +35,16 @@ void TitleBarButton::paintEvent(QPaintEvent *event)
|
||||
painter.setRenderHint(QPainter::Antialiasing, false);
|
||||
|
||||
switch (this->style_) {
|
||||
case Minimize: {
|
||||
case TitleBarButtonStyle::Minimize: {
|
||||
painter.fillRect(centerX - xD / 2, xD * 3 / 2, xD, 1, color);
|
||||
break;
|
||||
}
|
||||
case Maximize: {
|
||||
case TitleBarButtonStyle::Maximize: {
|
||||
painter.setPen(color);
|
||||
painter.drawRect(centerX - xD / 2, xD, xD - 1, xD - 1);
|
||||
break;
|
||||
}
|
||||
case Unmaximize: {
|
||||
case TitleBarButtonStyle::Unmaximize: {
|
||||
int xD2 = xD * 1 / 5;
|
||||
int xD3 = xD * 4 / 5;
|
||||
|
||||
@@ -54,7 +54,7 @@ void TitleBarButton::paintEvent(QPaintEvent *event)
|
||||
painter.drawRect(centerX - xD / 2, xD + xD2, xD3, xD3);
|
||||
break;
|
||||
}
|
||||
case Close: {
|
||||
case TitleBarButtonStyle::Close: {
|
||||
QRect rect(centerX - xD / 2, xD, xD - 1, xD - 1);
|
||||
painter.setPen(QPen(color, 1));
|
||||
|
||||
@@ -62,7 +62,7 @@ void TitleBarButton::paintEvent(QPaintEvent *event)
|
||||
painter.drawLine(rect.topRight(), rect.bottomLeft());
|
||||
break;
|
||||
}
|
||||
case User: {
|
||||
case TitleBarButtonStyle::User: {
|
||||
color = "#999";
|
||||
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
@@ -88,7 +88,7 @@ void TitleBarButton::paintEvent(QPaintEvent *event)
|
||||
|
||||
break;
|
||||
}
|
||||
case Settings: {
|
||||
case TitleBarButtonStyle::Settings: {
|
||||
color = "#999";
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
painter.setRenderHint(QPainter::HighQualityAntialiasing);
|
||||
@@ -119,7 +119,7 @@ void TitleBarButton::paintEvent(QPaintEvent *event)
|
||||
default:;
|
||||
}
|
||||
|
||||
RippleEffectButton::paintEvent(event);
|
||||
Button::paintEvent(event);
|
||||
// this->fancyPaint(painter);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,32 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
#include "widgets/helper/RippleEffectButton.hpp"
|
||||
#include "widgets/helper/Button.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
class TitleBarButton : public RippleEffectButton
|
||||
enum class TitleBarButtonStyle {
|
||||
None = 0,
|
||||
Minimize = 1,
|
||||
Maximize = 2,
|
||||
Unmaximize = 4,
|
||||
Close = 8,
|
||||
User = 16,
|
||||
Settings = 32
|
||||
};
|
||||
|
||||
class TitleBarButton : public Button
|
||||
{
|
||||
public:
|
||||
enum Style {
|
||||
None = 0,
|
||||
Minimize = 1,
|
||||
Maximize = 2,
|
||||
Unmaximize = 4,
|
||||
Close = 8,
|
||||
User = 16,
|
||||
Settings = 32
|
||||
};
|
||||
|
||||
TitleBarButton();
|
||||
|
||||
Style getButtonStyle() const;
|
||||
void setButtonStyle(Style style_);
|
||||
TitleBarButtonStyle getButtonStyle() const;
|
||||
void setButtonStyle(TitleBarButtonStyle style_);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *) override;
|
||||
|
||||
private:
|
||||
Style style_;
|
||||
TitleBarButtonStyle style_;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
Reference in New Issue
Block a user