mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
changed .clang-format
This commit is contained in:
parent
44c16f1b3a
commit
af7b742a23
46 changed files with 1636 additions and 1611 deletions
|
@ -25,6 +25,9 @@ DerivePointerBinding: false
|
||||||
FixNamespaceComments: true
|
FixNamespaceComments: true
|
||||||
IndentCaseLabels: true
|
IndentCaseLabels: true
|
||||||
IndentWidth: 4
|
IndentWidth: 4
|
||||||
|
IndentWrappedFunctionNames: true
|
||||||
|
IndentPPDirectives: AfterHash
|
||||||
|
NamespaceIndentation: Inner
|
||||||
PointerBindsToType: false
|
PointerBindsToType: false
|
||||||
SpacesBeforeTrailingComments: 2
|
SpacesBeforeTrailingComments: 2
|
||||||
Standard: Auto
|
Standard: Auto
|
||||||
|
|
|
@ -99,15 +99,15 @@ void Application::save()
|
||||||
void Application::initNm()
|
void Application::initNm()
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
#ifdef QT_DEBUG
|
# ifdef QT_DEBUG
|
||||||
#ifdef C_DEBUG_NM
|
# ifdef C_DEBUG_NM
|
||||||
this->nativeMessaging->registerHost();
|
this->nativeMessaging->registerHost();
|
||||||
this->nativeMessaging->openGuiMessageQueue();
|
this->nativeMessaging->openGuiMessageQueue();
|
||||||
#endif
|
# endif
|
||||||
#else
|
# else
|
||||||
this->nativeMessaging->registerHost();
|
this->nativeMessaging->registerHost();
|
||||||
this->nativeMessaging->openGuiMessageQueue();
|
this->nativeMessaging->openGuiMessageQueue();
|
||||||
#endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,24 +9,24 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
#include <fcntl.h>
|
# include <fcntl.h>
|
||||||
#include <io.h>
|
# include <io.h>
|
||||||
#include <stdio.h>
|
# include <stdio.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
void initFileMode()
|
void initFileMode()
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
_setmode(_fileno(stdin), _O_BINARY);
|
_setmode(_fileno(stdin), _O_BINARY);
|
||||||
_setmode(_fileno(stdout), _O_BINARY);
|
_setmode(_fileno(stdout), _O_BINARY);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void runLoop(NativeMessagingClient &client)
|
void runLoop(NativeMessagingClient &client)
|
||||||
{
|
{
|
||||||
while (true) {
|
while (true) {
|
||||||
char size_c[4];
|
char size_c[4];
|
||||||
std::cin.read(size_c, 4);
|
std::cin.read(size_c, 4);
|
||||||
|
@ -52,10 +52,10 @@ void runLoop(NativeMessagingClient &client)
|
||||||
std::cin.read(buffer.get(), size);
|
std::cin.read(buffer.get(), size);
|
||||||
*(buffer.get() + size) = '\0';
|
*(buffer.get() + size) = '\0';
|
||||||
|
|
||||||
client.sendMessage(
|
client.sendMessage(QByteArray::fromRawData(
|
||||||
QByteArray::fromRawData(buffer.get(), static_cast<int32_t>(size)));
|
buffer.get(), static_cast<int32_t>(size)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
bool shouldRunBrowserExtensionHost(const QStringList &args)
|
bool shouldRunBrowserExtensionHost(const QStringList &args)
|
||||||
|
|
|
@ -1,168 +1,168 @@
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#include <fmt/format.h>
|
# include <fmt/format.h>
|
||||||
#include <irccommand.h>
|
# include <irccommand.h>
|
||||||
#include <ircconnection.h>
|
# include <ircconnection.h>
|
||||||
#include <rapidjson/document.h>
|
# include <rapidjson/document.h>
|
||||||
#include <rapidjson/error/en.h>
|
# include <rapidjson/error/en.h>
|
||||||
#include <rapidjson/error/error.h>
|
# include <rapidjson/error/error.h>
|
||||||
#include <IrcMessage>
|
# include <IrcMessage>
|
||||||
#include <QAbstractListModel>
|
# include <QAbstractListModel>
|
||||||
#include <QAbstractNativeEventFilter>
|
# include <QAbstractNativeEventFilter>
|
||||||
#include <QAction>
|
# include <QAction>
|
||||||
#include <QApplication>
|
# include <QApplication>
|
||||||
#include <QBrush>
|
# include <QBrush>
|
||||||
#include <QBuffer>
|
# include <QBuffer>
|
||||||
#include <QButtonGroup>
|
# include <QButtonGroup>
|
||||||
#include <QByteArray>
|
# include <QByteArray>
|
||||||
#include <QCheckBox>
|
# include <QCheckBox>
|
||||||
#include <QClipboard>
|
# include <QClipboard>
|
||||||
#include <QColor>
|
# include <QColor>
|
||||||
#include <QComboBox>
|
# include <QComboBox>
|
||||||
#include <QCompleter>
|
# include <QCompleter>
|
||||||
#include <QCoreApplication>
|
# include <QCoreApplication>
|
||||||
#include <QDateTime>
|
# include <QDateTime>
|
||||||
#include <QDebug>
|
# include <QDebug>
|
||||||
#include <QDesktopServices>
|
# include <QDesktopServices>
|
||||||
#include <QDialog>
|
# include <QDialog>
|
||||||
#include <QDialogButtonBox>
|
# include <QDialogButtonBox>
|
||||||
#include <QDir>
|
# include <QDir>
|
||||||
#include <QDockWidget>
|
# include <QDockWidget>
|
||||||
#include <QDrag>
|
# include <QDrag>
|
||||||
#include <QDragEnterEvent>
|
# include <QDragEnterEvent>
|
||||||
#include <QElapsedTimer>
|
# include <QElapsedTimer>
|
||||||
#include <QEventLoop>
|
# include <QEventLoop>
|
||||||
#include <QFile>
|
# include <QFile>
|
||||||
#include <QFileDialog>
|
# include <QFileDialog>
|
||||||
#include <QFileInfo>
|
# include <QFileInfo>
|
||||||
#include <QFlags>
|
# include <QFlags>
|
||||||
#include <QFont>
|
# include <QFont>
|
||||||
#include <QFontDatabase>
|
# include <QFontDatabase>
|
||||||
#include <QFontDialog>
|
# include <QFontDialog>
|
||||||
#include <QFontMetrics>
|
# include <QFontMetrics>
|
||||||
#include <QFormLayout>
|
# include <QFormLayout>
|
||||||
#include <QGraphicsBlurEffect>
|
# include <QGraphicsBlurEffect>
|
||||||
#include <QGroupBox>
|
# include <QGroupBox>
|
||||||
#include <QHBoxLayout>
|
# include <QHBoxLayout>
|
||||||
#include <QHeaderView>
|
# include <QHeaderView>
|
||||||
#include <QIcon>
|
# include <QIcon>
|
||||||
#include <QImageReader>
|
# include <QImageReader>
|
||||||
#include <QJsonArray>
|
# include <QJsonArray>
|
||||||
#include <QJsonDocument>
|
# include <QJsonDocument>
|
||||||
#include <QJsonObject>
|
# include <QJsonObject>
|
||||||
#include <QJsonValue>
|
# include <QJsonValue>
|
||||||
#include <QKeyEvent>
|
# include <QKeyEvent>
|
||||||
#include <QLabel>
|
# include <QLabel>
|
||||||
#include <QLayout>
|
# include <QLayout>
|
||||||
#include <QLibrary>
|
# include <QLibrary>
|
||||||
#include <QLineEdit>
|
# include <QLineEdit>
|
||||||
#include <QList>
|
# include <QList>
|
||||||
#include <QListView>
|
# include <QListView>
|
||||||
#include <QListWidget>
|
# include <QListWidget>
|
||||||
#include <QMap>
|
# include <QMap>
|
||||||
#include <QMediaPlayer>
|
# include <QMediaPlayer>
|
||||||
#include <QMenu>
|
# include <QMenu>
|
||||||
#include <QMessageBox>
|
# include <QMessageBox>
|
||||||
#include <QMimeData>
|
# include <QMimeData>
|
||||||
#include <QMouseEvent>
|
# include <QMouseEvent>
|
||||||
#include <QMutex>
|
# include <QMutex>
|
||||||
#include <QMutexLocker>
|
# include <QMutexLocker>
|
||||||
#include <QNetworkAccessManager>
|
# include <QNetworkAccessManager>
|
||||||
#include <QNetworkReply>
|
# include <QNetworkReply>
|
||||||
#include <QNetworkRequest>
|
# include <QNetworkRequest>
|
||||||
#include <QObject>
|
# include <QObject>
|
||||||
#include <QPaintEvent>
|
# include <QPaintEvent>
|
||||||
#include <QPainter>
|
# include <QPainter>
|
||||||
#include <QPainterPath>
|
# include <QPainterPath>
|
||||||
#include <QPalette>
|
# include <QPalette>
|
||||||
#include <QPixmap>
|
# include <QPixmap>
|
||||||
#include <QPoint>
|
# include <QPoint>
|
||||||
#include <QProcess>
|
# include <QProcess>
|
||||||
#include <QPropertyAnimation>
|
# include <QPropertyAnimation>
|
||||||
#include <QPushButton>
|
# include <QPushButton>
|
||||||
#include <QRadialGradient>
|
# include <QRadialGradient>
|
||||||
#include <QRect>
|
# include <QRect>
|
||||||
#include <QRegularExpression>
|
# include <QRegularExpression>
|
||||||
#include <QRunnable>
|
# include <QRunnable>
|
||||||
#include <QScroller>
|
# include <QScroller>
|
||||||
#include <QShortcut>
|
# include <QShortcut>
|
||||||
#include <QSizePolicy>
|
# include <QSizePolicy>
|
||||||
#include <QSlider>
|
# include <QSlider>
|
||||||
#include <QStackedLayout>
|
# include <QStackedLayout>
|
||||||
#include <QStandardPaths>
|
# include <QStandardPaths>
|
||||||
#include <QString>
|
# include <QString>
|
||||||
#include <QStyle>
|
# include <QStyle>
|
||||||
#include <QStyleOption>
|
# include <QStyleOption>
|
||||||
#include <QTabWidget>
|
# include <QTabWidget>
|
||||||
#include <QTextEdit>
|
# include <QTextEdit>
|
||||||
#include <QThread>
|
# include <QThread>
|
||||||
#include <QThreadPool>
|
# include <QThreadPool>
|
||||||
#include <QTime>
|
# include <QTime>
|
||||||
#include <QTimer>
|
# include <QTimer>
|
||||||
#include <QUrl>
|
# include <QUrl>
|
||||||
#include <QUuid>
|
# include <QUuid>
|
||||||
#include <QVBoxLayout>
|
# include <QVBoxLayout>
|
||||||
#include <QVariant>
|
# include <QVariant>
|
||||||
#include <QVector>
|
# include <QVector>
|
||||||
#include <QWheelEvent>
|
# include <QWheelEvent>
|
||||||
#include <QWidget>
|
# include <QWidget>
|
||||||
#include <QtCore/QVariant>
|
# include <QtCore/QVariant>
|
||||||
#include <QtGlobal>
|
# include <QtGlobal>
|
||||||
#include <QtWidgets/QAction>
|
# include <QtWidgets/QAction>
|
||||||
#include <QtWidgets/QApplication>
|
# include <QtWidgets/QApplication>
|
||||||
#include <QtWidgets/QButtonGroup>
|
# include <QtWidgets/QButtonGroup>
|
||||||
#include <QtWidgets/QDialog>
|
# include <QtWidgets/QDialog>
|
||||||
#include <QtWidgets/QDialogButtonBox>
|
# include <QtWidgets/QDialogButtonBox>
|
||||||
#include <QtWidgets/QFormLayout>
|
# include <QtWidgets/QFormLayout>
|
||||||
#include <QtWidgets/QHBoxLayout>
|
# include <QtWidgets/QHBoxLayout>
|
||||||
#include <QtWidgets/QHeaderView>
|
# include <QtWidgets/QHeaderView>
|
||||||
#include <QtWidgets/QLabel>
|
# include <QtWidgets/QLabel>
|
||||||
#include <QtWidgets/QLineEdit>
|
# include <QtWidgets/QLineEdit>
|
||||||
#include <QtWidgets/QPushButton>
|
# include <QtWidgets/QPushButton>
|
||||||
#include <QtWidgets/QTabWidget>
|
# include <QtWidgets/QTabWidget>
|
||||||
#include <QtWidgets/QVBoxLayout>
|
# include <QtWidgets/QVBoxLayout>
|
||||||
#include <algorithm>
|
# include <algorithm>
|
||||||
#include <boost/current_function.hpp>
|
# include <boost/current_function.hpp>
|
||||||
#include <boost/foreach.hpp>
|
# include <boost/foreach.hpp>
|
||||||
#include <boost/noncopyable.hpp>
|
# include <boost/noncopyable.hpp>
|
||||||
#include <boost/optional.hpp>
|
# include <boost/optional.hpp>
|
||||||
#include <cassert>
|
# include <cassert>
|
||||||
#include <chrono>
|
# include <chrono>
|
||||||
#include <cinttypes>
|
# include <cinttypes>
|
||||||
#include <climits>
|
# include <climits>
|
||||||
#include <cmath>
|
# include <cmath>
|
||||||
#include <cstdint>
|
# include <cstdint>
|
||||||
#include <ctime>
|
# include <ctime>
|
||||||
#include <functional>
|
# include <functional>
|
||||||
#include <future>
|
# include <future>
|
||||||
#include <list>
|
# include <list>
|
||||||
#include <map>
|
# include <map>
|
||||||
#include <memory>
|
# include <memory>
|
||||||
#include <mutex>
|
# include <mutex>
|
||||||
#include <pajlada/settings/serialize.hpp>
|
# include <pajlada/settings/serialize.hpp>
|
||||||
#include <pajlada/settings/setting.hpp>
|
# include <pajlada/settings/setting.hpp>
|
||||||
#include <pajlada/settings/settinglistener.hpp>
|
# include <pajlada/settings/settinglistener.hpp>
|
||||||
#include <pajlada/signals/connection.hpp>
|
# include <pajlada/signals/connection.hpp>
|
||||||
#include <pajlada/signals/signal.hpp>
|
# include <pajlada/signals/signal.hpp>
|
||||||
#include <random>
|
# include <random>
|
||||||
#include <set>
|
# include <set>
|
||||||
#include <string>
|
# include <string>
|
||||||
#include <thread>
|
# include <thread>
|
||||||
#include <tuple>
|
# include <tuple>
|
||||||
#include <type_traits>
|
# include <type_traits>
|
||||||
#include <unordered_map>
|
# include <unordered_map>
|
||||||
#include <unordered_set>
|
# include <unordered_set>
|
||||||
#include <vector>
|
# include <vector>
|
||||||
|
|
||||||
#ifndef UNUSED
|
# ifndef UNUSED
|
||||||
#define UNUSED(x) (void)(x)
|
# define UNUSED(x) (void)(x)
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
#ifndef ATTR_UNUSED
|
# ifndef ATTR_UNUSED
|
||||||
#ifdef Q_OS_WIN
|
# ifdef Q_OS_WIN
|
||||||
#define ATTR_UNUSED
|
# define ATTR_UNUSED
|
||||||
#else
|
# else
|
||||||
#define ATTR_UNUSED __attribute__((unused))
|
# define ATTR_UNUSED __attribute__((unused))
|
||||||
#endif
|
# endif
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
#include "widgets/dialogs/LastRunCrashDialog.hpp"
|
#include "widgets/dialogs/LastRunCrashDialog.hpp"
|
||||||
|
|
||||||
#ifdef C_USE_BREAKPAD
|
#ifdef C_USE_BREAKPAD
|
||||||
#include <QBreakpadHandler.h>
|
# include <QBreakpadHandler.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// void initQt();
|
// void initQt();
|
||||||
|
@ -23,8 +23,8 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace {
|
namespace {
|
||||||
void installCustomPalette()
|
void installCustomPalette()
|
||||||
{
|
{
|
||||||
// borrowed from
|
// borrowed from
|
||||||
// https://stackoverflow.com/questions/15035767/is-the-qt-5-dark-fusion-theme-available-for-windows
|
// https://stackoverflow.com/questions/15035767/is-the-qt-5-dark-fusion-theme-available-for-windows
|
||||||
auto dark = qApp->palette();
|
auto dark = qApp->palette();
|
||||||
|
@ -38,7 +38,8 @@ void installCustomPalette()
|
||||||
dark.setColor(QPalette::AlternateBase, QColor("#444"));
|
dark.setColor(QPalette::AlternateBase, QColor("#444"));
|
||||||
dark.setColor(QPalette::ToolTipBase, Qt::white);
|
dark.setColor(QPalette::ToolTipBase, Qt::white);
|
||||||
dark.setColor(QPalette::ToolTipText, Qt::white);
|
dark.setColor(QPalette::ToolTipText, Qt::white);
|
||||||
dark.setColor(QPalette::Disabled, QPalette::Text, QColor(127, 127, 127));
|
dark.setColor(QPalette::Disabled, QPalette::Text,
|
||||||
|
QColor(127, 127, 127));
|
||||||
dark.setColor(QPalette::Dark, QColor(35, 35, 35));
|
dark.setColor(QPalette::Dark, QColor(35, 35, 35));
|
||||||
dark.setColor(QPalette::Shadow, QColor(20, 20, 20));
|
dark.setColor(QPalette::Shadow, QColor(20, 20, 20));
|
||||||
dark.setColor(QPalette::Button, QColor(70, 70, 70));
|
dark.setColor(QPalette::Button, QColor(70, 70, 70));
|
||||||
|
@ -48,16 +49,17 @@ void installCustomPalette()
|
||||||
dark.setColor(QPalette::BrightText, Qt::red);
|
dark.setColor(QPalette::BrightText, Qt::red);
|
||||||
dark.setColor(QPalette::Link, QColor(42, 130, 218));
|
dark.setColor(QPalette::Link, QColor(42, 130, 218));
|
||||||
dark.setColor(QPalette::Highlight, QColor(42, 130, 218));
|
dark.setColor(QPalette::Highlight, QColor(42, 130, 218));
|
||||||
dark.setColor(QPalette::Disabled, QPalette::Highlight, QColor(80, 80, 80));
|
dark.setColor(QPalette::Disabled, QPalette::Highlight,
|
||||||
|
QColor(80, 80, 80));
|
||||||
dark.setColor(QPalette::HighlightedText, Qt::white);
|
dark.setColor(QPalette::HighlightedText, Qt::white);
|
||||||
dark.setColor(QPalette::Disabled, QPalette::HighlightedText,
|
dark.setColor(QPalette::Disabled, QPalette::HighlightedText,
|
||||||
QColor(127, 127, 127));
|
QColor(127, 127, 127));
|
||||||
|
|
||||||
qApp->setPalette(dark);
|
qApp->setPalette(dark);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initQt()
|
void initQt()
|
||||||
{
|
{
|
||||||
// set up the QApplication flags
|
// set up the QApplication flags
|
||||||
QApplication::setAttribute(Qt::AA_Use96Dpi, true);
|
QApplication::setAttribute(Qt::AA_Use96Dpi, true);
|
||||||
#ifdef Q_OS_WIN32
|
#ifdef Q_OS_WIN32
|
||||||
|
@ -67,10 +69,10 @@ void initQt()
|
||||||
QApplication::setStyle(QStyleFactory::create("Fusion"));
|
QApplication::setStyle(QStyleFactory::create("Fusion"));
|
||||||
|
|
||||||
installCustomPalette();
|
installCustomPalette();
|
||||||
}
|
}
|
||||||
|
|
||||||
void showLastCrashDialog()
|
void showLastCrashDialog()
|
||||||
{
|
{
|
||||||
#ifndef C_DISABLE_CRASH_DIALOG
|
#ifndef C_DISABLE_CRASH_DIALOG
|
||||||
LastRunCrashDialog dialog;
|
LastRunCrashDialog dialog;
|
||||||
|
|
||||||
|
@ -82,21 +84,21 @@ void showLastCrashDialog()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void createRunningFile(const QString &path)
|
void createRunningFile(const QString &path)
|
||||||
{
|
{
|
||||||
QFile runningFile(path);
|
QFile runningFile(path);
|
||||||
|
|
||||||
runningFile.open(QIODevice::WriteOnly | QIODevice::Truncate);
|
runningFile.open(QIODevice::WriteOnly | QIODevice::Truncate);
|
||||||
runningFile.flush();
|
runningFile.flush();
|
||||||
runningFile.close();
|
runningFile.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeRunningFile(const QString &path)
|
void removeRunningFile(const QString &path)
|
||||||
{
|
{
|
||||||
QFile::remove(path);
|
QFile::remove(path);
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void runGui(QApplication &a, Paths &paths, Settings &settings)
|
void runGui(QApplication &a, Paths &paths, Settings &settings)
|
||||||
|
|
|
@ -5,9 +5,9 @@
|
||||||
#define CHATTERINO_VERSION "2.0.4"
|
#define CHATTERINO_VERSION "2.0.4"
|
||||||
|
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
#define CHATTERINO_OS "win"
|
# define CHATTERINO_OS "win"
|
||||||
#elif defined(Q_OS_MACOS)
|
#elif defined(Q_OS_MACOS)
|
||||||
#define CHATTERINO_OS "macos"
|
# define CHATTERINO_OS "macos"
|
||||||
#elif defined(Q_OS_LINUX)
|
#elif defined(Q_OS_LINUX)
|
||||||
#define CHATTERINO_OS "linux"
|
# define CHATTERINO_OS "linux"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -68,9 +68,10 @@ private:
|
||||||
namespace pajlada {
|
namespace pajlada {
|
||||||
namespace Settings {
|
namespace Settings {
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct Serialize<chatterino::HighlightBlacklistUser> {
|
struct Serialize<chatterino::HighlightBlacklistUser> {
|
||||||
static rapidjson::Value get(const chatterino::HighlightBlacklistUser &value,
|
static rapidjson::Value get(
|
||||||
|
const chatterino::HighlightBlacklistUser &value,
|
||||||
rapidjson::Document::AllocatorType &a)
|
rapidjson::Document::AllocatorType &a)
|
||||||
{
|
{
|
||||||
rapidjson::Value ret(rapidjson::kObjectType);
|
rapidjson::Value ret(rapidjson::kObjectType);
|
||||||
|
@ -80,11 +81,12 @@ struct Serialize<chatterino::HighlightBlacklistUser> {
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct Deserialize<chatterino::HighlightBlacklistUser> {
|
struct Deserialize<chatterino::HighlightBlacklistUser> {
|
||||||
static chatterino::HighlightBlacklistUser get(const rapidjson::Value &value)
|
static chatterino::HighlightBlacklistUser get(
|
||||||
|
const rapidjson::Value &value)
|
||||||
{
|
{
|
||||||
QString pattern;
|
QString pattern;
|
||||||
bool isRegex = false;
|
bool isRegex = false;
|
||||||
|
@ -98,7 +100,7 @@ struct Deserialize<chatterino::HighlightBlacklistUser> {
|
||||||
|
|
||||||
return chatterino::HighlightBlacklistUser(pattern, isRegex);
|
return chatterino::HighlightBlacklistUser(pattern, isRegex);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Settings
|
} // namespace Settings
|
||||||
} // namespace pajlada
|
} // namespace pajlada
|
||||||
|
|
|
@ -72,8 +72,8 @@ private:
|
||||||
namespace pajlada {
|
namespace pajlada {
|
||||||
namespace Settings {
|
namespace Settings {
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct Serialize<chatterino::HighlightPhrase> {
|
struct Serialize<chatterino::HighlightPhrase> {
|
||||||
static rapidjson::Value get(const chatterino::HighlightPhrase &value,
|
static rapidjson::Value get(const chatterino::HighlightPhrase &value,
|
||||||
rapidjson::Document::AllocatorType &a)
|
rapidjson::Document::AllocatorType &a)
|
||||||
{
|
{
|
||||||
|
@ -86,14 +86,15 @@ struct Serialize<chatterino::HighlightPhrase> {
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct Deserialize<chatterino::HighlightPhrase> {
|
struct Deserialize<chatterino::HighlightPhrase> {
|
||||||
static chatterino::HighlightPhrase get(const rapidjson::Value &value)
|
static chatterino::HighlightPhrase get(const rapidjson::Value &value)
|
||||||
{
|
{
|
||||||
if (!value.IsObject()) {
|
if (!value.IsObject()) {
|
||||||
return chatterino::HighlightPhrase(QString(), true, false, false);
|
return chatterino::HighlightPhrase(QString(), true, false,
|
||||||
|
false);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString _pattern;
|
QString _pattern;
|
||||||
|
@ -106,9 +107,10 @@ struct Deserialize<chatterino::HighlightPhrase> {
|
||||||
chatterino::rj::getSafe(value, "sound", _sound);
|
chatterino::rj::getSafe(value, "sound", _sound);
|
||||||
chatterino::rj::getSafe(value, "regex", _isRegex);
|
chatterino::rj::getSafe(value, "regex", _isRegex);
|
||||||
|
|
||||||
return chatterino::HighlightPhrase(_pattern, _alert, _sound, _isRegex);
|
return chatterino::HighlightPhrase(_pattern, _alert, _sound,
|
||||||
|
_isRegex);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Settings
|
} // namespace Settings
|
||||||
} // namespace pajlada
|
} // namespace pajlada
|
||||||
|
|
|
@ -59,8 +59,8 @@ private:
|
||||||
namespace pajlada {
|
namespace pajlada {
|
||||||
namespace Settings {
|
namespace Settings {
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct Serialize<chatterino::IgnorePhrase> {
|
struct Serialize<chatterino::IgnorePhrase> {
|
||||||
static rapidjson::Value get(const chatterino::IgnorePhrase &value,
|
static rapidjson::Value get(const chatterino::IgnorePhrase &value,
|
||||||
rapidjson::Document::AllocatorType &a)
|
rapidjson::Document::AllocatorType &a)
|
||||||
{
|
{
|
||||||
|
@ -71,10 +71,10 @@ struct Serialize<chatterino::IgnorePhrase> {
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct Deserialize<chatterino::IgnorePhrase> {
|
struct Deserialize<chatterino::IgnorePhrase> {
|
||||||
static chatterino::IgnorePhrase get(const rapidjson::Value &value)
|
static chatterino::IgnorePhrase get(const rapidjson::Value &value)
|
||||||
{
|
{
|
||||||
if (!value.IsObject()) {
|
if (!value.IsObject()) {
|
||||||
|
@ -89,7 +89,7 @@ struct Deserialize<chatterino::IgnorePhrase> {
|
||||||
|
|
||||||
return chatterino::IgnorePhrase(_pattern, _isRegex);
|
return chatterino::IgnorePhrase(_pattern, _isRegex);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Settings
|
} // namespace Settings
|
||||||
} // namespace pajlada
|
} // namespace pajlada
|
||||||
|
|
|
@ -36,8 +36,8 @@ private:
|
||||||
namespace pajlada {
|
namespace pajlada {
|
||||||
namespace Settings {
|
namespace Settings {
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct Serialize<chatterino::ModerationAction> {
|
struct Serialize<chatterino::ModerationAction> {
|
||||||
static rapidjson::Value get(const chatterino::ModerationAction &value,
|
static rapidjson::Value get(const chatterino::ModerationAction &value,
|
||||||
rapidjson::Document::AllocatorType &a)
|
rapidjson::Document::AllocatorType &a)
|
||||||
{
|
{
|
||||||
|
@ -47,10 +47,10 @@ struct Serialize<chatterino::ModerationAction> {
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct Deserialize<chatterino::ModerationAction> {
|
struct Deserialize<chatterino::ModerationAction> {
|
||||||
static chatterino::ModerationAction get(const rapidjson::Value &value)
|
static chatterino::ModerationAction get(const rapidjson::Value &value)
|
||||||
{
|
{
|
||||||
if (!value.IsObject()) {
|
if (!value.IsObject()) {
|
||||||
|
@ -63,7 +63,7 @@ struct Deserialize<chatterino::ModerationAction> {
|
||||||
|
|
||||||
return chatterino::ModerationAction(pattern);
|
return chatterino::ModerationAction(pattern);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Settings
|
} // namespace Settings
|
||||||
} // namespace pajlada
|
} // namespace pajlada
|
||||||
|
|
|
@ -22,28 +22,29 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace {
|
namespace {
|
||||||
// Frames
|
// Frames
|
||||||
Frames::Frames()
|
Frames::Frames()
|
||||||
{
|
{
|
||||||
DebugCount::increase("images");
|
DebugCount::increase("images");
|
||||||
}
|
}
|
||||||
|
|
||||||
Frames::Frames(const QVector<Frame<QPixmap>> &frames)
|
Frames::Frames(const QVector<Frame<QPixmap>> &frames)
|
||||||
: items_(frames)
|
: items_(frames)
|
||||||
{
|
{
|
||||||
assertInGuiThread();
|
assertInGuiThread();
|
||||||
DebugCount::increase("images");
|
DebugCount::increase("images");
|
||||||
|
|
||||||
if (this->animated()) {
|
if (this->animated()) {
|
||||||
DebugCount::increase("animated images");
|
DebugCount::increase("animated images");
|
||||||
|
|
||||||
this->gifTimerConnection_ = getApp()->emotes->gifTimer.signal.connect(
|
this->gifTimerConnection_ =
|
||||||
|
getApp()->emotes->gifTimer.signal.connect(
|
||||||
[this] { this->advance(); });
|
[this] { this->advance(); });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Frames::~Frames()
|
Frames::~Frames()
|
||||||
{
|
{
|
||||||
assertInGuiThread();
|
assertInGuiThread();
|
||||||
DebugCount::decrease("images");
|
DebugCount::decrease("images");
|
||||||
|
|
||||||
|
@ -52,10 +53,10 @@ Frames::~Frames()
|
||||||
}
|
}
|
||||||
|
|
||||||
this->gifTimerConnection_.disconnect();
|
this->gifTimerConnection_.disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Frames::advance()
|
void Frames::advance()
|
||||||
{
|
{
|
||||||
this->durationOffset_ += GIF_FRAME_LENGTH;
|
this->durationOffset_ += GIF_FRAME_LENGTH;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
@ -72,28 +73,28 @@ void Frames::advance()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Frames::animated() const
|
bool Frames::animated() const
|
||||||
{
|
{
|
||||||
return this->items_.size() > 1;
|
return this->items_.size() > 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::optional<QPixmap> Frames::current() const
|
boost::optional<QPixmap> Frames::current() const
|
||||||
{
|
{
|
||||||
if (this->items_.size() == 0) return boost::none;
|
if (this->items_.size() == 0) return boost::none;
|
||||||
return this->items_[this->index_].image;
|
return this->items_[this->index_].image;
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::optional<QPixmap> Frames::first() const
|
boost::optional<QPixmap> Frames::first() const
|
||||||
{
|
{
|
||||||
if (this->items_.size() == 0) return boost::none;
|
if (this->items_.size() == 0) return boost::none;
|
||||||
return this->items_.front().image;
|
return this->items_.front().image;
|
||||||
}
|
}
|
||||||
|
|
||||||
// functions
|
// functions
|
||||||
QVector<Frame<QImage>> readFrames(QImageReader &reader, const Url &url)
|
QVector<Frame<QImage>> readFrames(QImageReader &reader, const Url &url)
|
||||||
{
|
{
|
||||||
QVector<Frame<QImage>> frames;
|
QVector<Frame<QImage>> frames;
|
||||||
|
|
||||||
if (reader.imageCount() == 0) {
|
if (reader.imageCount() == 0) {
|
||||||
|
@ -118,14 +119,14 @@ QVector<Frame<QImage>> readFrames(QImageReader &reader, const Url &url)
|
||||||
}
|
}
|
||||||
|
|
||||||
return frames;
|
return frames;
|
||||||
}
|
}
|
||||||
|
|
||||||
// parsed
|
// parsed
|
||||||
template <typename Assign>
|
template <typename Assign>
|
||||||
void assignDelayed(
|
void assignDelayed(
|
||||||
std::queue<std::pair<Assign, QVector<Frame<QPixmap>>>> &queued,
|
std::queue<std::pair<Assign, QVector<Frame<QPixmap>>>> &queued,
|
||||||
std::mutex &mutex, std::atomic_bool &loadedEventQueued)
|
std::mutex &mutex, std::atomic_bool &loadedEventQueued)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(mutex);
|
std::lock_guard<std::mutex> lock(mutex);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
|
@ -134,30 +135,34 @@ void assignDelayed(
|
||||||
queued.pop();
|
queued.pop();
|
||||||
|
|
||||||
if (++i > 50) {
|
if (++i > 50) {
|
||||||
QTimer::singleShot(
|
QTimer::singleShot(3, [&] {
|
||||||
3, [&] { assignDelayed(queued, mutex, loadedEventQueued); });
|
assignDelayed(queued, mutex, loadedEventQueued);
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getApp()->windows->forceLayoutChannelViews();
|
getApp()->windows->forceLayoutChannelViews();
|
||||||
loadedEventQueued = false;
|
loadedEventQueued = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Assign>
|
template <typename Assign>
|
||||||
auto makeConvertCallback(const QVector<Frame<QImage>> &parsed, Assign assign)
|
auto makeConvertCallback(const QVector<Frame<QImage>> &parsed,
|
||||||
{
|
Assign assign)
|
||||||
|
{
|
||||||
return [parsed, assign] {
|
return [parsed, assign] {
|
||||||
// convert to pixmap
|
// convert to pixmap
|
||||||
auto frames = QVector<Frame<QPixmap>>();
|
auto frames = QVector<Frame<QPixmap>>();
|
||||||
std::transform(parsed.begin(), parsed.end(), std::back_inserter(frames),
|
std::transform(parsed.begin(), parsed.end(),
|
||||||
[](auto &frame) {
|
std::back_inserter(frames), [](auto &frame) {
|
||||||
return Frame<QPixmap>{
|
return Frame<QPixmap>{
|
||||||
QPixmap::fromImage(frame.image), frame.duration};
|
QPixmap::fromImage(frame.image),
|
||||||
|
frame.duration};
|
||||||
});
|
});
|
||||||
|
|
||||||
// put into stack
|
// put into stack
|
||||||
static std::queue<std::pair<Assign, QVector<Frame<QPixmap>>>> queued;
|
static std::queue<std::pair<Assign, QVector<Frame<QPixmap>>>>
|
||||||
|
queued;
|
||||||
static std::mutex mutex;
|
static std::mutex mutex;
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lock(mutex);
|
std::lock_guard<std::mutex> lock(mutex);
|
||||||
|
@ -168,11 +173,12 @@ auto makeConvertCallback(const QVector<Frame<QImage>> &parsed, Assign assign)
|
||||||
if (!loadedEventQueued) {
|
if (!loadedEventQueued) {
|
||||||
loadedEventQueued = true;
|
loadedEventQueued = true;
|
||||||
|
|
||||||
QTimer::singleShot(
|
QTimer::singleShot(100, [=] {
|
||||||
100, [=] { assignDelayed(queued, mutex, loadedEventQueued); });
|
assignDelayed(queued, mutex, loadedEventQueued);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
// IMAGE2
|
// IMAGE2
|
||||||
|
|
|
@ -17,14 +17,14 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace {
|
namespace {
|
||||||
template <typename Image>
|
template <typename Image>
|
||||||
struct Frame {
|
struct Frame {
|
||||||
Image image;
|
Image image;
|
||||||
int duration;
|
int duration;
|
||||||
};
|
};
|
||||||
class Frames : boost::noncopyable
|
class Frames : boost::noncopyable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Frames();
|
Frames();
|
||||||
Frames(const QVector<Frame<QPixmap>> &frames);
|
Frames(const QVector<Frame<QPixmap>> &frames);
|
||||||
~Frames();
|
~Frames();
|
||||||
|
@ -34,12 +34,12 @@ public:
|
||||||
boost::optional<QPixmap> current() const;
|
boost::optional<QPixmap> current() const;
|
||||||
boost::optional<QPixmap> first() const;
|
boost::optional<QPixmap> first() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QVector<Frame<QPixmap>> items_;
|
QVector<Frame<QPixmap>> items_;
|
||||||
int index_{0};
|
int index_{0};
|
||||||
int durationOffset_{0};
|
int durationOffset_{0};
|
||||||
pajlada::Signals::Connection gifTimerConnection_;
|
pajlada::Signals::Connection gifTimerConnection_;
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
class Image;
|
class Image;
|
||||||
|
|
|
@ -2,5 +2,4 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -13,24 +13,26 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace {
|
namespace {
|
||||||
Url getEmoteLink(QString urlTemplate, const EmoteId &id,
|
Url getEmoteLink(QString urlTemplate, const EmoteId &id,
|
||||||
const QString &emoteScale)
|
const QString &emoteScale)
|
||||||
{
|
{
|
||||||
urlTemplate.detach();
|
urlTemplate.detach();
|
||||||
|
|
||||||
return {urlTemplate.replace("{{id}}", id.string)
|
return {urlTemplate.replace("{{id}}", id.string)
|
||||||
.replace("{{image}}", emoteScale)};
|
.replace("{{image}}", emoteScale)};
|
||||||
}
|
}
|
||||||
std::pair<Outcome, EmoteMap> parseGlobalEmotes(const QJsonObject &jsonRoot,
|
std::pair<Outcome, EmoteMap> parseGlobalEmotes(
|
||||||
const EmoteMap ¤tEmotes)
|
const QJsonObject &jsonRoot, const EmoteMap ¤tEmotes)
|
||||||
{
|
{
|
||||||
auto emotes = EmoteMap();
|
auto emotes = EmoteMap();
|
||||||
auto jsonEmotes = jsonRoot.value("emotes").toArray();
|
auto jsonEmotes = jsonRoot.value("emotes").toArray();
|
||||||
auto urlTemplate = qS("https:") + jsonRoot.value("urlTemplate").toString();
|
auto urlTemplate =
|
||||||
|
qS("https:") + jsonRoot.value("urlTemplate").toString();
|
||||||
|
|
||||||
for (auto jsonEmote : jsonEmotes) {
|
for (auto jsonEmote : jsonEmotes) {
|
||||||
auto id = EmoteId{jsonEmote.toObject().value("id").toString()};
|
auto id = EmoteId{jsonEmote.toObject().value("id").toString()};
|
||||||
auto name = EmoteName{jsonEmote.toObject().value("code").toString()};
|
auto name =
|
||||||
|
EmoteName{jsonEmote.toObject().value("code").toString()};
|
||||||
|
|
||||||
auto emote = Emote(
|
auto emote = Emote(
|
||||||
{name,
|
{name,
|
||||||
|
@ -41,20 +43,21 @@ std::pair<Outcome, EmoteMap> parseGlobalEmotes(const QJsonObject &jsonRoot,
|
||||||
Tooltip{name.string + "<br />Global Bttv Emote"},
|
Tooltip{name.string + "<br />Global Bttv Emote"},
|
||||||
Url{"https://manage.betterttv.net/emotes/" + id.string}});
|
Url{"https://manage.betterttv.net/emotes/" + id.string}});
|
||||||
|
|
||||||
emotes[name] = cachedOrMakeEmotePtr(std::move(emote), currentEmotes);
|
emotes[name] =
|
||||||
|
cachedOrMakeEmotePtr(std::move(emote), currentEmotes);
|
||||||
}
|
}
|
||||||
|
|
||||||
return {Success, std::move(emotes)};
|
return {Success, std::move(emotes)};
|
||||||
}
|
}
|
||||||
EmotePtr cachedOrMake(Emote &&emote, const EmoteId &id)
|
EmotePtr cachedOrMake(Emote &&emote, const EmoteId &id)
|
||||||
{
|
{
|
||||||
static std::unordered_map<EmoteId, std::weak_ptr<const Emote>> cache;
|
static std::unordered_map<EmoteId, std::weak_ptr<const Emote>> cache;
|
||||||
static std::mutex mutex;
|
static std::mutex mutex;
|
||||||
|
|
||||||
return cachedOrMakeEmotePtr(std::move(emote), cache, mutex, id);
|
return cachedOrMakeEmotePtr(std::move(emote), cache, mutex, id);
|
||||||
}
|
}
|
||||||
std::pair<Outcome, EmoteMap> parseChannelEmotes(const QJsonObject &jsonRoot)
|
std::pair<Outcome, EmoteMap> parseChannelEmotes(const QJsonObject &jsonRoot)
|
||||||
{
|
{
|
||||||
auto emotes = EmoteMap();
|
auto emotes = EmoteMap();
|
||||||
auto jsonEmotes = jsonRoot.value("emotes").toArray();
|
auto jsonEmotes = jsonRoot.value("emotes").toArray();
|
||||||
auto urlTemplate = "https:" + jsonRoot.value("urlTemplate").toString();
|
auto urlTemplate = "https:" + jsonRoot.value("urlTemplate").toString();
|
||||||
|
@ -79,7 +82,7 @@ std::pair<Outcome, EmoteMap> parseChannelEmotes(const QJsonObject &jsonRoot)
|
||||||
}
|
}
|
||||||
|
|
||||||
return {Success, std::move(emotes)};
|
return {Success, std::move(emotes)};
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -13,13 +13,11 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
void parseEmoji(const std::shared_ptr<EmojiData> &emojiData,
|
||||||
void parseEmoji(const std::shared_ptr<EmojiData> &emojiData,
|
|
||||||
const rapidjson::Value &unparsedEmoji,
|
const rapidjson::Value &unparsedEmoji,
|
||||||
QString shortCode = QString())
|
QString shortCode = QString())
|
||||||
{
|
{
|
||||||
static uint unicodeBytes[4];
|
static uint unicodeBytes[4];
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
@ -40,7 +38,8 @@ void parseEmoji(const std::shared_ptr<EmojiData> &emojiData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rj::getSafe(unparsedEmoji, "non_qualified", emojiData->nonQualifiedCode);
|
rj::getSafe(unparsedEmoji, "non_qualified",
|
||||||
|
emojiData->nonQualifiedCode);
|
||||||
rj::getSafe(unparsedEmoji, "unified", emojiData->unifiedCode);
|
rj::getSafe(unparsedEmoji, "unified", emojiData->unifiedCode);
|
||||||
|
|
||||||
rj::getSafe(unparsedEmoji, "has_img_apple", capabilities.apple);
|
rj::getSafe(unparsedEmoji, "has_img_apple", capabilities.apple);
|
||||||
|
@ -71,7 +70,8 @@ void parseEmoji(const std::shared_ptr<EmojiData> &emojiData,
|
||||||
|
|
||||||
QStringList unicodeCharacters;
|
QStringList unicodeCharacters;
|
||||||
if (!emojiData->nonQualifiedCode.isEmpty()) {
|
if (!emojiData->nonQualifiedCode.isEmpty()) {
|
||||||
unicodeCharacters = emojiData->nonQualifiedCode.toLower().split('-');
|
unicodeCharacters =
|
||||||
|
emojiData->nonQualifiedCode.toLower().split('-');
|
||||||
} else {
|
} else {
|
||||||
unicodeCharacters = emojiData->unifiedCode.toLower().split('-');
|
unicodeCharacters = emojiData->unifiedCode.toLower().split('-');
|
||||||
}
|
}
|
||||||
|
@ -87,8 +87,7 @@ void parseEmoji(const std::shared_ptr<EmojiData> &emojiData,
|
||||||
}
|
}
|
||||||
|
|
||||||
emojiData->value = QString::fromUcs4(unicodeBytes, numUnicodeBytes);
|
emojiData->value = QString::fromUcs4(unicodeBytes, numUnicodeBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void Emojis::load()
|
void Emojis::load()
|
||||||
|
|
|
@ -10,8 +10,8 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace {
|
namespace {
|
||||||
Url getEmoteLink(const QJsonObject &urls, const QString &emoteScale)
|
Url getEmoteLink(const QJsonObject &urls, const QString &emoteScale)
|
||||||
{
|
{
|
||||||
auto emote = urls.value(emoteScale);
|
auto emote = urls.value(emoteScale);
|
||||||
if (emote.isUndefined()) {
|
if (emote.isUndefined()) {
|
||||||
return {""};
|
return {""};
|
||||||
|
@ -20,10 +20,10 @@ Url getEmoteLink(const QJsonObject &urls, const QString &emoteScale)
|
||||||
assert(emote.isString());
|
assert(emote.isString());
|
||||||
|
|
||||||
return {"https:" + emote.toString()};
|
return {"https:" + emote.toString()};
|
||||||
}
|
}
|
||||||
void fillInEmoteData(const QJsonObject &urls, const EmoteName &name,
|
void fillInEmoteData(const QJsonObject &urls, const EmoteName &name,
|
||||||
const QString &tooltip, Emote &emoteData)
|
const QString &tooltip, Emote &emoteData)
|
||||||
{
|
{
|
||||||
auto url1x = getEmoteLink(urls, "1");
|
auto url1x = getEmoteLink(urls, "1");
|
||||||
auto url2x = getEmoteLink(urls, "2");
|
auto url2x = getEmoteLink(urls, "2");
|
||||||
auto url3x = getEmoteLink(urls, "4");
|
auto url3x = getEmoteLink(urls, "4");
|
||||||
|
@ -34,17 +34,17 @@ void fillInEmoteData(const QJsonObject &urls, const EmoteName &name,
|
||||||
ImageSet{Image::fromUrl(url1x, 1), Image::fromUrl(url2x, 0.5),
|
ImageSet{Image::fromUrl(url1x, 1), Image::fromUrl(url2x, 0.5),
|
||||||
Image::fromUrl(url3x, 0.25)};
|
Image::fromUrl(url3x, 0.25)};
|
||||||
emoteData.tooltip = {tooltip};
|
emoteData.tooltip = {tooltip};
|
||||||
}
|
}
|
||||||
EmotePtr cachedOrMake(Emote &&emote, const EmoteId &id)
|
EmotePtr cachedOrMake(Emote &&emote, const EmoteId &id)
|
||||||
{
|
{
|
||||||
static std::unordered_map<EmoteId, std::weak_ptr<const Emote>> cache;
|
static std::unordered_map<EmoteId, std::weak_ptr<const Emote>> cache;
|
||||||
static std::mutex mutex;
|
static std::mutex mutex;
|
||||||
|
|
||||||
return cachedOrMakeEmotePtr(std::move(emote), cache, mutex, id);
|
return cachedOrMakeEmotePtr(std::move(emote), cache, mutex, id);
|
||||||
}
|
}
|
||||||
std::pair<Outcome, EmoteMap> parseGlobalEmotes(const QJsonObject &jsonRoot,
|
std::pair<Outcome, EmoteMap> parseGlobalEmotes(
|
||||||
const EmoteMap ¤tEmotes)
|
const QJsonObject &jsonRoot, const EmoteMap ¤tEmotes)
|
||||||
{
|
{
|
||||||
auto jsonSets = jsonRoot.value("sets").toObject();
|
auto jsonSets = jsonRoot.value("sets").toObject();
|
||||||
auto emotes = EmoteMap();
|
auto emotes = EmoteMap();
|
||||||
|
|
||||||
|
@ -59,8 +59,8 @@ std::pair<Outcome, EmoteMap> parseGlobalEmotes(const QJsonObject &jsonRoot,
|
||||||
auto urls = jsonEmote.value("urls").toObject();
|
auto urls = jsonEmote.value("urls").toObject();
|
||||||
|
|
||||||
auto emote = Emote();
|
auto emote = Emote();
|
||||||
fillInEmoteData(urls, name, name.string + "<br/>Global FFZ Emote",
|
fillInEmoteData(urls, name,
|
||||||
emote);
|
name.string + "<br/>Global FFZ Emote", emote);
|
||||||
emote.homePage =
|
emote.homePage =
|
||||||
Url{QString("https://www.frankerfacez.com/emoticon/%1-%2")
|
Url{QString("https://www.frankerfacez.com/emoticon/%1-%2")
|
||||||
.arg(id.string)
|
.arg(id.string)
|
||||||
|
@ -72,9 +72,9 @@ std::pair<Outcome, EmoteMap> parseGlobalEmotes(const QJsonObject &jsonRoot,
|
||||||
}
|
}
|
||||||
|
|
||||||
return {Success, std::move(emotes)};
|
return {Success, std::move(emotes)};
|
||||||
}
|
}
|
||||||
std::pair<Outcome, EmoteMap> parseChannelEmotes(const QJsonObject &jsonRoot)
|
std::pair<Outcome, EmoteMap> parseChannelEmotes(const QJsonObject &jsonRoot)
|
||||||
{
|
{
|
||||||
auto jsonSets = jsonRoot.value("sets").toObject();
|
auto jsonSets = jsonRoot.value("sets").toObject();
|
||||||
auto emotes = EmoteMap();
|
auto emotes = EmoteMap();
|
||||||
|
|
||||||
|
@ -85,13 +85,14 @@ std::pair<Outcome, EmoteMap> parseChannelEmotes(const QJsonObject &jsonRoot)
|
||||||
auto jsonEmote = _jsonEmote.toObject();
|
auto jsonEmote = _jsonEmote.toObject();
|
||||||
|
|
||||||
// margins
|
// margins
|
||||||
auto id = EmoteId{QString::number(jsonEmote.value("id").toInt())};
|
auto id =
|
||||||
|
EmoteId{QString::number(jsonEmote.value("id").toInt())};
|
||||||
auto name = EmoteName{jsonEmote.value("name").toString()};
|
auto name = EmoteName{jsonEmote.value("name").toString()};
|
||||||
auto urls = jsonEmote.value("urls").toObject();
|
auto urls = jsonEmote.value("urls").toObject();
|
||||||
|
|
||||||
Emote emote;
|
Emote emote;
|
||||||
fillInEmoteData(urls, name, name.string + "<br/>Channel FFZ Emote",
|
fillInEmoteData(urls, name,
|
||||||
emote);
|
name.string + "<br/>Channel FFZ Emote", emote);
|
||||||
emote.homePage =
|
emote.homePage =
|
||||||
Url{QString("https://www.frankerfacez.com/emoticon/%1-%2")
|
Url{QString("https://www.frankerfacez.com/emoticon/%1-%2")
|
||||||
.arg(id.string)
|
.arg(id.string)
|
||||||
|
@ -102,7 +103,7 @@ std::pair<Outcome, EmoteMap> parseChannelEmotes(const QJsonObject &jsonRoot)
|
||||||
}
|
}
|
||||||
|
|
||||||
return {Success, std::move(emotes)};
|
return {Success, std::move(emotes)};
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
FfzEmotes::FfzEmotes()
|
FfzEmotes::FfzEmotes()
|
||||||
|
|
|
@ -24,31 +24,31 @@ static std::map<QString, std::string> sentMessages;
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
PubSubClient::PubSubClient(WebsocketClient &websocketClient,
|
PubSubClient::PubSubClient(WebsocketClient &websocketClient,
|
||||||
WebsocketHandle handle)
|
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) {
|
||||||
|
@ -73,13 +73,14 @@ bool PubSubClient::listen(rapidjson::Document &message)
|
||||||
this->send(payload.c_str());
|
this->send(payload.c_str());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PubSubClient::unlistenPrefix(const std::string &prefix)
|
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);
|
||||||
|
@ -103,19 +104,19 @@ void PubSubClient::unlistenPrefix(const std::string &prefix)
|
||||||
sentMessages[uuid] = payload;
|
sentMessages[uuid] = payload;
|
||||||
|
|
||||||
this->send(payload.c_str());
|
this->send(payload.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
@ -123,10 +124,10 @@ bool PubSubClient::isListeningToTopic(const std::string &payload)
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PubSubClient::ping()
|
void PubSubClient::ping()
|
||||||
{
|
{
|
||||||
assert(this->started_);
|
assert(this->started_);
|
||||||
|
|
||||||
if (!this->send(pingPayload)) {
|
if (!this->send(pingPayload)) {
|
||||||
|
@ -137,44 +138,45 @@ void PubSubClient::ping()
|
||||||
|
|
||||||
auto self = this->shared_from_this();
|
auto self = this->shared_from_this();
|
||||||
|
|
||||||
runAfter(this->websocketClient_.get_io_service(), std::chrono::seconds(15),
|
runAfter(this->websocketClient_.get_io_service(),
|
||||||
[self](auto timer) {
|
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),
|
runAfter(this->websocketClient_.get_io_service(),
|
||||||
[self](auto timer) {
|
std::chrono::minutes(5), [self](auto timer) {
|
||||||
if (!self->started_) {
|
if (!self->started_) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self->ping(); //
|
self->ping(); //
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PubSubClient::send(const char *payload)
|
bool PubSubClient::send(const char *payload)
|
||||||
{
|
{
|
||||||
WebsocketErrorCode ec;
|
WebsocketErrorCode ec;
|
||||||
this->websocketClient_.send(this->handle_, payload,
|
this->websocketClient_.send(this->handle_, payload,
|
||||||
websocketpp::frame::opcode::text, ec);
|
websocketpp::frame::opcode::text, ec);
|
||||||
|
|
||||||
if (ec) {
|
if (ec) {
|
||||||
log("Error sending message {}: {}", payload, ec.message());
|
log("Error sending message {}: {}", payload, ec.message());
|
||||||
// TODO(pajlada): Check which error code happened and maybe gracefully
|
// TODO(pajlada): Check which error code happened and maybe
|
||||||
// handle it
|
// gracefully handle it
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
|
|
|
@ -32,17 +32,18 @@ using WebsocketErrorCode = websocketpp::lib::error_code;
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
struct Listener {
|
struct Listener {
|
||||||
std::string topic;
|
std::string topic;
|
||||||
bool authed;
|
bool authed;
|
||||||
bool persistent;
|
bool persistent;
|
||||||
bool confirmed = false;
|
bool confirmed = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PubSubClient : public std::enable_shared_from_this<PubSubClient>
|
class PubSubClient : public std::enable_shared_from_this<PubSubClient>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PubSubClient(WebsocketClient &_websocketClient, WebsocketHandle _handle);
|
PubSubClient(WebsocketClient &_websocketClient,
|
||||||
|
WebsocketHandle _handle);
|
||||||
|
|
||||||
void start();
|
void start();
|
||||||
void stop();
|
void stop();
|
||||||
|
@ -54,7 +55,7 @@ public:
|
||||||
|
|
||||||
bool isListeningToTopic(const std::string &topic);
|
bool isListeningToTopic(const std::string &topic);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ping();
|
void ping();
|
||||||
bool send(const char *payload);
|
bool send(const char *payload);
|
||||||
|
|
||||||
|
@ -66,7 +67,7 @@ private:
|
||||||
|
|
||||||
std::atomic<bool> awaitingPong_{false};
|
std::atomic<bool> awaitingPong_{false};
|
||||||
std::atomic<bool> started_{false};
|
std::atomic<bool> started_{false};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "debug/Log.hpp"
|
|
||||||
#include "util/RapidjsonHelpers.hpp"
|
|
||||||
#include "debug/Log.hpp"
|
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
#include <boost/asio/steady_timer.hpp>
|
#include <boost/asio/steady_timer.hpp>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include "debug/Log.hpp"
|
||||||
|
#include "util/RapidjsonHelpers.hpp"
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,8 @@ namespace chatterino {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
EmoteName cleanUpCode(const EmoteName &dirtyEmoteCode)
|
EmoteName cleanUpCode(const EmoteName &dirtyEmoteCode)
|
||||||
{
|
{
|
||||||
auto cleanCode = dirtyEmoteCode.string;
|
auto cleanCode = dirtyEmoteCode.string;
|
||||||
cleanCode.detach();
|
cleanCode.detach();
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ EmoteName cleanUpCode(const EmoteName &dirtyEmoteCode)
|
||||||
cleanCode.replace(">", ">");
|
cleanCode.replace(">", ">");
|
||||||
|
|
||||||
return {cleanCode};
|
return {cleanCode};
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
@ -417,7 +417,7 @@ void TwitchAccount::loadEmotes()
|
||||||
}
|
}
|
||||||
|
|
||||||
AccessGuard<const TwitchAccount::TwitchAccountEmoteData>
|
AccessGuard<const TwitchAccount::TwitchAccountEmoteData>
|
||||||
TwitchAccount::accessEmotes() const
|
TwitchAccount::accessEmotes() const
|
||||||
{
|
{
|
||||||
return this->emotes_.accessConst();
|
return this->emotes_.accessConst();
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,8 +25,9 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace {
|
namespace {
|
||||||
auto parseRecentMessages(const QJsonObject &jsonRoot, TwitchChannel &channel)
|
auto parseRecentMessages(const QJsonObject &jsonRoot,
|
||||||
{
|
TwitchChannel &channel)
|
||||||
|
{
|
||||||
QJsonArray jsonMessages = jsonRoot.value("messages").toArray();
|
QJsonArray jsonMessages = jsonRoot.value("messages").toArray();
|
||||||
std::vector<MessagePtr> messages;
|
std::vector<MessagePtr> messages;
|
||||||
|
|
||||||
|
@ -34,8 +35,8 @@ auto parseRecentMessages(const QJsonObject &jsonRoot, TwitchChannel &channel)
|
||||||
|
|
||||||
for (const auto jsonMessage : jsonMessages) {
|
for (const auto jsonMessage : jsonMessages) {
|
||||||
auto content = jsonMessage.toString().toUtf8();
|
auto content = jsonMessage.toString().toUtf8();
|
||||||
// passing nullptr as the channel makes the message invalid but we don't
|
// passing nullptr as the channel makes the message invalid but we
|
||||||
// check for that anyways
|
// don't check for that anyways
|
||||||
auto message = Communi::IrcMessage::fromData(content, nullptr);
|
auto message = Communi::IrcMessage::fromData(content, nullptr);
|
||||||
auto privMsg = dynamic_cast<Communi::IrcPrivateMessage *>(message);
|
auto privMsg = dynamic_cast<Communi::IrcPrivateMessage *>(message);
|
||||||
assert(privMsg);
|
assert(privMsg);
|
||||||
|
@ -48,9 +49,9 @@ auto parseRecentMessages(const QJsonObject &jsonRoot, TwitchChannel &channel)
|
||||||
}
|
}
|
||||||
|
|
||||||
return messages;
|
return messages;
|
||||||
}
|
}
|
||||||
std::pair<Outcome, UsernameSet> parseChatters(const QJsonObject &jsonRoot)
|
std::pair<Outcome, UsernameSet> parseChatters(const QJsonObject &jsonRoot)
|
||||||
{
|
{
|
||||||
static QStringList categories = {"moderators", "staff", "admins",
|
static QStringList categories = {"moderators", "staff", "admins",
|
||||||
"global_mods", "viewers"};
|
"global_mods", "viewers"};
|
||||||
|
|
||||||
|
@ -66,7 +67,7 @@ std::pair<Outcome, UsernameSet> parseChatters(const QJsonObject &jsonRoot)
|
||||||
}
|
}
|
||||||
|
|
||||||
return {Success, std::move(usernames)};
|
return {Success, std::move(usernames)};
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
TwitchChannel::TwitchChannel(const QString &name,
|
TwitchChannel::TwitchChannel(const QString &name,
|
||||||
|
@ -309,7 +310,7 @@ bool TwitchChannel::isLive() const
|
||||||
}
|
}
|
||||||
|
|
||||||
AccessGuard<const TwitchChannel::StreamStatus>
|
AccessGuard<const TwitchChannel::StreamStatus>
|
||||||
TwitchChannel::accessStreamStatus() const
|
TwitchChannel::accessStreamStatus() const
|
||||||
{
|
{
|
||||||
return this->streamStatus_.accessConst();
|
return this->streamStatus_.accessConst();
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,10 @@ namespace chatterino {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
inline bool ReadValue(const rapidjson::Value &object, const char *key,
|
inline bool ReadValue(const rapidjson::Value &object, const char *key,
|
||||||
Type &out)
|
Type &out)
|
||||||
{
|
{
|
||||||
if (!object.HasMember(key)) {
|
if (!object.HasMember(key)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -25,12 +25,12 @@ inline bool ReadValue(const rapidjson::Value &object, const char *key,
|
||||||
out = value.Get<Type>();
|
out = value.Get<Type>();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline bool ReadValue<QString>(const rapidjson::Value &object, const char *key,
|
inline bool ReadValue<QString>(const rapidjson::Value &object,
|
||||||
QString &out)
|
const char *key, QString &out)
|
||||||
{
|
{
|
||||||
if (!object.HasMember(key)) {
|
if (!object.HasMember(key)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -44,13 +44,13 @@ inline bool ReadValue<QString>(const rapidjson::Value &object, const char *key,
|
||||||
out = value.GetString();
|
out = value.GetString();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline bool ReadValue<std::vector<QString>>(const rapidjson::Value &object,
|
inline bool ReadValue<std::vector<QString>>(const rapidjson::Value &object,
|
||||||
const char *key,
|
const char *key,
|
||||||
std::vector<QString> &out)
|
std::vector<QString> &out)
|
||||||
{
|
{
|
||||||
if (!object.HasMember(key)) {
|
if (!object.HasMember(key)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -70,12 +70,12 @@ inline bool ReadValue<std::vector<QString>>(const rapidjson::Value &object,
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse a single cheermote set (or "action") from the twitch api
|
// Parse a single cheermote set (or "action") from the twitch api
|
||||||
inline bool ParseSingleCheermoteSet(JSONCheermoteSet &set,
|
inline bool ParseSingleCheermoteSet(JSONCheermoteSet &set,
|
||||||
const rapidjson::Value &action)
|
const rapidjson::Value &action)
|
||||||
{
|
{
|
||||||
if (!action.IsObject()) {
|
if (!action.IsObject()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -236,7 +236,7 @@ inline bool ParseSingleCheermoteSet(JSONCheermoteSet &set,
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
// Look through the results of
|
// Look through the results of
|
||||||
|
|
|
@ -34,8 +34,8 @@ struct TwitchUser {
|
||||||
namespace pajlada {
|
namespace pajlada {
|
||||||
namespace Settings {
|
namespace Settings {
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct Deserialize<chatterino::TwitchUser> {
|
struct Deserialize<chatterino::TwitchUser> {
|
||||||
static chatterino::TwitchUser get(const rapidjson::Value &value,
|
static chatterino::TwitchUser get(const rapidjson::Value &value,
|
||||||
bool *error = nullptr)
|
bool *error = nullptr)
|
||||||
{
|
{
|
||||||
|
@ -70,7 +70,7 @@ struct Deserialize<chatterino::TwitchUser> {
|
||||||
|
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Settings
|
} // namespace Settings
|
||||||
} // namespace pajlada
|
} // namespace pajlada
|
||||||
|
|
|
@ -9,16 +9,16 @@
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
|
||||||
#ifdef Q_OS_WIN32
|
#ifdef Q_OS_WIN32
|
||||||
#define DEFAULT_FONT_FAMILY "Segoe UI"
|
# define DEFAULT_FONT_FAMILY "Segoe UI"
|
||||||
#define DEFAULT_FONT_SIZE 10
|
# define DEFAULT_FONT_SIZE 10
|
||||||
#else
|
#else
|
||||||
#ifdef Q_OS_MACOS
|
# ifdef Q_OS_MACOS
|
||||||
#define DEFAULT_FONT_FAMILY "Helvetica Neue"
|
# define DEFAULT_FONT_FAMILY "Helvetica Neue"
|
||||||
#define DEFAULT_FONT_SIZE 12
|
# define DEFAULT_FONT_SIZE 12
|
||||||
#else
|
# else
|
||||||
#define DEFAULT_FONT_FAMILY "Arial"
|
# define DEFAULT_FONT_FAMILY "Arial"
|
||||||
#define DEFAULT_FONT_SIZE 11
|
# define DEFAULT_FONT_SIZE 11
|
||||||
#endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
@ -104,8 +104,7 @@ Fonts::FontData Fonts::createFontData(FontStyle type, float scale)
|
||||||
{FontStyle::ChatMediumSmall, {0.8f, false, QFont::Normal}},
|
{FontStyle::ChatMediumSmall, {0.8f, false, QFont::Normal}},
|
||||||
{FontStyle::ChatMedium, {1, false, QFont::Normal}},
|
{FontStyle::ChatMedium, {1, false, QFont::Normal}},
|
||||||
{FontStyle::ChatMediumBold,
|
{FontStyle::ChatMediumBold,
|
||||||
{1, false,
|
{1, false, QFont::Weight(getSettings()->boldScale.getValue())}},
|
||||||
QFont::Weight(getSettings()->boldScale.getValue())}},
|
|
||||||
{FontStyle::ChatMediumItalic, {1, true, QFont::Normal}},
|
{FontStyle::ChatMediumItalic, {1, true, QFont::Normal}},
|
||||||
{FontStyle::ChatLarge, {1.2f, false, QFont::Normal}},
|
{FontStyle::ChatLarge, {1.2f, false, QFont::Normal}},
|
||||||
{FontStyle::ChatVeryLarge, {1.4f, false, QFont::Normal}},
|
{FontStyle::ChatVeryLarge, {1.4f, false, QFont::Normal}},
|
||||||
|
|
|
@ -17,11 +17,11 @@
|
||||||
namespace ipc = boost::interprocess;
|
namespace ipc = boost::interprocess;
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
#include <QProcess>
|
# include <QProcess>
|
||||||
|
|
||||||
#include <Windows.h>
|
# include <Windows.h>
|
||||||
#include "singletons/WindowManager.hpp"
|
# include "singletons/WindowManager.hpp"
|
||||||
#include "widgets/AttachedWindow.hpp"
|
# include "widgets/AttachedWindow.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
|
@ -10,8 +10,8 @@ namespace chatterino {
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
double getMultiplierByTheme(const QString &themeName)
|
double getMultiplierByTheme(const QString &themeName)
|
||||||
{
|
{
|
||||||
if (themeName == "Light") {
|
if (themeName == "Light") {
|
||||||
return 0.8;
|
return 0.8;
|
||||||
} else if (themeName == "White") {
|
} else if (themeName == "White") {
|
||||||
|
@ -23,7 +23,7 @@ double getMultiplierByTheme(const QString &themeName)
|
||||||
}
|
}
|
||||||
|
|
||||||
return -0.8;
|
return -0.8;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace {
|
namespace {
|
||||||
void appendDuration(int count, QChar &&order, QString &outString)
|
void appendDuration(int count, QChar &&order, QString &outString)
|
||||||
{
|
{
|
||||||
outString.append(QString::number(count));
|
outString.append(QString::number(count));
|
||||||
outString.append(order);
|
outString.append(order);
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
QString formatTime(int totalSeconds)
|
QString formatTime(int totalSeconds)
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
namespace pajlada {
|
namespace pajlada {
|
||||||
namespace Signals {
|
namespace Signals {
|
||||||
class SignalHolder;
|
class SignalHolder;
|
||||||
}
|
}
|
||||||
} // namespace pajlada
|
} // namespace pajlada
|
||||||
|
|
||||||
|
|
|
@ -6,17 +6,17 @@
|
||||||
namespace pajlada {
|
namespace pajlada {
|
||||||
namespace Settings {
|
namespace Settings {
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct Serialize<QString> {
|
struct Serialize<QString> {
|
||||||
static rapidjson::Value get(const QString &value,
|
static rapidjson::Value get(const QString &value,
|
||||||
rapidjson::Document::AllocatorType &a)
|
rapidjson::Document::AllocatorType &a)
|
||||||
{
|
{
|
||||||
return rapidjson::Value(value.toUtf8(), a);
|
return rapidjson::Value(value.toUtf8(), a);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct Deserialize<QString> {
|
struct Deserialize<QString> {
|
||||||
static QString get(const rapidjson::Value &value, bool *error = nullptr)
|
static QString get(const rapidjson::Value &value, bool *error = nullptr)
|
||||||
{
|
{
|
||||||
if (!value.IsString()) {
|
if (!value.IsString()) {
|
||||||
|
@ -37,7 +37,7 @@ struct Deserialize<QString> {
|
||||||
|
|
||||||
return QString{};
|
return QString{};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Settings
|
} // namespace Settings
|
||||||
} // namespace pajlada
|
} // namespace pajlada
|
||||||
|
|
|
@ -5,26 +5,28 @@
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace rj {
|
namespace rj {
|
||||||
|
|
||||||
void addMember(rapidjson::Value &obj, const char *key, rapidjson::Value &&value,
|
void addMember(rapidjson::Value &obj, const char *key,
|
||||||
|
rapidjson::Value &&value,
|
||||||
rapidjson::Document::AllocatorType &a)
|
rapidjson::Document::AllocatorType &a)
|
||||||
{
|
{
|
||||||
obj.AddMember(rapidjson::Value(key, a).Move(), value, a);
|
obj.AddMember(rapidjson::Value(key, a).Move(), value, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
void addMember(rapidjson::Value &obj, const char *key, rapidjson::Value &value,
|
void addMember(rapidjson::Value &obj, const char *key,
|
||||||
|
rapidjson::Value &value,
|
||||||
rapidjson::Document::AllocatorType &a)
|
rapidjson::Document::AllocatorType &a)
|
||||||
{
|
{
|
||||||
obj.AddMember(rapidjson::Value(key, a).Move(), value.Move(), a);
|
obj.AddMember(rapidjson::Value(key, a).Move(), value.Move(), a);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string stringify(const rapidjson::Value &value)
|
std::string stringify(const rapidjson::Value &value)
|
||||||
{
|
{
|
||||||
rapidjson::StringBuffer buffer;
|
rapidjson::StringBuffer buffer;
|
||||||
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
|
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
|
||||||
value.Accept(writer);
|
value.Accept(writer);
|
||||||
|
|
||||||
return std::string(buffer.GetString());
|
return std::string(buffer.GetString());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace rj
|
} // namespace rj
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -11,63 +11,67 @@
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace rj {
|
namespace rj {
|
||||||
|
|
||||||
void addMember(rapidjson::Value &obj, const char *key, rapidjson::Value &&value,
|
void addMember(rapidjson::Value &obj, const char *key,
|
||||||
|
rapidjson::Value &&value,
|
||||||
rapidjson::Document::AllocatorType &a);
|
rapidjson::Document::AllocatorType &a);
|
||||||
void addMember(rapidjson::Value &obj, const char *key, rapidjson::Value &value,
|
void addMember(rapidjson::Value &obj, const char *key,
|
||||||
|
rapidjson::Value &value,
|
||||||
rapidjson::Document::AllocatorType &a);
|
rapidjson::Document::AllocatorType &a);
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
void set(rapidjson::Value &obj, const char *key, const Type &value,
|
void set(rapidjson::Value &obj, const char *key, const Type &value,
|
||||||
rapidjson::Document::AllocatorType &a)
|
rapidjson::Document::AllocatorType &a)
|
||||||
{
|
{
|
||||||
assert(obj.IsObject());
|
assert(obj.IsObject());
|
||||||
|
|
||||||
addMember(obj, key, pajlada::Settings::Serialize<Type>::get(value, a), a);
|
addMember(obj, key, pajlada::Settings::Serialize<Type>::get(value, a),
|
||||||
}
|
a);
|
||||||
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline void set(rapidjson::Value &obj, const char *key,
|
inline void set(rapidjson::Value &obj, const char *key,
|
||||||
const rapidjson::Value &value,
|
const rapidjson::Value &value,
|
||||||
rapidjson::Document::AllocatorType &a)
|
rapidjson::Document::AllocatorType &a)
|
||||||
{
|
{
|
||||||
assert(obj.IsObject());
|
assert(obj.IsObject());
|
||||||
|
|
||||||
addMember(obj, key, const_cast<rapidjson::Value &>(value), a);
|
addMember(obj, key, const_cast<rapidjson::Value &>(value), a);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
void set(rapidjson::Document &obj, const char *key, const Type &value)
|
void set(rapidjson::Document &obj, const char *key, const Type &value)
|
||||||
{
|
{
|
||||||
assert(obj.IsObject());
|
assert(obj.IsObject());
|
||||||
|
|
||||||
auto &a = obj.GetAllocator();
|
auto &a = obj.GetAllocator();
|
||||||
|
|
||||||
addMember(obj, key, pajlada::Settings::Serialize<Type>::get(value, a), a);
|
addMember(obj, key, pajlada::Settings::Serialize<Type>::get(value, a),
|
||||||
}
|
a);
|
||||||
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline void set(rapidjson::Document &obj, const char *key,
|
inline void set(rapidjson::Document &obj, const char *key,
|
||||||
const rapidjson::Value &value)
|
const rapidjson::Value &value)
|
||||||
{
|
{
|
||||||
assert(obj.IsObject());
|
assert(obj.IsObject());
|
||||||
|
|
||||||
auto &a = obj.GetAllocator();
|
auto &a = obj.GetAllocator();
|
||||||
|
|
||||||
addMember(obj, key, const_cast<rapidjson::Value &>(value), a);
|
addMember(obj, key, const_cast<rapidjson::Value &>(value), a);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
void add(rapidjson::Value &arr, const Type &value,
|
void add(rapidjson::Value &arr, const Type &value,
|
||||||
rapidjson::Document::AllocatorType &a)
|
rapidjson::Document::AllocatorType &a)
|
||||||
{
|
{
|
||||||
assert(arr.IsArray());
|
assert(arr.IsArray());
|
||||||
|
|
||||||
arr.PushBack(pajlada::Settings::Serialize<Type>::get(value, a), a);
|
arr.PushBack(pajlada::Settings::Serialize<Type>::get(value, a), a);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
bool getSafe(const rapidjson::Value &obj, const char *key, Type &out)
|
bool getSafe(const rapidjson::Value &obj, const char *key, Type &out)
|
||||||
{
|
{
|
||||||
if (!obj.IsObject()) {
|
if (!obj.IsObject()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -84,18 +88,18 @@ bool getSafe(const rapidjson::Value &obj, const char *key, Type &out)
|
||||||
out = pajlada::Settings::Deserialize<Type>::get(obj[key], &error);
|
out = pajlada::Settings::Deserialize<Type>::get(obj[key], &error);
|
||||||
|
|
||||||
return !error;
|
return !error;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
bool getSafe(const rapidjson::Value &value, Type &out)
|
bool getSafe(const rapidjson::Value &value, Type &out)
|
||||||
{
|
{
|
||||||
bool error = false;
|
bool error = false;
|
||||||
out = pajlada::Settings::Deserialize<Type>::get(value, &error);
|
out = pajlada::Settings::Deserialize<Type>::get(value, &error);
|
||||||
|
|
||||||
return !error;
|
return !error;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string stringify(const rapidjson::Value &value);
|
std::string stringify(const rapidjson::Value &value);
|
||||||
|
|
||||||
} // namespace rj
|
} // namespace rj
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
#include "Application.hpp"
|
#include "Application.hpp"
|
||||||
#include "Helpers.hpp"
|
#include "Helpers.hpp"
|
||||||
|
#include "debug/Log.hpp"
|
||||||
#include "singletons/Settings.hpp"
|
#include "singletons/Settings.hpp"
|
||||||
#include "widgets/dialogs/QualityPopup.hpp"
|
#include "widgets/dialogs/QualityPopup.hpp"
|
||||||
#include "debug/Log.hpp"
|
|
||||||
|
|
||||||
#include <QErrorMessage>
|
#include <QErrorMessage>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
@ -16,26 +16,26 @@ namespace chatterino {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
const char *getBinaryName()
|
const char *getBinaryName()
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
return "streamlink.exe";
|
return "streamlink.exe";
|
||||||
#else
|
#else
|
||||||
return "streamlink";
|
return "streamlink";
|
||||||
#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";
|
||||||
#else
|
#else
|
||||||
return "/usr/bin/streamlink";
|
return "/usr/bin/streamlink";
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
QString getStreamlinkProgram()
|
QString getStreamlinkProgram()
|
||||||
{
|
{
|
||||||
auto app = getApp();
|
auto app = getApp();
|
||||||
|
|
||||||
if (getSettings()->streamlinkUseCustomPath) {
|
if (getSettings()->streamlinkUseCustomPath) {
|
||||||
|
@ -43,29 +43,30 @@ QString getStreamlinkProgram()
|
||||||
} else {
|
} else {
|
||||||
return getBinaryName();
|
return getBinaryName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool checkStreamlinkPath(const QString &path)
|
bool checkStreamlinkPath(const QString &path)
|
||||||
{
|
{
|
||||||
QFileInfo fileinfo(path);
|
QFileInfo fileinfo(path);
|
||||||
|
|
||||||
if (!fileinfo.exists()) {
|
if (!fileinfo.exists()) {
|
||||||
return false;
|
return false;
|
||||||
// throw Exception(fS("Streamlink path ({}) is invalid, file does not
|
// throw Exception(fS("Streamlink path ({}) is invalid, file does
|
||||||
// exist", path));
|
// not exist", path));
|
||||||
}
|
}
|
||||||
|
|
||||||
return fileinfo.isExecutable();
|
return fileinfo.isExecutable();
|
||||||
}
|
}
|
||||||
|
|
||||||
void showStreamlinkNotFoundError()
|
void showStreamlinkNotFoundError()
|
||||||
{
|
{
|
||||||
static QErrorMessage *msg = new QErrorMessage;
|
static QErrorMessage *msg = new QErrorMessage;
|
||||||
|
|
||||||
auto app = getApp();
|
auto app = getApp();
|
||||||
if (getSettings()->streamlinkUseCustomPath) {
|
if (getSettings()->streamlinkUseCustomPath) {
|
||||||
msg->showMessage(
|
msg->showMessage(
|
||||||
"Unable to find Streamlink executable\nMake sure your custom path "
|
"Unable to find Streamlink executable\nMake sure your custom "
|
||||||
|
"path "
|
||||||
"is pointing "
|
"is pointing "
|
||||||
"to the DIRECTORY where the streamlink executable is located");
|
"to the DIRECTORY where the streamlink executable is located");
|
||||||
} else {
|
} else {
|
||||||
|
@ -73,10 +74,10 @@ void showStreamlinkNotFoundError()
|
||||||
"Unable to find Streamlink executable.\nIf you have Streamlink "
|
"Unable to find Streamlink executable.\nIf you have Streamlink "
|
||||||
"installed, you might need to enable the custom path option");
|
"installed, you might need to enable the custom path option");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QProcess *createStreamlinkProcess()
|
QProcess *createStreamlinkProcess()
|
||||||
{
|
{
|
||||||
auto p = new QProcess;
|
auto p = new QProcess;
|
||||||
p->setProgram(getStreamlinkProgram());
|
p->setProgram(getStreamlinkProgram());
|
||||||
|
|
||||||
|
@ -90,14 +91,14 @@ QProcess *createStreamlinkProcess()
|
||||||
p->deleteLater();
|
p->deleteLater();
|
||||||
});
|
});
|
||||||
|
|
||||||
QObject::connect(p,
|
QObject::connect(
|
||||||
static_cast<void (QProcess::*)(int)>(&QProcess::finished),
|
p, static_cast<void (QProcess::*)(int)>(&QProcess::finished),
|
||||||
[=](int res) {
|
[=](int res) {
|
||||||
p->deleteLater(); //
|
p->deleteLater(); //
|
||||||
});
|
});
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
#ifdef USEWINSDK
|
#ifdef USEWINSDK
|
||||||
|
|
||||||
#include <Windows.h>
|
# include <Windows.h>
|
||||||
#include <boost/optional.hpp>
|
# include <boost/optional.hpp>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
|
|
|
@ -8,12 +8,12 @@
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
#ifdef USEWINSDK
|
#ifdef USEWINSDK
|
||||||
#include "util/WindowsHelper.hpp"
|
# include "util/WindowsHelper.hpp"
|
||||||
|
|
||||||
#include "Windows.h"
|
# include "Windows.h"
|
||||||
// don't even think about reordering these
|
// don't even think about reordering these
|
||||||
#include "Psapi.h"
|
# include "Psapi.h"
|
||||||
#pragma comment(lib, "Dwmapi.lib")
|
# pragma comment(lib, "Dwmapi.lib")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
|
@ -20,20 +20,20 @@
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
#ifdef USEWINSDK
|
#ifdef USEWINSDK
|
||||||
#include <ObjIdl.h>
|
# include <ObjIdl.h>
|
||||||
#include <VersionHelpers.h>
|
# include <VersionHelpers.h>
|
||||||
#include <Windows.h>
|
# include <Windows.h>
|
||||||
#include <dwmapi.h>
|
# include <dwmapi.h>
|
||||||
#include <gdiplus.h>
|
# include <gdiplus.h>
|
||||||
#include <windowsx.h>
|
# include <windowsx.h>
|
||||||
|
|
||||||
//#include <ShellScalingApi.h>
|
//#include <ShellScalingApi.h>
|
||||||
#pragma comment(lib, "Dwmapi.lib")
|
# pragma comment(lib, "Dwmapi.lib")
|
||||||
|
|
||||||
#include <QHBoxLayout>
|
# include <QHBoxLayout>
|
||||||
#include <QVBoxLayout>
|
# include <QVBoxLayout>
|
||||||
|
|
||||||
#define WM_DPICHANGED 0x02E0
|
# define WM_DPICHANGED 0x02E0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "widgets/helper/TitlebarButton.hpp"
|
#include "widgets/helper/TitlebarButton.hpp"
|
||||||
|
@ -460,11 +460,11 @@ bool BaseWindow::nativeEvent(const QByteArray &eventType, void *message,
|
||||||
long *result)
|
long *result)
|
||||||
{
|
{
|
||||||
#ifdef USEWINSDK
|
#ifdef USEWINSDK
|
||||||
#if (QT_VERSION == QT_VERSION_CHECK(5, 11, 1))
|
# if (QT_VERSION == QT_VERSION_CHECK(5, 11, 1))
|
||||||
MSG *msg = *reinterpret_cast<MSG **>(message);
|
MSG *msg = *reinterpret_cast<MSG **>(message);
|
||||||
#else
|
# else
|
||||||
MSG *msg = reinterpret_cast<MSG *>(message);
|
MSG *msg = reinterpret_cast<MSG *>(message);
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
bool returnValue = false;
|
bool returnValue = false;
|
||||||
|
|
||||||
|
|
|
@ -433,8 +433,7 @@ void SplitNotebook::addCustomButtons()
|
||||||
// settings
|
// settings
|
||||||
auto settingsBtn = this->addCustomButton();
|
auto settingsBtn = this->addCustomButton();
|
||||||
|
|
||||||
settingsBtn->setVisible(
|
settingsBtn->setVisible(!getSettings()->hidePreferencesButton.getValue());
|
||||||
!getSettings()->hidePreferencesButton.getValue());
|
|
||||||
|
|
||||||
getSettings()->hidePreferencesButton.connect(
|
getSettings()->hidePreferencesButton.connect(
|
||||||
[settingsBtn](bool hide, auto) { settingsBtn->setVisible(!hide); },
|
[settingsBtn](bool hide, auto) { settingsBtn->setVisible(!hide); },
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#include "widgets/splits/Split.hpp"
|
#include "widgets/splits/Split.hpp"
|
||||||
|
|
||||||
#ifdef USEWEBENGINE
|
#ifdef USEWEBENGINE
|
||||||
#include <QtWebEngineWidgets>
|
# include <QtWebEngineWidgets>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
#ifdef USEWINSDK
|
#ifdef USEWINSDK
|
||||||
#include <Windows.h>
|
# include <Windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
|
@ -16,30 +16,32 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace {
|
namespace {
|
||||||
auto makeTitleMessage(const QString &title)
|
auto makeTitleMessage(const QString &title)
|
||||||
{
|
{
|
||||||
MessageBuilder builder;
|
MessageBuilder builder;
|
||||||
builder.emplace<TextElement>(title, MessageElementFlag::Text);
|
builder.emplace<TextElement>(title, MessageElementFlag::Text);
|
||||||
builder->flags.set(MessageFlag::Centered);
|
builder->flags.set(MessageFlag::Centered);
|
||||||
return builder.release();
|
return builder.release();
|
||||||
}
|
}
|
||||||
auto makeEmoteMessage(const EmoteMap &map)
|
auto makeEmoteMessage(const EmoteMap &map)
|
||||||
{
|
{
|
||||||
MessageBuilder builder;
|
MessageBuilder builder;
|
||||||
builder->flags.set(MessageFlag::Centered);
|
builder->flags.set(MessageFlag::Centered);
|
||||||
builder->flags.set(MessageFlag::DisableCompactEmotes);
|
builder->flags.set(MessageFlag::DisableCompactEmotes);
|
||||||
|
|
||||||
for (const auto &emote : map) {
|
for (const auto &emote : map) {
|
||||||
builder
|
builder
|
||||||
.emplace<EmoteElement>(emote.second, MessageElementFlag::AlwaysShow)
|
.emplace<EmoteElement>(emote.second,
|
||||||
|
MessageElementFlag::AlwaysShow)
|
||||||
->setLink(Link(Link::InsertText, emote.first.string));
|
->setLink(Link(Link::InsertText, emote.first.string));
|
||||||
}
|
}
|
||||||
|
|
||||||
return builder.release();
|
return builder.release();
|
||||||
}
|
}
|
||||||
void addEmoteSets(std::vector<std::shared_ptr<TwitchAccount::EmoteSet>> sets,
|
void addEmoteSets(
|
||||||
|
std::vector<std::shared_ptr<TwitchAccount::EmoteSet>> sets,
|
||||||
Channel &globalChannel, Channel &subChannel)
|
Channel &globalChannel, Channel &subChannel)
|
||||||
{
|
{
|
||||||
for (const auto &set : sets) {
|
for (const auto &set : sets) {
|
||||||
auto &channel = set->key == "0" ? globalChannel : subChannel;
|
auto &channel = set->key == "0" ? globalChannel : subChannel;
|
||||||
|
|
||||||
|
@ -64,7 +66,7 @@ void addEmoteSets(std::vector<std::shared_ptr<TwitchAccount::EmoteSet>> sets,
|
||||||
|
|
||||||
channel.addMessage(builder.release());
|
channel.addMessage(builder.release());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
EmotePopup::EmotePopup()
|
EmotePopup::EmotePopup()
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#include "providers/twitch/PartialTwitchUser.hpp"
|
#include "providers/twitch/PartialTwitchUser.hpp"
|
||||||
|
|
||||||
#ifdef USEWINSDK
|
#ifdef USEWINSDK
|
||||||
#include <Windows.h>
|
# include <Windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
|
@ -21,11 +21,11 @@ namespace chatterino {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
void LogInWithCredentials(const std::string &userID,
|
void LogInWithCredentials(const std::string &userID,
|
||||||
const std::string &username,
|
const std::string &username,
|
||||||
const std::string &clientID,
|
const std::string &clientID,
|
||||||
const std::string &oauthToken)
|
const std::string &oauthToken)
|
||||||
{
|
{
|
||||||
QStringList errors;
|
QStringList errors;
|
||||||
|
|
||||||
if (userID.empty()) {
|
if (userID.empty()) {
|
||||||
|
@ -68,7 +68,7 @@ void LogInWithCredentials(const std::string &userID,
|
||||||
// messageBox.exec();
|
// messageBox.exec();
|
||||||
|
|
||||||
getApp()->accounts->twitch.currentUsername = username;
|
getApp()->accounts->twitch.currentUsername = username;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|
|
@ -39,9 +39,9 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace {
|
namespace {
|
||||||
void addEmoteContextMenuItems(const Emote &emote,
|
void addEmoteContextMenuItems(const Emote &emote,
|
||||||
MessageElementFlags creatorFlags, QMenu &menu)
|
MessageElementFlags creatorFlags, QMenu &menu)
|
||||||
{
|
{
|
||||||
auto openAction = menu.addAction("Open");
|
auto openAction = menu.addAction("Open");
|
||||||
auto openMenu = new QMenu;
|
auto openMenu = new QMenu;
|
||||||
openAction->setMenu(openMenu);
|
openAction->setMenu(openMenu);
|
||||||
|
@ -63,8 +63,8 @@ void addEmoteContextMenuItems(const Emote &emote,
|
||||||
QString(scale) + "x link", [url = image->url()] {
|
QString(scale) + "x link", [url = image->url()] {
|
||||||
QApplication::clipboard()->setText(url.string);
|
QApplication::clipboard()->setText(url.string);
|
||||||
});
|
});
|
||||||
openMenu->addAction(QString(scale) + "x link",
|
openMenu->addAction(
|
||||||
[url = image->url()] {
|
QString(scale) + "x link", [url = image->url()] {
|
||||||
QDesktopServices::openUrl(QUrl(url.string));
|
QDesktopServices::openUrl(QUrl(url.string));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -83,8 +83,8 @@ void addEmoteContextMenuItems(const Emote &emote,
|
||||||
"Copy " + name + " emote link", [url = emote.homePage] {
|
"Copy " + name + " emote link", [url = emote.homePage] {
|
||||||
QApplication::clipboard()->setText(url.string); //
|
QApplication::clipboard()->setText(url.string); //
|
||||||
});
|
});
|
||||||
openMenu->addAction("Open " + name + " emote link",
|
openMenu->addAction(
|
||||||
[url = emote.homePage] {
|
"Open " + name + " emote link", [url = emote.homePage] {
|
||||||
QDesktopServices::openUrl(QUrl(url.string)); //
|
QDesktopServices::openUrl(QUrl(url.string)); //
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -94,7 +94,7 @@ void addEmoteContextMenuItems(const Emote &emote,
|
||||||
} else if (creatorFlags.has(MessageElementFlag::FfzEmote)) {
|
} else if (creatorFlags.has(MessageElementFlag::FfzEmote)) {
|
||||||
addPageLink("FFZ");
|
addPageLink("FFZ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
ChannelView::ChannelView(BaseWidget *parent)
|
ChannelView::ChannelView(BaseWidget *parent)
|
||||||
|
|
|
@ -9,15 +9,13 @@
|
||||||
"Choose", "Source", "High", "Medium", "Low", "Audio only"
|
"Choose", "Source", "High", "Medium", "Low", "Audio only"
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
QString createLink(const QString &url, const QString &name)
|
||||||
QString CreateLink(const QString &url, const QString &name)
|
{
|
||||||
{
|
return QString("<a href=\"" + url +
|
||||||
return QString("<a href=\"" + url + "\"><span style=\"color: white;\">" +
|
"\"><span style=\"color: white;\">" + name +
|
||||||
name + "</span></a>");
|
"</span></a>");
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
ExternalToolsPage::ExternalToolsPage()
|
ExternalToolsPage::ExternalToolsPage()
|
||||||
|
@ -41,8 +39,8 @@ ExternalToolsPage::ExternalToolsPage()
|
||||||
description->setStyleSheet("color: #bbb");
|
description->setStyleSheet("color: #bbb");
|
||||||
|
|
||||||
auto links = new QLabel(
|
auto links = new QLabel(
|
||||||
CreateLink("https://streamlink.github.io/", "Website") + " " +
|
createLink("https://streamlink.github.io/", "Website") + " " +
|
||||||
CreateLink(
|
createLink(
|
||||||
"https://github.com/streamlink/streamlink/releases/latest",
|
"https://github.com/streamlink/streamlink/releases/latest",
|
||||||
"Download"));
|
"Download"));
|
||||||
links->setTextFormat(Qt::RichText);
|
links->setTextFormat(Qt::RichText);
|
||||||
|
|
|
@ -69,8 +69,7 @@ void addPhrasesTab(LayoutCreator<QVBoxLayout> layout)
|
||||||
void addUsersTab(IgnoresPage &page, LayoutCreator<QVBoxLayout> users,
|
void addUsersTab(IgnoresPage &page, LayoutCreator<QVBoxLayout> users,
|
||||||
QStringListModel &userModel)
|
QStringListModel &userModel)
|
||||||
{
|
{
|
||||||
users.append(
|
users.append(page.createCheckBox("Enable twitch ignored users",
|
||||||
page.createCheckBox("Enable twitch ignored users",
|
|
||||||
getSettings()->enableTwitchIgnoredUsers));
|
getSettings()->enableTwitchIgnoredUsers));
|
||||||
|
|
||||||
auto anyways = users.emplace<QHBoxLayout>().withoutMargin();
|
auto anyways = users.emplace<QHBoxLayout>().withoutMargin();
|
||||||
|
|
|
@ -31,9 +31,9 @@
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
#ifdef USEWINSDK
|
#ifdef USEWINSDK
|
||||||
#define WINDOW_TOPMOST "Window always on top"
|
# define WINDOW_TOPMOST "Window always on top"
|
||||||
#else
|
#else
|
||||||
#define WINDOW_TOPMOST "Window always on top (requires restart)"
|
# define WINDOW_TOPMOST "Window always on top (requires restart)"
|
||||||
#endif
|
#endif
|
||||||
#define INPUT_EMPTY "Show input box when empty"
|
#define INPUT_EMPTY "Show input box when empty"
|
||||||
#define LAST_MSG "Mark the last message you read"
|
#define LAST_MSG "Mark the last message you read"
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
inline QString CreateLink(const QString &url, bool file = false)
|
inline QString createLink(const QString &url, bool file = false)
|
||||||
{
|
{
|
||||||
if (file) {
|
if (file) {
|
||||||
return QString("<a href=\"file:///" + url +
|
return QString("<a href=\"file:///" + url +
|
||||||
|
|
|
@ -26,13 +26,13 @@
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
#ifdef USEWEBENGINE
|
#ifdef USEWEBENGINE
|
||||||
#include "widgets/StreamView.hpp"
|
# include "widgets/StreamView.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace {
|
namespace {
|
||||||
auto formatRoomMode(TwitchChannel &channel) -> QString
|
auto formatRoomMode(TwitchChannel &channel) -> QString
|
||||||
{
|
{
|
||||||
QString text;
|
QString text;
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -40,7 +40,8 @@ auto formatRoomMode(TwitchChannel &channel) -> QString
|
||||||
|
|
||||||
if (modes->r9k) text += "r9k, ";
|
if (modes->r9k) text += "r9k, ";
|
||||||
if (modes->slowMode)
|
if (modes->slowMode)
|
||||||
text += QString("slow(%1), ").arg(QString::number(modes->slowMode));
|
text +=
|
||||||
|
QString("slow(%1), ").arg(QString::number(modes->slowMode));
|
||||||
if (modes->emoteOnly) text += "emote, ";
|
if (modes->emoteOnly) text += "emote, ";
|
||||||
if (modes->submode) text += "sub, ";
|
if (modes->submode) text += "sub, ";
|
||||||
}
|
}
|
||||||
|
@ -60,9 +61,9 @@ auto formatRoomMode(TwitchChannel &channel) -> QString
|
||||||
if (text.isEmpty() && channel.hasModRights()) return "none";
|
if (text.isEmpty() && channel.hasModRights()) return "none";
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
auto formatTooltip(const TwitchChannel::StreamStatus &s)
|
auto formatTooltip(const TwitchChannel::StreamStatus &s)
|
||||||
{
|
{
|
||||||
return QStringList{"<style>.center { text-align: center; }</style>",
|
return QStringList{"<style>.center { text-align: center; }</style>",
|
||||||
"<p class=\"center\">",
|
"<p class=\"center\">",
|
||||||
s.title,
|
s.title,
|
||||||
|
@ -77,9 +78,9 @@ auto formatTooltip(const TwitchChannel::StreamStatus &s)
|
||||||
" viewers",
|
" viewers",
|
||||||
"</p>"}
|
"</p>"}
|
||||||
.join("");
|
.join("");
|
||||||
}
|
}
|
||||||
auto formatTitle(const TwitchChannel::StreamStatus &s, Settings &settings)
|
auto formatTitle(const TwitchChannel::StreamStatus &s, Settings &settings)
|
||||||
{
|
{
|
||||||
auto title = QString();
|
auto title = QString();
|
||||||
|
|
||||||
// live
|
// live
|
||||||
|
@ -98,14 +99,14 @@ auto formatTitle(const TwitchChannel::StreamStatus &s, Settings &settings)
|
||||||
if (settings.showUptime) title += " - " + s.uptime;
|
if (settings.showUptime) title += " - " + s.uptime;
|
||||||
|
|
||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
auto distance(QPoint a, QPoint b)
|
auto distance(QPoint a, QPoint b)
|
||||||
{
|
{
|
||||||
auto x = std::abs(a.x() - b.x());
|
auto x = std::abs(a.x() - b.x());
|
||||||
auto y = std::abs(a.y() - b.y());
|
auto y = std::abs(a.y() - b.y());
|
||||||
|
|
||||||
return std::sqrt(x * x + y * y);
|
return std::sqrt(x * x + y * y);
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
SplitHeader::SplitHeader(Split *_split)
|
SplitHeader::SplitHeader(Split *_split)
|
||||||
|
|
Loading…
Reference in a new issue