Tweaking of new label dialog.

This commit is contained in:
Jim Evins
2015-08-23 20:30:50 -04:00
parent 85541c2ec3
commit ea8a5d084c
9 changed files with 323 additions and 118 deletions
+50 -42
View File
@@ -32,41 +32,29 @@ namespace glabels
/// ///
/// Constructor /// Constructor
/// ///
NewLabelDialog::NewLabelDialog( QWidget *parent = 0 ) NewLabelDialog::NewLabelDialog( QWidget *parent )
: QDialog(parent), mCanceled(false)
{ {
setupUi( this ); setupUi( this );
// TODO: Set default based on locale and/or saved preferences // TODO: Set default based on locale and/or saved preferences
// Perhaps move to checkboxes // Perhaps move to checkboxes
pageSizeIsoRadio->setChecked( true ); pageSizeIsoCheck->setChecked( false );
pageSizeUsCheck->setChecked( true );
pageSizeOtherCheck->setChecked( true );
QList<libglabels::Template*> tmplates = libglabels::Db::templates(); QList<libglabels::Template*> tmplates = libglabels::Db::templates();
templatePicker->setTemplates( tmplates ); templatePicker->setTemplates( tmplates );
templatePicker->applyFilter( searchEntry->text(), templatePicker->applyFilter( searchEntry->text(),
pageSizeIsoRadio->isChecked(), pageSizeIsoCheck->isChecked(),
pageSizeUsRadio->isChecked(), pageSizeUsCheck->isChecked(),
pageSizeOtherRadio->isChecked() ); pageSizeOtherCheck->isChecked() );
similarBrowser->setAttribute(Qt::WA_TranslucentBackground); similarBrowser->setAttribute(Qt::WA_TranslucentBackground);
similarBrowser->viewport()->setAutoFillBackground(false); similarBrowser->viewport()->setAutoFillBackground(false);
selectionStackedWidget->setCurrentIndex( 0 ); selectionStackedWidget->setCurrentIndex( 0 );
connect( searchEntry, SIGNAL(textChanged(const QString &)),
this, SLOT(searchEntryTextChanged(const QString &)) );
connect( pageSizeIsoRadio, SIGNAL(toggled(bool)), this, SLOT(pageSizeRadioToggled(bool)) );
connect( pageSizeUsRadio, SIGNAL(toggled(bool)), this, SLOT(pageSizeRadioToggled(bool)) );
connect( pageSizeOtherRadio, SIGNAL(toggled(bool)), this, SLOT(pageSizeRadioToggled(bool)) );
connect( templatePicker, SIGNAL(itemSelectionChanged()), this, SLOT(templatePickerSelectionChanged()) );
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()) );
} }
/// ///
@@ -74,7 +62,14 @@ namespace glabels
/// ///
const libglabels::Template* NewLabelDialog::tmplate() const const libglabels::Template* NewLabelDialog::tmplate() const
{ {
return templatePicker->selectedTemplate(); if ( !mCanceled )
{
return templatePicker->selectedTemplate();
}
else
{
return 0;
}
} }
@@ -90,34 +85,40 @@ namespace glabels
/// ///
/// Search Entry Text Changed Slot /// Search Entry Text Changed Slot
/// ///
void NewLabelDialog::searchEntryTextChanged( const QString &text ) void NewLabelDialog::onSearchEntryTextChanged()
{ {
templatePicker->applyFilter( text, templatePicker->applyFilter( searchEntry->text(),
pageSizeIsoRadio->isChecked(), pageSizeIsoCheck->isChecked(),
pageSizeUsRadio->isChecked(), pageSizeUsCheck->isChecked(),
pageSizeOtherRadio->isChecked() ); pageSizeOtherCheck->isChecked() );
}
///
/// Search Entry Text Changed Slot
///
void NewLabelDialog::onSearchClearButtonClicked()
{
searchEntry->setText( "" );
} }
/// ///
/// Page Size Radio Toggled Slot /// Page Size Check Toggled Slot
/// ///
void NewLabelDialog::pageSizeRadioToggled( bool checked ) void NewLabelDialog::onPageSizeCheckToggled()
{ {
if ( checked ) templatePicker->applyFilter( searchEntry->text(),
{ pageSizeIsoCheck->isChecked(),
templatePicker->applyFilter( searchEntry->text(), pageSizeUsCheck->isChecked(),
pageSizeIsoRadio->isChecked(), pageSizeOtherCheck->isChecked() );
pageSizeUsRadio->isChecked(),
pageSizeOtherRadio->isChecked() );
}
} }
/// ///
/// Template Picker Selection Changed Slot /// Template Picker Selection Changed Slot
/// ///
void NewLabelDialog::templatePickerSelectionChanged() void NewLabelDialog::onTemplatePickerSelectionChanged()
{ {
orientationNormalRadio->setChecked( true ); orientationNormalRadio->setChecked( true );
@@ -197,21 +198,28 @@ namespace glabels
/// ///
/// Orientation Radio Button Toggled Slot /// Orientation Radio Button Toggled Slot
/// ///
void NewLabelDialog::orientationRadioToggled( bool checked ) void NewLabelDialog::onOrientationRadioToggled()
{ {
if ( checked ) simplePreview->setRotate( orientationRotatedRadio->isChecked() );
{
simplePreview->setRotate( orientationRotatedRadio->isChecked() );
}
} }
/// ///
/// Create Button Clicked Slot /// Create Button Clicked Slot
/// ///
void NewLabelDialog::createButtonClicked() void NewLabelDialog::onCreateButtonClicked()
{ {
close(); close();
} }
///
/// Cancel Button Clicked Slot
///
void NewLabelDialog::onCancelButtonClicked()
{
mCanceled = true;
close();
}
} }
+15 -6
View File
@@ -39,7 +39,7 @@ namespace glabels
// Life Cycle // Life Cycle
///////////////////////////////// /////////////////////////////////
public: public:
NewLabelDialog( QWidget *parent ); NewLabelDialog( QWidget *parent = 0 );
///////////////////////////////// /////////////////////////////////
@@ -53,11 +53,20 @@ namespace glabels
// Slots // Slots
///////////////////////////////// /////////////////////////////////
private slots: private slots:
void searchEntryTextChanged( const QString &text ); void onSearchEntryTextChanged();
void pageSizeRadioToggled( bool checked ); void onSearchClearButtonClicked();
void templatePickerSelectionChanged(); void onPageSizeCheckToggled();
void orientationRadioToggled( bool checked ); void onTemplatePickerSelectionChanged();
void createButtonClicked(); void onOrientationRadioToggled();
void onCreateButtonClicked();
void onCancelButtonClicked();
/////////////////////////////////
// Private data
/////////////////////////////////
private:
bool mCanceled;
}; };
+6 -5
View File
@@ -64,13 +64,14 @@ namespace glabels
{ {
TemplatePickerItem *tItem = dynamic_cast<TemplatePickerItem *>(item); TemplatePickerItem *tItem = dynamic_cast<TemplatePickerItem *>(item);
if ( tItem->tmplate()->name().contains( searchString, Qt::CaseInsensitive ) && bool sizeMask =
(isoMask == tItem->tmplate()->isSizeIso()) && (isoMask && tItem->tmplate()->isSizeIso()) ||
(usMask == tItem->tmplate()->isSizeUs()) && (usMask && tItem->tmplate()->isSizeUs()) ||
(otherMask == tItem->tmplate()->isSizeOther()) ) (otherMask && tItem->tmplate()->isSizeOther());
if ( tItem->tmplate()->name().contains( searchString, Qt::CaseInsensitive ) && sizeMask )
{ {
item->setHidden( false ); item->setHidden( false );
} }
else else
{ {
+4
View File
@@ -2,6 +2,8 @@
<RCC version="1.0"> <RCC version="1.0">
<qresource> <qresource>
<file>icons/16x16/actions/edit-clear.png</file>
<file>icons/16x16/actions/edit-find.png</file>
<file>icons/16x16/actions/glabels-align-bottom.png</file> <file>icons/16x16/actions/glabels-align-bottom.png</file>
<file>icons/16x16/actions/glabels-align-hcenter.png</file> <file>icons/16x16/actions/glabels-align-hcenter.png</file>
<file>icons/16x16/actions/glabels-align-left.png</file> <file>icons/16x16/actions/glabels-align-left.png</file>
@@ -28,6 +30,8 @@
<file>icons/16x16/actions/glabels-rotate-right.png</file> <file>icons/16x16/actions/glabels-rotate-right.png</file>
<file>icons/16x16/actions/glabels-text.png</file> <file>icons/16x16/actions/glabels-text.png</file>
<file>icons/16x16/apps/glabels.png</file> <file>icons/16x16/apps/glabels.png</file>
<file>icons/24x24/actions/edit-clear.png</file>
<file>icons/24x24/actions/edit-find.png</file>
<file>icons/24x24/actions/glabels-align-text-center.png</file> <file>icons/24x24/actions/glabels-align-text-center.png</file>
<file>icons/24x24/actions/glabels-align-text-left.png</file> <file>icons/24x24/actions/glabels-align-text-left.png</file>
<file>icons/24x24/actions/glabels-align-text-right.png</file> <file>icons/24x24/actions/glabels-align-text-right.png</file>
Binary file not shown.

After

Width:  |  Height:  |  Size: 292 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 416 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 449 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 569 B

+248 -65
View File
@@ -21,13 +21,45 @@
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item> <item>
<widget class="QLineEdit" name="searchEntry"> <widget class="QGroupBox" name="groupBox_2">
<property name="sizePolicy"> <property name="title">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed"> <string>Search</string>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QLineEdit" name="searchEntry">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="placeholderText">
<string>Search</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="searchClearButton">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/16x16/actions/edit-clear.png</normaloff>:/icons/16x16/actions/edit-clear.png</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget> </widget>
</item> </item>
<item> <item>
@@ -61,65 +93,44 @@
<property name="checkable"> <property name="checkable">
<bool>false</bool> <bool>false</bool>
</property> </property>
<widget class="QRadioButton" name="pageSizeIsoRadio"> <layout class="QVBoxLayout" name="verticalLayout_5">
<property name="geometry"> <item>
<rect> <widget class="QCheckBox" name="pageSizeIsoCheck">
<x>10</x> <property name="text">
<y>20</y> <string>ISO sizes</string>
<width>121</width> </property>
<height>21</height> </widget>
</rect> </item>
</property> <item>
<property name="font"> <widget class="QCheckBox" name="pageSizeUsCheck">
<font> <property name="text">
<weight>50</weight> <string>US sizes</string>
<bold>false</bold> </property>
</font> </widget>
</property> </item>
<property name="text"> <item>
<string>ISO sizes</string> <widget class="QCheckBox" name="pageSizeOtherCheck">
</property> <property name="text">
</widget> <string>Other</string>
<widget class="QRadioButton" name="pageSizeUsRadio"> </property>
<property name="geometry"> </widget>
<rect> </item>
<x>10</x> </layout>
<y>40</y>
<width>111</width>
<height>21</height>
</rect>
</property>
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>US sizes</string>
</property>
</widget>
<widget class="QRadioButton" name="pageSizeOtherRadio">
<property name="geometry">
<rect>
<x>10</x>
<y>60</y>
<width>111</width>
<height>21</height>
</rect>
</property>
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Other</string>
</property>
</widget>
</widget> </widget>
</item> </item>
<item>
<spacer name="verticalSpacer_2">
<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>
<item> <item>
@@ -445,6 +456,178 @@
<header>SimplePreview.h</header> <header>SimplePreview.h</header>
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<resources/> <resources>
<connections/> <include location="../icons.qrc"/>
</resources>
<connections>
<connection>
<sender>searchEntry</sender>
<signal>textChanged(QString)</signal>
<receiver>NewLabelDialog</receiver>
<slot>onSearchEntryTextChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>69</x>
<y>48</y>
</hint>
<hint type="destinationlabel">
<x>2</x>
<y>53</y>
</hint>
</hints>
</connection>
<connection>
<sender>searchClearButton</sender>
<signal>clicked()</signal>
<receiver>NewLabelDialog</receiver>
<slot>onSearchClearButtonClicked()</slot>
<hints>
<hint type="sourcelabel">
<x>177</x>
<y>52</y>
</hint>
<hint type="destinationlabel">
<x>190</x>
<y>7</y>
</hint>
</hints>
</connection>
<connection>
<sender>pageSizeIsoCheck</sender>
<signal>toggled(bool)</signal>
<receiver>NewLabelDialog</receiver>
<slot>onPageSizeCheckToggled()</slot>
<hints>
<hint type="sourcelabel">
<x>78</x>
<y>116</y>
</hint>
<hint type="destinationlabel">
<x>3</x>
<y>110</y>
</hint>
</hints>
</connection>
<connection>
<sender>pageSizeUsCheck</sender>
<signal>toggled(bool)</signal>
<receiver>NewLabelDialog</receiver>
<slot>onPageSizeCheckToggled()</slot>
<hints>
<hint type="sourcelabel">
<x>52</x>
<y>145</y>
</hint>
<hint type="destinationlabel">
<x>8</x>
<y>144</y>
</hint>
</hints>
</connection>
<connection>
<sender>pageSizeOtherCheck</sender>
<signal>toggled(bool)</signal>
<receiver>NewLabelDialog</receiver>
<slot>onPageSizeCheckToggled()</slot>
<hints>
<hint type="sourcelabel">
<x>37</x>
<y>170</y>
</hint>
<hint type="destinationlabel">
<x>10</x>
<y>188</y>
</hint>
</hints>
</connection>
<connection>
<sender>templatePicker</sender>
<signal>itemSelectionChanged()</signal>
<receiver>NewLabelDialog</receiver>
<slot>onTemplatePickerSelectionChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>232</x>
<y>550</y>
</hint>
<hint type="destinationlabel">
<x>244</x>
<y>697</y>
</hint>
</hints>
</connection>
<connection>
<sender>orientationRotatedRadio</sender>
<signal>toggled(bool)</signal>
<receiver>NewLabelDialog</receiver>
<slot>onOrientationRadioToggled()</slot>
<hints>
<hint type="sourcelabel">
<x>901</x>
<y>637</y>
</hint>
<hint type="destinationlabel">
<x>982</x>
<y>617</y>
</hint>
</hints>
</connection>
<connection>
<sender>orientationNormalRadio</sender>
<signal>toggled(bool)</signal>
<receiver>NewLabelDialog</receiver>
<slot>onOrientationRadioToggled()</slot>
<hints>
<hint type="sourcelabel">
<x>807</x>
<y>644</y>
</hint>
<hint type="destinationlabel">
<x>982</x>
<y>592</y>
</hint>
</hints>
</connection>
<connection>
<sender>createButton</sender>
<signal>clicked()</signal>
<receiver>NewLabelDialog</receiver>
<slot>onCreateButtonClicked()</slot>
<hints>
<hint type="sourcelabel">
<x>951</x>
<y>699</y>
</hint>
<hint type="destinationlabel">
<x>985</x>
<y>671</y>
</hint>
</hints>
</connection>
<connection>
<sender>cancelButton</sender>
<signal>clicked()</signal>
<receiver>NewLabelDialog</receiver>
<slot>onCancelButtonClicked()</slot>
<hints>
<hint type="sourcelabel">
<x>837</x>
<y>692</y>
</hint>
<hint type="destinationlabel">
<x>767</x>
<y>704</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>onSearchClearButtonClicked()</slot>
<slot>onPageSizeCheckToggled()</slot>
<slot>onTemplatePickerSelectionChanged()</slot>
<slot>onOrientationRadioToggled()</slot>
<slot>onCreateButtonClicked()</slot>
<slot>onSearchEntryTextChanged()</slot>
<slot>onCancelButtonClicked()</slot>
</slots>
</ui> </ui>