7 Commits

Author SHA1 Message Date
ruglory 038e449c0f Tagging the 0.3 release
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/tags/release-0.3@30 cac9541e-1b8d-4bfa-827e-589bba606050
2009-01-29 02:33:22 +00:00
ruglory 85fc6fed99 News for release 0.3 added
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@29 cac9541e-1b8d-4bfa-827e-589bba606050
2009-01-29 02:30:43 +00:00
ruglory 00e160bf1f Confirmation dialog added on main window close to save changed documents
Confirmation dialog added to QCDView close to save if changed


git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@28 cac9541e-1b8d-4bfa-827e-589bba606050
2009-01-29 02:18:28 +00:00
ruglory 357067be63 When new item added or edited by dialog cdscene notified to be changed
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@27 cac9541e-1b8d-4bfa-827e-589bba606050
2009-01-28 21:42:15 +00:00
ruglory 78eafba502 Install updated
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@26 cac9541e-1b8d-4bfa-827e-589bba606050
2009-01-28 21:10:08 +00:00
ruglory 2031990216 Added environment variable LIGHTSCRIBEDIR to help cmake find lightScribe api
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@25 cac9541e-1b8d-4bfa-827e-589bba606050
2009-01-28 21:06:37 +00:00
ruglory e8125ce680 Added filename and name to cd scene
Added name title on cdview window
Open, "save as" and save reimplemented


git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@24 cac9541e-1b8d-4bfa-827e-589bba606050
2009-01-28 05:45:57 +00:00
11 changed files with 266 additions and 67 deletions
+6 -1
View File
@@ -21,9 +21,14 @@ Then go to the source directory and type:
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 "sudo qlscribe"
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:
+6
View File
@@ -1,5 +1,11 @@
NEWS - list of user-visible changes between releases of qlscribe
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
+3 -2
View File
@@ -18,13 +18,14 @@
#
# $Id$
FIND_PATH( LSCRIBE_INCLUDE_DIR lightscribe.h /usr/local/include )
FIND_PATH( LSCRIBE_INCLUDE_DIR lightscribe.h /usr/local/include $ENV{LIGHTSCRIBEDIR}/include )
FIND_LIBRARY( LSCRIBE_LIBRARY lightscribe /usr/local/lib )
FIND_LIBRARY( LSCRIBE_LIBRARY lightscribe /usr/local/lib $ENV{LIGHTSCRIBEDIR}/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 )
+84 -56
View File
@@ -34,16 +34,8 @@
#include <QMessageBox>
#include <QSignalMapper>
#include <QFileDialog>
#include <QXmlStreamWriter>
#include <QLabel>
/*#include <QImage>
#include <QBuffer>
#include <QGraphicsScene>
#include <QFontDialog>
#include <QPainter>*/
//#include <lightscribe.h>
#include <QCloseEvent>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
@@ -116,11 +108,75 @@ 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;
newView->setScene( new QCDScene( newView ) );
//newView->setWindowTitle( "Baba" );
QCDScene *scene = new QCDScene( newView );
newView->setScene( scene );
scene->setName();
QMdiSubWindow *subWindow = m_mdiArea->addSubWindow( newView );
subWindow->show();
}
@@ -161,6 +217,7 @@ void MainWindow::onMenuInsert( int id )
item->setFlag( QGraphicsItem::ItemIsMovable, true );
item->setFlag( QGraphicsItem::ItemIsSelectable, true );
cdscene->addItem( item );
cdscene->setChanged();
}
void MainWindow::onMenuOpen()
@@ -173,33 +230,31 @@ 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 );
QXmlStreamReader reader( &file );
try {
scene->read( reader );
}
catch( const QString &err ) {
QMessageBox::critical( this, tr( "Error" ), tr( "Cannot read file " ) + fileName + "\n" + err );
if( !scene->load( fileName ) ) {
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()
@@ -219,6 +274,7 @@ 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 ) {
@@ -235,40 +291,12 @@ 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.2 $Revision$</p>"
"<p>release 0.3 $Revision$</p>"
"<p>visit project at home page "
"<a href=\"http://qlscribe.sourceforge.net/\">qlscribe.sourceforge.net</a></p>" ) );
}
+7
View File
@@ -25,6 +25,7 @@
class QMdiArea;
class QSignalMapper;
class QCDScene;
class MainWindow : public QMainWindow {
Q_OBJECT
@@ -33,6 +34,10 @@ public:
explicit MainWindow(QWidget *parent = 0);
virtual ~MainWindow();
bool saveScene( QCDScene *scene );
protected:
virtual void closeEvent( QCloseEvent *event );
private slots:
void onMenuNew();
void onMenuOpen();
@@ -45,6 +50,8 @@ private slots:
void onMenuQtAbout();
private:
bool saveSceneAs( QCDScene *scene );
QMdiArea *m_mdiArea;
QMenu *m_menuFile;
+96 -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 "qcdscene.h"
#include "qshapefactory.h"
@@ -25,10 +25,17 @@
#include <QMessageBox>
#include <QGraphicsItem>
#include <QGraphicsSceneMouseEvent>
#include <QFile>
#include <QXmlStreamReader>
#include <QXmlStreamWriter>
#include <QMessageBox>
#include <QGraphicsView>
#include <QRegExp>
QCDScene::QCDScene( QObject * parent )
: QGraphicsScene( parent )
: QGraphicsScene( parent ),
m_index( 0 ),
m_saved( true )
{
setSceneRect( -60.0, -60.0, 60.0 * 2, 60.0 * 2 );
}
@@ -39,6 +46,93 @@ 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();
+22 -3
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,14 +32,33 @@ public:
QCDScene( QObject * parent = 0 );
virtual ~QCDScene();
void write( QXmlStreamWriter &writer );
void read( QXmlStreamReader &reader );
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; }
protected:
virtual void contextMenuEvent( QGraphicsSceneContextMenuEvent *contextMenuEvent );
private slots:
void onMenuEdit();
private:
void write( QXmlStreamWriter &writer );
void read( QXmlStreamReader &reader );
private:
QString m_name;
QString m_fileName;
int m_index;
bool m_saved;
};
#endif //QCDSCENE_H
+32 -1
View File
@@ -16,10 +16,14 @@
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 ),
@@ -49,6 +53,33 @@ 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 )
{
+2 -1
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,6 +39,7 @@ 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 );
+2
View File
@@ -22,6 +22,7 @@
#include "ui_qdialogprogress.h"
#include "qlightscribe.h"
#include "qdialogprint.h"
#include "qcdscene.h"
#include <QMessageBox>
#include <QAbstractButton>
@@ -67,6 +68,7 @@ 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)) );
+6 -1
View File
@@ -16,9 +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 "qshapefactory.h"
#include "qcdscene.h"
#include <QGraphicsItem>
#include <QMessageBox>
@@ -43,6 +44,10 @@ bool QShapeController::edit( QGraphicsItem *item, QWidget *parent ) const
throw;
}
delete dialog;
if( rez && item->scene() )
static_cast< QCDScene * >( item->scene() )->setChanged();
return rez;
}