From: Sami Rämö Date: Fri, 3 Sep 2010 07:19:55 +0000 (+0300) Subject: Added background for ListItemContextButtonBar X-Git-Tag: v2.0b-1~17^2~5 X-Git-Url: http://git.maemo.org/git/?p=situare;a=commitdiff_plain;h=e1ff07a180d7dbfba8218d437ee4ee504c427aed Added background for ListItemContextButtonBar --- diff --git a/images.qrc b/images.qrc index 400684d..2325349 100644 --- a/images.qrc +++ b/images.qrc @@ -60,5 +60,8 @@ res/images/zoom_in.png res/images/zoom_out.png res/images/location_search.png + res/images/list_item_context_button_bar_left.png + res/images/list_item_context_button_bar_right.png + res/images/list_item_context_button_bar_tile.png diff --git a/res/images/list_item_context_button_bar_left.png b/res/images/list_item_context_button_bar_left.png new file mode 100644 index 0000000..4eb44c1 Binary files /dev/null and b/res/images/list_item_context_button_bar_left.png differ diff --git a/res/images/list_item_context_button_bar_right.png b/res/images/list_item_context_button_bar_right.png new file mode 100644 index 0000000..3eb816b Binary files /dev/null and b/res/images/list_item_context_button_bar_right.png differ diff --git a/res/images/list_item_context_button_bar_tile.png b/res/images/list_item_context_button_bar_tile.png new file mode 100644 index 0000000..2bf223b Binary files /dev/null and b/res/images/list_item_context_button_bar_tile.png differ diff --git a/src/ui/listitemcontextbuttonbar.cpp b/src/ui/listitemcontextbuttonbar.cpp index b9ef662..4a8edb5 100644 --- a/src/ui/listitemcontextbuttonbar.cpp +++ b/src/ui/listitemcontextbuttonbar.cpp @@ -20,6 +20,7 @@ */ #include +#include #include #include @@ -36,6 +37,15 @@ ListItemContextButtonBar::ListItemContextButtonBar(QWidget *parent) : { qDebug() << __PRETTY_FUNCTION__; + // --- BAR LOOK --- + const int BAR_HEIGHT = 78; + setFixedHeight(BAR_HEIGHT); + + m_backgroundLeft = new QPixmap(":/res/images/list_item_context_button_bar_left.png"); + m_backgroundMiddle = new QPixmap(":/res/images/list_item_context_button_bar_tile.png"); + m_backgroundRight = new QPixmap(":/res/images/list_item_context_button_bar_right.png"); + + // --- ANIMATION --- const int ANIMATION_DURATION_MS = 150; m_animation = new QPropertyAnimation(this, "pos", this); @@ -45,6 +55,20 @@ ListItemContextButtonBar::ListItemContextButtonBar(QWidget *parent) : this, SLOT(onAnimationFinished())); } +ListItemContextButtonBar::~ListItemContextButtonBar() +{ + qDebug() << __PRETTY_FUNCTION__; + + if (m_backgroundLeft) + delete m_backgroundLeft; + + if (m_backgroundMiddle) + delete m_backgroundMiddle; + + if (m_backgroundRight) + delete m_backgroundRight; +} + void ListItemContextButtonBar::changeButtons() { qDebug() << __PRETTY_FUNCTION__; @@ -116,6 +140,19 @@ void ListItemContextButtonBar::onListItemSelectionChanged(bool itemIsSelected) } } +void ListItemContextButtonBar::paintEvent(QPaintEvent *event) +{ + qDebug() << __PRETTY_FUNCTION__; + + Q_UNUSED(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); +} + void ListItemContextButtonBar::setContextButtons(QWidget *contextButtons) { qDebug() << __PRETTY_FUNCTION__; diff --git a/src/ui/listitemcontextbuttonbar.h b/src/ui/listitemcontextbuttonbar.h index 49d4846..7b4a357 100644 --- a/src/ui/listitemcontextbuttonbar.h +++ b/src/ui/listitemcontextbuttonbar.h @@ -33,6 +33,10 @@ class ListItemContextButtonBar : public QWidget public: explicit ListItemContextButtonBar(QWidget *parent = 0); + ~ListItemContextButtonBar(); + + void paintEvent(QPaintEvent *event); + void hideContextButtonBar(); /** @@ -65,6 +69,10 @@ private: bool m_waitForOpen; + QPixmap *m_backgroundLeft; + QPixmap *m_backgroundMiddle; + QPixmap *m_backgroundRight; + QPropertyAnimation *m_animation; QWidget *m_contextButtons; ///< Widget for context buttons