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,
26 #include "panelsidebar.h"
28 PanelSideBar::PanelSideBar(QWidget *parent, Side side)
31 qDebug() << __PRETTY_FUNCTION__;
34 setObjectName("SidePanelLeft");
35 m_panelTile.load(":res/images/side_bar_tile_left.png");
36 m_panelMiddleTile.load(":res/images/side_bar_middle_left.png");
37 move(0, PANEL_TOP_PADDING);
38 } else if (side == RIGHT) {
39 setObjectName("SidePanelRight");
40 m_panelTile.load(":res/images/side_bar_tile_right.png");
41 m_panelMiddleTile.load(":res/images/side_bar_middle_right.png");
42 move(DEFAULT_SCREEN_WIDTH - SIDEBAR_WIDTH, PANEL_TOP_PADDING);
44 qFatal("Illegal PanelSideBar 2nd argument");
47 m_menuDropShadowTile.load(":res/images/menu_bar_drop_shadow.png");
49 middleRect.setRect(0, (SIDEBAR_HEIGHT / 2) - (m_panelMiddleTile.height() / 2),
50 SIDEBAR_WIDTH, m_panelMiddleTile.height());
51 topRect.setRect(0, 0, SIDEBAR_WIDTH, middleRect.top());
52 bottomRect.setRect(0, middleRect.bottom() + 1, SIDEBAR_WIDTH,
53 SIDEBAR_HEIGHT - topRect.height() - middleRect.height());
55 resize(SIDEBAR_WIDTH, SIDEBAR_HEIGHT);
56 setAttribute(Qt::WA_TransparentForMouseEvents, true);
59 void PanelSideBar::paintEvent(QPaintEvent *)
61 qDebug() << __PRETTY_FUNCTION__;
63 QPainter painter(this);
65 painter.drawTiledPixmap(topRect, m_panelTile);
66 painter.drawPixmap(middleRect, m_panelMiddleTile);
67 painter.drawTiledPixmap(bottomRect, m_panelTile);
68 painter.drawTiledPixmap(0, 0, SIDEBAR_WIDTH, m_menuDropShadowTile.height(), m_menuDropShadowTile);
71 void PanelSideBar::resizeSideBar(const QSize &size)
73 qDebug() << __PRETTY_FUNCTION__;
75 if (objectName() == "SidePanelRight")
76 move(size.width() - SIDEBAR_WIDTH, PANEL_TOP_PADDING);
78 middleRect.setRect(0, (size.height() / 2) - (m_panelMiddleTile.height() / 2),
79 SIDEBAR_WIDTH, m_panelMiddleTile.height());
80 topRect.setRect(0, 0, SIDEBAR_WIDTH, middleRect.top());
81 bottomRect.setRect(0, middleRect.bottom() + 1,
82 SIDEBAR_WIDTH, size.height() - topRect.height() - middleRect.height());
84 resize(SIDEBAR_WIDTH, size.height() - PANEL_TOP_PADDING - PANEL_BOTTOM_PADDING);