fix: relayout tabs when update button visibility changes (#6447)
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -1492,7 +1492,12 @@ void SplitNotebook::addCustomButtons()
|
||||
// updates
|
||||
auto *updateBtn = this->addCustomButton<PixmapButton>();
|
||||
|
||||
initUpdateButton(*updateBtn, this->signalHolder_);
|
||||
initUpdateButton(
|
||||
*updateBtn,
|
||||
[this] {
|
||||
this->performLayout(false);
|
||||
},
|
||||
this->signalHolder_);
|
||||
|
||||
// streamer mode
|
||||
this->streamerModeIcon_ = this->addCustomButton<PixmapButton>();
|
||||
|
||||
@@ -17,10 +17,8 @@ namespace chatterino {
|
||||
|
||||
class Button;
|
||||
class PixmapButton;
|
||||
class SvgButton;
|
||||
class Window;
|
||||
class DrawnButton;
|
||||
class UpdateDialog;
|
||||
class NotebookTab;
|
||||
class SplitContainer;
|
||||
class Split;
|
||||
|
||||
@@ -221,7 +221,7 @@ void Window::addCustomTitlebarButtons()
|
||||
// updates
|
||||
auto *update = this->addTitleBarButton<PixmapButton>([] {});
|
||||
|
||||
initUpdateButton(*update, this->signalHolder_);
|
||||
initUpdateButton(*update, [] {}, this->signalHolder_);
|
||||
|
||||
// account
|
||||
this->userLabel_ = this->addTitleBarLabel([this] {
|
||||
|
||||
@@ -7,12 +7,13 @@
|
||||
namespace chatterino {
|
||||
|
||||
void initUpdateButton(PixmapButton &button,
|
||||
const std::function<void()> &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());
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
|
||||
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<void()> &relayout,
|
||||
pajlada::Signals::SignalHolder &signalHolder);
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
Reference in New Issue
Block a user