summaryrefslogtreecommitdiffstats
path: root/src/styles/qcommonstyle.cpp
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-08-07 01:31:43 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-08-07 01:31:43 -0500
commit58451e41d9ecfb405f5dd2718444ac78e8d51c8b (patch)
tree1b52d26a8b3ffe81516df83896285ebfa843d849 /src/styles/qcommonstyle.cpp
parent0008bc5bcd95694b38b0d0322aac2ea6fdb21298 (diff)
downloadqt3-58451e41d9ecfb405f5dd2718444ac78e8d51c8b.tar.gz
qt3-58451e41d9ecfb405f5dd2718444ac78e8d51c8b.zip
Extend TQStyle API further and bump Qt version number
Diffstat (limited to 'src/styles/qcommonstyle.cpp')
-rw-r--r--src/styles/qcommonstyle.cpp47
1 files changed, 35 insertions, 12 deletions
diff --git a/src/styles/qcommonstyle.cpp b/src/styles/qcommonstyle.cpp
index 38ff35b..e46f264 100644
--- a/src/styles/qcommonstyle.cpp
+++ b/src/styles/qcommonstyle.cpp
@@ -156,7 +156,7 @@ QStringList getObjectTypeListForObject(const QObject* object) {
return objectTypes;
}
-QStyle::ControlElementFlags getControlElementFlagsForObject(const QObject* object, QStringList objectTypeList, const QStyleOption& opt) {
+QStyle::ControlElementFlags getControlElementFlagsForObject(const QObject* object, QStringList objectTypeList, const QStyleOption& opt, bool populateReliantFields) {
QStyle::ControlElementFlags cef = (QStyle::ControlElementFlags)0;
if (object) {
@@ -226,6 +226,11 @@ QStyle::ControlElementFlags getControlElementFlagsForObject(const QObject* objec
if (widget->parentWidget()) cef = cef | QStyle::CEF_HasParentWidget;
if (widget->focusProxy()) cef = cef | QStyle::CEF_HasFocusProxy;
if (widget->hasFocus()) cef = cef | QStyle::CEF_HasFocus;
+ if (populateReliantFields) {
+ if (widget->isActiveWindow()) cef = cef | QStyle::CEF_IsActiveWindow;
+ if (widget->isTopLevel()) cef = cef | QStyle::CEF_IsTopLevel;
+ if (widget->isVisible()) cef = cef | QStyle::CEF_IsVisible;
+ }
}
}
else {
@@ -240,6 +245,7 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid
if (widget) {
ceData.widgetObjectTypes = getObjectTypeListForObject(widget);
+ ceData.allDataPopulated = populateReliantFields;
const QPixmap* erasePixmap = widget->backgroundPixmap();
if (erasePixmap) {
ceData.bgPixmap = *erasePixmap;
@@ -373,8 +379,11 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid
ceData.maxSteps = sb->maxValue();
ceData.currentStep = sb->value();
ceData.startStep = sb->sliderStart();
+ ceData.lineStep = sb->lineStep();
ceData.pageStep = sb->pageStep();
-
+ if (populateReliantFields) {
+ ceData.sliderRect = sb->sliderRect();
+ }
}
}
if (ceData.widgetObjectTypes.contains("QSlider")) {
@@ -387,6 +396,9 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid
ceData.startStep = sl->sliderStart();
ceData.lineStep = sl->lineStep();
ceData.pageStep = sl->pageStep();
+ if (populateReliantFields) {
+ ceData.sliderRect = sl->sliderRect();
+ }
}
}
if (ceData.widgetObjectTypes.contains("QDialogButtons")) {
@@ -434,6 +446,7 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid
QWidget* viewport = lv->viewport();
if (viewport) {
ceData.viewportData.widgetObjectTypes = getObjectTypeListForObject(viewport);
+ ceData.viewportData.allDataPopulated = populateReliantFields;
const QPixmap* erasePixmap = viewport->backgroundPixmap();
if (erasePixmap) {
ceData.viewportData.bgPixmap = *erasePixmap;
@@ -470,10 +483,17 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid
}
}
}
+ if (ceData.widgetObjectTypes.contains("QFrame")) {
+ const QFrame *frame = dynamic_cast<const QFrame*>(widget);
+ if (frame) {
+ ceData.frameStyle = frame->frameStyle();
+ }
+ }
const QWidget* parentWidget = widget->parentWidget();
if (parentWidget) {
ceData.parentWidgetData.widgetObjectTypes = getObjectTypeListForObject(parentWidget);
+ ceData.parentWidgetData.allDataPopulated = populateReliantFields;
const QPixmap* erasePixmap = parentWidget->backgroundPixmap();
if (erasePixmap) {
ceData.parentWidgetData.bgPixmap = *erasePixmap;
@@ -1111,7 +1131,7 @@ void QCommonStyle::drawControl( ControlElement element,
}
int tf=AlignVCenter | ShowPrefix;
- if (!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, QStyleOption::Default, 0, widget))
+ if ((!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, QStyleOption::Default, 0, widget)) || ((styleHint(SH_HideUnderlineAcceleratorWhenAltUp, ceData, elementFlags, QStyleOption::Default, 0, widget)) && (!acceleratorsShown())))
tf |= NoAccel;
#ifndef QT_NO_ICONSET
@@ -1164,7 +1184,7 @@ void QCommonStyle::drawControl( ControlElement element,
{
#ifndef QT_NO_CHECKBOX
int alignment = QApplication::reverseLayout() ? AlignRight : AlignLeft;
- if (!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, QStyleOption::Default, 0, widget))
+ if ((!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, QStyleOption::Default, 0, widget)) || ((styleHint(SH_HideUnderlineAcceleratorWhenAltUp, ceData, elementFlags, QStyleOption::Default, 0, widget)) && (!acceleratorsShown())))
alignment |= NoAccel;
drawItem(p, r, alignment | AlignVCenter | ShowPrefix, cg,
@@ -1186,7 +1206,7 @@ void QCommonStyle::drawControl( ControlElement element,
{
#ifndef QT_NO_RADIOBUTTON
int alignment = QApplication::reverseLayout() ? AlignRight : AlignLeft;
- if (!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, QStyleOption::Default, 0, widget))
+ if ((!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, QStyleOption::Default, 0, widget)) || ((styleHint(SH_HideUnderlineAcceleratorWhenAltUp, ceData, elementFlags, QStyleOption::Default, 0, widget)) && (!acceleratorsShown())))
alignment |= NoAccel;
drawItem(p, r, alignment | AlignVCenter | ShowPrefix, cg,
flags & Style_Enabled, (ceData.fgPixmap.isNull())?NULL:&ceData.fgPixmap, ceData.text);
@@ -1253,7 +1273,7 @@ void QCommonStyle::drawControl( ControlElement element,
pixelMetric( QStyle::PM_DefaultFrameWidth, ceData, elementFlags, widget ) );
int alignment = AlignCenter | ShowPrefix;
- if (!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, QStyleOption::Default, 0, widget))
+ if ((!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, QStyleOption::Default, 0, widget)) || ((styleHint(SH_HideUnderlineAcceleratorWhenAltUp, ceData, elementFlags, QStyleOption::Default, 0, widget)) && (!acceleratorsShown())))
alignment |= NoAccel;
drawItem( p, tr, alignment, cg,
flags & Style_Enabled, 0, t->text() );
@@ -1386,7 +1406,7 @@ void QCommonStyle::drawControl( ControlElement element,
QMenuItem *mi = opt.menuItem();
int alignment = AlignCenter|ShowPrefix|DontClip|SingleLine;
- if (!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, QStyleOption::Default, 0, widget))
+ if ((!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, QStyleOption::Default, 0, widget)) || ((styleHint(SH_HideUnderlineAcceleratorWhenAltUp, ceData, elementFlags, QStyleOption::Default, 0, widget)) && (!acceleratorsShown())))
alignment |= NoAccel;
drawItem( p, r, alignment, cg,
flags & Style_Enabled, mi->pixmap(), mi->text(), -1,
@@ -1428,7 +1448,7 @@ void QCommonStyle::drawControl( ControlElement element,
! ceData.text.isNull() &&
! (elementFlags & CEF_UsesTextLabel)) {
int alignment = AlignCenter | ShowPrefix;
- if (!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, QStyleOption::Default, 0, widget))
+ if ((!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, QStyleOption::Default, 0, widget)) || ((styleHint(SH_HideUnderlineAcceleratorWhenAltUp, ceData, elementFlags, QStyleOption::Default, 0, widget)) && (!acceleratorsShown())))
alignment |= NoAccel;
rect.moveBy(shiftX, shiftY);
@@ -1455,7 +1475,7 @@ void QCommonStyle::drawControl( ControlElement element,
p->setFont( ceData.font );
QRect pr = rect, tr = rect;
int alignment = ShowPrefix;
- if (!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, QStyleOption::Default, 0, widget))
+ if ((!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, QStyleOption::Default, 0, widget)) || ((styleHint(SH_HideUnderlineAcceleratorWhenAltUp, ceData, elementFlags, QStyleOption::Default, 0, widget)) && (!acceleratorsShown())))
alignment |= NoAccel;
if ( ceData.toolButtonTextPosition == QToolButton::Under ) {
@@ -2379,7 +2399,7 @@ QRect QCommonStyle::querySubControlMetrics( ComplexControl control,
}
#endif
- QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, QStyleOption());
+ QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, QStyleOption(), false);
return querySubControlMetrics(control, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, QStyleOption()), sc, opt, widget);
}
@@ -3126,7 +3146,7 @@ QSize QCommonStyle::sizeFromContents(ContentsType contents,
int QCommonStyle::styleHint(StyleHint sh, const QWidget * w, const QStyleOption &so, QStyleHintReturn *shr) const
{
QStyleControlElementData ceData = populateControlElementDataFromWidget(w, QStyleOption(), false);
- return styleHint(sh, ceData, getControlElementFlagsForObject(w, ceData.widgetObjectTypes, QStyleOption()), so, shr, w);
+ return styleHint(sh, ceData, getControlElementFlagsForObject(w, ceData.widgetObjectTypes, QStyleOption(), false), so, shr, w);
}
/*! \reimp */
@@ -3200,6 +3220,10 @@ int QCommonStyle::styleHint(StyleHint sh, QStyleControlElementData ceData, Contr
ret = 1;
break;
+ case SH_HideUnderlineAcceleratorWhenAltUp:
+ ret = 0;
+ break;
+
default:
ret = 0;
break;
@@ -3221,5 +3245,4 @@ QPixmap QCommonStyle::stylePixmap(StylePixmap, QStyleControlElementData, Control
return QPixmap();
}
-
#endif // QT_NO_STYLE