mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Renamed private members
This commit is contained in:
parent
6935619820
commit
280bb4cf8e
|
@ -138,7 +138,6 @@ SOURCES += \
|
|||
src/providers/irc/IrcConnection2.cpp \
|
||||
src/providers/irc/IrcServer.cpp \
|
||||
src/providers/twitch/IrcMessageHandler.cpp \
|
||||
src/providers/twitch/Pubsub.cpp \
|
||||
src/providers/twitch/PubsubActions.cpp \
|
||||
src/providers/twitch/PubsubHelpers.cpp \
|
||||
src/providers/twitch/TwitchAccount.cpp \
|
||||
|
@ -177,8 +176,6 @@ SOURCES += \
|
|||
src/widgets/helper/ChannelView.cpp \
|
||||
src/widgets/helper/ComboBoxItemDelegate.cpp \
|
||||
src/widgets/helper/DebugPopup.cpp \
|
||||
src/widgets/helper/DropOverlay.cpp \
|
||||
src/widgets/helper/DropPreview.cpp \
|
||||
src/widgets/helper/EditableModelView.cpp \
|
||||
src/widgets/helper/NotebookButton.cpp \
|
||||
src/widgets/helper/NotebookTab.cpp \
|
||||
|
@ -229,7 +226,8 @@ SOURCES += \
|
|||
src/widgets/settingspages/FeelPage.cpp \
|
||||
src/util/InitUpdateButton.cpp \
|
||||
src/widgets/dialogs/UpdateDialog.cpp \
|
||||
src/widgets/settingspages/IgnoresPage.cpp
|
||||
src/widgets/settingspages/IgnoresPage.cpp \
|
||||
src/providers/twitch/PubsubClient.cpp
|
||||
|
||||
HEADERS += \
|
||||
src/Application.hpp \
|
||||
|
@ -296,7 +294,6 @@ HEADERS += \
|
|||
src/providers/irc/IrcServer.hpp \
|
||||
src/providers/twitch/EmoteValue.hpp \
|
||||
src/providers/twitch/IrcMessageHandler.hpp \
|
||||
src/providers/twitch/Pubsub.hpp \
|
||||
src/providers/twitch/PubsubActions.hpp \
|
||||
src/providers/twitch/PubsubHelpers.hpp \
|
||||
src/providers/twitch/TwitchAccount.hpp \
|
||||
|
@ -347,8 +344,6 @@ HEADERS += \
|
|||
src/widgets/helper/ChannelView.hpp \
|
||||
src/widgets/helper/ComboBoxItemDelegate.hpp \
|
||||
src/widgets/helper/DebugPopup.hpp \
|
||||
src/widgets/helper/DropOverlay.hpp \
|
||||
src/widgets/helper/DropPreview.hpp \
|
||||
src/widgets/helper/EditableModelView.hpp \
|
||||
src/widgets/helper/Line.hpp \
|
||||
src/widgets/helper/NotebookButton.hpp \
|
||||
|
@ -407,7 +402,8 @@ HEADERS += \
|
|||
src/widgets/settingspages/FeelPage.hpp \
|
||||
src/util/InitUpdateButton.hpp \
|
||||
src/widgets/dialogs/UpdateDialog.hpp \
|
||||
src/widgets/settingspages/IgnoresPage.hpp
|
||||
src/widgets/settingspages/IgnoresPage.hpp \
|
||||
src/providers/twitch/PubsubClient.hpp
|
||||
|
||||
RESOURCES += \
|
||||
resources/resources.qrc \
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include "controllers/ignores/IgnoreController.hpp"
|
||||
#include "controllers/moderationactions/ModerationActions.hpp"
|
||||
#include "controllers/taggedusers/TaggedUsersController.hpp"
|
||||
#include "providers/twitch/Pubsub.hpp"
|
||||
#include "providers/twitch/PubsubClient.hpp"
|
||||
#include "providers/twitch/TwitchServer.hpp"
|
||||
#include "singletons/Emotes.hpp"
|
||||
#include "singletons/Fonts.hpp"
|
||||
|
@ -33,8 +33,8 @@ static Application *staticApp = nullptr;
|
|||
// It will create the instances of the major classes, and connect their signals to each other
|
||||
|
||||
Application::Application(int _argc, char **_argv)
|
||||
: argc(_argc)
|
||||
, argv(_argv)
|
||||
: argc_(_argc)
|
||||
, argv_(_argv)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ class Application
|
|||
Application(int _argc, char **_argv);
|
||||
|
||||
public:
|
||||
static void instantiate(int argc, char **argv);
|
||||
static void instantiate(int argc_, char **argv_);
|
||||
|
||||
~Application() = delete;
|
||||
|
||||
|
@ -72,8 +72,8 @@ public:
|
|||
static void runNativeMessagingHost();
|
||||
|
||||
private:
|
||||
int argc;
|
||||
char **argv;
|
||||
int argc_;
|
||||
char **argv_;
|
||||
};
|
||||
|
||||
Application *getApp();
|
||||
|
|
|
@ -9,15 +9,15 @@ namespace chatterino {
|
|||
|
||||
void IgnoreController::initialize()
|
||||
{
|
||||
assert(!this->initialized);
|
||||
this->initialized = true;
|
||||
assert(!this->initialized_);
|
||||
this->initialized_ = true;
|
||||
|
||||
for (const IgnorePhrase &phrase : this->ignoresSetting.getValue()) {
|
||||
for (const IgnorePhrase &phrase : this->ignoresSetting_.getValue()) {
|
||||
this->phrases.appendItem(phrase);
|
||||
}
|
||||
|
||||
this->phrases.delayedItemsChanged.connect([this] { //
|
||||
this->ignoresSetting.setValue(this->phrases.getVector());
|
||||
this->ignoresSetting_.setValue(this->phrases.getVector());
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -18,9 +18,9 @@ public:
|
|||
IgnoreModel *createModel(QObject *parent);
|
||||
|
||||
private:
|
||||
bool initialized = false;
|
||||
bool initialized_ = false;
|
||||
|
||||
ChatterinoSetting<std::vector<IgnorePhrase>> ignoresSetting = {"/ignore/phrases"};
|
||||
ChatterinoSetting<std::vector<IgnorePhrase>> ignoresSetting_ = {"/ignore/phrases"};
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -13,43 +13,44 @@ namespace chatterino {
|
|||
|
||||
class IgnorePhrase
|
||||
{
|
||||
QString pattern;
|
||||
bool _isRegex;
|
||||
QRegularExpression regex;
|
||||
|
||||
public:
|
||||
bool operator==(const IgnorePhrase &other) const
|
||||
{
|
||||
return std::tie(this->pattern, this->_isRegex) == std::tie(other.pattern, other._isRegex);
|
||||
return std::tie(this->pattern_, this->isRegex_) == std::tie(other.pattern_, other.isRegex_);
|
||||
}
|
||||
|
||||
IgnorePhrase(const QString &_pattern, bool isRegex)
|
||||
: pattern(_pattern)
|
||||
, _isRegex(isRegex)
|
||||
, regex(_isRegex ? _pattern : "\\b" + QRegularExpression::escape(_pattern) + "\\b",
|
||||
QRegularExpression::CaseInsensitiveOption |
|
||||
QRegularExpression::UseUnicodePropertiesOption)
|
||||
IgnorePhrase(const QString &pattern, bool isRegex)
|
||||
: pattern_(pattern)
|
||||
, isRegex_(isRegex)
|
||||
, regex_(isRegex_ ? pattern : "\\b" + QRegularExpression::escape(pattern) + "\\b",
|
||||
QRegularExpression::CaseInsensitiveOption |
|
||||
QRegularExpression::UseUnicodePropertiesOption)
|
||||
{
|
||||
}
|
||||
|
||||
const QString &getPattern() const
|
||||
{
|
||||
return this->pattern;
|
||||
return this->pattern_;
|
||||
}
|
||||
bool isRegex() const
|
||||
{
|
||||
return this->_isRegex;
|
||||
return this->isRegex_;
|
||||
}
|
||||
|
||||
bool isValid() const
|
||||
{
|
||||
return !this->pattern.isEmpty() && this->regex.isValid();
|
||||
return !this->pattern_.isEmpty() && this->regex_.isValid();
|
||||
}
|
||||
|
||||
bool isMatch(const QString &subject) const
|
||||
{
|
||||
return this->isValid() && this->regex.match(subject).hasMatch();
|
||||
return this->isValid() && this->regex_.match(subject).hasMatch();
|
||||
}
|
||||
|
||||
private:
|
||||
QString pattern_;
|
||||
bool isRegex_;
|
||||
QRegularExpression regex_;
|
||||
};
|
||||
} // namespace chatterino
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ class Image;
|
|||
class ModerationAction
|
||||
{
|
||||
public:
|
||||
ModerationAction(const QString &action_);
|
||||
ModerationAction(const QString &action);
|
||||
|
||||
bool operator==(const ModerationAction &other) const;
|
||||
|
||||
|
|
|
@ -14,15 +14,15 @@ ModerationActions::ModerationActions()
|
|||
|
||||
void ModerationActions::initialize()
|
||||
{
|
||||
assert(!this->initialized);
|
||||
this->initialized = true;
|
||||
assert(!this->initialized_);
|
||||
this->initialized_ = true;
|
||||
|
||||
for (auto &val : this->setting.getValue()) {
|
||||
for (auto &val : this->setting_.getValue()) {
|
||||
this->items.insertItem(val);
|
||||
}
|
||||
|
||||
this->items.delayedItemsChanged.connect([this] { //
|
||||
this->setting.setValue(this->items.getVector());
|
||||
this->setting_.setValue(this->items.getVector());
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -20,8 +20,8 @@ public:
|
|||
ModerationActionModel *createModel(QObject *parent);
|
||||
|
||||
private:
|
||||
ChatterinoSetting<std::vector<ModerationAction>> setting = {"/moderation/actions"};
|
||||
bool initialized = false;
|
||||
ChatterinoSetting<std::vector<ModerationAction>> setting_ = {"/moderation/actions"};
|
||||
bool initialized_ = false;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -4,17 +4,32 @@
|
|||
|
||||
namespace chatterino {
|
||||
|
||||
TaggedUser::TaggedUser(ProviderId _provider, const QString &_name, const QString &_id)
|
||||
: provider(_provider)
|
||||
, name(_name)
|
||||
, id(_id)
|
||||
TaggedUser::TaggedUser(ProviderId provider, const QString &name, const QString &id)
|
||||
: providerId_(provider)
|
||||
, name_(name)
|
||||
, id_(id)
|
||||
{
|
||||
}
|
||||
|
||||
bool TaggedUser::operator<(const TaggedUser &other) const
|
||||
{
|
||||
return std::tie(this->provider, this->name, this->id) <
|
||||
std::tie(other.provider, other.name, other.id);
|
||||
return std::tie(this->providerId_, this->name_, this->id_) <
|
||||
std::tie(other.providerId_, other.name_, other.id_);
|
||||
}
|
||||
|
||||
ProviderId TaggedUser::getProviderId() const
|
||||
{
|
||||
return this->providerId_;
|
||||
}
|
||||
|
||||
QString TaggedUser::getName() const
|
||||
{
|
||||
return this->name_;
|
||||
}
|
||||
|
||||
QString TaggedUser::getId() const
|
||||
{
|
||||
return this->id_;
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -9,13 +9,18 @@ namespace chatterino {
|
|||
class TaggedUser
|
||||
{
|
||||
public:
|
||||
TaggedUser(ProviderId provider, const QString &name, const QString &id);
|
||||
TaggedUser(ProviderId providerId, const QString &name, const QString &id);
|
||||
|
||||
bool operator<(const TaggedUser &other) const;
|
||||
|
||||
ProviderId provider;
|
||||
QString name;
|
||||
QString id;
|
||||
ProviderId getProviderId() const;
|
||||
QString getName() const;
|
||||
QString getId() const;
|
||||
|
||||
private:
|
||||
ProviderId providerId_;
|
||||
QString name_;
|
||||
QString id_;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -21,7 +21,7 @@ TaggedUser TaggedUsersModel::getItemFromRow(std::vector<QStandardItem *> &row,
|
|||
// turns a row in the model into a vector item
|
||||
void TaggedUsersModel::getRowFromItem(const TaggedUser &item, std::vector<QStandardItem *> &row)
|
||||
{
|
||||
setStringItem(row[0], item.name);
|
||||
setStringItem(row[0], item.getName());
|
||||
}
|
||||
|
||||
void TaggedUsersModel::afterInit()
|
||||
|
|
|
@ -31,55 +31,55 @@ protected:
|
|||
typedef std::shared_ptr<std::vector<Chunk>> ChunkVector;
|
||||
|
||||
public:
|
||||
LimitedQueue(int _limit = 1000)
|
||||
: limit(_limit)
|
||||
LimitedQueue(int limit = 1000)
|
||||
: limit_(limit)
|
||||
{
|
||||
this->clear();
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(this->mutex);
|
||||
std::lock_guard<std::mutex> lock(this->mutex_);
|
||||
|
||||
this->chunks = std::make_shared<std::vector<std::shared_ptr<std::vector<T>>>>();
|
||||
this->chunks_ = std::make_shared<std::vector<std::shared_ptr<std::vector<T>>>>();
|
||||
Chunk chunk = std::make_shared<std::vector<T>>();
|
||||
chunk->resize(this->chunkSize);
|
||||
this->chunks->push_back(chunk);
|
||||
this->firstChunkOffset = 0;
|
||||
this->lastChunkEnd = 0;
|
||||
chunk->resize(this->chunkSize_);
|
||||
this->chunks_->push_back(chunk);
|
||||
this->firstChunkOffset_ = 0;
|
||||
this->lastChunkEnd_ = 0;
|
||||
}
|
||||
|
||||
// return true if an item was deleted
|
||||
// deleted will be set if the item was deleted
|
||||
bool pushBack(const T &item, T &deleted)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(this->mutex);
|
||||
std::lock_guard<std::mutex> lock(this->mutex_);
|
||||
|
||||
Chunk lastChunk = this->chunks->back();
|
||||
Chunk lastChunk = this->chunks_->back();
|
||||
|
||||
// still space in the last chunk
|
||||
if (lastChunk->size() <= this->lastChunkEnd) {
|
||||
if (lastChunk->size() <= this->lastChunkEnd_) {
|
||||
// create new chunk vector
|
||||
ChunkVector newVector =
|
||||
std::make_shared<std::vector<std::shared_ptr<std::vector<T>>>>();
|
||||
|
||||
// copy chunks
|
||||
for (Chunk &chunk : *this->chunks) {
|
||||
for (Chunk &chunk : *this->chunks_) {
|
||||
newVector->push_back(chunk);
|
||||
}
|
||||
|
||||
// push back new chunk
|
||||
Chunk newChunk = std::make_shared<std::vector<T>>();
|
||||
newChunk->resize(this->chunkSize);
|
||||
newChunk->resize(this->chunkSize_);
|
||||
newVector->push_back(newChunk);
|
||||
|
||||
// replace current chunk vector
|
||||
this->chunks = newVector;
|
||||
this->lastChunkEnd = 0;
|
||||
lastChunk = this->chunks->back();
|
||||
this->chunks_ = newVector;
|
||||
this->lastChunkEnd_ = 0;
|
||||
lastChunk = this->chunks_->back();
|
||||
}
|
||||
|
||||
lastChunk->at(this->lastChunkEnd++) = item;
|
||||
lastChunk->at(this->lastChunkEnd_++) = item;
|
||||
|
||||
return this->deleteFirstItem(deleted);
|
||||
}
|
||||
|
@ -90,41 +90,41 @@ public:
|
|||
std::vector<T> acceptedItems;
|
||||
|
||||
if (this->space() > 0) {
|
||||
std::lock_guard<std::mutex> lock(this->mutex);
|
||||
std::lock_guard<std::mutex> lock(this->mutex_);
|
||||
|
||||
// create new vector to clone chunks into
|
||||
ChunkVector newChunks =
|
||||
std::make_shared<std::vector<std::shared_ptr<std::vector<T>>>>();
|
||||
|
||||
newChunks->resize(this->chunks->size());
|
||||
newChunks->resize(this->chunks_->size());
|
||||
|
||||
// copy chunks except for first one
|
||||
for (size_t i = 1; i < this->chunks->size(); i++) {
|
||||
newChunks->at(i) = this->chunks->at(i);
|
||||
for (size_t i = 1; i < this->chunks_->size(); i++) {
|
||||
newChunks->at(i) = this->chunks_->at(i);
|
||||
}
|
||||
|
||||
// create new chunk for the first one
|
||||
size_t offset = std::min(this->space(), items.size());
|
||||
Chunk newFirstChunk = std::make_shared<std::vector<T>>();
|
||||
newFirstChunk->resize(this->chunks->front()->size() + offset);
|
||||
newFirstChunk->resize(this->chunks_->front()->size() + offset);
|
||||
|
||||
for (size_t i = 0; i < offset; i++) {
|
||||
newFirstChunk->at(i) = items[items.size() - offset + i];
|
||||
acceptedItems.push_back(items[items.size() - offset + i]);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < this->chunks->at(0)->size(); i++) {
|
||||
newFirstChunk->at(i + offset) = this->chunks->at(0)->at(i);
|
||||
for (size_t i = 0; i < this->chunks_->at(0)->size(); i++) {
|
||||
newFirstChunk->at(i + offset) = this->chunks_->at(0)->at(i);
|
||||
}
|
||||
|
||||
newChunks->at(0) = newFirstChunk;
|
||||
|
||||
this->chunks = newChunks;
|
||||
this->chunks_ = newChunks;
|
||||
// qDebug() << acceptedItems.size();
|
||||
// qDebug() << this->chunks->at(0)->size();
|
||||
|
||||
if (this->chunks->size() == 1) {
|
||||
this->lastChunkEnd += offset;
|
||||
if (this->chunks_->size() == 1) {
|
||||
this->lastChunkEnd_ += offset;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -134,15 +134,15 @@ public:
|
|||
// replace an single item, return index if successful, -1 if unsuccessful
|
||||
int replaceItem(const T &item, const T &replacement)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(this->mutex);
|
||||
std::lock_guard<std::mutex> lock(this->mutex_);
|
||||
|
||||
int x = 0;
|
||||
|
||||
for (size_t i = 0; i < this->chunks->size(); i++) {
|
||||
Chunk &chunk = this->chunks->at(i);
|
||||
for (size_t i = 0; i < this->chunks_->size(); i++) {
|
||||
Chunk &chunk = this->chunks_->at(i);
|
||||
|
||||
size_t start = i == 0 ? this->firstChunkOffset : 0;
|
||||
size_t end = i == chunk->size() - 1 ? this->lastChunkEnd : chunk->size();
|
||||
size_t start = i == 0 ? this->firstChunkOffset_ : 0;
|
||||
size_t end = i == chunk->size() - 1 ? this->lastChunkEnd_ : chunk->size();
|
||||
|
||||
for (size_t j = start; j < end; j++) {
|
||||
if (chunk->at(j) == item) {
|
||||
|
@ -154,7 +154,7 @@ public:
|
|||
}
|
||||
|
||||
newChunk->at(j) = replacement;
|
||||
this->chunks->at(i) = newChunk;
|
||||
this->chunks_->at(i) = newChunk;
|
||||
|
||||
return x;
|
||||
}
|
||||
|
@ -168,15 +168,15 @@ public:
|
|||
// replace an item at index, return true if worked
|
||||
bool replaceItem(size_t index, const T &replacement)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(this->mutex);
|
||||
std::lock_guard<std::mutex> lock(this->mutex_);
|
||||
|
||||
size_t x = 0;
|
||||
|
||||
for (size_t i = 0; i < this->chunks->size(); i++) {
|
||||
Chunk &chunk = this->chunks->at(i);
|
||||
for (size_t i = 0; i < this->chunks_->size(); i++) {
|
||||
Chunk &chunk = this->chunks_->at(i);
|
||||
|
||||
size_t start = i == 0 ? this->firstChunkOffset : 0;
|
||||
size_t end = i == chunk->size() - 1 ? this->lastChunkEnd : chunk->size();
|
||||
size_t start = i == 0 ? this->firstChunkOffset_ : 0;
|
||||
size_t end = i == chunk->size() - 1 ? this->lastChunkEnd_ : chunk->size();
|
||||
|
||||
for (size_t j = start; j < end; j++) {
|
||||
if (x == index) {
|
||||
|
@ -188,7 +188,7 @@ public:
|
|||
}
|
||||
|
||||
newChunk->at(j) = replacement;
|
||||
this->chunks->at(i) = newChunk;
|
||||
this->chunks_->at(i) = newChunk;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -202,26 +202,26 @@ public:
|
|||
|
||||
LimitedQueueSnapshot<T> getSnapshot()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(this->mutex);
|
||||
std::lock_guard<std::mutex> lock(this->mutex_);
|
||||
|
||||
return LimitedQueueSnapshot<T>(this->chunks, this->limit - this->space(),
|
||||
this->firstChunkOffset, this->lastChunkEnd);
|
||||
return LimitedQueueSnapshot<T>(this->chunks_, this->limit_ - this->space(),
|
||||
this->firstChunkOffset_, this->lastChunkEnd_);
|
||||
}
|
||||
|
||||
private:
|
||||
size_t space()
|
||||
{
|
||||
size_t totalSize = 0;
|
||||
for (Chunk &chunk : *this->chunks) {
|
||||
for (Chunk &chunk : *this->chunks_) {
|
||||
totalSize += chunk->size();
|
||||
}
|
||||
|
||||
totalSize -= this->chunks->back()->size() - this->lastChunkEnd;
|
||||
if (this->chunks->size() != 1) {
|
||||
totalSize -= this->firstChunkOffset;
|
||||
totalSize -= this->chunks_->back()->size() - this->lastChunkEnd_;
|
||||
if (this->chunks_->size() != 1) {
|
||||
totalSize -= this->firstChunkOffset_;
|
||||
}
|
||||
|
||||
return this->limit - totalSize;
|
||||
return this->limit_ - totalSize;
|
||||
}
|
||||
|
||||
bool deleteFirstItem(T &deleted)
|
||||
|
@ -231,39 +231,39 @@ private:
|
|||
return false;
|
||||
}
|
||||
|
||||
deleted = this->chunks->front()->at(this->firstChunkOffset);
|
||||
deleted = this->chunks_->front()->at(this->firstChunkOffset_);
|
||||
|
||||
this->firstChunkOffset++;
|
||||
this->firstChunkOffset_++;
|
||||
|
||||
// need to delete the first chunk
|
||||
if (this->firstChunkOffset == this->chunks->front()->size() - 1) {
|
||||
if (this->firstChunkOffset_ == this->chunks_->front()->size() - 1) {
|
||||
// copy the chunk vector
|
||||
ChunkVector newVector =
|
||||
std::make_shared<std::vector<std::shared_ptr<std::vector<T>>>>();
|
||||
|
||||
// delete first chunk
|
||||
bool first = true;
|
||||
for (Chunk &chunk : *this->chunks) {
|
||||
for (Chunk &chunk : *this->chunks_) {
|
||||
if (!first) {
|
||||
newVector->push_back(chunk);
|
||||
}
|
||||
first = false;
|
||||
}
|
||||
|
||||
this->chunks = newVector;
|
||||
this->firstChunkOffset = 0;
|
||||
this->chunks_ = newVector;
|
||||
this->firstChunkOffset_ = 0;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
ChunkVector chunks;
|
||||
std::mutex mutex;
|
||||
ChunkVector chunks_;
|
||||
std::mutex mutex_;
|
||||
|
||||
size_t firstChunkOffset;
|
||||
size_t lastChunkEnd;
|
||||
size_t limit;
|
||||
size_t firstChunkOffset_;
|
||||
size_t lastChunkEnd_;
|
||||
size_t limit_;
|
||||
|
||||
const size_t chunkSize = 100;
|
||||
const size_t chunkSize_ = 100;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -12,28 +12,28 @@ class LimitedQueueSnapshot
|
|||
public:
|
||||
LimitedQueueSnapshot() = default;
|
||||
|
||||
LimitedQueueSnapshot(std::shared_ptr<std::vector<std::shared_ptr<std::vector<T>>>> _chunks,
|
||||
size_t _length, size_t _firstChunkOffset, size_t _lastChunkEnd)
|
||||
: chunks(_chunks)
|
||||
, length(_length)
|
||||
, firstChunkOffset(_firstChunkOffset)
|
||||
, lastChunkEnd(_lastChunkEnd)
|
||||
LimitedQueueSnapshot(std::shared_ptr<std::vector<std::shared_ptr<std::vector<T>>>> chunks,
|
||||
size_t length, size_t firstChunkOffset, size_t lastChunkEnd)
|
||||
: chunks_(chunks)
|
||||
, length_(length)
|
||||
, firstChunkOffset_(firstChunkOffset)
|
||||
, lastChunkEnd_(lastChunkEnd)
|
||||
{
|
||||
}
|
||||
|
||||
std::size_t getLength()
|
||||
{
|
||||
return this->length;
|
||||
return this->length_;
|
||||
}
|
||||
|
||||
T const &operator[](std::size_t index) const
|
||||
{
|
||||
index += this->firstChunkOffset;
|
||||
index += this->firstChunkOffset_;
|
||||
|
||||
size_t x = 0;
|
||||
|
||||
for (size_t i = 0; i < this->chunks->size(); i++) {
|
||||
auto &chunk = this->chunks->at(i);
|
||||
for (size_t i = 0; i < this->chunks_->size(); i++) {
|
||||
auto &chunk = this->chunks_->at(i);
|
||||
|
||||
if (x <= index && x + chunk->size() > index) {
|
||||
return chunk->at(index - x);
|
||||
|
@ -43,15 +43,15 @@ public:
|
|||
|
||||
assert(false && "out of range");
|
||||
|
||||
return this->chunks->at(0)->at(0);
|
||||
return this->chunks_->at(0)->at(0);
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<std::vector<std::shared_ptr<std::vector<T>>>> chunks;
|
||||
std::shared_ptr<std::vector<std::shared_ptr<std::vector<T>>>> chunks_;
|
||||
|
||||
size_t length = 0;
|
||||
size_t firstChunkOffset = 0;
|
||||
size_t lastChunkEnd = 0;
|
||||
size_t length_ = 0;
|
||||
size_t firstChunkOffset_ = 0;
|
||||
size_t lastChunkEnd_ = 0;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -9,12 +9,12 @@ namespace chatterino {
|
|||
|
||||
void Message::addElement(MessageElement *element)
|
||||
{
|
||||
this->elements.push_back(std::unique_ptr<MessageElement>(element));
|
||||
this->elements_.push_back(std::unique_ptr<MessageElement>(element));
|
||||
}
|
||||
|
||||
const std::vector<std::unique_ptr<MessageElement>> &Message::getElements() const
|
||||
{
|
||||
return this->elements;
|
||||
return this->elements_;
|
||||
}
|
||||
|
||||
SBHighlight Message::getScrollBarHighlight() const
|
||||
|
|
|
@ -62,7 +62,7 @@ struct Message {
|
|||
ScrollbarHighlight getScrollBarHighlight() const;
|
||||
|
||||
private:
|
||||
std::vector<std::unique_ptr<MessageElement>> elements;
|
||||
std::vector<std::unique_ptr<MessageElement>> elements_;
|
||||
|
||||
public:
|
||||
static std::shared_ptr<Message> createSystemMessage(const QString &text);
|
||||
|
|
|
@ -10,18 +10,18 @@
|
|||
namespace chatterino {
|
||||
|
||||
MessageBuilder::MessageBuilder()
|
||||
: message(new Message)
|
||||
: message_(new Message)
|
||||
{
|
||||
}
|
||||
|
||||
MessagePtr MessageBuilder::getMessage()
|
||||
{
|
||||
return this->message;
|
||||
return this->message_;
|
||||
}
|
||||
|
||||
void MessageBuilder::append(MessageElement *element)
|
||||
{
|
||||
this->message->addElement(element);
|
||||
this->message_->addElement(element);
|
||||
}
|
||||
|
||||
void MessageBuilder::appendTimestamp()
|
||||
|
@ -32,9 +32,9 @@ void MessageBuilder::appendTimestamp()
|
|||
void MessageBuilder::setHighlight(bool value)
|
||||
{
|
||||
if (value) {
|
||||
this->message->flags |= Message::Highlighted;
|
||||
this->message_->flags |= Message::Highlighted;
|
||||
} else {
|
||||
this->message->flags &= ~Message::Highlighted;
|
||||
this->message_->flags &= ~Message::Highlighted;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ public:
|
|||
}
|
||||
|
||||
protected:
|
||||
MessagePtr message;
|
||||
MessagePtr message_;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -2,22 +2,22 @@
|
|||
|
||||
namespace chatterino {
|
||||
|
||||
MessageColor::MessageColor(const QColor &_color)
|
||||
: type(Type::Custom)
|
||||
, customColor(_color)
|
||||
MessageColor::MessageColor(const QColor &color)
|
||||
: type_(Type::Custom)
|
||||
, customColor_(color)
|
||||
{
|
||||
}
|
||||
|
||||
MessageColor::MessageColor(Type _type)
|
||||
: type(_type)
|
||||
MessageColor::MessageColor(Type type)
|
||||
: type_(type)
|
||||
{
|
||||
}
|
||||
|
||||
const QColor &MessageColor::getColor(Theme &themeManager) const
|
||||
{
|
||||
switch (this->type) {
|
||||
switch (this->type_) {
|
||||
case Type::Custom:
|
||||
return this->customColor;
|
||||
return this->customColor_;
|
||||
case Type::Text:
|
||||
return themeManager.messages.textColors.regular;
|
||||
case Type::System:
|
||||
|
|
|
@ -10,13 +10,13 @@ struct MessageColor {
|
|||
enum Type { Custom, Text, Link, System };
|
||||
|
||||
MessageColor(const QColor &color);
|
||||
MessageColor(Type type = Text);
|
||||
MessageColor(Type type_ = Text);
|
||||
|
||||
const QColor &getColor(Theme &themeManager) const;
|
||||
|
||||
private:
|
||||
Type type;
|
||||
QColor customColor;
|
||||
Type type_;
|
||||
QColor customColor_;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
|
||||
namespace chatterino {
|
||||
|
||||
MessageElement::MessageElement(Flags _flags)
|
||||
: flags(_flags)
|
||||
MessageElement::MessageElement(Flags flags)
|
||||
: flags_(flags)
|
||||
{
|
||||
DebugCount::increase("message elements");
|
||||
}
|
||||
|
@ -21,15 +21,15 @@ MessageElement::~MessageElement()
|
|||
DebugCount::decrease("message elements");
|
||||
}
|
||||
|
||||
MessageElement *MessageElement::setLink(const Link &_link)
|
||||
MessageElement *MessageElement::setLink(const Link &link)
|
||||
{
|
||||
this->link = _link;
|
||||
this->link_ = link;
|
||||
return this;
|
||||
}
|
||||
|
||||
MessageElement *MessageElement::setTooltip(const QString &_tooltip)
|
||||
MessageElement *MessageElement::setTooltip(const QString &tooltip)
|
||||
{
|
||||
this->tooltip = _tooltip;
|
||||
this->tooltip_ = tooltip;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -41,12 +41,12 @@ MessageElement *MessageElement::setTrailingSpace(bool value)
|
|||
|
||||
const QString &MessageElement::getTooltip() const
|
||||
{
|
||||
return this->tooltip;
|
||||
return this->tooltip_;
|
||||
}
|
||||
|
||||
const Link &MessageElement::getLink() const
|
||||
{
|
||||
return this->link;
|
||||
return this->link_;
|
||||
}
|
||||
|
||||
bool MessageElement::hasTrailingSpace() const
|
||||
|
@ -56,58 +56,58 @@ bool MessageElement::hasTrailingSpace() const
|
|||
|
||||
MessageElement::Flags MessageElement::getFlags() const
|
||||
{
|
||||
return this->flags;
|
||||
return this->flags_;
|
||||
}
|
||||
|
||||
// IMAGE
|
||||
ImageElement::ImageElement(Image *_image, MessageElement::Flags flags)
|
||||
ImageElement::ImageElement(Image *image, MessageElement::Flags flags)
|
||||
: MessageElement(flags)
|
||||
, image(_image)
|
||||
, image_(image)
|
||||
{
|
||||
this->setTooltip(_image->getTooltip());
|
||||
this->setTooltip(image->getTooltip());
|
||||
}
|
||||
|
||||
void ImageElement::addToContainer(MessageLayoutContainer &container, MessageElement::Flags _flags)
|
||||
void ImageElement::addToContainer(MessageLayoutContainer &container, MessageElement::Flags flags)
|
||||
{
|
||||
if (_flags & this->getFlags()) {
|
||||
QSize size(this->image->getScaledWidth() * container.getScale(),
|
||||
this->image->getScaledHeight() * container.getScale());
|
||||
if (flags & this->getFlags()) {
|
||||
QSize size(this->image_->getScaledWidth() * container.getScale(),
|
||||
this->image_->getScaledHeight() * container.getScale());
|
||||
|
||||
container.addElement(
|
||||
(new ImageLayoutElement(*this, this->image, size))->setLink(this->getLink()));
|
||||
(new ImageLayoutElement(*this, this->image_, size))->setLink(this->getLink()));
|
||||
}
|
||||
}
|
||||
|
||||
// EMOTE
|
||||
EmoteElement::EmoteElement(const EmoteData &_data, MessageElement::Flags flags)
|
||||
EmoteElement::EmoteElement(const EmoteData &data, MessageElement::Flags flags)
|
||||
: MessageElement(flags)
|
||||
, data(_data)
|
||||
, data(data)
|
||||
{
|
||||
if (_data.isValid()) {
|
||||
if (data.isValid()) {
|
||||
this->setTooltip(data.image1x->getTooltip());
|
||||
this->textElement.reset(
|
||||
new TextElement(_data.image1x->getCopyString(), MessageElement::Misc));
|
||||
this->textElement_.reset(
|
||||
new TextElement(data.image1x->getCopyString(), MessageElement::Misc));
|
||||
}
|
||||
}
|
||||
|
||||
void EmoteElement::addToContainer(MessageLayoutContainer &container, MessageElement::Flags _flags)
|
||||
void EmoteElement::addToContainer(MessageLayoutContainer &container, MessageElement::Flags flags)
|
||||
{
|
||||
if (_flags & this->getFlags()) {
|
||||
if (_flags & MessageElement::EmoteImages) {
|
||||
if (flags & this->getFlags()) {
|
||||
if (flags & MessageElement::EmoteImages) {
|
||||
if (!this->data.isValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Image *_image = this->data.getImage(container.getScale());
|
||||
Image *image = this->data.getImage(container.getScale());
|
||||
|
||||
QSize size(int(container.getScale() * _image->getScaledWidth()),
|
||||
int(container.getScale() * _image->getScaledHeight()));
|
||||
QSize size(int(container.getScale() * image->getScaledWidth()),
|
||||
int(container.getScale() * image->getScaledHeight()));
|
||||
|
||||
container.addElement(
|
||||
(new ImageLayoutElement(*this, _image, size))->setLink(this->getLink()));
|
||||
(new ImageLayoutElement(*this, image, size))->setLink(this->getLink()));
|
||||
} else {
|
||||
if (this->textElement) {
|
||||
this->textElement->addToContainer(container, MessageElement::Misc);
|
||||
if (this->textElement_) {
|
||||
this->textElement_->addToContainer(container, MessageElement::Misc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -115,31 +115,31 @@ void EmoteElement::addToContainer(MessageLayoutContainer &container, MessageElem
|
|||
|
||||
// TEXT
|
||||
TextElement::TextElement(const QString &text, MessageElement::Flags flags,
|
||||
const MessageColor &_color, FontStyle _style)
|
||||
const MessageColor &color, FontStyle style)
|
||||
: MessageElement(flags)
|
||||
, color(_color)
|
||||
, style(_style)
|
||||
, color_(color)
|
||||
, style_(style)
|
||||
{
|
||||
for (QString word : text.split(' ')) {
|
||||
this->words.push_back({word, -1});
|
||||
this->words_.push_back({word, -1});
|
||||
// fourtf: add logic to store multiple spaces after message
|
||||
}
|
||||
}
|
||||
|
||||
void TextElement::addToContainer(MessageLayoutContainer &container, MessageElement::Flags _flags)
|
||||
void TextElement::addToContainer(MessageLayoutContainer &container, MessageElement::Flags flags)
|
||||
{
|
||||
auto app = getApp();
|
||||
|
||||
if (_flags & this->getFlags()) {
|
||||
QFontMetrics metrics = app->fonts->getFontMetrics(this->style, container.getScale());
|
||||
if (flags & this->getFlags()) {
|
||||
QFontMetrics metrics = app->fonts->getFontMetrics(this->style_, container.getScale());
|
||||
|
||||
for (Word &word : this->words) {
|
||||
for (Word &word : this->words_) {
|
||||
auto getTextLayoutElement = [&](QString text, int width, bool trailingSpace) {
|
||||
QColor color = this->color.getColor(*app->themes);
|
||||
QColor color = this->color_.getColor(*app->themes);
|
||||
app->themes->normalizeColor(color);
|
||||
|
||||
auto e = (new TextLayoutElement(*this, text, QSize(width, metrics.height()), color,
|
||||
this->style, container.getScale()))
|
||||
this->style_, container.getScale()))
|
||||
->setLink(this->getLink());
|
||||
e->setTrailingSpace(trailingSpace);
|
||||
return e;
|
||||
|
@ -206,25 +206,25 @@ void TextElement::addToContainer(MessageLayoutContainer &container, MessageEleme
|
|||
}
|
||||
|
||||
// TIMESTAMP
|
||||
TimestampElement::TimestampElement(QTime _time)
|
||||
TimestampElement::TimestampElement(QTime time)
|
||||
: MessageElement(MessageElement::Timestamp)
|
||||
, time(_time)
|
||||
, element(this->formatTime(_time))
|
||||
, time_(time)
|
||||
, element_(this->formatTime(time))
|
||||
{
|
||||
assert(this->element != nullptr);
|
||||
assert(this->element_ != nullptr);
|
||||
}
|
||||
|
||||
void TimestampElement::addToContainer(MessageLayoutContainer &container,
|
||||
MessageElement::Flags _flags)
|
||||
MessageElement::Flags flags)
|
||||
{
|
||||
if (_flags & this->getFlags()) {
|
||||
if (flags & this->getFlags()) {
|
||||
auto app = getApp();
|
||||
if (app->settings->timestampFormat != this->format) {
|
||||
this->format = app->settings->timestampFormat.getValue();
|
||||
this->element.reset(this->formatTime(this->time));
|
||||
if (app->settings->timestampFormat != this->format_) {
|
||||
this->format_ = app->settings->timestampFormat.getValue();
|
||||
this->element_.reset(this->formatTime(this->time_));
|
||||
}
|
||||
|
||||
this->element->addToContainer(container, _flags);
|
||||
this->element_->addToContainer(container, flags);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -244,9 +244,9 @@ TwitchModerationElement::TwitchModerationElement()
|
|||
}
|
||||
|
||||
void TwitchModerationElement::addToContainer(MessageLayoutContainer &container,
|
||||
MessageElement::Flags _flags)
|
||||
MessageElement::Flags flags)
|
||||
{
|
||||
if (_flags & MessageElement::ModeratorTools) {
|
||||
if (flags & MessageElement::ModeratorTools) {
|
||||
QSize size(int(container.getScale() * 16), int(container.getScale() * 16));
|
||||
|
||||
for (const ModerationAction &m : getApp()->moderationActions->items.getVector()) {
|
||||
|
|
|
@ -120,34 +120,26 @@ protected:
|
|||
bool trailingSpace = true;
|
||||
|
||||
private:
|
||||
Link link;
|
||||
QString tooltip;
|
||||
Flags flags;
|
||||
Link link_;
|
||||
QString tooltip_;
|
||||
Flags flags_;
|
||||
};
|
||||
|
||||
// contains a simple image
|
||||
class ImageElement : public MessageElement
|
||||
{
|
||||
Image *image;
|
||||
|
||||
public:
|
||||
ImageElement(Image *image, MessageElement::Flags flags);
|
||||
|
||||
void addToContainer(MessageLayoutContainer &container, MessageElement::Flags flags) override;
|
||||
|
||||
private:
|
||||
Image *image_;
|
||||
};
|
||||
|
||||
// contains a text, it will split it into words
|
||||
class TextElement : public MessageElement
|
||||
{
|
||||
MessageColor color;
|
||||
FontStyle style;
|
||||
|
||||
struct Word {
|
||||
QString text;
|
||||
int width = -1;
|
||||
};
|
||||
std::vector<Word> words;
|
||||
|
||||
public:
|
||||
TextElement(const QString &text, MessageElement::Flags flags,
|
||||
const MessageColor &color = MessageColor::Text,
|
||||
|
@ -155,6 +147,16 @@ public:
|
|||
~TextElement() override = default;
|
||||
|
||||
void addToContainer(MessageLayoutContainer &container, MessageElement::Flags flags) override;
|
||||
|
||||
private:
|
||||
MessageColor color_;
|
||||
FontStyle style_;
|
||||
|
||||
struct Word {
|
||||
QString text;
|
||||
int width = -1;
|
||||
};
|
||||
std::vector<Word> words_;
|
||||
};
|
||||
|
||||
// contains emote data and will pick the emote based on :
|
||||
|
@ -162,15 +164,16 @@ public:
|
|||
// b) which size it wants
|
||||
class EmoteElement : public MessageElement
|
||||
{
|
||||
std::unique_ptr<TextElement> textElement;
|
||||
|
||||
public:
|
||||
EmoteElement(const EmoteData &data, MessageElement::Flags flags);
|
||||
EmoteElement(const EmoteData &data, MessageElement::Flags flags_);
|
||||
~EmoteElement() override = default;
|
||||
|
||||
void addToContainer(MessageLayoutContainer &container, MessageElement::Flags flags) override;
|
||||
void addToContainer(MessageLayoutContainer &container, MessageElement::Flags flags_) override;
|
||||
|
||||
const EmoteData data;
|
||||
|
||||
private:
|
||||
std::unique_ptr<TextElement> textElement_;
|
||||
};
|
||||
|
||||
// contains a text, formated depending on the preferences
|
||||
|
@ -182,7 +185,7 @@ public:
|
|||
|
||||
void addToContainer(MessageLayoutContainer &container, MessageElement::Flags flags) override;
|
||||
|
||||
TextElement *formatTime(const QTime &time_);
|
||||
TextElement *formatTime(const QTime &time);
|
||||
|
||||
private:
|
||||
QTime time_;
|
||||
|
|
|
@ -15,46 +15,46 @@ namespace chatterino {
|
|||
|
||||
int MessageLayoutContainer::getHeight() const
|
||||
{
|
||||
return this->height;
|
||||
return this->height_;
|
||||
}
|
||||
|
||||
int MessageLayoutContainer::getWidth() const
|
||||
{
|
||||
return this->width;
|
||||
return this->width_;
|
||||
}
|
||||
|
||||
float MessageLayoutContainer::getScale() const
|
||||
{
|
||||
return this->scale;
|
||||
return this->scale_;
|
||||
}
|
||||
|
||||
// methods
|
||||
void MessageLayoutContainer::begin(int _width, float _scale, Message::MessageFlags _flags)
|
||||
void MessageLayoutContainer::begin(int width, float scale, Message::MessageFlags flags)
|
||||
{
|
||||
this->clear();
|
||||
this->width = _width;
|
||||
this->scale = _scale;
|
||||
this->flags = _flags;
|
||||
auto mediumFontMetrics = getApp()->fonts->getFontMetrics(FontStyle::ChatMedium, _scale);
|
||||
this->textLineHeight = mediumFontMetrics.height();
|
||||
this->spaceWidth = mediumFontMetrics.width(' ');
|
||||
this->dotdotdotWidth = mediumFontMetrics.width("...");
|
||||
this->_canAddMessages = true;
|
||||
this->_isCollapsed = false;
|
||||
this->width_ = width;
|
||||
this->scale_ = scale;
|
||||
this->flags_ = flags;
|
||||
auto mediumFontMetrics = getApp()->fonts->getFontMetrics(FontStyle::ChatMedium, scale);
|
||||
this->textLineHeight_ = mediumFontMetrics.height();
|
||||
this->spaceWidth_ = mediumFontMetrics.width(' ');
|
||||
this->dotdotdotWidth_ = mediumFontMetrics.width("...");
|
||||
this->canAddMessages_ = true;
|
||||
this->isCollapsed_ = false;
|
||||
}
|
||||
|
||||
void MessageLayoutContainer::clear()
|
||||
{
|
||||
this->elements.clear();
|
||||
this->lines.clear();
|
||||
this->elements_.clear();
|
||||
this->lines_.clear();
|
||||
|
||||
this->height = 0;
|
||||
this->line = 0;
|
||||
this->currentX = 0;
|
||||
this->currentY = 0;
|
||||
this->lineStart = 0;
|
||||
this->lineHeight = 0;
|
||||
this->charIndex = 0;
|
||||
this->height_ = 0;
|
||||
this->line_ = 0;
|
||||
this->currentX_ = 0;
|
||||
this->currentY_ = 0;
|
||||
this->lineStart_ = 0;
|
||||
this->lineHeight_ = 0;
|
||||
this->charIndex_ = 0;
|
||||
}
|
||||
|
||||
void MessageLayoutContainer::addElement(MessageLayoutElement *element)
|
||||
|
@ -73,7 +73,7 @@ void MessageLayoutContainer::addElementNoLineBreak(MessageLayoutElement *element
|
|||
|
||||
bool MessageLayoutContainer::canAddElements()
|
||||
{
|
||||
return this->_canAddMessages;
|
||||
return this->canAddMessages_;
|
||||
}
|
||||
|
||||
void MessageLayoutContainer::_addElement(MessageLayoutElement *element, bool forceAdd)
|
||||
|
@ -84,34 +84,34 @@ void MessageLayoutContainer::_addElement(MessageLayoutElement *element, bool for
|
|||
}
|
||||
|
||||
// top margin
|
||||
if (this->elements.size() == 0) {
|
||||
this->currentY = this->margin.top * this->scale;
|
||||
if (this->elements_.size() == 0) {
|
||||
this->currentY_ = this->margin.top * this->scale_;
|
||||
}
|
||||
|
||||
int newLineHeight = element->getRect().height();
|
||||
|
||||
// compact emote offset
|
||||
bool isCompactEmote = !(this->flags & Message::DisableCompactEmotes) &&
|
||||
bool isCompactEmote = !(this->flags_ & Message::DisableCompactEmotes) &&
|
||||
element->getCreator().getFlags() & MessageElement::EmoteImages;
|
||||
|
||||
if (isCompactEmote) {
|
||||
newLineHeight -= COMPACT_EMOTES_OFFSET * this->scale;
|
||||
newLineHeight -= COMPACT_EMOTES_OFFSET * this->scale_;
|
||||
}
|
||||
|
||||
// update line height
|
||||
this->lineHeight = std::max(this->lineHeight, newLineHeight);
|
||||
this->lineHeight_ = std::max(this->lineHeight_, newLineHeight);
|
||||
|
||||
// set move element
|
||||
element->setPosition(QPoint(this->currentX, this->currentY - element->getRect().height()));
|
||||
element->setPosition(QPoint(this->currentX_, this->currentY_ - element->getRect().height()));
|
||||
|
||||
// add element
|
||||
this->elements.push_back(std::unique_ptr<MessageLayoutElement>(element));
|
||||
this->elements_.push_back(std::unique_ptr<MessageLayoutElement>(element));
|
||||
|
||||
// set current x
|
||||
this->currentX += element->getRect().width();
|
||||
this->currentX_ += element->getRect().width();
|
||||
|
||||
if (element->hasTrailingSpace()) {
|
||||
this->currentX += this->spaceWidth;
|
||||
this->currentX_ += this->spaceWidth_;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -119,66 +119,66 @@ void MessageLayoutContainer::breakLine()
|
|||
{
|
||||
int xOffset = 0;
|
||||
|
||||
if (this->flags & Message::Centered && this->elements.size() > 0) {
|
||||
xOffset = (width - this->elements.at(this->elements.size() - 1)->getRect().right()) / 2;
|
||||
if (this->flags_ & Message::Centered && this->elements_.size() > 0) {
|
||||
xOffset = (width_ - this->elements_.at(this->elements_.size() - 1)->getRect().right()) / 2;
|
||||
}
|
||||
|
||||
for (size_t i = lineStart; i < this->elements.size(); i++) {
|
||||
MessageLayoutElement *element = this->elements.at(i).get();
|
||||
for (size_t i = lineStart_; i < this->elements_.size(); i++) {
|
||||
MessageLayoutElement *element = this->elements_.at(i).get();
|
||||
|
||||
bool isCompactEmote = !(this->flags & Message::DisableCompactEmotes) &&
|
||||
bool isCompactEmote = !(this->flags_ & Message::DisableCompactEmotes) &&
|
||||
element->getCreator().getFlags() & MessageElement::EmoteImages;
|
||||
|
||||
int yExtra = 0;
|
||||
if (isCompactEmote) {
|
||||
yExtra = (COMPACT_EMOTES_OFFSET / 2) * this->scale;
|
||||
yExtra = (COMPACT_EMOTES_OFFSET / 2) * this->scale_;
|
||||
}
|
||||
|
||||
// if (element->getCreator().getFlags() & MessageElement::Badges) {
|
||||
if (element->getRect().height() < this->textLineHeight) {
|
||||
yExtra -= (this->textLineHeight - element->getRect().height()) / 2;
|
||||
if (element->getRect().height() < this->textLineHeight_) {
|
||||
yExtra -= (this->textLineHeight_ - element->getRect().height()) / 2;
|
||||
}
|
||||
|
||||
element->setPosition(QPoint(element->getRect().x() + xOffset + this->margin.left,
|
||||
element->getRect().y() + this->lineHeight + yExtra));
|
||||
element->getRect().y() + this->lineHeight_ + yExtra));
|
||||
}
|
||||
|
||||
if (this->lines.size() != 0) {
|
||||
this->lines.back().endIndex = this->lineStart;
|
||||
this->lines.back().endCharIndex = this->charIndex;
|
||||
if (this->lines_.size() != 0) {
|
||||
this->lines_.back().endIndex = this->lineStart_;
|
||||
this->lines_.back().endCharIndex = this->charIndex_;
|
||||
}
|
||||
this->lines.push_back({(int)lineStart, 0, this->charIndex, 0,
|
||||
QRect(-100000, this->currentY, 200000, lineHeight)});
|
||||
this->lines_.push_back({(int)lineStart_, 0, this->charIndex_, 0,
|
||||
QRect(-100000, this->currentY_, 200000, lineHeight_)});
|
||||
|
||||
for (int i = this->lineStart; i < this->elements.size(); i++) {
|
||||
this->charIndex += this->elements[i]->getSelectionIndexCount();
|
||||
for (int i = this->lineStart_; i < this->elements_.size(); i++) {
|
||||
this->charIndex_ += this->elements_[i]->getSelectionIndexCount();
|
||||
}
|
||||
|
||||
this->lineStart = this->elements.size();
|
||||
this->lineStart_ = this->elements_.size();
|
||||
// this->currentX = (int)(this->scale * 8);
|
||||
|
||||
if (this->canCollapse() && line + 1 >= MAX_UNCOLLAPSED_LINES) {
|
||||
this->_canAddMessages = false;
|
||||
if (this->canCollapse() && line_ + 1 >= MAX_UNCOLLAPSED_LINES) {
|
||||
this->canAddMessages_ = false;
|
||||
return;
|
||||
}
|
||||
|
||||
this->currentX = 0;
|
||||
this->currentY += this->lineHeight;
|
||||
this->height = this->currentY + (this->margin.bottom * this->scale);
|
||||
this->lineHeight = 0;
|
||||
this->line++;
|
||||
this->currentX_ = 0;
|
||||
this->currentY_ += this->lineHeight_;
|
||||
this->height_ = this->currentY_ + (this->margin.bottom * this->scale_);
|
||||
this->lineHeight_ = 0;
|
||||
this->line_++;
|
||||
}
|
||||
|
||||
bool MessageLayoutContainer::atStartOfLine()
|
||||
{
|
||||
return this->lineStart == this->elements.size();
|
||||
return this->lineStart_ == this->elements_.size();
|
||||
}
|
||||
|
||||
bool MessageLayoutContainer::fitsInLine(int _width)
|
||||
{
|
||||
return this->currentX + _width <=
|
||||
(this->width - this->margin.left - this->margin.right -
|
||||
(this->line + 1 == MAX_UNCOLLAPSED_LINES ? this->dotdotdotWidth : 0));
|
||||
return this->currentX_ + _width <=
|
||||
(this->width_ - this->margin.left - this->margin.right -
|
||||
(this->line_ + 1 == MAX_UNCOLLAPSED_LINES ? this->dotdotdotWidth_ : 0));
|
||||
}
|
||||
|
||||
void MessageLayoutContainer::end()
|
||||
|
@ -188,42 +188,42 @@ void MessageLayoutContainer::end()
|
|||
static QString dotdotdotText("...");
|
||||
|
||||
auto *element = new TextLayoutElement(
|
||||
dotdotdot, dotdotdotText, QSize(this->dotdotdotWidth, this->textLineHeight),
|
||||
QColor("#00D80A"), FontStyle::ChatMediumBold, this->scale);
|
||||
dotdotdot, dotdotdotText, QSize(this->dotdotdotWidth_, this->textLineHeight_),
|
||||
QColor("#00D80A"), FontStyle::ChatMediumBold, this->scale_);
|
||||
|
||||
// getApp()->themes->messages.textColors.system
|
||||
this->_addElement(element, true);
|
||||
this->_isCollapsed = true;
|
||||
this->isCollapsed_ = true;
|
||||
}
|
||||
|
||||
if (!this->atStartOfLine()) {
|
||||
this->breakLine();
|
||||
}
|
||||
|
||||
this->height += this->lineHeight;
|
||||
this->height_ += this->lineHeight_;
|
||||
|
||||
if (this->lines.size() != 0) {
|
||||
this->lines[0].rect.setTop(-100000);
|
||||
this->lines.back().rect.setBottom(100000);
|
||||
this->lines.back().endIndex = this->elements.size();
|
||||
this->lines.back().endCharIndex = this->charIndex;
|
||||
if (this->lines_.size() != 0) {
|
||||
this->lines_[0].rect.setTop(-100000);
|
||||
this->lines_.back().rect.setBottom(100000);
|
||||
this->lines_.back().endIndex = this->elements_.size();
|
||||
this->lines_.back().endCharIndex = this->charIndex_;
|
||||
}
|
||||
}
|
||||
|
||||
bool MessageLayoutContainer::canCollapse()
|
||||
{
|
||||
return getApp()->settings->collpseMessagesMinLines.getValue() > 0 &&
|
||||
this->flags & Message::MessageFlags::Collapsed;
|
||||
this->flags_ & Message::MessageFlags::Collapsed;
|
||||
}
|
||||
|
||||
bool MessageLayoutContainer::isCollapsed()
|
||||
{
|
||||
return this->_isCollapsed;
|
||||
return this->isCollapsed_;
|
||||
}
|
||||
|
||||
MessageLayoutElement *MessageLayoutContainer::getElementAt(QPoint point)
|
||||
{
|
||||
for (std::unique_ptr<MessageLayoutElement> &element : this->elements) {
|
||||
for (std::unique_ptr<MessageLayoutElement> &element : this->elements_) {
|
||||
if (element->getRect().contains(point)) {
|
||||
return element.get();
|
||||
}
|
||||
|
@ -235,7 +235,7 @@ MessageLayoutElement *MessageLayoutContainer::getElementAt(QPoint point)
|
|||
// painting
|
||||
void MessageLayoutContainer::paintElements(QPainter &painter)
|
||||
{
|
||||
for (const std::unique_ptr<MessageLayoutElement> &element : this->elements) {
|
||||
for (const std::unique_ptr<MessageLayoutElement> &element : this->elements_) {
|
||||
#ifdef FOURTF
|
||||
painter.setPen(QColor(0, 255, 0));
|
||||
painter.drawRect(element->getRect());
|
||||
|
@ -247,7 +247,7 @@ void MessageLayoutContainer::paintElements(QPainter &painter)
|
|||
|
||||
void MessageLayoutContainer::paintAnimatedElements(QPainter &painter, int yOffset)
|
||||
{
|
||||
for (const std::unique_ptr<MessageLayoutElement> &element : this->elements) {
|
||||
for (const std::unique_ptr<MessageLayoutElement> &element : this->elements_) {
|
||||
element->paintAnimated(painter, yOffset);
|
||||
}
|
||||
}
|
||||
|
@ -267,13 +267,13 @@ void MessageLayoutContainer::paintSelection(QPainter &painter, int messageIndex,
|
|||
// fully selected
|
||||
if (selection.selectionMin.messageIndex < messageIndex &&
|
||||
selection.selectionMax.messageIndex > messageIndex) {
|
||||
for (Line &line : this->lines) {
|
||||
for (Line &line : this->lines_) {
|
||||
QRect rect = line.rect;
|
||||
|
||||
rect.setTop(std::max(0, rect.top()) + yOffset);
|
||||
rect.setBottom(std::min(this->height, rect.bottom()) + yOffset);
|
||||
rect.setLeft(this->elements[line.startIndex]->getRect().left());
|
||||
rect.setRight(this->elements[line.endIndex - 1]->getRect().right());
|
||||
rect.setBottom(std::min(this->height_, rect.bottom()) + yOffset);
|
||||
rect.setLeft(this->elements_[line.startIndex]->getRect().left());
|
||||
rect.setRight(this->elements_[line.endIndex - 1]->getRect().right());
|
||||
|
||||
painter.fillRect(rect, selectionColor);
|
||||
}
|
||||
|
@ -285,24 +285,24 @@ void MessageLayoutContainer::paintSelection(QPainter &painter, int messageIndex,
|
|||
|
||||
// start in this message
|
||||
if (selection.selectionMin.messageIndex == messageIndex) {
|
||||
for (; lineIndex < this->lines.size(); lineIndex++) {
|
||||
Line &line = this->lines[lineIndex];
|
||||
for (; lineIndex < this->lines_.size(); lineIndex++) {
|
||||
Line &line = this->lines_[lineIndex];
|
||||
index = line.startCharIndex;
|
||||
|
||||
bool returnAfter = false;
|
||||
bool breakAfter = false;
|
||||
int x = this->elements[line.startIndex]->getRect().left();
|
||||
int r = this->elements[line.endIndex - 1]->getRect().right();
|
||||
int x = this->elements_[line.startIndex]->getRect().left();
|
||||
int r = this->elements_[line.endIndex - 1]->getRect().right();
|
||||
|
||||
if (line.endCharIndex < selection.selectionMin.charIndex) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int i = line.startIndex; i < line.endIndex; i++) {
|
||||
int c = this->elements[i]->getSelectionIndexCount();
|
||||
int c = this->elements_[i]->getSelectionIndexCount();
|
||||
|
||||
if (index + c > selection.selectionMin.charIndex) {
|
||||
x = this->elements[i]->getXFromIndex(selection.selectionMin.charIndex - index);
|
||||
x = this->elements_[i]->getXFromIndex(selection.selectionMin.charIndex - index);
|
||||
|
||||
// ends in same line
|
||||
if (selection.selectionMax.messageIndex == messageIndex &&
|
||||
|
@ -311,10 +311,10 @@ void MessageLayoutContainer::paintSelection(QPainter &painter, int messageIndex,
|
|||
returnAfter = true;
|
||||
index = line.startCharIndex;
|
||||
for (int i = line.startIndex; i < line.endIndex; i++) {
|
||||
int c = this->elements[i]->getSelectionIndexCount();
|
||||
int c = this->elements_[i]->getSelectionIndexCount();
|
||||
|
||||
if (index + c > selection.selectionMax.charIndex) {
|
||||
r = this->elements[i]->getXFromIndex(
|
||||
r = this->elements_[i]->getXFromIndex(
|
||||
selection.selectionMax.charIndex - index);
|
||||
break;
|
||||
}
|
||||
|
@ -325,14 +325,14 @@ void MessageLayoutContainer::paintSelection(QPainter &painter, int messageIndex,
|
|||
|
||||
if (selection.selectionMax.messageIndex != messageIndex) {
|
||||
int lineIndex2 = lineIndex + 1;
|
||||
for (; lineIndex2 < this->lines.size(); lineIndex2++) {
|
||||
Line &line = this->lines[lineIndex2];
|
||||
for (; lineIndex2 < this->lines_.size(); lineIndex2++) {
|
||||
Line &line = this->lines_[lineIndex2];
|
||||
QRect rect = line.rect;
|
||||
|
||||
rect.setTop(std::max(0, rect.top()) + yOffset);
|
||||
rect.setBottom(std::min(this->height, rect.bottom()) + yOffset);
|
||||
rect.setLeft(this->elements[line.startIndex]->getRect().left());
|
||||
rect.setRight(this->elements[line.endIndex - 1]->getRect().right());
|
||||
rect.setBottom(std::min(this->height_, rect.bottom()) + yOffset);
|
||||
rect.setLeft(this->elements_[line.startIndex]->getRect().left());
|
||||
rect.setRight(this->elements_[line.endIndex - 1]->getRect().right());
|
||||
|
||||
painter.fillRect(rect, selectionColor);
|
||||
}
|
||||
|
@ -350,7 +350,7 @@ void MessageLayoutContainer::paintSelection(QPainter &painter, int messageIndex,
|
|||
QRect rect = line.rect;
|
||||
|
||||
rect.setTop(std::max(0, rect.top()) + yOffset);
|
||||
rect.setBottom(std::min(this->height, rect.bottom()) + yOffset);
|
||||
rect.setBottom(std::min(this->height_, rect.bottom()) + yOffset);
|
||||
rect.setLeft(x);
|
||||
rect.setRight(r);
|
||||
|
||||
|
@ -367,8 +367,8 @@ void MessageLayoutContainer::paintSelection(QPainter &painter, int messageIndex,
|
|||
}
|
||||
|
||||
// start in this message
|
||||
for (; lineIndex < this->lines.size(); lineIndex++) {
|
||||
Line &line = this->lines[lineIndex];
|
||||
for (; lineIndex < this->lines_.size(); lineIndex++) {
|
||||
Line &line = this->lines_[lineIndex];
|
||||
index = line.startCharIndex;
|
||||
|
||||
// just draw the garbage
|
||||
|
@ -376,21 +376,21 @@ void MessageLayoutContainer::paintSelection(QPainter &painter, int messageIndex,
|
|||
QRect rect = line.rect;
|
||||
|
||||
rect.setTop(std::max(0, rect.top()) + yOffset);
|
||||
rect.setBottom(std::min(this->height, rect.bottom()) + yOffset);
|
||||
rect.setLeft(this->elements[line.startIndex]->getRect().left());
|
||||
rect.setRight(this->elements[line.endIndex - 1]->getRect().right());
|
||||
rect.setBottom(std::min(this->height_, rect.bottom()) + yOffset);
|
||||
rect.setLeft(this->elements_[line.startIndex]->getRect().left());
|
||||
rect.setRight(this->elements_[line.endIndex - 1]->getRect().right());
|
||||
|
||||
painter.fillRect(rect, selectionColor);
|
||||
continue;
|
||||
}
|
||||
|
||||
int r = this->elements[line.endIndex - 1]->getRect().right();
|
||||
int r = this->elements_[line.endIndex - 1]->getRect().right();
|
||||
|
||||
for (int i = line.startIndex; i < line.endIndex; i++) {
|
||||
int c = this->elements[i]->getSelectionIndexCount();
|
||||
int c = this->elements_[i]->getSelectionIndexCount();
|
||||
|
||||
if (index + c > selection.selectionMax.charIndex) {
|
||||
r = this->elements[i]->getXFromIndex(selection.selectionMax.charIndex - index);
|
||||
r = this->elements_[i]->getXFromIndex(selection.selectionMax.charIndex - index);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -400,8 +400,8 @@ void MessageLayoutContainer::paintSelection(QPainter &painter, int messageIndex,
|
|||
QRect rect = line.rect;
|
||||
|
||||
rect.setTop(std::max(0, rect.top()) + yOffset);
|
||||
rect.setBottom(std::min(this->height, rect.bottom()) + yOffset);
|
||||
rect.setLeft(this->elements[line.startIndex]->getRect().left());
|
||||
rect.setBottom(std::min(this->height_, rect.bottom()) + yOffset);
|
||||
rect.setLeft(this->elements_[line.startIndex]->getRect().left());
|
||||
rect.setRight(r);
|
||||
|
||||
painter.fillRect(rect, selectionColor);
|
||||
|
@ -412,23 +412,23 @@ void MessageLayoutContainer::paintSelection(QPainter &painter, int messageIndex,
|
|||
// selection
|
||||
int MessageLayoutContainer::getSelectionIndex(QPoint point)
|
||||
{
|
||||
if (this->elements.size() == 0) {
|
||||
if (this->elements_.size() == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto line = this->lines.begin();
|
||||
auto line = this->lines_.begin();
|
||||
|
||||
for (; line != this->lines.end(); line++) {
|
||||
for (; line != this->lines_.end(); line++) {
|
||||
if (line->rect.contains(point)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int lineStart = line == this->lines.end() ? this->lines.back().startIndex : line->startIndex;
|
||||
if (line != this->lines.end()) {
|
||||
int lineStart = line == this->lines_.end() ? this->lines_.back().startIndex : line->startIndex;
|
||||
if (line != this->lines_.end()) {
|
||||
line++;
|
||||
}
|
||||
int lineEnd = line == this->lines.end() ? this->elements.size() : line->startIndex;
|
||||
int lineEnd = line == this->lines_.end() ? this->elements_.size() : line->startIndex;
|
||||
|
||||
int index = 0;
|
||||
|
||||
|
@ -440,17 +440,17 @@ int MessageLayoutContainer::getSelectionIndex(QPoint point)
|
|||
|
||||
// before line
|
||||
if (i < lineStart) {
|
||||
index += this->elements[i]->getSelectionIndexCount();
|
||||
index += this->elements_[i]->getSelectionIndexCount();
|
||||
continue;
|
||||
}
|
||||
|
||||
// this is the word
|
||||
if (point.x() < this->elements[i]->getRect().right()) {
|
||||
index += this->elements[i]->getMouseOverIndex(point);
|
||||
if (point.x() < this->elements_[i]->getRect().right()) {
|
||||
index += this->elements_[i]->getMouseOverIndex(point);
|
||||
break;
|
||||
}
|
||||
|
||||
index += this->elements[i]->getSelectionIndexCount();
|
||||
index += this->elements_[i]->getSelectionIndexCount();
|
||||
}
|
||||
|
||||
return index;
|
||||
|
@ -459,10 +459,10 @@ int MessageLayoutContainer::getSelectionIndex(QPoint point)
|
|||
// fourtf: no idea if this is acurate LOL
|
||||
int MessageLayoutContainer::getLastCharacterIndex() const
|
||||
{
|
||||
if (this->lines.size() == 0) {
|
||||
if (this->lines_.size() == 0) {
|
||||
return 0;
|
||||
}
|
||||
return this->lines.back().endCharIndex;
|
||||
return this->lines_.back().endCharIndex;
|
||||
}
|
||||
|
||||
void MessageLayoutContainer::addSelectionText(QString &str, int from, int to)
|
||||
|
@ -470,7 +470,7 @@ void MessageLayoutContainer::addSelectionText(QString &str, int from, int to)
|
|||
int index = 0;
|
||||
bool first = true;
|
||||
|
||||
for (std::unique_ptr<MessageLayoutElement> &ele : this->elements) {
|
||||
for (std::unique_ptr<MessageLayoutElement> &ele : this->elements_) {
|
||||
int c = ele->getSelectionIndexCount();
|
||||
|
||||
if (first) {
|
||||
|
|
|
@ -51,7 +51,7 @@ struct MessageLayoutContainer {
|
|||
float getScale() const;
|
||||
|
||||
// methods
|
||||
void begin(int width, float scale, Message::MessageFlags flags);
|
||||
void begin(int width_, float scale_, Message::MessageFlags flags_);
|
||||
void end();
|
||||
|
||||
void clear();
|
||||
|
@ -60,7 +60,7 @@ struct MessageLayoutContainer {
|
|||
void addElementNoLineBreak(MessageLayoutElement *element);
|
||||
void breakLine();
|
||||
bool atStartOfLine();
|
||||
bool fitsInLine(int width);
|
||||
bool fitsInLine(int width_);
|
||||
MessageLayoutElement *getElementAt(QPoint point);
|
||||
|
||||
// painting
|
||||
|
@ -86,28 +86,27 @@ private:
|
|||
|
||||
// helpers
|
||||
void _addElement(MessageLayoutElement *element, bool forceAdd = false);
|
||||
|
||||
// variables
|
||||
float scale = 1.f;
|
||||
int width = 0;
|
||||
Message::MessageFlags flags = Message::MessageFlags::None;
|
||||
int line = 0;
|
||||
int height = 0;
|
||||
int currentX = 0;
|
||||
int currentY = 0;
|
||||
int charIndex = 0;
|
||||
size_t lineStart = 0;
|
||||
int lineHeight = 0;
|
||||
int spaceWidth = 4;
|
||||
int textLineHeight = 0;
|
||||
int dotdotdotWidth = 0;
|
||||
bool _canAddMessages = true;
|
||||
bool _isCollapsed = false;
|
||||
|
||||
bool canCollapse();
|
||||
|
||||
std::vector<std::unique_ptr<MessageLayoutElement>> elements;
|
||||
std::vector<Line> lines;
|
||||
// variables
|
||||
float scale_ = 1.f;
|
||||
int width_ = 0;
|
||||
Message::MessageFlags flags_ = Message::MessageFlags::None;
|
||||
int line_ = 0;
|
||||
int height_ = 0;
|
||||
int currentX_ = 0;
|
||||
int currentY_ = 0;
|
||||
int charIndex_ = 0;
|
||||
size_t lineStart_ = 0;
|
||||
int lineHeight_ = 0;
|
||||
int spaceWidth_ = 4;
|
||||
int textLineHeight_ = 0;
|
||||
int dotdotdotWidth_ = 0;
|
||||
bool canAddMessages_ = true;
|
||||
bool isCollapsed_ = false;
|
||||
|
||||
std::vector<std::unique_ptr<MessageLayoutElement>> elements_;
|
||||
std::vector<Line> lines_;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -11,13 +11,13 @@ namespace chatterino {
|
|||
|
||||
const QRect &MessageLayoutElement::getRect() const
|
||||
{
|
||||
return this->rect;
|
||||
return this->rect_;
|
||||
}
|
||||
|
||||
MessageLayoutElement::MessageLayoutElement(MessageElement &_creator, const QSize &size)
|
||||
: creator(_creator)
|
||||
MessageLayoutElement::MessageLayoutElement(MessageElement &creator, const QSize &size)
|
||||
: creator_(creator)
|
||||
{
|
||||
this->rect.setSize(size);
|
||||
this->rect_.setSize(size);
|
||||
DebugCount::increase("message layout elements");
|
||||
}
|
||||
|
||||
|
@ -28,12 +28,12 @@ MessageLayoutElement::~MessageLayoutElement()
|
|||
|
||||
MessageElement &MessageLayoutElement::getCreator() const
|
||||
{
|
||||
return this->creator;
|
||||
return this->creator_;
|
||||
}
|
||||
|
||||
void MessageLayoutElement::setPosition(QPoint point)
|
||||
{
|
||||
this->rect.moveTopLeft(point);
|
||||
this->rect_.moveTopLeft(point);
|
||||
}
|
||||
|
||||
bool MessageLayoutElement::hasTrailingSpace() const
|
||||
|
@ -50,13 +50,13 @@ MessageLayoutElement *MessageLayoutElement::setTrailingSpace(bool value)
|
|||
|
||||
MessageLayoutElement *MessageLayoutElement::setLink(const Link &_link)
|
||||
{
|
||||
this->link = _link;
|
||||
this->link_ = _link;
|
||||
return this;
|
||||
}
|
||||
|
||||
const Link &MessageLayoutElement::getLink() const
|
||||
{
|
||||
return this->link;
|
||||
return this->link_;
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -20,7 +20,7 @@ class Image;
|
|||
class MessageLayoutElement : boost::noncopyable
|
||||
{
|
||||
public:
|
||||
MessageLayoutElement(MessageElement &creator, const QSize &size);
|
||||
MessageLayoutElement(MessageElement &creator_, const QSize &size);
|
||||
virtual ~MessageLayoutElement();
|
||||
|
||||
const QRect &getRect() const;
|
||||
|
@ -29,7 +29,7 @@ public:
|
|||
bool hasTrailingSpace() const;
|
||||
|
||||
MessageLayoutElement *setTrailingSpace(bool value);
|
||||
MessageLayoutElement *setLink(const Link &link);
|
||||
MessageLayoutElement *setLink(const Link &link_);
|
||||
|
||||
virtual void addCopyTextToString(QString &str, int from = 0, int to = INT_MAX) const = 0;
|
||||
virtual int getSelectionIndexCount() = 0;
|
||||
|
@ -43,16 +43,16 @@ protected:
|
|||
bool trailingSpace = true;
|
||||
|
||||
private:
|
||||
QRect rect;
|
||||
Link link;
|
||||
MessageElement &creator;
|
||||
QRect rect_;
|
||||
Link link_;
|
||||
MessageElement &creator_;
|
||||
};
|
||||
|
||||
// IMAGE
|
||||
class ImageLayoutElement : public MessageLayoutElement
|
||||
{
|
||||
public:
|
||||
ImageLayoutElement(MessageElement &creator, Image *image, const QSize &size);
|
||||
ImageLayoutElement(MessageElement &creator_, Image *image, const QSize &size);
|
||||
|
||||
protected:
|
||||
void addCopyTextToString(QString &str, int from = 0, int to = INT_MAX) const override;
|
||||
|
@ -70,7 +70,7 @@ private:
|
|||
class TextLayoutElement : public MessageLayoutElement
|
||||
{
|
||||
public:
|
||||
TextLayoutElement(MessageElement &creator, QString &text, const QSize &size, QColor color,
|
||||
TextLayoutElement(MessageElement &creator_, QString &text, const QSize &size, QColor color,
|
||||
FontStyle style, float scale);
|
||||
|
||||
protected:
|
||||
|
@ -93,7 +93,7 @@ private:
|
|||
class TextIconLayoutElement : public MessageLayoutElement
|
||||
{
|
||||
public:
|
||||
TextIconLayoutElement(MessageElement &creator, const QString &line1, const QString &line2,
|
||||
TextIconLayoutElement(MessageElement &creator_, const QString &line1, const QString &line2,
|
||||
float scale, const QSize &size);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -85,7 +85,7 @@ void BTTVEmotes::loadChannelEmotes(const QString &channelName, std::weak_ptr<Emo
|
|||
QString code = emoteObject.value("code").toString();
|
||||
// emoteObject.value("imageType").toString();
|
||||
|
||||
auto emote = this->channelEmoteCache.getOrAdd(id, [&] {
|
||||
auto emote = this->channelEmoteCache_.getOrAdd(id, [&] {
|
||||
EmoteData emoteData;
|
||||
QString link = linkTemplate;
|
||||
link.detach();
|
||||
|
|
|
@ -21,7 +21,7 @@ public:
|
|||
void loadChannelEmotes(const QString &channelName, std::weak_ptr<EmoteMap> channelEmoteMap);
|
||||
|
||||
private:
|
||||
EmoteMap channelEmoteCache;
|
||||
EmoteMap channelEmoteCache_;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -121,11 +121,11 @@ void Emojis::loadEmojis()
|
|||
parseEmoji(emojiData, unparsedEmoji);
|
||||
|
||||
for (const auto &shortCode : emojiData->shortCodes) {
|
||||
this->emojiShortCodeToEmoji.insert(shortCode, emojiData);
|
||||
this->emojiShortCodeToEmoji_.insert(shortCode, emojiData);
|
||||
this->shortCodes.emplace_back(shortCode);
|
||||
}
|
||||
|
||||
this->emojiFirstByte[emojiData->value.at(0)].append(emojiData);
|
||||
this->emojiFirstByte_[emojiData->value.at(0)].append(emojiData);
|
||||
|
||||
this->emojis.insert(emojiData->unifiedCode, emojiData);
|
||||
|
||||
|
@ -145,11 +145,11 @@ void Emojis::loadEmojis()
|
|||
parseEmoji(variationEmojiData, variation,
|
||||
emojiData->shortCodes[0] + "_" + toneNameIt->second);
|
||||
|
||||
this->emojiShortCodeToEmoji.insert(variationEmojiData->shortCodes[0],
|
||||
this->emojiShortCodeToEmoji_.insert(variationEmojiData->shortCodes[0],
|
||||
variationEmojiData);
|
||||
this->shortCodes.push_back(variationEmojiData->shortCodes[0]);
|
||||
|
||||
this->emojiFirstByte[variationEmojiData->value.at(0)].append(variationEmojiData);
|
||||
this->emojiFirstByte_[variationEmojiData->value.at(0)].append(variationEmojiData);
|
||||
|
||||
this->emojis.insert(variationEmojiData->unifiedCode, variationEmojiData);
|
||||
}
|
||||
|
@ -179,8 +179,8 @@ void Emojis::loadEmojiOne2Capabilities()
|
|||
|
||||
QString shortCode = parts[0];
|
||||
|
||||
auto emojiIt = this->emojiShortCodeToEmoji.find(shortCode);
|
||||
if (emojiIt != this->emojiShortCodeToEmoji.end()) {
|
||||
auto emojiIt = this->emojiShortCodeToEmoji_.find(shortCode);
|
||||
if (emojiIt != this->emojiShortCodeToEmoji_.end()) {
|
||||
std::shared_ptr<EmojiData> emoji = *emojiIt;
|
||||
emoji->capabilities.insert("EmojiOne 2");
|
||||
continue;
|
||||
|
@ -190,7 +190,7 @@ void Emojis::loadEmojiOne2Capabilities()
|
|||
|
||||
void Emojis::sortEmojis()
|
||||
{
|
||||
for (auto &p : this->emojiFirstByte) {
|
||||
for (auto &p : this->emojiFirstByte_) {
|
||||
std::stable_sort(p.begin(), p.end(), [](const auto &lhs, const auto &rhs) {
|
||||
return lhs->value.length() > rhs->value.length();
|
||||
});
|
||||
|
@ -277,8 +277,8 @@ void Emojis::parse(std::vector<std::tuple<EmoteData, QString>> &parsedWords, con
|
|||
continue;
|
||||
}
|
||||
|
||||
auto it = this->emojiFirstByte.find(character);
|
||||
if (it == this->emojiFirstByte.end()) {
|
||||
auto it = this->emojiFirstByte_.find(character);
|
||||
if (it == this->emojiFirstByte_.end()) {
|
||||
// No emoji starts with this character
|
||||
continue;
|
||||
}
|
||||
|
@ -348,7 +348,7 @@ void Emojis::parse(std::vector<std::tuple<EmoteData, QString>> &parsedWords, con
|
|||
QString Emojis::replaceShortCodes(const QString &text)
|
||||
{
|
||||
QString ret(text);
|
||||
auto it = this->findShortCodesRegex.globalMatch(text);
|
||||
auto it = this->findShortCodesRegex_.globalMatch(text);
|
||||
|
||||
int32_t offset = 0;
|
||||
|
||||
|
@ -359,9 +359,9 @@ QString Emojis::replaceShortCodes(const QString &text)
|
|||
|
||||
QString matchString = capturedString.toLower().mid(1, capturedString.size() - 2);
|
||||
|
||||
auto emojiIt = this->emojiShortCodeToEmoji.constFind(matchString);
|
||||
auto emojiIt = this->emojiShortCodeToEmoji_.constFind(matchString);
|
||||
|
||||
if (emojiIt == this->emojiShortCodeToEmoji.constEnd()) {
|
||||
if (emojiIt == this->emojiShortCodeToEmoji_.constEnd()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,12 +35,12 @@ class Emojis
|
|||
{
|
||||
public:
|
||||
void initialize();
|
||||
void load();
|
||||
void parse(std::vector<std::tuple<EmoteData, QString>> &parsedWords, const QString &text);
|
||||
|
||||
EmojiMap emojis;
|
||||
|
||||
std::vector<QString> shortCodes;
|
||||
|
||||
void load();
|
||||
QString replaceShortCodes(const QString &text);
|
||||
|
||||
private:
|
||||
void loadEmojis();
|
||||
|
@ -48,20 +48,14 @@ private:
|
|||
void sortEmojis();
|
||||
void loadEmojiSet();
|
||||
|
||||
public:
|
||||
QString replaceShortCodes(const QString &text);
|
||||
|
||||
void parse(std::vector<std::tuple<EmoteData, QString>> &parsedWords, const QString &text);
|
||||
|
||||
private:
|
||||
/// Emojis
|
||||
QRegularExpression findShortCodesRegex{":([-+\\w]+):"};
|
||||
QRegularExpression findShortCodesRegex_{":([-+\\w]+):"};
|
||||
|
||||
// shortCodeToEmoji maps strings like "sunglasses" to its emoji
|
||||
QMap<QString, std::shared_ptr<EmojiData>> emojiShortCodeToEmoji;
|
||||
QMap<QString, std::shared_ptr<EmojiData>> emojiShortCodeToEmoji_;
|
||||
|
||||
// Maps the first character of the emoji unicode string to a vector of possible emojis
|
||||
QMap<QChar, QVector<std::shared_ptr<EmojiData>>> emojiFirstByte;
|
||||
QMap<QChar, QVector<std::shared_ptr<EmojiData>>> emojiFirstByte_;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -112,7 +112,7 @@ void FFZEmotes::loadChannelEmotes(const QString &channelName, std::weak_ptr<Emot
|
|||
|
||||
QJsonObject urls = emoteObject.value("urls").toObject();
|
||||
|
||||
auto emote = this->channelEmoteCache.getOrAdd(id, [id, &code, &urls] {
|
||||
auto emote = this->channelEmoteCache_.getOrAdd(id, [id, &code, &urls] {
|
||||
EmoteData emoteData;
|
||||
fillInEmoteData(urls, code, code + "<br/>Channel FFZ Emote", emoteData);
|
||||
emoteData.pageLink =
|
||||
|
|
|
@ -21,7 +21,7 @@ public:
|
|||
void loadChannelEmotes(const QString &channelName, std::weak_ptr<EmoteMap> channelEmoteMap);
|
||||
|
||||
private:
|
||||
ConcurrentMap<int, EmoteData> channelEmoteCache;
|
||||
ConcurrentMap<int, EmoteData> channelEmoteCache_;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -8,23 +8,23 @@ struct EmoteValue {
|
|||
public:
|
||||
int getSet()
|
||||
{
|
||||
return _set;
|
||||
return set_;
|
||||
}
|
||||
|
||||
int getId()
|
||||
{
|
||||
return _id;
|
||||
return id_;
|
||||
}
|
||||
|
||||
const QString &getChannelName()
|
||||
{
|
||||
return _channelName;
|
||||
return channelName_;
|
||||
}
|
||||
|
||||
private:
|
||||
int _set;
|
||||
int _id;
|
||||
QString _channelName;
|
||||
int set_;
|
||||
int id_;
|
||||
QString channelName_;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "providers/twitch/Pubsub.hpp"
|
||||
#include "providers/twitch/PubsubClient.hpp"
|
||||
|
||||
#include "debug/Log.hpp"
|
||||
#include "providers/twitch/PubsubActions.hpp"
|
||||
|
@ -24,41 +24,41 @@ static std::map<QString, std::string> sentMessages;
|
|||
|
||||
namespace detail {
|
||||
|
||||
PubSubClient::PubSubClient(WebsocketClient &_websocketClient, WebsocketHandle _handle)
|
||||
: websocketClient(_websocketClient)
|
||||
, handle(_handle)
|
||||
PubSubClient::PubSubClient(WebsocketClient &websocketClient, WebsocketHandle handle)
|
||||
: websocketClient_(websocketClient)
|
||||
, handle_(handle)
|
||||
{
|
||||
}
|
||||
|
||||
void PubSubClient::start()
|
||||
{
|
||||
assert(!this->started);
|
||||
assert(!this->started_);
|
||||
|
||||
this->started = true;
|
||||
this->started_ = true;
|
||||
|
||||
this->ping();
|
||||
}
|
||||
|
||||
void PubSubClient::stop()
|
||||
{
|
||||
assert(this->started);
|
||||
assert(this->started_);
|
||||
|
||||
this->started = false;
|
||||
this->started_ = false;
|
||||
}
|
||||
|
||||
bool PubSubClient::listen(rapidjson::Document &message)
|
||||
{
|
||||
int numRequestedListens = message["data"]["topics"].Size();
|
||||
|
||||
if (this->numListens + numRequestedListens > MAX_PUBSUB_LISTENS) {
|
||||
if (this->numListens_ + numRequestedListens > MAX_PUBSUB_LISTENS) {
|
||||
// This PubSubClient is already at its peak listens
|
||||
return false;
|
||||
}
|
||||
|
||||
this->numListens += numRequestedListens;
|
||||
this->numListens_ += numRequestedListens;
|
||||
|
||||
for (const auto &topic : message["data"]["topics"].GetArray()) {
|
||||
this->listeners.emplace_back(Listener{topic.GetString(), false, false, false});
|
||||
this->listeners_.emplace_back(Listener{topic.GetString(), false, false, false});
|
||||
}
|
||||
|
||||
auto uuid = CreateUUID();
|
||||
|
@ -77,11 +77,11 @@ void PubSubClient::unlistenPrefix(const std::string &prefix)
|
|||
{
|
||||
std::vector<std::string> topics;
|
||||
|
||||
for (auto it = this->listeners.begin(); it != this->listeners.end();) {
|
||||
for (auto it = this->listeners_.begin(); it != this->listeners_.end();) {
|
||||
const auto &listener = *it;
|
||||
if (listener.topic.find(prefix) == 0) {
|
||||
topics.push_back(listener.topic);
|
||||
it = this->listeners.erase(it);
|
||||
it = this->listeners_.erase(it);
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
|
@ -105,16 +105,16 @@ void PubSubClient::unlistenPrefix(const std::string &prefix)
|
|||
|
||||
void PubSubClient::handlePong()
|
||||
{
|
||||
assert(this->awaitingPong);
|
||||
assert(this->awaitingPong_);
|
||||
|
||||
Log("Got pong!");
|
||||
|
||||
this->awaitingPong = false;
|
||||
this->awaitingPong_ = false;
|
||||
}
|
||||
|
||||
bool PubSubClient::isListeningToTopic(const std::string &payload)
|
||||
{
|
||||
for (const auto &listener : this->listeners) {
|
||||
for (const auto &listener : this->listeners_) {
|
||||
if (listener.topic == payload) {
|
||||
return true;
|
||||
}
|
||||
|
@ -125,29 +125,29 @@ bool PubSubClient::isListeningToTopic(const std::string &payload)
|
|||
|
||||
void PubSubClient::ping()
|
||||
{
|
||||
assert(this->started);
|
||||
assert(this->started_);
|
||||
|
||||
if (!this->send(pingPayload)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this->awaitingPong = true;
|
||||
this->awaitingPong_ = true;
|
||||
|
||||
auto self = this->shared_from_this();
|
||||
|
||||
runAfter(this->websocketClient.get_io_service(), std::chrono::seconds(15), [self](auto timer) {
|
||||
if (!self->started) {
|
||||
runAfter(this->websocketClient_.get_io_service(), std::chrono::seconds(15), [self](auto timer) {
|
||||
if (!self->started_) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (self->awaitingPong) {
|
||||
if (self->awaitingPong_) {
|
||||
Log("No pong respnose, disconnect!");
|
||||
// TODO(pajlada): Label this connection as "disconnect me"
|
||||
}
|
||||
});
|
||||
|
||||
runAfter(this->websocketClient.get_io_service(), std::chrono::minutes(5), [self](auto timer) {
|
||||
if (!self->started) {
|
||||
runAfter(this->websocketClient_.get_io_service(), std::chrono::minutes(5), [self](auto timer) {
|
||||
if (!self->started_) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -158,7 +158,7 @@ void PubSubClient::ping()
|
|||
bool PubSubClient::send(const char *payload)
|
||||
{
|
||||
WebsocketErrorCode ec;
|
||||
this->websocketClient.send(this->handle, payload, websocketpp::frame::opcode::text, ec);
|
||||
this->websocketClient_.send(this->handle_, payload, websocketpp::frame::opcode::text, ec);
|
||||
|
||||
if (ec) {
|
||||
Log("Error sending message {}: {}", payload, ec.message());
|
|
@ -40,15 +40,6 @@ struct Listener {
|
|||
|
||||
class PubSubClient : public std::enable_shared_from_this<PubSubClient>
|
||||
{
|
||||
WebsocketClient &websocketClient;
|
||||
WebsocketHandle handle;
|
||||
uint16_t numListens = 0;
|
||||
|
||||
std::vector<Listener> listeners;
|
||||
|
||||
std::atomic<bool> awaitingPong{false};
|
||||
std::atomic<bool> started{false};
|
||||
|
||||
public:
|
||||
PubSubClient(WebsocketClient &_websocketClient, WebsocketHandle _handle);
|
||||
|
||||
|
@ -65,6 +56,15 @@ public:
|
|||
private:
|
||||
void ping();
|
||||
bool send(const char *payload);
|
||||
|
||||
WebsocketClient &websocketClient_;
|
||||
WebsocketHandle handle_;
|
||||
uint16_t numListens_ = 0;
|
||||
|
||||
std::vector<Listener> listeners_;
|
||||
|
||||
std::atomic<bool> awaitingPong_{false};
|
||||
std::atomic<bool> started_{false};
|
||||
};
|
||||
|
||||
} // namespace detail
|
|
@ -8,14 +8,14 @@
|
|||
|
||||
namespace chatterino {
|
||||
|
||||
TwitchAccount::TwitchAccount(const QString &_username, const QString &_oauthToken,
|
||||
const QString &_oauthClient, const QString &_userID)
|
||||
TwitchAccount::TwitchAccount(const QString &username, const QString &oauthToken,
|
||||
const QString &oauthClient, const QString &userID)
|
||||
: Account(ProviderId::Twitch)
|
||||
, oauthClient(_oauthClient)
|
||||
, oauthToken(_oauthToken)
|
||||
, userName(_username)
|
||||
, userId(_userID)
|
||||
, _isAnon(_username == ANONYMOUS_USERNAME)
|
||||
, oauthClient_(oauthClient)
|
||||
, oauthToken_(oauthToken)
|
||||
, userName_(username)
|
||||
, userId_(userID)
|
||||
, isAnon_(username == ANONYMOUS_USERNAME)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -26,49 +26,49 @@ QString TwitchAccount::toString() const
|
|||
|
||||
const QString &TwitchAccount::getUserName() const
|
||||
{
|
||||
return this->userName;
|
||||
return this->userName_;
|
||||
}
|
||||
|
||||
const QString &TwitchAccount::getOAuthClient() const
|
||||
{
|
||||
return this->oauthClient;
|
||||
return this->oauthClient_;
|
||||
}
|
||||
|
||||
const QString &TwitchAccount::getOAuthToken() const
|
||||
{
|
||||
return this->oauthToken;
|
||||
return this->oauthToken_;
|
||||
}
|
||||
|
||||
const QString &TwitchAccount::getUserId() const
|
||||
{
|
||||
return this->userId;
|
||||
return this->userId_;
|
||||
}
|
||||
|
||||
bool TwitchAccount::setOAuthClient(const QString &newClientID)
|
||||
{
|
||||
if (this->oauthClient.compare(newClientID) == 0) {
|
||||
if (this->oauthClient_.compare(newClientID) == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this->oauthClient = newClientID;
|
||||
this->oauthClient_ = newClientID;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TwitchAccount::setOAuthToken(const QString &newOAuthToken)
|
||||
{
|
||||
if (this->oauthToken.compare(newOAuthToken) == 0) {
|
||||
if (this->oauthToken_.compare(newOAuthToken) == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this->oauthToken = newOAuthToken;
|
||||
this->oauthToken_ = newOAuthToken;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TwitchAccount::isAnon() const
|
||||
{
|
||||
return this->_isAnon;
|
||||
return this->isAnon_;
|
||||
}
|
||||
|
||||
void TwitchAccount::loadIgnores()
|
||||
|
@ -95,8 +95,8 @@ void TwitchAccount::loadIgnores()
|
|||
}
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(this->ignoresMutex);
|
||||
this->ignores.clear();
|
||||
std::lock_guard<std::mutex> lock(this->ignoresMutex_);
|
||||
this->ignores_.clear();
|
||||
|
||||
for (const auto &block : blocks.GetArray()) {
|
||||
if (!block.IsObject()) {
|
||||
|
@ -112,7 +112,7 @@ void TwitchAccount::loadIgnores()
|
|||
continue;
|
||||
}
|
||||
|
||||
this->ignores.insert(ignoredUser);
|
||||
this->ignores_.insert(ignoredUser);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -168,9 +168,9 @@ void TwitchAccount::ignoreByID(const QString &targetUserID, const QString &targe
|
|||
return false;
|
||||
}
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(this->ignoresMutex);
|
||||
std::lock_guard<std::mutex> lock(this->ignoresMutex_);
|
||||
|
||||
auto res = this->ignores.insert(ignoredUser);
|
||||
auto res = this->ignores_.insert(ignoredUser);
|
||||
if (!res.second) {
|
||||
const TwitchUser &existingUser = *(res.first);
|
||||
existingUser.update(ignoredUser);
|
||||
|
@ -219,9 +219,9 @@ void TwitchAccount::unignoreByID(
|
|||
TwitchUser ignoredUser;
|
||||
ignoredUser.id = targetUserID;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(this->ignoresMutex);
|
||||
std::lock_guard<std::mutex> lock(this->ignoresMutex_);
|
||||
|
||||
this->ignores.erase(ignoredUser);
|
||||
this->ignores_.erase(ignoredUser);
|
||||
}
|
||||
onFinished(UnignoreResult_Success, "Successfully unignored user " + targetName);
|
||||
|
||||
|
@ -262,9 +262,9 @@ void TwitchAccount::checkFollow(const QString targetUserID,
|
|||
|
||||
std::set<TwitchUser> TwitchAccount::getIgnores() const
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(this->ignoresMutex);
|
||||
std::lock_guard<std::mutex> lock(this->ignoresMutex_);
|
||||
|
||||
return this->ignores;
|
||||
return this->ignores_;
|
||||
}
|
||||
|
||||
void TwitchAccount::loadEmotes(std::function<void(const rapidjson::Document &)> cb)
|
||||
|
|
|
@ -33,7 +33,7 @@ enum FollowResult {
|
|||
class TwitchAccount : public Account
|
||||
{
|
||||
public:
|
||||
TwitchAccount(const QString &username, const QString &oauthToken, const QString &oauthClient,
|
||||
TwitchAccount(const QString &username, const QString &oauthToken_, const QString &oauthClient_,
|
||||
const QString &_userID);
|
||||
|
||||
virtual QString toString() const override;
|
||||
|
@ -73,14 +73,14 @@ public:
|
|||
QColor color;
|
||||
|
||||
private:
|
||||
QString oauthClient;
|
||||
QString oauthToken;
|
||||
QString userName;
|
||||
QString userId;
|
||||
const bool _isAnon;
|
||||
QString oauthClient_;
|
||||
QString oauthToken_;
|
||||
QString userName_;
|
||||
QString userId_;
|
||||
const bool isAnon_;
|
||||
|
||||
mutable std::mutex ignoresMutex;
|
||||
std::set<TwitchUser> ignores;
|
||||
mutable std::mutex ignoresMutex_;
|
||||
std::set<TwitchUser> ignores_;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
namespace chatterino {
|
||||
|
||||
TwitchAccountManager::TwitchAccountManager()
|
||||
: anonymousUser(new TwitchAccount(ANONYMOUS_USERNAME, "", "", ""))
|
||||
: anonymousUser_(new TwitchAccount(ANONYMOUS_USERNAME, "", "", ""))
|
||||
{
|
||||
this->currentUserChanged.connect([this] {
|
||||
auto currentUser = this->getCurrent();
|
||||
|
@ -20,18 +20,18 @@ TwitchAccountManager::TwitchAccountManager()
|
|||
|
||||
std::shared_ptr<TwitchAccount> TwitchAccountManager::getCurrent()
|
||||
{
|
||||
if (!this->currentUser) {
|
||||
return this->anonymousUser;
|
||||
if (!this->currentUser_) {
|
||||
return this->anonymousUser_;
|
||||
}
|
||||
|
||||
return this->currentUser;
|
||||
return this->currentUser_;
|
||||
}
|
||||
|
||||
std::vector<QString> TwitchAccountManager::getUsernames() const
|
||||
{
|
||||
std::vector<QString> userNames;
|
||||
|
||||
std::lock_guard<std::mutex> lock(this->mutex);
|
||||
std::lock_guard<std::mutex> lock(this->mutex_);
|
||||
|
||||
for (const auto &user : this->accounts.getVector()) {
|
||||
userNames.push_back(user->getUserName());
|
||||
|
@ -43,7 +43,7 @@ std::vector<QString> TwitchAccountManager::getUsernames() const
|
|||
std::shared_ptr<TwitchAccount> TwitchAccountManager::findUserByUsername(
|
||||
const QString &username) const
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(this->mutex);
|
||||
std::lock_guard<std::mutex> lock(this->mutex_);
|
||||
|
||||
for (const auto &user : this->accounts.getVector()) {
|
||||
if (username.compare(user->getUserName(), Qt::CaseInsensitive) == 0) {
|
||||
|
@ -124,10 +124,10 @@ void TwitchAccountManager::load()
|
|||
if (user) {
|
||||
Log("[AccountManager:currentUsernameChanged] User successfully updated to {}",
|
||||
newUsername);
|
||||
this->currentUser = user;
|
||||
this->currentUser_ = user;
|
||||
} else {
|
||||
Log("[AccountManager:currentUsernameChanged] User successfully updated to anonymous");
|
||||
this->currentUser = this->anonymousUser;
|
||||
this->currentUser_ = this->anonymousUser_;
|
||||
}
|
||||
|
||||
this->currentUserChanged.invoke();
|
||||
|
@ -136,13 +136,13 @@ void TwitchAccountManager::load()
|
|||
|
||||
bool TwitchAccountManager::isLoggedIn() const
|
||||
{
|
||||
if (!this->currentUser) {
|
||||
if (!this->currentUser_) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Once `TwitchAccount` class has a way to check, we should also return false if the credentials
|
||||
// are incorrect
|
||||
return !this->currentUser->isAnon();
|
||||
return !this->currentUser_->isAnon();
|
||||
}
|
||||
|
||||
bool TwitchAccountManager::removeUser(TwitchAccount *account)
|
||||
|
|
|
@ -59,10 +59,10 @@ private:
|
|||
AddUserResponse addUser(const UserData &data);
|
||||
bool removeUser(TwitchAccount *account);
|
||||
|
||||
std::shared_ptr<TwitchAccount> currentUser;
|
||||
std::shared_ptr<TwitchAccount> currentUser_;
|
||||
|
||||
std::shared_ptr<TwitchAccount> anonymousUser;
|
||||
mutable std::mutex mutex;
|
||||
std::shared_ptr<TwitchAccount> anonymousUser_;
|
||||
mutable std::mutex mutex_;
|
||||
|
||||
friend class AccountController;
|
||||
};
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "common/UrlFetch.hpp"
|
||||
#include "debug/Log.hpp"
|
||||
#include "messages/Message.hpp"
|
||||
#include "providers/twitch/Pubsub.hpp"
|
||||
#include "providers/twitch/PubsubClient.hpp"
|
||||
#include "providers/twitch/TwitchMessageBuilder.hpp"
|
||||
#include "singletons/Emotes.hpp"
|
||||
#include "singletons/Settings.hpp"
|
||||
|
@ -16,15 +16,15 @@
|
|||
|
||||
namespace chatterino {
|
||||
|
||||
TwitchChannel::TwitchChannel(const QString &channelName, Communi::IrcConnection *_readConnection)
|
||||
TwitchChannel::TwitchChannel(const QString &channelName, Communi::IrcConnection *readConnection)
|
||||
: Channel(channelName, Channel::Type::Twitch)
|
||||
, bttvChannelEmotes(new EmoteMap)
|
||||
, ffzChannelEmotes(new EmoteMap)
|
||||
, subscriptionURL("https://www.twitch.tv/subs/" + name)
|
||||
, channelURL("https://twitch.tv/" + name)
|
||||
, popoutPlayerURL("https://player.twitch.tv/?channel=" + name)
|
||||
, mod(false)
|
||||
, readConnection(_readConnection)
|
||||
, mod_(false)
|
||||
, readConnection_(readConnection)
|
||||
{
|
||||
Log("[TwitchChannel:{}] Opened", this->name);
|
||||
|
||||
|
@ -60,8 +60,8 @@ TwitchChannel::TwitchChannel(const QString &channelName, Communi::IrcConnection
|
|||
this->fetchRecentMessages(); //
|
||||
});
|
||||
|
||||
this->messageSuffix.append(' ');
|
||||
this->messageSuffix.append(QChar(0x206D));
|
||||
this->messageSuffix_.append(' ');
|
||||
this->messageSuffix_.append(QChar(0x206D));
|
||||
|
||||
static QStringList jsonLabels = {"moderators", "staff", "admins", "global_mods", "viewers"};
|
||||
auto refreshChatters = [=](QJsonObject obj) {
|
||||
|
@ -161,8 +161,8 @@ void TwitchChannel::sendMessage(const QString &message)
|
|||
|
||||
if (!this->hasModRights()) {
|
||||
if (app->settings->allowDuplicateMessages) {
|
||||
if (parsedMessage == this->lastSentMessage) {
|
||||
parsedMessage.append(this->messageSuffix);
|
||||
if (parsedMessage == this->lastSentMessage_) {
|
||||
parsedMessage.append(this->messageSuffix_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -172,19 +172,19 @@ void TwitchChannel::sendMessage(const QString &message)
|
|||
|
||||
if (messageSent) {
|
||||
qDebug() << "sent";
|
||||
this->lastSentMessage = parsedMessage;
|
||||
this->lastSentMessage_ = parsedMessage;
|
||||
}
|
||||
}
|
||||
|
||||
bool TwitchChannel::isMod() const
|
||||
{
|
||||
return this->mod;
|
||||
return this->mod_;
|
||||
}
|
||||
|
||||
void TwitchChannel::setMod(bool value)
|
||||
{
|
||||
if (this->mod != value) {
|
||||
this->mod = value;
|
||||
if (this->mod_ != value) {
|
||||
this->mod_ = value;
|
||||
|
||||
this->userStateChanged.invoke();
|
||||
}
|
||||
|
@ -201,9 +201,9 @@ void TwitchChannel::addRecentChatter(const std::shared_ptr<Message> &message)
|
|||
{
|
||||
assert(!message->loginName.isEmpty());
|
||||
|
||||
std::lock_guard<std::mutex> lock(this->recentChattersMutex);
|
||||
std::lock_guard<std::mutex> lock(this->recentChattersMutex_);
|
||||
|
||||
this->recentChatters[message->loginName] = {message->displayName, message->localizedName};
|
||||
this->recentChatters_[message->loginName] = {message->displayName, message->localizedName};
|
||||
|
||||
this->completionModel.addUser(message->displayName);
|
||||
}
|
||||
|
@ -216,22 +216,22 @@ void TwitchChannel::addJoinedUser(const QString &user)
|
|||
return;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> guard(this->joinedUserMutex);
|
||||
std::lock_guard<std::mutex> guard(this->joinedUserMutex_);
|
||||
|
||||
joinedUsers << user;
|
||||
joinedUsers_ << user;
|
||||
|
||||
if (!this->joinedUsersMergeQueued) {
|
||||
this->joinedUsersMergeQueued = true;
|
||||
if (!this->joinedUsersMergeQueued_) {
|
||||
this->joinedUsersMergeQueued_ = true;
|
||||
|
||||
QTimer::singleShot(500, &this->object, [this] {
|
||||
std::lock_guard<std::mutex> guard(this->joinedUserMutex);
|
||||
QTimer::singleShot(500, &this->object_, [this] {
|
||||
std::lock_guard<std::mutex> guard(this->joinedUserMutex_);
|
||||
|
||||
auto message =
|
||||
Message::createSystemMessage("Users joined: " + this->joinedUsers.join(", "));
|
||||
Message::createSystemMessage("Users joined: " + this->joinedUsers_.join(", "));
|
||||
message->flags |= Message::Collapsed;
|
||||
this->addMessage(message);
|
||||
this->joinedUsers.clear();
|
||||
this->joinedUsersMergeQueued = false;
|
||||
this->joinedUsers_.clear();
|
||||
this->joinedUsersMergeQueued_ = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -245,39 +245,39 @@ void TwitchChannel::addPartedUser(const QString &user)
|
|||
return;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> guard(this->partedUserMutex);
|
||||
std::lock_guard<std::mutex> guard(this->partedUserMutex_);
|
||||
|
||||
partedUsers << user;
|
||||
partedUsers_ << user;
|
||||
|
||||
if (!this->partedUsersMergeQueued) {
|
||||
this->partedUsersMergeQueued = true;
|
||||
if (!this->partedUsersMergeQueued_) {
|
||||
this->partedUsersMergeQueued_ = true;
|
||||
|
||||
QTimer::singleShot(500, &this->object, [this] {
|
||||
std::lock_guard<std::mutex> guard(this->partedUserMutex);
|
||||
QTimer::singleShot(500, &this->object_, [this] {
|
||||
std::lock_guard<std::mutex> guard(this->partedUserMutex_);
|
||||
|
||||
auto message =
|
||||
Message::createSystemMessage("Users parted: " + this->partedUsers.join(", "));
|
||||
Message::createSystemMessage("Users parted: " + this->partedUsers_.join(", "));
|
||||
message->flags |= Message::Collapsed;
|
||||
this->addMessage(message);
|
||||
this->partedUsers.clear();
|
||||
this->partedUsers_.clear();
|
||||
|
||||
this->partedUsersMergeQueued = false;
|
||||
this->partedUsersMergeQueued_ = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
TwitchChannel::RoomModes TwitchChannel::getRoomModes()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(this->roomModeMutex);
|
||||
std::lock_guard<std::mutex> lock(this->roomModeMutex_);
|
||||
|
||||
return this->roomModes;
|
||||
return this->roomModes_;
|
||||
}
|
||||
|
||||
void TwitchChannel::setRoomModes(const RoomModes &_roomModes)
|
||||
{
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(this->roomModeMutex);
|
||||
this->roomModes = _roomModes;
|
||||
std::lock_guard<std::mutex> lock(this->roomModeMutex_);
|
||||
this->roomModes_ = _roomModes;
|
||||
}
|
||||
|
||||
this->roomModesChanged.invoke();
|
||||
|
@ -285,24 +285,24 @@ void TwitchChannel::setRoomModes(const RoomModes &_roomModes)
|
|||
|
||||
bool TwitchChannel::isLive() const
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(this->streamStatusMutex);
|
||||
return this->streamStatus.live;
|
||||
std::lock_guard<std::mutex> lock(this->streamStatusMutex_);
|
||||
return this->streamStatus_.live;
|
||||
}
|
||||
|
||||
TwitchChannel::StreamStatus TwitchChannel::getStreamStatus() const
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(this->streamStatusMutex);
|
||||
return this->streamStatus;
|
||||
std::lock_guard<std::mutex> lock(this->streamStatusMutex_);
|
||||
return this->streamStatus_;
|
||||
}
|
||||
|
||||
void TwitchChannel::setLive(bool newLiveStatus)
|
||||
{
|
||||
bool gotNewLiveStatus = false;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(this->streamStatusMutex);
|
||||
if (this->streamStatus.live != newLiveStatus) {
|
||||
std::lock_guard<std::mutex> lock(this->streamStatusMutex_);
|
||||
if (this->streamStatus_.live != newLiveStatus) {
|
||||
gotNewLiveStatus = true;
|
||||
this->streamStatus.live = newLiveStatus;
|
||||
this->streamStatus_.live = newLiveStatus;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -369,21 +369,21 @@ void TwitchChannel::refreshLiveStatus()
|
|||
// Stream is live
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(channel->streamStatusMutex);
|
||||
channel->streamStatus.live = true;
|
||||
channel->streamStatus.viewerCount = stream["viewers"].GetUint();
|
||||
channel->streamStatus.game = stream["game"].GetString();
|
||||
channel->streamStatus.title = streamChannel["status"].GetString();
|
||||
std::lock_guard<std::mutex> lock(channel->streamStatusMutex_);
|
||||
channel->streamStatus_.live = true;
|
||||
channel->streamStatus_.viewerCount = stream["viewers"].GetUint();
|
||||
channel->streamStatus_.game = stream["game"].GetString();
|
||||
channel->streamStatus_.title = streamChannel["status"].GetString();
|
||||
QDateTime since = QDateTime::fromString(stream["created_at"].GetString(), Qt::ISODate);
|
||||
auto diff = since.secsTo(QDateTime::currentDateTime());
|
||||
channel->streamStatus.uptime =
|
||||
channel->streamStatus_.uptime =
|
||||
QString::number(diff / 3600) + "h " + QString::number(diff % 3600 / 60) + "m";
|
||||
|
||||
channel->streamStatus.rerun = false;
|
||||
channel->streamStatus_.rerun = false;
|
||||
if (stream.HasMember("stream_type")) {
|
||||
channel->streamStatus.streamType = stream["stream_type"].GetString();
|
||||
channel->streamStatus_.streamType = stream["stream_type"].GetString();
|
||||
} else {
|
||||
channel->streamStatus.streamType = QString();
|
||||
channel->streamStatus_.streamType = QString();
|
||||
}
|
||||
|
||||
if (stream.HasMember("broadcast_platform")) {
|
||||
|
@ -392,7 +392,7 @@ void TwitchChannel::refreshLiveStatus()
|
|||
if (broadcastPlatformValue.IsString()) {
|
||||
const char *broadcastPlatform = stream["broadcast_platform"].GetString();
|
||||
if (strcmp(broadcastPlatform, "rerun") == 0) {
|
||||
channel->streamStatus.rerun = true;
|
||||
channel->streamStatus_.rerun = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -435,7 +435,7 @@ void TwitchChannel::fetchRecentMessages()
|
|||
auto channel = dynamic_cast<TwitchChannel *>(shared.get());
|
||||
assert(channel != nullptr);
|
||||
|
||||
static auto readConnection = channel->readConnection;
|
||||
static auto readConnection = channel->readConnection_;
|
||||
|
||||
QJsonArray msgArray = obj.value("messages").toArray();
|
||||
if (msgArray.empty()) {
|
||||
|
|
|
@ -80,7 +80,7 @@ public:
|
|||
QString roomID;
|
||||
|
||||
RoomModes getRoomModes();
|
||||
void setRoomModes(const RoomModes &roomModes);
|
||||
void setRoomModes(const RoomModes &roomModes_);
|
||||
|
||||
StreamStatus getStreamStatus() const;
|
||||
|
||||
|
@ -97,36 +97,35 @@ private:
|
|||
void setLive(bool newLiveStatus);
|
||||
void refreshLiveStatus();
|
||||
void startRefreshLiveStatusTimer(int intervalMS);
|
||||
|
||||
mutable std::mutex streamStatusMutex;
|
||||
StreamStatus streamStatus;
|
||||
|
||||
mutable std::mutex userStateMutex;
|
||||
UserState userState;
|
||||
|
||||
void fetchRecentMessages();
|
||||
|
||||
bool mod;
|
||||
QByteArray messageSuffix;
|
||||
QString lastSentMessage;
|
||||
RoomModes roomModes;
|
||||
std::mutex roomModeMutex;
|
||||
mutable std::mutex streamStatusMutex_;
|
||||
StreamStatus streamStatus_;
|
||||
|
||||
QObject object;
|
||||
std::mutex joinedUserMutex;
|
||||
QStringList joinedUsers;
|
||||
bool joinedUsersMergeQueued = false;
|
||||
std::mutex partedUserMutex;
|
||||
QStringList partedUsers;
|
||||
bool partedUsersMergeQueued = false;
|
||||
mutable std::mutex userStateMutex_;
|
||||
UserState userState_;
|
||||
|
||||
Communi::IrcConnection *readConnection;
|
||||
bool mod_ = false;
|
||||
QByteArray messageSuffix_;
|
||||
QString lastSentMessage_;
|
||||
RoomModes roomModes_;
|
||||
std::mutex roomModeMutex_;
|
||||
|
||||
friend class TwitchServer;
|
||||
QObject object_;
|
||||
std::mutex joinedUserMutex_;
|
||||
QStringList joinedUsers_;
|
||||
bool joinedUsersMergeQueued_ = false;
|
||||
std::mutex partedUserMutex_;
|
||||
QStringList partedUsers_;
|
||||
bool partedUsersMergeQueued_ = false;
|
||||
|
||||
Communi::IrcConnection *readConnection_ = nullptr;
|
||||
|
||||
// Key = login name
|
||||
std::map<QString, NameOptions> recentChatters;
|
||||
std::mutex recentChattersMutex;
|
||||
std::map<QString, NameOptions> recentChatters_;
|
||||
std::mutex recentChattersMutex_;
|
||||
|
||||
friend class TwitchServer;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -120,7 +120,7 @@ EmoteData TwitchEmotes::getEmoteById(const QString &id, const QString &emoteName
|
|||
_emoteName = it.value();
|
||||
}
|
||||
|
||||
return _twitchEmoteFromCache.getOrAdd(id, [&emoteName, &_emoteName, &id] {
|
||||
return twitchEmoteFromCache_.getOrAdd(id, [&emoteName, &_emoteName, &id] {
|
||||
EmoteData newEmoteData;
|
||||
auto cleanCode = cleanUpCode(emoteName);
|
||||
newEmoteData.image1x =
|
||||
|
|
|
@ -62,10 +62,10 @@ private:
|
|||
void loadSetData(std::shared_ptr<TwitchEmotes::EmoteSet> emoteSet);
|
||||
|
||||
// emote code
|
||||
ConcurrentMap<QString, EmoteValue *> _twitchEmotes;
|
||||
ConcurrentMap<QString, EmoteValue *> twitchEmotes_;
|
||||
|
||||
// emote id
|
||||
ConcurrentMap<QString, EmoteData> _twitchEmoteFromCache;
|
||||
// emote id
|
||||
ConcurrentMap<QString, EmoteData> twitchEmoteFromCache_;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -27,11 +27,11 @@ TwitchMessageBuilder::TwitchMessageBuilder(Channel *_channel,
|
|||
, ircMessage(_ircMessage)
|
||||
, args(_args)
|
||||
, tags(this->ircMessage->tags())
|
||||
, originalMessage(_ircMessage->content())
|
||||
, action(_ircMessage->isAction())
|
||||
, originalMessage_(_ircMessage->content())
|
||||
, action_(_ircMessage->isAction())
|
||||
{
|
||||
auto app = getApp();
|
||||
this->usernameColor = app->themes->messages.textColors.system;
|
||||
this->usernameColor_ = app->themes->messages.textColors.system;
|
||||
}
|
||||
|
||||
TwitchMessageBuilder::TwitchMessageBuilder(Channel *_channel,
|
||||
|
@ -43,11 +43,11 @@ TwitchMessageBuilder::TwitchMessageBuilder(Channel *_channel,
|
|||
, ircMessage(_ircMessage)
|
||||
, args(_args)
|
||||
, tags(this->ircMessage->tags())
|
||||
, originalMessage(content)
|
||||
, action(isAction)
|
||||
, originalMessage_(content)
|
||||
, action_(isAction)
|
||||
{
|
||||
auto app = getApp();
|
||||
this->usernameColor = app->themes->messages.textColors.system;
|
||||
this->usernameColor_ = app->themes->messages.textColors.system;
|
||||
}
|
||||
|
||||
bool TwitchMessageBuilder::isIgnored() const
|
||||
|
@ -56,7 +56,7 @@ bool TwitchMessageBuilder::isIgnored() const
|
|||
|
||||
// TODO(pajlada): Do we need to check if the phrase is valid first?
|
||||
for (const auto &phrase : app->ignores->phrases.getVector()) {
|
||||
if (phrase.isMatch(this->originalMessage)) {
|
||||
if (phrase.isMatch(this->originalMessage_)) {
|
||||
Log("Blocking message because it contains ignored phrase {}", phrase.getPattern());
|
||||
return true;
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ MessagePtr TwitchMessageBuilder::build()
|
|||
// MessageElement::Collapsed);
|
||||
// }
|
||||
//#endif
|
||||
this->message->flags |= Message::Collapsed;
|
||||
this->message_->flags |= Message::Collapsed;
|
||||
|
||||
// PARSING
|
||||
this->parseMessageID();
|
||||
|
@ -181,13 +181,13 @@ MessagePtr TwitchMessageBuilder::build()
|
|||
|
||||
// words
|
||||
|
||||
QStringList splits = this->originalMessage.split(' ');
|
||||
QStringList splits = this->originalMessage_.split(' ');
|
||||
|
||||
long int i = 0;
|
||||
|
||||
for (QString split : splits) {
|
||||
MessageColor textColor =
|
||||
this->action ? MessageColor(this->usernameColor) : MessageColor(MessageColor::Text);
|
||||
this->action_ ? MessageColor(this->usernameColor_) : MessageColor(MessageColor::Text);
|
||||
|
||||
// twitch emote
|
||||
if (currentTwitchEmote != twitchEmotes.end() && currentTwitchEmote->first == i) {
|
||||
|
@ -279,7 +279,7 @@ MessagePtr TwitchMessageBuilder::build()
|
|||
i++;
|
||||
}
|
||||
|
||||
this->message->searchText = this->userName + ": " + this->originalMessage;
|
||||
this->message_->searchText = this->userName + ": " + this->originalMessage_;
|
||||
|
||||
return this->getMessage();
|
||||
}
|
||||
|
@ -302,10 +302,10 @@ void TwitchMessageBuilder::parseRoomID()
|
|||
auto iterator = this->tags.find("room-id");
|
||||
|
||||
if (iterator != std::end(this->tags)) {
|
||||
this->roomID = iterator.value().toString();
|
||||
this->roomID_ = iterator.value().toString();
|
||||
|
||||
if (this->twitchChannel->roomID.isEmpty()) {
|
||||
this->twitchChannel->roomID = this->roomID;
|
||||
this->twitchChannel->roomID = this->roomID_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -323,7 +323,7 @@ void TwitchMessageBuilder::parseUsername()
|
|||
{
|
||||
auto iterator = this->tags.find("color");
|
||||
if (iterator != this->tags.end()) {
|
||||
this->usernameColor = QColor(iterator.value().toString());
|
||||
this->usernameColor_ = QColor(iterator.value().toString());
|
||||
}
|
||||
|
||||
// username
|
||||
|
@ -339,7 +339,7 @@ void TwitchMessageBuilder::parseUsername()
|
|||
// this->userName = displayNameVariant.toString() + " (" + this->userName + ")";
|
||||
// }
|
||||
|
||||
this->message->loginName = this->userName;
|
||||
this->message_->loginName = this->userName;
|
||||
}
|
||||
|
||||
void TwitchMessageBuilder::appendUsername()
|
||||
|
@ -347,7 +347,7 @@ void TwitchMessageBuilder::appendUsername()
|
|||
auto app = getApp();
|
||||
|
||||
QString username = this->userName;
|
||||
this->message->loginName = username;
|
||||
this->message_->loginName = username;
|
||||
QString localizedName;
|
||||
|
||||
auto iterator = this->tags.find("display-name");
|
||||
|
@ -357,12 +357,12 @@ void TwitchMessageBuilder::appendUsername()
|
|||
if (QString::compare(displayName, this->userName, Qt::CaseInsensitive) == 0) {
|
||||
username = displayName;
|
||||
|
||||
this->message->displayName = displayName;
|
||||
this->message_->displayName = displayName;
|
||||
} else {
|
||||
localizedName = displayName;
|
||||
|
||||
this->message->displayName = username;
|
||||
this->message->localizedName = displayName;
|
||||
this->message_->displayName = username;
|
||||
this->message_->localizedName = displayName;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -402,7 +402,7 @@ void TwitchMessageBuilder::appendUsername()
|
|||
// userDisplayString += IrcManager::getInstance().getUser().getUserName();
|
||||
} else if (this->args.isReceivedWhisper) {
|
||||
// Sender username
|
||||
this->emplace<TextElement>(usernameText, MessageElement::Text, this->usernameColor,
|
||||
this->emplace<TextElement>(usernameText, MessageElement::Text, this->usernameColor_,
|
||||
FontStyle::ChatMediumBold)
|
||||
->setLink({Link::UserInfo, this->userName});
|
||||
|
||||
|
@ -421,11 +421,11 @@ void TwitchMessageBuilder::appendUsername()
|
|||
this->emplace<TextElement>(currentUser->getUserName() + ":", MessageElement::Text,
|
||||
selfColor, FontStyle::ChatMediumBold);
|
||||
} else {
|
||||
if (!this->action) {
|
||||
if (!this->action_) {
|
||||
usernameText += ":";
|
||||
}
|
||||
|
||||
this->emplace<TextElement>(usernameText, MessageElement::Text, this->usernameColor,
|
||||
this->emplace<TextElement>(usernameText, MessageElement::Text, this->usernameColor_,
|
||||
FontStyle::ChatMediumBold)
|
||||
->setLink({Link::UserInfo, this->userName});
|
||||
}
|
||||
|
@ -443,7 +443,7 @@ void TwitchMessageBuilder::parseHighlights()
|
|||
QString currentUsername = currentUser->getUserName();
|
||||
|
||||
if (this->ircMessage->nick() == currentUsername) {
|
||||
currentUser->color = this->usernameColor;
|
||||
currentUser->color = this->usernameColor_;
|
||||
// Do nothing. Highlights cannot be triggered by yourself
|
||||
return;
|
||||
}
|
||||
|
@ -481,8 +481,8 @@ void TwitchMessageBuilder::parseHighlights()
|
|||
|
||||
if (!app->highlights->blacklistContains(this->ircMessage->nick())) {
|
||||
for (const HighlightPhrase &highlight : activeHighlights) {
|
||||
if (highlight.isMatch(this->originalMessage)) {
|
||||
Log("Highlight because {} matches {}", this->originalMessage,
|
||||
if (highlight.isMatch(this->originalMessage_)) {
|
||||
Log("Highlight because {} matches {}", this->originalMessage_,
|
||||
highlight.getPattern());
|
||||
doHighlight = true;
|
||||
|
||||
|
@ -533,7 +533,7 @@ void TwitchMessageBuilder::parseHighlights()
|
|||
}
|
||||
|
||||
if (doHighlight) {
|
||||
this->message->flags |= Message::Highlighted;
|
||||
this->message_->flags |= Message::Highlighted;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -567,11 +567,11 @@ void TwitchMessageBuilder::appendTwitchEmote(const Communi::IrcMessage *ircMessa
|
|||
int start = coords.at(0).toInt();
|
||||
int end = coords.at(1).toInt();
|
||||
|
||||
if (start >= end || start < 0 || end > this->originalMessage.length()) {
|
||||
if (start >= end || start < 0 || end > this->originalMessage_.length()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QString name = this->originalMessage.mid(start, end - start + 1);
|
||||
QString name = this->originalMessage_.mid(start, end - start + 1);
|
||||
|
||||
vec.push_back(
|
||||
std::pair<long int, EmoteData>(start, app->emotes->twitch.getEmoteById(id, name)));
|
||||
|
@ -613,7 +613,7 @@ void TwitchMessageBuilder::appendTwitchBadges()
|
|||
{
|
||||
auto app = getApp();
|
||||
|
||||
const auto &channelResources = app->resources->channels[this->roomID];
|
||||
const auto &channelResources = app->resources->channels[this->roomID_];
|
||||
|
||||
auto iterator = this->tags.find("badges");
|
||||
|
||||
|
@ -791,7 +791,7 @@ bool TwitchMessageBuilder::tryParseCheermote(const QString &string)
|
|||
{
|
||||
auto app = getApp();
|
||||
// Try to parse custom cheermotes
|
||||
const auto &channelResources = app->resources->channels[this->roomID];
|
||||
const auto &channelResources = app->resources->channels[this->roomID_];
|
||||
if (channelResources.loaded) {
|
||||
for (const auto &cheermoteSet : channelResources.cheermoteSets) {
|
||||
auto match = cheermoteSet.regex.match(string);
|
||||
|
|
|
@ -28,8 +28,7 @@ public:
|
|||
explicit TwitchMessageBuilder(Channel *_channel, const Communi::IrcPrivateMessage *_ircMessage,
|
||||
const MessageParseArgs &_args);
|
||||
explicit TwitchMessageBuilder(Channel *_channel, const Communi::IrcMessage *_ircMessage,
|
||||
const MessageParseArgs &_args, QString content,
|
||||
bool isAction);
|
||||
const MessageParseArgs &_args, QString content, bool isAction);
|
||||
|
||||
Channel *channel;
|
||||
TwitchChannel *twitchChannel;
|
||||
|
@ -44,14 +43,6 @@ public:
|
|||
MessagePtr build();
|
||||
|
||||
private:
|
||||
QString roomID;
|
||||
|
||||
QColor usernameColor;
|
||||
const QString originalMessage;
|
||||
bool senderIsBroadcaster{};
|
||||
|
||||
const bool action = false;
|
||||
|
||||
void parseMessageID();
|
||||
void parseRoomID();
|
||||
void appendChannelName();
|
||||
|
@ -66,6 +57,14 @@ private:
|
|||
void appendTwitchBadges();
|
||||
void appendChatterinoBadges();
|
||||
bool tryParseCheermote(const QString &string);
|
||||
|
||||
QString roomID_;
|
||||
|
||||
QColor usernameColor_;
|
||||
const QString originalMessage_;
|
||||
bool senderIsBroadcaster{};
|
||||
|
||||
const bool action_ = false;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -42,13 +42,13 @@ protected:
|
|||
QString cleanChannelName(const QString &dirtyChannelName) override;
|
||||
|
||||
private:
|
||||
void onMessageSendRequested(TwitchChannel *channel, const QString &message, bool &sent);
|
||||
|
||||
std::mutex lastMessageMutex_;
|
||||
std::queue<std::chrono::steady_clock::time_point> lastMessagePleb_;
|
||||
std::queue<std::chrono::steady_clock::time_point> lastMessageMod_;
|
||||
std::chrono::steady_clock::time_point lastErrorTimeSpeed_;
|
||||
std::chrono::steady_clock::time_point lastErrorTimeAmount_;
|
||||
|
||||
void onMessageSendRequested(TwitchChannel *channel, const QString &message, bool &sent);
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -35,7 +35,7 @@ Fonts::Fonts()
|
|||
getApp()->windows->incGeneration();
|
||||
}
|
||||
|
||||
for (auto &map : this->fontsByType) {
|
||||
for (auto &map : this->fontsByType_) {
|
||||
map.clear();
|
||||
}
|
||||
this->fontChanged.invoke();
|
||||
|
@ -48,13 +48,13 @@ Fonts::Fonts()
|
|||
getApp()->windows->incGeneration();
|
||||
}
|
||||
|
||||
for (auto &map : this->fontsByType) {
|
||||
for (auto &map : this->fontsByType_) {
|
||||
map.clear();
|
||||
}
|
||||
this->fontChanged.invoke();
|
||||
});
|
||||
|
||||
this->fontsByType.resize(size_t(EndType));
|
||||
this->fontsByType_.resize(size_t(EndType));
|
||||
}
|
||||
|
||||
QFont Fonts::getFont(Fonts::Type type, float scale)
|
||||
|
@ -73,7 +73,7 @@ Fonts::FontData &Fonts::getOrCreateFontData(Type type, float scale)
|
|||
|
||||
assert(type >= 0 && type < EndType);
|
||||
|
||||
auto &map = this->fontsByType[size_t(type)];
|
||||
auto &map = this->fontsByType_[size_t(type)];
|
||||
|
||||
// find element
|
||||
auto it = map.find(scale);
|
||||
|
|
|
@ -74,7 +74,7 @@ private:
|
|||
FontData &getOrCreateFontData(Type type, float scale);
|
||||
FontData createFontData(Type type, float scale);
|
||||
|
||||
std::vector<std::unordered_map<float, FontData>> fontsByType;
|
||||
std::vector<std::unordered_map<float, FontData>> fontsByType_;
|
||||
};
|
||||
|
||||
using FontStyle = Fonts::Type;
|
||||
|
|
|
@ -25,11 +25,11 @@ void Logging::addMessage(const QString &channelName, MessagePtr message)
|
|||
return;
|
||||
}
|
||||
|
||||
auto it = this->loggingChannels.find(channelName);
|
||||
if (it == this->loggingChannels.end()) {
|
||||
auto it = this->loggingChannels_.find(channelName);
|
||||
if (it == this->loggingChannels_.end()) {
|
||||
auto channel = new LoggingChannel(channelName);
|
||||
channel->addMessage(message);
|
||||
this->loggingChannels.emplace(channelName,
|
||||
this->loggingChannels_.emplace(channelName,
|
||||
std::unique_ptr<LoggingChannel>(std::move(channel)));
|
||||
} else {
|
||||
it->second->addMessage(message);
|
||||
|
|
|
@ -23,7 +23,7 @@ public:
|
|||
void addMessage(const QString &channelName, MessagePtr message);
|
||||
|
||||
private:
|
||||
std::map<QString, std::unique_ptr<LoggingChannel>> loggingChannels;
|
||||
std::map<QString, std::unique_ptr<LoggingChannel>> loggingChannels_;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -42,7 +42,7 @@ bool Paths::createFolder(const QString &folderPath)
|
|||
|
||||
bool Paths::isPortable()
|
||||
{
|
||||
return this->portable.get();
|
||||
return this->portable_.get();
|
||||
}
|
||||
|
||||
void Paths::initAppFilePathHash()
|
||||
|
@ -58,13 +58,13 @@ void Paths::initAppFilePathHash()
|
|||
|
||||
void Paths::initCheckPortable()
|
||||
{
|
||||
this->portable =
|
||||
this->portable_ =
|
||||
QFileInfo::exists(combinePath(QCoreApplication::applicationDirPath(), "portable"));
|
||||
}
|
||||
|
||||
void Paths::initAppDataDirectory()
|
||||
{
|
||||
assert(this->portable.is_initialized());
|
||||
assert(this->portable_.is_initialized());
|
||||
|
||||
// Root path = %APPDATA%/Chatterino or the folder that the executable resides in
|
||||
|
||||
|
|
|
@ -36,13 +36,13 @@ public:
|
|||
bool isPortable();
|
||||
|
||||
private:
|
||||
static Paths *instance;
|
||||
boost::optional<bool> portable;
|
||||
|
||||
void initAppFilePathHash();
|
||||
void initCheckPortable();
|
||||
void initAppDataDirectory();
|
||||
void initSubDirectories();
|
||||
|
||||
static Paths *instance;
|
||||
boost::optional<bool> portable_;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -69,18 +69,18 @@ void Settings::saveSnapshot()
|
|||
d->AddMember(key.Move(), val.Move(), a);
|
||||
}
|
||||
|
||||
this->snapshot.reset(d);
|
||||
this->snapshot_.reset(d);
|
||||
|
||||
Log("hehe: {}", pajlada::Settings::SettingManager::stringify(*d));
|
||||
}
|
||||
|
||||
void Settings::restoreSnapshot()
|
||||
{
|
||||
if (!this->snapshot) {
|
||||
if (!this->snapshot_) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto &snapshotObject = this->snapshot->GetObject();
|
||||
const auto &snapshotObject = this->snapshot_->GetObject();
|
||||
|
||||
for (const auto &weakSetting : _settings) {
|
||||
auto setting = weakSetting.lock();
|
||||
|
|
|
@ -125,9 +125,9 @@ public:
|
|||
void restoreSnapshot();
|
||||
|
||||
private:
|
||||
std::unique_ptr<rapidjson::Document> snapshot;
|
||||
|
||||
void updateModerationActions();
|
||||
|
||||
std::unique_ptr<rapidjson::Document> snapshot_;
|
||||
};
|
||||
|
||||
Settings *getSettings();
|
||||
|
|
|
@ -46,8 +46,8 @@ void Theme::update()
|
|||
// multiplier: 1 = white, 0.8 = light, -0.8 dark, -1 black
|
||||
void Theme::actuallyUpdate(double hue, double multiplier)
|
||||
{
|
||||
isLight = multiplier > 0;
|
||||
bool lightWin = isLight;
|
||||
isLight_ = multiplier > 0;
|
||||
bool lightWin = isLight_;
|
||||
|
||||
// QColor themeColor = QColor::fromHslF(hue, 0.43, 0.5);
|
||||
QColor themeColor = QColor::fromHslF(hue, 0.8, 0.5);
|
||||
|
@ -82,7 +82,7 @@ void Theme::actuallyUpdate(double hue, double multiplier)
|
|||
|
||||
// message (referenced later)
|
||||
this->messages.textColors.caret = //
|
||||
this->messages.textColors.regular = isLight ? "#000" : "#fff";
|
||||
this->messages.textColors.regular = isLight_ ? "#000" : "#fff";
|
||||
|
||||
QColor highlighted = lightWin ? QColor("#ff0000") : QColor("#ee6166");
|
||||
|
||||
|
@ -141,14 +141,14 @@ void Theme::actuallyUpdate(double hue, double multiplier)
|
|||
}
|
||||
|
||||
// Split
|
||||
bool flat = isLight;
|
||||
bool flat = isLight_;
|
||||
|
||||
this->splits.messageSeperator = isLight ? QColor(127, 127, 127) : QColor(60, 60, 60);
|
||||
this->splits.messageSeperator = isLight_ ? QColor(127, 127, 127) : QColor(60, 60, 60);
|
||||
this->splits.background = getColor(0, sat, 1);
|
||||
this->splits.dropPreview = QColor(0, 148, 255, 0x30);
|
||||
this->splits.dropPreviewBorder = QColor(0, 148, 255, 0xff);
|
||||
|
||||
if (isLight) {
|
||||
if (isLight_) {
|
||||
this->splits.dropTargetRect = QColor(255, 255, 255, 0x00);
|
||||
this->splits.dropTargetRectBorder = QColor(0, 148, 255, 0x00);
|
||||
|
||||
|
@ -165,7 +165,7 @@ void Theme::actuallyUpdate(double hue, double multiplier)
|
|||
this->splits.header.background = getColor(0, sat, flat ? 1 : 0.9);
|
||||
this->splits.header.border = getColor(0, sat, flat ? 1 : 0.85);
|
||||
this->splits.header.text = this->messages.textColors.regular;
|
||||
this->splits.header.focusedText = isLight ? QColor("#198CFF") : QColor("#84C1FF");
|
||||
this->splits.header.focusedText = isLight_ ? QColor("#198CFF") : QColor("#84C1FF");
|
||||
|
||||
this->splits.input.background = getColor(0, sat, flat ? 0.95 : 0.95);
|
||||
this->splits.input.border = getColor(0, sat, flat ? 1 : 1);
|
||||
|
@ -175,16 +175,16 @@ void Theme::actuallyUpdate(double hue, double multiplier)
|
|||
"border:" + this->tabs.selected.backgrounds.regular.color().name() + ";" +
|
||||
"color:" + this->messages.textColors.regular.name() + ";" + //
|
||||
"selection-background-color:" +
|
||||
(isLight ? "#68B1FF" : this->tabs.selected.backgrounds.regular.color().name());
|
||||
(isLight_ ? "#68B1FF" : this->tabs.selected.backgrounds.regular.color().name());
|
||||
|
||||
// Message
|
||||
this->messages.textColors.link = isLight ? QColor(66, 134, 244) : QColor(66, 134, 244);
|
||||
this->messages.textColors.link = isLight_ ? QColor(66, 134, 244) : QColor(66, 134, 244);
|
||||
this->messages.textColors.system = QColor(140, 127, 127);
|
||||
|
||||
this->messages.backgrounds.regular = splits.background;
|
||||
this->messages.backgrounds.alternate = getColor(0, sat, 0.93);
|
||||
|
||||
if (isLight) {
|
||||
if (isLight_) {
|
||||
this->messages.backgrounds.highlighted =
|
||||
blendColors(themeColor, this->messages.backgrounds.regular, 0.8);
|
||||
} else {
|
||||
|
@ -228,7 +228,7 @@ QColor Theme::blendColors(const QColor &color1, const QColor &color2, qreal rati
|
|||
|
||||
void Theme::normalizeColor(QColor &color)
|
||||
{
|
||||
if (this->isLight) {
|
||||
if (this->isLight_) {
|
||||
if (color.lightnessF() > 0.5) {
|
||||
color.setHslF(color.hueF(), color.saturationF(), 0.5);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ public:
|
|||
|
||||
inline bool isLightTheme() const
|
||||
{
|
||||
return this->isLight;
|
||||
return this->isLight_;
|
||||
}
|
||||
|
||||
struct TabColors {
|
||||
|
@ -136,16 +136,15 @@ public:
|
|||
private:
|
||||
void actuallyUpdate(double hue, double multiplier);
|
||||
QColor blendColors(const QColor &color1, const QColor &color2, qreal ratio);
|
||||
|
||||
double middleLookupTable[360] = {};
|
||||
double minLookupTable[360] = {};
|
||||
|
||||
void fillLookupTableValues(double (&array)[360], double from, double to, double fromValue,
|
||||
double toValue);
|
||||
|
||||
bool isLight = false;
|
||||
double middleLookupTable_[360] = {};
|
||||
double minLookupTable_[360] = {};
|
||||
|
||||
pajlada::Signals::NoArgSignal repaintVisibleChatWidgets;
|
||||
bool isLight_ = false;
|
||||
|
||||
pajlada::Signals::NoArgSignal repaintVisibleChatWidgets_;
|
||||
|
||||
friend class WindowManager;
|
||||
};
|
||||
|
|
|
@ -62,20 +62,20 @@ WindowManager::WindowManager()
|
|||
|
||||
auto settings = getSettings();
|
||||
|
||||
this->wordFlagsListener.addSetting(settings->showTimestamps);
|
||||
this->wordFlagsListener.addSetting(settings->showBadges);
|
||||
this->wordFlagsListener.addSetting(settings->enableBttvEmotes);
|
||||
this->wordFlagsListener.addSetting(settings->enableEmojis);
|
||||
this->wordFlagsListener.addSetting(settings->enableFfzEmotes);
|
||||
this->wordFlagsListener.addSetting(settings->enableTwitchEmotes);
|
||||
this->wordFlagsListener.cb = [this](auto) {
|
||||
this->wordFlagsListener_.addSetting(settings->showTimestamps);
|
||||
this->wordFlagsListener_.addSetting(settings->showBadges);
|
||||
this->wordFlagsListener_.addSetting(settings->enableBttvEmotes);
|
||||
this->wordFlagsListener_.addSetting(settings->enableEmojis);
|
||||
this->wordFlagsListener_.addSetting(settings->enableFfzEmotes);
|
||||
this->wordFlagsListener_.addSetting(settings->enableTwitchEmotes);
|
||||
this->wordFlagsListener_.cb = [this](auto) {
|
||||
this->updateWordTypeMask(); //
|
||||
};
|
||||
}
|
||||
|
||||
MessageElement::Flags WindowManager::getWordFlags()
|
||||
{
|
||||
return this->wordFlags;
|
||||
return this->wordFlags_;
|
||||
}
|
||||
|
||||
void WindowManager::updateWordTypeMask()
|
||||
|
@ -114,8 +114,8 @@ void WindowManager::updateWordTypeMask()
|
|||
// update flags
|
||||
MessageElement::Flags newFlags = static_cast<MessageElement::Flags>(flags);
|
||||
|
||||
if (newFlags != this->wordFlags) {
|
||||
this->wordFlags = newFlags;
|
||||
if (newFlags != this->wordFlags_) {
|
||||
this->wordFlags_ = newFlags;
|
||||
|
||||
this->wordFlagsChanged.invoke();
|
||||
}
|
||||
|
@ -134,8 +134,8 @@ void WindowManager::forceLayoutChannelViews()
|
|||
|
||||
void WindowManager::repaintVisibleChatWidgets(Channel *channel)
|
||||
{
|
||||
if (this->mainWindow != nullptr) {
|
||||
this->mainWindow->repaintVisibleChatWidgets(channel);
|
||||
if (this->mainWindow_ != nullptr) {
|
||||
this->mainWindow_->repaintVisibleChatWidgets(channel);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -155,14 +155,14 @@ Window &WindowManager::getMainWindow()
|
|||
{
|
||||
assertInGuiThread();
|
||||
|
||||
return *this->mainWindow;
|
||||
return *this->mainWindow_;
|
||||
}
|
||||
|
||||
Window &WindowManager::getSelectedWindow()
|
||||
{
|
||||
assertInGuiThread();
|
||||
|
||||
return *this->selectedWindow;
|
||||
return *this->selectedWindow_;
|
||||
}
|
||||
|
||||
Window &WindowManager::createWindow(Window::Type type)
|
||||
|
@ -170,16 +170,16 @@ Window &WindowManager::createWindow(Window::Type type)
|
|||
assertInGuiThread();
|
||||
|
||||
auto *window = new Window(type);
|
||||
this->windows.push_back(window);
|
||||
this->windows_.push_back(window);
|
||||
window->show();
|
||||
|
||||
if (type != Window::Type::Main) {
|
||||
window->setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
QObject::connect(window, &QWidget::destroyed, [this, window] {
|
||||
for (auto it = this->windows.begin(); it != this->windows.end(); it++) {
|
||||
for (auto it = this->windows_.begin(); it != this->windows_.end(); it++) {
|
||||
if (*it == window) {
|
||||
this->windows.erase(it);
|
||||
this->windows_.erase(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -191,19 +191,19 @@ Window &WindowManager::createWindow(Window::Type type)
|
|||
|
||||
int WindowManager::windowCount()
|
||||
{
|
||||
return this->windows.size();
|
||||
return this->windows_.size();
|
||||
}
|
||||
|
||||
Window *WindowManager::windowAt(int index)
|
||||
{
|
||||
assertInGuiThread();
|
||||
|
||||
if (index < 0 || (size_t)index >= this->windows.size()) {
|
||||
if (index < 0 || (size_t)index >= this->windows_.size()) {
|
||||
return nullptr;
|
||||
}
|
||||
Log("getting window at bad index {}", index);
|
||||
|
||||
return this->windows.at(index);
|
||||
return this->windows_.at(index);
|
||||
}
|
||||
|
||||
void WindowManager::initialize()
|
||||
|
@ -211,9 +211,9 @@ void WindowManager::initialize()
|
|||
assertInGuiThread();
|
||||
|
||||
auto app = getApp();
|
||||
app->themes->repaintVisibleChatWidgets.connect([this] { this->repaintVisibleChatWidgets(); });
|
||||
app->themes->repaintVisibleChatWidgets_.connect([this] { this->repaintVisibleChatWidgets(); });
|
||||
|
||||
assert(!this->initialized);
|
||||
assert(!this->initialized_);
|
||||
|
||||
// load file
|
||||
QString settingsPath = app->paths->settingsDirectory + SETTINGS_FILENAME;
|
||||
|
@ -231,14 +231,14 @@ void WindowManager::initialize()
|
|||
QString type_val = window_obj.value("type").toString();
|
||||
Window::Type type = type_val == "main" ? Window::Type::Main : Window::Type::Popup;
|
||||
|
||||
if (type == Window::Type::Main && mainWindow != nullptr) {
|
||||
if (type == Window::Type::Main && mainWindow_ != nullptr) {
|
||||
type = Window::Type::Popup;
|
||||
}
|
||||
|
||||
Window &window = createWindow(type);
|
||||
|
||||
if (type == Window::Type::Main) {
|
||||
mainWindow = &window;
|
||||
mainWindow_ = &window;
|
||||
}
|
||||
|
||||
// get geometry
|
||||
|
@ -296,12 +296,12 @@ void WindowManager::initialize()
|
|||
}
|
||||
}
|
||||
|
||||
if (mainWindow == nullptr) {
|
||||
mainWindow = &createWindow(Window::Type::Main);
|
||||
mainWindow->getNotebook().addPage(true);
|
||||
if (mainWindow_ == nullptr) {
|
||||
mainWindow_ = &createWindow(Window::Type::Main);
|
||||
mainWindow_->getNotebook().addPage(true);
|
||||
}
|
||||
|
||||
this->initialized = true;
|
||||
this->initialized_ = true;
|
||||
}
|
||||
|
||||
void WindowManager::save()
|
||||
|
@ -313,7 +313,7 @@ void WindowManager::save()
|
|||
|
||||
// "serialize"
|
||||
QJsonArray window_arr;
|
||||
for (Window *window : this->windows) {
|
||||
for (Window *window : this->windows_) {
|
||||
QJsonObject window_obj;
|
||||
|
||||
// window type
|
||||
|
@ -457,19 +457,19 @@ void WindowManager::closeAll()
|
|||
{
|
||||
assertInGuiThread();
|
||||
|
||||
for (Window *window : windows) {
|
||||
for (Window *window : windows_) {
|
||||
window->close();
|
||||
}
|
||||
}
|
||||
|
||||
int WindowManager::getGeneration() const
|
||||
{
|
||||
return this->generation;
|
||||
return this->generation_;
|
||||
}
|
||||
|
||||
void WindowManager::incGeneration()
|
||||
{
|
||||
this->generation++;
|
||||
this->generation_++;
|
||||
}
|
||||
|
||||
int WindowManager::clampUiScale(int scale)
|
||||
|
|
|
@ -9,9 +9,18 @@ class WindowManager
|
|||
{
|
||||
public:
|
||||
WindowManager();
|
||||
|
||||
~WindowManager() = delete;
|
||||
|
||||
static void encodeChannel(IndirectChannel channel, QJsonObject &obj);
|
||||
static IndirectChannel decodeChannel(const QJsonObject &obj);
|
||||
|
||||
static int clampUiScale(int scale);
|
||||
static float getUiScaleValue();
|
||||
static float getUiScaleValue(int scale);
|
||||
|
||||
static const int uiScaleMin;
|
||||
static const int uiScaleMax;
|
||||
|
||||
void showSettingsDialog();
|
||||
void showAccountSelectPopup(QPoint point);
|
||||
|
||||
|
@ -19,7 +28,6 @@ public:
|
|||
void forceLayoutChannelViews();
|
||||
void repaintVisibleChatWidgets(Channel *channel = nullptr);
|
||||
void repaintGifEmotes();
|
||||
// void updateAll();
|
||||
|
||||
Window &getMainWindow();
|
||||
Window &getSelectedWindow();
|
||||
|
@ -35,38 +43,28 @@ public:
|
|||
int getGeneration() const;
|
||||
void incGeneration();
|
||||
|
||||
pajlada::Signals::NoArgSignal repaintGifs;
|
||||
pajlada::Signals::Signal<Channel *> layout;
|
||||
|
||||
static const int uiScaleMin;
|
||||
static const int uiScaleMax;
|
||||
static int clampUiScale(int scale);
|
||||
static float getUiScaleValue();
|
||||
static float getUiScaleValue(int scale);
|
||||
|
||||
MessageElement::Flags getWordFlags();
|
||||
void updateWordTypeMask();
|
||||
|
||||
pajlada::Signals::NoArgSignal repaintGifs;
|
||||
pajlada::Signals::Signal<Channel *> layout;
|
||||
|
||||
pajlada::Signals::NoArgSignal wordFlagsChanged;
|
||||
|
||||
private:
|
||||
bool initialized = false;
|
||||
|
||||
std::atomic<int> generation{0};
|
||||
|
||||
std::vector<Window *> windows;
|
||||
|
||||
Window *mainWindow = nullptr;
|
||||
Window *selectedWindow = nullptr;
|
||||
|
||||
void encodeNodeRecusively(SplitContainer::Node *node, QJsonObject &obj);
|
||||
|
||||
MessageElement::Flags wordFlags = MessageElement::Default;
|
||||
pajlada::Settings::SettingListener wordFlagsListener;
|
||||
bool initialized_ = false;
|
||||
|
||||
public:
|
||||
static void encodeChannel(IndirectChannel channel, QJsonObject &obj);
|
||||
static IndirectChannel decodeChannel(const QJsonObject &obj);
|
||||
std::atomic<int> generation_{0};
|
||||
|
||||
std::vector<Window *> windows_;
|
||||
|
||||
Window *mainWindow_ = nullptr;
|
||||
Window *selectedWindow_ = nullptr;
|
||||
|
||||
MessageElement::Flags wordFlags_ = MessageElement::Default;
|
||||
pajlada::Settings::SettingListener wordFlagsListener_;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -18,10 +18,10 @@ public:
|
|||
|
||||
bool tryGet(const TKey &name, TValue &value) const
|
||||
{
|
||||
QMutexLocker lock(&this->mutex);
|
||||
QMutexLocker lock(&this->mutex_);
|
||||
|
||||
auto a = this->data.find(name);
|
||||
if (a == this->data.end()) {
|
||||
auto a = this->data_.find(name);
|
||||
if (a == this->data_.end()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -32,12 +32,12 @@ public:
|
|||
|
||||
TValue getOrAdd(const TKey &name, std::function<TValue()> addLambda)
|
||||
{
|
||||
QMutexLocker lock(&this->mutex);
|
||||
QMutexLocker lock(&this->mutex_);
|
||||
|
||||
auto a = this->data.find(name);
|
||||
if (a == this->data.end()) {
|
||||
auto a = this->data_.find(name);
|
||||
if (a == this->data_.end()) {
|
||||
TValue value = addLambda();
|
||||
this->data.insert(name, value);
|
||||
this->data_.insert(name, value);
|
||||
return value;
|
||||
}
|
||||
|
||||
|
@ -46,30 +46,30 @@ public:
|
|||
|
||||
TValue &operator[](const TKey &name)
|
||||
{
|
||||
QMutexLocker lock(&this->mutex);
|
||||
QMutexLocker lock(&this->mutex_);
|
||||
|
||||
return this->data[name];
|
||||
return this->data_[name];
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
QMutexLocker lock(&this->mutex);
|
||||
QMutexLocker lock(&this->mutex_);
|
||||
|
||||
this->data.clear();
|
||||
this->data_.clear();
|
||||
}
|
||||
|
||||
void insert(const TKey &name, const TValue &value)
|
||||
{
|
||||
QMutexLocker lock(&this->mutex);
|
||||
QMutexLocker lock(&this->mutex_);
|
||||
|
||||
this->data.insert(name, value);
|
||||
this->data_.insert(name, value);
|
||||
}
|
||||
|
||||
void each(std::function<void(const TKey &name, const TValue &value)> func) const
|
||||
{
|
||||
QMutexLocker lock(&this->mutex);
|
||||
QMutexLocker lock(&this->mutex_);
|
||||
|
||||
QMapIterator<TKey, TValue> it(this->data);
|
||||
QMapIterator<TKey, TValue> it(this->data_);
|
||||
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
|
@ -79,9 +79,9 @@ public:
|
|||
|
||||
void each(std::function<void(const TKey &name, TValue &value)> func)
|
||||
{
|
||||
QMutexLocker lock(&this->mutex);
|
||||
QMutexLocker lock(&this->mutex_);
|
||||
|
||||
QMutableMapIterator<TKey, TValue> it(this->data);
|
||||
QMutableMapIterator<TKey, TValue> it(this->data_);
|
||||
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
|
@ -90,8 +90,8 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
mutable QMutex mutex;
|
||||
QMap<TKey, TValue> data;
|
||||
mutable QMutex mutex_;
|
||||
QMap<TKey, TValue> data_;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace chatterino {
|
||||
|
||||
QMap<QString, int64_t> DebugCount::counts;
|
||||
std::mutex DebugCount::mut;
|
||||
QMap<QString, int64_t> DebugCount::counts_;
|
||||
std::mutex DebugCount::mut_;
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -10,17 +10,14 @@ namespace chatterino {
|
|||
|
||||
class DebugCount
|
||||
{
|
||||
static QMap<QString, int64_t> counts;
|
||||
static std::mutex mut;
|
||||
|
||||
public:
|
||||
static void increase(const QString &name)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mut);
|
||||
std::lock_guard<std::mutex> lock(mut_);
|
||||
|
||||
auto it = counts.find(name);
|
||||
if (it == counts.end()) {
|
||||
counts.insert(name, 1);
|
||||
auto it = counts_.find(name);
|
||||
if (it == counts_.end()) {
|
||||
counts_.insert(name, 1);
|
||||
} else {
|
||||
reinterpret_cast<int64_t &>(it.value())++;
|
||||
}
|
||||
|
@ -28,11 +25,11 @@ public:
|
|||
|
||||
static void decrease(const QString &name)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mut);
|
||||
std::lock_guard<std::mutex> lock(mut_);
|
||||
|
||||
auto it = counts.find(name);
|
||||
if (it == counts.end()) {
|
||||
counts.insert(name, -1);
|
||||
auto it = counts_.find(name);
|
||||
if (it == counts_.end()) {
|
||||
counts_.insert(name, -1);
|
||||
} else {
|
||||
reinterpret_cast<int64_t &>(it.value())--;
|
||||
}
|
||||
|
@ -40,10 +37,10 @@ public:
|
|||
|
||||
static QString getDebugText()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mut);
|
||||
std::lock_guard<std::mutex> lock(mut_);
|
||||
|
||||
QString text;
|
||||
for (auto it = counts.begin(); it != counts.end(); it++) {
|
||||
for (auto it = counts_.begin(); it != counts_.end(); it++) {
|
||||
text += it.key() + ": " + QString::number(it.value()) + "\n";
|
||||
}
|
||||
return text;
|
||||
|
@ -53,6 +50,10 @@ public:
|
|||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
private:
|
||||
static QMap<QString, int64_t> counts_;
|
||||
static std::mutex mut_;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -15,29 +15,29 @@ class LayoutCreator
|
|||
{
|
||||
public:
|
||||
LayoutCreator(T *_item)
|
||||
: item(_item)
|
||||
: item_(_item)
|
||||
{
|
||||
}
|
||||
|
||||
T *operator->()
|
||||
{
|
||||
return this->item;
|
||||
return this->item_;
|
||||
}
|
||||
|
||||
T &operator*()
|
||||
{
|
||||
return *this->item;
|
||||
return *this->item_;
|
||||
}
|
||||
|
||||
T *getElement()
|
||||
{
|
||||
return this->item;
|
||||
return this->item_;
|
||||
}
|
||||
|
||||
template <typename T2>
|
||||
LayoutCreator<T2> append(T2 *_item)
|
||||
{
|
||||
this->_addItem(this->getOrCreateLayout(), _item);
|
||||
this->addItem(this->getOrCreateLayout(), _item);
|
||||
|
||||
return LayoutCreator<T2>(_item);
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ public:
|
|||
{
|
||||
T2 *t = new T2(std::forward<Args>(args)...);
|
||||
|
||||
this->_addItem(this->getOrCreateLayout(), t);
|
||||
this->addItem(this->getOrCreateLayout(), t);
|
||||
|
||||
return LayoutCreator<T2>(t);
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ public:
|
|||
LayoutCreator<QWidget> emplaceScrollAreaWidget()
|
||||
{
|
||||
QWidget *widget = new QWidget;
|
||||
this->item->setWidget(widget);
|
||||
this->item_->setWidget(widget);
|
||||
return LayoutCreator<QWidget>(widget);
|
||||
}
|
||||
|
||||
|
@ -68,14 +68,14 @@ public:
|
|||
{
|
||||
T2 *layout = new T2;
|
||||
|
||||
this->item->setLayout(layout);
|
||||
this->item_->setLayout(layout);
|
||||
|
||||
return LayoutCreator<T2>(layout);
|
||||
}
|
||||
|
||||
LayoutCreator<T> assign(T **ptr)
|
||||
{
|
||||
*ptr = this->item;
|
||||
*ptr = this->item_;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ public:
|
|||
typename std::enable_if<std::is_base_of<QLayout, Q>::value, int>::type = 0>
|
||||
LayoutCreator<T> withoutMargin()
|
||||
{
|
||||
this->item->setContentsMargins(0, 0, 0, 0);
|
||||
this->item_->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ public:
|
|||
typename std::enable_if<std::is_base_of<QWidget, Q>::value, int>::type = 0>
|
||||
LayoutCreator<T> hidden()
|
||||
{
|
||||
this->item->setVisible(false);
|
||||
this->item_->setVisible(false);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
@ -107,24 +107,24 @@ public:
|
|||
QWidget *widget = new QWidget;
|
||||
widget->setLayout(item);
|
||||
|
||||
this->item->addTab(widget, title);
|
||||
this->item_->addTab(widget, title);
|
||||
|
||||
return LayoutCreator<T2>(item);
|
||||
}
|
||||
|
||||
private:
|
||||
T *item;
|
||||
T *item_;
|
||||
|
||||
template <typename T2,
|
||||
typename std::enable_if<std::is_base_of<QWidget, T2>::value, int>::type = 0>
|
||||
void _addItem(QLayout *layout, T2 *item)
|
||||
void addItem(QLayout *layout, T2 *item)
|
||||
{
|
||||
layout->addWidget(item);
|
||||
}
|
||||
|
||||
template <typename T2,
|
||||
typename std::enable_if<std::is_base_of<QLayout, T2>::value, int>::type = 0>
|
||||
void _addItem(QLayout *layout, T2 *item)
|
||||
void addItem(QLayout *layout, T2 *item)
|
||||
{
|
||||
QWidget *widget = new QWidget();
|
||||
widget->setLayout(item);
|
||||
|
@ -135,18 +135,18 @@ private:
|
|||
typename std::enable_if<std::is_base_of<QLayout, Q>::value, int>::type = 0>
|
||||
QLayout *getOrCreateLayout()
|
||||
{
|
||||
return this->item;
|
||||
return this->item_;
|
||||
}
|
||||
|
||||
template <typename Q = T,
|
||||
typename std::enable_if<std::is_base_of<QWidget, Q>::value, int>::type = 0>
|
||||
QLayout *getOrCreateLayout()
|
||||
{
|
||||
if (!this->item->layout()) {
|
||||
this->item->setLayout(new QHBoxLayout());
|
||||
if (!this->item_->layout()) {
|
||||
this->item_->setLayout(new QHBoxLayout());
|
||||
}
|
||||
|
||||
return this->item->layout();
|
||||
return this->item_->layout();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -16,16 +16,16 @@ class LambdaRunnable : public QRunnable
|
|||
public:
|
||||
LambdaRunnable(std::function<void()> action)
|
||||
{
|
||||
this->action = action;
|
||||
this->action_ = action;
|
||||
}
|
||||
|
||||
void run()
|
||||
{
|
||||
this->action();
|
||||
this->action_();
|
||||
}
|
||||
|
||||
private:
|
||||
std::function<void()> action;
|
||||
std::function<void()> action_;
|
||||
};
|
||||
|
||||
// Taken from
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace chatterino {
|
|||
|
||||
namespace {
|
||||
|
||||
const char *GetBinaryName()
|
||||
const char *getBinaryName()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return "streamlink.exe";
|
||||
|
@ -24,7 +24,7 @@ const char *GetBinaryName()
|
|||
#endif
|
||||
}
|
||||
|
||||
const char *GetDefaultBinaryPath()
|
||||
const char *getDefaultBinaryPath()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return "C:\\Program Files (x86)\\Streamlink\\bin\\streamlink.exe";
|
||||
|
@ -38,13 +38,13 @@ QString getStreamlinkProgram()
|
|||
auto app = getApp();
|
||||
|
||||
if (app->settings->streamlinkUseCustomPath) {
|
||||
return app->settings->streamlinkPath + "/" + GetBinaryName();
|
||||
return app->settings->streamlinkPath + "/" + getBinaryName();
|
||||
} else {
|
||||
return GetBinaryName();
|
||||
return getBinaryName();
|
||||
}
|
||||
}
|
||||
|
||||
bool CheckStreamlinkPath(const QString &path)
|
||||
bool checkStreamlinkPath(const QString &path)
|
||||
{
|
||||
QFileInfo fileinfo(path);
|
||||
|
||||
|
@ -95,7 +95,7 @@ QProcess *createStreamlinkProcess()
|
|||
|
||||
} // namespace
|
||||
|
||||
void GetStreamQualities(const QString &channelURL, std::function<void(QStringList)> cb)
|
||||
void getStreamQualities(const QString &channelURL, std::function<void(QStringList)> cb)
|
||||
{
|
||||
auto p = createStreamlinkProcess();
|
||||
|
||||
|
@ -130,7 +130,7 @@ void GetStreamQualities(const QString &channelURL, std::function<void(QStringLis
|
|||
p->start();
|
||||
}
|
||||
|
||||
void OpenStreamlink(const QString &channelURL, const QString &quality, QStringList extraArguments)
|
||||
void openStreamlink(const QString &channelURL, const QString &quality, QStringList extraArguments)
|
||||
{
|
||||
auto app = getApp();
|
||||
|
||||
|
@ -156,7 +156,7 @@ void OpenStreamlink(const QString &channelURL, const QString &quality, QStringLi
|
|||
}
|
||||
}
|
||||
|
||||
void Start(const QString &channel)
|
||||
void openStreamlinkForChannel(const QString &channel)
|
||||
{
|
||||
auto app = getApp();
|
||||
|
||||
|
@ -166,7 +166,7 @@ void Start(const QString &channel)
|
|||
preferredQuality = preferredQuality.toLower();
|
||||
|
||||
if (preferredQuality == "choose") {
|
||||
GetStreamQualities(channelURL, [=](QStringList qualityOptions) {
|
||||
getStreamQualities(channelURL, [=](QStringList qualityOptions) {
|
||||
QualityPopup::showDialog(channel, qualityOptions);
|
||||
});
|
||||
|
||||
|
@ -198,7 +198,7 @@ void Start(const QString &channel)
|
|||
args << "--stream-sorting-excludes" << exclude;
|
||||
}
|
||||
|
||||
OpenStreamlink(channelURL, quality, args);
|
||||
openStreamlink(channelURL, quality, args);
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -16,11 +16,11 @@ public:
|
|||
|
||||
// Open streamlink for given channel, quality and extra arguments
|
||||
// the "Additional arguments" are fetched and added at the beginning of the streamlink call
|
||||
void OpenStreamlink(const QString &channelURL, const QString &quality,
|
||||
void openStreamlink(const QString &channelURL, const QString &quality,
|
||||
QStringList extraArguments = QStringList());
|
||||
|
||||
// Start opening streamlink for the given channel, reading settings like quality from settings
|
||||
// and opening a quality dialog if the quality is "Choose"
|
||||
void Start(const QString &channel);
|
||||
void openStreamlinkForChannel(const QString &channel);
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -17,10 +17,10 @@ AccountSwitchPopupWidget::AccountSwitchPopupWidget(QWidget *parent)
|
|||
|
||||
this->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
this->ui.accountSwitchWidget = new AccountSwitchWidget(this);
|
||||
this->ui_.accountSwitchWidget = new AccountSwitchWidget(this);
|
||||
QVBoxLayout *vbox = new QVBoxLayout(this);
|
||||
this->ui.accountSwitchWidget->setFocusPolicy(Qt::NoFocus);
|
||||
vbox->addWidget(this->ui.accountSwitchWidget);
|
||||
this->ui_.accountSwitchWidget->setFocusPolicy(Qt::NoFocus);
|
||||
vbox->addWidget(this->ui_.accountSwitchWidget);
|
||||
|
||||
// vbox->setSizeConstraint(QLayout::SetMinimumSize);
|
||||
|
||||
|
@ -41,7 +41,7 @@ AccountSwitchPopupWidget::AccountSwitchPopupWidget(QWidget *parent)
|
|||
|
||||
void AccountSwitchPopupWidget::refresh()
|
||||
{
|
||||
this->ui.accountSwitchWidget->refresh();
|
||||
this->ui_.accountSwitchWidget->refresh();
|
||||
}
|
||||
|
||||
void AccountSwitchPopupWidget::focusOutEvent(QFocusEvent *)
|
||||
|
|
|
@ -22,7 +22,7 @@ protected:
|
|||
private:
|
||||
struct {
|
||||
AccountSwitchWidget *accountSwitchWidget = nullptr;
|
||||
} ui;
|
||||
} ui_;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -32,6 +32,21 @@ protected:
|
|||
// override;
|
||||
|
||||
private:
|
||||
struct {
|
||||
Split *split;
|
||||
} ui_;
|
||||
|
||||
struct Item {
|
||||
void *hwnd;
|
||||
AttachedWindow *window;
|
||||
QString winId;
|
||||
};
|
||||
|
||||
static std::vector<Item> items;
|
||||
|
||||
void attachToHwnd(void *attached);
|
||||
void updateWindowRect(void *attached);
|
||||
|
||||
void *target_;
|
||||
int yOffset_;
|
||||
int currentYOffset_;
|
||||
|
@ -42,21 +57,6 @@ private:
|
|||
bool attached_ = false;
|
||||
#endif
|
||||
QTimer timer_;
|
||||
|
||||
struct {
|
||||
Split *split;
|
||||
} ui_;
|
||||
|
||||
void attachToHwnd(void *attached);
|
||||
void updateWindowRect(void *attached);
|
||||
|
||||
struct Item {
|
||||
void *hwnd;
|
||||
AttachedWindow *window;
|
||||
QString winId;
|
||||
};
|
||||
|
||||
static std::vector<Item> items;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -160,7 +160,7 @@ void BaseWindow::init()
|
|||
::SetWindowPos(HWND(this->winId()), topMost ? HWND_TOPMOST : HWND_NOTOPMOST, 0,
|
||||
0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
|
||||
},
|
||||
this->managedConnections);
|
||||
this->managedConnections_);
|
||||
});
|
||||
}
|
||||
#else
|
||||
|
|
|
@ -112,7 +112,7 @@ private:
|
|||
} ui_;
|
||||
|
||||
pajlada::Signals::SignalHolder connections_;
|
||||
std::vector<pajlada::Signals::ScopedConnection> managedConnections;
|
||||
std::vector<pajlada::Signals::ScopedConnection> managedConnections_;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -34,7 +34,8 @@ protected:
|
|||
virtual QSize minimumSizeHint() const override;
|
||||
|
||||
private:
|
||||
pajlada::Signals::SignalHolder connections_;
|
||||
void updateSize();
|
||||
int getOffset();
|
||||
|
||||
QString text_;
|
||||
FontStyle fontStyle_;
|
||||
|
@ -42,8 +43,7 @@ private:
|
|||
bool centered_ = false;
|
||||
bool hasOffset_ = true;
|
||||
|
||||
void updateSize();
|
||||
int getOffset();
|
||||
pajlada::Signals::SignalHolder connections_;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -27,9 +27,9 @@ namespace chatterino {
|
|||
|
||||
Notebook::Notebook(QWidget *parent)
|
||||
: BaseWidget(parent)
|
||||
, addButton(this)
|
||||
, addButton_(this)
|
||||
{
|
||||
this->addButton.setHidden(true);
|
||||
this->addButton_.setHidden(true);
|
||||
|
||||
auto *shortcut_next = new QShortcut(QKeySequence("Ctrl+Tab"), this);
|
||||
QObject::connect(shortcut_next, &QShortcut::activated, [this] { this->selectNextTab(); });
|
||||
|
@ -49,12 +49,12 @@ NotebookTab *Notebook::addPage(QWidget *page, QString title, bool select)
|
|||
item.page = page;
|
||||
item.tab = tab;
|
||||
|
||||
this->items.append(item);
|
||||
this->items_.append(item);
|
||||
|
||||
page->hide();
|
||||
page->setParent(this);
|
||||
|
||||
if (select || this->items.count() == 1) {
|
||||
if (select || this->items_.count() == 1) {
|
||||
this->select(page);
|
||||
}
|
||||
|
||||
|
@ -67,24 +67,24 @@ NotebookTab *Notebook::addPage(QWidget *page, QString title, bool select)
|
|||
|
||||
void Notebook::removePage(QWidget *page)
|
||||
{
|
||||
for (int i = 0; i < this->items.count(); i++) {
|
||||
if (this->items[i].page == page) {
|
||||
if (this->items.count() == 1) {
|
||||
for (int i = 0; i < this->items_.count(); i++) {
|
||||
if (this->items_[i].page == page) {
|
||||
if (this->items_.count() == 1) {
|
||||
this->select(nullptr);
|
||||
} else if (i == this->items.count() - 1) {
|
||||
this->select(this->items[i - 1].page);
|
||||
} else if (i == this->items_.count() - 1) {
|
||||
this->select(this->items_[i - 1].page);
|
||||
} else {
|
||||
this->select(this->items[i + 1].page);
|
||||
this->select(this->items_[i + 1].page);
|
||||
}
|
||||
|
||||
this->items[i].page->deleteLater();
|
||||
this->items[i].tab->deleteLater();
|
||||
this->items_[i].page->deleteLater();
|
||||
this->items_[i].tab->deleteLater();
|
||||
|
||||
// if (this->items.empty()) {
|
||||
// this->addNewPage();
|
||||
// }
|
||||
|
||||
this->items.removeAt(i);
|
||||
this->items_.removeAt(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -94,15 +94,15 @@ void Notebook::removePage(QWidget *page)
|
|||
|
||||
void Notebook::removeCurrentPage()
|
||||
{
|
||||
if (this->selectedPage != nullptr) {
|
||||
this->removePage(this->selectedPage);
|
||||
if (this->selectedPage_ != nullptr) {
|
||||
this->removePage(this->selectedPage_);
|
||||
}
|
||||
}
|
||||
|
||||
int Notebook::indexOf(QWidget *page) const
|
||||
{
|
||||
for (int i = 0; i < this->items.count(); i++) {
|
||||
if (this->items[i].page == page) {
|
||||
for (int i = 0; i < this->items_.count(); i++) {
|
||||
if (this->items_[i].page == page) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ int Notebook::indexOf(QWidget *page) const
|
|||
|
||||
void Notebook::select(QWidget *page)
|
||||
{
|
||||
if (page == this->selectedPage) {
|
||||
if (page == this->selectedPage_) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -137,35 +137,35 @@ void Notebook::select(QWidget *page)
|
|||
}
|
||||
}
|
||||
|
||||
if (this->selectedPage != nullptr) {
|
||||
this->selectedPage->setHidden(true);
|
||||
if (this->selectedPage_ != nullptr) {
|
||||
this->selectedPage_->setHidden(true);
|
||||
|
||||
Item &item = this->findItem(selectedPage);
|
||||
Item &item = this->findItem(selectedPage_);
|
||||
item.tab->setSelected(false);
|
||||
|
||||
// for (auto split : this->selectedPage->getSplits()) {
|
||||
// split->updateLastReadMessage();
|
||||
// }
|
||||
|
||||
item.selectedWidget = this->selectedPage->focusWidget();
|
||||
item.selectedWidget = this->selectedPage_->focusWidget();
|
||||
}
|
||||
|
||||
this->selectedPage = page;
|
||||
this->selectedPage_ = page;
|
||||
|
||||
this->performLayout();
|
||||
}
|
||||
|
||||
bool Notebook::containsPage(QWidget *page)
|
||||
{
|
||||
return std::any_of(this->items.begin(), this->items.end(),
|
||||
return std::any_of(this->items_.begin(), this->items_.end(),
|
||||
[page](const auto &item) { return item.page == page; });
|
||||
}
|
||||
|
||||
Notebook::Item &Notebook::findItem(QWidget *page)
|
||||
{
|
||||
auto it = std::find_if(this->items.begin(), this->items.end(),
|
||||
auto it = std::find_if(this->items_.begin(), this->items_.end(),
|
||||
[page](const auto &item) { return page == item.page; });
|
||||
assert(it != this->items.end());
|
||||
assert(it != this->items_.end());
|
||||
return *it;
|
||||
}
|
||||
|
||||
|
@ -182,64 +182,64 @@ bool Notebook::containsChild(const QObject *obj, const QObject *child)
|
|||
|
||||
void Notebook::selectIndex(int index)
|
||||
{
|
||||
if (index < 0 || this->items.count() <= index) {
|
||||
if (index < 0 || this->items_.count() <= index) {
|
||||
return;
|
||||
}
|
||||
|
||||
this->select(this->items[index].page);
|
||||
this->select(this->items_[index].page);
|
||||
}
|
||||
|
||||
void Notebook::selectNextTab()
|
||||
{
|
||||
if (this->items.size() <= 1) {
|
||||
if (this->items_.size() <= 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
int index = (this->indexOf(this->selectedPage) + 1) % this->items.count();
|
||||
int index = (this->indexOf(this->selectedPage_) + 1) % this->items_.count();
|
||||
|
||||
this->select(this->items[index].page);
|
||||
this->select(this->items_[index].page);
|
||||
}
|
||||
|
||||
void Notebook::selectPreviousTab()
|
||||
{
|
||||
if (this->items.size() <= 1) {
|
||||
if (this->items_.size() <= 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
int index = this->indexOf(this->selectedPage) - 1;
|
||||
int index = this->indexOf(this->selectedPage_) - 1;
|
||||
|
||||
if (index < 0) {
|
||||
index += this->items.count();
|
||||
index += this->items_.count();
|
||||
}
|
||||
|
||||
this->select(this->items[index].page);
|
||||
this->select(this->items_[index].page);
|
||||
}
|
||||
|
||||
int Notebook::getPageCount() const
|
||||
{
|
||||
return this->items.count();
|
||||
return this->items_.count();
|
||||
}
|
||||
|
||||
QWidget *Notebook::getPageAt(int index) const
|
||||
{
|
||||
return this->items[index].page;
|
||||
return this->items_[index].page;
|
||||
}
|
||||
|
||||
int Notebook::getSelectedIndex() const
|
||||
{
|
||||
return this->indexOf(this->selectedPage);
|
||||
return this->indexOf(this->selectedPage_);
|
||||
}
|
||||
|
||||
QWidget *Notebook::getSelectedPage() const
|
||||
{
|
||||
return this->selectedPage;
|
||||
return this->selectedPage_;
|
||||
}
|
||||
|
||||
QWidget *Notebook::tabAt(QPoint point, int &index, int maxWidth)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for (auto &item : this->items) {
|
||||
for (auto &item : this->items_) {
|
||||
QRect rect = item.tab->getDesiredRect();
|
||||
rect.setHeight((int)(this->getScale() * 24));
|
||||
|
||||
|
@ -259,40 +259,40 @@ QWidget *Notebook::tabAt(QPoint point, int &index, int maxWidth)
|
|||
|
||||
void Notebook::rearrangePage(QWidget *page, int index)
|
||||
{
|
||||
this->items.move(this->indexOf(page), index);
|
||||
this->items_.move(this->indexOf(page), index);
|
||||
|
||||
this->performLayout(true);
|
||||
}
|
||||
|
||||
bool Notebook::getAllowUserTabManagement() const
|
||||
{
|
||||
return this->allowUserTabManagement;
|
||||
return this->allowUserTabManagement_;
|
||||
}
|
||||
|
||||
void Notebook::setAllowUserTabManagement(bool value)
|
||||
{
|
||||
this->allowUserTabManagement = value;
|
||||
this->allowUserTabManagement_ = value;
|
||||
}
|
||||
|
||||
bool Notebook::getShowAddButton() const
|
||||
{
|
||||
return this->showAddButton;
|
||||
return this->showAddButton_;
|
||||
}
|
||||
|
||||
void Notebook::setShowAddButton(bool value)
|
||||
{
|
||||
this->showAddButton = value;
|
||||
this->showAddButton_ = value;
|
||||
|
||||
this->addButton.setHidden(!value);
|
||||
this->addButton_.setHidden(!value);
|
||||
}
|
||||
|
||||
void Notebook::scaleChangedEvent(float scale)
|
||||
{
|
||||
float h = NOTEBOOK_TAB_HEIGHT * this->getScale();
|
||||
|
||||
this->addButton.setFixedSize(h, h);
|
||||
this->addButton_.setFixedSize(h, h);
|
||||
|
||||
for (auto &i : this->items) {
|
||||
for (auto &i : this->items_) {
|
||||
i.tab->updateSize();
|
||||
}
|
||||
}
|
||||
|
@ -311,7 +311,7 @@ void Notebook::performLayout(bool animated)
|
|||
|
||||
int h = int(NOTEBOOK_TAB_HEIGHT * this->getScale());
|
||||
|
||||
for (auto *btn : this->customButtons) {
|
||||
for (auto *btn : this->customButtons_) {
|
||||
if (!btn->isVisible()) {
|
||||
continue;
|
||||
}
|
||||
|
@ -324,9 +324,9 @@ void Notebook::performLayout(bool animated)
|
|||
int tabHeight = static_cast<int>(NOTEBOOK_TAB_HEIGHT * scale);
|
||||
bool first = true;
|
||||
|
||||
for (auto i = this->items.begin(); i != this->items.end(); i++) {
|
||||
for (auto i = this->items_.begin(); i != this->items_.end(); i++) {
|
||||
bool wrap =
|
||||
!first && (((i + 1 == this->items.end() && this->showAddButton) ? tabHeight : 0) + x +
|
||||
!first && (((i + 1 == this->items_.end() && this->showAddButton_) ? tabHeight : 0) + x +
|
||||
i->tab->width()) > width();
|
||||
|
||||
if (wrap) {
|
||||
|
@ -343,29 +343,29 @@ void Notebook::performLayout(bool animated)
|
|||
first = false;
|
||||
}
|
||||
|
||||
if (this->showAddButton) {
|
||||
this->addButton.move(x, y);
|
||||
if (this->showAddButton_) {
|
||||
this->addButton_.move(x, y);
|
||||
}
|
||||
|
||||
if (this->lineY != y + tabHeight) {
|
||||
this->lineY = y + tabHeight;
|
||||
if (this->lineY_ != y + tabHeight) {
|
||||
this->lineY_ = y + tabHeight;
|
||||
this->update();
|
||||
}
|
||||
|
||||
y += int(3 * scale);
|
||||
|
||||
for (auto &i : this->items) {
|
||||
for (auto &i : this->items_) {
|
||||
i.tab->raise();
|
||||
}
|
||||
|
||||
if (this->showAddButton) {
|
||||
this->addButton.raise();
|
||||
if (this->showAddButton_) {
|
||||
this->addButton_.raise();
|
||||
}
|
||||
|
||||
if (this->selectedPage != nullptr) {
|
||||
this->selectedPage->move(0, y + tabHeight);
|
||||
this->selectedPage->resize(width(), height() - y - tabHeight);
|
||||
this->selectedPage->raise();
|
||||
if (this->selectedPage_ != nullptr) {
|
||||
this->selectedPage_->move(0, y + tabHeight);
|
||||
this->selectedPage_->resize(width(), height() - y - tabHeight);
|
||||
this->selectedPage_->raise();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -374,20 +374,20 @@ void Notebook::paintEvent(QPaintEvent *event)
|
|||
BaseWidget::paintEvent(event);
|
||||
|
||||
QPainter painter(this);
|
||||
painter.fillRect(0, this->lineY, this->width(), (int)(3 * this->getScale()),
|
||||
painter.fillRect(0, this->lineY_, this->width(), (int)(3 * this->getScale()),
|
||||
this->theme->tabs.bottomLine);
|
||||
}
|
||||
|
||||
NotebookButton *Notebook::getAddButton()
|
||||
{
|
||||
return &this->addButton;
|
||||
return &this->addButton_;
|
||||
}
|
||||
|
||||
NotebookButton *Notebook::addCustomButton()
|
||||
{
|
||||
NotebookButton *btn = new NotebookButton(this);
|
||||
|
||||
this->customButtons.push_back(btn);
|
||||
this->customButtons_.push_back(btn);
|
||||
|
||||
this->performLayout();
|
||||
return btn;
|
||||
|
@ -395,7 +395,7 @@ NotebookButton *Notebook::addCustomButton()
|
|||
|
||||
NotebookTab *Notebook::getTabFromPage(QWidget *page)
|
||||
{
|
||||
for (auto &it : this->items) {
|
||||
for (auto &it : this->items_) {
|
||||
if (it.page == page) {
|
||||
return it.tab;
|
||||
}
|
||||
|
@ -426,7 +426,7 @@ void SplitNotebook::addCustomButtons()
|
|||
|
||||
getApp()->settings->hidePreferencesButton.connect(
|
||||
[settingsBtn](bool hide, auto) { settingsBtn->setVisible(!hide); },
|
||||
this->uniqueConnections);
|
||||
this->connections_);
|
||||
|
||||
settingsBtn->setIcon(NotebookButton::Settings);
|
||||
|
||||
|
@ -437,7 +437,7 @@ void SplitNotebook::addCustomButtons()
|
|||
auto userBtn = this->addCustomButton();
|
||||
userBtn->setVisible(!getApp()->settings->hideUserButton.getValue());
|
||||
getApp()->settings->hideUserButton.connect(
|
||||
[userBtn](bool hide, auto) { userBtn->setVisible(!hide); }, this->uniqueConnections);
|
||||
[userBtn](bool hide, auto) { userBtn->setVisible(!hide); }, this->connections_);
|
||||
|
||||
userBtn->setIcon(NotebookButton::User);
|
||||
QObject::connect(userBtn, &NotebookButton::clicked, [this, userBtn] {
|
||||
|
|
|
@ -64,22 +64,21 @@ private:
|
|||
QWidget *selectedWidget = nullptr;
|
||||
};
|
||||
|
||||
QList<Item> items;
|
||||
QWidget *selectedPage = nullptr;
|
||||
|
||||
bool containsPage(QWidget *page);
|
||||
Item &findItem(QWidget *page);
|
||||
|
||||
static bool containsChild(const QObject *obj, const QObject *child);
|
||||
|
||||
NotebookButton addButton;
|
||||
std::vector<NotebookButton *> customButtons;
|
||||
|
||||
bool allowUserTabManagement = false;
|
||||
bool showAddButton = false;
|
||||
int lineY = 20;
|
||||
|
||||
NotebookTab *getTabFromPage(QWidget *page);
|
||||
|
||||
QList<Item> items_;
|
||||
QWidget *selectedPage_ = nullptr;
|
||||
|
||||
NotebookButton addButton_;
|
||||
std::vector<NotebookButton *> customButtons_;
|
||||
|
||||
bool allowUserTabManagement_ = false;
|
||||
bool showAddButton_ = false;
|
||||
int lineY_ = 20;
|
||||
};
|
||||
|
||||
class SplitNotebook : public Notebook, pajlada::Signals::SignalHolder
|
||||
|
@ -96,7 +95,7 @@ private:
|
|||
pajlada::Signals::SignalHolder signalHolder_;
|
||||
std::unique_ptr<UpdateDialog> updateDialogHandle_;
|
||||
|
||||
std::vector<pajlada::Signals::ScopedConnection> uniqueConnections;
|
||||
std::vector<pajlada::Signals::ScopedConnection> connections_;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -64,6 +64,9 @@ protected:
|
|||
private:
|
||||
Q_PROPERTY(qreal currentValue_ READ getCurrentValue WRITE setCurrentValue)
|
||||
|
||||
LimitedQueueSnapshot<ScrollbarHighlight> getHighlightSnapshot();
|
||||
void updateScroll();
|
||||
|
||||
QMutex mutex_;
|
||||
|
||||
QPropertyAnimation currentValueAnimation_;
|
||||
|
@ -71,7 +74,6 @@ private:
|
|||
LimitedQueue<ScrollbarHighlight> highlights_;
|
||||
bool highlightsPaused_{false};
|
||||
LimitedQueueSnapshot<ScrollbarHighlight> highlightSnapshot_;
|
||||
LimitedQueueSnapshot<ScrollbarHighlight> getHighlightSnapshot();
|
||||
|
||||
bool atBottom_{false};
|
||||
|
||||
|
@ -94,8 +96,6 @@ private:
|
|||
|
||||
pajlada::Signals::NoArgSignal currentValueChanged_;
|
||||
pajlada::Signals::NoArgSignal desiredValueChanged_;
|
||||
|
||||
void updateScroll();
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -26,7 +26,7 @@ TooltipWidget *TooltipWidget::getInstance()
|
|||
|
||||
TooltipWidget::TooltipWidget(BaseWidget *parent)
|
||||
: BaseWindow(parent, BaseWindow::TopMost)
|
||||
, displayText(new QLabel())
|
||||
, displayText_(new QLabel())
|
||||
{
|
||||
auto app = getApp();
|
||||
|
||||
|
@ -39,19 +39,19 @@ TooltipWidget::TooltipWidget(BaseWidget *parent)
|
|||
this->setWindowFlags(Qt::Tool | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint |
|
||||
Qt::BypassWindowManagerHint);
|
||||
|
||||
displayText->setAlignment(Qt::AlignHCenter);
|
||||
displayText->setText("tooltip text");
|
||||
displayText_->setAlignment(Qt::AlignHCenter);
|
||||
displayText_->setText("tooltip text");
|
||||
auto layout = new QVBoxLayout();
|
||||
layout->setContentsMargins(10, 5, 10, 5);
|
||||
layout->addWidget(displayText);
|
||||
layout->addWidget(displayText_);
|
||||
this->setLayout(layout);
|
||||
|
||||
this->fontChangedConnection = app->fonts->fontChanged.connect([this] { this->updateFont(); });
|
||||
this->fontChangedConnection_ = app->fonts->fontChanged.connect([this] { this->updateFont(); });
|
||||
}
|
||||
|
||||
TooltipWidget::~TooltipWidget()
|
||||
{
|
||||
this->fontChangedConnection.disconnect();
|
||||
this->fontChangedConnection_.disconnect();
|
||||
}
|
||||
|
||||
#ifdef USEWINSDK
|
||||
|
@ -81,7 +81,7 @@ void TooltipWidget::updateFont()
|
|||
|
||||
void TooltipWidget::setText(QString text)
|
||||
{
|
||||
this->displayText->setText(text);
|
||||
this->displayText_->setText(text);
|
||||
}
|
||||
|
||||
void TooltipWidget::changeEvent(QEvent *)
|
||||
|
|
|
@ -31,10 +31,10 @@ protected:
|
|||
void scaleChangedEvent(float) override;
|
||||
|
||||
private:
|
||||
QLabel *displayText;
|
||||
pajlada::Signals::Connection fontChangedConnection;
|
||||
|
||||
void updateFont();
|
||||
|
||||
QLabel *displayText_;
|
||||
pajlada::Signals::Connection fontChangedConnection_;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -15,16 +15,16 @@ namespace chatterino {
|
|||
EmotePopup::EmotePopup()
|
||||
: BaseWindow(nullptr, BaseWindow::EnableCustomFrame)
|
||||
{
|
||||
this->viewEmotes = new ChannelView();
|
||||
this->viewEmojis = new ChannelView();
|
||||
this->viewEmotes_ = new ChannelView();
|
||||
this->viewEmojis_ = new ChannelView();
|
||||
|
||||
this->viewEmotes->setOverrideFlags(MessageElement::Flags(
|
||||
this->viewEmotes_->setOverrideFlags(MessageElement::Flags(
|
||||
MessageElement::Default | MessageElement::AlwaysShow | MessageElement::EmoteImages));
|
||||
this->viewEmojis->setOverrideFlags(MessageElement::Flags(
|
||||
this->viewEmojis_->setOverrideFlags(MessageElement::Flags(
|
||||
MessageElement::Default | MessageElement::AlwaysShow | MessageElement::EmoteImages));
|
||||
|
||||
this->viewEmotes->setEnableScrollingToBottom(false);
|
||||
this->viewEmojis->setEnableScrollingToBottom(false);
|
||||
this->viewEmotes_->setEnableScrollingToBottom(false);
|
||||
this->viewEmojis_->setEnableScrollingToBottom(false);
|
||||
|
||||
auto *layout = new QVBoxLayout(this);
|
||||
this->getLayoutContainer()->setLayout(layout);
|
||||
|
@ -33,14 +33,14 @@ EmotePopup::EmotePopup()
|
|||
layout->addWidget(notebook);
|
||||
layout->setMargin(0);
|
||||
|
||||
notebook->addPage(this->viewEmotes, "Emotes");
|
||||
notebook->addPage(this->viewEmojis, "Emojis");
|
||||
notebook->addPage(this->viewEmotes_, "Emotes");
|
||||
notebook->addPage(this->viewEmojis_, "Emojis");
|
||||
|
||||
this->loadEmojis();
|
||||
|
||||
this->viewEmotes->linkClicked.connect(
|
||||
this->viewEmotes_->linkClicked.connect(
|
||||
[this](const Link &link) { this->linkClicked.invoke(link); });
|
||||
this->viewEmojis->linkClicked.connect(
|
||||
this->viewEmojis_->linkClicked.connect(
|
||||
[this](const Link &link) { this->linkClicked.invoke(link); });
|
||||
}
|
||||
|
||||
|
@ -127,7 +127,7 @@ void EmotePopup::loadChannel(ChannelPtr _channel)
|
|||
addEmotes(*channel->ffzChannelEmotes.get(), "FrankerFaceZ Channel Emotes",
|
||||
"FrankerFaceZ Channel Emote");
|
||||
|
||||
this->viewEmotes->setChannel(emoteChannel);
|
||||
this->viewEmotes_->setChannel(emoteChannel);
|
||||
}
|
||||
|
||||
void EmotePopup::loadEmojis()
|
||||
|
@ -155,7 +155,7 @@ void EmotePopup::loadEmojis()
|
|||
});
|
||||
emojiChannel->addMessage(builder.getMessage());
|
||||
|
||||
this->viewEmojis->setChannel(emojiChannel);
|
||||
this->viewEmojis_->setChannel(emojiChannel);
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -19,8 +19,8 @@ public:
|
|||
pajlada::Signals::Signal<Link> linkClicked;
|
||||
|
||||
private:
|
||||
ChannelView *viewEmotes;
|
||||
ChannelView *viewEmojis;
|
||||
ChannelView *viewEmotes_;
|
||||
ChannelView *viewEmojis_;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -63,22 +63,22 @@ void LogInWithCredentials(const std::string &userID, const std::string &username
|
|||
|
||||
BasicLoginWidget::BasicLoginWidget()
|
||||
{
|
||||
this->setLayout(&this->ui.layout);
|
||||
this->setLayout(&this->ui_.layout);
|
||||
|
||||
this->ui.loginButton.setText("Log in (Opens in browser)");
|
||||
this->ui.pasteCodeButton.setText("Paste code");
|
||||
this->ui_.loginButton.setText("Log in (Opens in browser)");
|
||||
this->ui_.pasteCodeButton.setText("Paste code");
|
||||
|
||||
this->ui.horizontalLayout.addWidget(&this->ui.loginButton);
|
||||
this->ui.horizontalLayout.addWidget(&this->ui.pasteCodeButton);
|
||||
this->ui_.horizontalLayout.addWidget(&this->ui_.loginButton);
|
||||
this->ui_.horizontalLayout.addWidget(&this->ui_.pasteCodeButton);
|
||||
|
||||
this->ui.layout.addLayout(&this->ui.horizontalLayout);
|
||||
this->ui_.layout.addLayout(&this->ui_.horizontalLayout);
|
||||
|
||||
connect(&this->ui.loginButton, &QPushButton::clicked, []() {
|
||||
connect(&this->ui_.loginButton, &QPushButton::clicked, []() {
|
||||
printf("open login in browser\n");
|
||||
QDesktopServices::openUrl(QUrl("https://chatterino.com/client_login"));
|
||||
});
|
||||
|
||||
connect(&this->ui.pasteCodeButton, &QPushButton::clicked, [this]() {
|
||||
connect(&this->ui_.pasteCodeButton, &QPushButton::clicked, [this]() {
|
||||
QClipboard *clipboard = QGuiApplication::clipboard();
|
||||
QString clipboardString = clipboard->text();
|
||||
QStringList parameters = clipboardString.split(';');
|
||||
|
@ -115,78 +115,80 @@ BasicLoginWidget::BasicLoginWidget()
|
|||
|
||||
AdvancedLoginWidget::AdvancedLoginWidget()
|
||||
{
|
||||
this->setLayout(&this->ui.layout);
|
||||
this->setLayout(&this->ui_.layout);
|
||||
|
||||
this->ui.instructionsLabel.setText("1. Fill in your username\n2. Fill in your user ID or press "
|
||||
"the 'Get user ID from username' button\n3. Fill in your "
|
||||
"Client ID\n4. Fill in your OAuth Token\n5. Press Add User");
|
||||
this->ui.instructionsLabel.setWordWrap(true);
|
||||
this->ui_.instructionsLabel.setText(
|
||||
"1. Fill in your username\n2. Fill in your user ID or press "
|
||||
"the 'Get user ID from username' button\n3. Fill in your "
|
||||
"Client ID\n4. Fill in your OAuth Token\n5. Press Add User");
|
||||
this->ui_.instructionsLabel.setWordWrap(true);
|
||||
|
||||
this->ui.layout.addWidget(&this->ui.instructionsLabel);
|
||||
this->ui.layout.addLayout(&this->ui.formLayout);
|
||||
this->ui.layout.addLayout(&this->ui.buttonUpperRow.layout);
|
||||
this->ui.layout.addLayout(&this->ui.buttonLowerRow.layout);
|
||||
this->ui_.layout.addWidget(&this->ui_.instructionsLabel);
|
||||
this->ui_.layout.addLayout(&this->ui_.formLayout);
|
||||
this->ui_.layout.addLayout(&this->ui_.buttonUpperRow.layout);
|
||||
this->ui_.layout.addLayout(&this->ui_.buttonLowerRow.layout);
|
||||
|
||||
this->refreshButtons();
|
||||
|
||||
/// Form
|
||||
this->ui.formLayout.addRow("Username", &this->ui.usernameInput);
|
||||
this->ui.formLayout.addRow("User ID", &this->ui.userIDInput);
|
||||
this->ui.formLayout.addRow("Client ID", &this->ui.clientIDInput);
|
||||
this->ui.formLayout.addRow("Oauth token", &this->ui.oauthTokenInput);
|
||||
this->ui_.formLayout.addRow("Username", &this->ui_.usernameInput);
|
||||
this->ui_.formLayout.addRow("User ID", &this->ui_.userIDInput);
|
||||
this->ui_.formLayout.addRow("Client ID", &this->ui_.clientIDInput);
|
||||
this->ui_.formLayout.addRow("Oauth token", &this->ui_.oauthTokenInput);
|
||||
|
||||
this->ui.oauthTokenInput.setEchoMode(QLineEdit::Password);
|
||||
this->ui_.oauthTokenInput.setEchoMode(QLineEdit::Password);
|
||||
|
||||
connect(&this->ui.userIDInput, &QLineEdit::textChanged, [=]() { this->refreshButtons(); });
|
||||
connect(&this->ui.usernameInput, &QLineEdit::textChanged, [=]() { this->refreshButtons(); });
|
||||
connect(&this->ui.clientIDInput, &QLineEdit::textChanged, [=]() { this->refreshButtons(); });
|
||||
connect(&this->ui.oauthTokenInput, &QLineEdit::textChanged, [=]() { this->refreshButtons(); });
|
||||
connect(&this->ui_.userIDInput, &QLineEdit::textChanged, [=]() { this->refreshButtons(); });
|
||||
connect(&this->ui_.usernameInput, &QLineEdit::textChanged, [=]() { this->refreshButtons(); });
|
||||
connect(&this->ui_.clientIDInput, &QLineEdit::textChanged, [=]() { this->refreshButtons(); });
|
||||
connect(&this->ui_.oauthTokenInput, &QLineEdit::textChanged, [=]() { this->refreshButtons(); });
|
||||
|
||||
/// Upper button row
|
||||
|
||||
this->ui.buttonUpperRow.addUserButton.setText("Add user");
|
||||
this->ui.buttonUpperRow.clearFieldsButton.setText("Clear fields");
|
||||
this->ui_.buttonUpperRow.addUserButton.setText("Add user");
|
||||
this->ui_.buttonUpperRow.clearFieldsButton.setText("Clear fields");
|
||||
|
||||
this->ui.buttonUpperRow.layout.addWidget(&this->ui.buttonUpperRow.addUserButton);
|
||||
this->ui.buttonUpperRow.layout.addWidget(&this->ui.buttonUpperRow.clearFieldsButton);
|
||||
this->ui_.buttonUpperRow.layout.addWidget(&this->ui_.buttonUpperRow.addUserButton);
|
||||
this->ui_.buttonUpperRow.layout.addWidget(&this->ui_.buttonUpperRow.clearFieldsButton);
|
||||
|
||||
connect(&this->ui.buttonUpperRow.clearFieldsButton, &QPushButton::clicked, [=]() {
|
||||
this->ui.userIDInput.clear();
|
||||
this->ui.usernameInput.clear();
|
||||
this->ui.clientIDInput.clear();
|
||||
this->ui.oauthTokenInput.clear();
|
||||
connect(&this->ui_.buttonUpperRow.clearFieldsButton, &QPushButton::clicked, [=]() {
|
||||
this->ui_.userIDInput.clear();
|
||||
this->ui_.usernameInput.clear();
|
||||
this->ui_.clientIDInput.clear();
|
||||
this->ui_.oauthTokenInput.clear();
|
||||
});
|
||||
|
||||
connect(&this->ui.buttonUpperRow.addUserButton, &QPushButton::clicked, [=]() {
|
||||
std::string userID = this->ui.userIDInput.text().toStdString();
|
||||
std::string username = this->ui.usernameInput.text().toStdString();
|
||||
std::string clientID = this->ui.clientIDInput.text().toStdString();
|
||||
std::string oauthToken = this->ui.oauthTokenInput.text().toStdString();
|
||||
connect(&this->ui_.buttonUpperRow.addUserButton, &QPushButton::clicked, [=]() {
|
||||
std::string userID = this->ui_.userIDInput.text().toStdString();
|
||||
std::string username = this->ui_.usernameInput.text().toStdString();
|
||||
std::string clientID = this->ui_.clientIDInput.text().toStdString();
|
||||
std::string oauthToken = this->ui_.oauthTokenInput.text().toStdString();
|
||||
|
||||
LogInWithCredentials(userID, username, clientID, oauthToken);
|
||||
});
|
||||
|
||||
/// Lower button row
|
||||
this->ui.buttonLowerRow.fillInUserIDButton.setText("Get user ID from username");
|
||||
this->ui_.buttonLowerRow.fillInUserIDButton.setText("Get user ID from username");
|
||||
|
||||
this->ui.buttonLowerRow.layout.addWidget(&this->ui.buttonLowerRow.fillInUserIDButton);
|
||||
this->ui_.buttonLowerRow.layout.addWidget(&this->ui_.buttonLowerRow.fillInUserIDButton);
|
||||
|
||||
connect(&this->ui.buttonLowerRow.fillInUserIDButton, &QPushButton::clicked, [=]() {
|
||||
twitchApiGetUserID(this->ui.usernameInput.text(), this, [=](const QString &userID) {
|
||||
this->ui.userIDInput.setText(userID); //
|
||||
connect(&this->ui_.buttonLowerRow.fillInUserIDButton, &QPushButton::clicked, [=]() {
|
||||
twitchApiGetUserID(this->ui_.usernameInput.text(), this, [=](const QString &userID) {
|
||||
this->ui_.userIDInput.setText(userID); //
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
void AdvancedLoginWidget::refreshButtons()
|
||||
{
|
||||
this->ui.buttonLowerRow.fillInUserIDButton.setEnabled(!this->ui.usernameInput.text().isEmpty());
|
||||
this->ui_.buttonLowerRow.fillInUserIDButton.setEnabled(
|
||||
!this->ui_.usernameInput.text().isEmpty());
|
||||
|
||||
if (this->ui.userIDInput.text().isEmpty() || this->ui.usernameInput.text().isEmpty() ||
|
||||
this->ui.clientIDInput.text().isEmpty() || this->ui.oauthTokenInput.text().isEmpty()) {
|
||||
this->ui.buttonUpperRow.addUserButton.setEnabled(false);
|
||||
if (this->ui_.userIDInput.text().isEmpty() || this->ui_.usernameInput.text().isEmpty() ||
|
||||
this->ui_.clientIDInput.text().isEmpty() || this->ui_.oauthTokenInput.text().isEmpty()) {
|
||||
this->ui_.buttonUpperRow.addUserButton.setEnabled(false);
|
||||
} else {
|
||||
this->ui.buttonUpperRow.addUserButton.setEnabled(true);
|
||||
this->ui_.buttonUpperRow.addUserButton.setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -197,21 +199,21 @@ LoginWidget::LoginWidget()
|
|||
SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
|
||||
#endif
|
||||
|
||||
this->setLayout(&this->ui.mainLayout);
|
||||
this->setLayout(&this->ui_.mainLayout);
|
||||
|
||||
this->ui.mainLayout.addWidget(&this->ui.tabWidget);
|
||||
this->ui_.mainLayout.addWidget(&this->ui_.tabWidget);
|
||||
|
||||
this->ui.tabWidget.addTab(&this->ui.basic, "Basic");
|
||||
this->ui_.tabWidget.addTab(&this->ui_.basic, "Basic");
|
||||
|
||||
this->ui.tabWidget.addTab(&this->ui.advanced, "Advanced");
|
||||
this->ui_.tabWidget.addTab(&this->ui_.advanced, "Advanced");
|
||||
|
||||
this->ui.buttonBox.setStandardButtons(QDialogButtonBox::Close);
|
||||
this->ui_.buttonBox.setStandardButtons(QDialogButtonBox::Close);
|
||||
|
||||
QObject::connect(&this->ui.buttonBox, &QDialogButtonBox::rejected, [this]() {
|
||||
QObject::connect(&this->ui_.buttonBox, &QDialogButtonBox::rejected, [this]() {
|
||||
this->close(); //
|
||||
});
|
||||
|
||||
this->ui.mainLayout.addWidget(&this->ui.buttonBox);
|
||||
this->ui_.mainLayout.addWidget(&this->ui_.buttonBox);
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -29,7 +29,7 @@ public:
|
|||
QHBoxLayout horizontalLayout;
|
||||
QPushButton loginButton;
|
||||
QPushButton pasteCodeButton;
|
||||
} ui;
|
||||
} ui_;
|
||||
};
|
||||
|
||||
class AdvancedLoginWidget : public QWidget
|
||||
|
@ -63,7 +63,7 @@ public:
|
|||
|
||||
QPushButton fillInUserIDButton;
|
||||
} buttonLowerRow;
|
||||
} ui;
|
||||
} ui_;
|
||||
};
|
||||
|
||||
class LoginWidget : public QDialog
|
||||
|
@ -82,7 +82,7 @@ private:
|
|||
BasicLoginWidget basic;
|
||||
|
||||
AdvancedLoginWidget advanced;
|
||||
} ui;
|
||||
} ui_;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -16,15 +16,15 @@ public:
|
|||
void setInfo(std::shared_ptr<Channel> channel, QString userName);
|
||||
|
||||
private:
|
||||
ChannelView *channelView_ = nullptr;
|
||||
ChannelPtr channel_ = Channel::getEmpty();
|
||||
|
||||
QString userName_;
|
||||
|
||||
void initLayout();
|
||||
void setMessages(std::vector<MessagePtr> &messages);
|
||||
void getOverrustleLogs();
|
||||
void getLogviewerLogs();
|
||||
|
||||
ChannelView *channelView_ = nullptr;
|
||||
ChannelPtr channel_ = Channel::getEmpty();
|
||||
|
||||
QString userName_;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -10,17 +10,17 @@ namespace chatterino {
|
|||
|
||||
NotificationPopup::NotificationPopup()
|
||||
: BaseWindow((QWidget *)nullptr, BaseWindow::Frameless)
|
||||
, channel(std::make_shared<Channel>("notifications", Channel::Type::None))
|
||||
, channel_(std::make_shared<Channel>("notifications", Channel::Type::None))
|
||||
|
||||
{
|
||||
this->channelView = new ChannelView(this);
|
||||
this->channelView_ = new ChannelView(this);
|
||||
|
||||
auto *layout = new QVBoxLayout(this);
|
||||
this->setLayout(layout);
|
||||
|
||||
layout->addWidget(this->channelView);
|
||||
layout->addWidget(this->channelView_);
|
||||
|
||||
this->channelView->setChannel(this->channel);
|
||||
this->channelView_->setChannel(this->channel_);
|
||||
this->setScaleIndependantSize(300, 150);
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ void NotificationPopup::updatePosition()
|
|||
|
||||
void NotificationPopup::addMessage(MessagePtr msg)
|
||||
{
|
||||
this->channel->addMessage(msg);
|
||||
this->channel_->addMessage(msg);
|
||||
|
||||
// QTimer::singleShot(5000, this, [this, msg] { this->channel->remove });
|
||||
}
|
||||
|
|
|
@ -18,8 +18,8 @@ public:
|
|||
void updatePosition();
|
||||
|
||||
private:
|
||||
ChannelView *channelView;
|
||||
ChannelPtr channel;
|
||||
ChannelView *channelView_;
|
||||
ChannelPtr channel_;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
namespace chatterino {
|
||||
|
||||
QualityPopup::QualityPopup(const QString &_channelName, QStringList options)
|
||||
: channelName(_channelName)
|
||||
: channelName_(_channelName)
|
||||
{
|
||||
this->ui_.okButton.setText("OK");
|
||||
this->ui_.cancelButton.setText("Cancel");
|
||||
|
@ -41,10 +41,10 @@ void QualityPopup::showDialog(const QString &channelName, QStringList options)
|
|||
|
||||
void QualityPopup::okButtonClicked()
|
||||
{
|
||||
QString channelURL = "twitch.tv/" + this->channelName;
|
||||
QString channelURL = "twitch.tv/" + this->channelName_;
|
||||
|
||||
try {
|
||||
OpenStreamlink(channelURL, this->ui_.selector.currentText());
|
||||
openStreamlink(channelURL, this->ui_.selector.currentText());
|
||||
} catch (const Exception &ex) {
|
||||
Log("Exception caught trying to open streamlink: {}", ex.what());
|
||||
}
|
||||
|
|
|
@ -16,6 +16,9 @@ public:
|
|||
static void showDialog(const QString &_channelName, QStringList options);
|
||||
|
||||
private:
|
||||
void okButtonClicked();
|
||||
void cancelButtonClicked();
|
||||
|
||||
struct {
|
||||
QVBoxLayout vbox;
|
||||
QComboBox selector;
|
||||
|
@ -24,10 +27,7 @@ private:
|
|||
QPushButton cancelButton;
|
||||
} ui_;
|
||||
|
||||
QString channelName;
|
||||
|
||||
void okButtonClicked();
|
||||
void cancelButtonClicked();
|
||||
QString channelName_;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -17,11 +17,11 @@ namespace chatterino {
|
|||
|
||||
SelectChannelDialog::SelectChannelDialog(QWidget *parent)
|
||||
: BaseWindow(parent, BaseWindow::EnableCustomFrame)
|
||||
, selectedChannel(Channel::getEmpty())
|
||||
, selectedChannel_(Channel::getEmpty())
|
||||
{
|
||||
this->setWindowTitle("Select a channel to join");
|
||||
|
||||
this->tabFilter.dialog = this;
|
||||
this->tabFilter_.dialog = this;
|
||||
|
||||
LayoutCreator<QWidget> layoutWidget(this->getLayoutContainer());
|
||||
auto layout = layoutWidget.setLayoutType<QVBoxLayout>().withoutMargin();
|
||||
|
@ -50,8 +50,8 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent)
|
|||
channel_lbl->setVisible(enabled);
|
||||
});
|
||||
|
||||
channel_btn->installEventFilter(&this->tabFilter);
|
||||
channel_edit->installEventFilter(&this->tabFilter);
|
||||
channel_btn->installEventFilter(&this->tabFilter_);
|
||||
channel_edit->installEventFilter(&this->tabFilter_);
|
||||
|
||||
// whispers_btn
|
||||
auto whispers_btn =
|
||||
|
@ -61,7 +61,7 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent)
|
|||
.hidden();
|
||||
|
||||
whispers_lbl->setWordWrap(true);
|
||||
whispers_btn->installEventFilter(&this->tabFilter);
|
||||
whispers_btn->installEventFilter(&this->tabFilter_);
|
||||
|
||||
QObject::connect(whispers_btn.getElement(), &QRadioButton::toggled,
|
||||
[=](bool enabled) mutable { whispers_lbl->setVisible(enabled); });
|
||||
|
@ -74,7 +74,7 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent)
|
|||
.hidden();
|
||||
|
||||
mentions_lbl->setWordWrap(true);
|
||||
mentions_btn->installEventFilter(&this->tabFilter);
|
||||
mentions_btn->installEventFilter(&this->tabFilter_);
|
||||
|
||||
QObject::connect(mentions_btn.getElement(), &QRadioButton::toggled,
|
||||
[=](bool enabled) mutable { mentions_lbl->setVisible(enabled); });
|
||||
|
@ -86,7 +86,7 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent)
|
|||
vbox.emplace<QLabel>("Requires the chatterino browser extension.").hidden();
|
||||
|
||||
watching_lbl->setWordWrap(true);
|
||||
watching_btn->installEventFilter(&this->tabFilter);
|
||||
watching_btn->installEventFilter(&this->tabFilter_);
|
||||
|
||||
QObject::connect(watching_btn.getElement(), &QRadioButton::toggled,
|
||||
[=](bool enabled) mutable { watching_lbl->setVisible(enabled); });
|
||||
|
@ -138,7 +138,7 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent)
|
|||
|
||||
void SelectChannelDialog::ok()
|
||||
{
|
||||
this->_hasSelectedChannel = true;
|
||||
this->hasSelectedChannel_ = true;
|
||||
this->close();
|
||||
}
|
||||
|
||||
|
@ -148,7 +148,7 @@ void SelectChannelDialog::setSelectedChannel(IndirectChannel _channel)
|
|||
|
||||
assert(channel);
|
||||
|
||||
this->selectedChannel = channel;
|
||||
this->selectedChannel_ = channel;
|
||||
|
||||
switch (_channel.getType()) {
|
||||
case Channel::Type::Twitch: {
|
||||
|
@ -174,13 +174,13 @@ void SelectChannelDialog::setSelectedChannel(IndirectChannel _channel)
|
|||
}
|
||||
}
|
||||
|
||||
this->_hasSelectedChannel = false;
|
||||
this->hasSelectedChannel_ = false;
|
||||
}
|
||||
|
||||
IndirectChannel SelectChannelDialog::getSelectedChannel() const
|
||||
{
|
||||
if (!this->_hasSelectedChannel) {
|
||||
return this->selectedChannel;
|
||||
if (!this->hasSelectedChannel_) {
|
||||
return this->selectedChannel_;
|
||||
}
|
||||
|
||||
auto app = getApp();
|
||||
|
@ -199,12 +199,12 @@ IndirectChannel SelectChannelDialog::getSelectedChannel() const
|
|||
}
|
||||
}
|
||||
|
||||
return this->selectedChannel;
|
||||
return this->selectedChannel_;
|
||||
}
|
||||
|
||||
bool SelectChannelDialog::hasSeletedChannel() const
|
||||
{
|
||||
return this->_hasSelectedChannel;
|
||||
return this->hasSelectedChannel_;
|
||||
}
|
||||
|
||||
bool SelectChannelDialog::EventFilter::eventFilter(QObject *watched, QEvent *event)
|
||||
|
|
|
@ -16,7 +16,7 @@ class SelectChannelDialog : public BaseWindow
|
|||
public:
|
||||
SelectChannelDialog(QWidget *parent = nullptr);
|
||||
|
||||
void setSelectedChannel(IndirectChannel selectedChannel);
|
||||
void setSelectedChannel(IndirectChannel selectedChannel_);
|
||||
IndirectChannel getSelectedChannel() const;
|
||||
bool hasSeletedChannel() const;
|
||||
|
||||
|
@ -47,10 +47,10 @@ private:
|
|||
} twitch;
|
||||
} ui_;
|
||||
|
||||
EventFilter tabFilter;
|
||||
EventFilter tabFilter_;
|
||||
|
||||
ChannelPtr selectedChannel;
|
||||
bool _hasSelectedChannel = false;
|
||||
ChannelPtr selectedChannel_;
|
||||
bool hasSelectedChannel_ = false;
|
||||
|
||||
void ok();
|
||||
friend class EventFilter;
|
||||
|
|
|
@ -28,7 +28,6 @@ SettingsDialog::SettingsDialog()
|
|||
: BaseWindow(nullptr, BaseWindow::DisableCustomScaling)
|
||||
{
|
||||
this->initUi();
|
||||
|
||||
this->addTabs();
|
||||
|
||||
this->scaleChangedEvent(this->getScale());
|
||||
|
@ -63,10 +62,9 @@ void SettingsDialog::initUi()
|
|||
this->ui_.tabContainerContainer->setObjectName("tabWidget");
|
||||
this->ui_.pageStack->setObjectName("pages");
|
||||
|
||||
QObject::connect(this->ui_.okButton, &QPushButton::clicked, this,
|
||||
&SettingsDialog::okButtonClicked);
|
||||
QObject::connect(this->ui_.okButton, &QPushButton::clicked, this, &SettingsDialog::onOkClicked);
|
||||
QObject::connect(this->ui_.cancelButton, &QPushButton::clicked, this,
|
||||
&SettingsDialog::cancelButtonClicked);
|
||||
&SettingsDialog::onCancelClicked);
|
||||
}
|
||||
|
||||
SettingsDialog *SettingsDialog::getHandle()
|
||||
|
@ -111,25 +109,25 @@ void SettingsDialog::addTab(SettingsPage *page, Qt::Alignment alignment)
|
|||
|
||||
this->ui_.pageStack->addWidget(page);
|
||||
this->ui_.tabContainer->addWidget(tab, 0, alignment);
|
||||
this->tabs.push_back(tab);
|
||||
this->tabs_.push_back(tab);
|
||||
|
||||
if (this->tabs.size() == 1) {
|
||||
this->select(tab);
|
||||
if (this->tabs_.size() == 1) {
|
||||
this->selectTab(tab);
|
||||
}
|
||||
}
|
||||
|
||||
void SettingsDialog::select(SettingsDialogTab *tab)
|
||||
void SettingsDialog::selectTab(SettingsDialogTab *tab)
|
||||
{
|
||||
this->ui_.pageStack->setCurrentWidget(tab->getSettingsPage());
|
||||
|
||||
if (this->selectedTab != nullptr) {
|
||||
this->selectedTab->setSelected(false);
|
||||
this->selectedTab->setStyleSheet("color: #FFF");
|
||||
if (this->selectedTab_ != nullptr) {
|
||||
this->selectedTab_->setSelected(false);
|
||||
this->selectedTab_->setStyleSheet("color: #FFF");
|
||||
}
|
||||
|
||||
tab->setSelected(true);
|
||||
tab->setStyleSheet("background: #555; color: #FFF");
|
||||
this->selectedTab = tab;
|
||||
this->selectedTab_ = tab;
|
||||
}
|
||||
|
||||
void SettingsDialog::showDialog(PreferredTab preferredTab)
|
||||
|
@ -139,7 +137,7 @@ void SettingsDialog::showDialog(PreferredTab preferredTab)
|
|||
|
||||
switch (preferredTab) {
|
||||
case SettingsDialog::PreferredTab::Accounts: {
|
||||
instance->select(instance->tabs.at(0));
|
||||
instance->selectTab(instance->tabs_.at(0));
|
||||
} break;
|
||||
}
|
||||
|
||||
|
@ -153,7 +151,7 @@ void SettingsDialog::refresh()
|
|||
{
|
||||
getApp()->settings->saveSnapshot();
|
||||
|
||||
for (auto *tab : this->tabs) {
|
||||
for (auto *tab : this->tabs_) {
|
||||
tab->getSettingsPage()->onShow();
|
||||
}
|
||||
}
|
||||
|
@ -166,7 +164,7 @@ void SettingsDialog::scaleChangedEvent(float newDpi)
|
|||
styleSheet.replace("<font-size>", QString::number(int(14 * newDpi)));
|
||||
styleSheet.replace("<checkbox-size>", QString::number(int(14 * newDpi)));
|
||||
|
||||
for (SettingsDialogTab *tab : this->tabs) {
|
||||
for (SettingsDialogTab *tab : this->tabs_) {
|
||||
tab->setFixedHeight(int(30 * newDpi));
|
||||
}
|
||||
|
||||
|
@ -185,14 +183,14 @@ void SettingsDialog::themeChangedEvent()
|
|||
}
|
||||
|
||||
///// Widget creation helpers
|
||||
void SettingsDialog::okButtonClicked()
|
||||
void SettingsDialog::onOkClicked()
|
||||
{
|
||||
this->close();
|
||||
}
|
||||
|
||||
void SettingsDialog::cancelButtonClicked()
|
||||
void SettingsDialog::onCancelClicked()
|
||||
{
|
||||
for (auto &tab : this->tabs) {
|
||||
for (auto &tab : this->tabs_) {
|
||||
tab->getSettingsPage()->cancel();
|
||||
}
|
||||
|
||||
|
|
|
@ -32,9 +32,18 @@ protected:
|
|||
virtual void themeChangedEvent() override;
|
||||
|
||||
private:
|
||||
void refresh();
|
||||
static SettingsDialog *handle;
|
||||
|
||||
void refresh();
|
||||
|
||||
void initUi();
|
||||
void addTabs();
|
||||
void addTab(SettingsPage *page, Qt::Alignment alignment = Qt::AlignTop);
|
||||
void selectTab(SettingsDialogTab *tab);
|
||||
|
||||
void onOkClicked();
|
||||
void onCancelClicked();
|
||||
|
||||
struct {
|
||||
QWidget *tabContainerContainer;
|
||||
QVBoxLayout *tabContainer;
|
||||
|
@ -42,23 +51,10 @@ private:
|
|||
QPushButton *okButton;
|
||||
QPushButton *cancelButton;
|
||||
} ui_;
|
||||
|
||||
std::vector<SettingsDialogTab *> tabs;
|
||||
|
||||
void initUi();
|
||||
void addTabs();
|
||||
void addTab(SettingsPage *page, Qt::Alignment alignment = Qt::AlignTop);
|
||||
|
||||
void select(SettingsDialogTab *tab);
|
||||
|
||||
SettingsDialogTab *selectedTab = nullptr;
|
||||
|
||||
void okButtonClicked();
|
||||
void cancelButtonClicked();
|
||||
std::vector<SettingsDialogTab *> tabs_;
|
||||
SettingsDialogTab *selectedTab_ = nullptr;
|
||||
|
||||
friend class SettingsDialogTab;
|
||||
|
||||
// static void setChildrensFont(QLayout *object, QFont &font, int indent = 0);
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -5,40 +5,50 @@ namespace chatterino {
|
|||
|
||||
TextInputDialog::TextInputDialog(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, _vbox(this)
|
||||
, _okButton("OK")
|
||||
, _cancelButton("Cancel")
|
||||
, vbox_(this)
|
||||
, okButton_("OK")
|
||||
, cancelButton_("Cancel")
|
||||
{
|
||||
_vbox.addWidget(&_lineEdit);
|
||||
_vbox.addLayout(&_buttonBox);
|
||||
_buttonBox.addStretch(1);
|
||||
_buttonBox.addWidget(&_okButton);
|
||||
_buttonBox.addWidget(&_cancelButton);
|
||||
this->vbox_.addWidget(&lineEdit_);
|
||||
this->vbox_.addLayout(&buttonBox_);
|
||||
this->buttonBox_.addStretch(1);
|
||||
this->buttonBox_.addWidget(&okButton_);
|
||||
this->buttonBox_.addWidget(&cancelButton_);
|
||||
|
||||
QObject::connect(&_okButton, SIGNAL(clicked()), this, SLOT(okButtonClicked()));
|
||||
QObject::connect(&_cancelButton, SIGNAL(clicked()), this, SLOT(cancelButtonClicked()));
|
||||
QObject::connect(&this->okButton_, SIGNAL(clicked()), this, SLOT(okButtonClicked()));
|
||||
QObject::connect(&this->cancelButton_, SIGNAL(clicked()), this, SLOT(cancelButtonClicked()));
|
||||
|
||||
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
|
||||
setWindowFlags((windowFlags() & ~(Qt::WindowContextHelpButtonHint)) | Qt::Dialog |
|
||||
Qt::MSWindowsFixedSizeDialogHint);
|
||||
this->setWindowFlags((this->windowFlags() & ~(Qt::WindowContextHelpButtonHint)) | Qt::Dialog |
|
||||
Qt::MSWindowsFixedSizeDialogHint);
|
||||
}
|
||||
|
||||
QString TextInputDialog::getText() const
|
||||
{
|
||||
return this->lineEdit_.text();
|
||||
}
|
||||
|
||||
void TextInputDialog::setText(const QString &text)
|
||||
{
|
||||
this->lineEdit_.setText(text);
|
||||
}
|
||||
|
||||
void TextInputDialog::okButtonClicked()
|
||||
{
|
||||
accept();
|
||||
close();
|
||||
this->accept();
|
||||
this->close();
|
||||
}
|
||||
|
||||
void TextInputDialog::cancelButtonClicked()
|
||||
{
|
||||
reject();
|
||||
close();
|
||||
this->reject();
|
||||
this->close();
|
||||
}
|
||||
|
||||
void TextInputDialog::highlightText()
|
||||
{
|
||||
this->_lineEdit.selectAll();
|
||||
this->lineEdit_.selectAll();
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -16,24 +16,17 @@ class TextInputDialog : public QDialog
|
|||
public:
|
||||
TextInputDialog(QWidget *parent = nullptr);
|
||||
|
||||
QString getText() const
|
||||
{
|
||||
return _lineEdit.text();
|
||||
}
|
||||
|
||||
void setText(const QString &text)
|
||||
{
|
||||
_lineEdit.setText(text);
|
||||
}
|
||||
QString getText() const;
|
||||
void setText(const QString &text);
|
||||
|
||||
void highlightText();
|
||||
|
||||
private:
|
||||
QVBoxLayout _vbox;
|
||||
QLineEdit _lineEdit;
|
||||
QHBoxLayout _buttonBox;
|
||||
QPushButton _okButton;
|
||||
QPushButton _cancelButton;
|
||||
QVBoxLayout vbox_;
|
||||
QLineEdit lineEdit_;
|
||||
QHBoxLayout buttonBox_;
|
||||
QPushButton okButton_;
|
||||
QPushButton cancelButton_;
|
||||
|
||||
private slots:
|
||||
void okButtonClicked();
|
||||
|
|
|
@ -94,7 +94,7 @@ UserInfoPopup::UserInfoPopup()
|
|||
[this] { this->channel_->sendMessage("/unmod " + this->userName_); });
|
||||
|
||||
// userstate
|
||||
this->userStateChanged.connect([this, mod, unmod]() mutable {
|
||||
this->userStateChanged_.connect([this, mod, unmod]() mutable {
|
||||
TwitchChannel *twitchChannel = dynamic_cast<TwitchChannel *>(this->channel_.get());
|
||||
|
||||
if (twitchChannel) {
|
||||
|
@ -118,7 +118,7 @@ UserInfoPopup::UserInfoPopup()
|
|||
{
|
||||
auto timeout = moderation.emplace<TimeoutWidget>();
|
||||
|
||||
this->userStateChanged.connect([this, lineMod, timeout]() mutable {
|
||||
this->userStateChanged_.connect([this, lineMod, timeout]() mutable {
|
||||
TwitchChannel *twitchChannel = dynamic_cast<TwitchChannel *>(this->channel_.get());
|
||||
|
||||
if (twitchChannel) {
|
||||
|
@ -232,7 +232,7 @@ void UserInfoPopup::setData(const QString &name, const ChannelPtr &channel)
|
|||
|
||||
this->updateUserData();
|
||||
|
||||
this->userStateChanged.invoke();
|
||||
this->userStateChanged_.invoke();
|
||||
}
|
||||
|
||||
void UserInfoPopup::updateUserData()
|
||||
|
|
|
@ -24,6 +24,10 @@ protected:
|
|||
virtual void themeChangedEvent() override;
|
||||
|
||||
private:
|
||||
void installEvents();
|
||||
void updateUserData();
|
||||
|
||||
void loadAvatar(const QUrl &url);
|
||||
bool isMod_;
|
||||
bool isBroadcaster_;
|
||||
|
||||
|
@ -31,12 +35,7 @@ private:
|
|||
QString userId_;
|
||||
ChannelPtr channel_;
|
||||
|
||||
pajlada::Signals::NoArgSignal userStateChanged;
|
||||
|
||||
void installEvents();
|
||||
|
||||
void updateUserData();
|
||||
void loadAvatar(const QUrl &url);
|
||||
pajlada::Signals::NoArgSignal userStateChanged_;
|
||||
|
||||
std::shared_ptr<bool> hack_;
|
||||
|
||||
|
|
|
@ -70,13 +70,26 @@ protected:
|
|||
|
||||
void hideEvent(QHideEvent *) override;
|
||||
|
||||
void handleLinkClick(QMouseEvent *event, const Link &link,
|
||||
MessageLayout *layout);
|
||||
void handleLinkClick(QMouseEvent *event, const Link &link, MessageLayout *layout);
|
||||
|
||||
bool tryGetMessageAt(QPoint p, std::shared_ptr<MessageLayout> &message,
|
||||
QPoint &relativePos, int &index);
|
||||
bool tryGetMessageAt(QPoint p, std::shared_ptr<MessageLayout> &message, QPoint &relativePos,
|
||||
int &index);
|
||||
|
||||
private:
|
||||
void updatePauseStatus();
|
||||
void detachChannel();
|
||||
void actuallyLayoutMessages(bool causedByScollbar = false);
|
||||
|
||||
void drawMessages(QPainter &painter);
|
||||
void setSelection(const SelectionItem &start, const SelectionItem &end);
|
||||
MessageElement::Flags getFlags() const;
|
||||
bool isPaused();
|
||||
|
||||
void handleMouseClick(QMouseEvent *event, const MessageLayoutElement *hoverLayoutElement,
|
||||
MessageLayout *layout);
|
||||
void addContextMenuItems(const MessageLayoutElement *hoveredElement, MessageLayout *layout);
|
||||
int getLayoutWidth() const;
|
||||
|
||||
QTimer *layoutCooldown_;
|
||||
bool layoutQueued_;
|
||||
|
||||
|
@ -88,7 +101,6 @@ private:
|
|||
bool pausedTemporarily_ = false;
|
||||
bool pausedBySelection_ = false;
|
||||
bool pausedByScrollingUp_ = false;
|
||||
void updatePauseStatus();
|
||||
int messagesAddedSinceSelectionPause_ = 0;
|
||||
|
||||
QTimer pauseTimeout_;
|
||||
|
@ -97,23 +109,6 @@ private:
|
|||
|
||||
LimitedQueueSnapshot<MessageLayoutPtr> snapshot_;
|
||||
|
||||
void detachChannel();
|
||||
void actuallyLayoutMessages(bool causedByScollbar = false);
|
||||
|
||||
void drawMessages(QPainter &painter);
|
||||
void setSelection(const SelectionItem &start, const SelectionItem &end);
|
||||
MessageElement::Flags getFlags() const;
|
||||
bool isPaused();
|
||||
|
||||
void handleMouseClick(QMouseEvent *event,
|
||||
const MessageLayoutElement *hoverLayoutElement,
|
||||
MessageLayout *layout);
|
||||
void addContextMenuItems(const MessageLayoutElement *hoveredElement,
|
||||
MessageLayout *layout);
|
||||
|
||||
// void beginPause();
|
||||
// void endPause();
|
||||
|
||||
ChannelPtr channel_;
|
||||
|
||||
Scrollbar scrollBar_;
|
||||
|
@ -149,8 +144,6 @@ private:
|
|||
|
||||
std::unordered_set<std::shared_ptr<MessageLayout>> messagesOnScreen_;
|
||||
|
||||
int getLayoutWidth() const;
|
||||
|
||||
private slots:
|
||||
void wordFlagsChanged()
|
||||
{
|
||||
|
|
|
@ -11,7 +11,7 @@ class ComboBoxItemDelegate : public QStyledItemDelegate
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ComboBoxItemDelegate(QObject *parent = 0);
|
||||
ComboBoxItemDelegate(QObject *parent = nullptr);
|
||||
~ComboBoxItemDelegate();
|
||||
|
||||
virtual QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
//#include "DropOverlay.hpp"
|
||||
|
||||
// namespace chatterino {
|
||||
// namespace widgets {
|
||||
// namespace helper {
|
||||
|
||||
// DropOverlay::DropOverlay()
|
||||
//{
|
||||
//}
|
||||
|
||||
//} // namespace helper
|
||||
//} // namespace widgets
|
||||
//} // namespace chatterino
|
|
@ -1,11 +0,0 @@
|
|||
//#pragma once
|
||||
|
||||
//#include "widgets/helper/SplitNode.hpp"
|
||||
|
||||
// namespace chatterino {
|
||||
// namespace widgets {
|
||||
// namespace helper {
|
||||
|
||||
//} // namespace helper
|
||||
//} // namespace widgets
|
||||
//} // namespace chatterino
|
|
@ -1,53 +0,0 @@
|
|||
#include "widgets/helper/DropPreview.hpp"
|
||||
#include "Application.hpp"
|
||||
#include "singletons/Theme.hpp"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QPainter>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
NotebookPageDropPreview::NotebookPageDropPreview(BaseWidget *parent)
|
||||
: BaseWidget(parent)
|
||||
// , positionAnimation(this, "geometry")
|
||||
{
|
||||
// this->positionAnimation.setEasingCurve(QEasingCurve(QEasingCurve::InCubic));
|
||||
this->setHidden(true);
|
||||
}
|
||||
|
||||
void NotebookPageDropPreview::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QPainter painter(this);
|
||||
|
||||
painter.setPen(getApp()->themes->splits.dropPreviewBorder);
|
||||
painter.setBrush(getApp()->themes->splits.dropPreview);
|
||||
painter.drawRect(8, 8, this->width() - 17, this->height() - 17);
|
||||
}
|
||||
|
||||
void NotebookPageDropPreview::hideEvent(QHideEvent *)
|
||||
{
|
||||
// this->animate = false;
|
||||
}
|
||||
|
||||
void NotebookPageDropPreview::setBounds(const QRect &rect)
|
||||
{
|
||||
// if (rect == this->desiredGeometry) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// if (this->animate) {
|
||||
// this->positionAnimation.stop();
|
||||
// this->positionAnimation.setDuration(50);
|
||||
// this->positionAnimation.setStartValue(this->geometry());
|
||||
// this->positionAnimation.setEndValue(rect);
|
||||
// this->positionAnimation.start();
|
||||
// } else {
|
||||
this->setGeometry(rect);
|
||||
// }
|
||||
|
||||
// this->desiredGeometry = rect;
|
||||
|
||||
// this->animate = true;
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
|
@ -1,26 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "widgets/BaseWidget.hpp"
|
||||
|
||||
#include <QPropertyAnimation>
|
||||
#include <QWidget>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
class NotebookPageDropPreview : public BaseWidget
|
||||
{
|
||||
public:
|
||||
NotebookPageDropPreview(BaseWidget *parent);
|
||||
|
||||
void setBounds(const QRect &rect);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *) override;
|
||||
void hideEvent(QHideEvent *) override;
|
||||
|
||||
// QPropertyAnimation positionAnimation;
|
||||
// QRect desiredGeometry;
|
||||
// bool animate = false;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
|
@ -9,20 +9,20 @@
|
|||
|
||||
namespace chatterino {
|
||||
|
||||
EditableModelView::EditableModelView(QAbstractTableModel *_model)
|
||||
: tableView(new QTableView(this))
|
||||
, model(_model)
|
||||
EditableModelView::EditableModelView(QAbstractTableModel *model)
|
||||
: tableView_(new QTableView(this))
|
||||
, model_(model)
|
||||
{
|
||||
this->model->setParent(this);
|
||||
this->tableView->setModel(_model);
|
||||
this->tableView->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
this->tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
this->tableView->verticalHeader()->hide();
|
||||
this->model_->setParent(this);
|
||||
this->tableView_->setModel(model);
|
||||
this->tableView_->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
this->tableView_->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
this->tableView_->verticalHeader()->hide();
|
||||
|
||||
// create layout
|
||||
QVBoxLayout *vbox = new QVBoxLayout(this);
|
||||
vbox->setMargin(0);
|
||||
vbox->addWidget(this->tableView);
|
||||
vbox->addWidget(this->tableView_);
|
||||
|
||||
// create button layout
|
||||
QHBoxLayout *buttons = new QHBoxLayout(this);
|
||||
|
@ -39,7 +39,7 @@ EditableModelView::EditableModelView(QAbstractTableModel *_model)
|
|||
QObject::connect(remove, &QPushButton::clicked, [this] {
|
||||
QModelIndexList list;
|
||||
while ((list = this->getTableView()->selectionModel()->selectedRows(0)).length() > 0) {
|
||||
model->removeRow(list[0].row());
|
||||
model_->removeRow(list[0].row());
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -51,22 +51,22 @@ void EditableModelView::setTitles(std::initializer_list<QString> titles)
|
|||
{
|
||||
int i = 0;
|
||||
for (const QString &title : titles) {
|
||||
if (this->model->columnCount() == i) {
|
||||
if (this->model_->columnCount() == i) {
|
||||
break;
|
||||
}
|
||||
|
||||
this->model->setHeaderData(i++, Qt::Horizontal, title, Qt::DisplayRole);
|
||||
this->model_->setHeaderData(i++, Qt::Horizontal, title, Qt::DisplayRole);
|
||||
}
|
||||
}
|
||||
|
||||
QTableView *EditableModelView::getTableView()
|
||||
{
|
||||
return this->tableView;
|
||||
return this->tableView_;
|
||||
}
|
||||
|
||||
QAbstractTableModel *EditableModelView::getModel()
|
||||
{
|
||||
return this->model;
|
||||
return this->model_;
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue