QTfrontend/ui/widget/SquareLabel.cpp
changeset 6616 f77bb02b669f
parent 6428 2d2b5e3c59a7
child 6700 e04da46ee43c
equal deleted inserted replaced
6615:65602f1ef0f8 6616:f77bb02b669f
    31 {
    31 {
    32     Q_UNUSED(event);
    32     Q_UNUSED(event);
    33 
    33 
    34     QPainter painter(this);
    34     QPainter painter(this);
    35     int pixsize;
    35     int pixsize;
    36     if (width() > height()) {
    36     if (width() > height())
       
    37     {
    37         pixsize = height();
    38         pixsize = height();
    38         painter.translate((width() - pixsize) / 2, 0);
    39         painter.translate((width() - pixsize) / 2, 0);
    39     } else {
    40     }
       
    41     else
       
    42     {
    40         pixsize = width();
    43         pixsize = width();
    41         painter.translate(0, (height() - pixsize) / 2);
    44         painter.translate(0, (height() - pixsize) / 2);
    42     }
    45     }
    43     painter.drawPixmap(0, 0, pixsize, pixsize, pixmap.scaled(pixsize, pixsize, Qt::KeepAspectRatio));
    46     painter.drawPixmap(0, 0, pixsize, pixsize, pixmap.scaled(pixsize, pixsize, Qt::KeepAspectRatio));
    44 }
    47 }