Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
feat(emoticonswidget):Keep emoticon option open
Browse files Browse the repository at this point in the history
Emoticon dialog remains open, and the selected emoticon is pasted into the text window
close #3043
  • Loading branch information
PKEv committed Apr 24, 2016
1 parent edc35ba commit d0ea5bb
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/widget/emoticonswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,6 @@ EmoticonsWidget::EmoticonsWidget(QWidget *parent) :

void EmoticonsWidget::onSmileyClicked()
{
// hide the QMenu
hide();

// emit insert emoticon
QWidget* sender = qobject_cast<QWidget*>(QObject::sender());
if (sender)
Expand Down Expand Up @@ -193,3 +190,10 @@ void EmoticonsWidget::PageButtonsUpdate()
t_pageButton->setChecked(false);
}
}

void EmoticonsWidget::keyPressEvent(QKeyEvent *e)
{
Q_UNUSED(e)
hide();
}

1 change: 1 addition & 0 deletions src/widget/emoticonswidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ private slots:
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;
Expand Down
10 changes: 10 additions & 0 deletions src/widget/form/genericchatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<QWidget*>(QObject::sender());
if (sender)
Expand Down Expand Up @@ -497,6 +498,15 @@ void GenericChatForm::resizeEvent(QResizeEvent* event)

bool GenericChatForm::eventFilter(QObject* object, QEvent* event)
{
EmoticonsWidget * ev = qobject_cast<EmoticonsWidget *>(object);
if (( ev) && (event->type() == QEvent::KeyPress) )
{
QKeyEvent* key = static_cast<QKeyEvent*>(event);
msgEdit->sendKeyEvent(key);
msgEdit->setFocus();
return false;
}

if (object != this->fileButton && object != this->fileFlyout)
return false;

Expand Down
8 changes: 8 additions & 0 deletions src/widget/tool/chattextedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
Expand All @@ -69,3 +72,8 @@ void ChatTextEdit::retranslateUi()
{
setPlaceholderText(tr("Type your message here..."));
}

void ChatTextEdit::sendKeyEvent(QKeyEvent * event)
{
emit keyPressEvent(event);
}
1 change: 1 addition & 0 deletions src/widget/tool/chattextedit.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class ChatTextEdit final : public QTextEdit
explicit ChatTextEdit(QWidget *parent = 0);
~ChatTextEdit();
void setLastMessage(QString lm);
void sendKeyEvent(QKeyEvent * event);

signals:
void enterPressed();
Expand Down

0 comments on commit d0ea5bb

Please sign in to comment.