refactor: buttons and friends (#6102)
This commit is contained in:
@@ -10,13 +10,15 @@
|
||||
#include "providers/twitch/TwitchChannel.hpp"
|
||||
#include "providers/twitch/TwitchCommon.hpp"
|
||||
#include "providers/twitch/TwitchIrcServer.hpp"
|
||||
#include "singletons/Fonts.hpp"
|
||||
#include "singletons/Settings.hpp"
|
||||
#include "singletons/Theme.hpp"
|
||||
#include "util/Helpers.hpp"
|
||||
#include "util/LayoutCreator.hpp"
|
||||
#include "widgets/buttons/LabelButton.hpp"
|
||||
#include "widgets/buttons/SvgButton.hpp"
|
||||
#include "widgets/dialogs/EmotePopup.hpp"
|
||||
#include "widgets/helper/ChannelView.hpp"
|
||||
#include "widgets/helper/EffectLabel.hpp"
|
||||
#include "widgets/helper/MessageView.hpp"
|
||||
#include "widgets/helper/ResizingTextEdit.hpp"
|
||||
#include "widgets/Notebook.hpp"
|
||||
@@ -112,8 +114,14 @@ void SplitInput::initLayout()
|
||||
|
||||
replyHbox->addStretch(1);
|
||||
|
||||
auto replyCancelButton =
|
||||
replyHbox.emplace<Button>().assign(&this->ui_.cancelReplyButton);
|
||||
auto replyCancelButton = replyHbox
|
||||
.emplace<SvgButton>(
|
||||
SvgButton::Src{
|
||||
.dark = ":/buttons/cancel.svg",
|
||||
.light = ":/buttons/cancelDark.svg",
|
||||
},
|
||||
nullptr, QSize{4, 0})
|
||||
.assign(&this->ui_.cancelReplyButton);
|
||||
|
||||
replyCancelButton->hide();
|
||||
replyLabel->hide();
|
||||
@@ -133,11 +141,10 @@ void SplitInput::initLayout()
|
||||
connect(textEdit.getElement(), &ResizingTextEdit::textChanged, this,
|
||||
&SplitInput::editTextChanged);
|
||||
|
||||
hboxLayout.emplace<EffectLabel>().assign(&this->ui_.sendButton);
|
||||
this->ui_.sendButton->getLabel().setText("SEND");
|
||||
hboxLayout.emplace<LabelButton>("SEND").assign(&this->ui_.sendButton);
|
||||
this->ui_.sendButton->hide();
|
||||
|
||||
QObject::connect(this->ui_.sendButton, &EffectLabel::leftClicked, [this] {
|
||||
QObject::connect(this->ui_.sendButton, &Button::leftClicked, [this] {
|
||||
std::vector<QString> arguments;
|
||||
this->handleSendMessage(arguments);
|
||||
});
|
||||
@@ -164,7 +171,13 @@ void SplitInput::initLayout()
|
||||
textEditLength->setAlignment(Qt::AlignRight);
|
||||
|
||||
box->addStretch(1);
|
||||
box.emplace<Button>().assign(&this->ui_.emoteButton);
|
||||
box.emplace<SvgButton>(
|
||||
SvgButton::Src{
|
||||
.dark = ":/buttons/emote.svg",
|
||||
.light = ":/buttons/emoteDark.svg",
|
||||
},
|
||||
nullptr, QSize{6, 3})
|
||||
.assign(&this->ui_.emoteButton);
|
||||
}
|
||||
|
||||
// ---- misc
|
||||
@@ -186,15 +199,14 @@ void SplitInput::initLayout()
|
||||
});
|
||||
|
||||
// open emote popup
|
||||
QObject::connect(this->ui_.emoteButton, &EffectLabel::leftClicked, [this] {
|
||||
QObject::connect(this->ui_.emoteButton, &Button::leftClicked, [this] {
|
||||
this->openEmotePopup();
|
||||
});
|
||||
|
||||
// remove reply target
|
||||
QObject::connect(this->ui_.cancelReplyButton, &EffectLabel::leftClicked,
|
||||
[this] {
|
||||
this->setReply(nullptr);
|
||||
});
|
||||
// clear input and remove reply thread
|
||||
QObject::connect(this->ui_.cancelReplyButton, &Button::leftClicked, [this] {
|
||||
this->setReply(nullptr);
|
||||
});
|
||||
|
||||
// Forward selection change signal
|
||||
QObject::connect(this->ui_.textEdit, &QTextEdit::copyAvailable,
|
||||
@@ -256,8 +268,6 @@ void SplitInput::themeChangedEvent()
|
||||
QPalette::PlaceholderText,
|
||||
this->theme->messages.textColors.chatPlaceholder);
|
||||
|
||||
this->updateEmoteButton();
|
||||
this->updateCancelReplyButton();
|
||||
this->ui_.textEditLength->setPalette(palette);
|
||||
|
||||
this->ui_.textEdit->setStyleSheet(this->theme->splits.input.styleSheet);
|
||||
@@ -284,15 +294,6 @@ void SplitInput::updateEmoteButton()
|
||||
{
|
||||
auto scale = this->scale();
|
||||
|
||||
if (this->theme->isLightTheme())
|
||||
{
|
||||
this->ui_.emoteButton->setSvgResource(":/buttons/emoteDark.svg");
|
||||
}
|
||||
else
|
||||
{
|
||||
this->ui_.emoteButton->setSvgResource(":/buttons/emote.svg");
|
||||
}
|
||||
|
||||
this->ui_.emoteButton->setFixedHeight(int(18 * scale));
|
||||
// Make button slightly wider so it's easier to click
|
||||
this->ui_.emoteButton->setFixedWidth(int(24 * scale));
|
||||
@@ -302,15 +303,6 @@ void SplitInput::updateCancelReplyButton()
|
||||
{
|
||||
float scale = this->scale();
|
||||
|
||||
if (this->theme->isLightTheme())
|
||||
{
|
||||
this->ui_.cancelReplyButton->setSvgResource(":/buttons/cancelDark.svg");
|
||||
}
|
||||
else
|
||||
{
|
||||
this->ui_.cancelReplyButton->setSvgResource(":/buttons/cancel.svg");
|
||||
}
|
||||
this->ui_.cancelReplyButton->setEnableMargin(false);
|
||||
this->ui_.cancelReplyButton->setFixedHeight(int(12 * scale));
|
||||
this->ui_.cancelReplyButton->setFixedWidth(int(20 * scale));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user