Diffstat (limited to 'noncore/styles/liquid/liquid.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/styles/liquid/liquid.cpp | 7 |
1 files changed, 0 insertions, 7 deletions
diff --git a/noncore/styles/liquid/liquid.cpp b/noncore/styles/liquid/liquid.cpp index daac22c..e6d8310 100644 --- a/noncore/styles/liquid/liquid.cpp +++ b/noncore/styles/liquid/liquid.cpp | |||
@@ -1011,340 +1011,333 @@ public: | |||
1011 | p.restore(); | 1011 | p.restore(); |
1012 | } | 1012 | } |
1013 | if ( event->rect().intersects( contentsRect() )) { | 1013 | if ( event->rect().intersects( contentsRect() )) { |
1014 | p.setClipRegion( event->region().intersect( contentsRect() ) ); | 1014 | p.setClipRegion( event->region().intersect( contentsRect() ) ); |
1015 | 1015 | ||
1016 | int x, y, w, h; | 1016 | int x, y, w, h; |
1017 | contentsRect ( ). rect ( &x, &y, &w, &h ); | 1017 | contentsRect ( ). rect ( &x, &y, &w, &h ); |
1018 | 1018 | ||
1019 | int prog = progress ( ); | 1019 | int prog = progress ( ); |
1020 | int total = totalSteps ( ); | 1020 | int total = totalSteps ( ); |
1021 | if ( prog < 0 ) | 1021 | if ( prog < 0 ) |
1022 | prog = 0; | 1022 | prog = 0; |
1023 | if ( total <= 0 ) | 1023 | if ( total <= 0 ) |
1024 | total = 1; | 1024 | total = 1; |
1025 | int bw = w * prog / total; | 1025 | int bw = w * prog / total; |
1026 | if ( bw > w ) | 1026 | if ( bw > w ) |
1027 | bw = w; | 1027 | bw = w; |
1028 | 1028 | ||
1029 | p.setPen(g.button().dark(130)); | 1029 | p.setPen(g.button().dark(130)); |
1030 | p.drawRect(x, y, bw, h); | 1030 | p.drawRect(x, y, bw, h); |
1031 | p.setPen(g.button().light(120)); | 1031 | p.setPen(g.button().light(120)); |
1032 | p.drawRect(x+1, y+1, bw-2, h-2); | 1032 | p.drawRect(x+1, y+1, bw-2, h-2); |
1033 | 1033 | ||
1034 | if(bw >= 4 && h >= 4 && pix) | 1034 | if(bw >= 4 && h >= 4 && pix) |
1035 | p.drawTiledPixmap(x+2, y+2, bw-4, h-4, *pix); | 1035 | p.drawTiledPixmap(x+2, y+2, bw-4, h-4, *pix); |
1036 | 1036 | ||
1037 | if ( progress ( )>= 0 && totalSteps ( ) > 0 ) { | 1037 | if ( progress ( )>= 0 && totalSteps ( ) > 0 ) { |
1038 | QString pstr; | 1038 | QString pstr; |
1039 | pstr. sprintf ( "%d%%", 100 * progress()/totalSteps ()); | 1039 | pstr. sprintf ( "%d%%", 100 * progress()/totalSteps ()); |
1040 | p. setPen ( g.text());//g.highlightedText ( )); | 1040 | p. setPen ( g.text());//g.highlightedText ( )); |
1041 | p. drawText (x,y,w-1,h-1,AlignCenter,pstr); | 1041 | p. drawText (x,y,w-1,h-1,AlignCenter,pstr); |
1042 | } | 1042 | } |
1043 | } | 1043 | } |
1044 | } | 1044 | } |
1045 | }; | 1045 | }; |
1046 | 1046 | ||
1047 | 1047 | ||
1048 | /* | 1048 | /* |
1049 | * The same for QToolButton: | 1049 | * The same for QToolButton: |
1050 | * TT hardcoded the drawing of the focus rect ... | 1050 | * TT hardcoded the drawing of the focus rect ... |
1051 | * | 1051 | * |
1052 | * - sandman | 1052 | * - sandman |
1053 | */ | 1053 | */ |
1054 | 1054 | ||
1055 | 1055 | ||
1056 | class HackToolButton : public QToolButton { | 1056 | class HackToolButton : public QToolButton { |
1057 | public: | 1057 | public: |
1058 | HackToolButton ( ); | 1058 | HackToolButton ( ); |
1059 | 1059 | ||
1060 | void paint ( QPaintEvent *ev ) | 1060 | void paint ( QPaintEvent *ev ) |
1061 | { | 1061 | { |
1062 | erase ( ev-> region ( )); | 1062 | erase ( ev-> region ( )); |
1063 | QPainter p ( this ); | 1063 | QPainter p ( this ); |
1064 | style ( ). drawToolButton ( this, &p ); | 1064 | style ( ). drawToolButton ( this, &p ); |
1065 | drawButtonLabel ( &p ); | 1065 | drawButtonLabel ( &p ); |
1066 | } | 1066 | } |
1067 | }; | 1067 | }; |
1068 | 1068 | ||
1069 | /* | 1069 | /* |
1070 | * This is a fun method ;-) Here's an overview. KToolBar grabs resize to | 1070 | * This is a fun method ;-) Here's an overview. KToolBar grabs resize to |
1071 | * force everything to erase and repaint on resize. This is going away, I'm | 1071 | * force everything to erase and repaint on resize. This is going away, I'm |
1072 | * trying to get shaped widgets to work right without masking. QPushButton, | 1072 | * trying to get shaped widgets to work right without masking. QPushButton, |
1073 | * QComboBox, and Panel applet handles capture mouse enter and leaves in order | 1073 | * QComboBox, and Panel applet handles capture mouse enter and leaves in order |
1074 | * to set the highlightwidget and repaint for mouse hovers. CheckBoxes and | 1074 | * to set the highlightwidget and repaint for mouse hovers. CheckBoxes and |
1075 | * RadioButtons need to do this differently. Qt buffers these in pixmaps and | 1075 | * RadioButtons need to do this differently. Qt buffers these in pixmaps and |
1076 | * caches them in QPixmapCache, which is bad for doing things like hover | 1076 | * caches them in QPixmapCache, which is bad for doing things like hover |
1077 | * because the style methods aren't called in paintEvents if everything | 1077 | * because the style methods aren't called in paintEvents if everything |
1078 | * is cached. We use our own Paint event handler instead. Taskbuttons and | 1078 | * is cached. We use our own Paint event handler instead. Taskbuttons and |
1079 | * pager buttons draw into a pixmap buffer, so we handle those with palette | 1079 | * pager buttons draw into a pixmap buffer, so we handle those with palette |
1080 | * modifications. For QHeader, different header items are actually one widget | 1080 | * modifications. For QHeader, different header items are actually one widget |
1081 | * that draws multiple items, so we need to check which ID is hightlighted | 1081 | * that draws multiple items, so we need to check which ID is hightlighted |
1082 | * and draw it. Finally, we also check enter and leave events for QLineEdit, | 1082 | * and draw it. Finally, we also check enter and leave events for QLineEdit, |
1083 | * since if it's inside a combobox we want to highlight the combobox during | 1083 | * since if it's inside a combobox we want to highlight the combobox during |
1084 | * hovering in the edit. | 1084 | * hovering in the edit. |
1085 | */ | 1085 | */ |
1086 | bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev) | 1086 | bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev) |
1087 | { | 1087 | { |
1088 | if(obj->inherits("QToolBar")){ | 1088 | if(obj->inherits("QToolBar")){ |
1089 | if(ev->type() == QEvent::Resize){ | 1089 | if(ev->type() == QEvent::Resize){ |
1090 | const QObjectList *tbChildList = obj->children(); | 1090 | const QObjectList *tbChildList = obj->children(); |
1091 | QObjectListIt it(*tbChildList); | 1091 | QObjectListIt it(*tbChildList); |
1092 | QObject *child; | 1092 | QObject *child; |
1093 | while((child = it.current()) != NULL){ | 1093 | while((child = it.current()) != NULL){ |
1094 | ++it; | 1094 | ++it; |
1095 | if(child->isWidgetType()) | 1095 | if(child->isWidgetType()) |
1096 | ((QWidget *)child)->repaint(true); | 1096 | ((QWidget *)child)->repaint(true); |
1097 | } | 1097 | } |
1098 | 1098 | ||
1099 | } | 1099 | } |
1100 | } | 1100 | } |
1101 | else if(obj->inherits("QToolButton")){ | 1101 | else if(obj->inherits("QToolButton")){ |
1102 | QToolButton *btn = (QToolButton *)obj; | 1102 | QToolButton *btn = (QToolButton *)obj; |
1103 | if(ev->type() == QEvent::FocusIn ){ // && !btn-> autoRaise () | 1103 | if(ev->type() == QEvent::FocusIn ){ // && !btn-> autoRaise () |
1104 | if(btn->isEnabled()){ | 1104 | if(btn->isEnabled()){ |
1105 | highlightWidget = btn; | 1105 | highlightWidget = btn; |
1106 | btn->repaint(false); | 1106 | btn->repaint(false); |
1107 | |||
1108 | qDebug ( "TB FOCUS IN [%p]", btn ); | ||
1109 | } | 1107 | } |
1110 | } | 1108 | } |
1111 | else if(ev->type() == QEvent::FocusOut ){ | 1109 | else if(ev->type() == QEvent::FocusOut ){ |
1112 | if(btn == highlightWidget){ | 1110 | if(btn == highlightWidget){ |
1113 | highlightWidget = NULL; | 1111 | highlightWidget = NULL; |
1114 | btn->repaint(false); | 1112 | btn->repaint(false); |
1115 | |||
1116 | qDebug ( "TB FOCUS OUT [%p]", btn ); | ||
1117 | } | 1113 | } |
1118 | } | 1114 | } |
1119 | else if(ev->type() == QEvent::Paint) { | 1115 | else if(ev->type() == QEvent::Paint) { |
1120 | (( HackToolButton *) btn )-> paint ((QPaintEvent *) ev ); | 1116 | (( HackToolButton *) btn )-> paint ((QPaintEvent *) ev ); |
1121 | return true; | 1117 | return true; |
1122 | } | 1118 | } |
1123 | } | 1119 | } |
1124 | else if(obj->inherits("QRadioButton") || obj->inherits("QCheckBox")){ | 1120 | else if(obj->inherits("QRadioButton") || obj->inherits("QCheckBox")){ |
1125 | QButton *btn = (QButton *)obj; | 1121 | QButton *btn = (QButton *)obj; |
1126 | bool isRadio = obj->inherits("QRadioButton"); | 1122 | bool isRadio = obj->inherits("QRadioButton"); |
1127 | if(ev->type() == QEvent::Paint){ | 1123 | if(ev->type() == QEvent::Paint){ |
1128 | //if(btn->autoMask()) | 1124 | //if(btn->autoMask()) |
1129 | btn->erase(); | 1125 | btn->erase(); |
1130 | QPainter p; | 1126 | QPainter p; |
1131 | p.begin(btn); | 1127 | p.begin(btn); |
1132 | QFontMetrics fm = btn->fontMetrics(); | 1128 | QFontMetrics fm = btn->fontMetrics(); |
1133 | QSize lsz = fm.size(ShowPrefix, btn->text()); | 1129 | QSize lsz = fm.size(ShowPrefix, btn->text()); |
1134 | QSize sz = isRadio ? exclusiveIndicatorSize() | 1130 | QSize sz = isRadio ? exclusiveIndicatorSize() |
1135 | : indicatorSize(); | 1131 | : indicatorSize(); |
1136 | 1132 | ||
1137 | /* | 1133 | /* |
1138 | if(btn->hasFocus()){ | 1134 | if(btn->hasFocus()){ |
1139 | QRect r = QRect(0, 0, btn->width(), btn->height()); | 1135 | QRect r = QRect(0, 0, btn->width(), btn->height()); |
1140 | p.setPen(btn->colorGroup().button().dark(140)); | 1136 | p.setPen(btn->colorGroup().button().dark(140)); |
1141 | p.drawLine(r.x()+1, r.y(), r.right()-1, r.y()); | 1137 | p.drawLine(r.x()+1, r.y(), r.right()-1, r.y()); |
1142 | p.drawLine(r.x(), r.y()+1, r.x(), r.bottom()-1); | 1138 | p.drawLine(r.x(), r.y()+1, r.x(), r.bottom()-1); |
1143 | p.drawLine(r.right(), r.y()+1, r.right(), r.bottom()-1); | 1139 | p.drawLine(r.right(), r.y()+1, r.right(), r.bottom()-1); |
1144 | p.drawLine(r.x()+1, r.bottom(), r.right()-1, r.bottom()); | 1140 | p.drawLine(r.x()+1, r.bottom(), r.right()-1, r.bottom()); |
1145 | } | 1141 | } |
1146 | */ | 1142 | */ |
1147 | int x = 0; | 1143 | int x = 0; |
1148 | int y = (btn->height()-lsz.height()+fm.height()-sz.height())/2; | 1144 | int y = (btn->height()-lsz.height()+fm.height()-sz.height())/2; |
1149 | if(isRadio) | 1145 | if(isRadio) |
1150 | drawExclusiveIndicator(&p, x, y, sz.width(), sz.height(), | 1146 | drawExclusiveIndicator(&p, x, y, sz.width(), sz.height(), |
1151 | btn->colorGroup(), btn->isOn(), | 1147 | btn->colorGroup(), btn->isOn(), |
1152 | btn->isDown(), btn->isEnabled()); | 1148 | btn->isDown(), btn->isEnabled()); |
1153 | else | 1149 | else |
1154 | drawIndicator(&p, x, y, sz.width(), sz.height(), | 1150 | drawIndicator(&p, x, y, sz.width(), sz.height(), |
1155 | btn->colorGroup(), btn->state(), btn->isDown(), | 1151 | btn->colorGroup(), btn->state(), btn->isDown(), |
1156 | btn->isEnabled()); | 1152 | btn->isEnabled()); |
1157 | x = sz.width() + 6; | 1153 | x = sz.width() + 6; |
1158 | y = 0; | 1154 | y = 0; |
1159 | drawItem(&p, sz.width()+6+1, 0, btn->width()-(sz.width()+6+1), | 1155 | drawItem(&p, sz.width()+6+1, 0, btn->width()-(sz.width()+6+1), |
1160 | btn->height(), AlignLeft|AlignVCenter|ShowPrefix, | 1156 | btn->height(), AlignLeft|AlignVCenter|ShowPrefix, |
1161 | btn->colorGroup(), btn->isEnabled(), | 1157 | btn->colorGroup(), btn->isEnabled(), |
1162 | btn->pixmap(), btn->text()); | 1158 | btn->pixmap(), btn->text()); |
1163 | p.end(); | 1159 | p.end(); |
1164 | return(true); | 1160 | return(true); |
1165 | } | 1161 | } |
1166 | } | 1162 | } |
1167 | else if(obj->inherits("QHeader")){ | 1163 | else if(obj->inherits("QHeader")){ |
1168 | QHeader *hw = (QHeader *)obj; | 1164 | QHeader *hw = (QHeader *)obj; |
1169 | if(ev->type() == QEvent::Enter){ | 1165 | if(ev->type() == QEvent::Enter){ |
1170 | currentHeader = hw; | 1166 | currentHeader = hw; |
1171 | headerHoverID = -1; | 1167 | headerHoverID = -1; |
1172 | } | 1168 | } |
1173 | else if(ev->type() == QEvent::Leave){ | 1169 | else if(ev->type() == QEvent::Leave){ |
1174 | currentHeader = NULL; | 1170 | currentHeader = NULL; |
1175 | if(headerHoverID != -1){ | 1171 | if(headerHoverID != -1){ |
1176 | hw->repaint(hw->sectionPos(headerHoverID), 0, | 1172 | hw->repaint(hw->sectionPos(headerHoverID), 0, |
1177 | hw->sectionSize(headerHoverID), hw->height()); | 1173 | hw->sectionSize(headerHoverID), hw->height()); |
1178 | } | 1174 | } |
1179 | headerHoverID = -1; | 1175 | headerHoverID = -1; |
1180 | } | 1176 | } |
1181 | else if(ev->type() == QEvent::MouseMove){ | 1177 | else if(ev->type() == QEvent::MouseMove){ |
1182 | QMouseEvent *me = (QMouseEvent *)ev; | 1178 | QMouseEvent *me = (QMouseEvent *)ev; |
1183 | int oldHeader = headerHoverID; | 1179 | int oldHeader = headerHoverID; |
1184 | headerHoverID = hw->sectionAt(me->x()); | 1180 | headerHoverID = hw->sectionAt(me->x()); |
1185 | if(oldHeader != headerHoverID){ | 1181 | if(oldHeader != headerHoverID){ |
1186 | // reset old header | 1182 | // reset old header |
1187 | if(oldHeader != -1){ | 1183 | if(oldHeader != -1){ |
1188 | hw->repaint(hw->sectionPos(oldHeader), 0, | 1184 | hw->repaint(hw->sectionPos(oldHeader), 0, |
1189 | hw->sectionSize(oldHeader), hw->height()); | 1185 | hw->sectionSize(oldHeader), hw->height()); |
1190 | } | 1186 | } |
1191 | if(headerHoverID != -1){ | 1187 | if(headerHoverID != -1){ |
1192 | hw->repaint(hw->sectionPos(headerHoverID), 0, | 1188 | hw->repaint(hw->sectionPos(headerHoverID), 0, |
1193 | hw->sectionSize(headerHoverID), hw->height()); | 1189 | hw->sectionSize(headerHoverID), hw->height()); |
1194 | } | 1190 | } |
1195 | } | 1191 | } |
1196 | } | 1192 | } |
1197 | } | 1193 | } |
1198 | else if (obj-> inherits( "QProgressBar" )) { | 1194 | else if (obj-> inherits( "QProgressBar" )) { |
1199 | if ( ev->type() == QEvent::Paint ) { | 1195 | if ( ev->type() == QEvent::Paint ) { |
1200 | HackProgressBar *p = (HackProgressBar *) obj; | 1196 | HackProgressBar *p = (HackProgressBar *) obj; |
1201 | const QColorGroup &g = p-> colorGroup ( ); | 1197 | const QColorGroup &g = p-> colorGroup ( ); |
1202 | 1198 | ||
1203 | QPixmap *pix = bevelFillDict.find(g.button().dark(120).rgb()); | 1199 | QPixmap *pix = bevelFillDict.find(g.button().dark(120).rgb()); |
1204 | if(!pix){ | 1200 | if(!pix){ |
1205 | int h, s, v; | 1201 | int h, s, v; |
1206 | g.button().dark(120).hsv(&h, &s, &v); | 1202 | g.button().dark(120).hsv(&h, &s, &v); |
1207 | pix = new QPixmap(*bevelFillPix); | 1203 | pix = new QPixmap(*bevelFillPix); |
1208 | adjustHSV(*pix, h, s, v); | 1204 | adjustHSV(*pix, h, s, v); |
1209 | bevelFillDict.insert(g.button().dark(120).rgb(), pix); | 1205 | bevelFillDict.insert(g.button().dark(120).rgb(), pix); |
1210 | } | 1206 | } |
1211 | p-> paint ((QPaintEvent *) ev, g, pix ); | 1207 | p-> paint ((QPaintEvent *) ev, g, pix ); |
1212 | return true; | 1208 | return true; |
1213 | } | 1209 | } |
1214 | } | 1210 | } |
1215 | return false ; | 1211 | return false ; |
1216 | } | 1212 | } |
1217 | 1213 | ||
1218 | void LiquidStyle::drawButton(QPainter *p, int x, int y, int w, int h, | 1214 | void LiquidStyle::drawButton(QPainter *p, int x, int y, int w, int h, |
1219 | const QColorGroup &g, bool sunken, | 1215 | const QColorGroup &g, bool sunken, |
1220 | const QBrush *) | 1216 | const QBrush *) |
1221 | { | 1217 | { |
1222 | drawRoundButton(p, sunken ? g.background() : g.button(), g.background(), | 1218 | drawRoundButton(p, sunken ? g.background() : g.button(), g.background(), |
1223 | x, y, w, h); | 1219 | x, y, w, h); |
1224 | } | 1220 | } |
1225 | 1221 | ||
1226 | void LiquidStyle::drawToolButton(QPainter *p, int x, int y, int w, int h, | 1222 | void LiquidStyle::drawToolButton(QPainter *p, int x, int y, int w, int h, |
1227 | const QColorGroup &g, bool sunken, | 1223 | const QColorGroup &g, bool sunken, |
1228 | const QBrush *) | 1224 | const QBrush *) |
1229 | { | 1225 | { |
1230 | if(p->device()->devType() != QInternal::Widget){ | 1226 | if(p->device()->devType() != QInternal::Widget){ |
1231 | // drawing into a temp pixmap, don't use mask | 1227 | // drawing into a temp pixmap, don't use mask |
1232 | QColor c = sunken ? g.button() : g.background(); | 1228 | QColor c = sunken ? g.button() : g.background(); |
1233 | p->setPen(c.dark(130)); | 1229 | p->setPen(c.dark(130)); |
1234 | p->drawRect(x, y, w, h); | 1230 | p->drawRect(x, y, w, h); |
1235 | p->setPen(c.light(105)); | 1231 | p->setPen(c.light(105)); |
1236 | p->drawRect(x+1, y+1, w-2, h-2); | 1232 | p->drawRect(x+1, y+1, w-2, h-2); |
1237 | 1233 | ||
1238 | 1234 | ||
1239 | // fill | 1235 | // fill |
1240 | QPixmap *pix = bevelFillDict.find(c.rgb()); | 1236 | QPixmap *pix = bevelFillDict.find(c.rgb()); |
1241 | if(!pix){ | 1237 | if(!pix){ |
1242 | int h, s, v; | 1238 | int h, s, v; |
1243 | c.hsv(&h, &s, &v); | 1239 | c.hsv(&h, &s, &v); |
1244 | pix = new QPixmap(*bevelFillPix); | 1240 | pix = new QPixmap(*bevelFillPix); |
1245 | adjustHSV(*pix, h, s, v); | 1241 | adjustHSV(*pix, h, s, v); |
1246 | bevelFillDict.insert(c.rgb(), pix); | 1242 | bevelFillDict.insert(c.rgb(), pix); |
1247 | } | 1243 | } |
1248 | 1244 | ||
1249 | p->drawTiledPixmap(x+2, y+2, w-4, h-4, *pix); | 1245 | p->drawTiledPixmap(x+2, y+2, w-4, h-4, *pix); |
1250 | qDebug ( "DRAW TOOLBUTTON IN PIXMAP" ); | ||
1251 | } | 1246 | } |
1252 | else{ | 1247 | else{ |
1253 | qDebug ( "DRAW TOOLBUTTON sunken=%d/high=%p/device=%p", sunken, highlightWidget,p->device() ); | ||
1254 | |||
1255 | drawClearBevel(p, x, y, w, h, sunken ? g.button() : | 1248 | drawClearBevel(p, x, y, w, h, sunken ? g.button() : |
1256 | highlightWidget == p->device() ? g.button().light(110) : | 1249 | highlightWidget == p->device() ? g.button().light(110) : |
1257 | g.background(), g.background()); | 1250 | g.background(), g.background()); |
1258 | } | 1251 | } |
1259 | } | 1252 | } |
1260 | 1253 | ||
1261 | void LiquidStyle::drawPushButton(QPushButton *btn, QPainter *p) | 1254 | void LiquidStyle::drawPushButton(QPushButton *btn, QPainter *p) |
1262 | { | 1255 | { |
1263 | QRect r = btn->rect(); | 1256 | QRect r = btn->rect(); |
1264 | bool sunken = btn->isOn() || btn->isDown(); | 1257 | bool sunken = btn->isOn() || btn->isDown(); |
1265 | QColorGroup g = btn->colorGroup(); | 1258 | QColorGroup g = btn->colorGroup(); |
1266 | 1259 | ||
1267 | 1260 | ||
1268 | //int dw = buttonDefaultIndicatorWidth(); | 1261 | //int dw = buttonDefaultIndicatorWidth(); |
1269 | if(btn->hasFocus() || btn->isDefault()){ | 1262 | if(btn->hasFocus() || btn->isDefault()){ |
1270 | QColor c = btn->hasFocus() ? g.button().light(110) : g.background(); | 1263 | QColor c = btn->hasFocus() ? g.button().light(110) : g.background(); |
1271 | QPixmap *pix = bevelFillDict.find(c.rgb()); | 1264 | QPixmap *pix = bevelFillDict.find(c.rgb()); |
1272 | if(!pix){ | 1265 | if(!pix){ |
1273 | int h, s, v; | 1266 | int h, s, v; |
1274 | c.hsv(&h, &s, &v); | 1267 | c.hsv(&h, &s, &v); |
1275 | pix = new QPixmap(*bevelFillPix); | 1268 | pix = new QPixmap(*bevelFillPix); |
1276 | adjustHSV(*pix, h, s, v); | 1269 | adjustHSV(*pix, h, s, v); |
1277 | bevelFillDict.insert(c.rgb(), pix); | 1270 | bevelFillDict.insert(c.rgb(), pix); |
1278 | } | 1271 | } |
1279 | p->setPen(c.dark(150)); | 1272 | p->setPen(c.dark(150)); |
1280 | p->drawLine(r.x()+1, r.y(), r.right()-1, r.y()); | 1273 | p->drawLine(r.x()+1, r.y(), r.right()-1, r.y()); |
1281 | p->drawLine(r.x(), r.y()+1, r.x(), r.bottom()-1); | 1274 | p->drawLine(r.x(), r.y()+1, r.x(), r.bottom()-1); |
1282 | p->drawLine(r.right(), r.y()+1, r.right(), r.bottom()-1); | 1275 | p->drawLine(r.right(), r.y()+1, r.right(), r.bottom()-1); |
1283 | p->drawLine(r.x()+1, r.bottom(), r.right()-1, r.bottom()); | 1276 | p->drawLine(r.x()+1, r.bottom(), r.right()-1, r.bottom()); |
1284 | p->drawTiledPixmap(r.x()+1, r.y()+1, r.width()-2, r.height()-2, *pix); | 1277 | p->drawTiledPixmap(r.x()+1, r.y()+1, r.width()-2, r.height()-2, *pix); |
1285 | } | 1278 | } |
1286 | 1279 | ||
1287 | QColor newColor = btn == highlightWidget || sunken ? | 1280 | QColor newColor = btn == highlightWidget || sunken ? |
1288 | g.button().light(120) : g.button(); | 1281 | g.button().light(120) : g.button(); |
1289 | 1282 | ||
1290 | drawRoundButton(p, newColor, g.background(), | 1283 | drawRoundButton(p, newColor, g.background(), |
1291 | r.x(), r.y(), r.width(), r.height(), !btn->autoMask(), | 1284 | r.x(), r.y(), r.width(), r.height(), !btn->autoMask(), |
1292 | sunken, btn->isDefault() || btn->autoDefault() || btn->hasFocus(), | 1285 | sunken, btn->isDefault() || btn->autoDefault() || btn->hasFocus(), |
1293 | btn->autoMask()); | 1286 | btn->autoMask()); |
1294 | } | 1287 | } |
1295 | 1288 | ||
1296 | void LiquidStyle::drawPushButtonLabel(QPushButton *btn, QPainter *p) | 1289 | void LiquidStyle::drawPushButtonLabel(QPushButton *btn, QPainter *p) |
1297 | { | 1290 | { |
1298 | int x1, y1, x2, y2, w, h; | 1291 | int x1, y1, x2, y2, w, h; |
1299 | btn->rect().coords(&x1, &y1, &x2, &y2); | 1292 | btn->rect().coords(&x1, &y1, &x2, &y2); |
1300 | w = btn->width(); | 1293 | w = btn->width(); |
1301 | h = btn->height(); | 1294 | h = btn->height(); |
1302 | 1295 | ||
1303 | bool act = btn->isOn() || btn->isDown(); | 1296 | bool act = btn->isOn() || btn->isDown(); |
1304 | if(act){ | 1297 | if(act){ |
1305 | ++x1, ++y1; | 1298 | ++x1, ++y1; |
1306 | } | 1299 | } |
1307 | 1300 | ||
1308 | // Draw iconset first, if any | 1301 | // Draw iconset first, if any |
1309 | if ( btn->iconSet() && !btn->iconSet()->isNull() ) | 1302 | if ( btn->iconSet() && !btn->iconSet()->isNull() ) |
1310 | { | 1303 | { |
1311 | QIconSet::Mode mode = btn->isEnabled() | 1304 | QIconSet::Mode mode = btn->isEnabled() |
1312 | ? QIconSet::Normal : QIconSet::Disabled; | 1305 | ? QIconSet::Normal : QIconSet::Disabled; |
1313 | if ( mode == QIconSet::Normal && btn->hasFocus() ) | 1306 | if ( mode == QIconSet::Normal && btn->hasFocus() ) |
1314 | mode = QIconSet::Active; | 1307 | mode = QIconSet::Active; |
1315 | QPixmap pixmap = btn->iconSet()->pixmap( QIconSet::Small, mode ); | 1308 | QPixmap pixmap = btn->iconSet()->pixmap( QIconSet::Small, mode ); |
1316 | int pixw = pixmap.width(); | 1309 | int pixw = pixmap.width(); |
1317 | int pixh = pixmap.height(); | 1310 | int pixh = pixmap.height(); |
1318 | 1311 | ||
1319 | p->drawPixmap( x1+6, y1+h/2-pixh/2, pixmap ); | 1312 | p->drawPixmap( x1+6, y1+h/2-pixh/2, pixmap ); |
1320 | x1 += pixw + 8; | 1313 | x1 += pixw + 8; |
1321 | w -= pixw + 8; | 1314 | w -= pixw + 8; |
1322 | } | 1315 | } |
1323 | 1316 | ||
1324 | if(act){ | 1317 | if(act){ |
1325 | QFont font = btn->font(); | 1318 | QFont font = btn->font(); |
1326 | font.setBold(true); | 1319 | font.setBold(true); |
1327 | p->setFont(font); | 1320 | p->setFont(font); |
1328 | QColor shadow(btn->colorGroup().button().dark(130)); | 1321 | QColor shadow(btn->colorGroup().button().dark(130)); |
1329 | drawItem( p, x1+1, y1+1, w, h, | 1322 | drawItem( p, x1+1, y1+1, w, h, |
1330 | AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(), | 1323 | AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(), |
1331 | btn->pixmap(), btn->text(), -1, | 1324 | btn->pixmap(), btn->text(), -1, |
1332 | &shadow); | 1325 | &shadow); |
1333 | 1326 | ||
1334 | drawItem( p, x1, y1, w, h, | 1327 | drawItem( p, x1, y1, w, h, |
1335 | AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(), | 1328 | AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(), |
1336 | btn->pixmap(), btn->text(), -1, &btn->colorGroup().light()); | 1329 | btn->pixmap(), btn->text(), -1, &btn->colorGroup().light()); |
1337 | } | 1330 | } |
1338 | else{ | 1331 | else{ |
1339 | /* Too blurry | 1332 | /* Too blurry |
1340 | drawItem( p, x1+1, y1+1, w, h, | 1333 | drawItem( p, x1+1, y1+1, w, h, |
1341 | AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(), | 1334 | AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(), |
1342 | btn->pixmap(), btn->text(), -1, | 1335 | btn->pixmap(), btn->text(), -1, |
1343 | &btn->colorGroup().button().dark(115)); | 1336 | &btn->colorGroup().button().dark(115)); |
1344 | */ | 1337 | */ |
1345 | drawItem( p, x1, y1, w, h, | 1338 | drawItem( p, x1, y1, w, h, |
1346 | AlignCenter | ShowPrefix, | 1339 | AlignCenter | ShowPrefix, |
1347 | btn->colorGroup(), btn->isEnabled(), | 1340 | btn->colorGroup(), btn->isEnabled(), |
1348 | btn->pixmap(), btn->text(), -1, | 1341 | btn->pixmap(), btn->text(), -1, |
1349 | &btn->colorGroup().buttonText()); | 1342 | &btn->colorGroup().buttonText()); |
1350 | } | 1343 | } |