turning a lot of includes into forward declares
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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_;
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user