src/gui/styles/qstylesheetstyle.cpp
changeset 30 5dc02b23752f
parent 23 89e065397ea6
child 33 3e2da88830cd
equal deleted inserted replaced
29:b72c6db6890b 30:5dc02b23752f
  1063         if (flags & Padding) {
  1063         if (flags & Padding) {
  1064             const int *p = box()->paddings;
  1064             const int *p = box()->paddings;
  1065             r.adjust(-p[LeftEdge], -p[TopEdge], p[RightEdge], p[BottomEdge]);
  1065             r.adjust(-p[LeftEdge], -p[TopEdge], p[RightEdge], p[BottomEdge]);
  1066         }
  1066         }
  1067     }
  1067     }
  1068     if (!hasNativeBorder() && (flags & Border)) {
  1068     if (hasBorder() && (flags & Border)) {
  1069         const int *b = border()->borders;
  1069         const int *b = border()->borders;
  1070         r.adjust(-b[LeftEdge], -b[TopEdge], b[RightEdge], b[BottomEdge]);
  1070         r.adjust(-b[LeftEdge], -b[TopEdge], b[RightEdge], b[BottomEdge]);
  1071     }
  1071     }
  1072     return r;
  1072     return r;
  1073 }
  1073 }
  1350 {
  1350 {
  1351     if (bg && bg->brush.style() != Qt::NoBrush) {
  1351     if (bg && bg->brush.style() != Qt::NoBrush) {
  1352         if (br != QPalette::NoRole)
  1352         if (br != QPalette::NoRole)
  1353             p->setBrush(br, bg->brush);
  1353             p->setBrush(br, bg->brush);
  1354         p->setBrush(QPalette::Window, bg->brush);
  1354         p->setBrush(QPalette::Window, bg->brush);
       
  1355         if (bg->brush.style() == Qt::SolidPattern) {
       
  1356             p->setBrush(QPalette::Light, bg->brush.color().lighter(115));
       
  1357             p->setBrush(QPalette::Midlight, bg->brush.color().lighter(107));
       
  1358             p->setBrush(QPalette::Dark, bg->brush.color().darker(150));
       
  1359             p->setBrush(QPalette::Shadow, bg->brush.color().darker(300));
       
  1360         }
  1355     }
  1361     }
  1356 
  1362 
  1357     if (!hasPalette())
  1363     if (!hasPalette())
  1358         return;
  1364         return;
  1359 
  1365 
  2535 {
  2541 {
  2536     struct RuleRoleMap {
  2542     struct RuleRoleMap {
  2537         int state;
  2543         int state;
  2538         QPalette::ColorGroup group;
  2544         QPalette::ColorGroup group;
  2539     } map[3] = {
  2545     } map[3] = {
  2540         { PseudoClass_Active | PseudoClass_Enabled, QPalette::Active },
  2546         { int(PseudoClass_Active | PseudoClass_Enabled), QPalette::Active },
  2541         { PseudoClass_Disabled, QPalette::Disabled },
  2547         { PseudoClass_Disabled, QPalette::Disabled },
  2542         { PseudoClass_Enabled, QPalette::Inactive }
  2548         { PseudoClass_Enabled, QPalette::Inactive }
  2543     };
  2549     };
  2544 
  2550 
  2545     QPalette p = w->palette();
  2551     QPalette p = w->palette();
  3168 
  3174 
  3169                 QRenderRule subRule1 = renderRule(w, opt, PseudoElement_SliderSubPage);
  3175                 QRenderRule subRule1 = renderRule(w, opt, PseudoElement_SliderSubPage);
  3170                 if (subRule1.hasDrawable()) {
  3176                 if (subRule1.hasDrawable()) {
  3171                     QRect r(gr.topLeft(),
  3177                     QRect r(gr.topLeft(),
  3172                             slider->orientation == Qt::Horizontal
  3178                             slider->orientation == Qt::Horizontal
  3173                                 ? QPoint(hr.x()+hr.width()/2, gr.y()+gr.height())
  3179                                 ? QPoint(hr.x()+hr.width()/2, gr.y()+gr.height() - 1)
  3174                                 : QPoint(gr.x()+gr.width(), hr.y()+hr.height()/2));
  3180                                 : QPoint(gr.x()+gr.width() - 1, hr.y()+hr.height()/2));
  3175                     subRule1.drawRule(p, r);
  3181                     subRule1.drawRule(p, r);
  3176                 }
  3182                 }
  3177 
  3183 
  3178                 QRenderRule subRule2 = renderRule(w, opt, PseudoElement_SliderAddPage);
  3184                 QRenderRule subRule2 = renderRule(w, opt, PseudoElement_SliderAddPage);
  3179                 if (subRule2.hasDrawable()) {
  3185                 if (subRule2.hasDrawable()) {
  3456         }
  3462         }
  3457         return;
  3463         return;
  3458 
  3464 
  3459     case CE_RadioButton:
  3465     case CE_RadioButton:
  3460     case CE_CheckBox:
  3466     case CE_CheckBox:
  3461         rule.drawRule(p, opt->rect);
  3467         if (rule.hasBox() || !rule.hasNativeBorder() || rule.hasDrawable() || hasStyleRule(w, PseudoElement_Indicator)) {
  3462         ParentStyle::drawControl(ce, opt, p, w);
  3468             rule.drawRule(p, opt->rect);
  3463         return;
  3469             ParentStyle::drawControl(ce, opt, p, w);
  3464 
  3470             return;
       
  3471         } else if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
       
  3472             QStyleOptionButton butOpt(*btn);
       
  3473             rule.configurePalette(&butOpt.palette, QPalette::ButtonText, QPalette::Button);
       
  3474             baseStyle()->drawControl(ce, &butOpt, p, w);
       
  3475             return;
       
  3476         }
       
  3477         break;
  3465     case CE_RadioButtonLabel:
  3478     case CE_RadioButtonLabel:
  3466     case CE_CheckBoxLabel:
  3479     case CE_CheckBoxLabel:
  3467         if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
  3480         if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
  3468             QStyleOptionButton butOpt(*btn);
  3481             QStyleOptionButton butOpt(*btn);
  3469             rule.configurePalette(&butOpt.palette, QPalette::ButtonText, QPalette::Button);
  3482             rule.configurePalette(&butOpt.palette, QPalette::ButtonText, QPalette::Button);