Skip to content

Commit

Permalink
Merge branch 'master' into fix/repopulate-user-info-popup-with-id
Browse files Browse the repository at this point in the history
  • Loading branch information
Felanbird authored Nov 26, 2024
2 parents 0c72f7f + 280f9e4 commit b38d3a3
Show file tree
Hide file tree
Showing 18 changed files with 293 additions and 85 deletions.
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
- Minor: Made usernames in bits and sub messages clickable. (#5686)
- Minor: Mentions of FrankerFaceZ and BetterTTV in settings are standardized as such. (#5698)
- Minor: Emote names are no longer duplicated when using smarter emote completion. (#5705)
- Minor: Added a setting to hide the scrollbar thumb (the handle you can drag). Hiding the scrollbar thumb will disable mouse click & drag interactions in the scrollbar. (#5731)
- Minor: Added a setting to hide the scrollbar highlights. (#5732)
- Minor: The window layout is now backed up like the other settings. (#5647)
- Bugfix: Fixed tab move animation occasionally failing to start after closing a tab. (#5426, #5612)
- 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 @@ -67,7 +70,9 @@
- Bugfix: Fixed global badges not showing in anonymous mode. (#5599)
- Bugfix: Fixed grammar in the user highlight page. (#5602)
- Bugfix: Fixed incorrect message being disabled in some cases upon approving or denying an automod caught message. (#5611)
- Bugfix: Fixed network requests timing out despite them not being in flight for that long, for Qt 6.3+ where we have the technology. (#5729)
- Bugfix: Fixed double-click selection not working when clicking outside a message. (#5617)
- Bugfix: Fixed a potential rare crash that could occur on Windows if a toast was about to fire just as we were shutting down. (#5728)
- Bugfix: Fixed emotes starting with ":" not tab-completing. (#5603)
- Bugfix: Fixed 7TV emotes messing with Qt's HTML. (#5677)
- Bugfix: Fixed incorrect messages getting replaced visually. (#5683)
Expand Down Expand Up @@ -119,7 +124,6 @@
- Dev: Refactored legacy Unicode zero-width-joiner replacement. (#5594)
- Dev: The JSON output when copying a message (<kbd>SHIFT</kbd> + right-click) is now more extensive. (#5600)
- Dev: Added more tests for message building. (#5598, #5654, #5656, #5671)
- Dev: Twitch messages are now sent using Twitch's Helix API instead of IRC by default. (#5607)
- Dev: `GIFTimer` is no longer initialized in tests. (#5608)
- Dev: Emojis now use flags instead of a set of strings for capabilities. (#5616)
- Dev: Move plugins to Sol2. (#5622, #5682)
Expand All @@ -129,10 +133,11 @@
- Dev: Decoupled reply parsing from `MessageBuilder`. (#5660, #5668)
- Dev: Refactored IRC message building. (#5663)
- Dev: Fixed some compiler warnings. (#5672)
- Dev: Explicitly print output from `--version` to `stdout`. (#5727)
- Dev: Unified parsing of historic and live IRC messages. (#5678)
- Dev: 7TV's `entitlement.reset` is now explicitly ignored. (#5685)
- Dev: Qt 6.8 and later now default to the GDI fontengine. (#5710)
- Dev: Moved to condition variables when shutting down worker threads. (#5721)
- Dev: Moved to condition variables when shutting down worker threads. (#5721, #5733)

## 2.5.1

Expand Down
2 changes: 1 addition & 1 deletion lib/settings
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ set(SOURCE_FILES
util/DisplayBadge.cpp
util/DisplayBadge.hpp
util/Expected.hpp
util/FilesystemHelpers.hpp
util/FormatTime.cpp
util/FormatTime.hpp
util/FunctionEventFilter.cpp
Expand Down
25 changes: 19 additions & 6 deletions src/common/network/NetworkTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,35 @@ NetworkTask::~NetworkTask()

void NetworkTask::run()
{
this->reply_ = this->createReply();
if (!this->reply_)
{
this->deleteLater();
return;
}

const auto &timeout = this->data_->timeout;
if (timeout.has_value())
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 3, 0)
QObject::connect(this->reply_, &QNetworkReply::requestSent, this,
[this]() {
const auto &timeout = this->data_->timeout;
this->timer_ = new QTimer(this);
this->timer_->setSingleShot(true);
this->timer_->start(timeout.value());
QObject::connect(this->timer_, &QTimer::timeout,
this, &NetworkTask::timeout);
});
#else
this->timer_ = new QTimer(this);
this->timer_->setSingleShot(true);
this->timer_->start(timeout.value());
QObject::connect(this->timer_, &QTimer::timeout, this,
&NetworkTask::timeout);
#endif
}

this->reply_ = this->createReply();
if (!this->reply_)
{
this->deleteLater();
return;
}
QObject::connect(this->reply_, &QNetworkReply::finished, this,
&NetworkTask::finished);
}
Expand Down
21 changes: 13 additions & 8 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,16 @@ int main(int argc, char **argv)
QMessageBox box;
if (Modes::instance().isPortable)
{
box.setText(
auto errorMessage =
error.what() +
QStringLiteral(
"\n\nInfo: Portable mode requires the application to "
"be in a writeable location. If you don't want "
"portable mode reinstall the application. "
"https://chatterino.com."));
"https://chatterino.com.");
std::cerr << errorMessage.toLocal8Bit().constData() << '\n';
std::cerr.flush();
box.setText(errorMessage);
}
else
{
Expand All @@ -77,12 +80,14 @@ int main(int argc, char **argv)
attachToConsole();

auto version = Version::instance();
qInfo().noquote() << QString("%1 (commit %2%3)")
.arg(version.fullVersion())
.arg(version.commitHash())
.arg(Modes::instance().isNightly
? ", " + version.dateOfBuild()
: "");
auto versionMessage =
QString("%1 (commit %2%3)")
.arg(version.fullVersion())
.arg(version.commitHash())
.arg(Modes::instance().isNightly ? ", " + version.dateOfBuild()
: "");
std::cout << versionMessage.toLocal8Bit().constData() << '\n';
std::cout.flush();
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions src/providers/twitch/TwitchIrcServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,14 @@ bool shouldSendHelixChat()
{
switch (getSettings()->chatSendProtocol)
{
case ChatSendProtocol::Default:
case ChatSendProtocol::Helix:
return true;
case ChatSendProtocol::Default:
case ChatSendProtocol::IRC:
return false;
default:
assert(false && "Invalid chat protocol value");
return true;
return false;
}
}

Expand Down
10 changes: 10 additions & 0 deletions src/singletons/Settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,16 @@ class Settings
{300, 500},
};

// Scrollbar
BoolSetting hideScrollbarThumb = {
"/appearance/scrollbar/hideThumb",
false,
};
BoolSetting hideScrollbarHighlights = {
"/appearance/scrollbar/hideHighlights",
false,
};

/// Behaviour
BoolSetting allowDuplicateMessages = {"/behaviour/allowDuplicateMessages",
true};
Expand Down
7 changes: 7 additions & 0 deletions src/singletons/Toasts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ using WinToastLib::WinToast;
using WinToastLib::WinToastTemplate;
#endif

Toasts::~Toasts()
{
#ifdef Q_OS_WIN
WinToast::instance()->clear();
#endif
}

bool Toasts::isEnabled()
{
#ifdef Q_OS_WIN
Expand Down
4 changes: 4 additions & 0 deletions src/singletons/Toasts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include <pajlada/settings/setting.hpp>
#include <QString>

#include <cstdint>

namespace chatterino {

enum class Platform : uint8_t;
Expand All @@ -17,6 +19,8 @@ enum class ToastReaction {
class Toasts final
{
public:
~Toasts();

void sendChannelNotification(const QString &channelName,
const QString &channelTitle, Platform p);
static QString findStringFromReaction(const ToastReaction &reaction);
Expand Down
40 changes: 28 additions & 12 deletions src/singletons/WindowManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "singletons/Settings.hpp"
#include "singletons/Theme.hpp"
#include "util/CombinePath.hpp"
#include "util/FilesystemHelpers.hpp"
#include "util/SignalListener.hpp"
#include "widgets/AccountSwitchPopup.hpp"
#include "widgets/dialogs/SettingsDialog.hpp"
Expand All @@ -21,6 +22,7 @@
#include "widgets/splits/SplitContainer.hpp"
#include "widgets/Window.hpp"

#include <pajlada/settings/backup.hpp>
#include <QDebug>
#include <QJsonArray>
#include <QJsonDocument>
Expand Down Expand Up @@ -516,19 +518,33 @@ void WindowManager::save()
document.setObject(obj);

// save file
QSaveFile file(this->windowLayoutFilePath);
file.open(QIODevice::WriteOnly | QIODevice::Truncate);

QJsonDocument::JsonFormat format =
#ifdef _DEBUG
QJsonDocument::JsonFormat::Compact
#else
(QJsonDocument::JsonFormat)0
#endif
;
std::error_code ec;
pajlada::Settings::Backup::saveWithBackup(
qStringToStdPath(this->windowLayoutFilePath),
{.enabled = true, .numSlots = 9},
[&](const auto &path, auto &ec) {
QSaveFile file(stdPathToQString(path));
if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate))
{
ec = std::make_error_code(std::errc::io_error);
return;
}

file.write(document.toJson(QJsonDocument::Indented));
if (!file.commit() || file.error() != QFile::NoError)
{
ec = std::make_error_code(std::errc::io_error);
}
},
ec);

file.write(document.toJson(format));
file.commit();
if (ec)
{
// TODO(Qt 6.5): drop fromStdString
qCWarning(chatterinoWindowmanager)
<< "Failed to save windowlayout"
<< QString::fromStdString(ec.message());
}
}

void WindowManager::sendAlert()
Expand Down
26 changes: 26 additions & 0 deletions src/util/FilesystemHelpers.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#pragma once

#include <QFileDevice>
#include <QString>

#include <filesystem>

namespace chatterino {

inline QString stdPathToQString(const std::filesystem::path &path)
{
#ifdef Q_OS_WIN
return QString::fromStdWString(path.native());
#else
return QString::fromStdString(path.native());
#endif
}

inline std::filesystem::path qStringToStdPath(const QString &path)
{
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
const auto *ptr = reinterpret_cast<const char16_t *>(path.utf16());
return {ptr, ptr + path.size()};
}

} // namespace chatterino
2 changes: 1 addition & 1 deletion src/widgets/OverlayWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ OverlayWindow::OverlayWindow(IndirectChannel channel,
this->holder_.managedConnect(this->channel_.getChannelChanged(), [this]() {
this->channelView_.setChannel(this->channel_.get());
});
this->channelView_.scrollbar()->setShowThumb(false);
this->channelView_.scrollbar()->setHideThumb(true);

this->setAutoFillBackground(false);
this->resize(300, 500);
Expand Down
Loading

0 comments on commit b38d3a3

Please sign in to comment.