ui: restrict subwindow movement

restrict subwindow movement to mainwindow
to make sure you cant move it were you dont see it
This commit is contained in:
Andreas Stallinger
2017-06-07 17:21:54 +02:00
parent 38e016c909
commit 255fea62af
2 changed files with 22 additions and 2 deletions
+2
View File
@@ -20,6 +20,7 @@
.DS_Store
.idea
.vscode
/ide_plugins/vs/vs2015/SourcetrailPlugin/SourcetrailPlugin/bin
/ide_plugins/vs/vs2015/SourcetrailPlugin/SourcetrailPlugin/obj
@@ -55,6 +56,7 @@ sourcetrail.srctrlprj
compile_commands.json
Makefile
CMakeLists.txt.user*
/__pycache__/
/deployment/windows/wixSetup/bin
+20 -2
View File
@@ -409,8 +409,26 @@ void QtWindow::mouseMoveEvent(QMouseEvent* event)
{
if (event->buttons() & Qt::LeftButton && m_mousePressedInWindow)
{
move(event->globalPos() - m_dragPosition);
event->accept();
if (m_isSubWindow)
{
QPoint pos = event->globalPos() - m_dragPosition;
QRect parentRect = parentWidget()->rect();
if (pos.x() < parentRect.left())
{
pos.setX(parentRect.left());
}
pos.setX(qBound(parentRect.left(), parentRect.right() - width(), pos.x()));
pos.setY(qBound(parentRect.top(), parentRect.bottom() - height(), pos.y()));
move(pos);
event->accept();
}
else
{
move(event->globalPos() - m_dragPosition);
event->accept();
}
}
}