Changed the way how the context buttons are implemented and how they are forwadded...
[situare] / src / ui / panelcontextbuttonbar.cpp
index 11c4bbd..03dfd1e 100644 (file)
 #include <QDebug>
 #include <QPainter>
 
-#include "imagebutton.h"
-
 #include "panelcontextbuttonbar.h"
 
 const int CONTEXT_BUTTON_BAR_WIDTH = 78;
 
 PanelContextButtonBar::PanelContextButtonBar(QWidget *parent)
-    : QWidget(parent)
+    : QWidget(parent),
+      m_contextButtons(0)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
@@ -61,29 +60,20 @@ void PanelContextButtonBar::paintEvent(QPaintEvent *event)
 
 }
 
-void PanelContextButtonBar::setContextButtons(const QList<ImageButton *> &contextButtonList)
+void PanelContextButtonBar::setContextButtons(QWidget *contextButtons)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    const int CONTEXT_BUTTON_HEIGHT = 74;
-    const int CONTEXT_BUTTON_MARGIN_LEFT = 2;
-    const int CONTEXT_BUTTON_MARGIN_TOP = 10;
-
     // Hide previous buttons (if any)
-    for (int i = 0; i < m_contextButtonList.size(); i ++) {
-        m_contextButtonList.at(i)->setParent(0);
-    }
+    if (m_contextButtons)
+        m_contextButtons->setParent(0);
 
-    m_contextButtonList = contextButtonList;
+    m_contextButtons = contextButtons;
 
-    for (int i = 0; i < m_contextButtonList.size(); i ++) {
-        m_contextButtonList.at(i)->setParent(this);
-        m_contextButtonList.at(i)->setVisible(true);
-        m_contextButtonList.at(i)->move(CONTEXT_BUTTON_MARGIN_LEFT,
-                                        CONTEXT_BUTTON_MARGIN_TOP + (CONTEXT_BUTTON_HEIGHT * i));
-    }
+    m_contextButtons->setParent(this);
+    m_contextButtons->setVisible(true);
 
-    setFixedHeight(CONTEXT_BUTTON_MARGIN_TOP + (CONTEXT_BUTTON_HEIGHT * contextButtonList.size()));
+    setFixedHeight(m_contextButtons->height());
 
     emit positionChangeRequested();
 }