From 76ea823c6fc446526f1f24bd2ec989ee2b2b1895 Mon Sep 17 00:00:00 2001 From: ruglory Date: Wed, 4 Feb 2009 22:55:44 +0000 Subject: [PATCH] Dialog added to edit CD properties git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@53 cac9541e-1b8d-4bfa-827e-589bba606050 --- src/CMakeLists.txt | 13 ++- src/mainwindow.cpp | 14 +++ src/mainwindow.h | 1 + src/qcdscene.cpp | 4 +- src/qdialogcdproperties.cpp | 95 ++++++++++++++++++ src/qdialogcdproperties.h | 53 ++++++++++ src/qdialogcdproperties.ui | 191 ++++++++++++++++++++++++++++++++++++ src/qdialogprint.cpp | 3 + src/qdialogtext.cpp | 4 +- src/qlscribe.pro | 9 +- 10 files changed, 376 insertions(+), 11 deletions(-) create mode 100644 src/qdialogcdproperties.cpp create mode 100644 src/qdialogcdproperties.h create mode 100644 src/qdialogcdproperties.ui diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1dd8654..adf1e43 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -18,14 +18,17 @@ # # $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 ) +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 qdialogcdproperties.cpp) -SET( QLSCRIBE_UIS qdialogtext.ui qdialogroundtext.ui qdialogpixmap.ui qdialogprint.ui qdialogprogress.ui ) +SET( QLSCRIBE_UIS qdialogtext.ui qdialogroundtext.ui qdialogpixmap.ui + qdialogprint.ui qdialogprogress.ui qdialogcdproperties.ui) SET( QLSCRIBE_MOC_HDRS mainwindow.h qcdscene.h qdialogpixmap.h qdialogroundtext.h - qdialogtext.h qlightscribe.h qdialogprint.h qdialogprogress.h ) + qdialogtext.h qlightscribe.h qdialogprint.h qdialogprogress.h + qdialogcdproperties.h) ADD_DEFINITIONS( -Wall ) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index b472965..23af7ef 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -26,6 +26,7 @@ #include "qlightscribe.h" #include "qdialogprint.h" #include "qdialogprogress.h" +#include "qdialogcdproperties.h" #include #include @@ -83,6 +84,12 @@ MainWindow::MainWindow( bool enablePrint ) m_menuFile->addSeparator(); + m_menuFile->addAction( tr( "Label properties...", "Menu item \"Label propeties...\"" ), + this, + SLOT(onMenuProperties()) ); + + m_menuFile->addSeparator(); + m_menuFile->addAction( tr( "Print preview...", "Menu item \"Print preview\"" ), this, SLOT(onMenuPrintPreview()) ); @@ -278,6 +285,13 @@ void MainWindow::onMenuSaveAs() saveSceneAs( scene ); } +void MainWindow::onMenuProperties() +{ + QCDScene *scene = getScene( m_mdiArea ); + if( scene ) + QDialogCDProperties::exec( this, scene ); +} + void MainWindow::onMenuPrintPreview() { QCDScene *cdscene = getScene( m_mdiArea ); diff --git a/src/mainwindow.h b/src/mainwindow.h index 965785b..cde6583 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -43,6 +43,7 @@ private slots: void onMenuOpen(); void onMenuSave(); void onMenuSaveAs(); + void onMenuProperties(); void onMenuPrintPreview(); void onMenuPrint(); void onMenuInsert( int id ); diff --git a/src/qcdscene.cpp b/src/qcdscene.cpp index 5486a06..44c24cb 100644 --- a/src/qcdscene.cpp +++ b/src/qcdscene.cpp @@ -88,12 +88,14 @@ void QCDScene::setLabelMode( LabelMode mode ) { m_labelMode = mode; update(); + setChanged(); } void QCDScene::setCDColor( const QColor &color ) { m_cdColor = color; update(); + setChanged(); } void QCDScene::setName() @@ -121,7 +123,7 @@ void QCDScene::setChanged() void QCDScene::updateTitles() const { - QString name = m_name; + QString name = tr( "Label: ", "Window title \"Label\"" ) + m_name; if( !m_saved ) name += " *"; diff --git a/src/qdialogcdproperties.cpp b/src/qdialogcdproperties.cpp new file mode 100644 index 0000000..b8cd249 --- /dev/null +++ b/src/qdialogcdproperties.cpp @@ -0,0 +1,95 @@ +/* qlscribe - Qt based application to print lightScribe discs + + Copyright (C) 2009 Vyacheslav Kononenko + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + $Id$ */ + +#include "qdialogcdproperties.h" +#include "ui_qdialogcdproperties.h" + +#include "qcdscene.h" + +#include + +QDialogCDProperties::QDialogCDProperties(QWidget *parent) : + QDialog(parent), + m_ui(new Ui::QDialogCDProperties) +{ + m_ui->setupUi(this); + connect( m_ui->btnColor, SIGNAL(clicked()), this, SLOT(onColor()) ); + connect( m_ui->radioModeFull, SIGNAL(toggled(bool)), this, SLOT(onChangeMode()) ); + connect( m_ui->radioModeContent, SIGNAL(toggled(bool)), this, SLOT(onChangeMode()) ); + connect( m_ui->radioModeTitle, SIGNAL(toggled(bool)), this, SLOT(onChangeMode()) ); +} + +bool QDialogCDProperties::exec( QWidget *parent, QCDScene *scene ) +{ + QCDScene lscene; + lscene.setLabelMode( scene->labelMode() ); + lscene.setCDColor( scene->cdColor() ); + + QDialogCDProperties dialog( parent ); + dialog.setWindowTitle( tr( "Label properties: ", "Dialog title \"Label properties: \"" ) + + scene->name() ); + dialog.m_ui->cdView->setScene( &lscene ); + + if( dialog.QDialog::exec() == Rejected ) return false; + + scene->setLabelMode( lscene.labelMode() ); + scene->setCDColor( lscene.cdColor() ); + + return true; +} + + +QDialogCDProperties::~QDialogCDProperties() +{ + delete m_ui; +} + +void QDialogCDProperties::changeEvent(QEvent *e) +{ + switch (e->type()) { + case QEvent::LanguageChange: + m_ui->retranslateUi(this); + break; + default: + break; + } +} + +void QDialogCDProperties::onChangeMode() +{ + QCDScene *scene = m_ui->cdView->scene(); + if( m_ui->radioModeFull->isChecked() ) + scene->setLabelMode( modeFull ); + + if( m_ui->radioModeTitle->isChecked() ) + scene->setLabelMode( modeTitle ); + + if( m_ui->radioModeContent->isChecked() ) + scene->setLabelMode( modeContent ); +} + +void QDialogCDProperties::onColor() +{ + QCDScene *scene = m_ui->cdView->scene(); + QColor color = QColorDialog::getColor( scene->cdColor(), this ); + if( color.isValid() ){ + scene->setCDColor( color ); + } +} diff --git a/src/qdialogcdproperties.h b/src/qdialogcdproperties.h new file mode 100644 index 0000000..1ee732b --- /dev/null +++ b/src/qdialogcdproperties.h @@ -0,0 +1,53 @@ +/* qlscribe - Qt based application to print lightScribe discs + + Copyright (C) 2009 Vyacheslav Kononenko + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + $Id$ */ + + +#ifndef QDIALOGCDPROPERTIES_H +#define QDIALOGCDPROPERTIES_H + +#include + +namespace Ui { + class QDialogCDProperties; +} + +class QCDScene; + +class QDialogCDProperties : public QDialog { + Q_OBJECT + Q_DISABLE_COPY(QDialogCDProperties) +public: + static bool exec( QWidget *parent, QCDScene *scene ); + +protected: + virtual void changeEvent(QEvent *e); + +private slots: + void onChangeMode(); + void onColor(); + +private: + explicit QDialogCDProperties(QWidget *parent = 0); + virtual ~QDialogCDProperties(); + + Ui::QDialogCDProperties *m_ui; +}; + +#endif // QDIALOGCDPROPERTIES_H diff --git a/src/qdialogcdproperties.ui b/src/qdialogcdproperties.ui new file mode 100644 index 0000000..6bebf76 --- /dev/null +++ b/src/qdialogcdproperties.ui @@ -0,0 +1,191 @@ + + QDialogCDProperties + + + Qt::NonModal + + + + 0 + 0 + 398 + 532 + + + + Label properties + + + false + + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + 3 + + + + + + + + + + Label mode: + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + Full + + + true + + + + + + + Title + + + + + + + Content + + + + + + + + + + + + Change color... + + + false + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + 0 + 2 + + + + + 0 + 0 + + + + false + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + QCDView + QGraphicsView +
qcdview.h
+
+
+ + buttonBox + + + + + buttonBox + accepted() + QDialogCDProperties + accept() + + + 258 + 582 + + + 157 + 274 + + + + + buttonBox + rejected() + QDialogCDProperties + reject() + + + 326 + 582 + + + 286 + 274 + + + + +
diff --git a/src/qdialogprint.cpp b/src/qdialogprint.cpp index 6df3c3e..a673223 100644 --- a/src/qdialogprint.cpp +++ b/src/qdialogprint.cpp @@ -69,6 +69,9 @@ QLightDrive *QDialogPrint::exec( QWidget *parent, QLightScribe::PrintParameters params = QLightScribe::PrintParameters(); // reset to default + if( dialog.m_ui->radioModeFull->isChecked() ) + params.m_labelMode = modeFull; + if( dialog.m_ui->radioModeTitle->isChecked() ) params.m_labelMode = modeTitle; diff --git a/src/qdialogtext.cpp b/src/qdialogtext.cpp index b0b70ae..a5be18a 100644 --- a/src/qdialogtext.cpp +++ b/src/qdialogtext.cpp @@ -32,8 +32,8 @@ QDialogText::QDialogText(QWidget *parent) : m_item( 0 ) { m_ui->setupUi(this); - connect( m_ui->btnFont, SIGNAL(clicked()), this, SLOT(onFont()) ); - connect( m_ui->btnColor, SIGNAL(clicked()), this, SLOT(onColor()) ); + connect( m_ui->btnFont, SIGNAL(clicked()), this, SLOT(onFont()) ); + connect( m_ui->btnColor, SIGNAL(clicked()), this, SLOT(onColor()) ); } QDialogText::~QDialogText() diff --git a/src/qlscribe.pro b/src/qlscribe.pro index adb2e2b..7ba5e31 100644 --- a/src/qlscribe.pro +++ b/src/qlscribe.pro @@ -18,7 +18,8 @@ SOURCES += main.cpp \ qdialogprint.cpp \ qdialogprogress.cpp \ qlighttextitem.cpp \ - qlightpixmapitem.cpp + qlightpixmapitem.cpp \ + qdialogcdproperties.cpp QMAKE_LIBS += -llightscribe HEADERS += mainwindow.h \ qlightroundtextitem.h \ @@ -33,9 +34,11 @@ HEADERS += mainwindow.h \ qdialogprogress.h \ qlighttextitem.h \ qlightpixmapitem.h \ - qlscribe.h + qlscribe.h \ + qdialogcdproperties.h FORMS += qdialogtext.ui \ qdialogroundtext.ui \ qdialogpixmap.ui \ qdialogprint.ui \ - qdialogprogress.ui + qdialogprogress.ui \ + qdialogcdproperties.ui