This commit is contained in:
2017-12-17 02:42:04 +01:00
35 changed files with 150 additions and 251 deletions
+9 -9
View File
@@ -11,10 +11,8 @@ using namespace chatterino::messages;
namespace chatterino {
namespace widgets {
EmotePopup::EmotePopup(ColorScheme &colorScheme, EmoteManager &emoteManager,
WindowManager &windowManager)
EmotePopup::EmotePopup(ColorScheme &colorScheme)
: BaseWidget(colorScheme, 0)
, emoteManager(emoteManager)
{
this->initAsWindow();
@@ -22,8 +20,8 @@ EmotePopup::EmotePopup(ColorScheme &colorScheme, EmoteManager &emoteManager,
this->setLayout(layout);
layout->setMargin(0);
view = new ChannelView(windowManager, this);
layout->addWidget(view);
this->view = new ChannelView(this);
layout->addWidget(this->view);
}
void EmotePopup::loadChannel(std::shared_ptr<Channel> _channel)
@@ -58,18 +56,20 @@ void EmotePopup::loadChannel(std::shared_ptr<Channel> _channel)
emoteChannel->addMessage(builder2.getMessage());
};
addEmotes(this->emoteManager.bttvGlobalEmotes, "BetterTTV Global Emotes",
"BetterTTV Global Emote");
EmoteManager &emoteManager = EmoteManager::getInstance();
addEmotes(emoteManager.bttvGlobalEmotes, "BetterTTV Global Emotes", "BetterTTV Global Emote");
addEmotes(*channel->bttvChannelEmotes.get(), "BetterTTV Channel Emotes",
"BetterTTV Channel Emote");
addEmotes(this->emoteManager.ffzGlobalEmotes, "FrankerFaceZ Global Emotes",
addEmotes(emoteManager.ffzGlobalEmotes, "FrankerFaceZ Global Emotes",
"FrankerFaceZ Global Emote");
addEmotes(*channel->ffzChannelEmotes.get(), "FrankerFaceZ Channel Emotes",
"FrankerFaceZ Channel Emote");
// addEmotes(this->emoteManager.getEmojis(), "Emojis", "Emoji");
// addEmotes(emoteManager.getEmojis(), "Emojis", "Emoji");
this->view->setChannel(emoteChannel);
}
} // namespace widgets
} // namespace chatterino
+4 -5
View File
@@ -1,7 +1,6 @@
#pragma once
#include "channel.hpp"
#include "emotemanager.hpp"
#include "widgets/basewidget.hpp"
#include "widgets/helper/channelview.hpp"
@@ -11,13 +10,13 @@ namespace widgets {
class EmotePopup : public BaseWidget
{
public:
explicit EmotePopup(ColorScheme &, EmoteManager &, WindowManager &);
explicit EmotePopup(ColorScheme &);
void loadChannel(std::shared_ptr<Channel> channel);
private:
ChannelView *view;
EmoteManager &emoteManager;
};
}
}
} // namespace widgets
} // namespace chatterino
+8 -9
View File
@@ -28,9 +28,8 @@ using namespace chatterino::messages;
namespace chatterino {
namespace widgets {
ChannelView::ChannelView(WindowManager &windowManager, BaseWidget *parent)
ChannelView::ChannelView(BaseWidget *parent)
: BaseWidget(parent)
, windowManager(windowManager)
, scrollBar(this)
, userPopupWidget(std::shared_ptr<twitch::TwitchChannel>())
{
@@ -51,6 +50,8 @@ ChannelView::ChannelView(WindowManager &windowManager, BaseWidget *parent)
this->queueUpdate();
});
WindowManager &windowManager = *WindowManager::instance;
this->repaintGifsConnection =
windowManager.repaintGifs.connect([&] { this->updateGifEmotes(); });
this->layoutConnection = windowManager.layout.connect([&] { this->layoutMessages(); });
@@ -240,9 +241,8 @@ 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
@@ -519,10 +519,9 @@ 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
+1 -2
View File
@@ -85,7 +85,7 @@ class ChannelView : public BaseWidget
Q_OBJECT
public:
explicit ChannelView(WindowManager &windowManager, BaseWidget *parent = 0);
explicit ChannelView(BaseWidget *parent = 0);
~ChannelView();
void updateGifEmotes();
@@ -123,7 +123,6 @@ private:
QRect rect;
};
WindowManager &windowManager;
QTimer updateTimer;
bool updateQueued = false;
+4 -7
View File
@@ -13,11 +13,9 @@
namespace chatterino {
namespace widgets {
SplitInput::SplitInput(Split *_chatWidget, EmoteManager &emoteManager, WindowManager &windowManager)
SplitInput::SplitInput(Split *_chatWidget)
: BaseWidget(_chatWidget)
, chatWidget(_chatWidget)
, emoteManager(emoteManager)
, windowManager(windowManager)
, emotesLabel(this)
{
this->setMaximumHeight(150);
@@ -55,8 +53,7 @@ SplitInput::SplitInput(Split *_chatWidget, EmoteManager &emoteManager, WindowMan
connect(&this->emotesLabel, &RippleEffectLabel::clicked, [this] {
if (this->emotePopup == nullptr) {
this->emotePopup =
new EmotePopup(this->colorScheme, this->emoteManager, this->windowManager);
this->emotePopup = new EmotePopup(this->colorScheme);
}
this->emotePopup->resize(300, 500);
@@ -69,8 +66,8 @@ SplitInput::SplitInput(Split *_chatWidget, EmoteManager &emoteManager, WindowMan
this->refreshTheme();
textLengthLabel.setHidden(!SettingsManager::getInstance().showMessageLength);
auto completer = new QCompleter(
this->chatWidget->completionManager.createModel(this->chatWidget->channelName));
auto completer =
new QCompleter(CompletionManager::getInstance().createModel(this->chatWidget->channelName));
this->textInput.setCompleter(completer);
+1 -4
View File
@@ -1,6 +1,5 @@
#pragma once
#include "emotemanager.hpp"
#include "resizingtextedit.hpp"
#include "widgets/basewidget.hpp"
#include "widgets/emotepopup.hpp"
@@ -26,7 +25,7 @@ class SplitInput : public BaseWidget
Q_OBJECT
public:
SplitInput(Split *_chatWidget, EmoteManager &, WindowManager &);
SplitInput(Split *_chatWidget);
~SplitInput();
void clearSelection();
@@ -40,8 +39,6 @@ protected:
private:
Split *const chatWidget;
EmotePopup *emotePopup = nullptr;
EmoteManager &emoteManager;
WindowManager &windowManager;
pajlada::Signals::Signal<const bool &>::Connection textLengthVisibleChangedConnection;
QHBoxLayout hbox;
-1
View File
@@ -22,7 +22,6 @@ namespace widgets {
Notebook::Notebook(ChannelManager &_channelManager, Window *parent, bool _showButtons)
: BaseWidget(parent)
, channelManager(_channelManager)
, completionManager(parent->completionManager)
, addButton(this)
, settingsButton(this)
, userButton(this)
-2
View File
@@ -12,7 +12,6 @@
namespace chatterino {
class ChannelManager;
class CompletionManager;
namespace widgets {
@@ -58,7 +57,6 @@ public slots:
public:
ChannelManager &channelManager;
CompletionManager &completionManager;
private:
QList<SplitContainer *> pages;
+2 -3
View File
@@ -52,12 +52,11 @@ Split::Split(ChannelManager &_channelManager, SplitContainer *parent)
, channelName("/chatWidgets/" + std::to_string(index++) + "/channelName")
, parentPage(*parent)
, channelManager(_channelManager)
, completionManager(parent->completionManager)
, channel(_channelManager.emptyChannel)
, vbox(this)
, header(this)
, view(_channelManager.getWindowManager(), this)
, input(this, _channelManager.getEmoteManager(), _channelManager.getWindowManager())
, view(this)
, input(this)
, flexSizeX(1)
, flexSizeY(1)
{
-2
View File
@@ -22,7 +22,6 @@ namespace chatterino {
class ChannelManager;
class ColorScheme;
class CompletionManager;
namespace widgets {
@@ -49,7 +48,6 @@ public:
~Split();
ChannelManager &channelManager;
CompletionManager &completionManager;
pajlada::Settings::Setting<std::string> channelName;
boost::signals2::signal<void()> channelChanged;
-1
View File
@@ -26,7 +26,6 @@ std::pair<int, int> SplitContainer::dropPosition = std::pair<int, int>(-1, -1);
SplitContainer::SplitContainer(ChannelManager &_channelManager, Notebook *parent, NotebookTab *_tab)
: BaseWidget(parent->colorScheme, parent)
, channelManager(_channelManager)
, completionManager(parent->completionManager)
, tab(_tab)
, dropPreview(this)
, chatWidgets()
-2
View File
@@ -17,7 +17,6 @@
namespace chatterino {
class ChannelManager;
class CompletionManager;
namespace widgets {
@@ -29,7 +28,6 @@ public:
SplitContainer(ChannelManager &_channelManager, Notebook *parent, NotebookTab *_tab);
ChannelManager &channelManager;
CompletionManager &completionManager;
std::pair<int, int> removeFromLayout(Split *widget);
void addToLayout(Split *widget, std::pair<int, int> position = std::pair<int, int>(-1, -1));
+2 -4
View File
@@ -2,9 +2,9 @@
#include "channelmanager.hpp"
#include "colorscheme.hpp"
#include "settingsmanager.hpp"
#include "widgets/split.hpp"
#include "widgets/notebook.hpp"
#include "widgets/settingsdialog.hpp"
#include "widgets/split.hpp"
#include <QDebug>
#include <QLibrary>
@@ -16,12 +16,10 @@
namespace chatterino {
namespace widgets {
Window::Window(ChannelManager &_channelManager, ColorScheme &_colorScheme,
CompletionManager &_completionManager, bool _isMainWindow)
Window::Window(ChannelManager &_channelManager, ColorScheme &_colorScheme, bool _isMainWindow)
: BaseWidget(_colorScheme, nullptr)
, channelManager(_channelManager)
, colorScheme(_colorScheme)
, completionManager(_completionManager)
, notebook(this->channelManager, this, _isMainWindow)
, dpi(this->getDpiMultiplier())
// , windowGeometry("/windows/0/geometry")
+1 -3
View File
@@ -26,8 +26,7 @@ class Window : public BaseWidget
Q_OBJECT
public:
explicit Window(ChannelManager &_channelManager, ColorScheme &_colorScheme,
CompletionManager &_completionManager, bool isMainWindow);
explicit Window(ChannelManager &_channelManager, ColorScheme &_colorScheme, bool isMainWindow);
void repaintVisibleChatWidgets(Channel *channel = nullptr);
@@ -51,7 +50,6 @@ private:
ChannelManager &channelManager;
ColorScheme &colorScheme;
CompletionManager &completionManager;
Notebook notebook;
bool loaded = false;