MCPcopy Create free account
hub / github.com/Linloir/GraphBuilder / mouseMoveEvent

Method mouseMoveEvent

mainwindow.cpp:336–390  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

334}
335
336void MainWindow::mouseMoveEvent(QMouseEvent *event){
337 if(event->buttons() == Qt::NoButton)
338 mousePressed = false;
339 if(!mousePressed){
340 mouseState = 0;
341 if(!maximized && abs(event->pos().x() - ui->mainWidget->pos().x()) < 5)
342 mouseState |= AT_LEFT;
343 if(!maximized && abs(event->pos().y() - ui->mainWidget->pos().y()) < 5)
344 mouseState |= AT_TOP;
345 if(!maximized && abs(event->pos().x() - ui->mainWidget->pos().x() - ui->mainWidget->width()) < 5)
346 mouseState |= AT_RIGHT;
347 if(!maximized && abs(event->pos().y() - ui->mainWidget->pos().y() - ui->mainWidget->height()) < 5)
348 mouseState |= AT_BOTTOM;
349 if(mouseState == AT_TOP_LEFT || mouseState == AT_BOTTOM_RIGHT)
350 setCursor(Qt::SizeFDiagCursor);
351 else if(mouseState == AT_TOP_RIGHT || mouseState == AT_BOTTOM_LEFT)
352 setCursor(Qt::SizeBDiagCursor);
353 else if(mouseState & (AT_LEFT | AT_RIGHT))
354 setCursor(Qt::SizeHorCursor);
355 else if(mouseState & (AT_TOP | AT_BOTTOM))
356 setCursor(Qt::SizeVerCursor);
357 else
358 unsetCursor();
359 }
360 else{
361 if(mouseState == 0){
362 if(maximized){
363 qreal wRatio = (double)event->pos().x() / (double)ui->mainWidget->width();
364 controlWindowScale();
365 this->move(QPoint(event->globalPosition().x() - ui->mainWidget->width() * wRatio, -30));
366 lastPos = QPoint(ui->mainWidget->width() * wRatio, event->pos().y());
367 }
368 else
369 this->move(event->globalPosition().toPoint() - lastPos);
370 }
371 else{
372 QPoint d = event->globalPosition().toPoint() - frameGeometry().topLeft() - lastPos;
373 if(mouseState & AT_LEFT){
374 this->move(this->frameGeometry().x() + d.x(), this->frameGeometry().y());
375 this->resize(this->width() - d.x(), this->height());
376 }
377 if(mouseState & AT_RIGHT){
378 this->resize(this->width() + d.x(), this->height());
379 }
380 if(mouseState & AT_TOP){
381 this->move(this->frameGeometry().x(), this->frameGeometry().y() + d.y());
382 this->resize(this->width(), this->height() - d.y());
383 }
384 if(mouseState & AT_BOTTOM){
385 this->resize(this->width(), this->height() + d.y());
386 }
387 }
388 lastPos = event->globalPosition().toPoint() - this->frameGeometry().topLeft();
389 }
390}
391
392void MainWindow::resizeEvent(QResizeEvent *event){
393 //Resize border

Callers

nothing calls this directly

Calls 1

moveMethod · 0.80

Tested by

no test coverage detected