From 36ebb19469f34b9ff9f07a751ede56dcdfb1b019 Mon Sep 17 00:00:00 2001 From: pajlada Date: Sat, 6 Sep 2025 12:48:27 +0200 Subject: [PATCH] fix: relayout tabs when update button visibility changes (#6447) --- CHANGELOG.md | 1 + .../commands/builtin/chatterino/Debugging.cpp | 6 ++++ src/widgets/Notebook.cpp | 7 +++- src/widgets/Notebook.hpp | 2 -- src/widgets/Window.cpp | 2 +- src/widgets/buttons/InitUpdateButton.cpp | 33 +++++++++++-------- src/widgets/buttons/InitUpdateButton.hpp | 7 +++- 7 files changed, 39 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4dd97a08..6ea7a22c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Bugfix: Fixed crashes that could occur when Lua functions errored with values other than strings. (#6441) - Bugfix: Fixed zero-width global BTTV emotes not showing in the `:~` completions. (#6440) +- Bugfix: Fixed an issue where the update button would be unclickable on macOS and Linux. (#6447) ## 2.5.4-beta.1 diff --git a/src/controllers/commands/builtin/chatterino/Debugging.cpp b/src/controllers/commands/builtin/chatterino/Debugging.cpp index 38d496cf..0d7cb8ce 100644 --- a/src/controllers/commands/builtin/chatterino/Debugging.cpp +++ b/src/controllers/commands/builtin/chatterino/Debugging.cpp @@ -15,6 +15,7 @@ #include "providers/twitch/TwitchIrcServer.hpp" #include "singletons/Theme.hpp" #include "singletons/Toasts.hpp" +#include "singletons/Updates.hpp" #include "singletons/WindowManager.hpp" #include "util/PostToThread.hpp" @@ -196,6 +197,11 @@ QString debugTest(const CommandContext &ctx) ctx.channel->addSystemMessage( QString("debug-test sent desktop notification")); } + else if (command == "update-check") + { + getApp()->getUpdates().checkForUpdates(); + ctx.channel->addSystemMessage(QString("checking for updates")); + } else { ctx.channel->addSystemMessage( diff --git a/src/widgets/Notebook.cpp b/src/widgets/Notebook.cpp index d0413c9b..b5a945e9 100644 --- a/src/widgets/Notebook.cpp +++ b/src/widgets/Notebook.cpp @@ -1492,7 +1492,12 @@ void SplitNotebook::addCustomButtons() // updates auto *updateBtn = this->addCustomButton(); - initUpdateButton(*updateBtn, this->signalHolder_); + initUpdateButton( + *updateBtn, + [this] { + this->performLayout(false); + }, + this->signalHolder_); // streamer mode this->streamerModeIcon_ = this->addCustomButton(); diff --git a/src/widgets/Notebook.hpp b/src/widgets/Notebook.hpp index 71786363..d94488a9 100644 --- a/src/widgets/Notebook.hpp +++ b/src/widgets/Notebook.hpp @@ -17,10 +17,8 @@ namespace chatterino { class Button; class PixmapButton; -class SvgButton; class Window; class DrawnButton; -class UpdateDialog; class NotebookTab; class SplitContainer; class Split; diff --git a/src/widgets/Window.cpp b/src/widgets/Window.cpp index 04d7c9db..82c31b3c 100644 --- a/src/widgets/Window.cpp +++ b/src/widgets/Window.cpp @@ -221,7 +221,7 @@ void Window::addCustomTitlebarButtons() // updates auto *update = this->addTitleBarButton([] {}); - initUpdateButton(*update, this->signalHolder_); + initUpdateButton(*update, [] {}, this->signalHolder_); // account this->userLabel_ = this->addTitleBarLabel([this] { diff --git a/src/widgets/buttons/InitUpdateButton.cpp b/src/widgets/buttons/InitUpdateButton.cpp index 1e7c281d..a797a707 100644 --- a/src/widgets/buttons/InitUpdateButton.cpp +++ b/src/widgets/buttons/InitUpdateButton.cpp @@ -7,12 +7,13 @@ namespace chatterino { void initUpdateButton(PixmapButton &button, + const std::function &relayout, pajlada::Signals::SignalHolder &signalHolder) { button.hide(); // show update prompt when clicking the button - QObject::connect(&button, &Button::leftClicked, [&button] { + QObject::connect(&button, &Button::leftClicked, [&button, relayout] { auto *dialog = new UpdateDialog(); auto globalPoint = button.mapToGlobal( @@ -32,32 +33,36 @@ void initUpdateButton(PixmapButton &button, // be destroyed before the button is destroyed, since it is destroyed on focus loss // // The button is either attached to a Notebook, or a Window frame - std::ignore = dialog->buttonClicked.connect([&button](auto buttonType) { - switch (buttonType) - { - case UpdateDialog::Dismiss: { - button.hide(); + std::ignore = + dialog->buttonClicked.connect([&button, relayout](auto buttonType) { + switch (buttonType) + { + case UpdateDialog::Dismiss: { + button.hide(); + relayout(); + } + break; + case UpdateDialog::Install: { + getApp()->getUpdates().installUpdates(); + } + break; } - break; - case UpdateDialog::Install: { - getApp()->getUpdates().installUpdates(); - } - break; - } - }); + }); // handle.reset(dialog); // dialog->closing.connect([&handle] { handle.release(); }); }); // update image when state changes - auto updateChange = [&button](auto) { + auto updateChange = [&button, relayout](auto) { button.setVisible(getApp()->getUpdates().shouldShowUpdateButton()); const auto *imageUrl = getApp()->getUpdates().isError() ? ":/buttons/updateError.png" : ":/buttons/update.png"; button.setPixmap(QPixmap(imageUrl)); + + relayout(); }; updateChange(getApp()->getUpdates().getStatus()); diff --git a/src/widgets/buttons/InitUpdateButton.hpp b/src/widgets/buttons/InitUpdateButton.hpp index 6b8398c6..2f7a33b3 100644 --- a/src/widgets/buttons/InitUpdateButton.hpp +++ b/src/widgets/buttons/InitUpdateButton.hpp @@ -1,5 +1,7 @@ #pragma once +#include + namespace pajlada::Signals { class SignalHolder; } // namespace pajlada::Signals @@ -7,9 +9,12 @@ class SignalHolder; namespace chatterino { class PixmapButton; -class UpdateDialog; +/// Initializes the update button +/// +/// The `relayout` function gets called whenever the button visibility changes void initUpdateButton(PixmapButton &button, + const std::function &relayout, pajlada::Signals::SignalHolder &signalHolder); } // namespace chatterino