fix: relayout tabs when update button visibility changes (#6447)

This commit is contained in:
pajlada
2025-09-06 12:48:27 +02:00
committed by GitHub
parent 6a0ca0bff8
commit 36ebb19469
7 changed files with 39 additions and 19 deletions
+1
View File
@@ -4,6 +4,7 @@
- Bugfix: Fixed crashes that could occur when Lua functions errored with values other than strings. (#6441) - 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 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 ## 2.5.4-beta.1
@@ -15,6 +15,7 @@
#include "providers/twitch/TwitchIrcServer.hpp" #include "providers/twitch/TwitchIrcServer.hpp"
#include "singletons/Theme.hpp" #include "singletons/Theme.hpp"
#include "singletons/Toasts.hpp" #include "singletons/Toasts.hpp"
#include "singletons/Updates.hpp"
#include "singletons/WindowManager.hpp" #include "singletons/WindowManager.hpp"
#include "util/PostToThread.hpp" #include "util/PostToThread.hpp"
@@ -196,6 +197,11 @@ QString debugTest(const CommandContext &ctx)
ctx.channel->addSystemMessage( ctx.channel->addSystemMessage(
QString("debug-test sent desktop notification")); QString("debug-test sent desktop notification"));
} }
else if (command == "update-check")
{
getApp()->getUpdates().checkForUpdates();
ctx.channel->addSystemMessage(QString("checking for updates"));
}
else else
{ {
ctx.channel->addSystemMessage( ctx.channel->addSystemMessage(
+6 -1
View File
@@ -1492,7 +1492,12 @@ void SplitNotebook::addCustomButtons()
// updates // updates
auto *updateBtn = this->addCustomButton<PixmapButton>(); auto *updateBtn = this->addCustomButton<PixmapButton>();
initUpdateButton(*updateBtn, this->signalHolder_); initUpdateButton(
*updateBtn,
[this] {
this->performLayout(false);
},
this->signalHolder_);
// streamer mode // streamer mode
this->streamerModeIcon_ = this->addCustomButton<PixmapButton>(); this->streamerModeIcon_ = this->addCustomButton<PixmapButton>();
-2
View File
@@ -17,10 +17,8 @@ namespace chatterino {
class Button; class Button;
class PixmapButton; class PixmapButton;
class SvgButton;
class Window; class Window;
class DrawnButton; class DrawnButton;
class UpdateDialog;
class NotebookTab; class NotebookTab;
class SplitContainer; class SplitContainer;
class Split; class Split;
+1 -1
View File
@@ -221,7 +221,7 @@ void Window::addCustomTitlebarButtons()
// updates // updates
auto *update = this->addTitleBarButton<PixmapButton>([] {}); auto *update = this->addTitleBarButton<PixmapButton>([] {});
initUpdateButton(*update, this->signalHolder_); initUpdateButton(*update, [] {}, this->signalHolder_);
// account // account
this->userLabel_ = this->addTitleBarLabel([this] { this->userLabel_ = this->addTitleBarLabel([this] {
+19 -14
View File
@@ -7,12 +7,13 @@
namespace chatterino { namespace chatterino {
void initUpdateButton(PixmapButton &button, void initUpdateButton(PixmapButton &button,
const std::function<void()> &relayout,
pajlada::Signals::SignalHolder &signalHolder) pajlada::Signals::SignalHolder &signalHolder)
{ {
button.hide(); button.hide();
// show update prompt when clicking the button // 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 *dialog = new UpdateDialog();
auto globalPoint = button.mapToGlobal( 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 // 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 // The button is either attached to a Notebook, or a Window frame
std::ignore = dialog->buttonClicked.connect([&button](auto buttonType) { std::ignore =
switch (buttonType) dialog->buttonClicked.connect([&button, relayout](auto buttonType) {
{ switch (buttonType)
case UpdateDialog::Dismiss: { {
button.hide(); 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); // handle.reset(dialog);
// dialog->closing.connect([&handle] { handle.release(); }); // dialog->closing.connect([&handle] { handle.release(); });
}); });
// update image when state changes // update image when state changes
auto updateChange = [&button](auto) { auto updateChange = [&button, relayout](auto) {
button.setVisible(getApp()->getUpdates().shouldShowUpdateButton()); button.setVisible(getApp()->getUpdates().shouldShowUpdateButton());
const auto *imageUrl = getApp()->getUpdates().isError() const auto *imageUrl = getApp()->getUpdates().isError()
? ":/buttons/updateError.png" ? ":/buttons/updateError.png"
: ":/buttons/update.png"; : ":/buttons/update.png";
button.setPixmap(QPixmap(imageUrl)); button.setPixmap(QPixmap(imageUrl));
relayout();
}; };
updateChange(getApp()->getUpdates().getStatus()); updateChange(getApp()->getUpdates().getStatus());
+6 -1
View File
@@ -1,5 +1,7 @@
#pragma once #pragma once
#include <functional>
namespace pajlada::Signals { namespace pajlada::Signals {
class SignalHolder; class SignalHolder;
} // namespace pajlada::Signals } // namespace pajlada::Signals
@@ -7,9 +9,12 @@ class SignalHolder;
namespace chatterino { namespace chatterino {
class PixmapButton; class PixmapButton;
class UpdateDialog;
/// Initializes the update button
///
/// The `relayout` function gets called whenever the button visibility changes
void initUpdateButton(PixmapButton &button, void initUpdateButton(PixmapButton &button,
const std::function<void()> &relayout,
pajlada::Signals::SignalHolder &signalHolder); pajlada::Signals::SignalHolder &signalHolder);
} // namespace chatterino } // namespace chatterino