| 90 | } |
| 91 | |
| 92 | QIcon GradientDialog::makeIcon(const Preset& preset){ |
| 93 | // Paint gradient into a square |
| 94 | int w = 60, h = 60; |
| 95 | QImage image(w, h, QImage::Format_RGB888); |
| 96 | QPainter painter(&image); |
| 97 | // Draw background |
| 98 | for(int x = 0; x < w; x += 30){ |
| 99 | for(int y = 0; y < h; y += 30){ |
| 100 | painter.fillRect(x, y, 15, 15, QColor(255, 255, 255)); |
| 101 | painter.fillRect(x + 15, y, 15, 15, QColor(192, 192, 192)); |
| 102 | painter.fillRect(x, y + 15, 15, 15, QColor(192, 192, 192)); |
| 103 | painter.fillRect(x + 15, y + 15, 15, 15, QColor(255, 255, 255)); |
| 104 | } |
| 105 | } |
| 106 | // Draw gradient |
| 107 | painter.setPen(QColor(0, 0, 0)); |
| 108 | QLinearGradient gradient(1., 1., w - 1., h - 1.); |
| 109 | gradient.setStops(preset.gradient); |
| 110 | painter.setBrush(gradient); |
| 111 | painter.drawRect(0, 0, w - 1, h - 1); |
| 112 | return QPixmap::fromImage(image); |
| 113 | } |
| 114 | |
| 115 | void GradientDialog::updatePresets(){ |
| 116 | ui->presetList->clear(); |