Switch some c-style includes to c++-style includes (i.e. stdint.h to

cstdint)

Make MessageElement to a class to fit better with the derived classes.
Make MessageLayoutElement to a class to fit better with the derived
classes.

Remove virtual from override functions

Replace all instances of boost::signals2 with pajlada::Signals. This
lets us properly use clang code model to check for issues.

Add missing virtual destructor to AbstractIrcServer
Add missing virtual destructor to MessageLayoutElement

Remove unused "connectedConnection" connection in TwitchChannel

Fix typo in TrimChannelName function
Fix typo in MessageParseArgs

Replace some raw pointers with unique pointers where it made more sense.
This allowed us to remove some manually written destructors whose only
purpose was to delete that raw pointer.

Reformat: Add namespace comments
Reformat: Add empty empty lines between main namespace beginning and end
Reformat: Re-order includes
Reformat: Fix some includes that used quotes where they should use angle
brackets
Reformat: Replace some typedef's with using's

Filter out more useless warnings
This commit is contained in:
Rasmus Karlsson 2018-04-03 02:55:32 +02:00
parent 5bcb561eb2
commit adf3ff3075
103 changed files with 305 additions and 248 deletions

View file

@ -313,12 +313,16 @@ win32-msvc* {
# 4127 - conditional expression is constant # 4127 - conditional expression is constant
# 4503 - decorated name length exceeded, name was truncated # 4503 - decorated name length exceeded, name was truncated
# 4100 - unreferences formal parameter # 4100 - unreferences formal parameter
# 4305 - possible truncation of data
# 4267 - possible loss of data in return
QMAKE_CXXFLAGS_WARN_ON += /wd4714 QMAKE_CXXFLAGS_WARN_ON += /wd4714
QMAKE_CXXFLAGS_WARN_ON += /wd4996 QMAKE_CXXFLAGS_WARN_ON += /wd4996
QMAKE_CXXFLAGS_WARN_ON += /wd4505 QMAKE_CXXFLAGS_WARN_ON += /wd4505
QMAKE_CXXFLAGS_WARN_ON += /wd4127 QMAKE_CXXFLAGS_WARN_ON += /wd4127
QMAKE_CXXFLAGS_WARN_ON += /wd4503 QMAKE_CXXFLAGS_WARN_ON += /wd4503
QMAKE_CXXFLAGS_WARN_ON += /wd4100 QMAKE_CXXFLAGS_WARN_ON += /wd4100
QMAKE_CXXFLAGS_WARN_ON += /wd4305
QMAKE_CXXFLAGS_WARN_ON += /wd4267
} else { } else {
QMAKE_CXXFLAGS_WARN_ON = -Wall QMAKE_CXXFLAGS_WARN_ON = -Wall

View file

@ -61,10 +61,10 @@ void Channel::addMessage(MessagePtr message)
singletons::LoggingManager::getInstance().addMessage(this->name, message); singletons::LoggingManager::getInstance().addMessage(this->name, message);
if (this->messages.pushBack(message, deleted)) { if (this->messages.pushBack(message, deleted)) {
this->messageRemovedFromStart(deleted); this->messageRemovedFromStart.invoke(deleted);
} }
this->messageAppended(message); this->messageAppended.invoke(message);
} }
void Channel::addMessagesAtStart(std::vector<messages::MessagePtr> &_messages) void Channel::addMessagesAtStart(std::vector<messages::MessagePtr> &_messages)
@ -72,7 +72,7 @@ void Channel::addMessagesAtStart(std::vector<messages::MessagePtr> &_messages)
std::vector<messages::MessagePtr> addedMessages = this->messages.pushFront(_messages); std::vector<messages::MessagePtr> addedMessages = this->messages.pushFront(_messages);
if (addedMessages.size() != 0) { if (addedMessages.size() != 0) {
this->messagesAddedAtStart(addedMessages); this->messagesAddedAtStart.invoke(addedMessages);
} }
} }
@ -81,7 +81,7 @@ void Channel::replaceMessage(messages::MessagePtr message, messages::MessagePtr
int index = this->messages.replaceItem(message, replacement); int index = this->messages.replaceItem(message, replacement);
if (index >= 0) { if (index >= 0) {
this->messageReplaced((size_t)index, replacement); this->messageReplaced.invoke((size_t)index, replacement);
} }
} }

View file

