Merge branch 'new_panels_with_context_buttons' of https://vcs.maemo.org/git/situare...
authorSami Rämö <sami.ramo@ixonos.com>
Wed, 25 Aug 2010 07:45:33 +0000 (10:45 +0300)
committerSami Rämö <sami.ramo@ixonos.com>
Wed, 25 Aug 2010 10:02:59 +0000 (13:02 +0300)
 - Also fixed the routing panel buttons

20 files changed:
doc/testing/functionality-tests.doc
src/ui/friendlistpanel.cpp
src/ui/imagebutton.cpp
src/ui/imagebutton.h
src/ui/indicatorbutton.cpp
src/ui/indicatorbutton.h
src/ui/mainwindow.cpp
src/ui/panelbase.cpp
src/ui/panelbase.h
src/ui/panelcontextbuttonbar.cpp
src/ui/panelcontextbuttonbar.h
src/ui/routingpanel.cpp
src/ui/userinfo.cpp
src/ui/userinfopanel.cpp
src/ui/zoombutton.cpp
src/ui/zoombutton.h
src/ui/zoombuttonpanel.cpp
src/ui/zoombuttonpanel.h
tests/ui/tabbedpanel/tabbedpanel.pro
tests/ui/tabbedpanel/testtabbedpanel.cpp

index 1a5b902..0bac792 100644 (file)
Binary files a/doc/testing/functionality-tests.doc and b/doc/testing/functionality-tests.doc differ
index 31fe911..d333b39 100644 (file)
@@ -63,8 +63,8 @@ FriendListPanel::FriendListPanel(QWidget *parent)
     m_friendListHeaderWidget->setLayout(filterLayout);
     m_friendListHeaderWidget->setAutoFillBackground(true);
 
-    m_routeButton = new ImageButton(this, ":res/images/route_to_friend.png",
-                                    ":res/images/route_to_friend_s.png");
+    m_routeButton = new ImageButton(":res/images/route_to_friend.png",
+                                    ":res/images/route_to_friend_s.png", "", this);
     m_routeButton->setDisabled(true);
 
     QPalette labelPalette = m_friendListHeaderWidget->palette();
@@ -73,8 +73,8 @@ FriendListPanel::FriendListPanel(QWidget *parent)
     m_friendListHeaderWidget->setPalette(labelPalette);
     m_friendListHeaderWidget->hide();
     m_friendListLabel = new QLabel(this);
-    m_clearFilterButton = new ImageButton(this, ":res/images/filtered.png",
-                                          ":res/images/filtered_s.png");
+    m_clearFilterButton = new ImageButton(":res/images/filtered.png",
+                                          ":res/images/filtered_s.png", "", this);
 
     m_clearFilterButton->setCheckable(true);
 
@@ -137,8 +137,8 @@ FriendListPanel::FriendListPanel(QWidget *parent)
             this, SLOT(topmostWindowChanged(bool)));
 
     // CONTEXT BUTTONS
-    m_contextButtonList.append(m_routeButton);
-    m_contextButtonList.append(m_clearFilterButton);
+    m_contextButtonLayout->addWidget(m_routeButton, 0, 0);
+    m_contextButtonLayout->addWidget(m_clearFilterButton, 1, 0);
 }
 
 void FriendListPanel::anyPanelClosed()
index 0dfd592..84fbb16 100644 (file)
    USA.
 */
 
-#include <QSize>
 #include <QDebug>
-#include <QPixmap>
+#include <QMouseEvent>
 #include <QPainter>
 
 #include "imagebutton.h"
 
