Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

SAP: paint icons via QIcon::paint

Carsten Hartenfelsf2d1a3c26c0c
diff --git a/libs/ui/kis_selection_actions_panel_button.cpp b/libs/ui/kis_selection_actions_panel_button.cpp
index a593e6417f..bbcd700170 100644
--- a/libs/ui/kis_selection_actions_panel_button.cpp
+++ b/libs/ui/kis_selection_actions_panel_button.cpp
@@ -50,8 +50,8 @@ void KisSelectionActionsPanelButton::draw(QPainter &painter)
painter.drawPath(path) ;
}
- QPixmap map = this->icon().pixmap(iconSize());
- painter.drawPixmap(rect.x() + ICON_SIZE_OFFSET / 2.0 , rect.y() + ICON_SIZE_OFFSET / 2.0, map);
+ int padding = ICON_SIZE_OFFSET / 2;
+ icon().paint(&painter, rect.marginsRemoved(QMargins(padding, padding, padding, padding)));
}
diff --git a/libs/ui/kis_selection_actions_panel_handle.cpp b/libs/ui/kis_selection_actions_panel_handle.cpp
index 546892001b..0077e838fe 100644
--- a/libs/ui/kis_selection_actions_panel_handle.cpp
+++ b/libs/ui/kis_selection_actions_panel_handle.cpp
@@ -46,19 +46,9 @@ void KisSelectionActionsPanelHandle::set_held(bool held)
void KisSelectionActionsPanelHandle::draw(QPainter& painter)
{
- QPixmap map = d->handle_icon.pixmap(d->size);
-
QRect rect = geometry();
- //Adjust the rct a bit to fill the right side of the bar properly
- rect.setY(rect.y() - 4);
- rect.setHeight(rect.height() + 4);
- rect.setX(rect.x() + 3);
- rect.setWidth(rect.width() + 1);
-
- QColor bgColor = Qt::darkGray;
- painter.fillRect(rect, bgColor);
-
- painter.fillRect(rect, bgColor);
+ // Adjust the rect a bit to fill the right side of the bar properly
+ painter.fillRect(rect.marginsAdded(QMargins(-3, 4, 1, 4)), Qt::darkGray);
// Adjusting the icon location a bit to be properly centered
- painter.drawPixmap(geometry().x() + 3, geometry().y(), map);
+ d->handle_icon.paint(&painter, QRect(rect.x() + 3, rect.y(), d->size, d->size));
}