Commit 9500e2d5 authored by Exc404's avatar Exc404

Dynamic scaling of the game grid

parent 8c3903d8
...@@ -7,7 +7,7 @@ import "../constants/tabs.js" as TabConstants ...@@ -7,7 +7,7 @@ import "../constants/tabs.js" as TabConstants
Rectangle { Rectangle {
// PROPERTIES // PROPERTIES
property string currentTab: TabConstants.systemManagementTab property string currentTab: TabConstants.gamesTab
// FIELDS // FIELDS
id: tabs id: tabs
...@@ -53,25 +53,29 @@ Rectangle { ...@@ -53,25 +53,29 @@ Rectangle {
anchors.topMargin: 60 anchors.topMargin: 60
clip : true clip : true
GridLayout { GridLayout {
id: gamesGrid id: gamesGrid
readonly property int elementWidth: 256 + gamesGrid.rowSpacing*2 readonly property int elementWidth: 228 + 15// + gamesGrid.rowSpacing*2
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.top: parent.top anchors.top: parent.top
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
//Layout.alignment: AlignCenter
// columns: Math.max(Math.floor(parent.width / elementWidth), 1) // columns: Math.max(Math.floor(parent.width / elementWidth), 1)
// rows: Math.max(Math.ceil(children.length / columns), 1) // rows: Math.max(Math.ceil(children.length / columns), 1)
columns: Math.max(Math.floor(gamesScroller.width / elementWidth), 1) //columns: Math.max(Math.min(Math.floor(gamesScroller.width / elementWidth),6), 1)
columns: 5
rows: Math.max(Math.ceil(children.length / columns), 1) rows: Math.max(Math.ceil(children.length / columns), 1)
anchors.rightMargin: 8 anchors.rightMargin: 8
anchors.leftMargin: 8 anchors.leftMargin: 8
anchors.bottomMargin: 8 anchors.bottomMargin: 8
anchors.topMargin: 8 anchors.topMargin: 8
rowSpacing: 8 rowSpacing: 15
columnSpacing: rowSpacing columnSpacing: rowSpacing
Repeater { Repeater {
...@@ -84,8 +88,12 @@ Rectangle { ...@@ -84,8 +88,12 @@ Rectangle {
gameExec: model.exec gameExec: model.exec
gameIcon: model.icon gameIcon: model.icon
width: 256 // Layout.fillWidth: true
height: 256 // Layout.preferredWidth: 1000
//width: parent.width / 4
Layout.preferredWidth: (gamesScroller.width) / gamesGrid.columns - gamesGrid.rowSpacing
Layout.preferredHeight: Layout.preferredWidth / 2 * 3
// icon: core_app.games.icon // icon: core_app.games.icon
// exec: core_app.games.exec // exec: core_app.games.exec
} }
......
import QtQuick import QtQuick
import "../constants/scene.js" as SceneConstants import "../constants/scene.js" as SceneConstants
import "../components/" as C //import "../components/" as C
import QtQuick.Controls as C
C.Button { C.Button {
property string gameTitle: "Generic title" property string gameTitle: "Generic title"
...@@ -8,11 +11,8 @@ C.Button { ...@@ -8,11 +11,8 @@ C.Button {
property string gameExec: "" property string gameExec: ""
id: game id: game
width: 256
height: 256
implicitWidth: 256
implicitHeight: 256
text: "" text: ""
// color: "#efefef" // color: "#efefef"
//radius: 5 //radius: 5
// border.width: 1 // border.width: 1
...@@ -33,27 +33,28 @@ C.Button { ...@@ -33,27 +33,28 @@ C.Button {
anchors.top: parent.top anchors.top: parent.top
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
source: game.gameIcon source: game.gameIcon
anchors.rightMargin: 8 // anchors.rightMargin: 8
anchors.bottomMargin: 47 // anchors.bottomMargin: 47
anchors.leftMargin: 8 // anchors.leftMargin: 8
anchors.topMargin: 8 // anchors.topMargin: 8
fillMode: Image.PreserveAspectFit fillMode: Image.PreserveAspectFit
} }
Text { // Text {
id: title // id: title
y: 439 // y: 439
height: 33 // height: 33
text: game.gameTitle // color: "#e23f3f"
anchors.left: parent.left // text: game.gameTitle
anchors.right: parent.right // anchors.left: parent.left
anchors.bottom: parent.bottom // anchors.right: parent.right
font.pixelSize: 22 // anchors.bottom: parent.bottom
horizontalAlignment: Text.AlignHCenter // font.pixelSize: 22
anchors.rightMargin: 8 // horizontalAlignment: Text.AlignHCenter
anchors.leftMargin: 8 // anchors.rightMargin: 8
anchors.bottomMargin: 8 // anchors.leftMargin: 8
} // anchors.bottomMargin: 8
// }
} }
...@@ -66,6 +66,8 @@ class App(QtCore.QObject): ...@@ -66,6 +66,8 @@ class App(QtCore.QObject):
icon = (os.path.isfile(icon) and icon icon = (os.path.isfile(icon) and icon
or os.path.realpath(f"{Path(__file__).resolve().parent}../../../qml/images/game_icon.png")) or os.path.realpath(f"{Path(__file__).resolve().parent}../../../qml/images/game_icon.png"))
# Тест карточек
icon = os.path.realpath(f"{Path(__file__).resolve().parent}../../../qml/images/PUBG.png")
self.games_model.add_game(Game(name=name, icon=icon, exec=exec)) self.games_model.add_game(Game(name=name, icon=icon, exec=exec))
except FileNotFoundError: except FileNotFoundError:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment