summary refs log tree commit diff
path: root/src/TextInputWidget.cpp
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2018-09-19 23:38:36 +0300
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2018-09-19 23:38:36 +0300
commit1b7816f7ca585a84dbbeb88d6779e9d5d71686cc (patch)
tree23e5cc2fd9e3ba6fad37496677e455c7668c59a3 /src/TextInputWidget.cpp
parentImprovements on the system theme (diff)
downloadnheko-1b7816f7ca585a84dbbeb88d6779e9d5d71686cc.tar.xz
macOS: Use the native emoji picker
fixes #79
Diffstat (limited to 'src/TextInputWidget.cpp')
-rw-r--r--src/TextInputWidget.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/TextInputWidget.cpp b/src/TextInputWidget.cpp
index 7167f572..4a03762d 100644
--- a/src/TextInputWidget.cpp
+++ b/src/TextInputWidget.cpp
@@ -37,6 +37,10 @@
 #include "ui/FlatButton.h"
 #include "ui/LoadingIndicator.h"
 
+#if defined(Q_OS_MAC)
+#include "emoji/MacHelper.h"
+#endif
+
 static constexpr size_t INPUT_HISTORY_SIZE = 127;
 static constexpr int MAX_TEXTINPUT_HEIGHT  = 120;
 static constexpr int InputHeight           = 26;
@@ -124,6 +128,12 @@ FilteredTextEdit::keyPressEvent(QKeyEvent *event)
 {
         const bool isModifier = (event->modifiers() != Qt::NoModifier);
 
+#if defined(Q_OS_MAC)
+        if (event->modifiers() == (Qt::ControlModifier | Qt::MetaModifier) &&
+            event->key() == Qt::Key_Space)
+                MacHelper::showEmojiWindow();
+#endif
+
         if (!isModifier) {
                 if (!typingTimer_->isActive())
                         emit startedTyping();
@@ -503,6 +513,11 @@ TextInputWidget::TextInputWidget(QWidget *parent)
         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);