Added padding variables for ColorButton and ColorComboBoxDelegate

This commit is contained in:
Magnus Hellströmer
2025-03-03 23:24:28 +01:00
parent 0e5f37503c
commit 80e404048c
2 changed files with 11 additions and 2 deletions

View File

@@ -73,6 +73,11 @@ void ColorButton::clicked(bool checked)
*/
void ColorButton::paintEvent(QPaintEvent *e) {
QPushButton::paintEvent(e);
// Padding for the color indicator
const int padding_x = 5;
const int padding_y = 5;
QPainter painter(this);
// Get dimensions of the button paint surface
@@ -80,6 +85,6 @@ void ColorButton::paintEvent(QPaintEvent *e) {
auto r_height = painter.device()->height();
// Paint a rectangle with a margin of 5
auto color_indicator = QRect(5, 5, r_width - 10, r_height - 10);
auto color_indicator = QRect(padding_x, padding_y, r_width - padding_x * 2, r_height - padding_y * 2);
painter.fillRect(color_indicator, m_color);
}