QDialogPrint added
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@12 cac9541e-1b8d-4bfa-827e-589bba606050
This commit is contained in:
+6
-3
@@ -19,12 +19,13 @@
|
||||
# $Id$
|
||||
|
||||
SET( QLSCRIBE_SRCS main.cpp mainwindow.cpp qcdscene.cpp qcdview.cpp qdialogpixmap.cpp qdialogroundtext.cpp
|
||||
qdialogtext.cpp qgraphicsroundtextitem.cpp qlightscribe.cpp qshapecontrollers.cpp qshapefactory.cpp )
|
||||
qdialogtext.cpp qgraphicsroundtextitem.cpp qlightscribe.cpp qshapecontrollers.cpp qshapefactory.cpp
|
||||
qdialogprint.cpp )
|
||||
|
||||
SET( QLSCRIBE_UIS qdialogtext.ui qdialogroundtext.ui qdialogpixmap.ui )
|
||||
SET( QLSCRIBE_UIS qdialogtext.ui qdialogroundtext.ui qdialogpixmap.ui qdialogprint.ui )
|
||||
|
||||
SET( QLSCRIBE_MOC_HDRS mainwindow.h qcdscene.h qdialogpixmap.h qdialogroundtext.h
|
||||
qdialogtext.h qlightscribe.h )
|
||||
qdialogtext.h qlightscribe.h qdialogprint.h )
|
||||
|
||||
ADD_DEFINITIONS( -Wall )
|
||||
|
||||
@@ -39,3 +40,5 @@ INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR}/src ${CMAKE_SOURCE_DIR}/src )
|
||||
ADD_EXECUTABLE( qlscribe ${QLSCRIBE_SRCS} ${QLSCRIBE_MOC_SRCS} ${QLSCRIBE_UI_HDRS} )
|
||||
|
||||
TARGET_LINK_LIBRARIES( qlscribe ${QT_LIBRARIES} ${LSCRIBE_LIBRARIES} )
|
||||
|
||||
INSTALL( TARGETS qlscribe DESTINATION bin )
|
||||
|
||||
+3
-3
@@ -45,7 +45,6 @@
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
m_lscribe( new QLightScribe( this ) ),
|
||||
m_mdiArea( new QMdiArea( this ) ),
|
||||
m_menuFile( 0 ), m_menuInsert( 0 ),
|
||||
m_insertMapper( new QSignalMapper( this ) )
|
||||
@@ -102,8 +101,9 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
m_lscribe->stopThread();
|
||||
m_lscribe->wait( 1000 );
|
||||
QLightScribe *lscribe = QLightScribe::instance();
|
||||
lscribe->stopThread();
|
||||
lscribe->wait( 1000 );
|
||||
}
|
||||
|
||||
void MainWindow::onMenuNew()
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
|
||||
#include <QtGui/QMainWindow>
|
||||
|
||||
class QLightScribe;
|
||||
class QMdiArea;
|
||||
class QSignalMapper;
|
||||
|
||||
@@ -44,7 +43,6 @@ private slots:
|
||||
void onMenuQtAbout();
|
||||
|
||||
private:
|
||||
QLightScribe *m_lscribe;
|
||||
QMdiArea *m_mdiArea;
|
||||
|
||||
QMenu *m_menuFile;
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
#include "qdialogprint.h"
|
||||
#include "ui_qdialogprint.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
QDialogPrint::QDialogPrint(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
m_ui(new Ui::QDialogPrint)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
}
|
||||
|
||||
QDialogPrint::~QDialogPrint()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void QDialogPrint::changeEvent(QEvent *e)
|
||||
{
|
||||
switch (e->type()) {
|
||||
case QEvent::LanguageChange:
|
||||
m_ui->retranslateUi(this);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
QLightDrive *QDialogPrint::exec( QWidget *parent, QLightScribe::PrintParameters ¶ms )
|
||||
{
|
||||
QList<QLightDrive *> drives = QLightScribe::instance()->getDrives();
|
||||
if( drives.isEmpty() ) {
|
||||
QMessageBox::critical( parent, tr( "Error" ), tr( "Cannot find any lightScribe drive" ) );
|
||||
return 0;
|
||||
}
|
||||
QDialogPrint dialog( parent );
|
||||
int index = 0;
|
||||
foreach( QLightDrive *drv, drives ) {
|
||||
dialog.m_ui->comboDrive->insertItem( index++, drv->displayName() );
|
||||
}
|
||||
if( dialog.QDialog::exec() == Rejected )
|
||||
return 0;
|
||||
|
||||
params = QLightScribe::PrintParameters(); // reset to default
|
||||
|
||||
if( dialog.m_ui->radioModeTitle->isChecked() )
|
||||
params.m_labelMode = QLightScribe::modeTitle;
|
||||
|
||||
if( dialog.m_ui->radioModeContent->isChecked() )
|
||||
params.m_labelMode = QLightScribe::modeContent;
|
||||
|
||||
if( dialog.m_ui->radioQualityNormal->isChecked() )
|
||||
params.m_printQuality = QLightScribe::qualityNormal;
|
||||
|
||||
if( dialog.m_ui->radioQualityDraft->isChecked() )
|
||||
params.m_printQuality = QLightScribe::qualityDraft;
|
||||
|
||||
if( dialog.m_ui->radioMediaGeneric->isChecked() )
|
||||
params.m_mediaOptimizationLevel = QLightScribe::mediaGeneric;
|
||||
|
||||
return drives.at( dialog.m_ui->comboDrive->currentIndex() );
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
#ifndef QDIALOGPRINT_H
|
||||
#define QDIALOGPRINT_H
|
||||
|
||||
#include <QtGui/QDialog>
|
||||
|
||||
#include "qlightscribe.h"
|
||||
|
||||
namespace Ui {
|
||||
class QDialogPrint;
|
||||
}
|
||||
|
||||
class QDialogPrint : public QDialog {
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(QDialogPrint)
|
||||
public:
|
||||
static QLightDrive *exec( QWidget *parent, QLightScribe::PrintParameters ¶ms );
|
||||
|
||||
protected:
|
||||
explicit QDialogPrint(QWidget *parent = 0);
|
||||
virtual ~QDialogPrint();
|
||||
|
||||
virtual void changeEvent(QEvent *e);
|
||||
|
||||
private:
|
||||
Ui::QDialogPrint *m_ui;
|
||||
};
|
||||
|
||||
#endif // QDIALOGPRINT_H
|
||||
@@ -0,0 +1,240 @@
|
||||
<ui version="4.0" >
|
||||
<class>QDialogPrint</class>
|
||||
<widget class="QDialog" name="QDialogPrint" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>631</width>
|
||||
<height>203</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<string>Print parameters</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3" >
|
||||
<item>
|
||||
<widget class="QFrame" name="frame" >
|
||||
<property name="frameShape" >
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow" >
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_6" >
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout" >
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3" >
|
||||
<property name="text" >
|
||||
<string>Drive:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboDrive" />
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" >
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout" >
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="label" >
|
||||
<property name="text" >
|
||||
<string>Label mode:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
<widget class="QFrame" name="frame_2" >
|
||||
<property name="frameShape" >
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow" >
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2" >
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioModeFull" >
|
||||
<property name="text" >
|
||||
<string>Full</string>
|
||||
</property>
|
||||
<property name="checked" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioModeTitle" >
|
||||
<property name="text" >
|
||||
<string>Title</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioModeContent" >
|
||||
<property name="text" >
|
||||
<string>Content</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout_3" >
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="label_2" >
|
||||
<property name="text" >
|
||||
<string>Quality:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
<widget class="QFrame" name="frame_3" >
|
||||
<property name="frameShape" >
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow" >
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4" >
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioQualityBest" >
|
||||
<property name="text" >
|
||||
<string>Best</string>
|
||||
</property>
|
||||
<property name="checked" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioQualityNormal" >
|
||||
<property name="text" >
|
||||
<string>Normal</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioQualityDraft" >
|
||||
<property name="text" >
|
||||
<string>Draft</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout_2" >
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="label_4" >
|
||||
<property name="text" >
|
||||
<string>Optimization level:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
<widget class="QFrame" name="frame_4" >
|
||||
<property name="frameShape" >
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow" >
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5" >
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton_7" >
|
||||
<property name="text" >
|
||||
<string>Recognized media</string>
|
||||
</property>
|
||||
<property name="checked" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioMediaGeneric" >
|
||||
<property name="text" >
|
||||
<string>Generic media</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</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>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox" >
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons" >
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>QDialogPrint</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>QDialogPrint</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
+37
-6
@@ -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 "qlightscribe.h"
|
||||
#include "qcdscene.h"
|
||||
@@ -36,6 +36,7 @@ struct QLightScribe::Task {
|
||||
enum Action { getDrives, preview, print, stop };
|
||||
Action m_action;
|
||||
bool m_done;
|
||||
PrintParameters m_parameters;
|
||||
QImage *m_image;
|
||||
QList< QLightDrive * > m_drives;
|
||||
QTemporaryFile m_tmpFile;
|
||||
@@ -45,9 +46,14 @@ struct QLightScribe::Task {
|
||||
~Task() { delete m_image; }
|
||||
};
|
||||
|
||||
QLightScribe::QLightScribe( QObject *parent )
|
||||
: QThread( parent ),
|
||||
m_task( 0 ),
|
||||
QLightScribe *QLightScribe::instance()
|
||||
{
|
||||
static QLightScribe inst;
|
||||
return &inst;
|
||||
}
|
||||
|
||||
QLightScribe::QLightScribe()
|
||||
: m_task( 0 ),
|
||||
m_aborted( false ),
|
||||
m_mutex( new QMutex ),
|
||||
m_waitQueue( new QWaitCondition ),
|
||||
@@ -88,13 +94,14 @@ QList< QLightDrive * > QLightScribe::getDrives( bool refresh )
|
||||
return m_drives;
|
||||
}
|
||||
|
||||
QPixmap QLightScribe::preview( QLightDrive *drive, QCDScene *scene, const QSize &size )
|
||||
QPixmap QLightScribe::preview( QLightDrive *drive, const PrintParameters ¶ms, QCDScene *scene, const QSize &size )
|
||||
{
|
||||
QMutexLocker lock( m_mutex );
|
||||
if( m_task ) // what should we do?
|
||||
return QPixmap();
|
||||
|
||||
m_task = new Task( Task::preview );
|
||||
m_task->m_parameters = params;
|
||||
m_task->m_size = size;
|
||||
m_task->m_image = new QImage( 2772, 2772, QImage::Format_RGB888 );
|
||||
m_task->m_image->fill( 0xFFFFFFFF );
|
||||
@@ -119,8 +126,32 @@ QPixmap QLightScribe::preview( QLightDrive *drive, QCDScene *scene, const QSize
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
void QLightScribe::print( QLightDrive *drive, QCDScene *scene )
|
||||
void QLightScribe::print( QLightDrive *drive, const PrintParameters ¶ms, QCDScene *scene )
|
||||
{
|
||||
QMutexLocker lock( m_mutex );
|
||||
if( m_task ) // what should we do?
|
||||
return;
|
||||
|
||||
m_task = new Task( Task::print );
|
||||
m_task->m_parameters = params;
|
||||
m_task->m_image = new QImage( 2772, 2772, QImage::Format_RGB888 );
|
||||
m_task->m_image->fill( 0xFFFFFFFF );
|
||||
|
||||
{
|
||||
QPainter painter( m_task->m_image );
|
||||
scene->render( &painter, m_task->m_image->rect() );
|
||||
}
|
||||
|
||||
m_task->m_image->setDotsPerMeterX( 23622 );
|
||||
m_task->m_image->setDotsPerMeterY( 23622 );
|
||||
|
||||
m_waitQueue->wakeOne();
|
||||
|
||||
while( !m_task->m_done )
|
||||
m_waitDone->wait( m_mutex );
|
||||
|
||||
delete m_task;
|
||||
m_task = 0;
|
||||
}
|
||||
|
||||
void QLightScribe::abort()
|
||||
|
||||
+59
-5
@@ -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 QLIGHTSCRIBE_H
|
||||
#define QLIGHTSCRIBE_H
|
||||
@@ -52,12 +52,63 @@ private:
|
||||
class QLightScribe : public QThread {
|
||||
Q_OBJECT
|
||||
public:
|
||||
QLightScribe( QObject *parent = 0 );
|
||||
virtual ~QLightScribe();
|
||||
enum LabelMode {
|
||||
/** label the entire disc */
|
||||
modeFull=0,
|
||||
/** label within the title mode constraints */
|
||||
modeTitle=1,
|
||||
/** label within the content mode constraints */
|
||||
modeContent=2
|
||||
};
|
||||
|
||||
enum DrawOptions {
|
||||
/** disable scaling of bitmaps; they will be cropped if needed */
|
||||
drawDefault=0,
|
||||
/** Fit the height to the label size */
|
||||
drawFitHeightToLabel=1,
|
||||
/** Fit the width to the label size */
|
||||
drawFitWidthToLabel=2,
|
||||
/** Fit the smallest dimension to the label size */
|
||||
drawFitSmallestToLabel=4
|
||||
};
|
||||
|
||||
enum PrintQuality {
|
||||
/** Best and slowest. */
|
||||
qualityBest=0,
|
||||
/** OK for everyday use. */
|
||||
qualityNormal=1,
|
||||
/** Fast but lower contrast. */
|
||||
qualityDraft=2
|
||||
};
|
||||
|
||||
enum MediaOptimizationLevel {
|
||||
/** Require that media is present and optimized labeling
|
||||
* parameters are available */
|
||||
mediaRecognized,
|
||||
/** Require that media is present but optimized labeling
|
||||
* parameters are not available */
|
||||
mediaGeneric
|
||||
};
|
||||
|
||||
struct PrintParameters {
|
||||
LabelMode m_labelMode;
|
||||
DrawOptions m_drawOptions;
|
||||
PrintQuality m_printQuality;
|
||||
MediaOptimizationLevel m_mediaOptimizationLevel;
|
||||
|
||||
PrintParameters()
|
||||
: m_labelMode( modeFull ), m_drawOptions( drawDefault ),
|
||||
m_printQuality( qualityBest ), m_mediaOptimizationLevel( mediaRecognized ) {}
|
||||
PrintParameters( LabelMode labelMode, DrawOptions drawOptions, PrintQuality printQuality, MediaOptimizationLevel mediaOptimizationLevel )
|
||||
: m_labelMode( labelMode ), m_drawOptions( drawOptions ),
|
||||
m_printQuality( printQuality ), m_mediaOptimizationLevel( mediaOptimizationLevel ) {}
|
||||
};
|
||||
|
||||
static QLightScribe *instance();
|
||||
|
||||
QList< QLightDrive * > getDrives( bool refresh = false );
|
||||
QPixmap preview( QLightDrive *drive, QCDScene *scene, const QSize &size );
|
||||
void print( QLightDrive *drive, QCDScene *scene );
|
||||
QPixmap preview( QLightDrive *drive, const PrintParameters ¶ms, QCDScene *scene, const QSize &size );
|
||||
void print( QLightDrive *drive, const PrintParameters ¶ms, QCDScene *scene );
|
||||
|
||||
public slots:
|
||||
void abort();
|
||||
@@ -73,6 +124,9 @@ protected:
|
||||
virtual void run ();
|
||||
|
||||
private:
|
||||
QLightScribe();
|
||||
virtual ~QLightScribe();
|
||||
|
||||
struct Task;
|
||||
|
||||
QList< QLightDrive * > m_drives;
|
||||
|
||||
+6
-3
@@ -14,7 +14,8 @@ SOURCES += main.cpp \
|
||||
qdialogtext.cpp \
|
||||
qdialogroundtext.cpp \
|
||||
qlightscribe.cpp \
|
||||
qdialogpixmap.cpp
|
||||
qdialogpixmap.cpp \
|
||||
qdialogprint.cpp
|
||||
QMAKE_LIBS += -llightscribe
|
||||
HEADERS += mainwindow.h \
|
||||
qgraphicsroundtextitem.h \
|
||||
@@ -25,7 +26,9 @@ HEADERS += mainwindow.h \
|
||||
qdialogtext.h \
|
||||
qdialogroundtext.h \
|
||||
qlightscribe.h \
|
||||
qdialogpixmap.h
|
||||
qdialogpixmap.h \
|
||||
qdialogprint.h
|
||||
FORMS += qdialogtext.ui \
|
||||
qdialogroundtext.ui \
|
||||
qdialogpixmap.ui
|
||||
qdialogpixmap.ui \
|
||||
qdialogprint.ui
|
||||
|
||||
Reference in New Issue
Block a user