-ImageButton::ImageButton(QWidget *parent, QString normalIconPictureFileName,
-                         QString selectedIconPictureFileName)
-    : QPushButton(parent),
-      m_buttonMode(QIcon::Normal)
+ImageButton::ImageButton(const QString &normalIconPictureFileName,
+                         const QString &selectedIconPictureFileName,
+                         const QString &disabledIconPictureFileName, QWidget *parent)
+    : QPushButton(parent)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
@@ -43,6 +42,10 @@ ImageButton::ImageButton(QWidget *parent, QString normalIconPictureFileName,
         if(!selectedIconPictureFileName.isEmpty())
             icon.addFile(selectedIconPictureFileName, buttonSize, QIcon::Selected);
 
+        // If there is a picture for disabled state, use it instead of a simple color change
+        if(!disabledIconPictureFileName.isEmpty())
+            icon.addFile(disabledIconPictureFileName, buttonSize, QIcon::Disabled);
+
         initButton(buttonSize, icon);
     }
 }
@@ -57,32 +60,6 @@ void ImageButton::setButtonIcon(const QPixmap &image)
     initButton(buttonSize, icon);
 }
 
-void ImageButton::mousePressEvent(QMouseEvent *event)
-{
-    qDebug() << __PRETTY_FUNCTION__;
-
-    if(m_buttonMode != QIcon::Disabled) {
-        QPushButton::mousePressEvent(event);
-        setMode(QIcon::Selected);
-    } else {
-        setDown(true);
-        emit pressed();
-    }
-}
-
-void ImageButton::mouseReleaseEvent(QMouseEvent *event)
-{
-    qDebug() << __PRETTY_FUNCTION__;
-
-    if(m_buttonMode != QIcon::Disabled) {
-        QPushButton::mouseReleaseEvent(event);
-        setMode(QIcon::Normal);
-    } else {
-        setDown(false);
-        emit released();
-    }
-}
-
 void ImageButton::paintEvent(QPaintEvent *event)
 {
     qDebug() << __PRETTY_FUNCTION__;
@@ -90,22 +67,17 @@ void ImageButton::paintEvent(QPaintEvent *event)
     Q_UNUSED(event);
 
     QPainter painter(this);
-    icon().paint(&painter, this->rect(), NULL, m_buttonMode);
-}
 
-void ImageButton::setMode(QIcon::Mode mode)
-{
-    qDebug() << __PRETTY_FUNCTION__;
-
-    m_buttonMode = mode;
-    update();
-}
-
-QIcon::Mode ImageButton::mode()
-{
-    qDebug() << __PRETTY_FUNCTION__;
-
-    return m_buttonMode;
+    if (isEnabled()) {
+        if (isChecked())
+            icon().paint(&painter, rect(), NULL, QIcon::Selected);
+        else if (isDown())
+            icon().paint(&painter, rect(), NULL, QIcon::Selected);
+        else
+            icon().paint(&painter, rect(), NULL, QIcon::Normal);
+    } else {
+        icon().paint(&painter, rect(), NULL, QIcon::Disabled);
+    }
 }
 
 void ImageButton::initButton(const QSize &size, const QIcon &icon)
index 5876486..224532f 100644 (file)
 #ifndef IMAGEBUTTON_H
 #define IMAGEBUTTON_H
 
-#include <QIcon>
-#include <QString>
-#include <QWidget>
 #include <QPushButton>
-#include <QMouseEvent>
-#include <QPaintEvent>
 
 /**
  * @brief A simple class for icon button
@@ -42,32 +37,20 @@ public:
     /**
      * @brief Constructor
      *
-     * @param parent Parent
      * @param normalIconPictureFileName Normal state icon image file name
      * @param selectedIconPictureFileName Selected state icon image file name (optional)
+     * @param disabledIconPictureFileName Disabled state icon image file name (optional)
+     * @param parent Parent
      */
-    ImageButton(QWidget *parent = 0, QString normalIconPictureFileName = "",
-                QString selectedIconPictureFileName = "");
+    ImageButton(const QString &normalIconPictureFileName = QString(),
+                const QString &selectedIconPictureFileName = QString(),
+                const QString &disabledIconPictureFileName = QString(), QWidget *parent = 0);
 
 /*******************************************************************************
  * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
  ******************************************************************************/
 protected:
     /**
-     * @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 Event handler for paint events
      *
      * Paints the button and its icon
@@ -86,20 +69,6 @@ public:
      */
     void setButtonIcon(const QPixmap &image);
 
