turning a lot of includes into forward declares

This commit is contained in:
fourtf 2018-08-11 22:23:06 +02:00
parent 63eaf3b94c
commit 44f5a15da3
117 changed files with 591 additions and 536 deletions

View file

@ -6,11 +6,13 @@
#include "controllers/ignores/IgnoreController.hpp"
#include "controllers/moderationactions/ModerationActions.hpp"
#include "controllers/taggedusers/TaggedUsersController.hpp"
#include "debug/Log.hpp"
#include "messages/MessageBuilder.hpp"
#include "providers/bttv/BttvEmotes.hpp"
#include "providers/ffz/FfzEmotes.hpp"
#include "providers/twitch/PubsubClient.hpp"
#include "providers/twitch/TwitchServer.hpp"
#include "singletons/Emotes.hpp"
#include "singletons/Fonts.hpp"
#include "singletons/Logging.hpp"
#include "singletons/NativeMessaging.hpp"
@ -21,6 +23,7 @@
#include "singletons/WindowManager.hpp"
#include "util/IsBigEndian.hpp"
#include "util/PostToThread.hpp"
#include "widgets/Window.hpp"
#include <atomic>

View file

@ -1,7 +1,6 @@
#pragma once
#include "common/Singleton.hpp"
#include "singletons/Resources.hpp"
#include <QApplication>
#include <memory>
@ -26,7 +25,7 @@ class AccountManager;
class Emotes;
class Settings;
class Fonts;
class Resources;
class Resources2;
class Application
{

View file

@ -32,3 +32,5 @@ QStringAlias(UserName);
QStringAlias(UserId);
QStringAlias(Url);
QStringAlias(Tooltip);
QStringAlias(EmoteId);
QStringAlias(EmoteName);

View file

@ -1,9 +1,7 @@
#pragma once
#include "common/CompletionModel.hpp"
#include "messages/Image.hpp"
#include "messages/LimitedQueue.hpp"
#include "messages/Message.hpp"
#include <QString>
#include <QTimer>
@ -12,7 +10,9 @@
#include <memory>
namespace chatterino {
struct Message;
using MessagePtr = std::shared_ptr<const Message>;
class Channel : public std::enable_shared_from_this<Channel>
{

View file

@ -3,7 +3,6 @@
#include "common/Aliases.hpp"
#include "common/Outcome.hpp"
#include "common/ProviderId.hpp"
#include "debug/Log.hpp"
#include <QString>
#include <QWidget>
@ -39,4 +38,7 @@ std::weak_ptr<T> weakOf(T *element)
return element->shared_from_this();
}
struct Message;
using MessagePtr = std::shared_ptr<const Message>;
} // namespace chatterino

View file

@ -5,6 +5,7 @@
#include "controllers/accounts/AccountController.hpp"
#include "controllers/commands/CommandController.hpp"
#include "debug/Log.hpp"
#include "providers/twitch/TwitchChannel.hpp"
#include "providers/twitch/TwitchServer.hpp"
#include "singletons/Emotes.hpp"

View file

@ -1,7 +1,5 @@
#pragma once
#include "common/Common.hpp"
#include <QAbstractListModel>
#include <chrono>

View file

@ -2,12 +2,11 @@
#include <functional>
#include "Common.hpp"
class QNetworkReply;
namespace chatterino {
class Outcome;
class NetworkResult;
using NetworkSuccessCallback = std::function<Outcome(NetworkResult)>;

View file

@ -1,16 +1,7 @@
#pragma once
#include "common/NetworkRequester.hpp"
#include "common/NetworkWorker.hpp"
#include "debug/Log.hpp"
#include <QJsonDocument>
#include <QJsonObject>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QThread>
#include <QTimer>
#include <QUrl>
namespace chatterino {

View file

@ -1,7 +1,9 @@
#include "common/NetworkRequest.hpp"
#include "Application.hpp"
#include "common/NetworkData.hpp"
#include "common/NetworkManager.hpp"
#include "common/Outcome.hpp"
#include "debug/Log.hpp"
#include "providers/twitch/TwitchCommon.hpp"
#include "singletons/Paths.hpp"

View file

@ -1,14 +1,13 @@
#pragma once
#include "Application.hpp"
#include "common/NetworkCommon.hpp"
#include "common/NetworkData.hpp"
#include "common/NetworkRequester.hpp"
#include "common/NetworkResult.hpp"
#include "common/NetworkTimer.hpp"
#include "common/NetworkWorker.hpp"
namespace chatterino {
class NetworkData;
class NetworkRequest
{

View file

@ -1,6 +1,8 @@
#include "AccountController.hpp"
#include "controllers/accounts/Account.hpp"
#include "controllers/accounts/AccountModel.hpp"
#include "providers/twitch/TwitchAccount.hpp"
namespace chatterino {

View file

@ -1,16 +1,15 @@
#pragma once
#include "common/Singleton.hpp"
#include <QObject>
#include "common/SignalVector.hpp"
#include "controllers/accounts/Account.hpp"
#include "common/Singleton.hpp"
#include "providers/twitch/TwitchAccountManager.hpp"
#include "util/SharedPtrElementLess.hpp"
namespace chatterino {
class Account;
class Settings;
class Paths;

View file

@ -1,5 +1,6 @@
#include "AccountModel.hpp"
#include "controllers/accounts/Account.hpp"
#include "util/StandardItemHelper.hpp"
namespace chatterino {

View file

@ -8,6 +8,7 @@
namespace chatterino {
class Account;
class AccountController;
class AccountModel : public SignalVectorModel<std::shared_ptr<Account>>

View file

@ -5,7 +5,10 @@
#include "controllers/accounts/AccountController.hpp"
#include "controllers/commands/Command.hpp"
#include "controllers/commands/CommandModel.hpp"
#include "debug/Log.hpp"
#include "messages/Message.hpp"
#include "messages/MessageBuilder.hpp"
#include "messages/MessageElement.hpp"
#include "providers/twitch/TwitchApi.hpp"
#include "providers/twitch/TwitchChannel.hpp"
#include "providers/twitch/TwitchServer.hpp"

View file

@ -1,15 +1,16 @@
#pragma once
#include "common/Singleton.hpp"
#include "common/ChatterinoSetting.hpp"
#include "common/SignalVector.hpp"
#include "common/Singleton.hpp"
#include "controllers/highlights/HighlightBlacklistUser.hpp"
#include "controllers/highlights/HighlightPhrase.hpp"
#include "messages/Message.hpp"
#include "singletons/Settings.hpp"
namespace chatterino {
struct Message;
using MessagePtr = std::shared_ptr<const Message>;
class Settings;
class Paths;

View file

@ -1,10 +1,9 @@
#pragma once
#include "common/Singleton.hpp"
#include "common/ChatterinoSetting.hpp"
#include "common/SignalVector.hpp"
#include "common/Singleton.hpp"
#include "controllers/ignores/IgnorePhrase.hpp"
#include "singletons/Settings.hpp"
namespace chatterino {

View file

@ -2,6 +2,7 @@
#include <QRegularExpression>
#include "Application.hpp"
#include "messages/Image.hpp"
#include "singletons/Resources.hpp"
namespace chatterino {

View file

@ -4,11 +4,13 @@
#include <boost/optional.hpp>
#include <pajlada/settings/serialize.hpp>
#include "messages/Image.hpp"
#include "util/RapidjsonHelpers.hpp"
namespace chatterino {
class Image;
using ImagePtr = std::shared_ptr<Image>;
class ModerationAction
{
public:

View file

@ -7,9 +7,6 @@
#include <memory>
#include <unordered_map>
QStringAlias(EmoteId);
QStringAlias(EmoteName);
namespace chatterino {
struct Emote {

View file

@ -1,93 +0,0 @@
#pragma once
#include <QString>
#include <boost/optional.hpp>
#include <unordered_map>
#include <util/QStringHash.hpp>
#include "common/UniqueAccess.hpp"
#include "messages/Emote.hpp"
namespace chatterino {
template <typename TKey>
class MapReplacement
{
public:
MapReplacement(std::unordered_map<TKey, EmotePtr> &items)
: oldItems_(items)
{
}
void add(const TKey &key, const Emote &data)
{
this->add(key, Emote(data));
}
void add(const TKey &key, Emote &&data)
{
auto it = this->oldItems_.find(key);
if (it != this->oldItems_.end() && *it->second == data) {
this->newItems_[key] = it->second;
} else {
this->newItems_[key] = std::make_shared<Emote>(std::move(data));
}
}
void apply()
{
this->oldItems_ = std::move(this->newItems_);
}
private:
std::unordered_map<TKey, EmotePtr> &oldItems_;
std::unordered_map<TKey, EmotePtr> newItems_;
};
template <typename TKey>
class EmoteCache
{
public:
using Iterator = typename std::unordered_map<TKey, EmotePtr>::iterator;
using ConstIterator = typename std::unordered_map<TKey, EmotePtr>::iterator;
Iterator begin()
{
return this->items_.begin();
}
ConstIterator begin() const
{
return this->items_.begin();
}
Iterator end()
{
return this->items_.end();
}
ConstIterator end() const
{
return this->items_.end();
}
boost::optional<EmotePtr> get(const TKey &key) const
{
auto it = this->items_.find(key);
if (it == this->items_.end())
return boost::none;
else
return it->second;
}
MapReplacement<TKey> makeReplacment()
{
return MapReplacement<TKey>(this->items_);
}
private:
std::unordered_map<TKey, EmotePtr> items_;
};
} // namespace chatterino

View file

@ -1,6 +1,7 @@
#include "messages/Image.hpp"
#include "Application.hpp"
#include "common/Common.hpp"
#include "common/NetworkRequest.hpp"
#include "debug/AssertInGuiThread.hpp"
#include "debug/Benchmark.hpp"

View file

@ -1,18 +1,18 @@
#pragma once
#include "common/Common.hpp"
#include <QPixmap>
#include <QString>
#include <QThread>
#include <QVector>
#include <atomic>
#include <boost/noncopyable.hpp>
#include <boost/optional.hpp>
#include <boost/variant.hpp>
#include <memory>
#include <mutex>
#include <pajlada/signals/signal.hpp>
#include "common/Aliases.hpp"
#include "common/NullablePtr.hpp"
namespace chatterino {

View file

@ -1,7 +1,6 @@
#pragma once
#include <QString>
#include <common/Common.hpp>
namespace chatterino {

View file

@ -1,16 +1,16 @@
#pragma once
#include "common/FlagsEnum.hpp"
#include "messages/MessageElement.hpp"
#include "providers/twitch/PubsubActions.hpp"
#include "widgets/helper/ScrollbarHighlight.hpp"
#include <QTime>
#include <boost/noncopyable.hpp>
#include <cinttypes>
#include <memory>
#include <vector>
namespace chatterino {
class MessageElement;
enum class MessageFlag : uint16_t {
None = 0,

View file

@ -1,6 +1,9 @@
#include "MessageBuilder.hpp"
#include "common/LinkParser.hpp"
#include "messages/Message.hpp"
#include "messages/MessageElement.hpp"
#include "providers/twitch/PubsubActions.hpp"
#include "singletons/Emotes.hpp"
#include "singletons/Resources.hpp"
#include "singletons/Theme.hpp"
@ -17,7 +20,7 @@ MessagePtr makeSystemMessage(const QString &text)
}
MessageBuilder::MessageBuilder()
: message_(std::make_unique<Message>())
: message_(std::make_shared<Message>())
{
}
@ -165,7 +168,9 @@ Message &MessageBuilder::message()
MessagePtr MessageBuilder::release()
{
return MessagePtr(this->message_.release());
std::shared_ptr<Message> ptr;
this->message_.swap(ptr);
return ptr;
}
void MessageBuilder::append(std::unique_ptr<MessageElement> element)

View file

@ -1,11 +1,15 @@
#pragma once
#include "messages/Message.hpp"
#include "messages/MessageElement.hpp"
#include <QRegularExpression>
#include <ctime>
namespace chatterino {
struct BanAction;
struct UnbanAction;
struct Message;
using MessagePtr = std::shared_ptr<const Message>;
struct SystemMessageTag {
};
@ -56,7 +60,7 @@ public:
}
private:
std::unique_ptr<Message> message_;
std::shared_ptr<Message> message_;
};
} // namespace chatterino

View file

@ -1,5 +1,7 @@
#include "MessageColor.hpp"
#include "singletons/Theme.hpp"
namespace chatterino {
MessageColor::MessageColor(const QColor &color)

View file

@ -1,10 +1,9 @@
#pragma once
#include "singletons/Theme.hpp"
#include <QColor>
namespace chatterino {
class Theme;
struct MessageColor {
enum Type { Custom, Text, Link, System };

View file

@ -3,9 +3,11 @@
#include "Application.hpp"
#include "controllers/moderationactions/ModerationActions.hpp"
#include "debug/Benchmark.hpp"
#include "messages/Emote.hpp"
#include "messages/layouts/MessageLayoutContainer.hpp"
#include "messages/layouts/MessageLayoutElement.hpp"
#include "singletons/Settings.hpp"
#include "singletons/Theme.hpp"
#include "util/DebugCount.hpp"
namespace chatterino {

View file

@ -1,8 +1,6 @@
#pragma once
#include "common/FlagsEnum.hpp"
#include "messages/Emote.hpp"
#include "messages/Image.hpp"
#include "messages/Link.hpp"
#include "messages/MessageColor.hpp"
#include "singletons/Fonts.hpp"
@ -11,14 +9,20 @@
#include <QString>
#include <QTime>
#include <boost/noncopyable.hpp>
#include <cstdint>
#include <memory>
#include <vector>
namespace chatterino {
class Channel;
struct MessageLayoutContainer;
class Image;
using ImagePtr = std::shared_ptr<Image>;
struct Emote;
using EmotePtr = std::shared_ptr<const Emote>;
enum class MessageElementFlag {
None = 0,
Misc = (1 << 0),

View file

@ -2,8 +2,12 @@
#include "Application.hpp"
#include "debug/Benchmark.hpp"
#include "messages/Message.hpp"
#include "messages/MessageElement.hpp"
#include "messages/layouts/MessageLayoutContainer.hpp"
#include "singletons/Emotes.hpp"
#include "singletons/Settings.hpp"
#include "singletons/Theme.hpp"
#include "singletons/WindowManager.hpp"
#include "util/DebugCount.hpp"
@ -24,6 +28,7 @@ namespace chatterino {
MessageLayout::MessageLayout(MessagePtr message)
: message_(message)
, buffer_(nullptr)
, container_(std::make_shared<MessageLayoutContainer>())
{
DebugCount::increase("message layout");
}
@ -41,7 +46,7 @@ const Message *MessageLayout::getMessage()
// Height
int MessageLayout::getHeight() const
{
return container_.getHeight();
return container_->getHeight();
}
// Layout
@ -82,9 +87,9 @@ bool MessageLayout::layout(int width, float scale, MessageElementFlags flags)
return false;
}
int oldHeight = this->container_.getHeight();
int oldHeight = this->container_->getHeight();
this->actuallyLayout(width, flags);
if (widthChanged || this->container_.getHeight() != oldHeight) {
if (widthChanged || this->container_->getHeight() != oldHeight) {
this->deleteBuffer();
}
this->invalidateBuffer();
@ -103,22 +108,22 @@ void MessageLayout::actuallyLayout(int width, MessageElementFlags _flags)
messageFlags.unset(MessageFlag::Collapsed);
}
this->container_.begin(width, this->scale_, messageFlags);
this->container_->begin(width, this->scale_, messageFlags);
for (const auto &element : this->message_->elements) {
element->addToContainer(this->container_, _flags);
element->addToContainer(*this->container_, _flags);
}
if (this->height_ != this->container_.getHeight()) {
if (this->height_ != this->container_->getHeight()) {
this->deleteBuffer();
}
this->container_.end();
this->height_ = this->container_.getHeight();
this->container_->end();
this->height_ = this->container_->getHeight();
// collapsed state
this->flags.unset(MessageLayoutFlag::Collapsed);
if (this->container_.isCollapsed()) {
if (this->container_->isCollapsed()) {
this->flags.set(MessageLayoutFlag::Collapsed);
}
}
@ -135,11 +140,12 @@ void MessageLayout::paint(QPainter &painter, int width, int y, int messageIndex,
if (!pixmap) {
#ifdef Q_OS_MACOS
pixmap = new QPixmap(int(width * painter.device()->devicePixelRatioF()),
int(container_.getHeight() *
int(container_->getHeight() *
painter.device()->devicePixelRatioF()));
pixmap->setDevicePixelRatio(painter.device()->devicePixelRatioF());
#else
pixmap = new QPixmap(width, std::max(16, this->container_.getHeight()));
pixmap =
new QPixmap(width, std::max(16, this->container_->getHeight()));
#endif
this->buffer_ = std::shared_ptr<QPixmap>(pixmap);
@ -157,7 +163,7 @@ void MessageLayout::paint(QPainter &painter, int width, int y, int messageIndex,
// this->container.getHeight(), *pixmap);
// draw gif emotes
this->container_.paintAnimatedElements(painter, y);
this->container_->paintAnimatedElements(painter, y);
// draw disabled
if (this->message_->flags.has(MessageFlag::Disabled)) {
@ -167,12 +173,12 @@ void MessageLayout::paint(QPainter &painter, int width, int y, int messageIndex,
// draw selection
if (!selection.isEmpty()) {
this->container_.paintSelection(painter, messageIndex, selection, y);
this->container_->paintSelection(painter, messageIndex, selection, y);
}
// draw message seperation line
if (app->settings->separateMessages.getValue()) {
painter.fillRect(0, y, this->container_.getWidth(), 1,
painter.fillRect(0, y, this->container_->getWidth(), 1,
app->themes->splits.messageSeperator);
}
@ -186,7 +192,7 @@ void MessageLayout::paint(QPainter &painter, int width, int y, int messageIndex,
QBrush brush(color, static_cast<Qt::BrushStyle>(
app->settings->lastMessagePattern.getValue()));
painter.fillRect(0, y + this->container_.getHeight() - 1,
painter.fillRect(0, y + this->container_->getHeight() - 1,
pixmap->width(), 1, brush);
}
@ -217,7 +223,7 @@ void MessageLayout::updateBuffer(QPixmap *buffer, int /*messageIndex*/,
painter.fillRect(buffer->rect(), backgroundColor);
// draw message
this->container_.paintElements(painter);
this->container_->paintElements(painter);
#ifdef FOURTF
// debug
@ -252,7 +258,7 @@ void MessageLayout::deleteCache()
this->deleteBuffer();
#ifdef XD
this->container_.clear();
this->container_->clear();
#endif
}
@ -265,22 +271,22 @@ void MessageLayout::deleteCache()
const MessageLayoutElement *MessageLayout::getElementAt(QPoint point)
{
// go through all words and return the first one that contains the point.
return this->container_.getElementAt(point);
return this->container_->getElementAt(point);
}
int MessageLayout::getLastCharacterIndex() const
{
return this->container_.getLastCharacterIndex();
return this->container_->getLastCharacterIndex();
}
int MessageLayout::getSelectionIndex(QPoint position)
{
return this->container_.getSelectionIndex(position);
return this->container_->getSelectionIndex(position);
}
void MessageLayout::addSelectionText(QString &str, int from, int to)
{
this->container_.addSelectionText(str, from, to);
this->container_->addSelectionText(str, from, to);
}
} // namespace chatterino

View file

@ -1,19 +1,24 @@
#pragma once
#include "common/FlagsEnum.hpp"
#include "messages/Message.hpp"
#include "messages/Selection.hpp"
#include "messages/layouts/MessageLayoutContainer.hpp"
#include "messages/layouts/MessageLayoutElement.hpp"
#include <QPixmap>
#include <boost/noncopyable.hpp>
#include <cinttypes>
#include <memory>
namespace chatterino {
struct Message;
using MessagePtr = std::shared_ptr<const Message>;
struct Selection;
struct MessageLayoutContainer;
class MessageLayoutElement;
enum class MessageElementFlag;
using MessageElementFlags = FlagsEnum<MessageElementFlag>;
enum class MessageLayoutFlag : uint8_t {
RequiresBufferUpdate = 1 << 1,
RequiresLayout = 1 << 2,
@ -57,7 +62,7 @@ public:
private:
// variables
MessagePtr message_;
MessageLayoutContainer container_;
std::shared_ptr<MessageLayoutContainer> container_;
std::shared_ptr<QPixmap> buffer_ = nullptr;
bool bufferValid_ = false;

View file

@ -1,9 +1,13 @@
#include "MessageLayoutContainer.hpp"
#include "Application.hpp"
#include "MessageLayoutElement.hpp"
#include "messages/Message.hpp"
#include "messages/MessageElement.hpp"
#include "messages/Selection.hpp"
#include "messages/layouts/MessageLayoutElement.hpp"
#include "singletons/Fonts.hpp"
#include "singletons/Settings.hpp"
#include "singletons/Theme.hpp"
#include <QDebug>
#include <QPainter>

View file

@ -1,18 +1,20 @@
#pragma once
#include <memory>
#include <vector>
#include <QPoint>
#include <QRect>
#include <memory>
#include <vector>
#include "messages/Message.hpp"
#include "common/FlagsEnum.hpp"
#include "messages/Selection.hpp"
#include "messages/layouts/MessageLayoutElement.hpp"
class QPainter;
namespace chatterino {
class MessageLayoutElement;
enum class MessageFlag : uint16_t;
using MessageFlags = FlagsEnum<MessageFlag>;
struct Margin {
int top;
@ -92,7 +94,7 @@ private:
// variables
float scale_ = 1.f;
int width_ = 0;
MessageFlags flags_ = MessageFlag::None;
MessageFlags flags_{};
int line_ = 0;
int height_ = 0;
int currentX_ = 0;

View file

@ -1,7 +1,9 @@
#include "messages/layouts/MessageLayoutElement.hpp"
#include "Application.hpp"
#include "messages/Image.hpp"
#include "messages/MessageElement.hpp"
#include "singletons/Theme.hpp"
#include "util/DebugCount.hpp"
#include <QDebug>

View file

@ -3,19 +3,19 @@
#include <QPoint>
#include <QRect>
#include <QString>
#include <boost/noncopyable.hpp>
#include <climits>
#include "messages/Image.hpp"
#include "messages/Link.hpp"
#include "messages/MessageColor.hpp"
#include "singletons/Fonts.hpp"
class QPainter;
namespace chatterino {
class MessageElement;
class Image;
using ImagePtr = std::shared_ptr<Image>;
enum class FontStyle : uint8_t;
class MessageLayoutElement : boost::noncopyable
{

View file

@ -1,5 +1,6 @@
#include "providers/bttv/BttvEmotes.hpp"
#include "common/Common.hpp"
#include "common/NetworkRequest.hpp"
#include "debug/Log.hpp"
#include "messages/Image.hpp"

View file

@ -1,6 +1,8 @@
#pragma once
#include <boost/optional.hpp>
#include <memory>
#include "common/Atomic.hpp"
#include "messages/Emote.hpp"

View file

@ -14,39 +14,41 @@ ChatterinoBadges::ChatterinoBadges()
boost::optional<EmotePtr> ChatterinoBadges::getBadge(const UserName &username)
{
return this->badges.access()->get(username);
return boost::none;
// return this->badges.access()->get(username);
}
void ChatterinoBadges::loadChatterinoBadges()
{
static QString url("https://fourtf.com/chatterino/badges.json");
// static QString url("https://fourtf.com/chatterino/badges.json");
NetworkRequest req(url);
req.setCaller(QThread::currentThread());
// NetworkRequest req(url);
// req.setCaller(QThread::currentThread());
req.onSuccess([this](auto result) {
auto jsonRoot = result.parseJson();
auto badges = this->badges.access();
auto replacement = badges->makeReplacment();
// req.onSuccess([this](auto result) {
// auto jsonRoot = result.parseJson();
// auto badges = this->badges.access();
// auto replacement = badges->makeReplacment();
for (auto jsonBadge_ : jsonRoot.value("badges").toArray()) {
auto jsonBadge = jsonBadge_.toObject();
// for (auto jsonBadge_ : jsonRoot.value("badges").toArray()) {
// auto jsonBadge = jsonBadge_.toObject();
auto emote = Emote{
EmoteName{}, ImageSet{Url{jsonBadge.value("image").toString()}},
Tooltip{jsonBadge.value("tooltip").toString()}, Url{}};
// auto emote = Emote{
// EmoteName{},
// ImageSet{Url{jsonBadge.value("image").toString()}},
// Tooltip{jsonBadge.value("tooltip").toString()}, Url{}};
for (auto jsonUser : jsonBadge.value("users").toArray()) {
replacement.add(UserName{jsonUser.toString()},
std::move(emote));
}
}
// for (auto jsonUser : jsonBadge.value("users").toArray()) {
// replacement.add(UserName{jsonUser.toString()},
// std::move(emote));
// }
// }
replacement.apply();
return Success;
});
// replacement.apply();
// return Success;
//});
req.execute();
// req.execute();
}
} // namespace chatterino

View file

@ -1,14 +1,14 @@
#pragma once
#include <boost/optional.hpp>
#include <unordered_map>
#include "common/Common.hpp"
#include "common/UniqueAccess.hpp"
#include "messages/Emote.hpp"
#include "messages/EmoteCache.hpp"
#include "common/Aliases.hpp"
namespace chatterino {
struct Emote;
using EmotePtr = std::shared_ptr<const Emote>;
class ChatterinoBadges
{
public:
@ -19,7 +19,7 @@ public:
private:
void loadChatterinoBadges();
UniqueAccess<EmoteCache<UserName>> badges;
// UniqueAccess<EmoteCache<UserName>> badges;
};
} // namespace chatterino

View file

@ -2,6 +2,7 @@
#include "Application.hpp"
#include "debug/Log.hpp"
#include "messages/Emote.hpp"
#include "singletons/Settings.hpp"
#include <rapidjson/error/en.h>

View file

@ -1,6 +1,5 @@
#pragma once
#include "messages/Emote.hpp"
#include "util/ConcurrentMap.hpp"
#include <QMap>
@ -12,6 +11,9 @@
namespace chatterino {
struct Emote;
using EmotePtr = std::shared_ptr<const Emote>;
struct EmojiData {
// actual byte-representation of the emoji (i.e. \154075\156150 which is
// :male:)

View file

@ -3,6 +3,7 @@
#include <QJsonArray>
#include "common/NetworkRequest.hpp"
#include "common/Outcome.hpp"
#include "debug/Log.hpp"
#include "messages/Image.hpp"

View file

@ -1,6 +1,8 @@
#include "AbstractIrcServer.hpp"
#include "common/Channel.hpp"
#include "common/Common.hpp"
#include "debug/Log.hpp"
#include "messages/LimitedQueueSnapshot.hpp"
#include "messages/Message.hpp"
#include "messages/MessageBuilder.hpp"

View file

@ -1,6 +1,5 @@
#pragma once
#include "common/Channel.hpp"
#include "providers/irc/IrcConnection2.hpp"
#include <IrcMessage>
@ -11,6 +10,9 @@
namespace chatterino {
class Channel;
using ChannelPtr = std::shared_ptr<Channel>;
class AbstractIrcServer
{
public:

View file

@ -10,6 +10,7 @@
#include "providers/twitch/TwitchMessageBuilder.hpp"
#include "providers/twitch/TwitchServer.hpp"
#include "singletons/Resources.hpp"
#include "singletons/Settings.hpp"
#include "singletons/WindowManager.hpp"
#include "util/IrcHelpers.hpp"

View file

@ -1,5 +1,6 @@
#include "providers/twitch/PartialTwitchUser.hpp"
#include "common/Common.hpp"
#include "common/NetworkRequest.hpp"
#include "debug/Log.hpp"
#include "providers/twitch/TwitchCommon.hpp"

View file

@ -1,6 +1,7 @@
#include "providers/twitch/PubsubHelpers.hpp"
#include "providers/twitch/PubsubActions.hpp"
#include "providers/twitch/TwitchAccount.hpp"
#include "util/RapidjsonHelpers.hpp"
namespace chatterino {

View file

@ -1,16 +1,14 @@
#pragma once
#include "debug/Log.hpp"
#include "providers/twitch/TwitchAccount.hpp"
#include "util/RapidjsonHelpers.hpp"
#include <boost/asio.hpp>
#include <boost/asio/steady_timer.hpp>
#include <memory>
namespace chatterino {
class TwitchAccount;
struct ActionUser;
const rapidjson::Value &getArgs(const rapidjson::Value &data);

View file

@ -4,6 +4,7 @@
#include "Application.hpp"
#include "common/NetworkRequest.hpp"
#include "common/Outcome.hpp"
#include "debug/Log.hpp"
#include "providers/twitch/PartialTwitchUser.hpp"
#include "providers/twitch/TwitchCommon.hpp"

View file

@ -1,5 +1,6 @@
#pragma once
#include "common/Aliases.hpp"
#include "common/Atomic.hpp"
#include "common/UniqueAccess.hpp"
#include "controllers/accounts/Account.hpp"

View file

@ -2,6 +2,7 @@
#include "common/Common.hpp"
#include "debug/Log.hpp"
#include "providers/twitch/TwitchAccount.hpp"
#include "providers/twitch/TwitchCommon.hpp"
namespace chatterino {

View file

@ -17,6 +17,7 @@
namespace chatterino {
class TwitchAccount;
class AccountController;
class TwitchAccountManager

View file

@ -1,5 +1,6 @@
#include "providers/twitch/TwitchApi.hpp"
#include "common/Common.hpp"
#include "common/NetworkRequest.hpp"
#include "debug/Log.hpp"
#include "providers/twitch/TwitchCommon.hpp"

View file

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

View file

@ -5,6 +5,8 @@
#include <QJsonValue>
#include <QThread>
#include "common/NetworkRequest.hpp"
#include "common/Outcome.hpp"
#include "messages/Emote.hpp"
namespace chatterino {

View file

@ -1,12 +1,14 @@
#pragma once
#include <QString>
#include <messages/Emote.hpp>
#include <unordered_map>
#include "util/QStringHash.hpp"
namespace chatterino {
struct Emote;
using EmotePtr = std::shared_ptr<const Emote>;
class Settings;
class Paths;

View file

@ -1,5 +1,6 @@
#include "providers/twitch/TwitchChannel.hpp"
#include "Application.hpp"
#include "common/Common.hpp"
#include "common/NetworkRequest.hpp"
#include "controllers/accounts/AccountController.hpp"

View file

@ -2,21 +2,23 @@
#include <IrcConnection>
#include "common/Aliases.hpp"
#include "common/Atomic.hpp"
#include "common/Channel.hpp"
#include "common/Common.hpp"
#include "common/Outcome.hpp"
#include "common/UniqueAccess.hpp"
#include "messages/Emote.hpp"
#include "singletons/Emotes.hpp"
#include "util/ConcurrentMap.hpp"
#include <pajlada/signals/signalholder.hpp>
#include <boost/optional.hpp>
#include <mutex>
#include <pajlada/signals/signalholder.hpp>
#include <unordered_map>
namespace chatterino {
struct Emote;
using EmotePtr = std::shared_ptr<const Emote>;
class EmoteMap;
class TwitchServer;
class TwitchChannel final : public Channel, pajlada::Signals::SignalHolder

View file

@ -3,6 +3,7 @@
#include "common/NetworkRequest.hpp"
#include "debug/Benchmark.hpp"
#include "debug/Log.hpp"
#include "messages/Emote.hpp"
#include "messages/Image.hpp"
#include "util/RapidjsonHelpers.hpp"

View file

@ -3,18 +3,18 @@
#include <QString>
#include <unordered_map>
#include "common/Aliases.hpp"
#include "common/UniqueAccess.hpp"
#include "messages/Emote.hpp"
#include "providers/twitch/EmoteValue.hpp"
#include "providers/twitch/TwitchAccount.hpp"
#include "providers/twitch/TwitchEmotes.hpp"
#include "util/ConcurrentMap.hpp"
#define TWITCH_EMOTE_TEMPLATE \
"https://static-cdn.jtvnw.net/emoticons/v1/{id}/{scale}"
namespace chatterino {
struct Emote;
using EmotePtr = std::shared_ptr<const Emote>;
class TwitchEmotes
{
public:

View file

@ -5,6 +5,7 @@
#include "controllers/highlights/HighlightController.hpp"
#include "controllers/ignores/IgnoreController.hpp"
#include "debug/Log.hpp"
#include "messages/Message.hpp"
#include "providers/twitch/TwitchChannel.hpp"
#include "singletons/Emotes.hpp"
#include "singletons/Resources.hpp"
@ -12,6 +13,7 @@
#include "singletons/Theme.hpp"
#include "singletons/WindowManager.hpp"
#include "util/IrcHelpers.hpp"
#include "widgets/Window.hpp"
#include <QApplication>
#include <QDebug>

View file

@ -1,15 +1,18 @@
#pragma once
#include "common/Aliases.hpp"
#include "common/Outcome.hpp"
#include "messages/MessageBuilder.hpp"
#include "singletons/Emotes.hpp"
#include <IrcMessage>
#include <QString>
#include <QVariant>
namespace chatterino {
struct Emote;
using EmotePtr = std::shared_ptr<const Emote>;
class Channel;
class TwitchChannel;

View file

@ -7,6 +7,7 @@
#include "providers/twitch/IrcMessageHandler.hpp"
#include "providers/twitch/PubsubClient.hpp"
#include "providers/twitch/TwitchAccount.hpp"
#include "providers/twitch/TwitchChannel.hpp"
#include "providers/twitch/TwitchHelpers.hpp"
#include "providers/twitch/TwitchMessageBuilder.hpp"
#include "util/PostToThread.hpp"

View file

@ -1,10 +1,10 @@
#pragma once
#include "common/Atomic.hpp"
#include "common/Channel.hpp"
#include "common/Singleton.hpp"
#include "pajlada/signals/signalholder.hpp"
#include "providers/irc/AbstractIrcServer.hpp"
#include "providers/twitch/TwitchAccount.hpp"
#include "providers/twitch/TwitchChannel.hpp"
#include <chrono>
#include <memory>

View file

@ -2,6 +2,7 @@
#include "Application.hpp"
#include "debug/AssertInGuiThread.hpp"
#include "singletons/Settings.hpp"
#include "singletons/WindowManager.hpp"
#include <QDebug>
@ -26,7 +27,7 @@ Fonts::Fonts()
: chatFontFamily("/appearance/currentFontFamily", DEFAULT_FONT_FAMILY)
, chatFontSize("/appearance/currentFontSize", DEFAULT_FONT_SIZE)
{
this->fontsByType_.resize(size_t(EndType));
this->fontsByType_.resize(size_t(FontStyle::EndType));
}
void Fonts::initialize(Settings &, Paths &)
@ -61,21 +62,21 @@ void Fonts::initialize(Settings &, Paths &)
});
}
QFont Fonts::getFont(Fonts::Type type, float scale)
QFont Fonts::getFont(FontStyle type, float scale)
{
return this->getOrCreateFontData(type, scale).font;
}
QFontMetrics Fonts::getFontMetrics(Fonts::Type type, float scale)
QFontMetrics Fonts::getFontMetrics(FontStyle type, float scale)
{
return this->getOrCreateFontData(type, scale).metrics;
}
Fonts::FontData &Fonts::getOrCreateFontData(Type type, float scale)
Fonts::FontData &Fonts::getOrCreateFontData(FontStyle type, float scale)
{
assertInGuiThread();
assert(type >= 0 && type < EndType);
assert(type < FontStyle::EndType);
auto &map = this->fontsByType_[size_t(type)];
@ -94,22 +95,22 @@ Fonts::FontData &Fonts::getOrCreateFontData(Type type, float scale)
return result.first->second;
}
Fonts::FontData Fonts::createFontData(Type type, float scale)
Fonts::FontData Fonts::createFontData(FontStyle type, float scale)
{
// check if it's a chat (scale the setting)
if (type >= ChatStart && type <= ChatEnd) {
static std::unordered_map<Type, ChatFontData> sizeScale{
{ChatSmall, {0.6f, false, QFont::Normal}},
{ChatMediumSmall, {0.8f, false, QFont::Normal}},
{ChatMedium, {1, false, QFont::Normal}},
{ChatMediumBold,
if (type >= FontStyle::ChatStart && type <= FontStyle::ChatEnd) {
static std::unordered_map<FontStyle, ChatFontData> sizeScale{
{FontStyle::ChatSmall, {0.6f, false, QFont::Normal}},
{FontStyle::ChatMediumSmall, {0.8f, false, QFont::Normal}},
{FontStyle::ChatMedium, {1, false, QFont::Normal}},
{FontStyle::ChatMediumBold,
{1, false,
QFont::Weight(getApp()->settings->boldScale.getValue())}},
{ChatMediumItalic, {1, true, QFont::Normal}},
{ChatLarge, {1.2f, false, QFont::Normal}},
{ChatVeryLarge, {1.4f, false, QFont::Normal}},
{FontStyle::ChatMediumItalic, {1, true, QFont::Normal}},
{FontStyle::ChatLarge, {1.2f, false, QFont::Normal}},
{FontStyle::ChatVeryLarge, {1.4f, false, QFont::Normal}},
};
sizeScale[ChatMediumBold] = {
sizeScale[FontStyle::ChatMediumBold] = {
1, false, QFont::Weight(getApp()->settings->boldScale.getValue())};
auto data = sizeScale[type];
return FontData(
@ -126,11 +127,11 @@ Fonts::FontData Fonts::createFontData(Type type, float scale)
constexpr float multiplier = 1.f;
#endif
static std::unordered_map<Type, UiFontData> defaultSize{
{Tiny, {8, "Monospace", false, QFont::Normal}},
{UiMedium,
static std::unordered_map<FontStyle, UiFontData> defaultSize{
{FontStyle::Tiny, {8, "Monospace", false, QFont::Normal}},
{FontStyle::UiMedium,
{int(9 * multiplier), DEFAULT_FONT_FAMILY, false, QFont::Normal}},
{UiTabs,
{FontStyle::UiTabs,
{int(9 * multiplier), DEFAULT_FONT_FAMILY, false, QFont::Normal}},
};

View file

@ -16,6 +16,27 @@ namespace chatterino {
class Settings;
class Paths;
enum class FontStyle : uint8_t {
Tiny,
ChatSmall,
ChatMediumSmall,
ChatMedium,
ChatMediumBold,
ChatMediumItalic,
ChatLarge,
ChatVeryLarge,
UiMedium,
UiTabs,
// don't remove this value
EndType,
// make sure to update these values accordingly!
ChatStart = ChatSmall,
ChatEnd = ChatVeryLarge,
};
class Fonts final : public Singleton
{
public:
@ -24,29 +45,9 @@ public:
virtual void initialize(Settings &settings, Paths &paths) override;
// font data gets set in createFontData(...)
enum Type : uint8_t {
Tiny,
ChatSmall,
ChatMediumSmall,
ChatMedium,
ChatMediumBold,
ChatMediumItalic,
ChatLarge,
ChatVeryLarge,
UiMedium,
UiTabs,
// don't remove this value
EndType,
// make sure to update these values accordingly!
ChatStart = ChatSmall,
ChatEnd = ChatVeryLarge,
};
QFont getFont(Type type, float scale);
QFontMetrics getFontMetrics(Type type, float scale);
QFont getFont(FontStyle type, float scale);
QFontMetrics getFontMetrics(FontStyle type, float scale);
pajlada::Settings::Setting<std::string> chatFontFamily;
pajlada::Settings::Setting<int> chatFontSize;
@ -78,12 +79,10 @@ private:
QFont::Weight weight;
};
FontData &getOrCreateFontData(Type type, float scale);
FontData createFontData(Type type, float scale);
FontData &getOrCreateFontData(FontStyle type, float scale);
FontData createFontData(FontStyle type, float scale);
std::vector<std::unordered_map<float, FontData>> fontsByType_;
};
using FontStyle = Fonts::Type;
} // namespace chatterino

View file

@ -5,7 +5,6 @@
#include "common/ChatterinoSetting.hpp"
#include "controllers/highlights/HighlightPhrase.hpp"
#include "controllers/moderationactions/ModerationAction.hpp"
#include "messages/MessageElement.hpp"
#include <pajlada/settings/setting.hpp>
#include <pajlada/settings/settinglistener.hpp>

View file

@ -1,6 +1,7 @@
#include "Updates.hpp"
#include "common/NetworkRequest.hpp"
#include "common/Outcome.hpp"
#include "common/Version.hpp"
#include "singletons/Paths.hpp"
#include "util/CombinePath.hpp"

View file

@ -3,13 +3,20 @@
#include "Application.hpp"
#include "debug/AssertInGuiThread.hpp"
#include "debug/Log.hpp"
#include "messages/MessageElement.hpp"
#include "providers/twitch/TwitchServer.hpp"
#include "singletons/Fonts.hpp"
#include "singletons/Paths.hpp"
#include "singletons/Settings.hpp"
#include "singletons/Theme.hpp"
#include "util/Clamp.hpp"
#include "widgets/AccountSwitchPopupWidget.hpp"
#include "widgets/Notebook.hpp"
#include "widgets/Window.hpp"
#include "widgets/dialogs/SettingsDialog.hpp"
#include "widgets/helper/NotebookTab.hpp"
#include "widgets/splits/Split.hpp"
#include "widgets/splits/SplitContainer.hpp"
#include <QDebug>
#include <QJsonArray>
@ -174,7 +181,7 @@ Window &WindowManager::getSelectedWindow()
return *this->selectedWindow_;
}
Window &WindowManager::createWindow(Window::Type type)
Window &WindowManager::createWindow(WindowType type)
{
assertInGuiThread();
@ -182,7 +189,7 @@ Window &WindowManager::createWindow(Window::Type type)
this->windows_.push_back(window);
window->show();
if (type != Window::Type::Main) {
if (type != WindowType::Main) {
window->setAttribute(Qt::WA_DeleteOnClose);
QObject::connect(window, &QWidget::destroyed, [this, window] {
@ -239,16 +246,16 @@ void WindowManager::initialize(Settings &settings, Paths &paths)
// get type
QString type_val = window_obj.value("type").toString();
Window::Type type =
type_val == "main" ? Window::Type::Main : Window::Type::Popup;
WindowType type =
type_val == "main" ? WindowType::Main : WindowType::Popup;
if (type == Window::Type::Main && mainWindow_ != nullptr) {
type = Window::Type::Popup;
if (type == WindowType::Main && mainWindow_ != nullptr) {
type = WindowType::Popup;
}
Window &window = createWindow(type);
if (type == Window::Type::Main) {
if (type == WindowType::Main) {
mainWindow_ = &window;
}
@ -308,7 +315,7 @@ void WindowManager::initialize(Settings &settings, Paths &paths)
}
if (mainWindow_ == nullptr) {
mainWindow_ = &createWindow(Window::Type::Main);
mainWindow_ = &createWindow(WindowType::Main);
mainWindow_->getNotebook().addPage(true);
}
@ -344,15 +351,15 @@ void WindowManager::save()
// window type
switch (window->getType()) {
case Window::Type::Main:
case WindowType::Main:
window_obj.insert("type", "main");
break;
case Window::Type::Popup:
case WindowType::Popup:
window_obj.insert("type", "popup");
break;
case Window::Type::Attached:;
case WindowType::Attached:;
}
// window geometry

View file

@ -1,13 +1,20 @@
#pragma once
#include "common/Channel.hpp"
#include "common/FlagsEnum.hpp"
#include "common/Singleton.hpp"
#include "widgets/Window.hpp"
#include "widgets/splits/SplitContainer.hpp"
namespace chatterino {
class Settings;
class Paths;
class Window;
class SplitContainer;
enum class MessageElementFlag;
using MessageElementFlags = FlagsEnum<MessageElementFlag>;
enum class WindowType;
class WindowManager final : public Singleton
{
@ -34,7 +41,7 @@ public:
Window &getMainWindow();
Window &getSelectedWindow();
Window &createWindow(Window::Type type);
Window &createWindow(WindowType type);
int windowCount();
Window *windowAt(int index);
@ -63,10 +70,10 @@ private:
std::vector<Window *> windows_;
Window *mainWindow_ = nullptr;
Window *selectedWindow_ = nullptr;
Window *mainWindow_{};
Window *selectedWindow_{};
MessageElementFlags wordFlags_ = MessageElementFlag::Default;
MessageElementFlags wordFlags_{};
pajlada::Settings::SettingListener wordFlagsListener_;
};

View file

@ -6,15 +6,12 @@
namespace chatterino {
void initUpdateButton(Button &button,
std::unique_ptr<UpdateDialog> &handle,
pajlada::Signals::SignalHolder &signalHolder)
{
button.hide();
// show update prompt when clicking the button
QObject::connect(&button, &Button::clicked, [&button, &handle] {
(void)(handle);
QObject::connect(&button, &Button::clicked, [&button] {
auto dialog = new UpdateDialog();
dialog->setActionOnFocusLoss(BaseWindow::Delete);
dialog->move(button.mapToGlobal(

View file

@ -14,7 +14,6 @@ class Button;
class UpdateDialog;
void initUpdateButton(Button &button,
std::unique_ptr<UpdateDialog> &handle,
pajlada::Signals::SignalHolder &signalHolder);
} // namespace chatterino

View file

@ -3,6 +3,7 @@
#include "Application.hpp"
#include "common/Common.hpp"
#include "controllers/accounts/AccountController.hpp"
#include "providers/twitch/TwitchAccount.hpp"
#include "providers/twitch/TwitchCommon.hpp"
namespace chatterino {

View file

@ -1,12 +1,14 @@
#pragma once
#include <QTimer>
#include <QWidget>
#include "common/Channel.hpp"
#include "widgets/splits/Split.hpp"
namespace chatterino {
class Split;
class Channel;
using ChannelPtr = std::shared_ptr<Channel>;
class AttachedWindow : public QWidget
{
AttachedWindow(void *_target, int _yOffset);

View file

@ -4,6 +4,7 @@
#include "boost/algorithm/algorithm.hpp"
#include "debug/Log.hpp"
#include "singletons/Settings.hpp"
#include "singletons/Theme.hpp"
#include "singletons/WindowManager.hpp"
#include "util/PostToThread.hpp"
#include "util/WindowsHelper.hpp"
@ -110,11 +111,11 @@ void BaseWindow::init()
// buttons
TitleBarButton *_minButton = new TitleBarButton;
_minButton->setButtonStyle(TitleBarButton::Minimize);
_minButton->setButtonStyle(TitleBarButtonStyle::Minimize);
TitleBarButton *_maxButton = new TitleBarButton;
_maxButton->setButtonStyle(TitleBarButton::Maximize);
_maxButton->setButtonStyle(TitleBarButtonStyle::Maximize);
TitleBarButton *_exitButton = new TitleBarButton;
_exitButton->setButtonStyle(TitleBarButton::Close);
_exitButton->setButtonStyle(TitleBarButtonStyle::Close);
QObject::connect(_minButton, &TitleBarButton::clicked, this,
[this] {
@ -353,8 +354,8 @@ void BaseWindow::mouseMoveEvent(QMouseEvent *event)
BaseWidget::mouseMoveEvent(event);
}
TitleBarButton *BaseWindow::addTitleBarButton(
const TitleBarButton::Style &style, std::function<void()> onClicked)
TitleBarButton *BaseWindow::addTitleBarButton(const TitleBarButtonStyle &style,
std::function<void()> onClicked)
{
TitleBarButton *button = new TitleBarButton;
button->setScaleIndependantSize(30, 30);
@ -389,10 +390,10 @@ void BaseWindow::changeEvent(QEvent *)
#ifdef USEWINSDK
if (this->ui_.maxButton) {
this->ui_.maxButton->setButtonStyle(this->windowState() &
Qt::WindowMaximized
? TitleBarButton::Unmaximize
: TitleBarButton::Maximize);
this->ui_.maxButton->setButtonStyle(
this->windowState() & Qt::WindowMaximized
? TitleBarButtonStyle::Unmaximize
: TitleBarButtonStyle::Maximize);
}
#endif

View file

@ -1,7 +1,6 @@
#pragma once
#include "BaseWidget.hpp"
#include "widgets/helper/TitlebarButton.hpp"
#include <functional>
#include <pajlada/signals/signalholder.hpp>
@ -15,6 +14,7 @@ namespace chatterino {
class Button;
class EffectLabel;
class TitleBarButton;
enum class TitleBarButtonStyle;
class BaseWindow : public BaseWidget
{
@ -36,7 +36,7 @@ public:
QWidget *getLayoutContainer();
bool hasCustomWindowFrame();
TitleBarButton *addTitleBarButton(const TitleBarButton::Style &style,
TitleBarButton *addTitleBarButton(const TitleBarButtonStyle &style,
std::function<void()> onClicked);
EffectLabel *addTitleBarLabel(std::function<void()> onClicked);
@ -114,6 +114,6 @@ private:
pajlada::Signals::SignalHolder connections_;
std::vector<pajlada::Signals::ScopedConnection> managedConnections_;
};
}; // namespace chatterino
} // namespace chatterino

View file

@ -2,6 +2,7 @@
#include "Application.hpp"
#include "debug/Log.hpp"
#include "singletons/Settings.hpp"
#include "singletons/Theme.hpp"
#include "singletons/WindowManager.hpp"
#include "util/InitUpdateButton.hpp"
@ -27,11 +28,11 @@ namespace chatterino {
Notebook::Notebook(QWidget *parent)
: BaseWidget(parent)
, addButton_(this)
, addButton_(new NotebookButton(this))
{
this->addButton_.setIcon(NotebookButton::Icon::Plus);
this->addButton_->setIcon(NotebookButton::Icon::Plus);
this->addButton_.setHidden(true);
this->addButton_->setHidden(true);
auto *shortcut_next = new QShortcut(QKeySequence("Ctrl+Tab"), this);
QObject::connect(shortcut_next, &QShortcut::activated,
@ -290,14 +291,14 @@ void Notebook::setShowAddButton(bool value)
{
this->showAddButton_ = value;
this->addButton_.setHidden(!value);
this->addButton_->setHidden(!value);
}
void Notebook::scaleChangedEvent(float scale)
{
float h = NOTEBOOK_TAB_HEIGHT * this->getScale();
this->addButton_.setFixedSize(h, h);
this->addButton_->setFixedSize(h, h);
for (auto &i : this->items_) {
i.tab->updateSize();
@ -353,7 +354,7 @@ void Notebook::performLayout(bool animated)
}
if (this->showAddButton_) {
this->addButton_.move(x, y);
this->addButton_->move(x, y);
}
if (this->lineY_ != y + tabHeight) {
@ -368,7 +369,7 @@ void Notebook::performLayout(bool animated)
}
if (this->showAddButton_) {
this->addButton_.raise();
this->addButton_->raise();
}
if (this->selectedPage_ != nullptr) {
@ -389,7 +390,7 @@ void Notebook::paintEvent(QPaintEvent *event)
NotebookButton *Notebook::getAddButton()
{
return &this->addButton_;
return this->addButton_;
}
NotebookButton *Notebook::addCustomButton()
@ -460,8 +461,7 @@ void SplitNotebook::addCustomButtons()
// updates
auto updateBtn = this->addCustomButton();
initUpdateButton(*updateBtn, this->updateDialogHandle_,
this->signalHolder_);
initUpdateButton(*updateBtn, this->signalHolder_);
}
SplitContainer *SplitNotebook::addPage(bool select)

View file

@ -2,10 +2,6 @@
#include "pajlada/signals/signal.hpp"
#include "widgets/BaseWidget.hpp"
#include "widgets/dialogs/UpdateDialog.hpp"
#include "widgets/helper/NotebookButton.hpp"
#include "widgets/helper/NotebookTab.hpp"
#include "widgets/splits/SplitContainer.hpp"
#include <QList>
#include <QMessageBox>
@ -15,6 +11,10 @@
namespace chatterino {
class Window;
class UpdateDialog;
class NotebookButton;
class NotebookTab;
class SplitContainer;
class Notebook : public BaseWidget
{
@ -22,6 +22,7 @@ class Notebook : public BaseWidget
public:
explicit Notebook(QWidget *parent);
~Notebook() override = default;
NotebookTab *addPage(QWidget *page, QString title = QString(),
bool select = false);
@ -74,7 +75,7 @@ private:
QList<Item> items_;
QWidget *selectedPage_ = nullptr;
NotebookButton addButton_;
NotebookButton *addButton_;
std::vector<NotebookButton *> customButtons_;
bool allowUserTabManagement_ = false;
@ -94,7 +95,7 @@ private:
void addCustomButtons();
pajlada::Signals::SignalHolder signalHolder_;
std::unique_ptr<UpdateDialog> updateDialogHandle_;
std::shared_ptr<UpdateDialog> updateDialogHandle_;
std::vector<pajlada::Signals::ScopedConnection> connections_;
};

View file

@ -1,6 +1,7 @@
#include "widgets/Scrollbar.hpp"
#include "Application.hpp"
#include "singletons/Settings.hpp"
#include "singletons/Theme.hpp"
#include "widgets/helper/ChannelView.hpp"
@ -103,8 +104,7 @@ void Scrollbar::setSmallChange(qreal value)
void Scrollbar::setDesiredValue(qreal value, bool animated)
{
auto app = getApp();
animated &= app->settings->enableSmoothScrolling.getValue();
animated &= getSettings()->enableSmoothScrolling.getValue();
value = std::max(this->minimum_,
std::min(this->maximum_ - this->largeChange_, value));
@ -221,8 +221,6 @@ void Scrollbar::printCurrentState(const QString &prefix) const
void Scrollbar::paintEvent(QPaintEvent *)
{
auto *app = getApp();
bool mouseOver = this->mouseOverIndex_ != -1;
int xOffset = mouseOver ? 0 : width() - int(4 * this->getScale());
@ -267,9 +265,11 @@ void Scrollbar::paintEvent(QPaintEvent *)
QColor color = [&] {
switch (highlight.getColor()) {
case ScrollbarHighlight::Highlight:
return app->themes->scrollbars.highlights.highlight;
return getApp()
->themes->scrollbars.highlights.highlight;
case ScrollbarHighlight::Subscription:
return app->themes->scrollbars.highlights.subscription;
return getApp()
->themes->scrollbars.highlights.subscription;
}
return QColor();
}();

View file

@ -1,7 +1,6 @@
#pragma once
#include "messages/LimitedQueue.hpp"
#include "singletons/Settings.hpp"
#include "widgets/BaseWidget.hpp"
#include "widgets/helper/ScrollbarHighlight.hpp"

View file

@ -3,6 +3,7 @@
#include "common/Channel.hpp"
#include "util/Helpers.hpp"
#include "util/LayoutCreator.hpp"
#include "widgets/helper/ChannelView.hpp"
#include "widgets/splits/Split.hpp"
#ifdef USEWEBENGINE

View file

@ -79,7 +79,7 @@ void TooltipWidget::updateFont()
auto app = getApp();
this->setFont(
app->fonts->getFont(Fonts::Type::ChatMediumSmall, this->getScale()));
app->fonts->getFont(FontStyle::ChatMediumSmall, this->getScale()));
}
void TooltipWidget::setText(QString text)

View file

@ -14,8 +14,11 @@
#include "widgets/dialogs/SettingsDialog.hpp"
#include "widgets/dialogs/UpdateDialog.hpp"
#include "widgets/dialogs/WelcomeDialog.hpp"
#include "widgets/helper/EffectLabel.hpp"
#include "widgets/helper/Shortcut.hpp"
#include "widgets/helper/TitlebarButton.hpp"
#include "widgets/splits/Split.hpp"
#include "widgets/splits/SplitContainer.hpp"
#include <QApplication>
#include <QDesktopServices>
@ -28,10 +31,10 @@
namespace chatterino {
Window::Window(Type type)
Window::Window(WindowType type)
: BaseWindow(nullptr, BaseWindow::EnableCustomFrame)
, type_(type)
, notebook_(this)
, notebook_(new SplitNotebook(this))
{
this->addCustomTitlebarButtons();
this->addDebugStuff();
@ -42,26 +45,26 @@ Window::Window(Type type)
[this] { this->onAccountSelected(); });
this->onAccountSelected();
if (type == Type::Main) {
if (type == WindowType::Main) {
this->resize(int(600 * this->getScale()), int(500 * this->getScale()));
} else {
this->resize(int(300 * this->getScale()), int(500 * this->getScale()));
}
}
Window::Type Window::getType()
WindowType Window::getType()
{
return this->type_;
}
SplitNotebook &Window::getNotebook()
{
return this->notebook_;
return *this->notebook_;
}
void Window::repaintVisibleChatWidgets(Channel *channel)
{
auto page = this->notebook_.getOrAddSelectedPage();
auto page = this->notebook_->getOrAddSelectedPage();
for (const auto &split : page->getSplits()) {
if (channel == nullptr || channel == split->getChannel().get()) {
@ -77,7 +80,7 @@ bool Window::event(QEvent *event)
break;
case QEvent::WindowDeactivate: {
auto page = this->notebook_.getOrAddSelectedPage();
auto page = this->notebook_->getOrAddSelectedPage();
if (page != nullptr) {
std::vector<Split *> splits = page->getSplits();
@ -135,7 +138,7 @@ void Window::showEvent(QShowEvent *event)
void Window::closeEvent(QCloseEvent *)
{
if (this->type_ == Type::Main) {
if (this->type_ == WindowType::Main) {
auto app = getApp();
app->windows->save();
app->windows->closeAll();
@ -143,7 +146,7 @@ void Window::closeEvent(QCloseEvent *)
this->closed.invoke();
if (this->type_ == Type::Main) {
if (this->type_ == WindowType::Main) {
QApplication::exit();
}
}
@ -152,35 +155,34 @@ void Window::addLayout()
{
QVBoxLayout *layout = new QVBoxLayout(this);
layout->addWidget(&this->notebook_);
layout->addWidget(this->notebook_);
this->getLayoutContainer()->setLayout(layout);
// set margin
layout->setMargin(0);
this->notebook_.setAllowUserTabManagement(true);
this->notebook_.setShowAddButton(true);
this->notebook_->setAllowUserTabManagement(true);
this->notebook_->setShowAddButton(true);
}
void Window::addCustomTitlebarButtons()
{
if (!this->hasCustomWindowFrame()) return;
if (this->type_ != Type::Main) return;
if (this->type_ != WindowType::Main) return;
// settings
this->addTitleBarButton(TitleBarButton::Settings, [] {
getApp()->windows->showSettingsDialog(); //
});
this->addTitleBarButton(TitleBarButtonStyle::Settings,
[] { getApp()->windows->showSettingsDialog(); });
// updates
auto update = this->addTitleBarButton(TitleBarButton::None, [] {});
auto update = this->addTitleBarButton(TitleBarButtonStyle::None, [] {});
initUpdateButton(*update, this->updateDialogHandle_, this->signalHolder_);
initUpdateButton(*update, this->signalHolder_);
// account
this->userLabel_ = this->addTitleBarLabel([this] {
getApp()->windows->showAccountSelectPopup(this->userLabel_->mapToGlobal(
this->userLabel_->rect().bottomLeft())); //
this->userLabel_->rect().bottomLeft()));
});
this->userLabel_->setMinimumWidth(20 * getScale());
}
@ -252,27 +254,27 @@ void Window::addShortcuts()
// Switch tab
createWindowShortcut(this, "CTRL+T", [this] {
this->notebook_.getOrAddSelectedPage()->appendNewSplit(true);
this->notebook_->getOrAddSelectedPage()->appendNewSplit(true);
});
createWindowShortcut(this, "CTRL+1",
[this] { this->notebook_.selectIndex(0); });
[this] { this->notebook_->selectIndex(0); });
createWindowShortcut(this, "CTRL+2",
[this] { this->notebook_.selectIndex(1); });
[this] { this->notebook_->selectIndex(1); });
createWindowShortcut(this, "CTRL+3",
[this] { this->notebook_.selectIndex(2); });
[this] { this->notebook_->selectIndex(2); });
createWindowShortcut(this, "CTRL+4",
[this] { this->notebook_.selectIndex(3); });
[this] { this->notebook_->selectIndex(3); });
createWindowShortcut(this, "CTRL+5",
[this] { this->notebook_.selectIndex(4); });
[this] { this->notebook_->selectIndex(4); });
createWindowShortcut(this, "CTRL+6",
[this] { this->notebook_.selectIndex(5); });
[this] { this->notebook_->selectIndex(5); });
createWindowShortcut(this, "CTRL+7",
[this] { this->notebook_.selectIndex(6); });
[this] { this->notebook_->selectIndex(6); });
createWindowShortcut(this, "CTRL+8",
[this] { this->notebook_.selectIndex(7); });
[this] { this->notebook_->selectIndex(7); });
createWindowShortcut(this, "CTRL+9",
[this] { this->notebook_.selectIndex(8); });
[this] { this->notebook_->selectIndex(8); });
// Zoom in
{
@ -296,11 +298,11 @@ void Window::addShortcuts()
// New tab
createWindowShortcut(this, "CTRL+SHIFT+T",
[this] { this->notebook_.addPage(true); });
[this] { this->notebook_->addPage(true); });
// Close tab
createWindowShortcut(this, "CTRL+SHIFT+W",
[this] { this->notebook_.removeCurrentPage(); });
[this] { this->notebook_->removeCurrentPage(); });
}
void Window::onAccountSelected()

View file

@ -1,13 +1,6 @@
#pragma once
#include "util/Helpers.hpp"
#include "widgets/BaseWindow.hpp"
#include "widgets/Notebook.hpp"
#include "widgets/dialogs/UpdateDialog.hpp"
//#ifdef USEWINSDK
//#include <platform/borderless/qwinwidget.h>
//#endif
#include <pajlada/settings/setting.hpp>
#include <pajlada/signals/signal.hpp>
@ -16,17 +9,20 @@
namespace chatterino {
class Theme;
class UpdateDialog;
class SplitNotebook;
class Channel;
enum class WindowType { Main, Popup, Attached };
class Window : public BaseWindow
{
Q_OBJECT
public:
enum class Type { Main, Popup, Attached };
explicit Window(WindowType type);
explicit Window(Window::Type type);
Type getType();
WindowType getType();
SplitNotebook &getNotebook();
void repaintVisibleChatWidgets(Channel *channel = nullptr);
@ -45,11 +41,11 @@ private:
void addLayout();
void onAccountSelected();
Type type_;
WindowType type_;
SplitNotebook notebook_;
SplitNotebook *notebook_;
EffectLabel *userLabel_ = nullptr;
std::unique_ptr<UpdateDialog> updateDialogHandle_;
std::shared_ptr<UpdateDialog> updateDialogHandle_;
pajlada::Signals::SignalHolder signalHolder_;

View file

@ -3,9 +3,12 @@
#include "Application.hpp"
#include "controllers/accounts/AccountController.hpp"
#include "debug/Benchmark.hpp"
#include "messages/Message.hpp"
#include "messages/MessageBuilder.hpp"
#include "providers/twitch/TwitchChannel.hpp"
#include "singletons/Emotes.hpp"
#include "widgets/Notebook.hpp"
#include "widgets/helper/ChannelView.hpp"
#include <QHBoxLayout>
#include <QShortcut>

View file

@ -1,13 +1,16 @@
#pragma once
#include "common/Channel.hpp"
#include "widgets/BaseWindow.hpp"
#include "widgets/helper/ChannelView.hpp"
#include <pajlada/signals/signal.hpp>
namespace chatterino {
class Link;
class ChannelView;
class Channel;
using ChannelPtr = std::shared_ptr<Channel>;
class EmotePopup : public BaseWindow
{
public:

View file

@ -1,5 +1,6 @@
#include "widgets/dialogs/LoginDialog.hpp"
#include "Application.hpp"
#include "common/Common.hpp"
#include "common/NetworkRequest.hpp"
#include "controllers/accounts/AccountController.hpp"

View file

@ -1,6 +1,7 @@
#include "LogsPopup.hpp"
#include "IrcMessage"
#include "common/Channel.hpp"
#include "common/NetworkRequest.hpp"
#include "providers/twitch/TwitchChannel.hpp"
#include "providers/twitch/TwitchMessageBuilder.hpp"
@ -14,6 +15,7 @@
namespace chatterino {
LogsPopup::LogsPopup()
: channel_(Channel::getEmpty())
{
this->initLayout();
this->resize(400, 600);

View file

@ -1,6 +1,5 @@
#pragma once
#include "common/Channel.hpp"
#include "widgets/BaseWindow.hpp"
namespace chatterino {
@ -8,6 +7,12 @@ namespace chatterino {
class Channel;
class ChannelView;
class Channel;
using ChannelPtr = std::shared_ptr<Channel>;
struct Message;
using MessagePtr = std::shared_ptr<const Message>;
class LogsPopup : public BaseWindow
{
public:
@ -17,7 +22,7 @@ public:
private:
ChannelView *channelView_ = nullptr;
ChannelPtr channel_ = Channel::getEmpty();
ChannelPtr channel_;
QString userName_;
int roomID_;

View file

@ -1,5 +1,7 @@
#include "NotificationPopup.hpp"
#include "common/Channel.hpp"
#include "messages/Message.hpp"
#include "widgets/helper/ChannelView.hpp"
#include <QApplication>

View file

@ -1,13 +1,17 @@
#pragma once
#include "common/Channel.hpp"
#include "messages/Message.hpp"
#include "widgets/BaseWindow.hpp"
namespace chatterino {
class ChannelView;
class Channel;
using ChannelPtr = std::shared_ptr<Channel>;
struct Message;
using MessagePtr = std::shared_ptr<const Message>;
class NotificationPopup : public BaseWindow
{
public:

View file

@ -2,8 +2,10 @@
#include "Application.hpp"
#include "providers/twitch/TwitchServer.hpp"
#include "singletons/Theme.hpp"
#include "util/LayoutCreator.hpp"
#include "widgets/Notebook.hpp"
#include "widgets/helper/NotebookTab.hpp"
#include <QDialogButtonBox>
#include <QGroupBox>

View file

@ -1,8 +1,8 @@
#pragma once
#include "Application.hpp"
#include "common/Channel.hpp"
#include "widgets/BaseWindow.hpp"
#include "widgets/Notebook.hpp"
#include <pajlada/signals/signal.hpp>
@ -11,7 +11,9 @@
namespace chatterino {
class SelectChannelDialog : public BaseWindow
class Notebook;
class SelectChannelDialog final : public BaseWindow
{
public:
SelectChannelDialog(QWidget *parent = nullptr);

View file

@ -1,6 +1,7 @@
#include "UserInfoPopup.hpp"
#include "Application.hpp"
#include "common/Channel.hpp"
#include "common/NetworkRequest.hpp"
#include "controllers/accounts/AccountController.hpp"
#include "controllers/highlights/HighlightController.hpp"

View file

@ -1,6 +1,5 @@
#pragma once
#include "common/Channel.hpp"
#include "widgets/BaseWindow.hpp"
#include <pajlada/signals/signal.hpp>
@ -9,6 +8,8 @@ class QCheckBox;
namespace chatterino {
class Channel;
using ChannelPtr = std::shared_ptr<Channel>;
class Label;
class UserInfoPopup final : public BaseWindow

View file

@ -1,18 +1,24 @@
#include "ChannelView.hpp"
#include "Application.hpp"
#include "common/Common.hpp"
#include "debug/Benchmark.hpp"
#include "debug/Log.hpp"
#include "messages/Emote.hpp"
#include "messages/LimitedQueueSnapshot.hpp"
#include "messages/Message.hpp"
#include "messages/MessageElement.hpp"
#include "messages/layouts/MessageLayout.hpp"
#include "messages/layouts/MessageLayoutElement.hpp"
#include "providers/twitch/TwitchServer.hpp"
#include "singletons/Settings.hpp"
#include "singletons/Theme.hpp"
#include "singletons/WindowManager.hpp"
#include "util/DistanceBetweenPoints.hpp"
#include "widgets/Scrollbar.hpp"
#include "widgets/TooltipWidget.hpp"
#include "widgets/dialogs/UserInfoPopup.hpp"
#include "widgets/helper/EffectLabel.hpp"
#include "widgets/splits/Split.hpp"
#include <QClipboard>
@ -93,7 +99,7 @@ void addEmoteContextMenuItems(const Emote &emote,
ChannelView::ChannelView(BaseWidget *parent)
: BaseWidget(parent)
, scrollBar_(this)
, scrollBar_(new Scrollbar(this))
{
this->setMouseTracking(true);
@ -124,7 +130,7 @@ void ChannelView::initializeLayout()
QObject::connect(this->goToBottom_, &EffectLabel::clicked, this, [=] {
QTimer::singleShot(180, [=] {
this->scrollBar_.scrollToBottom(
this->scrollBar_->scrollToBottom(
getApp()
->settings->enableSmoothScrollingNewMessages.getValue());
});
@ -133,18 +139,18 @@ void ChannelView::initializeLayout()
void ChannelView::initializeScrollbar()
{
this->scrollBar_.getCurrentValueChanged().connect([this] {
this->scrollBar_->getCurrentValueChanged().connect([this] {
this->actuallyLayoutMessages(true);
this->goToBottom_->setVisible(this->enableScrollingToBottom_ &&
this->scrollBar_.isVisible() &&
!this->scrollBar_.isAtBottom());
this->scrollBar_->isVisible() &&
!this->scrollBar_->isAtBottom());
this->queueUpdate();
});
this->scrollBar_.getDesiredValueChanged().connect([this] {
this->pausedByScrollingUp_ = !this->scrollBar_.isAtBottom();
this->scrollBar_->getDesiredValueChanged().connect([this] {
this->pausedByScrollingUp_ = !this->scrollBar_->isAtBottom();
});
}
@ -212,7 +218,7 @@ void ChannelView::actuallyLayoutMessages(bool causedByScrollbar)
auto messagesSnapshot = this->getMessagesSnapshot();
if (messagesSnapshot.getLength() == 0) {
this->scrollBar_.setVisible(false);
this->scrollBar_->setVisible(false);
return;
}
@ -225,9 +231,9 @@ void ChannelView::actuallyLayoutMessages(bool causedByScrollbar)
// The scrollbar was not visible
// The scrollbar was visible and at the bottom
this->showingLatestMessages_ =
this->scrollBar_.isAtBottom() || !this->scrollBar_.isVisible();
this->scrollBar_->isAtBottom() || !this->scrollBar_->isVisible();
size_t start = size_t(this->scrollBar_.getCurrentValue());
size_t start = size_t(this->scrollBar_->getCurrentValue());
int layoutWidth = this->getLayoutWidth();
MessageElementFlags flags = this->getFlags();
@ -235,7 +241,7 @@ void ChannelView::actuallyLayoutMessages(bool causedByScrollbar)
// layout the visible messages in the view
if (messagesSnapshot.getLength() > start) {
int y = int(-(messagesSnapshot[start]->getHeight() *
(fmod(this->scrollBar_.getCurrentValue(), 1))));
(fmod(this->scrollBar_->getCurrentValue(), 1))));
for (size_t i = start; i < messagesSnapshot.getLength(); ++i) {
auto message = messagesSnapshot[i];
@ -262,8 +268,9 @@ void ChannelView::actuallyLayoutMessages(bool causedByScrollbar)
h -= message->getHeight();
if (h < 0) {
this->scrollBar_.setLargeChange((messagesSnapshot.getLength() - i) +
qreal(h) / message->getHeight());
this->scrollBar_->setLargeChange(
(messagesSnapshot.getLength() - i) +
qreal(h) / message->getHeight());
// this->scrollBar.setDesiredValue(this->scrollBar.getDesiredValue());
showScrollbar = true;
@ -271,20 +278,20 @@ void ChannelView::actuallyLayoutMessages(bool causedByScrollbar)
}
}
this->scrollBar_.setVisible(showScrollbar);
this->scrollBar_->setVisible(showScrollbar);
if (!showScrollbar && !causedByScrollbar) {
this->scrollBar_.setDesiredValue(0);
this->scrollBar_->setDesiredValue(0);
}
this->scrollBar_.setMaximum(messagesSnapshot.getLength());
this->scrollBar_->setMaximum(messagesSnapshot.getLength());
// If we were showing the latest messages and the scrollbar now wants to be
// rendered, scroll to bottom
if (this->enableScrollingToBottom_ && this->showingLatestMessages_ &&
showScrollbar) {
if (!this->isPaused()) {
this->scrollBar_.scrollToBottom(
this->scrollBar_->scrollToBottom(
// this->messageWasAdded &&
app->settings->enableSmoothScrollingNewMessages.getValue());
}
@ -309,7 +316,7 @@ void ChannelView::clearMessages()
Scrollbar &ChannelView::getScrollBar()
{
return this->scrollBar_;
return *this->scrollBar_;
}
QString ChannelView::getSelectedText()
@ -378,7 +385,7 @@ const boost::optional<MessageElementFlags> &ChannelView::getOverrideFlags()
LimitedQueueSnapshot<MessageLayoutPtr> ChannelView::getMessagesSnapshot()
{
if (!this->isPaused() /*|| this->scrollBar_.isVisible()*/) {
if (!this->isPaused() /*|| this->scrollBar_->isVisible()*/) {
this->snapshot_ = this->messages.getSnapshot();
}
@ -413,10 +420,10 @@ void ChannelView::setChannel(ChannelPtr newChannel)
if (this->messages.pushBack(MessageLayoutPtr(messageRef),
deleted)) {
// if (!this->isPaused()) {
if (this->scrollBar_.isAtBottom()) {
this->scrollBar_.scrollToBottom();
if (this->scrollBar_->isAtBottom()) {
this->scrollBar_->scrollToBottom();
} else {
this->scrollBar_.offset(-1);
this->scrollBar_->offset(-1);
}
// }
}
@ -431,7 +438,7 @@ void ChannelView::setChannel(ChannelPtr newChannel)
}
}
this->scrollBar_.addHighlight(message->getScrollBarHighlight());
this->scrollBar_->addHighlight(message->getScrollBarHighlight());
this->messageWasAdded_ = true;
this->layoutMessages();
@ -449,10 +456,10 @@ void ChannelView::setChannel(ChannelPtr newChannel)
if (!this->isPaused()) {
if (this->messages.pushFront(messageRefs).size() > 0) {
if (this->scrollBar_.isAtBottom()) {
this->scrollBar_.scrollToBottom();
if (this->scrollBar_->isAtBottom()) {
this->scrollBar_->scrollToBottom();
} else {
this->scrollBar_.offset(qreal(messages.size()));
this->scrollBar_->offset(qreal(messages.size()));
}
}
}
@ -464,7 +471,7 @@ void ChannelView::setChannel(ChannelPtr newChannel)
messages.at(i)->getScrollBarHighlight());
}
this->scrollBar_.addHighlightsAtStart(highlights);
this->scrollBar_->addHighlightsAtStart(highlights);
this->messageWasAdded_ = true;
this->layoutMessages();
@ -503,7 +510,7 @@ void ChannelView::setChannel(ChannelPtr newChannel)
newItem->flags.set(MessageLayoutFlag::AlternateBackground);
}
this->scrollBar_.replaceHighlight(
this->scrollBar_->replaceHighlight(
index, replacement->getScrollBarHighlight());
this->messages.replaceItem(message, newItem);
@ -563,12 +570,12 @@ void ChannelView::updateLastReadMessage()
void ChannelView::resizeEvent(QResizeEvent *)
{
this->scrollBar_.setGeometry(this->width() - this->scrollBar_.width(), 0,
this->scrollBar_.width(), this->height());
this->scrollBar_->setGeometry(this->width() - this->scrollBar_->width(), 0,
this->scrollBar_->width(), this->height());
this->goToBottom_->setGeometry(0, this->height() - 32, this->width(), 32);
this->scrollBar_.raise();
this->scrollBar_->raise();
this->layoutMessages();
@ -625,9 +632,9 @@ bool ChannelView::isPaused()
void ChannelView::updatePauseStatus()
{
if (this->isPaused()) {
this->scrollBar_.pauseHighlights();
this->scrollBar_->pauseHighlights();
} else {
this->scrollBar_.unpauseHighlights();
this->scrollBar_->unpauseHighlights();
}
}
@ -651,14 +658,14 @@ void ChannelView::drawMessages(QPainter &painter)
auto messagesSnapshot = this->getMessagesSnapshot();
size_t start = size_t(this->scrollBar_.getCurrentValue());
size_t start = size_t(this->scrollBar_->getCurrentValue());
if (start >= messagesSnapshot.getLength()) {
return;
}
int y = int(-(messagesSnapshot[start].get()->getHeight() *
(fmod(this->scrollBar_.getCurrentValue(), 1))));
(fmod(this->scrollBar_->getCurrentValue(), 1))));
MessageLayout *end = nullptr;
bool windowFocused = this->window() == QApplication::activeWindow();
@ -729,12 +736,12 @@ void ChannelView::wheelEvent(QWheelEvent *event)
return;
}
if (this->scrollBar_.isVisible()) {
if (this->scrollBar_->isVisible()) {
auto app = getApp();
float mouseMultiplier = app->settings->mouseScrollMultiplier;
qreal desired = this->scrollBar_.getDesiredValue();
qreal desired = this->scrollBar_->getDesiredValue();
qreal delta = event->delta() * qreal(1.5) * mouseMultiplier;
auto snapshot = this->getMessagesSnapshot();
@ -792,7 +799,7 @@ void ChannelView::wheelEvent(QWheelEvent *event)
}
}
this->scrollBar_.setDesiredValue(desired, true);
this->scrollBar_->setDesiredValue(desired, true);
}
}
@ -1192,14 +1199,14 @@ bool ChannelView::tryGetMessageAt(QPoint p,
{
auto messagesSnapshot = this->getMessagesSnapshot();
size_t start = this->scrollBar_.getCurrentValue();
size_t start = this->scrollBar_->getCurrentValue();
if (start >= messagesSnapshot.getLength()) {
return false;
}
int y = -(messagesSnapshot[start]->getHeight() *
(fmod(this->scrollBar_.getCurrentValue(), 1)));
(fmod(this->scrollBar_->getCurrentValue(), 1)));
for (size_t i = start; i < messagesSnapshot.getLength(); ++i) {
auto message = messagesSnapshot[i];
@ -1219,7 +1226,7 @@ bool ChannelView::tryGetMessageAt(QPoint p,
int ChannelView::getLayoutWidth() const
{
if (this->scrollBar_.isVisible())
if (this->scrollBar_->isVisible())
return int(this->width() - 8 * this->getScale());
return this->width();

View file

@ -1,14 +1,10 @@
#pragma once
#include "common/Channel.hpp"
#include "messages/Image.hpp"
#include "common/FlagsEnum.hpp"
#include "messages/LimitedQueue.hpp"
#include "messages/LimitedQueueSnapshot.hpp"
#include "messages/MessageElement.hpp"
#include "messages/Selection.hpp"
#include "messages/layouts/MessageLayout.hpp"
#include "widgets/BaseWidget.hpp"
#include "widgets/Scrollbar.hpp"
#include "widgets/helper/EffectLabel.hpp"
#include <QPaintEvent>
#include <QScroller>
@ -20,8 +16,23 @@
#include <unordered_set>
namespace chatterino {
enum class HighlightState;
class ChannelView : public BaseWidget
class Channel;
using ChannelPtr = std::shared_ptr<Channel>;
class MessageLayout;
using MessageLayoutPtr = std::shared_ptr<MessageLayout>;
enum class MessageElementFlag;
using MessageElementFlags = FlagsEnum<MessageElementFlag>;
class Scrollbar;
class EffectLabel;
struct Link;
class MessageLayoutElement;
class ChannelView final : public BaseWidget
{
Q_OBJECT
@ -121,7 +132,7 @@ private:
ChannelPtr channel_;
Scrollbar scrollBar_;
Scrollbar *scrollBar_;
EffectLabel *goToBottom_;
// This variable can be used to decide whether or not we should render the

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