2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Pekka Nissinen - pekka.nissinen@ixonos.com
7 Situare is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 version 2 as published by the Free Software Foundation.
11 Situare is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with Situare; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
25 #include "zoombuttonpanel.h"
26 #include "panelcommon.h"
28 ZoomButtonPanel::ZoomButtonPanel(QWidget *parent, int x, int y)
36 qDebug() << __PRETTY_FUNCTION__;
38 m_zoomInButton = new ImageButton(this, ":/res/images/zoom_in.png");
39 m_zoomOutButton = new ImageButton(this, ":/res/images/zoom_out.png");
41 m_panelLayout.setMargin(0);
42 m_panelLayout.setSpacing(0);
43 m_panelLayout.setVerticalSpacing(ZOOM_BUTTON_PANEL_BUTTON_SPACING);
44 m_panelLayout.setSizeConstraint(QLayout::SetFixedSize);
46 m_panelLayout.addWidget(m_zoomInButton, 0, 0);
47 m_panelLayout.addWidget(m_zoomOutButton, 1, 0);
51 QPalette pal = palette();
52 pal.setColor(QPalette::Background, QColor(0, 0, 0, 128));
56 // BUG: long mouse press before dragging causes panel to not be centered
57 // on the cursor. Cause: Long press does not appear to be mousePressEvent o_O
58 void ZoomButtonPanel::mousePressEvent(QMouseEvent *event)
60 qDebug() << __PRETTY_FUNCTION__;
61 if (event->button() == Qt::LeftButton) {
63 dragPosition = event->pos();
64 qWarning() << "EvPos:" << event->pos().x() << event->pos().y() << "DP:" << dragPosition.x() << dragPosition.y();
69 void ZoomButtonPanel::mouseMoveEvent(QMouseEvent *event)
71 qDebug() << __PRETTY_FUNCTION__;
72 if (event->buttons() & Qt::LeftButton) {
73 move(mapToParent(event->pos()) - dragPosition);
74 // move(event->pos() - dragPosition);
75 qWarning() << "EvPos2:" << event->pos().x() << event->pos().y();
76 setAutoFillBackground(true);
81 void ZoomButtonPanel::mouseReleaseEvent(QMouseEvent *event)
83 qDebug() << __PRETTY_FUNCTION__;
84 setAutoFillBackground(false);
88 void ZoomButtonPanel::disableZoomInButton()
90 qDebug() << __PRETTY_FUNCTION__;
92 m_zoomInButton->setMode(QIcon::Disabled);
95 void ZoomButtonPanel::disableZoomOutButton()
97 qDebug() << __PRETTY_FUNCTION__;
99 m_zoomOutButton->setMode(QIcon::Disabled);
102 void ZoomButtonPanel::resetButtons()
104 qDebug() << __PRETTY_FUNCTION__;
106 m_zoomInButton->setMode(QIcon::Normal);
107 m_zoomOutButton->setMode(QIcon::Normal);