Removed a few constants from panelcommon.h (that really weren't common at all) and...
authorPekka Nissinen <pekka.nissinen@ixonos.com>
Tue, 17 Aug 2010 07:16:53 +0000 (10:16 +0300)
committerPekka Nissinen <pekka.nissinen@ixonos.com>
Tue, 17 Aug 2010 07:16:53 +0000 (10:16 +0300)
src/ui/friendlistpanel.cpp
src/ui/mainwindow.h
src/ui/panelcommon.h
src/ui/panelcontentstack.cpp
src/ui/panelcontentstack.h
src/ui/paneltab.cpp
src/ui/paneltabbar.cpp
src/ui/paneltabbar.h
src/ui/tabbedpanel.cpp

index 49cbae4..a1bd15e 100644 (file)
@@ -38,6 +38,9 @@ FriendListPanel::FriendListPanel(QWidget *parent)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
+    const int FRIENDPANEL_FILTER_MARGIN_LEFT = PANEL_MARGIN_LEFT + 4;
+    const int FRIENDPANEL_FILTER_MARGIN_RIGHT = PANEL_MARGIN_RIGHT + MAEMO5_SCROLLBAR_WIDTH + 4;
+
     QVBoxLayout *friendListPanelLayout = new QVBoxLayout();
     friendListPanelLayout->setMargin(0);
     friendListPanelLayout->setSpacing(0);
index ab87f39..c928aea 100644 (file)
@@ -201,7 +201,6 @@ public slots:
     /**
      * @brief Public slot to intercept signal when old cerdentials are invalid or credentials
      *        doesn't exist yet
-     *
      */
     void startLoginProcess();
 
index 32b22a4..ccafaa3 100644 (file)
@@ -26,7 +26,7 @@
 
 #include <QString>
 
-#include "../common.h"
+#include "common.h"
 
 // Dragging settings
 const int DRAG_INIT_TIME = 1000;        ///< How long buttons must be pressed to start drag mode
@@ -50,24 +50,6 @@ const int PANEL_MARGIN_RIGHT = 0;                     ///< Panel inner margin (r
 const int PANEL_MARGIN_TOP = 0;                       ///< Panel inner margin (top)
 const int PANEL_MARGIN_BOTTOM = 0;                    ///< Panel inner margin (bottom)
 
-/**
- * @brief Friend list filter bar margin (left)
- *
- * @var FRIENDPANEL_FILTER_MARGIN_LEFT
- */
-///< @todo not really commom
-const int FRIENDPANEL_FILTER_MARGIN_LEFT = PANEL_MARGIN_LEFT + 4;
-
-/**
- * @brief Friend list filter bar margin (right)
- *
- * @var FRIENDPANEL_FILTER_MARGIN_RIGHT
- */
-///< @todo not really common
-const int FRIENDPANEL_FILTER_MARGIN_RIGHT = PANEL_MARGIN_RIGHT + MAEMO5_SCROLLBAR_WIDTH + 4;
-
-const int SHOW_ALL_BUTTON_RIGHT_MARGIN = 39; ///< Show all button right margin
-
 const int PANEL_CLOSED_X = DEFAULT_SCREEN_WIDTH - PANEL_TAB_WIDTH
                                  - PANEL_BAR_WIDTH; ///< Horizontal position of a closed panel
 
index d59e401..36a5057 100644 (file)
@@ -32,12 +32,14 @@ PanelContentStack::PanelContentStack(QWidget *parent)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
+    const QColor SEMI_TRANSPARENT_BLACK = QColor(0, 0, 0, 128);
+
     resize(PANEL_WIDTH, PANEL_HEIGHT);
 
     m_menuDropShadowTile.load(":res/images/menu_bar_drop_shadow.png");
 
     QPalette pal = palette();
-    pal.setColor(QPalette::Background, QColor(0, 0, 0, 128));
+    pal.setColor(QPalette::Background, SEMI_TRANSPARENT_BLACK);
     setPalette(pal);
     setAutoFillBackground(true);
 }
@@ -49,12 +51,12 @@ void PanelContentStack::paintEvent(QPaintEvent *event)
     Q_UNUSED(event);
 
     QPainter painter(this);
-
-    QRect shadowRect = QRect(0, 0, this->rect().width(), m_menuDropShadowTile.height());
+    ///< @todo magic
+    QRect shadowRect = QRect(0, 0, rect().width(), m_menuDropShadowTile.height());
     painter.drawTiledPixmap(shadowRect, m_menuDropShadowTile);
 }
 
-void PanelContentStack::resizePanelContentStack(const QSize &size)
+void PanelContentStack::resizeContentStack(const QSize &size)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
index fe284f5..9f93a65 100644 (file)
@@ -63,7 +63,7 @@ public slots:
      *
      * @param size Size of the new window
      */
