summary refs log tree commit diff
path: root/src/TextInputWidget.cpp
diff options
context:
space:
mode:
authorredsky17 <joedonofry@gmail.com>2019-02-07 23:15:25 +0000
committerredsky17 <joedonofry@gmail.com>2019-02-07 23:15:25 +0000
commitbb345a9a9f6ded16356f5e0607577bba089ccee4 (patch)
tree1fcdd6a4e6d9795853e43b3b235e845fe63a9c73 /src/TextInputWidget.cpp
parentMerge pull request #12 from rnhmjoj/fix-join (diff)
parentPrevent symlinks from overwriting files (diff)
downloadnheko-bb345a9a9f6ded16356f5e0607577bba089ccee4.tar.xz
Merge branch 'ui-enhancements'
Preparing for 0.6.3 release
Diffstat (limited to 'src/TextInputWidget.cpp')
-rw-r--r--src/TextInputWidget.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/TextInputWidget.cpp b/src/TextInputWidget.cpp

index 89513037..5fcba7a9 100644 --- a/src/TextInputWidget.cpp +++ b/src/TextInputWidget.cpp
@@ -513,8 +513,22 @@ TextInputWidget::TextInputWidget(QWidget *parent) sendMessageBtn_->setIcon(send_message_icon); sendMessageBtn_->setIconSize(QSize(ButtonHeight, ButtonHeight)); + emojiBtn_ = new emoji::PickButton(this); + emojiBtn_->setToolTip(tr("Emoji")); + +#if defined(Q_OS_MAC) + // macOS has a native emoji picker. + emojiBtn_->hide(); +#endif + + QIcon emoji_icon; + emoji_icon.addFile(":/icons/icons/ui/smile.png"); + emojiBtn_->setIcon(emoji_icon); + emojiBtn_->setIconSize(QSize(ButtonHeight, ButtonHeight)); + topLayout_->addWidget(sendFileBtn_); topLayout_->addWidget(input_); + topLayout_->addWidget(emojiBtn_); topLayout_->addWidget(sendMessageBtn_); setLayout(topLayout_); @@ -527,6 +541,11 @@ TextInputWidget::TextInputWidget(QWidget *parent) connect(input_, &FilteredTextEdit::audio, this, &TextInputWidget::uploadAudio); connect(input_, &FilteredTextEdit::video, this, &TextInputWidget::uploadVideo); connect(input_, &FilteredTextEdit::file, this, &TextInputWidget::uploadFile); + connect(emojiBtn_, + SIGNAL(emojiSelected(const QString &)), + this, + SLOT(addSelectedEmoji(const QString &))); + connect(input_, &FilteredTextEdit::startedTyping, this, &TextInputWidget::startedTyping); connect(input_, &FilteredTextEdit::stoppedTyping, this, &TextInputWidget::stoppedTyping); @@ -536,6 +555,22 @@ TextInputWidget::TextInputWidget(QWidget *parent) } void +TextInputWidget::addSelectedEmoji(const QString &emoji) +{ + QTextCursor cursor = input_->textCursor(); + + QTextCharFormat charfmt; + input_->setCurrentCharFormat(charfmt); + + input_->insertPlainText(emoji); + cursor.movePosition(QTextCursor::End); + + input_->setCurrentCharFormat(charfmt); + + input_->show(); +} + +void TextInputWidget::command(QString command, QString args) { if (command == "me") {