QDialogPixmap added
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@5 cac9541e-1b8d-4bfa-827e-589bba606050
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
/* qlscribe - Qt based application to print lightScribe discs
|
||||
|
||||
Copyright (C) 2009 Vyacheslav Kononenko <vyacheslav@kononenko.net>
|
||||
|
||||
This program 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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
$Id$ */
|
||||
|
||||
#include "qdialogpixmap.h"
|
||||
#include "ui_qdialogpixmap.h"
|
||||
#include "qcdscene.h"
|
||||
|
||||
#include <QGraphicsPixmapItem>
|
||||
#include <QImageReader>
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
|
||||
QDialogPixmap::QDialogPixmap(QWidget *parent) :
|
||||
QItemDialog( parent ),
|
||||
m_ui( new Ui::QDialogPixmap ),
|
||||
m_item( 0 )
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
connect( m_ui->btnImage, SIGNAL(clicked()), this, SLOT(onLoadImage()) );
|
||||
}
|
||||
|
||||
QDialogPixmap::~QDialogPixmap()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void QDialogPixmap::changeEvent(QEvent *e)
|
||||
{
|
||||
switch (e->type()) {
|
||||
case QEvent::LanguageChange:
|
||||
m_ui->retranslateUi(this);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool QDialogPixmap::exec( QGraphicsItem *graphicsItem )
|
||||
{
|
||||
QGraphicsPixmapItem *item = dynamic_cast< QGraphicsPixmapItem * >( graphicsItem );
|
||||
if( !item )
|
||||
return false;
|
||||
|
||||
QCDScene scene;
|
||||
m_ui->cdView->setScene( &scene );
|
||||
m_item = new QGraphicsPixmapItem;
|
||||
|
||||
m_item->setPos( item->pos() );
|
||||
m_item->setPixmap( item->pixmap() );
|
||||
|
||||
scene.addItem( m_item );
|
||||
|
||||
m_ui->spinX->setValue( m_item->pos().x() );
|
||||
m_ui->spinY->setValue( m_item->pos().y() );
|
||||
|
||||
connect( m_ui->spinX, SIGNAL(valueChanged(double)),
|
||||
this, SLOT(posChanged()) );
|
||||
|
||||
connect( m_ui->spinY, SIGNAL(valueChanged(double)),
|
||||
this, SLOT(posChanged()) );
|
||||
|
||||
if( QDialog::exec() == Rejected ) return false;
|
||||
|
||||
item->setPos( m_item->pos() );
|
||||
item->setPixmap( m_item->pixmap() );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void QDialogPixmap::onLoadImage()
|
||||
{
|
||||
QList<QByteArray> list = QImageReader::supportedImageFormats();
|
||||
QString msg;
|
||||
foreach( QByteArray arr, list ) {
|
||||
msg += arr.data();
|
||||
}
|
||||
QMessageBox::warning( this, "Formats", msg );
|
||||
}
|
||||
|
||||
void QDialogPixmap::posChanged()
|
||||
{
|
||||
m_item->setPos( m_ui->spinX->value(), m_ui->spinY->value() );
|
||||
}
|
||||
Reference in New Issue
Block a user