Tuning the ListItemContextButtonBar look
authorSami Rämö <sami.ramo@ixonos.com>
Fri, 3 Sep 2010 07:44:07 +0000 (10:44 +0300)
committerSami Rämö <sami.ramo@ixonos.com>
Fri, 3 Sep 2010 07:44:07 +0000 (10:44 +0300)
 - ListItemContextButtonBar is hidden until first button widget is
   set, because then the location and size are correct

 - PanelBase: margins and spacing for item related buttons

src/ui/listitemcontextbuttonbar.cpp
src/ui/panelbase.cpp
src/ui/tabbedpanel.cpp

index 4a8edb5..3d5791e 100644 (file)
@@ -75,6 +75,9 @@ void ListItemContextButtonBar::changeButtons()
 
     Q_ASSERT(m_animation->state() == QAbstractAnimation::Stopped);
 
+    if (!isVisible())
+        show();
+
     // Hide previous buttons (if any)
     if (m_contextButtons)
         m_contextButtons->setParent(0);
@@ -83,7 +86,7 @@ void ListItemContextButtonBar::changeButtons()
     m_newContextButtons = 0;
     m_contextButtons->setParent(this);
     m_contextButtons->show();
-    setFixedSize(m_contextButtons->size());
+    setFixedWidth(m_contextButtons->width());
 
     // center this widget horizontally to middle of the panel contents area and set outside of
     // the view
@@ -148,9 +151,14 @@ void ListItemContextButtonBar::paintEvent(QPaintEvent *event)
 
     QPainter painter(this);
 
-    painter.drawPixmap(0, 0, *m_backgroundLeft);
-    painter.drawTiledPixmap(24, 0, width() - 2 * 24, 78, *m_backgroundMiddle);
-    painter.drawPixmap(width() - 24, 0, *m_backgroundRight);
+    const int TOP = 0;
+    const int LEFT = 0;
+    painter.drawPixmap(TOP, LEFT, *m_backgroundLeft);
+    painter.drawTiledPixmap(m_backgroundLeft->width(), TOP,
+                            width() - m_backgroundLeft->width() - m_backgroundRight->width(),
+                            height(),
+                            *m_backgroundMiddle);
+    painter.drawPixmap(width() - m_backgroundRight->width(), TOP, *m_backgroundRight);
 }
 
 void ListItemContextButtonBar::setContextButtons(QWidget *contextButtons)
index 3510669..72cd122 100644 (file)
@@ -32,16 +32,16 @@ PanelBase::PanelBase(QWidget *parent)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
+
+    // --- GENERIC BUTTONS ---
+    m_genericButtons = new QWidget;
+    m_genericButtonsLayout = new QVBoxLayout;
+
     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;
-
-    // --- GENERIC BUTTONS ---
-    m_genericButtons = new QWidget;
-
-    m_genericButtonsLayout = new QVBoxLayout;
     m_genericButtonsLayout->setContentsMargins(CONTEXT_BUTTON_MARGIN_LEFT,
                                               CONTEXT_BUTTON_MARGIN_TOP,
                                               CONTEXT_BUTTON_MARGIN_RIGHT,
@@ -53,7 +53,18 @@ PanelBase::PanelBase(QWidget *parent)
     // --- ITEM RELATED BUTTONS ---
     m_itemButtons = new QWidget(this);
     m_itemButtonsLayout = new QHBoxLayout;
-    /// @todo set margins
+
+    const int ITEM_CONTEXT_BUTTON_MARGIN_BOTTOM = 0;
+    const int ITEM_CONTEXT_BUTTON_MARGIN_LEFT = 2;
+    const int ITEM_CONTEXT_BUTTON_MARGIN_RIGHT = 2;
+    const int ITEM_CONTEXT_BUTTON_MARGIN_TOP = 2;
+    const int ITEM_CONTEXT_BUTTON_SPACING = 0;
+    m_itemButtonsLayout->setContentsMargins(ITEM_CONTEXT_BUTTON_MARGIN_LEFT,
+                                            ITEM_CONTEXT_BUTTON_MARGIN_TOP,
+                                            ITEM_CONTEXT_BUTTON_MARGIN_RIGHT,
+                                            ITEM_CONTEXT_BUTTON_MARGIN_BOTTOM);
+    m_itemButtonsLayout->setSpacing(ITEM_CONTEXT_BUTTON_SPACING);
+
     m_itemButtons->setLayout(m_itemButtonsLayout);
 }
 
index f42b1ef..3f130fc 100644 (file)
@@ -86,6 +86,7 @@ TabbedPanel::TabbedPanel(QWidget *parent)
 
     // --- LIST ITEM RELATED CONTEXT BUTTONS BAR ---
     m_itemContextButtonBar = new ListItemContextButtonBar(this);
+    m_itemContextButtonBar->hide();
 
     connect(this, SIGNAL(listItemSelectionChanged(bool)),
             m_itemContextButtonBar, SLOT(onListItemSelectionChanged(bool)));