-    /**
-     * @brief Sets the button icon mode
-     *
-     * @param mode Button icon mode
-     */
-    void setMode(QIcon::Mode mode);
-
-    /**
-     * @brief Returns the current button icon mode
-     *
-     * @return Button icon mode
-     */
-    QIcon::Mode mode();
-
 private:
     /**
      * @brief Initializes the button by setting graphics and alpha mask
@@ -108,12 +77,6 @@ private:
      * @param icon Image icon
      */
     void initButton(const QSize &size, const QIcon &icon);
-
-/*******************************************************************************
- * DATA MEMBERS
- ******************************************************************************/
-protected:
-    QIcon::Mode m_buttonMode; ///< Button mode (Normal, Selected etc...)
 };
 
 #endif // IMAGEBUTTON_H
index d2a5fed..81bc7b2 100644 (file)
@@ -82,15 +82,6 @@ const QPoint& IndicatorButton::eventPosition()
     return m_eventPosition;
 }
 
-void IndicatorButton::mouseMoveEvent(QMouseEvent *event)
-{
-    qDebug() << __PRETTY_FUNCTION__;
-
-    QToolButton::mouseMoveEvent(event);
-
-    event->ignore();
-}
-
 void IndicatorButton::mousePressEvent(QMouseEvent *event)
 {
     qDebug() << __PRETTY_FUNCTION__;
index 4397aec..743370e 100644 (file)
@@ -57,13 +57,6 @@ public:
  ******************************************************************************/
 protected:
     /**
-     * @brief Event handler for mouse move events
-     *
-     * @param event Mouse event
-     */
-    void mouseMoveEvent(QMouseEvent *event);
-
-    /**
      * @brief Event handler for mouse press events
      *
      * @param event Mouse event
index 18c5f85..039ba38 100644 (file)
@@ -350,10 +350,8 @@ void MainWindow::buildRoutingPanel()
     connect(this, SIGNAL(locationDataParsed(const QList<Location>&)),
             m_routingPanel, SLOT(populateLocationListView(const QList<Location>&)));
 
-    connect(m_routingPanel,
-            SIGNAL(locationItemClicked(const GeoCoordinate&, const GeoCoordinate&)),
-            this,
-            SIGNAL(locationItemClicked(const GeoCoordinate&, const GeoCoordinate&)));
+    connect(m_routingPanel, SIGNAL(locationItemClicked(const GeoCoordinate&, const GeoCoordinate&)),
+            this, SIGNAL(locationItemClicked(const GeoCoordinate&, const GeoCoordinate&)));
 
     connect(m_routingPanel, SIGNAL(routeToLocation(const GeoCoordinate&)),
             this, SIGNAL(routeTo(const GeoCoordinate&)));
index 1eb2175..59e6ab7 100644 (file)
@@ -27,11 +27,28 @@ PanelBase::PanelBase(QWidget *parent)
     : QWidget(parent)
 {
     qDebug() << __PRETTY_FUNCTION__;
+
+    const int CONTEXT_BUTTON_MARGIN_LEFT = 2;
+    const int CONTEXT_BUTTON_MARGIN_TOP = 10;
+    const int CONTEXT_BUTTON_MARGIN_RIGHT = 0;
+    const int CONTEXT_BUTTON_MARGIN_BOTTOM = 0;
+    const int CONTEXT_BUTTON_SPACING = 0;
+
+    m_contextButtons = new QWidget;
+
+    m_contextButtonLayout = new QGridLayout;
+    m_contextButtonLayout->setContentsMargins(CONTEXT_BUTTON_MARGIN_LEFT,
+                                              CONTEXT_BUTTON_MARGIN_TOP,
+                                              CONTEXT_BUTTON_MARGIN_RIGHT,
+                                              CONTEXT_BUTTON_MARGIN_BOTTOM);
+    m_contextButtonLayout->setSpacing(CONTEXT_BUTTON_SPACING);
+
+    m_contextButtons->setLayout(m_contextButtonLayout);
 }
 
-const QList<ImageButton *>& PanelBase::contextButtons() const
+QWidget* PanelBase::contextButtons() const
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    return m_contextButtonList;
+    return m_contextButtons;
 }
index 528dc29..272b8df 100644 (file)
@@ -22,6 +22,7 @@
 #ifndef PANELBASE_H
 #define PANELBASE_H
 
+#include <QGridLayout>
 #include <QWidget>
 
 class ImageButton;
@@ -48,11 +49,11 @@ public:
  ******************************************************************************/
 public:
     /**
-     * @brief Get list of context buttons
+     * @brief Getter for the context buttons
      *
-     * @returns Reference to list of context buttons
+     * @returns Pointer to context buttons widget
      */
-    const QList<ImageButton *>& contextButtons() const;
+    QWidget* contextButtons() const;
 
 /*******************************************************************************
  * SIGNALS
@@ -69,6 +70,9 @@ signals:
  * DATA MEMBERS
  ******************************************************************************/
 protected:
-    QList<ImageButton *> m_contextButtonList; ///< List of context buttons
+    QGridLayout *m_contextButtonLayout; ///< Layout for context buttons
+
+private:
+    QWidget *m_contextButtons;          ///< Widget for context buttons
 };
 #endif // PANELBASE_H
