mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
EmoticonsWidget: Do not close on misclick (#393)
This commit is contained in:
parent
6b39184915
commit
4582706243
|
@ -23,6 +23,7 @@
|
|||
#include <QFile>
|
||||
#include <QLayout>
|
||||
#include <QGridLayout>
|
||||
#include <QMouseEvent>
|
||||
|
||||
EmoticonsWidget::EmoticonsWidget(QWidget *parent) :
|
||||
QMenu(parent)
|
||||
|
@ -43,7 +44,7 @@ EmoticonsWidget::EmoticonsWidget(QWidget *parent) :
|
|||
|
||||
const QList<QStringList>& 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<QWidget*>(QObject::sender());
|
||||
|
@ -136,3 +137,9 @@ QSize EmoticonsWidget::sizeHint() const
|
|||
{
|
||||
return layout.sizeHint();
|
||||
}
|
||||
|
||||
void EmoticonsWidget::mouseReleaseEvent(QMouseEvent *ev)
|
||||
{
|
||||
if (!rect().contains(ev->pos()))
|
||||
hide();
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user