Fixed positioning and sizing of the ListItemContextButtonBar
authorSami Rämö <sami.ramo@ixonos.com>
Thu, 2 Sep 2010 11:54:37 +0000 (14:54 +0300)
committerSami Rämö <sami.ramo@ixonos.com>
Thu, 2 Sep 2010 11:54:37 +0000 (14:54 +0300)
src/ui/listitemcontextbuttonbar.cpp
src/ui/panelbase.cpp
src/ui/panelbase.h
src/ui/tabbedpanel.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);
 }
index f825aa7..6400053 100644 (file)
@@ -82,12 +82,3 @@ void PanelBase::onListItemSelectionChanged()
     else
         m_itemButtons->hide();
 }
-
-void PanelBase::resizeEvent(QResizeEvent *event)
-{
-    qDebug() << __PRETTY_FUNCTION__;
-
-//    int x =  event->size().width() / 2 - m_itemButtons->width() / 2;
-//    const int Y = 0;
-//    m_itemButtons->move(x, Y);
-}
index a1a1bd6..6bc77af 100644 (file)
@@ -49,9 +49,6 @@ public:
      */
     PanelBase(QWidget *parent = 0);
 
-protected:
-    void resizeEvent(QResizeEvent *event);
-
 /*******************************************************************************
  * MEMBER FUNCTIONS AND SLOTS
  ******************************************************************************/
index 52155d0..3ffc2fb 100644 (file)
@@ -262,12 +262,6 @@ void TabbedPanel::setCurrentIndex(int index)
         QWidget *itemContextButtons = static_cast<PanelBase *>(m_panelContentStack->widget(index))->itemButtons();
         m_itemContextButtonBar->setContextButtons(itemContextButtons);
 
-        const int FROM_PANEL_CONTENTS_LEFT = PANEL_WIDTH / 2 - itemContextButtons->width() / 2;
-        const int Y = 0;
-
-        m_itemContextButtonBar->move(PANEL_TAB_BAR_WIDTH + PANEL_BAR_WIDTH
-                                     + FROM_PANEL_CONTENTS_LEFT, Y);
-
         emit currentChanged(index);
     }
 }