Merge pull request #684 from 23rd/patch-7-hotkey-emote-menu

Added hotkey for Emote menu.
This commit is contained in:
pajlada 2018-08-29 01:34:56 +02:00 committed by GitHub
commit 875e12f728
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 15 deletions

View file

@ -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

View file

@ -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<EmotePopup>();
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<EmotePopup>();
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) {
this->openEmotePopup();
}
});
}

View file

@ -43,6 +43,7 @@ private:
void initLayout();
void installKeyPressedEvent();
void updateEmoteButton();
void openEmotePopup();
Split *const split_;
std::shared_ptr<EmotePopup> emotePopup_;