qt-material-widgets/lib/style.cpp

44 lines
895 B
C++
Raw Normal View History

2016-05-11 22:18:09 +00:00
#include "lib/style.h"
2016-04-30 09:38:30 +00:00
#include <QPainter>
#include <QStyleOption>
2016-05-11 22:18:09 +00:00
void Style::setTheme(Theme *theme)
{
_theme = theme;
theme->setParent(this);
}
QColor Style::themeColor(const QString &key) const
{
if (!_theme)
return QColor();
return _theme->getColor(key);
}
2016-04-30 09:38:30 +00:00
2016-04-30 09:53:58 +00:00
void Style::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w) const
2016-04-30 09:38:30 +00:00
{
switch (pe)
{
2016-05-14 10:41:40 +00:00
case PE_FrameFocusRect:
//p->setPen(Qt::blue);
//p->drawRect(opt->rect);
break;
default:
QCommonStyle::drawPrimitive(pe, opt, p, w);
2016-04-30 09:38:30 +00:00
}
}
2016-05-14 10:41:40 +00:00
int Style::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWidget *widget) const
{
switch (m)
{
case PM_ButtonShiftHorizontal:
case PM_ButtonShiftVertical:
return 0;
default:
break;
}
return QCommonStyle::pixelMetric(m, opt, widget);
}