2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Kaj Wallin - kaj.wallin@ixonos.com
6 Pekka Nissinen - pekka.nissinen@ixonos.com
8 Situare is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 version 2 as published by the Free Software Foundation.
12 Situare is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with Situare; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
27 #include "panelsliderbar.h"
29 PanelSliderBar::PanelSliderBar(QWidget *parent, Side side)
32 qDebug() << __PRETTY_FUNCTION__;
35 m_sliderButtonArrow.load(":res/images/arrow_right.png");
36 else if (side == RIGHT)
37 m_sliderButtonArrow.load(":res/images/arrow_left.png");
39 qFatal("Illegal PanelSliderBar 2nd argument");
41 m_sliderTile.load(":res/images/sliding_bar_tile.png");
42 m_sliderButton.load(":res/images/sliding_bar_button.png");
43 m_menuDropShadowTile.load(":res/images/menu_bar_drop_shadow.png");
45 m_buttonRect.setRect(0, (SLIDER_HEIGHT / 2) - (m_sliderButton.height() / 2),
46 SLIDER_WIDTH, m_sliderButton.height());
47 m_topRect.setRect(SLIDER_BUTTON_OFFSET, 0, SLIDER_BAR_WIDTH, m_buttonRect.top());
48 m_bottomRect.setRect(SLIDER_BUTTON_OFFSET, m_buttonRect.bottom() + 1,
49 SLIDER_BAR_WIDTH, SLIDER_HEIGHT - m_topRect.height() - m_buttonRect.height());
51 m_sliderRegion = QRegion(m_buttonRect).united(QRegion(m_topRect).united(QRegion(m_bottomRect)));
52 setMask(m_sliderRegion);
54 resize(SLIDER_WIDTH, SLIDER_HEIGHT);
57 void PanelSliderBar::paintEvent(QPaintEvent *)
59 qDebug() << __PRETTY_FUNCTION__;
61 QPainter painter(this);
63 painter.drawTiledPixmap(m_topRect, m_sliderTile);
64 painter.drawTiledPixmap(m_bottomRect, m_sliderTile);
65 painter.drawTiledPixmap(SLIDER_BUTTON_OFFSET, 0, SLIDER_BAR_WIDTH, m_menuDropShadowTile.height(),
66 m_menuDropShadowTile);
67 painter.drawPixmap(m_buttonRect, m_sliderButton);
68 painter.drawPixmap((this->width() / 2) - (m_sliderButtonArrow.width() / 2),
69 (this->height() / 2) - (m_sliderButtonArrow.height() / 2),
73 void PanelSliderBar::mouseReleaseEvent(QMouseEvent *)
75 qDebug() << __PRETTY_FUNCTION__;
80 void PanelSliderBar::resizeSliderBar(const QSize &size)
82 qDebug() << __PRETTY_FUNCTION__;
84 m_buttonRect.setRect(0, (size.height() / 2) - (m_sliderButton.height() / 2),
85 SLIDER_WIDTH, m_sliderButton.height());
86 m_topRect.setRect(SLIDER_BUTTON_OFFSET, 0, SLIDER_BAR_WIDTH, m_buttonRect.top());
87 m_bottomRect.setRect(SLIDER_BUTTON_OFFSET, m_buttonRect.bottom() + 1,
88 SLIDER_BAR_WIDTH, size.height() - m_topRect.height() - m_buttonRect.height());
90 m_sliderRegion = QRegion(m_buttonRect).united(QRegion(m_topRect).united(QRegion(m_bottomRect)));
91 setMask(m_sliderRegion);
93 resize(SLIDER_WIDTH, size.height() - PANEL_TOP_PADDING - PANEL_BOTTOM_PADDING);