#include <QDebug>
#include <QPainter>
+#include "imagebutton.h"
+
#include "panelcontextbuttonbar.h"
-const int CONTEXT_BUTTON_BAR_RECT_X = 0;
const int CONTEXT_BUTTON_BAR_WIDTH = 78;
-const int CONTEXT_BUTTON_BAR_HEIGHT = 16;
-const int CONTEXT_BUTTON_BAR_TOP_HEIGHT = 32;
PanelContextButtonBar::PanelContextButtonBar(QWidget *parent)
: QWidget(parent)
m_barTile.load(":/res/images/panel_context_button_bar_tile.png");
m_barTop.load(":/res/images/panel_context_button_bar_top.png");
- m_barRect.setRect(CONTEXT_BUTTON_BAR_RECT_X, CONTEXT_BUTTON_BAR_TOP_HEIGHT,
- CONTEXT_BUTTON_BAR_WIDTH, CONTEXT_BUTTON_BAR_HEIGHT);
-
- resize(CONTEXT_BUTTON_BAR_WIDTH, CONTEXT_BUTTON_BAR_HEIGHT + CONTEXT_BUTTON_BAR_TOP_HEIGHT);
+ setFixedWidth(CONTEXT_BUTTON_BAR_WIDTH);
}
void PanelContextButtonBar::paintEvent(QPaintEvent *event)
Q_UNUSED(event);
+ const int CONTEXT_BUTTON_BAR_RECT_X = 0;
+
+ const int CONTEXT_BUTTON_BAR_TOP_HEIGHT = 32;
const int CONTEXT_BUTTON_BAR_TOP_X = 0;
const int CONTEXT_BUTTON_BAR_TOP_Y = 0;
QPainter painter(this);
+ m_barRect.setRect(CONTEXT_BUTTON_BAR_RECT_X, CONTEXT_BUTTON_BAR_TOP_HEIGHT,
+ CONTEXT_BUTTON_BAR_WIDTH, height() - CONTEXT_BUTTON_BAR_TOP_HEIGHT);
+
painter.drawPixmap(CONTEXT_BUTTON_BAR_TOP_X, CONTEXT_BUTTON_BAR_TOP_Y, m_barTop);
painter.drawTiledPixmap(m_barRect, m_barTile);
}
+
+void PanelContextButtonBar::setContextButtons(const QList<ImageButton *> &contextButtonList)
+{
+ 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);
+ }
+
+ m_contextButtonList = contextButtonList;
+
+ 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));
+ }
+
+ setFixedHeight(CONTEXT_BUTTON_MARGIN_TOP + (CONTEXT_BUTTON_HEIGHT * contextButtonList.size()));
+
+ emit positionChangeRequested();
+}
#include <QWidget>
+class ImageButton;
+
class PanelContextButtonBar : public QWidget
{
Q_OBJECT
void paintEvent(QPaintEvent *event);
/*******************************************************************************
+ * MEMBER FUNCTIONS AND SLOTS
+ ******************************************************************************/
+public:
+ /**
+ * @brief Sets the context buttons to the context button bar
+ *
+ * @param contextButtonList List of context buttons
+ */
+ void setContextButtons(const QList<ImageButton *> &contextButtonList);
+
+/*******************************************************************************
+ * SIGNALS
+ ******************************************************************************/
+signals:
+ /**
+ * @brief This signal is called when context button bar needs to be repositioned
+ */
+ void positionChangeRequested();
+
+/*******************************************************************************
* DATA MEMBERS
******************************************************************************/
private:
+ QList<ImageButton *> m_contextButtonList;
+
QPixmap m_barTile; ///< Pixmap for button bar
QPixmap m_barTop; ///< Pixmap for button bar top