Fix regressions
[kphotoalbum.git] / ImportExport / MiniViewer.cpp
blob1df1eee1b39f8dd18f404f099f9cb1bbffa80529
1 /* Copyright (C) 2003-2006 Jesper K. Pedersen <blackie@kde.org>
3 This program is free software; you can redistribute it and/or
4 modify it under the terms of the GNU General Public
5 License as published by the Free Software Foundation; either
6 version 2 of the License, or (at your option) any later version.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program; see the file COPYING. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
19 #include "MiniViewer.h"
20 #include <qpushbutton.h>
21 #include <klocale.h>
22 #include <qlabel.h>
23 #include <qlayout.h>
24 #include <qimage.h>
25 #include "DB/ImageInfo.h"
26 #include <qmatrix.h>
28 using namespace ImportExport;
30 MiniViewer* MiniViewer::_instance = 0;
32 void MiniViewer::show( QImage img, DB::ImageInfoPtr info, QWidget* parent )
34 if ( !_instance )
35 _instance = new MiniViewer( parent );
37 if ( info->angle() != 0 ) {
38 QMatrix matrix;
39 matrix.rotate( info->angle() );
40 img = img.transformed( matrix );
42 if ( img.width() > 800 || img.height() > 600 )
43 img = img.scaled( 800, 600, Qt::KeepAspectRatio );
45 _instance->_pixmap->setPixmap( QPixmap::fromImage(img) );
46 _instance->QDialog::show();
47 _instance->raise();
50 void MiniViewer::closeEvent( QCloseEvent* )
52 slotClose();
55 void MiniViewer::slotClose()
57 _instance = 0;
58 deleteLater();
61 MiniViewer::MiniViewer( QWidget* parent ): QDialog( parent )
63 QVBoxLayout* vlay = new QVBoxLayout( this );
64 _pixmap = new QLabel( this );
65 vlay->addWidget( _pixmap );
66 QHBoxLayout* hlay = new QHBoxLayout;
67 vlay->addLayout(hlay);
68 hlay->addStretch(1);
69 QPushButton* but = new QPushButton( i18n("Close"), this );
70 connect( but, SIGNAL( clicked() ), this, SLOT( slotClose() ) );
71 hlay->addWidget( but );
74 #include "MiniViewer.moc"