From: Sami Rämö Date: Fri, 3 Sep 2010 07:44:07 +0000 (+0300) Subject: Tuning the ListItemContextButtonBar look X-Git-Tag: v2.0b-1~17^2~4 X-Git-Url: http://git.maemo.org/git/?p=situare;a=commitdiff_plain;h=7d7b6b85ffa59650e47b7fb6077dce6186386e3e Tuning the ListItemContextButtonBar look - 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 --- diff --git a/src/ui/listitemcontextbuttonbar.cpp b/src/ui/listitemcontextbuttonbar.cpp index 4a8edb5..3d5791e 100644 --- a/src/ui/listitemcontextbuttonbar.cpp +++ b/src/ui/listitemcontextbuttonbar.cpp @@ -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) diff --git a/src/ui/panelbase.cpp b/src/ui/panelbase.cpp index 3510669..72cd122 100644 --- a/src/ui/panelbase.cpp +++ b/src/ui/panelbase.cpp @@ -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); } diff --git a/src/ui/tabbedpanel.cpp b/src/ui/tabbedpanel.cpp index f42b1ef..3f130fc 100644 --- a/src/ui/tabbedpanel.cpp +++ b/src/ui/tabbedpanel.cpp @@ -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)));