turning a lot of includes into forward declares

This commit is contained in:
fourtf
2018-08-11 22:23:06 +02:00
parent 63eaf3b94c
commit 44f5a15da3
117 changed files with 591 additions and 536 deletions
+1
View File
@@ -3,6 +3,7 @@
#include "Application.hpp"
#include "common/Common.hpp"
#include "controllers/accounts/AccountController.hpp"
#include "providers/twitch/TwitchAccount.hpp"
#include "providers/twitch/TwitchCommon.hpp"
namespace chatterino {
+5 -3
View File
@@ -1,12 +1,14 @@
#pragma once
#include <QTimer>
#include <QWidget>
#include "common/Channel.hpp"
#include "widgets/splits/Split.hpp"
namespace chatterino {
class Split;
class Channel;
using ChannelPtr = std::shared_ptr<Channel>;
class AttachedWindow : public QWidget
{
AttachedWindow(void *_target, int _yOffset);
+10 -9
View File
@@ -4,6 +4,7 @@
#include "boost/algorithm/algorithm.hpp"
#include "debug/Log.hpp"
#include "singletons/Settings.hpp"
#include "singletons/Theme.hpp"
#include "singletons/WindowManager.hpp"
#include "util/PostToThread.hpp"
#include "util/WindowsHelper.hpp"
@@ -110,11 +111,11 @@ void BaseWindow::init()
// buttons
TitleBarButton *_minButton = new TitleBarButton;
_minButton->setButtonStyle(TitleBarButton::Minimize);
_minButton->setButtonStyle(TitleBarButtonStyle::Minimize);
TitleBarButton *_maxButton = new TitleBarButton;
_maxButton->setButtonStyle(TitleBarButton::Maximize);
_maxButton->setButtonStyle(TitleBarButtonStyle::Maximize);
TitleBarButton *_exitButton = new TitleBarButton;
_exitButton->setButtonStyle(TitleBarButton::Close);
_exitButton->setButtonStyle(TitleBarButtonStyle::Close);
QObject::connect(_minButton, &TitleBarButton::clicked, this,
[this] {
@@ -353,8 +354,8 @@ void BaseWindow::mouseMoveEvent(QMouseEvent *event)
BaseWidget::mouseMoveEvent(event);
}
TitleBarButton *BaseWindow::addTitleBarButton(
const TitleBarButton::Style &style, std::function<void()> onClicked)
TitleBarButton *BaseWindow::addTitleBarButton(const TitleBarButtonStyle &style,
std::function<void()> onClicked)
{
TitleBarButton *button = new TitleBarButton;
button->setScaleIndependantSize(30, 30);
@@ -389,10 +390,10 @@ void BaseWindow::changeEvent(QEvent *)
#ifdef USEWINSDK
if (this->ui_.maxButton) {
this->ui_.maxButton->setButtonStyle(this->windowState() &
Qt::WindowMaximized
? TitleBarButton::Unmaximize
: TitleBarButton::Maximize);
this->ui_.maxButton->setButtonStyle(
this->windowState() & Qt::WindowMaximized
? TitleBarButtonStyle::Unmaximize
: TitleBarButtonStyle::Maximize);
}
#endif
+3 -3
View File
@@ -1,7 +1,6 @@
#pragma once
#include "BaseWidget.hpp"
#include "widgets/helper/TitlebarButton.hpp"
#include <functional>
#include <pajlada/signals/signalholder.hpp>
@@ -15,6 +14,7 @@ namespace chatterino {
class Button;
class EffectLabel;
class TitleBarButton;
enum class TitleBarButtonStyle;
class BaseWindow : public BaseWidget
{
@@ -36,7 +36,7 @@ public:
QWidget *getLayoutContainer();
bool hasCustomWindowFrame();
TitleBarButton *addTitleBarButton(const TitleBarButton::Style &style,
TitleBarButton *addTitleBarButton(const TitleBarButtonStyle &style,
std::function<void()> onClicked);
EffectLabel *addTitleBarLabel(std::function<void()> onClicked);
@@ -114,6 +114,6 @@ private:
pajlada::Signals::SignalHolder connections_;
std::vector<pajlada::Signals::ScopedConnection> managedConnections_;
};
}; // namespace chatterino
} // namespace chatterino
+10 -10
View File
@@ -2,6 +2,7 @@
#include "Application.hpp"
#include "debug/Log.hpp"
#include "singletons/Settings.hpp"
#include "singletons/Theme.hpp"
#include "singletons/WindowManager.hpp"
#include "util/InitUpdateButton.hpp"
@@ -27,11 +28,11 @@ namespace chatterino {
Notebook::Notebook(QWidget *parent)
: BaseWidget(parent)
, addButton_(this)
, addButton_(new NotebookButton(this))
{
this->addButton_.setIcon(NotebookButton::Icon::Plus);
this->addButton_->setIcon(NotebookButton::Icon::Plus);
this->addButton_.setHidden(true);
this->addButton_->setHidden(true);
auto *shortcut_next = new QShortcut(QKeySequence("Ctrl+Tab"), this);
QObject::connect(shortcut_next, &QShortcut::activated,
@@ -290,14 +291,14 @@ void Notebook::setShowAddButton(bool value)
{
this->showAddButton_ = value;
this->addButton_.setHidden(!value);
this->addButton_->setHidden(!value);
}
void Notebook::scaleChangedEvent(float scale)
{
float h = NOTEBOOK_TAB_HEIGHT * this->getScale();
this->addButton_.setFixedSize(h, h);
this->addButton_->setFixedSize(h, h);
for (auto &i : this->items_) {
i.tab->updateSize();
@@ -353,7 +354,7 @@ void Notebook::performLayout(bool animated)
}
if (this->showAddButton_) {
this->addButton_.move(x, y);
this->addButton_->move(x, y);
}
if (this->lineY_ != y + tabHeight) {
@@ -368,7 +369,7 @@ void Notebook::performLayout(bool animated)
}
if (this->showAddButton_) {
this->addButton_.raise();
this->addButton_->raise();
}
if (this->selectedPage_ != nullptr) {
@@ -389,7 +390,7 @@ void Notebook::paintEvent(QPaintEvent *event)
NotebookButton *Notebook::getAddButton()
{
return &this->addButton_;
return this->addButton_;
}
NotebookButton *Notebook::addCustomButton()
@@ -460,8 +461,7 @@ void SplitNotebook::addCustomButtons()
// updates
auto updateBtn = this->addCustomButton();
initUpdateButton(*updateBtn, this->updateDialogHandle_,
this->signalHolder_);
initUpdateButton(*updateBtn, this->signalHolder_);
}
SplitContainer *SplitNotebook::addPage(bool select)
+7 -6
View File
@@ -2,10 +2,6 @@
#include "pajlada/signals/signal.hpp"
#include "widgets/BaseWidget.hpp"
#include "widgets/dialogs/UpdateDialog.hpp"
#include "widgets/helper/NotebookButton.hpp"
#include "widgets/helper/NotebookTab.hpp"
#include "widgets/splits/SplitContainer.hpp"
#include <QList>
#include <QMessageBox>
@@ -15,6 +11,10 @@
namespace chatterino {
class Window;
class UpdateDialog;
class NotebookButton;
class NotebookTab;
class SplitContainer;
class Notebook : public BaseWidget
{
@@ -22,6 +22,7 @@ class Notebook : public BaseWidget
public:
explicit Notebook(QWidget *parent);
~Notebook() override = default;
NotebookTab *addPage(QWidget *page, QString title = QString(),
bool select = false);
@@ -74,7 +75,7 @@ private:
QList<Item> items_;
QWidget *selectedPage_ = nullptr;
NotebookButton addButton_;
NotebookButton *addButton_;
std::vector<NotebookButton *> customButtons_;
bool allowUserTabManagement_ = false;
@@ -94,7 +95,7 @@ private:
void addCustomButtons();
pajlada::Signals::SignalHolder signalHolder_;
std::unique_ptr<UpdateDialog> updateDialogHandle_;
std::shared_ptr<UpdateDialog> updateDialogHandle_;
std::vector<pajlada::Signals::ScopedConnection> connections_;
};
+6 -6
View File
@@ -1,6 +1,7 @@
#include "widgets/Scrollbar.hpp"
#include "Application.hpp"
#include "singletons/Settings.hpp"
#include "singletons/Theme.hpp"
#include "widgets/helper/ChannelView.hpp"
@@ -103,8 +104,7 @@ void Scrollbar::setSmallChange(qreal value)
void Scrollbar::setDesiredValue(qreal value, bool animated)
{
auto app = getApp();
animated &= app->settings->enableSmoothScrolling.getValue();
animated &= getSettings()->enableSmoothScrolling.getValue();
value = std::max(this->minimum_,
std::min(this->maximum_ - this->largeChange_, value));
@@ -221,8 +221,6 @@ void Scrollbar::printCurrentState(const QString &prefix) const
void Scrollbar::paintEvent(QPaintEvent *)
{
auto *app = getApp();
bool mouseOver = this->mouseOverIndex_ != -1;
int xOffset = mouseOver ? 0 : width() - int(4 * this->getScale());
@@ -267,9 +265,11 @@ void Scrollbar::paintEvent(QPaintEvent *)
QColor color = [&] {
switch (highlight.getColor()) {
case ScrollbarHighlight::Highlight:
return app->themes->scrollbars.highlights.highlight;
return getApp()
->themes->scrollbars.highlights.highlight;
case ScrollbarHighlight::Subscription:
return app->themes->scrollbars.highlights.subscription;
return getApp()
->themes->scrollbars.highlights.subscription;
}
return QColor();
}();
-1
View File
@@ -1,7 +1,6 @@
#pragma once
#include "messages/LimitedQueue.hpp"
#include "singletons/Settings.hpp"
#include "widgets/BaseWidget.hpp"
#include "widgets/helper/ScrollbarHighlight.hpp"
+1
View File
@@ -3,6 +3,7 @@
#include "common/Channel.hpp"
#include "util/Helpers.hpp"
#include "util/LayoutCreator.hpp"
#include "widgets/helper/ChannelView.hpp"
#include "widgets/splits/Split.hpp"
#ifdef USEWEBENGINE
+1 -1
View File
@@ -79,7 +79,7 @@ void TooltipWidget::updateFont()
auto app = getApp();
this->setFont(
app->fonts->getFont(Fonts::Type::ChatMediumSmall, this->getScale()));
app->fonts->getFont(FontStyle::ChatMediumSmall, this->getScale()));
}
void TooltipWidget::setText(QString text)
+33 -31
View File
@@ -14,8 +14,11 @@
#include "widgets/dialogs/SettingsDialog.hpp"
#include "widgets/dialogs/UpdateDialog.hpp"
#include "widgets/dialogs/WelcomeDialog.hpp"
#include "widgets/helper/EffectLabel.hpp"
#include "widgets/helper/Shortcut.hpp"
#include "widgets/helper/TitlebarButton.hpp"
#include "widgets/splits/Split.hpp"
#include "widgets/splits/SplitContainer.hpp"
#include <QApplication>
#include <QDesktopServices>
@@ -28,10 +31,10 @@
namespace chatterino {
Window::Window(Type type)
Window::Window(WindowType type)
: BaseWindow(nullptr, BaseWindow::EnableCustomFrame)
, type_(type)
, notebook_(this)
, notebook_(new SplitNotebook(this))
{
this->addCustomTitlebarButtons();
this->addDebugStuff();
@@ -42,26 +45,26 @@ Window::Window(Type type)
[this] { this->onAccountSelected(); });
this->onAccountSelected();
if (type == Type::Main) {
if (type == WindowType::Main) {
this->resize(int(600 * this->getScale()), int(500 * this->getScale()));
} else {
this->resize(int(300 * this->getScale()), int(500 * this->getScale()));
}
}
Window::Type Window::getType()
WindowType Window::getType()
{
return this->type_;
}
SplitNotebook &Window::getNotebook()
{
return this->notebook_;
return *this->notebook_;
}
void Window::repaintVisibleChatWidgets(Channel *channel)
{
auto page = this->notebook_.getOrAddSelectedPage();
auto page = this->notebook_->getOrAddSelectedPage();
for (const auto &split : page->getSplits()) {
if (channel == nullptr || channel == split->getChannel().get()) {
@@ -77,7 +80,7 @@ bool Window::event(QEvent *event)
break;
case QEvent::WindowDeactivate: {
auto page = this->notebook_.getOrAddSelectedPage();
auto page = this->notebook_->getOrAddSelectedPage();
if (page != nullptr) {
std::vector<Split *> splits = page->getSplits();
@@ -135,7 +138,7 @@ void Window::showEvent(QShowEvent *event)
void Window::closeEvent(QCloseEvent *)
{
if (this->type_ == Type::Main) {
if (this->type_ == WindowType::Main) {
auto app = getApp();
app->windows->save();
app->windows->closeAll();
@@ -143,7 +146,7 @@ void Window::closeEvent(QCloseEvent *)
this->closed.invoke();
if (this->type_ == Type::Main) {
if (this->type_ == WindowType::Main) {
QApplication::exit();
}
}
@@ -152,35 +155,34 @@ void Window::addLayout()
{
QVBoxLayout *layout = new QVBoxLayout(this);
layout->addWidget(&this->notebook_);
layout->addWidget(this->notebook_);
this->getLayoutContainer()->setLayout(layout);
// set margin
layout->setMargin(0);
this->notebook_.setAllowUserTabManagement(true);
this->notebook_.setShowAddButton(true);
this->notebook_->setAllowUserTabManagement(true);
this->notebook_->setShowAddButton(true);
}
void Window::addCustomTitlebarButtons()
{
if (!this->hasCustomWindowFrame()) return;
if (this->type_ != Type::Main) return;
if (this->type_ != WindowType::Main) return;
// settings
this->addTitleBarButton(TitleBarButton::Settings, [] {
getApp()->windows->showSettingsDialog(); //
});
this->addTitleBarButton(TitleBarButtonStyle::Settings,
[] { getApp()->windows->showSettingsDialog(); });
// updates
auto update = this->addTitleBarButton(TitleBarButton::None, [] {});
auto update = this->addTitleBarButton(TitleBarButtonStyle::None, [] {});
initUpdateButton(*update, this->updateDialogHandle_, this->signalHolder_);
initUpdateButton(*update, this->signalHolder_);
// account
this->userLabel_ = this->addTitleBarLabel([this] {
getApp()->windows->showAccountSelectPopup(this->userLabel_->mapToGlobal(
this->userLabel_->rect().bottomLeft())); //
this->userLabel_->rect().bottomLeft()));
});
this->userLabel_->setMinimumWidth(20 * getScale());
}
@@ -252,27 +254,27 @@ void Window::addShortcuts()
// Switch tab
createWindowShortcut(this, "CTRL+T", [this] {
this->notebook_.getOrAddSelectedPage()->appendNewSplit(true);
this->notebook_->getOrAddSelectedPage()->appendNewSplit(true);
});
createWindowShortcut(this, "CTRL+1",
[this] { this->notebook_.selectIndex(0); });
[this] { this->notebook_->selectIndex(0); });
createWindowShortcut(this, "CTRL+2",
[this] { this->notebook_.selectIndex(1); });
[this] { this->notebook_->selectIndex(1); });
createWindowShortcut(this, "CTRL+3",
[this] { this->notebook_.selectIndex(2); });
[this] { this->notebook_->selectIndex(2); });
createWindowShortcut(this, "CTRL+4",
[this] { this->notebook_.selectIndex(3); });
[this] { this->notebook_->selectIndex(3); });
createWindowShortcut(this, "CTRL+5",
[this] { this->notebook_.selectIndex(4); });
[this] { this->notebook_->selectIndex(4); });
createWindowShortcut(this, "CTRL+6",
[this] { this->notebook_.selectIndex(5); });
[this] { this->notebook_->selectIndex(5); });
createWindowShortcut(this, "CTRL+7",
[this] { this->notebook_.selectIndex(6); });
[this] { this->notebook_->selectIndex(6); });
createWindowShortcut(this, "CTRL+8",
[this] { this->notebook_.selectIndex(7); });
[this] { this->notebook_->selectIndex(7); });
createWindowShortcut(this, "CTRL+9",
[this] { this->notebook_.selectIndex(8); });
[this] { this->notebook_->selectIndex(8); });
// Zoom in
{
@@ -296,11 +298,11 @@ void Window::addShortcuts()
// New tab
createWindowShortcut(this, "CTRL+SHIFT+T",
[this] { this->notebook_.addPage(true); });
[this] { this->notebook_->addPage(true); });
// Close tab
createWindowShortcut(this, "CTRL+SHIFT+W",
[this] { this->notebook_.removeCurrentPage(); });
[this] { this->notebook_->removeCurrentPage(); });
}
void Window::onAccountSelected()
+10 -14
View File
@@ -1,13 +1,6 @@
#pragma once
#include "util/Helpers.hpp"
#include "widgets/BaseWindow.hpp"
#include "widgets/Notebook.hpp"
#include "widgets/dialogs/UpdateDialog.hpp"
//#ifdef USEWINSDK
//#include <platform/borderless/qwinwidget.h>
//#endif
#include <pajlada/settings/setting.hpp>
#include <pajlada/signals/signal.hpp>
@@ -16,17 +9,20 @@
namespace chatterino {
class Theme;
class UpdateDialog;
class SplitNotebook;
class Channel;
enum class WindowType { Main, Popup, Attached };
class Window : public BaseWindow
{
Q_OBJECT
public:
enum class Type { Main, Popup, Attached };
explicit Window(WindowType type);
explicit Window(Window::Type type);
Type getType();
WindowType getType();
SplitNotebook &getNotebook();
void repaintVisibleChatWidgets(Channel *channel = nullptr);
@@ -45,11 +41,11 @@ private:
void addLayout();
void onAccountSelected();
Type type_;
WindowType type_;
SplitNotebook notebook_;
SplitNotebook *notebook_;
EffectLabel *userLabel_ = nullptr;
std::unique_ptr<UpdateDialog> updateDialogHandle_;
std::shared_ptr<UpdateDialog> updateDialogHandle_;
pajlada::Signals::SignalHolder signalHolder_;
+3
View File
@@ -3,9 +3,12 @@
#include "Application.hpp"
#include "controllers/accounts/AccountController.hpp"
#include "debug/Benchmark.hpp"
#include "messages/Message.hpp"
#include "messages/MessageBuilder.hpp"
#include "providers/twitch/TwitchChannel.hpp"
#include "singletons/Emotes.hpp"
#include "widgets/Notebook.hpp"
#include "widgets/helper/ChannelView.hpp"
#include <QHBoxLayout>
#include <QShortcut>
+5 -2
View File
@@ -1,13 +1,16 @@
#pragma once
#include "common/Channel.hpp"
#include "widgets/BaseWindow.hpp"
#include "widgets/helper/ChannelView.hpp"
#include <pajlada/signals/signal.hpp>
namespace chatterino {
class Link;
class ChannelView;
class Channel;
using ChannelPtr = std::shared_ptr<Channel>;
class EmotePopup : public BaseWindow
{
public:
+1
View File
@@ -1,5 +1,6 @@
#include "widgets/dialogs/LoginDialog.hpp"
#include "Application.hpp"
#include "common/Common.hpp"
#include "common/NetworkRequest.hpp"
#include "controllers/accounts/AccountController.hpp"
+2
View File
@@ -1,6 +1,7 @@
#include "LogsPopup.hpp"
#include "IrcMessage"
#include "common/Channel.hpp"
#include "common/NetworkRequest.hpp"
#include "providers/twitch/TwitchChannel.hpp"
#include "providers/twitch/TwitchMessageBuilder.hpp"
@@ -14,6 +15,7 @@
namespace chatterino {
LogsPopup::LogsPopup()
: channel_(Channel::getEmpty())
{
this->initLayout();
this->resize(400, 600);
+7 -2
View File
@@ -1,6 +1,5 @@
#pragma once
#include "common/Channel.hpp"
#include "widgets/BaseWindow.hpp"
namespace chatterino {
@@ -8,6 +7,12 @@ namespace chatterino {
class Channel;
class ChannelView;
class Channel;
using ChannelPtr = std::shared_ptr<Channel>;
struct Message;
using MessagePtr = std::shared_ptr<const Message>;
class LogsPopup : public BaseWindow
{
public:
@@ -17,7 +22,7 @@ public:
private:
ChannelView *channelView_ = nullptr;
ChannelPtr channel_ = Channel::getEmpty();
ChannelPtr channel_;
QString userName_;
int roomID_;
@@ -1,5 +1,7 @@
#include "NotificationPopup.hpp"
#include "common/Channel.hpp"
#include "messages/Message.hpp"
#include "widgets/helper/ChannelView.hpp"
#include <QApplication>
+6 -2
View File
@@ -1,13 +1,17 @@
#pragma once
#include "common/Channel.hpp"
#include "messages/Message.hpp"
#include "widgets/BaseWindow.hpp"
namespace chatterino {
class ChannelView;
class Channel;
using ChannelPtr = std::shared_ptr<Channel>;
struct Message;
using MessagePtr = std::shared_ptr<const Message>;
class NotificationPopup : public BaseWindow
{
public:
@@ -2,8 +2,10 @@
#include "Application.hpp"
#include "providers/twitch/TwitchServer.hpp"
#include "singletons/Theme.hpp"
#include "util/LayoutCreator.hpp"
#include "widgets/Notebook.hpp"
#include "widgets/helper/NotebookTab.hpp"
#include <QDialogButtonBox>
#include <QGroupBox>
+4 -2
View File
@@ -1,8 +1,8 @@
#pragma once
#include "Application.hpp"
#include "common/Channel.hpp"
#include "widgets/BaseWindow.hpp"
#include "widgets/Notebook.hpp"
#include <pajlada/signals/signal.hpp>
@@ -11,7 +11,9 @@
namespace chatterino {
class SelectChannelDialog : public BaseWindow
class Notebook;
class SelectChannelDialog final : public BaseWindow
{
public:
SelectChannelDialog(QWidget *parent = nullptr);
+1
View File
@@ -1,6 +1,7 @@
#include "UserInfoPopup.hpp"
#include "Application.hpp"
#include "common/Channel.hpp"
#include "common/NetworkRequest.hpp"
#include "controllers/accounts/AccountController.hpp"
#include "controllers/highlights/HighlightController.hpp"
+2 -1
View File
@@ -1,6 +1,5 @@
#pragma once
#include "common/Channel.hpp"
#include "widgets/BaseWindow.hpp"
#include <pajlada/signals/signal.hpp>
@@ -9,6 +8,8 @@ class QCheckBox;
namespace chatterino {
class Channel;
using ChannelPtr = std::shared_ptr<Channel>;
class Label;
class UserInfoPopup final : public BaseWindow
+48 -41
View File
@@ -1,18 +1,24 @@
#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 "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>
@@ -93,7 +99,7 @@ void addEmoteContextMenuItems(const Emote &emote,
ChannelView::ChannelView(BaseWidget *parent)
: BaseWidget(parent)
, scrollBar_(this)
, scrollBar_(new Scrollbar(this))
{
this->setMouseTracking(true);
@@ -124,7 +130,7 @@ void ChannelView::initializeLayout()
QObject::connect(this->goToBottom_, &EffectLabel::clicked, this, [=] {
QTimer::singleShot(180, [=] {
this->scrollBar_.scrollToBottom(
this->scrollBar_->scrollToBottom(
getApp()
->settings->enableSmoothScrollingNewMessages.getValue());
});
@@ -133,18 +139,18 @@ void ChannelView::initializeLayout()
void ChannelView::initializeScrollbar()
{
this->scrollBar_.getCurrentValueChanged().connect([this] {
this->scrollBar_->getCurrentValueChanged().connect([this] {
this->actuallyLayoutMessages(true);
this->goToBottom_->setVisible(this->enableScrollingToBottom_ &&
this->scrollBar_.isVisible() &&
!this->scrollBar_.isAtBottom());
this->scrollBar_->isVisible() &&
!this->scrollBar_->isAtBottom());
this->queueUpdate();
});
this->scrollBar_.getDesiredValueChanged().connect([this] {
this->pausedByScrollingUp_ = !this->scrollBar_.isAtBottom();
this->scrollBar_->getDesiredValueChanged().connect([this] {
this->pausedByScrollingUp_ = !this->scrollBar_->isAtBottom();
});
}
@@ -212,7 +218,7 @@ void ChannelView::actuallyLayoutMessages(bool causedByScrollbar)
auto messagesSnapshot = this->getMessagesSnapshot();
if (messagesSnapshot.getLength() == 0) {
this->scrollBar_.setVisible(false);
this->scrollBar_->setVisible(false);
return;
}
@@ -225,9 +231,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();
@@ -235,7 +241,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];
@@ -262,8 +268,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;
@@ -271,20 +278,20 @@ 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());
}
@@ -309,7 +316,7 @@ void ChannelView::clearMessages()
Scrollbar &ChannelView::getScrollBar()
{
return this->scrollBar_;
return *this->scrollBar_;
}
QString ChannelView::getSelectedText()
@@ -378,7 +385,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();
}
@@ -413,10 +420,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);
}
// }
}
@@ -431,7 +438,7 @@ void ChannelView::setChannel(ChannelPtr newChannel)
}
}
this->scrollBar_.addHighlight(message->getScrollBarHighlight());
this->scrollBar_->addHighlight(message->getScrollBarHighlight());
this->messageWasAdded_ = true;
this->layoutMessages();
@@ -449,10 +456,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()));
}
}
}
@@ -464,7 +471,7 @@ void ChannelView::setChannel(ChannelPtr newChannel)
messages.at(i)->getScrollBarHighlight());
}
this->scrollBar_.addHighlightsAtStart(highlights);
this->scrollBar_->addHighlightsAtStart(highlights);
this->messageWasAdded_ = true;
this->layoutMessages();
@@ -503,7 +510,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);
@@ -563,12 +570,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();
@@ -625,9 +632,9 @@ bool ChannelView::isPaused()
void ChannelView::updatePauseStatus()
{
if (this->isPaused()) {
this->scrollBar_.pauseHighlights();
this->scrollBar_->pauseHighlights();
} else {
this->scrollBar_.unpauseHighlights();
this->scrollBar_->unpauseHighlights();
}
}
@@ -651,14 +658,14 @@ void ChannelView::drawMessages(QPainter &painter)
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();
@@ -729,12 +736,12 @@ void ChannelView::wheelEvent(QWheelEvent *event)
return;
}
if (this->scrollBar_.isVisible()) {
if (this->scrollBar_->isVisible()) {
auto app = getApp();
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();
@@ -792,7 +799,7 @@ void ChannelView::wheelEvent(QWheelEvent *event)
}
}
this->scrollBar_.setDesiredValue(desired, true);
this->scrollBar_->setDesiredValue(desired, true);
}
}
@@ -1192,14 +1199,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];
@@ -1219,7 +1226,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();
+19 -8
View File
@@ -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/EffectLabel.hpp"
#include <QPaintEvent>
#include <QScroller>
@@ -20,8 +16,23 @@
#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
@@ -121,7 +132,7 @@ private:
ChannelPtr channel_;
Scrollbar scrollBar_;
Scrollbar *scrollBar_;
EffectLabel *goToBottom_;
// This variable can be used to decide whether or not we should render the
+1
View File
@@ -2,6 +2,7 @@
#include "singletons/Theme.hpp"
#include "widgets/Notebook.hpp"
#include "widgets/helper/Button.hpp"
#include "widgets/splits/Split.hpp"
#include "widgets/splits/SplitContainer.hpp"
#include <QMouseEvent>
+2
View File
@@ -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>
@@ -1,7 +1,5 @@
#pragma once
#include <QString>
namespace chatterino {
class ScrollbarHighlight
+1
View File
@@ -6,6 +6,7 @@
#include <QVBoxLayout>
#include "common/Channel.hpp"
#include "messages/Message.hpp"
#include "widgets/helper/ChannelView.hpp"
namespace chatterino {
+3 -1
View File
@@ -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:
+8 -8
View File
@@ -9,12 +9,12 @@ TitleBarButton::TitleBarButton()
{
}
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);
+13 -13
View File
@@ -4,29 +4,29 @@
namespace chatterino {
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
@@ -4,6 +4,7 @@
#include "controllers/accounts/AccountController.hpp"
#include "controllers/ignores/IgnoreController.hpp"
#include "controllers/ignores/IgnoreModel.hpp"
#include "providers/twitch/TwitchAccount.hpp"
#include "singletons/Settings.hpp"
#include "util/LayoutCreator.hpp"
#include "widgets/helper/EditableModelView.hpp"
+5 -1
View File
@@ -1,10 +1,14 @@
#include "LookPage.hpp"
#include "Application.hpp"
#include "messages/Image.hpp"
#include "messages/MessageBuilder.hpp"
#include "singletons/Resources.hpp"
#include "singletons/Theme.hpp"
#include "singletons/WindowManager.hpp"
#include "util/LayoutCreator.hpp"
#include "util/RemoveScrollAreaBackground.hpp"
#include "widgets/helper/ChannelView.hpp"
#include "widgets/helper/Line.hpp"
#include <QFontDialog>
@@ -416,7 +420,7 @@ QLayout *LookPage::createFontChanger()
button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Policy::Fixed);
QObject::connect(button, &QPushButton::clicked, [=]() {
QFontDialog dialog(app->fonts->getFont(Fonts::ChatMedium, 1.));
QFontDialog dialog(app->fonts->getFont(FontStyle::ChatMedium, 1.));
dialog.setWindowFlag(Qt::WindowStaysOnTopHint);
+53 -49
View File
@@ -1,8 +1,8 @@
#include "widgets/splits/Split.hpp"
#include "Application.hpp"
#include "common/Common.hpp"
#include "common/NetworkRequest.hpp"
#include "debug/Log.hpp"
#include "providers/twitch/EmoteValue.hpp"
#include "providers/twitch/TwitchChannel.hpp"
#include "providers/twitch/TwitchMessageBuilder.hpp"
@@ -11,15 +11,20 @@
#include "singletons/Theme.hpp"
#include "singletons/WindowManager.hpp"
#include "util/StreamLink.hpp"
#include "widgets/Notebook.hpp"
#include "widgets/Window.hpp"
#include "widgets/dialogs/QualityPopup.hpp"
#include "widgets/dialogs/SelectChannelDialog.hpp"
#include "widgets/dialogs/TextInputDialog.hpp"
#include "widgets/dialogs/UserInfoPopup.hpp"
#include "widgets/helper/ChannelView.hpp"
#include "widgets/helper/DebugPopup.hpp"
#include "widgets/helper/ResizingTextEdit.hpp"
#include "widgets/helper/SearchPopup.hpp"
#include "widgets/helper/Shortcut.hpp"
#include "widgets/splits/SplitContainer.hpp"
#include "widgets/splits/SplitHeader.hpp"
#include "widgets/splits/SplitInput.hpp"
#include "widgets/splits/SplitOverlay.hpp"
#include <QApplication>
@@ -37,7 +42,6 @@
#include <random>
namespace chatterino {
pajlada::Signals::Signal<Qt::KeyboardModifiers> Split::modifierStatusChanged;
Qt::KeyboardModifiers Split::modifierStatus = Qt::NoModifier;
@@ -51,20 +55,20 @@ Split::Split(QWidget *parent)
: BaseWidget(parent)
, container_(nullptr)
, channel_(Channel::getEmpty())
, vbox_(this)
, header_(this)
, view_(this)
, input_(this)
, vbox_(new QVBoxLayout(this))
, header_(new SplitHeader(this))
, view_(new ChannelView(this))
, input_(new SplitInput(this))
, overlay_(new SplitOverlay(this))
{
this->setMouseTracking(true);
this->vbox_.setSpacing(0);
this->vbox_.setMargin(1);
this->vbox_->setSpacing(0);
this->vbox_->setMargin(1);
this->vbox_.addWidget(&this->header_);
this->vbox_.addWidget(&this->view_, 1);
this->vbox_.addWidget(&this->input_);
this->vbox_->addWidget(this->header_);
this->vbox_->addWidget(this->view_, 1);
this->vbox_->addWidget(this->input_);
// Initialize chat widget-wide hotkeys
// CTRL+W: Close Split
@@ -89,41 +93,41 @@ Split::Split(QWidget *parent)
// CreateShortcut(this, "ALT+SHIFT+UP", &Split::doIncFlexY);
// CreateShortcut(this, "ALT+SHIFT+DOWN", &Split::doDecFlexY);
this->input_.ui_.textEdit->installEventFilter(parent);
this->input_->ui_.textEdit->installEventFilter(parent);
this->view_.mouseDown.connect([this](QMouseEvent *) {
this->view_->mouseDown.connect([this](QMouseEvent *) {
//
this->giveFocus(Qt::MouseFocusReason);
});
this->view_.selectionChanged.connect([this]() {
if (view_.hasSelection()) {
this->input_.clearSelection();
this->view_->selectionChanged.connect([this]() {
if (view_->hasSelection()) {
this->input_->clearSelection();
}
});
this->input_.textChanged.connect([=](const QString &newText) {
this->input_->textChanged.connect([=](const QString &newText) {
if (getSettings()->showEmptyInput) {
return;
}
if (newText.length() == 0) {
this->input_.hide();
} else if (this->input_.isHidden()) {
this->input_.show();
this->input_->hide();
} else if (this->input_->isHidden()) {
this->input_->show();
}
});
getSettings()->showEmptyInput.connect(
[this](const bool &showEmptyInput, auto) {
if (!showEmptyInput && this->input_.getInputText().length() == 0) {
this->input_.hide();
if (!showEmptyInput && this->input_->getInputText().length() == 0) {
this->input_->hide();
} else {
this->input_.show();
this->input_->show();
}
},
this->managedConnections_);
this->header_.updateModerationModeIcon();
this->header_->updateModerationModeIcon();
this->overlay_->hide();
this->setSizePolicy(QSizePolicy::MinimumExpanding,
@@ -139,9 +143,9 @@ Split::Split(QWidget *parent)
}
});
this->input_.ui_.textEdit->focused.connect(
this->input_->ui_.textEdit->focused.connect(
[this] { this->focused.invoke(); });
this->input_.ui_.textEdit->focusLost.connect(
this->input_->ui_.textEdit->focusLost.connect(
[this] { this->focusLost.invoke(); });
}
@@ -155,7 +159,7 @@ Split::~Split()
ChannelView &Split::getChannelView()
{
return this->view_;
return *this->view_;
}
SplitContainer *Split::getContainer()
@@ -187,7 +191,7 @@ void Split::setChannel(IndirectChannel newChannel)
{
this->channel_ = newChannel;
this->view_.setChannel(newChannel.get());
this->view_->setChannel(newChannel.get());
this->usermodeChangedConnection_.disconnect();
this->roomModeChangedConnection_.disconnect();
@@ -197,12 +201,12 @@ void Split::setChannel(IndirectChannel newChannel)
if (tc != nullptr) {
this->usermodeChangedConnection_ = tc->userStateChanged.connect([this] {
this->header_.updateModerationModeIcon();
this->header_.updateRoomModes();
this->header_->updateModerationModeIcon();
this->header_->updateRoomModes();
});
this->roomModeChangedConnection_ = tc->roomModesChanged.connect(
[this] { this->header_.updateRoomModes(); });
[this] { this->header_->updateRoomModes(); });
}
this->indirectChannelChangedConnection_ =
@@ -210,9 +214,9 @@ void Split::setChannel(IndirectChannel newChannel)
QTimer::singleShot(0, [this] { this->setChannel(this->channel_); });
});
this->header_.updateModerationModeIcon();
this->header_.updateChannelText();
this->header_.updateRoomModes();
this->header_->updateModerationModeIcon();
this->header_->updateChannelText();
this->header_->updateRoomModes();
this->channelChanged.invoke();
}
@@ -221,8 +225,8 @@ void Split::setModerationMode(bool value)
{
if (value != this->moderationMode_) {
this->moderationMode_ = value;
this->header_.updateModerationModeIcon();
this->view_.layoutMessages();
this->header_->updateModerationModeIcon();
this->view_->layoutMessages();
}
}
@@ -233,7 +237,7 @@ bool Split::getModerationMode() const
void Split::insertTextToInput(const QString &text)
{
this->input_.insertText(text);
this->input_->insertText(text);
}
void Split::showChangeChannelPopup(const char *dialogTitle, bool empty,
@@ -267,27 +271,27 @@ void Split::showChangeChannelPopup(const char *dialogTitle, bool empty,
void Split::layoutMessages()
{
this->view_.layoutMessages();
this->view_->layoutMessages();
}
void Split::updateGifEmotes()
{
this->view_.queueUpdate();
this->view_->queueUpdate();
}
void Split::updateLastReadMessage()
{
this->view_.updateLastReadMessage();
this->view_->updateLastReadMessage();
}
void Split::giveFocus(Qt::FocusReason reason)
{
this->input_.ui_.textEdit->setFocus(reason);
this->input_->ui_.textEdit->setFocus(reason);
}
bool Split::hasFocus() const
{
return this->input_.ui_.textEdit->hasFocus();
return this->input_->ui_.textEdit->hasFocus();
}
void Split::paintEvent(QPaintEvent *)
@@ -305,13 +309,13 @@ void Split::mouseMoveEvent(QMouseEvent *event)
void Split::keyPressEvent(QKeyEvent *event)
{
this->view_.unsetCursor();
this->view_->unsetCursor();
this->handleModifiers(QGuiApplication::queryKeyboardModifiers());
}
void Split::keyReleaseEvent(QKeyEvent *event)
{
this->view_.unsetCursor();
this->view_->unsetCursor();
this->handleModifiers(QGuiApplication::queryKeyboardModifiers());
}
@@ -389,7 +393,7 @@ void Split::changeChannel()
void Split::popup()
{
auto app = getApp();
Window &window = app->windows->createWindow(Window::Type::Popup);
Window &window = app->windows->createWindow(WindowType::Popup);
Split *split = new Split(static_cast<SplitContainer *>(
window.getNotebook().getOrAddSelectedPage()));
@@ -402,7 +406,7 @@ void Split::popup()
void Split::clear()
{
this->view_.clearMessages();
this->view_->clearMessages();
}
void Split::openInBrowser()
@@ -442,8 +446,8 @@ void Split::showViewerList()
QDockWidget::DockWidgetFloatable);
viewerDock->resize(
0.5 * this->width(),
this->height() - this->header_.height() - this->input_.height());
viewerDock->move(0, this->header_.height());
this->height() - this->header_->height() - this->input_->height());
viewerDock->move(0, this->header_->height());
auto multiWidget = new QWidget(viewerDock);
auto dockVbox = new QVBoxLayout(viewerDock);
@@ -543,7 +547,7 @@ void Split::showUserInfoPopup(const UserName &user)
void Split::copyToClipboard()
{
QApplication::clipboard()->setText(this->view_.getSelectedText());
QApplication::clipboard()->setText(this->view_->getSelectedText());
}
void Split::showSearch()
+8 -13
View File
@@ -1,17 +1,9 @@
#pragma once
#include "common/Aliases.hpp"
#include "common/Channel.hpp"
#include "common/NullablePtr.hpp"
#include "messages/LimitedQueueSnapshot.hpp"
#include "messages/MessageElement.hpp"
#include "messages/layouts/MessageLayout.hpp"
#include "messages/layouts/MessageLayoutElement.hpp"
#include "util/RapidJsonSerializeQString.hpp"
#include "widgets/BaseWidget.hpp"
#include "widgets/helper/ChannelView.hpp"
#include "widgets/helper/EffectLabel.hpp"
#include "widgets/splits/SplitHeader.hpp"
#include "widgets/splits/SplitInput.hpp"
#include <QFont>
#include <QShortcut>
@@ -20,6 +12,9 @@
namespace chatterino {
class ChannelView;
class SplitHeader;
class SplitInput;
class SplitContainer;
class SplitOverlay;
class SelectChannelDialog;
@@ -103,10 +98,10 @@ private:
SplitContainer *container_;
IndirectChannel channel_;
QVBoxLayout vbox_;
SplitHeader header_;
ChannelView view_;
SplitInput input_;
QVBoxLayout *vbox_;
SplitHeader *header_;
ChannelView *view_;
SplitInput *input_;
SplitOverlay *overlay_;
NullablePtr<SelectChannelDialog> selectChannelDialog_;
+1
View File
@@ -7,6 +7,7 @@
#include "util/Helpers.hpp"
#include "util/LayoutCreator.hpp"
#include "widgets/Notebook.hpp"
#include "widgets/helper/ChannelView.hpp"
#include "widgets/helper/NotebookTab.hpp"
#include "widgets/splits/Split.hpp"
+6 -5
View File
@@ -1,8 +1,6 @@
#pragma once
#include "widgets/BaseWidget.hpp"
#include "widgets/helper/NotebookTab.hpp"
#include "widgets/splits/Split.hpp"
#include <QDragEnterEvent>
#include <QHBoxLayout>
@@ -13,21 +11,24 @@
#include <algorithm>
#include <functional>
#include <vector>
#include <pajlada/signals/signal.hpp>
#include <pajlada/signals/signalholder.hpp>
#include <vector>
class QJsonObject;
namespace chatterino {
class Split;
class NotebookTab;
class Notebook;
//
// Note: This class is a spaghetti container. There is a lot of spaghetti code
// inside but it doesn't expose any of it publicly.
//
class SplitContainer : public BaseWidget, pajlada::Signals::SignalHolder
class SplitContainer final : public BaseWidget, pajlada::Signals::SignalHolder
{
Q_OBJECT
+3
View File
@@ -5,17 +5,20 @@
#include "providers/twitch/TwitchChannel.hpp"
#include "providers/twitch/TwitchServer.hpp"
#include "singletons/Resources.hpp"
#include "singletons/Settings.hpp"
#include "singletons/Theme.hpp"
#include "util/LayoutCreator.hpp"
#include "util/LayoutHelper.hpp"
#include "widgets/Label.hpp"
#include "widgets/TooltipWidget.hpp"
#include "widgets/helper/EffectLabel.hpp"
#include "widgets/splits/Split.hpp"
#include "widgets/splits/SplitContainer.hpp"
#include <QByteArray>
#include <QDesktopWidget>
#include <QDrag>
#include <QHBoxLayout>
#include <QInputDialog>
#include <QMenu>
#include <QMimeData>
+10 -4
View File
@@ -2,14 +2,20 @@
#include "Application.hpp"
#include "controllers/commands/CommandController.hpp"
#include "messages/Link.hpp"
#include "providers/twitch/TwitchChannel.hpp"
#include "providers/twitch/TwitchServer.hpp"
#include "singletons/Settings.hpp"
#include "singletons/Theme.hpp"
#include "util/LayoutCreator.hpp"
#include "widgets/Notebook.hpp"
#include "widgets/dialogs/EmotePopup.hpp"
#include "widgets/helper/ChannelView.hpp"
#include "widgets/helper/EffectLabel.hpp"
#include "widgets/helper/ResizingTextEdit.hpp"
#include "widgets/splits/Split.hpp"
#include "widgets/splits/SplitContainer.hpp"
#include "widgets/splits/SplitInput.hpp"
#include <QCompleter>
#include <QPainter>
@@ -70,11 +76,11 @@ void SplitInput::initLayout()
// set edit font
this->ui_.textEdit->setFont(
app->fonts->getFont(Fonts::Type::ChatMedium, this->getScale()));
app->fonts->getFont(FontStyle::ChatMedium, this->getScale()));
this->managedConnections_.push_back(app->fonts->fontChanged.connect([=]() {
this->ui_.textEdit->setFont(
app->fonts->getFont(Fonts::Type::ChatMedium, this->getScale()));
app->fonts->getFont(FontStyle::ChatMedium, this->getScale()));
}));
// open emote popup
@@ -98,7 +104,7 @@ void SplitInput::initLayout()
QObject::connect(this->ui_.textEdit, &QTextEdit::copyAvailable,
[this](bool available) {
if (available) {
this->split_->view_.clearSelection();
this->split_->view_->clearSelection();
}
});
@@ -273,7 +279,7 @@ void SplitInput::installKeyPressedEvent()
}
} else if (event->key() == Qt::Key_C &&
event->modifiers() == Qt::ControlModifier) {
if (this->split_->view_.hasSelection()) {
if (this->split_->view_->hasSelection()) {
this->split_->copyToClipboard();
event->accept();
}
+4 -4
View File
@@ -1,9 +1,6 @@
#pragma once
#include "widgets/BaseWidget.hpp"
#include "widgets/dialogs/EmotePopup.hpp"
#include "widgets/helper/ResizingTextEdit.hpp"
#include "widgets/helper/EffectLabel.hpp"
#include <QHBoxLayout>
#include <QLabel>
@@ -16,6 +13,9 @@
namespace chatterino {
class Split;
class EmotePopup;
class EffectLabel;
class ResizingTextEdit;
class SplitInput : public BaseWidget
{
@@ -45,7 +45,7 @@ private:
void updateEmoteButton();
Split *const split_;
std::unique_ptr<EmotePopup> emotePopup_;
std::shared_ptr<EmotePopup> emotePopup_;
struct {
ResizingTextEdit *textEdit;
+1
View File
@@ -10,6 +10,7 @@
#include "Application.hpp"
#include "singletons/Resources.hpp"
#include "singletons/Theme.hpp"
#include "widgets/splits/Split.hpp"
#include "widgets/splits/SplitContainer.hpp"