Fixed positioning and sizing of the ListItemContextButtonBar
[situare] / src / ui / listitemcontextbuttonbar.cpp
index b4e4038..48487b3 100644 (file)
@@ -21,6 +21,8 @@
 
 #include <QDebug>
 
+#include "panelcommon.h"
+
 #include "listitemcontextbuttonbar.h"
 
 ListItemContextButtonBar::ListItemContextButtonBar(QWidget *parent) :
@@ -41,9 +43,14 @@ void ListItemContextButtonBar::setContextButtons(QWidget *contextButtons)
     m_contextButtons = contextButtons;
 
     m_contextButtons->setParent(this);
-//    m_contextButtons->setVisible(true);
 
-//    setFixedHeight(m_contextButtons->height());
+    // widget must be temporarily visible so we can get the size, doesn't work with invisible widget
+    m_contextButtons->setVisible(true);
+    setFixedSize(m_contextButtons->size());
+    m_contextButtons->setVisible(false);
 
-//    emit positionChangeRequested();
+    // center this widget horizontally to middle of the panel contents area
+    const int FROM_PANEL_CONTENTS_LEFT = PANEL_WIDTH / 2 - m_contextButtons->width() / 2;
+    const int Y = 0;
+    move(PANEL_TAB_BAR_WIDTH + PANEL_BAR_WIDTH + FROM_PANEL_CONTENTS_LEFT, Y);
 }