Make more use of single pattern

This commit is contained in:
Rasmus Karlsson
2017-12-17 02:18:13 +01:00
parent d5f1c6acec
commit 70cbb9df7f
35 changed files with 146 additions and 249 deletions
+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;