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,
23 #include <QMouseEvent>
29 const int TAB_HEIGHT = 66;
30 const int TAB_WIDTH_ACTIVE = PANEL_TAB_BAR_WIDTH;
32 PanelTab::PanelTab(QWidget *parent)
33 : QToolButton(parent),
37 qDebug() << __PRETTY_FUNCTION__;
39 m_tabActiveImage.load(":/res/images/tab_active.png");
40 m_tabInactiveImage.load(":/res/images/tab_inactive.png");
41 m_tabInactiveImage2.load(":/res/images/tab_inactive2.png");
45 setFixedSize(TAB_WIDTH_ACTIVE, TAB_HEIGHT);
48 void PanelTab::mouseMoveEvent(QMouseEvent *event)
50 qDebug() << __PRETTY_FUNCTION__;
53 if (!rect().contains(event->pos()))
60 void PanelTab::mousePressEvent(QMouseEvent *event)
62 qDebug() << __PRETTY_FUNCTION__;
64 if (event->button() == Qt::LeftButton) {
70 void PanelTab::mouseReleaseEvent(QMouseEvent *event)
72 qDebug() << __PRETTY_FUNCTION__;
74 if (event->button() == Qt::LeftButton) {
75 if (rect().contains(event->pos())) {
85 m_tabSelected = false;
89 void PanelTab::paintEvent(QPaintEvent *event)
91 qDebug() << __PRETTY_FUNCTION__;
95 const int TAB_WIDTH = 66;
96 const int TAB_RECT_X = 0;
97 const int TAB_RECT_Y = 0;
99 QPainter painter(this);
102 m_tabRect.setRect(TAB_RECT_X, TAB_RECT_Y, TAB_WIDTH_ACTIVE, TAB_HEIGHT);
103 painter.drawPixmap(m_tabRect, m_tabActiveImage);
105 m_tabRect.setRect(TAB_WIDTH_ACTIVE - TAB_WIDTH, TAB_RECT_Y, TAB_WIDTH, TAB_HEIGHT);
106 painter.drawPixmap(m_tabRect, m_tabInactiveImage);
110 icon().paint(&painter, m_tabRect, Qt::AlignCenter, QIcon::Selected);
111 else if (isChecked())
112 icon().paint(&painter, m_tabRect, Qt::AlignCenter, QIcon::Normal);
114 icon().paint(&painter, m_tabRect, Qt::AlignCenter, QIcon::Disabled);