fix: correctly scale SelectChannelDialog (#6081)
This commit is contained in:
@@ -46,6 +46,7 @@
|
|||||||
- Bugfix: Fixed a crash that would occurr if the user tried to open the search popup in an uninitialized split. (#6057)
|
- Bugfix: Fixed a crash that would occurr if the user tried to open the search popup in an uninitialized split. (#6057)
|
||||||
- Bugfix: Fixed an issue where commands would sometimes reset if Chatterino was improperly shut down. (#6011)
|
- Bugfix: Fixed an issue where commands would sometimes reset if Chatterino was improperly shut down. (#6011)
|
||||||
- Bugfix: Fixed a thick border on Windows 11. (#5836)
|
- Bugfix: Fixed a thick border on Windows 11. (#5836)
|
||||||
|
- Bugfix: Fixed an issue where the Select Channel Dialog did not correctly scale when your window scale was too high. (#6081)
|
||||||
- Bugfix: Fixed some windows not immediately closing. (#6054)
|
- Bugfix: Fixed some windows not immediately closing. (#6054)
|
||||||
- Bugfix: The emote button no longer looks crunchy. (#6080)
|
- Bugfix: The emote button no longer looks crunchy. (#6080)
|
||||||
- Dev: Subscriptions to PubSub channel points redemption topics now use no auth token, making it continue to work during PubSub shutdown. (#5947)
|
- Dev: Subscriptions to PubSub channel points redemption topics now use no auth token, making it continue to work during PubSub shutdown. (#5947)
|
||||||
|
|||||||
@@ -440,16 +440,14 @@ pajlada::Signals::NoArgSignal &IndirectChannel::getChannelChanged()
|
|||||||
return this->data_->changed;
|
return this->data_->changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
Channel::Type IndirectChannel::getType()
|
Channel::Type IndirectChannel::getType() const
|
||||||
{
|
{
|
||||||
if (this->data_->type == Channel::Type::Direct)
|
if (this->data_->type == Channel::Type::Direct)
|
||||||
{
|
{
|
||||||
return this->get()->getType();
|
return this->get()->getType();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
return this->data_->type;
|
||||||
return this->data_->type;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ public:
|
|||||||
ChannelPtr get() const;
|
ChannelPtr get() const;
|
||||||
void reset(ChannelPtr channel);
|
void reset(ChannelPtr channel);
|
||||||
pajlada::Signals::NoArgSignal &getChannelChanged();
|
pajlada::Signals::NoArgSignal &getChannelChanged();
|
||||||
Channel::Type getType();
|
Channel::Type getType() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<Data> data_;
|
std::shared_ptr<Data> data_;
|
||||||
|
|||||||
@@ -1,20 +1,17 @@
|
|||||||
#include "widgets/dialogs/SelectChannelDialog.hpp"
|
#include "widgets/dialogs/SelectChannelDialog.hpp"
|
||||||
|
|
||||||
#include "Application.hpp"
|
#include "Application.hpp"
|
||||||
#include "common/QLogging.hpp"
|
|
||||||
#include "controllers/hotkeys/HotkeyController.hpp"
|
#include "controllers/hotkeys/HotkeyController.hpp"
|
||||||
#include "providers/twitch/TwitchIrcServer.hpp"
|
#include "providers/twitch/TwitchIrcServer.hpp"
|
||||||
#include "singletons/Settings.hpp"
|
#include "singletons/Fonts.hpp"
|
||||||
#include "singletons/Theme.hpp"
|
#include "singletons/Theme.hpp"
|
||||||
#include "util/LayoutCreator.hpp"
|
|
||||||
#include "widgets/helper/EditableModelView.hpp"
|
|
||||||
#include "widgets/helper/NotebookTab.hpp"
|
|
||||||
#include "widgets/Notebook.hpp"
|
|
||||||
|
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
|
#include <QEvent>
|
||||||
#include <QFormLayout>
|
#include <QFormLayout>
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
|
#include <QKeyEvent>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
@@ -23,8 +20,6 @@
|
|||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
constexpr int TAB_TWITCH = 0;
|
|
||||||
|
|
||||||
SelectChannelDialog::SelectChannelDialog(QWidget *parent)
|
SelectChannelDialog::SelectChannelDialog(QWidget *parent)
|
||||||
: BaseWindow(
|
: BaseWindow(
|
||||||
{
|
{
|
||||||
@@ -36,159 +31,141 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent)
|
|||||||
parent)
|
parent)
|
||||||
, selectedChannel_(Channel::getEmpty())
|
, selectedChannel_(Channel::getEmpty())
|
||||||
{
|
{
|
||||||
|
using AutoCheckedRadioButton = detail::AutoCheckedRadioButton;
|
||||||
|
|
||||||
this->setWindowTitle("Select a channel to join");
|
this->setWindowTitle("Select a channel to join");
|
||||||
|
|
||||||
this->tabFilter_.dialog = this;
|
this->tabFilter_.dialog = this;
|
||||||
|
|
||||||
LayoutCreator<QWidget> layoutWidget(this->getLayoutContainer());
|
auto *layout = new QVBoxLayout(this->getLayoutContainer());
|
||||||
auto layout = layoutWidget.setLayoutType<QVBoxLayout>().withoutMargin();
|
|
||||||
auto notebook = layout.emplace<Notebook>(this).assign(&this->ui_.notebook);
|
|
||||||
|
|
||||||
// twitch
|
auto &ui = this->ui_;
|
||||||
{
|
// Channel
|
||||||
LayoutCreator<QWidget> obj(new QWidget());
|
ui.channel = new AutoCheckedRadioButton("Channel");
|
||||||
auto vbox = obj.setLayoutType<QVBoxLayout>();
|
layout->addWidget(ui.channel);
|
||||||
|
|
||||||
// channel_btn
|
ui.channelLabel = new QLabel("Join a Twitch channel by its channel name");
|
||||||
auto channel_btn = vbox.emplace<QRadioButton>("Channel").assign(
|
ui.channelLabel->setVisible(false);
|
||||||
&this->ui_.twitch.channel);
|
layout->addWidget(ui.channelLabel);
|
||||||
auto channel_lbl =
|
|
||||||
vbox.emplace<QLabel>("Join a Twitch channel by its name.").hidden();
|
|
||||||
channel_lbl->setWordWrap(true);
|
|
||||||
auto channel_edit = vbox.emplace<QLineEdit>().hidden().assign(
|
|
||||||
&this->ui_.twitch.channelName);
|
|
||||||
|
|
||||||
QObject::connect(channel_btn.getElement(), &QRadioButton::toggled,
|
ui.channelName = new QLineEdit();
|
||||||
[=](bool enabled) mutable {
|
ui.channelName->setVisible(false);
|
||||||
if (enabled)
|
layout->addWidget(ui.channelName);
|
||||||
{
|
|
||||||
channel_edit->setFocus();
|
|
||||||
channel_edit->setSelection(
|
|
||||||
0, channel_edit->text().length());
|
|
||||||
}
|
|
||||||
|
|
||||||
channel_edit->setVisible(enabled);
|
QObject::connect(ui.channel, &AutoCheckedRadioButton::toggled, this,
|
||||||
channel_lbl->setVisible(enabled);
|
[this](bool enabled) {
|
||||||
});
|
auto &ui = this->ui_;
|
||||||
|
if (enabled)
|
||||||
|
{
|
||||||
|
ui.channelName->setFocus();
|
||||||
|
ui.channelName->selectAll();
|
||||||
|
}
|
||||||
|
|
||||||
channel_btn->installEventFilter(&this->tabFilter_);
|
ui.channelName->setVisible(enabled);
|
||||||
channel_edit->installEventFilter(&this->tabFilter_);
|
ui.channelLabel->setVisible(enabled);
|
||||||
|
});
|
||||||
|
|
||||||
// whispers_btn
|
ui.channel->installEventFilter(&this->tabFilter_);
|
||||||
auto whispers_btn = vbox.emplace<QRadioButton>("Whispers")
|
ui.channelName->installEventFilter(&this->tabFilter_);
|
||||||
.assign(&this->ui_.twitch.whispers);
|
|
||||||
auto whispers_lbl =
|
|
||||||
vbox.emplace<QLabel>("Shows the whispers that you receive while "
|
|
||||||
"Chatterino is running.")
|
|
||||||
.hidden();
|
|
||||||
|
|
||||||
whispers_lbl->setWordWrap(true);
|
// Whispers
|
||||||
whispers_btn->installEventFilter(&this->tabFilter_);
|
ui.whispers = new AutoCheckedRadioButton("Whispers");
|
||||||
|
layout->addWidget(ui.whispers);
|
||||||
|
|
||||||
QObject::connect(whispers_btn.getElement(), &QRadioButton::toggled,
|
ui.whispersLabel = new QLabel(
|
||||||
[=](bool enabled) mutable {
|
"Shows the whispers that you receive while Chatterino is running");
|
||||||
whispers_lbl->setVisible(enabled);
|
ui.whispersLabel->setVisible(false);
|
||||||
});
|
ui.whispersLabel->setWordWrap(true);
|
||||||
|
layout->addWidget(ui.whispersLabel);
|
||||||
|
|
||||||
// mentions_btn
|
QObject::connect(ui.whispers, &AutoCheckedRadioButton::toggled, this,
|
||||||
auto mentions_btn = vbox.emplace<QRadioButton>("Mentions")
|
[this](bool enabled) {
|
||||||
.assign(&this->ui_.twitch.mentions);
|
auto &ui = this->ui_;
|
||||||
auto mentions_lbl =
|
ui.whispersLabel->setVisible(enabled);
|
||||||
vbox.emplace<QLabel>("Shows all the messages that highlight you "
|
});
|
||||||
"from any channel.")
|
|
||||||
.hidden();
|
|
||||||
|
|
||||||
mentions_lbl->setWordWrap(true);
|
ui.whispers->installEventFilter(&this->tabFilter_);
|
||||||
mentions_btn->installEventFilter(&this->tabFilter_);
|
|
||||||
|
|
||||||
QObject::connect(mentions_btn.getElement(), &QRadioButton::toggled,
|
// Mentions
|
||||||
[=](bool enabled) mutable {
|
ui.mentions = new AutoCheckedRadioButton("Mentions");
|
||||||
mentions_lbl->setVisible(enabled);
|
layout->addWidget(ui.mentions);
|
||||||
});
|
|
||||||
|
|
||||||
// watching_btn
|
ui.mentionsLabel = new QLabel(
|
||||||
auto watching_btn = vbox.emplace<QRadioButton>("Watching")
|
"Shows all the messages that highlight you from any channel");
|
||||||
.assign(&this->ui_.twitch.watching);
|
ui.mentionsLabel->setVisible(false);
|
||||||
auto watching_lbl =
|
ui.mentionsLabel->setWordWrap(true);
|
||||||
vbox.emplace<QLabel>("Requires the Chatterino browser extension.")
|
layout->addWidget(ui.mentionsLabel);
|
||||||
.hidden();
|
|
||||||
|
|
||||||
watching_lbl->setWordWrap(true);
|
QObject::connect(ui.mentions, &AutoCheckedRadioButton::toggled, this,
|
||||||
watching_btn->installEventFilter(&this->tabFilter_);
|
[this](bool enabled) {
|
||||||
|
auto &ui = this->ui_;
|
||||||
|
ui.mentionsLabel->setVisible(enabled);
|
||||||
|
});
|
||||||
|
|
||||||
QObject::connect(watching_btn.getElement(), &QRadioButton::toggled,
|
ui.mentions->installEventFilter(&this->tabFilter_);
|
||||||
[=](bool enabled) mutable {
|
|
||||||
watching_lbl->setVisible(enabled);
|
|
||||||
});
|
|
||||||
|
|
||||||
// live_btn
|
// Watching
|
||||||
auto live_btn =
|
ui.watching = new AutoCheckedRadioButton("Watching");
|
||||||
vbox.emplace<QRadioButton>("Live").assign(&this->ui_.twitch.live);
|
layout->addWidget(ui.watching);
|
||||||
auto live_lbl =
|
|
||||||
vbox.emplace<QLabel>("Shows when channels go live.").hidden();
|
|
||||||
|
|
||||||
live_lbl->setWordWrap(true);
|
ui.watchingLabel = new QLabel("Requires the Chatterino browser extension");
|
||||||
live_btn->installEventFilter(&this->tabFilter_);
|
ui.watchingLabel->setVisible(false);
|
||||||
|
layout->addWidget(ui.watchingLabel);
|
||||||
|
|
||||||
QObject::connect(live_btn.getElement(), &QRadioButton::toggled,
|
QObject::connect(ui.watching, &AutoCheckedRadioButton::toggled, this,
|
||||||
[=](bool enabled) mutable {
|
[this](bool enabled) {
|
||||||
live_lbl->setVisible(enabled);
|
auto &ui = this->ui_;
|
||||||
});
|
ui.watchingLabel->setVisible(enabled);
|
||||||
|
});
|
||||||
|
|
||||||
// automod_btn
|
ui.watching->installEventFilter(&this->tabFilter_);
|
||||||
auto automod_btn = vbox.emplace<QRadioButton>("AutoMod").assign(
|
|
||||||
&this->ui_.twitch.automod);
|
|
||||||
auto automod_lbl =
|
|
||||||
vbox.emplace<QLabel>("Shows when AutoMod catches a message in any "
|
|
||||||
"channel you moderate.")
|
|
||||||
.hidden();
|
|
||||||
|
|
||||||
automod_lbl->setWordWrap(true);
|
// Live
|
||||||
automod_btn->installEventFilter(&this->tabFilter_);
|
ui.live = new AutoCheckedRadioButton("Live");
|
||||||
|
layout->addWidget(ui.live);
|
||||||
|
|
||||||
QObject::connect(automod_btn.getElement(), &QRadioButton::toggled,
|
ui.liveLabel = new QLabel("Shows when channels go live");
|
||||||
[=](bool enabled) mutable {
|
ui.liveLabel->setVisible(false);
|
||||||
automod_lbl->setVisible(enabled);
|
layout->addWidget(ui.liveLabel);
|
||||||
});
|
|
||||||
|
|
||||||
vbox->addStretch(1);
|
QObject::connect(ui.live, &AutoCheckedRadioButton::toggled, this,
|
||||||
|
[this](bool enabled) {
|
||||||
|
auto &ui = this->ui_;
|
||||||
|
ui.liveLabel->setVisible(enabled);
|
||||||
|
});
|
||||||
|
|
||||||
// tabbing order
|
ui.live->installEventFilter(&this->tabFilter_);
|
||||||
QWidget::setTabOrder(automod_btn.getElement(),
|
|
||||||
channel_btn.getElement());
|
|
||||||
QWidget::setTabOrder(channel_btn.getElement(),
|
|
||||||
whispers_btn.getElement());
|
|
||||||
QWidget::setTabOrder(whispers_btn.getElement(),
|
|
||||||
mentions_btn.getElement());
|
|
||||||
QWidget::setTabOrder(mentions_btn.getElement(),
|
|
||||||
watching_btn.getElement());
|
|
||||||
QWidget::setTabOrder(watching_btn.getElement(), live_btn.getElement());
|
|
||||||
QWidget::setTabOrder(live_btn.getElement(), automod_btn.getElement());
|
|
||||||
|
|
||||||
// tab
|
// Automod
|
||||||
auto *tab = notebook->addPage(obj.getElement());
|
ui.automod = new AutoCheckedRadioButton("AutoMod");
|
||||||
tab->setCustomTitle("Twitch");
|
layout->addWidget(ui.automod);
|
||||||
}
|
|
||||||
|
|
||||||
layout->setStretchFactor(notebook.getElement(), 1);
|
ui.automodLabel = new QLabel("Shows when AutoMod catches a message in "
|
||||||
|
"any channel you moderate.");
|
||||||
|
ui.automodLabel->setVisible(false);
|
||||||
|
ui.automodLabel->setWordWrap(true);
|
||||||
|
layout->addWidget(ui.automodLabel);
|
||||||
|
|
||||||
auto buttons =
|
QObject::connect(ui.automod, &AutoCheckedRadioButton::toggled, this,
|
||||||
layout.emplace<QHBoxLayout>().emplace<QDialogButtonBox>(this);
|
[this](bool enabled) {
|
||||||
{
|
auto &ui = this->ui_;
|
||||||
auto *button_ok = buttons->addButton(QDialogButtonBox::Ok);
|
ui.automodLabel->setVisible(enabled);
|
||||||
QObject::connect(button_ok, &QPushButton::clicked, [this](bool) {
|
});
|
||||||
this->ok();
|
|
||||||
});
|
|
||||||
auto *button_cancel = buttons->addButton(QDialogButtonBox::Cancel);
|
|
||||||
QObject::connect(button_cancel, &QAbstractButton::clicked,
|
|
||||||
[this](bool) {
|
|
||||||
this->close();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
this->setMinimumSize(300, 310);
|
ui.automod->installEventFilter(&this->tabFilter_);
|
||||||
this->ui_.notebook->selectIndex(TAB_TWITCH);
|
|
||||||
this->ui_.twitch.channel->setFocus();
|
layout->addStretch(1);
|
||||||
|
|
||||||
|
auto *buttonBox =
|
||||||
|
new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||||
|
layout->addWidget(buttonBox);
|
||||||
|
|
||||||
|
QObject::connect(buttonBox, &QDialogButtonBox::accepted, this, [this] {
|
||||||
|
this->ok();
|
||||||
|
});
|
||||||
|
QObject::connect(buttonBox, &QDialogButtonBox::rejected, [this] {
|
||||||
|
this->close();
|
||||||
|
});
|
||||||
|
|
||||||
this->addShortcuts();
|
this->addShortcuts();
|
||||||
|
|
||||||
@@ -202,50 +179,53 @@ void SelectChannelDialog::ok()
|
|||||||
this->close();
|
this->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SelectChannelDialog::setSelectedChannel(IndirectChannel _channel)
|
void SelectChannelDialog::setSelectedChannel(
|
||||||
|
std::optional<IndirectChannel> channel_)
|
||||||
{
|
{
|
||||||
auto channel = _channel.get();
|
if (!channel_.has_value())
|
||||||
|
{
|
||||||
|
this->ui_.channel->setChecked(true);
|
||||||
|
|
||||||
|
this->hasSelectedChannel_ = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto &indirectChannel = channel_.value();
|
||||||
|
const auto &channel = indirectChannel.get();
|
||||||
|
|
||||||
assert(channel);
|
assert(channel);
|
||||||
|
|
||||||
this->selectedChannel_ = channel;
|
this->selectedChannel_ = channel;
|
||||||
|
|
||||||
switch (_channel.getType())
|
switch (indirectChannel.getType())
|
||||||
{
|
{
|
||||||
case Channel::Type::Twitch: {
|
case Channel::Type::Twitch: {
|
||||||
this->ui_.notebook->selectIndex(TAB_TWITCH);
|
this->ui_.channelName->setText(channel->getName());
|
||||||
this->ui_.twitch.channel->setFocus();
|
this->ui_.channel->setChecked(true);
|
||||||
this->ui_.twitch.channelName->setText(channel->getName());
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Channel::Type::TwitchWatching: {
|
case Channel::Type::TwitchWatching: {
|
||||||
this->ui_.notebook->selectIndex(TAB_TWITCH);
|
this->ui_.watching->setFocus();
|
||||||
this->ui_.twitch.watching->setFocus();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Channel::Type::TwitchMentions: {
|
case Channel::Type::TwitchMentions: {
|
||||||
this->ui_.notebook->selectIndex(TAB_TWITCH);
|
this->ui_.mentions->setFocus();
|
||||||
this->ui_.twitch.mentions->setFocus();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Channel::Type::TwitchWhispers: {
|
case Channel::Type::TwitchWhispers: {
|
||||||
this->ui_.notebook->selectIndex(TAB_TWITCH);
|
this->ui_.whispers->setFocus();
|
||||||
this->ui_.twitch.whispers->setFocus();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Channel::Type::TwitchLive: {
|
case Channel::Type::TwitchLive: {
|
||||||
this->ui_.notebook->selectIndex(TAB_TWITCH);
|
this->ui_.live->setFocus();
|
||||||
this->ui_.twitch.live->setFocus();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Channel::Type::TwitchAutomod: {
|
case Channel::Type::TwitchAutomod: {
|
||||||
this->ui_.notebook->selectIndex(TAB_TWITCH);
|
this->ui_.automod->setFocus();
|
||||||
this->ui_.twitch.automod->setFocus();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default: {
|
default: {
|
||||||
this->ui_.notebook->selectIndex(TAB_TWITCH);
|
this->ui_.channel->setChecked(true);
|
||||||
this->ui_.twitch.channel->setFocus();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,36 +239,35 @@ IndirectChannel SelectChannelDialog::getSelectedChannel() const
|
|||||||
return this->selectedChannel_;
|
return this->selectedChannel_;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (this->ui_.notebook->getSelectedIndex())
|
if (this->ui_.channel->isChecked())
|
||||||
{
|
{
|
||||||
case TAB_TWITCH: {
|
return getApp()->getTwitch()->getOrAddChannel(
|
||||||
if (this->ui_.twitch.channel->isChecked())
|
this->ui_.channelName->text().trimmed());
|
||||||
{
|
}
|
||||||
return getApp()->getTwitch()->getOrAddChannel(
|
|
||||||
this->ui_.twitch.channelName->text().trimmed());
|
if (this->ui_.watching->isChecked())
|
||||||
}
|
{
|
||||||
else if (this->ui_.twitch.watching->isChecked())
|
return getApp()->getTwitch()->getWatchingChannel();
|
||||||
{
|
}
|
||||||
return getApp()->getTwitch()->getWatchingChannel();
|
|
||||||
}
|
if (this->ui_.mentions->isChecked())
|
||||||
else if (this->ui_.twitch.mentions->isChecked())
|
{
|
||||||
{
|
return getApp()->getTwitch()->getMentionsChannel();
|
||||||
return getApp()->getTwitch()->getMentionsChannel();
|
}
|
||||||
}
|
|
||||||
else if (this->ui_.twitch.whispers->isChecked())
|
if (this->ui_.whispers->isChecked())
|
||||||
{
|
{
|
||||||
return getApp()->getTwitch()->getWhispersChannel();
|
return getApp()->getTwitch()->getWhispersChannel();
|
||||||
}
|
}
|
||||||
else if (this->ui_.twitch.live->isChecked())
|
|
||||||
{
|
if (this->ui_.live->isChecked())
|
||||||
return getApp()->getTwitch()->getLiveChannel();
|
{
|
||||||
}
|
return getApp()->getTwitch()->getLiveChannel();
|
||||||
else if (this->ui_.twitch.automod->isChecked())
|
}
|
||||||
{
|
|
||||||
return getApp()->getTwitch()->getAutomodChannel();
|
if (this->ui_.automod->isChecked())
|
||||||
}
|
{
|
||||||
}
|
return getApp()->getTwitch()->getAutomodChannel();
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return this->selectedChannel_;
|
return this->selectedChannel_;
|
||||||
@@ -302,90 +281,92 @@ bool SelectChannelDialog::hasSeletedChannel() const
|
|||||||
bool SelectChannelDialog::EventFilter::eventFilter(QObject *watched,
|
bool SelectChannelDialog::EventFilter::eventFilter(QObject *watched,
|
||||||
QEvent *event)
|
QEvent *event)
|
||||||
{
|
{
|
||||||
auto *widget = static_cast<QWidget *>(watched);
|
auto *widget = dynamic_cast<QWidget *>(watched);
|
||||||
|
assert(widget);
|
||||||
|
|
||||||
if (event->type() == QEvent::FocusIn)
|
auto &ui = this->dialog->ui_;
|
||||||
|
|
||||||
|
if (event->type() == QEvent::KeyPress)
|
||||||
{
|
{
|
||||||
auto *radio = dynamic_cast<QRadioButton *>(watched);
|
auto *keyEvent = dynamic_cast<QKeyEvent *>(event);
|
||||||
if (radio)
|
assert(keyEvent);
|
||||||
{
|
|
||||||
radio->setChecked(true);
|
if ((keyEvent->key() == Qt::Key_Tab ||
|
||||||
return true;
|
keyEvent->key() == Qt::Key_Down) &&
|
||||||
}
|
keyEvent->modifiers() == Qt::NoModifier)
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (event->type() == QEvent::KeyPress)
|
|
||||||
{
|
|
||||||
QKeyEvent *event_key = static_cast<QKeyEvent *>(event);
|
|
||||||
if ((event_key->key() == Qt::Key_Tab ||
|
|
||||||
event_key->key() == Qt::Key_Down) &&
|
|
||||||
event_key->modifiers() == Qt::NoModifier)
|
|
||||||
{
|
{
|
||||||
// Tab has been pressed, focus next entry in list
|
// Tab has been pressed, focus next entry in list
|
||||||
|
|
||||||
if (widget == this->dialog->ui_.twitch.channelName)
|
if (widget == ui.channelName)
|
||||||
{
|
{
|
||||||
// Special case for when current selection is the "Channel" entry's edit box since the Edit box actually has the focus
|
// Special case for when current selection is the "Channel" entry's edit box since the Edit box actually has the focus
|
||||||
this->dialog->ui_.twitch.whispers->setFocus();
|
ui.whispers->setFocus();
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (widget == this->dialog->ui_.twitch.automod)
|
|
||||||
{
|
|
||||||
// Special case for when current selection is "AutoMod" (the last entry in the list), next wrap is Channel, but we need to select its edit box
|
|
||||||
this->dialog->ui_.twitch.channel->setFocus();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
widget->nextInFocusChain()->setFocus();
|
if (widget == ui.automod)
|
||||||
|
{
|
||||||
|
// Special case for when current selection is "AutoMod" (the last entry in the list), next wrap is Channel, but we need to select its edit box
|
||||||
|
ui.channel->setFocus();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto *nextInFocusChain = widget->nextInFocusChain();
|
||||||
|
if (nextInFocusChain->focusPolicy() == Qt::FocusPolicy::NoFocus)
|
||||||
|
{
|
||||||
|
// Make sure we're not selecting one of the labels
|
||||||
|
nextInFocusChain = nextInFocusChain->nextInFocusChain();
|
||||||
|
}
|
||||||
|
nextInFocusChain->setFocus();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (((event_key->key() == Qt::Key_Tab ||
|
|
||||||
event_key->key() == Qt::Key_Backtab) &&
|
if (((keyEvent->key() == Qt::Key_Tab ||
|
||||||
event_key->modifiers() == Qt::ShiftModifier) ||
|
keyEvent->key() == Qt::Key_Backtab) &&
|
||||||
((event_key->key() == Qt::Key_Up) &&
|
keyEvent->modifiers() == Qt::ShiftModifier) ||
|
||||||
event_key->modifiers() == Qt::NoModifier))
|
((keyEvent->key() == Qt::Key_Up) &&
|
||||||
|
keyEvent->modifiers() == Qt::NoModifier))
|
||||||
{
|
{
|
||||||
// Shift+Tab has been pressed, focus previous entry in list
|
// Shift+Tab has been pressed, focus previous entry in list
|
||||||
|
|
||||||
if (widget == this->dialog->ui_.twitch.channelName)
|
if (widget == ui.channelName)
|
||||||
{
|
{
|
||||||
// Special case for when current selection is the "Channel" entry's edit box since the Edit box actually has the focus
|
// Special case for when current selection is the "Channel" entry's edit box since the Edit box actually has the focus
|
||||||
this->dialog->ui_.twitch.automod->setFocus();
|
ui.automod->setFocus();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
widget->previousInFocusChain()->setFocus();
|
if (widget == ui.whispers)
|
||||||
|
{
|
||||||
|
ui.channel->setFocus();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto *previousInFocusChain = widget->previousInFocusChain();
|
||||||
|
if (previousInFocusChain->focusPolicy() == Qt::FocusPolicy::NoFocus)
|
||||||
|
{
|
||||||
|
// Make sure we're not selecting one of the labels
|
||||||
|
previousInFocusChain =
|
||||||
|
previousInFocusChain->previousInFocusChain();
|
||||||
|
}
|
||||||
|
previousInFocusChain->setFocus();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (event_key == QKeySequence::DeleteStartOfWord &&
|
|
||||||
this->dialog->ui_.twitch.channelName->selectionLength() > 0)
|
if (keyEvent == QKeySequence::DeleteStartOfWord &&
|
||||||
{
|
ui.channelName->selectionLength() > 0)
|
||||||
this->dialog->ui_.twitch.channelName->backspace();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (event->type() == QEvent::KeyRelease)
|
|
||||||
{
|
|
||||||
QKeyEvent *event_key = static_cast<QKeyEvent *>(event);
|
|
||||||
if ((event_key->key() == Qt::Key_Backtab ||
|
|
||||||
event_key->key() == Qt::Key_Down) &&
|
|
||||||
event_key->modifiers() == Qt::NoModifier)
|
|
||||||
{
|
{
|
||||||
|
ui.channelName->backspace();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SelectChannelDialog::closeEvent(QCloseEvent *)
|
void SelectChannelDialog::closeEvent(QCloseEvent * /*event*/)
|
||||||
{
|
{
|
||||||
this->closed.invoke();
|
this->closed.invoke();
|
||||||
}
|
}
|
||||||
@@ -394,23 +375,38 @@ void SelectChannelDialog::themeChangedEvent()
|
|||||||
{
|
{
|
||||||
BaseWindow::themeChangedEvent();
|
BaseWindow::themeChangedEvent();
|
||||||
|
|
||||||
|
auto &ui = this->ui_;
|
||||||
|
|
||||||
// NOTE: This currently overrides the QLineEdit's font size.
|
// NOTE: This currently overrides the QLineEdit's font size.
|
||||||
// If the dialog is open when the theme is changed, things will look a bit off.
|
// If the dialog is open when the theme is changed, things will look a bit off.
|
||||||
// This can be alleviated by us using a single application-wide style sheet for these things.
|
// This can be alleviated by us using a single application-wide style sheet for these things.
|
||||||
this->ui_.twitch.channelName->setStyleSheet(
|
ui.channelName->setStyleSheet(this->theme->splits.input.styleSheet);
|
||||||
this->theme->splits.input.styleSheet);
|
}
|
||||||
|
|
||||||
|
void SelectChannelDialog::scaleChangedEvent(float newScale)
|
||||||
|
{
|
||||||
|
BaseWindow::scaleChangedEvent(newScale);
|
||||||
|
|
||||||
|
auto &ui = this->ui_;
|
||||||
|
|
||||||
|
// NOTE: Normally the font is automatically inherited from its parent, but since we override
|
||||||
|
// the style sheet to respect light/dark theme, we have to manually update the font here
|
||||||
|
auto uiFont =
|
||||||
|
getApp()->getFonts()->getFont(FontStyle::UiMedium, this->scale());
|
||||||
|
|
||||||
|
ui.channelName->setFont(uiFont);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SelectChannelDialog::addShortcuts()
|
void SelectChannelDialog::addShortcuts()
|
||||||
{
|
{
|
||||||
HotkeyController::HotkeyMap actions{
|
HotkeyController::HotkeyMap actions{
|
||||||
{"accept",
|
{"accept",
|
||||||
[this](std::vector<QString>) -> QString {
|
[this](const std::vector<QString> &) -> QString {
|
||||||
this->ok();
|
this->ok();
|
||||||
return "";
|
return "";
|
||||||
}},
|
}},
|
||||||
{"reject",
|
{"reject",
|
||||||
[this](std::vector<QString>) -> QString {
|
[this](const std::vector<QString> &) -> QString {
|
||||||
this->close();
|
this->close();
|
||||||
return "";
|
return "";
|
||||||
}},
|
}},
|
||||||
|
|||||||
@@ -3,13 +3,35 @@
|
|||||||
#include "widgets/BaseWindow.hpp"
|
#include "widgets/BaseWindow.hpp"
|
||||||
|
|
||||||
#include <pajlada/signals/signal.hpp>
|
#include <pajlada/signals/signal.hpp>
|
||||||
|
#include <QFocusEvent>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QRadioButton>
|
#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 {
|
namespace chatterino {
|
||||||
|
|
||||||
class Notebook;
|
|
||||||
class EditableModelView;
|
class EditableModelView;
|
||||||
class IndirectChannel;
|
class IndirectChannel;
|
||||||
class Channel;
|
class Channel;
|
||||||
@@ -20,15 +42,16 @@ class SelectChannelDialog final : public BaseWindow
|
|||||||
public:
|
public:
|
||||||
SelectChannelDialog(QWidget *parent = nullptr);
|
SelectChannelDialog(QWidget *parent = nullptr);
|
||||||
|
|
||||||
void setSelectedChannel(IndirectChannel selectedChannel_);
|
void setSelectedChannel(std::optional<IndirectChannel> channel_);
|
||||||
IndirectChannel getSelectedChannel() const;
|
IndirectChannel getSelectedChannel() const;
|
||||||
bool hasSeletedChannel() const;
|
bool hasSeletedChannel() const;
|
||||||
|
|
||||||
pajlada::Signals::NoArgSignal closed;
|
pajlada::Signals::NoArgSignal closed;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void closeEvent(QCloseEvent *) override;
|
void closeEvent(QCloseEvent *event) override;
|
||||||
void themeChangedEvent() override;
|
void themeChangedEvent() override;
|
||||||
|
void scaleChangedEvent(float newScale) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class EventFilter : public QObject
|
class EventFilter : public QObject
|
||||||
@@ -41,17 +64,25 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
Notebook *notebook;
|
detail::AutoCheckedRadioButton *channel;
|
||||||
struct {
|
QLabel *channelLabel;
|
||||||
QRadioButton *channel;
|
QLineEdit *channelName;
|
||||||
QLineEdit *channelName;
|
|
||||||
QRadioButton *whispers;
|
detail::AutoCheckedRadioButton *whispers;
|
||||||
QRadioButton *mentions;
|
QLabel *whispersLabel;
|
||||||
QRadioButton *watching;
|
|
||||||
QRadioButton *live;
|
detail::AutoCheckedRadioButton *mentions;
|
||||||
QRadioButton *automod;
|
QLabel *mentionsLabel;
|
||||||
} twitch;
|
|
||||||
} ui_;
|
detail::AutoCheckedRadioButton *watching;
|
||||||
|
QLabel *watchingLabel;
|
||||||
|
|
||||||
|
detail::AutoCheckedRadioButton *live;
|
||||||
|
QLabel *liveLabel;
|
||||||
|
|
||||||
|
detail::AutoCheckedRadioButton *automod;
|
||||||
|
QLabel *automodLabel;
|
||||||
|
} ui_{};
|
||||||
|
|
||||||
EventFilter tabFilter_;
|
EventFilter tabFilter_;
|
||||||
|
|
||||||
|
|||||||
@@ -1029,6 +1029,10 @@ void Split::showChangeChannelPopup(const char *dialogTitle, bool empty,
|
|||||||
{
|
{
|
||||||
dialog->setSelectedChannel(this->getIndirectChannel());
|
dialog->setSelectedChannel(this->getIndirectChannel());
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dialog->setSelectedChannel({});
|
||||||
|
}
|
||||||
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
dialog->setWindowTitle(dialogTitle);
|
dialog->setWindowTitle(dialogTitle);
|
||||||
dialog->show();
|
dialog->show();
|
||||||
|
|||||||
Reference in New Issue
Block a user