-    void resizePanelContentStack(const QSize &size);
+    void resizeContentStack(const QSize &size);
 
 /*******************************************************************************
  * DATA MEMBERS
index 12fad9b..d12bc3d 100644 (file)
@@ -97,9 +97,11 @@ void PanelTab::paintEvent(QPaintEvent *event)
     QPainter painter(this);
 
     if (isChecked()) {
+        ///< @todo magic
         m_tabRect.setRect(0, 0, TAB_WIDTH_ACTIVE, TAB_HEIGHT);
         painter.drawPixmap(m_tabRect, m_tabActiveImage);
     } else {
+        ///< @todo magic
         m_tabRect.setRect(TAB_WIDTH_ACTIVE - TAB_WIDTH, 0, TAB_WIDTH, TAB_HEIGHT);
         painter.drawPixmap(m_tabRect, m_tabInactiveImage);
     }
index 4decac6..e21d63f 100644 (file)
 
 #include "paneltabbar.h"
 
+const int NO_ACTIVE_TABS = -1;
+
 PanelTabBar::PanelTabBar(QWidget *parent)
     : QWidget(parent),
-      m_activeTab(-1) ///< @todo magic
+      m_activeTab(NO_ACTIVE_TABS)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
@@ -60,19 +62,10 @@ int PanelTabBar::insertTab(int index, const QIcon& icon)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    const int TAB_BAR_TOP_SPACING = 8;
-
-    int verticalStartPoint = TAB_BAR_TOP_SPACING;
-
     m_tabButtonGroup->addButton(new PanelTab(this), index);
     m_tabButtonGroup->button(index)->setIcon(icon);
 
-    ///< @todo  [BEGIN]: Purkkaa (to be removed ASAP!!!)
-    if (index > 0)
-        verticalStartPoint += 65 * index;
-
-    m_tabButtonGroup->button(index)->move(0, verticalStartPoint);
-    // [END]: Purkkaa
+    setUpTabLayout();
 
     return index;
 }
@@ -84,6 +77,8 @@ void PanelTabBar::removeTab(int index)
     if (QAbstractButton *tab = m_tabButtonGroup->button(index)) {
         m_tabButtonGroup->removeButton(tab);
         delete tab;
+
+        setUpTabLayout();
     }
 }
 
@@ -100,11 +95,23 @@ void PanelTabBar::setCurrentIndex(int index)
     qDebug() << __PRETTY_FUNCTION__;
 
     if (m_activeTab == index) {
-        ///< @todo magic
-        m_activeTab = -1;
+        m_activeTab = NO_ACTIVE_TABS;
         emit tabCloseRequested(index);
     } else {
         m_activeTab = index;
         emit currentChanged(index);
     }
 }
+
+void PanelTabBar::setUpTabLayout()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    const int TAB_BUTTON_STEPPING = 65;
+
+    QList<QAbstractButton *> tabList = m_tabButtonGroup->buttons();
+
+    for (int i = 0; i < tabList.size(); i ++) {
+        tabList.at(i)->move(0, i * TAB_BUTTON_STEPPING);
+    }
+}
index 6714abd..17da9f4 100644 (file)
@@ -78,6 +78,12 @@ public:
      */
     void removeTab(int index);
 
+private:
+    /**
+     * @brief Initializes and formats tab buttons layout
+     */
+    void setUpTabLayout();
+
 public slots:
     /**
      * @brief This slot is used to clear tab selections
index 0e28947..b4ee1d6 100644 (file)
@@ -38,11 +38,14 @@ TabbedPanel::TabbedPanel(QWidget *parent)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
+    const int TAB_BAR_TOP_SPACING = 8;
+
     resize(PANEL_BAR_TABBED_WIDTH + PANEL_WIDTH, PANEL_HEIGHT);
     move(PANEL_CLOSED_X, PANEL_TOP_PADDING);
 
     // --- TABS ---
     m_panelTabBar = new PanelTabBar(this);
+    m_panelTabBar->move(0, TAB_BAR_TOP_SPACING);
 
     connect(m_panelTabBar, SIGNAL(currentChanged(int)),
             this, SLOT(setCurrentIndex(int)));
@@ -55,10 +58,12 @@ TabbedPanel::TabbedPanel(QWidget *parent)
 
     // --- BAR ---
     m_panelBar = new PanelBar(this);
+    ///< @todo magic
     m_panelBar->move(PANEL_TAB_WIDTH, 0);
 
     // --- PANEL CONTENT ---
     m_panelContentStack = new PanelContentStack(this);
+    ///< @todo magic
     m_panelContentStack->move(PANEL_TAB_WIDTH + PANEL_BAR_WIDTH, 0);
 
     // --- PANEL ANIMATION ---
@@ -141,7 +146,7 @@ void TabbedPanel::resizePanel(const QSize &size)
 
     m_panelBar->resizeBar(size);
 
-    m_panelContentStack->resizePanelContentStack(size);
+    m_panelContentStack->resizeContentStack(size);
 
     QPoint closedPosition(size.width() - PANEL_TAB_WIDTH - PANEL_BAR_WIDTH, PANEL_TOP_PADDING);
     m_panelStateClosed->assignProperty(this, "pos", closedPosition);