diff --git a/src/qdialogpixmap.cpp b/src/qdialogpixmap.cpp new file mode 100644 index 0000000..cf66033 --- /dev/null +++ b/src/qdialogpixmap.cpp @@ -0,0 +1,100 @@ +/* qlscribe - Qt based application to print lightScribe discs + + Copyright (C) 2009 Vyacheslav Kononenko + + 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 +#include +#include +#include + +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 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() ); +} diff --git a/src/qdialogpixmap.h b/src/qdialogpixmap.h new file mode 100644 index 0000000..ad04f89 --- /dev/null +++ b/src/qdialogpixmap.h @@ -0,0 +1,54 @@ +/* qlscribe - Qt based application to print lightScribe discs + + Copyright (C) 2009 Vyacheslav Kononenko + + 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$ */ + +#ifndef QDIALOGPIXMAP_H +#define QDIALOGPIXMAP_H + +#include "qshapefactory.h" + +namespace Ui { + class QDialogPixmap; +} + +class QGraphicsPixmapItem; + +class QDialogPixmap : public QItemDialog { + Q_OBJECT + Q_DISABLE_COPY(QDialogPixmap) +public: + explicit QDialogPixmap( QWidget *parent ); + virtual ~QDialogPixmap(); + + virtual bool exec( QGraphicsItem *item ); + +protected: + virtual void changeEvent(QEvent *e); + +private slots: + void onLoadImage(); + void posChanged(); + +private: + Ui::QDialogPixmap *m_ui; + QGraphicsPixmapItem *m_item; +}; + + +#endif // QDIALOGPIXMAP_H diff --git a/src/qdialogpixmap.ui b/src/qdialogpixmap.ui new file mode 100644 index 0000000..3f7b8d8 --- /dev/null +++ b/src/qdialogpixmap.ui @@ -0,0 +1,197 @@ + + QDialogPixmap + + + Qt::NonModal + + + + 0 + 0 + 542 + 649 + + + + Text properties + + + false + + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + 3 + + + + + + QLayout::SetMaximumSize + + + 0 + + + + + + + X: + + + + + + + 1 + + + -61.000000000000000 + + + 61.000000000000000 + + + + + + + Y: + + + + + + + 1 + + + -61.000000000000000 + + + 61.000000000000000 + + + + + + + + + QFormLayout::ExpandingFieldsGrow + + + + + Image: + + + + + + + + + + Load image... + + + + + + + + + + + + 0 + 2 + + + + + 0 + 0 + + + + false + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + QCDView + QGraphicsView +
qcdview.h
+
+
+ + spinX + spinY + buttonBox + + + + + buttonBox + accepted() + QDialogPixmap + accept() + + + 258 + 582 + + + 157 + 274 + + + + + buttonBox + rejected() + QDialogPixmap + reject() + + + 326 + 582 + + + 286 + 274 + + + + +
diff --git a/src/qlscribe.pro b/src/qlscribe.pro index bb456b4..e1922bd 100644 --- a/src/qlscribe.pro +++ b/src/qlscribe.pro @@ -13,10 +13,9 @@ SOURCES += main.cpp \ qshapecontrollers.cpp \ qdialogtext.cpp \ qdialogroundtext.cpp \ - qlightscribe.cpp - + qlightscribe.cpp \ + qdialogpixmap.cpp QMAKE_LIBS += -llightscribe - HEADERS += mainwindow.h \ qgraphicsroundtextitem.h \ qcdview.h \ @@ -25,6 +24,8 @@ HEADERS += mainwindow.h \ qshapecontrollers.h \ qdialogtext.h \ qdialogroundtext.h \ - qlightscribe.h + qlightscribe.h \ + qdialogpixmap.h FORMS += qdialogtext.ui \ - qdialogroundtext.ui + qdialogroundtext.ui \ + qdialogpixmap.ui