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