2018-03-29 07:58:25 +00:00
|
|
|
#include "gui/mainwindow.h"
|
2018-03-04 09:19:32 +00:00
|
|
|
#include "gui/newrecipedialog.h"
|
2018-03-31 20:01:49 +00:00
|
|
|
|
2018-02-02 09:00:46 +00:00
|
|
|
#include <QApplication>
|
2018-03-31 20:01:49 +00:00
|
|
|
#include <QFontDatabase>
|
2018-02-02 10:41:36 +00:00
|
|
|
|
2018-02-12 13:24:11 +00:00
|
|
|
#include "model/database/database.h"
|
2018-03-01 16:19:13 +00:00
|
|
|
#include "model/database/recipedatabase.h"
|
2018-03-29 15:17:07 +00:00
|
|
|
#include "utils/fileutils.h"
|
2018-02-02 09:00:46 +00:00
|
|
|
|
2018-03-31 13:02:35 +00:00
|
|
|
Recipe checkForFirstRun(RecipeDatabase *recipeDB){
|
|
|
|
Recipe r = recipeDB->retrieveRandomRecipe();
|
|
|
|
if (r.isEmpty()){//There are no recipes in the database.
|
|
|
|
//Add some basic units to the units, and some basic ingredients.
|
2018-05-22 21:09:52 +00:00
|
|
|
|
2018-03-31 13:02:35 +00:00
|
|
|
}
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2018-03-31 20:01:49 +00:00
|
|
|
void loadAndSetFonts(){
|
2018-03-31 20:45:19 +00:00
|
|
|
int id = QFontDatabase::addApplicationFont(":/fonts/fonts/NotoSans-Light.ttf");
|
|
|
|
if (id == -1){
|
|
|
|
return;
|
|
|
|
}
|
2018-03-31 20:15:01 +00:00
|
|
|
QString family = QFontDatabase::applicationFontFamilies(id).at(0);
|
2018-03-31 20:01:49 +00:00
|
|
|
}
|
|
|
|
|
2018-02-02 09:00:46 +00:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2018-03-29 15:17:07 +00:00
|
|
|
RecipeDatabase recipeDB(QString(FileUtils::appDataPath+"recipes.db").toStdString());
|
2018-02-02 09:00:46 +00:00
|
|
|
|
2018-03-31 13:02:35 +00:00
|
|
|
QApplication a(argc, argv);
|
2018-03-31 20:15:01 +00:00
|
|
|
|
|
|
|
loadAndSetFonts();
|
2018-03-31 20:45:19 +00:00
|
|
|
QFont notoFont("Noto Sans");
|
|
|
|
notoFont.setStyleHint(QFont::SansSerif);
|
|
|
|
notoFont.setWeight(QFont::Thin);
|
|
|
|
a.setFont(notoFont);
|
2018-03-31 20:15:01 +00:00
|
|
|
|
2018-03-31 13:02:35 +00:00
|
|
|
MainWindow w(&recipeDB);
|
|
|
|
w.loadFromRecipe(checkForFirstRun(&recipeDB));
|
|
|
|
w.show();
|
2018-03-30 10:29:10 +00:00
|
|
|
|
|
|
|
a.exec();
|
|
|
|
recipeDB.closeConnection();
|
2018-03-30 12:33:48 +00:00
|
|
|
|
2018-03-30 10:29:10 +00:00
|
|
|
return 0;
|
|
|
|
}
|