-
- if(m_isDraggable) {
- if (event->buttons() & Qt::LeftButton) {
- QPoint newLocation = mapToParent(event->pos()) - m_dragPosition;
-
- if (newLocation.x() < SIDEBAR_WIDTH)
- newLocation.rx() = SIDEBAR_WIDTH;
- else if (newLocation.x() > m_screenSize.width() - m_eventBlocker->width())
- newLocation.rx() = m_screenSize.width() - m_eventBlocker->width();
-
- if (newLocation.y() < 0)
- newLocation.ry() = 0;
- else if (newLocation.y() > m_screenSize.height() - m_eventBlocker->height())
- newLocation.ry() = m_screenSize.height() - m_eventBlocker->height();
-
- move(newLocation);
- event->accept();
+ if(this->rect().contains(event->pos())) {
+ if(m_isDraggable) {
+ if (event->buttons() & Qt::LeftButton) {
+ QPoint newLocation = mapToParent(event->pos()) - m_dragPosition;
+
+ if (newLocation.x() < SIDEBAR_WIDTH)
+ newLocation.rx() = SIDEBAR_WIDTH;
+ else if (newLocation.x() > m_screenSize.width() - m_eventBlocker->width())
+ newLocation.rx() = m_screenSize.width() - m_eventBlocker->width();
+
+ if (newLocation.y() < 0)
+ newLocation.ry() = 0;
+ else if (newLocation.y() > m_screenSize.height() - m_eventBlocker->height())
+ newLocation.ry() = m_screenSize.height() - m_eventBlocker->height();
+
+ move(newLocation);
+ event->accept();
+ }
+ }
+ else {
+ m_dragPosition = event->pos();