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

Fix segfault on friend id copy

This commit is contained in:
Kevin Flynn 2014-07-02 15:27:30 -07:00
parent 126a36083d
commit fac182596b
2 changed files with 77 additions and 81 deletions

View File

@ -89,13 +89,6 @@ Widget::Widget(QWidget *parent) :
setWindowFlags(Qt::CustomizeWindowHint);
setWindowFlags(Qt::FramelessWindowHint);
setAttribute(Qt::WA_DeleteOnClose);
setMouseTracking(true);
ui->titleBar->setMouseTracking(true);
ui->LTitle->setMouseTracking(true);
ui->tbMenu->setMouseTracking(true);
ui->pbMin->setMouseTracking(true);
ui->pbMax->setMouseTracking(true);
ui->pbClose->setMouseTracking(true);
addAction(ui->actionClose);
@ -154,6 +147,15 @@ Widget::Widget(QWidget *parent) :
ui->statusLabel->label->setStyleSheet("QLabel { color : white; font-size: 8pt;}");
ui->friendList->widget()->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
setMouseTracking(true);
ui->titleBar->setMouseTracking(true);
ui->LTitle->setMouseTracking(true);
ui->tbMenu->setMouseTracking(true);
ui->pbMin->setMouseTracking(true);
ui->pbMax->setMouseTracking(true);
ui->pbClose->setMouseTracking(true);
//ui->->setMouseTracking(true);
camera = new Camera;
camview = new SelfCamView(camera);
@ -550,7 +552,6 @@ void Widget::copyFriendIdToClipboard(int friendId)
{
QClipboard *clipboard = QApplication::clipboard();
clipboard->setText(f->userId, QClipboard::Clipboard);
clipboard->deleteLater();
}
}
@ -695,78 +696,6 @@ bool Widget::isFriendWidgetCurActiveWidget(Friend* f)
return true;
}
void Widget::mouseMoveEvent(QMouseEvent *e)
{
if (!useNativeTheme)
{
int xMouse = e->pos().x();
int yMouse = e->pos().y();
int wWidth = this->geometry().width();
int wHeight = this->geometry().height();
if (moveWidget)
{
inResizeZone = false;
moveWindow(e);
}
else if (allowToResize)
resizeWindow(e);
//right
else if (xMouse >= wWidth - PIXELS_TO_ACT or allowToResize)
{
inResizeZone = true;
if (yMouse >= wHeight - PIXELS_TO_ACT)
setCursor(Qt::SizeFDiagCursor);
else if (yMouse <= PIXELS_TO_ACT)
setCursor(Qt::SizeBDiagCursor);
else
setCursor(Qt::SizeHorCursor);
resizeWindow(e);
}
//left
else if (xMouse <= PIXELS_TO_ACT or allowToResize)
{
inResizeZone = true;
if (yMouse >= wHeight - PIXELS_TO_ACT)
setCursor(Qt::SizeBDiagCursor);
else if (yMouse <= PIXELS_TO_ACT)
setCursor(Qt::SizeFDiagCursor);
else
setCursor(Qt::SizeHorCursor);
resizeWindow(e);
}
//bottom edge
else if ((yMouse >= wHeight - PIXELS_TO_ACT) or allowToResize)
{
inResizeZone = true;
setCursor(Qt::SizeVerCursor);
resizeWindow(e);
}
//Cursor part top
else if (yMouse <= PIXELS_TO_ACT or allowToResize)
{
inResizeZone = true;
setCursor(Qt::SizeVerCursor);
resizeWindow(e);
}
else
{
inResizeZone = false;
setCursor(Qt::ArrowCursor);
}
e->accept();
}
}
bool Widget::event(QEvent * e)
{
if (e->type() == QEvent::WindowStateChange)
@ -803,6 +732,73 @@ bool Widget::event(QEvent * e)
this->setObjectName("inactiveWindow");
this->style()->polish(this);
}
else if (e->type() == QEvent::MouseMove && !useNativeTheme)
{
QMouseEvent *k = (QMouseEvent *)e;
int xMouse = k->pos().x();
int yMouse = k->pos().y();
int wWidth = this->geometry().width();
int wHeight = this->geometry().height();
if (moveWidget)
{
inResizeZone = false;
moveWindow(k);
}
else if (allowToResize)
resizeWindow(k);
//right
else if (xMouse >= wWidth - PIXELS_TO_ACT or allowToResize)
{
inResizeZone = true;
if (yMouse >= wHeight - PIXELS_TO_ACT)
setCursor(Qt::SizeFDiagCursor);
else if (yMouse <= PIXELS_TO_ACT)
setCursor(Qt::SizeBDiagCursor);
else
setCursor(Qt::SizeHorCursor);
resizeWindow(k);
}
//left
else if (xMouse <= PIXELS_TO_ACT or allowToResize)
{
inResizeZone = true;
if (yMouse >= wHeight - PIXELS_TO_ACT)
setCursor(Qt::SizeBDiagCursor);
else if (yMouse <= PIXELS_TO_ACT)
setCursor(Qt::SizeFDiagCursor);
else
setCursor(Qt::SizeHorCursor);
resizeWindow(k);
}
//bottom edge
else if ((yMouse >= wHeight - PIXELS_TO_ACT) or allowToResize)
{
inResizeZone = true;
setCursor(Qt::SizeVerCursor);
resizeWindow(k);
}
//Cursor part top
else if (yMouse <= PIXELS_TO_ACT or allowToResize)
{
inResizeZone = true;
setCursor(Qt::SizeVerCursor);
resizeWindow(k);
}
else
{
inResizeZone = false;
setCursor(Qt::ArrowCursor);
}
e->accept();
}
return QWidget::event(e);
}

View File

@ -108,7 +108,7 @@ private:
bool resizeHorEsq;
bool resizeDiagSupEsq;
bool resizeDiagSupDer;
void mouseMoveEvent(QMouseEvent *e);
//void mouseMoveEvent(QMouseEvent *e);
void mousePressEvent(QMouseEvent *e);
void mouseReleaseEvent(QMouseEvent *e);
void mouseDoubleClickEvent(QMouseEvent *e);