From d0ea5bb4fd6e5ffdb2bb11c4e63d1c518af36b65 Mon Sep 17 00:00:00 2001 From: PKEv Date: Sat, 23 Apr 2016 13:44:19 +0300 Subject: [PATCH] feat(emoticonswidget):Keep emoticon option open Emoticon dialog remains open, and the selected emoticon is pasted into the text window close #3043 --- src/widget/emoticonswidget.cpp | 10 +++++++--- src/widget/emoticonswidget.h | 1 + src/widget/form/genericchatform.cpp | 10 ++++++++++ src/widget/tool/chattextedit.cpp | 8 ++++++++ src/widget/tool/chattextedit.h | 1 + 5 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/widget/emoticonswidget.cpp b/src/widget/emoticonswidget.cpp index 9aafb761f..9d1147056 100644 --- a/src/widget/emoticonswidget.cpp +++ b/src/widget/emoticonswidget.cpp @@ -126,9 +126,6 @@ EmoticonsWidget::EmoticonsWidget(QWidget *parent) : void EmoticonsWidget::onSmileyClicked() { - // hide the QMenu - hide(); - // emit insert emoticon QWidget* sender = qobject_cast(QObject::sender()); if (sender) @@ -193,3 +190,10 @@ void EmoticonsWidget::PageButtonsUpdate() t_pageButton->setChecked(false); } } + +void EmoticonsWidget::keyPressEvent(QKeyEvent *e) +{ + Q_UNUSED(e) + hide(); +} + diff --git a/src/widget/emoticonswidget.h b/src/widget/emoticonswidget.h index 6cbf5e67d..6cc84ef5d 100644 --- a/src/widget/emoticonswidget.h +++ b/src/widget/emoticonswidget.h @@ -42,6 +42,7 @@ protected: void mouseReleaseEvent(QMouseEvent *ev) final override; void mousePressEvent(QMouseEvent *ev) final override; void wheelEvent(QWheelEvent * event) final override; + void keyPressEvent(QKeyEvent *e) final override; private: QStackedWidget stack; diff --git a/src/widget/form/genericchatform.cpp b/src/widget/form/genericchatform.cpp index c9901e6c1..0d118460d 100644 --- a/src/widget/form/genericchatform.cpp +++ b/src/widget/form/genericchatform.cpp @@ -365,6 +365,7 @@ void GenericChatForm::onEmoteButtonClicked() EmoticonsWidget widget; connect(&widget, SIGNAL(insertEmoticon(QString)), this, SLOT(onEmoteInsertRequested(QString))); + widget.installEventFilter(this); QWidget* sender = qobject_cast(QObject::sender()); if (sender) @@ -497,6 +498,15 @@ void GenericChatForm::resizeEvent(QResizeEvent* event) bool GenericChatForm::eventFilter(QObject* object, QEvent* event) { + EmoticonsWidget * ev = qobject_cast(object); + if (( ev) && (event->type() == QEvent::KeyPress) ) + { + QKeyEvent* key = static_cast(event); + msgEdit->sendKeyEvent(key); + msgEdit->setFocus(); + return false; + } + if (object != this->fileButton && object != this->fileFlyout) return false; diff --git a/src/widget/tool/chattextedit.cpp b/src/widget/tool/chattextedit.cpp index f9eebfa74..05d7fb406 100644 --- a/src/widget/tool/chattextedit.cpp +++ b/src/widget/tool/chattextedit.cpp @@ -45,7 +45,10 @@ void ChatTextEdit::keyPressEvent(QKeyEvent * event) if (event->modifiers()) event->ignore(); else + { emit tabPressed(); + event->ignore(); + } } else if (key == Qt::Key_Up && this->toPlainText().isEmpty()) { @@ -69,3 +72,8 @@ void ChatTextEdit::retranslateUi() { setPlaceholderText(tr("Type your message here...")); } + +void ChatTextEdit::sendKeyEvent(QKeyEvent * event) +{ + emit keyPressEvent(event); +} diff --git a/src/widget/tool/chattextedit.h b/src/widget/tool/chattextedit.h index 54d28a490..21f00c861 100644 --- a/src/widget/tool/chattextedit.h +++ b/src/widget/tool/chattextedit.h @@ -29,6 +29,7 @@ public: explicit ChatTextEdit(QWidget *parent = 0); ~ChatTextEdit(); void setLastMessage(QString lm); + void sendKeyEvent(QKeyEvent * event); signals: void enterPressed();