diff --git a/app/NewLabelDialog.cpp b/app/NewLabelDialog.cpp index 16ce540..c709709 100644 --- a/app/NewLabelDialog.cpp +++ b/app/NewLabelDialog.cpp @@ -20,6 +20,8 @@ #include "NewLabelDialog.h" +#include + #include "libglabels/Db.h" #include "TemplatePickerItem.h" @@ -58,6 +60,9 @@ namespace gLabels connect( orientationNormalRadio, SIGNAL(toggled(bool)), this, SLOT(orientationRadioToggled(bool)) ); connect( orientationRotatedRadio, SIGNAL(toggled(bool)), this, SLOT(orientationRadioToggled(bool)) ); + + connect( cancelButton, SIGNAL(clicked()), this, SLOT(close()) ); + connect( createButton, SIGNAL(clicked()), this, SLOT(createButtonClicked()) ); } @@ -86,19 +91,18 @@ namespace gLabels { orientationNormalRadio->setChecked( true ); - QList selectedItems = templatePicker->selectedItems(); + const libglabels::Template *tmplate = templatePicker->selectedTemplate(); - if ( selectedItems.isEmpty() ) + if ( tmplate == NULL ) { + createButton->setEnabled( false ); selectionStackedWidget->setCurrentIndex( 0 ); } else { + createButton->setEnabled( true ); selectionStackedWidget->setCurrentIndex( 1 ); - // Set template to preview - TemplatePickerItem *tItem = dynamic_cast(selectedItems.first()); - const libglabels::Template *tmplate = tItem->tmplate(); const libglabels::Frame *frame = tmplate->frames().first(); simplePreview->setTemplate( tmplate ); @@ -169,4 +173,15 @@ 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/app/NewLabelDialog.h b/app/NewLabelDialog.h index 5d3d7c1..dafb067 100644 --- a/app/NewLabelDialog.h +++ b/app/NewLabelDialog.h @@ -39,6 +39,7 @@ namespace gLabels void pageSizeRadioToggled( bool checked ); void templatePickerSelectionChanged(); void orientationRadioToggled( bool checked ); + void createButtonClicked(); }; diff --git a/app/TemplatePicker.cpp b/app/TemplatePicker.cpp index 6182468..7d0ebec 100644 --- a/app/TemplatePicker.cpp +++ b/app/TemplatePicker.cpp @@ -71,5 +71,20 @@ namespace gLabels } } + + const libglabels::Template *TemplatePicker::selectedTemplate() + { + QList items = selectedItems(); + if ( items.isEmpty() ) + { + return NULL; + } + else + { + TemplatePickerItem *tItem = dynamic_cast(items.first()); + return tItem->tmplate(); + } + } + } diff --git a/app/TemplatePicker.h b/app/TemplatePicker.h index b849e73..92445c0 100644 --- a/app/TemplatePicker.h +++ b/app/TemplatePicker.h @@ -42,9 +42,7 @@ namespace gLabels void applyFilter( const QString &searchString, bool isoMask, bool usMask, bool otherMask ); - - private: - + const libglabels::Template *selectedTemplate(); }; diff --git a/app/ui/NewLabelDialog.ui b/app/ui/NewLabelDialog.ui index 063a2a2..98aa10c 100644 --- a/app/ui/NewLabelDialog.ui +++ b/app/ui/NewLabelDialog.ui @@ -6,8 +6,8 @@ 0 0 - 1012 - 777 + 991 + 820 @@ -205,6 +205,9 @@ + + QFormLayout::AllNonFixedFieldsGrow + @@ -329,10 +332,23 @@ + + + + Qt::Vertical + + + + 20 + 40 + + + + - + 0 0 @@ -340,12 +356,9 @@ Orientation - - - 9 - + - + @@ -372,22 +385,12 @@ - - - - Qt::Vertical - - - - 20 - 40 - - - - + orientationNormalRadio + orientationRotatedRadio + orientationNormalRadio @@ -414,9 +417,19 @@ - + - Create + &Cancel + + + + + + + false + + + C&reate