From 9bebf921b280fc178eda0f0557d6b852aa2038f1 Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Tue, 11 Aug 2015 10:50:24 -0400 Subject: [PATCH] Create label based on new label dialog. --- glabels/File.cpp | 19 +++++++++++++++++++ glabels/NewLabelDialog.cpp | 26 +++++++++++++++++++------- glabels/NewLabelDialog.h | 7 +++++++ 3 files changed, 45 insertions(+), 7 deletions(-) diff --git a/glabels/File.cpp b/glabels/File.cpp index 08e916d..679af21 100644 --- a/glabels/File.cpp +++ b/glabels/File.cpp @@ -38,6 +38,25 @@ namespace glabels { NewLabelDialog newDialog( window ); newDialog.exec(); + + const libglabels::Template* tmplate = newDialog.tmplate(); + if ( tmplate ) + { + LabelModel* label = new LabelModel(); + label->setTmplate( tmplate ); + label->setRotate( newDialog.rotate() ); + + if ( window->isEmpty() ) + { + window->setModel( label ); + } + else + { + MainWindow *newWindow = new MainWindow(); + newWindow->setModel( label ); + newWindow->show(); + } + } } diff --git a/glabels/NewLabelDialog.cpp b/glabels/NewLabelDialog.cpp index 23c38b0..ce305a3 100644 --- a/glabels/NewLabelDialog.cpp +++ b/glabels/NewLabelDialog.cpp @@ -36,7 +36,8 @@ namespace glabels { setupUi( this ); - // TODO: Set default based on locale + // TODO: Set default based on locale and/or saved preferences + // Perhaps move to checkboxes pageSizeIsoRadio->setChecked( true ); QList tmplates = libglabels::Db::templates(); @@ -68,8 +69,25 @@ namespace glabels connect( createButton, SIGNAL(clicked()), this, SLOT(createButtonClicked()) ); } + /// + /// Get selected template + /// + const libglabels::Template* NewLabelDialog::tmplate() const + { + return templatePicker->selectedTemplate(); + } + /// + /// Get rotation selection + /// + bool NewLabelDialog::rotate() const + { + return orientationRotatedRadio->isChecked(); + } + + + /// /// Search Entry Text Changed Slot /// void NewLabelDialog::searchEntryTextChanged( const QString &text ) @@ -193,12 +211,6 @@ namespace glabels /// void NewLabelDialog::createButtonClicked() { - const libglabels::Template *tmplate = templatePicker->selectedTemplate(); - - std::cout << "TODO: create new label, template = '" << qPrintable(tmplate->name()) - << "', rotate = " << orientationRotatedRadio->isChecked() - << std::endl; - close(); } diff --git a/glabels/NewLabelDialog.h b/glabels/NewLabelDialog.h index 69eee0c..d894213 100644 --- a/glabels/NewLabelDialog.h +++ b/glabels/NewLabelDialog.h @@ -42,6 +42,13 @@ namespace glabels NewLabelDialog( QWidget *parent ); + ///////////////////////////////// + // Accessors + ///////////////////////////////// + const libglabels::Template* tmplate() const; + bool rotate() const; + + ///////////////////////////////// // Slots /////////////////////////////////