index 11c4bbd..03dfd1e 100644 (file)
 #include <QDebug>
 #include <QPainter>
 
-#include "imagebutton.h"
-
 #include "panelcontextbuttonbar.h"
 
 const int CONTEXT_BUTTON_BAR_WIDTH = 78;
 
 PanelContextButtonBar::PanelContextButtonBar(QWidget *parent)
-    : QWidget(parent)
+    : QWidget(parent),
+      m_contextButtons(0)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
@@ -61,29 +60,20 @@ void PanelContextButtonBar::paintEvent(QPaintEvent *event)
 
 }
 
-void PanelContextButtonBar::setContextButtons(const QList<ImageButton *> &contextButtonList)
+void PanelContextButtonBar::setContextButtons(QWidget *contextButtons)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    const int CONTEXT_BUTTON_HEIGHT = 74;
-    const int CONTEXT_BUTTON_MARGIN_LEFT = 2;
-    const int CONTEXT_BUTTON_MARGIN_TOP = 10;
-
     // Hide previous buttons (if any)
-    for (int i = 0; i < m_contextButtonList.size(); i ++) {
-        m_contextButtonList.at(i)->setParent(0);
-    }
+    if (m_contextButtons)
+        m_contextButtons->setParent(0);
 
-    m_contextButtonList = contextButtonList;
+    m_contextButtons = contextButtons;
 
-    for (int i = 0; i < m_contextButtonList.size(); i ++) {
-        m_contextButtonList.at(i)->setParent(this);
-        m_contextButtonList.at(i)->setVisible(true);
-        m_contextButtonList.at(i)->move(CONTEXT_BUTTON_MARGIN_LEFT,
-                                        CONTEXT_BUTTON_MARGIN_TOP + (CONTEXT_BUTTON_HEIGHT * i));
-    }
+    m_contextButtons->setParent(this);
+    m_contextButtons->setVisible(true);
 
-    setFixedHeight(CONTEXT_BUTTON_MARGIN_TOP + (CONTEXT_BUTTON_HEIGHT * contextButtonList.size()));
+    setFixedHeight(m_contextButtons->height());
 
     emit positionChangeRequested();
 }
index d2528ae..7b4a4ba 100644 (file)
@@ -24,8 +24,6 @@
 
 #include <QWidget>
 
