Removed unused PanelSideBar classes and added new PanelTab classes for tabbed panels
authorPekka Nissinen <pekka.nissinen@ixonos.com>
Thu, 5 Aug 2010 08:38:20 +0000 (11:38 +0300)
committerPekka Nissinen <pekka.nissinen@ixonos.com>
Thu, 5 Aug 2010 08:38:20 +0000 (11:38 +0300)
src/ui/panelsidebar.cpp [deleted file]
src/ui/panelsidebar.h [deleted file]
src/ui/paneltab.cpp [new file with mode: 0644]
src/ui/paneltab.h [new file with mode: 0644]

diff --git a/src/ui/panelsidebar.cpp b/src/ui/panelsidebar.cpp
deleted file mode 100644 (file)
index bd6cf4b..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
-    Situare - A location system for Facebook
-    Copyright (C) 2010  Ixonos Plc. Authors:
-
-        Kaj Wallin - kaj.wallin@ixonos.com
-        Pekka Nissinen - pekka.nissinen@ixonos.com
-
-    Situare is free software; you can redistribute it and/or
-    modify it under the terms of the GNU General Public License
-    version 2 as published by the Free Software Foundation.
-
-    Situare is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with Situare; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
-    USA.
-*/
-
-#include <QDebug>
-#include <QPainter>
-
-#include "panelsidebar.h"
-
-PanelSideBar::PanelSideBar(QWidget *parent, Side side)
-    : QWidget(parent)
-{
-    qDebug() << __PRETTY_FUNCTION__;
-
-    if (side == LEFT) {
-        setObjectName("SidePanelLeft");
-        m_panelTile.load(":res/images/side_bar_tile_left.png");
-        m_panelMiddleTile.load(":res/images/side_bar_middle_left.png");
-        move(0, PANEL_TOP_PADDING);
-    } else if (side == RIGHT) {
-        setObjectName("SidePanelRight");
-        m_panelTile.load(":res/images/side_bar_tile_right.png");
-        m_panelMiddleTile.load(":res/images/side_bar_middle_right.png");
-        move(DEFAULT_SCREEN_WIDTH - SIDEBAR_WIDTH, PANEL_TOP_PADDING);
-    } else {
-        qFatal("Illegal PanelSideBar 2nd argument");
-    }
-
-    m_menuDropShadowTile.load(":res/images/menu_bar_drop_shadow.png");
-
-    middleRect.setRect(0, (SIDEBAR_HEIGHT / 2) - (m_panelMiddleTile.height() / 2),
-                             SIDEBAR_WIDTH, m_panelMiddleTile.height());
-    topRect.setRect(0, 0, SIDEBAR_WIDTH, middleRect.top());
-    bottomRect.setRect(0, middleRect.bottom() + 1, SIDEBAR_WIDTH,
-                             SIDEBAR_HEIGHT - topRect.height() - middleRect.height());
-
-    resize(SIDEBAR_WIDTH, SIDEBAR_HEIGHT);
-    setAttribute(Qt::WA_TransparentForMouseEvents, true);
-}
-
-void PanelSideBar::paintEvent(QPaintEvent *)
-{
-    qDebug() << __PRETTY_FUNCTION__;
-
-    QPainter painter(this);
-
-    painter.drawTiledPixmap(topRect, m_panelTile);
-    painter.drawPixmap(middleRect, m_panelMiddleTile);
-    painter.drawTiledPixmap(bottomRect, m_panelTile);
-    painter.drawTiledPixmap(0, 0, SIDEBAR_WIDTH, m_menuDropShadowTile.height(), m_menuDropShadowTile);
-}
-
-void PanelSideBar::resizeSideBar(const QSize &size)
-{
-    qDebug() << __PRETTY_FUNCTION__;
-
-    if (objectName() == "SidePanelRight")
-        move(size.width() - SIDEBAR_WIDTH, PANEL_TOP_PADDING);
-
-    middleRect.setRect(0, (size.height() / 2) - (m_panelMiddleTile.height() / 2),
-                             SIDEBAR_WIDTH, m_panelMiddleTile.height());
-    topRect.setRect(0, 0, SIDEBAR_WIDTH, middleRect.top());
-    bottomRect.setRect(0, middleRect.bottom() + 1,
-                       SIDEBAR_WIDTH, size.height() - topRect.height() - middleRect.height());
-
-    resize(SIDEBAR_WIDTH, size.height() - PANEL_TOP_PADDING - PANEL_BOTTOM_PADDING);
-}
diff --git a/src/ui/panelsidebar.h b/src/ui/panelsidebar.h
deleted file mode 100644 (file)
index 671baa7..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
-    Situare - A location system for Facebook
-    Copyright (C) 2010  Ixonos Plc. Authors:
-
-        Kaj Wallin - kaj.wallin@ixonos.com
-        Pekka Nissinen - pekka.nissinen@ixonos.com
-
-    Situare is free software; you can redistribute it and/or
-    modify it under the terms of the GNU General Public License
-    version 2 as published by the Free Software Foundation.
-
-    Situare is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with Situare; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
-    USA.
-*/
-
-#ifndef PANELSIDEBAR_H
-#define PANELSIDEBAR_H
-
-#include <QPaintEvent>
-#include <QPixmap>
-#include <QRect>
-#include <QSize>
-#include <QWidget>
-
-#include "panelcommon.h"
-
-/**
- * @brief Generic class for drawing sidebar anchors at the side of the screen
- *
- * @author Kaj Wallin - kaj.wallin (at) ixonos.com
- * @author Pekka Nissinen - pekka.nissinen@ixonos.com
- *
- * @class PanelSideBar panelsidebar.h "ui/panelsidebar.h"
- */
-class PanelSideBar : public QWidget
-{
-    Q_OBJECT
-
-public:
-    /**
-     * @brief Constructor
-     *
-     * @param parent Parent
-     * @param side Qstring for the sidebar location. Accepts "left" and "right"
-     */
-    PanelSideBar(QWidget *parent = 0, Side side = LEFT);
-
-/*******************************************************************************
- * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
- ******************************************************************************/
-protected:
-    /**
-     * @brief Draws stylesheet used in this class.
-     *
-     * @param * QPaintEvent unused
-     */
-    void paintEvent(QPaintEvent *);
-
-/*******************************************************************************
- * MEMBER FUNCTIONS AND SLOTS
- ******************************************************************************/
-public slots:
-    /**
-     * @brief Slot to redraw the side bar after window resize event
-     *
-     * @param size Size of the new window
-     */
-    void resizeSideBar(const QSize &size);
-
-/*******************************************************************************
- * DATA MEMBERS
- ******************************************************************************/
-private:
-    QPixmap m_menuDropShadowTile;   ///< Pixmap for menu drop shadow
-    QPixmap m_panelMiddleTile;      ///< Pixmap for side bar middle tile
-    QPixmap m_panelTile;            ///< Pixmap for side bar tile
-    QRect topRect;      ///< Rect for side bar top
-    QRect middleRect;   ///< Rect for side bar middle
-    QRect bottomRect;   ///< Rect for side bar bottom
-};
-
-#endif // PANELSIDEBAR_H
diff --git a/src/ui/paneltab.cpp b/src/ui/paneltab.cpp
new file mode 100644 (file)
index 0000000..0a81cb5
--- /dev/null
@@ -0,0 +1,130 @@
+/*
+    Situare - A location system for Facebook
+    Copyright (C) 2010  Ixonos Plc. Authors:
+
+        Pekka Nissinen - pekka.nissinen@ixonos.com
+
+    Situare is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License
+    version 2 as published by the Free Software Foundation.
+
+    Situare is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with Situare; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+    USA.
+*/
+
+#include <QDebug>
+#include <QMouseEvent>
+#include <QPainter>
+#include <QRect>
+
+#include "paneltab.h"
+
+const int TAB_WIDTH = 66;
+const int TAB_WIDTH_ACTIVE = 74;
+const int TAB_HEIGHT = 66;
+
+PanelTab::PanelTab(QWidget *parent)
+    : QToolButton(parent),
+      m_tabActive(false),
+      m_tabSelected(false)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    m_tabPixmaps[0].load(":/res/images/tab_inactive.png");
+    m_tabPixmaps[1].load(":/res/images/tab_inactive2.png");
+    m_tabPixmaps[2].load(":/res/images/tab_active.png");
+
+//    m_tabRect.setRect(TAB_WIDTH_ACTIVE - TAB_WIDTH, 0, TAB_WIDTH, TAB_HEIGHT);
+
+    setCheckable(true);
+
+    setFixedSize(TAB_WIDTH_ACTIVE, TAB_HEIGHT);
+}
+
+void PanelTab::mouseMoveEvent(QMouseEvent *event)
+{
+//    qDebug() << __PRETTY_FUNCTION__;
+
+    if(m_tabSelected) {
+        if(!rect().contains(event->pos()))
+            setDown(false);
+        else
+            setDown(true);
+    }
+}
+
+void PanelTab::mousePressEvent(QMouseEvent *event)
+{
+//    qDebug() << __PRETTY_FUNCTION__;
+
+    if(event->button() == Qt::LeftButton) {
+        setDown(true);
+        m_tabSelected = true;
+    }
+}
+
+void PanelTab::mouseReleaseEvent(QMouseEvent *event)
+{
+//    qDebug() << __PRETTY_FUNCTION__;
+
+    if(this->rect().contains(event->pos())) {
+//        emit QAbstractButton::clicked();
+//        emit clicked();
+        click();
+
+//        if(m_tabActive) {
+        if(isChecked()) {
+//            m_tabActive = false;
+            setChecked(false);
+//            m_tabRect.setRect(TAB_WIDTH_ACTIVE - TAB_WIDTH, 0, TAB_WIDTH, TAB_HEIGHT);
+        } else {
+//            m_tabActive = true;
+            setChecked(true);
+//            m_tabRect.setRect(0, 0, TAB_WIDTH_ACTIVE, TAB_HEIGHT);
+        }
+    }
+
+    setDown(false);
+    m_tabSelected = false;
+}
+
+void PanelTab::paintEvent(QPaintEvent *)
+{
+//    qDebug() << __PRETTY_FUNCTION__;
+
+    QPainter painter(this);
+
+    if(isChecked()) {
+        m_tabRect.setRect(0, 0, TAB_WIDTH_ACTIVE, TAB_HEIGHT);
+        painter.drawPixmap(m_tabRect, m_tabPixmaps[2]);
+    } else {
+        m_tabRect.setRect(TAB_WIDTH_ACTIVE - TAB_WIDTH, 0, TAB_WIDTH, TAB_HEIGHT);
+        painter.drawPixmap(m_tabRect, m_tabPixmaps[0]);
+    }
+
+    if(isDown())
+        icon().paint(&painter, m_tabRect, Qt::AlignCenter, QIcon::Selected);
+    else if(isChecked())
+        icon().paint(&painter, m_tabRect, Qt::AlignCenter, QIcon::Normal);
+    else
+        icon().paint(&painter, m_tabRect, Qt::AlignCenter, QIcon::Disabled);
+}
+
+void PanelTab::setActive(bool state)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    if(state)
+//        m_tabActive = true;
+        setChecked(true);
+    else
+//        m_tabActive = false;
+        setChecked(false);
+}
diff --git a/src/ui/paneltab.h b/src/ui/paneltab.h
new file mode 100644 (file)
index 0000000..30aa857
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+    Situare - A location system for Facebook
+    Copyright (C) 2010  Ixonos Plc. Authors:
+
+        Pekka Nissinen - pekka.nissinen@ixonos.com
+
+    Situare is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License
+    version 2 as published by the Free Software Foundation.
+
+    Situare is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with Situare; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+    USA.
+*/
+
+#ifndef PANELTAB_H
+#define PANELTAB_H
+
+#include <QToolButton>
+
+class QMouseEvent;
+
+class PanelTab : public QToolButton
+{
+    Q_OBJECT
+
+public:
+    /**
+     * @brief Constructor
+     *
+     * @param parent
+     */
+    PanelTab(QWidget *parent = 0);
+
+/*******************************************************************************
+ * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
+ ******************************************************************************/
+protected:
+    /**
+     * @brief Move event for the distance indicator button
+     *
+     * @param event Mouse event
+     */
+    void mouseMoveEvent(QMouseEvent *event);
+
+    /**
+     * @brief Event handler for mouse press events
+     *
+     * @param event Mouse event
+     */
+    void mousePressEvent(QMouseEvent *event);
+
+    /**
+     * @brief Event handler for mouse release events
+     *
+     * @param event Mouse event
+     */
+    void mouseReleaseEvent(QMouseEvent *event);
+
+    /**
+     * @brief Draws the tab button
+     *
+     * @param * QPaintEvent unused
+     */
+    void paintEvent(QPaintEvent *);
+
+/*******************************************************************************
+ * MEMBER FUNCTIONS AND SLOTS
+ ******************************************************************************/
+public:
+    void setActive(bool state);
+
+/*******************************************************************************
+ * DATA MEMBERS
+ ******************************************************************************/
+private:
+    bool m_tabActive;
+    bool m_tabSelected;
+
+    QPixmap m_tabPixmaps[3];
+
+    QRect m_tabRect;
+};
+
+#endif // PANELTAB_H