Mercurial > retraceit
diff src/pngplayer.cpp @ 2:97d2c8869c39
First prototype implementation of table view and player
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Mon, 23 Mar 2015 16:34:42 +0100 |
parents | |
children | 248d5d1cdb38 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pngplayer.cpp Mon Mar 23 16:34:42 2015 +0100 @@ -0,0 +1,36 @@ +/* Copyright (C) 2014 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 "pngplayer.h" +#include <QVBoxLayout> +#include <QPixmap> +#include <QLabel> + +PNGPlayer::PNGPlayer(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f) { + setupGUI(); + return; +} + +void PNGPlayer::setupGUI() { + QVBoxLayout *baseLayout = new QVBoxLayout; + mPNGLabel = new QLabel; + baseLayout->addWidget(mPNGLabel); + connect(&mAdvanceTimer, SIGNAL(timeout()), this, SIGNAL(advance())); + setLayout(baseLayout); + mAdvanceTimer.setInterval(2000); + mAdvanceTimer.start(); +} + +void PNGPlayer::showPicture(const QString& fileName, const QString& info) { + QPixmap pic(mBaseDir.filePath(fileName)); + /* If this is too slow we could use a pixmap cache here and do + * some intelligent preloading */ + if (pic.isNull()) { + emit error(tr("Failed to load picture: '%1'").arg(fileName)); + return; + } + mPNGLabel->setPixmap(pic); +}