This repository has been archived by the owner on Apr 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
recipeinfo.cpp
69 lines (49 loc) · 1.96 KB
/
recipeinfo.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include "recipeinfo.h"
RecipeInfo::RecipeInfo(QWidget *parent) : QWidget(parent)
{
stepdialog = new StepsDialog(this);
QVBoxLayout * mainLayout = new QVBoxLayout();
recipetab = new RecipeTab();
ingtab = new IngredientTab();
QScrollArea * recipeTabScroll = new QScrollArea(this);
recipeTabScroll->setWidgetResizable(true);
recipeTabScroll->setWidget(recipetab);
tabs = new QTabWidget();
tabs->addTab(recipeTabScroll, "");
tabs->addTab(ingtab, "");
startBtn = new QPushButton();
startBtn->setDisabled(true);
mainLayout->addWidget(tabs);
mainLayout->addWidget(startBtn);
startLabel = new QLabel();
startLabel->setAlignment(Qt::AlignCenter);
mainLayout->addWidget(startLabel);
setLayout(mainLayout);
UpdateLang();
connect(startBtn, SIGNAL(clicked()), this, SLOT(StartCooking()));
connect(this, SIGNAL(recipeLoaded(Recipe*)), recipetab, SLOT(UpdateUI(Recipe*)));
connect(this, SIGNAL(ingredientsLoaded(const QStringList&)), ingtab, SLOT(SetIngredients(const QStringList&)));
connect(this, SIGNAL(stepLoaded(const QStringList&)), stepdialog, SLOT(Init(const QStringList&)));
connect(this, SIGNAL(changeLang()), recipetab, SLOT(UpdateLang()));
tabs->hide();
startBtn->hide();
}
void RecipeInfo::UpdateLang() {
startLabel->setText(tr("Veuillez charger une recette\nFichier -> Charger une recette\nOU\nGlissez-Déposez un fichier de recette"));
tabs->setTabText(0, tr("Informations"));
tabs->setTabText(1, tr("Ingrédients"));
startBtn->setText(tr("Cuisiner"));
emit changeLang();
}
void RecipeInfo::StartCooking() {
stepdialog->show();
}
void RecipeInfo::LoadRecipe(Recipe * r) {
emit recipeLoaded(r);
emit ingredientsLoaded(r->getIngredients());
emit stepLoaded(r->getInstructions());
startBtn->setEnabled(true);
startLabel->hide();
tabs->show();
startBtn->show();
}