From 11d0f5a06c05f43706b0149316077797c50320a6 Mon Sep 17 00:00:00 2001 From: dorian Date: Sun, 17 Feb 2019 15:13:00 +0100 Subject: [PATCH] - put shop delegate to an extra qml file --- QcookieClicker.pro.user | 506 ++++++++++++++++---------------- qml/ShopPopup.qml | 176 +---------- qml/components/ShopDelegate.qml | 188 ++++++++++++ qml/qml.qrc | 1 + 4 files changed, 445 insertions(+), 426 deletions(-) create mode 100644 qml/components/ShopDelegate.qml diff --git a/QcookieClicker.pro.user b/QcookieClicker.pro.user index 3dab907..3a06242 100644 --- a/QcookieClicker.pro.user +++ b/QcookieClicker.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -61,258 +61,6 @@ ProjectExplorer.Project.Target.0 - - Desktop Qt 5.11.3 GCC 64bit - Desktop Qt 5.11.3 GCC 64bit - qt.qt5.5113.gcc_64_kit - 0 - 0 - 0 - - /home/dorian/build-QcookieClicker-Desktop_Qt_5_11_3_GCC_64bit-Debug - - - true - qmake - - QtProjectManager.QMakeBuildStep - true - - false - false - false - - - true - Make - - Qt4ProjectManager.MakeStep - - false - - - false - - 2 - Build - - ProjectExplorer.BuildSteps.Build - - - - true - Make - - Qt4ProjectManager.MakeStep - - true - clean - - false - - 1 - Clean - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Debug - Debug - Qt4ProjectManager.Qt4BuildConfiguration - 2 - true - - - /home/dorian/build-QcookieClicker-Desktop_Qt_5_11_3_GCC_64bit-Release - - - true - qmake - - QtProjectManager.QMakeBuildStep - false - - false - false - true - - - true - Make - - Qt4ProjectManager.MakeStep - - false - - - false - - 2 - Build - - ProjectExplorer.BuildSteps.Build - - - - true - Make - - Qt4ProjectManager.MakeStep - - true - clean - - false - - 1 - Clean - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Release - Release - Qt4ProjectManager.Qt4BuildConfiguration - 0 - true - - - /home/dorian/build-QcookieClicker-Desktop_Qt_5_11_3_GCC_64bit-Profile - - - true - qmake - - QtProjectManager.QMakeBuildStep - true - - false - true - true - - - true - Make - - Qt4ProjectManager.MakeStep - - false - - - false - - 2 - Build - - ProjectExplorer.BuildSteps.Build - - - - true - Make - - Qt4ProjectManager.MakeStep - - true - clean - - false - - 1 - Clean - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Profile - Profile - Qt4ProjectManager.Qt4BuildConfiguration - 0 - true - - 3 - - - 0 - Deploy - - ProjectExplorer.BuildSteps.Deploy - - 1 - Deploy Configuration - - ProjectExplorer.DefaultDeployConfiguration - - 1 - - - false - false - 1000 - - true - - false - false - false - false - true - 0.01 - 10 - true - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - QcookieClicker - QcookieClicker2 - Qt4ProjectManager.Qt4RunConfiguration:/home/dorian/Documents/git/qcookieclicker/QcookieClicker.pro - QcookieClicker.pro - - 3768 - false - true - true - false - false - true - - /home/dorian/build-QcookieClicker-Desktop_Qt_5_11_3_GCC_64bit-Debug - - 1 - - - - ProjectExplorer.Project.Target.1 Android for armeabi-v7a (Clang Qt 5.11.3 for Android ARMv7) Android for armeabi-v7a (Clang Qt 5.11.3 for Android ARMv7) @@ -620,6 +368,258 @@ 1 + + ProjectExplorer.Project.Target.1 + + Desktop Qt 5.11.3 GCC 64bit + Desktop Qt 5.11.3 GCC 64bit + qt.qt5.5113.gcc_64_kit + 0 + 0 + 0 + + /home/dorian/build-QcookieClicker-Desktop_Qt_5_11_3_GCC_64bit-Debug + + + true + qmake + + QtProjectManager.QMakeBuildStep + true + + false + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + true + + + /home/dorian/build-QcookieClicker-Desktop_Qt_5_11_3_GCC_64bit-Release + + + true + qmake + + QtProjectManager.QMakeBuildStep + false + + false + false + true + + + true + Make + + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + + /home/dorian/build-QcookieClicker-Desktop_Qt_5_11_3_GCC_64bit-Profile + + + true + qmake + + QtProjectManager.QMakeBuildStep + true + + false + true + true + + + true + Make + + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Profile + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + 3 + + + 0 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + Deploy Configuration + + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + QcookieClicker + QcookieClicker2 + Qt4ProjectManager.Qt4RunConfiguration:/home/dorian/Documents/git/qcookieclicker/QcookieClicker.pro + QcookieClicker.pro + + 3768 + false + true + true + false + false + true + + /home/dorian/build-QcookieClicker-Desktop_Qt_5_11_3_GCC_64bit-Debug + + 1 + + ProjectExplorer.Project.Target.2 diff --git a/qml/ShopPopup.qml b/qml/ShopPopup.qml index c3669b7..828fb4a 100644 --- a/qml/ShopPopup.qml +++ b/qml/ShopPopup.qml @@ -1,6 +1,7 @@ import QtQuick 2.9 import QtQuick.Controls 2.4 import QtGraphicalEffects 1.0 +import "./components" Popup { id: control @@ -33,181 +34,10 @@ Popup { Column { anchors.fill: parent - ItemDelegate { - id: itemDelegate - width: parent.width - height: 40 - - Item { - id: leftSectionItm - - anchors { - top: parent.top - bottom: parent.bottom - left: parent.left - right: parent.right - rightMargin: parent.width * 0.8 - margins: 5 - } - - Rectangle { - id: iconRect - - anchors { - fill: parent - } - - width: height - - color: "red" - } - - } - - Item { - id: middleSectionItm - - anchors { - top: parent.top - bottom: parent.bottom - left: parent.left - leftMargin: parent.width * 0.2 - right: parent.right - rightMargin: parent.width * 0.3 - margins: 5 - } - - Label { - id: titleLab - - anchors { - top: parent.top - left: iconRect.right - } - - font.bold: true - - text: "title" - - } - - Item { - id: costItm - - anchors { - top: titleLab.bottom - bottom: parent.bottom - left: iconRect.right - } - - Image { - id: costCookieImg - source: "qrc:/icons/cookie.png" - mipmap: true - height: parent.height - width: height - } - - Label { - id: costLa - - anchors { - left: costCookieImg.right - verticalCenter: costCookieImg.verticalCenter - } - - text: "10" - } - - } - - } - - Item { - id: rightsectionItm - - anchors { - top: parent.top - bottom: parent.bottom - left: parent.left - leftMargin: parent.width * 0.75 - right: parent.right - margins: 5 - } - - Label { - id: levelLableLa - - anchors { - top: parent.top - left: parent.left - } - - font.pixelSize: parent.height * 0.45 - - text: "Level:" - } - - Label { - id: levelTextLa - - anchors { - verticalCenter: parent.verticalCenter - verticalCenterOffset: -parent.height * 0.24 - left: levelLableLa.right - right: parent.right - } - - font.pixelSize: parent.height * 0.45 * 1/text.length * 5 > parent.height * 0.45 ? parent.height * 0.45:parent.height * 0.45 * 1/text.length * 5 - - horizontalAlignment: Text.AlignRight - verticalAlignment: Text.AlignVCenter - - text: "10" - - } - - Label { - id: useLableLa - - anchors { - bottom: parent.bottom - left: parent.left - } - - font.pixelSize: parent.height * 0.45 - - text: "Click:" - } - - Label { - id: useTextLa - - anchors { - verticalCenter: parent.verticalCenter - verticalCenterOffset: parent.height * 0.24 - left: useLableLa.right - right: parent.right - } - - font.pixelSize: parent.height * 0.45 * 1/text.length * 5 > parent.height * 0.45 ? parent.height * 0.45:parent.height * 0.45 * 1/text.length * 5 - - horizontalAlignment: Text.AlignRight - verticalAlignment: Text.AlignVCenter - - text: "10" - - } - - } - - background: Rectangle { - color: parent.pressed ? "lightgrey":"white" - border.color: "grey" - border.width: 2 - } + ShopDelegate { } + } } } diff --git a/qml/components/ShopDelegate.qml b/qml/components/ShopDelegate.qml new file mode 100644 index 0000000..4cdbf2c --- /dev/null +++ b/qml/components/ShopDelegate.qml @@ -0,0 +1,188 @@ +import QtQuick 2.9 +import QtQuick.Controls 2.4 + +ItemDelegate { + id: control + width: parent.width + height: 40 + + property string iconSource: "qrc:/icons/cookie.png" + property string costIconSource: "qrc:/icons/cookie.png" + property string title: "Title" + property string cost: "10" + property string levelLabel: "Level:" + property string level: "10" + property string useLabel: "Cps:" + property string use: "+10" + + Item { + id: leftSectionItm + + anchors { + top: parent.top + bottom: parent.bottom + left: parent.left + right: parent.right + rightMargin: parent.width * 0.8 + margins: 5 + } + + Image { + id: iconRect + + anchors { + centerIn: parent + } + + height: parent.height + width: height + + source: control.iconSource + mipmap: true + } + + } + + Item { + id: middleSectionItm + + anchors { + top: parent.top + bottom: parent.bottom + left: parent.left + leftMargin: parent.width * 0.2 + right: parent.right + rightMargin: parent.width * 0.3 + margins: 5 + } + + Label { + id: titleLab + + anchors { + top: parent.top + } + + font.bold: true + + text: control.title + + } + + Item { + id: costItm + + anchors { + top: titleLab.bottom + bottom: parent.bottom + } + + Image { + id: costCookieImg + source: control.costIconSource + mipmap: true + height: parent.height + width: height + } + + Label { + id: costLa + + anchors { + left: costCookieImg.right + verticalCenter: costCookieImg.verticalCenter + } + + text: control.cost + } + + } + + } + + Item { + id: rightsectionItm + + anchors { + top: parent.top + bottom: parent.bottom + left: parent.left + leftMargin: parent.width * 0.75 + right: parent.right + margins: 5 + } + + Label { + id: levelLableLa + + anchors { + top: parent.top + left: parent.left + } + + font.pixelSize: parent.height * 0.45 + + text: control.levelLabel + } + + Label { + id: levelTextLa + + anchors { + verticalCenter: parent.verticalCenter + verticalCenterOffset: -parent.height * 0.24 + left: levelLableLa.right + right: parent.right + } + + font.pixelSize: parent.height * 0.45 * 1/text.length * 5 > parent.height * 0.45 ? parent.height * 0.45:parent.height * 0.45 * 1/text.length * 5 + + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter + + text: control.level + + } + + Label { + id: useLableLa + + anchors { + bottom: parent.bottom + left: parent.left + } + + font.pixelSize: parent.height * 0.45 + + text: control.useLabel + } + + Label { + id: useTextLa + + anchors { + verticalCenter: parent.verticalCenter + verticalCenterOffset: parent.height * 0.24 + left: useLableLa.right + right: parent.right + } + + font.pixelSize: parent.height * 0.45 * 1/text.length * 5 > parent.height * 0.45 ? parent.height * 0.45:parent.height * 0.45 * 1/text.length * 5 + + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter + + text: control.use + + } + + } + + background: Rectangle { + color: parent.pressed ? "lightgrey":"white" + border.color: "grey" + border.width: 2 + } + +} + diff --git a/qml/qml.qrc b/qml/qml.qrc index 44fdff8..709315b 100644 --- a/qml/qml.qrc +++ b/qml/qml.qrc @@ -3,5 +3,6 @@ main.qml components/GameButton.qml ShopPopup.qml + components/ShopDelegate.qml