diff --git a/glabels/NewLabelDialog.cpp b/glabels/NewLabelDialog.cpp index ce305a3..82185fe 100644 --- a/glabels/NewLabelDialog.cpp +++ b/glabels/NewLabelDialog.cpp @@ -32,41 +32,29 @@ namespace glabels /// /// Constructor /// - NewLabelDialog::NewLabelDialog( QWidget *parent = 0 ) + NewLabelDialog::NewLabelDialog( QWidget *parent ) + : QDialog(parent), mCanceled(false) { setupUi( this ); // TODO: Set default based on locale and/or saved preferences // Perhaps move to checkboxes - pageSizeIsoRadio->setChecked( true ); + pageSizeIsoCheck->setChecked( false ); + pageSizeUsCheck->setChecked( true ); + pageSizeOtherCheck->setChecked( true ); QList tmplates = libglabels::Db::templates(); templatePicker->setTemplates( tmplates ); templatePicker->applyFilter( searchEntry->text(), - pageSizeIsoRadio->isChecked(), - pageSizeUsRadio->isChecked(), - pageSizeOtherRadio->isChecked() ); + pageSizeIsoCheck->isChecked(), + pageSizeUsCheck->isChecked(), + pageSizeOtherCheck->isChecked() ); similarBrowser->setAttribute(Qt::WA_TranslucentBackground); similarBrowser->viewport()->setAutoFillBackground(false); 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 { - return templatePicker->selectedTemplate(); + if ( !mCanceled ) + { + return templatePicker->selectedTemplate(); + } + else + { + return 0; + } } @@ -90,34 +85,40 @@ namespace glabels /// /// Search Entry Text Changed Slot /// - void NewLabelDialog::searchEntryTextChanged( const QString &text ) + void NewLabelDialog::onSearchEntryTextChanged() { - templatePicker->applyFilter( text, - pageSizeIsoRadio->isChecked(), - pageSizeUsRadio->isChecked(), - pageSizeOtherRadio->isChecked() ); + templatePicker->applyFilter( searchEntry->text(), + pageSizeIsoCheck->isChecked(), + pageSizeUsCheck->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(), - pageSizeIsoRadio->isChecked(), - pageSizeUsRadio->isChecked(), - pageSizeOtherRadio->isChecked() ); - } + templatePicker->applyFilter( searchEntry->text(), + pageSizeIsoCheck->isChecked(), + pageSizeUsCheck->isChecked(), + pageSizeOtherCheck->isChecked() ); } /// /// Template Picker Selection Changed Slot /// - void NewLabelDialog::templatePickerSelectionChanged() + void NewLabelDialog::onTemplatePickerSelectionChanged() { orientationNormalRadio->setChecked( true ); @@ -197,21 +198,28 @@ namespace glabels /// /// 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 /// - void NewLabelDialog::createButtonClicked() + void NewLabelDialog::onCreateButtonClicked() { close(); } + + /// + /// Cancel Button Clicked Slot + /// + void NewLabelDialog::onCancelButtonClicked() + { + mCanceled = true; + close(); + } + } diff --git a/glabels/NewLabelDialog.h b/glabels/NewLabelDialog.h index d894213..8bf3d78 100644 --- a/glabels/NewLabelDialog.h +++ b/glabels/NewLabelDialog.h @@ -39,7 +39,7 @@ namespace glabels // Life Cycle ///////////////////////////////// public: - NewLabelDialog( QWidget *parent ); + NewLabelDialog( QWidget *parent = 0 ); ///////////////////////////////// @@ -53,11 +53,20 @@ namespace glabels // Slots ///////////////////////////////// private slots: - void searchEntryTextChanged( const QString &text ); - void pageSizeRadioToggled( bool checked ); - void templatePickerSelectionChanged(); - void orientationRadioToggled( bool checked ); - void createButtonClicked(); + void onSearchEntryTextChanged(); + void onSearchClearButtonClicked(); + void onPageSizeCheckToggled(); + void onTemplatePickerSelectionChanged(); + void onOrientationRadioToggled(); + void onCreateButtonClicked(); + void onCancelButtonClicked(); + + + ///////////////////////////////// + // Private data + ///////////////////////////////// + private: + bool mCanceled; }; diff --git a/glabels/TemplatePicker.cpp b/glabels/TemplatePicker.cpp index 1734e7d..6c9a2d2 100644 --- a/glabels/TemplatePicker.cpp +++ b/glabels/TemplatePicker.cpp @@ -64,13 +64,14 @@ namespace glabels { TemplatePickerItem *tItem = dynamic_cast(item); - if ( tItem->tmplate()->name().contains( searchString, Qt::CaseInsensitive ) && - (isoMask == tItem->tmplate()->isSizeIso()) && - (usMask == tItem->tmplate()->isSizeUs()) && - (otherMask == tItem->tmplate()->isSizeOther()) ) + bool sizeMask = + (isoMask && tItem->tmplate()->isSizeIso()) || + (usMask && tItem->tmplate()->isSizeUs()) || + (otherMask && tItem->tmplate()->isSizeOther()); + + if ( tItem->tmplate()->name().contains( searchString, Qt::CaseInsensitive ) && sizeMask ) { item->setHidden( false ); - } else { diff --git a/glabels/icons.qrc b/glabels/icons.qrc index 8e4b4be..2702f15 100644 --- a/glabels/icons.qrc +++ b/glabels/icons.qrc @@ -2,6 +2,8 @@ + icons/16x16/actions/edit-clear.png + icons/16x16/actions/edit-find.png icons/16x16/actions/glabels-align-bottom.png icons/16x16/actions/glabels-align-hcenter.png icons/16x16/actions/glabels-align-left.png @@ -28,6 +30,8 @@ icons/16x16/actions/glabels-rotate-right.png icons/16x16/actions/glabels-text.png icons/16x16/apps/glabels.png + icons/24x24/actions/edit-clear.png + icons/24x24/actions/edit-find.png icons/24x24/actions/glabels-align-text-center.png icons/24x24/actions/glabels-align-text-left.png icons/24x24/actions/glabels-align-text-right.png diff --git a/glabels/icons/16x16/actions/edit-clear.png b/glabels/icons/16x16/actions/edit-clear.png new file mode 100644 index 0000000..b88491c Binary files /dev/null and b/glabels/icons/16x16/actions/edit-clear.png differ diff --git a/glabels/icons/16x16/actions/edit-find.png b/glabels/icons/16x16/actions/edit-find.png new file mode 100644 index 0000000..94e0cec Binary files /dev/null and b/glabels/icons/16x16/actions/edit-find.png differ diff --git a/glabels/icons/24x24/actions/edit-clear.png b/glabels/icons/24x24/actions/edit-clear.png new file mode 100644 index 0000000..b85fa29 Binary files /dev/null and b/glabels/icons/24x24/actions/edit-clear.png differ diff --git a/glabels/icons/24x24/actions/edit-find.png b/glabels/icons/24x24/actions/edit-find.png new file mode 100644 index 0000000..ae9787f Binary files /dev/null and b/glabels/icons/24x24/actions/edit-find.png differ diff --git a/glabels/ui/NewLabelDialog.ui b/glabels/ui/NewLabelDialog.ui index c7fad4f..8e74ac2 100644 --- a/glabels/ui/NewLabelDialog.ui +++ b/glabels/ui/NewLabelDialog.ui @@ -21,13 +21,45 @@ - - - - 0 - 0 - + + + Search + + + + + + 0 + 0 + + + + Search + + + + + + + + + + + :/icons/16x16/actions/edit-clear.png:/icons/16x16/actions/edit-clear.png + + + + 16 + 16 + + + + true + + + + @@ -61,65 +93,44 @@ false - - - - 10 - 20 - 121 - 21 - - - - - 50 - false - - - - ISO sizes - - - - - - 10 - 40 - 111 - 21 - - - - - 50 - false - - - - US sizes - - - - - - 10 - 60 - 111 - 21 - - - - - 50 - false - - - - Other - - + + + + + ISO sizes + + + + + + + US sizes + + + + + + + Other + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + @@ -445,6 +456,178 @@
SimplePreview.h
- - + + + + + + searchEntry + textChanged(QString) + NewLabelDialog + onSearchEntryTextChanged() + + + 69 + 48 + + + 2 + 53 + + + + + searchClearButton + clicked() + NewLabelDialog + onSearchClearButtonClicked() + + + 177 + 52 + + + 190 + 7 + + + + + pageSizeIsoCheck + toggled(bool) + NewLabelDialog + onPageSizeCheckToggled() + + + 78 + 116 + + + 3 + 110 + + + + + pageSizeUsCheck + toggled(bool) + NewLabelDialog + onPageSizeCheckToggled() + + + 52 + 145 + + + 8 + 144 + + + + + pageSizeOtherCheck + toggled(bool) + NewLabelDialog + onPageSizeCheckToggled() + + + 37 + 170 + + + 10 + 188 + + + + + templatePicker + itemSelectionChanged() + NewLabelDialog + onTemplatePickerSelectionChanged() + + + 232 + 550 + + + 244 + 697 + + + + + orientationRotatedRadio + toggled(bool) + NewLabelDialog + onOrientationRadioToggled() + + + 901 + 637 + + + 982 + 617 + + + + + orientationNormalRadio + toggled(bool) + NewLabelDialog + onOrientationRadioToggled() + + + 807 + 644 + + + 982 + 592 + + + + + createButton + clicked() + NewLabelDialog + onCreateButtonClicked() + + + 951 + 699 + + + 985 + 671 + + + + + cancelButton + clicked() + NewLabelDialog + onCancelButtonClicked() + + + 837 + 692 + + + 767 + 704 + + + + + + onSearchClearButtonClicked() + onPageSizeCheckToggled() + onTemplatePickerSelectionChanged() + onOrientationRadioToggled() + onCreateButtonClicked() + onSearchEntryTextChanged() + onCancelButtonClicked() +