view src/imagelabel.cpp @ 96:a9e72af2e6fa 1.2

(Auto) Update translations
author Andre Heinecke <andre.heinecke@intevation.de>
date Mon, 29 Jun 2015 15:40:19 +0200
parents 26e1521b9afd
children
line wrap: on
line source
/* Copyright (C) 2015 by ETH Zürich
 * Software engineering by Intevation GmbH
 *
 * This file is Free Software under the GNU GPL (v>=2)
 * and comes with ABSOLUTELY NO WARRANTY!
 * See LICENSE.txt for details.
 */

#include "imagelabel.h"

ImageLabel::ImageLabel(QWidget *parent) :
    QWidget(parent) {
    label = new QLabel(this);
    label->setScaledContents(true);
    label->setFixedSize(0,0);
}

void ImageLabel::resizeEvent(QResizeEvent *event) {
    QWidget::resizeEvent(event);
    resizeImage();
}

const QPixmap* ImageLabel::pixmap() const {
    return label->pixmap();
}

void ImageLabel::setPixmap (const QPixmap &pixmap){
    label->setPixmap(pixmap);
    resizeImage();
}

void ImageLabel::resizeImage() {
    QSize pixSize = label->pixmap()->size();
    pixSize.scale(size(), Qt::KeepAspectRatio);
    label->setFixedSize(pixSize);
}

void ImageLabel::mouseDoubleClickEvent(QMouseEvent * e) {
    QWidget::mouseDoubleClickEvent(e);
    emit doubleClicked();
}

void ImageLabel::closeEvent(QCloseEvent *e) {
    Q_UNUSED(e);
    emit closeRequested();
}
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)