renamed a bunch of files and classes

This commit is contained in:
2017-11-12 17:21:50 +01:00
parent ad8ee97de9
commit 7f18cefee4
44 changed files with 699 additions and 505 deletions

View file

@ -1,225 +1,230 @@
#-------------------------------------------------
#
# Project created by QtCreator 2016-12-28T18:23:35
#
#-------------------------------------------------
QT += core gui network multimedia
CONFIG += communi
COMMUNI += core model util
CONFIG += c++14
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
# Include ourself
INCLUDEPATH += src/
TARGET = chatterino
TEMPLATE = app
DEFINES += QT_DEPRECATED_WARNINGS
# Define warning flags for Chatterino
win32-msvc* {
QMAKE_CXXFLAGS_WARN_ON = -W4
# 4714 - function marked as __forceinline not inlined
# 4996 - occurs when the compiler encounters a function or variable that is marked as deprecated.
# These functions may have a different preferred name, may be insecure or have
# a more secure variant, or may be obsolete.
QMAKE_CXXFLAGS_WARN_ON += /wd4714
QMAKE_CXXFLAGS_WARN_ON += /wd4996
} else {
QMAKE_CXXFLAGS_WARN_ON = -Wall
QMAKE_CXXFLAGS_WARN_ON += -Wno-unused-function
QMAKE_CXXFLAGS_WARN_ON += -Wno-switch
QMAKE_CXXFLAGS_WARN_ON += -Wno-deprecated-declarations
}
# do not use windows min/max macros
win32 {
DEFINES += NOMINMAX
}
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
src/main.cpp \
src/application.cpp \
src/channel.cpp \
src/channeldata.cpp \
src/colorscheme.cpp \
src/ircmanager.cpp \
src/messages/lazyloadedimage.cpp \
src/messages/link.cpp \
src/messages/message.cpp \
src/messages/word.cpp \
src/messages/wordpart.cpp \
src/resources.cpp \
src/widgets/chatwidget.cpp \
src/widgets/chatwidgetheader.cpp \
src/widgets/chatwidgetinput.cpp \
src/widgets/mainwindow.cpp \
src/widgets/notebook.cpp \
src/widgets/notebookbutton.cpp \
src/widgets/notebookpage.cpp \
src/widgets/notebookpagedroppreview.cpp \
src/widgets/notebooktab.cpp \
src/widgets/scrollbar.cpp \
src/widgets/scrollbarhighlight.cpp \
src/widgets/settingsdialog.cpp \
src/widgets/settingsdialogtab.cpp \
src/widgets/textinputdialog.cpp \
src/messages/messageref.cpp \
src/logging/loggingmanager.cpp \
src/logging/loggingchannel.cpp \
src/windowmanager.cpp \
src/channelmanager.cpp \
src/fontmanager.cpp \
src/settingsmanager.cpp \
src/emotemanager.cpp \
src/messages/messagebuilder.cpp \
src/twitch/twitchmessagebuilder.cpp \
src/twitch/twitchparsemessage.cpp \
src/widgets/titlebar.cpp \
src/appdatapath.cpp \
src/accountmanager.cpp \
src/twitch/twitchuser.cpp \
src/ircaccount.cpp \
src/widgets/accountpopup.cpp \
src/widgets/basewidget.cpp \
src/widgets/resizingtextedit.cpp \
src/completionmanager.cpp \
src/widgets/logindialog.cpp \
src/widgets/qualitypopup.cpp \
src/widgets/emotepopup.cpp \
src/widgets/channelview.cpp \
src/twitch/twitchchannel.cpp \
src/widgets/rippleeffectlabel.cpp \
src/widgets/rippleeffectbutton.cpp \
src/messages/messagecolor.cpp \
src/util/networkmanager.cpp
HEADERS += \
src/asyncexec.hpp \
src/channel.hpp \
src/colorscheme.hpp \
src/concurrentmap.hpp \
src/emojis.hpp \
src/ircmanager.hpp \
src/messages/lazyloadedimage.hpp \
src/messages/link.hpp \
src/messages/message.hpp \
src/messages/word.hpp \
src/messages/wordpart.hpp \
src/resources.hpp \
src/setting.hpp \
src/twitch/emotevalue.hpp \
src/widgets/chatwidget.hpp \
src/widgets/chatwidgetheader.hpp \
src/widgets/chatwidgetinput.hpp \
src/widgets/mainwindow.hpp \
src/widgets/notebook.hpp \
src/widgets/notebookbutton.hpp \
src/widgets/notebookpage.hpp \
src/widgets/notebookpagedroppreview.hpp \
src/widgets/notebooktab.hpp \
src/widgets/scrollbar.hpp \
src/widgets/scrollbarhighlight.hpp \
src/widgets/settingsdialog.hpp \
src/widgets/settingsdialogtab.hpp \
src/widgets/signallabel.hpp \
src/widgets/textinputdialog.hpp \
src/widgets/resizingtextedit.hpp \
src/settingssnapshot.hpp \
src/messages/limitedqueue.hpp \
src/messages/limitedqueuesnapshot.hpp \
src/messages/messageref.hpp \
src/logging/loggingmanager.hpp \
src/logging/loggingchannel.hpp \
src/channelmanager.hpp \
src/windowmanager.hpp \
src/settingsmanager.hpp \
src/fontmanager.hpp \
src/emotemanager.hpp \
src/util/urlfetch.hpp \
src/messages/messageparseargs.hpp \
src/messages/messagebuilder.hpp \
src/twitch/twitchmessagebuilder.hpp \
src/twitch/twitchparsemessage.hpp \
src/widgets/titlebar.hpp \
src/appdatapath.hpp \
src/accountmanager.hpp \
src/twitch/twitchuser.hpp \
src/ircaccount.hpp \
src/widgets/accountpopup.hpp \
src/util/distancebetweenpoints.hpp \
src/widgets/basewidget.hpp \
src/completionmanager.hpp \
src/widgets/channelview.hpp \
src/twitch/twitchchannel.hpp \
src/widgets/rippleeffectbutton.hpp \
src/widgets/rippleeffectlabel.hpp \
src/widgets/qualitypopup.hpp \
src/widgets/emotepopup.hpp \
src/messages/messagecolor.hpp \
src/util/nativeeventhelper.hpp \
src/debug/log.hpp \
src/util/benchmark.hpp \
src/util/networkmanager.hpp
PRECOMPILED_HEADER =
RESOURCES += \
resources/resources.qrc
DISTFILES +=
# Include boost
win32 {
INCLUDEPATH += C:\local\boost\
}
win32 {
LIBS += -luser32
LIBS += -lgdi32
}
# Optional dependency on windows sdk 7.1
win32:exists(C:\Program Files\Microsoft SDKs\Windows\v7.1\Include\Windows.h) {
LIBS += -L"C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib" \
-ldwmapi \
-lgdi32
# SOURCES += platform/borderless/qwinwidget.cpp \
# platform/borderless/winnativewindow.cpp \
# platform/borderless/widget.cpp
# HEADERS += platform/borderless/qwinwidget.h \
# platform/borderless/winnativewindow.h \
# platform/borderless/widget.h
DEFINES += "USEWINSDK"
}
macx {
INCLUDEPATH += /usr/local/include
}
FORMS += \
forms/accountpopupform.ui
werr {
QMAKE_CXXFLAGS += -Werror
message("Enabling error on warning")
}
# External dependencies
include(dependencies/rapidjson.pri)
include(dependencies/settings.pri)
include(dependencies/signals.pri)
include(dependencies/humanize.pri)
include(dependencies/fmt.pri)
DEFINES += IRC_NAMESPACE=Communi
include(dependencies/libcommuni.pri)
#-------------------------------------------------
#
# Project created by QtCreator 2016-12-28T18:23:35
#
#-------------------------------------------------
QT += core gui network multimedia
CONFIG += communi
COMMUNI += core model util
CONFIG += c++14
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
# Include ourself
INCLUDEPATH += src/
TARGET = chatterino
TEMPLATE = app
DEFINES += QT_DEPRECATED_WARNINGS
# Define warning flags for Chatterino
win32-msvc* {
QMAKE_CXXFLAGS_WARN_ON = -W4
# 4714 - function marked as __forceinline not inlined
# 4996 - occurs when the compiler encounters a function or variable that is marked as deprecated.
# These functions may have a different preferred name, may be insecure or have
# a more secure variant, or may be obsolete.
QMAKE_CXXFLAGS_WARN_ON += /wd4714
QMAKE_CXXFLAGS_WARN_ON += /wd4996
} else {
QMAKE_CXXFLAGS_WARN_ON = -Wall
QMAKE_CXXFLAGS_WARN_ON += -Wno-unused-function
QMAKE_CXXFLAGS_WARN_ON += -Wno-switch
QMAKE_CXXFLAGS_WARN_ON += -Wno-deprecated-declarations
}
# do not use windows min/max macros
win32 {
DEFINES += NOMINMAX
}
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
src/main.cpp \
src/application.cpp \
src/channel.cpp \
src/channeldata.cpp \
src/colorscheme.cpp \
src/ircmanager.cpp \
src/messages/lazyloadedimage.cpp \
src/messages/link.cpp \
src/messages/message.cpp \
src/messages/word.cpp \
src/messages/wordpart.cpp \
src/resources.cpp \
src/widgets/notebook.cpp \
src/widgets/helper/notebookbutton.cpp \
src/widgets/helper/notebooktab.cpp \
src/widgets/scrollbar.cpp \
src/widgets/helper/scrollbarhighlight.cpp \
src/widgets/settingsdialog.cpp \
src/widgets/helper/settingsdialogtab.cpp \
src/widgets/textinputdialog.cpp \
src/messages/messageref.cpp \
src/logging/loggingmanager.cpp \
src/logging/loggingchannel.cpp \
src/windowmanager.cpp \
src/channelmanager.cpp \
src/fontmanager.cpp \
src/settingsmanager.cpp \
src/emotemanager.cpp \
src/messages/messagebuilder.cpp \
src/twitch/twitchmessagebuilder.cpp \
src/twitch/twitchparsemessage.cpp \
src/widgets/titlebar.cpp \
src/appdatapath.cpp \
src/accountmanager.cpp \
src/twitch/twitchuser.cpp \
src/ircaccount.cpp \
src/widgets/accountpopup.cpp \
src/widgets/basewidget.cpp \
src/widgets/helper/resizingtextedit.cpp \
src/completionmanager.cpp \
src/widgets/logindialog.cpp \
src/widgets/qualitypopup.cpp \
src/widgets/emotepopup.cpp \
src/widgets/helper/channelview.cpp \
src/twitch/twitchchannel.cpp \
src/widgets/helper/rippleeffectlabel.cpp \
src/widgets/helper/rippleeffectbutton.cpp \
src/messages/messagecolor.cpp \
src/util/networkmanager.cpp \
src/commandmanager.cpp \
src/widgets/split.cpp \
src/widgets/helper/splitinput.cpp \
src/widgets/helper/splitheader.cpp \
src/widgets/splitcontainer.cpp \
src/widgets/helper/droppreview.cpp \
src/widgets/window.cpp \
src/widgets/helper/splitcolumn.cpp
HEADERS += \
src/asyncexec.hpp \
src/channel.hpp \
src/colorscheme.hpp \
src/concurrentmap.hpp \
src/emojis.hpp \
src/ircmanager.hpp \
src/messages/lazyloadedimage.hpp \
src/messages/link.hpp \
src/messages/message.hpp \
src/messages/word.hpp \
src/messages/wordpart.hpp \
src/resources.hpp \
src/setting.hpp \
src/twitch/emotevalue.hpp \
src/widgets/notebook.hpp \
src/widgets/helper/notebookbutton.hpp \
src/widgets/helper/notebooktab.hpp \
src/widgets/scrollbar.hpp \
src/widgets/helper/scrollbarhighlight.hpp \
src/widgets/settingsdialog.hpp \
src/widgets/helper/settingsdialogtab.hpp \
src/widgets/helper/signallabel.hpp \
src/widgets/textinputdialog.hpp \
src/widgets/helper/resizingtextedit.hpp \
src/settingssnapshot.hpp \
src/messages/limitedqueue.hpp \
src/messages/limitedqueuesnapshot.hpp \
src/messages/messageref.hpp \
src/logging/loggingmanager.hpp \
src/logging/loggingchannel.hpp \
src/channelmanager.hpp \
src/windowmanager.hpp \
src/settingsmanager.hpp \
src/fontmanager.hpp \
src/emotemanager.hpp \
src/util/urlfetch.hpp \
src/messages/messageparseargs.hpp \
src/messages/messagebuilder.hpp \
src/twitch/twitchmessagebuilder.hpp \
src/twitch/twitchparsemessage.hpp \
src/widgets/titlebar.hpp \
src/appdatapath.hpp \
src/accountmanager.hpp \
src/twitch/twitchuser.hpp \
src/ircaccount.hpp \
src/widgets/accountpopup.hpp \
src/util/distancebetweenpoints.hpp \
src/widgets/basewidget.hpp \
src/completionmanager.hpp \
src/widgets/helper/channelview.hpp \
src/twitch/twitchchannel.hpp \
src/widgets/helper/rippleeffectbutton.hpp \
src/widgets/helper/rippleeffectlabel.hpp \
src/widgets/qualitypopup.hpp \
src/widgets/emotepopup.hpp \
src/messages/messagecolor.hpp \
src/util/nativeeventhelper.hpp \
src/debug/log.hpp \
src/util/benchmark.hpp \
src/util/networkmanager.hpp \
src/commandmanager.hpp \
src/widgets/split.hpp \
src/widgets/helper/splitheader.hpp \
src/widgets/helper/splitinput.hpp \
src/widgets/window.hpp \
src/widgets/splitcontainer.hpp \
src/widgets/helper/droppreview.hpp \
src/widgets/helper/splitcolumn.hpp
PRECOMPILED_HEADER =
RESOURCES += \
resources/resources.qrc
DISTFILES +=
# Include boost
win32 {
INCLUDEPATH += C:\local\boost\
}
win32 {
LIBS += -luser32
LIBS += -lgdi32
}
# Optional dependency on windows sdk 7.1
win32:exists(C:\Program Files\Microsoft SDKs\Windows\v7.1\Include\Windows.h) {
LIBS += -L"C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib" \
-ldwmapi \
-lgdi32
# SOURCES += platform/borderless/qwinwidget.cpp \
# platform/borderless/winnativewindow.cpp \
# platform/borderless/widget.cpp
# HEADERS += platform/borderless/qwinwidget.h \
# platform/borderless/winnativewindow.h \
# platform/borderless/widget.h
DEFINES += "USEWINSDK"
}
macx {
INCLUDEPATH += /usr/local/include
}
FORMS += \
forms/accountpopupform.ui
werr {
QMAKE_CXXFLAGS += -Werror
message("Enabling error on warning")
}
# External dependencies
include(dependencies/rapidjson.pri)
include(dependencies/settings.pri)
include(dependencies/signals.pri)
include(dependencies/humanize.pri)
include(dependencies/fmt.pri)
DEFINES += IRC_NAMESPACE=Communi
include(dependencies/libcommuni.pri)

