From 8ead95b959e53bcf23b0c2a58c0424f44c942ddb Mon Sep 17 00:00:00 2001 From: pajlada Date: Sat, 30 Oct 2021 12:54:43 +0200 Subject: [PATCH 1/4] Flatten the scrollbar highlight iteration (#3326) --- src/widgets/Scrollbar.cpp | 50 ++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/src/widgets/Scrollbar.cpp b/src/widgets/Scrollbar.cpp index c581723b67f..adbd8e4d1bd 100644 --- a/src/widgets/Scrollbar.cpp +++ b/src/widgets/Scrollbar.cpp @@ -287,36 +287,38 @@ void Scrollbar::paintEvent(QPaintEvent *) int highlightHeight = int(std::ceil(std::max(this->scale() * 2, dY))); - for (size_t i = 0; i < snapshotLength; i++) + for (size_t i = 0; i < snapshotLength; i++, y += dY) { ScrollbarHighlight const &highlight = snapshot[i]; - if (!highlight.isNull()) + if (highlight.isNull()) { - if (!highlight.isRedeemedHighlight() || enableRedeemedHighlights) - { - QColor color = highlight.getColor(); - color.setAlpha(255); - - switch (highlight.getStyle()) - { - case ScrollbarHighlight::Default: { - painter.fillRect(w / 8 * 3, int(y), w / 4, - highlightHeight, color); - } - break; - - case ScrollbarHighlight::Line: { - painter.fillRect(0, int(y), w, 1, color); - } - break; - - case ScrollbarHighlight::None:; - } - } + continue; + } + + if (highlight.isRedeemedHighlight() && !enableRedeemedHighlights) + { + continue; } - y += dY; + QColor color = highlight.getColor(); + color.setAlpha(255); + + switch (highlight.getStyle()) + { + case ScrollbarHighlight::Default: { + painter.fillRect(w / 8 * 3, int(y), w / 4, highlightHeight, + color); + } + break; + + case ScrollbarHighlight::Line: { + painter.fillRect(0, int(y), w, 1, color); + } + break; + + case ScrollbarHighlight::None:; + } } } From e24dffa9612110c2d0eb1e29dd7b84d996b7344a Mon Sep 17 00:00:00 2001 From: Ryan <59930937+1xelerate@users.noreply.github.com> Date: Sat, 30 Oct 2021 07:24:38 -0400 Subject: [PATCH 2/4] Fix 'First Message' scrollbar highlights not being disabled (#3325) Co-authored-by: Rasmus Karlsson --- CHANGELOG.md | 1 + src/messages/Message.cpp | 2 +- src/widgets/Scrollbar.cpp | 8 ++++++++ src/widgets/helper/ScrollbarHighlight.cpp | 9 ++++++++- src/widgets/helper/ScrollbarHighlight.hpp | 5 ++++- 5 files changed, 22 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d393f7b8d71..5dd3fb48095 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,7 @@ - Bugfix: Fixed `QCharRef with an index pointing outside the valid range of a QString` warning that was emitted on every Tab press. (#3234) - Bugfix: Fixed being unable to disable `First Message` highlights (#3293) - Bugfix: Fixed `First Message` custom sound not persisting through restart. (#3303) +- Bugfix: Fixed `First Message` scrollbar highlights not being disabled. (#3325) - Dev: Renamed CMake's build option `USE_SYSTEM_QT5KEYCHAIN` to `USE_SYSTEM_QTKEYCHAIN`. (#3103) - Dev: Add benchmarks that can be compiled with the `BUILD_BENCHMARKS` CMake flag. Off by default. (#3038) diff --git a/src/messages/Message.cpp b/src/messages/Message.cpp index 7f312905045..d7089512f8b 100644 --- a/src/messages/Message.cpp +++ b/src/messages/Message.cpp @@ -46,7 +46,7 @@ SBHighlight Message::getScrollBarHighlight() const { return SBHighlight( ColorProvider::instance().color(ColorType::FirstMessageHighlight), - SBHighlight::Default, true); + SBHighlight::Default, false, true); } return SBHighlight(); } diff --git a/src/widgets/Scrollbar.cpp b/src/widgets/Scrollbar.cpp index adbd8e4d1bd..69a99c66e11 100644 --- a/src/widgets/Scrollbar.cpp +++ b/src/widgets/Scrollbar.cpp @@ -251,6 +251,8 @@ void Scrollbar::paintEvent(QPaintEvent *) painter.fillRect(rect(), this->theme->scrollbars.background); bool enableRedeemedHighlights = getSettings()->enableRedeemedHighlight; + bool enableFirstMessageHighlights = + getSettings()->enableFirstMessageHighlight; // painter.fillRect(QRect(xOffset, 0, width(), this->buttonHeight), // this->themeManager->ScrollbarArrow); @@ -301,6 +303,12 @@ void Scrollbar::paintEvent(QPaintEvent *) continue; } + if (highlight.isFirstMessageHighlight() && + !enableFirstMessageHighlights) + { + continue; + } + QColor color = highlight.getColor(); color.setAlpha(255); diff --git a/src/widgets/helper/ScrollbarHighlight.cpp b/src/widgets/helper/ScrollbarHighlight.cpp index ab18354e943..f733b89d89a 100644 --- a/src/widgets/helper/ScrollbarHighlight.cpp +++ b/src/widgets/helper/ScrollbarHighlight.cpp @@ -13,10 +13,12 @@ ScrollbarHighlight::ScrollbarHighlight() } ScrollbarHighlight::ScrollbarHighlight(const std::shared_ptr color, - Style style, bool isRedeemedHighlight) + Style style, bool isRedeemedHighlight, + bool isFirstMessageHighlight) : color_(color) , style_(style) , isRedeemedHighlight_(isRedeemedHighlight) + , isFirstMessageHighlight_(isFirstMessageHighlight) { } @@ -35,6 +37,11 @@ bool ScrollbarHighlight::isRedeemedHighlight() const return this->isRedeemedHighlight_; } +bool ScrollbarHighlight::isFirstMessageHighlight() const +{ + return this->isFirstMessageHighlight_; +} + bool ScrollbarHighlight::isNull() const { return this->style_ == None; diff --git a/src/widgets/helper/ScrollbarHighlight.hpp b/src/widgets/helper/ScrollbarHighlight.hpp index 41b76b89d1c..f6b936b3506 100644 --- a/src/widgets/helper/ScrollbarHighlight.hpp +++ b/src/widgets/helper/ScrollbarHighlight.hpp @@ -21,17 +21,20 @@ class ScrollbarHighlight ScrollbarHighlight(); ScrollbarHighlight(const std::shared_ptr color, - Style style = Default, bool isRedeemedHighlight = false); + Style style = Default, bool isRedeemedHighlight = false, + bool isFirstMessageHighlight = false); QColor getColor() const; Style getStyle() const; bool isRedeemedHighlight() const; + bool isFirstMessageHighlight() const; bool isNull() const; private: std::shared_ptr color_; Style style_; bool isRedeemedHighlight_; + bool isFirstMessageHighlight_; }; } // namespace chatterino From 076152630ae1d126e567d19562900909771e14b5 Mon Sep 17 00:00:00 2001 From: pajlada Date: Sat, 30 Oct 2021 14:24:43 +0200 Subject: [PATCH 3/4] Add GitHub action to test builds with precompiled headers disabled (#3327) --- .github/workflows/build.yml | 15 ++++++++++++++- CHANGELOG.md | 1 + src/CMakeLists.txt | 3 +++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 47f16f7b995..95e5b7ef9f6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,14 +15,21 @@ jobs: os: [windows-latest, ubuntu-latest, macos-latest] qt-version: [5.15.2, 5.12.10] build-system: [qmake, cmake] + pch: [true] exclude: - os: windows-latest qt-version: 5.12.10 build-system: cmake + pch: true include: - os: windows-2016 qt-version: 5.12.10 build-system: cmake + pch: true + - os: ubuntu-latest + qt-version: 5.15.2 + build-system: cmake + pch: false fail-fast: false steps: @@ -158,7 +165,12 @@ jobs: run: | mkdir build cd build - cmake -DCMAKE_INSTALL_PREFIX=appdir/usr/ -DCMAKE_BUILD_TYPE=Release -DPAJLADA_SETTINGS_USE_BOOST_FILESYSTEM=On .. + cmake \ + -DCMAKE_INSTALL_PREFIX=appdir/usr/ \ + -DCMAKE_BUILD_TYPE=Release \ + -DPAJLADA_SETTINGS_USE_BOOST_FILESYSTEM=On \ + -DUSE_PRECOMPILED_HEADERS=${{ matrix.pch }} \ + .. make -j8 shell: bash @@ -214,6 +226,7 @@ jobs: cmake \ -DCMAKE_BUILD_TYPE=Release \ -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl \ + -DUSE_PRECOMPILED_HEADERS=${{ matrix.pch }} \ .. make -j8 shell: bash diff --git a/CHANGELOG.md b/CHANGELOG.md index 5dd3fb48095..91d1ff58760 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,7 @@ - Bugfix: Fixed being unable to disable `First Message` highlights (#3293) - Bugfix: Fixed `First Message` custom sound not persisting through restart. (#3303) - Bugfix: Fixed `First Message` scrollbar highlights not being disabled. (#3325) +- Dev: Add GitHub action to test builds without precompiled headers enabled. (#3327) - Dev: Renamed CMake's build option `USE_SYSTEM_QT5KEYCHAIN` to `USE_SYSTEM_QTKEYCHAIN`. (#3103) - Dev: Add benchmarks that can be compiled with the `BUILD_BENCHMARKS` CMake flag. Off by default. (#3038) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e78de47b843..8b62babf7dd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -556,7 +556,10 @@ if (BUILD_APP) endif () if (USE_PRECOMPILED_HEADERS) + message(STATUS "Building with precompiled headers") target_precompile_headers(${LIBRARY_PROJECT} PRIVATE PrecompiledHeader.hpp) +else () + message(STATUS "Building without precompiled headers") endif () # Enable autogeneration of Qts MOC/RCC/UIC From b4b745024c1290977d5236f78f81429a8f8eb028 Mon Sep 17 00:00:00 2001 From: Infinitay Date: Sat, 30 Oct 2021 08:49:41 -0400 Subject: [PATCH 4/4] Clean up chat messages of special line characters prior to sending (#3312) Co-authored-by: Rasmus Karlsson --- CHANGELOG.md | 1 + src/providers/twitch/TwitchChannel.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 91d1ff58760..e9f4b0e026e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ - Minor: Ignore out of bounds check for tiling wms (#3270) - Minor: Added `flags.first_message` filter variable (#3292) - Minor: Removed duplicate setting for toggling `Channel Point Redeemed Message` highlights (#3296) +- Minor: Clean up chat messages of special line characters prior to sending. (#3312) - Bugfix: Fixed colored usernames sometimes not working. (#3170) - Bugfix: Restored ability to send duplicate `/me` messages. (#3166) - Bugfix: Notifications for moderators about other moderators deleting messages can now be disabled. (#3121) diff --git a/src/providers/twitch/TwitchChannel.cpp b/src/providers/twitch/TwitchChannel.cpp index 3080a61e19b..21f65669447 100644 --- a/src/providers/twitch/TwitchChannel.cpp +++ b/src/providers/twitch/TwitchChannel.cpp @@ -363,7 +363,7 @@ void TwitchChannel::sendMessage(const QString &message) // Do last message processing QString parsedMessage = app->emotes->emojis.replaceShortCodes(message); - parsedMessage = parsedMessage.trimmed(); + parsedMessage = parsedMessage.simplified(); if (parsedMessage.isEmpty()) {