Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into chatterino7
Browse files Browse the repository at this point in the history
  • Loading branch information
Nerixyz committed Aug 4, 2024
2 parents 38fd01c + 3257da1 commit 2bec1c6
Show file tree
Hide file tree
Showing 99 changed files with 962 additions and 524 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
- Minor: Support more Firefox variants for incognito link opening. (#5503)
- Minor: Replying to a message will now display the message being replied to. (#4350, #5519)
- Minor: Links can now have prefixes and suffixes such as parentheses. (#5486, #5515)
- Minor: Added support for scrolling in splits with touchscreen panning gestures. (#5524)
- Bugfix: Fixed tab move animation occasionally failing to start after closing a tab. (#5426)
- Bugfix: If a network request errors with 200 OK, Qt's error code is now reported instead of the HTTP status. (#5378)
- Bugfix: Fixed restricted users usernames not being clickable. (#5405)
Expand All @@ -34,6 +35,7 @@
- Bugfix: Fixed `/clearmessages` not working with more than one window. (#5489)
- Bugfix: Fixed splits staying paused after unfocusing Chatterino in certain configurations. (#5504)
- Bugfix: Links with invalid characters in the domain are no longer detected. (#5509)
- Bugfix: Fixed janky selection for messages with RTL segments (selection is still wrong, but consistently wrong). (#5525)
- Dev: Update Windows build from Qt 6.5.0 to Qt 6.7.1. (#5420)
- Dev: Update vcpkg build Qt from 6.5.0 to 6.7.0, boost from 1.83.0 to 1.85.0, openssl from 3.1.3 to 3.3.0. (#5422)
- Dev: Unsingletonize `ISoundController`. (#5462)
Expand All @@ -55,6 +57,9 @@
- Dev: Deprecate Qt 5.12. (#5396)
- Dev: The running Qt version is now shown in the about page if it differs from the compiled version. (#5501)
- Dev: `FlagsEnum` is now `constexpr`. (#5510)
- Dev: Documented and added tests to RTL handling. (#5473)
- Dev: Refactored a few `#define`s into `const(expr)` and cleaned includes. (#5527)
- Dev: Prepared for Qt 6.8 by addressing some deprecations. (#5529)

## 2.5.1

Expand Down
2 changes: 1 addition & 1 deletion src/common/ChannelChatters.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "ChannelChatters.hpp"
#include "common/ChannelChatters.hpp"

#include "common/Channel.hpp"
#include "messages/Message.hpp"
Expand Down
33 changes: 13 additions & 20 deletions src/common/Common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,32 @@
#include <QWidget>

#include <memory>
#include <optional>
#include <string>

#define LINK_CHATTERINO_WIKI "https://wiki.chatterino.com"
#define LINK_CHATTERINO_DISCORD "https://discord.gg/7Y5AYhAK4z"
#define LINK_CHATTERINO_SOURCE "https://github.com/Chatterino/chatterino2"

namespace chatterino {

const inline auto TWITCH_PLAYER_URL =
QStringLiteral("https://player.twitch.tv/?channel=%1&parent=twitch.tv");
constexpr QStringView LINK_CHATTERINO_WIKI = u"https://wiki.chatterino.com";
constexpr QStringView LINK_CHATTERINO_DISCORD =
u"https://discord.gg/7Y5AYhAK4z";
constexpr QStringView LINK_CHATTERINO_SOURCE =
u"https://github.com/Chatterino/chatterino2";

constexpr QStringView TWITCH_PLAYER_URL =
u"https://player.twitch.tv/?channel=%1&parent=twitch.tv";

enum class HighlightState {
None,
Highlighted,
NewMessage,
};

const Qt::KeyboardModifiers showSplitOverlayModifiers =
constexpr Qt::KeyboardModifiers SHOW_SPLIT_OVERLAY_MODIFIERS =
Qt::ControlModifier | Qt::AltModifier;
const Qt::KeyboardModifiers showAddSplitRegions =
constexpr Qt::KeyboardModifiers SHOW_ADD_SPLIT_REGIONS =
Qt::ControlModifier | Qt::AltModifier;
const Qt::KeyboardModifiers showResizeHandlesModifiers = Qt::ControlModifier;

#ifndef ATTR_UNUSED
# ifdef Q_OS_WIN
# define ATTR_UNUSED
# else
# define ATTR_UNUSED __attribute__((unused))
# endif
#endif
constexpr Qt::KeyboardModifiers SHOW_RESIZE_HANDLES_MODIFIERS =
Qt::ControlModifier;

static const char *ANONYMOUS_USERNAME_LABEL ATTR_UNUSED = " - anonymous - ";
constexpr const char *ANONYMOUS_USERNAME_LABEL = " - anonymous - ";

template <typename T>
std::weak_ptr<T> weakOf(T *element)
Expand Down
19 changes: 10 additions & 9 deletions src/common/Credentials.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <QJsonDocument>
#include <QJsonObject>
#include <QSaveFile>
#include <QStringBuilder>

#include <variant>

Expand All @@ -26,16 +27,16 @@
# endif
#endif

#define FORMAT_NAME \
([&] { \
assert(!provider.contains(":")); \
return QString("chatterino:%1:%2").arg(provider).arg(name_); \
})()

namespace {

using namespace chatterino;

QString formatName(const QString &provider, const QString &name)
{
assert(!provider.contains(":"));
return u"chatterino:" % provider % u':' % name;
}

bool useKeyring()
{
#ifdef NO_QTKEYCHAIN
Expand Down Expand Up @@ -184,7 +185,7 @@ void Credentials::get(const QString &provider, const QString &name_,
{
assertInGuiThread();

auto name = FORMAT_NAME;
auto name = formatName(provider, name_);

if (useKeyring())
{
Expand Down Expand Up @@ -219,7 +220,7 @@ void Credentials::set(const QString &provider, const QString &name_,
/// On linux, we try to use a keychain but show a message to disable it when it fails.
/// XXX: add said message

auto name = FORMAT_NAME;
auto name = formatName(provider, name_);

if (useKeyring())
{
Expand All @@ -242,7 +243,7 @@ void Credentials::erase(const QString &provider, const QString &name_)
{
assertInGuiThread();

auto name = FORMAT_NAME;
auto name = formatName(provider, name_);

if (useKeyring())
{
Expand Down
34 changes: 18 additions & 16 deletions src/common/LinkParser.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
#define QT_NO_CAST_FROM_ASCII // avoids unexpected implicit casts
#include "common/LinkParser.hpp"

#include "util/QCompareCaseInsensitive.hpp"

#include <QFile>
#include <QSet>
#include <QString>
#include <QStringView>
#include <QTextStream>

#include <set>

namespace {

QSet<QString> &tlds()
using namespace chatterino;

using TldSet = std::set<QString, QCompareCaseInsensitive>;

TldSet &tlds()
{
static QSet<QString> tlds = [] {
static TldSet tlds = [] {
QFile file(QStringLiteral(":/tlds.txt"));
file.open(QFile::ReadOnly);
QTextStream stream(&file);
Expand All @@ -21,19 +28,12 @@ QSet<QString> &tlds()
#else
stream.setCodec("UTF-8");
#endif
int safetyMax = 20000;

QSet<QString> set;
TldSet set;

while (!stream.atEnd())
{
auto line = stream.readLine();
set.insert(line);

if (safetyMax-- == 0)
{
break;
}
set.emplace(stream.readLine());
}

return set;
Expand All @@ -43,7 +43,7 @@ QSet<QString> &tlds()

bool isValidTld(QStringView tld)
{
return tlds().contains(tld.toString().toLower());
return tlds().contains(tld);
}

bool isValidIpv4(QStringView host)
Expand Down Expand Up @@ -166,6 +166,8 @@ namespace chatterino::linkparser {

std::optional<Parsed> parse(const QString &source) noexcept
{
using SizeType = QString::size_type;

std::optional<Parsed> result;
// This is not implemented with a regex to increase performance.

Expand Down Expand Up @@ -201,11 +203,11 @@ std::optional<Parsed> parse(const QString &source) noexcept
QStringView host = remaining;
QStringView rest;
bool lastWasDot = true;
int lastDotPos = -1;
int nDots = 0;
SizeType lastDotPos = -1;
SizeType nDots = 0;

// Extract the host
for (int i = 0; i < remaining.size(); i++)
for (SizeType i = 0; i < remaining.size(); i++)
{
char16_t currentChar = remaining[i].unicode();
if (currentChar == u'.')
Expand Down
2 changes: 1 addition & 1 deletion src/common/Modes.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "Modes.hpp"
#include "common/Modes.hpp"

#include "util/CombinePath.hpp"

Expand Down
19 changes: 3 additions & 16 deletions src/common/Version.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#pragma once

#include <QString>
#include <QtGlobal>

namespace chatterino {

/**
* Valid version formats, in order of latest to oldest
Expand All @@ -24,21 +25,7 @@
* - 2.4.0-alpha.2
* - 2.4.0-alpha
**/
#define CHATTERINO_VERSION "7.5.1"

#if defined(Q_OS_WIN)
# define CHATTERINO_OS "win"
#elif defined(Q_OS_MACOS)
# define CHATTERINO_OS "macos"
#elif defined(Q_OS_LINUX)
# define CHATTERINO_OS "linux"
#elif defined(Q_OS_FREEBSD)
# define CHATTERINO_OS "freebsd"
#else
# define CHATTERINO_OS "unknown"
#endif

namespace chatterino {
inline const QString CHATTERINO_VERSION = QStringLiteral("7.5.1");

class Version
{
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/accounts/Account.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "Account.hpp"
#include "controllers/accounts/Account.hpp"

#include <tuple>

Expand Down
2 changes: 1 addition & 1 deletion src/controllers/accounts/AccountModel.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "AccountModel.hpp"
#include "controllers/accounts/AccountModel.hpp"

#include "controllers/accounts/Account.hpp"
#include "util/StandardItemHelper.hpp"
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/commands/Command.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "Command.hpp"
#include "controllers/commands/Command.hpp"

namespace chatterino {

Expand Down
23 changes: 18 additions & 5 deletions src/controllers/filters/lang/Types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,35 @@ QString possibleTypeToString(const PossibleType &possible);

bool isList(const PossibleType &possibleType);

inline bool variantIs(const QVariant &a, QMetaType::Type type)
inline bool variantIs(const QVariant &a, int type)
{
return static_cast<QMetaType::Type>(a.type()) == type;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
return a.typeId() == type;
#else
return a.type() == type;
#endif
}

inline bool variantIsNot(const QVariant &a, QMetaType::Type type)
inline bool variantIsNot(const QVariant &a, int type)
{
return static_cast<QMetaType::Type>(a.type()) != type;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
return a.typeId() != type;
#else
return a.type() != type;
#endif
}

inline bool convertVariantTypes(QVariant &a, QVariant &b, int type)
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QMetaType ty(type);
return a.convert(ty) && b.convert(ty);
#else
return a.convert(type) && b.convert(type);
#endif
}

inline bool variantTypesMatch(QVariant &a, QVariant &b, QMetaType::Type type)
inline bool variantTypesMatch(QVariant &a, QVariant &b, int type)
{
return variantIs(a, type) && variantIs(b, type);
}
Expand Down
Loading

0 comments on commit 2bec1c6

Please sign in to comment.