| 43 | namespace QodeAssist { |
| 44 | |
| 45 | static QIcon createThemedIcon(const QString &svgPath, const QColor &color) |
| 46 | { |
| 47 | QSvgRenderer renderer(svgPath); |
| 48 | if (!renderer.isValid()) { |
| 49 | return QIcon(); |
| 50 | } |
| 51 | |
| 52 | QSize iconSize(16, 16); |
| 53 | QPixmap pixmap(iconSize); |
| 54 | pixmap.fill(Qt::transparent); |
| 55 | |
| 56 | QPainter painter(&pixmap); |
| 57 | renderer.render(&painter); |
| 58 | painter.end(); |
| 59 | |
| 60 | QImage image = pixmap.toImage().convertToFormat(QImage::Format_ARGB32); |
| 61 | |
| 62 | uchar *bits = image.bits(); |
| 63 | const int bytesPerPixel = 4; |
| 64 | const int totalBytes = image.width() * image.height() * bytesPerPixel; |
| 65 | |
| 66 | const int newR = color.red(); |
| 67 | const int newG = color.green(); |
| 68 | const int newB = color.blue(); |
| 69 | |
| 70 | for (int i = 0; i < totalBytes; i += bytesPerPixel) { |
| 71 | int alpha = bits[i + 3]; |
| 72 | if (alpha > 0) { |
| 73 | bits[i] = newB; |
| 74 | bits[i + 1] = newG; |
| 75 | bits[i + 2] = newR; |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | return QIcon(QPixmap::fromImage(image)); |
| 80 | } |
| 81 | |
| 82 | QuickRefactorDialog::QuickRefactorDialog(QWidget *parent, const QString &lastInstructions) |
| 83 | : QDialog(parent) |