From 4f78b374609cb3a3d7985f26f3fc528c541ba6d6 Mon Sep 17 00:00:00 2001 From: andrewlalis Date: Sat, 10 Mar 2018 14:06:24 +0100 Subject: [PATCH] Added window icons, add new ingredient and add new tag dialogs. --- RecipeDB.pro | 12 +- gui/mainwindow.ui | 8 +- gui/newDialogs/newingredientdialog.cpp | 18 +++ gui/newDialogs/newingredientdialog.h | 26 ++++ gui/newDialogs/newingredientdialog.ui | 120 ++++++++++++++++++ gui/newDialogs/newtagdialog.cpp | 18 +++ gui/newDialogs/newtagdialog.h | 26 ++++ gui/newDialogs/newtagdialog.ui | 92 ++++++++++++++ gui/newrecipedialog.cpp | 24 ++++ gui/newrecipedialog.h | 9 ++ gui/newrecipedialog.ui | 30 ++++- images.qrc | 1 + images/icon.png | Bin 0 -> 912 bytes .../ingredients/ingredientlistmodel.cpp | 1 + model/recipe/tags/taglistmodel.cpp | 1 + 15 files changed, 381 insertions(+), 5 deletions(-) create mode 100644 gui/newDialogs/newingredientdialog.cpp create mode 100644 gui/newDialogs/newingredientdialog.h create mode 100644 gui/newDialogs/newingredientdialog.ui create mode 100644 gui/newDialogs/newtagdialog.cpp create mode 100644 gui/newDialogs/newtagdialog.h create mode 100644 gui/newDialogs/newtagdialog.ui create mode 100644 images/icon.png diff --git a/RecipeDB.pro b/RecipeDB.pro index c2c8a98..e573956 100644 --- a/RecipeDB.pro +++ b/RecipeDB.pro @@ -27,7 +27,9 @@ SOURCES += model/recipe/instruction.cpp \ model/database/recipedatabase.cpp \ utils/fileutils.cpp \ gui/newrecipedialog.cpp \ - model/recipe/tags/taglistmodel.cpp + model/recipe/tags/taglistmodel.cpp \ + gui/newDialogs/newingredientdialog.cpp \ + gui/newDialogs/newtagdialog.cpp HEADERS += model/recipe/instruction.h \ model/recipe/recipe.h \ @@ -44,12 +46,16 @@ HEADERS += model/recipe/instruction.h \ model/database/recipedatabase.h \ utils/fileutils.h \ gui/newrecipedialog.h \ - model/recipe/tags/taglistmodel.h + model/recipe/tags/taglistmodel.h \ + gui/newDialogs/newingredientdialog.h \ + gui/newDialogs/newtagdialog.h LIBS += -ldl \ FORMS += gui/mainwindow.ui \ - gui/newrecipedialog.ui + gui/newrecipedialog.ui \ + gui/newDialogs/newingredientdialog.ui \ + gui/newDialogs/newtagdialog.ui DISTFILES += \ .gitignore diff --git a/gui/mainwindow.ui b/gui/mainwindow.ui index ae24fae..252d695 100644 --- a/gui/mainwindow.ui +++ b/gui/mainwindow.ui @@ -25,6 +25,10 @@ RecipeDB + + + :/images/images/icon.png:/images/images/icon.png + 1.000000000000000 @@ -556,6 +560,8 @@ p, li { white-space: pre-wrap; } - + + + diff --git a/gui/newDialogs/newingredientdialog.cpp b/gui/newDialogs/newingredientdialog.cpp new file mode 100644 index 0000000..5b7597a --- /dev/null +++ b/gui/newDialogs/newingredientdialog.cpp @@ -0,0 +1,18 @@ +#include "newingredientdialog.h" +#include "ui_newingredientdialog.h" + +NewIngredientDialog::NewIngredientDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::NewIngredientDialog) +{ + ui->setupUi(this); +} + +NewIngredientDialog::~NewIngredientDialog() +{ + delete ui; +} + +Ingredient NewIngredientDialog::getIngredient(){ + return Ingredient(ui->nameEdit->text().toLower().toStdString(), ui->foodGroupEdit->text().toLower().toStdString()); +} diff --git a/gui/newDialogs/newingredientdialog.h b/gui/newDialogs/newingredientdialog.h new file mode 100644 index 0000000..4c94275 --- /dev/null +++ b/gui/newDialogs/newingredientdialog.h @@ -0,0 +1,26 @@ +#ifndef NEWINGREDIENTDIALOG_H +#define NEWINGREDIENTDIALOG_H + +#include +#include "model/recipe/ingredients/ingredient.h" + +namespace Ui { +class NewIngredientDialog; +} + +class NewIngredientDialog : public QDialog +{ + Q_OBJECT + + public: + explicit NewIngredientDialog(QWidget *parent = 0); + ~NewIngredientDialog(); + + //Access values. + Ingredient getIngredient(); + + private: + Ui::NewIngredientDialog *ui; +}; + +#endif // NEWINGREDIENTDIALOG_H diff --git a/gui/newDialogs/newingredientdialog.ui b/gui/newDialogs/newingredientdialog.ui new file mode 100644 index 0000000..8f4f268 --- /dev/null +++ b/gui/newDialogs/newingredientdialog.ui @@ -0,0 +1,120 @@ + + + NewIngredientDialog + + + + 0 + 0 + 240 + 320 + + + + New Ingredient + + + + :/images/images/icon.png:/images/images/icon.png + + + true + + + + + + true + + + + + + + + + Name + + + Qt::AlignCenter + + + + + + + + + + + + + + + + Food Group + + + Qt::AlignCenter + + + + + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + + buttonBox + accepted() + NewIngredientDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + NewIngredientDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/gui/newDialogs/newtagdialog.cpp b/gui/newDialogs/newtagdialog.cpp new file mode 100644 index 0000000..dd26afc --- /dev/null +++ b/gui/newDialogs/newtagdialog.cpp @@ -0,0 +1,18 @@ +#include "newtagdialog.h" +#include "ui_newtagdialog.h" + +NewTagDialog::NewTagDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::newTagDialog) +{ + ui->setupUi(this); +} + +NewTagDialog::~NewTagDialog() +{ + delete ui; +} + +RecipeTag NewTagDialog::getTag(){ + return RecipeTag(ui->tagEdit->text().toLower().toStdString()); +} diff --git a/gui/newDialogs/newtagdialog.h b/gui/newDialogs/newtagdialog.h new file mode 100644 index 0000000..e096f21 --- /dev/null +++ b/gui/newDialogs/newtagdialog.h @@ -0,0 +1,26 @@ +#ifndef NEWTAGDIALOG_H +#define NEWTAGDIALOG_H + +#include + +#include "model/recipe/tags/recipetag.h" + +namespace Ui { +class newTagDialog; +} + +class NewTagDialog : public QDialog +{ + Q_OBJECT + + public: + explicit NewTagDialog(QWidget *parent = 0); + ~NewTagDialog(); + + //Access values + RecipeTag getTag(); + private: + Ui::newTagDialog *ui; +}; + +#endif // NEWTAGDIALOG_H diff --git a/gui/newDialogs/newtagdialog.ui b/gui/newDialogs/newtagdialog.ui new file mode 100644 index 0000000..fd77812 --- /dev/null +++ b/gui/newDialogs/newtagdialog.ui @@ -0,0 +1,92 @@ + + + newTagDialog + + + + 0 + 0 + 240 + 320 + + + + Dialog + + + + :/images/images/icon.png:/images/images/icon.png + + + true + + + + + + + + + New Tag + + + Qt::AlignCenter + + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + + buttonBox + accepted() + newTagDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + newTagDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/gui/newrecipedialog.cpp b/gui/newrecipedialog.cpp index 058b0dd..4cfaeea 100644 --- a/gui/newrecipedialog.cpp +++ b/gui/newrecipedialog.cpp @@ -118,3 +118,27 @@ void NewRecipeDialog::on_selectImageButton_clicked(){ ui->imageDisplayLabel->setPixmap(QPixmap(filename)); } } + +void NewRecipeDialog::on_deleteIngredientButton_clicked(){ + QModelIndexList indexList = ui->ingredientsListView->selectionModel()->selectedIndexes(); + for (QModelIndexList::iterator it = indexList.begin(); it != indexList.end(); ++it){ + QModelIndex i = *it; + this->ingredientListModel.deleteIngredient(i.row()); + } +} + +void NewRecipeDialog::on_newIngredientButton_clicked(){ + NewIngredientDialog d(this); + d.show(); + if (d.exec() == QDialog::Accepted){ + Ingredient i = d.getIngredient(); + this->recipeDB->storeIngredient(i); + this->populateIngredientsBox(); + } +} + +void NewRecipeDialog::on_newTagButton_clicked(){ + newTagDialog + d.show(); + +} diff --git a/gui/newrecipedialog.h b/gui/newrecipedialog.h index 6e14097..43ff140 100644 --- a/gui/newrecipedialog.h +++ b/gui/newrecipedialog.h @@ -10,6 +10,9 @@ #include "model/recipe/ingredients/ingredientlistmodel.h" #include "model/recipe/tags/taglistmodel.h" +#include "gui/newDialogs/newingredientdialog.h" +#include "gui/newDialogs/newtagdialog.h" + namespace Ui { class NewRecipeDialog; } @@ -42,6 +45,12 @@ class NewRecipeDialog : public QDialog void on_selectImageButton_clicked(); + void on_deleteIngredientButton_clicked(); + + void on_newIngredientButton_clicked(); + + void on_newTagButton_clicked(); + private: Ui::NewRecipeDialog *ui; RecipeDatabase *recipeDB; diff --git a/gui/newrecipedialog.ui b/gui/newrecipedialog.ui index 25ffbbc..9a72e5e 100644 --- a/gui/newrecipedialog.ui +++ b/gui/newrecipedialog.ui @@ -22,6 +22,13 @@ New Recipe + + + :/images/images/icon.png:/images/images/icon.png + + + true + 0 @@ -327,6 +334,9 @@ QFrame::NoFrame + + QAbstractItemView::MultiSelection + @@ -599,6 +609,9 @@ QFrame::NoFrame + + QAbstractItemView::MultiSelection + 100 @@ -610,7 +623,7 @@ - + @@ -665,6 +678,9 @@ + + background-color: rgb(250, 250, 255); + @@ -728,6 +744,12 @@ + + background-color: rgb(255, 255, 255); + + + QFrame::NoFrame + Enter instructions here. @@ -741,9 +763,15 @@ Qt::LeftToRight + + false + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + true + diff --git a/images.qrc b/images.qrc index 6634926..5f9348c 100644 --- a/images.qrc +++ b/images.qrc @@ -1,5 +1,6 @@ images/no_image.png + images/icon.png diff --git a/images/icon.png b/images/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..9a2db3c33ebcf57ecdf1bc565dc7773efe8eb524 GIT binary patch literal 912 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K5893O0R7}x|G$6%N?Bp530R%N1DIE+9%l7&9>S(9P*t)Fc{f3hMWqbx2UKLX|J~|UpFxl6yta{%ys|jCsSl3^D zx<|I}vT}nZ6GP%C8juiJ{{6Z6-bTmmugj~LoWIq6XLOj!;4otp(LDriY`Yc(%nFkA YXGHkTHi-Eo0J9i_r>mdKI;Vst0F?>R`Tzg` literal 0 HcmV?d00001 diff --git a/model/recipe/ingredients/ingredientlistmodel.cpp b/model/recipe/ingredients/ingredientlistmodel.cpp index 360d48c..7763671 100644 --- a/model/recipe/ingredients/ingredientlistmodel.cpp +++ b/model/recipe/ingredients/ingredientlistmodel.cpp @@ -55,6 +55,7 @@ bool IngredientListModel::addIngredient(RecipeIngredient ri){ void IngredientListModel::deleteIngredient(int index){ this->ingredients.erase(this->ingredients.begin() + index); + emit dataChanged(createIndex(0, 0), createIndex(this->ingredients.size()-1, 0)); } vector IngredientListModel::getIngredients(){ diff --git a/model/recipe/tags/taglistmodel.cpp b/model/recipe/tags/taglistmodel.cpp index 4555cd7..149ad3e 100644 --- a/model/recipe/tags/taglistmodel.cpp +++ b/model/recipe/tags/taglistmodel.cpp @@ -41,6 +41,7 @@ bool TagListModel::addTag(RecipeTag tag){ void TagListModel::deleteTag(int index){ this->tags.erase(this->tags.begin() + index); + emit dataChanged(createIndex(0, 0), createIndex(this->tags.size()-1, 0)); } vector TagListModel::getTags(){