diff --git a/src/widget/emoticonswidget.cpp b/src/widget/emoticonswidget.cpp index 212d01f1a..c98fb44f8 100644 --- a/src/widget/emoticonswidget.cpp +++ b/src/widget/emoticonswidget.cpp @@ -23,6 +23,7 @@ #include #include #include +#include EmoticonsWidget::EmoticonsWidget(QWidget *parent) : QMenu(parent) @@ -43,7 +44,7 @@ EmoticonsWidget::EmoticonsWidget(QWidget *parent) : const QList& emoticons = SmileyPack::getInstance().getEmoticons(); int itemCount = emoticons.size(); - int pageCount = (itemCount / itemsPerPage) + 1; + int pageCount = ceil(float(itemCount) / float(itemsPerPage)); int currPage = 0; int currItem = 0; int row = 0; @@ -114,7 +115,7 @@ EmoticonsWidget::EmoticonsWidget(QWidget *parent) : void EmoticonsWidget::onSmileyClicked() { // hide the QMenu - QMenu::hide(); + hide(); // emit insert emoticon QWidget* sender = qobject_cast(QObject::sender()); @@ -136,3 +137,9 @@ QSize EmoticonsWidget::sizeHint() const { return layout.sizeHint(); } + +void EmoticonsWidget::mouseReleaseEvent(QMouseEvent *ev) +{ + if (!rect().contains(ev->pos())) + hide(); +} diff --git a/src/widget/emoticonswidget.h b/src/widget/emoticonswidget.h index 559fb7443..3c6c979b1 100644 --- a/src/widget/emoticonswidget.h +++ b/src/widget/emoticonswidget.h @@ -34,12 +34,16 @@ private slots: void onSmileyClicked(); void onPageButtonClicked(); +protected: + virtual void mouseReleaseEvent(QMouseEvent *ev); + private: QStackedWidget stack; QVBoxLayout layout; public: virtual QSize sizeHint() const; + }; #endif // EMOTICONSWIDGET_H