1 Commits

Author SHA1 Message Date
ruglory 9f3fd65866 Tagging the 0.1 release
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/tags/release-0.1@17 cac9541e-1b8d-4bfa-827e-589bba606050
2009-01-26 06:49:04 +00:00
33 changed files with 294 additions and 1090 deletions
-38
View File
@@ -1,38 +0,0 @@
Qt lightScribe Installaton instructions
=======================================
To compile and install, first download release from http://qlscribe.sourceforge.net/
or check out project from subversion repository for particular release:
svn co https://qlscribe.svn.sourceforge.net/svnroot/qlscribe/tags/release-N.M qlscribe
or if you want to test latest development version:
svn co https://qlscribe.svn.sourceforge.net/svnroot/qlscribe/trunk qlscribe
Then go to the source directory and type:
mkdir build
cd build
cmake ..
(If you want to install in a different path, use instead:
cmake .. -DCMAKE_INSTALL_PREFIX=/install/path)
make
sudo make install
If cmake fails to find lightScribe API specify environment variable LIGHTSCRIBEDIR:
LIGHTSCRIBEDIR=/opt/lightscribe cmake ..
Include files should be in ${LIGHTSCRIBEDIR}/include and lib in ${LIGHTSCRIBEDIR}/lib
Once installed, you can start Qt lightScribe by typing "qlscribe", but due to API
requirement if you want to burn qlscribe has to be started by root as "sudo qlscribe"
You need to download lightScribe SDK for qlscribe to build and lightScribe runtime
for qlscribe to run. For details see lightScribe webpage:
http://www.lightscribe.org/
Enjoy!
+3 -27
View File
@@ -1,30 +1,6 @@
NEWS - list of user-visible changes between releases of qlscribe
New in 0.5:
Bugfix for crash on writing
CD inner size increased to 25mm on QCDView
Maximum image size increased to 150
Fixed bug with not setting color on round text
Text scaled to 1/2
Fixed bug with missing button "OK" on pixmap edit dialog
New in 0.4:
Scene detects when item is moved by mouse and changes status to unsaved
On installation sticky bit is set, qlscribe becomes root when burns label
Bugfix on progress dialog crush with empty document printed
New in 0.3:
Documents keep their names and detect changes (changes on item postion through window
itself is not detected yet)
Main window on close scan all documents and confirm to save changed ones
Document window confirm to save on close
New in 0.2:
Print progress dialog shows elapsed/estimated time
Bugfix for not loading angle in round text item
Image items can be scaled now
New in 0.1:
Open/save as implemented. Text, round text and image items can be inserted and edited
Print preview and print is working (no exclusive lock or tray lock on printing yet)
New in 0.1:
* First release of qlscribe
* *
+4 -14
View File
@@ -1,17 +1,7 @@
Qt lightScribe V 0.1 by Vyacheslav Kononenko <vyacheslav@kononenko.net>
qlscribe
********
Qt lightScribe is Qt base application to burn CD/DVD labels on lightScribe capable
drives and medias
Introduction
============
This is the first alpha release. Program functionality is very limited at this stage.
Please check the project page for more information, and to report new bugs.
http://qlscribe.sourceforge.net/
Application based on lightScribe(c) API: http://www.lightscribe.org
and requires lightScribe API, available to download from:
http://www.lightscribe.org/downloadSection/linux/index.aspx
Thanks and regards,
Vyacheslav
+2 -3
View File
@@ -18,14 +18,13 @@
#
# $Id$
FIND_PATH( LSCRIBE_INCLUDE_DIR lightscribe.h /usr/local/include $ENV{LIGHTSCRIBEDIR}/include )
FIND_PATH( LSCRIBE_INCLUDE_DIR lightscribe.h /usr/local/include )
FIND_LIBRARY( LSCRIBE_LIBRARY lightscribe /usr/local/lib $ENV{LIGHTSCRIBEDIR}/lib )
FIND_LIBRARY( LSCRIBE_LIBRARY lightscribe /usr/local/lib )
if( LSCRIBE_INCLUDE_DIR AND LSCRIBE_LIBRARY )
SET( LSCRIBE_FOUND TRUE )
SET( LSCRIBE_LIBRARIES ${LSCRIBE_LIBRARY} )
INCLUDE_DIRECTORIES(${LSCRIBE_INCLUDE_DIR})
ENDIF( LSCRIBE_INCLUDE_DIR AND LSCRIBE_LIBRARY )
IF( LSCRIBE_FOUND )
+3 -6
View File
@@ -19,8 +19,8 @@
# $Id$
SET( QLSCRIBE_SRCS main.cpp mainwindow.cpp qcdscene.cpp qcdview.cpp qdialogpixmap.cpp qdialogroundtext.cpp
qdialogtext.cpp qlightroundtextitem.cpp qlightscribe.cpp qshapefactory.cpp
qlighttextitem.cpp qlightpixmapitem.cpp qdialogprint.cpp qdialogprogress.cpp )
qdialogtext.cpp qgraphicsroundtextitem.cpp qlightscribe.cpp qshapecontrollers.cpp qshapefactory.cpp
qdialogprint.cpp qdialogprogress.cpp )
SET( QLSCRIBE_UIS qdialogtext.ui qdialogroundtext.ui qdialogpixmap.ui qdialogprint.ui qdialogprogress.ui )
@@ -41,7 +41,4 @@ ADD_EXECUTABLE( qlscribe ${QLSCRIBE_SRCS} ${QLSCRIBE_MOC_SRCS} ${QLSCRIBE_UI_HDR
TARGET_LINK_LIBRARIES( qlscribe ${QT_LIBRARIES} ${LSCRIBE_LIBRARIES} )
INSTALL( TARGETS qlscribe
DESTINATION bin
PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE SETUID )
INSTALL( TARGETS qlscribe DESTINATION bin )
+1 -23
View File
@@ -19,34 +19,12 @@
$Id$ */
#include <QApplication>
#include <QMessageBox>
#include "mainwindow.h"
uid_t realUserId;
int main(int argc, char **argv)
{
QApplication app(argc, argv);
app.addLibraryPath( "/usr/lib32/qt4/plugins" );
bool enablePrint = false;
if( geteuid() ) {
if( QMessageBox::question( 0,
QObject::tr( "Confirmation" ),
QObject::tr( "Print functionality requires setuid (sticky) flag set on the application\n"
"This program does not seem to have it set, print functiionality will be disabled\n"
"You still will be able to do print preview and edit documents\n"
"Do you want to continue?" ),
QMessageBox::Yes | QMessageBox::No,
QMessageBox::No )
== QMessageBox::No )
return 1;
} else {
realUserId = getuid();
setreuid( 0, realUserId );
enablePrint = true;
}
MainWindow mwindow( enablePrint );
MainWindow mwindow;
mwindow.show();
return app.exec();
+61 -93
View File
@@ -19,7 +19,7 @@
$Id$ */
#include "mainwindow.h"
#include "qlightroundtextitem.h"
#include "qgraphicsroundtextitem.h"
#include "qcdview.h"
#include "qcdscene.h"
#include "qshapefactory.h"
@@ -34,12 +34,19 @@
#include <QMessageBox>
#include <QSignalMapper>
#include <QFileDialog>
#include <QXmlStreamWriter>
#include <QLabel>
#include <QCloseEvent>
/*#include <QImage>
#include <QBuffer>
#include <QGraphicsScene>
#include <QFontDialog>
#include <QPainter>*/
MainWindow::MainWindow( bool enablePrint )
: QMainWindow( 0 ),
//#include <lightscribe.h>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
m_mdiArea( new QMdiArea( this ) ),
m_menuFile( 0 ), m_menuInsert( 0 ),
m_insertMapper( new QSignalMapper( this ) )
@@ -71,12 +78,9 @@ MainWindow::MainWindow( bool enablePrint )
this,
SLOT(onMenuPrintPreview()) );
QAction *printAction =
m_menuFile->addAction( tr( "Print...", "Menu item \"Print\"" ),
this,
SLOT(onMenuPrint()) );
if( !enablePrint )
printAction->setEnabled( false );
m_menuFile->addAction( tr( "Print...", "Menu item \"Print\"" ),
this,
SLOT(onMenuPrint()) );
m_menuFile->addAction( tr( "Exit", "Menu item \"Exit\"" ),
this,
@@ -112,75 +116,11 @@ MainWindow::~MainWindow()
lscribe->wait( 1000 );
}
bool MainWindow::saveSceneAs( QCDScene *scene )
{
QString fileName =
QFileDialog::getSaveFileName( this,
scene->name() + tr( ": save as" ),
QString(),
tr("qlscribe document (*.qlx)") );
if( fileName.isNull() )
return false;
if( !fileName.contains( '.' ) )
fileName += ".qlx";
return scene->saveAs( fileName );
}
bool MainWindow::saveScene( QCDScene *scene )
{
return scene->isUnnamed() ? saveSceneAs( scene ) : scene->save();
}
void MainWindow::closeEvent(QCloseEvent *event)
{
bool saveAll = false;
QList< QMdiSubWindow * > subs = m_mdiArea->subWindowList();
foreach( QMdiSubWindow *sub, subs ) {
QCDView *cdview = dynamic_cast< QCDView * >( sub->widget() );
if( !cdview )
continue;
QCDScene *scene = cdview->scene();
if( !scene || scene->isSaved() )
continue;
bool save = saveAll;
if( !save ) {
QMessageBox::StandardButton button =
QMessageBox::question( this,
tr( "Confirmation" ),
scene->name() + tr( " is unsaved, do you want to save?" ),
QMessageBox::Save | QMessageBox::SaveAll | QMessageBox::Discard | QMessageBox::Cancel );
if( button == QMessageBox::Cancel ) {
event->ignore();
return;
}
if( button == QMessageBox::SaveAll ) {
saveAll = true;
save = true;
}
if( button == QMessageBox::Save )
save = true;
}
if( save )
if( !saveScene( scene ) ) {
event->ignore();
return;
}
}
event->accept();
}
void MainWindow::onMenuNew()
{
QCDView *newView = new QCDView;
QCDScene *scene = new QCDScene( newView );
newView->setScene( scene );
scene->setName();
newView->setScene( new QCDScene( newView ) );
//newView->setWindowTitle( "Baba" );
QMdiSubWindow *subWindow = m_mdiArea->addSubWindow( newView );
subWindow->show();
}
@@ -221,7 +161,6 @@ void MainWindow::onMenuInsert( int id )
item->setFlag( QGraphicsItem::ItemIsMovable, true );
item->setFlag( QGraphicsItem::ItemIsSelectable, true );
cdscene->addItem( item );
cdscene->setChanged();
}
void MainWindow::onMenuOpen()
@@ -234,31 +173,33 @@ void MainWindow::onMenuOpen()
if( fileName.isNull() )
return;
QFile file( fileName );
if( !file.open( QIODevice::ReadOnly | QIODevice::Text ) ) {
QMessageBox::critical( this, tr( "Error" ), tr( "Cannot open file for reading\n" ) + fileName );
return;
}
QCDView *newView = new QCDView;
QCDScene *scene = new QCDScene( newView );
newView->setScene( scene );
if( !scene->load( fileName ) ) {
QXmlStreamReader reader( &file );
try {
scene->read( reader );
}
catch( const QString &err ) {
QMessageBox::critical( this, tr( "Error" ), tr( "Cannot read file " ) + fileName + "\n" + err );
delete newView;
return;
}
}
//newView->setWindowTitle( "Baba" );
QMdiSubWindow *subWindow = m_mdiArea->addSubWindow( newView );
subWindow->show();
}
void MainWindow::onMenuSave()
{
QCDScene *scene = getScene( m_mdiArea );
if( scene )
saveScene( scene );
}
void MainWindow::onMenuSaveAs()
{
QCDScene *scene = getScene( m_mdiArea );
if( scene )
saveSceneAs( scene );
}
void MainWindow::onMenuPrintPreview()
@@ -278,7 +219,6 @@ void MainWindow::onMenuPrintPreview()
QLabel *label = new QLabel;
label->setPixmap( pixmap );
QMdiSubWindow *subWindow = m_mdiArea->addSubWindow( label );
subWindow->setWindowTitle( "Preview: " + cdscene->name() );
subWindow->show();
}
catch( const QString &err ) {
@@ -295,12 +235,40 @@ void MainWindow::onMenuPrint()
QDialogProgress::exec( this, cdscene );
}
void MainWindow::onMenuSaveAs()
{
QCDScene *cdscene = getScene( m_mdiArea );
if( !cdscene )
return;
QString fileName =
QFileDialog::getSaveFileName( this,
tr( "Save as:" ),
QString(),
tr("qlscribe document (*.qlx)") );
if( fileName.isNull() )
return;
if( !fileName.contains( '.' ) )
fileName += ".qlx";
QFile file( fileName );
if( !file.open( QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text ) ) {
QMessageBox::warning( this, tr( "Warning" ), tr( "Cannot open file for writing: " ) + fileName );
return;
}
QXmlStreamWriter writer( &file );
writer.setAutoFormatting( true );
cdscene->write( writer );
}
void MainWindow::onMenuAbout()
{
QMessageBox::about( this,
tr( "About" ),
tr( "<h3>qlscribe - Qt lisghtScribe</h3>"
"<p>release 0.5 $Revision$</p>"
"<p>$Revision$</p>"
"<p>visit project at home page "
"<a href=\"http://qlscribe.sourceforge.net/\">qlscribe.sourceforge.net</a></p>" ) );
}
+1 -8
View File
@@ -25,19 +25,14 @@
class QMdiArea;
class QSignalMapper;
class QCDScene;
class MainWindow : public QMainWindow {
Q_OBJECT
Q_DISABLE_COPY(MainWindow)
public:
explicit MainWindow( bool enablePrint );
explicit MainWindow(QWidget *parent = 0);
virtual ~MainWindow();
bool saveScene( QCDScene *scene );
protected:
virtual void closeEvent( QCloseEvent *event );
private slots:
void onMenuNew();
void onMenuOpen();
@@ -50,8 +45,6 @@ private slots:
void onMenuQtAbout();
private:
bool saveSceneAs( QCDScene *scene );
QMdiArea *m_mdiArea;
QMenu *m_menuFile;
+2 -139
View File
@@ -16,7 +16,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
$Id$ */
$Id:$ */
#include "qcdscene.h"
#include "qshapefactory.h"
@@ -25,17 +25,10 @@
#include <QMessageBox>
#include <QGraphicsItem>
#include <QGraphicsSceneMouseEvent>
#include <QFile>
#include <QXmlStreamReader>
#include <QXmlStreamWriter>
#include <QMessageBox>
#include <QGraphicsView>
#include <QRegExp>
QCDScene::QCDScene( QObject * parent )
: QGraphicsScene( parent ),
m_index( 0 ),
m_saved( true )
: QGraphicsScene( parent )
{
setSceneRect( -60.0, -60.0, 60.0 * 2, 60.0 * 2 );
}
@@ -46,93 +39,6 @@ QCDScene::~QCDScene()
{
}
bool QCDScene::load( const QString &fileName )
{
QFile file( fileName );
if( !file.open( QIODevice::ReadOnly | QIODevice::Text ) ) {
QMessageBox::critical( 0, tr( "Error" ), tr( "Cannot open file for reading\n" ) + fileName );
return false;
}
QXmlStreamReader reader( &file );
try {
read( reader );
}
catch( const QString &err ) {
QMessageBox::critical( 0, tr( "Error" ), tr( "Cannot read file " ) + fileName + "\n" + err );
return false;
}
m_fileName = fileName;
m_saved = true;
setName();
return true;
}
bool QCDScene::save()
{
QFile file( m_fileName );
if( !file.open( QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text ) ) {
QMessageBox::warning( 0, tr( "Warning" ), tr( "Cannot open file for writing: " ) + m_fileName );
return false;
}
QXmlStreamWriter writer( &file );
writer.setAutoFormatting( true );
write( writer );
m_saved = true;
setName();
return true;
}
void QCDScene::setName()
{
if( m_fileName.isEmpty() ) {
if( !m_index ) {
static int index = 1;
m_index = index++;
}
m_name = "Unnamed_" + QString::number( m_index );
} else {
QRegExp rx( "(.*/)?(.*)\\.qlx" );
rx.indexIn( m_fileName );
m_name = rx.cap( 2 );
}
updateTitles();
}
void QCDScene::setChanged()
{
m_saved = false;
updateTitles();
}
void QCDScene::updateTitles() const
{
QString name = m_name;
if( !m_saved )
name += " *";
QList<QGraphicsView *> allViews = views();
foreach( QGraphicsView *view, allViews ) {
view->setWindowTitle( name );
}
}
bool QCDScene::saveAs( const QString &fileName )
{
QFile file( fileName );
if( !file.open( QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text ) ) {
QMessageBox::warning( 0, tr( "Warning" ), tr( "Cannot open file for writing: " ) + fileName );
return false;
}
QXmlStreamWriter writer( &file );
writer.setAutoFormatting( true );
write( writer );
m_saved = true;
m_fileName = fileName;
setName();
return true;
}
void QCDScene::write( QXmlStreamWriter &writer )
{
writer.writeStartDocument();
@@ -204,9 +110,6 @@ void QCDScene::contextMenuEvent( QGraphicsSceneContextMenuEvent *mouseEvent )
item->setSelected( true );
QMenu menu;
menu.addAction( tr( "edit..." ), this, SLOT( onMenuEdit() ) );
menu.addAction( tr( "bring to Front" ), this, SLOT( onMenuToFront() ) );
menu.addAction( tr( "send to Back" ), this, SLOT( onMenuToBack() ) );
menu.addAction( tr( "delete" ), this, SLOT( onMenuDelete() ) );
menu.exec( mouseEvent->screenPos() );
}
@@ -218,43 +121,3 @@ void QCDScene::onMenuEdit()
QGraphicsItem *item = list.front();
QShapeFactory::instance().edit( item, 0 );
}
void QCDScene::onMenuToFront()
{
sendItemTo( true );
}
void QCDScene::onMenuToBack()
{
sendItemTo( false );
}
void QCDScene::onMenuDelete()
{
QList<QGraphicsItem *> list = selectedItems();
if( list.empty() )
return;
QGraphicsItem *item = list.front();
removeItem( item );
delete item;
setChanged();
}
void QCDScene::sendItemTo( bool front )
{
if ( selectedItems().isEmpty())
return;
QGraphicsItem *selectedItem = selectedItems().first();
QList<QGraphicsItem *> overlapItems = selectedItem->collidingItems();
qreal zValue = 0;
foreach( QGraphicsItem *item, overlapItems ) {
if( front && item->zValue() >= zValue )
zValue = item->zValue() + 0.1;
if( !front && item->zValue() <= zValue )
zValue = item->zValue() - 0.1;
}
selectedItem->setZValue( zValue );
}
+3 -26
View File
@@ -16,7 +16,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
$Id$ */
$Id:$ */
#ifndef QCDSCENE_H
#define QCDSCENE_H
@@ -32,37 +32,14 @@ public:
QCDScene( QObject * parent = 0 );
virtual ~QCDScene();
bool isSaved() const { return m_saved; }
bool isUnnamed() const { return m_fileName.isEmpty(); }
void setChanged();
void setName();
bool load( const QString &fileName );
bool save();
bool saveAs( const QString &fileName );
void updateTitles() const;
QString name() const { return m_name; }
void write( QXmlStreamWriter &writer );
void read( QXmlStreamReader &reader );
protected:
virtual void contextMenuEvent( QGraphicsSceneContextMenuEvent *contextMenuEvent );
private slots:
void onMenuEdit();
void onMenuToFront();
void onMenuToBack();
void onMenuDelete();
private:
void write( QXmlStreamWriter &writer );
void read( QXmlStreamReader &reader );
void sendItemTo( bool front );
private:
QString m_name;
QString m_fileName;
int m_index;
bool m_saved;
};
#endif //QCDSCENE_H
+3 -35
View File
@@ -16,14 +16,10 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
$Id$ */
$Id:$ */
#include "qcdview.h"
#include "qcdscene.h"
#include "mainwindow.h"
#include <QCloseEvent>
#include <QMessageBox>
QCDView::QCDView( QWidget *parent )
: QGraphicsView( parent ),
@@ -53,38 +49,10 @@ QCDScene *QCDView::scene() const
return static_cast< QCDScene * >( QGraphicsView::scene() );
}
void QCDView::closeEvent( QCloseEvent *event )
{
QCDScene *cdscene = scene();
if( cdscene && !cdscene->isSaved() ) {
QMessageBox::StandardButton button =
QMessageBox::question( this,
tr( "Confitmation" ),
cdscene->name() + tr( " is changed, do you want to save it?" ),
QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel );
if( button == QMessageBox::Cancel ) {
event->ignore();
return;
}
if( button == QMessageBox::Yes ) {
QWidget *parent = parentWidget();
for( ; parent->parentWidget(); parent = parent->parentWidget() );
if( !static_cast< MainWindow * >( parent )->saveScene( cdscene ) ) {
event->ignore();
return;
}
}
}
event->accept();
}
inline
void drawCircle( QPainter *painter, double radi )
{
painter->drawEllipse( int( -radi ), int( -radi ),
int( radi * 2 ), int( radi * 2 ) );
painter->drawEllipse( -radi, -radi, radi * 2, radi * 2 );
}
void QCDView::drawCD( QPainter *painter, const QRectF & rect, bool alpha )
@@ -96,7 +64,7 @@ void QCDView::drawCD( QPainter *painter, const QRectF & rect, bool alpha )
drawCircle( painter, 59.0 );
painter->setBrush( alpha ? Qt::lightGray : Qt::darkGray );
drawCircle( painter, 25.0 );
drawCircle( painter, 21.7 );
painter->setBrush( alpha ? Qt::white : Qt::gray );
drawCircle( painter, 10.7 );
+1 -2
View File
@@ -16,7 +16,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
$Id$ */
$Id:$ */
#ifndef QCDVIEW_H
#define QCDVIEW_H
@@ -39,7 +39,6 @@ public:
virtual QSize sizeHint () const;
protected:
virtual void closeEvent( QCloseEvent *event );
void drawForeground ( QPainter * painter, const QRectF & rect );
void drawBackground ( QPainter * painter, const QRectF & rect );
+1 -47
View File
@@ -66,21 +66,11 @@ bool QDialogPixmap::exec( QGraphicsItem *graphicsItem )
m_item->setOffset( item->offset() );
m_item->setPixmap( item->pixmap() );
m_item->setData( 0, item->data( 0 ) );
m_item->setTransform( item->transform() );
scene.addItem( m_item );
m_ui->spinX->setValue( m_item->pos().x() );
m_ui->spinY->setValue( m_item->pos().y() );
m_ui->lineEdit->setText( m_item->data( 0 ).toString() );
if( !m_item->pixmap().isNull() ) {
QSize size = m_item->pixmap().size();
QPointF scale = m_item->transform().map( QPointF( size.width(), size.height() ) );
m_ui->spinWidth->setValue( scale.x() );
m_ui->spinHeight->setValue( scale.y() );
m_ui->lockedRatio->setChecked( scale.x() == scale.y() ? Qt::Checked : Qt::Unchecked );
m_ui->buttonBox->setStandardButtons( m_ui->buttonBox->standardButtons() | QDialogButtonBox::Ok );
}
connect( m_ui->spinX, SIGNAL(valueChanged(double)),
this, SLOT(posChanged()) );
@@ -88,25 +78,12 @@ bool QDialogPixmap::exec( QGraphicsItem *graphicsItem )
connect( m_ui->spinY, SIGNAL(valueChanged(double)),
this, SLOT(posChanged()) );
connect( m_ui->spinWidth, SIGNAL(valueChanged(double)),
this, SLOT(sizeChanged()) );
connect( m_ui->spinHeight, SIGNAL(valueChanged(double)),
this, SLOT(sizeChanged()) );
connect( m_ui->btnSizeReset, SIGNAL(clicked()),
this, SLOT(onResetSize()) );
connect( m_ui->lockedRatio, SIGNAL(stateChanged(int)),
this, SLOT(sizeChanged()) );
if( QDialog::exec() == Rejected ) return false;
item->setPos( m_item->pos() );
item->setOffset( m_item->offset() );
item->setPixmap( m_item->pixmap() );
item->setData( 0, m_item->data( 0 ) );
item->setTransform( m_item->transform() );
return true;
}
@@ -132,36 +109,13 @@ void QDialogPixmap::onLoadImage()
}
m_item->setPixmap( pixmap );
m_item->setData( 0, fileName );
m_item->setOffset( -QPointF( pixmap.size().width(), pixmap.size().height() ) / 2.0 );
m_item->setOffset( -QPointF( pixmap.size().height(), pixmap.size().width() ) / 2.0 );
m_ui->lineEdit->setText( fileName );
m_ui->buttonBox->setStandardButtons( m_ui->buttonBox->standardButtons() | QDialogButtonBox::Ok );
onResetSize();
}
void QDialogPixmap::posChanged()
{
m_item->setPos( m_ui->spinX->value(), m_ui->spinY->value() );
}
void QDialogPixmap::onResetSize()
{
m_ui->spinWidth->setValue( m_item->pixmap().size().width() / 10.0 );
m_ui->spinHeight->setValue( m_item->pixmap().size().height() / 10.0 );
}
void QDialogPixmap::sizeChanged()
{
if( m_ui->lockedRatio->checkState() == Qt::Checked ) {
QObject *senderObj = sender();
QSize size = m_item->pixmap().size();
if( senderObj == m_ui->spinWidth || senderObj == m_ui->lockedRatio ) {
m_ui->spinHeight->setValue( m_ui->spinWidth->value() / size.width() * size.height() );
} else {
m_ui->spinWidth->setValue( m_ui->spinHeight->value() / size.height() * size.width() );
}
}
m_item->setTransform( QTransform().scale( m_ui->spinWidth->value() / m_item->pixmap().size().width(),
m_ui->spinHeight->value() / m_item->pixmap().size().height() ) );
}
-2
View File
@@ -44,8 +44,6 @@ protected:
private slots:
void onLoadImage();
void posChanged();
void onResetSize();
void sizeChanged();
private:
Ui::QDialogPixmap *m_ui;
+21 -87
View File
@@ -8,12 +8,12 @@
<rect>
<x>0</x>
<y>0</y>
<width>464</width>
<height>618</height>
<width>542</width>
<height>649</height>
</rect>
</property>
<property name="windowTitle" >
<string>Image properties</string>
<string>Text properties</string>
</property>
<property name="modal" >
<bool>false</bool>
@@ -32,9 +32,15 @@
<property name="lineWidth" >
<number>3</number>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3" >
<layout class="QVBoxLayout" name="verticalLayout_2" >
<item>
<layout class="QHBoxLayout" name="horizontalLayout" >
<property name="sizeConstraint" >
<enum>QLayout::SetMaximumSize</enum>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<item>
<layout class="QFormLayout" name="formLayout" >
<item row="0" column="0" >
@@ -80,105 +86,33 @@
</layout>
</item>
<item>
<layout class="QFormLayout" name="formLayout_2" >
<layout class="QFormLayout" name="formLayout_3" >
<property name="fieldGrowthPolicy" >
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="0" column="0" >
<widget class="QLabel" name="label_3" >
<widget class="QLabel" name="label_5" >
<property name="text" >
<string>Width:</string>
<string>Image:</string>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QDoubleSpinBox" name="spinWidth" >
<property name="minimum" >
<double>1.000000000000000</double>
</property>
<property name="maximum" >
<double>200.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="label_4" >
<property name="text" >
<string>Height:</string>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QDoubleSpinBox" name="spinHeight" >
<property name="minimum" >
<double>1.000000000000000</double>
</property>
<property name="maximum" >
<double>200.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2" >
<item>
<widget class="QCheckBox" name="lockedRatio" >
<property name="text" >
<string>Locked ratio</string>
</property>
<property name="checked" >
<widget class="QLineEdit" name="lineEdit" >
<property name="readOnly" >
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnSizeReset" >
<item row="1" column="1" >
<widget class="QPushButton" name="btnImage" >
<property name="text" >
<string>Reset size</string>
<string>Load image...</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QFormLayout" name="formLayout_3" >
<property name="fieldGrowthPolicy" >
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="0" column="0" >
<widget class="QLabel" name="label_5" >
<property name="text" >
<string>Image:</string>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QLineEdit" name="lineEdit" >
<property name="readOnly" >
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QPushButton" name="btnImage" >
<property name="text" >
<string>Load image...</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
-20
View File
@@ -1,23 +1,3 @@
/* 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 "qdialogprint.h"
#include "ui_qdialogprint.h"
-20
View File
@@ -1,23 +1,3 @@
/* 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$ */
#ifndef QDIALOGPRINT_H
#define QDIALOGPRINT_H
+2 -47
View File
@@ -1,51 +1,21 @@
/* 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 "qdialogprogress.h"
#include "ui_qdialogprogress.h"
#include "qlightscribe.h"
#include "qdialogprint.h"
#include "qcdscene.h"
#include <QMessageBox>
#include <QAbstractButton>
#include <QTime>
#include <QTimer>
QDialogProgress::QDialogProgress(QWidget *parent) :
QDialog(parent),
m_ui(new Ui::QDialogProgress),
m_start( new QTime ),
m_timer( new QTimer( this ) )
m_ui(new Ui::QDialogProgress)
{
m_ui->setupUi(this);
m_start->start();
connect( m_timer, SIGNAL(timeout()), this, SLOT(onTimeout()) );
m_timer->start( 500 );
}
QDialogProgress::~QDialogProgress()
{
delete m_start;
delete m_timer;
delete m_ui;
delete m_ui;
}
void QDialogProgress::changeEvent(QEvent *e)
@@ -68,7 +38,6 @@ bool QDialogProgress::exec( QWidget *parent, QCDScene *scene )
QLightScribe *scribe = QLightScribe::instance();
QDialogProgress dialog( parent );
dialog.setWindowTitle( tr( "Printing: " ) + scene->name() );
connect( dialog.m_ui->buttonBox, SIGNAL(clicked(QAbstractButton*)), &dialog, SLOT(onButtonClicked(QAbstractButton*)) );
connect( scribe, SIGNAL(prepareProgress(long,long)), &dialog, SLOT(onPrepareProgress(long,long)) );
@@ -106,28 +75,14 @@ void QDialogProgress::onLabelProgress( long current, long final )
{
m_ui->progressPrinting->setMaximum( final );
m_ui->progressPrinting->setValue( current );
if( current && final / double( current ) < 10.0 ) {
int elapsed = m_start->elapsed();
int estimate = double( elapsed ) / current * final;
m_ui->timeEstimated->setTime( QTime().addMSecs( estimate ) );
}
}
void QDialogProgress::onTimeEstimate( long time )
{
m_ui->timeEstimated->setTime( QTime().addSecs( time ) );
}
void QDialogProgress::onFinished(int status )
{
m_timer->stop();
m_ui->progressPrinting->setValue( m_ui->progressPrinting->maximum() );
m_ui->lineResult->setText( status ? tr( "Failed - error code: 0x" ) + QString::number( status, 16 ) : tr( "Success" ) );
m_ui->buttonBox->setStandardButtons( QDialogButtonBox::Close );
}
void QDialogProgress::onTimeout()
{
m_ui->timeElapsed->setTime( QTime().addMSecs( m_start->elapsed() ) );
}
-25
View File
@@ -1,23 +1,3 @@
/* 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$ */
#ifndef QDIALOGPROGRESS_H
#define QDIALOGPROGRESS_H
@@ -29,8 +9,6 @@ namespace Ui {
class QCDScene;
class QAbstractButton;
class QTime;
class QTimer;
class QDialogProgress : public QDialog {
Q_OBJECT
@@ -44,7 +22,6 @@ protected slots:
void onLabelProgress( long current, long final );
void onTimeEstimate( long time );
void onFinished(int status );
void onTimeout();
protected:
virtual void changeEvent(QEvent *e);
@@ -54,8 +31,6 @@ private:
virtual ~QDialogProgress();
Ui::QDialogProgress *m_ui;
QTime *m_start;
QTimer *m_timer;
};
#endif // QDIALOGPROGRESS_H
+1 -10
View File
@@ -10,7 +10,7 @@
</rect>
</property>
<property name="windowTitle" >
<string>Print progress</string>
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2" >
<item>
@@ -85,9 +85,6 @@
<property name="displayFormat" >
<string>hh:mm:ss</string>
</property>
<property name="currentSectionIndex" >
<number>0</number>
</property>
</widget>
</item>
<item row="1" column="0" >
@@ -175,12 +172,6 @@
</item>
</layout>
</widget>
<tabstops>
<tabstop>buttonBox</tabstop>
<tabstop>lineResult</tabstop>
<tabstop>timeEstimated</tabstop>
<tabstop>timeElapsed</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>
+3 -4
View File
@@ -20,7 +20,7 @@
#include "qdialogroundtext.h"
#include "ui_qdialogroundtext.h"
#include "qlightroundtextitem.h"
#include "qgraphicsroundtextitem.h"
#include "qcdscene.h"
#include <QFontDialog>
@@ -55,13 +55,13 @@ void QDialogRoundText::changeEvent(QEvent *e)
bool QDialogRoundText::exec( QGraphicsItem *graphicsItem )
{
QLightRoundTextItem *item = dynamic_cast< QLightRoundTextItem * >( graphicsItem );
QGraphicsRoundTextItem *item = dynamic_cast< QGraphicsRoundTextItem * >( graphicsItem );
if( !item )
return false;
QCDScene scene;
m_ui->cdView->setScene( &scene );
m_item = new QLightRoundTextItem;
m_item = new QGraphicsRoundTextItem;
m_item->setPos( item->pos() );
m_item->setText( item->text() );
@@ -129,7 +129,6 @@ void QDialogRoundText::onFont()
{
bool ok = true;
QFont font = QFontDialog::getFont( &ok, m_item->font(), this );
//font.setPointSizeF( font.pointSizeF() / 2.0 );
if( ok ) {
m_item->setFont( font );
fontChanged();
+4 -4
View File
@@ -16,7 +16,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
$Id$ */
$Id:$ */
#ifndef QDIALOGROUNDTEXT_H
#define QDIALOGROUNDTEXT_H
@@ -27,7 +27,7 @@ namespace Ui {
class QDialogRoundText;
}
class QLightRoundTextItem;
class QGraphicsRoundTextItem;
class QDialogRoundText : public QItemDialog {
Q_OBJECT
@@ -54,8 +54,8 @@ private slots:
void locChanged();
private:
Ui::QDialogRoundText *m_ui;
QLightRoundTextItem *m_item;
Ui::QDialogRoundText *m_ui;
QGraphicsRoundTextItem *m_item;
};
#endif // QDIALOGROUNDTEXT_H
-3
View File
@@ -206,9 +206,6 @@
</item>
<item row="0" column="1" >
<widget class="QFontComboBox" name="fontName" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="editable" >
<bool>false</bool>
</property>
+1 -2
View File
@@ -16,7 +16,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
$Id$ */
$Id:$ */
#include "qdialogtext.h"
#include "ui_qdialogtext.h"
@@ -66,7 +66,6 @@ bool QDialogText::exec( QGraphicsItem *graphicsItem )
m_item->setText( item->text() );
m_item->setFont( item->font() );
m_item->setBrush( item->brush() );
m_item->setTransform( item->transform() );
scene.addItem( m_item );
@@ -16,98 +16,95 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
$Id$ */
$Id:$ */
#include "qlightroundtextitem.h"
#include "qgraphicsroundtextitem.h"
#include "qdialogroundtext.h"
#include "qcdscene.h"
#include <QPainter>
#include <QFontMetrics>
#include <QStyleOptionGraphicsItem>
#include <QMessageBox>
#include <QXmlStreamWriter>
#include <QTextLayout>
#include <math.h>
QLightRoundTextItem::QLightRoundTextItem( QGraphicsItem *parent )
QGraphicsRoundTextItem::QGraphicsRoundTextItem( QGraphicsItem *parent )
: QAbstractGraphicsShapeItem( parent ),
m_radius( 40.0 ),
m_angle( 0.0 ),
m_alignment( Qt::AlignLeft ),
m_outside( true )
{
setBrush( Qt::black );
}
const QFont & QLightRoundTextItem::font() const
const QFont & QGraphicsRoundTextItem::font() const
{
return m_font;
}
const QString & QLightRoundTextItem::text() const
const QString & QGraphicsRoundTextItem::text() const
{
return m_text;
}
double QLightRoundTextItem::radius() const
double QGraphicsRoundTextItem::radius() const
{
return m_radius;
}
double QLightRoundTextItem::angle() const
double QGraphicsRoundTextItem::angle() const
{
return m_angle;
}
Qt::Alignment QLightRoundTextItem::alignment() const
Qt::Alignment QGraphicsRoundTextItem::alignment() const
{
return m_alignment;
}
bool QLightRoundTextItem::outside() const
bool QGraphicsRoundTextItem::outside() const
{
return m_outside;
}
void QLightRoundTextItem::setFont( const QFont &font )
void QGraphicsRoundTextItem::setFont( const QFont &font )
{
prepareGeometryChange();
m_font = font;
}
void QLightRoundTextItem::setText( const QString &text )
void QGraphicsRoundTextItem::setText( const QString &text )
{
prepareGeometryChange();
m_text = text;
}
void QLightRoundTextItem::setRadius( double radius )
void QGraphicsRoundTextItem::setRadius( double radius )
{
prepareGeometryChange();
m_radius = radius;
}
void QLightRoundTextItem::setAngle( double angle )
void QGraphicsRoundTextItem::setAngle( double angle )
{
prepareGeometryChange();
m_angle = angle;
}
void QLightRoundTextItem::setAlignment( Qt::Alignment alignment )
void QGraphicsRoundTextItem::setAlignment( Qt::Alignment alignment )
{
prepareGeometryChange();
m_alignment = alignment;
}
void QLightRoundTextItem::setOutside( bool outside )
void QGraphicsRoundTextItem::setOutside( bool outside )
{
prepareGeometryChange();
m_outside = outside;
}
QRectF QLightRoundTextItem::boundingRect() const
QRectF QGraphicsRoundTextItem::boundingRect() const
{
double height = m_radius;
if( m_outside ) {
@@ -118,11 +115,9 @@ QRectF QLightRoundTextItem::boundingRect() const
return QRectF( -height, -height, 2 * height, 2 * height );
}
QPainterPath QLightRoundTextItem::shape() const
QPainterPath QGraphicsRoundTextItem::shape() const
{
QFont font( m_font );
font.setPointSizeF( m_font.pointSizeF() / 2 );
QFontMetrics mcs( font );
QFontMetrics mcs( m_font );
double arcAngle = 0.0;
const double pad = 1;
@@ -169,20 +164,18 @@ QPainterPath QLightRoundTextItem::shape() const
}
void QLightRoundTextItem::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget )
void QGraphicsRoundTextItem::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget )
{
Q_UNUSED( option );
Q_UNUSED( widget );
if( !painter || !m_radius ) return;
painter->save();
QFont font( m_font );
font.setPointSizeF( m_font.pointSizeF() / 2 );
painter->setFont( font );
painter->setFont( m_font );
//painter->drawEllipse( - m_radius, - m_radius, m_radius * 2, m_radius * 2 );
QFontMetrics mcs( font );
QFontMetrics mcs( m_font );
const double radi = m_radius - ( m_outside ? 0 : mcs.xHeight() );
const double diam = 2 * radi;
@@ -199,14 +192,8 @@ void QLightRoundTextItem::paint( QPainter *painter, const QStyleOptionGraphicsIt
QTransform trans;
trans.rotateRadians( angle );
painter->setRenderHint( QPainter::TextAntialiasing, true );
painter->setWorldTransform( trans, true );
QPen p;
p.setBrush( brush() );
painter->setPen( p );
painter->setBrush( Qt::NoBrush );
int prevWidth = 0;
for( int i = 0; i < m_text.size(); ++i ) {
QChar ch = m_text[ i ];
@@ -215,12 +202,9 @@ void QLightRoundTextItem::paint( QPainter *painter, const QStyleOptionGraphicsIt
trans.reset();
trans.rotateRadians( m_outside ? d : -d );
painter->setWorldTransform( trans, true );
prevWidth = mcs.width( ch );
painter->drawText( int( -prevWidth / 2.0 ),
int( m_outside ? -m_radius : m_radius ),
ch );
painter->drawText( -prevWidth / 2.0, m_outside ? -m_radius : m_radius, ch );
}
painter->restore();
if (option->state & QStyle::State_Selected) {
@@ -230,14 +214,6 @@ void QLightRoundTextItem::paint( QPainter *painter, const QStyleOptionGraphicsIt
}
}
QVariant QLightRoundTextItem::itemChange( GraphicsItemChange change, const QVariant & value )
{
if( scene() && change == ItemPositionHasChanged )
static_cast<QCDScene *>( scene() )->setChanged();
return value;
}
RegisterController< QShapeControllerRoundText > regControllerRoundText;
QString QShapeControllerRoundText::name() const
@@ -252,8 +228,7 @@ QString QShapeControllerRoundText::menuName() const
QGraphicsItem *QShapeControllerRoundText::create() const
{
QLightRoundTextItem *item = new QLightRoundTextItem;
return item;
return new QGraphicsRoundTextItem;
}
QItemDialog *QShapeControllerRoundText::createDialog( QWidget *parent ) const
@@ -263,7 +238,7 @@ QItemDialog *QShapeControllerRoundText::createDialog( QWidget *parent ) const
void QShapeControllerRoundText::writeData( QXmlStreamWriter &writer, const QGraphicsItem *item ) const
{
const QLightRoundTextItem *textItem = static_cast< const QLightRoundTextItem * >( item );
const QGraphicsRoundTextItem *textItem = static_cast< const QGraphicsRoundTextItem * >( item );
writer.writeEmptyElement( "pos" );
writer.writeAttribute( QXmlStreamAttribute( "x", QString::number( textItem->pos().x() ) ) );
writer.writeAttribute( QXmlStreamAttribute( "y", QString::number( textItem->pos().y() ) ) );
@@ -282,7 +257,7 @@ void QShapeControllerRoundText::readData( const QString &element,
const QString &data,
QGraphicsItem *item ) const
{
QLightRoundTextItem *textItem = static_cast< QLightRoundTextItem * >( item );
QGraphicsRoundTextItem *textItem = static_cast< QGraphicsRoundTextItem * >( item );
if( element == "pos" ) {
textItem->setPos( attrs.value( "x" ).toString().toDouble(),
@@ -312,11 +287,6 @@ void QShapeControllerRoundText::readData( const QString &element,
return;
}
if( element == "angle" ) {
textItem->setAngle( data.toDouble() );
return;
}
if( element == "alignment" ) {
textItem->setAlignment( Qt::Alignment( data.toInt() ) );
return;
@@ -16,21 +16,21 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
$Id$ */
$Id:$ */
#ifndef QLIGHTROUNDTEXTITEM_H
#define QLIGHTROUNDTEXTITEM_H
#ifndef QGRAPHICSROUNDTEXTITEM_H
#define QGRAPHICSROUNDTEXTITEM_H
#include "qshapefactory.h"
#include <QAbstractGraphicsShapeItem>
#include <QFont>
class QLightRoundTextItem : public QAbstractGraphicsShapeItem {
class QGraphicsRoundTextItem : public QAbstractGraphicsShapeItem {
public:
enum { Type = UserType + 1 };
QLightRoundTextItem( QGraphicsItem * parent = 0 );
QGraphicsRoundTextItem( QGraphicsItem * parent = 0 );
const QFont &font() const;
const QString &text() const;
@@ -53,10 +53,6 @@ public:
QWidget *widget );
virtual int type() const { return Type; }
protected:
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant & value );
private:
QFont m_font;
QString m_text;
@@ -68,7 +64,7 @@ private:
class QShapeControllerRoundText : public QShapeController {
public:
enum { Type = QLightRoundTextItem::Type };
enum { Type = QGraphicsRoundTextItem::Type };
virtual QString name() const;
virtual QString menuName() const;
@@ -85,4 +81,4 @@ protected:
};
#endif // QLIGHTROUNDTEXTITEM_H
#endif // QGRAPHICSROUNDTEXTITEM_H
-56
View File
@@ -1,56 +0,0 @@
/* 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$ */
#ifndef QLIGHTPIXMAPITEM_H
#define QLIGHTPIXMAPITEM_H
#include <QGraphicsPixmapItem>
#include "qshapefactory.h"
class QLightPixmapItem : public QGraphicsPixmapItem
{
public:
QLightPixmapItem();
protected:
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant & value );
};
class QShapeControllerPixmap : public QShapeController {
public:
enum { Type = QLightPixmapItem::Type };
virtual QString name() const;
virtual QString menuName() const;
virtual QGraphicsItem *create() const;
protected:
virtual QItemDialog *createDialog( QWidget *parent ) const;
virtual void writeData( QXmlStreamWriter &writer, const QGraphicsItem *item ) const;
virtual void readData( const QString &element,
const QXmlStreamAttributes &attrs,
const QString &data,
QGraphicsItem *item ) const;
};
#endif // QLIGHTPIXMAPITEM_H
+51 -119
View File
@@ -201,69 +201,6 @@ bool QLightScribe::clReportLabelTimeEstimate(long time)
return false;
}
namespace {
class AutoUidSetter {
public:
AutoUidSetter() : m_saved( 0 ) {}
AutoUidSetter( uid_t userId ) : m_saved( 0 ) { set( userId ); }
~AutoUidSetter() { unset(); }
void set( uid_t userId )
{
if( userId ) {
setreuid( userId, 0 );
m_saved = userId;
}
}
void unset()
{
if( m_saved ) {
setreuid( 0, m_saved );
m_saved = 0;
}
}
private:
uid_t m_saved;
};
typedef void (LightScribe::DiscPrinter::*DiscPrinterOp)();
template<DiscPrinterOp dlock, DiscPrinterOp dunlock >
class AutoOp {
public:
AutoOp( LightScribe::DiscPrinter &printer ) : m_printer( &printer ), m_locked( false ) {}
AutoOp() { unlock(); }
void lock()
{
if( !m_locked ) {
(m_printer->*dlock)();
m_locked = true;
}
}
void unlock()
{
if( m_locked ) {
try {
(m_printer->*dunlock)();
}
catch(...){}
m_locked = false;
}
}
private:
LightScribe::DiscPrinter *m_printer;
bool m_locked;
};
}
extern uid_t realUserId;
void QLightScribe::run()
{
QMutexLocker lock( m_mutex );
@@ -317,74 +254,69 @@ void QLightScribe::run()
throw tr( "Cannot find drive: \"" ) + m_task->m_selectedDrive->displayName() + "\"";
DiscPrinter printer = printers.Item( found );
function = "LS_DiscPrinter_OpenPrintSession";
DiscPrintSession session = printer.OpenPrintSession();
AutoUidSetter autoUid;
AutoOp< &DiscPrinter::AddExclusiveUse, &DiscPrinter::ReleaseExclusiveUse > autoExclusive( printer );
AutoOp< &DiscPrinter::LockDriveTray, &DiscPrinter::UnlockDriveTray > autoLock( printer );
LS_PrintCallbacks callbacks;
callbacks.AbortLabel = clAbortLabel;
callbacks.ReportPrepareProgress = clReportPrepareProgress;
callbacks.ReportLabelProgress = clReportLabelProgress;
callbacks.ReportFinished = clReportFinished;
callbacks.ReportLabelTimeEstimate = clReportLabelTimeEstimate;
if( m_task->m_action == Task::print ) {
autoUid.set( realUserId );
function = "LS_DiscPrinter_AddExclusiveUse";
autoExclusive.lock();
function = "LS_DiscPrinter_LockDriveTray";
autoLock.lock();
}
session.SetProgressCallback( &callbacks );
{
function = "LS_DiscPrinter_OpenPrintSession";
DiscPrintSession session = printer.OpenPrintSession();
const size_t bitmapHeaderSize = 54;
LS_PrintCallbacks callbacks;
callbacks.AbortLabel = clAbortLabel;
callbacks.ReportPrepareProgress = clReportPrepareProgress;
callbacks.ReportLabelProgress = clReportLabelProgress;
callbacks.ReportFinished = clReportFinished;
callbacks.ReportLabelTimeEstimate = clReportLabelTimeEstimate;
if( m_task->m_action == Task::preview ) {
session.SetProgressCallback( &callbacks );
LS_Size size;
size.x = m_task->m_size.width();
size.y = m_task->m_size.height();
const size_t bitmapHeaderSize = 54;
m_task->m_tmpFile.open();
if( m_task->m_action == Task::preview ) {
LS_Size size;
size.x = m_task->m_size.width();
size.y = m_task->m_size.height();
m_task->m_tmpFile.open();
function = "LS_DiscPrintSession_PrintPreview";
session.PrintPreview( LS_windows_bitmap,
LS_LabelMode( m_task->m_parameters.m_labelMode ),
LS_DrawOptions( m_task->m_parameters.m_drawOptions ),
LS_PrintQuality( m_task->m_parameters.m_printQuality ),
LS_MediaOptimizationLevel( m_task->m_parameters.m_mediaOptimizationLevel ),
ba.data() + 14,
bitmapHeaderSize - 14,
ba.data() + bitmapHeaderSize,
ba.size() - bitmapHeaderSize,
m_task->m_tmpFile.fileName().toAscii().data(),
LS_windows_bitmap,
size,
true );
} else {
PrintParameters params = m_task->m_parameters;
delete m_task;
m_task = 0;
lock.unlock();
// print here
session.PrintDisc( LS_windows_bitmap,
LS_LabelMode( params.m_labelMode ),
LS_DrawOptions( params.m_drawOptions ),
LS_PrintQuality( params.m_printQuality ),
LS_MediaOptimizationLevel( params.m_mediaOptimizationLevel ),
function = "LS_DiscPrintSession_PrintPreview";
session.PrintPreview( LS_windows_bitmap,
LS_LabelMode( m_task->m_parameters.m_labelMode ),
LS_DrawOptions( m_task->m_parameters.m_drawOptions ),
LS_PrintQuality( m_task->m_parameters.m_printQuality ),
LS_MediaOptimizationLevel( m_task->m_parameters.m_mediaOptimizationLevel ),
ba.data() + 14,
bitmapHeaderSize - 14,
ba.data() + bitmapHeaderSize,
ba.size() - bitmapHeaderSize );
ba.size() - bitmapHeaderSize,
m_task->m_tmpFile.fileName().toAscii().data(),
LS_windows_bitmap,
size,
true );
} else {
PrintParameters params = m_task->m_parameters;
delete m_task;
m_task = 0;
lock.unlock();
// print here
try {
//printer.AddExclusiveUse();
//printer.LockDriveTray();
session.PrintDisc( LS_windows_bitmap,
LS_LabelMode( params.m_labelMode ),
LS_DrawOptions( params.m_drawOptions ),
LS_PrintQuality( params.m_printQuality ),
LS_MediaOptimizationLevel( params.m_mediaOptimizationLevel ),
ba.data() + 14,
bitmapHeaderSize - 14,
ba.data() + bitmapHeaderSize,
ba.size() - bitmapHeaderSize );
}
catch( LightScribe::LSException &ex ) {
emit finished( ex.GetCode() );
throw;
}
}
//printer.UnlockDriveTray();
//printer.ReleaseExclusiveUse();
}
function = "";
}
}
-109
View File
@@ -1,109 +0,0 @@
/* 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 "qlighttextitem.h"
#include "qdialogtext.h"
#include "qcdscene.h"
#include <QXmlStreamWriter>
#include <QXmlStreamReader>
QLightTextItem::QLightTextItem()
{
}
QVariant QLightTextItem::itemChange( GraphicsItemChange change, const QVariant & value )
{
if( scene() && change == ItemPositionHasChanged )
static_cast<QCDScene *>( scene() )->setChanged();
return value;
}
RegisterController< QShapeControllerText > regControllerText;
QString QShapeControllerText::name() const
{
return "text";
}
QString QShapeControllerText::menuName() const
{
return QObject::tr( "Text", "QShapeControllerText name" );
}
QGraphicsItem *QShapeControllerText::create() const
{
QGraphicsItem *item = new QLightTextItem;
item->setTransform( QTransform().scale( 0.5, 0.5 ), true );
return item;
}
QItemDialog *QShapeControllerText::createDialog( QWidget *parent ) const
{
return new QDialogText( parent );
}
void QShapeControllerText::writeData( QXmlStreamWriter &writer, const QGraphicsItem *item ) const
{
const QGraphicsSimpleTextItem *textItem = static_cast< const QGraphicsSimpleTextItem * >( item );
writer.writeEmptyElement( "pos" );
writer.writeAttribute( QXmlStreamAttribute( "x", QString::number( textItem->pos().x() ) ) );
writer.writeAttribute( QXmlStreamAttribute( "y", QString::number( textItem->pos().y() ) ) );
writer.writeTextElement( "font", textItem->font().toString() );
writer.writeTextElement( "color", textItem->brush().color().name() );
writer.writeTextElement( "text", textItem->text() );
}
void QShapeControllerText::readData( const QString &element,
const QXmlStreamAttributes &attrs,
const QString &data,
QGraphicsItem *item ) const
{
QGraphicsSimpleTextItem *textItem = static_cast< QGraphicsSimpleTextItem * >( item );
if( element == "pos" ) {
textItem->setPos( attrs.value( "x" ).toString().toDouble(),
attrs.value( "y" ).toString().toDouble() );
return;
}
if( element == "font" ) {
QFont font;
font.fromString( data );
textItem->setFont( font );
return;
}
if( element == "color" ) {
textItem->setBrush( QColor( data ) );
return;
}
if( element == "text" ) {
textItem->setText( data );
return;
}
}
+6 -9
View File
@@ -1,38 +1,35 @@
TEMPLATE = app
LANGUAGE = C++
CONFIG += qt
INCLUDEPATH += ../build/src
QMAKE_CXXFLAGS += -m32
QMAKE_LFLAGS += -m32
QMAKE_LIBDIR = /usr/lib32
SOURCES += main.cpp \
mainwindow.cpp \
qlightroundtextitem.cpp \
qgraphicsroundtextitem.cpp \
qcdview.cpp \
qcdscene.cpp \
qshapefactory.cpp \
qshapecontrollers.cpp \
qdialogtext.cpp \
qdialogroundtext.cpp \
qlightscribe.cpp \
qdialogpixmap.cpp \
qdialogprint.cpp \
qdialogprogress.cpp \
qlighttextitem.cpp \
qlightpixmapitem.cpp
qdialogprogress.cpp
QMAKE_LIBS += -llightscribe
HEADERS += mainwindow.h \
qlightroundtextitem.h \
qgraphicsroundtextitem.h \
qcdview.h \
qcdscene.h \
qshapefactory.h \
qshapecontrollers.h \
qdialogtext.h \
qdialogroundtext.h \
qlightscribe.h \
qdialogpixmap.h \
qdialogprint.h \
qdialogprogress.h \
qlighttextitem.h \
qlightpixmapitem.h
qdialogprogress.h
FORMS += qdialogtext.ui \
qdialogroundtext.ui \
qdialogpixmap.ui \
@@ -18,25 +18,78 @@
$Id$ */
#include "qlightpixmapitem.h"
#include "qshapecontrollers.h"
#include "qdialogtext.h"
#include "qdialogpixmap.h"
#include "qcdscene.h"
#include <QXmlStreamWriter>
#include <QXmlStreamReader>
QLightPixmapItem::QLightPixmapItem()
RegisterController< QShapeControllerText > regControllerText;
QString QShapeControllerText::name() const
{
return "text";
}
QVariant QLightPixmapItem::itemChange( GraphicsItemChange change, const QVariant & value )
QString QShapeControllerText::menuName() const
{
if( scene() && change == ItemPositionHasChanged )
static_cast<QCDScene *>( scene() )->setChanged();
return value;
return QObject::tr( "Text", "QShapeControllerText name" );
}
QGraphicsItem *QShapeControllerText::create() const
{
return new QGraphicsSimpleTextItem;
}
QItemDialog *QShapeControllerText::createDialog( QWidget *parent ) const
{
return new QDialogText( parent );
}
void QShapeControllerText::writeData( QXmlStreamWriter &writer, const QGraphicsItem *item ) const
{
const QGraphicsSimpleTextItem *textItem = static_cast< const QGraphicsSimpleTextItem * >( item );
writer.writeEmptyElement( "pos" );
writer.writeAttribute( QXmlStreamAttribute( "x", QString::number( textItem->pos().x() ) ) );
writer.writeAttribute( QXmlStreamAttribute( "y", QString::number( textItem->pos().y() ) ) );
writer.writeTextElement( "font", textItem->font().toString() );
writer.writeTextElement( "color", textItem->brush().color().name() );
writer.writeTextElement( "text", textItem->text() );
}
void QShapeControllerText::readData( const QString &element,
const QXmlStreamAttributes &attrs,
const QString &data,
QGraphicsItem *item ) const
{
QGraphicsSimpleTextItem *textItem = static_cast< QGraphicsSimpleTextItem * >( item );
if( element == "pos" ) {
textItem->setPos( attrs.value( "x" ).toString().toDouble(),
attrs.value( "y" ).toString().toDouble() );
return;
}
if( element == "font" ) {
QFont font;
font.fromString( data );
textItem->setFont( font );
return;
}
if( element == "color" ) {
textItem->setBrush( QColor( data ) );
return;
}
if( element == "text" ) {
textItem->setText( data );
return;
}
}
RegisterController< QShapeControllerPixmap > regControllerPixmap;
@@ -52,11 +105,7 @@ QString QShapeControllerPixmap::menuName() const
QGraphicsItem *QShapeControllerPixmap::create() const
{
QGraphicsPixmapItem *item = new QLightPixmapItem;
item->setShapeMode( QGraphicsPixmapItem::BoundingRectShape );
item->setTransformationMode( Qt::SmoothTransformation );
return item;
return new QGraphicsPixmapItem;
}
QItemDialog *QShapeControllerPixmap::createDialog( QWidget *parent ) const
@@ -72,16 +121,10 @@ void QShapeControllerPixmap::writeData( QXmlStreamWriter &writer, const QGraphic
writer.writeEmptyElement( "pos" );
writer.writeAttribute(
QXmlStreamAttribute( "x", QString::number( pixmapItem->pos().x() ) ) );
writer.writeAttribute(
QXmlStreamAttribute( "y", QString::number( pixmapItem->pos().y() ) ) );
QPointF scale = pixmapItem->transform().map( QPointF( 1.0, 1.0 ) );
writer.writeEmptyElement( "scale" );
writer.writeAttribute(
QXmlStreamAttribute( "sx", QString::number( scale.x() ) ) );
writer.writeAttribute(
QXmlStreamAttribute( "sy", QString::number( scale.y() ) ) );
writer.writeTextElement( "image", pixmapItem->data( 0 ).toString() );
}
@@ -99,11 +142,6 @@ void QShapeControllerPixmap::readData( const QString &element,
return;
}
if( element == "scale" ) {
pixmapItem->setTransform( QTransform().scale( attrs.value( "sx" ).toString().toDouble(),
attrs.value( "sy" ).toString().toDouble() ) );
}
if( element == "image" ) {
pixmapItem->setData( 0, data );
QPixmap pixmap( data );
@@ -18,26 +18,17 @@
$Id$ */
#ifndef QLIGHTTEXTITEM_H
#define QLIGHTTEXTITEM_H
#include <QGraphicsSimpleTextItem>
#ifndef QSHAPECONTROLLERS_H
#define QSHAPECONTROLLERS_H
#include "qshapefactory.h"
class QLightTextItem : public QGraphicsSimpleTextItem
{
public:
QLightTextItem();
protected:
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant & value );
};
#include <QGraphicsSimpleTextItem>
#include <QGraphicsPixmapItem>
class QShapeControllerText : public QShapeController {
public:
enum { Type = QLightTextItem::Type };
enum { Type = QGraphicsSimpleTextItem::Type };
virtual QString name() const;
virtual QString menuName() const;
@@ -53,4 +44,22 @@ protected:
QGraphicsItem *item ) const;
};
#endif // QLIGHTTEXTITEM_H
class QShapeControllerPixmap : public QShapeController {
public:
enum { Type = QGraphicsPixmapItem::Type };
virtual QString name() const;
virtual QString menuName() const;
virtual QGraphicsItem *create() const;
protected:
virtual QItemDialog *createDialog( QWidget *parent ) const;
virtual void writeData( QXmlStreamWriter &writer, const QGraphicsItem *item ) const;
virtual void readData( const QString &element,
const QXmlStreamAttributes &attrs,
const QString &data,
QGraphicsItem *item ) const;
};
#endif // QSHAPECONTROLLERS_H
+1 -6
View File
@@ -16,10 +16,9 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
$Id$ */
$Id:$ */
#include "qshapefactory.h"
#include "qcdscene.h"
#include <QGraphicsItem>
#include <QMessageBox>
@@ -44,10 +43,6 @@ bool QShapeController::edit( QGraphicsItem *item, QWidget *parent ) const
throw;
}
delete dialog;
if( rez && item->scene() )
static_cast< QCDScene * >( item->scene() )->setChanged();
return rez;
}