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 Nov 30, 2024
2 parents 2036aba + f6d6e2c commit bc3794f
Show file tree
Hide file tree
Showing 14 changed files with 197 additions and 72 deletions.
8 changes: 6 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 Down Expand Up @@ -75,6 +78,7 @@
- Bugfix: Fixed incorrect messages getting replaced visually. (#5683)
- Bugfix: Fixed rendering of multi-line selection that starts at a trailing space. (#5691)
- Bugfix: Fixed pause indicator not appearing in certain cases. (#5707)
- Bugfix: Fixed usercards not showing the login name in specific cases. (#5738)
- Dev: Default build with Qt6 on all platforms. (#5716)
- 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)
Expand Down Expand Up @@ -120,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 @@ -134,7 +137,8 @@
- 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)
- Dev: Reduced layouts in channel views when setting a channel. (#5737)

## 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 @@ -513,6 +513,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
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 @@ -229,6 +229,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
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
142 changes: 92 additions & 50 deletions src/widgets/Scrollbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,20 @@ Scrollbar::Scrollbar(size_t messagesLimit, ChannelView *parent)
&Scrollbar::resetBounds);

this->setMouseTracking(true);

getSettings()->hideScrollbarThumb.connect(
[this](bool newValue) {
this->settingHideThumb = newValue;
this->update();
},
this->signalHolder);

getSettings()->hideScrollbarHighlights.connect(
[this](bool newValue) {
this->settingHideHighlights = newValue;
this->update();
},
this->signalHolder);
}

boost::circular_buffer<ScrollbarHighlight> Scrollbar::getHighlights() const
Expand Down Expand Up @@ -285,7 +299,7 @@ void Scrollbar::paintEvent(QPaintEvent * /*event*/)
bool enableElevatedMessageHighlights =
getSettings()->enableElevatedMessageHighlight;

if (this->showThumb_)
if (this->shouldShowThumb())
{
this->thumbRect_.setX(xOffset);

Expand All @@ -302,62 +316,60 @@ void Scrollbar::paintEvent(QPaintEvent * /*event*/)
}
}

// draw highlights
if (this->highlights_.empty())
if (this->shouldShowHighlights() && !this->highlights_.empty())
{
return;
}

size_t nHighlights = this->highlights_.size();
int w = this->width();
float dY =
static_cast<float>(this->height()) / static_cast<float>(nHighlights);
int highlightHeight =
static_cast<int>(std::ceil(std::max(this->scale() * 2.0F, dY)));
size_t nHighlights = this->highlights_.size();
int w = this->width();
float dY = static_cast<float>(this->height()) /
static_cast<float>(nHighlights);
int highlightHeight =
static_cast<int>(std::ceil(std::max(this->scale() * 2.0F, dY)));

for (size_t i = 0; i < nHighlights; i++)
{
const auto &highlight = this->highlights_[i];

for (size_t i = 0; i < nHighlights; i++)
{
const auto &highlight = this->highlights_[i];
if (highlight.isNull())
{
continue;
}

if (highlight.isNull())
{
continue;
}
if (highlight.isRedeemedHighlight() && !enableRedeemedHighlights)
{
continue;
}

if (highlight.isRedeemedHighlight() && !enableRedeemedHighlights)
{
continue;
}
if (highlight.isFirstMessageHighlight() &&
!enableFirstMessageHighlights)
{
continue;
}

if (highlight.isFirstMessageHighlight() &&
!enableFirstMessageHighlights)
{
continue;
}
if (highlight.isElevatedMessageHighlight() &&
!enableElevatedMessageHighlights)
{
continue;
}

if (highlight.isElevatedMessageHighlight() &&
!enableElevatedMessageHighlights)
{
continue;
}
QColor color = highlight.getColor();
color.setAlpha(255);

QColor color = highlight.getColor();
color.setAlpha(255);
int y = static_cast<int>(dY * static_cast<float>(i));
switch (highlight.getStyle())
{
case ScrollbarHighlight::Default: {
painter.fillRect(w / 8 * 3, y, w / 4, highlightHeight,
color);
}
break;

int y = static_cast<int>(dY * static_cast<float>(i));
switch (highlight.getStyle())
{
case ScrollbarHighlight::Default: {
painter.fillRect(w / 8 * 3, y, w / 4, highlightHeight, color);
}
break;
case ScrollbarHighlight::Line: {
painter.fillRect(0, y, w, 1, color);
}
break;

case ScrollbarHighlight::Line: {
painter.fillRect(0, y, w, 1, color);
case ScrollbarHighlight::None:;
}
break;

case ScrollbarHighlight::None:;
}
}
}
Expand All @@ -369,6 +381,11 @@ void Scrollbar::resizeEvent(QResizeEvent * /*event*/)

void Scrollbar::mouseMoveEvent(QMouseEvent *event)
{
if (!this->shouldHandleMouseEvents())
{
return;
}

if (this->mouseDownLocation_ == MouseLocation::Outside)
{
auto moveLocation = this->locationOfMouseEvent(event);
Expand All @@ -394,12 +411,22 @@ void Scrollbar::mouseMoveEvent(QMouseEvent *event)

void Scrollbar::mousePressEvent(QMouseEvent *event)
{
if (!this->shouldHandleMouseEvents())
{
return;
}

this->mouseDownLocation_ = this->locationOfMouseEvent(event);
this->update();
}

void Scrollbar::mouseReleaseEvent(QMouseEvent *event)
{
if (!this->shouldHandleMouseEvents())
{
return;
}

auto releaseLocation = this->locationOfMouseEvent(event);
if (this->mouseDownLocation_ != releaseLocation)
{
Expand Down Expand Up @@ -452,17 +479,32 @@ void Scrollbar::updateScroll()
this->update();
}

void Scrollbar::setShowThumb(bool showThumb)
void Scrollbar::setHideThumb(bool hideThumb)
{
if (this->showThumb_ == showThumb)
if (this->hideThumb == hideThumb)
{
return;
}

this->showThumb_ = showThumb;
this->hideThumb = hideThumb;
this->update();
}

bool Scrollbar::shouldShowThumb() const
{
return !(this->hideThumb || this->settingHideThumb);
}

bool Scrollbar::shouldShowHighlights() const
{
return !this->settingHideHighlights;
}

bool Scrollbar::shouldHandleMouseEvents() const
{
return this->shouldShowThumb();
}

Scrollbar::MouseLocation Scrollbar::locationOfMouseEvent(
QMouseEvent *event) const
{
Expand Down
Loading

0 comments on commit bc3794f

Please sign in to comment.