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,10 +241,152 @@ QPushButton#browseButton:pressed{
<property name="bottomMargin">
<number>0</number>
</property>
<item alignment="Qt::AlignTop">
<item>
<widget class="QWidget" name="basicInfoPanel" native="true">
<property name="font">
<font>
<weight>50</weight>
<italic>false</italic>
<bold>false</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(219, 216, 216);
font: &quot;Noto Sans CJK KR&quot;;</string>
</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="Preferred" vsizetype="Fixed">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -258,17 +400,13 @@ QPushButton#browseButton:pressed{
<property name="font">
<font>
<family>Noto Sans CJK KR Light</family>
<pointsize>24</pointsize>
<pointsize>30</pointsize>
<weight>50</weight>
<italic>false</italic>
<bold>false</bold>
<stylestrategy>PreferAntialias</stylestrategy>
<kerning>true</kerning>
</font>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(219, 216, 216);</string>
</property>
<property name="text">
<string>Recipe Name</string>
</property>
@ -277,6 +415,9 @@ QPushButton#browseButton:pressed{
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="displayPanelContent" native="true">
<property name="sizePolicy">
@ -417,6 +558,12 @@ QPushButton#browseButton:pressed{
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>400</width>
<height>0</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="spacing">
<number>0</number>

View File

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

View File

@ -22,6 +22,9 @@ void MainWindow::loadFromRecipe(Recipe recipe){
setInstruction(recipe.getInstruction());
setIngredients(recipe.getIngredients());
setImage(recipe.getImage());
setPrepTime(recipe.getPrepTime());
setCookTime(recipe.getCookTime());
setServings(recipe.getServings());
}
void MainWindow::setRecipeName(string name){
@ -40,6 +43,18 @@ void MainWindow::setImage(QImage 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(){
NewRecipeDialog d(this->recipeDB, this);
d.show();

View File

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