2 Commits

Author SHA1 Message Date
ruglory 317864659f Tagging the 0.8 release
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/tags/release-0.8@115 cac9541e-1b8d-4bfa-827e-589bba606050
2009-03-05 03:41:22 +00:00
ruglory 9925d346db Tagging the 0.8 release
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/tags/release-0.8@112 cac9541e-1b8d-4bfa-827e-589bba606050
2009-03-05 03:06:10 +00:00
24 changed files with 66 additions and 534 deletions
-1
View File
@@ -22,7 +22,6 @@ PROJECT( qlscribe )
CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0)
SET( FINAL_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX} CACHE PATH "Final install path")
SET( CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake )
SET( QLSCRIBE_DBUS_SERVICE org.lightscribe )
-7
View File
@@ -1,12 +1,5 @@
NEWS - list of user-visible changes between releases of qlscribe
New in 0.9:
Parameter --image added to print label in console mode into image
Parameter --file added to process file in format KEY=VALUE
Copy/cut/paste added for items in label
Menu rearranged and menu items enabled/disabled based on state
Application icon added
New in 0.8:
Application is splitted into 2 parts: qlscribe and dbus daemon lscribed
qlscribe does not require sticky bit and can be compiled in 64 bit mode if necessary
+2 -2
View File
@@ -1,5 +1,5 @@
qlscribe (0.8-0ubuntu1) unstable; urgency=low
* Release 0.8 imported
qlscribe (0.7-0ubuntu1) unstable; urgency=low
* Initial release
-- Vyacheslav Kononenko <vyacheslav@kononenko.net> Sun, 15 Feb 2009 21:49:41 -0500
+2 -2
View File
@@ -7,7 +7,7 @@ Standards-Version: 3.7.3
Homepage: http://qlscribe.sourceforge.net/
Package: qlscribe
Architecture: any
Depends: ${shlibs:Depends}, lightscribe
Architecture: i386
Depends: ${shlibs:Depends}, lightscribe, libstdc++5
Description: Qt based application to print lightScribe discs
Qt lightScribe is a GUI application to burn labels on lightScribe capable drives.
-14
View File
@@ -1,14 +0,0 @@
#!/bin/sh
set -e
if [ "$1" = "configure" ] ; then
cp -f /usr/share/qlscribe/lightscribe.conf /etc/dbus-1/system.d/
cp -f /usr/share/qlscribe/org.lightscribe.Manager.service /usr/share/dbus-1/system-services/
/etc/init.d/dbus reload
fi
#DEBHELPER#
exit 0
-21
View File
@@ -1,21 +0,0 @@
#!/bin/sh
set -e
if [ "$1" = "remove" -o "$1" = "upgrade" ] ; then
PID=`pidof lscribed`
if [ "X$PID" != "X" ] ; then
kill $PID
fi
fi
if [ "$1" = "remove" ] ; then
rm -f /etc/dbus-1/system.d/lightscribe.conf
rm -f /usr/share/dbus-1/system-services/org.lightscribe.Manager.service
/etc/init.d/dbus reload
fi
#DEBHELPER#
exit 0
+2 -3
View File
@@ -14,8 +14,7 @@ configure-stamp:
dh_testdir
# Add here commands to configure the package.
mkdir -p build
cd build; cmake .. -DCMAKE_INSTALL_PREFIX=$(CURDIR)/debian/qlscribe/usr \
-DFINAL_INSTALL_PREFIX=/usr
cd build; cmake .. -DCMAKE_INSTALL_PREFIX=$(CURDIR)/debian/qlscribe/usr
touch configure-stamp
@@ -78,7 +77,7 @@ binary-arch: build install
# dh_link
# dh_strip
dh_compress
dh_fixperms
# dh_fixperms #need suid
# dh_perl
# dh_makeshlibs
dh_installdeb
-128
View File
@@ -1,128 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<meta name="keywords" content="Qt,lightscribe,linux,cddb">
<meta name="GENERATOR" content="PageBreeze Free HTML Editor (http://www.pagebreeze.com)">
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1" >
<title>HOWTO print CDDB titles with Qt lightscribe</title>
<style>
<!--
h1 { font-family: Arial, sans-serif; font-size: 30px; }
h2 { font-family: Arial, sans-serif; font-size: 18px; }
body,p,b,i,em,dt,dd,dl,sl,caption,th,td,tr,u,blink,select,option,form,div,li { font-family: Arial, sans-serif; font-size: 12px; }
-->
</style>
</head>
<body bgcolor="#ffffff">
<p>This document describes how you can create a qlscribe
template for printing labels with CDDB information embedded. So let's start.</p>
<h4>1 Materials used.</h4>
<p>qlscribe version 0.9 or later is used. If you have older
version please <a
href="https://sourceforge.net/project/showfiles.php?group_id=251217">update</a> </p>
<p>I downloaded label images from <a
href="http://www.lightscribe.com/ideas/index.aspx?id=2358">lightScribe design
center</a></p>
<p>Music album "Aphex Twin / Girl Boy EP"&nbsp;I used just as an example, I do not
actually have this disc nor copy of it.</p>
<p>cddbcmd utility is part of package cddb and on Ubuntu
can be downloaded from standard repository:</p>
<pre> sudo apt-get install cddb</pre>
<h4>2 Create new label and load image</h4>
<p>Start qlscribe, hit File -&gt; New Label -&gt; Full. You
should see something like this:</p>
<p><img hspace="0" src="/dbimage.php?id=207997" border=0></p>
<p>Insert image Edit -&gt; Insert -&gt; Image then on
dialog click "Load image.." select image "MixTape.jpg" downloaded from <a
href="http://www.lightscribe.com/ideas/index.aspx?id=2358">lightScribe design
center</a>&nbsp;Here how&nbsp;my label is&nbsp;looking now:</p>
<p><img hspace="0" src="/dbimage.php?id=207998" border=0></p>
<h4>3 Create text placeholders</h4>
<p>Now select Edit -&gt; Insert -&gt; Text&nbsp;and on
dialog put text "?DTITLE?". Question marks around name will make this text
disapear in qlscribe console mode print. This could be not necessary for disk
title as it usually set in CDDB data anyway, but would not harm. We should
put question marks on song names, as number of placeholders of title
names should be at least not less than songs on the disk. Adjust font size, so
when printed it would fit in white area. Now move your text box in the
place:</p>
<p><img hspace="0" src="/dbimage.php?id=207999" border=0></p>
<p>First we would create a placeholder for the first song,
adjust font properly and then copy/paste it for others. So Edit -&gt; Insert
-&gt; Text and put "?TTITLE0?". Again if we would not put question marks around
name it will still work, but unused placeholders will be printed as ugly
TTITLEN... strings. Move the text box to the proper position and press Ctrl-C or
from menu Edit -&gt; Copy. Press Ctrl-V and move the text box to the new postion
for TTITLE1. Right click, then "edit..." and change text to "?TTITLE1?". Repeat
until you have enough titles. Your label could look like this one now:</p>
<p><img hspace="0" src="/dbimage.php?id=208000" border=0></p>
<p>Hit menu File -&gt; Save, save it&nbsp;for example
as&nbsp;"tape.qlx" and exit qlscribe.</p>
<h4>4 Download CDDB data</h4>
<p>If you do not have audio disk in cd-rom you can lookup
your disk id from http://www.freedb.org/ or similar. Copy it and run this command:</p>
<pre> cddbcmd cddb read rock 4d03a706 &gt; girlboy.txt</pre>
<p>In my case disk id is rock/4d03a706.</p>
<p>Check that file have proper data, it should look similar
to this:</p>
<code><pre># xmcd CD database file
#^M
# Track frame offsets:
# 182
# 22097
# 40767
# 47095
# 55912
# 62745
#^M
# Disc length: 937 seconds
#^M
# Revision: 0
# Processed by: cddbd v1.5.2PL0 Copyright (c) Steve Scherf et al.
# Submitted via: IdiotJukebox 1.0 (Emacs 19.34.1)
#^M
DISCID=4d03a706
DTITLE=Aphex Twin / Girl Boy EP
TTITLE0=Girl Boy (nls mix)
TTITLE1=Milk Man
TTITLE2=Inkey$
TTITLE3=Girl Boy (Snarerushmix)
TTITLE4=Beetles
TTITLE5=Girl Boy (Redruthmix)
EXTD=
EXTT0=
EXTT1=
EXTT2=
EXTT3=
EXTT4=
EXTT5=
PLAYORDER=</pre></code>
<h4>5 Test you template</h4>
<p>Now we can test how our created at step 2-3 template works with the data. Run qlscribe
in console mode to print label as an image:</p>
<pre> qlscribe --image girlboy.jpg --file girlboy.txt tape.qlx</pre>
<p>If everything fine you should now see file girlboy.jpg
in the current directory. Here is what I got for mine:</p>
<p><img src="/dbimage.php?id=208002"></p>
<h4>6 Print label</h4>
<p>Now if you are happy with the result at step 5 you can print label
directly:</p>
<pre> qlscribe --print --file girlboy.txt tape.qlx</pre>
<p>Enjoy!</p>
<p>Please send comments,&nbsp;suggestions or noticed errors
directly to <a
href="mailto:vyacheslav@kononenko.net">mailto:vyacheslav@kononenko.net</a> or
visit <a
href="http://qlscribe.sourceforge.net">http://qlscribe.sourceforge.net</a> and create
an item in the Bug tracker.</p>
</body>
</html>
+1 -1
View File
@@ -43,7 +43,7 @@ INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} )
ADD_EXECUTABLE( lscribed ${LSCRIBED_SRCS} )
TARGET_LINK_LIBRARIES( lscribed ${LSCRIBE_LIBRARIES} ${DBUS_LIBRARIES} pthread )
TARGET_LINK_LIBRARIES( lscribed ${LSCRIBE_LIBRARIES} ${DBUS_LIBRARIES} )
INSTALL( TARGETS lscribed DESTINATION sbin )
INSTALL( FILES ${LSCRIBED_CONF_FILE} ${LSCRIBED_SERVICE_FILE} DESTINATION share/qlscribe )
+1 -1
View File
@@ -1,4 +1,4 @@
[D-BUS Service]
Name=@QLSCRIBE_DBUS_MANAGER_SERVICE@
Exec=@FINAL_INSTALL_PREFIX@/sbin/lscribed
Exec=@CMAKE_INSTALL_PREFIX@/sbin/lscribed
User=root
-5
View File
@@ -1,5 +0,0 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file>qlscribe64.png</file>
</qresource>
</RCC>
+3 -6
View File
@@ -43,8 +43,6 @@ QT4_WRAP_UI( QLSCRIBE_UI_HDRS ${QLSCRIBE_UIS} )
QT4_WRAP_CPP( QLSCRIBE_MOC_SRCS ${QLSCRIBE_MOC_HDRS} )
QT4_ADD_RESOURCES( QLSCRIBE_RCC_SRCS ../resources/qlscribe.qrc )
MACRO(ADD_DBUS_INTERFACE _sources _interface _basename)
GET_FILENAME_COMPONENT(_infile ${_interface} ABSOLUTE)
SET(_header ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h)
@@ -67,12 +65,11 @@ ADD_DBUS_INTERFACE( QLSCRIBE_DBUS_SRCS lightscribe.xml lightscribe_interface )
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} )
ADD_EXECUTABLE( qlscribe ${QLSCRIBE_SRCS} ${QLSCRIBE_MOC_SRCS}
${QLSCRIBE_RCC_SRCS} ${QLSCRIBE_UI_HDRS}
${QLSCRIBE_DBUS_SRCS} )
ADD_EXECUTABLE( qlscribe ${QLSCRIBE_SRCS} ${QLSCRIBE_MOC_SRCS} ${QLSCRIBE_UI_HDRS} ${QLSCRIBE_DBUS_SRCS} )
TARGET_LINK_LIBRARIES( qlscribe ${QT_LIBRARIES} )
INSTALL( TARGETS qlscribe
DESTINATION bin )
DESTINATION bin
PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE SETUID )
+1 -82
View File
@@ -21,10 +21,6 @@
#include <QApplication>
#include <QMessageBox>
#include <QMap>
#include <QPainter>
#include <QFile>
#include <QTextStream>
#include <QIcon>
#include "mainwindow.h"
#include "qcdscene.h"
#include "qlightscribe.h"
@@ -45,11 +41,8 @@ void usage()
<< "\tParameters:\n"
<< "\t\t--help | -h - print this message\n"
<< "\t\t--print | -p - switch to print mode\n"
<< "\t\t--image | -i image - print to this image\n"
<< "\t\t--size | -s size - image size, 400 by default\n"
<< "\t\t--drive | -d NUMBER - use this drive, starts from 0, 0 is default\n"
<< "\t\t--replace | -r KEY=VALUE - replace text from KEY to VALUE\n"
<< "\t\t--file | -f filename - read replacements in format KEY=VALUE from file\n"
<< std::endl;
}
@@ -57,16 +50,12 @@ int main( int argc, char **argv )
{
QApplication app( argc, argv );
app.addLibraryPath( "/usr/lib32/qt4/plugins" );
app.setWindowIcon( QIcon( ":/qlscribe64.png" ) );
bool doPrint = false;
QStringList arguments = app.arguments();
QStringList files;
QCDScene::QString2String replacements;
int driveIndex = 0;
int imageSize = 400;
QString imageName;
QString replacementsFile;
PrintParameters params;
bool labelModeOverriden = false;
@@ -96,29 +85,6 @@ int main( int argc, char **argv )
replacements[ param.left( pos ) ] = param.right( param.size() - pos - 1 );
continue;
}
if( arg == "--file" || arg == "-f" ) {
if( i == arguments.size() - 1 ) {
std::cerr << "Error: arg#" << i
<< " argument expected for \"" << arg << "\" not enough parameters" << std::endl;
return 1;
}
QFile data( arguments[ ++i ] );
if( !data.open( QIODevice::ReadOnly ) ) {
std::cerr << "cannot open file \"" << arguments[ i ] << "\" for reading" << std::endl;
return 2;
}
QTextStream stream( &data );
while( true ) {
QString line = stream.readLine();
if( line.isNull() )
break;
int pos = line.indexOf( '=' );
if( pos == -1 )
continue;
replacements[ line.left( pos ) ] = line.right( line.size() - pos - 1 );
}
continue;
}
if( arg == "--drive" || arg == "-d" ) {
if( i == arguments.size() - 1 ) {
std::cerr << "Error: arg#" << i
@@ -128,30 +94,6 @@ int main( int argc, char **argv )
QString param = arguments[ ++i ];
driveIndex = param.toInt();
}
if( arg == "--image" || arg == "-i" ) {
if( i == arguments.size() - 1 ) {
std::cerr << "Error: arg#" << i
<< " argument expected for \"" << arg << "\" not enough parameters" << std::endl;
return 1;
}
doPrint = true;
imageName = arguments[ ++i ];
continue;
}
if( arg == "--size" || arg == "-s" ) {
if( i == arguments.size() - 1 ) {
std::cerr << "Error: arg#" << i
<< " argument expected for \"" << arg << "\" not enough parameters" << std::endl;
return 1;
}
imageSize = arguments[ ++i ].toInt();
if( imageSize <=0 ) {
std::cerr << "Error: arg#" << i
<< " invalid argument for image size, value > 0 is expected" << std::endl;
return 2;
}
continue;
}
if( arg[0] != '-' )
files.append( arg );
}
@@ -178,32 +120,10 @@ int main( int argc, char **argv )
if( !labelModeOverriden )
params.m_labelMode = scene.labelMode();
if( !imageName.isEmpty() ) {
QImage image( imageSize, imageSize, QImage::Format_RGB32 );
image.fill( 0xFFFFFFFF );
{
QPainter painter( &image );
/*int innerSize = int( imageSize / 120.0 * 24.7 );
int center = imageSize / 2;
painter.setBrush( Qt::lightGray );
painter.drawEllipse( 0, 0, imageSize, imageSize );
painter.setBrush( Qt::white );
painter.drawEllipse( center - innerSize, center - innerSize,
innerSize * 2, innerSize * 2 );*/
scene.render( &painter, image.rect() );
}
std::cerr << "Printing to \"" << imageName << "\" as "
<< imageSize << "x" << imageSize <<" image"
<< std::endl;
image.save( imageName );
return 0;
}
QLightScribe *scribe = QLightScribe::instance();
QList< QLightDrive * > drives = scribe->getDrives();
if( driveIndex >= drives.size() ) {
std::cerr << "Error: drive " << driveIndex
<< " specified, but there are only " << drives.size() << " drives" << std::endl;
std::cerr << "Error: drive " << driveIndex << " specified, but there are only " << drives.size() << " drives" << std::endl;
return 6;
}
std::cout << "Printing label " << files.front() << std::endl;
@@ -212,7 +132,6 @@ int main( int argc, char **argv )
QConsolePrintProgress progress( drive );
drive->print( params, &scene );
rez = app.exec();
} else {
MainWindow mwindow( true );
mwindow.show();
+20 -96
View File
@@ -37,8 +37,6 @@
#include <QFileDialog>
#include <QLabel>
#include <QCloseEvent>
#include <QApplication>
#include <QClipboard>
MainWindow::MainWindow( bool enablePrint )
@@ -51,7 +49,7 @@ MainWindow::MainWindow( bool enablePrint )
setWindowTitle( tr( "Qt lightScribe", "Main window title \"Qt lightScribe\"" ) );
setCentralWidget( m_mdiArea );
m_menuFile = menuBar()->addMenu( tr( "File", "Menu item \"File\"" ) );
m_menuFile = menuBar()->addMenu( tr( "File", "Menu item \"File\"" ) );
{
QMenu *newSubMenu = m_menuFile->addMenu( tr( "New label", "Menu item \"New lable\"" ) );
@@ -76,58 +74,39 @@ MainWindow::MainWindow( bool enablePrint )
this,
SLOT(onMenuOpen()) );
m_actionSave = m_menuFile->addAction( tr( "Save", "Menu item \"Save\"" ),
this,
SLOT(onMenuSave()),
QKeySequence( Qt::CTRL + Qt::Key_S ) );
m_menuFile->addAction( tr( "Save", "Menu item \"Save\"" ),
this,
SLOT(onMenuSave()) );
m_actionSaveAs = m_menuFile->addAction( tr( "Save as...", "Menu item \"Save as\"" ),
this,
SLOT(onMenuSaveAs()) );
m_menuFile->addAction( tr( "Save as...", "Menu item \"Save as\"" ),
this,
SLOT(onMenuSaveAs()) );
m_menuFile->addSeparator();
m_actionLabelProperties =
m_menuFile->addAction( tr( "Label properties...", "Menu item \"Label propeties...\"" ),
this,
SLOT(onMenuProperties()) );
m_menuFile->addAction( tr( "Label properties...", "Menu item \"Label propeties...\"" ),
this,
SLOT(onMenuProperties()) );
m_menuFile->addSeparator();
m_actionPrintPreview =
m_menuFile->addAction( tr( "Print preview...", "Menu item \"Print preview\"" ),
this,
SLOT(onMenuPrintPreview()) );
m_menuFile->addAction( tr( "Print preview...", "Menu item \"Print preview\"" ),
this,
SLOT(onMenuPrintPreview()) );
m_actionPrint =
QAction *printAction =
m_menuFile->addAction( tr( "Print...", "Menu item \"Print\"" ),
this,
SLOT(onMenuPrint()) );
if( !enablePrint )
printAction->setEnabled( false );
m_menuFile->addAction( tr( "Exit", "Menu item \"Exit\"" ),
this,
SLOT(close()),
QKeySequence( Qt::CTRL + Qt::Key_X ) );
SLOT(close()));
m_menuEdit = menuBar()->addMenu( tr( "Edit", "Menu item \"Edit\"" ) );
m_actionCopy = m_menuEdit->addAction( tr( "Copy", "Menu item \"Copy\"" ),
this,
SLOT(onMenuCopy()),
QKeySequence( Qt::CTRL + Qt::Key_C ) );
m_actionCut = m_menuEdit->addAction( tr( "Cut", "Menu item \"Cut\"" ),
this,
SLOT(onMenuCut()),
QKeySequence( Qt::CTRL + Qt::Key_X ) );
m_actionPaste = m_menuEdit->addAction( tr( "Paste", "Menu item \"Paste\"" ),
this,
SLOT(onMenuPaste()),
QKeySequence( Qt::CTRL + Qt::Key_V ) );
m_menuInsert = m_menuEdit->addMenu( tr( "Insert", "Menu item \"Insert\"" ) );
m_menuInsert = menuBar()->addMenu( tr( "Insert", "Menu item \"Insert\"" ) );
m_menuHelp = menuBar()->addMenu( tr( "Help", "Menu item \"Help\"" ) );
@@ -148,13 +127,6 @@ MainWindow::MainWindow( bool enablePrint )
connect( action, SIGNAL(triggered()), m_insertMapper, SLOT(map()) );
}
connect( m_insertMapper, SIGNAL(mapped(int)), this, SLOT(onMenuInsert(int)) );
connect( QApplication::clipboard(), SIGNAL(changed(QClipboard::Mode)),
this, SLOT(updateMenu()) );
connect( m_mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)),
this, SLOT(updateMenu()) );
updateMenu();
}
MainWindow::~MainWindow()
@@ -247,7 +219,6 @@ void MainWindow::onMenuNewLabel( int mode )
scene->setLabelMode( LabelMode( mode ) );
newView->setScene( scene );
scene->setName();
connect( scene, SIGNAL(selectionChanged()), this, SLOT(updateMenu()) );
QMdiSubWindow *subWindow = m_mdiArea->addSubWindow( newView );
subWindow->show();
@@ -310,7 +281,6 @@ void MainWindow::onMenuOpen()
delete newView;
return;
}
connect( scene, SIGNAL(selectionChanged()), this, SLOT(updateMenu()) );
QMdiSubWindow *subWindow = m_mdiArea->addSubWindow( newView );
subWindow->show();
@@ -377,33 +347,12 @@ void MainWindow::onMenuPrint()
}
}
void MainWindow::onMenuCopy()
{
QCDScene *scene = getScene( m_mdiArea );
if( scene )
scene->putItemToClipboard( false );
}
void MainWindow::onMenuCut()
{
QCDScene *scene = getScene( m_mdiArea );
if( scene )
scene->putItemToClipboard( true );
}
void MainWindow::onMenuPaste()
{
QCDScene *scene = getScene( m_mdiArea );
if( scene )
scene->getItemFromClipboard();
}
void MainWindow::onMenuAbout()
{
QMessageBox::about( this,
tr( "About" ),
tr( "<h3>qlscribe - Qt lisghtScribe</h3>"
"<p>release 0.9 $Revision$</p>"
"<p>release 0.8 $Revision$</p>"
"<p>visit project at home page "
"<a href=\"http://qlscribe.sourceforge.net/\">qlscribe.sourceforge.net</a></p>" ) );
}
@@ -412,28 +361,3 @@ void MainWindow::onMenuQtAbout()
{
QMessageBox::aboutQt( this );
}
void MainWindow::updateMenu()
{
QCDScene *scene = getScene( m_mdiArea );
m_actionSave->setEnabled( scene );
m_actionSaveAs->setEnabled( scene );
m_actionLabelProperties->setEnabled( scene );
m_actionPrint->setEnabled( scene );
m_actionPrintPreview->setEnabled( scene );
m_menuInsert->setEnabled( scene );
if( !scene ) {
m_actionCopy->setEnabled( false );
m_actionCut->setEnabled( false );
m_actionPaste->setEnabled( false );
} else {
const QMimeData *mdata = QApplication::clipboard()->mimeData();
m_actionPaste->setEnabled( mdata && mdata->hasFormat( itemMimeType ) );
bool selected = scene->selectedItems().count();
m_actionCopy->setEnabled( selected );
m_actionCut->setEnabled( selected );
}
}
-15
View File
@@ -48,34 +48,19 @@ private slots:
void onMenuProperties();
void onMenuPrintPreview();
void onMenuPrint();
void onMenuCopy();
void onMenuCut();
void onMenuPaste();
void onMenuInsert( int id );
void onMenuAbout();
void onMenuQtAbout();
void updateMenu();
private:
bool saveSceneAs( QCDScene *scene );
QMdiArea *m_mdiArea;
QMenu *m_menuFile;
QMenu *m_menuEdit;
QMenu *m_menuInsert;
QMenu *m_menuHelp;
QAction *m_actionSave;
QAction *m_actionSaveAs;
QAction *m_actionLabelProperties;
QAction *m_actionPrint;
QAction *m_actionPrintPreview;
QAction *m_actionCopy;
QAction *m_actionCut;
QAction *m_actionPaste;
QSignalMapper *m_insertMapper;
QSignalMapper *m_newLabelMapper;
};
+17 -102
View File
@@ -31,9 +31,6 @@
#include <QMessageBox>
#include <QGraphicsView>
#include <QRegExp>
#include <QApplication>
#include <QClipboard>
#include <QMimeData>
QCDScene::QCDScene( QObject * parent )
: QGraphicsScene( parent ),
@@ -63,11 +60,6 @@ void QCDScene::replace( const QString2String &strings )
f->second->replace( item, st.key(), st.value() );
}
}
foreach(QGraphicsItem *item, list ) {
QShapeFactory::iterator f = sfactory.find( item->type() );
if( f != sfactory.end() )
f->second->replace( item, "", "" ); // to clean placeholders
}
}
bool QCDScene::load( const QString &fileName, QString *errMessage )
@@ -203,34 +195,12 @@ void QCDScene::write( QXmlStreamWriter &writer )
writer.writeEndDocument();
}
bool QCDScene::readItem( QXmlStreamReader &reader )
{
QShapeFactory &sfactory = QShapeFactory::instance();
QString type = reader.attributes().value( "type" ).toString();
QShapeFactory::iterator f = sfactory.find( type );
if( f == sfactory.end() ) {
QMessageBox::warning( 0,
"Warning",
QString( "QCDScene: unknown item type \"" )
+ type + "\"" );
return false;
}
QGraphicsItem *item = f->second->read( reader );
if( item ) {
item->setFlag( QGraphicsItem::ItemIsMovable, true );
item->setFlag( QGraphicsItem::ItemIsSelectable, true );
addItem( item );
return true;
}
return false;
}
void QCDScene::read( QXmlStreamReader &reader )
{
bool gotScene = false;
QShapeFactory &sfactory = QShapeFactory::instance();
while( !reader.atEnd() ) {
QXmlStreamReader::TokenType ttype = reader.readNext();
if( ttype != QXmlStreamReader::StartElement )
@@ -250,70 +220,27 @@ void QCDScene::read( QXmlStreamReader &reader )
}
if( elementName == "item" ) {
readItem( reader );
QString type = reader.attributes().value( "type" ).toString();
QShapeFactory::iterator f = sfactory.find( type );
if( f == sfactory.end() ) {
QMessageBox::warning( 0,
"Warning",
QString( "QCDScene: unknown item type \"" )
+ type + "\"" );
continue;
}
QGraphicsItem *item = f->second->read( reader );
if( item ) {
item->setFlag( QGraphicsItem::ItemIsMovable, true );
item->setFlag( QGraphicsItem::ItemIsSelectable, true );
addItem( item );
}
} else
throw QString( "QCDScene: unknown element \"" ) + elementName + "\"";
}
}
void QCDScene::putItemToClipboard( bool move )
{
QList<QGraphicsItem *> list = selectedItems();
if( list.empty() )
return;
QGraphicsItem *item = list.front();
QShapeFactory &sfactory = QShapeFactory::instance();
QShapeFactory::iterator f = sfactory.find( item->type() );
if( f == sfactory.end() ) {
QMessageBox::warning( 0, tr( "Warning" ), tr( "Cannot find controller for type %n", 0, item->type() ) );
return;
}
QByteArray array;
QXmlStreamWriter writer( &array );
f->second->write( writer, item );
QMimeData *mdata = new QMimeData;
mdata->setData( itemMimeType, array );
mdata->setText( array.data() );
QApplication::clipboard()->setMimeData( mdata );
if( move ) {
removeItem( item );
delete item;
setChanged();
}
}
void QCDScene::getItemFromClipboard()
{
const QMimeData *mdata = QApplication::clipboard()->mimeData();
if( !mdata )
return;
if( !mdata->hasFormat( itemMimeType ) )
return;
QByteArray array = mdata->data( itemMimeType );
QXmlStreamReader reader( array );
while( !reader.atEnd() ) {
QXmlStreamReader::TokenType ttype = reader.readNext();
if( ttype != QXmlStreamReader::StartElement )
continue;
QString elementName = reader.name().toString();
if( elementName == "item" ) {
if( readItem( reader ) )
setChanged();
}
}
}
void QCDScene::contextMenuEvent( QGraphicsSceneContextMenuEvent *mouseEvent )
{
QGraphicsItem *item = itemAt( mouseEvent->scenePos() );
@@ -322,8 +249,6 @@ void QCDScene::contextMenuEvent( QGraphicsSceneContextMenuEvent *mouseEvent )
item->setSelected( true );
QMenu menu;
menu.addAction( tr( "edit..." ), this, SLOT( onMenuEdit() ) );
menu.addAction( tr( "copy" ), this, SLOT( onMenuCopy() ) );
menu.addAction( tr( "cut" ), this, SLOT( onMenuCut() ) );
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() ) );
@@ -339,16 +264,6 @@ void QCDScene::onMenuEdit()
QShapeFactory::instance().edit( item, 0 );
}
void QCDScene::onMenuCopy()
{
putItemToClipboard( false );
}
void QCDScene::onMenuCut()
{
putItemToClipboard( true );
}
void QCDScene::onMenuToFront()
{
sendItemTo( true );
-6
View File
@@ -52,9 +52,6 @@ public:
bool save();
bool saveAs( const QString &fileName );
void putItemToClipboard( bool move );
void getItemFromClipboard();
void updateTitles() const;
void redrawViews() const;
QString name() const { return m_name; }
@@ -64,15 +61,12 @@ protected:
private slots:
void onMenuEdit();
void onMenuCopy();
void onMenuCut();
void onMenuToFront();
void onMenuToBack();
void onMenuDelete();
private:
void write( QXmlStreamWriter &writer );
bool readItem( QXmlStreamReader &reader );
void read( QXmlStreamReader &reader );
void sendItemTo( bool front );
+7 -7
View File
@@ -20,9 +20,9 @@
#include "qdialogpixmap.h"
#include "ui_qdialogpixmap.h"
#include "qlightpixmapitem.h"
#include "qcdscene.h"
#include <QGraphicsPixmapItem>
#include <QImageReader>
#include <QFileDialog>
#include <QMessageBox>
@@ -54,25 +54,25 @@ void QDialogPixmap::changeEvent(QEvent *e)
bool QDialogPixmap::exec( QGraphicsItem *graphicsItem )
{
QLightPixmapItem *item = dynamic_cast< QLightPixmapItem * >( graphicsItem );
QGraphicsPixmapItem *item = dynamic_cast< QGraphicsPixmapItem * >( graphicsItem );
if( !item )
return false;
QCDScene scene;
m_ui->cdView->setScene( &scene );
m_item = new QLightPixmapItem;
m_item = new QGraphicsPixmapItem;
m_item->setPos( item->pos() );
m_item->setOffset( item->offset() );
m_item->setPixmap( item->pixmap() );
m_item->imageName( item->imageName() );
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->imageName() );
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() ) );
@@ -105,7 +105,7 @@ bool QDialogPixmap::exec( QGraphicsItem *graphicsItem )
item->setPos( m_item->pos() );
item->setOffset( m_item->offset() );
item->setPixmap( m_item->pixmap() );
item->imageName( m_item->imageName() );
item->setData( 0, m_item->data( 0 ) );
item->setTransform( m_item->transform() );
return true;
@@ -131,7 +131,7 @@ void QDialogPixmap::onLoadImage()
return;
}
m_item->setPixmap( pixmap );
m_item->imageName( fileName );
m_item->setData( 0, fileName );
m_item->setOffset( -QPointF( pixmap.size().width(), pixmap.size().height() ) / 2.0 );
m_ui->lineEdit->setText( fileName );
+3 -3
View File
@@ -27,7 +27,7 @@ namespace Ui {
class QDialogPixmap;
}
class QLightPixmapItem;
class QGraphicsPixmapItem;
class QDialogPixmap : public QItemDialog {
Q_OBJECT
@@ -48,8 +48,8 @@ private slots:
void sizeChanged();
private:
Ui::QDialogPixmap *m_ui;
QLightPixmapItem *m_item;
Ui::QDialogPixmap *m_ui;
QGraphicsPixmapItem *m_item;
};
+5 -5
View File
@@ -66,8 +66,8 @@ QItemDialog *QShapeControllerPixmap::createDialog( QWidget *parent ) const
void QShapeControllerPixmap::writeData( QXmlStreamWriter &writer, const QGraphicsItem *item ) const
{
const QLightPixmapItem *pixmapItem
= static_cast< const QLightPixmapItem * >( item );
const QGraphicsPixmapItem *pixmapItem
= static_cast< const QGraphicsPixmapItem * >( item );
writer.writeEmptyElement( "pos" );
writer.writeAttribute( QXmlStreamAttribute( "x", QString::number( pixmapItem->pos().x() ) ) );
@@ -81,7 +81,7 @@ void QShapeControllerPixmap::writeData( QXmlStreamWriter &writer, const QGraphic
writer.writeAttribute(
QXmlStreamAttribute( "sy", QString::number( scale.y() ) ) );
writer.writeTextElement( "image", pixmapItem->imageName() );
writer.writeTextElement( "image", pixmapItem->data( 0 ).toString() );
}
@@ -90,7 +90,7 @@ void QShapeControllerPixmap::readData( const QString &element,
const QString &data,
QGraphicsItem *item ) const
{
QLightPixmapItem *pixmapItem = static_cast< QLightPixmapItem * >( item );
QGraphicsPixmapItem *pixmapItem = static_cast< QGraphicsPixmapItem * >( item );
if( element == "pos" ) {
pixmapItem->setPos( attrs.value( "x" ).toString().toDouble(),
@@ -105,12 +105,12 @@ void QShapeControllerPixmap::readData( const QString &element,
}
if( element == "image" ) {
pixmapItem->setData( 0, data );
QPixmap pixmap( data );
if( pixmap.isNull() ) {
throw QString( "QShapeControllerPixmap: image loading from \"" ) +
data + "\" failed";
}
pixmapItem->imageName( data );
pixmapItem->setPixmap( pixmap );
pixmapItem->setOffset( -QPointF( pixmap.size().height(), pixmap.size().width() ) / 2.0 );
return;
-6
View File
@@ -30,14 +30,8 @@ class QLightPixmapItem : public QGraphicsPixmapItem
public:
QLightPixmapItem();
void imageName( const QString &name ) { m_imageName = name; }
const QString &imageName() const { return m_imageName; }
protected:
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant & value );
private:
QString m_imageName;
};
class QShapeControllerPixmap : public QShapeController {
+1 -9
View File
@@ -264,15 +264,7 @@ QItemDialog *QShapeControllerRoundText::createDialog( QWidget *parent ) const
void QShapeControllerRoundText::replace( QGraphicsItem *item, const QString &from, const QString &to ) const
{
QLightRoundTextItem *textItem = static_cast< QLightRoundTextItem * >( item );
bool placeHolder = textItem->text().left( 1 ) == "?" && textItem->text().right( 1 ) == "?";
bool replace = false;
if( from.isEmpty() )
replace = placeHolder;
else
replace = textItem->text() == ( placeHolder ? QString( "?%1?" ).arg( from ) : from );
if( replace )
if( textItem->text() == from )
textItem->setText( to );
}
+1 -10
View File
@@ -81,16 +81,7 @@ void QShapeControllerText::writeData( QXmlStreamWriter &writer, const QGraphicsI
void QShapeControllerText::replace( QGraphicsItem *item, const QString &from, const QString &to ) const
{
QGraphicsSimpleTextItem *textItem = static_cast< QGraphicsSimpleTextItem * >( item );
bool placeHolder = textItem->text().left( 1 ) == "?" && textItem->text().right( 1 ) == "?";
bool replace = false;
if( from.isEmpty() )
replace = placeHolder;
else
replace = textItem->text() == ( placeHolder ? QString( "?%1?" ).arg( from ) : from );
if( replace )
if( textItem->text() == from )
textItem->setText( to );
}
-2
View File
@@ -59,8 +59,6 @@ enum MediaOptimizationLevel {
mediaGeneric
};
const char * const itemMimeType = "application/x-qlscribe;item";
const char * const DBusServiceName = "@QLSCRIBE_DBUS_MANAGER_SERVICE@";
const char * const DBusManagerPath = "@QLSCRIBE_DBUS_MANAGER_PATH@";