Tuning the ListItemContextButtonBar look
[situare] / src / ui / listitemcontextbuttonbar.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)