@ -8,14 +8,14 @@
#include <QString> #include <QString>
#include <QTimer> #include <QTimer>
#include <boost/signals2.hpp> #include <pajlada/signals/signal.hpp>
#include <memory> #include <memory>
namespace chatterino { namespace chatterino {
namespace messages { namespace messages {
struct Message; struct Message;
} } // namespace messages
class Channel : public std::enable_shared_from_this<Channel> class Channel : public std::enable_shared_from_this<Channel>
{ {
@ -27,10 +27,10 @@ public:
pajlada::Signals::Signal<const QString &, const QString &> sendMessageSignal; pajlada::Signals::Signal<const QString &, const QString &> sendMessageSignal;
boost::signals2::signal<void(messages::MessagePtr &)> messageRemovedFromStart; pajlada::Signals::Signal<messages::MessagePtr &> messageRemovedFromStart;
boost::signals2::signal<void(messages::MessagePtr &)> messageAppended; pajlada::Signals::Signal<messages::MessagePtr &> messageAppended;
boost::signals2::signal<void(std::vector<messages::MessagePtr> &)> messagesAddedAtStart; pajlada::Signals::Signal<std::vector<messages::MessagePtr> &> messagesAddedAtStart;
boost::signals2::signal<void(size_t index, messages::MessagePtr &)> messageReplaced; pajlada::Signals::Signal<size_t, messages::MessagePtr &> messageReplaced;
pajlada::Signals::NoArgSignal destroyed; pajlada::Signals::NoArgSignal destroyed;
virtual bool isEmpty() const; virtual bool isEmpty() const;

View file

@ -1,10 +1,11 @@
#pragma once #pragma once
#include "debug/log.hpp"
#include <QString> #include <QString>
#include <boost/preprocessor.hpp> #include <boost/preprocessor.hpp>
#include <string>
#include "debug/log.hpp" #include <string>
namespace chatterino { namespace chatterino {

View file

@ -1,5 +1,7 @@
#pragma once #pragma once
#include <QByteArray>
namespace chatterino { namespace chatterino {
inline QByteArray getDefaultClientID() inline QByteArray getDefaultClientID()

View file

@ -5,7 +5,6 @@
#include <boost/noncopyable.hpp> #include <boost/noncopyable.hpp>
#include <atomic> #include <atomic>
#include <mutex>
namespace chatterino { namespace chatterino {
namespace messages { namespace messages {

View file

@ -15,7 +15,7 @@ namespace chatterino {
namespace messages { namespace messages {
namespace layouts { namespace layouts {
struct MessageLayoutElement; class MessageLayoutElement;
struct Margin { struct Margin {
int top; int top;

View file

@ -102,9 +102,9 @@ void ImageLayoutElement::paintAnimated(QPainter &painter, int yOffset)
if (pixmap != nullptr) { if (pixmap != nullptr) {
// fourtf: make it use qreal values // fourtf: make it use qreal values
QRect rect = this->getRect(); QRect _rect = this->getRect();
rect.moveTop(rect.y() + yOffset); _rect.moveTop(_rect.y() + yOffset);
painter.drawPixmap(QRectF(rect), *pixmap, QRectF()); painter.drawPixmap(QRectF(_rect), *pixmap, QRectF());
} }
} }
} }
@ -240,8 +240,8 @@ void TextIconLayoutElement::paint(QPainter &painter)
option.setAlignment(Qt::AlignHCenter); option.setAlignment(Qt::AlignHCenter);
if (this->line2.isEmpty()) { if (this->line2.isEmpty()) {
QRect rect(this->getRect()); QRect _rect(this->getRect());
painter.drawText(rect, this->line1, option); painter.drawText(_rect, this->line1, option);
} else { } else {
painter.drawText( painter.drawText(
QPoint(this->getRect().x(), this->getRect().y() + this->getRect().height() / 2), QPoint(this->getRect().x(), this->getRect().y() + this->getRect().height() / 2),

View file

@ -15,14 +15,16 @@ class QPainter;
namespace chatterino { namespace chatterino {
namespace messages { namespace messages {
struct MessageElement; class MessageElement;
class Image; class Image;
namespace layouts { namespace layouts {
struct MessageLayoutElement : boost::noncopyable { class MessageLayoutElement : boost::noncopyable
{
public: public:
MessageLayoutElement(MessageElement &creator, const QSize &size); MessageLayoutElement(MessageElement &creator, const QSize &size);
virtual ~MessageLayoutElement() = default;
const QRect &getRect() const; const QRect &getRect() const;
MessageElement &getCreator() const; MessageElement &getCreator() const;

View file

@ -1,9 +1,9 @@
#pragma once #pragma once
#include "QDebug"
#include "messages/limitedqueuesnapshot.hpp" #include "messages/limitedqueuesnapshot.hpp"
#include <QDebug>
#include <memory> #include <memory>
#include <mutex> #include <mutex>
#include <vector> #include <vector>

View file

@ -11,10 +11,7 @@ template <typename T>
class LimitedQueueSnapshot class LimitedQueueSnapshot
{ {
public: public:
LimitedQueueSnapshot() LimitedQueueSnapshot() = default;
: length(0)
{
}
LimitedQueueSnapshot(std::shared_ptr<std::vector<std::shared_ptr<std::vector<T>>>> _chunks, LimitedQueueSnapshot(std::shared_ptr<std::vector<std::shared_ptr<std::vector<T>>>> _chunks,
size_t _length, size_t _firstChunkOffset, size_t _lastChunkEnd) size_t _length, size_t _firstChunkOffset, size_t _lastChunkEnd)
@ -53,9 +50,9 @@ public:
private: private:
std::shared_ptr<std::vector<std::shared_ptr<std::vector<T>>>> chunks; std::shared_ptr<std::vector<std::shared_ptr<std::vector<T>>>> chunks;
size_t length; size_t length = 0;
size_t firstChunkOffset; size_t firstChunkOffset = 0;
size_t lastChunkEnd; size_t lastChunkEnd = 0;
}; };
} // namespace messages } // namespace messages

View file

@ -2,6 +2,7 @@
namespace chatterino { namespace chatterino {
namespace messages { namespace messages {
Link::Link() Link::Link()
: type(None) : type(None)
, value(QString()) , value(QString())
@ -18,5 +19,6 @@ bool Link::isValid() const
{ {
return this->type != None; return this->type != None;
} }
} // namespace messages } // namespace messages
} // namespace chatterino } // namespace chatterino

View file

@ -4,6 +4,7 @@
namespace chatterino { namespace chatterino {
namespace messages { namespace messages {
struct Link { struct Link {
public: public:
enum Type { enum Type {
@ -26,5 +27,6 @@ public:
bool isValid() const; bool isValid() const;
}; };
} // namespace messages } // namespace messages
} // namespace chatterino } // namespace chatterino

View file

@ -2,7 +2,7 @@
#include "messageelement.hpp" #include "messageelement.hpp"
#include "util/irchelpers.hpp" #include "util/irchelpers.hpp"
typedef chatterino::widgets::ScrollbarHighlight SBHighlight; using SBHighlight = chatterino::widgets::ScrollbarHighlight;
namespace chatterino { namespace chatterino {
namespace messages { namespace messages {

View file

@ -4,12 +4,12 @@
#include "util/flagsenum.hpp" #include "util/flagsenum.hpp"
#include "widgets/helper/scrollbarhighlight.hpp" #include "widgets/helper/scrollbarhighlight.hpp"
#include <QTime>
#include <cinttypes> #include <cinttypes>
#include <memory> #include <memory>
#include <vector> #include <vector>
#include <QTime>
namespace chatterino { namespace chatterino {
namespace messages { namespace messages {

View file

@ -2,6 +2,7 @@
namespace chatterino { namespace chatterino {
namespace messages { namespace messages {
MessageColor::MessageColor(const QColor &_color) MessageColor::MessageColor(const QColor &_color)
: type(Type::Custom) : type(Type::Custom)
, customColor(_color) , customColor(_color)
@ -29,5 +30,6 @@ const QColor &MessageColor::getColor(singletons::ThemeManager &themeManager) con
static QColor _default; static QColor _default;
return _default; return _default;
} }
} // namespace messages } // namespace messages
} // namespace chatterino } // namespace chatterino

View file

@ -1,11 +1,12 @@
#pragma once #pragma once
#include <QColor>
#include "singletons/thememanager.hpp" #include "singletons/thememanager.hpp"
#include <QColor>
namespace chatterino { namespace chatterino {
namespace messages { namespace messages {
struct MessageColor { struct MessageColor {
enum Type { Custom, Text, Link, System }; enum Type { Custom, Text, Link, System };
@ -18,5 +19,6 @@ private:
Type type; Type type;
QColor customColor; QColor customColor;
}; };
} // namespace messages } // namespace messages
} // namespace chatterino } // namespace chatterino

View file

@ -74,18 +74,10 @@ void ImageElement::addToContainer(MessageLayoutContainer &container, MessageElem
EmoteElement::EmoteElement(const util::EmoteData &_data, MessageElement::Flags flags) EmoteElement::EmoteElement(const util::EmoteData &_data, MessageElement::Flags flags)
: MessageElement(flags) : MessageElement(flags)
, data(_data) , data(_data)
, textElement(nullptr)
{ {
if (_data.isValid()) { if (_data.isValid()) {
this->setTooltip(data.image1x->getTooltip()); this->setTooltip(data.image1x->getTooltip());
this->textElement = new TextElement(_data.image1x->getName(), MessageElement::Misc); this->textElement.reset(new TextElement(_data.image1x->getName(), MessageElement::Misc));
}
}
EmoteElement::~EmoteElement()
{
if (this->textElement != nullptr) {
delete this->textElement;
} }
} }
@ -114,7 +106,7 @@ void EmoteElement::addToContainer(MessageLayoutContainer &container, MessageElem
container.addElement( container.addElement(
(new ImageLayoutElement(*this, _image, size))->setLink(this->getLink())); (new ImageLayoutElement(*this, _image, size))->setLink(this->getLink()));
} else { } else {
if (this->textElement != nullptr) { if (this->textElement) {
this->textElement->addToContainer(container, MessageElement::Misc); this->textElement->addToContainer(container, MessageElement::Misc);
} }
} }
@ -130,7 +122,7 @@ TextElement::TextElement(const QString &text, MessageElement::Flags flags,
{ {
for (QString word : text.split(' ')) { for (QString word : text.split(' ')) {
this->words.push_back({word, -1}); this->words.push_back({word, -1});
// fourtf: add logic to store mutliple spaces after message // fourtf: add logic to store multiple spaces after message
} }
} }
@ -213,32 +205,21 @@ void TextElement::addToContainer(MessageLayoutContainer &container, MessageEleme
} }
// TIMESTAMP // TIMESTAMP
TimestampElement::TimestampElement()
: TimestampElement(QTime::currentTime())
{
}
TimestampElement::TimestampElement(QTime _time) TimestampElement::TimestampElement(QTime _time)
: MessageElement(MessageElement::Timestamp) : MessageElement(MessageElement::Timestamp)
, time(_time) , time(_time)
, element(formatTime(_time)) , element(this->formatTime(_time))
{ {
assert(this->element != nullptr); assert(this->element != nullptr);
} }
TimestampElement::~TimestampElement()
{
delete this->element;
}
void TimestampElement::addToContainer(MessageLayoutContainer &container, void TimestampElement::addToContainer(MessageLayoutContainer &container,
MessageElement::Flags _flags) MessageElement::Flags _flags)
{ {
if (_flags & this->getFlags()) { if (_flags & this->getFlags()) {
if (singletons::SettingManager::getInstance().timestampFormat != this->format) { if (singletons::SettingManager::getInstance().timestampFormat != this->format) {
this->format = singletons::SettingManager::getInstance().timestampFormat.getValue(); this->format = singletons::SettingManager::getInstance().timestampFormat.getValue();
delete this->element; this->element.reset(this->formatTime(this->time));
this->element = TimestampElement::formatTime(this->time);
} }
this->element->addToContainer(container, _flags); this->element->addToContainer(container, _flags);

View file

@ -4,28 +4,29 @@
#include "messages/link.hpp" #include "messages/link.hpp"
#include "messages/messagecolor.hpp" #include "messages/messagecolor.hpp"
#include "singletons/fontmanager.hpp" #include "singletons/fontmanager.hpp"
#include "util/emotemap.hpp"
#include <stdint.h>
#include <QRect> #include <QRect>
#include <QString> #include <QString>
#include <QTime> #include <QTime>
#include <boost/noncopyable.hpp> #include <boost/noncopyable.hpp>
#include "util/emotemap.hpp"
#include <cstdint>
#include <memory>
namespace chatterino { namespace chatterino {
class Channel; class Channel;
namespace util { namespace util {
struct EmoteData; struct EmoteData;
} } // namespace util
namespace messages { namespace messages {
namespace layouts { namespace layouts {
struct MessageLayoutContainer; struct MessageLayoutContainer;
} } // namespace layouts
using namespace chatterino::messages::layouts; using namespace chatterino::messages::layouts;
struct MessageElement : boost::noncopyable class MessageElement : boost::noncopyable
{ {
public: public:
enum Flags : uint32_t { enum Flags : uint32_t {
@ -109,9 +110,7 @@ public:
Update_All = Update_Text | Update_Emotes | Update_Images Update_All = Update_Text | Update_Emotes | Update_Images
}; };
virtual ~MessageElement() virtual ~MessageElement() = default;
{
}
MessageElement *setLink(const Link &link); MessageElement *setLink(const Link &link);
MessageElement *setTooltip(const QString &tooltip); MessageElement *setTooltip(const QString &tooltip);
@ -141,8 +140,7 @@ class ImageElement : public MessageElement
public: public:
ImageElement(Image *image, MessageElement::Flags flags); ImageElement(Image *image, MessageElement::Flags flags);
virtual void addToContainer(MessageLayoutContainer &container, void addToContainer(MessageLayoutContainer &container, MessageElement::Flags flags) override;
MessageElement::Flags flags) override;
}; };
// contains a text, it will split it into words // contains a text, it will split it into words
@ -161,9 +159,9 @@ public:
TextElement(const QString &text, MessageElement::Flags flags, TextElement(const QString &text, MessageElement::Flags flags,
const MessageColor &color = MessageColor::Text, const MessageColor &color = MessageColor::Text,
FontStyle style = FontStyle::Medium); FontStyle style = FontStyle::Medium);
~TextElement() override = default;
virtual void addToContainer(MessageLayoutContainer &container, void addToContainer(MessageLayoutContainer &container, MessageElement::Flags flags) override;
MessageElement::Flags flags) override;
}; };
// contains emote data and will pick the emote based on : // contains emote data and will pick the emote based on :
@ -172,30 +170,27 @@ public:
class EmoteElement : public MessageElement class EmoteElement : public MessageElement
{ {
const util::EmoteData data; const util::EmoteData data;
TextElement *textElement; std::unique_ptr<TextElement> textElement;
public: public:
EmoteElement(const util::EmoteData &data, MessageElement::Flags flags); EmoteElement(const util::EmoteData &data, MessageElement::Flags flags);
~EmoteElement(); ~EmoteElement() override = default;
virtual void addToContainer(MessageLayoutContainer &container, void addToContainer(MessageLayoutContainer &container, MessageElement::Flags flags) override;
MessageElement::Flags flags) override;
}; };
// contains a text, formated depending on the preferences // contains a text, formated depending on the preferences
class TimestampElement : public MessageElement class TimestampElement : public MessageElement
{ {
QTime time; QTime time;
TextElement *element; std::unique_ptr<TextElement> element;
QString format; QString format;
public: public:
TimestampElement(); TimestampElement(QTime time = QTime::currentTime());
TimestampElement(QTime time); ~TimestampElement() override = default;
virtual ~TimestampElement();
virtual void addToContainer(MessageLayoutContainer &container, void addToContainer(MessageLayoutContainer &container, MessageElement::Flags flags) override;
MessageElement::Flags flags) override;
TextElement *formatTime(const QTime &time); TextElement *formatTime(const QTime &time);
}; };
@ -207,8 +202,8 @@ class TwitchModerationElement : public MessageElement
public: public:
TwitchModerationElement(); TwitchModerationElement();
virtual void addToContainer(MessageLayoutContainer &container, void addToContainer(MessageLayoutContainer &container, MessageElement::Flags flags) override;
MessageElement::Flags flags) override;
}; };
} // namespace messages } // namespace messages
} // namespace chatterino } // namespace chatterino

View file

@ -4,8 +4,7 @@ namespace chatterino {
namespace messages { namespace messages {
struct MessageParseArgs { struct MessageParseArgs {
public: bool disablePingSounds = false;
bool disablePingSoungs = false;
bool isReceivedWhisper = false; bool isReceivedWhisper = false;
bool isSentWhisper = false; bool isSentWhisper = false;
}; };

View file

@ -1,7 +1,10 @@
#pragma once #pragma once
#include <utility>
namespace chatterino { namespace chatterino {
namespace messages { namespace messages {
struct SelectionItem { struct SelectionItem {
int messageIndex; int messageIndex;
int charIndex; int charIndex;
@ -47,9 +50,7 @@ struct Selection {
SelectionItem min; SelectionItem min;
SelectionItem max; SelectionItem max;
Selection() Selection() = default;
{
}
Selection(const SelectionItem &start, const SelectionItem &end) Selection(const SelectionItem &start, const SelectionItem &end)
: start(start) : start(start)
@ -72,5 +73,6 @@ struct Selection {
return this->min.messageIndex == this->max.messageIndex; return this->min.messageIndex == this->max.messageIndex;
} }
}; };
} // namespace messages } // namespace messages
} // namespace chatterino } // namespace chatterino

View file

@ -2,11 +2,9 @@
#include <fmt/format.h> #include <fmt/format.h>
#include <irccommand.h> #include <irccommand.h>
#include <ircconnection.h> #include <ircconnection.h>
#include <math.h>
#include <rapidjson/document.h> #include <rapidjson/document.h>
#include <rapidjson/error/en.h> #include <rapidjson/error/en.h>
#include <rapidjson/error/error.h> #include <rapidjson/error/error.h>
#include <stdint.h>
#include <IrcMessage> #include <IrcMessage>
#include <QAbstractListModel> #include <QAbstractListModel>
#include <QAbstractNativeEventFilter> #include <QAbstractNativeEventFilter>
@ -127,13 +125,12 @@
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include <boost/noncopyable.hpp> #include <boost/noncopyable.hpp>
#include <boost/optional.hpp> #include <boost/optional.hpp>
#include <boost/signals2.hpp>
#include <boost/signals2/connection.hpp>
#include <cassert> #include <cassert>
#include <chrono> #include <chrono>
#include <cinttypes> #include <cinttypes>
#include <climits> #include <climits>
#include <cmath> #include <cmath>
#include <cstdint>
#include <ctime> #include <ctime>
#include <functional> #include <functional>
#include <future> #include <future>

View file

@ -2,10 +2,12 @@
#include "channel.hpp" #include "channel.hpp"
#include <IrcConnection>
#include <IrcMessage> #include <IrcMessage>
#include <pajlada/signals/signal.hpp>
#include <functional> #include <functional>
#include <mutex> #include <mutex>
#include <pajlada/signals/signal.hpp>
namespace chatterino { namespace chatterino {
namespace providers { namespace providers {
@ -14,6 +16,8 @@ namespace irc {
class AbstractIrcServer class AbstractIrcServer
{ {
public: public:
virtual ~AbstractIrcServer() = default;
// connection // connection
Communi::IrcConnection *getReadConnection() const; Communi::IrcConnection *getReadConnection() const;

View file

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "QString" #include <QString>
namespace chatterino { namespace chatterino {
namespace providers { namespace providers {

View file

@ -1,7 +1,5 @@
#include "ircmessagehandler.hpp" #include "ircmessagehandler.hpp"
#include <memory>
#include "debug/log.hpp" #include "debug/log.hpp"
#include "messages/limitedqueue.hpp" #include "messages/limitedqueue.hpp"
#include "messages/message.hpp" #include "messages/message.hpp"
@ -12,6 +10,8 @@
#include "singletons/resourcemanager.hpp" #include "singletons/resourcemanager.hpp"
#include "singletons/windowmanager.hpp" #include "singletons/windowmanager.hpp"
#include <memory>
using namespace chatterino::singletons; using namespace chatterino::singletons;
using namespace chatterino::messages; using namespace chatterino::messages;
@ -233,6 +233,7 @@ void IrcMessageHandler::handleWriteConnectionNoticeMessage(Communi::IrcNoticeMes
this->handleNoticeMessage(message); this->handleNoticeMessage(message);
} }
} // namespace twitch } // namespace twitch
} // namespace providers } // namespace providers
} // namespace chatterino } // namespace chatterino

View file

@ -13,11 +13,14 @@
// //
namespace chatterino { namespace chatterino {
namespace singletons { namespace singletons {
class AccountManager; class AccountManager;
} } // namespace singletons
namespace providers { namespace providers {
namespace twitch { namespace twitch {
class TwitchAccountManager class TwitchAccountManager
{ {
TwitchAccountManager(); TwitchAccountManager();
@ -62,6 +65,7 @@ private:
friend class chatterino::singletons::AccountManager; friend class chatterino::singletons::AccountManager;
}; };
} // namespace twitch } // namespace twitch
} // namespace providers } // namespace providers
} // namespace chatterino } // namespace chatterino

View file

@ -81,8 +81,6 @@ TwitchChannel::TwitchChannel(const QString &channelName, Communi::IrcConnection
TwitchChannel::~TwitchChannel() TwitchChannel::~TwitchChannel()
{ {
this->connectedConnection.disconnect();
this->liveStatusTimer->stop(); this->liveStatusTimer->stop();
this->liveStatusTimer->deleteLater(); this->liveStatusTimer->deleteLater();
@ -103,7 +101,7 @@ bool TwitchChannel::canSendMessage() const
void TwitchChannel::setRoomID(const QString &_roomID) void TwitchChannel::setRoomID(const QString &_roomID)
{ {
this->roomID = _roomID; this->roomID = _roomID;
this->roomIDchanged(); this->roomIDchanged.invoke();
this->fetchMessages.invoke(); this->fetchMessages.invoke();
} }
@ -155,7 +153,7 @@ void TwitchChannel::setMod(bool value)
if (this->mod != value) { if (this->mod != value) {
this->mod = value; this->mod = value;
this->userStateChanged(); this->userStateChanged.invoke();
} }
} }
@ -194,7 +192,7 @@ void TwitchChannel::setLive(bool newLiveStatus)
this->streamStatus.live = newLiveStatus; this->streamStatus.live = newLiveStatus;
} }
this->onlineStatusChanged(); this->onlineStatusChanged.invoke();
} }
void TwitchChannel::refreshLiveStatus() void TwitchChannel::refreshLiveStatus()

View file

@ -53,11 +53,11 @@ public:
const QString popoutPlayerURL; const QString popoutPlayerURL;
void setRoomID(const QString &_roomID); void setRoomID(const QString &_roomID);
boost::signals2::signal<void()> roomIDchanged; pajlada::Signals::NoArgSignal roomIDchanged;
boost::signals2::signal<void()> onlineStatusChanged; pajlada::Signals::NoArgSignal onlineStatusChanged;
pajlada::Signals::NoArgBoltSignal fetchMessages; pajlada::Signals::NoArgBoltSignal fetchMessages;
boost::signals2::signal<void()> userStateChanged; pajlada::Signals::NoArgSignal userStateChanged;
QString roomID; QString roomID;
@ -89,8 +89,6 @@ private:
void fetchRecentMessages(); void fetchRecentMessages();
boost::signals2::connection connectedConnection;
bool mod; bool mod;
QByteArray messageSuffix; QByteArray messageSuffix;
QString lastSentMessage; QString lastSentMessage;

View file

@ -8,7 +8,7 @@ namespace twitch {
bool TrimChannelName(const QString &channelName, QString &outChannelName) bool TrimChannelName(const QString &channelName, QString &outChannelName)
{ {
if (channelName.length() < 3) { if (channelName.length() < 3) {
debug::Log("channel name length below 2"); debug::Log("channel name length below 3");
return false; return false;
} }

View file

@ -552,7 +552,7 @@ util::EmoteData EmoteManager::getCheerImage(long long amount, bool animated)
return util::EmoteData(); return util::EmoteData();
} }
boost::signals2::signal<void()> &EmoteManager::getGifUpdateSignal() pajlada::Signals::NoArgSignal &EmoteManager::getGifUpdateSignal()
{ {
if (!this->gifUpdateTimerInitiated) { if (!this->gifUpdateTimerInitiated) {
this->gifUpdateTimerInitiated = true; this->gifUpdateTimerInitiated = true;
@ -571,7 +571,7 @@ boost::signals2::signal<void()> &EmoteManager::getGifUpdateSignal()
}); });
QObject::connect(&this->gifUpdateTimer, &QTimer::timeout, [this] { QObject::connect(&this->gifUpdateTimer, &QTimer::timeout, [this] {
this->gifUpdateTimerSignal(); this->gifUpdateTimerSignal.invoke();
// fourtf: // fourtf:
auto &windowManager = singletons::WindowManager::getInstance(); auto &windowManager = singletons::WindowManager::getInstance();
windowManager.repaintGifEmotes(); windowManager.repaintGifEmotes();

View file

@ -15,7 +15,7 @@
#include <QRegularExpression> #include <QRegularExpression>
#include <QString> #include <QString>
#include <QTimer> #include <QTimer>
#include <boost/signals2.hpp> #include <pajlada/signals/signal.hpp>
namespace chatterino { namespace chatterino {
namespace singletons { namespace singletons {
@ -56,7 +56,7 @@ public:
_generation++; _generation++;
} }
boost::signals2::signal<void()> &getGifUpdateSignal(); pajlada::Signals::NoArgSignal &getGifUpdateSignal();
// Bit badge/emotes? // Bit badge/emotes?
util::ConcurrentMap<QString, messages::Image *> miscImageCache; util::ConcurrentMap<QString, messages::Image *> miscImageCache;
@ -140,7 +140,7 @@ private:
/// Chatterino emotes /// Chatterino emotes
util::EmoteMap _chatterinoEmotes; util::EmoteMap _chatterinoEmotes;
boost::signals2::signal<void()> gifUpdateTimerSignal; pajlada::Signals::NoArgSignal gifUpdateTimerSignal;
QTimer gifUpdateTimer; QTimer gifUpdateTimer;
bool gifUpdateTimerInitiated = false; bool gifUpdateTimerInitiated = false;

View file

@ -105,5 +105,6 @@ FontManager::Font &FontManager::getCurrentFont(float scale)
return this->currentFontByScale.back().second; return this->currentFontByScale.back().second;
} }
} // namespace singletons } // namespace singletons
} // namespace chatterino } // namespace chatterino

View file

@ -137,7 +137,9 @@ private:
int generation = 0; int generation = 0;
}; };
} // namespace singletons } // namespace singletons
typedef singletons::FontManager::Type FontStyle; using FontStyle = singletons::FontManager::Type;
} // namespace chatterino } // namespace chatterino

View file

@ -2,6 +2,7 @@
namespace chatterino { namespace chatterino {
namespace singletons { namespace singletons {
static void _registerSetting(std::weak_ptr<pajlada::Settings::ISettingData> setting); static void _registerSetting(std::weak_ptr<pajlada::Settings::ISettingData> setting);
template <typename Type> template <typename Type>
@ -71,5 +72,6 @@ public:
return this->getValue(); return this->getValue();
} }
}; };
}
} } // namespace singletons
} // namespace chatterino

View file

@ -46,5 +46,6 @@ const QString &ModerationAction::getAction() const
{ {
return this->action; return this->action;
} }
} // namespace singletons } // namespace singletons
} // namespace chatterino } // namespace chatterino

View file

@ -3,9 +3,11 @@
#include <QString> #include <QString>
namespace chatterino { namespace chatterino {
namespace messages { namespace messages {
class Image; class Image;
} } // namespace messages
namespace singletons { namespace singletons {
class ModerationAction class ModerationAction
@ -27,5 +29,6 @@ private:
QString line2; QString line2;
QString action; QString action;
}; };
} // namespace singletons } // namespace singletons
} // namespace chatterino } // namespace chatterino

View file

@ -4,7 +4,7 @@
#include <QColor> #include <QColor>
#include <math.h> #include <cmath>
namespace chatterino { namespace chatterino {
namespace singletons { namespace singletons {
@ -156,7 +156,7 @@ void ThemeManager::actuallyUpdate(double hue, double multiplier)
// Selection // Selection
this->messages.selection = isLightTheme() ? QColor(0, 0, 0, 64) : QColor(255, 255, 255, 64); this->messages.selection = isLightTheme() ? QColor(0, 0, 0, 64) : QColor(255, 255, 255, 64);
this->updated(); this->updated.invoke();
} }
QColor ThemeManager::blendColors(const QColor &color1, const QColor &color2, qreal ratio) QColor ThemeManager::blendColors(const QColor &color1, const QColor &color2, qreal ratio)

View file

@ -1,10 +1,10 @@
#pragma once #pragma once
#include "util/serialize-custom.hpp"
#include <QBrush> #include <QBrush>
#include <QColor> #include <QColor>
#include <boost/signals2.hpp>
#include <pajlada/settings/setting.hpp> #include <pajlada/settings/setting.hpp>
#include "util/serialize-custom.hpp"
namespace chatterino { namespace chatterino {
namespace singletons { namespace singletons {
@ -105,7 +105,7 @@ public:
void update(); void update();
boost::signals2::signal<void()> updated; pajlada::Signals::NoArgSignal updated;
pajlada::Settings::Setting<QString> themeName; pajlada::Settings::Setting<QString> themeName;
pajlada::Settings::Setting<double> themeHue; pajlada::Settings::Setting<double> themeHue;

View file

@ -58,7 +58,7 @@ void WindowManager::initMainWindow()
void WindowManager::layoutVisibleChatWidgets(Channel *channel) void WindowManager::layoutVisibleChatWidgets(Channel *channel)
{ {
this->layout(channel); this->layout.invoke(channel);
} }
void WindowManager::repaintVisibleChatWidgets(Channel *channel) void WindowManager::repaintVisibleChatWidgets(Channel *channel)
@ -70,7 +70,7 @@ void WindowManager::repaintVisibleChatWidgets(Channel *channel)
void WindowManager::repaintGifEmotes() void WindowManager::repaintGifEmotes()
{ {
this->repaintGifs(); this->repaintGifs.invoke();
} }
// void WindowManager::updateAll() // void WindowManager::updateAll()

View file

@ -32,8 +32,8 @@ public:
void save(); void save();
boost::signals2::signal<void()> repaintGifs; pajlada::Signals::NoArgSignal repaintGifs;
boost::signals2::signal<void(Channel *)> layout; pajlada::Signals::Signal<Channel *> layout;
private: private:
ThemeManager &themeManager; ThemeManager &themeManager;

View file

@ -126,5 +126,6 @@ private:
return this->item->layout(); return this->item->layout();
} }
}; };
} // namespace util } // namespace util
} // namespace chatterino } // namespace chatterino

View file

@ -9,6 +9,7 @@
namespace chatterino { namespace chatterino {
namespace util { namespace util {
static boost::optional<UINT> getWindowDpi(quintptr ptr) static boost::optional<UINT> getWindowDpi(quintptr ptr)
{ {
typedef UINT(WINAPI * GetDpiForWindow)(HWND); typedef UINT(WINAPI * GetDpiForWindow)(HWND);

View file

@ -5,6 +5,8 @@
#include "util/networkrequester.hpp" #include "util/networkrequester.hpp"
#include "util/networkworker.hpp" #include "util/networkworker.hpp"
#include <rapidjson/document.h>
#include <rapidjson/error/en.h>
#include <QCryptographicHash> #include <QCryptographicHash>
#include <QFile> #include <QFile>
@ -152,7 +154,7 @@ public:
if (this->data.caller != nullptr) { if (this->data.caller != nullptr) {
QObject::connect(worker, &NetworkWorker::doneUrl, this->data.caller, QObject::connect(worker, &NetworkWorker::doneUrl, this->data.caller,
[ onFinished, data = this->data ](auto reply) mutable { [onFinished, data = this->data](auto reply) mutable {
if (reply->error() != QNetworkReply::NetworkError::NoError) { if (reply->error() != QNetworkReply::NetworkError::NoError) {
// TODO: We might want to call an onError callback here // TODO: We might want to call an onError callback here
return; return;
@ -172,7 +174,7 @@ public:
QObject::connect( QObject::connect(
&requester, &NetworkRequester::requestUrl, worker, &requester, &NetworkRequester::requestUrl, worker,
[ timer, data = std::move(this->data), worker, onFinished{std::move(onFinished)} ]() { [timer, data = std::move(this->data), worker, onFinished{std::move(onFinished)}]() {
QNetworkReply *reply = NetworkManager::NaM.get(data.request); QNetworkReply *reply = NetworkManager::NaM.get(data.request);
if (timer != nullptr) { if (timer != nullptr) {
@ -187,9 +189,9 @@ public:
data.onReplyCreated(reply); data.onReplyCreated(reply);
} }
QObject::connect(reply, &QNetworkReply::finished, worker, [ QObject::connect(reply, &QNetworkReply::finished, worker,
data = std::move(data), worker, reply, onFinished = std::move(onFinished) [data = std::move(data), worker, reply,
]() mutable { onFinished = std::move(onFinished)]() mutable {
if (data.caller == nullptr) { if (data.caller == nullptr) {
QByteArray bytes = reply->readAll(); QByteArray bytes = reply->readAll();
data.writeToCache(bytes); data.writeToCache(bytes);

View file

@ -2,6 +2,8 @@
#include <QObject> #include <QObject>
class QNetworkReply;
namespace chatterino { namespace chatterino {
namespace util { namespace util {

View file

@ -11,6 +11,7 @@
namespace chatterino { namespace chatterino {
namespace util { namespace util {
class LambdaRunnable : public QRunnable class LambdaRunnable : public QRunnable
{ {
public: public:
@ -47,12 +48,13 @@ static void postToThread(F &&fun, QObject *obj = qApp)
, fun(fun) , fun(fun)
{ {
} }
~Event() ~Event() override
{ {
fun(); fun();
} }
}; };
QCoreApplication::postEvent(obj, new Event(std::forward<F>(fun))); QCoreApplication::postEvent(obj, new Event(std::forward<F>(fun)));
} }
} // namespace util } // namespace util
} // namespace chatterino } // namespace chatterino

View file

@ -4,6 +4,7 @@
namespace chatterino { namespace chatterino {
namespace util { namespace util {
template <typename T> template <typename T>
class Property final : boost::noncopyable class Property final : boost::noncopyable
{ {
@ -30,5 +31,6 @@ public:
protected: protected:
T value; T value;
}; };
}
} } // namespace util
} // namespace chatterino

View file

@ -1,6 +1,7 @@
#pragma once #pragma once
#include <QString> #include <QString>
#include <QStringList>
#include <stdexcept> #include <stdexcept>
#include <string> #include <string>

View file

@ -9,6 +9,7 @@
#include <rapidjson/document.h> #include <rapidjson/document.h>
#include <rapidjson/error/en.h> #include <rapidjson/error/en.h>
#include <rapidjson/error/error.h> #include <rapidjson/error/error.h>
#include <QByteArray>
#include <QEventLoop> #include <QEventLoop>
#include <QJsonArray> #include <QJsonArray>
#include <QJsonDocument> #include <QJsonDocument>

View file

@ -11,7 +11,7 @@
namespace Ui { namespace Ui {
class AccountPopup; class AccountPopup;
} } // namespace Ui
namespace chatterino { namespace chatterino {
@ -35,7 +35,7 @@ signals:
void refreshButtons(); void refreshButtons();
protected: protected:
virtual void scaleChangedEvent(float newDpi) override; void scaleChangedEvent(float newDpi) override;
private: private:
Ui::AccountPopup *ui; Ui::AccountPopup *ui;
@ -76,8 +76,8 @@ private:
} relationship; } relationship;
protected: protected:
virtual void focusOutEvent(QFocusEvent *event) override; void focusOutEvent(QFocusEvent *event) override;
virtual void showEvent(QShowEvent *event) override; void showEvent(QShowEvent *event) override;
}; };
} // namespace widgets } // namespace widgets

View file

@ -54,5 +54,6 @@ void AccountSwitchPopupWidget::paintEvent(QPaintEvent *event)
painter.fillRect(this->rect(), QColor(255, 255, 255)); painter.fillRect(this->rect(), QColor(255, 255, 255));
} }
} // namespace widgets } // namespace widgets
} // namespace chatterino } // namespace chatterino

View file

@ -17,8 +17,8 @@ public:
void refresh(); void refresh();
protected: protected:
virtual void focusOutEvent(QFocusEvent *event) override final; void focusOutEvent(QFocusEvent *event) final;
virtual void paintEvent(QPaintEvent *event) override; void paintEvent(QPaintEvent *event) override;
private: private:
struct { struct {

View file

@ -1,4 +1,5 @@
#include "widgets/basewidget.hpp" #include "widgets/basewidget.hpp"
#include "debug/log.hpp"
#include "singletons/settingsmanager.hpp" #include "singletons/settingsmanager.hpp"
#include "singletons/thememanager.hpp" #include "singletons/thememanager.hpp"
@ -7,7 +8,6 @@
#include <QIcon> #include <QIcon>
#include <QLayout> #include <QLayout>
#include <QtGlobal> #include <QtGlobal>
#include <boost/signals2.hpp>
namespace chatterino { namespace chatterino {
namespace widgets { namespace widgets {
@ -82,13 +82,13 @@ void BaseWidget::setScaleIndependantHeight(int value)
void BaseWidget::init() void BaseWidget::init()
{ {
auto connection = this->themeManager.updated.connect([this]() { pajlada::Signals::Connection connection = this->themeManager.updated.connect([this]() {
this->themeRefreshEvent(); this->themeRefreshEvent();
this->update(); this->update();
}); });
QObject::connect(this, &QObject::destroyed, [connection] { QObject::connect(this, &QObject::destroyed, [connection]() mutable {
connection.disconnect(); // connection.disconnect(); //
}); });
} }

View file

@ -6,9 +6,10 @@
namespace chatterino { namespace chatterino {
namespace singletons { namespace singletons {
class ThemeManager; class ThemeManager;
} } // namespace singletons
namespace widgets { namespace widgets {
class BaseWindow; class BaseWindow;
class BaseWidget : public QWidget class BaseWidget : public QWidget
@ -34,7 +35,7 @@ public:
void setScaleIndependantHeight(int value); void setScaleIndependantHeight(int value);
protected: protected:
virtual void childEvent(QChildEvent *) override; void childEvent(QChildEvent *) override;
virtual void scaleChangedEvent(float newScale); virtual void scaleChangedEvent(float newScale);
virtual void themeRefreshEvent(); virtual void themeRefreshEvent();

View file

@ -1,5 +1,6 @@
#include "basewindow.hpp" #include "basewindow.hpp"
#include "debug/log.hpp"
#include "singletons/settingsmanager.hpp" #include "singletons/settingsmanager.hpp"
#include "util/nativeeventhelper.hpp" #include "util/nativeeventhelper.hpp"
#include "widgets/helper/rippleeffectlabel.hpp" #include "widgets/helper/rippleeffectlabel.hpp"
@ -11,10 +12,10 @@
#include <QIcon> #include <QIcon>
#ifdef USEWINSDK #ifdef USEWINSDK
#include <ObjIdl.h>
#include <Windows.h>
#include <dwmapi.h> #include <dwmapi.h>
#include <gdiplus.h> #include <gdiplus.h>
#include <objidl.h>
#include <windows.h>
#include <windowsx.h> #include <windowsx.h>
#pragma comment(lib, "Dwmapi.lib") #pragma comment(lib, "Dwmapi.lib")

View file

@ -9,12 +9,15 @@ class QHBoxLayout;
namespace chatterino { namespace chatterino {
namespace widgets { namespace widgets {
class RippleEffectButton; class RippleEffectButton;
class RippleEffectLabel; class RippleEffectLabel;
class TitleBarButton; class TitleBarButton;
class BaseWindow : public BaseWidget class BaseWindow : public BaseWidget
{ {
Q_OBJECT
public: public:
explicit BaseWindow(singletons::ThemeManager &_themeManager, QWidget *parent, explicit BaseWindow(singletons::ThemeManager &_themeManager, QWidget *parent,
bool enableCustomFrame = false); bool enableCustomFrame = false);
@ -60,5 +63,6 @@ private:
QWidget *layoutBase; QWidget *layoutBase;
std::vector<RippleEffectButton *> buttons; std::vector<RippleEffectButton *> buttons;
}; };
} // namespace widgets } // namespace widgets
} // namespace chatterino } // namespace chatterino

View file

@ -20,9 +20,9 @@
#include <QGraphicsBlurEffect> #include <QGraphicsBlurEffect>
#include <QPainter> #include <QPainter>
#include <math.h>
#include <algorithm> #include <algorithm>
#include <chrono> #include <chrono>
#include <cmath>
#include <functional> #include <functional>
#include <memory> #include <memory>
@ -461,7 +461,7 @@ void ChannelView::setSelection(const SelectionItem &start, const SelectionItem &
// selections // selections
this->selection = Selection(start, end); this->selection = Selection(start, end);
this->selectionChanged(); this->selectionChanged.invoke();
} }
messages::MessageElement::Flags ChannelView::getFlags() const messages::MessageElement::Flags ChannelView::getFlags() const
@ -729,7 +729,7 @@ void ChannelView::mousePressEvent(QMouseEvent *event)
QPoint relativePos; QPoint relativePos;
int messageIndex; int messageIndex;
this->mouseDown(event); this->mouseDown.invoke(event);
if (!tryGetMessageAt(event->pos(), layout, relativePos, messageIndex)) { if (!tryGetMessageAt(event->pos(), layout, relativePos, messageIndex)) {
setCursor(Qt::ArrowCursor); setCursor(Qt::ArrowCursor);

View file

@ -16,8 +16,8 @@
#include <QTimer> #include <QTimer>
#include <QWheelEvent> #include <QWheelEvent>
#include <QWidget> #include <QWidget>
#include <boost/signals2.hpp>
#include <pajlada/signals/signal.hpp> #include <pajlada/signals/signal.hpp>
#include <unordered_set> #include <unordered_set>
namespace chatterino { namespace chatterino {
@ -28,7 +28,7 @@ class ChannelView : public BaseWidget
Q_OBJECT Q_OBJECT
public: public:
explicit ChannelView(BaseWidget *parent = 0); explicit ChannelView(BaseWidget *parent = nullptr);
virtual ~ChannelView(); virtual ~ChannelView();
void queueUpdate(); void queueUpdate();
@ -49,26 +49,26 @@ public:
void clearMessages(); void clearMessages();
boost::signals2::signal<void(QMouseEvent *)> mouseDown; pajlada::Signals::Signal<QMouseEvent *> mouseDown;
boost::signals2::signal<void()> selectionChanged; pajlada::Signals::NoArgSignal selectionChanged;
pajlada::Signals::NoArgSignal highlightedMessageReceived; pajlada::Signals::NoArgSignal highlightedMessageReceived;
pajlada::Signals::Signal<const messages::Link &> linkClicked; pajlada::Signals::Signal<const messages::Link &> linkClicked;
protected: protected:
virtual void themeRefreshEvent() override; void themeRefreshEvent() override;
virtual void resizeEvent(QResizeEvent *) override; void resizeEvent(QResizeEvent *) override;
virtual void paintEvent(QPaintEvent *) override; void paintEvent(QPaintEvent *) override;
virtual void wheelEvent(QWheelEvent *event) override; void wheelEvent(QWheelEvent *event) override;
virtual void enterEvent(QEvent *) override; void enterEvent(QEvent *) override;
virtual void leaveEvent(QEvent *) override; void leaveEvent(QEvent *) override;
virtual void mouseMoveEvent(QMouseEvent *event) override; void mouseMoveEvent(QMouseEvent *event) override;
virtual void mousePressEvent(QMouseEvent *event) override; void mousePressEvent(QMouseEvent *event) override;
virtual void mouseReleaseEvent(QMouseEvent *event) override; void mouseReleaseEvent(QMouseEvent *event) override;
virtual void mouseDoubleClickEvent(QMouseEvent *event) override; void mouseDoubleClickEvent(QMouseEvent *event) override;
void handleLinkClick(QMouseEvent *event, const messages::Link &link, void handleLinkClick(QMouseEvent *event, const messages::Link &link,
messages::MessageLayout *layout); messages::MessageLayout *layout);
@ -116,12 +116,12 @@ private:
messages::LimitedQueue<messages::MessageLayoutPtr> messages; messages::LimitedQueue<messages::MessageLayoutPtr> messages;
boost::signals2::connection messageAppendedConnection; pajlada::Signals::Connection messageAppendedConnection;
boost::signals2::connection messageAddedAtStartConnection; pajlada::Signals::Connection messageAddedAtStartConnection;
boost::signals2::connection messageRemovedConnection; pajlada::Signals::Connection messageRemovedConnection;
boost::signals2::connection messageReplacedConnection; pajlada::Signals::Connection messageReplacedConnection;
boost::signals2::connection repaintGifsConnection; pajlada::Signals::Connection repaintGifsConnection;
boost::signals2::connection layoutConnection; pajlada::Signals::Connection layoutConnection;
std::vector<pajlada::Signals::ScopedConnection> managedConnections; std::vector<pajlada::Signals::ScopedConnection> managedConnections;

View file

@ -16,8 +16,8 @@ public:
void setBounds(const QRect &rect); void setBounds(const QRect &rect);
protected: protected:
virtual void paintEvent(QPaintEvent *) override; void paintEvent(QPaintEvent *) override;
virtual void hideEvent(QHideEvent *) override; void hideEvent(QHideEvent *) override;
QPropertyAnimation positionAnimation; QPropertyAnimation positionAnimation;
QRect desiredGeometry; QRect desiredGeometry;

View file

@ -5,6 +5,7 @@
namespace chatterino { namespace chatterino {
namespace widgets { namespace widgets {
Label::Label(BaseWidget *parent) Label::Label(BaseWidget *parent)
: BaseWidget(parent) : BaseWidget(parent)
{ {
@ -74,5 +75,6 @@ void Label::paintEvent(QPaintEvent *)
painter.drawText(this->rect(), flags, this->text); painter.drawText(this->rect(), flags, this->text);
} }
} // namespace widgets } // namespace widgets
} // namespace chatterino } // namespace chatterino

View file

@ -29,5 +29,6 @@ private:
QString text; QString text;
FontStyle fontStyle = FontStyle::Medium; FontStyle fontStyle = FontStyle::Medium;
}; };
} // namespace widgets } // namespace widgets
} // namespace chatterino } // namespace chatterino

View file

@ -144,5 +144,6 @@ void NotebookButton::dropEvent(QDropEvent *event)
} }
} }
} }
} // namespace widgets } // namespace widgets
} // namespace chatterino } // namespace chatterino

View file

@ -12,6 +12,7 @@
#include <QDebug> #include <QDebug>
#include <QLinearGradient> #include <QLinearGradient>
#include <QPainter> #include <QPainter>
#include <boost/bind.hpp>
namespace chatterino { namespace chatterino {
namespace widgets { namespace widgets {

View file

@ -9,7 +9,6 @@
#include <pajlada/signals/connection.hpp> #include <pajlada/signals/connection.hpp>
namespace chatterino { namespace chatterino {
namespace widgets { namespace widgets {
class Notebook; class Notebook;

View file

@ -73,7 +73,7 @@ void ResizingTextEdit::keyPressEvent(QKeyEvent *event)
{ {
event->ignore(); event->ignore();
this->keyPressed(event); this->keyPressed.invoke(event);
if (event->key() == Qt::Key_Backtab) { if (event->key() == Qt::Key_Backtab) {
// Ignore for now. We want to use it for autocomplete later // Ignore for now. We want to use it for autocomplete later

View file

@ -3,7 +3,7 @@
#include <QCompleter> #include <QCompleter>
#include <QKeyEvent> #include <QKeyEvent>
#include <QTextEdit> #include <QTextEdit>
#include <boost/signals2.hpp> #include <pajlada/signals/signal.hpp>
class ResizingTextEdit : public QTextEdit class ResizingTextEdit : public QTextEdit
{ {
@ -14,14 +14,14 @@ public:
bool hasHeightForWidth() const override; bool hasHeightForWidth() const override;
boost::signals2::signal<void(QKeyEvent *)> keyPressed; pajlada::Signals::Signal<QKeyEvent *> keyPressed;
void setCompleter(QCompleter *c); void setCompleter(QCompleter *c);
QCompleter *getCompleter() const; QCompleter *getCompleter() const;
protected: protected:
virtual int heightForWidth(int) const override; int heightForWidth(int) const override;
virtual void keyPressEvent(QKeyEvent *event) override; void keyPressEvent(QKeyEvent *event) override;
private: private:
QCompleter *completer = nullptr; QCompleter *completer = nullptr;

View file

@ -1,9 +1,10 @@
#pragma once #pragma once
#include "QString" #include <QString>
namespace chatterino { namespace chatterino {
namespace widgets { namespace widgets {
class ScrollbarHighlight class ScrollbarHighlight
{ {
public: public:

View file

@ -1,15 +1,19 @@
#pragma once #pragma once
#include <memory>
#include "messages/limitedqueuesnapshot.hpp" #include "messages/limitedqueuesnapshot.hpp"
#include "messages/message.hpp" #include "messages/message.hpp"
#include "widgets/basewindow.hpp" #include "widgets/basewindow.hpp"
#include <memory>
class QLineEdit; class QLineEdit;
namespace chatterino { namespace chatterino {
class Channel; class Channel;
namespace widgets { namespace widgets {
class ChannelView; class ChannelView;
class SearchPopup : public BaseWindow class SearchPopup : public BaseWindow
@ -27,5 +31,6 @@ private:
void initLayout(); void initLayout();
void performSearch(); void performSearch();
}; };
} // namespace widgets } // namespace widgets
} // namespace chatterino } // namespace chatterino

View file

@ -1,16 +1,16 @@
#pragma once #pragma once
#include "widgets/basewidget.hpp"
#include <QIcon> #include <QIcon>
#include <QPaintEvent> #include <QPaintEvent>
#include <QWidget> #include <QWidget>
#include "widgets/basewidget.hpp"
namespace chatterino { namespace chatterino {
namespace widgets { namespace widgets {
namespace settingspages { namespace settingspages {
class SettingsPage; class SettingsPage;
} } // namespace settingspages
class SettingsDialog; class SettingsDialog;

View file

@ -2,8 +2,6 @@
namespace chatterino { namespace chatterino {
namespace helper { namespace helper {
SplitColumn::SplitColumn()
{ } // namespace helper
} } // namespace chatterino
}
}

View file

@ -1,15 +1,16 @@
#pragma once #pragma once
#include <vector>
#include "widgets/split.hpp" #include "widgets/split.hpp"
#include <vector>
namespace chatterino { namespace chatterino {
namespace helper { namespace helper {
class SplitColumn class SplitColumn
{ {
public: public:
SplitColumn(); SplitColumn() = default;
void insert(widgets::Split *split, int index = -1); void insert(widgets::Split *split, int index = -1);
void remove(int index); void remove(int index);
@ -19,5 +20,6 @@ public:
private: private:
std::vector<widgets::Split> items; std::vector<widgets::Split> items;
}; };
}
} } // namespace helper
} // namespace chatterino

View file

@ -57,7 +57,8 @@ SplitHeader::SplitHeader(Split *_split)
title->setMouseTracking(true); title->setMouseTracking(true);
QObject::connect(this->titleLabel, &SignalLabel::mouseDoubleClick, this, QObject::connect(this->titleLabel, &SignalLabel::mouseDoubleClick, this,
&SplitHeader::mouseDoubleClickEvent); &SplitHeader::mouseDoubleClickEvent);
QObject::connect(this->titleLabel, &SignalLabel::mouseMove, this, &SplitHeader::mouseMoveEvent); QObject::connect(this->titleLabel, &SignalLabel::mouseMove, this,
&SplitHeader::mouseMoveEvent);
layout->addStretch(1); layout->addStretch(1);

View file

@ -13,11 +13,9 @@
#include <QPaintEvent> #include <QPaintEvent>
#include <QPoint> #include <QPoint>
#include <QWidget> #include <QWidget>
#include <boost/signals2/connection.hpp>
#include <pajlada/settings/setting.hpp> #include <pajlada/settings/setting.hpp>
namespace chatterino { namespace chatterino {
namespace widgets { namespace widgets {
class Split; class Split;
@ -50,7 +48,7 @@ private:
QPoint dragStart; QPoint dragStart;
bool dragging = false; bool dragging = false;
boost::signals2::connection onlineStatusChangedConnection; pajlada::Signals::Connection onlineStatusChangedConnection;
RippleEffectButton *dropdownButton; RippleEffectButton *dropdownButton;
// Label *titleLabel; // Label *titleLabel;

View file

@ -162,7 +162,7 @@ void Scrollbar::offset(qreal value)
} }
} }
boost::signals2::signal<void()> &Scrollbar::getCurrentValueChanged() pajlada::Signals::NoArgSignal &Scrollbar::getCurrentValueChanged()
{ {
return this->currentValueChanged; return this->currentValueChanged;
} }
@ -176,7 +176,7 @@ void Scrollbar::setCurrentValue(qreal value)
this->currentValue = value; this->currentValue = value;
this->updateScroll(); this->updateScroll();
this->currentValueChanged(); this->currentValueChanged.invoke();
this->update(); this->update();
} }

View file

@ -8,7 +8,7 @@
#include <QMutex> #include <QMutex>
#include <QPropertyAnimation> #include <QPropertyAnimation>
#include <QWidget> #include <QWidget>
#include <boost/signals2.hpp> #include <pajlada/signals/signal.hpp>
namespace chatterino { namespace chatterino {
@ -43,7 +43,7 @@ public:
qreal getCurrentValue() const; qreal getCurrentValue() const;
// offset the desired value without breaking smooth scolling // offset the desired value without breaking smooth scolling
void offset(qreal value); void offset(qreal value);
boost::signals2::signal<void()> &getCurrentValueChanged(); pajlada::Signals::NoArgSignal &getCurrentValueChanged();
void setCurrentValue(qreal value); void setCurrentValue(qreal value);
void printCurrentState(const QString &prefix = QString()) const; void printCurrentState(const QString &prefix = QString()) const;
@ -86,7 +86,7 @@ private:
qreal currentValue = 0; qreal currentValue = 0;
qreal smoothScrollingOffset = 0; qreal smoothScrollingOffset = 0;
boost::signals2::signal<void()> currentValueChanged; pajlada::Signals::NoArgSignal currentValueChanged;
pajlada::Settings::Setting<bool> &smoothScrollingSetting; pajlada::Settings::Setting<bool> &smoothScrollingSetting;

View file

@ -13,7 +13,7 @@ namespace widgets {
namespace settingspages { namespace settingspages {
class SettingsPage; class SettingsPage;
} } // namespace settingspages
class SettingsDialogTab; class SettingsDialogTab;
@ -32,7 +32,7 @@ public:
static void showDialog(PreferredTab preferredTab = PreferredTab::NoPreference); static void showDialog(PreferredTab preferredTab = PreferredTab::NoPreference);
protected: protected:
virtual void scaleChangedEvent(float newDpi) override; void scaleChangedEvent(float newDpi) override;
private: private:
void refresh(); void refresh();

View file

@ -53,6 +53,7 @@ AboutPage::AboutPage()
} }
layout->addStretch(1); layout->addStretch(1);
} }
} // namespace settingspages } // namespace settingspages
} // namespace widgets } // namespace widgets
} // namespace chatterino } // namespace chatterino

View file

@ -16,6 +16,7 @@ public:
private: private:
QLabel *logo; QLabel *logo;
}; };
} // namespace settingspages } // namespace settingspages
} // namespace widgets } // namespace widgets
} // namespace chatterino } // namespace chatterino

View file

@ -11,6 +11,7 @@
namespace chatterino { namespace chatterino {
namespace widgets { namespace widgets {
namespace settingspages { namespace settingspages {
AccountsPage::AccountsPage() AccountsPage::AccountsPage()
: SettingsPage("Accounts", ":/images/accounts.svg") : SettingsPage("Accounts", ":/images/accounts.svg")
{ {
@ -41,6 +42,7 @@ AccountsPage::AccountsPage()
singletons::AccountManager::getInstance().Twitch.removeUser(selectedUser); singletons::AccountManager::getInstance().Twitch.removeUser(selectedUser);
}); });
} }
} // namespace settingspages } // namespace settingspages
} // namespace widgets } // namespace widgets
} // namespace chatterino } // namespace chatterino

View file

@ -1,10 +1,10 @@
#pragma once #pragma once
#include <QPushButton>
#include "widgets/accountswitchwidget.hpp" #include "widgets/accountswitchwidget.hpp"
#include "widgets/settingspages/settingspage.hpp" #include "widgets/settingspages/settingspage.hpp"
#include <QPushButton>
namespace chatterino { namespace chatterino {
namespace widgets { namespace widgets {
namespace settingspages { namespace settingspages {
@ -19,6 +19,7 @@ private:
QPushButton *removeButton; QPushButton *removeButton;
AccountSwitchWidget *accSwitchWidget; AccountSwitchWidget *accSwitchWidget;
}; };
} // namespace settingspages } // namespace settingspages
} // namespace widgets } // namespace widgets
} // namespace chatterino } // namespace chatterino

View file

@ -5,6 +5,7 @@
#include <QGroupBox> #include <QGroupBox>
#include <QLabel> #include <QLabel>
#include <QPushButton> #include <QPushButton>
#include <QSlider>
#include <QVBoxLayout> #include <QVBoxLayout>
#include "util/layoutcreator.hpp" #include "util/layoutcreator.hpp"
@ -65,7 +66,8 @@ AppearancePage::AppearancePage()
} }
messages.append(this->createCheckBox("Show badges", settings.showBadges)); messages.append(this->createCheckBox("Show badges", settings.showBadges));
messages.append(this->createCheckBox("Seperate messages", settings.seperateMessages)); messages.append(this->createCheckBox("Seperate messages", settings.seperateMessages));
messages.append(this->createCheckBox("Show message length while typing", settings.showMessageLength)); messages.append(
this->createCheckBox("Show message length while typing", settings.showMessageLength));
} }
layout->addStretch(1); layout->addStretch(1);
@ -148,6 +150,7 @@ QLayout *AppearancePage::createFontChanger()
return layout; return layout;
} }
} // namespace settingspages } // namespace settingspages
} // namespace widgets } // namespace widgets
} // namespace chatterino } // namespace chatterino

View file

@ -2,8 +2,6 @@
#include "widgets/settingspages/settingspage.hpp" #include "widgets/settingspages/settingspage.hpp"
#include <QSlider>
namespace chatterino { namespace chatterino {
namespace widgets { namespace widgets {
namespace settingspages { namespace settingspages {

View file

@ -19,6 +19,7 @@
namespace chatterino { namespace chatterino {
namespace widgets { namespace widgets {
namespace settingspages { namespace settingspages {
BehaviourPage::BehaviourPage() BehaviourPage::BehaviourPage()
: SettingsPage("Behaviour", ":/images/behave.svg") : SettingsPage("Behaviour", ":/images/behave.svg")
{ {
@ -80,6 +81,7 @@ QSlider *BehaviourPage::createMouseScrollSlider()
return slider; return slider;
} }
} // namespace settingspages } // namespace settingspages
} // namespace widgets } // namespace widgets
} // namespace chatterino } // namespace chatterino

View file

@ -11,6 +11,7 @@ class EmotesPage : public SettingsPage
public: public:
EmotesPage(); EmotesPage();
}; };
} // namespace settingspages } // namespace settingspages
} // namespace widgets } // namespace widgets
} // namespace chatterino } // namespace chatterino

View file

@ -19,6 +19,7 @@
namespace chatterino { namespace chatterino {
namespace widgets { namespace widgets {
namespace settingspages { namespace settingspages {
HighlightingPage::HighlightingPage() HighlightingPage::HighlightingPage()
: SettingsPage("Highlights", ":/images/notifications.svg") : SettingsPage("Highlights", ":/images/notifications.svg")
{ {
@ -239,6 +240,7 @@ void HighlightingPage::addHighlightTabSignals()
delete selectedHighlight; delete selectedHighlight;
}); });
} }
} // namespace settingspages } // namespace settingspages
} // namespace widgets } // namespace widgets
} // namespace chatterino } // namespace chatterino

View file

@ -1,9 +1,9 @@
#pragma once #pragma once
#include <QTimer>
#include "widgets/settingspages/settingspage.hpp" #include "widgets/settingspages/settingspage.hpp"
#include <QTimer>
class QPushButton; class QPushButton;
class QListWidget; class QListWidget;

View file

@ -8,6 +8,7 @@
namespace chatterino { namespace chatterino {
namespace widgets { namespace widgets {
namespace settingspages { namespace settingspages {
IgnoreMessagesPage::IgnoreMessagesPage() IgnoreMessagesPage::IgnoreMessagesPage()
: SettingsPage("Ignore Messages", "") : SettingsPage("Ignore Messages", "")
{ {
@ -32,6 +33,7 @@ IgnoreMessagesPage::IgnoreMessagesPage()
// ---- misc // ---- misc
this->keywordsUpdated.setSingleShot(true); this->keywordsUpdated.setSingleShot(true);
} }
} // namespace settingspages } // namespace settingspages
} // namespace widgets } // namespace widgets
} // namespace chatterino } // namespace chatterino

View file

@ -1,8 +1,9 @@
#pragma once #pragma once
#include <QTimer>
#include "widgets/settingspages/settingspage.hpp" #include "widgets/settingspages/settingspage.hpp"
#include <QTimer>
namespace chatterino { namespace chatterino {
namespace widgets { namespace widgets {
namespace settingspages { namespace settingspages {
@ -14,6 +15,7 @@ public:
QTimer keywordsUpdated; QTimer keywordsUpdated;
}; };
} // namespace settingspages } // namespace settingspages
} // namespace widgets } // namespace widgets
} // namespace chatterino } // namespace chatterino

View file

@ -17,6 +17,7 @@
namespace chatterino { namespace chatterino {
namespace widgets { namespace widgets {
namespace settingspages { namespace settingspages {
IgnoreUsersPage::IgnoreUsersPage() IgnoreUsersPage::IgnoreUsersPage()
: SettingsPage("Ignore Users", "") : SettingsPage("Ignore Users", "")
{ {
@ -50,6 +51,7 @@ IgnoreUsersPage::IgnoreUsersPage()
auto userList = group.emplace<QListView>(); auto userList = group.emplace<QListView>();
} }
} }
} // namespace settingspages } // namespace settingspages
} // namespace widgets } // namespace widgets
} // namespace chatterino } // namespace chatterino

View file

@ -5,11 +5,13 @@
namespace chatterino { namespace chatterino {
namespace widgets { namespace widgets {
namespace settingspages { namespace settingspages {
class IgnoreUsersPage : public SettingsPage class IgnoreUsersPage : public SettingsPage
{ {
public: public:
IgnoreUsersPage(); IgnoreUsersPage();
}; };
} // namespace settingspages } // namespace settingspages
} // namespace widgets } // namespace widgets
} // namespace chatterino } // namespace chatterino

View file

@ -3,10 +3,12 @@
namespace chatterino { namespace chatterino {
namespace widgets { namespace widgets {
namespace settingspages { namespace settingspages {
KeyboardSettingsPage::KeyboardSettingsPage() KeyboardSettingsPage::KeyboardSettingsPage()
: SettingsPage("Keybindings", "") : SettingsPage("Keybindings", "")
{ {
} }
} // namespace settingspages } // namespace settingspages
} // namespace widgets } // namespace widgets
} // namespace chatterino } // namespace chatterino

View file

@ -5,11 +5,13 @@
namespace chatterino { namespace chatterino {
namespace widgets { namespace widgets {
namespace settingspages { namespace settingspages {
class KeyboardSettingsPage : public SettingsPage class KeyboardSettingsPage : public SettingsPage
{ {
public: public:
KeyboardSettingsPage(); KeyboardSettingsPage();
}; };
} // namespace settingspages } // namespace settingspages
} // namespace widgets } // namespace widgets
} // namespace chatterino } // namespace chatterino

View file

@ -11,6 +11,7 @@ class LogsPage : public SettingsPage
public: public:
LogsPage(); LogsPage();
}; };
} // namespace settingspages } // namespace settingspages
} // namespace widgets } // namespace widgets
} // namespace chatterino } // namespace chatterino

View file

@ -10,6 +10,7 @@
namespace chatterino { namespace chatterino {
namespace widgets { namespace widgets {
namespace settingspages { namespace settingspages {
SpecialChannelsPage::SpecialChannelsPage() SpecialChannelsPage::SpecialChannelsPage()
: SettingsPage("Special channels", "") : SettingsPage("Special channels", "")
{ {
@ -30,6 +31,7 @@ SpecialChannelsPage::SpecialChannelsPage()
layout->addStretch(1); layout->addStretch(1);
} }
} // namespace settingspages } // namespace settingspages
} // namespace widgets } // namespace widgets
} // namespace chatterino } // namespace chatterino

View file

@ -5,11 +5,13 @@
namespace chatterino { namespace chatterino {
namespace widgets { namespace widgets {
namespace settingspages { namespace settingspages {
class SpecialChannelsPage : public SettingsPage class SpecialChannelsPage : public SettingsPage
{ {
public: public:
SpecialChannelsPage(); SpecialChannelsPage();
}; };
} // namespace settingspages } // namespace settingspages
} // namespace widgets } // namespace widgets
} // namespace chatterino } // namespace chatterino

View file

@ -25,7 +25,6 @@
#include <QMimeData> #include <QMimeData>
#include <QPainter> #include <QPainter>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <boost/signals2.hpp>
#include <functional> #include <functional>
#include <random> #include <random>
@ -150,7 +149,7 @@ void Split::setChannel(ChannelPtr _newChannel)
this->header.updateModerationModeIcon(); this->header.updateModerationModeIcon();
this->channelChanged(); this->channelChanged.invoke();
} }
void Split::setFlexSizeX(double x) void Split::setFlexSizeX(double x)

View file

@ -16,7 +16,6 @@
#include <QShortcut> #include <QShortcut>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QWidget> #include <QWidget>
#include <boost/signals2/connection.hpp>
namespace chatterino { namespace chatterino {
namespace widgets { namespace widgets {
@ -47,7 +46,7 @@ public:
~Split() override; ~Split() override;
pajlada::Settings::Setting<QString> channelName; pajlada::Settings::Setting<QString> channelName;
boost::signals2::signal<void()> channelChanged; pajlada::Signals::NoArgSignal channelChanged;
ChannelView &getChannelView() ChannelView &getChannelView()
{ {
@ -93,8 +92,8 @@ private:
bool moderationMode; bool moderationMode;
boost::signals2::connection channelIDChangedConnection; pajlada::Signals::Connection channelIDChangedConnection;
boost::signals2::connection usermodeChangedConnection; pajlada::Signals::Connection usermodeChangedConnection;
void setChannel(ChannelPtr newChannel); void setChannel(ChannelPtr newChannel);
void doOpenAccountPopupWidget(AccountPopupWidget *widget, QString user); void doOpenAccountPopupWidget(AccountPopupWidget *widget, QString user);

View file

@ -11,6 +11,7 @@
namespace chatterino { namespace chatterino {
namespace widgets { namespace widgets {
StreamView::StreamView(ChannelPtr channel, QUrl url) StreamView::StreamView(ChannelPtr channel, QUrl url)
{ {
util::LayoutCreator<StreamView> layoutCreator(this); util::LayoutCreator<StreamView> layoutCreator(this);
@ -30,5 +31,6 @@ StreamView::StreamView(ChannelPtr channel, QUrl url)
this->layout()->setSpacing(0); this->layout()->setSpacing(0);
this->layout()->setMargin(0); this->layout()->setMargin(0);
} }
} // namespace widgets } // namespace widgets
} // namespace chatterino } // namespace chatterino

View file

@ -2,14 +2,17 @@
#include <QUrl> #include <QUrl>
#include <QWidget> #include <QWidget>
#include <memory> #include <memory>
class QWebEngineView; class QWebEngineView;
namespace chatterino { namespace chatterino {
class Channel; class Channel;
namespace widgets { namespace widgets {
class StreamView : public QWidget class StreamView : public QWidget
{ {
public: public:
@ -18,5 +21,6 @@ public:
private: private:
QWebEngineView *stream; QWebEngineView *stream;
}; };
} // namespace widgets } // namespace widgets
} // namespace chatterino } // namespace chatterino

View file

@ -7,8 +7,6 @@ namespace widgets {
TextInputDialog::TextInputDialog(QWidget *parent) TextInputDialog::TextInputDialog(QWidget *parent)
: QDialog(parent) : QDialog(parent)
, _vbox(this) , _vbox(this)
, _lineEdit()
, _buttonBox()
, _okButton("OK") , _okButton("OK")
, _cancelButton("Cancel") , _cancelButton("Cancel")
{ {

View file

@ -65,5 +65,6 @@ void TooltipWidget::leaveEvent(QEvent *)
{ {
// clear parents event // clear parents event
} }
} // namespace widgets } // namespace widgets
} // namespace chatterino } // namespace chatterino

Some files were not shown because too many files have changed in this diff Show more