42
src/commandmanager.cpp Normal file
View file

@ -0,0 +1,42 @@
#include "commandmanager.hpp"
#include "windowmanager.hpp"
namespace chatterino {
void CommandManager::execCommand(QString command)
{
if (command == "selectr") {
selectSplitRelative(1, 0);
}
if (command == "selectl") {
selectSplitRelative(-1, 0);
}
if (command == "selectu") {
selectSplitRelative(0, -1);
}
if (command == "selectd") {
selectSplitRelative(0, 1);
}
if (command == "mover") {
moveSplitRelative(1, 0);
}
if (command == "movel") {
moveSplitRelative(-1, 0);
}
if (command == "moveu") {
moveSplitRelative(0, -1);
}
if (command == "moved") {
moveSplitRelative(0, 1);
}
}
void CommandManager::selectSplitRelative(int dx, int dy)
{
WindowManager::instance->getCurrentWindow().getNotebook().getSelectedPage();
}
void CommandManager::moveSplitRelative(int dx, int dy)
{
}
}

15
src/commandmanager.hpp Normal file
View file

@ -0,0 +1,15 @@
#pragma once
#include <QString>
namespace chatterino {
class CommandManager
{
public:
CommandManager() = delete;
void execCommand(QString command);
void selectSplitRelative(int dx, int dy);
void moveSplitRelative(int dx, int dy);
};
}

View file

