mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
turning a lot of includes into forward declares
This commit is contained in:
parent
63eaf3b94c
commit
44f5a15da3
|
@ -6,11 +6,13 @@
|
||||||
#include "controllers/ignores/IgnoreController.hpp"
|
#include "controllers/ignores/IgnoreController.hpp"
|
||||||
#include "controllers/moderationactions/ModerationActions.hpp"
|
#include "controllers/moderationactions/ModerationActions.hpp"
|
||||||
#include "controllers/taggedusers/TaggedUsersController.hpp"
|
#include "controllers/taggedusers/TaggedUsersController.hpp"
|
||||||
|
#include "debug/Log.hpp"
|
||||||
#include "messages/MessageBuilder.hpp"
|
#include "messages/MessageBuilder.hpp"
|
||||||
#include "providers/bttv/BttvEmotes.hpp"
|
#include "providers/bttv/BttvEmotes.hpp"
|
||||||
#include "providers/ffz/FfzEmotes.hpp"
|
#include "providers/ffz/FfzEmotes.hpp"
|
||||||
#include "providers/twitch/PubsubClient.hpp"
|
#include "providers/twitch/PubsubClient.hpp"
|
||||||
#include "providers/twitch/TwitchServer.hpp"
|
#include "providers/twitch/TwitchServer.hpp"
|
||||||
|
#include "singletons/Emotes.hpp"
|
||||||
#include "singletons/Fonts.hpp"
|
#include "singletons/Fonts.hpp"
|
||||||
#include "singletons/Logging.hpp"
|
#include "singletons/Logging.hpp"
|
||||||
#include "singletons/NativeMessaging.hpp"
|
#include "singletons/NativeMessaging.hpp"
|
||||||
|
@ -21,6 +23,7 @@
|
||||||
#include "singletons/WindowManager.hpp"
|
#include "singletons/WindowManager.hpp"
|
||||||
#include "util/IsBigEndian.hpp"
|
#include "util/IsBigEndian.hpp"
|
||||||
#include "util/PostToThread.hpp"
|
#include "util/PostToThread.hpp"
|
||||||
|
#include "widgets/Window.hpp"
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/Singleton.hpp"
|
#include "common/Singleton.hpp"
|
||||||
#include "singletons/Resources.hpp"
|
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
@ -26,7 +25,7 @@ class AccountManager;
|
||||||
class Emotes;
|
class Emotes;
|
||||||
class Settings;
|
class Settings;
|
||||||
class Fonts;
|
class Fonts;
|
||||||
class Resources;
|
class Resources2;
|
||||||
|
|
||||||
class Application
|
class Application
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,3 +32,5 @@ QStringAlias(UserName);
|
||||||
QStringAlias(UserId);
|
QStringAlias(UserId);
|
||||||
QStringAlias(Url);
|
QStringAlias(Url);
|
||||||
QStringAlias(Tooltip);
|
QStringAlias(Tooltip);
|
||||||
|
QStringAlias(EmoteId);
|
||||||
|
QStringAlias(EmoteName);
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/CompletionModel.hpp"
|
#include "common/CompletionModel.hpp"
|
||||||
#include "messages/Image.hpp"
|
|
||||||
#include "messages/LimitedQueue.hpp"
|
#include "messages/LimitedQueue.hpp"
|
||||||
#include "messages/Message.hpp"
|
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
@ -12,7 +10,9 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
struct Message;
|
struct Message;
|
||||||
|
using MessagePtr = std::shared_ptr<const Message>;
|
||||||
|
|
||||||
class Channel : public std::enable_shared_from_this<Channel>
|
class Channel : public std::enable_shared_from_this<Channel>
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
#include "common/Aliases.hpp"
|
#include "common/Aliases.hpp"
|
||||||
#include "common/Outcome.hpp"
|
#include "common/Outcome.hpp"
|
||||||
#include "common/ProviderId.hpp"
|
#include "common/ProviderId.hpp"
|
||||||
#include "debug/Log.hpp"
|
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
@ -39,4 +38,7 @@ std::weak_ptr<T> weakOf(T *element)
|
||||||
return element->shared_from_this();
|
return element->shared_from_this();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct Message;
|
||||||
|
using MessagePtr = std::shared_ptr<const Message>;
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include "controllers/accounts/AccountController.hpp"
|
#include "controllers/accounts/AccountController.hpp"
|
||||||
#include "controllers/commands/CommandController.hpp"
|
#include "controllers/commands/CommandController.hpp"
|
||||||
#include "debug/Log.hpp"
|
#include "debug/Log.hpp"
|
||||||
|
#include "providers/twitch/TwitchChannel.hpp"
|
||||||
#include "providers/twitch/TwitchServer.hpp"
|
#include "providers/twitch/TwitchServer.hpp"
|
||||||
#include "singletons/Emotes.hpp"
|
#include "singletons/Emotes.hpp"
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/Common.hpp"
|
|
||||||
|
|
||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|
|
@ -2,12 +2,11 @@
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
#include "Common.hpp"
|
|
||||||
|
|
||||||
class QNetworkReply;
|
class QNetworkReply;
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
|
class Outcome;
|
||||||
class NetworkResult;
|
class NetworkResult;
|
||||||
|
|
||||||
using NetworkSuccessCallback = std::function<Outcome(NetworkResult)>;
|
using NetworkSuccessCallback = std::function<Outcome(NetworkResult)>;
|
||||||
|
|
|
@ -1,16 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/NetworkRequester.hpp"
|
|
||||||
#include "common/NetworkWorker.hpp"
|
|
||||||
#include "debug/Log.hpp"
|
|
||||||
|
|
||||||
#include <QJsonDocument>
|
|
||||||
#include <QJsonObject>
|
|
||||||
#include <QNetworkAccessManager>
|
#include <QNetworkAccessManager>
|
||||||
#include <QNetworkReply>
|
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QTimer>
|
|
||||||
#include <QUrl>
|
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
#include "common/NetworkRequest.hpp"
|
#include "common/NetworkRequest.hpp"
|
||||||
|
|
||||||
#include "Application.hpp"
|
#include "Application.hpp"
|
||||||
|
#include "common/NetworkData.hpp"
|
||||||
#include "common/NetworkManager.hpp"
|
#include "common/NetworkManager.hpp"
|
||||||
|
#include "common/Outcome.hpp"
|
||||||
#include "debug/Log.hpp"
|
#include "debug/Log.hpp"
|
||||||
#include "providers/twitch/TwitchCommon.hpp"
|
#include "providers/twitch/TwitchCommon.hpp"
|
||||||
#include "singletons/Paths.hpp"
|
#include "singletons/Paths.hpp"
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Application.hpp"
|
|
||||||
#include "common/NetworkCommon.hpp"
|
#include "common/NetworkCommon.hpp"
|
||||||
#include "common/NetworkData.hpp"
|
|
||||||
#include "common/NetworkRequester.hpp"
|
#include "common/NetworkRequester.hpp"
|
||||||
#include "common/NetworkResult.hpp"
|
#include "common/NetworkResult.hpp"
|
||||||
#include "common/NetworkTimer.hpp"
|
#include "common/NetworkTimer.hpp"
|
||||||
#include "common/NetworkWorker.hpp"
|
#include "common/NetworkWorker.hpp"
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
class NetworkData;
|
||||||
|
|
||||||
class NetworkRequest
|
class NetworkRequest
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#include "AccountController.hpp"
|
#include "AccountController.hpp"
|
||||||
|
|
||||||
|
#include "controllers/accounts/Account.hpp"
|
||||||
#include "controllers/accounts/AccountModel.hpp"
|
#include "controllers/accounts/AccountModel.hpp"
|
||||||
|
#include "providers/twitch/TwitchAccount.hpp"
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/Singleton.hpp"
|
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include "common/SignalVector.hpp"
|
#include "common/SignalVector.hpp"
|
||||||
#include "controllers/accounts/Account.hpp"
|
#include "common/Singleton.hpp"
|
||||||
#include "providers/twitch/TwitchAccountManager.hpp"
|
#include "providers/twitch/TwitchAccountManager.hpp"
|
||||||
#include "util/SharedPtrElementLess.hpp"
|
#include "util/SharedPtrElementLess.hpp"
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
|
class Account;
|
||||||
class Settings;
|
class Settings;
|
||||||
class Paths;
|
class Paths;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "AccountModel.hpp"
|
#include "AccountModel.hpp"
|
||||||
|
|
||||||
|
#include "controllers/accounts/Account.hpp"
|
||||||
#include "util/StandardItemHelper.hpp"
|
#include "util/StandardItemHelper.hpp"
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
|
class Account;
|
||||||
class AccountController;
|
class AccountController;
|
||||||
|
|
||||||
class AccountModel : public SignalVectorModel<std::shared_ptr<Account>>
|
class AccountModel : public SignalVectorModel<std::shared_ptr<Account>>
|
||||||
|
|
|
@ -5,7 +5,10 @@
|
||||||
#include "controllers/accounts/AccountController.hpp"
|
#include "controllers/accounts/AccountController.hpp"
|
||||||
#include "controllers/commands/Command.hpp"
|
#include "controllers/commands/Command.hpp"
|
||||||
#include "controllers/commands/CommandModel.hpp"
|
#include "controllers/commands/CommandModel.hpp"
|
||||||
|
#include "debug/Log.hpp"
|
||||||
|
#include "messages/Message.hpp"
|
||||||
#include "messages/MessageBuilder.hpp"
|
#include "messages/MessageBuilder.hpp"
|
||||||
|
#include "messages/MessageElement.hpp"
|
||||||
#include "providers/twitch/TwitchApi.hpp"
|
#include "providers/twitch/TwitchApi.hpp"
|
||||||
#include "providers/twitch/TwitchChannel.hpp"
|
#include "providers/twitch/TwitchChannel.hpp"
|
||||||
#include "providers/twitch/TwitchServer.hpp"
|
#include "providers/twitch/TwitchServer.hpp"
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/Singleton.hpp"
|
#include "common/ChatterinoSetting.hpp"
|
||||||
|
|
||||||
#include "common/SignalVector.hpp"
|
#include "common/SignalVector.hpp"
|
||||||
|
#include "common/Singleton.hpp"
|
||||||
#include "controllers/highlights/HighlightBlacklistUser.hpp"
|
#include "controllers/highlights/HighlightBlacklistUser.hpp"
|
||||||
#include "controllers/highlights/HighlightPhrase.hpp"
|
#include "controllers/highlights/HighlightPhrase.hpp"
|
||||||
#include "messages/Message.hpp"
|
|
||||||
#include "singletons/Settings.hpp"
|
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
|
struct Message;
|
||||||
|
using MessagePtr = std::shared_ptr<const Message>;
|
||||||
|
|
||||||
class Settings;
|
class Settings;
|
||||||
class Paths;
|
class Paths;
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/Singleton.hpp"
|
#include "common/ChatterinoSetting.hpp"
|
||||||
|
|
||||||
#include "common/SignalVector.hpp"
|
#include "common/SignalVector.hpp"
|
||||||
|
#include "common/Singleton.hpp"
|
||||||
#include "controllers/ignores/IgnorePhrase.hpp"
|
#include "controllers/ignores/IgnorePhrase.hpp"
|
||||||
#include "singletons/Settings.hpp"
|
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include "Application.hpp"
|
#include "Application.hpp"
|
||||||
|
#include "messages/Image.hpp"
|
||||||
#include "singletons/Resources.hpp"
|
#include "singletons/Resources.hpp"
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
|
@ -4,11 +4,13 @@
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
#include <pajlada/settings/serialize.hpp>
|
#include <pajlada/settings/serialize.hpp>
|
||||||
|
|
||||||
#include "messages/Image.hpp"
|
|
||||||
#include "util/RapidjsonHelpers.hpp"
|
#include "util/RapidjsonHelpers.hpp"
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
|
class Image;
|
||||||
|
using ImagePtr = std::shared_ptr<Image>;
|
||||||
|
|
||||||
class ModerationAction
|
class ModerationAction
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -7,9 +7,6 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
QStringAlias(EmoteId);
|
|
||||||
QStringAlias(EmoteName);
|
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
struct Emote {
|
struct Emote {
|
||||||
|
|
|
@ -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
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "messages/Image.hpp"
|
#include "messages/Image.hpp"
|
||||||
|
|
||||||
#include "Application.hpp"
|
#include "Application.hpp"
|
||||||
|
#include "common/Common.hpp"
|
||||||
#include "common/NetworkRequest.hpp"
|
#include "common/NetworkRequest.hpp"
|
||||||
#include "debug/AssertInGuiThread.hpp"
|
#include "debug/AssertInGuiThread.hpp"
|
||||||
#include "debug/Benchmark.hpp"
|
#include "debug/Benchmark.hpp"
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/Common.hpp"
|
|
||||||
|
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <boost/noncopyable.hpp>
|
#include <boost/noncopyable.hpp>
|
||||||
|
#include <boost/optional.hpp>
|
||||||
#include <boost/variant.hpp>
|
#include <boost/variant.hpp>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <pajlada/signals/signal.hpp>
|
#include <pajlada/signals/signal.hpp>
|
||||||
|
|
||||||
|
#include "common/Aliases.hpp"
|
||||||
#include "common/NullablePtr.hpp"
|
#include "common/NullablePtr.hpp"
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <common/Common.hpp>
|
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/FlagsEnum.hpp"
|
#include "common/FlagsEnum.hpp"
|
||||||
#include "messages/MessageElement.hpp"
|
|
||||||
#include "providers/twitch/PubsubActions.hpp"
|
|
||||||
#include "widgets/helper/ScrollbarHighlight.hpp"
|
#include "widgets/helper/ScrollbarHighlight.hpp"
|
||||||
|
|
||||||
#include <QTime>
|
#include <QTime>
|
||||||
|
#include <boost/noncopyable.hpp>
|
||||||
#include <cinttypes>
|
#include <cinttypes>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
class MessageElement;
|
||||||
|
|
||||||
enum class MessageFlag : uint16_t {
|
enum class MessageFlag : uint16_t {
|
||||||
None = 0,
|
None = 0,
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
#include "MessageBuilder.hpp"
|
#include "MessageBuilder.hpp"
|
||||||
|
|
||||||
#include "common/LinkParser.hpp"
|
#include "common/LinkParser.hpp"
|
||||||
|
#include "messages/Message.hpp"
|
||||||
|
#include "messages/MessageElement.hpp"
|
||||||
|
#include "providers/twitch/PubsubActions.hpp"
|
||||||
#include "singletons/Emotes.hpp"
|
#include "singletons/Emotes.hpp"
|
||||||
#include "singletons/Resources.hpp"
|
#include "singletons/Resources.hpp"
|
||||||
#include "singletons/Theme.hpp"
|
#include "singletons/Theme.hpp"
|
||||||
|
@ -17,7 +20,7 @@ MessagePtr makeSystemMessage(const QString &text)
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageBuilder::MessageBuilder()
|
MessageBuilder::MessageBuilder()
|
||||||
: message_(std::make_unique<Message>())
|
: message_(std::make_shared<Message>())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,7 +168,9 @@ Message &MessageBuilder::message()
|
||||||
|
|
||||||
MessagePtr MessageBuilder::release()
|
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)
|
void MessageBuilder::append(std::unique_ptr<MessageElement> element)
|
||||||
|
|
|
@ -1,11 +1,15 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "messages/Message.hpp"
|
#include "messages/MessageElement.hpp"
|
||||||
|
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
struct BanAction;
|
||||||
|
struct UnbanAction;
|
||||||
|
struct Message;
|
||||||
|
using MessagePtr = std::shared_ptr<const Message>;
|
||||||
|
|
||||||
struct SystemMessageTag {
|
struct SystemMessageTag {
|
||||||
};
|
};
|
||||||
|
@ -56,7 +60,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<Message> message_;
|
std::shared_ptr<Message> message_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include "MessageColor.hpp"
|
#include "MessageColor.hpp"
|
||||||
|
|
||||||
|
#include "singletons/Theme.hpp"
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
MessageColor::MessageColor(const QColor &color)
|
MessageColor::MessageColor(const QColor &color)
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "singletons/Theme.hpp"
|
|
||||||
|
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
class Theme;
|
||||||
|
|
||||||
struct MessageColor {
|
struct MessageColor {
|
||||||
enum Type { Custom, Text, Link, System };
|
enum Type { Custom, Text, Link, System };
|
||||||
|
|
|
@ -3,9 +3,11 @@
|
||||||
#include "Application.hpp"
|
#include "Application.hpp"
|
||||||
#include "controllers/moderationactions/ModerationActions.hpp"
|
#include "controllers/moderationactions/ModerationActions.hpp"
|
||||||
#include "debug/Benchmark.hpp"
|
#include "debug/Benchmark.hpp"
|
||||||
|
#include "messages/Emote.hpp"
|
||||||
#include "messages/layouts/MessageLayoutContainer.hpp"
|
#include "messages/layouts/MessageLayoutContainer.hpp"
|
||||||
#include "messages/layouts/MessageLayoutElement.hpp"
|
#include "messages/layouts/MessageLayoutElement.hpp"
|
||||||
#include "singletons/Settings.hpp"
|
#include "singletons/Settings.hpp"
|
||||||
|
#include "singletons/Theme.hpp"
|
||||||
#include "util/DebugCount.hpp"
|
#include "util/DebugCount.hpp"
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/FlagsEnum.hpp"
|
#include "common/FlagsEnum.hpp"
|
||||||
#include "messages/Emote.hpp"
|
|
||||||
#include "messages/Image.hpp"
|
|
||||||
#include "messages/Link.hpp"
|
#include "messages/Link.hpp"
|
||||||
#include "messages/MessageColor.hpp"
|
#include "messages/MessageColor.hpp"
|
||||||
#include "singletons/Fonts.hpp"
|
#include "singletons/Fonts.hpp"
|
||||||
|
@ -11,14 +9,20 @@
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QTime>
|
#include <QTime>
|
||||||
#include <boost/noncopyable.hpp>
|
#include <boost/noncopyable.hpp>
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
class Channel;
|
class Channel;
|
||||||
struct MessageLayoutContainer;
|
struct MessageLayoutContainer;
|
||||||
|
|
||||||
|
class Image;
|
||||||
|
using ImagePtr = std::shared_ptr<Image>;
|
||||||
|
|
||||||
|
struct Emote;
|
||||||
|
using EmotePtr = std::shared_ptr<const Emote>;
|
||||||
|
|
||||||
enum class MessageElementFlag {
|
enum class MessageElementFlag {
|
||||||
None = 0,
|
None = 0,
|
||||||
Misc = (1 << 0),
|
Misc = (1 << 0),
|
||||||
|
|
|
@ -2,8 +2,12 @@
|
||||||
|
|
||||||
#include "Application.hpp"
|
#include "Application.hpp"
|
||||||
#include "debug/Benchmark.hpp"
|
#include "debug/Benchmark.hpp"
|
||||||
|
#include "messages/Message.hpp"
|
||||||
|
#include "messages/MessageElement.hpp"
|
||||||
|
#include "messages/layouts/MessageLayoutContainer.hpp"
|
||||||
#include "singletons/Emotes.hpp"
|
#include "singletons/Emotes.hpp"
|
||||||
#include "singletons/Settings.hpp"
|
#include "singletons/Settings.hpp"
|
||||||
|
#include "singletons/Theme.hpp"
|
||||||
#include "singletons/WindowManager.hpp"
|
#include "singletons/WindowManager.hpp"
|
||||||
#include "util/DebugCount.hpp"
|
#include "util/DebugCount.hpp"
|
||||||
|
|
||||||
|
@ -24,6 +28,7 @@ namespace chatterino {
|
||||||
MessageLayout::MessageLayout(MessagePtr message)
|
MessageLayout::MessageLayout(MessagePtr message)
|
||||||
: message_(message)
|
: message_(message)
|
||||||
, buffer_(nullptr)
|
, buffer_(nullptr)
|
||||||
|
, container_(std::make_shared<MessageLayoutContainer>())
|
||||||
{
|
{
|
||||||
DebugCount::increase("message layout");
|
DebugCount::increase("message layout");
|
||||||
}
|
}
|
||||||
|
@ -41,7 +46,7 @@ const Message *MessageLayout::getMessage()
|
||||||
// Height
|
// Height
|
||||||
int MessageLayout::getHeight() const
|
int MessageLayout::getHeight() const
|
||||||
{
|
{
|
||||||
return container_.getHeight();
|
return container_->getHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Layout
|
// Layout
|
||||||
|
@ -82,9 +87,9 @@ bool MessageLayout::layout(int width, float scale, MessageElementFlags flags)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int oldHeight = this->container_.getHeight();
|
int oldHeight = this->container_->getHeight();
|
||||||
this->actuallyLayout(width, flags);
|
this->actuallyLayout(width, flags);
|
||||||
if (widthChanged || this->container_.getHeight() != oldHeight) {
|
if (widthChanged || this->container_->getHeight() != oldHeight) {
|
||||||
this->deleteBuffer();
|
this->deleteBuffer();
|
||||||
}
|
}
|
||||||
this->invalidateBuffer();
|
this->invalidateBuffer();
|
||||||
|
@ -103,22 +108,22 @@ void MessageLayout::actuallyLayout(int width, MessageElementFlags _flags)
|
||||||
messageFlags.unset(MessageFlag::Collapsed);
|
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) {
|
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->deleteBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
this->container_.end();
|
this->container_->end();
|
||||||
this->height_ = this->container_.getHeight();
|
this->height_ = this->container_->getHeight();
|
||||||
|
|
||||||
// collapsed state
|
// collapsed state
|
||||||
this->flags.unset(MessageLayoutFlag::Collapsed);
|
this->flags.unset(MessageLayoutFlag::Collapsed);
|
||||||
if (this->container_.isCollapsed()) {
|
if (this->container_->isCollapsed()) {
|
||||||
this->flags.set(MessageLayoutFlag::Collapsed);
|
this->flags.set(MessageLayoutFlag::Collapsed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -135,11 +140,12 @@ void MessageLayout::paint(QPainter &painter, int width, int y, int messageIndex,
|
||||||
if (!pixmap) {
|
if (!pixmap) {
|
||||||
#ifdef Q_OS_MACOS
|
#ifdef Q_OS_MACOS
|
||||||
pixmap = new QPixmap(int(width * painter.device()->devicePixelRatioF()),
|
pixmap = new QPixmap(int(width * painter.device()->devicePixelRatioF()),
|
||||||
int(container_.getHeight() *
|
int(container_->getHeight() *
|
||||||
painter.device()->devicePixelRatioF()));
|
painter.device()->devicePixelRatioF()));
|
||||||
pixmap->setDevicePixelRatio(painter.device()->devicePixelRatioF());
|
pixmap->setDevicePixelRatio(painter.device()->devicePixelRatioF());
|
||||||
#else
|
#else
|
||||||
pixmap = new QPixmap(width, std::max(16, this->container_.getHeight()));
|
pixmap =
|
||||||
|
new QPixmap(width, std::max(16, this->container_->getHeight()));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
this->buffer_ = std::shared_ptr<QPixmap>(pixmap);
|
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);
|
// this->container.getHeight(), *pixmap);
|
||||||
|
|
||||||
// draw gif emotes
|
// draw gif emotes
|
||||||
this->container_.paintAnimatedElements(painter, y);
|
this->container_->paintAnimatedElements(painter, y);
|
||||||
|
|
||||||
// draw disabled
|
// draw disabled
|
||||||
if (this->message_->flags.has(MessageFlag::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
|
// draw selection
|
||||||
if (!selection.isEmpty()) {
|
if (!selection.isEmpty()) {
|
||||||
this->container_.paintSelection(painter, messageIndex, selection, y);
|
this->container_->paintSelection(painter, messageIndex, selection, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw message seperation line
|
// draw message seperation line
|
||||||
if (app->settings->separateMessages.getValue()) {
|
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);
|
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>(
|
QBrush brush(color, static_cast<Qt::BrushStyle>(
|
||||||
app->settings->lastMessagePattern.getValue()));
|
app->settings->lastMessagePattern.getValue()));
|
||||||
|
|
||||||
painter.fillRect(0, y + this->container_.getHeight() - 1,
|
painter.fillRect(0, y + this->container_->getHeight() - 1,
|
||||||
pixmap->width(), 1, brush);
|
pixmap->width(), 1, brush);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,7 +223,7 @@ void MessageLayout::updateBuffer(QPixmap *buffer, int /*messageIndex*/,
|
||||||
painter.fillRect(buffer->rect(), backgroundColor);
|
painter.fillRect(buffer->rect(), backgroundColor);
|
||||||
|
|
||||||
// draw message
|
// draw message
|
||||||
this->container_.paintElements(painter);
|
this->container_->paintElements(painter);
|
||||||
|
|
||||||
#ifdef FOURTF
|
#ifdef FOURTF
|
||||||
// debug
|
// debug
|
||||||
|
@ -252,7 +258,7 @@ void MessageLayout::deleteCache()
|
||||||
this->deleteBuffer();
|
this->deleteBuffer();
|
||||||
|
|
||||||
#ifdef XD
|
#ifdef XD
|
||||||
this->container_.clear();
|
this->container_->clear();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,22 +271,22 @@ void MessageLayout::deleteCache()
|
||||||
const MessageLayoutElement *MessageLayout::getElementAt(QPoint point)
|
const MessageLayoutElement *MessageLayout::getElementAt(QPoint point)
|
||||||
{
|
{
|
||||||
// go through all words and return the first one that contains the 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
|
int MessageLayout::getLastCharacterIndex() const
|
||||||
{
|
{
|
||||||
return this->container_.getLastCharacterIndex();
|
return this->container_->getLastCharacterIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
int MessageLayout::getSelectionIndex(QPoint position)
|
int MessageLayout::getSelectionIndex(QPoint position)
|
||||||
{
|
{
|
||||||
return this->container_.getSelectionIndex(position);
|
return this->container_->getSelectionIndex(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageLayout::addSelectionText(QString &str, int from, int to)
|
void MessageLayout::addSelectionText(QString &str, int from, int to)
|
||||||
{
|
{
|
||||||
this->container_.addSelectionText(str, from, to);
|
this->container_->addSelectionText(str, from, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -1,19 +1,24 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/FlagsEnum.hpp"
|
#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 <QPixmap>
|
||||||
|
|
||||||
#include <boost/noncopyable.hpp>
|
#include <boost/noncopyable.hpp>
|
||||||
#include <cinttypes>
|
#include <cinttypes>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace chatterino {
|
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 {
|
enum class MessageLayoutFlag : uint8_t {
|
||||||
RequiresBufferUpdate = 1 << 1,
|
RequiresBufferUpdate = 1 << 1,
|
||||||
RequiresLayout = 1 << 2,
|
RequiresLayout = 1 << 2,
|
||||||
|
@ -57,7 +62,7 @@ public:
|
||||||
private:
|
private:
|
||||||
// variables
|
// variables
|
||||||
MessagePtr message_;
|
MessagePtr message_;
|
||||||
MessageLayoutContainer container_;
|
std::shared_ptr<MessageLayoutContainer> container_;
|
||||||
std::shared_ptr<QPixmap> buffer_ = nullptr;
|
std::shared_ptr<QPixmap> buffer_ = nullptr;
|
||||||
bool bufferValid_ = false;
|
bool bufferValid_ = false;
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
#include "MessageLayoutContainer.hpp"
|
#include "MessageLayoutContainer.hpp"
|
||||||
|
|
||||||
#include "Application.hpp"
|
#include "Application.hpp"
|
||||||
#include "MessageLayoutElement.hpp"
|
#include "messages/Message.hpp"
|
||||||
|
#include "messages/MessageElement.hpp"
|
||||||
#include "messages/Selection.hpp"
|
#include "messages/Selection.hpp"
|
||||||
|
#include "messages/layouts/MessageLayoutElement.hpp"
|
||||||
|
#include "singletons/Fonts.hpp"
|
||||||
#include "singletons/Settings.hpp"
|
#include "singletons/Settings.hpp"
|
||||||
|
#include "singletons/Theme.hpp"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
|
@ -1,18 +1,20 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include <QPoint>
|
#include <QPoint>
|
||||||
#include <QRect>
|
#include <QRect>
|
||||||
|
#include <memory>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "messages/Message.hpp"
|
#include "common/FlagsEnum.hpp"
|
||||||
#include "messages/Selection.hpp"
|
#include "messages/Selection.hpp"
|
||||||
|
#include "messages/layouts/MessageLayoutElement.hpp"
|
||||||
|
|
||||||
class QPainter;
|
class QPainter;
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
class MessageLayoutElement;
|
|
||||||
|
enum class MessageFlag : uint16_t;
|
||||||
|
using MessageFlags = FlagsEnum<MessageFlag>;
|
||||||
|
|
||||||
struct Margin {
|
struct Margin {
|
||||||
int top;
|
int top;
|
||||||
|
@ -92,7 +94,7 @@ private:
|
||||||
// variables
|
// variables
|
||||||
float scale_ = 1.f;
|
float scale_ = 1.f;
|
||||||
int width_ = 0;
|
int width_ = 0;
|
||||||
MessageFlags flags_ = MessageFlag::None;
|
MessageFlags flags_{};
|
||||||
int line_ = 0;
|
int line_ = 0;
|
||||||
int height_ = 0;
|
int height_ = 0;
|
||||||
int currentX_ = 0;
|
int currentX_ = 0;
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
#include "messages/layouts/MessageLayoutElement.hpp"
|
#include "messages/layouts/MessageLayoutElement.hpp"
|
||||||
|
|
||||||
#include "Application.hpp"
|
#include "Application.hpp"
|
||||||
|
#include "messages/Image.hpp"
|
||||||
#include "messages/MessageElement.hpp"
|
#include "messages/MessageElement.hpp"
|
||||||
|
#include "singletons/Theme.hpp"
|
||||||
#include "util/DebugCount.hpp"
|
#include "util/DebugCount.hpp"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
|
@ -3,19 +3,19 @@
|
||||||
#include <QPoint>
|
#include <QPoint>
|
||||||
#include <QRect>
|
#include <QRect>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
#include <boost/noncopyable.hpp>
|
#include <boost/noncopyable.hpp>
|
||||||
#include <climits>
|
#include <climits>
|
||||||
|
|
||||||
#include "messages/Image.hpp"
|
|
||||||
#include "messages/Link.hpp"
|
#include "messages/Link.hpp"
|
||||||
#include "messages/MessageColor.hpp"
|
#include "messages/MessageColor.hpp"
|
||||||
#include "singletons/Fonts.hpp"
|
|
||||||
|
|
||||||
class QPainter;
|
class QPainter;
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
class MessageElement;
|
class MessageElement;
|
||||||
|
class Image;
|
||||||
|
using ImagePtr = std::shared_ptr<Image>;
|
||||||
|
enum class FontStyle : uint8_t;
|
||||||
|
|
||||||
class MessageLayoutElement : boost::noncopyable
|
class MessageLayoutElement : boost::noncopyable
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "providers/bttv/BttvEmotes.hpp"
|
#include "providers/bttv/BttvEmotes.hpp"
|
||||||
|
|
||||||
|
#include "common/Common.hpp"
|
||||||
#include "common/NetworkRequest.hpp"
|
#include "common/NetworkRequest.hpp"
|
||||||
#include "debug/Log.hpp"
|
#include "debug/Log.hpp"
|
||||||
#include "messages/Image.hpp"
|
#include "messages/Image.hpp"
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <boost/optional.hpp>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "common/Atomic.hpp"
|
#include "common/Atomic.hpp"
|
||||||
#include "messages/Emote.hpp"
|
#include "messages/Emote.hpp"
|
||||||
|
|
||||||
|
|
|
@ -14,39 +14,41 @@ ChatterinoBadges::ChatterinoBadges()
|
||||||
|
|
||||||
boost::optional<EmotePtr> ChatterinoBadges::getBadge(const UserName &username)
|
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()
|
void ChatterinoBadges::loadChatterinoBadges()
|
||||||
{
|
{
|
||||||
static QString url("https://fourtf.com/chatterino/badges.json");
|
// static QString url("https://fourtf.com/chatterino/badges.json");
|
||||||
|
|
||||||
NetworkRequest req(url);
|
// NetworkRequest req(url);
|
||||||
req.setCaller(QThread::currentThread());
|
// req.setCaller(QThread::currentThread());
|
||||||
|
|
||||||
req.onSuccess([this](auto result) {
|
// req.onSuccess([this](auto result) {
|
||||||
auto jsonRoot = result.parseJson();
|
// auto jsonRoot = result.parseJson();
|
||||||
auto badges = this->badges.access();
|
// auto badges = this->badges.access();
|
||||||
auto replacement = badges->makeReplacment();
|
// auto replacement = badges->makeReplacment();
|
||||||
|
|
||||||
for (auto jsonBadge_ : jsonRoot.value("badges").toArray()) {
|
// for (auto jsonBadge_ : jsonRoot.value("badges").toArray()) {
|
||||||
auto jsonBadge = jsonBadge_.toObject();
|
// auto jsonBadge = jsonBadge_.toObject();
|
||||||
|
|
||||||
auto emote = Emote{
|
// auto emote = Emote{
|
||||||
EmoteName{}, ImageSet{Url{jsonBadge.value("image").toString()}},
|
// EmoteName{},
|
||||||
Tooltip{jsonBadge.value("tooltip").toString()}, Url{}};
|
// ImageSet{Url{jsonBadge.value("image").toString()}},
|
||||||
|
// Tooltip{jsonBadge.value("tooltip").toString()}, Url{}};
|
||||||
|
|
||||||
for (auto jsonUser : jsonBadge.value("users").toArray()) {
|
// for (auto jsonUser : jsonBadge.value("users").toArray()) {
|
||||||
replacement.add(UserName{jsonUser.toString()},
|
// replacement.add(UserName{jsonUser.toString()},
|
||||||
std::move(emote));
|
// std::move(emote));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
replacement.apply();
|
// replacement.apply();
|
||||||
return Success;
|
// return Success;
|
||||||
});
|
//});
|
||||||
|
|
||||||
req.execute();
|
// req.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
#include <unordered_map>
|
|
||||||
#include "common/Common.hpp"
|
#include "common/Aliases.hpp"
|
||||||
#include "common/UniqueAccess.hpp"
|
|
||||||
#include "messages/Emote.hpp"
|
|
||||||
#include "messages/EmoteCache.hpp"
|
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
|
struct Emote;
|
||||||
|
using EmotePtr = std::shared_ptr<const Emote>;
|
||||||
|
|
||||||
class ChatterinoBadges
|
class ChatterinoBadges
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -19,7 +19,7 @@ public:
|
||||||
private:
|
private:
|
||||||
void loadChatterinoBadges();
|
void loadChatterinoBadges();
|
||||||
|
|
||||||
UniqueAccess<EmoteCache<UserName>> badges;
|
// UniqueAccess<EmoteCache<UserName>> badges;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include "Application.hpp"
|
#include "Application.hpp"
|
||||||
#include "debug/Log.hpp"
|
#include "debug/Log.hpp"
|
||||||
|
#include "messages/Emote.hpp"
|
||||||
#include "singletons/Settings.hpp"
|
#include "singletons/Settings.hpp"
|
||||||
|
|
||||||
#include <rapidjson/error/en.h>
|
#include <rapidjson/error/en.h>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "messages/Emote.hpp"
|
|
||||||
#include "util/ConcurrentMap.hpp"
|
#include "util/ConcurrentMap.hpp"
|
||||||
|
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
@ -12,6 +11,9 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
|
struct Emote;
|
||||||
|
using EmotePtr = std::shared_ptr<const Emote>;
|
||||||
|
|
||||||
struct EmojiData {
|
struct EmojiData {
|
||||||
// actual byte-representation of the emoji (i.e. \154075\156150 which is
|
// actual byte-representation of the emoji (i.e. \154075\156150 which is
|
||||||
// :male:)
|
// :male:)
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
|
|
||||||
#include "common/NetworkRequest.hpp"
|
#include "common/NetworkRequest.hpp"
|
||||||
|
#include "common/Outcome.hpp"
|
||||||
#include "debug/Log.hpp"
|
#include "debug/Log.hpp"
|
||||||
#include "messages/Image.hpp"
|
#include "messages/Image.hpp"
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#include "AbstractIrcServer.hpp"
|
#include "AbstractIrcServer.hpp"
|
||||||
|
|
||||||
|
#include "common/Channel.hpp"
|
||||||
#include "common/Common.hpp"
|
#include "common/Common.hpp"
|
||||||
|
#include "debug/Log.hpp"
|
||||||
#include "messages/LimitedQueueSnapshot.hpp"
|
#include "messages/LimitedQueueSnapshot.hpp"
|
||||||
#include "messages/Message.hpp"
|
#include "messages/Message.hpp"
|
||||||
#include "messages/MessageBuilder.hpp"
|
#include "messages/MessageBuilder.hpp"
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/Channel.hpp"
|
|
||||||
#include "providers/irc/IrcConnection2.hpp"
|
#include "providers/irc/IrcConnection2.hpp"
|
||||||
|
|
||||||
#include <IrcMessage>
|
#include <IrcMessage>
|
||||||
|
@ -11,6 +10,9 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
|
class Channel;
|
||||||
|
using ChannelPtr = std::shared_ptr<Channel>;
|
||||||
|
|
||||||
class AbstractIrcServer
|
class AbstractIrcServer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "providers/twitch/TwitchMessageBuilder.hpp"
|
#include "providers/twitch/TwitchMessageBuilder.hpp"
|
||||||
#include "providers/twitch/TwitchServer.hpp"
|
#include "providers/twitch/TwitchServer.hpp"
|
||||||
#include "singletons/Resources.hpp"
|
#include "singletons/Resources.hpp"
|
||||||
|
#include "singletons/Settings.hpp"
|
||||||
#include "singletons/WindowManager.hpp"
|
#include "singletons/WindowManager.hpp"
|
||||||
#include "util/IrcHelpers.hpp"
|
#include "util/IrcHelpers.hpp"
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "providers/twitch/PartialTwitchUser.hpp"
|
#include "providers/twitch/PartialTwitchUser.hpp"
|
||||||
|
|
||||||
|
#include "common/Common.hpp"
|
||||||
#include "common/NetworkRequest.hpp"
|
#include "common/NetworkRequest.hpp"
|
||||||
#include "debug/Log.hpp"
|
#include "debug/Log.hpp"
|
||||||
#include "providers/twitch/TwitchCommon.hpp"
|
#include "providers/twitch/TwitchCommon.hpp"
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "providers/twitch/PubsubHelpers.hpp"
|
#include "providers/twitch/PubsubHelpers.hpp"
|
||||||
|
|
||||||
#include "providers/twitch/PubsubActions.hpp"
|
#include "providers/twitch/PubsubActions.hpp"
|
||||||
|
#include "providers/twitch/TwitchAccount.hpp"
|
||||||
#include "util/RapidjsonHelpers.hpp"
|
#include "util/RapidjsonHelpers.hpp"
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
|
@ -1,16 +1,14 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "debug/Log.hpp"
|
|
||||||
#include "providers/twitch/TwitchAccount.hpp"
|
|
||||||
#include "util/RapidjsonHelpers.hpp"
|
#include "util/RapidjsonHelpers.hpp"
|
||||||
|
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
#include <boost/asio/steady_timer.hpp>
|
#include <boost/asio/steady_timer.hpp>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
|
class TwitchAccount;
|
||||||
struct ActionUser;
|
struct ActionUser;
|
||||||
|
|
||||||
const rapidjson::Value &getArgs(const rapidjson::Value &data);
|
const rapidjson::Value &getArgs(const rapidjson::Value &data);
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include "Application.hpp"
|
#include "Application.hpp"
|
||||||
#include "common/NetworkRequest.hpp"
|
#include "common/NetworkRequest.hpp"
|
||||||
|
#include "common/Outcome.hpp"
|
||||||
#include "debug/Log.hpp"
|
#include "debug/Log.hpp"
|
||||||
#include "providers/twitch/PartialTwitchUser.hpp"
|
#include "providers/twitch/PartialTwitchUser.hpp"
|
||||||
#include "providers/twitch/TwitchCommon.hpp"
|
#include "providers/twitch/TwitchCommon.hpp"
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "common/Aliases.hpp"
|
||||||
#include "common/Atomic.hpp"
|
#include "common/Atomic.hpp"
|
||||||
#include "common/UniqueAccess.hpp"
|
#include "common/UniqueAccess.hpp"
|
||||||
#include "controllers/accounts/Account.hpp"
|
#include "controllers/accounts/Account.hpp"
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include "common/Common.hpp"
|
#include "common/Common.hpp"
|
||||||
#include "debug/Log.hpp"
|
#include "debug/Log.hpp"
|
||||||
|
#include "providers/twitch/TwitchAccount.hpp"
|
||||||
#include "providers/twitch/TwitchCommon.hpp"
|
#include "providers/twitch/TwitchCommon.hpp"
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
|
class TwitchAccount;
|
||||||
class AccountController;
|
class AccountController;
|
||||||
|
|
||||||
class TwitchAccountManager
|
class TwitchAccountManager
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "providers/twitch/TwitchApi.hpp"
|
#include "providers/twitch/TwitchApi.hpp"
|
||||||
|
|
||||||
|
#include "common/Common.hpp"
|
||||||
#include "common/NetworkRequest.hpp"
|
#include "common/NetworkRequest.hpp"
|
||||||
#include "debug/Log.hpp"
|
#include "debug/Log.hpp"
|
||||||
#include "providers/twitch/TwitchCommon.hpp"
|
#include "providers/twitch/TwitchCommon.hpp"
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
#include <QJsonValue>
|
#include <QJsonValue>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include "common/NetworkRequest.hpp"
|
#include "common/NetworkRequest.hpp"
|
||||||
|
#include "common/Outcome.hpp"
|
||||||
|
#include "messages/Emote.hpp"
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <messages/Emote.hpp>
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include "util/QStringHash.hpp"
|
#include "util/QStringHash.hpp"
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
|
struct Emote;
|
||||||
|
using EmotePtr = std::shared_ptr<const Emote>;
|
||||||
|
|
||||||
class Settings;
|
class Settings;
|
||||||
class Paths;
|
class Paths;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "providers/twitch/TwitchChannel.hpp"
|
#include "providers/twitch/TwitchChannel.hpp"
|
||||||
|
|
||||||
|
#include "Application.hpp"
|
||||||
#include "common/Common.hpp"
|
#include "common/Common.hpp"
|
||||||
#include "common/NetworkRequest.hpp"
|
#include "common/NetworkRequest.hpp"
|
||||||
#include "controllers/accounts/AccountController.hpp"
|
#include "controllers/accounts/AccountController.hpp"
|
||||||
|
|
|
@ -2,21 +2,23 @@
|
||||||
|
|
||||||
#include <IrcConnection>
|
#include <IrcConnection>
|
||||||
|
|
||||||
|
#include "common/Aliases.hpp"
|
||||||
#include "common/Atomic.hpp"
|
#include "common/Atomic.hpp"
|
||||||
#include "common/Channel.hpp"
|
#include "common/Channel.hpp"
|
||||||
#include "common/Common.hpp"
|
#include "common/Outcome.hpp"
|
||||||
#include "common/UniqueAccess.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 <mutex>
|
||||||
|
#include <pajlada/signals/signalholder.hpp>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
|
struct Emote;
|
||||||
|
using EmotePtr = std::shared_ptr<const Emote>;
|
||||||
|
class EmoteMap;
|
||||||
|
|
||||||
class TwitchServer;
|
class TwitchServer;
|
||||||
|
|
||||||
class TwitchChannel final : public Channel, pajlada::Signals::SignalHolder
|
class TwitchChannel final : public Channel, pajlada::Signals::SignalHolder
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "common/NetworkRequest.hpp"
|
#include "common/NetworkRequest.hpp"
|
||||||
#include "debug/Benchmark.hpp"
|
#include "debug/Benchmark.hpp"
|
||||||
#include "debug/Log.hpp"
|
#include "debug/Log.hpp"
|
||||||
|
#include "messages/Emote.hpp"
|
||||||
#include "messages/Image.hpp"
|
#include "messages/Image.hpp"
|
||||||
#include "util/RapidjsonHelpers.hpp"
|
#include "util/RapidjsonHelpers.hpp"
|
||||||
|
|
||||||
|
|
|
@ -3,18 +3,18 @@
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
|
#include "common/Aliases.hpp"
|
||||||
#include "common/UniqueAccess.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 "providers/twitch/TwitchEmotes.hpp"
|
||||||
#include "util/ConcurrentMap.hpp"
|
|
||||||
|
|
||||||
#define TWITCH_EMOTE_TEMPLATE \
|
#define TWITCH_EMOTE_TEMPLATE \
|
||||||
"https://static-cdn.jtvnw.net/emoticons/v1/{id}/{scale}"
|
"https://static-cdn.jtvnw.net/emoticons/v1/{id}/{scale}"
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
|
struct Emote;
|
||||||
|
using EmotePtr = std::shared_ptr<const Emote>;
|
||||||
|
|
||||||
class TwitchEmotes
|
class TwitchEmotes
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include "controllers/highlights/HighlightController.hpp"
|
#include "controllers/highlights/HighlightController.hpp"
|
||||||
#include "controllers/ignores/IgnoreController.hpp"
|
#include "controllers/ignores/IgnoreController.hpp"
|
||||||
#include "debug/Log.hpp"
|
#include "debug/Log.hpp"
|
||||||
|
#include "messages/Message.hpp"
|
||||||
#include "providers/twitch/TwitchChannel.hpp"
|
#include "providers/twitch/TwitchChannel.hpp"
|
||||||
#include "singletons/Emotes.hpp"
|
#include "singletons/Emotes.hpp"
|
||||||
#include "singletons/Resources.hpp"
|
#include "singletons/Resources.hpp"
|
||||||
|
@ -12,6 +13,7 @@
|
||||||
#include "singletons/Theme.hpp"
|
#include "singletons/Theme.hpp"
|
||||||
#include "singletons/WindowManager.hpp"
|
#include "singletons/WindowManager.hpp"
|
||||||
#include "util/IrcHelpers.hpp"
|
#include "util/IrcHelpers.hpp"
|
||||||
|
#include "widgets/Window.hpp"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
|
@ -1,15 +1,18 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "common/Aliases.hpp"
|
||||||
|
#include "common/Outcome.hpp"
|
||||||
#include "messages/MessageBuilder.hpp"
|
#include "messages/MessageBuilder.hpp"
|
||||||
#include "singletons/Emotes.hpp"
|
|
||||||
|
|
||||||
#include <IrcMessage>
|
#include <IrcMessage>
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
|
struct Emote;
|
||||||
|
using EmotePtr = std::shared_ptr<const Emote>;
|
||||||
|
|
||||||
class Channel;
|
class Channel;
|
||||||
class TwitchChannel;
|
class TwitchChannel;
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "providers/twitch/IrcMessageHandler.hpp"
|
#include "providers/twitch/IrcMessageHandler.hpp"
|
||||||
#include "providers/twitch/PubsubClient.hpp"
|
#include "providers/twitch/PubsubClient.hpp"
|
||||||
#include "providers/twitch/TwitchAccount.hpp"
|
#include "providers/twitch/TwitchAccount.hpp"
|
||||||
|
#include "providers/twitch/TwitchChannel.hpp"
|
||||||
#include "providers/twitch/TwitchHelpers.hpp"
|
#include "providers/twitch/TwitchHelpers.hpp"
|
||||||
#include "providers/twitch/TwitchMessageBuilder.hpp"
|
#include "providers/twitch/TwitchMessageBuilder.hpp"
|
||||||
#include "util/PostToThread.hpp"
|
#include "util/PostToThread.hpp"
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/Atomic.hpp"
|
#include "common/Atomic.hpp"
|
||||||
|
#include "common/Channel.hpp"
|
||||||
#include "common/Singleton.hpp"
|
#include "common/Singleton.hpp"
|
||||||
|
#include "pajlada/signals/signalholder.hpp"
|
||||||
#include "providers/irc/AbstractIrcServer.hpp"
|
#include "providers/irc/AbstractIrcServer.hpp"
|
||||||
#include "providers/twitch/TwitchAccount.hpp"
|
|
||||||
#include "providers/twitch/TwitchChannel.hpp"
|
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include "Application.hpp"
|
#include "Application.hpp"
|
||||||
#include "debug/AssertInGuiThread.hpp"
|
#include "debug/AssertInGuiThread.hpp"
|
||||||
|
#include "singletons/Settings.hpp"
|
||||||
#include "singletons/WindowManager.hpp"
|
#include "singletons/WindowManager.hpp"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
@ -26,7 +27,7 @@ Fonts::Fonts()
|
||||||
: chatFontFamily("/appearance/currentFontFamily", DEFAULT_FONT_FAMILY)
|
: chatFontFamily("/appearance/currentFontFamily", DEFAULT_FONT_FAMILY)
|
||||||
, chatFontSize("/appearance/currentFontSize", DEFAULT_FONT_SIZE)
|
, chatFontSize("/appearance/currentFontSize", DEFAULT_FONT_SIZE)
|
||||||
{
|
{
|
||||||
this->fontsByType_.resize(size_t(EndType));
|
this->fontsByType_.resize(size_t(FontStyle::EndType));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fonts::initialize(Settings &, Paths &)
|
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;
|
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;
|
return this->getOrCreateFontData(type, scale).metrics;
|
||||||
}
|
}
|
||||||
|
|
||||||
Fonts::FontData &Fonts::getOrCreateFontData(Type type, float scale)
|
Fonts::FontData &Fonts::getOrCreateFontData(FontStyle type, float scale)
|
||||||
{
|
{
|
||||||
assertInGuiThread();
|
assertInGuiThread();
|
||||||
|
|
||||||
assert(type >= 0 && type < EndType);
|
assert(type < FontStyle::EndType);
|
||||||
|
|
||||||
auto &map = this->fontsByType_[size_t(type)];
|
auto &map = this->fontsByType_[size_t(type)];
|
||||||
|
|
||||||
|
@ -94,22 +95,22 @@ Fonts::FontData &Fonts::getOrCreateFontData(Type type, float scale)
|
||||||
return result.first->second;
|
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)
|
// check if it's a chat (scale the setting)
|
||||||
if (type >= ChatStart && type <= ChatEnd) {
|
if (type >= FontStyle::ChatStart && type <= FontStyle::ChatEnd) {
|
||||||
static std::unordered_map<Type, ChatFontData> sizeScale{
|
static std::unordered_map<FontStyle, ChatFontData> sizeScale{
|
||||||
{ChatSmall, {0.6f, false, QFont::Normal}},
|
{FontStyle::ChatSmall, {0.6f, false, QFont::Normal}},
|
||||||
{ChatMediumSmall, {0.8f, false, QFont::Normal}},
|
{FontStyle::ChatMediumSmall, {0.8f, false, QFont::Normal}},
|
||||||
{ChatMedium, {1, false, QFont::Normal}},
|
{FontStyle::ChatMedium, {1, false, QFont::Normal}},
|
||||||
{ChatMediumBold,
|
{FontStyle::ChatMediumBold,
|
||||||
{1, false,
|
{1, false,
|
||||||
QFont::Weight(getApp()->settings->boldScale.getValue())}},
|
QFont::Weight(getApp()->settings->boldScale.getValue())}},
|
||||||
{ChatMediumItalic, {1, true, QFont::Normal}},
|
{FontStyle::ChatMediumItalic, {1, true, QFont::Normal}},
|
||||||
{ChatLarge, {1.2f, false, QFont::Normal}},
|
{FontStyle::ChatLarge, {1.2f, false, QFont::Normal}},
|
||||||
{ChatVeryLarge, {1.4f, false, QFont::Normal}},
|
{FontStyle::ChatVeryLarge, {1.4f, false, QFont::Normal}},
|
||||||
};
|
};
|
||||||
sizeScale[ChatMediumBold] = {
|
sizeScale[FontStyle::ChatMediumBold] = {
|
||||||
1, false, QFont::Weight(getApp()->settings->boldScale.getValue())};
|
1, false, QFont::Weight(getApp()->settings->boldScale.getValue())};
|
||||||
auto data = sizeScale[type];
|
auto data = sizeScale[type];
|
||||||
return FontData(
|
return FontData(
|
||||||
|
@ -126,11 +127,11 @@ Fonts::FontData Fonts::createFontData(Type type, float scale)
|
||||||
constexpr float multiplier = 1.f;
|
constexpr float multiplier = 1.f;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static std::unordered_map<Type, UiFontData> defaultSize{
|
static std::unordered_map<FontStyle, UiFontData> defaultSize{
|
||||||
{Tiny, {8, "Monospace", false, QFont::Normal}},
|
{FontStyle::Tiny, {8, "Monospace", false, QFont::Normal}},
|
||||||
{UiMedium,
|
{FontStyle::UiMedium,
|
||||||
{int(9 * multiplier), DEFAULT_FONT_FAMILY, false, QFont::Normal}},
|
{int(9 * multiplier), DEFAULT_FONT_FAMILY, false, QFont::Normal}},
|
||||||
{UiTabs,
|
{FontStyle::UiTabs,
|
||||||
{int(9 * multiplier), DEFAULT_FONT_FAMILY, false, QFont::Normal}},
|
{int(9 * multiplier), DEFAULT_FONT_FAMILY, false, QFont::Normal}},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -16,15 +16,7 @@ namespace chatterino {
|
||||||
class Settings;
|
class Settings;
|
||||||
class Paths;
|
class Paths;
|
||||||
|
|
||||||
class Fonts final : public Singleton
|
enum class FontStyle : uint8_t {
|
||||||
{
|
|
||||||
public:
|
|
||||||
Fonts();
|
|
||||||
|
|
||||||
virtual void initialize(Settings &settings, Paths &paths) override;
|
|
||||||
|
|
||||||
// font data gets set in createFontData(...)
|
|
||||||
enum Type : uint8_t {
|
|
||||||
Tiny,
|
Tiny,
|
||||||
ChatSmall,
|
ChatSmall,
|
||||||
ChatMediumSmall,
|
ChatMediumSmall,
|
||||||
|
@ -43,10 +35,19 @@ public:
|
||||||
// make sure to update these values accordingly!
|
// make sure to update these values accordingly!
|
||||||
ChatStart = ChatSmall,
|
ChatStart = ChatSmall,
|
||||||
ChatEnd = ChatVeryLarge,
|
ChatEnd = ChatVeryLarge,
|
||||||
};
|
};
|
||||||
|
|
||||||
QFont getFont(Type type, float scale);
|
class Fonts final : public Singleton
|
||||||
QFontMetrics getFontMetrics(Type type, float scale);
|
{
|
||||||
|
public:
|
||||||
|
Fonts();
|
||||||
|
|
||||||
|
virtual void initialize(Settings &settings, Paths &paths) override;
|
||||||
|
|
||||||
|
// font data gets set in createFontData(...)
|
||||||
|
|
||||||
|
QFont getFont(FontStyle type, float scale);
|
||||||
|
QFontMetrics getFontMetrics(FontStyle type, float scale);
|
||||||
|
|
||||||
pajlada::Settings::Setting<std::string> chatFontFamily;
|
pajlada::Settings::Setting<std::string> chatFontFamily;
|
||||||
pajlada::Settings::Setting<int> chatFontSize;
|
pajlada::Settings::Setting<int> chatFontSize;
|
||||||
|
@ -78,12 +79,10 @@ private:
|
||||||
QFont::Weight weight;
|
QFont::Weight weight;
|
||||||
};
|
};
|
||||||
|
|
||||||
FontData &getOrCreateFontData(Type type, float scale);
|
FontData &getOrCreateFontData(FontStyle type, float scale);
|
||||||
FontData createFontData(Type type, float scale);
|
FontData createFontData(FontStyle type, float scale);
|
||||||
|
|
||||||
std::vector<std::unordered_map<float, FontData>> fontsByType_;
|
std::vector<std::unordered_map<float, FontData>> fontsByType_;
|
||||||
};
|
};
|
||||||
|
|
||||||
using FontStyle = Fonts::Type;
|
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
#include "common/ChatterinoSetting.hpp"
|
#include "common/ChatterinoSetting.hpp"
|
||||||
#include "controllers/highlights/HighlightPhrase.hpp"
|
#include "controllers/highlights/HighlightPhrase.hpp"
|
||||||
#include "controllers/moderationactions/ModerationAction.hpp"
|
#include "controllers/moderationactions/ModerationAction.hpp"
|
||||||
#include "messages/MessageElement.hpp"
|
|
||||||
|
|
||||||
#include <pajlada/settings/setting.hpp>
|
#include <pajlada/settings/setting.hpp>
|
||||||
#include <pajlada/settings/settinglistener.hpp>
|
#include <pajlada/settings/settinglistener.hpp>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "Updates.hpp"
|
#include "Updates.hpp"
|
||||||
|
|
||||||
#include "common/NetworkRequest.hpp"
|
#include "common/NetworkRequest.hpp"
|
||||||
|
#include "common/Outcome.hpp"
|
||||||
#include "common/Version.hpp"
|
#include "common/Version.hpp"
|
||||||
#include "singletons/Paths.hpp"
|
#include "singletons/Paths.hpp"
|
||||||
#include "util/CombinePath.hpp"
|
#include "util/CombinePath.hpp"
|
||||||
|
|
|
@ -3,13 +3,20 @@
|
||||||
#include "Application.hpp"
|
#include "Application.hpp"
|
||||||
#include "debug/AssertInGuiThread.hpp"
|
#include "debug/AssertInGuiThread.hpp"
|
||||||
#include "debug/Log.hpp"
|
#include "debug/Log.hpp"
|
||||||
|
#include "messages/MessageElement.hpp"
|
||||||
#include "providers/twitch/TwitchServer.hpp"
|
#include "providers/twitch/TwitchServer.hpp"
|
||||||
#include "singletons/Fonts.hpp"
|
#include "singletons/Fonts.hpp"
|
||||||
#include "singletons/Paths.hpp"
|
#include "singletons/Paths.hpp"
|
||||||
|
#include "singletons/Settings.hpp"
|
||||||
#include "singletons/Theme.hpp"
|
#include "singletons/Theme.hpp"
|
||||||
#include "util/Clamp.hpp"
|
#include "util/Clamp.hpp"
|
||||||
#include "widgets/AccountSwitchPopupWidget.hpp"
|
#include "widgets/AccountSwitchPopupWidget.hpp"
|
||||||
|
#include "widgets/Notebook.hpp"
|
||||||
|
#include "widgets/Window.hpp"
|
||||||
#include "widgets/dialogs/SettingsDialog.hpp"
|
#include "widgets/dialogs/SettingsDialog.hpp"
|
||||||
|
#include "widgets/helper/NotebookTab.hpp"
|
||||||
|
#include "widgets/splits/Split.hpp"
|
||||||
|
#include "widgets/splits/SplitContainer.hpp"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
|
@ -174,7 +181,7 @@ Window &WindowManager::getSelectedWindow()
|
||||||
return *this->selectedWindow_;
|
return *this->selectedWindow_;
|
||||||
}
|
}
|
||||||
|
|
||||||
Window &WindowManager::createWindow(Window::Type type)
|
Window &WindowManager::createWindow(WindowType type)
|
||||||
{
|
{
|
||||||
assertInGuiThread();
|
assertInGuiThread();
|
||||||
|
|
||||||
|
@ -182,7 +189,7 @@ Window &WindowManager::createWindow(Window::Type type)
|
||||||
this->windows_.push_back(window);
|
this->windows_.push_back(window);
|
||||||
window->show();
|
window->show();
|
||||||
|
|
||||||
if (type != Window::Type::Main) {
|
if (type != WindowType::Main) {
|
||||||
window->setAttribute(Qt::WA_DeleteOnClose);
|
window->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
|
||||||
QObject::connect(window, &QWidget::destroyed, [this, window] {
|
QObject::connect(window, &QWidget::destroyed, [this, window] {
|
||||||
|
@ -239,16 +246,16 @@ void WindowManager::initialize(Settings &settings, Paths &paths)
|
||||||
|
|
||||||
// get type
|
// get type
|
||||||
QString type_val = window_obj.value("type").toString();
|
QString type_val = window_obj.value("type").toString();
|
||||||
Window::Type type =
|
WindowType type =
|
||||||
type_val == "main" ? Window::Type::Main : Window::Type::Popup;
|
type_val == "main" ? WindowType::Main : WindowType::Popup;
|
||||||
|
|
||||||
if (type == Window::Type::Main && mainWindow_ != nullptr) {
|
if (type == WindowType::Main && mainWindow_ != nullptr) {
|
||||||
type = Window::Type::Popup;
|
type = WindowType::Popup;
|
||||||
}
|
}
|
||||||
|
|
||||||
Window &window = createWindow(type);
|
Window &window = createWindow(type);
|
||||||
|
|
||||||
if (type == Window::Type::Main) {
|
if (type == WindowType::Main) {
|
||||||
mainWindow_ = &window;
|
mainWindow_ = &window;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -308,7 +315,7 @@ void WindowManager::initialize(Settings &settings, Paths &paths)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mainWindow_ == nullptr) {
|
if (mainWindow_ == nullptr) {
|
||||||
mainWindow_ = &createWindow(Window::Type::Main);
|
mainWindow_ = &createWindow(WindowType::Main);
|
||||||
mainWindow_->getNotebook().addPage(true);
|
mainWindow_->getNotebook().addPage(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -344,15 +351,15 @@ void WindowManager::save()
|
||||||
|
|
||||||
// window type
|
// window type
|
||||||
switch (window->getType()) {
|
switch (window->getType()) {
|
||||||
case Window::Type::Main:
|
case WindowType::Main:
|
||||||
window_obj.insert("type", "main");
|
window_obj.insert("type", "main");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Window::Type::Popup:
|
case WindowType::Popup:
|
||||||
window_obj.insert("type", "popup");
|
window_obj.insert("type", "popup");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Window::Type::Attached:;
|
case WindowType::Attached:;
|
||||||
}
|
}
|
||||||
|
|
||||||
// window geometry
|
// window geometry
|
||||||
|
|
|
@ -1,13 +1,20 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "common/Channel.hpp"
|
||||||
|
#include "common/FlagsEnum.hpp"
|
||||||
#include "common/Singleton.hpp"
|
#include "common/Singleton.hpp"
|
||||||
#include "widgets/Window.hpp"
|
|
||||||
#include "widgets/splits/SplitContainer.hpp"
|
#include "widgets/splits/SplitContainer.hpp"
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
class Settings;
|
class Settings;
|
||||||
class Paths;
|
class Paths;
|
||||||
|
class Window;
|
||||||
|
class SplitContainer;
|
||||||
|
|
||||||
|
enum class MessageElementFlag;
|
||||||
|
using MessageElementFlags = FlagsEnum<MessageElementFlag>;
|
||||||
|
enum class WindowType;
|
||||||
|
|
||||||
class WindowManager final : public Singleton
|
class WindowManager final : public Singleton
|
||||||
{
|
{
|
||||||
|
@ -34,7 +41,7 @@ public:
|
||||||
|
|
||||||
Window &getMainWindow();
|
Window &getMainWindow();
|
||||||
Window &getSelectedWindow();
|
Window &getSelectedWindow();
|
||||||
Window &createWindow(Window::Type type);
|
Window &createWindow(WindowType type);
|
||||||
|
|
||||||
int windowCount();
|
int windowCount();
|
||||||
Window *windowAt(int index);
|
Window *windowAt(int index);
|
||||||
|
@ -63,10 +70,10 @@ private:
|
||||||
|
|
||||||
std::vector<Window *> windows_;
|
std::vector<Window *> windows_;
|
||||||
|
|
||||||
Window *mainWindow_ = nullptr;
|
Window *mainWindow_{};
|
||||||
Window *selectedWindow_ = nullptr;
|
Window *selectedWindow_{};
|
||||||
|
|
||||||
MessageElementFlags wordFlags_ = MessageElementFlag::Default;
|
MessageElementFlags wordFlags_{};
|
||||||
pajlada::Settings::SettingListener wordFlagsListener_;
|
pajlada::Settings::SettingListener wordFlagsListener_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -6,15 +6,12 @@
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
void initUpdateButton(Button &button,
|
void initUpdateButton(Button &button,
|
||||||
std::unique_ptr<UpdateDialog> &handle,
|
|
||||||
pajlada::Signals::SignalHolder &signalHolder)
|
pajlada::Signals::SignalHolder &signalHolder)
|
||||||
{
|
{
|
||||||
button.hide();
|
button.hide();
|
||||||
|
|
||||||
// show update prompt when clicking the button
|
// show update prompt when clicking the button
|
||||||
QObject::connect(&button, &Button::clicked, [&button, &handle] {
|
QObject::connect(&button, &Button::clicked, [&button] {
|
||||||
(void)(handle);
|
|
||||||
|
|
||||||
auto dialog = new UpdateDialog();
|
auto dialog = new UpdateDialog();
|
||||||
dialog->setActionOnFocusLoss(BaseWindow::Delete);
|
dialog->setActionOnFocusLoss(BaseWindow::Delete);
|
||||||
dialog->move(button.mapToGlobal(
|
dialog->move(button.mapToGlobal(
|
||||||
|
|
|
@ -14,7 +14,6 @@ class Button;
|
||||||
class UpdateDialog;
|
class UpdateDialog;
|
||||||
|
|
||||||
void initUpdateButton(Button &button,
|
void initUpdateButton(Button &button,
|
||||||
std::unique_ptr<UpdateDialog> &handle,
|
|
||||||
pajlada::Signals::SignalHolder &signalHolder);
|
pajlada::Signals::SignalHolder &signalHolder);
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "Application.hpp"
|
#include "Application.hpp"
|
||||||
#include "common/Common.hpp"
|
#include "common/Common.hpp"
|
||||||
#include "controllers/accounts/AccountController.hpp"
|
#include "controllers/accounts/AccountController.hpp"
|
||||||
|
#include "providers/twitch/TwitchAccount.hpp"
|
||||||
#include "providers/twitch/TwitchCommon.hpp"
|
#include "providers/twitch/TwitchCommon.hpp"
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <QTimer>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
#include "common/Channel.hpp"
|
|
||||||
#include "widgets/splits/Split.hpp"
|
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
|
class Split;
|
||||||
|
class Channel;
|
||||||
|
using ChannelPtr = std::shared_ptr<Channel>;
|
||||||
|
|
||||||
class AttachedWindow : public QWidget
|
class AttachedWindow : public QWidget
|
||||||
{
|
{
|
||||||
AttachedWindow(void *_target, int _yOffset);
|
AttachedWindow(void *_target, int _yOffset);
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "boost/algorithm/algorithm.hpp"
|
#include "boost/algorithm/algorithm.hpp"
|
||||||
#include "debug/Log.hpp"
|
#include "debug/Log.hpp"
|
||||||
#include "singletons/Settings.hpp"
|
#include "singletons/Settings.hpp"
|
||||||
|
#include "singletons/Theme.hpp"
|
||||||
#include "singletons/WindowManager.hpp"
|
#include "singletons/WindowManager.hpp"
|
||||||
#include "util/PostToThread.hpp"
|
#include "util/PostToThread.hpp"
|
||||||
#include "util/WindowsHelper.hpp"
|
#include "util/WindowsHelper.hpp"
|
||||||
|
@ -110,11 +111,11 @@ void BaseWindow::init()
|
||||||
|
|
||||||
// buttons
|
// buttons
|
||||||
TitleBarButton *_minButton = new TitleBarButton;
|
TitleBarButton *_minButton = new TitleBarButton;
|
||||||
_minButton->setButtonStyle(TitleBarButton::Minimize);
|
_minButton->setButtonStyle(TitleBarButtonStyle::Minimize);
|
||||||
TitleBarButton *_maxButton = new TitleBarButton;
|
TitleBarButton *_maxButton = new TitleBarButton;
|
||||||
_maxButton->setButtonStyle(TitleBarButton::Maximize);
|
_maxButton->setButtonStyle(TitleBarButtonStyle::Maximize);
|
||||||
TitleBarButton *_exitButton = new TitleBarButton;
|
TitleBarButton *_exitButton = new TitleBarButton;
|
||||||
_exitButton->setButtonStyle(TitleBarButton::Close);
|
_exitButton->setButtonStyle(TitleBarButtonStyle::Close);
|
||||||
|
|
||||||
QObject::connect(_minButton, &TitleBarButton::clicked, this,
|
QObject::connect(_minButton, &TitleBarButton::clicked, this,
|
||||||
[this] {
|
[this] {
|
||||||
|
@ -353,8 +354,8 @@ void BaseWindow::mouseMoveEvent(QMouseEvent *event)
|
||||||
BaseWidget::mouseMoveEvent(event);
|
BaseWidget::mouseMoveEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
TitleBarButton *BaseWindow::addTitleBarButton(
|
TitleBarButton *BaseWindow::addTitleBarButton(const TitleBarButtonStyle &style,
|
||||||
const TitleBarButton::Style &style, std::function<void()> onClicked)
|
std::function<void()> onClicked)
|
||||||
{
|
{
|
||||||
TitleBarButton *button = new TitleBarButton;
|
TitleBarButton *button = new TitleBarButton;
|
||||||
button->setScaleIndependantSize(30, 30);
|
button->setScaleIndependantSize(30, 30);
|
||||||
|
@ -389,10 +390,10 @@ void BaseWindow::changeEvent(QEvent *)
|
||||||
|
|
||||||
#ifdef USEWINSDK
|
#ifdef USEWINSDK
|
||||||
if (this->ui_.maxButton) {
|
if (this->ui_.maxButton) {
|
||||||
this->ui_.maxButton->setButtonStyle(this->windowState() &
|
this->ui_.maxButton->setButtonStyle(
|
||||||
Qt::WindowMaximized
|
this->windowState() & Qt::WindowMaximized
|
||||||
? TitleBarButton::Unmaximize
|
? TitleBarButtonStyle::Unmaximize
|
||||||
: TitleBarButton::Maximize);
|
: TitleBarButtonStyle::Maximize);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "BaseWidget.hpp"
|
#include "BaseWidget.hpp"
|
||||||
#include "widgets/helper/TitlebarButton.hpp"
|
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <pajlada/signals/signalholder.hpp>
|
#include <pajlada/signals/signalholder.hpp>
|
||||||
|
@ -15,6 +14,7 @@ namespace chatterino {
|
||||||
class Button;
|
class Button;
|
||||||
class EffectLabel;
|
class EffectLabel;
|
||||||
class TitleBarButton;
|
class TitleBarButton;
|
||||||
|
enum class TitleBarButtonStyle;
|
||||||
|
|
||||||
class BaseWindow : public BaseWidget
|
class BaseWindow : public BaseWidget
|
||||||
{
|
{
|
||||||
|
@ -36,7 +36,7 @@ public:
|
||||||
|
|
||||||
QWidget *getLayoutContainer();
|
QWidget *getLayoutContainer();
|
||||||
bool hasCustomWindowFrame();
|
bool hasCustomWindowFrame();
|
||||||
TitleBarButton *addTitleBarButton(const TitleBarButton::Style &style,
|
TitleBarButton *addTitleBarButton(const TitleBarButtonStyle &style,
|
||||||
std::function<void()> onClicked);
|
std::function<void()> onClicked);
|
||||||
EffectLabel *addTitleBarLabel(std::function<void()> onClicked);
|
EffectLabel *addTitleBarLabel(std::function<void()> onClicked);
|
||||||
|
|
||||||
|
@ -114,6 +114,6 @@ private:
|
||||||
|
|
||||||
pajlada::Signals::SignalHolder connections_;
|
pajlada::Signals::SignalHolder connections_;
|
||||||
std::vector<pajlada::Signals::ScopedConnection> managedConnections_;
|
std::vector<pajlada::Signals::ScopedConnection> managedConnections_;
|
||||||
};
|
}; // namespace chatterino
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include "Application.hpp"
|
#include "Application.hpp"
|
||||||
#include "debug/Log.hpp"
|
#include "debug/Log.hpp"
|
||||||
|
#include "singletons/Settings.hpp"
|
||||||
#include "singletons/Theme.hpp"
|
#include "singletons/Theme.hpp"
|
||||||
#include "singletons/WindowManager.hpp"
|
#include "singletons/WindowManager.hpp"
|
||||||
#include "util/InitUpdateButton.hpp"
|
#include "util/InitUpdateButton.hpp"
|
||||||
|
@ -27,11 +28,11 @@ namespace chatterino {
|
||||||
|
|
||||||
Notebook::Notebook(QWidget *parent)
|
Notebook::Notebook(QWidget *parent)
|
||||||
: BaseWidget(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);
|
auto *shortcut_next = new QShortcut(QKeySequence("Ctrl+Tab"), this);
|
||||||
QObject::connect(shortcut_next, &QShortcut::activated,
|
QObject::connect(shortcut_next, &QShortcut::activated,
|
||||||
|
@ -290,14 +291,14 @@ void Notebook::setShowAddButton(bool value)
|
||||||
{
|
{
|
||||||
this->showAddButton_ = value;
|
this->showAddButton_ = value;
|
||||||
|
|
||||||
this->addButton_.setHidden(!value);
|
this->addButton_->setHidden(!value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Notebook::scaleChangedEvent(float scale)
|
void Notebook::scaleChangedEvent(float scale)
|
||||||
{
|
{
|
||||||
float h = NOTEBOOK_TAB_HEIGHT * this->getScale();
|
float h = NOTEBOOK_TAB_HEIGHT * this->getScale();
|
||||||
|
|
||||||
this->addButton_.setFixedSize(h, h);
|
this->addButton_->setFixedSize(h, h);
|
||||||
|
|
||||||
for (auto &i : this->items_) {
|
for (auto &i : this->items_) {
|
||||||
i.tab->updateSize();
|
i.tab->updateSize();
|
||||||
|
@ -353,7 +354,7 @@ void Notebook::performLayout(bool animated)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->showAddButton_) {
|
if (this->showAddButton_) {
|
||||||
this->addButton_.move(x, y);
|
this->addButton_->move(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->lineY_ != y + tabHeight) {
|
if (this->lineY_ != y + tabHeight) {
|
||||||
|
@ -368,7 +369,7 @@ void Notebook::performLayout(bool animated)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->showAddButton_) {
|
if (this->showAddButton_) {
|
||||||
this->addButton_.raise();
|
this->addButton_->raise();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->selectedPage_ != nullptr) {
|
if (this->selectedPage_ != nullptr) {
|
||||||
|
@ -389,7 +390,7 @@ void Notebook::paintEvent(QPaintEvent *event)
|
||||||
|
|
||||||
NotebookButton *Notebook::getAddButton()
|
NotebookButton *Notebook::getAddButton()
|
||||||
{
|
{
|
||||||
return &this->addButton_;
|
return this->addButton_;
|
||||||
}
|
}
|
||||||
|
|
||||||
NotebookButton *Notebook::addCustomButton()
|
NotebookButton *Notebook::addCustomButton()
|
||||||
|
@ -460,8 +461,7 @@ void SplitNotebook::addCustomButtons()
|
||||||
// updates
|
// updates
|
||||||
auto updateBtn = this->addCustomButton();
|
auto updateBtn = this->addCustomButton();
|
||||||
|
|
||||||
initUpdateButton(*updateBtn, this->updateDialogHandle_,
|
initUpdateButton(*updateBtn, this->signalHolder_);
|
||||||
this->signalHolder_);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SplitContainer *SplitNotebook::addPage(bool select)
|
SplitContainer *SplitNotebook::addPage(bool select)
|
||||||
|
|
|
@ -2,10 +2,6 @@
|
||||||
|
|
||||||
#include "pajlada/signals/signal.hpp"
|
#include "pajlada/signals/signal.hpp"
|
||||||
#include "widgets/BaseWidget.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 <QList>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
@ -15,6 +11,10 @@
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
class Window;
|
class Window;
|
||||||
|
class UpdateDialog;
|
||||||
|
class NotebookButton;
|
||||||
|
class NotebookTab;
|
||||||
|
class SplitContainer;
|
||||||
|
|
||||||
class Notebook : public BaseWidget
|
class Notebook : public BaseWidget
|
||||||
{
|
{
|
||||||
|
@ -22,6 +22,7 @@ class Notebook : public BaseWidget
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Notebook(QWidget *parent);
|
explicit Notebook(QWidget *parent);
|
||||||
|
~Notebook() override = default;
|
||||||
|
|
||||||
NotebookTab *addPage(QWidget *page, QString title = QString(),
|
NotebookTab *addPage(QWidget *page, QString title = QString(),
|
||||||
bool select = false);
|
bool select = false);
|
||||||
|
@ -74,7 +75,7 @@ private:
|
||||||
QList<Item> items_;
|
QList<Item> items_;
|
||||||
QWidget *selectedPage_ = nullptr;
|
QWidget *selectedPage_ = nullptr;
|
||||||
|
|
||||||
NotebookButton addButton_;
|
NotebookButton *addButton_;
|
||||||
std::vector<NotebookButton *> customButtons_;
|
std::vector<NotebookButton *> customButtons_;
|
||||||
|
|
||||||
bool allowUserTabManagement_ = false;
|
bool allowUserTabManagement_ = false;
|
||||||
|
@ -94,7 +95,7 @@ private:
|
||||||
void addCustomButtons();
|
void addCustomButtons();
|
||||||
|
|
||||||
pajlada::Signals::SignalHolder signalHolder_;
|
pajlada::Signals::SignalHolder signalHolder_;
|
||||||
std::unique_ptr<UpdateDialog> updateDialogHandle_;
|
std::shared_ptr<UpdateDialog> updateDialogHandle_;
|
||||||
|
|
||||||
std::vector<pajlada::Signals::ScopedConnection> connections_;
|
std::vector<pajlada::Signals::ScopedConnection> connections_;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "widgets/Scrollbar.hpp"
|
#include "widgets/Scrollbar.hpp"
|
||||||
|
|
||||||
#include "Application.hpp"
|
#include "Application.hpp"
|
||||||
|
#include "singletons/Settings.hpp"
|
||||||
#include "singletons/Theme.hpp"
|
#include "singletons/Theme.hpp"
|
||||||
#include "widgets/helper/ChannelView.hpp"
|
#include "widgets/helper/ChannelView.hpp"
|
||||||
|
|
||||||
|
@ -103,8 +104,7 @@ void Scrollbar::setSmallChange(qreal value)
|
||||||
|
|
||||||
void Scrollbar::setDesiredValue(qreal value, bool animated)
|
void Scrollbar::setDesiredValue(qreal value, bool animated)
|
||||||
{
|
{
|
||||||
auto app = getApp();
|
animated &= getSettings()->enableSmoothScrolling.getValue();
|
||||||
animated &= app->settings->enableSmoothScrolling.getValue();
|
|
||||||
value = std::max(this->minimum_,
|
value = std::max(this->minimum_,
|
||||||
std::min(this->maximum_ - this->largeChange_, value));
|
std::min(this->maximum_ - this->largeChange_, value));
|
||||||
|
|
||||||
|
@ -221,8 +221,6 @@ void Scrollbar::printCurrentState(const QString &prefix) const
|
||||||
|
|
||||||
void Scrollbar::paintEvent(QPaintEvent *)
|
void Scrollbar::paintEvent(QPaintEvent *)
|
||||||
{
|
{
|
||||||
auto *app = getApp();
|
|
||||||
|
|
||||||
bool mouseOver = this->mouseOverIndex_ != -1;
|
bool mouseOver = this->mouseOverIndex_ != -1;
|
||||||
int xOffset = mouseOver ? 0 : width() - int(4 * this->getScale());
|
int xOffset = mouseOver ? 0 : width() - int(4 * this->getScale());
|
||||||
|
|
||||||
|
@ -267,9 +265,11 @@ void Scrollbar::paintEvent(QPaintEvent *)
|
||||||
QColor color = [&] {
|
QColor color = [&] {
|
||||||
switch (highlight.getColor()) {
|
switch (highlight.getColor()) {
|
||||||
case ScrollbarHighlight::Highlight:
|
case ScrollbarHighlight::Highlight:
|
||||||
return app->themes->scrollbars.highlights.highlight;
|
return getApp()
|
||||||
|
->themes->scrollbars.highlights.highlight;
|
||||||
case ScrollbarHighlight::Subscription:
|
case ScrollbarHighlight::Subscription:
|
||||||
return app->themes->scrollbars.highlights.subscription;
|
return getApp()
|
||||||
|
->themes->scrollbars.highlights.subscription;
|
||||||
}
|
}
|
||||||
return QColor();
|
return QColor();
|
||||||
}();
|
}();
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "messages/LimitedQueue.hpp"
|
#include "messages/LimitedQueue.hpp"
|
||||||
#include "singletons/Settings.hpp"
|
|
||||||
#include "widgets/BaseWidget.hpp"
|
#include "widgets/BaseWidget.hpp"
|
||||||
#include "widgets/helper/ScrollbarHighlight.hpp"
|
#include "widgets/helper/ScrollbarHighlight.hpp"
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "common/Channel.hpp"
|
#include "common/Channel.hpp"
|
||||||
#include "util/Helpers.hpp"
|
#include "util/Helpers.hpp"
|
||||||
#include "util/LayoutCreator.hpp"
|
#include "util/LayoutCreator.hpp"
|
||||||
|
#include "widgets/helper/ChannelView.hpp"
|
||||||
#include "widgets/splits/Split.hpp"
|
#include "widgets/splits/Split.hpp"
|
||||||
|
|
||||||
#ifdef USEWEBENGINE
|
#ifdef USEWEBENGINE
|
||||||
|
|
|
@ -79,7 +79,7 @@ void TooltipWidget::updateFont()
|
||||||
auto app = getApp();
|
auto app = getApp();
|
||||||
|
|
||||||
this->setFont(
|
this->setFont(
|
||||||
app->fonts->getFont(Fonts::Type::ChatMediumSmall, this->getScale()));
|
app->fonts->getFont(FontStyle::ChatMediumSmall, this->getScale()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TooltipWidget::setText(QString text)
|
void TooltipWidget::setText(QString text)
|
||||||
|
|
|
@ -14,8 +14,11 @@
|
||||||
#include "widgets/dialogs/SettingsDialog.hpp"
|
#include "widgets/dialogs/SettingsDialog.hpp"
|
||||||
#include "widgets/dialogs/UpdateDialog.hpp"
|
#include "widgets/dialogs/UpdateDialog.hpp"
|
||||||
#include "widgets/dialogs/WelcomeDialog.hpp"
|
#include "widgets/dialogs/WelcomeDialog.hpp"
|
||||||
|
#include "widgets/helper/EffectLabel.hpp"
|
||||||
#include "widgets/helper/Shortcut.hpp"
|
#include "widgets/helper/Shortcut.hpp"
|
||||||
|
#include "widgets/helper/TitlebarButton.hpp"
|
||||||
#include "widgets/splits/Split.hpp"
|
#include "widgets/splits/Split.hpp"
|
||||||
|
#include "widgets/splits/SplitContainer.hpp"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
|
@ -28,10 +31,10 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
Window::Window(Type type)
|
Window::Window(WindowType type)
|
||||||
: BaseWindow(nullptr, BaseWindow::EnableCustomFrame)
|
: BaseWindow(nullptr, BaseWindow::EnableCustomFrame)
|
||||||
, type_(type)
|
, type_(type)
|
||||||
, notebook_(this)
|
, notebook_(new SplitNotebook(this))
|
||||||
{
|
{
|
||||||
this->addCustomTitlebarButtons();
|
this->addCustomTitlebarButtons();
|
||||||
this->addDebugStuff();
|
this->addDebugStuff();
|
||||||
|
@ -42,26 +45,26 @@ Window::Window(Type type)
|
||||||
[this] { this->onAccountSelected(); });
|
[this] { this->onAccountSelected(); });
|
||||||
this->onAccountSelected();
|
this->onAccountSelected();
|
||||||
|
|
||||||
if (type == Type::Main) {
|
if (type == WindowType::Main) {
|
||||||
this->resize(int(600 * this->getScale()), int(500 * this->getScale()));
|
this->resize(int(600 * this->getScale()), int(500 * this->getScale()));
|
||||||
} else {
|
} else {
|
||||||
this->resize(int(300 * this->getScale()), int(500 * this->getScale()));
|
this->resize(int(300 * this->getScale()), int(500 * this->getScale()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Window::Type Window::getType()
|
WindowType Window::getType()
|
||||||
{
|
{
|
||||||
return this->type_;
|
return this->type_;
|
||||||
}
|
}
|
||||||
|
|
||||||
SplitNotebook &Window::getNotebook()
|
SplitNotebook &Window::getNotebook()
|
||||||
{
|
{
|
||||||
return this->notebook_;
|
return *this->notebook_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::repaintVisibleChatWidgets(Channel *channel)
|
void Window::repaintVisibleChatWidgets(Channel *channel)
|
||||||
{
|
{
|
||||||
auto page = this->notebook_.getOrAddSelectedPage();
|
auto page = this->notebook_->getOrAddSelectedPage();
|
||||||
|
|
||||||
for (const auto &split : page->getSplits()) {
|
for (const auto &split : page->getSplits()) {
|
||||||
if (channel == nullptr || channel == split->getChannel().get()) {
|
if (channel == nullptr || channel == split->getChannel().get()) {
|
||||||
|
@ -77,7 +80,7 @@ bool Window::event(QEvent *event)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QEvent::WindowDeactivate: {
|
case QEvent::WindowDeactivate: {
|
||||||
auto page = this->notebook_.getOrAddSelectedPage();
|
auto page = this->notebook_->getOrAddSelectedPage();
|
||||||
|
|
||||||
if (page != nullptr) {
|
if (page != nullptr) {
|
||||||
std::vector<Split *> splits = page->getSplits();
|
std::vector<Split *> splits = page->getSplits();
|
||||||
|
@ -135,7 +138,7 @@ void Window::showEvent(QShowEvent *event)
|
||||||
|
|
||||||
void Window::closeEvent(QCloseEvent *)
|
void Window::closeEvent(QCloseEvent *)
|
||||||
{
|
{
|
||||||
if (this->type_ == Type::Main) {
|
if (this->type_ == WindowType::Main) {
|
||||||
auto app = getApp();
|
auto app = getApp();
|
||||||
app->windows->save();
|
app->windows->save();
|
||||||
app->windows->closeAll();
|
app->windows->closeAll();
|
||||||
|
@ -143,7 +146,7 @@ void Window::closeEvent(QCloseEvent *)
|
||||||
|
|
||||||
this->closed.invoke();
|
this->closed.invoke();
|
||||||
|
|
||||||
if (this->type_ == Type::Main) {
|
if (this->type_ == WindowType::Main) {
|
||||||
QApplication::exit();
|
QApplication::exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -152,35 +155,34 @@ void Window::addLayout()
|
||||||
{
|
{
|
||||||
QVBoxLayout *layout = new QVBoxLayout(this);
|
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||||
|
|
||||||
layout->addWidget(&this->notebook_);
|
layout->addWidget(this->notebook_);
|
||||||
this->getLayoutContainer()->setLayout(layout);
|
this->getLayoutContainer()->setLayout(layout);
|
||||||
|
|
||||||
// set margin
|
// set margin
|
||||||
layout->setMargin(0);
|
layout->setMargin(0);
|
||||||
|
|
||||||
this->notebook_.setAllowUserTabManagement(true);
|
this->notebook_->setAllowUserTabManagement(true);
|
||||||
this->notebook_.setShowAddButton(true);
|
this->notebook_->setShowAddButton(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::addCustomTitlebarButtons()
|
void Window::addCustomTitlebarButtons()
|
||||||
{
|
{
|
||||||
if (!this->hasCustomWindowFrame()) return;
|
if (!this->hasCustomWindowFrame()) return;
|
||||||
if (this->type_ != Type::Main) return;
|
if (this->type_ != WindowType::Main) return;
|
||||||
|
|
||||||
// settings
|
// settings
|
||||||
this->addTitleBarButton(TitleBarButton::Settings, [] {
|
this->addTitleBarButton(TitleBarButtonStyle::Settings,
|
||||||
getApp()->windows->showSettingsDialog(); //
|
[] { getApp()->windows->showSettingsDialog(); });
|
||||||
});
|
|
||||||
|
|
||||||
// updates
|
// updates
|
||||||
auto update = this->addTitleBarButton(TitleBarButton::None, [] {});
|
auto update = this->addTitleBarButton(TitleBarButtonStyle::None, [] {});
|
||||||
|
|
||||||
initUpdateButton(*update, this->updateDialogHandle_, this->signalHolder_);
|
initUpdateButton(*update, this->signalHolder_);
|
||||||
|
|
||||||
// account
|
// account
|
||||||
this->userLabel_ = this->addTitleBarLabel([this] {
|
this->userLabel_ = this->addTitleBarLabel([this] {
|
||||||
getApp()->windows->showAccountSelectPopup(this->userLabel_->mapToGlobal(
|
getApp()->windows->showAccountSelectPopup(this->userLabel_->mapToGlobal(
|
||||||
this->userLabel_->rect().bottomLeft())); //
|
this->userLabel_->rect().bottomLeft()));
|
||||||
});
|
});
|
||||||
this->userLabel_->setMinimumWidth(20 * getScale());
|
this->userLabel_->setMinimumWidth(20 * getScale());
|
||||||
}
|
}
|
||||||
|
@ -252,27 +254,27 @@ void Window::addShortcuts()
|
||||||
|
|
||||||
// Switch tab
|
// Switch tab
|
||||||
createWindowShortcut(this, "CTRL+T", [this] {
|
createWindowShortcut(this, "CTRL+T", [this] {
|
||||||
this->notebook_.getOrAddSelectedPage()->appendNewSplit(true);
|
this->notebook_->getOrAddSelectedPage()->appendNewSplit(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
createWindowShortcut(this, "CTRL+1",
|
createWindowShortcut(this, "CTRL+1",
|
||||||
[this] { this->notebook_.selectIndex(0); });
|
[this] { this->notebook_->selectIndex(0); });
|
||||||
createWindowShortcut(this, "CTRL+2",
|
createWindowShortcut(this, "CTRL+2",
|
||||||
[this] { this->notebook_.selectIndex(1); });
|
[this] { this->notebook_->selectIndex(1); });
|
||||||
createWindowShortcut(this, "CTRL+3",
|
createWindowShortcut(this, "CTRL+3",
|
||||||
[this] { this->notebook_.selectIndex(2); });
|
[this] { this->notebook_->selectIndex(2); });
|
||||||
createWindowShortcut(this, "CTRL+4",
|
createWindowShortcut(this, "CTRL+4",
|
||||||
[this] { this->notebook_.selectIndex(3); });
|
[this] { this->notebook_->selectIndex(3); });
|
||||||
createWindowShortcut(this, "CTRL+5",
|
createWindowShortcut(this, "CTRL+5",
|
||||||
[this] { this->notebook_.selectIndex(4); });
|
[this] { this->notebook_->selectIndex(4); });
|
||||||
createWindowShortcut(this, "CTRL+6",
|
createWindowShortcut(this, "CTRL+6",
|
||||||
[this] { this->notebook_.selectIndex(5); });
|
[this] { this->notebook_->selectIndex(5); });
|
||||||
createWindowShortcut(this, "CTRL+7",
|
createWindowShortcut(this, "CTRL+7",
|
||||||
[this] { this->notebook_.selectIndex(6); });
|
[this] { this->notebook_->selectIndex(6); });
|
||||||
createWindowShortcut(this, "CTRL+8",
|
createWindowShortcut(this, "CTRL+8",
|
||||||
[this] { this->notebook_.selectIndex(7); });
|
[this] { this->notebook_->selectIndex(7); });
|
||||||
createWindowShortcut(this, "CTRL+9",
|
createWindowShortcut(this, "CTRL+9",
|
||||||
[this] { this->notebook_.selectIndex(8); });
|
[this] { this->notebook_->selectIndex(8); });
|
||||||
|
|
||||||
// Zoom in
|
// Zoom in
|
||||||
{
|
{
|
||||||
|
@ -296,11 +298,11 @@ void Window::addShortcuts()
|
||||||
|
|
||||||
// New tab
|
// New tab
|
||||||
createWindowShortcut(this, "CTRL+SHIFT+T",
|
createWindowShortcut(this, "CTRL+SHIFT+T",
|
||||||
[this] { this->notebook_.addPage(true); });
|
[this] { this->notebook_->addPage(true); });
|
||||||
|
|
||||||
// Close tab
|
// Close tab
|
||||||
createWindowShortcut(this, "CTRL+SHIFT+W",
|
createWindowShortcut(this, "CTRL+SHIFT+W",
|
||||||
[this] { this->notebook_.removeCurrentPage(); });
|
[this] { this->notebook_->removeCurrentPage(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::onAccountSelected()
|
void Window::onAccountSelected()
|
||||||
|
|
|
@ -1,13 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "util/Helpers.hpp"
|
|
||||||
#include "widgets/BaseWindow.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/settings/setting.hpp>
|
||||||
#include <pajlada/signals/signal.hpp>
|
#include <pajlada/signals/signal.hpp>
|
||||||
|
@ -16,17 +9,20 @@
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
class Theme;
|
class Theme;
|
||||||
|
class UpdateDialog;
|
||||||
|
class SplitNotebook;
|
||||||
|
class Channel;
|
||||||
|
|
||||||
|
enum class WindowType { Main, Popup, Attached };
|
||||||
|
|
||||||
class Window : public BaseWindow
|
class Window : public BaseWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum class Type { Main, Popup, Attached };
|
explicit Window(WindowType type);
|
||||||
|
|
||||||
explicit Window(Window::Type type);
|
WindowType getType();
|
||||||
|
|
||||||
Type getType();
|
|
||||||
SplitNotebook &getNotebook();
|
SplitNotebook &getNotebook();
|
||||||
|
|
||||||
void repaintVisibleChatWidgets(Channel *channel = nullptr);
|
void repaintVisibleChatWidgets(Channel *channel = nullptr);
|
||||||
|
@ -45,11 +41,11 @@ private:
|
||||||
void addLayout();
|
void addLayout();
|
||||||
void onAccountSelected();
|
void onAccountSelected();
|
||||||
|
|
||||||
Type type_;
|
WindowType type_;
|
||||||
|
|
||||||
SplitNotebook notebook_;
|
SplitNotebook *notebook_;
|
||||||
EffectLabel *userLabel_ = nullptr;
|
EffectLabel *userLabel_ = nullptr;
|
||||||
std::unique_ptr<UpdateDialog> updateDialogHandle_;
|
std::shared_ptr<UpdateDialog> updateDialogHandle_;
|
||||||
|
|
||||||
pajlada::Signals::SignalHolder signalHolder_;
|
pajlada::Signals::SignalHolder signalHolder_;
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,12 @@
|
||||||
#include "Application.hpp"
|
#include "Application.hpp"
|
||||||
#include "controllers/accounts/AccountController.hpp"
|
#include "controllers/accounts/AccountController.hpp"
|
||||||
#include "debug/Benchmark.hpp"
|
#include "debug/Benchmark.hpp"
|
||||||
|
#include "messages/Message.hpp"
|
||||||
#include "messages/MessageBuilder.hpp"
|
#include "messages/MessageBuilder.hpp"
|
||||||
#include "providers/twitch/TwitchChannel.hpp"
|
#include "providers/twitch/TwitchChannel.hpp"
|
||||||
|
#include "singletons/Emotes.hpp"
|
||||||
#include "widgets/Notebook.hpp"
|
#include "widgets/Notebook.hpp"
|
||||||
|
#include "widgets/helper/ChannelView.hpp"
|
||||||
|
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QShortcut>
|
#include <QShortcut>
|
||||||
|
|
|
@ -1,13 +1,16 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/Channel.hpp"
|
|
||||||
#include "widgets/BaseWindow.hpp"
|
#include "widgets/BaseWindow.hpp"
|
||||||
#include "widgets/helper/ChannelView.hpp"
|
|
||||||
|
|
||||||
#include <pajlada/signals/signal.hpp>
|
#include <pajlada/signals/signal.hpp>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
|
class Link;
|
||||||
|
class ChannelView;
|
||||||
|
class Channel;
|
||||||
|
using ChannelPtr = std::shared_ptr<Channel>;
|
||||||
|
|
||||||
class EmotePopup : public BaseWindow
|
class EmotePopup : public BaseWindow
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "widgets/dialogs/LoginDialog.hpp"
|
#include "widgets/dialogs/LoginDialog.hpp"
|
||||||
|
|
||||||
|
#include "Application.hpp"
|
||||||
#include "common/Common.hpp"
|
#include "common/Common.hpp"
|
||||||
#include "common/NetworkRequest.hpp"
|
#include "common/NetworkRequest.hpp"
|
||||||
#include "controllers/accounts/AccountController.hpp"
|
#include "controllers/accounts/AccountController.hpp"
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "LogsPopup.hpp"
|
#include "LogsPopup.hpp"
|
||||||
|
|
||||||
#include "IrcMessage"
|
#include "IrcMessage"
|
||||||
|
#include "common/Channel.hpp"
|
||||||
#include "common/NetworkRequest.hpp"
|
#include "common/NetworkRequest.hpp"
|
||||||
#include "providers/twitch/TwitchChannel.hpp"
|
#include "providers/twitch/TwitchChannel.hpp"
|
||||||
#include "providers/twitch/TwitchMessageBuilder.hpp"
|
#include "providers/twitch/TwitchMessageBuilder.hpp"
|
||||||
|
@ -14,6 +15,7 @@
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
LogsPopup::LogsPopup()
|
LogsPopup::LogsPopup()
|
||||||
|
: channel_(Channel::getEmpty())
|
||||||
{
|
{
|
||||||
this->initLayout();
|
this->initLayout();
|
||||||
this->resize(400, 600);
|
this->resize(400, 600);
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/Channel.hpp"
|
|
||||||
#include "widgets/BaseWindow.hpp"
|
#include "widgets/BaseWindow.hpp"
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
@ -8,6 +7,12 @@ namespace chatterino {
|
||||||
class Channel;
|
class Channel;
|
||||||
class ChannelView;
|
class ChannelView;
|
||||||
|
|
||||||
|
class Channel;
|
||||||
|
using ChannelPtr = std::shared_ptr<Channel>;
|
||||||
|
|
||||||
|
struct Message;
|
||||||
|
using MessagePtr = std::shared_ptr<const Message>;
|
||||||
|
|
||||||
class LogsPopup : public BaseWindow
|
class LogsPopup : public BaseWindow
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -17,7 +22,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ChannelView *channelView_ = nullptr;
|
ChannelView *channelView_ = nullptr;
|
||||||
ChannelPtr channel_ = Channel::getEmpty();
|
ChannelPtr channel_;
|
||||||
|
|
||||||
QString userName_;
|
QString userName_;
|
||||||
int roomID_;
|
int roomID_;
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include "NotificationPopup.hpp"
|
#include "NotificationPopup.hpp"
|
||||||
|
|
||||||
|
#include "common/Channel.hpp"
|
||||||
|
#include "messages/Message.hpp"
|
||||||
#include "widgets/helper/ChannelView.hpp"
|
#include "widgets/helper/ChannelView.hpp"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
|
@ -1,13 +1,17 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/Channel.hpp"
|
|
||||||
#include "messages/Message.hpp"
|
|
||||||
#include "widgets/BaseWindow.hpp"
|
#include "widgets/BaseWindow.hpp"
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
class ChannelView;
|
class ChannelView;
|
||||||
|
|
||||||
|
class Channel;
|
||||||
|
using ChannelPtr = std::shared_ptr<Channel>;
|
||||||
|
|
||||||
|
struct Message;
|
||||||
|
using MessagePtr = std::shared_ptr<const Message>;
|
||||||
|
|
||||||
class NotificationPopup : public BaseWindow
|
class NotificationPopup : public BaseWindow
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -2,8 +2,10 @@
|
||||||
|
|
||||||
#include "Application.hpp"
|
#include "Application.hpp"
|
||||||
#include "providers/twitch/TwitchServer.hpp"
|
#include "providers/twitch/TwitchServer.hpp"
|
||||||
|
#include "singletons/Theme.hpp"
|
||||||
#include "util/LayoutCreator.hpp"
|
#include "util/LayoutCreator.hpp"
|
||||||
#include "widgets/Notebook.hpp"
|
#include "widgets/Notebook.hpp"
|
||||||
|
#include "widgets/helper/NotebookTab.hpp"
|
||||||
|
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "Application.hpp"
|
||||||
#include "common/Channel.hpp"
|
#include "common/Channel.hpp"
|
||||||
#include "widgets/BaseWindow.hpp"
|
#include "widgets/BaseWindow.hpp"
|
||||||
#include "widgets/Notebook.hpp"
|
|
||||||
|
|
||||||
#include <pajlada/signals/signal.hpp>
|
#include <pajlada/signals/signal.hpp>
|
||||||
|
|
||||||
|
@ -11,7 +11,9 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
class SelectChannelDialog : public BaseWindow
|
class Notebook;
|
||||||
|
|
||||||
|
class SelectChannelDialog final : public BaseWindow
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SelectChannelDialog(QWidget *parent = nullptr);
|
SelectChannelDialog(QWidget *parent = nullptr);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "UserInfoPopup.hpp"
|
#include "UserInfoPopup.hpp"
|
||||||
|
|
||||||
#include "Application.hpp"
|
#include "Application.hpp"
|
||||||
|
#include "common/Channel.hpp"
|
||||||
#include "common/NetworkRequest.hpp"
|
#include "common/NetworkRequest.hpp"
|
||||||
#include "controllers/accounts/AccountController.hpp"
|
#include "controllers/accounts/AccountController.hpp"
|
||||||
#include "controllers/highlights/HighlightController.hpp"
|
#include "controllers/highlights/HighlightController.hpp"
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/Channel.hpp"
|
|
||||||
#include "widgets/BaseWindow.hpp"
|
#include "widgets/BaseWindow.hpp"
|
||||||
|
|
||||||
#include <pajlada/signals/signal.hpp>
|
#include <pajlada/signals/signal.hpp>
|
||||||
|
@ -9,6 +8,8 @@ class QCheckBox;
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
|
class Channel;
|
||||||
|
using ChannelPtr = std::shared_ptr<Channel>;
|
||||||
class Label;
|
class Label;
|
||||||
|
|
||||||
class UserInfoPopup final : public BaseWindow
|
class UserInfoPopup final : public BaseWindow
|
||||||
|
|
|
@ -1,18 +1,24 @@
|
||||||
#include "ChannelView.hpp"
|
#include "ChannelView.hpp"
|
||||||
|
|
||||||
#include "Application.hpp"
|
#include "Application.hpp"
|
||||||
|
#include "common/Common.hpp"
|
||||||
#include "debug/Benchmark.hpp"
|
#include "debug/Benchmark.hpp"
|
||||||
#include "debug/Log.hpp"
|
#include "debug/Log.hpp"
|
||||||
|
#include "messages/Emote.hpp"
|
||||||
#include "messages/LimitedQueueSnapshot.hpp"
|
#include "messages/LimitedQueueSnapshot.hpp"
|
||||||
#include "messages/Message.hpp"
|
#include "messages/Message.hpp"
|
||||||
|
#include "messages/MessageElement.hpp"
|
||||||
#include "messages/layouts/MessageLayout.hpp"
|
#include "messages/layouts/MessageLayout.hpp"
|
||||||
|
#include "messages/layouts/MessageLayoutElement.hpp"
|
||||||
#include "providers/twitch/TwitchServer.hpp"
|
#include "providers/twitch/TwitchServer.hpp"
|
||||||
#include "singletons/Settings.hpp"
|
#include "singletons/Settings.hpp"
|
||||||
#include "singletons/Theme.hpp"
|
#include "singletons/Theme.hpp"
|
||||||
#include "singletons/WindowManager.hpp"
|
#include "singletons/WindowManager.hpp"
|
||||||
#include "util/DistanceBetweenPoints.hpp"
|
#include "util/DistanceBetweenPoints.hpp"
|
||||||
|
#include "widgets/Scrollbar.hpp"
|
||||||
#include "widgets/TooltipWidget.hpp"
|
#include "widgets/TooltipWidget.hpp"
|
||||||
#include "widgets/dialogs/UserInfoPopup.hpp"
|
#include "widgets/dialogs/UserInfoPopup.hpp"
|
||||||
|
#include "widgets/helper/EffectLabel.hpp"
|
||||||
#include "widgets/splits/Split.hpp"
|
#include "widgets/splits/Split.hpp"
|
||||||
|
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
|
@ -93,7 +99,7 @@ void addEmoteContextMenuItems(const Emote &emote,
|
||||||
|
|
||||||
ChannelView::ChannelView(BaseWidget *parent)
|
ChannelView::ChannelView(BaseWidget *parent)
|
||||||
: BaseWidget(parent)
|
: BaseWidget(parent)
|
||||||
, scrollBar_(this)
|
, scrollBar_(new Scrollbar(this))
|
||||||
{
|
{
|
||||||
this->setMouseTracking(true);
|
this->setMouseTracking(true);
|
||||||
|
|
||||||
|
@ -124,7 +130,7 @@ void ChannelView::initializeLayout()
|
||||||
|
|
||||||
QObject::connect(this->goToBottom_, &EffectLabel::clicked, this, [=] {
|
QObject::connect(this->goToBottom_, &EffectLabel::clicked, this, [=] {
|
||||||
QTimer::singleShot(180, [=] {
|
QTimer::singleShot(180, [=] {
|
||||||
this->scrollBar_.scrollToBottom(
|
this->scrollBar_->scrollToBottom(
|
||||||
getApp()
|
getApp()
|
||||||
->settings->enableSmoothScrollingNewMessages.getValue());
|
->settings->enableSmoothScrollingNewMessages.getValue());
|
||||||
});
|
});
|
||||||
|
@ -133,18 +139,18 @@ void ChannelView::initializeLayout()
|
||||||
|
|
||||||
void ChannelView::initializeScrollbar()
|
void ChannelView::initializeScrollbar()
|
||||||
{
|
{
|
||||||
this->scrollBar_.getCurrentValueChanged().connect([this] {
|
this->scrollBar_->getCurrentValueChanged().connect([this] {
|
||||||
this->actuallyLayoutMessages(true);
|
this->actuallyLayoutMessages(true);
|
||||||
|
|
||||||
this->goToBottom_->setVisible(this->enableScrollingToBottom_ &&
|
this->goToBottom_->setVisible(this->enableScrollingToBottom_ &&
|
||||||
this->scrollBar_.isVisible() &&
|
this->scrollBar_->isVisible() &&
|
||||||
!this->scrollBar_.isAtBottom());
|
!this->scrollBar_->isAtBottom());
|
||||||
|
|
||||||
this->queueUpdate();
|
this->queueUpdate();
|
||||||
});
|
});
|
||||||
|
|
||||||
this->scrollBar_.getDesiredValueChanged().connect([this] {
|
this->scrollBar_->getDesiredValueChanged().connect([this] {
|
||||||
this->pausedByScrollingUp_ = !this->scrollBar_.isAtBottom();
|
this->pausedByScrollingUp_ = !this->scrollBar_->isAtBottom();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,7 +218,7 @@ void ChannelView::actuallyLayoutMessages(bool causedByScrollbar)
|
||||||
auto messagesSnapshot = this->getMessagesSnapshot();
|
auto messagesSnapshot = this->getMessagesSnapshot();
|
||||||
|
|
||||||
if (messagesSnapshot.getLength() == 0) {
|
if (messagesSnapshot.getLength() == 0) {
|
||||||
this->scrollBar_.setVisible(false);
|
this->scrollBar_->setVisible(false);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -225,9 +231,9 @@ void ChannelView::actuallyLayoutMessages(bool causedByScrollbar)
|
||||||
// The scrollbar was not visible
|
// The scrollbar was not visible
|
||||||
// The scrollbar was visible and at the bottom
|
// The scrollbar was visible and at the bottom
|
||||||
this->showingLatestMessages_ =
|
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();
|
int layoutWidth = this->getLayoutWidth();
|
||||||
|
|
||||||
MessageElementFlags flags = this->getFlags();
|
MessageElementFlags flags = this->getFlags();
|
||||||
|
@ -235,7 +241,7 @@ void ChannelView::actuallyLayoutMessages(bool causedByScrollbar)
|
||||||
// layout the visible messages in the view
|
// layout the visible messages in the view
|
||||||
if (messagesSnapshot.getLength() > start) {
|
if (messagesSnapshot.getLength() > start) {
|
||||||
int y = int(-(messagesSnapshot[start]->getHeight() *
|
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) {
|
for (size_t i = start; i < messagesSnapshot.getLength(); ++i) {
|
||||||
auto message = messagesSnapshot[i];
|
auto message = messagesSnapshot[i];
|
||||||
|
@ -262,7 +268,8 @@ void ChannelView::actuallyLayoutMessages(bool causedByScrollbar)
|
||||||
h -= message->getHeight();
|
h -= message->getHeight();
|
||||||
|
|
||||||
if (h < 0) {
|
if (h < 0) {
|
||||||
this->scrollBar_.setLargeChange((messagesSnapshot.getLength() - i) +
|
this->scrollBar_->setLargeChange(
|
||||||
|
(messagesSnapshot.getLength() - i) +
|
||||||
qreal(h) / message->getHeight());
|
qreal(h) / message->getHeight());
|
||||||
// this->scrollBar.setDesiredValue(this->scrollBar.getDesiredValue());
|
// this->scrollBar.setDesiredValue(this->scrollBar.getDesiredValue());
|
||||||
|
|
||||||
|
@ -271,20 +278,20 @@ void ChannelView::actuallyLayoutMessages(bool causedByScrollbar)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this->scrollBar_.setVisible(showScrollbar);
|
this->scrollBar_->setVisible(showScrollbar);
|
||||||
|
|
||||||
if (!showScrollbar && !causedByScrollbar) {
|
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
|
// If we were showing the latest messages and the scrollbar now wants to be
|
||||||
// rendered, scroll to bottom
|
// rendered, scroll to bottom
|
||||||
if (this->enableScrollingToBottom_ && this->showingLatestMessages_ &&
|
if (this->enableScrollingToBottom_ && this->showingLatestMessages_ &&
|
||||||
showScrollbar) {
|
showScrollbar) {
|
||||||
if (!this->isPaused()) {
|
if (!this->isPaused()) {
|
||||||
this->scrollBar_.scrollToBottom(
|
this->scrollBar_->scrollToBottom(
|
||||||
// this->messageWasAdded &&
|
// this->messageWasAdded &&
|
||||||
app->settings->enableSmoothScrollingNewMessages.getValue());
|
app->settings->enableSmoothScrollingNewMessages.getValue());
|
||||||
}
|
}
|
||||||
|
@ -309,7 +316,7 @@ void ChannelView::clearMessages()
|
||||||
|
|
||||||
Scrollbar &ChannelView::getScrollBar()
|
Scrollbar &ChannelView::getScrollBar()
|
||||||
{
|
{
|
||||||
return this->scrollBar_;
|
return *this->scrollBar_;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ChannelView::getSelectedText()
|
QString ChannelView::getSelectedText()
|
||||||
|
@ -378,7 +385,7 @@ const boost::optional<MessageElementFlags> &ChannelView::getOverrideFlags()
|
||||||
|
|
||||||
LimitedQueueSnapshot<MessageLayoutPtr> ChannelView::getMessagesSnapshot()
|
LimitedQueueSnapshot<MessageLayoutPtr> ChannelView::getMessagesSnapshot()
|
||||||
{
|
{
|
||||||
if (!this->isPaused() /*|| this->scrollBar_.isVisible()*/) {
|
if (!this->isPaused() /*|| this->scrollBar_->isVisible()*/) {
|
||||||
this->snapshot_ = this->messages.getSnapshot();
|
this->snapshot_ = this->messages.getSnapshot();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -413,10 +420,10 @@ void ChannelView::setChannel(ChannelPtr newChannel)
|
||||||
if (this->messages.pushBack(MessageLayoutPtr(messageRef),
|
if (this->messages.pushBack(MessageLayoutPtr(messageRef),
|
||||||
deleted)) {
|
deleted)) {
|
||||||
// if (!this->isPaused()) {
|
// if (!this->isPaused()) {
|
||||||
if (this->scrollBar_.isAtBottom()) {
|
if (this->scrollBar_->isAtBottom()) {
|
||||||
this->scrollBar_.scrollToBottom();
|
this->scrollBar_->scrollToBottom();
|
||||||
} else {
|
} 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->messageWasAdded_ = true;
|
||||||
this->layoutMessages();
|
this->layoutMessages();
|
||||||
|
@ -449,10 +456,10 @@ void ChannelView::setChannel(ChannelPtr newChannel)
|
||||||
|
|
||||||
if (!this->isPaused()) {
|
if (!this->isPaused()) {
|
||||||
if (this->messages.pushFront(messageRefs).size() > 0) {
|
if (this->messages.pushFront(messageRefs).size() > 0) {
|
||||||
if (this->scrollBar_.isAtBottom()) {
|
if (this->scrollBar_->isAtBottom()) {
|
||||||
this->scrollBar_.scrollToBottom();
|
this->scrollBar_->scrollToBottom();
|
||||||
} else {
|
} 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());
|
messages.at(i)->getScrollBarHighlight());
|
||||||
}
|
}
|
||||||
|
|
||||||
this->scrollBar_.addHighlightsAtStart(highlights);
|
this->scrollBar_->addHighlightsAtStart(highlights);
|
||||||
|
|
||||||
this->messageWasAdded_ = true;
|
this->messageWasAdded_ = true;
|
||||||
this->layoutMessages();
|
this->layoutMessages();
|
||||||
|
@ -503,7 +510,7 @@ void ChannelView::setChannel(ChannelPtr newChannel)
|
||||||
newItem->flags.set(MessageLayoutFlag::AlternateBackground);
|
newItem->flags.set(MessageLayoutFlag::AlternateBackground);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->scrollBar_.replaceHighlight(
|
this->scrollBar_->replaceHighlight(
|
||||||
index, replacement->getScrollBarHighlight());
|
index, replacement->getScrollBarHighlight());
|
||||||
|
|
||||||
this->messages.replaceItem(message, newItem);
|
this->messages.replaceItem(message, newItem);
|
||||||
|
@ -563,12 +570,12 @@ void ChannelView::updateLastReadMessage()
|
||||||
|
|
||||||
void ChannelView::resizeEvent(QResizeEvent *)
|
void ChannelView::resizeEvent(QResizeEvent *)
|
||||||
{
|
{
|
||||||
this->scrollBar_.setGeometry(this->width() - this->scrollBar_.width(), 0,
|
this->scrollBar_->setGeometry(this->width() - this->scrollBar_->width(), 0,
|
||||||
this->scrollBar_.width(), this->height());
|
this->scrollBar_->width(), this->height());
|
||||||
|
|
||||||
this->goToBottom_->setGeometry(0, this->height() - 32, this->width(), 32);
|
this->goToBottom_->setGeometry(0, this->height() - 32, this->width(), 32);
|
||||||
|
|
||||||
this->scrollBar_.raise();
|
this->scrollBar_->raise();
|
||||||
|
|
||||||
this->layoutMessages();
|
this->layoutMessages();
|
||||||
|
|
||||||
|
@ -625,9 +632,9 @@ bool ChannelView::isPaused()
|
||||||
void ChannelView::updatePauseStatus()
|
void ChannelView::updatePauseStatus()
|
||||||
{
|
{
|
||||||
if (this->isPaused()) {
|
if (this->isPaused()) {
|
||||||
this->scrollBar_.pauseHighlights();
|
this->scrollBar_->pauseHighlights();
|
||||||
} else {
|
} else {
|
||||||
this->scrollBar_.unpauseHighlights();
|
this->scrollBar_->unpauseHighlights();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -651,14 +658,14 @@ void ChannelView::drawMessages(QPainter &painter)
|
||||||
|
|
||||||
auto messagesSnapshot = this->getMessagesSnapshot();
|
auto messagesSnapshot = this->getMessagesSnapshot();
|
||||||
|
|
||||||
size_t start = size_t(this->scrollBar_.getCurrentValue());
|
size_t start = size_t(this->scrollBar_->getCurrentValue());
|
||||||
|
|
||||||
if (start >= messagesSnapshot.getLength()) {
|
if (start >= messagesSnapshot.getLength()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int y = int(-(messagesSnapshot[start].get()->getHeight() *
|
int y = int(-(messagesSnapshot[start].get()->getHeight() *
|
||||||
(fmod(this->scrollBar_.getCurrentValue(), 1))));
|
(fmod(this->scrollBar_->getCurrentValue(), 1))));
|
||||||
|
|
||||||
MessageLayout *end = nullptr;
|
MessageLayout *end = nullptr;
|
||||||
bool windowFocused = this->window() == QApplication::activeWindow();
|
bool windowFocused = this->window() == QApplication::activeWindow();
|
||||||
|
@ -729,12 +736,12 @@ void ChannelView::wheelEvent(QWheelEvent *event)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->scrollBar_.isVisible()) {
|
if (this->scrollBar_->isVisible()) {
|
||||||
auto app = getApp();
|
auto app = getApp();
|
||||||
|
|
||||||
float mouseMultiplier = app->settings->mouseScrollMultiplier;
|
float mouseMultiplier = app->settings->mouseScrollMultiplier;
|
||||||
|
|
||||||
qreal desired = this->scrollBar_.getDesiredValue();
|
qreal desired = this->scrollBar_->getDesiredValue();
|
||||||
qreal delta = event->delta() * qreal(1.5) * mouseMultiplier;
|
qreal delta = event->delta() * qreal(1.5) * mouseMultiplier;
|
||||||
|
|
||||||
auto snapshot = this->getMessagesSnapshot();
|
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();
|
auto messagesSnapshot = this->getMessagesSnapshot();
|
||||||
|
|
||||||
size_t start = this->scrollBar_.getCurrentValue();
|
size_t start = this->scrollBar_->getCurrentValue();
|
||||||
|
|
||||||
if (start >= messagesSnapshot.getLength()) {
|
if (start >= messagesSnapshot.getLength()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int y = -(messagesSnapshot[start]->getHeight() *
|
int y = -(messagesSnapshot[start]->getHeight() *
|
||||||
(fmod(this->scrollBar_.getCurrentValue(), 1)));
|
(fmod(this->scrollBar_->getCurrentValue(), 1)));
|
||||||
|
|
||||||
for (size_t i = start; i < messagesSnapshot.getLength(); ++i) {
|
for (size_t i = start; i < messagesSnapshot.getLength(); ++i) {
|
||||||
auto message = messagesSnapshot[i];
|
auto message = messagesSnapshot[i];
|
||||||
|
@ -1219,7 +1226,7 @@ bool ChannelView::tryGetMessageAt(QPoint p,
|
||||||
|
|
||||||
int ChannelView::getLayoutWidth() const
|
int ChannelView::getLayoutWidth() const
|
||||||
{
|
{
|
||||||
if (this->scrollBar_.isVisible())
|
if (this->scrollBar_->isVisible())
|
||||||
return int(this->width() - 8 * this->getScale());
|
return int(this->width() - 8 * this->getScale());
|
||||||
|
|
||||||
return this->width();
|
return this->width();
|
||||||
|
|
|
@ -1,14 +1,10 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/Channel.hpp"
|
#include "common/FlagsEnum.hpp"
|
||||||
#include "messages/Image.hpp"
|
#include "messages/LimitedQueue.hpp"
|
||||||
#include "messages/LimitedQueueSnapshot.hpp"
|
#include "messages/LimitedQueueSnapshot.hpp"
|
||||||
#include "messages/MessageElement.hpp"
|
|
||||||
#include "messages/Selection.hpp"
|
#include "messages/Selection.hpp"
|
||||||
#include "messages/layouts/MessageLayout.hpp"
|
|
||||||
#include "widgets/BaseWidget.hpp"
|
#include "widgets/BaseWidget.hpp"
|
||||||
#include "widgets/Scrollbar.hpp"
|
|
||||||
#include "widgets/helper/EffectLabel.hpp"
|
|
||||||
|
|
||||||
#include <QPaintEvent>
|
#include <QPaintEvent>
|
||||||
#include <QScroller>
|
#include <QScroller>
|
||||||
|
@ -20,8 +16,23 @@
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
|
||||||
namespace chatterino {
|
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
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -121,7 +132,7 @@ private:
|
||||||
|
|
||||||
ChannelPtr channel_;
|
ChannelPtr channel_;
|
||||||
|
|
||||||
Scrollbar scrollBar_;
|
Scrollbar *scrollBar_;
|
||||||
EffectLabel *goToBottom_;
|
EffectLabel *goToBottom_;
|
||||||
|
|
||||||
// This variable can be used to decide whether or not we should render the
|
// 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
Loading…
Reference in a new issue