@@ -704,9 +704,12 @@ void QgsColorSwatchDelegate::paint( QPainter *painter, const QStyleOptionViewIte
704704 }
705705
706706 QRect rect = option.rect ;
707+ const int iconSize = Qgis::UI_SCALE_FACTOR * option.fontMetrics .width ( ' X' ) * 4 ;
708+ const int cornerSize = iconSize / 6 ;
707709 // center it
708- rect.setLeft ( option.rect .center ().x () - 15 );
709- rect.setSize ( QSize ( 30 , 30 ) );
710+ rect.setLeft ( option.rect .center ().x () - iconSize / 2 );
711+
712+ rect.setSize ( QSize ( iconSize, iconSize ) );
710713 rect.adjust ( 0 , 1 , 0 , 1 );
711714 // create an icon pixmap
712715 painter->save ();
@@ -717,12 +720,12 @@ void QgsColorSwatchDelegate::paint( QPainter *painter, const QStyleOptionViewIte
717720 // start with checkboard pattern
718721 QBrush checkBrush = QBrush ( transparentBackground () );
719722 painter->setBrush ( checkBrush );
720- painter->drawRoundedRect ( rect, 5 , 5 );
723+ painter->drawRoundedRect ( rect, cornerSize, cornerSize );
721724 }
722725
723726 // draw semi-transparent color on top
724727 painter->setBrush ( color );
725- painter->drawRoundedRect ( rect, 5 , 5 );
728+ painter->drawRoundedRect ( rect, cornerSize, cornerSize );
726729 painter->restore ();
727730}
728731
@@ -738,9 +741,10 @@ QPixmap QgsColorSwatchDelegate::transparentBackground() const
738741
739742QSize QgsColorSwatchDelegate::sizeHint ( const QStyleOptionViewItem &option, const QModelIndex &index ) const
740743{
741- Q_UNUSED ( option );
742744 Q_UNUSED ( index );
743- return QSize ( 30 , 32 );
745+
746+ const int iconSize = Qgis::UI_SCALE_FACTOR * option.fontMetrics .width ( ' X' ) * 4 ;
747+ return QSize ( iconSize, iconSize * 32 / 30.0 );
744748}
745749
746750bool QgsColorSwatchDelegate::editorEvent ( QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index )
0 commit comments