fix: correctly scale SelectChannelDialog (#6081)

This commit is contained in:
pajlada
2025-03-16 10:44:25 +01:00
committed by GitHub
parent 95eee28002
commit 57dc0144b2
6 changed files with 286 additions and 256 deletions
+45 -14
View File
@@ -3,13 +3,35 @@
#include "widgets/BaseWindow.hpp"
#include <pajlada/signals/signal.hpp>
#include <QFocusEvent>
#include <QLabel>
#include <QLineEdit>
#include <QRadioButton>
#include <optional>
namespace chatterino::detail {
/// a radio button that checks itself when it receives focus
class AutoCheckedRadioButton : public QRadioButton
{
public:
AutoCheckedRadioButton(const QString &label)
: QRadioButton(label)
{
}
protected:
void focusInEvent(QFocusEvent * /*event*/) override
{
this->setChecked(true);
}
};
} // namespace chatterino::detail
namespace chatterino {
class Notebook;
class EditableModelView;
class IndirectChannel;
class Channel;
@@ -20,15 +42,16 @@ class SelectChannelDialog final : public BaseWindow
public:
SelectChannelDialog(QWidget *parent = nullptr);
void setSelectedChannel(IndirectChannel selectedChannel_);
void setSelectedChannel(std::optional<IndirectChannel> channel_);
IndirectChannel getSelectedChannel() const;
bool hasSeletedChannel() const;
pajlada::Signals::NoArgSignal closed;
protected:
void closeEvent(QCloseEvent *) override;
void closeEvent(QCloseEvent *event) override;
void themeChangedEvent() override;
void scaleChangedEvent(float newScale) override;
private:
class EventFilter : public QObject
@@ -41,17 +64,25 @@ private:
};
struct {
Notebook *notebook;
struct {
QRadioButton *channel;
QLineEdit *channelName;
QRadioButton *whispers;
QRadioButton *mentions;
QRadioButton *watching;
QRadioButton *live;
QRadioButton *automod;
} twitch;
} ui_;
detail::AutoCheckedRadioButton *channel;
QLabel *channelLabel;
QLineEdit *channelName;
detail::AutoCheckedRadioButton *whispers;
QLabel *whispersLabel;
detail::AutoCheckedRadioButton *mentions;
QLabel *mentionsLabel;
detail::AutoCheckedRadioButton *watching;
QLabel *watchingLabel;
detail::AutoCheckedRadioButton *live;
QLabel *liveLabel;
detail::AutoCheckedRadioButton *automod;
QLabel *automodLabel;
} ui_{};
EventFilter tabFilter_;