mirror of
https://github.com/parchlinux/calamares.git
synced 2025-06-29 10:25:36 -04:00
New FixedAspectRatioLabel for pixmaps.
This commit is contained in:
parent
161046af43
commit
80c76c549f
3 changed files with 91 additions and 0 deletions
50
src/libcalamaresui/widgets/FixedAspectRatioLabel.cpp
Normal file
50
src/libcalamaresui/widgets/FixedAspectRatioLabel.cpp
Normal file
|
@ -0,0 +1,50 @@
|
|||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2015, Teo Mrnjavac <teo@kde.org>
|
||||
*
|
||||
* Calamares is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Calamares is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "FixedAspectRatioLabel.h"
|
||||
|
||||
|
||||
FixedAspectRatioLabel::FixedAspectRatioLabel( QWidget* parent )
|
||||
: QLabel( parent )
|
||||
{}
|
||||
|
||||
|
||||
FixedAspectRatioLabel::~FixedAspectRatioLabel()
|
||||
{}
|
||||
|
||||
|
||||
void
|
||||
FixedAspectRatioLabel::setPixmap( const QPixmap& pixmap )
|
||||
{
|
||||
m_pixmap = pixmap;
|
||||
QLabel::setPixmap( pixmap.scaled(
|
||||
contentsRect().size(),
|
||||
Qt::KeepAspectRatio,
|
||||
Qt::SmoothTransformation ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FixedAspectRatioLabel::resizeEvent( QResizeEvent* event )
|
||||
{
|
||||
QLabel::setPixmap( m_pixmap.scaled(
|
||||
contentsRect().size(),
|
||||
Qt::KeepAspectRatio,
|
||||
Qt::SmoothTransformation ) );
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue