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 <QFile>
|
||||||
#include <QLayout>
|
#include <QLayout>
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
|
#include <QMouseEvent>
|
||||||
|
|
||||||
EmoticonsWidget::EmoticonsWidget(QWidget *parent) :
|
EmoticonsWidget::EmoticonsWidget(QWidget *parent) :
|
||||||
QMenu(parent)
|
QMenu(parent)
|
||||||
|
@ -43,7 +44,7 @@ EmoticonsWidget::EmoticonsWidget(QWidget *parent) :
|
||||||
|
|
||||||
const QList<QStringList>& emoticons = SmileyPack::getInstance().getEmoticons();
|
const QList<QStringList>& emoticons = SmileyPack::getInstance().getEmoticons();
|
||||||
int itemCount = emoticons.size();
|
int itemCount = emoticons.size();
|
||||||
int pageCount = (itemCount / itemsPerPage) + 1;
|
int pageCount = ceil(float(itemCount) / float(itemsPerPage));
|
||||||
int currPage = 0;
|
int currPage = 0;
|
||||||
int currItem = 0;
|
int currItem = 0;
|
||||||
int row = 0;
|
int row = 0;
|
||||||
|
@ -114,7 +115,7 @@ EmoticonsWidget::EmoticonsWidget(QWidget *parent) :
|
||||||
void EmoticonsWidget::onSmileyClicked()
|
void EmoticonsWidget::onSmileyClicked()
|
||||||
{
|
{
|
||||||
// hide the QMenu
|
// hide the QMenu
|
||||||
QMenu::hide();
|
hide();
|
||||||
|
|
||||||
// emit insert emoticon
|
// emit insert emoticon
|
||||||
QWidget* sender = qobject_cast<QWidget*>(QObject::sender());
|
QWidget* sender = qobject_cast<QWidget*>(QObject::sender());
|
||||||
|
@ -136,3 +137,9 @@ QSize EmoticonsWidget::sizeHint() const
|
||||||
{
|
{
|
||||||
return layout.sizeHint();
|
return layout.sizeHint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EmoticonsWidget::mouseReleaseEvent(QMouseEvent *ev)
|
||||||
|
{
|
||||||
|
if (!rect().contains(ev->pos()))
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
|
|
@ -34,12 +34,16 @@ private slots:
|
||||||
void onSmileyClicked();
|
void onSmileyClicked();
|
||||||
void onPageButtonClicked();
|
void onPageButtonClicked();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void mouseReleaseEvent(QMouseEvent *ev);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QStackedWidget stack;
|
QStackedWidget stack;
|
||||||
QVBoxLayout layout;
|
QVBoxLayout layout;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual QSize sizeHint() const;
|
virtual QSize sizeHint() const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // EMOTICONSWIDGET_H
|
#endif // EMOTICONSWIDGET_H
|
||||||
|
|
Loading…
Reference in New Issue
Block a user