Added cancel and create button handler slots.

This commit is contained in:
Jim Evins
2013-11-17 17:43:42 -05:00
parent d4541d396e
commit f5bdbb98f9
5 changed files with 73 additions and 31 deletions
+20 -5
View File
@@ -20,6 +20,8 @@
#include "NewLabelDialog.h" #include "NewLabelDialog.h"
#include <iostream>
#include "libglabels/Db.h" #include "libglabels/Db.h"
#include "TemplatePickerItem.h" #include "TemplatePickerItem.h"
@@ -58,6 +60,9 @@ namespace gLabels
connect( orientationNormalRadio, SIGNAL(toggled(bool)), this, SLOT(orientationRadioToggled(bool)) ); connect( orientationNormalRadio, SIGNAL(toggled(bool)), this, SLOT(orientationRadioToggled(bool)) );
connect( orientationRotatedRadio, 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 ); orientationNormalRadio->setChecked( true );
QList<QListWidgetItem *> selectedItems = templatePicker->selectedItems(); const libglabels::Template *tmplate = templatePicker->selectedTemplate();
if ( selectedItems.isEmpty() ) if ( tmplate == NULL )
{ {
createButton->setEnabled( false );
selectionStackedWidget->setCurrentIndex( 0 ); selectionStackedWidget->setCurrentIndex( 0 );
} }
else else
{ {
createButton->setEnabled( true );
selectionStackedWidget->setCurrentIndex( 1 ); selectionStackedWidget->setCurrentIndex( 1 );
// Set template to preview
TemplatePickerItem *tItem = dynamic_cast<TemplatePickerItem*>(selectedItems.first());
const libglabels::Template *tmplate = tItem->tmplate();
const libglabels::Frame *frame = tmplate->frames().first(); const libglabels::Frame *frame = tmplate->frames().first();
simplePreview->setTemplate( tmplate ); 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();
}
} }
+1
View File
@@ -39,6 +39,7 @@ namespace gLabels
void pageSizeRadioToggled( bool checked ); void pageSizeRadioToggled( bool checked );
void templatePickerSelectionChanged(); void templatePickerSelectionChanged();
void orientationRadioToggled( bool checked ); void orientationRadioToggled( bool checked );
void createButtonClicked();
}; };
+15
View File
@@ -71,5 +71,20 @@ namespace gLabels
} }
} }
const libglabels::Template *TemplatePicker::selectedTemplate()
{
QList<QListWidgetItem *> items = selectedItems();
if ( items.isEmpty() )
{
return NULL;
}
else
{
TemplatePickerItem *tItem = dynamic_cast<TemplatePickerItem*>(items.first());
return tItem->tmplate();
}
}
} }
+1 -3
View File
@@ -42,9 +42,7 @@ namespace gLabels
void applyFilter( const QString &searchString, bool isoMask, bool usMask, bool otherMask ); void applyFilter( const QString &searchString, bool isoMask, bool usMask, bool otherMask );
const libglabels::Template *selectedTemplate();
private:
}; };
+36 -23
View File
@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1012</width> <width>991</width>
<height>777</height> <height>820</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@@ -205,6 +205,9 @@
</item> </item>
<item> <item>
<layout class="QFormLayout" name="formLayout"> <layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
@@ -329,10 +332,23 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item> <item>
<widget class="QGroupBox" name="orientationGroupBox"> <widget class="QGroupBox" name="orientationGroupBox">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding"> <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@@ -340,12 +356,9 @@
<property name="title"> <property name="title">
<string>Orientation</string> <string>Orientation</string>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>9</number>
</property>
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QHBoxLayout" name="horizontalLayout_3">
<item> <item>
<widget class="QRadioButton" name="orientationNormalRadio"> <widget class="QRadioButton" name="orientationNormalRadio">
<property name="sizePolicy"> <property name="sizePolicy">
@@ -372,22 +385,12 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>
<zorder>orientationNormalRadio</zorder>
<zorder>orientationRotatedRadio</zorder>
<zorder>orientationNormalRadio</zorder>
</widget> </widget>
</item> </item>
</layout> </layout>
@@ -414,9 +417,19 @@
</spacer> </spacer>
</item> </item>
<item> <item>
<widget class="QPushButton" name="createButton"> <widget class="QPushButton" name="cancelButton">
<property name="text"> <property name="text">
<string>Create</string> <string>&amp;Cancel</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="createButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>C&amp;reate</string>
</property> </property>
</widget> </widget>
</item> </item>