Removed unnecessary image files (needed by old panels) and added new images for tabbe...
[situare] / src / ui / panelsidebar.cpp
1 /*
2     Situare - A location system for Facebook
3     Copyright (C) 2010  Ixonos Plc. Authors:
4
5         Kaj Wallin - kaj.wallin@ixonos.com
6         Pekka Nissinen - pekka.nissinen@ixonos.com
7
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.
11
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.
16
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,
20     USA.
21 */
22
23 #include <QDebug>
24 #include <QPainter>
25
26 #include "panelsidebar.h"
27
28 PanelSideBar::PanelSideBar(QWidget *parent, Side side)
29     : QWidget(parent)
30 {
31     qDebug() << __PRETTY_FUNCTION__;
32
33     if (side == LEFT) {
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);
43     } else {
44         qFatal("Illegal PanelSideBar 2nd argument");
45     }
46
47     m_menuDropShadowTile.load(":res/images/menu_bar_drop_shadow.png");
48
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());
54
55     resize(SIDEBAR_WIDTH, SIDEBAR_HEIGHT);
56     setAttribute(Qt::WA_TransparentForMouseEvents, true);
57 }
58
59 void PanelSideBar::paintEvent(QPaintEvent *)
60 {
61     qDebug() << __PRETTY_FUNCTION__;
62
63     QPainter painter(this);
64
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);
69 }
70
71 void PanelSideBar::resizeSideBar(const QSize &size)
72 {
73     qDebug() << __PRETTY_FUNCTION__;
74
75     if (objectName() == "SidePanelRight")
76         move(size.width() - SIDEBAR_WIDTH, PANEL_TOP_PADDING);
77
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());
83
84     resize(SIDEBAR_WIDTH, size.height() - PANEL_TOP_PADDING - PANEL_BOTTOM_PADDING);
85 }