Reviewed context button bar classes and fixed a small bug that messed up the context...
authorPekka Nissinen <pekka.nissinen@ixonos.com>
Mon, 30 Aug 2010 07:12:30 +0000 (10:12 +0300)
committerPekka Nissinen <pekka.nissinen@ixonos.com>
Mon, 30 Aug 2010 07:12:30 +0000 (10:12 +0300)
position if the tabs had a different amount of context buttons (ie. reverted back to the old
repositionContextButtonBar/positionChangeRequested signal/slot combination).

Reviewed by: Jussi Laitinen

src/src.pro
src/ui/panelbar.h
src/ui/panelbase.h
src/ui/panelcontentstack.h
src/ui/panelcontextbuttonbar.cpp
src/ui/panelcontextbuttonbar.h
src/ui/paneltab.h
src/ui/paneltabbar.h
src/ui/tabbedpanel.cpp
src/ui/tabbedpanel.h

index aeb675e..88395ed 100644 (file)
@@ -165,7 +165,6 @@ HEADERS += application.h \
     user/user.h
 QT += network \
     webkit
-
 DEFINES += QT_NO_DEBUG_OUTPUT
 
 simulator {
index 9da3f7b..4ff3527 100644 (file)
@@ -29,7 +29,7 @@
  * @brief Class for for drawing a vertical line between panel content and tab bar
  *
  * @author Kaj Wallin - kaj.wallin (at) ixonos.com
- * @author Pekka Nissinen - pekka.nissinen@ixonos.com
+ * @author Pekka Nissinen - pekka.nissinen (at) ixonos.com
  */
 class PanelBar : public QWidget
 {
index c226f57..6f4dd0a 100644 (file)
@@ -31,7 +31,7 @@ class ImageButton;
 /**
  * @brief Base class for panels
  *
- * @author Pekka Nissinen - pekka.nissinen@ixonos.com
+ * @author Pekka Nissinen - pekka.nissinen (at) ixonos.com
  */
 class PanelBase : public QWidget
 {
index 9f93a65..3fab86c 100644 (file)
@@ -29,7 +29,7 @@
  * @brief Stack class for tabbed panel widgets
  *
  * @author Kaj Wallin - kaj.wallin (at) ixonos.com
- * @author Pekka Nissinen - pekka.nissinen@ixonos.com
+ * @author Pekka Nissinen - pekka.nissinen (at) ixonos.com
  */
 class PanelContentStack : public QStackedWidget
 {
index e6f544a..48a15b4 100644 (file)
@@ -64,10 +64,10 @@ PanelContextButtonBar::PanelContextButtonBar(QWidget *parent)
     connect(animation, SIGNAL(finished()),
             this, SLOT(contextButtonBarStateChanged()));
 
-    QPoint hiddenPosition(this->pos().x(), this->pos().y());
+    QPoint hiddenPosition(pos().x(), pos().y());
     m_stateHidden->assignProperty(this, "pos", hiddenPosition);
 
-    QPoint visiblePosition(this->pos().x(), this->pos().y() - height());
+    QPoint visiblePosition(pos().x(), pos().y() - height());
     m_stateVisible->assignProperty(this, "pos", visiblePosition);
 
     stateMachine->start();
@@ -137,16 +137,6 @@ void PanelContextButtonBar::move(int x, int y)
     m_stateVisible->assignProperty(this, "pos", visiblePosition);
 }
 
-void PanelContextButtonBar::resizeEvent(QResizeEvent *event)
-{
-    qDebug() << __PRETTY_FUNCTION__;
-
-    QWidget::resizeEvent(event);
-
-    QPoint visiblePosition(pos().x(), pos().y() - height());
-    m_stateVisible->assignProperty(this, "pos", visiblePosition);
-}
-
 void PanelContextButtonBar::setContextButtons(QWidget *contextButtons)
 {
     qDebug() << __PRETTY_FUNCTION__;
@@ -161,6 +151,8 @@ void PanelContextButtonBar::setContextButtons(QWidget *contextButtons)
     m_contextButtons->setVisible(true);
 
     setFixedHeight(m_contextButtons->height());
+
+    emit positionChangeRequested();
 }
 
 void PanelContextButtonBar::showContextButtonBar()
index fbdd58e..340f580 100644 (file)
 
 class QState;
 
+/**
+ * @brief Base class for panel context button bar
+ *
+ * @author Pekka Nissinen - pekka.nissinen (at) ixonos.com
+ */
 class PanelContextButtonBar : public QWidget
 {
     Q_OBJECT
@@ -49,13 +54,6 @@ protected:
      */
     void paintEvent(QPaintEvent *event);
 
-    /**
-     * @brief Resizes the bar
-     *
-     * @param event Resize event
-     */
-    void resizeEvent(QResizeEvent *event);
-
 /*******************************************************************************
  * MEMBER FUNCTIONS AND SLOTS
  ******************************************************************************/
@@ -113,6 +111,11 @@ signals:
     void barVisible();
 
     /**
+     * @brief This signal is called when context button bar needs to be repositioned
+     */
+    void positionChangeRequested();
+
+    /**
      * @brief Signal that is sent when the context button bar state must be changed
      */
     void toggleState();
index a5e3e13..ed1e523 100644 (file)
@@ -29,7 +29,7 @@ class QMouseEvent;
 /**
  * @brief Class for tab button
  *
- * @author Pekka Nissinen - pekka.nissinen@ixonos.com
+ * @author Pekka Nissinen - pekka.nissinen (at) ixonos.com
  */
 class PanelTab : public QToolButton
 {
index fcb422d..9e555da 100644 (file)
@@ -29,7 +29,7 @@ class QButtonGroup;
 /**
  * @brief Class for tab bar
  *
- * @author Pekka Nissinen - pekka.nissinen@ixonos.com
+ * @author Pekka Nissinen - pekka.nissinen (at) ixonos.com
  */
 class PanelTabBar : public QWidget
 {
index 0b553de..49dd1b6 100644 (file)
@@ -74,6 +74,9 @@ TabbedPanel::TabbedPanel(QWidget *parent)
     connect(m_panelContextButtonBar, SIGNAL(barHidden()),
             this, SLOT(closePanel()));
 
+    connect(m_panelContextButtonBar, SIGNAL(positionChangeRequested()),
+            this, SLOT(repositionContextButtonBar()));
+
     // --- PANEL CONTENT ---
     m_panelContentStack = new PanelContentStack(this);
     m_panelContentStack->move(PANEL_TAB_WIDTH + PANEL_BAR_WIDTH, PANEL_TOP_Y);
@@ -172,6 +175,13 @@ void TabbedPanel::removeTab(int index)
     }
 }
 
+void TabbedPanel::repositionContextButtonBar()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    m_panelContextButtonBar->move(PANEL_CONTEXT_BUTTON_BAR_LEFT_X, height());
+}
+
 void TabbedPanel::resizePanel(const QSize &size)
 {
     qDebug() << __PRETTY_FUNCTION__;
index b7473cc..5420bf0 100644 (file)
@@ -41,7 +41,7 @@ class PanelTabBar;
  * @brief Class for tabbed panels
  *
  * @author Kaj Wallin - kaj.wallin (at) ixonos.com
- * @author Pekka Nissinen - pekka.nissinen@ixonos.com
+ * @author Pekka Nissinen - pekka.nissinen (at) ixonos.com
  */
 class TabbedPanel : public QWidget
 {
@@ -119,6 +119,11 @@ public slots:
 
 private slots:
     /**
+     * @brief Repositions context button bar
+     */
+    void repositionContextButtonBar();
+
+    /**
      * @brief Sets the panel at current index active
      *
      * @param index Index of the panel
@@ -169,11 +174,11 @@ signals:
  * DATA MEMBERS
  ******************************************************************************/
 private:
-    bool m_open;                            ///< Current state of the panel
-    bool m_closeRequestPending;
+    bool m_open;                ///< Current state of the panel
+    bool m_closeRequestPending; ///< Indicates wheater the panel is waiting to be closed
 
-    QState *m_stateClosed;                  ///< State of the closed panel
-    QState *m_stateOpened;                  ///< State of the opened panel
+    QState *m_stateClosed;      ///< State of the closed panel
+    QState *m_stateOpened;      ///< State of the opened panel
 
     PanelBar *m_panelBar;                               ///< Widget for panel bar
     PanelContentStack *m_panelContentStack;             ///< Stack for panel widgets