-class ImageButton;
-
 class PanelContextButtonBar : public QWidget
 {
     Q_OBJECT
@@ -56,9 +54,9 @@ public:
     /**
      * @brief Sets the context buttons to the context button bar
      *
-     * @param contextButtonList List of context buttons
+     * @param contextButtons Pointer to context buttons
      */
-    void setContextButtons(const QList<ImageButton *> &contextButtonList);
+    void setContextButtons(QWidget *contextButtons);
 
 /*******************************************************************************
  * SIGNALS
@@ -73,12 +71,12 @@ signals:
  * DATA MEMBERS
  ******************************************************************************/
 private:
-    QList<ImageButton *> m_contextButtonList;
+    QPixmap m_barTile;          ///< Pixmap for button bar
+    QPixmap m_barTop;           ///< Pixmap for button bar top
 
-    QPixmap m_barTile;  ///< Pixmap for button bar
-    QPixmap m_barTop;   ///< Pixmap for button bar top
+    QRect m_barRect;            ///< Rect for the button bar
 
-    QRect m_barRect;    ///< Rect for the button bar
+    QWidget *m_contextButtons;  ///< Widget for context buttons
 };
 
 #endif // PANELCONTEXTBUTTONBAR_H
index 1455ff6..9662506 100644 (file)
@@ -29,15 +29,15 @@ RoutingPanel::RoutingPanel(QWidget *parent)
     listViewLayout->setContentsMargins(PANEL_MARGIN_LEFT, PANEL_MARGIN_TOP,
                                        PANEL_MARGIN_RIGHT, PANEL_MARGIN_BOTTOM);
 
-    ImageButton *searchLocationButton = new ImageButton(0, ":/res/images/search.png",
-                                                             ":/res/images/search_s.png");
+    ImageButton *searchLocationButton = new ImageButton(":/res/images/search.png",
+                                                        ":/res/images/search_s.png",
+                                                        "", this);
 
-    m_contextButtonList.append(searchLocationButton);
+    m_contextButtonLayout->addWidget(searchLocationButton, 0, 0);
 
-    m_routeButton = new ImageButton(this, ":res/images/route_to_location.png",
-                                    ":res/images/route_to_location_s.png");
+    m_routeButton = new ImageButton(":res/images/route_to_location.png",
+                                    ":res/images/route_to_location_s.png", "", this);
     m_routeButton->setDisabled(true);
-    m_routeButton->hide();
 
     m_locationListHeaderWidget = new QWidget();
     m_locationListHeaderWidget->setLayout(headerLayout);
@@ -62,7 +62,6 @@ RoutingPanel::RoutingPanel(QWidget *parent)
     listViewLayout->addWidget(m_locationListView);
     listViewLayout->addWidget(m_routeWaypointListView);
 
-    routingLayout->addWidget(m_routeButton);
     routingLayout->addWidget(m_locationListHeaderWidget);
     routingLayout->addLayout(listViewLayout);
 
@@ -84,7 +83,7 @@ RoutingPanel::RoutingPanel(QWidget *parent)
             this, SIGNAL(requestSearchLocation()));
 
     // CONTEXT BUTTONS
-    m_contextButtonList.append(m_routeButton);
+    m_contextButtonLayout->addWidget(m_routeButton, 1, 0);
 }
 
 void RoutingPanel::clearListsSelections()
@@ -110,8 +109,6 @@ void RoutingPanel::populateLocationListView(const QList<Location> &locations)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    m_routeButton->show();
-
     m_locationListHeaderWidget->show();
     m_locationListLabel->setText(tr("Search results: %1").arg(locations.count()));
 
@@ -153,8 +150,6 @@ void RoutingPanel::setRoute(Route &route)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    m_routeButton->hide();
-
     m_locationListHeaderWidget->hide();
     m_locationListView->hide();
     m_routeWaypointListView->show();
index 102660e..d7e8f33 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <QFormLayout>
 #include <QLabel>
+#include <QMouseEvent>
 #include <QPainter>
 #include <QSettings>
 #include <QVBoxLayout>
index db35d46..a8ffab5 100644 (file)
@@ -79,13 +79,15 @@ UserInfoPanel::UserInfoPanel(QWidget *parent)
     connect(this, SIGNAL(clearUpdateLocationDialogData()),
             m_userInfo, SLOT(clearUpdateLocationDialogData()));
 
