void ZoomButtonPanel::mouseMoveEvent(QMouseEvent *event)
{
qDebug() << __PRETTY_FUNCTION__;
-
- 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();
}
}
else {
- m_dragPosition = event->pos();
+ if(m_isDraggable)
+ mouseReleaseEvent(event);
+ else
+ m_dragStartTimer->stop();
}
}
void ZoomButtonPanel::mouseReleaseEvent(QMouseEvent *event)
{
+ qDebug() << __PRETTY_FUNCTION__;
Q_UNUSED(event);
- setDraggable(false);
- QSettings settings(DIRECTORY_NAME, FILE_NAME);
- settings.setValue(ZOOMPANEL_POSITION, pos());
- releaseMouse();
- m_dragStartTimer->stop();
+ if(m_isDraggable) {
+ setDraggable(false);
+ QSettings settings(DIRECTORY_NAME, FILE_NAME);
+ settings.setValue(ZOOMPANEL_POSITION, pos());
+ releaseMouse();
+ m_dragStartTimer->stop();
+ }
}
-const ImageButton* ZoomButtonPanel::zoomInButton()
+const ZoomButton* ZoomButtonPanel::zoomInButton()
{
qDebug() << __PRETTY_FUNCTION__;
return m_zoomInButton;
}
-const ImageButton* ZoomButtonPanel::zoomOutButton()
+const ZoomButton* ZoomButtonPanel::zoomOutButton()
{
qDebug() << __PRETTY_FUNCTION__;
void ZoomButtonPanel::setDraggable(bool mode, QPoint eventPosition)
{
+ qDebug() << __PRETTY_FUNCTION__;
+
if(mode == true) {
m_eventBlocker->setAttribute(Qt::WA_TransparentForMouseEvents, false);
m_isDraggable = mode;
void ZoomButtonPanel::screenResized(const QSize &size)
{
+ qDebug() << __PRETTY_FUNCTION__;
+
m_screenSize = size;
}
void ZoomButtonPanel::setDragPosition(QPoint eventPosition)
{
+ qDebug() << __PRETTY_FUNCTION__;
+
m_dragPosition = eventPosition;
}
void ZoomButtonPanel::timerExpired()
{
+ qDebug() << __PRETTY_FUNCTION__;
+
setDraggable(true, m_dragPosition);
}