Added cancel and create button handler slots.
This commit is contained in:
+20
-5
@@ -20,6 +20,8 @@
|
||||
|
||||
#include "NewLabelDialog.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#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<QListWidgetItem *> 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<TemplatePickerItem*>(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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ namespace gLabels
|
||||
void pageSizeRadioToggled( bool checked );
|
||||
void templatePickerSelectionChanged();
|
||||
void orientationRadioToggled( bool checked );
|
||||
void createButtonClicked();
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -42,9 +42,7 @@ namespace gLabels
|
||||
|
||||
void applyFilter( const QString &searchString, bool isoMask, bool usMask, bool otherMask );
|
||||
|
||||
|
||||
private:
|
||||
|
||||
const libglabels::Template *selectedTemplate();
|
||||
|
||||
};
|
||||
|
||||
|
||||
+36
-23
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1012</width>
|
||||
<height>777</height>
|
||||
<width>991</width>
|
||||
<height>820</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -205,6 +205,9 @@
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
@@ -329,10 +332,23 @@
|
||||
</item>
|
||||
</layout>
|
||||
</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>
|
||||
<widget class="QGroupBox" name="orientationGroupBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@@ -340,12 +356,9 @@
|
||||
<property name="title">
|
||||
<string>Orientation</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="orientationNormalRadio">
|
||||
<property name="sizePolicy">
|
||||
@@ -372,22 +385,12 @@
|
||||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
</item>
|
||||
</layout>
|
||||
<zorder>orientationNormalRadio</zorder>
|
||||
<zorder>orientationRotatedRadio</zorder>
|
||||
<zorder>orientationNormalRadio</zorder>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@@ -414,9 +417,19 @@
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="createButton">
|
||||
<widget class="QPushButton" name="cancelButton">
|
||||
<property name="text">
|
||||
<string>Create</string>
|
||||
<string>&Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="createButton">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>C&reate</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
Reference in New Issue
Block a user