-    ImageButton *updateFriendsButton = new ImageButton(this, ":/res/images/refresh.png",
-                                                             ":/res/images/refresh_s.png");
-    ImageButton *updateStatusMessageButton = new ImageButton(this, ":/res/images/send_position.png",
-                                                                   ":/res/images/send_position_s.png");
-
-    m_contextButtonList.append(updateFriendsButton);
-    m_contextButtonList.append(updateStatusMessageButton);
+    ImageButton *updateFriendsButton = new ImageButton(":/res/images/refresh.png",
+                                                       ":/res/images/refresh_s.png",
+                                                       "", this);
+    ImageButton *updateStatusMessageButton = new ImageButton(":/res/images/send_position.png",
+                                                             ":/res/images/send_position_s.png",
+                                                             "", this);
+
+    m_contextButtonLayout->addWidget(updateFriendsButton, 0, 0);
+    m_contextButtonLayout->addWidget(updateStatusMessageButton, 1, 0);
 
     connect(updateFriendsButton, SIGNAL(clicked()),
             this, SIGNAL(refreshUserData()));
index 74fbcc6..e5dfab9 100644 (file)
  */
 
 #include <QDebug>
-#include <QTimer>
+#include <QMouseEvent>
 
 #include "zoombutton.h"
 
 #include "panelcommon.h"
 
-ZoomButton::ZoomButton(QWidget *parent, QString normalIconPictureFileName,
-                       QString selectedIconPictureFileName)
-    : ImageButton(parent, normalIconPictureFileName, selectedIconPictureFileName)
+ZoomButton::ZoomButton(const QString &iconPictureFileName, QWidget *parent)
+    : ImageButton(iconPictureFileName, "", "", parent)
 {
     qDebug() << __PRETTY_FUNCTION__;
 }
@@ -47,9 +46,9 @@ void ZoomButton::mousePressEvent(QMouseEvent *event)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    ImageButton::mousePressEvent(event);
-
     m_eventPosition = mapToParent(event->pos());
+
+    ImageButton::mousePressEvent(event);
 }
 
 const QPoint& ZoomButton::eventPosition()
index 773a483..6dd89e7 100644 (file)
@@ -22,8 +22,6 @@
 #ifndef ZOOMBUTTON_H
 #define ZOOMBUTTON_H
 
-class QTimer;
-
 #include "imagebutton.h"
 
 /**
@@ -39,12 +37,10 @@ public:
     /**
      * @brief Constructor
      *
+     * @param iconPictureFileName Icon image file name
      * @param parent Parent
-     * @param normalIconPictureFileName Normal state Icon image file name
-     * @param selectedIconPictureFileName Selected state Icon image file name (optional)
      */
-    ZoomButton(QWidget *parent = 0, QString normalIconPictureFileName = QString(),
-               QString selectedIconPictureFileName = QString());
+    ZoomButton(const QString &iconPictureFileName = QString(), QWidget *parent = 0);
 
 /*******************************************************************************
  * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
index 6ff47ef..67dfba7 100644 (file)
@@ -21,6 +21,7 @@
 */
 
 #include <QDebug>
+#include <QMouseEvent>
 #include <QPainter>
 #include <QSettings>
 
@@ -41,8 +42,8 @@ ZoomButtonPanel::ZoomButtonPanel(QWidget *parent)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    m_zoomInButton = new ZoomButton(this, ":/res/images/zoom_in.png");
-    m_zoomOutButton = new ZoomButton(this, ":/res/images/zoom_out.png");
+    m_zoomInButton = new ZoomButton(":/res/images/zoom_in.png", this);
+    m_zoomOutButton = new ZoomButton(":/res/images/zoom_out.png", this);
 
     m_panelLayout.setMargin(0);
     m_panelLayout.setSpacing(0);
@@ -159,14 +160,14 @@ void ZoomButtonPanel::paintEvent(QPaintEvent *event)
     }
 }
 
-const ZoomButton* ZoomButtonPanel::zoomInButton()
+const ZoomButton* ZoomButtonPanel::zoomInButton() const
 {
     qDebug() << __PRETTY_FUNCTION__;
 
     return m_zoomInButton;
 }
 
