Added extra stats to user interface.

This commit is contained in:
Andrew Lalis 2018-03-10 16:02:01 +01:00
parent 15117d6658
commit 44f8903154
4 changed files with 192 additions and 25 deletions

View File

@ -241,40 +241,181 @@ QPushButton#browseButton:pressed{
<property name="bottomMargin"> <property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item alignment="Qt::AlignTop"> <item>
<widget class="QLabel" name="recipeNameLabel"> <widget class="QWidget" name="basicInfoPanel" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>80</height>
</size>
</property>
<property name="font"> <property name="font">
<font> <font>
<family>Noto Sans CJK KR Light</family>
<pointsize>24</pointsize>
<weight>50</weight> <weight>50</weight>
<italic>false</italic> <italic>false</italic>
<bold>false</bold> <bold>false</bold>
<stylestrategy>PreferAntialias</stylestrategy>
<kerning>true</kerning>
</font> </font>
</property> </property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">background-color: rgb(219, 216, 216);</string> <string notr="true">background-color: rgb(219, 216, 216);
</property> font: &quot;Noto Sans CJK KR&quot;;</string>
<property name="text">
<string>Recipe Name</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item alignment="Qt::AlignLeft">
<widget class="QWidget" name="basicInfoSubPanel" native="true">
<property name="font">
<font>
<family>Noto Sans CJK KR Light</family>
</font>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QWidget" name="prepTimePanel" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="prepTimeLabel">
<property name="font">
<font>
<family>Noto Sans CJK KR Light</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Prep Time:</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="cookTimePanel" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="cookTimeLabel">
<property name="font">
<font>
<family>Noto Sans CJK KR Light</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Cook Time:</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="servingsPanel" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_6">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="servingsLabel">
<property name="font">
<font>
<family>Noto Sans CJK KR Light</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Servings:</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QLabel" name="recipeNameLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>80</height>
</size>
</property>
<property name="font">
<font>
<family>Noto Sans CJK KR Light</family>
<pointsize>30</pointsize>
<weight>50</weight>
<italic>false</italic>
<bold>false</bold>
<stylestrategy>PreferAntialias</stylestrategy>
</font>
</property>
<property name="text">
<string>Recipe Name</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget> </widget>
</item> </item>
<item> <item>
@ -417,6 +558,12 @@ QPushButton#browseButton:pressed{
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="minimumSize">
<size>
<width>400</width>
<height>0</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_3">
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>

View File

@ -48,5 +48,7 @@ int main(int argc, char *argv[])
// printf("Accepted the dialog.\n"); // printf("Accepted the dialog.\n");
// } // }
w.loadFromRecipe(recipeDB.retrieveRecipe("Generic Bread"));
return a.exec(); return a.exec();
} }

View File

@ -22,6 +22,9 @@ void MainWindow::loadFromRecipe(Recipe recipe){
setInstruction(recipe.getInstruction()); setInstruction(recipe.getInstruction());
setIngredients(recipe.getIngredients()); setIngredients(recipe.getIngredients());
setImage(recipe.getImage()); setImage(recipe.getImage());
setPrepTime(recipe.getPrepTime());
setCookTime(recipe.getCookTime());
setServings(recipe.getServings());
} }
void MainWindow::setRecipeName(string name){ void MainWindow::setRecipeName(string name){
@ -40,6 +43,18 @@ void MainWindow::setImage(QImage img){
ui->imageLabel->setPixmap(QPixmap::fromImage(img)); ui->imageLabel->setPixmap(QPixmap::fromImage(img));
} }
void MainWindow::setPrepTime(QTime prepTime){
ui->prepTimeLabel->setText(QString("Prep Time: ")+prepTime.toString("hh:mm:ss"));
}
void MainWindow::setCookTime(QTime cookTime){
ui->cookTimeLabel->setText(QString("Cook Time: ")+cookTime.toString("hh:mm:ss"));
}
void MainWindow::setServings(float servings){
ui->servingsLabel->setText(QString("Servings: ")+QString::fromStdString(toString(servings)));
}
void MainWindow::on_newButton_clicked(){ void MainWindow::on_newButton_clicked(){
NewRecipeDialog d(this->recipeDB, this); NewRecipeDialog d(this->recipeDB, this);
d.show(); d.show();

View File

@ -39,6 +39,9 @@ public:
void setInstruction(Instruction instruction); void setInstruction(Instruction instruction);
void setIngredients(vector<RecipeIngredient> ingredients); void setIngredients(vector<RecipeIngredient> ingredients);
void setImage(QImage img); void setImage(QImage img);
void setPrepTime(QTime prepTime);
void setCookTime(QTime cookTime);
void setServings(float servings);
}; };
#endif // MAINWINDOW_H #endif // MAINWINDOW_H