@ -3,7 +3,7 @@
#include "channel.hpp"
#include "emotemanager.hpp"
#include "widgets/basewidget.hpp"
#include "widgets/channelview.hpp"
#include "widgets/helper/channelview.hpp"
namespace chatterino {
namespace widgets {

View file

@ -0,0 +1 @@
../.clang-format

View file

@ -1,4 +1,4 @@
#include "widgets/channelview.hpp"
#include "widgets/helper/channelview.hpp"
#include "channelmanager.hpp"
#include "colorscheme.hpp"
#include "debug/log.hpp"
@ -9,7 +9,7 @@
#include "ui_accountpopupform.h"
#include "util/benchmark.hpp"
#include "util/distancebetweenpoints.hpp"
#include "widgets/chatwidget.hpp"
#include "widgets/split.hpp"
#include "windowmanager.hpp"
#include <QDebug>
@ -240,8 +240,9 @@ QString ChannelView::getSelectedText()
if (first) {
first = false;
bool isSingleWord = isSingleMessage && this->selection.max.charIndex - charIndex <
part.getCharacterLength();
bool isSingleWord =
isSingleMessage &&
this->selection.max.charIndex - charIndex < part.getCharacterLength();
if (isSingleWord) {
// return single word
@ -518,9 +519,10 @@ void ChannelView::updateMessageBuffer(messages::MessageRef *messageRef, QPixmap
// this->selectionMax.messageIndex >= messageIndex) {
// painter.fillRect(buffer->rect(), QColor(24, 55, 25));
//} else {
painter.fillRect(buffer->rect(), (messageRef->getMessage()->getCanHighlightTab())
? this->colorScheme.ChatBackgroundHighlighted
: this->colorScheme.ChatBackground);
painter.fillRect(buffer->rect(),
(messageRef->getMessage()->getCanHighlightTab())
? this->colorScheme.ChatBackgroundHighlighted
: this->colorScheme.ChatBackground);
//}
// draw selection

View file

@ -7,7 +7,7 @@
#include "messages/word.hpp"
#include "widgets/accountpopup.hpp"
#include "widgets/basewidget.hpp"
#include "widgets/rippleeffectlabel.hpp"
#include "widgets/helper/rippleeffectlabel.hpp"
#include "widgets/scrollbar.hpp"
#include <QPaintEvent>

View file

@ -1,4 +1,4 @@
#include "widgets/notebookpagedroppreview.hpp"
#include "widgets/helper/droppreview.hpp"
#include "colorscheme.hpp"
#include <QDebug>

View file

@ -1,6 +1,6 @@
#include "widgets/notebookbutton.hpp"
#include "widgets/helper/notebookbutton.hpp"
#include "colorscheme.hpp"
#include "widgets/rippleeffectbutton.hpp"
#include "widgets/helper/rippleeffectbutton.hpp"
#include <QMouseEvent>
#include <QPainter>

View file

@ -1,4 +1,4 @@
#include "widgets/notebooktab.hpp"
#include "widgets/helper/notebooktab.hpp"
#include "colorscheme.hpp"
#include "settingsmanager.hpp"
#include "widgets/notebook.hpp"
@ -279,7 +279,7 @@ void NotebookTab::mouseMoveEvent(QMouseEvent *event)
QPoint relPoint = this->mapToParent(event->pos());
int index;
NotebookPage *clickedPage = notebook->tabAt(relPoint, index);
SplitContainer *clickedPage = notebook->tabAt(relPoint, index);
if (clickedPage != nullptr && clickedPage != this->page) {
this->notebook->rearrangePage(clickedPage, index);

View file

@ -15,7 +15,7 @@ class ColorScheme;
namespace widgets {
class Notebook;
class NotebookPage;
class SplitContainer;
class NotebookTab : public BaseWidget
{
@ -29,7 +29,7 @@ public:
void calcSize();
NotebookPage *page;
SplitContainer *page;
const QString &getTitle() const;
void setTitle(const QString &newTitle);

View file

@ -1,4 +1,4 @@
#include "widgets/resizingtextedit.hpp"
#include "widgets/helper/resizingtextedit.hpp"
ResizingTextEdit::ResizingTextEdit()
{

View file

@ -1,6 +1,6 @@
#include "widgets/rippleeffectlabel.hpp"
#include "widgets/helper/rippleeffectlabel.hpp"
#include "colorscheme.hpp"
#include "widgets/chatwidgetheader.hpp"
#include "widgets/helper/splitheader.hpp"
#include <QBrush>
#include <QPainter>

View file

@ -1,8 +1,8 @@
#pragma once
#include "widgets/basewidget.hpp"
#include "widgets/rippleeffectbutton.hpp"
#include "widgets/signallabel.hpp"
#include "widgets/helper/rippleeffectbutton.hpp"
#include "widgets/helper/signallabel.hpp"
#include <QHBoxLayout>
#include <QLabel>

View file

@ -1,4 +1,4 @@
#include "widgets/scrollbarhighlight.hpp"
#include "widgets/helper/scrollbarhighlight.hpp"
#include "colorscheme.hpp"
#include "widgets/scrollbar.hpp"

View file

@ -1,4 +1,4 @@
#include "widgets/settingsdialogtab.hpp"
#include "widgets/helper/settingsdialogtab.hpp"
#include "widgets/settingsdialog.hpp"
#include <QPainter>

View file

@ -0,0 +1,9 @@
#include "splitcolumn.hpp"
namespace chatterino {
namespace helper {
SplitColumn::SplitColumn()
{
}
}
}

View file

@ -0,0 +1,23 @@
#pragma once
#include <vector>
#include "widgets/split.hpp"
namespace chatterino {
namespace helper {
class SplitColumn
{
public:
SplitColumn();
void insert(widgets::Split *split, int index = -1);
void remove(int index);
double getFlex();
void setFlex(double flex);
private:
std::vector<widgets::Split> items;
};
}
}

View file

@ -1,9 +1,9 @@
#include "widgets/chatwidgetheader.hpp"
#include "widgets/helper/splitheader.hpp"
#include "colorscheme.hpp"
#include "twitch/twitchchannel.hpp"
#include "util/urlfetch.hpp"
#include "widgets/chatwidget.hpp"
#include "widgets/notebookpage.hpp"
#include "widgets/split.hpp"
#include "widgets/splitcontainer.hpp"
#include <QByteArray>
#include <QDrag>
@ -13,7 +13,7 @@
namespace chatterino {
namespace widgets {
ChatWidgetHeader::ChatWidgetHeader(ChatWidget *_chatWidget)
SplitHeader::SplitHeader(Split *_chatWidget)
: BaseWidget(_chatWidget)
, chatWidget(_chatWidget)
, leftLabel(this)
@ -35,23 +35,22 @@ ChatWidgetHeader::ChatWidgetHeader(ChatWidget *_chatWidget)
this->leftLabel.getLabel().setTextFormat(Qt::RichText);
this->leftLabel.getLabel().setText("<img src=':/images/tool_moreCollapser_off16.png' />");
connect(&this->leftLabel, &RippleEffectLabel::clicked, this,
&ChatWidgetHeader::leftButtonClicked);
connect(&this->leftLabel, &RippleEffectLabel::clicked, this, &SplitHeader::leftButtonClicked);
this->leftMenu.addAction("Add new split", this->chatWidget, &ChatWidget::doAddSplit,
this->leftMenu.addAction("Add new split", this->chatWidget, &Split::doAddSplit,
QKeySequence(tr("Ctrl+T")));
this->leftMenu.addAction("Close split", this->chatWidget, &ChatWidget::doCloseSplit,
this->leftMenu.addAction("Close split", this->chatWidget, &Split::doCloseSplit,
QKeySequence(tr("Ctrl+W")));
this->leftMenu.addAction("Move split", this, SLOT(menuMoveSplit()));
this->leftMenu.addAction("Popup", this->chatWidget, &ChatWidget::doPopup);
this->leftMenu.addAction("Open viewer list", this->chatWidget, &ChatWidget::doOpenViewerList);
this->leftMenu.addAction("Popup", this->chatWidget, &Split::doPopup);
this->leftMenu.addAction("Open viewer list", this->chatWidget, &Split::doOpenViewerList);
this->leftMenu.addSeparator();
this->leftMenu.addAction("Change channel", this->chatWidget, &ChatWidget::doChangeChannel,
this->leftMenu.addAction("Change channel", this->chatWidget, &Split::doChangeChannel,
QKeySequence(tr("Ctrl+R")));
this->leftMenu.addAction("Clear chat", this->chatWidget, &ChatWidget::doClearChat);
this->leftMenu.addAction("Open channel", this->chatWidget, &ChatWidget::doOpenChannel);
this->leftMenu.addAction("Open popup player", this->chatWidget, &ChatWidget::doOpenPopupPlayer);
this->leftMenu.addAction("Open in Streamlink", this->chatWidget, &ChatWidget::doOpenStreamlink);
this->leftMenu.addAction("Clear chat", this->chatWidget, &Split::doClearChat);
this->leftMenu.addAction("Open channel", this->chatWidget, &Split::doOpenChannel);
this->leftMenu.addAction("Open popup player", this->chatWidget, &Split::doOpenPopupPlayer);
this->leftMenu.addAction("Open in Streamlink", this->chatWidget, &Split::doOpenStreamlink);
this->leftMenu.addSeparator();
this->leftMenu.addAction("Reload channel emotes", this, SLOT(menuReloadChannelEmotes()));
this->leftMenu.addAction("Manual reconnect", this, SLOT(menuManualReconnect()));
@ -62,7 +61,7 @@ ChatWidgetHeader::ChatWidgetHeader(ChatWidget *_chatWidget)
this->channelNameLabel.setAlignment(Qt::AlignCenter);
connect(&this->channelNameLabel, &SignalLabel::mouseDoubleClick, this,
&ChatWidgetHeader::mouseDoubleClickEvent);
&SplitHeader::mouseDoubleClickEvent);
// right
this->rightLabel.setMinimumWidth(this->height());
@ -76,7 +75,7 @@ ChatWidgetHeader::ChatWidgetHeader(ChatWidget *_chatWidget)
});
}
void ChatWidgetHeader::initializeChannelSignals()
void SplitHeader::initializeChannelSignals()
{
// Disconnect any previous signal first
this->onlineStatusChangedConnection.disconnect();
@ -91,12 +90,12 @@ void ChatWidgetHeader::initializeChannelSignals()
}
}
void ChatWidgetHeader::resizeEvent(QResizeEvent *event)
void SplitHeader::resizeEvent(QResizeEvent *event)
{
this->setFixedHeight(static_cast<float>(32 * getDpiMultiplier()));
this->setFixedHeight(static_cast<float>(28 * getDpiMultiplier()));
}
void ChatWidgetHeader::updateChannelText()
void SplitHeader::updateChannelText()
{
const std::string channelName = this->chatWidget->channelName;
if (channelName.empty()) {
@ -114,9 +113,8 @@ void ChatWidgetHeader::updateChannelText()
"<br>"
"Live for " +
twitchChannel->streamUptime + " with " +
twitchChannel->streamViewerCount +
" viewers"
"</p>");
twitchChannel->streamViewerCount + " viewers"
"</p>");
} else {
this->channelNameLabel.setText(QString::fromStdString(channelName));
this->setToolTip("");
@ -124,7 +122,7 @@ void ChatWidgetHeader::updateChannelText()
}
}
void ChatWidgetHeader::paintEvent(QPaintEvent *)
void SplitHeader::paintEvent(QPaintEvent *)
{
QPainter painter(this);
@ -133,23 +131,23 @@ void ChatWidgetHeader::paintEvent(QPaintEvent *)
painter.drawRect(0, 0, width() - 1, height() - 1);
}
void ChatWidgetHeader::mousePressEvent(QMouseEvent *event)
void SplitHeader::mousePressEvent(QMouseEvent *event)
{
this->dragging = true;
this->dragStart = event->pos();
}
void ChatWidgetHeader::mouseMoveEvent(QMouseEvent *event)
void SplitHeader::mouseMoveEvent(QMouseEvent *event)
{
if (this->dragging) {
if (std::abs(this->dragStart.x() - event->pos().x()) > 12 ||
std::abs(this->dragStart.y() - event->pos().y()) > 12) {
auto page = static_cast<NotebookPage *>(this->chatWidget->parentWidget());
auto page = static_cast<SplitContainer *>(this->chatWidget->parentWidget());
if (page != nullptr) {
NotebookPage::isDraggingSplit = true;
NotebookPage::draggingSplit = this->chatWidget;
SplitContainer::isDraggingSplit = true;
SplitContainer::draggingSplit = this->chatWidget;
auto originalLocation = page->removeFromLayout(this->chatWidget);
@ -168,20 +166,20 @@ void ChatWidgetHeader::mouseMoveEvent(QMouseEvent *event)
page->addToLayout(this->chatWidget, originalLocation);
}
NotebookPage::isDraggingSplit = false;
SplitContainer::isDraggingSplit = false;
}
}
}
}
void ChatWidgetHeader::mouseDoubleClickEvent(QMouseEvent *event)
void SplitHeader::mouseDoubleClickEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton) {
this->chatWidget->doChangeChannel();
}
}
void ChatWidgetHeader::leftButtonClicked()
void SplitHeader::leftButtonClicked()
{
QTimer::singleShot(80, [&] {
this->leftMenu.move(this->leftLabel.mapToGlobal(QPoint(0, this->leftLabel.height())));
@ -189,11 +187,11 @@ void ChatWidgetHeader::leftButtonClicked()
});
}
void ChatWidgetHeader::rightButtonClicked()
void SplitHeader::rightButtonClicked()
{
}
void ChatWidgetHeader::refreshTheme()
void SplitHeader::refreshTheme()
{
QPalette palette;
palette.setColor(QPalette::Foreground, this->colorScheme.Text);
@ -203,19 +201,19 @@ void ChatWidgetHeader::refreshTheme()
this->rightLabel.setPalette(palette);
}
void ChatWidgetHeader::menuMoveSplit()
void SplitHeader::menuMoveSplit()
{
}
void ChatWidgetHeader::menuReloadChannelEmotes()
void SplitHeader::menuReloadChannelEmotes()
{
}
void ChatWidgetHeader::menuManualReconnect()
void SplitHeader::menuManualReconnect()
{
}
void ChatWidgetHeader::menuShowChangelog()
void SplitHeader::menuShowChangelog()
{
}

View file

@ -1,8 +1,8 @@
#pragma once
#include "signallabel.hpp"
#include "widgets/basewidget.hpp"
#include "widgets/rippleeffectlabel.hpp"
#include "widgets/helper/rippleeffectlabel.hpp"
#include "widgets/helper/signallabel.hpp"
#include <QAction>
#include <QHBoxLayout>
@ -20,14 +20,14 @@ class ColorScheme;
namespace widgets {
class ChatWidget;
class Split;
class ChatWidgetHeader : public BaseWidget
class SplitHeader : public BaseWidget
{
Q_OBJECT
public:
explicit ChatWidgetHeader(ChatWidget *_chatWidget);
explicit SplitHeader(Split *_chatWidget);
// Update channel text from chat widget
void updateChannelText();
@ -39,7 +39,7 @@ protected:
virtual void resizeEvent(QResizeEvent *event) override;
private:
ChatWidget *const chatWidget;
Split *const chatWidget;
QPoint dragStart;
bool dragging = false;

View file

@ -1,11 +1,11 @@
#include "widgets/chatwidgetinput.hpp"
#include "chatwidget.hpp"
#include "widgets/helper/splitinput.hpp"
#include "colorscheme.hpp"
#include "completionmanager.hpp"
#include "ircmanager.hpp"
#include "notebook.hpp"
#include "notebookpage.hpp"
#include "settingsmanager.hpp"
#include "widgets/notebook.hpp"
#include "widgets/split.hpp"
#include "widgets/splitcontainer.hpp"
#include <QCompleter>
#include <QPainter>
@ -13,8 +13,7 @@
namespace chatterino {
namespace widgets {
ChatWidgetInput::ChatWidgetInput(ChatWidget *_chatWidget, EmoteManager &emoteManager,
WindowManager &windowManager)
SplitInput::SplitInput(Split *_chatWidget, EmoteManager &emoteManager, WindowManager &windowManager)
: BaseWidget(_chatWidget)
, chatWidget(_chatWidget)
, emoteManager(emoteManager)
@ -65,7 +64,7 @@ ChatWidgetInput::ChatWidgetInput(ChatWidget *_chatWidget, EmoteManager &emoteMan
this->emotePopup->show();
});
connect(&textInput, &ResizingTextEdit::textChanged, this, &ChatWidgetInput::editTextChanged);
connect(&textInput, &ResizingTextEdit::textChanged, this, &SplitInput::editTextChanged);
this->refreshTheme();
textLengthLabel.setHidden(!SettingsManager::getInstance().showMessageLength.get());
@ -96,7 +95,8 @@ ChatWidgetInput::ChatWidgetInput(ChatWidget *_chatWidget, EmoteManager &emoteMan
prevIndex = prevMsg.size();
} else if (event->key() == Qt::Key_Up) {
if (event->modifiers() == Qt::AltModifier) {
NotebookPage *page = static_cast<NotebookPage *>(this->chatWidget->parentWidget());
SplitContainer *page =
static_cast<SplitContainer *>(this->chatWidget->parentWidget());
int reqX = page->currentX;
int reqY = page->lastRequestedY[reqX] - 1;
@ -112,7 +112,8 @@ ChatWidgetInput::ChatWidgetInput(ChatWidget *_chatWidget, EmoteManager &emoteMan
}
} else if (event->key() == Qt::Key_Down) {
if (event->modifiers() == Qt::AltModifier) {
NotebookPage *page = static_cast<NotebookPage *>(this->chatWidget->parentWidget());
SplitContainer *page =
static_cast<SplitContainer *>(this->chatWidget->parentWidget());
int reqX = page->currentX;
int reqY = page->lastRequestedY[reqX] + 1;
@ -131,7 +132,8 @@ ChatWidgetInput::ChatWidgetInput(ChatWidget *_chatWidget, EmoteManager &emoteMan
}
} else if (event->key() == Qt::Key_Left) {
if (event->modifiers() == Qt::AltModifier) {
NotebookPage *page = static_cast<NotebookPage *>(this->chatWidget->parentWidget());
SplitContainer *page =
static_cast<SplitContainer *>(this->chatWidget->parentWidget());
int reqX = page->currentX - 1;
int reqY = page->lastRequestedY[reqX];
@ -142,7 +144,8 @@ ChatWidgetInput::ChatWidgetInput(ChatWidget *_chatWidget, EmoteManager &emoteMan
}
} else if (event->key() == Qt::Key_Right) {
if (event->modifiers() == Qt::AltModifier) {
NotebookPage *page = static_cast<NotebookPage *>(this->chatWidget->parentWidget());
SplitContainer *page =
static_cast<SplitContainer *>(this->chatWidget->parentWidget());
int reqX = page->currentX + 1;
int reqY = page->lastRequestedY[reqX];
@ -153,7 +156,8 @@ ChatWidgetInput::ChatWidgetInput(ChatWidget *_chatWidget, EmoteManager &emoteMan
}
} else if (event->key() == Qt::Key_Tab) {
if (event->modifiers() == Qt::ControlModifier) {
NotebookPage *page = static_cast<NotebookPage *>(this->chatWidget->parentWidget());
SplitContainer *page =
static_cast<SplitContainer *>(this->chatWidget->parentWidget());
Notebook *notebook = static_cast<Notebook *>(page->parentWidget());
@ -161,7 +165,8 @@ ChatWidgetInput::ChatWidgetInput(ChatWidget *_chatWidget, EmoteManager &emoteMan
}
} else if (event->key() == Qt::Key_Backtab) {
if (event->modifiers() == (Qt::ControlModifier | Qt::ShiftModifier)) {
NotebookPage *page = static_cast<NotebookPage *>(this->chatWidget->parentWidget());
SplitContainer *page =
static_cast<SplitContainer *>(this->chatWidget->parentWidget());
Notebook *notebook = static_cast<Notebook *>(page->parentWidget());
@ -186,12 +191,12 @@ ChatWidgetInput::ChatWidgetInput(ChatWidget *_chatWidget, EmoteManager &emoteMan
});
}
ChatWidgetInput::~ChatWidgetInput()
SplitInput::~SplitInput()
{
this->textLengthVisibleChangedConnection.disconnect();
}
void ChatWidgetInput::clearSelection()
void SplitInput::clearSelection()
{
QTextCursor c = this->textInput.textCursor();
@ -201,7 +206,7 @@ void ChatWidgetInput::clearSelection()
this->textInput.setTextCursor(c);
}
void ChatWidgetInput::refreshTheme()
void SplitInput::refreshTheme()
{
QPalette palette;
@ -212,11 +217,11 @@ void ChatWidgetInput::refreshTheme()
this->textInput.setStyleSheet(this->colorScheme.InputStyleSheet);
}
void ChatWidgetInput::editTextChanged()
void SplitInput::editTextChanged()
{
}
void ChatWidgetInput::paintEvent(QPaintEvent *)
void SplitInput::paintEvent(QPaintEvent *)
{
QPainter painter(this);
@ -225,7 +230,7 @@ void ChatWidgetInput::paintEvent(QPaintEvent *)
painter.drawRect(0, 0, this->width() - 1, this->height() - 1);
}
void ChatWidgetInput::resizeEvent(QResizeEvent *)
void SplitInput::resizeEvent(QResizeEvent *)
{
if (this->height() == this->maximumHeight()) {
this->textInput.setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
@ -234,7 +239,7 @@ void ChatWidgetInput::resizeEvent(QResizeEvent *)
}
}
void ChatWidgetInput::mousePressEvent(QMouseEvent *)
void SplitInput::mousePressEvent(QMouseEvent *)
{
this->chatWidget->giveFocus(Qt::MouseFocusReason);
}

View file

@ -4,7 +4,7 @@
#include "resizingtextedit.hpp"
#include "widgets/basewidget.hpp"
#include "widgets/emotepopup.hpp"
#include "widgets/rippleeffectlabel.hpp"
#include "widgets/helper/rippleeffectlabel.hpp"
#include <QHBoxLayout>
#include <QLabel>
@ -19,15 +19,15 @@
namespace chatterino {
namespace widgets {
class ChatWidget;
class Split;
class ChatWidgetInput : public BaseWidget
class SplitInput : public BaseWidget
{
Q_OBJECT
public:
ChatWidgetInput(ChatWidget *_chatWidget, EmoteManager &, WindowManager &);
~ChatWidgetInput();
SplitInput(Split *_chatWidget, EmoteManager &, WindowManager &);
~SplitInput();
void clearSelection();
@ -38,7 +38,7 @@ protected:
virtual void mousePressEvent(QMouseEvent *event) override;
private:
ChatWidget *const chatWidget;
Split *const chatWidget;
EmotePopup *emotePopup = nullptr;
EmoteManager &emoteManager;
WindowManager &windowManager;
@ -57,7 +57,7 @@ private:
private slots:
void editTextChanged();
friend class ChatWidget;
friend class Split;
};
} // namespace widgets

View file

@ -1,10 +1,10 @@
#include "widgets/notebook.hpp"
#include "colorscheme.hpp"
#include "widgets/mainwindow.hpp"
#include "widgets/notebookbutton.hpp"
#include "widgets/notebookpage.hpp"
#include "widgets/notebooktab.hpp"
#include "widgets/helper/notebookbutton.hpp"
#include "widgets/helper/notebooktab.hpp"
#include "widgets/settingsdialog.hpp"
#include "widgets/splitcontainer.hpp"
#include "widgets/window.hpp"
#include <QDebug>
#include <QFile>
@ -19,13 +19,14 @@
namespace chatterino {
namespace widgets {
Notebook::Notebook(ChannelManager &_channelManager, MainWindow *parent)
Notebook::Notebook(ChannelManager &_channelManager, Window *parent, bool _showButtons)
: BaseWidget(parent)
, channelManager(_channelManager)
, completionManager(parent->completionManager)
, addButton(this)
, settingsButton(this)
, userButton(this)
, showButtons(_showButtons)
{
this->connect(&this->settingsButton, SIGNAL(clicked()), this, SLOT(settingsButtonClicked()));
this->connect(&this->userButton, SIGNAL(clicked()), this, SLOT(usersButtonClicked()));
@ -42,10 +43,10 @@ Notebook::Notebook(ChannelManager &_channelManager, MainWindow *parent)
[this](const bool &) { this->performLayout(); });
}
NotebookPage *Notebook::addPage(bool select)
SplitContainer *Notebook::addPage(bool select)
{
auto tab = new NotebookTab(this);
auto page = new NotebookPage(this->channelManager, this, tab);
auto page = new SplitContainer(this->channelManager, this, tab);
tab->show();
@ -60,7 +61,7 @@ NotebookPage *Notebook::addPage(bool select)
return page;
}
void Notebook::removePage(NotebookPage *page)
void Notebook::removePage(SplitContainer *page)
{
int index = this->pages.indexOf(page);
@ -84,7 +85,7 @@ void Notebook::removePage(NotebookPage *page)
this->performLayout();
}
void Notebook::select(NotebookPage *page)
void Notebook::select(SplitContainer *page)
{
if (page == this->selectedPage) {
return;
@ -106,7 +107,7 @@ void Notebook::select(NotebookPage *page)
this->performLayout();
}
NotebookPage *Notebook::tabAt(QPoint point, int &index)
SplitContainer *Notebook::tabAt(QPoint point, int &index)
{
int i = 0;
@ -123,7 +124,7 @@ NotebookPage *Notebook::tabAt(QPoint point, int &index)
return nullptr;
}
void Notebook::rearrangePage(NotebookPage *page, int index)
void Notebook::rearrangePage(SplitContainer *page, int index)
{
this->pages.move(this->pages.indexOf(page), index);
@ -161,13 +162,13 @@ void Notebook::performLayout(bool animated)
int x = 0, y = 0;
float scale = this->getDpiMultiplier();
if (SettingsManager::getInstance().hidePreferencesButton.get()) {
if (!showButtons || SettingsManager::getInstance().hidePreferencesButton.get()) {
this->settingsButton.hide();
} else {
this->settingsButton.show();
x += settingsButton.width();
}
if (SettingsManager::getInstance().hideUserButton.get()) {
if (!showButtons || SettingsManager::getInstance().hideUserButton.get()) {
this->userButton.hide();
} else {
this->userButton.move(x, 0);

View file

@ -1,9 +1,9 @@
#pragma once
#include "widgets/basewidget.hpp"
#include "widgets/notebookbutton.hpp"
#include "widgets/notebookpage.hpp"
#include "widgets/notebooktab.hpp"
#include "widgets/helper/notebookbutton.hpp"
#include "widgets/helper/notebooktab.hpp"
#include "widgets/splitcontainer.hpp"
#include <QList>
#include <QWidget>
@ -16,7 +16,7 @@ class CompletionManager;
namespace widgets {
class MainWindow;
class Window;
class Notebook : public BaseWidget
{
@ -25,22 +25,22 @@ class Notebook : public BaseWidget
public:
enum HighlightType { none, highlighted, newMessage };
explicit Notebook(ChannelManager &_channelManager, MainWindow *parent);
explicit Notebook(ChannelManager &_channelManager, Window *parent, bool showButtons);
NotebookPage *addPage(bool select = false);
SplitContainer *addPage(bool select = false);
void removePage(NotebookPage *page);
void select(NotebookPage *page);
void removePage(SplitContainer *page);
void select(SplitContainer *page);
NotebookPage *getSelectedPage() const
SplitContainer *getSelectedPage() const
{
return selectedPage;
}
void performLayout(bool animate = true);
NotebookPage *tabAt(QPoint point, int &index);
void rearrangePage(NotebookPage *page, int index);
SplitContainer *tabAt(QPoint point, int &index);
void rearrangePage(SplitContainer *page, int index);
void nextTab();
void previousTab();
@ -60,13 +60,15 @@ public:
CompletionManager &completionManager;
private:
QList<NotebookPage *> pages;
QList<SplitContainer *> pages;
NotebookButton addButton;
NotebookButton settingsButton;
NotebookButton userButton;
NotebookPage *selectedPage = nullptr;
SplitContainer *selectedPage = nullptr;
bool showButtons;
public:
void load(const boost::property_tree::ptree &tree);

View file

@ -1,6 +1,6 @@
#include "widgets/scrollbar.hpp"
#include "colorscheme.hpp"
#include "widgets/channelview.hpp"
#include "widgets/helper/channelview.hpp"
#include <QDebug>
#include <QMouseEvent>

View file

@ -1,7 +1,7 @@
#pragma once
#include "widgets/basewidget.hpp"
#include "widgets/scrollbarhighlight.hpp"
#include "widgets/helper/scrollbarhighlight.hpp"
#include <QMutex>
#include <QPropertyAnimation>

View file

@ -2,8 +2,8 @@
#include "accountmanager.hpp"
#include "twitch/twitchmessagebuilder.hpp"
#include "twitch/twitchuser.hpp"
#include "widgets/helper/settingsdialogtab.hpp"
#include "widgets/logindialog.hpp"
#include "widgets/settingsdialogtab.hpp"
#include "windowmanager.hpp"
#include <QComboBox>
@ -176,7 +176,6 @@ QVBoxLayout *SettingsDialog::createAppearanceTab()
fontLayout->addWidget(fontFamilyLabel);
fontLayout->addWidget(fontSizeLabel);
{
auto &fontManager = FontManager::getInstance();

View file

@ -2,7 +2,7 @@
#include "settingsmanager.hpp"
#include "settingssnapshot.hpp"
#include "widgets/settingsdialogtab.hpp"
#include "widgets/helper/settingsdialogtab.hpp"
#include <QButtonGroup>
#include <QCheckBox>

View file

@ -1,12 +1,14 @@
#include "widgets/chatwidget.hpp"
#include "widgets/split.hpp"
#include "channelmanager.hpp"
#include "colorscheme.hpp"
#include "notebookpage.hpp"
#include "settingsmanager.hpp"
#include "twitch/twitchmessagebuilder.hpp"
#include "util/urlfetch.hpp"
#include "widgets/qualitypopup.hpp"
#include "widgets/splitcontainer.hpp"
#include "widgets/textinputdialog.hpp"
#include "widgets/window.hpp"
#include "windowmanager.hpp"
#include <QApplication>
#include <QClipboard>
@ -34,7 +36,7 @@ namespace widgets {
namespace {
template <typename T>
inline void ezShortcut(ChatWidget *w, const char *key, T t)
inline void ezShortcut(Split *w, const char *key, T t)
{
auto s = new QShortcut(QKeySequence(key), w);
s->setContext(Qt::WidgetWithChildrenShortcut);
@ -45,17 +47,19 @@ inline void ezShortcut(ChatWidget *w, const char *key, T t)
static int index = 0;
ChatWidget::ChatWidget(ChannelManager &_channelManager, NotebookPage *parent)
Split::Split(ChannelManager &_channelManager, SplitContainer *parent)
: BaseWidget(parent)
, channelName("/chatWidgets/" + std::to_string(index++) + "/channelName")
, parentPage(*parent)
, channelManager(_channelManager)
, completionManager(parent->completionManager)
, channelName("/chatWidgets/" + std::to_string(index++) + "/channelName")
, channel(_channelManager.emptyChannel)
, vbox(this)
, header(this)
, view(_channelManager.getWindowManager(), this)
, input(this, _channelManager.getEmoteManager(), _channelManager.getWindowManager())
, flexSizeX(1)
, flexSizeY(1)
{
this->vbox.setSpacing(0);
this->vbox.setMargin(1);
@ -66,21 +70,27 @@ ChatWidget::ChatWidget(ChannelManager &_channelManager, NotebookPage *parent)
// Initialize chat widget-wide hotkeys
// CTRL+T: Create new split (Add page)
ezShortcut(this, "CTRL+T", &ChatWidget::doAddSplit);
ezShortcut(this, "CTRL+T", &Split::doAddSplit);
// CTRL+W: Close Split
ezShortcut(this, "CTRL+W", &ChatWidget::doCloseSplit);
ezShortcut(this, "CTRL+W", &Split::doCloseSplit);
// CTRL+R: Change Channel
ezShortcut(this, "CTRL+R", &ChatWidget::doChangeChannel);
ezShortcut(this, "CTRL+R", &Split::doChangeChannel);
// xd
//ezShortcut(this, "ALT+SHIFT+RIGHT", &Split::doIncFlexX);
//ezShortcut(this, "ALT+SHIFT+LEFT", &Split::doDecFlexX);
//ezShortcut(this, "ALT+SHIFT+UP", &Split::doIncFlexY);
//ezShortcut(this, "ALT+SHIFT+DOWN", &Split::doDecFlexY);
#ifndef NDEBUG
// F12: Toggle message spawning
ezShortcut(this, "ALT+Q", &ChatWidget::doToggleMessageSpawning);
ezShortcut(this, "ALT+Q", &Split::doToggleMessageSpawning);
#endif
this->channelName.getValueChangedSignal().connect(
std::bind(&ChatWidget::channelNameUpdated, this, std::placeholders::_1));
std::bind(&Split::channelNameUpdated, this, std::placeholders::_1));
this->channelNameUpdated(this->channelName.getValue());
@ -94,26 +104,26 @@ ChatWidget::ChatWidget(ChannelManager &_channelManager, NotebookPage *parent)
});
QTimer *timer = new QTimer(this);
connect(timer, &QTimer::timeout, this, &ChatWidget::test);
connect(timer, &QTimer::timeout, this, &Split::test);
timer->start(1000);
}
ChatWidget::~ChatWidget()
Split::~Split()
{
this->channelNameUpdated("");
}
std::shared_ptr<Channel> ChatWidget::getChannel() const
std::shared_ptr<Channel> Split::getChannel() const
{
return this->channel;
}
std::shared_ptr<Channel> &ChatWidget::getChannelRef()
std::shared_ptr<Channel> &Split::getChannelRef()
{
return this->channel;
}
void ChatWidget::setChannel(std::shared_ptr<Channel> _newChannel)
void Split::setChannel(std::shared_ptr<Channel> _newChannel)
{
this->view.setChannel(_newChannel);
@ -122,7 +132,29 @@ void ChatWidget::setChannel(std::shared_ptr<Channel> _newChannel)
this->channelChanged();
}
void ChatWidget::channelNameUpdated(const std::string &newChannelName)
void Split::setFlexSizeX(double x)
{
this->flexSizeX = x;
this->parentPage.updateFlexValues();
}
double Split::getFlexSizeX()
{
return this->flexSizeX;
}
void Split::setFlexSizeY(double y)
{
this->flexSizeY = y;
this->parentPage.updateFlexValues();
}
double Split::getFlexSizeY()
{
return this->flexSizeY;
}
void Split::channelNameUpdated(const std::string &newChannelName)
{
// remove current channel
if (!this->channel->isEmpty()) {
@ -141,7 +173,7 @@ void ChatWidget::channelNameUpdated(const std::string &newChannelName)
this->header.updateChannelText();
}
bool ChatWidget::showChangeChannelPopup(const char *dialogTitle, bool empty)
bool Split::showChangeChannelPopup(const char *dialogTitle, bool empty)
{
// create new input dialog and execute it
TextInputDialog dialog(this);
@ -164,27 +196,27 @@ bool ChatWidget::showChangeChannelPopup(const char *dialogTitle, bool empty)
return false;
}
void ChatWidget::layoutMessages()
void Split::layoutMessages()
{
this->view.layoutMessages();
}
void ChatWidget::updateGifEmotes()
void Split::updateGifEmotes()
{
this->view.updateGifEmotes();
}
void ChatWidget::giveFocus(Qt::FocusReason reason)
void Split::giveFocus(Qt::FocusReason reason)
{
this->input.textInput.setFocus(reason);
}
bool ChatWidget::hasFocus() const
bool Split::hasFocus() const
{
return this->input.textInput.hasFocus();
}
void ChatWidget::paintEvent(QPaintEvent *)
void Split::paintEvent(QPaintEvent *)
{
// color the background of the chat
QPainter painter(this);
@ -192,7 +224,7 @@ void ChatWidget::paintEvent(QPaintEvent *)
painter.fillRect(this->rect(), this->colorScheme.ChatBackground);
}
void ChatWidget::load(const boost::property_tree::ptree &tree)
void Split::load(const boost::property_tree::ptree &tree)
{
// load tab text
try {
@ -201,7 +233,7 @@ void ChatWidget::load(const boost::property_tree::ptree &tree)
}
}
boost::property_tree::ptree ChatWidget::save()
boost::property_tree::ptree Split::save()
{
boost::property_tree::ptree tree;
@ -211,19 +243,19 @@ boost::property_tree::ptree ChatWidget::save()
}
/// Slots
void ChatWidget::doAddSplit()
void Split::doAddSplit()
{
NotebookPage *page = static_cast<NotebookPage *>(this->parentWidget());
SplitContainer *page = static_cast<SplitContainer *>(this->parentWidget());
page->addChat(true);
}
void ChatWidget::doCloseSplit()
void Split::doCloseSplit()
{
NotebookPage *page = static_cast<NotebookPage *>(this->parentWidget());
SplitContainer *page = static_cast<SplitContainer *>(this->parentWidget());
page->removeFromLayout(this);
}
void ChatWidget::doChangeChannel()
void Split::doChangeChannel()
{
this->showChangeChannelPopup("Change channel");
auto popup = this->findChildren<QDockWidget *>();
@ -233,33 +265,37 @@ void ChatWidget::doChangeChannel()
}
}
void ChatWidget::doPopup()
void Split::doPopup()
{
// TODO: Copy signals and stuff too
auto widget =
new ChatWidget(this->channelManager, static_cast<NotebookPage *>(this->parentWidget()));
widget->channelName = this->channelName;
widget->show();
Window &window = WindowManager::instance->createWindow();
Split *split = new Split(this->channelManager,
static_cast<SplitContainer *>(window.getNotebook().getSelectedPage()));
split->channelName = this->channelName.getValue();
window.getNotebook().getSelectedPage()->addToLayout(split);
window.show();
}
void ChatWidget::doClearChat()
void Split::doClearChat()
{
view.clearMessages();
}
void ChatWidget::doOpenChannel()
void Split::doOpenChannel()
{
qDebug() << "[UNIMPLEMENTED] Open twitch.tv/"
<< QString::fromStdString(this->channelName.getValue());
}
void ChatWidget::doOpenPopupPlayer()
void Split::doOpenPopupPlayer()
{
qDebug() << "[UNIMPLEMENTED] Open twitch.tv/"
<< QString::fromStdString(this->channelName.getValue()) << "/popout";
}
void ChatWidget::doOpenStreamlink()
void Split::doOpenStreamlink()
{
SettingsManager &settings = SettingsManager::getInstance();
QString preferredQuality =
@ -326,7 +362,7 @@ void ChatWidget::doOpenStreamlink()
}
}
void ChatWidget::doOpenViewerList()
void Split::doOpenViewerList()
{
auto viewerDock = new QDockWidget("Viewer List", this);
viewerDock->setAllowedAreas(Qt::LeftDockWidgetArea);
@ -412,7 +448,7 @@ void ChatWidget::doOpenViewerList()
viewerDock->show();
}
void ChatWidget::doOpenAccountPopupWidget(AccountPopupWidget *widget, QString user)
void Split::doOpenAccountPopupWidget(AccountPopupWidget *widget, QString user)
{
widget->setName(user);
widget->move(QCursor::pos());
@ -421,7 +457,7 @@ void ChatWidget::doOpenAccountPopupWidget(AccountPopupWidget *widget, QString us
widget->setFocus();
}
void ChatWidget::doCopy()
void Split::doCopy()
{
QApplication::clipboard()->setText(this->view.getSelectedText());
}
@ -466,7 +502,7 @@ static Iter select_randomly(Iter start, Iter end)
return select_randomly(start, end, gen);
}
void ChatWidget::test()
void Split::test()
{
if (this->testEnabled) {
messages::MessageParseArgs args;
@ -496,10 +532,29 @@ void ChatWidget::test()
}
}
void ChatWidget::doToggleMessageSpawning()
void Split::doToggleMessageSpawning()
{
this->testEnabled = !this->testEnabled;
}
void Split::doIncFlexX()
{
this->setFlexSizeX(this->getFlexSizeX() * 1.2);
}
void Split::doDecFlexX()
{
this->setFlexSizeX(this->getFlexSizeX() * (1 / 1.2));
}
void Split::doIncFlexY()
{
this->setFlexSizeY(this->getFlexSizeY() * 1.2);
}
void Split::doDecFlexY()
{
this->setFlexSizeY(this->getFlexSizeY() * (1 / 1.2));
}
} // namespace widgets
} // namespace chatterino

View file

@ -6,10 +6,10 @@
#include "messages/word.hpp"
#include "messages/wordpart.hpp"
#include "widgets/basewidget.hpp"
#include "widgets/channelview.hpp"
#include "widgets/chatwidgetheader.hpp"
#include "widgets/chatwidgetinput.hpp"
#include "widgets/rippleeffectlabel.hpp"
#include "widgets/helper/channelview.hpp"
#include "widgets/helper/rippleeffectlabel.hpp"
#include "widgets/helper/splitheader.hpp"
#include "widgets/helper/splitinput.hpp"
#include <QFont>
#include <QShortcut>
@ -26,7 +26,7 @@ class CompletionManager;
namespace widgets {
class NotebookPage;
class SplitContainer;
// Each ChatWidget consists of three sub-elements that handle their own part of the chat widget:
// ChatWidgetHeader
@ -38,59 +38,56 @@ class NotebookPage;
// - Responsible for rendering and handling user text input
//
// Each sub-element has a reference to the parent Chat Widget
class ChatWidget : public BaseWidget
class Split : public BaseWidget
{
friend class ChatWidgetInput;
friend class SplitInput;
Q_OBJECT
public:
ChatWidget(ChannelManager &_channelManager, NotebookPage *parent);
~ChatWidget();
Split(ChannelManager &_channelManager, SplitContainer *parent);
~Split();
ChannelManager &channelManager;
CompletionManager &completionManager;
pajlada::Settings::Setting<std::string> channelName;
boost::signals2::signal<void()> channelChanged;
bool testEnabled = false;
std::shared_ptr<Channel> getChannel() const;
std::shared_ptr<Channel> &getChannelRef();
void setFlexSizeX(double x);
double getFlexSizeX();
void setFlexSizeY(double y);
double getFlexSizeY();
bool showChangeChannelPopup(const char *dialogTitle, bool empty = false);
void giveFocus(Qt::FocusReason reason);
bool hasFocus() const;
void layoutMessages();
void updateGifEmotes();
boost::signals2::signal<void()> channelChanged;
void load(const boost::property_tree::ptree &tree);
boost::property_tree::ptree save();
protected:
virtual void paintEvent(QPaintEvent *) override;
public:
ChannelManager &channelManager;
CompletionManager &completionManager;
pajlada::Settings::Setting<std::string> channelName;
private:
void setChannel(std::shared_ptr<Channel> newChannel);
void doOpenAccountPopupWidget(AccountPopupWidget *widget, QString user);
void channelNameUpdated(const std::string &newChannelName);
NotebookPage &parentPage;
SplitContainer &parentPage;
std::shared_ptr<Channel> channel;
QVBoxLayout vbox;
ChatWidgetHeader header;
SplitHeader header;
ChannelView view;
ChatWidgetInput input;
SplitInput input;
double flexSizeX;
double flexSizeY;
boost::signals2::connection channelIDChangedConnection;
public:
void load(const boost::property_tree::ptree &tree);
boost::property_tree::ptree save();
bool testEnabled = false;
void setChannel(std::shared_ptr<Channel> newChannel);
void doOpenAccountPopupWidget(AccountPopupWidget *widget, QString user);
void channelNameUpdated(const std::string &newChannelName);
public slots:
// Add new split to the notebook page that this chat widget is in
@ -127,6 +124,10 @@ public slots:
void doToggleMessageSpawning();
void test();
void doIncFlexX();
void doDecFlexX();
void doIncFlexY();
void doDecFlexY();
};
} // namespace widgets

View file

@ -1,8 +1,8 @@
#include "widgets/notebookpage.hpp"
#include "widgets/splitcontainer.hpp"
#include "colorscheme.hpp"
#include "widgets/chatwidget.hpp"
#include "widgets/helper/notebooktab.hpp"
#include "widgets/notebook.hpp"
#include "widgets/notebooktab.hpp"
#include "widgets/split.hpp"
#include <QApplication>
#include <QDebug>
@ -19,16 +19,17 @@
namespace chatterino {
namespace widgets {
bool NotebookPage::isDraggingSplit = false;
ChatWidget *NotebookPage::draggingSplit = nullptr;
std::pair<int, int> NotebookPage::dropPosition = std::pair<int, int>(-1, -1);
bool SplitContainer::isDraggingSplit = false;
Split *SplitContainer::draggingSplit = nullptr;
std::pair<int, int> SplitContainer::dropPosition = std::pair<int, int>(-1, -1);
NotebookPage::NotebookPage(ChannelManager &_channelManager, Notebook *parent, NotebookTab *_tab)
SplitContainer::SplitContainer(ChannelManager &_channelManager, Notebook *parent, NotebookTab *_tab)
: BaseWidget(parent->colorScheme, parent)
, channelManager(_channelManager)
, completionManager(parent->completionManager)
, tab(_tab)
, dropPreview(this)
, chatWidgets()
{
this->tab->page = this;
@ -47,7 +48,18 @@ NotebookPage::NotebookPage(ChannelManager &_channelManager, Notebook *parent, No
this->refreshTitle();
}
std::pair<int, int> NotebookPage::removeFromLayout(ChatWidget *widget)
void SplitContainer::updateFlexValues()
{
for (int i = 0; i < this->ui.hbox.count(); i++) {
QVBoxLayout *vbox = (QVBoxLayout *)ui.hbox.itemAt(i)->layout();
if (vbox->count() != 0) {
ui.hbox.setStretch(i, (int)(1000 * ((Split *)vbox->itemAt(0))->getFlexSizeX()));
}
}
}
std::pair<int, int> SplitContainer::removeFromLayout(Split *widget)
{
// remove reference to chat widget from chatWidgets vector
auto it = std::find(std::begin(this->chatWidgets), std::end(this->chatWidgets), widget);
@ -83,8 +95,7 @@ std::pair<int, int> NotebookPage::removeFromLayout(ChatWidget *widget)
return std::pair<int, int>(-1, -1);
}
void NotebookPage::addToLayout(ChatWidget *widget,
std::pair<int, int> position = std::pair<int, int>(-1, -1))
void SplitContainer::addToLayout(Split *widget, std::pair<int, int> position)
{
this->chatWidgets.push_back(widget);
@ -120,19 +131,19 @@ void NotebookPage::addToLayout(ChatWidget *widget,
this->refreshCurrentFocusCoordinates();
}
const std::vector<ChatWidget *> &NotebookPage::getChatWidgets() const
const std::vector<Split *> &SplitContainer::getChatWidgets() const
{
return this->chatWidgets;
}
NotebookTab *NotebookPage::getTab() const
NotebookTab *SplitContainer::getTab() const
{
return this->tab;
}
void NotebookPage::addChat(bool openChannelNameDialog)
void SplitContainer::addChat(bool openChannelNameDialog)
{
ChatWidget *w = this->createChatWidget();
Split *w = this->createChatWidget();
if (openChannelNameDialog) {
bool ret = w->showChangeChannelPopup("Open channel", true);
@ -146,7 +157,7 @@ void NotebookPage::addChat(bool openChannelNameDialog)
this->addToLayout(w, std::pair<int, int>(-1, -1));
}
void NotebookPage::refreshCurrentFocusCoordinates(bool alsoSetLastRequested)
void SplitContainer::refreshCurrentFocusCoordinates(bool alsoSetLastRequested)
{
int setX = -1;
int setY = -1;
@ -171,7 +182,7 @@ void NotebookPage::refreshCurrentFocusCoordinates(bool alsoSetLastRequested)
QWidget *w = innerItem->widget();
if (w) {
ChatWidget *chatWidget = static_cast<ChatWidget *>(w);
Split *chatWidget = static_cast<Split *>(w);
if (chatWidget->hasFocus()) {
setX = x;
setY = y;
@ -199,7 +210,7 @@ void NotebookPage::refreshCurrentFocusCoordinates(bool alsoSetLastRequested)
}
}
void NotebookPage::requestFocus(int requestedX, int requestedY)
void SplitContainer::requestFocus(int requestedX, int requestedY)
{
// XXX: Perhaps if we request an Y coordinate out of bounds, we shuold set all previously set
// requestedYs to 0 (if -1 is requested) or that x-coordinates vbox count (if requestedY >=
@ -238,12 +249,12 @@ void NotebookPage::requestFocus(int requestedX, int requestedY)
QWidget *w = innerItem->widget();
if (w) {
ChatWidget *chatWidget = static_cast<ChatWidget *>(w);
Split *chatWidget = static_cast<Split *>(w);
chatWidget->giveFocus(Qt::OtherFocusReason);
}
}
void NotebookPage::enterEvent(QEvent *)
void SplitContainer::enterEvent(QEvent *)
{
if (this->ui.hbox.count() == 0) {
this->setCursor(QCursor(Qt::PointingHandCursor));
@ -252,11 +263,11 @@ void NotebookPage::enterEvent(QEvent *)
}
}
void NotebookPage::leaveEvent(QEvent *)
void SplitContainer::leaveEvent(QEvent *)
{
}
void NotebookPage::mouseReleaseEvent(QMouseEvent *event)
void SplitContainer::mouseReleaseEvent(QMouseEvent *event)
{
if (this->ui.hbox.count() == 0 && event->button() == Qt::LeftButton) {
// "Add Chat" was clicked
@ -266,7 +277,7 @@ void NotebookPage::mouseReleaseEvent(QMouseEvent *event)
}
}
void NotebookPage::dragEnterEvent(QDragEnterEvent *event)
void SplitContainer::dragEnterEvent(QDragEnterEvent *event)
{
if (!event->mimeData()->hasFormat("chatterino/split"))
return;
@ -306,12 +317,12 @@ void NotebookPage::dragEnterEvent(QDragEnterEvent *event)
event->acceptProposedAction();
}
void NotebookPage::dragMoveEvent(QDragMoveEvent *event)
void SplitContainer::dragMoveEvent(QDragMoveEvent *event)
{
setPreviewRect(event->pos());
}
void NotebookPage::setPreviewRect(QPoint mousePos)
void SplitContainer::setPreviewRect(QPoint mousePos)
{
for (DropRegion region : this->dropRegions) {
if (region.rect.contains(mousePos)) {
@ -331,25 +342,25 @@ void NotebookPage::setPreviewRect(QPoint mousePos)
this->dropPreview.hide();
}
void NotebookPage::dragLeaveEvent(QDragLeaveEvent *event)
void SplitContainer::dragLeaveEvent(QDragLeaveEvent *event)
{
this->dropPreview.hide();
}
void NotebookPage::dropEvent(QDropEvent *event)
void SplitContainer::dropEvent(QDropEvent *event)
{
if (isDraggingSplit) {
event->acceptProposedAction();
NotebookPage::draggingSplit->setParent(this);
SplitContainer::draggingSplit->setParent(this);
addToLayout(NotebookPage::draggingSplit, dropPosition);
addToLayout(SplitContainer::draggingSplit, dropPosition);
}
this->dropPreview.hide();
}
bool NotebookPage::eventFilter(QObject *object, QEvent *event)
bool SplitContainer::eventFilter(QObject *object, QEvent *event)
{
if (event->type() == QEvent::FocusIn) {
QFocusEvent *focusEvent = static_cast<QFocusEvent *>(event);
@ -360,7 +371,7 @@ bool NotebookPage::eventFilter(QObject *object, QEvent *event)
return false;
}
void NotebookPage::paintEvent(QPaintEvent *)
void SplitContainer::paintEvent(QPaintEvent *)
{
QPainter painter(this);
@ -380,7 +391,7 @@ void NotebookPage::paintEvent(QPaintEvent *)
painter.fillRect(0, 0, width(), 2, accentColor);
}
void NotebookPage::showEvent(QShowEvent *event)
void SplitContainer::showEvent(QShowEvent *event)
{
// Whenever this notebook page is shown, give focus to the last focused chat widget
// If this is the first time this notebook page is shown, it will give focus to the top-left
@ -388,7 +399,7 @@ void NotebookPage::showEvent(QShowEvent *event)
this->requestFocus(this->currentX, this->currentY);
}
static std::pair<int, int> getWidgetPositionInLayout(QLayout *layout, const ChatWidget *chatWidget)
static std::pair<int, int> getWidgetPositionInLayout(QLayout *layout, const Split *chatWidget)
{
for (int i = 0; i < layout->count(); ++i) {
printf("xD\n");
@ -397,7 +408,7 @@ static std::pair<int, int> getWidgetPositionInLayout(QLayout *layout, const Chat
return std::make_pair(-1, -1);
}
std::pair<int, int> NotebookPage::getChatPosition(const ChatWidget *chatWidget)
std::pair<int, int> SplitContainer::getChatPosition(const Split *chatWidget)
{
auto layout = this->ui.hbox.layout();
@ -408,12 +419,12 @@ std::pair<int, int> NotebookPage::getChatPosition(const ChatWidget *chatWidget)
return getWidgetPositionInLayout(layout, chatWidget);
}
ChatWidget *NotebookPage::createChatWidget()
Split *SplitContainer::createChatWidget()
{
return new ChatWidget(this->channelManager, this);
return new Split(this->channelManager, this);
}
void NotebookPage::refreshTitle()
void SplitContainer::refreshTitle()
{
if (!this->tab->useDefaultBehaviour) {
return;
@ -444,7 +455,7 @@ void NotebookPage::refreshTitle()
this->tab->setTitle(newTitle);
}
void NotebookPage::load(const boost::property_tree::ptree &tree)
void SplitContainer::load(const boost::property_tree::ptree &tree)
{
try {
int column = 0;
@ -488,7 +499,7 @@ static void saveFromLayout(QLayout *layout, boost::property_tree::ptree &tree)
continue;
}
ChatWidget *chatWidget = qobject_cast<ChatWidget *>(widget);
Split *chatWidget = qobject_cast<Split *>(widget);
if (chatWidget != nullptr) {
boost::property_tree::ptree chat = chatWidget->save();
@ -499,7 +510,7 @@ static void saveFromLayout(QLayout *layout, boost::property_tree::ptree &tree)
}
}
boost::property_tree::ptree NotebookPage::save()
boost::property_tree::ptree SplitContainer::save()
{
boost::property_tree::ptree tree;

View file

@ -1,10 +1,9 @@
#pragma once
#include "widgets/basewidget.hpp"
#include "widgets/chatwidget.hpp"
#include "widgets/notebookpage.hpp"
#include "widgets/notebookpagedroppreview.hpp"
#include "widgets/notebooktab.hpp"
#include "widgets/helper/droppreview.hpp"
#include "widgets/helper/notebooktab.hpp"
#include "widgets/split.hpp"
#include <QDragEnterEvent>
#include <QHBoxLayout>
@ -22,26 +21,26 @@ class CompletionManager;
namespace widgets {
class NotebookPage : public BaseWidget
class SplitContainer : public BaseWidget
{
Q_OBJECT
public:
NotebookPage(ChannelManager &_channelManager, Notebook *parent, NotebookTab *_tab);
SplitContainer(ChannelManager &_channelManager, Notebook *parent, NotebookTab *_tab);
ChannelManager &channelManager;
CompletionManager &completionManager;
std::pair<int, int> removeFromLayout(ChatWidget *widget);
void addToLayout(ChatWidget *widget, std::pair<int, int> position);
std::pair<int, int> removeFromLayout(Split *widget);
void addToLayout(Split *widget, std::pair<int, int> position = std::pair<int, int>(-1, -1));
const std::vector<ChatWidget *> &getChatWidgets() const;
const std::vector<Split *> &getChatWidgets() const;
NotebookTab *getTab() const;
void addChat(bool openChannelNameDialog = false);
static bool isDraggingSplit;
static ChatWidget *draggingSplit;
static Split *draggingSplit;
static std::pair<int, int> dropPosition;
int currentX = 0;
@ -51,6 +50,8 @@ public:
void refreshCurrentFocusCoordinates(bool alsoSetLastRequested = false);
void requestFocus(int x, int y);
void updateFlexValues();
protected:
virtual bool eventFilter(QObject *object, QEvent *event) override;
virtual void paintEvent(QPaintEvent *) override;
@ -86,16 +87,16 @@ private:
QHBoxLayout hbox;
} ui;
std::vector<ChatWidget *> chatWidgets;
std::vector<Split *> chatWidgets;
std::vector<DropRegion> dropRegions;
NotebookPageDropPreview dropPreview;
void setPreviewRect(QPoint mousePos);
std::pair<int, int> getChatPosition(const ChatWidget *chatWidget);
std::pair<int, int> getChatPosition(const Split *chatWidget);
ChatWidget *createChatWidget();
Split *createChatWidget();
public:
void refreshTitle();

View file

@ -1,8 +1,8 @@
#include "widgets/mainwindow.hpp"
#include "widgets/window.hpp"
#include "channelmanager.hpp"
#include "colorscheme.hpp"
#include "settingsmanager.hpp"
#include "widgets/chatwidget.hpp"
#include "widgets/split.hpp"
#include "widgets/notebook.hpp"
#include "widgets/settingsdialog.hpp"
@ -16,13 +16,13 @@
namespace chatterino {
namespace widgets {
MainWindow::MainWindow(ChannelManager &_channelManager, ColorScheme &_colorScheme,
CompletionManager &_completionManager)
Window::Window(ChannelManager &_channelManager, ColorScheme &_colorScheme,
CompletionManager &_completionManager, bool _isMainWindow)
: BaseWidget(_colorScheme, nullptr)
, channelManager(_channelManager)
, colorScheme(_colorScheme)
, completionManager(_completionManager)
, notebook(this->channelManager, this)
, notebook(this->channelManager, this, _isMainWindow)
, dpi(this->getDpiMultiplier())
// , windowGeometry("/windows/0/geometry")
{
@ -66,11 +66,11 @@ MainWindow::MainWindow(ChannelManager &_channelManager, ColorScheme &_colorSchem
}
}
MainWindow::~MainWindow()
Window::~Window()
{
}
void MainWindow::repaintVisibleChatWidgets(Channel *channel)
void Window::repaintVisibleChatWidgets(Channel *channel)
{
auto *page = this->notebook.getSelectedPage();
@ -78,10 +78,10 @@ void MainWindow::repaintVisibleChatWidgets(Channel *channel)
return;
}
const std::vector<ChatWidget *> &widgets = page->getChatWidgets();
const std::vector<Split *> &widgets = page->getChatWidgets();
for (auto it = widgets.begin(); it != widgets.end(); ++it) {
ChatWidget *widget = *it;
Split *widget = *it;
if (channel == nullptr || channel == widget->getChannel().get()) {
widget->layoutMessages();
@ -89,14 +89,14 @@ void MainWindow::repaintVisibleChatWidgets(Channel *channel)
}
}
void MainWindow::load(const boost::property_tree::ptree &tree)
void Window::load(const boost::property_tree::ptree &tree)
{
this->notebook.load(tree);
loaded = true;
}
boost::property_tree::ptree MainWindow::save()
boost::property_tree::ptree Window::save()
{
boost::property_tree::ptree child;
@ -107,30 +107,30 @@ boost::property_tree::ptree MainWindow::save()
return child;
}
void MainWindow::loadDefaults()
void Window::loadDefaults()
{
this->notebook.loadDefaults();
loaded = true;
}
bool MainWindow::isLoaded() const
bool Window::isLoaded() const
{
return loaded;
}
Notebook &MainWindow::getNotebook()
Notebook &Window::getNotebook()
{
return this->notebook;
}
void MainWindow::closeEvent(QCloseEvent *)
void Window::closeEvent(QCloseEvent *)
{
// Save closing window position
// this->windowGeometry = this->geometry();
}
void MainWindow::refreshTheme()
void Window::refreshTheme()
{
QPalette palette;
palette.setColor(QPalette::Background, this->colorScheme.TabBackground);

View file

@ -8,7 +8,6 @@
//#include <platform/borderless/qwinwidget.h>
//#endif
#include <QMainWindow>
#include <boost/property_tree/ptree.hpp>
#include <pajlada/settings/serialize.hpp>
#include <pajlada/settings/settingdata.hpp>
@ -21,14 +20,14 @@ class CompletionManager;
namespace widgets {
class MainWindow : public BaseWidget
class Window : public BaseWidget
{
Q_OBJECT
public:
explicit MainWindow(ChannelManager &_channelManager, ColorScheme &_colorScheme,
CompletionManager &_completionManager);
~MainWindow();
explicit Window(ChannelManager &_channelManager, ColorScheme &_colorScheme,
CompletionManager &_completionManager, bool isMainWindow);
~Window();
void repaintVisibleChatWidgets(Channel *channel = nullptr);

View file

@ -9,6 +9,7 @@
#include <boost/property_tree/json_parser.hpp>
namespace chatterino {
WindowManager *WindowManager::instance = nullptr;
WindowManager::WindowManager(ChannelManager &_channelManager, ColorScheme &_colorScheme,
CompletionManager &_completionManager)
@ -16,6 +17,7 @@ WindowManager::WindowManager(ChannelManager &_channelManager, ColorScheme &_colo
, colorScheme(_colorScheme)
, completionManager(_completionManager)
{
WindowManager::instance = this;
}
static const std::string &getSettingsPath()
@ -49,18 +51,35 @@ void WindowManager::repaintGifEmotes()
// }
//}
widgets::MainWindow &WindowManager::getMainWindow()
widgets::Window &WindowManager::getMainWindow()
{
std::lock_guard<std::mutex> lock(this->windowMutex);
if (this->mainWindow == nullptr) {
this->mainWindow = new widgets::MainWindow(this->channelManager, this->colorScheme,
this->completionManager);
this->mainWindow = new widgets::Window(this->channelManager, this->colorScheme,
this->completionManager, true);
}
return *this->mainWindow;
}
widgets::Window &WindowManager::getCurrentWindow()
{
}
widgets::Window &WindowManager::createWindow()
{
auto *window = new widgets::Window(this->channelManager, this->colorScheme,
this->completionManager, false);
std::lock_guard<std::mutex> lock(this->windowMutex);
window->loadDefaults();
this->windows.push_back(window);
return *window;
}
void WindowManager::load()
{
const auto &settingsPath = getSettingsPath();

View file

@ -1,6 +1,6 @@
#pragma once
#include "widgets/mainwindow.hpp"
#include "widgets/window.hpp"
#include <mutex>
@ -16,6 +16,8 @@ public:
explicit WindowManager(ChannelManager &_channelManager, ColorScheme &_colorScheme,
CompletionManager &_completionManager);
static WindowManager *instance;
ChannelManager &channelManager;
ColorScheme &colorScheme;
CompletionManager &completionManager;
@ -25,7 +27,10 @@ public:
void repaintGifEmotes();
// void updateAll();
widgets::MainWindow &getMainWindow();
widgets::Window &getMainWindow();
widgets::Window &getCurrentWindow();
widgets::Window &createWindow();
void load();
void save();
@ -35,9 +40,10 @@ public:
private:
std::mutex windowMutex;
std::vector<widgets::Window *> windows;
// TODO(pajlada): Store as a value instead of a pointer
widgets::MainWindow *mainWindow = nullptr;
widgets::Window *mainWindow = nullptr;
};
} // namespace chatterino