-const ZoomButton* ZoomButtonPanel::zoomOutButton()
+const ZoomButton* ZoomButtonPanel::zoomOutButton() const
 {
     qDebug() << __PRETTY_FUNCTION__;
 
@@ -177,22 +178,22 @@ void ZoomButtonPanel::disableZoomInButton()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    m_zoomInButton->setMode(QIcon::Disabled);
+    m_zoomInButton->setEnabled(false);
 }
 
 void ZoomButtonPanel::disableZoomOutButton()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    m_zoomOutButton->setMode(QIcon::Disabled);
+    m_zoomOutButton->setEnabled(false);
 }
 
 void ZoomButtonPanel::resetButtons()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    m_zoomInButton->setMode(QIcon::Normal);
-    m_zoomOutButton->setMode(QIcon::Normal);
+    m_zoomInButton->setEnabled(true);
+    m_zoomOutButton->setEnabled(true);
 }
 
 void ZoomButtonPanel::setDraggable(bool mode, QPoint eventPosition)
@@ -204,29 +205,24 @@ void ZoomButtonPanel::setDraggable(bool mode, QPoint eventPosition)
     if(mode) {
         emit draggingModeTriggered();
 
-        m_zoomInMode = m_zoomInButton->mode();
-        m_zoomOutMode = m_zoomOutButton->mode();
-        m_zoomInButton->setMode(QIcon::Disabled);
-        m_zoomOutButton->setMode(QIcon::Disabled);
+        m_zoomInMode = m_zoomInButton->isEnabled();
+        m_zoomOutMode = m_zoomOutButton->isEnabled();
+
+        m_zoomInButton->setEnabled(false);
+        m_zoomOutButton->setEnabled(false);
 
         grabMouse();
 
         m_forceReleaseTimer->start();
         m_dragPosition = eventPosition;
     } else {
-        if(m_zoomInMode == QIcon::Selected)
-            m_zoomInButton->setMode(QIcon::Normal);
-        else
-            m_zoomInButton->setMode(m_zoomInMode);
-
-        if(m_zoomOutMode == QIcon::Selected)
-            m_zoomOutButton->setMode(QIcon::Normal);
-        else
-            m_zoomOutButton->setMode(m_zoomOutMode);
+        m_zoomInButton->setEnabled(m_zoomInMode);
+        m_zoomOutButton->setEnabled(m_zoomOutMode);
 
         releaseMouse();
 
         m_forceReleaseTimer->stop();
+
         m_zoomInButton->setDown(false);
         m_zoomOutButton->setDown(false);
     }
index 8165751..71fde69 100644 (file)
@@ -90,14 +90,14 @@ public:
      *
      * @return Pointer to the zoomInButton
      */
-    const ZoomButton* zoomInButton();
+    const ZoomButton* zoomInButton() const;
 
     /**
      * @brief Getter for the zoom out button
      *
      * @return Pointer to the zoomOutButton
      */
-    const ZoomButton* zoomOutButton();
+    const ZoomButton* zoomOutButton() const;
 
 public slots:
     /**
@@ -152,14 +152,13 @@ signals:
  ******************************************************************************/
 private:
     bool m_isDraggable;             ///< Boolean for tracking the draggability state
+    bool m_zoomInMode;              ///< Boolean for storing zoom in button mode before dragging
+    bool m_zoomOutMode;             ///< Boolean for storing zoom out button mode before dragging
 
     QGridLayout m_panelLayout;      ///< Panel layout
 
     QPoint m_dragPosition;          ///< Location from where the widget is grabbed
 
-    QIcon::Mode m_zoomInMode;       ///< Store for zoom in button mode before dragging
-    QIcon::Mode m_zoomOutMode;      ///< Store for zoom out button mode before dragging
-
     QSize m_screenSize;             ///< Store for the screen size
 
     QTimer *m_dragStartTimer;       ///< Timer to init draggability of the zoom panel
index 7d71204..1b298f8 100644 (file)
@@ -5,13 +5,17 @@ SOURCES += \
     testtabbedpanel.cpp \
     ../../../src/ui/tabbedpanel.cpp \
     ../../../src/ui/panelbar.cpp \
