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