From 0f2d6a4a227695d379d077086ed524b69f99e4f4 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Mon, 27 Aug 2018 15:36:01 +0300 Subject: [PATCH 1/2] Added hotkey for Emote menu. --- .../settingspages/KeyboardSettingsPage.cpp | 2 ++ src/widgets/splits/SplitInput.cpp | 36 +++++++++++-------- src/widgets/splits/SplitInput.hpp | 1 + 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/widgets/settingspages/KeyboardSettingsPage.cpp b/src/widgets/settingspages/KeyboardSettingsPage.cpp index fb28ae877..e66a984bf 100644 --- a/src/widgets/settingspages/KeyboardSettingsPage.cpp +++ b/src/widgets/settingspages/KeyboardSettingsPage.cpp @@ -41,6 +41,8 @@ KeyboardSettingsPage::KeyboardSettingsPage() form->addRow(new QLabel("Ctrl + R"), new QLabel("Change channel")); form->addRow(new QLabel("Ctrl + F"), new QLabel("Search in current channel")); + form->addRow(new QLabel("Ctrl + E"), + new QLabel("Open Emote menu")); } } // namespace chatterino diff --git a/src/widgets/splits/SplitInput.cpp b/src/widgets/splits/SplitInput.cpp index d35acdf48..adf19ebcc 100644 --- a/src/widgets/splits/SplitInput.cpp +++ b/src/widgets/splits/SplitInput.cpp @@ -84,21 +84,7 @@ void SplitInput::initLayout() })); // open emote popup - QObject::connect(this->ui_.emoteButton, &EffectLabel::clicked, [this] { - if (!this->emotePopup_) { - this->emotePopup_ = std::make_unique(); - this->emotePopup_->linkClicked.connect([this](const Link &link) { - if (link.type == Link::InsertText) { - this->insertText(link.value + " "); - } - }); - } - - this->emotePopup_->resize(int(300 * this->emotePopup_->getScale()), - int(500 * this->emotePopup_->getScale())); - this->emotePopup_->loadChannel(this->split_->getChannel()); - this->emotePopup_->show(); - }); + QObject::connect(this->ui_.emoteButton, &EffectLabel::clicked, [=] { this->openEmotePopup(); }); // clear channelview selection when selecting in the input QObject::connect(this->ui_.textEdit, &QTextEdit::copyAvailable, @@ -159,6 +145,23 @@ void SplitInput::updateEmoteButton() this->ui_.emoteButton->setFixedHeight(int(18 * scale)); } +void SplitInput::openEmotePopup() +{ + if (!this->emotePopup_) { + this->emotePopup_ = std::make_unique(); + this->emotePopup_->linkClicked.connect([this](const Link &link) { + if (link.type == Link::InsertText) { + this->insertText(link.value + " "); + } + }); + } + + this->emotePopup_->resize(int(300 * this->emotePopup_->getScale()), + int(500 * this->emotePopup_->getScale())); + this->emotePopup_->loadChannel(this->split_->getChannel()); + this->emotePopup_->show(); +} + void SplitInput::installKeyPressedEvent() { auto app = getApp(); @@ -284,6 +287,9 @@ void SplitInput::installKeyPressedEvent() this->split_->copyToClipboard(); event->accept(); } + } else if (event->key() == Qt::Key_E && + event->modifiers() == Qt::ControlModifier) { + openEmotePopup(); } }); } diff --git a/src/widgets/splits/SplitInput.hpp b/src/widgets/splits/SplitInput.hpp index 6ad6f4f83..b26030b6b 100644 --- a/src/widgets/splits/SplitInput.hpp +++ b/src/widgets/splits/SplitInput.hpp @@ -43,6 +43,7 @@ private: void initLayout(); void installKeyPressedEvent(); void updateEmoteButton(); + void openEmotePopup(); Split *const split_; std::shared_ptr emotePopup_; From 235f9eebf1559c476cd3c08213dc806f9bd67d28 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Wed, 29 Aug 2018 02:22:57 +0300 Subject: [PATCH 2/2] Added 'this'. --- src/widgets/splits/SplitInput.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/splits/SplitInput.cpp b/src/widgets/splits/SplitInput.cpp index adf19ebcc..8c61dcd68 100644 --- a/src/widgets/splits/SplitInput.cpp +++ b/src/widgets/splits/SplitInput.cpp @@ -289,7 +289,7 @@ void SplitInput::installKeyPressedEvent() } } else if (event->key() == Qt::Key_E && event->modifiers() == Qt::ControlModifier) { - openEmotePopup(); + this->openEmotePopup(); } }); }