+    ../../../src/ui/panelbase.cpp \
     ../../../src/ui/panelcontentstack.cpp \
+    ../../../src/ui/panelcontextbuttonbar.cpp \
     ../../../src/ui/paneltab.cpp \
     ../../../src/ui/paneltabbar.cpp
 HEADERS += \
     ../../../src/ui/tabbedpanel.h \
     ../../../src/ui/panelbar.h \
+    ../../../src/ui/panelbase.h \
     ../../../src/ui/panelcontentstack.h \
+    ../../../src/ui/panelcontextbuttonbar.h \
     ../../../src/ui/paneltab.h \
     ../../../src/ui/paneltabbar.h \
     ../../../src/ui/panelcommon.h
index 63df118..1827f10 100644 (file)
@@ -22,8 +22,8 @@
 
 #include <QtTest/QtTest>
 #include <QtCore>
-#include <QWidget>
 
+#include "ui/panelbase.h"
 #include "ui/tabbedpanel.h"
 
 class TestTabbedPanel : public QObject
@@ -36,10 +36,10 @@ private slots:
 
 void TestTabbedPanel::testPanelToggling()
 {
-    TabbedPanel *testPanel = new TabbedPanel();
+    TabbedPanel *testTabbedPanel = new TabbedPanel;
 
-    QWidget *testWidget = new QWidget();
-    testPanel->addTab(testWidget, QIcon(":/res/images/user_info.png"));
+    PanelBase *testPanel = new PanelBase;
+    testTabbedPanel->addTab(testPanel, QIcon(":/res/images/user_info.png"));
 
     QSignalSpy closedSpy(testPanel, SIGNAL(panelClosed()));
     QSignalSpy openedSpy(testPanel, SIGNAL(panelOpened()));
@@ -56,7 +56,7 @@ void TestTabbedPanel::testPanelToggling()
     QCOMPARE(toggleSpy.count(), 0);
 
     // Try to close the panel. As the panel is closed, no signals should be sent.
-    testPanel->closePanel();
+    testTabbedPanel->closePanel();
     QTest::qWait(1);
     QCOMPARE(closedSpy.count(), 0);
     QCOMPARE(openedSpy.count(), 0);
@@ -67,7 +67,7 @@ void TestTabbedPanel::testPanelToggling()
     QCOMPARE(toggleSpy.count(), 0);
 
     // Now try to open the panel, only toggleState and panelOpened signals should be sent
-    testPanel->showPanel(testWidget);
+    testTabbedPanel->showPanel(testPanel);
     QTest::qWait(1);
     QCOMPARE(closedSpy.count(), 0);
     QCOMPARE(openedSpy.count(), 0);
@@ -78,7 +78,7 @@ void TestTabbedPanel::testPanelToggling()
     QCOMPARE(toggleSpy.count(), 1);
 
     // Now try to open the panel again. As the panel is already open, no signals should not be sent.
-    testPanel->showPanel(testWidget);
+    testTabbedPanel->showPanel(testPanel);
     QTest::qWait(1);
     QCOMPARE(closedSpy.count(), 0);
     QCOMPARE(openedSpy.count(), 1);
@@ -89,7 +89,7 @@ void TestTabbedPanel::testPanelToggling()
     QCOMPARE(toggleSpy.count(), 1);
 
     //Now try to close the panel, only toggleState and panelClosed signals should be sent
-    testPanel->closePanel();
+    testTabbedPanel->closePanel();
     QTest::qWait(1);
     QCOMPARE(closedSpy.count(), 0);
     QCOMPARE(openedSpy.count(), 1);
@@ -99,8 +99,8 @@ void TestTabbedPanel::testPanelToggling()
     QCOMPARE(openedSpy.count(), 1);
     QCOMPARE(toggleSpy.count(), 2);
 
-    delete testWidget;
     delete testPanel;
+    delete testTabbedPanel;
 }
 
 QTEST_MAIN(TestTabbedPanel)