1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

bug fix in ChatAreaWidget: absolute coordinates should be used to detect clicks on a FileTransferInstance's buttons

This commit is contained in:
apprb 2014-09-18 00:55:43 +07:00
parent 21267b3a68
commit 9d3bcaa387

View File

@ -21,6 +21,7 @@
#include <QTextTable>
#include <QAbstractTextDocumentLayout>
#include <QCoreApplication>
#include <QDebug>
ChatAreaWidget::ChatAreaWidget(QWidget *parent) :
QTextBrowser(parent)
@ -64,11 +65,13 @@ ChatAreaWidget::~ChatAreaWidget()
void ChatAreaWidget::mouseReleaseEvent(QMouseEvent * event)
{
QTextEdit::mouseReleaseEvent(event);
int pos = this->document()->documentLayout()->hitTest(event->pos(), Qt::ExactHit);
QPointF documentHitPost(event->pos().x() + horizontalScrollBar()->value(), event->pos().y() + verticalScrollBar()->value());
int pos = this->document()->documentLayout()->hitTest(documentHitPost, Qt::ExactHit);
if (pos > 0)
{
QTextCursor cursor(document());
cursor.setPosition(pos);
if(!cursor.atEnd())
{
cursor.setPosition(pos+1);
@ -85,6 +88,7 @@ void ChatAreaWidget::mouseReleaseEvent(QMouseEvent * event)
int middlepos = data.indexOf(".");
QString widgetID = data.left(middlepos);
QString widgetBtn = data.right(data.length() - middlepos - 1);
qDebug() << "ChatAreaWidget::mouseReleaseEvent:" << widgetID << widgetBtn;
emit onFileTranfertInterract(widgetID, widgetBtn);
}
}