subclass Style from QProxyStyle instead of QCommonStyle
This commit is contained in:
parent
a3e6ebb784
commit
5b07158b36
51
style.cpp
51
style.cpp
|
@ -4,7 +4,7 @@
|
|||
#include "style.h"
|
||||
|
||||
Style::Style()
|
||||
: QCommonStyle()
|
||||
: QProxyStyle()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ Style::~Style()
|
|||
void Style::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p,
|
||||
const QWidget *w) const
|
||||
{
|
||||
// qDebug() << pe;
|
||||
qDebug() << pe;
|
||||
|
||||
switch (pe) {
|
||||
case PE_FrameFocusRect:
|
||||
|
@ -23,31 +23,36 @@ void Style::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter
|
|||
p->drawRect(opt->rect);
|
||||
break;
|
||||
default:
|
||||
QCommonStyle::drawPrimitive(pe, opt, p, w);
|
||||
QProxyStyle::drawPrimitive(pe, opt, p, w);
|
||||
}
|
||||
}
|
||||
|
||||
void Style::drawControl(ControlElement element, const QStyleOption *opt,
|
||||
QPainter *p, const QWidget *widget) const
|
||||
{
|
||||
// qDebug() << element;
|
||||
qDebug() << element;
|
||||
|
||||
switch (element) {
|
||||
/*
|
||||
case CE_FocusFrame:
|
||||
p->fillRect(opt->rect, opt->palette.foreground());
|
||||
break;
|
||||
case CE_MenuItem:
|
||||
if (const QStyleOptionMenuItem *item = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
|
||||
p->drawText(item->rect, item->text);
|
||||
}
|
||||
break;
|
||||
*/
|
||||
default:
|
||||
QCommonStyle::drawControl(element, opt, p, widget);
|
||||
QProxyStyle::drawControl(element, opt, p, widget);
|
||||
}
|
||||
}
|
||||
|
||||
QRect Style::subElementRect(SubElement sr, const QStyleOption *opt,
|
||||
const QWidget *widget) const
|
||||
{
|
||||
// qDebug() << "subElementRect : " << sr;
|
||||
// qDebug() << "-----------------------------------------------";
|
||||
qDebug() << "subElementRect : " << sr;
|
||||
qDebug() << "-----------------------------------------------";
|
||||
|
||||
QRect r;
|
||||
switch (sr) {
|
||||
|
@ -58,11 +63,11 @@ QRect Style::subElementRect(SubElement sr, const QStyleOption *opt,
|
|||
}
|
||||
break;
|
||||
default:
|
||||
r = QCommonStyle::subElementRect(sr, opt, widget);
|
||||
r = QProxyStyle::subElementRect(sr, opt, widget);
|
||||
}
|
||||
|
||||
// qDebug() << "r = " << r;
|
||||
// qDebug() << "===============================================";
|
||||
qDebug() << "r = " << r;
|
||||
qDebug() << "===============================================";
|
||||
|
||||
return r;
|
||||
}
|
||||
|
@ -70,37 +75,37 @@ QRect Style::subElementRect(SubElement sr, const QStyleOption *opt,
|
|||
void Style::drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p,
|
||||
const QWidget *w) const
|
||||
{
|
||||
// qDebug() << "drawComplexControl : " << cc;
|
||||
// qDebug() << "===============================================";
|
||||
qDebug() << "drawComplexControl : " << cc;
|
||||
qDebug() << "===============================================";
|
||||
|
||||
switch (cc) {
|
||||
default:
|
||||
return QCommonStyle::drawComplexControl(cc, opt, p, w);
|
||||
QProxyStyle::drawComplexControl(cc, opt, p, w);
|
||||
}
|
||||
}
|
||||
|
||||
QRect Style::subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc,
|
||||
const QWidget *w) const
|
||||
{
|
||||
// qDebug() << "subControlRect : " << cc;
|
||||
// qDebug() << "------------------------------------------------";
|
||||
qDebug() << "subControlRect : " << cc;
|
||||
qDebug() << "------------------------------------------------";
|
||||
|
||||
QRect r;
|
||||
switch (cc) {
|
||||
default:
|
||||
r = QCommonStyle::subControlRect(cc, opt, sc, w);
|
||||
r = QProxyStyle::subControlRect(cc, opt, sc, w);
|
||||
}
|
||||
|
||||
// qDebug() << "r = " << r;
|
||||
// qDebug() << "===============================================";
|
||||
qDebug() << "r = " << r;
|
||||
qDebug() << "===============================================";
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
int Style::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWidget *widget) const
|
||||
{
|
||||
// qDebug() << "pixelMetric : " << m;
|
||||
// qDebug() << "-----------------------------------------------";
|
||||
qDebug() << "pixelMetric : " << m;
|
||||
qDebug() << "-----------------------------------------------";
|
||||
|
||||
int ret;
|
||||
|
||||
|
@ -111,11 +116,11 @@ int Style::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWidget *wi
|
|||
ret = 0;
|
||||
break;
|
||||
default:
|
||||
ret = QCommonStyle::pixelMetric(m, opt, widget);
|
||||
ret = QProxyStyle::pixelMetric(m, opt, widget);
|
||||
}
|
||||
|
||||
// qDebug() << "ret = " << ret;
|
||||
// qDebug() << "===============================================";
|
||||
qDebug() << "ret = " << ret;
|
||||
qDebug() << "===============================================";
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue