#include <QPainter>
#include <QRect>
+#include "panelcommon.h"
#include "paneltab.h"
-const int TAB_WIDTH_ACTIVE = 74;
const int TAB_HEIGHT = 66;
+const int TAB_WIDTH_ACTIVE = PANEL_TAB_BAR_WIDTH;
PanelTab::PanelTab(QWidget *parent)
: QToolButton(parent),
{
qDebug() << __PRETTY_FUNCTION__;
- if(m_tabSelected) {
- if(!rect().contains(event->pos()))
+ if (m_tabSelected) {
+ if (!rect().contains(event->pos()))
setDown(false);
else
setDown(true);
{
qDebug() << __PRETTY_FUNCTION__;
- if(event->button() == Qt::LeftButton) {
+ if (event->button() == Qt::LeftButton) {
setDown(true);
m_tabSelected = true;
}
qDebug() << __PRETTY_FUNCTION__;
if (event->button() == Qt::LeftButton) {
- if(this->rect().contains(event->pos())) {
+ if (rect().contains(event->pos())) {
click();
- if(isChecked())
+ if (isChecked())
setChecked(false);
else
setChecked(true);
Q_UNUSED(event);
const int TAB_WIDTH = 66;
+ const int TAB_RECT_X = 0;
+ const int TAB_RECT_Y = 0;
QPainter painter(this);
- if(isChecked()) {
- m_tabRect.setRect(0, 0, TAB_WIDTH_ACTIVE, TAB_HEIGHT);
+ if (isChecked()) {
+ m_tabRect.setRect(TAB_RECT_X, TAB_RECT_Y, TAB_WIDTH_ACTIVE, TAB_HEIGHT);
painter.drawPixmap(m_tabRect, m_tabActiveImage);
} else {
- m_tabRect.setRect(TAB_WIDTH_ACTIVE - TAB_WIDTH, 0, TAB_WIDTH, TAB_HEIGHT);
+ m_tabRect.setRect(TAB_WIDTH_ACTIVE - TAB_WIDTH, TAB_RECT_Y, TAB_WIDTH, TAB_HEIGHT);
painter.drawPixmap(m_tabRect, m_tabInactiveImage);
}
- if(isDown())
+ if (isDown())
icon().paint(&painter, m_tabRect, Qt::AlignCenter, QIcon::Selected);
- else if(isChecked())
- icon().paint(&painter, m_tabRect, Qt::AlignCenter, QIcon::Normal);
- else
+ else if (!isEnabled())
icon().paint(&painter, m_tabRect, Qt::AlignCenter, QIcon::Disabled);
+ else
+ icon().paint(&painter, m_tabRect, Qt::AlignCenter, QIcon::Normal);
}