diff --git a/ui/+mediacenter/Banner.qml b/ui/+mediacenter/Banner.qml index 09acb68..cba6632 100644 --- a/ui/+mediacenter/Banner.qml +++ b/ui/+mediacenter/Banner.qml @@ -2,13 +2,12 @@ * Copyright 2018 by Aditya Mehra */ -import QtQuick.Layouts 1.4 -import QtQuick 2.12 -import QtQuick.Controls 2.12 -import org.kde.kirigami 2.11 as Kirigami +import QtQuick.Layouts 1.15 +import QtQuick 2.15 +import QtQuick.Controls 2.15 +import org.kde.kirigami 2.19 as Kirigami import Mycroft 1.0 as Mycroft -import QtGraphicalEffects 1.0 - +import Qt5Compat.GraphicalEffects import "code/helper.js" as HelperJS Item { diff --git a/ui/+mediacenter/FoodWizardHome.qml b/ui/+mediacenter/FoodWizardHome.qml index 2ab8822..545ea54 100644 --- a/ui/+mediacenter/FoodWizardHome.qml +++ b/ui/+mediacenter/FoodWizardHome.qml @@ -16,12 +16,12 @@ * along with this program. If not, see . */ -import QtQuick.Layouts 1.4 -import QtQuick 2.8 -import QtQuick.Controls 2.2 -import org.kde.kirigami 2.10 as Kirigami +import QtQuick.Layouts 1.15 +import QtQuick 2.15 +import QtQuick.Controls 2.15 +import org.kde.kirigami 2.15 as Kirigami import Mycroft 1.0 as Mycroft -import QtGraphicalEffects 1.0 +import Qt5Compat.GraphicalEffects import "code/helper.js" as HelperJS Mycroft.Delegate { @@ -76,7 +76,7 @@ Mycroft.Delegate { Label { horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter - text: "Find Something To Cook With Custom Ingredients" + text: qsTr("Find Something To Cook With Custom Ingredients") anchors.left: headsImage.right anchors.top: parent.top anchors.bottom: parent.bottom @@ -122,7 +122,7 @@ Mycroft.Delegate { } } - Keys.onReturnPressed: { + Keys.onReturnPressed: (event)=> { Mycroft.SoundEffects.playClickedSound(Qt.resolvedUrl("sound/clicked.wav")) triggerGuiEvent("foodwizard.close", {}) } @@ -149,7 +149,7 @@ Mycroft.Delegate { KeyNavigation.up: closeBtn focus: true - Keys.onReturnPressed: { + Keys.onReturnPressed: (event)=> { txtFldInternal.forceActiveFocus() } @@ -159,13 +159,13 @@ Mycroft.Delegate { anchors.margins: Kirigami.Units.largeSpacing KeyNavigation.down: answerButton font.pixelSize: txtFld.height * 0.25 - placeholderText: "Add a list of ingredients e.g., orange, cheese, chicken, lime" + placeholderText: qsTr("Add a list of ingredients e.g., orange, cheese, chicken, lime") onAccepted: { Mycroft.SoundEffects.playClickedSound(Qt.resolvedUrl("sound/clicked.wav")) triggerGuiEvent("foodwizard.searchrecipe", {"query": txtFldInternal.text}) } - Keys.onReturnPressed: { + Keys.onReturnPressed: (event)=> { Mycroft.SoundEffects.playClickedSound(Qt.resolvedUrl("sound/clicked.wav")) triggerGuiEvent("foodwizard.searchrecipe", {"query": txtFldInternal.text}) } @@ -207,7 +207,7 @@ Mycroft.Delegate { answerButton.opacity = 1 } - Keys.onReturnPressed: { + Keys.onReturnPressed: (event)=> { clicked() } } diff --git a/ui/+mediacenter/RecipeDetail.qml b/ui/+mediacenter/RecipeDetail.qml index 94cdd8d..02eecc0 100755 --- a/ui/+mediacenter/RecipeDetail.qml +++ b/ui/+mediacenter/RecipeDetail.qml @@ -16,12 +16,12 @@ * along with this program. If not, see . */ -import QtQuick 2.12 -import QtQuick.Layouts 1.4 -import QtQuick.Controls 2.12 -import org.kde.kirigami 2.11 as Kirigami -import QtGraphicalEffects 1.0 +import QtQuick 2.15 +import QtQuick.Layouts 1.15 +import QtQuick.Controls 2.15 +import org.kde.kirigami 2.19 as Kirigami import Mycroft 1.0 as Mycroft +import Qt5Compat.GraphicalEffects import "code/helper.js" as HelperJS Mycroft.Delegate { @@ -30,16 +30,16 @@ Mycroft.Delegate { property bool horizontalMode: width > height ? 1 : 0 fillWidth: true - Keys.onBackPressed: { + Keys.onBackPressed: (event)=> { parent.parent.parent.currentIndex-- parent.parent.parent.currentItem.contentItem.forceActiveFocus() } - Keys.onUpPressed: { + Keys.onUpPressed: (event)=> { backButton.forceActiveFocus() } - Keys.onDownPressed: { + Keys.onDownPressed: (event)=> { readRecipeButton.forceActiveFocus() } @@ -76,6 +76,10 @@ Mycroft.Delegate { } } + Keys.onReturnPressed: (event)=> { + clicked() + } + onClicked: { root.parent.parent.parent.currentIndex-- root.parent.parent.parent.currentItem.contentItem.forceActiveFocus() @@ -409,6 +413,10 @@ Mycroft.Delegate { } } + Keys.onReturnPressed: (event)=> { + clicked() + } + onClicked: { if (ingredientsLabel.visible) { triggerGuiEvent("foodwizard.readrecipe.ingredients", {}) @@ -520,6 +528,10 @@ Mycroft.Delegate { color: Kirigami.Theme.textColor } } + + Keys.onReturnPressed: (event)=> { + clicked() + } } TabButton { @@ -544,6 +556,10 @@ Mycroft.Delegate { color: Kirigami.Theme.textColor } } + + Keys.onReturnPressed: (event)=> { + clicked() + } } } } diff --git a/ui/+mediacenter/SearchRecipe.qml b/ui/+mediacenter/SearchRecipe.qml index 2361450..46b65f1 100755 --- a/ui/+mediacenter/SearchRecipe.qml +++ b/ui/+mediacenter/SearchRecipe.qml @@ -16,12 +16,12 @@ * along with this program. If not, see . */ -import QtQuick.Layouts 1.4 -import QtQuick 2.8 -import QtQuick.Controls 2.2 -import org.kde.kirigami 2.11 as Kirigami +import QtQuick.Layouts 1.15 +import QtQuick 2.15 +import QtQuick.Controls 2.15 +import org.kde.kirigami 2.19 as Kirigami import Mycroft 1.0 as Mycroft -import QtGraphicalEffects 1.0 +import Qt5Compat.GraphicalEffects import "code/helper.js" as HelperJS @@ -50,7 +50,7 @@ Mycroft.Delegate { uiGridView.forceActiveFocus() } - Keys.onBackPressed: { + Keys.onBackPressed: (event)=> { parent.parent.parent.currentIndex-- parent.parent.parent.currentItem.contentItem.forceActiveFocus() } @@ -140,7 +140,7 @@ Mycroft.Delegate { triggerGuiEvent("foodwizard.showrecipe", {"recipe": RecipeUrl}); } - Keys.onReturnPressed: { + Keys.onReturnPressed: (event)=> { clicked() } @@ -151,14 +151,14 @@ Mycroft.Delegate { } } - Keys.onReturnPressed: { + Keys.onReturnPressed: (event)=> { card.clicked() } } } Kirigami.Heading { - text: "No recipes found" + text: qsTr("No recipes found") parent: root anchors.centerIn: parent visible: uiGridView.count == 0 diff --git a/ui/Banner.qml b/ui/Banner.qml index 09acb68..53f9bc4 100644 --- a/ui/Banner.qml +++ b/ui/Banner.qml @@ -2,12 +2,12 @@ * Copyright 2018 by Aditya Mehra */ -import QtQuick.Layouts 1.4 -import QtQuick 2.12 -import QtQuick.Controls 2.12 -import org.kde.kirigami 2.11 as Kirigami +import QtQuick.Layouts 1.15 +import QtQuick 2.15 +import QtQuick.Controls 2.15 +import org.kde.kirigami 2.19 as Kirigami import Mycroft 1.0 as Mycroft -import QtGraphicalEffects 1.0 +import Qt5Compat.GraphicalEffects import "code/helper.js" as HelperJS diff --git a/ui/FoodWizardHome.qml b/ui/FoodWizardHome.qml index 2ab8822..ca8e3c2 100644 --- a/ui/FoodWizardHome.qml +++ b/ui/FoodWizardHome.qml @@ -16,12 +16,12 @@ * along with this program. If not, see . */ -import QtQuick.Layouts 1.4 -import QtQuick 2.8 -import QtQuick.Controls 2.2 -import org.kde.kirigami 2.10 as Kirigami +import QtQuick.Layouts 1.15 +import QtQuick 2.15 +import QtQuick.Controls 2.15 +import org.kde.kirigami 2.19 as Kirigami import Mycroft 1.0 as Mycroft -import QtGraphicalEffects 1.0 +import Qt5Compat.GraphicalEffects import "code/helper.js" as HelperJS Mycroft.Delegate { @@ -76,7 +76,7 @@ Mycroft.Delegate { Label { horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter - text: "Find Something To Cook With Custom Ingredients" + text: qsTr("Find Something To Cook With Custom Ingredients") anchors.left: headsImage.right anchors.top: parent.top anchors.bottom: parent.bottom @@ -122,7 +122,7 @@ Mycroft.Delegate { } } - Keys.onReturnPressed: { + Keys.onReturnPressed: (event)=> { Mycroft.SoundEffects.playClickedSound(Qt.resolvedUrl("sound/clicked.wav")) triggerGuiEvent("foodwizard.close", {}) } @@ -149,7 +149,7 @@ Mycroft.Delegate { KeyNavigation.up: closeBtn focus: true - Keys.onReturnPressed: { + Keys.onReturnPressed: (event)=> { txtFldInternal.forceActiveFocus() } @@ -159,13 +159,13 @@ Mycroft.Delegate { anchors.margins: Kirigami.Units.largeSpacing KeyNavigation.down: answerButton font.pixelSize: txtFld.height * 0.25 - placeholderText: "Add a list of ingredients e.g., orange, cheese, chicken, lime" + placeholderText: qsTr("Add a list of ingredients e.g., orange, cheese, chicken, lime") onAccepted: { Mycroft.SoundEffects.playClickedSound(Qt.resolvedUrl("sound/clicked.wav")) triggerGuiEvent("foodwizard.searchrecipe", {"query": txtFldInternal.text}) } - Keys.onReturnPressed: { + Keys.onReturnPressed: (event)=> { Mycroft.SoundEffects.playClickedSound(Qt.resolvedUrl("sound/clicked.wav")) triggerGuiEvent("foodwizard.searchrecipe", {"query": txtFldInternal.text}) } diff --git a/ui/RecipeDetail.qml b/ui/RecipeDetail.qml index 944b3aa..b5a19b0 100755 --- a/ui/RecipeDetail.qml +++ b/ui/RecipeDetail.qml @@ -16,12 +16,12 @@ * along with this program. If not, see . */ -import QtQuick 2.12 -import QtQuick.Layouts 1.4 -import QtQuick.Controls 2.12 -import org.kde.kirigami 2.11 as Kirigami -import QtGraphicalEffects 1.0 +import QtQuick 2.15 +import QtQuick.Layouts 1.15 +import QtQuick.Controls 2.15 +import org.kde.kirigami 2.19 as Kirigami import Mycroft 1.0 as Mycroft +import Qt5Compat.GraphicalEffects import "code/helper.js" as HelperJS Mycroft.Delegate { @@ -30,7 +30,7 @@ Mycroft.Delegate { property bool horizontalMode: width > height ? 1 : 0 fillWidth: true - Keys.onBackPressed: { + Keys.onBackPressed: (event)=> { parent.parent.parent.currentIndex-- parent.parent.parent.currentItem.contentItem.forceActiveFocus() } diff --git a/ui/SearchRecipe.qml b/ui/SearchRecipe.qml index cb23db2..b1ed24c 100755 --- a/ui/SearchRecipe.qml +++ b/ui/SearchRecipe.qml @@ -16,12 +16,12 @@ * along with this program. If not, see . */ -import QtQuick.Layouts 1.4 -import QtQuick 2.8 -import QtQuick.Controls 2.2 -import org.kde.kirigami 2.11 as Kirigami +import QtQuick.Layouts 1.15 +import QtQuick 2.15 +import QtQuick.Controls 2.15 +import org.kde.kirigami 2.19 as Kirigami import Mycroft 1.0 as Mycroft -import QtGraphicalEffects 1.0 +import Qt5Compat.GraphicalEffects import "code/helper.js" as HelperJS @@ -158,7 +158,7 @@ Mycroft.Delegate { } Kirigami.Heading { - text: "No recipes found" + text: qsTr("No recipes found") parent: root anchors.centerIn: parent visible: uiGridView.count == 0 diff --git a/ui/translations/FoodWizardHome_de.ts b/ui/translations/FoodWizardHome_de.ts new file mode 100644 index 0000000..a8340f0 --- /dev/null +++ b/ui/translations/FoodWizardHome_de.ts @@ -0,0 +1,22 @@ + + + + + FoodWizardHome + + + Find Something To Cook With Custom Ingredients + Finden Sie etwas zum Kochen mit benutzerdefinierten Zutaten + + + + Add a list of ingredients e.g., orange, cheese, chicken, lime + Fügen Sie eine Zutatenliste hinz + + + + Find Recipes + Rezepte finden + + + diff --git a/ui/translations/FoodWizardHome_es.ts b/ui/translations/FoodWizardHome_es.ts new file mode 100644 index 0000000..9569549 --- /dev/null +++ b/ui/translations/FoodWizardHome_es.ts @@ -0,0 +1,22 @@ + + + + + FoodWizardHome + + + Find Something To Cook With Custom Ingredients + Encuentra algo para cocinar con ingredientes personalizados + + + + Add a list of ingredients e.g., orange, cheese, chicken, lime + Agregue una lista de ingrediente + + + + Find Recipes + Encuentra Recetas + + + diff --git a/ui/translations/FoodWizardHome_fr.ts b/ui/translations/FoodWizardHome_fr.ts new file mode 100644 index 0000000..5e4cf4e --- /dev/null +++ b/ui/translations/FoodWizardHome_fr.ts @@ -0,0 +1,22 @@ + + + + + FoodWizardHome + + + Find Something To Cook With Custom Ingredients + Trouvez quelque chose à cuisiner avec des ingrédients personnalisés + + + + Add a list of ingredients e.g., orange, cheese, chicken, lime + Ajouter une liste d'ingrédient + + + + Find Recipes + Trouver des recettes + + + diff --git a/ui/translations/FoodWizardHome_it.ts b/ui/translations/FoodWizardHome_it.ts new file mode 100644 index 0000000..6678ae6 --- /dev/null +++ b/ui/translations/FoodWizardHome_it.ts @@ -0,0 +1,22 @@ + + + + + FoodWizardHome + + + Find Something To Cook With Custom Ingredients + Trova qualcosa da cucinare con ingredienti personalizzati + + + + Add a list of ingredients e.g., orange, cheese, chicken, lime + Aggiungi un elenco di ingredient + + + + Find Recipes + Trova ricette + + + diff --git a/ui/translations/FoodWizardHome_nl.ts b/ui/translations/FoodWizardHome_nl.ts new file mode 100644 index 0000000..aa1f2af --- /dev/null +++ b/ui/translations/FoodWizardHome_nl.ts @@ -0,0 +1,22 @@ + + + + + FoodWizardHome + + + Find Something To Cook With Custom Ingredients + Zoek iets om te koken met aangepaste ingrediënten + + + + Add a list of ingredients e.g., orange, cheese, chicken, lime + Voeg een lijst met ingrediënten to + + + + Find Recipes + Vind Recepten + + + diff --git a/ui/translations/FoodWizardHome_pt.ts b/ui/translations/FoodWizardHome_pt.ts new file mode 100644 index 0000000..17fba2e --- /dev/null +++ b/ui/translations/FoodWizardHome_pt.ts @@ -0,0 +1,22 @@ + + + + + FoodWizardHome + + + Find Something To Cook With Custom Ingredients + Encontre algo para cozinhar com ingredientes personalizados + + + + Add a list of ingredients e.g., orange, cheese, chicken, lime + Adicione uma lista de ingrediente + + + + Find Recipes + Encontrar receitas + + + diff --git a/ui/translations/RecipeDetail_de.ts b/ui/translations/RecipeDetail_de.ts new file mode 100644 index 0000000..a84d66a --- /dev/null +++ b/ui/translations/RecipeDetail_de.ts @@ -0,0 +1,57 @@ + + + + + RecipeDetail + + + Source + Quelle + + + + Calories + Kalorien + + + + Diet Type + Diät-Typ + + + + Health Tags + Gesundheits-Tags + + + + Recipe Ingredients + Rezeptzutaten + + + + Recipe Instructions + Rezeptanleitung + + + + Read Instructions + + + + + Read Ingredients + + + + + Ingredients + Zutaten + + + + Instructions + Anweisungen + + + diff --git a/ui/translations/RecipeDetail_es.ts b/ui/translations/RecipeDetail_es.ts new file mode 100644 index 0000000..d6330f9 --- /dev/null +++ b/ui/translations/RecipeDetail_es.ts @@ -0,0 +1,57 @@ + + + + + RecipeDetail + + + Source + Fuente + + + + Calories + calorías + + + + Diet Type + Tipo de dieta + + + + Health Tags + Etiquetas de salud + + + + Recipe Ingredients + Ingredientes de la receta + + + + Recipe Instructions + Instrucciones de recetas + + + + Read Instructions + + + + + Read Ingredients + + + + + Ingredients + Ingredientes + + + + Instructions + Instrucciones + + + diff --git a/ui/translations/RecipeDetail_fr.ts b/ui/translations/RecipeDetail_fr.ts new file mode 100644 index 0000000..837cc17 --- /dev/null +++ b/ui/translations/RecipeDetail_fr.ts @@ -0,0 +1,57 @@ + + + + + RecipeDetail + + + Source + Source + + + + Calories + Calories + + + + Diet Type + Type de régime + + + + Health Tags + Étiquettes de santé + + + + Recipe Ingredients + Ingrédients de la recette + + + + Recipe Instructions + Instructions de recette + + + + Read Instructions + + + + + Read Ingredients + + + + + Ingredients + Ingrédients + + + + Instructions + Instructions + + + diff --git a/ui/translations/RecipeDetail_it.ts b/ui/translations/RecipeDetail_it.ts new file mode 100644 index 0000000..d84a160 --- /dev/null +++ b/ui/translations/RecipeDetail_it.ts @@ -0,0 +1,57 @@ + + + + + RecipeDetail + + + Source + Fonte + + + + Calories + Calorie + + + + Diet Type + Tipo di dieta + + + + Health Tags + Tag di salute + + + + Recipe Ingredients + Ingredienti della ricetta + + + + Recipe Instructions + Istruzioni per la ricetta + + + + Read Instructions + + + + + Read Ingredients + + + + + Ingredients + ingredienti + + + + Instructions + Istruzioni + + + diff --git a/ui/translations/RecipeDetail_nl.ts b/ui/translations/RecipeDetail_nl.ts new file mode 100644 index 0000000..12b49ea --- /dev/null +++ b/ui/translations/RecipeDetail_nl.ts @@ -0,0 +1,57 @@ + + + + + RecipeDetail + + + Source + Bron + + + + Calories + Calorieën + + + + Diet Type + Soort dieet + + + + Health Tags + Gezondheidstags + + + + Recipe Ingredients + Recept Ingrediënten + + + + Recipe Instructions + Recept instructies + + + + Read Instructions + + + + + Read Ingredients + + + + + Ingredients + Ingrediënten + + + + Instructions + Instructies + + + diff --git a/ui/translations/RecipeDetail_pt.ts b/ui/translations/RecipeDetail_pt.ts new file mode 100644 index 0000000..e81212b --- /dev/null +++ b/ui/translations/RecipeDetail_pt.ts @@ -0,0 +1,57 @@ + + + + + RecipeDetail + + + Source + Fonte + + + + Calories + calorias + + + + Diet Type + Tipo de Dieta + + + + Health Tags + Etiquetas de Saúde + + + + Recipe Ingredients + Ingredientes da receita + + + + Recipe Instructions + Instruções da receita + + + + Read Instructions + + + + + Read Ingredients + + + + + Ingredients + Ingredientes + + + + Instructions + Instruções + + + diff --git a/ui/translations/SearchRecipe_de.ts b/ui/translations/SearchRecipe_de.ts new file mode 100644 index 0000000..d3970f2 --- /dev/null +++ b/ui/translations/SearchRecipe_de.ts @@ -0,0 +1,12 @@ + + + + + SearchRecipe + + + No recipes found + Keine Rezepte gefunden + + + diff --git a/ui/translations/SearchRecipe_es.ts b/ui/translations/SearchRecipe_es.ts new file mode 100644 index 0000000..be504fb --- /dev/null +++ b/ui/translations/SearchRecipe_es.ts @@ -0,0 +1,12 @@ + + + + + SearchRecipe + + + No recipes found + No se encontraron recetas + + + diff --git a/ui/translations/SearchRecipe_fr.ts b/ui/translations/SearchRecipe_fr.ts new file mode 100644 index 0000000..447f564 --- /dev/null +++ b/ui/translations/SearchRecipe_fr.ts @@ -0,0 +1,12 @@ + + + + + SearchRecipe + + + No recipes found + Aucune recette trouvée + + + diff --git a/ui/translations/SearchRecipe_it.ts b/ui/translations/SearchRecipe_it.ts new file mode 100644 index 0000000..c384a2f --- /dev/null +++ b/ui/translations/SearchRecipe_it.ts @@ -0,0 +1,12 @@ + + + + + SearchRecipe + + + No recipes found + Nessuna ricetta trovata + + + diff --git a/ui/translations/SearchRecipe_nl.ts b/ui/translations/SearchRecipe_nl.ts new file mode 100644 index 0000000..7417f91 --- /dev/null +++ b/ui/translations/SearchRecipe_nl.ts @@ -0,0 +1,12 @@ + + + + + SearchRecipe + + + No recipes found + Geen recepten gevonden + + + diff --git a/ui/translations/SearchRecipe_pt.ts b/ui/translations/SearchRecipe_pt.ts new file mode 100644 index 0000000..a628793 --- /dev/null +++ b/ui/translations/SearchRecipe_pt.ts @@ -0,0 +1,12 @@ + + + + + SearchRecipe + + + No recipes found + Nenhuma receita encontrada + + + diff --git a/ui/translations/skill-ovos-food-wizard.openvoiceos_de.qm b/ui/translations/skill-ovos-food-wizard.openvoiceos_de.qm new file mode 100644 index 0000000..2913cd6 Binary files /dev/null and b/ui/translations/skill-ovos-food-wizard.openvoiceos_de.qm differ diff --git a/ui/translations/skill-ovos-food-wizard.openvoiceos_es.qm b/ui/translations/skill-ovos-food-wizard.openvoiceos_es.qm new file mode 100644 index 0000000..0f3c345 Binary files /dev/null and b/ui/translations/skill-ovos-food-wizard.openvoiceos_es.qm differ diff --git a/ui/translations/skill-ovos-food-wizard.openvoiceos_fr.qm b/ui/translations/skill-ovos-food-wizard.openvoiceos_fr.qm new file mode 100644 index 0000000..a7c2a63 Binary files /dev/null and b/ui/translations/skill-ovos-food-wizard.openvoiceos_fr.qm differ diff --git a/ui/translations/skill-ovos-food-wizard.openvoiceos_it.qm b/ui/translations/skill-ovos-food-wizard.openvoiceos_it.qm new file mode 100644 index 0000000..6a86e9a Binary files /dev/null and b/ui/translations/skill-ovos-food-wizard.openvoiceos_it.qm differ diff --git a/ui/translations/skill-ovos-food-wizard.openvoiceos_nl.qm b/ui/translations/skill-ovos-food-wizard.openvoiceos_nl.qm new file mode 100644 index 0000000..3f460b0 Binary files /dev/null and b/ui/translations/skill-ovos-food-wizard.openvoiceos_nl.qm differ diff --git a/ui/translations/skill-ovos-food-wizard.openvoiceos_pt.qm b/ui/translations/skill-ovos-food-wizard.openvoiceos_pt.qm new file mode 100644 index 0000000..cc94b60 Binary files /dev/null and b/ui/translations/skill-ovos-food-wizard.openvoiceos_pt.qm differ diff --git a/ui5/+mediacenter/Banner.qml b/ui5/+mediacenter/Banner.qml new file mode 100644 index 0000000..09acb68 --- /dev/null +++ b/ui5/+mediacenter/Banner.qml @@ -0,0 +1,74 @@ +/* + * Copyright 2018 by Aditya Mehra + */ + +import QtQuick.Layouts 1.4 +import QtQuick 2.12 +import QtQuick.Controls 2.12 +import org.kde.kirigami 2.11 as Kirigami +import Mycroft 1.0 as Mycroft +import QtGraphicalEffects 1.0 + +import "code/helper.js" as HelperJS + +Item { + id: bannerRoot + property alias title: bannerTitle.text + property alias source: bannerImage.source + property alias titleWrapMode: bannerTitle.wrapMode + property alias titleLevel: bannerTitle.level + property alias radius: imgRoot.radius + + Rectangle { + id: imgRoot + color: "transparent" + clip: true + anchors.fill: parent + anchors.topMargin: 1 + anchors.leftMargin: 1 + anchors.rightMargin: 1 + anchors.bottomMargin: 0 + radius: bannerRoot.radius + + layer.enabled: true + layer.effect: OpacityMask { + maskSource: Rectangle { + x: imgRoot.x; y: imgRoot.y + width: imgRoot.width + height: imgRoot.height + radius: imgRoot.radius + } + } + + Image { + id: bannerImage + width: parent.width + height: parent.height + y: -12 + opacity: 1 + fillMode: Image.PreserveAspectCrop + + Rectangle { + id: bannerOverlay + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + height: parent.height * 0.3 + color: Kirigami.Theme.backgroundColor + opacity: 0.8 + + Kirigami.Heading { + id: bannerTitle + anchors.fill: parent + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + wrapMode: Text.WordWrap + elide: Text.ElideRight + level: 2 + maximumLineCount: 2 + color: Kirigami.Theme.textColor + } + } + } + } +} \ No newline at end of file diff --git a/ui5/+mediacenter/FoodWizardHome.qml b/ui5/+mediacenter/FoodWizardHome.qml new file mode 100644 index 0000000..2ab8822 --- /dev/null +++ b/ui5/+mediacenter/FoodWizardHome.qml @@ -0,0 +1,216 @@ +/* + * Copyright 2018 by Aditya Mehra + * Copyright 2018 Marco Martin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import QtQuick.Layouts 1.4 +import QtQuick 2.8 +import QtQuick.Controls 2.2 +import org.kde.kirigami 2.10 as Kirigami +import Mycroft 1.0 as Mycroft +import QtGraphicalEffects 1.0 +import "code/helper.js" as HelperJS + +Mycroft.Delegate { + id: root + skillBackgroundSource: "https://source.unsplash.com/1920x1080/?+food" + property bool compactMode: parent.height >= 550 ? 0 : 1 + property bool horizontalMode: width > height ? 1 : 0 + fillWidth: true + + Kirigami.Icon { + anchors.bottom: parent.bottom + anchors.horizontalCenter: parent.horizontalCenter + width: 150 + height: 60 + opacity: 0.7 + source: HelperJS.isLight(Kirigami.Theme.backgroundColor) ? Qt.resolvedUrl("images/edamam-dark.svg") : Qt.resolvedUrl("images/edamam-light.svg") + } + + Component.onCompleted: { + txtFld.forceActiveFocus() + } + + Item { + anchors.fill: parent + + ColumnLayout { + width: parent.width + height: parent.height / 2 + anchors.verticalCenter: compactMode ? undefined : parent.verticalCenter + anchors.top: compactMode ? parent.top : undefined + spacing: Kirigami.Units.largeSpacing + + Rectangle { + id: heads + Layout.fillWidth: true + Layout.fillHeight: true + Layout.maximumHeight: Mycroft.Units.gridUnit * 6 + Layout.minimumHeight: Mycroft.Units.gridUnit * 4 + radius: 10 + color: Qt.rgba(Kirigami.Theme.backgroundColor.r, Kirigami.Theme.backgroundColor.g, Kirigami.Theme.backgroundColor.b, 0.9) + + Image { + id: headsImage + anchors.left: parent.left + anchors.leftMargin: Mycroft.Units.gridUnit / 2 + anchors.verticalCenter: parent.verticalCenter + width: Mycroft.Units.gridUnit * 2 + height: Mycroft.Units.gridUnit * 2 + source: Qt.resolvedUrl("images/foodwizz.png") + } + + Label { + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + text: "Find Something To Cook With Custom Ingredients" + anchors.left: headsImage.right + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.right: closeBtn.left + anchors.margins: Mycroft.Units.gridUnit / 2 + wrapMode: Text.WordWrap + fontSizeMode: Text.Fit + font.pixelSize: heads.height * 0.25 + minimumPixelSize: 10 + color: Kirigami.Theme.textColor + } + + Button { + id: closeBtn + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.right: parent.right + anchors.margins: 4 + width: height + KeyNavigation.up: answerButton + KeyNavigation.down: txtFld + + background: Rectangle { + color: "transparent" + border.color: closeBtn.activeFocus ? Kirigami.Theme.linkColor : "transparent" + border.width: 2 + radius: 3 + } + + contentItem: Item { + Kirigami.Icon { + anchors.centerIn: parent + width: parent.width * 0.9 + height: parent.height * 0.9 + source: "window-close" + color: Kirigami.Theme.textColor + + ColorOverlay { + anchors.fill: parent + source: parent + color: closeBtn.activeFocus ? Kirigami.Theme.linkColor : Kirigami.Theme.textColor + } + } + } + + Keys.onReturnPressed: { + Mycroft.SoundEffects.playClickedSound(Qt.resolvedUrl("sound/clicked.wav")) + triggerGuiEvent("foodwizard.close", {}) + } + + onClicked: { + Mycroft.SoundEffects.playClickedSound(Qt.resolvedUrl("sound/clicked.wav")) + triggerGuiEvent("foodwizard.close", {}) + } + } + } + + Rectangle { + id: txtFld + anchors.top: sep.bottom + Layout.fillWidth: true + Layout.fillHeight: true + Layout.maximumHeight: Mycroft.Units.gridUnit * 8 + Layout.minimumHeight: Mycroft.Units.gridUnit * 5 + color: "transparent" + border.width: 2 + radius: Kirigami.Units.smallSpacing + border.color: txtFld.activeFocus ? Kirigami.Theme.linkColor : "transparent" + KeyNavigation.down: answerButton + KeyNavigation.up: closeBtn + focus: true + + Keys.onReturnPressed: { + txtFldInternal.forceActiveFocus() + } + + TextField { + id: txtFldInternal + anchors.fill: parent + anchors.margins: Kirigami.Units.largeSpacing + KeyNavigation.down: answerButton + font.pixelSize: txtFld.height * 0.25 + placeholderText: "Add a list of ingredients e.g., orange, cheese, chicken, lime" + + onAccepted: { + Mycroft.SoundEffects.playClickedSound(Qt.resolvedUrl("sound/clicked.wav")) + triggerGuiEvent("foodwizard.searchrecipe", {"query": txtFldInternal.text}) + } + Keys.onReturnPressed: { + Mycroft.SoundEffects.playClickedSound(Qt.resolvedUrl("sound/clicked.wav")) + triggerGuiEvent("foodwizard.searchrecipe", {"query": txtFldInternal.text}) + } + } + } + + Button { + id: answerButton + Layout.fillWidth: true + Layout.fillHeight: true + Layout.maximumHeight: Mycroft.Units.gridUnit * 6 + Layout.minimumHeight: Mycroft.Units.gridUnit * 4 + Layout.margins: Kirigami.Units.gridUnit + KeyNavigation.up: txtFld + + background: Rectangle { + color: answerButton.activeFocus ? "#4169E1" : "#4124AA" + radius: Kirigami.Units.gridUnit + } + + contentItem: Item { + Kirigami.Heading { + anchors.centerIn: parent + text: qsTr("Find Recipes") + level: compactMode ? 3 : 1 + } + } + + onClicked: { + Mycroft.SoundEffects.playClickedSound(Qt.resolvedUrl("sound/clicked.wav")) + triggerGuiEvent("foodwizard.searchrecipe", {"query": txtFldInternal.text}) + } + + onPressed: { + answerButton.opacity = 0.5 + } + + onReleased: { + answerButton.opacity = 1 + } + + Keys.onReturnPressed: { + clicked() + } + } + } + } +} diff --git a/ui5/+mediacenter/RecipeDetail.qml b/ui5/+mediacenter/RecipeDetail.qml new file mode 100755 index 0000000..94cdd8d --- /dev/null +++ b/ui5/+mediacenter/RecipeDetail.qml @@ -0,0 +1,550 @@ +/* + * Copyright 2018 by Aditya Mehra + * Copyright 2018 Marco Martin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import QtQuick 2.12 +import QtQuick.Layouts 1.4 +import QtQuick.Controls 2.12 +import org.kde.kirigami 2.11 as Kirigami +import QtGraphicalEffects 1.0 +import Mycroft 1.0 as Mycroft +import "code/helper.js" as HelperJS + +Mycroft.Delegate { + id: root + skillBackgroundSource: img.source + property bool horizontalMode: width > height ? 1 : 0 + fillWidth: true + + Keys.onBackPressed: { + parent.parent.parent.currentIndex-- + parent.parent.parent.currentItem.contentItem.forceActiveFocus() + } + + Keys.onUpPressed: { + backButton.forceActiveFocus() + } + + Keys.onDownPressed: { + readRecipeButton.forceActiveFocus() + } + + Item { + id: topAreaHeaderBackground + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + height: Mycroft.Units.gridUnit * 3 + + Button { + id: backButton + anchors.left: parent.left + anchors.leftMargin: Mycroft.Units.gridUnit + anchors.verticalCenter: parent.verticalCenter + width: Mycroft.Units.gridUnit * 3 + height: Mycroft.Units.gridUnit * 3 + + background: Rectangle { + color: Kirigami.Theme.backgroundColor + radius: 10 + } + + contentItem: Kirigami.Icon { + source: "arrow-left" + width: Mycroft.Units.gridUnit * 2 + height: Mycroft.Units.gridUnit * 2 + color: Kirigami.Theme.textColor + + ColorOverlay { + anchors.fill: parent + source: parent + color: Kirigami.Theme.textColor + } + } + + onClicked: { + root.parent.parent.parent.currentIndex-- + root.parent.parent.parent.currentItem.contentItem.forceActiveFocus() + } + + onPressed: { + backButton.opacity = 0.5 + } + + onReleased: { + backButton.opacity = 1.0 + } + } + + Rectangle { + color: Kirigami.Theme.backgroundColor + anchors.left: backButton.right + anchors.leftMargin: Mycroft.Units.gridUnit + anchors.right: parent.right + anchors.rightMargin: Mycroft.Units.gridUnit + height: parent.height + radius: 10 + + Kirigami.Heading { + id: title + anchors.top: parent.top + anchors.left: parent.left + anchors.right: poweredBy.left + anchors.bottom: parent.bottom + fontSizeMode: Text.Fit + minimumPixelSize: 16 + font.pixelSize: Mycroft.Units.gridUnit * 2 + anchors.margins: Mycroft.Units.gridUnit + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignLeft + level: 1 + wrapMode: Text.WordWrap + text: sessionData.recipeTitle + color: Kirigami.Theme.textColor + } + + Kirigami.Icon { + id: poweredBy + anchors.right: parent.right + anchors.rightMargin: Mycroft.Units.gridUnit / 2 + anchors.verticalCenter: parent.verticalCenter + width: height * 2 + height: parent.height + source: HelperJS.isLight(Kirigami.Theme.backgroundColor) ? Qt.resolvedUrl("images/edamam-dark.svg") : Qt.resolvedUrl("images/edamam-light.svg") + } + } + } + + Flickable { + id: flickContainer + anchors.top: topAreaHeaderBackground.bottom + anchors.topMargin: Mycroft.Units.gridUnit + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: bottomBarArea.top + anchors.bottomMargin: Mycroft.Units.gridUnit + 10 + contentWidth: parent.width + contentHeight: ingdLay.implicitHeight + ScrollBar.vertical: ScrollBar { + active: true + } + + clip: true + + ColumnLayout { + id: ingdLay + width: parent.width + + RowLayout { + Layout.fillWidth: true + Layout.preferredHeight: Kirigami.Units.gridUnit * 10 + + Item { + Layout.preferredWidth: root.width < 500 ? Kirigami.Units.gridUnit * 5 : Kirigami.Units.gridUnit * 10 + Layout.fillHeight: true + + Image { + id: img + fillMode: Image.PreserveAspectCrop + width: root.width < 500 ? Kirigami.Units.gridUnit * 5 : Kirigami.Units.gridUnit * 10 + height: root.width < 500 ? Kirigami.Units.gridUnit * 5 : Kirigami.Units.gridUnit * 10 + source: sessionData.recipeImage + + Rectangle { + id: formSourceRect + anchors.top: parent.top + anchors.right: parent.right + anchors.left: parent.left + anchors.margins: Mycroft.Units.gridUnit / 2 + height: formSourceRow.implicitHeight + Kirigami.Units.gridUnit + color: Qt.rgba(Kirigami.Theme.backgroundColor.r, Kirigami.Theme.backgroundColor.g, Kirigami.Theme.backgroundColor.b, 0.5) + radius: Kirigami.Units.smallSpacing + + Label { + id: formSourceRow + width: parent.width + height: parent.height + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + wrapMode: Text.WordWrap + elide: Text.ElideRight + text: qsTr("Source") + ": " + sessionData.recipeSource + color: Kirigami.Theme.textColor + } + } + } + } + + Item { + Layout.fillWidth: true + Layout.fillHeight: true + + Rectangle { + id: formCalorieRect + anchors.top: parent.top + anchors.left: parent.left + anchors.topMargin: Kirigami.Units.smallSpacing + width: formCalorieRow.implicitWidth + Kirigami.Units.gridUnit + height: formCalorieRow.implicitHeight + Kirigami.Units.gridUnit + color: Kirigami.Theme.backgroundColor + radius: Kirigami.Units.smallSpacing + + RowLayout { + id: formCalorieRow + anchors.centerIn: parent + + Label { + Layout.fillWidth: true + Layout.fillHeight: true + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + wrapMode: Text.WordWrap + elide: Text.ElideRight + text: qsTr("Calories") + ": " + color: Kirigami.Theme.textColor + } + + Label { + Layout.fillWidth: true + Layout.fillHeight: true + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + wrapMode: Text.WordWrap + elide: Text.ElideRight + text: Math.round(sessionData.recipeCalories) + color: Kirigami.Theme.textColor + } + } + } + + Rectangle { + id: formDietTypeRect + anchors.top: formCalorieRect.bottom + anchors.topMargin: Kirigami.Units.smallSpacing + width: formDietTypeTagsRow.implicitWidth + Kirigami.Units.gridUnit + height: formDietTypeTagsRow.implicitHeight + Kirigami.Units.gridUnit + color: Kirigami.Theme.backgroundColor + radius: Kirigami.Units.smallSpacing + + RowLayout { + id: formDietTypeTagsRow + anchors.centerIn: parent + + Label { + Layout.fillWidth: true + Layout.fillHeight: true + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + wrapMode: Text.WordWrap + elide: Text.ElideRight + text: qsTr("Diet Type") + ": " + color: Kirigami.Theme.textColor + } + + ColumnLayout { + id: formDietTypeCol + + Repeater { + model: sessionData.recipeDietType.dietTags + delegate: Label { + text: modelData + //Layout.fillWidth: true + wrapMode: Text.WordWrap + elide: Text.ElideRight + color: Kirigami.Theme.textColor + } + } + } + } + } + + Rectangle { + id: formHealthTypeRect + anchors.top: formDietTypeRect.bottom + anchors.topMargin: Kirigami.Units.smallSpacing + width: formHealthTagsRow.implicitWidth + Kirigami.Units.gridUnit + height: formHealthTagsRow.implicitHeight + Kirigami.Units.gridUnit + color: Kirigami.Theme.backgroundColor + radius: Kirigami.Units.smallSpacing + + RowLayout { + id: formHealthTagsRow + anchors.centerIn: parent + + Label { + Layout.fillWidth: true + Layout.fillHeight: true + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + wrapMode: Text.WordWrap + elide: Text.ElideRight + text: qsTr("Health Tags") + ": " + color: Kirigami.Theme.textColor + } + + ColumnLayout { + id: formHealthTagsCol + + Repeater { + property var limitedTags: sessionData.recipeHealthTag.slice(0, 3) + model: limitedTags + delegate: Label { + text: modelData + wrapMode: Text.WordWrap + elide: Text.ElideRight + color: Kirigami.Theme.textColor + } + } + } + } + } + } + } + + Rectangle { + Layout.fillWidth: true + Layout.preferredHeight: Mycroft.Units.gridUnit * 3 + radius: 10 + color: Kirigami.Theme.backgroundColor + + Rectangle { + anchors.left: parent.left + anchors.top: parent.top + anchors.bottom: parent.bottom + width: Mycroft.Units.gridUnit / 2 + radius: 10 + color: Kirigami.Theme.highlightColor + } + + Item { + anchors.left: parent.left + anchors.leftMargin: Mycroft.Units.gridUnit + anchors.right: readButtonItems.left + height: parent.height + + Kirigami.Heading { + id: ingredientsLabel + level: 1 + width: parent.width + height: parent.height + elide: Text.ElideRight + visible: tabbar.currentIndex == 0 + enabled: tabbar.currentIndex == 0 + wrapMode: Text.WordWrap + color: Kirigami.Theme.textColor + text: qsTr("Recipe Ingredients") + } + + Kirigami.Heading { + id: instructionsLabel + level: 1 + width: parent.width + height: parent.height + elide: Text.ElideRight + visible: tabbar.currentIndex == 1 + enabled: tabbar.currentIndex == 1 + wrapMode: Text.WordWrap + color: Kirigami.Theme.textColor + text: qsTr("Recipe Instructions") + } + } + + Item { + id: readButtonItems + anchors.right: parent.right + anchors.rightMargin: Mycroft.Units.gridUnit / 2 + width: Mycroft.Units.gridUnit * 20 + height: parent.height + + Button { + id: readRecipeButton + anchors.fill: parent + anchors.margins: Mycroft.Units.gridUnit / 2 + KeyNavigation.down: ingredientsTabButton + KeyNavigation.up: backButton + + background: Rectangle { + color: Kirigami.Theme.highlightColor + radius: 10 + } + contentItem: Item { + RowLayout { + anchors.centerIn: parent + + Kirigami.Icon { + id: readRecipeIcon + Layout.alignment: Qt.AlignLeft + Layout.fillHeight: true + Layout.preferredWidth: Mycroft.Units.gridUnit * 2 + source: "speaker" + color: Kirigami.Theme.textColor + + ColorOverlay { + anchors.fill: parent + source: parent + color: Kirigami.Theme.textColor + } + } + + Label { + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + text: instructionsLabel.visible ? qsTr("Read Instructions") : qsTr("Read Ingredients") + color: Kirigami.Theme.textColor + } + } + } + + onClicked: { + if (ingredientsLabel.visible) { + triggerGuiEvent("foodwizard.readrecipe.ingredients", {}) + } + if (instructionsLabel.visible) { + triggerGuiEvent("foodwizard.readrecipe.instructions", {}) + } + } + + onPressed: { + readRecipeButton.opacity = 0.5 + } + + onReleased: { + readRecipeButton.opacity = 1.0 + } + } + } + } + + Repeater { + id: ingredientsOrInstructionsList + model: tabbar.currentIndex == 0 ? sessionData.recipeIngredients : sessionData.recipeInstructions + + delegate: Kirigami.AbstractListItem { + Layout.fillWidth: true + Layout.preferredHeight: Kirigami.Units.gridUnit * 3 + + background: Rectangle { + color: Kirigami.Theme.backgroundColor + radius: 10 + } + + RowLayout { + id: ingdRow + anchors.left: parent.left + anchors.right: parent.right + anchors.leftMargin: Kirigami.Units.smallSpacing + anchors.rightMargin: Kirigami.Units.smallSpacing + spacing: Kirigami.Units.smallSpacing + + Image { + id: ingredientImage + Layout.preferredWidth: Kirigami.Units.gridUnit * 2 + Layout.preferredHeight: Kirigami.Units.gridUnit * 2 + Layout.topMargin: Kirigami.Units.smallSpacing + Layout.bottomMargin: Kirigami.Units.smallSpacing + fillMode: Image.PreserveAspectFit + visible: tabbar.currentIndex == 0 ? 1 : 0 + enabled: tabbar.currentIndex == 0 ? 1 : 0 + source: model.image + } + + Label { + id: ingredientName + Layout.fillWidth: true + Layout.fillHeight: true + color: Kirigami.Theme.textColor + wrapMode: Text.WordWrap + elide: Text.ElideRight + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + text: tabbar.currentIndex == 0 ? model.name : (index + 1) + ". " + model.step + } + } + } + } + } + } + + GridLayout { + id: bottomBarArea + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.right: parent.right + height: Mycroft.Units.gridUnit * 3 + columns: root.horizontalMode ? 2 : 1 + + TabBar { + id: tabbar + Layout.fillWidth: true + Layout.preferredHeight: Kirigami.Units.gridUnit * 3 + currentIndex: 0 + spacing: Kirigami.Units.smallSpacing + + background: Rectangle { + color: "transparent" + } + + TabButton { + id: ingredientsTabButton + onClicked: tabbar.currentIndex = 0 + enabled: true + visible: true + height: Kirigami.Units.gridUnit * 1.5 + KeyNavigation.up: readRecipeButton + KeyNavigation.right: instructionsTabButton + KeyNavigation.down: backButton + + background: Rectangle { + color: ingredientsLabel.visible ? Kirigami.Theme.highlightColor : Kirigami.Theme.backgroundColor + radius: 10 + } + + contentItem: Item { + Label { + anchors.centerIn: parent + text: qsTr("Ingredients") + color: Kirigami.Theme.textColor + } + } + } + + TabButton { + id: instructionsTabButton + onClicked: tabbar.currentIndex = 1 + enabled: sessionData.hasInstructions + visible: sessionData.hasInstructions + height: Kirigami.Units.gridUnit * 1.5 + KeyNavigation.up: readRecipeButton + KeyNavigation.left: ingredientsTabButton + KeyNavigation.down: backButton + + background: Rectangle { + color: instructionsLabel.visible ? Kirigami.Theme.highlightColor : Kirigami.Theme.backgroundColor + radius: 10 + } + + contentItem: Item { + Label { + anchors.centerIn: parent + text: qsTr("Instructions") + color: Kirigami.Theme.textColor + } + } + } + } + } +} \ No newline at end of file diff --git a/ui5/+mediacenter/SearchRecipe.qml b/ui5/+mediacenter/SearchRecipe.qml new file mode 100755 index 0000000..2361450 --- /dev/null +++ b/ui5/+mediacenter/SearchRecipe.qml @@ -0,0 +1,166 @@ +/* + * Copyright 2018 by Aditya Mehra + * Copyright 2018 Marco Martin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import QtQuick.Layouts 1.4 +import QtQuick 2.8 +import QtQuick.Controls 2.2 +import org.kde.kirigami 2.11 as Kirigami +import Mycroft 1.0 as Mycroft +import QtGraphicalEffects 1.0 + +import "code/helper.js" as HelperJS + +Mycroft.Delegate { + id: root + skillBackgroundSource: "https://source.unsplash.com/1920x1080/?+food" + property bool compactMode: parent.height >= 550 ? 0 : 1 + fillWidth: true + + background: Item { + anchors.fill: parent + z: -1 + + Kirigami.Icon { + anchors.bottom: parent.bottom + anchors.bottomMargin: 16 + anchors.right: parent.right + width: 60 + height: 150 + opacity: 0.85 + source: HelperJS.isLight(Kirigami.Theme.backgroundColor) ? Qt.resolvedUrl("images/edamam-dark-vertical.svg") : Qt.resolvedUrl("images/edamam-light-vertical.svg") + } + } + + Component.onCompleted: { + uiGridView.forceActiveFocus() + } + + Keys.onBackPressed: { + parent.parent.parent.currentIndex-- + parent.parent.parent.currentItem.contentItem.forceActiveFocus() + } + + GridView { + id: uiGridView + anchors.fill: parent + cacheBuffer: width + property int columns: { + var width = parent.width + if (width >= 1920) { + return 4 + } else if (width >= 1366) { + return 3 + } else if (width >= 1024) { + return 2 + } else { + return 1 + } + } + cellWidth: parent.width / columns + cellHeight: Kirigami.Units.gridUnit * 12 + model: sessionData.recipeBlob.hits + keyNavigationEnabled: true + highlightFollowsCurrentItem: true + ScrollBar.vertical: ScrollBar {} + + delegate: Item { + id: cardRoot + width: uiGridView.cellWidth + height: uiGridView.cellHeight + + ItemDelegate { + id: card + width: uiGridView.cellHeight + Kirigami.Units.gridUnit + height: uiGridView.cellHeight - Kirigami.Units.gridUnit + anchors.centerIn: parent + + background: Rectangle { + id: cardBackground + color: Kirigami.Theme.backgroundColor + radius: Kirigami.Units.largeSpacing / 2 + border.color: Qt.rgba(Kirigami.Theme.backgroundColor.r, Kirigami.Theme.backgroundColor.g, Kirigami.Theme.backgroundColor.b, 0.5) + border.width: 1 + layer.enabled: true + layer.effect: DropShadow { + horizontalOffset: 0 + verticalOffset: 0 + radius: 10 + samples: 16 + color: Qt.rgba(0, 0, 0, 0.5) + } + } + + ColumnLayout { + anchors.fill: parent + + Banner { + id: bannerImage + title: modelData.recipe.label + source: modelData.recipe.image + titleWrapMode: Text.WordWrap + Layout.fillWidth: true + Layout.fillHeight: true + radius: cardBackground.radius + } + + Label { + wrapMode: Text.WordWrap + Layout.fillWidth: true + Layout.preferredHeight: Mycroft.Units.gridUnit * 2 + Layout.leftMargin: Mycroft.Units.gridUnit / 2 + Layout.rightMargin: Mycroft.Units.gridUnit / 2 + Layout.bottomMargin: Mycroft.Units.gridUnit / 2 + Layout.topMargin: -Mycroft.Units.gridUnit / 2 + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + text: modelData.recipe.source + font.pixelSize: parent.width * 0.07 + color: Kirigami.Theme.textColor + } + } + + onClicked: { + var RecipeUrl = modelData.recipe.url; + Mycroft.SoundEffects.playClickedSound(Qt.resolvedUrl("../sound/clicked.wav")) + triggerGuiEvent("foodwizard.showrecipe", {"recipe": RecipeUrl}); + } + + Keys.onReturnPressed: { + clicked() + } + + Rectangle { + anchors.fill: parent + visible: cardRoot.activeFocus ? 1 : 0 + color: Qt.rgba(0, 0, 3, 0.2) + } + } + + Keys.onReturnPressed: { + card.clicked() + } + } + } + + Kirigami.Heading { + text: "No recipes found" + parent: root + anchors.centerIn: parent + visible: uiGridView.count == 0 + } +} diff --git a/ui5/Banner.qml b/ui5/Banner.qml new file mode 100644 index 0000000..09acb68 --- /dev/null +++ b/ui5/Banner.qml @@ -0,0 +1,74 @@ +/* + * Copyright 2018 by Aditya Mehra + */ + +import QtQuick.Layouts 1.4 +import QtQuick 2.12 +import QtQuick.Controls 2.12 +import org.kde.kirigami 2.11 as Kirigami +import Mycroft 1.0 as Mycroft +import QtGraphicalEffects 1.0 + +import "code/helper.js" as HelperJS + +Item { + id: bannerRoot + property alias title: bannerTitle.text + property alias source: bannerImage.source + property alias titleWrapMode: bannerTitle.wrapMode + property alias titleLevel: bannerTitle.level + property alias radius: imgRoot.radius + + Rectangle { + id: imgRoot + color: "transparent" + clip: true + anchors.fill: parent + anchors.topMargin: 1 + anchors.leftMargin: 1 + anchors.rightMargin: 1 + anchors.bottomMargin: 0 + radius: bannerRoot.radius + + layer.enabled: true + layer.effect: OpacityMask { + maskSource: Rectangle { + x: imgRoot.x; y: imgRoot.y + width: imgRoot.width + height: imgRoot.height + radius: imgRoot.radius + } + } + + Image { + id: bannerImage + width: parent.width + height: parent.height + y: -12 + opacity: 1 + fillMode: Image.PreserveAspectCrop + + Rectangle { + id: bannerOverlay + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + height: parent.height * 0.3 + color: Kirigami.Theme.backgroundColor + opacity: 0.8 + + Kirigami.Heading { + id: bannerTitle + anchors.fill: parent + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + wrapMode: Text.WordWrap + elide: Text.ElideRight + level: 2 + maximumLineCount: 2 + color: Kirigami.Theme.textColor + } + } + } + } +} \ No newline at end of file diff --git a/ui5/FoodWizardHome.qml b/ui5/FoodWizardHome.qml new file mode 100644 index 0000000..2ab8822 --- /dev/null +++ b/ui5/FoodWizardHome.qml @@ -0,0 +1,216 @@ +/* + * Copyright 2018 by Aditya Mehra + * Copyright 2018 Marco Martin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import QtQuick.Layouts 1.4 +import QtQuick 2.8 +import QtQuick.Controls 2.2 +import org.kde.kirigami 2.10 as Kirigami +import Mycroft 1.0 as Mycroft +import QtGraphicalEffects 1.0 +import "code/helper.js" as HelperJS + +Mycroft.Delegate { + id: root + skillBackgroundSource: "https://source.unsplash.com/1920x1080/?+food" + property bool compactMode: parent.height >= 550 ? 0 : 1 + property bool horizontalMode: width > height ? 1 : 0 + fillWidth: true + + Kirigami.Icon { + anchors.bottom: parent.bottom + anchors.horizontalCenter: parent.horizontalCenter + width: 150 + height: 60 + opacity: 0.7 + source: HelperJS.isLight(Kirigami.Theme.backgroundColor) ? Qt.resolvedUrl("images/edamam-dark.svg") : Qt.resolvedUrl("images/edamam-light.svg") + } + + Component.onCompleted: { + txtFld.forceActiveFocus() + } + + Item { + anchors.fill: parent + + ColumnLayout { + width: parent.width + height: parent.height / 2 + anchors.verticalCenter: compactMode ? undefined : parent.verticalCenter + anchors.top: compactMode ? parent.top : undefined + spacing: Kirigami.Units.largeSpacing + + Rectangle { + id: heads + Layout.fillWidth: true + Layout.fillHeight: true + Layout.maximumHeight: Mycroft.Units.gridUnit * 6 + Layout.minimumHeight: Mycroft.Units.gridUnit * 4 + radius: 10 + color: Qt.rgba(Kirigami.Theme.backgroundColor.r, Kirigami.Theme.backgroundColor.g, Kirigami.Theme.backgroundColor.b, 0.9) + + Image { + id: headsImage + anchors.left: parent.left + anchors.leftMargin: Mycroft.Units.gridUnit / 2 + anchors.verticalCenter: parent.verticalCenter + width: Mycroft.Units.gridUnit * 2 + height: Mycroft.Units.gridUnit * 2 + source: Qt.resolvedUrl("images/foodwizz.png") + } + + Label { + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + text: "Find Something To Cook With Custom Ingredients" + anchors.left: headsImage.right + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.right: closeBtn.left + anchors.margins: Mycroft.Units.gridUnit / 2 + wrapMode: Text.WordWrap + fontSizeMode: Text.Fit + font.pixelSize: heads.height * 0.25 + minimumPixelSize: 10 + color: Kirigami.Theme.textColor + } + + Button { + id: closeBtn + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.right: parent.right + anchors.margins: 4 + width: height + KeyNavigation.up: answerButton + KeyNavigation.down: txtFld + + background: Rectangle { + color: "transparent" + border.color: closeBtn.activeFocus ? Kirigami.Theme.linkColor : "transparent" + border.width: 2 + radius: 3 + } + + contentItem: Item { + Kirigami.Icon { + anchors.centerIn: parent + width: parent.width * 0.9 + height: parent.height * 0.9 + source: "window-close" + color: Kirigami.Theme.textColor + + ColorOverlay { + anchors.fill: parent + source: parent + color: closeBtn.activeFocus ? Kirigami.Theme.linkColor : Kirigami.Theme.textColor + } + } + } + + Keys.onReturnPressed: { + Mycroft.SoundEffects.playClickedSound(Qt.resolvedUrl("sound/clicked.wav")) + triggerGuiEvent("foodwizard.close", {}) + } + + onClicked: { + Mycroft.SoundEffects.playClickedSound(Qt.resolvedUrl("sound/clicked.wav")) + triggerGuiEvent("foodwizard.close", {}) + } + } + } + + Rectangle { + id: txtFld + anchors.top: sep.bottom + Layout.fillWidth: true + Layout.fillHeight: true + Layout.maximumHeight: Mycroft.Units.gridUnit * 8 + Layout.minimumHeight: Mycroft.Units.gridUnit * 5 + color: "transparent" + border.width: 2 + radius: Kirigami.Units.smallSpacing + border.color: txtFld.activeFocus ? Kirigami.Theme.linkColor : "transparent" + KeyNavigation.down: answerButton + KeyNavigation.up: closeBtn + focus: true + + Keys.onReturnPressed: { + txtFldInternal.forceActiveFocus() + } + + TextField { + id: txtFldInternal + anchors.fill: parent + anchors.margins: Kirigami.Units.largeSpacing + KeyNavigation.down: answerButton + font.pixelSize: txtFld.height * 0.25 + placeholderText: "Add a list of ingredients e.g., orange, cheese, chicken, lime" + + onAccepted: { + Mycroft.SoundEffects.playClickedSound(Qt.resolvedUrl("sound/clicked.wav")) + triggerGuiEvent("foodwizard.searchrecipe", {"query": txtFldInternal.text}) + } + Keys.onReturnPressed: { + Mycroft.SoundEffects.playClickedSound(Qt.resolvedUrl("sound/clicked.wav")) + triggerGuiEvent("foodwizard.searchrecipe", {"query": txtFldInternal.text}) + } + } + } + + Button { + id: answerButton + Layout.fillWidth: true + Layout.fillHeight: true + Layout.maximumHeight: Mycroft.Units.gridUnit * 6 + Layout.minimumHeight: Mycroft.Units.gridUnit * 4 + Layout.margins: Kirigami.Units.gridUnit + KeyNavigation.up: txtFld + + background: Rectangle { + color: answerButton.activeFocus ? "#4169E1" : "#4124AA" + radius: Kirigami.Units.gridUnit + } + + contentItem: Item { + Kirigami.Heading { + anchors.centerIn: parent + text: qsTr("Find Recipes") + level: compactMode ? 3 : 1 + } + } + + onClicked: { + Mycroft.SoundEffects.playClickedSound(Qt.resolvedUrl("sound/clicked.wav")) + triggerGuiEvent("foodwizard.searchrecipe", {"query": txtFldInternal.text}) + } + + onPressed: { + answerButton.opacity = 0.5 + } + + onReleased: { + answerButton.opacity = 1 + } + + Keys.onReturnPressed: { + clicked() + } + } + } + } +} diff --git a/ui5/RecipeDetail.qml b/ui5/RecipeDetail.qml new file mode 100755 index 0000000..944b3aa --- /dev/null +++ b/ui5/RecipeDetail.qml @@ -0,0 +1,532 @@ +/* + * Copyright 2018 by Aditya Mehra + * Copyright 2018 Marco Martin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import QtQuick 2.12 +import QtQuick.Layouts 1.4 +import QtQuick.Controls 2.12 +import org.kde.kirigami 2.11 as Kirigami +import QtGraphicalEffects 1.0 +import Mycroft 1.0 as Mycroft +import "code/helper.js" as HelperJS + +Mycroft.Delegate { + id: root + skillBackgroundSource: img.source + property bool horizontalMode: width > height ? 1 : 0 + fillWidth: true + + Keys.onBackPressed: { + parent.parent.parent.currentIndex-- + parent.parent.parent.currentItem.contentItem.forceActiveFocus() + } + + Item { + id: topAreaHeaderBackground + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + height: Mycroft.Units.gridUnit * 3 + + Button { + id: backButton + anchors.left: parent.left + anchors.leftMargin: Mycroft.Units.gridUnit + anchors.verticalCenter: parent.verticalCenter + width: Mycroft.Units.gridUnit * 3 + height: Mycroft.Units.gridUnit * 3 + + background: Rectangle { + color: Kirigami.Theme.backgroundColor + radius: 10 + } + + contentItem: Kirigami.Icon { + source: "arrow-left" + width: Mycroft.Units.gridUnit * 2 + height: Mycroft.Units.gridUnit * 2 + color: Kirigami.Theme.textColor + + ColorOverlay { + anchors.fill: parent + source: parent + color: Kirigami.Theme.textColor + } + } + + onClicked: { + root.parent.parent.parent.currentIndex-- + root.parent.parent.parent.currentItem.contentItem.forceActiveFocus() + } + + onPressed: { + backButton.opacity = 0.5 + } + + onReleased: { + backButton.opacity = 1.0 + } + } + + Rectangle { + color: Kirigami.Theme.backgroundColor + anchors.left: backButton.right + anchors.leftMargin: Mycroft.Units.gridUnit + anchors.right: parent.right + anchors.rightMargin: Mycroft.Units.gridUnit + height: parent.height + radius: 10 + + Kirigami.Heading { + id: title + anchors.top: parent.top + anchors.left: parent.left + anchors.right: poweredBy.left + anchors.bottom: parent.bottom + fontSizeMode: Text.Fit + minimumPixelSize: 16 + font.pixelSize: Mycroft.Units.gridUnit * 2 + anchors.margins: Mycroft.Units.gridUnit + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignLeft + level: 1 + wrapMode: Text.WordWrap + text: sessionData.recipeTitle + color: Kirigami.Theme.textColor + } + + Kirigami.Icon { + id: poweredBy + anchors.right: parent.right + anchors.rightMargin: Mycroft.Units.gridUnit / 2 + anchors.verticalCenter: parent.verticalCenter + width: height * 2 + height: parent.height + source: HelperJS.isLight(Kirigami.Theme.backgroundColor) ? Qt.resolvedUrl("images/edamam-dark.svg") : Qt.resolvedUrl("images/edamam-light.svg") + } + } + } + + Flickable { + id: flickContainer + anchors.top: topAreaHeaderBackground.bottom + anchors.topMargin: Mycroft.Units.gridUnit + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: bottomBarArea.top + anchors.bottomMargin: Mycroft.Units.gridUnit + 10 + contentWidth: parent.width + contentHeight: ingdLay.implicitHeight + ScrollBar.vertical: ScrollBar { + active: true + } + + clip: true + + ColumnLayout { + id: ingdLay + width: parent.width + + RowLayout { + Layout.fillWidth: true + Layout.preferredHeight: Kirigami.Units.gridUnit * 10 + + Item { + Layout.preferredWidth: root.width < 500 ? Kirigami.Units.gridUnit * 5 : Kirigami.Units.gridUnit * 10 + Layout.fillHeight: true + + Image { + id: img + fillMode: Image.PreserveAspectCrop + width: root.width < 500 ? Kirigami.Units.gridUnit * 5 : Kirigami.Units.gridUnit * 10 + height: root.width < 500 ? Kirigami.Units.gridUnit * 5 : Kirigami.Units.gridUnit * 10 + source: sessionData.recipeImage + + Rectangle { + id: formSourceRect + anchors.top: parent.top + anchors.right: parent.right + anchors.left: parent.left + anchors.margins: Mycroft.Units.gridUnit / 2 + height: formSourceRow.implicitHeight + Kirigami.Units.gridUnit + color: Qt.rgba(Kirigami.Theme.backgroundColor.r, Kirigami.Theme.backgroundColor.g, Kirigami.Theme.backgroundColor.b, 0.5) + radius: Kirigami.Units.smallSpacing + + Label { + id: formSourceRow + width: parent.width + height: parent.height + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + wrapMode: Text.WordWrap + elide: Text.ElideRight + text: qsTr("Source") + ": " + sessionData.recipeSource + color: Kirigami.Theme.textColor + } + } + } + } + + Item { + Layout.fillWidth: true + Layout.fillHeight: true + + Rectangle { + id: formCalorieRect + anchors.top: parent.top + anchors.left: parent.left + anchors.topMargin: Kirigami.Units.smallSpacing + width: formCalorieRow.implicitWidth + Kirigami.Units.gridUnit + height: formCalorieRow.implicitHeight + Kirigami.Units.gridUnit + color: Kirigami.Theme.backgroundColor + radius: Kirigami.Units.smallSpacing + + RowLayout { + id: formCalorieRow + anchors.centerIn: parent + + Label { + Layout.fillWidth: true + Layout.fillHeight: true + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + wrapMode: Text.WordWrap + elide: Text.ElideRight + text: qsTr("Calories") + ": " + color: Kirigami.Theme.textColor + } + + Label { + Layout.fillWidth: true + Layout.fillHeight: true + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + wrapMode: Text.WordWrap + elide: Text.ElideRight + text: Math.round(sessionData.recipeCalories) + color: Kirigami.Theme.textColor + } + } + } + + Rectangle { + id: formDietTypeRect + anchors.top: formCalorieRect.bottom + anchors.topMargin: Kirigami.Units.smallSpacing + width: formDietTypeTagsRow.implicitWidth + Kirigami.Units.gridUnit + height: formDietTypeTagsRow.implicitHeight + Kirigami.Units.gridUnit + color: Kirigami.Theme.backgroundColor + radius: Kirigami.Units.smallSpacing + + RowLayout { + id: formDietTypeTagsRow + anchors.centerIn: parent + + Label { + Layout.fillWidth: true + Layout.fillHeight: true + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + wrapMode: Text.WordWrap + elide: Text.ElideRight + text: qsTr("Diet Type") + ": " + color: Kirigami.Theme.textColor + } + + ColumnLayout { + id: formDietTypeCol + + Repeater { + model: sessionData.recipeDietType.dietTags + delegate: Label { + text: modelData + //Layout.fillWidth: true + wrapMode: Text.WordWrap + elide: Text.ElideRight + color: Kirigami.Theme.textColor + } + } + } + } + } + + Rectangle { + id: formHealthTypeRect + anchors.top: formDietTypeRect.bottom + anchors.topMargin: Kirigami.Units.smallSpacing + width: formHealthTagsRow.implicitWidth + Kirigami.Units.gridUnit + height: formHealthTagsRow.implicitHeight + Kirigami.Units.gridUnit + color: Kirigami.Theme.backgroundColor + radius: Kirigami.Units.smallSpacing + + RowLayout { + id: formHealthTagsRow + anchors.centerIn: parent + + Label { + Layout.fillWidth: true + Layout.fillHeight: true + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + wrapMode: Text.WordWrap + elide: Text.ElideRight + text: qsTr("Health Tags") + ": " + color: Kirigami.Theme.textColor + } + + ColumnLayout { + id: formHealthTagsCol + + Repeater { + property var limitedTags: sessionData.recipeHealthTag.slice(0, 3) + model: limitedTags + delegate: Label { + text: modelData + wrapMode: Text.WordWrap + elide: Text.ElideRight + color: Kirigami.Theme.textColor + } + } + } + } + } + } + } + + Rectangle { + Layout.fillWidth: true + Layout.preferredHeight: Mycroft.Units.gridUnit * 3 + radius: 10 + color: Kirigami.Theme.backgroundColor + + Rectangle { + anchors.left: parent.left + anchors.top: parent.top + anchors.bottom: parent.bottom + width: Mycroft.Units.gridUnit / 2 + radius: 10 + color: Kirigami.Theme.highlightColor + } + + Item { + anchors.left: parent.left + anchors.leftMargin: Mycroft.Units.gridUnit + anchors.right: readButtonItems.left + height: parent.height + + Kirigami.Heading { + id: ingredientsLabel + level: 1 + width: parent.width + height: parent.height + elide: Text.ElideRight + visible: tabbar.currentIndex == 0 + enabled: tabbar.currentIndex == 0 + wrapMode: Text.WordWrap + color: Kirigami.Theme.textColor + text: qsTr("Recipe Ingredients") + } + + Kirigami.Heading { + id: instructionsLabel + level: 1 + width: parent.width + height: parent.height + elide: Text.ElideRight + visible: tabbar.currentIndex == 1 + enabled: tabbar.currentIndex == 1 + wrapMode: Text.WordWrap + color: Kirigami.Theme.textColor + text: qsTr("Recipe Instructions") + } + } + + Item { + id: readButtonItems + anchors.right: parent.right + anchors.rightMargin: Mycroft.Units.gridUnit / 2 + width: Mycroft.Units.gridUnit * 20 + height: parent.height + + Button { + id: readRecipeButton + anchors.fill: parent + anchors.margins: Mycroft.Units.gridUnit / 2 + + background: Rectangle { + color: Kirigami.Theme.highlightColor + radius: 10 + } + contentItem: Item { + RowLayout { + anchors.centerIn: parent + + Kirigami.Icon { + id: readRecipeIcon + Layout.alignment: Qt.AlignLeft + Layout.fillHeight: true + Layout.preferredWidth: Mycroft.Units.gridUnit * 2 + source: "speaker" + color: Kirigami.Theme.textColor + + ColorOverlay { + anchors.fill: parent + source: parent + color: Kirigami.Theme.textColor + } + } + + Label { + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + text: instructionsLabel.visible ? qsTr("Read Instructions") : qsTr("Read Ingredients") + color: Kirigami.Theme.textColor + } + } + } + + onClicked: { + if (ingredientsLabel.visible) { + triggerGuiEvent("foodwizard.readrecipe.ingredients", {}) + } + if (instructionsLabel.visible) { + triggerGuiEvent("foodwizard.readrecipe.instructions", {}) + } + } + + onPressed: { + readRecipeButton.opacity = 0.5 + } + + onReleased: { + readRecipeButton.opacity = 1.0 + } + } + } + } + + Repeater { + id: ingredientsOrInstructionsList + model: tabbar.currentIndex == 0 ? sessionData.recipeIngredients : sessionData.recipeInstructions + + delegate: Kirigami.AbstractListItem { + Layout.fillWidth: true + Layout.preferredHeight: Kirigami.Units.gridUnit * 3 + + background: Rectangle { + color: Kirigami.Theme.backgroundColor + radius: 10 + } + + RowLayout { + id: ingdRow + anchors.left: parent.left + anchors.right: parent.right + anchors.leftMargin: Kirigami.Units.smallSpacing + anchors.rightMargin: Kirigami.Units.smallSpacing + spacing: Kirigami.Units.smallSpacing + + Image { + id: ingredientImage + Layout.preferredWidth: Kirigami.Units.gridUnit * 2 + Layout.preferredHeight: Kirigami.Units.gridUnit * 2 + Layout.topMargin: Kirigami.Units.smallSpacing + Layout.bottomMargin: Kirigami.Units.smallSpacing + fillMode: Image.PreserveAspectFit + visible: tabbar.currentIndex == 0 ? 1 : 0 + enabled: tabbar.currentIndex == 0 ? 1 : 0 + source: model.image + } + + Label { + id: ingredientName + Layout.fillWidth: true + Layout.fillHeight: true + color: Kirigami.Theme.textColor + wrapMode: Text.WordWrap + elide: Text.ElideRight + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + text: tabbar.currentIndex == 0 ? model.name : (index + 1) + ". " + model.step + } + } + } + } + } + } + + GridLayout { + id: bottomBarArea + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.right: parent.right + height: Mycroft.Units.gridUnit * 3 + columns: root.horizontalMode ? 2 : 1 + + TabBar { + id: tabbar + Layout.fillWidth: true + Layout.preferredHeight: Kirigami.Units.gridUnit * 3 + currentIndex: 0 + spacing: Kirigami.Units.smallSpacing + + background: Rectangle { + color: "transparent" + } + + TabButton { + onClicked: tabbar.currentIndex = 0 + enabled: true + visible: true + height: Kirigami.Units.gridUnit * 1.5 + + background: Rectangle { + color: ingredientsLabel.visible ? Kirigami.Theme.highlightColor : Kirigami.Theme.backgroundColor + radius: 10 + } + + contentItem: Item { + Label { + anchors.centerIn: parent + text: qsTr("Ingredients") + color: Kirigami.Theme.textColor + } + } + } + + TabButton { + onClicked: tabbar.currentIndex = 1 + enabled: sessionData.hasInstructions + visible: sessionData.hasInstructions + height: Kirigami.Units.gridUnit * 1.5 + + background: Rectangle { + color: instructionsLabel.visible ? Kirigami.Theme.highlightColor : Kirigami.Theme.backgroundColor + radius: 10 + } + + contentItem: Item { + Label { + anchors.centerIn: parent + text: qsTr("Instructions") + color: Kirigami.Theme.textColor + } + } + } + } + } +} diff --git a/ui/RecipeDetailTopArea.qml b/ui5/RecipeDetailTopArea.qml similarity index 100% rename from ui/RecipeDetailTopArea.qml rename to ui5/RecipeDetailTopArea.qml diff --git a/ui5/SearchRecipe.qml b/ui5/SearchRecipe.qml new file mode 100755 index 0000000..cb23db2 --- /dev/null +++ b/ui5/SearchRecipe.qml @@ -0,0 +1,166 @@ +/* + * Copyright 2018 by Aditya Mehra + * Copyright 2018 Marco Martin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import QtQuick.Layouts 1.4 +import QtQuick 2.8 +import QtQuick.Controls 2.2 +import org.kde.kirigami 2.11 as Kirigami +import Mycroft 1.0 as Mycroft +import QtGraphicalEffects 1.0 + +import "code/helper.js" as HelperJS + +Mycroft.Delegate { + id: root + skillBackgroundSource: "https://source.unsplash.com/1920x1080/?+food" + property bool compactMode: parent.height >= 550 ? 0 : 1 + fillWidth: true + + background: Item { + anchors.fill: parent + z: -1 + + Kirigami.Icon { + anchors.bottom: parent.bottom + anchors.bottomMargin: 16 + anchors.right: parent.right + width: 60 + height: 150 + opacity: 0.85 + source: HelperJS.isLight(Kirigami.Theme.backgroundColor) ? Qt.resolvedUrl("images/edamam-dark-vertical.svg") : Qt.resolvedUrl("images/edamam-light-vertical.svg") + } + } + + Component.onCompleted: { + uiGridView.forceActiveFocus() + } + + Keys.onBackPressed: { + parent.parent.parent.currentIndex-- + parent.parent.parent.currentItem.contentItem.forceActiveFocus() + } + + GridView { + id: uiGridView + anchors.fill: parent + cacheBuffer: width + property int columns: { + var width = parent.width + if (width >= 1920) { + return 4 + } else if (width >= 1366) { + return 3 + } else if (width >= 1024) { + return 2 + } else { + return 1 + } + } + cellWidth: parent.width / columns + cellHeight: Kirigami.Units.gridUnit * 12 + model: sessionData.recipeBlob.hits + keyNavigationEnabled: true + highlightFollowsCurrentItem: true + ScrollBar.vertical: ScrollBar {} + + delegate: Item { + id: cardRoot + width: uiGridView.cellWidth + height: uiGridView.cellHeight + + ItemDelegate { + id: card + width: uiGridView.cellHeight + Kirigami.Units.gridUnit + height: uiGridView.cellHeight - Kirigami.Units.gridUnit + anchors.centerIn: parent + + background: Rectangle { + id: cardBackground + color: Kirigami.Theme.backgroundColor + radius: Kirigami.Units.largeSpacing / 2 + border.color: Qt.rgba(Kirigami.Theme.backgroundColor.r, Kirigami.Theme.backgroundColor.g, Kirigami.Theme.backgroundColor.b, 0.5) + border.width: 1 + layer.enabled: true + layer.effect: DropShadow { + horizontalOffset: 0 + verticalOffset: 0 + radius: 10 + samples: 16 + color: Qt.rgba(0, 0, 0, 0.5) + } + } + + ColumnLayout { + anchors.fill: parent + + Banner { + id: bannerImage + title: modelData.recipe.label + source: modelData.recipe.image + titleWrapMode: Text.WordWrap + Layout.fillWidth: true + Layout.fillHeight: true + radius: cardBackground.radius + } + + Label { + wrapMode: Text.WordWrap + Layout.fillWidth: true + Layout.preferredHeight: Mycroft.Units.gridUnit * 2 + Layout.leftMargin: Mycroft.Units.gridUnit / 2 + Layout.rightMargin: Mycroft.Units.gridUnit / 2 + Layout.bottomMargin: Mycroft.Units.gridUnit / 2 + Layout.topMargin: -Mycroft.Units.gridUnit / 2 + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + text: modelData.recipe.source + font.pixelSize: parent.width * 0.07 + color: Kirigami.Theme.textColor + } + } + + onClicked: { + var RecipeUrl = modelData.recipe.url; + Mycroft.SoundEffects.playClickedSound(Qt.resolvedUrl("sound/clicked.wav")) + triggerGuiEvent("foodwizard.showrecipe", {"recipe": RecipeUrl}); + } + + Keys.onReturnPressed: { + clicked() + } + + Rectangle { + anchors.fill: parent + visible: cardRoot.activeFocus ? 1 : 0 + color: Qt.rgba(0, 0, 3, 0.2) + } + } + + Keys.onReturnPressed: { + card.clicked() + } + } + } + + Kirigami.Heading { + text: "No recipes found" + parent: root + anchors.centerIn: parent + visible: uiGridView.count == 0 + } +} diff --git a/ui5/code/helper.js b/ui5/code/helper.js new file mode 100644 index 0000000..45b7ed3 --- /dev/null +++ b/ui5/code/helper.js @@ -0,0 +1,27 @@ +function isLight(color) { + // Convert color to string + color = color.toString(); + + var color_r = color.slice(1,3); + var color_g = color.slice(3,5); + var color_b = color.slice(5,7); + + var r = parseInt(color_r, 16); + var g = parseInt(color_g, 16); + var b = parseInt(color_b, 16); + + var hsp = Math.sqrt( + 0.299 * (r * r) + + 0.587 * (g * g) + + 0.114 * (b * b) + ); + + if (hsp>127.5) { + + return true; + } + else { + + return false; + } +} \ No newline at end of file diff --git a/ui5/images/edamam-dark-vertical.svg b/ui5/images/edamam-dark-vertical.svg new file mode 100644 index 0000000..31a4ccc --- /dev/null +++ b/ui5/images/edamam-dark-vertical.svg @@ -0,0 +1,170 @@ + + + +image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ui5/images/edamam-dark.svg b/ui5/images/edamam-dark.svg new file mode 100644 index 0000000..b15ec27 --- /dev/null +++ b/ui5/images/edamam-dark.svg @@ -0,0 +1,168 @@ + + + +image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ui5/images/edamam-light-vertical.svg b/ui5/images/edamam-light-vertical.svg new file mode 100644 index 0000000..f5a68ba --- /dev/null +++ b/ui5/images/edamam-light-vertical.svg @@ -0,0 +1,170 @@ + + + +image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ui5/images/edamam-light.svg b/ui5/images/edamam-light.svg new file mode 100644 index 0000000..449d438 --- /dev/null +++ b/ui5/images/edamam-light.svg @@ -0,0 +1,168 @@ + + + +image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ui5/images/foodwizz.png b/ui5/images/foodwizz.png new file mode 100644 index 0000000..1d02661 Binary files /dev/null and b/ui5/images/foodwizz.png differ diff --git a/ui5/qmldir b/ui5/qmldir new file mode 100644 index 0000000..ddfd4fb --- /dev/null +++ b/ui5/qmldir @@ -0,0 +1,3 @@ +FoodWizardHome 1.0 FoodWizardHome.qml +RecipeDetail 1.0 RecipeDetail.qml +SearchRecipe 1.0 SearchRecipe.qml \ No newline at end of file diff --git a/ui5/sound/clicked.wav b/ui5/sound/clicked.wav new file mode 100644 index 0000000..91b55f6 Binary files /dev/null and b/ui5/sound/clicked.wav differ