summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimothy Pearson <[email protected]>2012-11-11 18:05:44 -0600
committerTimothy Pearson <[email protected]>2012-11-11 18:05:44 -0600
commit515545630499e6a4db2af7e2cfc43e2ab7593a64 (patch)
tree72ce3d68a2e9ea621c5f057736ec218c83406641
parent1079dc4b331da45fb98e8b814932421a46c0b13c (diff)
downloadtde-style-qtcurve-515545630499e6a4db2af7e2cfc43e2ab7593a64.tar.gz
tde-style-qtcurve-515545630499e6a4db2af7e2cfc43e2ab7593a64.zip
Fix crashes when used with third party toolkits
-rw-r--r--style/qtcurve.cpp93
1 files changed, 46 insertions, 47 deletions
diff --git a/style/qtcurve.cpp b/style/qtcurve.cpp
index 873bcae..ba3aafa 100644
--- a/style/qtcurve.cpp
+++ b/style/qtcurve.cpp
@@ -287,7 +287,7 @@ static TQString kdeHome(bool trinity=false)
if (kdeHome[trinity ? 0 : 1].isEmpty())
{
TQDir homeDir(TQDir::homeDirPath());
- TQString kdeConfDir("/.trinity");
+ TQString kdeConfDir("/.kde");
if (!trinity && homeDir.exists(".kde4"))
kdeConfDir = TQString("/.kde4");
kdeHome[trinity ? 0 : 1] = TQDir::homeDirPath() + kdeConfDir;
@@ -4947,7 +4947,7 @@ void QtCurveStyle::drawControl(ControlElement control, TQPainter *p, TQStyleCont
r.rect(&x, &y, &w, &h);
const TQPushButton *button(static_cast<const TQPushButton *>(widget));
- bool active(button->isOn() || button->isDown()),
+ bool active((elementFlags & CEF_IsOn) || (elementFlags & CEF_IsDown)),
cornArrow(false);
// Shift button contents if pushed.
@@ -4964,8 +4964,8 @@ void QtCurveStyle::drawControl(ControlElement control, TQPainter *p, TQStyleCont
int dx(pixelMetric(PM_MenuButtonIndicator, ceData, elementFlags, widget)),
margin(pixelMetric(PM_ButtonMargin, ceData, elementFlags, widget));
- if(button->iconSet() && !button->iconSet()->isNull() &&
- (dx+button->iconSet()->pixmap(TQIconSet::Small, TQIconSet::Normal, TQIconSet::Off
+ if(!ceData.iconSet.isNull() &&
+ (dx+ceData.iconSet.pixmap(TQIconSet::Small, TQIconSet::Normal, TQIconSet::Off
).width()) >= w )
cornArrow = true; //To little room. Draw the arrow in the corner, don't adjust
//the widget
@@ -4978,17 +4978,17 @@ void QtCurveStyle::drawControl(ControlElement control, TQPainter *p, TQStyleCont
}
// Draw the icon if there is one
- if (button->iconSet() && !button->iconSet()->isNull())
+ if (!ceData.iconSet.isNull())
{
TQIconSet::Mode mode(TQIconSet::Disabled);
TQIconSet::State state(TQIconSet::Off);
- if (button->isEnabled())
- mode = button->hasFocus() ? TQIconSet::Active : TQIconSet::Normal;
- if (button->isToggleButton() && button->isOn())
+ if (elementFlags & CEF_IsEnabled)
+ mode = (elementFlags & CEF_HasFocus) ? TQIconSet::Active : TQIconSet::Normal;
+ if ((elementFlags & CEF_BiState) && (elementFlags & CEF_IsOn))
state = TQIconSet::On;
- TQPixmap pixmap = button->iconSet()->pixmap(TQIconSet::Small, mode, state);
+ TQPixmap pixmap = ceData.iconSet.pixmap(TQIconSet::Small, mode, state);
static const int constSpace(2);
@@ -5031,18 +5031,18 @@ void QtCurveStyle::drawControl(ControlElement control, TQPainter *p, TQStyleCont
// Make the label indicate if the button is a default button or not
int i,
- j(opts.embolden && button->isDefault() ? 2 : 1);
+ j(opts.embolden && (elementFlags & CEF_IsDefault) ? 2 : 1);
bool sidebar(!opts.stdSidebarButtons &&
- ((button->isFlat() && button->inherits("KMultiTabBarTab")) ||
- (button->parentWidget() && button->inherits("Ideal::Button") &&
+ (((elementFlags & CEF_IsFlat) && button->inherits("KMultiTabBarTab")) ||
+ ((elementFlags & CEF_HasParentWidget) && button->inherits("Ideal::Button") &&
button->parentWidget()->inherits("Ideal::ButtonBar"))));
- const TQColor &textCol(sidebar && (button->isOn() || flags&Style_On)
+ const TQColor &textCol(sidebar && ((elementFlags & CEF_IsOn) || flags&Style_On)
? TQApplication::palette().active().highlightedText()
- : button->colorGroup().buttonText());
+ : ceData.colorGroup.buttonText());
for(i=0; i<j; i++)
- drawItem(p, TQRect(x+i, y, w, h), AlignCenter|ShowPrefix, button->colorGroup(),
- button->isEnabled(),
+ drawItem(p, TQRect(x+i, y, w, h), AlignCenter|ShowPrefix, ceData.colorGroup,
+ (elementFlags & CEF_IsEnabled),
button->pixmap(), button->text(), -1, &textCol);
// Draw a focus rect if the button has focus
@@ -5372,18 +5372,17 @@ void QtCurveStyle::drawControl(ControlElement control, TQPainter *p, TQStyleCont
}
case CE_PushButton:
{
- const TQPushButton *button(static_cast<const TQPushButton *>(widget));
bool sidebar(!opts.stdSidebarButtons &&
- ((button->isFlat() && button->inherits("KMultiTabBarTab")) ||
- (button->parentWidget() && button->inherits("Ideal::Button") &&
- button->parentWidget()->inherits("Ideal::ButtonBar"))));
+ (((elementFlags & CEF_IsFlat) && ceData.widgetObjectTypes.contains("KMultiTabBarTab")) ||
+ ((elementFlags & CEF_HasParentWidget) && ceData.widgetObjectTypes.contains("Ideal::Button") &&
+ ceData.parentWidgetData.widgetObjectTypes.contains("Ideal::ButtonBar"))));
if(sidebar)
{
TQRect r2(r);
flags|=TOGGLE_BUTTON;
- if(button->isOn())
+ if(elementFlags & CEF_IsOn)
flags|=Style_On;
const TQColor *use(flags&Style_On ? getSidebarButtons() : buttonColors(cg));
@@ -5431,17 +5430,17 @@ void QtCurveStyle::drawControl(ControlElement control, TQPainter *p, TQStyleCont
{
itsFormMode = isFormWidget(widget);
- if(IND_FONT_COLOR==opts.defBtnIndicator && button->isDefault())
+ if(IND_FONT_COLOR==opts.defBtnIndicator && (elementFlags & CEF_IsDefault))
flags|=Style_ButtonDefault;
- if(button->isToggleButton())
+ if(elementFlags & CEF_BiState)
flags|=TOGGLE_BUTTON;
if(sidebar)
flags|=NO_ETCH_BUTTON;
drawPrimitive(PE_ButtonCommand, p, ceData, elementFlags, r, cg, flags);
- if (button->isDefault() && IND_CORNER==opts.defBtnIndicator)
+ if ((elementFlags & CEF_IsDefault) && IND_CORNER==opts.defBtnIndicator)
drawPrimitive(PE_ButtonDefault, p, ceData, elementFlags, r, cg, flags);
itsFormMode = false;
}
@@ -5471,7 +5470,7 @@ void QtCurveStyle::drawControl(ControlElement control, TQPainter *p, TQStyleCont
cr.height()));
#else
- TQRegion r(checkbox->rect());
+ TQRegion r(ceData.rect);
#endif
r-=visualRect(subRect(SR_CheckBoxIndicator, ceData, elementFlags, widget), ceData, elementFlags);
p->setClipRegion(r);
@@ -5515,11 +5514,11 @@ void QtCurveStyle::drawControl(ControlElement control, TQPainter *p, TQStyleCont
pixelMetric(PM_ExclusiveIndicatorWidth, ceData, elementFlags)+4,
rb.height()));
#else
- TQRegion r(radiobutton->rect());
+ TQRegion r(ceData.rect);
#endif
r-=visualRect(subRect(SR_RadioButtonIndicator, ceData, elementFlags, widget), ceData, elementFlags);
p->setClipRegion(r);
- drawBevelGradient(shade(cg.background(), TO_FACTOR(opts.crHighlight)), p, radiobutton->rect(), true,
+ drawBevelGradient(shade(cg.background(), TO_FACTOR(opts.crHighlight)), p, ceData.rect, true,
false, opts.selectionAppearance, WIDGET_SELECTION);
p->setClipping(false);
}
@@ -5529,7 +5528,7 @@ void QtCurveStyle::drawControl(ControlElement control, TQPainter *p, TQStyleCont
drawItem(p, r, alignment | AlignVCenter | ShowPrefix, cg, flags & Style_Enabled,
radiobutton->pixmap(), radiobutton->text());
- if(radiobutton->hasFocus() && FOCUS_GLOW!=opts.focus)
+ if((elementFlags & CEF_HasFocus) && FOCUS_GLOW!=opts.focus)
drawPrimitive(PE_FocusRect, p, ceData, elementFlags, visualRect(subRect(SR_RadioButtonFocusRect, ceData, elementFlags,
widget), ceData, elementFlags), cg, flags);
break;
@@ -5663,16 +5662,16 @@ void QtCurveStyle::drawComplexControl(ComplexControl control, TQPainter *p, TQSt
break;
}
- const TQToolBar *tb(widget->parentWidget()
- ? ::tqqt_cast<const TQToolBar *>(widget->parentWidget()) : 0L);
+ const TQToolBar *tb((widget)?(widget->parentWidget()
+ ? ::tqqt_cast<const TQToolBar *>(widget->parentWidget()) : 0L) : 0L);
bool onControlButtons(false),
onExtender(!tb &&
- widget->parentWidget() &&
- widget->parentWidget()->inherits( "TQToolBarExtensionWidget") &&
+ (elementFlags & CEF_HasParentWidget) &&
+ ceData.parentWidgetData.widgetObjectTypes.contains( "TQToolBarExtensionWidget") &&
::tqqt_cast<TQToolBar *>(widget->parentWidget()->parentWidget())),
isDWClose(!tb && !onExtender &&
- widget->parentWidget() &&
- widget->parentWidget()->inherits( TQDOCKWINDOWHANDLE_OBJECT_NAME_STRING));
+ (elementFlags & CEF_HasParentWidget) &&
+ ceData.parentWidgetData.widgetObjectTypes.contains( TQDOCKWINDOWHANDLE_OBJECT_NAME_STRING));
if(isDWClose)
{
@@ -5682,8 +5681,8 @@ void QtCurveStyle::drawComplexControl(ComplexControl control, TQPainter *p, TQSt
bflags|=DW_CLOSE_BUTTON;
}
- if (!tb && !onExtender && widget->parentWidget() &&
- !qstrcmp(widget->parentWidget()->name(), "qt_maxcontrols"))
+ if (!tb && !onExtender && (elementFlags & CEF_HasParentWidget) &&
+ !qstrcmp(ceData.parentWidgetData.name.ascii(), "qt_maxcontrols"))
onControlButtons = true;
if(active & SC_ToolButton)
@@ -5696,7 +5695,7 @@ void QtCurveStyle::drawComplexControl(ComplexControl control, TQPainter *p, TQSt
if(controls&SC_ToolButton)
{
if(onControlButtons ||
- (toolbutton->parentWidget() && toolbutton->parentWidget()->parentWidget() &&
+ ((elementFlags & CEF_HasParentWidget) && toolbutton && toolbutton->parentWidget()->parentWidget() &&
::tqqt_cast<const TQMenuBar *>(toolbutton->parentWidget()->parentWidget())))
bflags|=NO_ETCH_BUTTON;
@@ -5713,7 +5712,7 @@ void QtCurveStyle::drawComplexControl(ComplexControl control, TQPainter *p, TQSt
bflags |= Style_Horizontal;
if(tb) {
- if(Qt::Vertical==tb->orientation()) {
+ if(TQt::Vertical==ceData.toolBarData.orientation) {
bflags|=VERTICAL_TB_BUTTON;
}
else {
@@ -5721,25 +5720,25 @@ void QtCurveStyle::drawComplexControl(ComplexControl control, TQPainter *p, TQSt
}
}
- if(toolbutton->isToggleButton())
+ if(elementFlags & CEF_BiState)
bflags|=TOGGLE_BUTTON;
drawPrimitive(PE_ButtonTool, p, ceData, elementFlags, button, cg, bflags, data);
}
// Check whether to draw a background pixmap
- else if(APP_MACTOR!=itsThemedApp && toolbutton->parentWidget() &&
- toolbutton->parentWidget()->backgroundPixmap() &&
+ else if(APP_MACTOR!=itsThemedApp && (elementFlags & CEF_HasParentWidget) &&
+ toolbutton && toolbutton->parentWidget()->backgroundPixmap() &&
!toolbutton->parentWidget()->backgroundPixmap()->isNull())
p->drawTiledPixmap(r, *(toolbutton->parentWidget()->backgroundPixmap()),
toolbutton->pos());
- else if(widget->parent())
+ else if(elementFlags & CEF_HasParentWidget)
{
TQToolBar *tb(0L);
- if(::tqqt_cast<const TQToolBar *>(widget->parent()))
+ if(::tqqt_cast<const TQToolBar *>((widget)?widget->parent():0L))
tb=(TQToolBar*)widget->parent();
- else if(widget->parent()->inherits("TQToolBarExtensionWidget"))
+ else if(ceData.parentWidgetData.widgetObjectTypes.contains("TQToolBarExtensionWidget"))
{
TQWidget *parent=(TQWidget*)widget->parent();
@@ -5748,7 +5747,7 @@ void QtCurveStyle::drawComplexControl(ComplexControl control, TQPainter *p, TQSt
if(tb)
{
- TQRect tbr(tb->rect());
+ TQRect tbr(ceData.parentWidgetData.rect);
bool horiz(TQt::Horizontal==ceData.orientation);
if(!IS_FLAT(opts.toolbarAppearance)) {
@@ -5772,9 +5771,9 @@ void QtCurveStyle::drawComplexControl(ComplexControl control, TQPainter *p, TQSt
::drawArrow(p, menuarea, MO_ARROW(cg.buttonText()), PE_ArrowDown, opts, true);
}
- if(toolbutton->hasFocus() && !toolbutton->focusProxy())
+ if((elementFlags & CEF_HasFocus) && !(elementFlags & CEF_HasFocusProxy))
{
- TQRect fr(toolbutton->rect());
+ TQRect fr(ceData.rect);
if(FOCUS_FULL!=opts.focus) {
fr.addCoords(2, 2,-2,-2);
}