MCPcopy Create free account
hub / github.com/ccMSC/ckb / updateImage

Method updateImage

src/ckb/gradientbutton.cpp:17–36  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15}
16
17void GradientButton::updateImage(){
18 const int w = 130, h = 16;
19 QImage image(w, h, QImage::Format_RGB888);
20 QPainter painter(&image);
21 painter.setPen(Qt::NoPen);
22 painter.fillRect(0, 0, w, h, QColor(0, 0, 0));
23 if(_alpha){
24 for(int x = 1; x < w - 1; x += h){
25 painter.fillRect(x, 1, h / 2, h / 2 - 1, QColor(255, 255, 255));
26 painter.fillRect(x + h / 2, 1, h / 2, h / 2 - 1, QColor(192, 192, 192));
27 painter.fillRect(x, h / 2, h / 2, h / 2 - 1, QColor(192, 192, 192));
28 painter.fillRect(x + h / 2, h / 2, h / 2, h / 2 - 1, QColor(255, 255, 255));
29 }
30 }
31 QLinearGradient gradient(1., 0., w - 1, 0.);
32 gradient.setStops(_stops);
33 painter.fillRect(1, 1, w - 2, h - 2, QBrush(gradient));
34 setIconSize(QSize(w, h));
35 setIcon(QIcon(QPixmap::fromImage(image)));
36}
37
38void GradientButton::fromString(const QString& string){
39 // Clear existing stops

Callers

nothing calls this directly

Calls 2

fillRectMethod · 0.80
setStopsMethod · 0.80

Tested by

no test coverage detected