Browse Source

updated painter to pick better font color and enlarged maximum size of single block

tags/1.3
Sven Oliver Moll 1 year ago
parent
commit
a8b068e5eb
2 changed files with 4 additions and 11 deletions
  1. 3
    10
      src/fridgegrid/DragLabel.cpp
  2. 1
    1
      src/fridgegrid/DragLabelPropertiesDialog.cpp

+ 3
- 10
src/fridgegrid/DragLabel.cpp View File

@@ -217,16 +217,9 @@ void DragLabel::draw()
painter.drawRect( QRectF(0.5, 0.5, image.width()-1, image.height()-1) );

painter.setFont( font );
if( (mColor.red() < 96) &&
(mColor.green() < 96) &&
(mColor.blue() < 96) )
{
painter.setPen( QColor(255,255,255) );
}
else
{
painter.setPen( QColor(0,0,0) );
}

qreal bright = 0.299 * mColor.redF() + 0.587 * mColor.greenF() + 0.114 * mColor.blueF();
painter.setPen( bright >= 0.5 ? QColor(0,0,0) : QColor(255,255,255) );
painter.drawText( QRect(mpParent->gridStyle().topLeft(), size), Qt::AlignCenter, text );
painter.end();


+ 1
- 1
src/fridgegrid/DragLabelPropertiesDialog.cpp View File

@@ -45,7 +45,7 @@ DragLabelPropertiesDialog::DragLabelPropertiesDialog( DragLabel *parent )
mpWidthEdit->setValue( mpParent->gridSize().width() );
mpHeightEdit->setValue( mpParent->gridSize().height() );
mpWidthEdit->setRange( 1, 76 );
mpHeightEdit->setRange( 1, 30 );
mpHeightEdit->setRange( 1, 50 );
mpColorEdit->setMaxLength( 6 );
mpColorEdit->setText( mpParent->color().name().mid(1) );


Loading…
Cancel
Save