| 11 | namespace QodeAssist { |
| 12 | |
| 13 | EditorChatButton::EditorChatButton(QWidget *parent) |
| 14 | : QWidget(parent) |
| 15 | { |
| 16 | m_textColor = Utils::creatorTheme()->color(Utils::Theme::TextColorNormal); |
| 17 | m_backgroundColor = Utils::creatorTheme()->color(Utils::Theme::BackgroundColorNormal); |
| 18 | |
| 19 | m_logoPixmap = QPixmap(":/resources/images/qoderassist-icon.png"); |
| 20 | |
| 21 | if (!m_logoPixmap.isNull()) { |
| 22 | QImage image = m_logoPixmap.toImage(); |
| 23 | image = image.convertToFormat(QImage::Format_ARGB32); |
| 24 | |
| 25 | for (int y = 0; y < image.height(); ++y) { |
| 26 | for (int x = 0; x < image.width(); ++x) { |
| 27 | QColor pixelColor = QColor::fromRgba(image.pixel(x, y)); |
| 28 | |
| 29 | int brightness = (pixelColor.red() + pixelColor.green() + pixelColor.blue()) / 3; |
| 30 | |
| 31 | if (brightness > 200) { |
| 32 | pixelColor.setAlpha(0); |
| 33 | image.setPixelColor(x, y, pixelColor); |
| 34 | } else if (pixelColor.alpha() > 0) { |
| 35 | int alpha = pixelColor.alpha(); |
| 36 | pixelColor = m_textColor; |
| 37 | pixelColor.setAlpha(alpha); |
| 38 | image.setPixelColor(x, y, pixelColor); |
| 39 | } |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | m_logoPixmap = QPixmap::fromImage(image); |
| 44 | m_logoPixmap = m_logoPixmap.scaled(24, 24, Qt::KeepAspectRatio, Qt::SmoothTransformation); |
| 45 | } |
| 46 | |
| 47 | setFixedSize(40, 40); |
| 48 | setCursor(Qt::PointingHandCursor); |
| 49 | setToolTip(tr("Open QodeAssist Chat")); |
| 50 | } |
| 51 | |
| 52 | EditorChatButton::~EditorChatButton() = default; |
| 53 |
nothing calls this directly
no outgoing calls
no test coverage detected