mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Compare commits
6 commits
dec2ec8ad6
...
0bd80f4886
Author | SHA1 | Date | |
---|---|---|---|
|
0bd80f4886 | ||
|
90211cca55 | ||
|
bbcd8c5eb2 | ||
|
f54bdf939a | ||
|
adf124c11b | ||
|
74101d40f5 |
28 changed files with 392 additions and 143 deletions
|
@ -72,6 +72,7 @@
|
||||||
- Dev: Refactor and document `Scrollbar`. (#5334, #5393)
|
- Dev: Refactor and document `Scrollbar`. (#5334, #5393)
|
||||||
- Dev: Refactor `TwitchIrcServer`, making it abstracted. (#5421, #5435)
|
- Dev: Refactor `TwitchIrcServer`, making it abstracted. (#5421, #5435)
|
||||||
- Dev: Reduced the amount of scale events. (#5404, #5406)
|
- Dev: Reduced the amount of scale events. (#5404, #5406)
|
||||||
|
- Dev: Refactored settings widget creation. (#5585)
|
||||||
- Dev: Removed unused timegate settings. (#5361)
|
- Dev: Removed unused timegate settings. (#5361)
|
||||||
- Dev: Add `Channel::addSystemMessage` helper function, allowing us to avoid the common `channel->addMessage(makeSystemMessage(...));` pattern. (#5500)
|
- Dev: Add `Channel::addSystemMessage` helper function, allowing us to avoid the common `channel->addMessage(makeSystemMessage(...));` pattern. (#5500)
|
||||||
- Dev: Unsingletonize `Resources2`. (#5460)
|
- Dev: Unsingletonize `Resources2`. (#5460)
|
||||||
|
@ -114,6 +115,7 @@
|
||||||
- Dev: Refactored static `MessageBuilder` helpers to standalone functions. (#5652)
|
- Dev: Refactored static `MessageBuilder` helpers to standalone functions. (#5652)
|
||||||
- Dev: Decoupled reply parsing from `MessageBuilder`. (#5660, #5668)
|
- Dev: Decoupled reply parsing from `MessageBuilder`. (#5660, #5668)
|
||||||
- Dev: Refactored IRC message building. (#5663)
|
- Dev: Refactored IRC message building. (#5663)
|
||||||
|
- Dev: Fixed some compiler warnings. (#5672)
|
||||||
|
|
||||||
## 2.5.1
|
## 2.5.1
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
cmake_minimum_required(VERSION 3.15)
|
cmake_minimum_required(VERSION 3.15)
|
||||||
cmake_policy(SET CMP0087 NEW) # evaluates generator expressions in `install(CODE/SCRIPT)`
|
cmake_policy(SET CMP0087 NEW) # evaluates generator expressions in `install(CODE/SCRIPT)`
|
||||||
cmake_policy(SET CMP0091 NEW) # select MSVC runtime library through `CMAKE_MSVC_RUNTIME_LIBRARY`
|
cmake_policy(SET CMP0091 NEW) # select MSVC runtime library through `CMAKE_MSVC_RUNTIME_LIBRARY`
|
||||||
|
if (POLICY CMP0167)
|
||||||
|
cmake_policy(SET CMP0167 NEW) # find Boost's own CMake config file
|
||||||
|
endif ()
|
||||||
include(FeatureSummary)
|
include(FeatureSummary)
|
||||||
|
|
||||||
list(APPEND CMAKE_MODULE_PATH
|
list(APPEND CMAKE_MODULE_PATH
|
||||||
|
|
|
@ -350,7 +350,7 @@ public:
|
||||||
// contains a comma
|
// contains a comma
|
||||||
MOCK_METHOD(
|
MOCK_METHOD(
|
||||||
void, getChatters,
|
void, getChatters,
|
||||||
(QString broadcasterID, QString moderatorID, int maxChattersToFetch,
|
(QString broadcasterID, QString moderatorID, size_t maxChattersToFetch,
|
||||||
ResultCallback<HelixChatters> successCallback,
|
ResultCallback<HelixChatters> successCallback,
|
||||||
(FailureCallback<HelixGetChattersError, QString> failureCallback)),
|
(FailureCallback<HelixGetChattersError, QString> failureCallback)),
|
||||||
(override)); // getChatters
|
(override)); // getChatters
|
||||||
|
|
|
@ -61,6 +61,11 @@ chatterino--DescriptionLabel {
|
||||||
color: #999;
|
color: #999;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QLabel#description {
|
||||||
|
color: #999;
|
||||||
|
padding-left: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
chatterino--NavigationLabel {
|
chatterino--NavigationLabel {
|
||||||
font-family: "Segoe UI light";
|
font-family: "Segoe UI light";
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
|
|
|
@ -2,6 +2,7 @@ set(LIBRARY_PROJECT "${PROJECT_NAME}-lib")
|
||||||
set(VERSION_PROJECT "${LIBRARY_PROJECT}-version")
|
set(VERSION_PROJECT "${LIBRARY_PROJECT}-version")
|
||||||
set(EXECUTABLE_PROJECT "${PROJECT_NAME}")
|
set(EXECUTABLE_PROJECT "${PROJECT_NAME}")
|
||||||
add_compile_definitions(QT_DISABLE_DEPRECATED_BEFORE=0x050F00)
|
add_compile_definitions(QT_DISABLE_DEPRECATED_BEFORE=0x050F00)
|
||||||
|
add_compile_definitions(QT_WARN_DEPRECATED_UP_TO=0x050F00)
|
||||||
|
|
||||||
# registers the native messageing host
|
# registers the native messageing host
|
||||||
option(CHATTERINO_DEBUG_NATIVE_MESSAGES "Debug native messages" OFF)
|
option(CHATTERINO_DEBUG_NATIVE_MESSAGES "Debug native messages" OFF)
|
||||||
|
@ -713,6 +714,8 @@ set(SOURCE_FILES
|
||||||
widgets/settingspages/PluginsPage.hpp
|
widgets/settingspages/PluginsPage.hpp
|
||||||
widgets/settingspages/SettingsPage.cpp
|
widgets/settingspages/SettingsPage.cpp
|
||||||
widgets/settingspages/SettingsPage.hpp
|
widgets/settingspages/SettingsPage.hpp
|
||||||
|
widgets/settingspages/SettingWidget.cpp
|
||||||
|
widgets/settingspages/SettingWidget.hpp
|
||||||
|
|
||||||
widgets/splits/ClosedSplits.cpp
|
widgets/splits/ClosedSplits.cpp
|
||||||
widgets/splits/ClosedSplits.hpp
|
widgets/splits/ClosedSplits.hpp
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
enum class ProviderId { Twitch, Irc };
|
enum class ProviderId { // NOLINT(performance-enum-size)
|
||||||
|
Twitch,
|
||||||
|
};
|
||||||
//
|
//
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -87,7 +87,8 @@ public:
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
assert(index >= 0 && index <= this->items_.size());
|
assert(index >= 0 &&
|
||||||
|
index <= static_cast<int>(this->items_.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
this->items_.insert(this->items_.begin() + index, item);
|
this->items_.insert(this->items_.begin() + index, item);
|
||||||
|
@ -116,7 +117,7 @@ public:
|
||||||
void removeAt(int index, void *caller = nullptr)
|
void removeAt(int index, void *caller = nullptr)
|
||||||
{
|
{
|
||||||
assertInGuiThread();
|
assertInGuiThread();
|
||||||
assert(index >= 0 && index < int(this->items_.size()));
|
assert(index >= 0 && index < static_cast<int>(this->items_.size()));
|
||||||
|
|
||||||
T item = this->items_[index];
|
T item = this->items_[index];
|
||||||
this->items_.erase(this->items_.begin() + index);
|
this->items_.erase(this->items_.begin() + index);
|
||||||
|
@ -132,13 +133,14 @@ public:
|
||||||
{
|
{
|
||||||
assertInGuiThread();
|
assertInGuiThread();
|
||||||
|
|
||||||
for (int index = 0; index < this->items_.size(); ++index)
|
for (size_t index = 0; index < this->items_.size(); ++index)
|
||||||
{
|
{
|
||||||
T item = this->items_[index];
|
T item = this->items_[index];
|
||||||
if (matcher(item))
|
if (matcher(item))
|
||||||
{
|
{
|
||||||
this->items_.erase(this->items_.begin() + index);
|
this->items_.erase(this->items_.begin() + index);
|
||||||
SignalVectorItemEvent<T> args{item, index, caller};
|
SignalVectorItemEvent<T> args{item, static_cast<int>(index),
|
||||||
|
caller};
|
||||||
this->itemRemoved.invoke(args);
|
this->itemRemoved.invoke(args);
|
||||||
this->itemsChanged_();
|
this->itemsChanged_();
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -43,7 +43,7 @@ public:
|
||||||
}
|
}
|
||||||
// get row index
|
// get row index
|
||||||
int index = this->getModelIndexFromVectorIndex(args.index);
|
int index = this->getModelIndexFromVectorIndex(args.index);
|
||||||
assert(index >= 0 && index <= this->rows_.size());
|
assert(index >= 0 && index <= static_cast<int>(this->rows_.size()));
|
||||||
|
|
||||||
// get row items
|
// get row items
|
||||||
std::vector<QStandardItem *> row = this->createRow();
|
std::vector<QStandardItem *> row = this->createRow();
|
||||||
|
@ -75,7 +75,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
int row = this->getModelIndexFromVectorIndex(args.index);
|
int row = this->getModelIndexFromVectorIndex(args.index);
|
||||||
assert(row >= 0 && row <= this->rows_.size());
|
assert(row >= 0 && row <= static_cast<int>(this->rows_.size()));
|
||||||
|
|
||||||
// remove row
|
// remove row
|
||||||
std::vector<QStandardItem *> items = this->rows_[row].items;
|
std::vector<QStandardItem *> items = this->rows_[row].items;
|
||||||
|
@ -130,7 +130,8 @@ public:
|
||||||
{
|
{
|
||||||
int row = index.row();
|
int row = index.row();
|
||||||
int column = index.column();
|
int column = index.column();
|
||||||
if (row < 0 || column < 0 || row >= this->rows_.size() ||
|
if (row < 0 || column < 0 ||
|
||||||
|
row >= static_cast<int>(this->rows_.size()) ||
|
||||||
column >= this->columnCount_)
|
column >= this->columnCount_)
|
||||||
{
|
{
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
@ -144,7 +145,8 @@ public:
|
||||||
{
|
{
|
||||||
int row = index.row();
|
int row = index.row();
|
||||||
int column = index.column();
|
int column = index.column();
|
||||||
if (row < 0 || column < 0 || row >= this->rows_.size() ||
|
if (row < 0 || column < 0 ||
|
||||||
|
row >= static_cast<int>(this->rows_.size()) ||
|
||||||
column >= this->columnCount_)
|
column >= this->columnCount_)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -152,7 +154,7 @@ public:
|
||||||
|
|
||||||
Row &rowItem = this->rows_[row];
|
Row &rowItem = this->rows_[row];
|
||||||
|
|
||||||
assert(this->columnCount_ == rowItem.items.size());
|
assert(this->columnCount_ == static_cast<int>(rowItem.items.size()));
|
||||||
|
|
||||||
auto &cell = rowItem.items[column];
|
auto &cell = rowItem.items[column];
|
||||||
|
|
||||||
|
@ -167,7 +169,7 @@ public:
|
||||||
int vecRow = this->getVectorIndexFromModelIndex(row);
|
int vecRow = this->getVectorIndexFromModelIndex(row);
|
||||||
// TODO: This is only a safety-thing for when we modify data that's being modified right now.
|
// TODO: This is only a safety-thing for when we modify data that's being modified right now.
|
||||||
// It should not be necessary, but it would require some rethinking about this surrounding logic
|
// It should not be necessary, but it would require some rethinking about this surrounding logic
|
||||||
if (vecRow >= this->vector_->readOnly()->size())
|
if (vecRow >= static_cast<int>(this->vector_->readOnly()->size()))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -224,18 +226,19 @@ public:
|
||||||
{
|
{
|
||||||
int row = index.row(), column = index.column();
|
int row = index.row(), column = index.column();
|
||||||
|
|
||||||
if (row < 0 || column < 0 || row >= this->rows_.size() ||
|
if (row < 0 || column < 0 ||
|
||||||
|
row >= static_cast<int>(this->rows_.size()) ||
|
||||||
column >= this->columnCount_)
|
column >= this->columnCount_)
|
||||||
{
|
{
|
||||||
return Qt::NoItemFlags;
|
return Qt::NoItemFlags;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(row >= 0 && row < this->rows_.size() && column >= 0 &&
|
assert(row >= 0 && row < static_cast<int>(this->rows_.size()) &&
|
||||||
column < this->columnCount_);
|
column >= 0 && column < this->columnCount_);
|
||||||
|
|
||||||
const auto &rowItem = this->rows_[row];
|
const auto &rowItem = this->rows_[row];
|
||||||
|
|
||||||
assert(this->columnCount_ == rowItem.items.size());
|
assert(this->columnCount_ == static_cast<int>(rowItem.items.size()));
|
||||||
|
|
||||||
return rowItem.items[column]->flags();
|
return rowItem.items[column]->flags();
|
||||||
}
|
}
|
||||||
|
@ -267,7 +270,8 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(sourceRow >= 0 && sourceRow < this->rows_.size());
|
assert(sourceRow >= 0 &&
|
||||||
|
sourceRow < static_cast<int>(this->rows_.size()));
|
||||||
|
|
||||||
int signalVectorRow = this->getVectorIndexFromModelIndex(sourceRow);
|
int signalVectorRow = this->getVectorIndexFromModelIndex(sourceRow);
|
||||||
this->beginMoveRows(sourceParent, sourceRow, sourceRow,
|
this->beginMoveRows(sourceParent, sourceRow, sourceRow,
|
||||||
|
@ -294,7 +298,7 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(row >= 0 && row < this->rows_.size());
|
assert(row >= 0 && row < static_cast<int>(this->rows_.size()));
|
||||||
|
|
||||||
int signalVectorRow = this->getVectorIndexFromModelIndex(row);
|
int signalVectorRow = this->getVectorIndexFromModelIndex(row);
|
||||||
this->vector_->removeAt(signalVectorRow);
|
this->vector_->removeAt(signalVectorRow);
|
||||||
|
@ -337,8 +341,10 @@ public:
|
||||||
int from = data->data("chatterino_row_id").toInt();
|
int from = data->data("chatterino_row_id").toInt();
|
||||||
int to = parent.row();
|
int to = parent.row();
|
||||||
|
|
||||||
int vectorFrom = this->getVectorIndexFromModelIndex(from);
|
auto vectorFrom =
|
||||||
int vectorTo = this->getVectorIndexFromModelIndex(to);
|
static_cast<size_t>(this->getVectorIndexFromModelIndex(from));
|
||||||
|
auto vectorTo =
|
||||||
|
static_cast<size_t>(this->getVectorIndexFromModelIndex(to));
|
||||||
|
|
||||||
if (vectorFrom < 0 || vectorFrom > this->vector_->raw().size() ||
|
if (vectorFrom < 0 || vectorFrom > this->vector_->raw().size() ||
|
||||||
vectorTo < 0 || vectorTo > this->vector_->raw().size())
|
vectorTo < 0 || vectorTo > this->vector_->raw().size())
|
||||||
|
@ -402,7 +408,7 @@ protected:
|
||||||
|
|
||||||
void insertCustomRow(std::vector<QStandardItem *> row, int index)
|
void insertCustomRow(std::vector<QStandardItem *> row, int index)
|
||||||
{
|
{
|
||||||
assert(index >= 0 && index <= this->rows_.size());
|
assert(index >= 0 && index <= static_cast<int>(this->rows_.size()));
|
||||||
|
|
||||||
this->beginInsertRows(QModelIndex(), index, index);
|
this->beginInsertRows(QModelIndex(), index, index);
|
||||||
this->rows_.insert(this->rows_.begin() + index,
|
this->rows_.insert(this->rows_.begin() + index,
|
||||||
|
@ -412,7 +418,7 @@ protected:
|
||||||
|
|
||||||
void removeCustomRow(int index)
|
void removeCustomRow(int index)
|
||||||
{
|
{
|
||||||
assert(index >= 0 && index <= this->rows_.size());
|
assert(index >= 0 && index <= static_cast<int>(this->rows_.size()));
|
||||||
assert(this->rows_[index].isCustomRow);
|
assert(this->rows_[index].isCustomRow);
|
||||||
|
|
||||||
this->beginRemoveRows(QModelIndex(), index, index);
|
this->beginRemoveRows(QModelIndex(), index, index);
|
||||||
|
|
|
@ -37,7 +37,7 @@ void UnifiedSource::addToListModel(GenericListModel &model,
|
||||||
source->addToListModel(model, maxCount - used);
|
source->addToListModel(model, maxCount - used);
|
||||||
// Calculate how many items have been added so far
|
// Calculate how many items have been added so far
|
||||||
used = model.rowCount() - startingSize;
|
used = model.rowCount() - startingSize;
|
||||||
if (used >= maxCount)
|
if (used >= static_cast<int>(maxCount))
|
||||||
{
|
{
|
||||||
// Used up all of limit
|
// Used up all of limit
|
||||||
break;
|
break;
|
||||||
|
@ -58,15 +58,15 @@ void UnifiedSource::addToStringList(QStringList &list, size_t maxCount,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure to only add maxCount elements in total.
|
// Make sure to only add maxCount elements in total.
|
||||||
int startingSize = list.size();
|
auto startingSize = list.size();
|
||||||
int used = 0;
|
QStringList::size_type used = 0;
|
||||||
|
|
||||||
for (const auto &source : this->sources_)
|
for (const auto &source : this->sources_)
|
||||||
{
|
{
|
||||||
source->addToStringList(list, maxCount - used, isFirstWord);
|
source->addToStringList(list, maxCount - used, isFirstWord);
|
||||||
// Calculate how many items have been added so far
|
// Calculate how many items have been added so far
|
||||||
used = list.size() - startingSize;
|
used = list.size() - startingSize;
|
||||||
if (used >= maxCount)
|
if (used >= static_cast<QStringList::size_type>(maxCount))
|
||||||
{
|
{
|
||||||
// Used up all of limit
|
// Used up all of limit
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -196,12 +196,12 @@ public:
|
||||||
std::unique_lock lock(this->mutex_);
|
std::unique_lock lock(this->mutex_);
|
||||||
|
|
||||||
Equals eq;
|
Equals eq;
|
||||||
for (int i = 0; i < this->buffer_.size(); ++i)
|
for (size_t i = 0; i < this->buffer_.size(); ++i)
|
||||||
{
|
{
|
||||||
if (eq(this->buffer_[i], needle))
|
if (eq(this->buffer_[i], needle))
|
||||||
{
|
{
|
||||||
this->buffer_[i] = replacement;
|
this->buffer_[i] = replacement;
|
||||||
return i;
|
return static_cast<int>(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -116,7 +116,7 @@ QString formatUpdatedEmoteList(const QString &platform,
|
||||||
text += QString(" %1 %2 emotes ").arg(emoteNames.size()).arg(platform);
|
text += QString(" %1 %2 emotes ").arg(emoteNames.size()).arg(platform);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto i = 0;
|
size_t i = 0;
|
||||||
for (const auto &emoteName : emoteNames)
|
for (const auto &emoteName : emoteNames)
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
|
|
|
@ -212,7 +212,8 @@ void MessageLayoutContainer::breakLine()
|
||||||
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() && this->line_ + 1 >= maxUncollapsedLines())
|
if (this->canCollapse() &&
|
||||||
|
static_cast<int>(this->line_ + 1) >= maxUncollapsedLines())
|
||||||
{
|
{
|
||||||
this->canAddMessages_ = false;
|
this->canAddMessages_ = false;
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -514,9 +514,10 @@ int TextLayoutElement::getXFromIndex(size_t index)
|
||||||
else if (index < static_cast<size_t>(this->getText().size()))
|
else if (index < static_cast<size_t>(this->getText().size()))
|
||||||
{
|
{
|
||||||
int x = 0;
|
int x = 0;
|
||||||
for (int i = 0; i < index; i++)
|
for (size_t i = 0; i < index; i++)
|
||||||
{
|
{
|
||||||
x += metrics.horizontalAdvance(this->getText()[i]);
|
x += metrics.horizontalAdvance(
|
||||||
|
this->getText()[static_cast<QString::size_type>(i)]);
|
||||||
}
|
}
|
||||||
return x + this->getRect().left();
|
return x + this->getRect().left();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1411,7 +1411,7 @@ float IrcMessageHandler::similarity(
|
||||||
float similarityPercent = 0.0F;
|
float similarityPercent = 0.0F;
|
||||||
int checked = 0;
|
int checked = 0;
|
||||||
|
|
||||||
for (int i = 1; i <= messages.size(); ++i)
|
for (size_t i = 1; i <= messages.size(); ++i)
|
||||||
{
|
{
|
||||||
if (checked >= getSettings()->hideSimilarMaxMessagesToCheck)
|
if (checked >= getSettings()->hideSimilarMaxMessagesToCheck)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1909,7 +1909,7 @@ void Helix::updateChatSettings(
|
||||||
|
|
||||||
void Helix::onFetchChattersSuccess(
|
void Helix::onFetchChattersSuccess(
|
||||||
std::shared_ptr<HelixChatters> finalChatters, QString broadcasterID,
|
std::shared_ptr<HelixChatters> finalChatters, QString broadcasterID,
|
||||||
QString moderatorID, int maxChattersToFetch,
|
QString moderatorID, size_t maxChattersToFetch,
|
||||||
ResultCallback<HelixChatters> successCallback,
|
ResultCallback<HelixChatters> successCallback,
|
||||||
FailureCallback<HelixGetChattersError, QString> failureCallback,
|
FailureCallback<HelixGetChattersError, QString> failureCallback,
|
||||||
HelixChatters chatters)
|
HelixChatters chatters)
|
||||||
|
@ -2022,7 +2022,7 @@ void Helix::fetchChatters(
|
||||||
|
|
||||||
void Helix::onFetchModeratorsSuccess(
|
void Helix::onFetchModeratorsSuccess(
|
||||||
std::shared_ptr<std::vector<HelixModerator>> finalModerators,
|
std::shared_ptr<std::vector<HelixModerator>> finalModerators,
|
||||||
QString broadcasterID, int maxModeratorsToFetch,
|
QString broadcasterID, size_t maxModeratorsToFetch,
|
||||||
ResultCallback<std::vector<HelixModerator>> successCallback,
|
ResultCallback<std::vector<HelixModerator>> successCallback,
|
||||||
FailureCallback<HelixGetModeratorsError, QString> failureCallback,
|
FailureCallback<HelixGetModeratorsError, QString> failureCallback,
|
||||||
HelixModerators moderators)
|
HelixModerators moderators)
|
||||||
|
@ -2459,7 +2459,7 @@ void Helix::sendWhisper(
|
||||||
|
|
||||||
// https://dev.twitch.tv/docs/api/reference#get-chatters
|
// https://dev.twitch.tv/docs/api/reference#get-chatters
|
||||||
void Helix::getChatters(
|
void Helix::getChatters(
|
||||||
QString broadcasterID, QString moderatorID, int maxChattersToFetch,
|
QString broadcasterID, QString moderatorID, size_t maxChattersToFetch,
|
||||||
ResultCallback<HelixChatters> successCallback,
|
ResultCallback<HelixChatters> successCallback,
|
||||||
FailureCallback<HelixGetChattersError, QString> failureCallback)
|
FailureCallback<HelixGetChattersError, QString> failureCallback)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1073,7 +1073,7 @@ public:
|
||||||
// This will follow the returned cursor and return up to `maxChattersToFetch` chatters
|
// This will follow the returned cursor and return up to `maxChattersToFetch` chatters
|
||||||
// https://dev.twitch.tv/docs/api/reference#get-chatters
|
// https://dev.twitch.tv/docs/api/reference#get-chatters
|
||||||
virtual void getChatters(
|
virtual void getChatters(
|
||||||
QString broadcasterID, QString moderatorID, int maxChattersToFetch,
|
QString broadcasterID, QString moderatorID, size_t maxChattersToFetch,
|
||||||
ResultCallback<HelixChatters> successCallback,
|
ResultCallback<HelixChatters> successCallback,
|
||||||
FailureCallback<HelixGetChattersError, QString> failureCallback) = 0;
|
FailureCallback<HelixGetChattersError, QString> failureCallback) = 0;
|
||||||
|
|
||||||
|
@ -1417,7 +1417,7 @@ public:
|
||||||
// This will follow the returned cursor and return up to `maxChattersToFetch` chatters
|
// This will follow the returned cursor and return up to `maxChattersToFetch` chatters
|
||||||
// https://dev.twitch.tv/docs/api/reference#get-chatters
|
// https://dev.twitch.tv/docs/api/reference#get-chatters
|
||||||
void getChatters(
|
void getChatters(
|
||||||
QString broadcasterID, QString moderatorID, int maxChattersToFetch,
|
QString broadcasterID, QString moderatorID, size_t maxChattersToFetch,
|
||||||
ResultCallback<HelixChatters> successCallback,
|
ResultCallback<HelixChatters> successCallback,
|
||||||
FailureCallback<HelixGetChattersError, QString> failureCallback) final;
|
FailureCallback<HelixGetChattersError, QString> failureCallback) final;
|
||||||
|
|
||||||
|
@ -1505,7 +1505,7 @@ protected:
|
||||||
// Recursive boy
|
// Recursive boy
|
||||||
void onFetchChattersSuccess(
|
void onFetchChattersSuccess(
|
||||||
std::shared_ptr<HelixChatters> finalChatters, QString broadcasterID,
|
std::shared_ptr<HelixChatters> finalChatters, QString broadcasterID,
|
||||||
QString moderatorID, int maxChattersToFetch,
|
QString moderatorID, size_t maxChattersToFetch,
|
||||||
ResultCallback<HelixChatters> successCallback,
|
ResultCallback<HelixChatters> successCallback,
|
||||||
FailureCallback<HelixGetChattersError, QString> failureCallback,
|
FailureCallback<HelixGetChattersError, QString> failureCallback,
|
||||||
HelixChatters chatters);
|
HelixChatters chatters);
|
||||||
|
@ -1520,7 +1520,7 @@ protected:
|
||||||
// Recursive boy
|
// Recursive boy
|
||||||
void onFetchModeratorsSuccess(
|
void onFetchModeratorsSuccess(
|
||||||
std::shared_ptr<std::vector<HelixModerator>> finalModerators,
|
std::shared_ptr<std::vector<HelixModerator>> finalModerators,
|
||||||
QString broadcasterID, int maxModeratorsToFetch,
|
QString broadcasterID, size_t maxModeratorsToFetch,
|
||||||
ResultCallback<std::vector<HelixModerator>> successCallback,
|
ResultCallback<std::vector<HelixModerator>> successCallback,
|
||||||
FailureCallback<HelixGetModeratorsError, QString> failureCallback,
|
FailureCallback<HelixGetModeratorsError, QString> failureCallback,
|
||||||
HelixModerators moderators);
|
HelixModerators moderators);
|
||||||
|
|
|
@ -119,9 +119,9 @@ void TooltipWidget::set(const std::vector<TooltipEntry> &entries,
|
||||||
|
|
||||||
this->setVisibleEntries(entries.size());
|
this->setVisibleEntries(entries.size());
|
||||||
|
|
||||||
for (int i = 0; i < entries.size(); ++i)
|
for (size_t i = 0; i < entries.size(); ++i)
|
||||||
{
|
{
|
||||||
if (auto *entryWidget = this->entryAt(i))
|
if (auto *entryWidget = this->entryAt(static_cast<int>(i)))
|
||||||
{
|
{
|
||||||
const auto &entry = entries[i];
|
const auto &entry = entries[i];
|
||||||
entryWidget->setImage(entry.image);
|
entryWidget->setImage(entry.image);
|
||||||
|
|
|
@ -79,7 +79,7 @@ void EditHotkeyDialog::setFromHotkey(std::shared_ptr<Hotkey> hotkey)
|
||||||
this->ui_->easyArgsLabel->setText(def->argumentsPrompt);
|
this->ui_->easyArgsLabel->setText(def->argumentsPrompt);
|
||||||
this->ui_->easyArgsLabel->setToolTip(def->argumentsPromptHover);
|
this->ui_->easyArgsLabel->setToolTip(def->argumentsPromptHover);
|
||||||
int matchIdx = -1;
|
int matchIdx = -1;
|
||||||
for (int i = 0; i < def->possibleArguments.size(); i++)
|
for (size_t i = 0; i < def->possibleArguments.size(); i++)
|
||||||
{
|
{
|
||||||
const auto &[displayText, argData] = def->possibleArguments.at(i);
|
const auto &[displayText, argData] = def->possibleArguments.at(i);
|
||||||
this->ui_->easyArgsPicker->addItem(displayText);
|
this->ui_->easyArgsPicker->addItem(displayText);
|
||||||
|
@ -90,7 +90,7 @@ void EditHotkeyDialog::setFromHotkey(std::shared_ptr<Hotkey> hotkey)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
bool matches = true;
|
bool matches = true;
|
||||||
for (int j = 0; j < argData.size(); j++)
|
for (size_t j = 0; j < argData.size(); j++)
|
||||||
{
|
{
|
||||||
if (argData.at(j) != hotkey->arguments().at(j))
|
if (argData.at(j) != hotkey->arguments().at(j))
|
||||||
{
|
{
|
||||||
|
@ -100,7 +100,7 @@ void EditHotkeyDialog::setFromHotkey(std::shared_ptr<Hotkey> hotkey)
|
||||||
}
|
}
|
||||||
if (matches)
|
if (matches)
|
||||||
{
|
{
|
||||||
matchIdx = i;
|
matchIdx = static_cast<int>(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (matchIdx != -1)
|
if (matchIdx != -1)
|
||||||
|
|
|
@ -219,11 +219,13 @@ UserInfoPopup::UserInfoPopup(bool closeAutomatically, Split *split)
|
||||||
|
|
||||||
const auto &timeoutButtons =
|
const auto &timeoutButtons =
|
||||||
getSettings()->timeoutButtons.getValue();
|
getSettings()->timeoutButtons.getValue();
|
||||||
if (timeoutButtons.size() < buttonNum || 0 >= buttonNum)
|
if (static_cast<int>(timeoutButtons.size()) < buttonNum ||
|
||||||
|
0 >= buttonNum)
|
||||||
{
|
{
|
||||||
return QString("Invalid argument for execModeratorAction: "
|
return QString("Invalid argument for execModeratorAction: "
|
||||||
"%1. Integer out of usable range: [1, %2]")
|
"%1. Integer out of usable range: [1, %2]")
|
||||||
.arg(buttonNum, timeoutButtons.size() - 1);
|
.arg(buttonNum,
|
||||||
|
static_cast<int>(timeoutButtons.size()) - 1);
|
||||||
}
|
}
|
||||||
const auto &button = timeoutButtons.at(buttonNum - 1);
|
const auto &button = timeoutButtons.at(buttonNum - 1);
|
||||||
msg = QString("/timeout %1 %2")
|
msg = QString("/timeout %1 %2")
|
||||||
|
@ -690,9 +692,10 @@ void UserInfoPopup::installEvents()
|
||||||
{
|
{
|
||||||
const auto &vector = getSettings()->blacklistedUsers.raw();
|
const auto &vector = getSettings()->blacklistedUsers.raw();
|
||||||
|
|
||||||
for (int i = 0; i < vector.size(); i++)
|
for (int i = 0; i < static_cast<int>(vector.size()); i++)
|
||||||
{
|
{
|
||||||
if (this->userName_ == vector[i].getPattern())
|
if (this->userName_ ==
|
||||||
|
vector[static_cast<size_t>(i)].getPattern())
|
||||||
{
|
{
|
||||||
getSettings()->blacklistedUsers.removeAt(i);
|
getSettings()->blacklistedUsers.removeAt(i);
|
||||||
i--;
|
i--;
|
||||||
|
@ -899,9 +902,9 @@ void UserInfoPopup::updateUserData()
|
||||||
// get ignoreHighlights state
|
// get ignoreHighlights state
|
||||||
bool isIgnoringHighlights = false;
|
bool isIgnoringHighlights = false;
|
||||||
const auto &vector = getSettings()->blacklistedUsers.raw();
|
const auto &vector = getSettings()->blacklistedUsers.raw();
|
||||||
for (int i = 0; i < vector.size(); i++)
|
for (const auto &user : vector)
|
||||||
{
|
{
|
||||||
if (this->userName_ == vector[i].getPattern())
|
if (this->userName_ == user.getPattern())
|
||||||
{
|
{
|
||||||
isIgnoringHighlights = true;
|
isIgnoringHighlights = true;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -2204,8 +2204,8 @@ void ChannelView::mouseReleaseEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
this->isDoubleClick_ = false;
|
this->isDoubleClick_ = false;
|
||||||
// Was actually not a wanted triple-click
|
// Was actually not a wanted triple-click
|
||||||
if (fabsf(distanceBetweenPoints(this->lastDoubleClickPosition_,
|
if (std::abs(distanceBetweenPoints(this->lastDoubleClickPosition_,
|
||||||
event->screenPos())) > 10.F)
|
event->screenPos())) > 10.F)
|
||||||
{
|
{
|
||||||
this->clickTimer_.stop();
|
this->clickTimer_.stop();
|
||||||
return;
|
return;
|
||||||
|
@ -2215,16 +2215,16 @@ void ChannelView::mouseReleaseEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
this->isLeftMouseDown_ = false;
|
this->isLeftMouseDown_ = false;
|
||||||
|
|
||||||
if (fabsf(distanceBetweenPoints(this->lastLeftPressPosition_,
|
if (std::abs(distanceBetweenPoints(this->lastLeftPressPosition_,
|
||||||
event->screenPos())) > 15.F)
|
event->screenPos())) > 15.F)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Triple-clicking a message selects the whole message
|
// Triple-clicking a message selects the whole message
|
||||||
if (foundElement && this->clickTimer_.isActive() &&
|
if (foundElement && this->clickTimer_.isActive() &&
|
||||||
(fabsf(distanceBetweenPoints(this->lastDoubleClickPosition_,
|
(std::abs(distanceBetweenPoints(this->lastDoubleClickPosition_,
|
||||||
event->screenPos())) < 10.F))
|
event->screenPos())) < 10.F))
|
||||||
{
|
{
|
||||||
this->selectWholeMessage(layout.get(), messageIndex);
|
this->selectWholeMessage(layout.get(), messageIndex);
|
||||||
return;
|
return;
|
||||||
|
@ -2241,8 +2241,8 @@ void ChannelView::mouseReleaseEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
this->isRightMouseDown_ = false;
|
this->isRightMouseDown_ = false;
|
||||||
|
|
||||||
if (fabsf(distanceBetweenPoints(this->lastRightPressPosition_,
|
if (std::abs(distanceBetweenPoints(this->lastRightPressPosition_,
|
||||||
event->screenPos())) > 15.F)
|
event->screenPos())) > 15.F)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -241,10 +241,8 @@ LimitedQueueSnapshot<MessagePtr> SearchPopup::buildSnapshot()
|
||||||
const LimitedQueueSnapshot<MessagePtr> &snapshot =
|
const LimitedQueueSnapshot<MessagePtr> &snapshot =
|
||||||
sharedView.channel()->getMessageSnapshot();
|
sharedView.channel()->getMessageSnapshot();
|
||||||
|
|
||||||
// TODO: implement iterator on LimitedQueueSnapshot?
|
for (const auto &message : snapshot)
|
||||||
for (auto i = 0; i < snapshot.size(); ++i)
|
|
||||||
{
|
{
|
||||||
const MessagePtr &message = snapshot[i];
|
|
||||||
if (filterSet && !filterSet->filter(message, sharedView.channel()))
|
if (filterSet && !filterSet->filter(message, sharedView.channel()))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -19,7 +19,7 @@ QVariant GenericListModel::data(const QModelIndex &index, int /* role */) const
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index.row() >= this->items_.size())
|
if (index.row() >= static_cast<int>(this->items_.size()))
|
||||||
{
|
{
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "util/IncognitoBrowser.hpp"
|
#include "util/IncognitoBrowser.hpp"
|
||||||
#include "widgets/BaseWindow.hpp"
|
#include "widgets/BaseWindow.hpp"
|
||||||
#include "widgets/settingspages/GeneralPageView.hpp"
|
#include "widgets/settingspages/GeneralPageView.hpp"
|
||||||
|
#include "widgets/settingspages/SettingWidget.hpp"
|
||||||
|
|
||||||
#include <magic_enum/magic_enum.hpp>
|
#include <magic_enum/magic_enum.hpp>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
|
@ -265,10 +266,13 @@ void GeneralPage::initLayout(GeneralPageView &layout)
|
||||||
},
|
},
|
||||||
false, "Choose which tabs are visible in the notebook");
|
false, "Choose which tabs are visible in the notebook");
|
||||||
|
|
||||||
layout.addCheckbox(
|
SettingWidget::inverseCheckbox("Show message reply context",
|
||||||
"Show message reply context", s.hideReplyContext, true,
|
s.hideReplyContext)
|
||||||
"This setting will only affect how messages are shown. You can reply "
|
->setTooltip(
|
||||||
"to a message regardless of this setting.");
|
"This setting will only affect how messages are shown. You can "
|
||||||
|
"reply to a message regardless of this setting.")
|
||||||
|
->addTo(layout);
|
||||||
|
|
||||||
layout.addCheckbox("Show message reply button", s.showReplyButton, false,
|
layout.addCheckbox("Show message reply button", s.showReplyButton, false,
|
||||||
"Show a reply button next to every chat message");
|
"Show a reply button next to every chat message");
|
||||||
|
|
||||||
|
@ -614,10 +618,19 @@ void GeneralPage::initLayout(GeneralPageView &layout)
|
||||||
"Google",
|
"Google",
|
||||||
},
|
},
|
||||||
s.emojiSet);
|
s.emojiSet);
|
||||||
layout.addCheckbox("Show BTTV global emotes", s.enableBTTVGlobalEmotes);
|
SettingWidget::checkbox("Show BetterTTV global emotes",
|
||||||
layout.addCheckbox("Show BTTV channel emotes", s.enableBTTVChannelEmotes);
|
s.enableBTTVGlobalEmotes)
|
||||||
layout.addCheckbox("Enable BTTV live emote updates (requires restart)",
|
->addKeywords({"bttv"})
|
||||||
s.enableBTTVLiveUpdates);
|
->addTo(layout);
|
||||||
|
SettingWidget::checkbox("Show BetterTTV channel emotes",
|
||||||
|
s.enableBTTVChannelEmotes)
|
||||||
|
->addKeywords({"bttv"})
|
||||||
|
->addTo(layout);
|
||||||
|
SettingWidget::checkbox(
|
||||||
|
"Enable BetterTTV live emote updates (requires restart)",
|
||||||
|
s.enableBTTVLiveUpdates)
|
||||||
|
->addKeywords({"bttv"})
|
||||||
|
->addTo(layout);
|
||||||
layout.addCheckbox("Show FFZ global emotes", s.enableFFZGlobalEmotes);
|
layout.addCheckbox("Show FFZ global emotes", s.enableFFZGlobalEmotes);
|
||||||
layout.addCheckbox("Show FFZ channel emotes", s.enableFFZChannelEmotes);
|
layout.addCheckbox("Show FFZ channel emotes", s.enableFFZChannelEmotes);
|
||||||
layout.addCheckbox("Show 7TV global emotes", s.enableSevenTVGlobalEmotes);
|
layout.addCheckbox("Show 7TV global emotes", s.enableSevenTVGlobalEmotes);
|
||||||
|
@ -1063,10 +1076,11 @@ void GeneralPage::initLayout(GeneralPageView &layout)
|
||||||
false,
|
false,
|
||||||
"Make all clickable links lowercase to deter "
|
"Make all clickable links lowercase to deter "
|
||||||
"phishing attempts.");
|
"phishing attempts.");
|
||||||
layout.addCheckbox(
|
SettingWidget::checkbox("Show user's pronouns in user card", s.showPronouns)
|
||||||
"Show user's pronouns in user card", s.showPronouns, false,
|
->setDescription(
|
||||||
"Shows users' pronouns in their user card. "
|
R"(Pronouns are retrieved from <a href="https://pr.alejo.io">pr.alejo.io</a> when a user card is opened.)")
|
||||||
"Pronouns are retrieved from alejo.io when the user card is opened.");
|
->addTo(layout);
|
||||||
|
|
||||||
layout.addCheckbox("Bold @usernames", s.boldUsernames, false,
|
layout.addCheckbox("Bold @usernames", s.boldUsernames, false,
|
||||||
"Bold @mentions to make them more noticable.");
|
"Bold @mentions to make them more noticable.");
|
||||||
layout.addCheckbox("Color @usernames", s.colorUsernames, false,
|
layout.addCheckbox("Color @usernames", s.colorUsernames, false,
|
||||||
|
@ -1191,25 +1205,20 @@ void GeneralPage::initLayout(GeneralPageView &layout)
|
||||||
"@mention for the related thread. If the reply context is hidden, "
|
"@mention for the related thread. If the reply context is hidden, "
|
||||||
"these mentions will never be stripped.");
|
"these mentions will never be stripped.");
|
||||||
|
|
||||||
layout.addDropdownEnumClass<ChatSendProtocol>(
|
SettingWidget::dropdown("Chat send protocol", s.chatSendProtocol)
|
||||||
"Chat send protocol", qmagicenum::enumNames<ChatSendProtocol>(),
|
->setTooltip("'Helix' will use Twitch's Helix API to send message. "
|
||||||
s.chatSendProtocol,
|
"'IRC' will use IRC to send messages.")
|
||||||
"'Helix' will use Twitch's Helix API to send message. 'IRC' will use "
|
->addTo(layout);
|
||||||
"IRC to send messages.",
|
|
||||||
{});
|
|
||||||
|
|
||||||
layout.addCheckbox(
|
SettingWidget::checkbox("Show send message button", s.showSendButton)
|
||||||
"Show send message button", s.showSendButton, false,
|
->setTooltip("Show a Send button next to each split input that can be "
|
||||||
"Show a Send button next to each split input that can be "
|
"clicked to send the message")
|
||||||
"clicked to send the message");
|
->addTo(layout);
|
||||||
|
|
||||||
auto *soundBackend = layout.addDropdownEnumClass<SoundBackend>(
|
SettingWidget::dropdown("Sound backend (requires restart)", s.soundBackend)
|
||||||
"Sound backend (requires restart)",
|
->setTooltip("Change this only if you're noticing issues "
|
||||||
qmagicenum::enumNames<SoundBackend>(), s.soundBackend,
|
"with sound playback on your system")
|
||||||
"Change this only if you're noticing issues with sound playback on "
|
->addTo(layout);
|
||||||
"your system",
|
|
||||||
{});
|
|
||||||
soundBackend->setMinimumWidth(soundBackend->minimumSizeHint().width());
|
|
||||||
|
|
||||||
layout.addStretch();
|
layout.addStretch();
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include "widgets/dialogs/ColorPickerDialog.hpp"
|
#include "widgets/dialogs/ColorPickerDialog.hpp"
|
||||||
#include "widgets/helper/color/ColorButton.hpp"
|
#include "widgets/helper/color/ColorButton.hpp"
|
||||||
#include "widgets/helper/Line.hpp"
|
#include "widgets/helper/Line.hpp"
|
||||||
|
#include "widgets/settingspages/SettingWidget.hpp"
|
||||||
|
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QScrollArea>
|
#include <QScrollArea>
|
||||||
|
@ -44,9 +45,16 @@ GeneralPageView::GeneralPageView(QWidget *parent)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeneralPageView::addWidget(QWidget *widget)
|
void GeneralPageView::addWidget(QWidget *widget, QStringList keywords)
|
||||||
{
|
{
|
||||||
this->contentLayout_->addWidget(widget);
|
this->contentLayout_->addWidget(widget);
|
||||||
|
if (!keywords.isEmpty())
|
||||||
|
{
|
||||||
|
this->groups_.back().widgets.push_back({
|
||||||
|
.element = widget,
|
||||||
|
.keywords = keywords,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeneralPageView::addLayout(QLayout *layout)
|
void GeneralPageView::addLayout(QLayout *layout)
|
||||||
|
@ -376,11 +384,10 @@ bool GeneralPageView::filterElements(const QString &query)
|
||||||
currentSubtitleVisible = true;
|
currentSubtitleVisible = true;
|
||||||
widget.element->show();
|
widget.element->show();
|
||||||
groupAny = true;
|
groupAny = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
widget.element->hide();
|
||||||
widget.element->hide();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ class QScrollArea;
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
class ColorButton;
|
class ColorButton;
|
||||||
|
class SettingWidget;
|
||||||
|
|
||||||
class Space : public QLabel
|
class Space : public QLabel
|
||||||
{
|
{
|
||||||
|
@ -95,7 +96,7 @@ class GeneralPageView : public QWidget
|
||||||
public:
|
public:
|
||||||
GeneralPageView(QWidget *parent = nullptr);
|
GeneralPageView(QWidget *parent = nullptr);
|
||||||
|
|
||||||
void addWidget(QWidget *widget);
|
void addWidget(QWidget *widget, QStringList keywords = {});
|
||||||
void addLayout(QLayout *layout);
|
void addLayout(QLayout *layout);
|
||||||
void addStretch();
|
void addStretch();
|
||||||
|
|
||||||
|
@ -274,50 +275,6 @@ public:
|
||||||
return combo;
|
return combo;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, std::size_t N>
|
|
||||||
ComboBox *addDropdownEnumClass(const QString &text,
|
|
||||||
const std::array<QStringView, N> &items,
|
|
||||||
EnumStringSetting<T> &setting,
|
|
||||||
QString toolTipText,
|
|
||||||
const QString &defaultValueText)
|
|
||||||
{
|
|
||||||
auto *combo = this->addDropdown(text, {}, std::move(toolTipText));
|
|
||||||
|
|
||||||
for (const auto &item : items)
|
|
||||||
{
|
|
||||||
combo->addItem(item.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!defaultValueText.isEmpty())
|
|
||||||
{
|
|
||||||
combo->setCurrentText(defaultValueText);
|
|
||||||
}
|
|
||||||
|
|
||||||
setting.connect(
|
|
||||||
[&setting, combo](const QString &value) {
|
|
||||||
auto enumValue =
|
|
||||||
qmagicenum::enumCast<T>(value, qmagicenum::CASE_INSENSITIVE)
|
|
||||||
.value_or(setting.defaultValue);
|
|
||||||
|
|
||||||
auto i = magic_enum::enum_integer(enumValue);
|
|
||||||
|
|
||||||
combo->setCurrentIndex(i);
|
|
||||||
},
|
|
||||||
this->managedConnections_);
|
|
||||||
|
|
||||||
QObject::connect(
|
|
||||||
combo, &QComboBox::currentTextChanged,
|
|
||||||
[&setting](const auto &newText) {
|
|
||||||
// The setter for EnumStringSetting does not check that this value is valid
|
|
||||||
// Instead, it's up to the getters to make sure that the setting is legic - see the enum_cast above
|
|
||||||
// You could also use the settings `getEnum` function
|
|
||||||
setting = newText;
|
|
||||||
getApp()->getWindows()->forceLayoutChannelViews();
|
|
||||||
});
|
|
||||||
|
|
||||||
return combo;
|
|
||||||
}
|
|
||||||
|
|
||||||
void enableIf(QComboBox *widget, auto &setting, auto cb)
|
void enableIf(QComboBox *widget, auto &setting, auto cb)
|
||||||
{
|
{
|
||||||
auto updateVisibility = [cb = std::move(cb), &setting, widget]() {
|
auto updateVisibility = [cb = std::move(cb), &setting, widget]() {
|
||||||
|
|
144
src/widgets/settingspages/SettingWidget.cpp
Normal file
144
src/widgets/settingspages/SettingWidget.cpp
Normal file
|
@ -0,0 +1,144 @@
|
||||||
|
#include "widgets/settingspages/SettingWidget.hpp"
|
||||||
|
|
||||||
|
#include "widgets/settingspages/GeneralPageView.hpp"
|
||||||
|
|
||||||
|
#include <QBoxLayout>
|
||||||
|
#include <QCheckBox>
|
||||||
|
#include <QLabel>
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
constexpr int MAX_TOOLTIP_LINE_LENGTH = 50;
|
||||||
|
const auto MAX_TOOLTIP_LINE_LENGTH_PATTERN =
|
||||||
|
QStringLiteral(R"(.{%1}\S*\K(\s+))").arg(MAX_TOOLTIP_LINE_LENGTH);
|
||||||
|
const QRegularExpression MAX_TOOLTIP_LINE_LENGTH_REGEX(
|
||||||
|
MAX_TOOLTIP_LINE_LENGTH_PATTERN);
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
namespace chatterino {
|
||||||
|
|
||||||
|
SettingWidget::SettingWidget(const QString &mainKeyword)
|
||||||
|
: vLayout(new QVBoxLayout(this))
|
||||||
|
, hLayout(new QHBoxLayout)
|
||||||
|
{
|
||||||
|
this->vLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
|
||||||
|
this->hLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
this->vLayout->addLayout(hLayout);
|
||||||
|
|
||||||
|
this->keywords.append(mainKeyword);
|
||||||
|
}
|
||||||
|
|
||||||
|
SettingWidget *SettingWidget::checkbox(const QString &label,
|
||||||
|
BoolSetting &setting)
|
||||||
|
{
|
||||||
|
auto *widget = new SettingWidget(label);
|
||||||
|
|
||||||
|
auto *check = new QCheckBox(label);
|
||||||
|
|
||||||
|
widget->hLayout->addWidget(check);
|
||||||
|
|
||||||
|
// update when setting changes
|
||||||
|
setting.connect(
|
||||||
|
[check](const bool &value, auto) {
|
||||||
|
check->setChecked(value);
|
||||||
|
},
|
||||||
|
widget->managedConnections);
|
||||||
|
|
||||||
|
// update setting on toggle
|
||||||
|
QObject::connect(check, &QCheckBox::toggled, widget,
|
||||||
|
[&setting](bool state) {
|
||||||
|
setting = state;
|
||||||
|
});
|
||||||
|
|
||||||
|
widget->actionWidget = check;
|
||||||
|
widget->label = check;
|
||||||
|
|
||||||
|
return widget;
|
||||||
|
}
|
||||||
|
|
||||||
|
SettingWidget *SettingWidget::inverseCheckbox(const QString &label,
|
||||||
|
BoolSetting &setting)
|
||||||
|
{
|
||||||
|
auto *widget = new SettingWidget(label);
|
||||||
|
|
||||||
|
auto *check = new QCheckBox(label);
|
||||||
|
|
||||||
|
widget->hLayout->addWidget(check);
|
||||||
|
|
||||||
|
// update when setting changes
|
||||||
|
setting.connect(
|
||||||
|
[check](const bool &value, auto) {
|
||||||
|
check->setChecked(!value);
|
||||||
|
},
|
||||||
|
widget->managedConnections);
|
||||||
|
|
||||||
|
// update setting on toggle
|
||||||
|
QObject::connect(check, &QCheckBox::toggled, widget,
|
||||||
|
[&setting](bool state) {
|
||||||
|
setting = !state;
|
||||||
|
});
|
||||||
|
|
||||||
|
widget->actionWidget = check;
|
||||||
|
widget->label = check;
|
||||||
|
|
||||||
|
return widget;
|
||||||
|
}
|
||||||
|
|
||||||
|
SettingWidget *SettingWidget::setTooltip(QString tooltip)
|
||||||
|
{
|
||||||
|
assert(!tooltip.isEmpty());
|
||||||
|
|
||||||
|
if (tooltip.length() > MAX_TOOLTIP_LINE_LENGTH)
|
||||||
|
{
|
||||||
|
// match MAX_TOOLTIP_LINE_LENGTH characters, any remaining
|
||||||
|
// non-space, and then capture the following space for
|
||||||
|
// replacement with newline
|
||||||
|
tooltip.replace(MAX_TOOLTIP_LINE_LENGTH_REGEX, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this->label != nullptr)
|
||||||
|
{
|
||||||
|
this->label->setToolTip(tooltip);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this->actionWidget != nullptr)
|
||||||
|
{
|
||||||
|
this->actionWidget->setToolTip(tooltip);
|
||||||
|
}
|
||||||
|
|
||||||
|
this->keywords.append(tooltip);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
SettingWidget *SettingWidget::setDescription(const QString &text)
|
||||||
|
{
|
||||||
|
auto *lbl = new QLabel(text);
|
||||||
|
lbl->setTextInteractionFlags(Qt::TextBrowserInteraction |
|
||||||
|
Qt::LinksAccessibleByKeyboard);
|
||||||
|
lbl->setOpenExternalLinks(true);
|
||||||
|
lbl->setWordWrap(true);
|
||||||
|
lbl->setObjectName("description");
|
||||||
|
|
||||||
|
this->vLayout->insertWidget(0, lbl);
|
||||||
|
|
||||||
|
this->keywords.append(text);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
SettingWidget *SettingWidget::addKeywords(const QStringList &newKeywords)
|
||||||
|
{
|
||||||
|
this->keywords.append(newKeywords);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingWidget::addTo(GeneralPageView &view)
|
||||||
|
{
|
||||||
|
view.addWidget(this, this->keywords);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace chatterino
|
106
src/widgets/settingspages/SettingWidget.hpp
Normal file
106
src/widgets/settingspages/SettingWidget.hpp
Normal file
|
@ -0,0 +1,106 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "common/ChatterinoSetting.hpp"
|
||||||
|
#include "util/QMagicEnum.hpp"
|
||||||
|
#include "widgets/settingspages/GeneralPageView.hpp"
|
||||||
|
|
||||||
|
#include <pajlada/signals/signalholder.hpp>
|
||||||
|
#include <QBoxLayout>
|
||||||
|
#include <QComboBox>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QString>
|
||||||
|
#include <QStringList>
|
||||||
|
#include <QtContainerFwd>
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
namespace chatterino {
|
||||||
|
|
||||||
|
class GeneralPageView;
|
||||||
|
|
||||||
|
class SettingWidget : QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
explicit SettingWidget(const QString &mainKeyword);
|
||||||
|
|
||||||
|
public:
|
||||||
|
~SettingWidget() override = default;
|
||||||
|
SettingWidget &operator=(const SettingWidget &) = delete;
|
||||||
|
SettingWidget &operator=(SettingWidget &&) = delete;
|
||||||
|
SettingWidget(const SettingWidget &other) = delete;
|
||||||
|
SettingWidget(SettingWidget &&other) = delete;
|
||||||
|
|
||||||
|
static SettingWidget *checkbox(const QString &label, BoolSetting &setting);
|
||||||
|
static SettingWidget *inverseCheckbox(const QString &label,
|
||||||
|
BoolSetting &setting);
|
||||||
|
template <typename T>
|
||||||
|
static SettingWidget *dropdown(const QString &label,
|
||||||
|
EnumStringSetting<T> &setting)
|
||||||
|
{
|
||||||
|
auto *widget = new SettingWidget(label);
|
||||||
|
|
||||||
|
auto *lbl = new QLabel(label % ":");
|
||||||
|
auto *combo = new ComboBox;
|
||||||
|
combo->setFocusPolicy(Qt::StrongFocus);
|
||||||
|
for (const auto &item : qmagicenum::enumNames<T>())
|
||||||
|
{
|
||||||
|
combo->addItem(item.toString());
|
||||||
|
}
|
||||||
|
// TODO: this can probably use some other size hint/size strategy
|
||||||
|
combo->setMinimumWidth(combo->minimumSizeHint().width());
|
||||||
|
|
||||||
|
widget->actionWidget = combo;
|
||||||
|
widget->label = lbl;
|
||||||
|
|
||||||
|
widget->hLayout->addWidget(lbl);
|
||||||
|
widget->hLayout->addStretch(1);
|
||||||
|
widget->hLayout->addWidget(combo);
|
||||||
|
|
||||||
|
setting.connect(
|
||||||
|
[&setting, combo](const QString &value) {
|
||||||
|
auto enumValue =
|
||||||
|
qmagicenum::enumCast<T>(value, qmagicenum::CASE_INSENSITIVE)
|
||||||
|
.value_or(setting.defaultValue);
|
||||||
|
|
||||||
|
auto i = magic_enum::enum_integer(enumValue);
|
||||||
|
|
||||||
|
combo->setCurrentIndex(i);
|
||||||
|
},
|
||||||
|
widget->managedConnections);
|
||||||
|
|
||||||
|
QObject::connect(
|
||||||
|
combo, &QComboBox::currentTextChanged,
|
||||||
|
[&setting](const auto &newText) {
|
||||||
|
// The setter for EnumStringSetting does not check that this value is valid
|
||||||
|
// Instead, it's up to the getters to make sure that the setting is legic - see the enum_cast above
|
||||||
|
// You could also use the settings `getEnum` function
|
||||||
|
setting = newText;
|
||||||
|
});
|
||||||
|
|
||||||
|
return widget;
|
||||||
|
}
|
||||||
|
|
||||||
|
SettingWidget *setTooltip(QString tooltip);
|
||||||
|
SettingWidget *setDescription(const QString &text);
|
||||||
|
|
||||||
|
/// Add extra keywords to the widget
|
||||||
|
///
|
||||||
|
/// All text from the tooltip, description, and label are already keywords
|
||||||
|
SettingWidget *addKeywords(const QStringList &newKeywords);
|
||||||
|
|
||||||
|
void addTo(GeneralPageView &view);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QWidget *label = nullptr;
|
||||||
|
QWidget *actionWidget = nullptr;
|
||||||
|
|
||||||
|
QVBoxLayout *vLayout;
|
||||||
|
QHBoxLayout *hLayout;
|
||||||
|
|
||||||
|
pajlada::Signals::SignalHolder managedConnections;
|
||||||
|
|
||||||
|
QStringList keywords;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace chatterino
|
|
@ -42,7 +42,7 @@ namespace {
|
||||||
using namespace chatterino;
|
using namespace chatterino;
|
||||||
|
|
||||||
// 5 minutes
|
// 5 minutes
|
||||||
constexpr const uint64_t THUMBNAIL_MAX_AGE_MS = 5ULL * 60 * 1000;
|
constexpr const qint64 THUMBNAIL_MAX_AGE_MS = 5LL * 60 * 1000;
|
||||||
|
|
||||||
auto formatRoomModeUnclean(
|
auto formatRoomModeUnclean(
|
||||||
const SharedAccessGuard<const TwitchChannel::RoomModes> &modes) -> QString
|
const SharedAccessGuard<const TwitchChannel::RoomModes> &modes) -> QString
|
||||||
|
|
Loading…
Reference in a new issue