mirror of
https://github.com/moonlight-stream/moonlight-qt
synced 2024-12-13 21:02:28 +00:00
Ensure the anchor hack stays in sync with changing margins prior to Qt 5.12
This commit is contained in:
parent
d4b0057423
commit
ce5dac07d3
2 changed files with 32 additions and 8 deletions
|
@ -9,13 +9,20 @@ GridView {
|
||||||
property AppModel appModel : createModel()
|
property AppModel appModel : createModel()
|
||||||
property bool activated
|
property bool activated
|
||||||
|
|
||||||
|
// Prevent the margin from dropping below 10. By keeping a floor on the margin value
|
||||||
|
// this prevents a binding loop caused by the ternary condition changing and decreasing
|
||||||
|
// the margin size, thus causing it to change back.
|
||||||
|
property real horizontalMargin: Math.max(10,
|
||||||
|
contentHeight > cellHeight && parent.width > cellWidth ?
|
||||||
|
(parent.width % cellWidth) / 2 : 0)
|
||||||
|
|
||||||
id: appGrid
|
id: appGrid
|
||||||
focus: true
|
focus: true
|
||||||
activeFocusOnTab: true
|
activeFocusOnTab: true
|
||||||
topMargin: 20
|
topMargin: 20
|
||||||
bottomMargin: 5
|
bottomMargin: 5
|
||||||
leftMargin: contentHeight > cellHeight && parent.width > cellWidth ? (parent.width % cellWidth) / 2 : 10
|
leftMargin: horizontalMargin
|
||||||
rightMargin: leftMargin
|
rightMargin: horizontalMargin
|
||||||
cellWidth: 230; cellHeight: 297;
|
cellWidth: 230; cellHeight: 297;
|
||||||
|
|
||||||
function computerLost()
|
function computerLost()
|
||||||
|
@ -24,6 +31,13 @@ GridView {
|
||||||
stackView.pop()
|
stackView.pop()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onHorizontalMarginChanged: {
|
||||||
|
if (this.synchronousDrag === undefined) {
|
||||||
|
anchors.leftMargin = horizontalMargin
|
||||||
|
anchors.rightMargin = horizontalMargin
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
// Don't show any highlighted item until interacting with them.
|
// Don't show any highlighted item until interacting with them.
|
||||||
// We do this here instead of onActivated to avoid losing the user's
|
// We do this here instead of onActivated to avoid losing the user's
|
||||||
|
@ -36,8 +50,6 @@ GridView {
|
||||||
// the grid will not be centered in the window.
|
// the grid will not be centered in the window.
|
||||||
if (this.synchronousDrag === undefined) {
|
if (this.synchronousDrag === undefined) {
|
||||||
anchors.fill = parent
|
anchors.fill = parent
|
||||||
anchors.leftMargin = leftMargin
|
|
||||||
anchors.rightMargin = rightMargin
|
|
||||||
anchors.topMargin = topMargin
|
anchors.topMargin = topMargin
|
||||||
anchors.bottomMargin = bottomMargin
|
anchors.bottomMargin = bottomMargin
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,16 +9,30 @@ import StreamingPreferences 1.0
|
||||||
GridView {
|
GridView {
|
||||||
property ComputerModel computerModel : createModel()
|
property ComputerModel computerModel : createModel()
|
||||||
|
|
||||||
|
// Prevent the margin from dropping below 10. By keeping a floor on the margin value
|
||||||
|
// this prevents a binding loop caused by the ternary condition changing and decreasing
|
||||||
|
// the margin size, thus causing it to change back.
|
||||||
|
property real horizontalMargin: Math.max(10,
|
||||||
|
contentHeight > cellHeight && parent.width > cellWidth ?
|
||||||
|
(parent.width % cellWidth) / 2 : 0)
|
||||||
|
|
||||||
id: pcGrid
|
id: pcGrid
|
||||||
focus: true
|
focus: true
|
||||||
activeFocusOnTab: true
|
activeFocusOnTab: true
|
||||||
topMargin: 20
|
topMargin: 20
|
||||||
bottomMargin: 5
|
bottomMargin: 5
|
||||||
leftMargin: contentHeight > cellHeight && parent.width > cellWidth ? (parent.width % cellWidth) / 2 : 10
|
leftMargin: horizontalMargin
|
||||||
rightMargin: leftMargin
|
rightMargin: horizontalMargin
|
||||||
cellWidth: 310; cellHeight: 350;
|
cellWidth: 310; cellHeight: 350;
|
||||||
objectName: "Computers"
|
objectName: "Computers"
|
||||||
|
|
||||||
|
onHorizontalMarginChanged: {
|
||||||
|
if (this.synchronousDrag === undefined) {
|
||||||
|
anchors.leftMargin = horizontalMargin
|
||||||
|
anchors.rightMargin = horizontalMargin
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
// Don't show any highlighted item until interacting with them.
|
// Don't show any highlighted item until interacting with them.
|
||||||
// We do this here instead of onActivated to avoid losing the user's
|
// We do this here instead of onActivated to avoid losing the user's
|
||||||
|
@ -31,8 +45,6 @@ GridView {
|
||||||
// the grid will not be centered in the window.
|
// the grid will not be centered in the window.
|
||||||
if (this.synchronousDrag === undefined) {
|
if (this.synchronousDrag === undefined) {
|
||||||
anchors.fill = parent
|
anchors.fill = parent
|
||||||
anchors.leftMargin = leftMargin
|
|
||||||
anchors.rightMargin = rightMargin
|
|
||||||
anchors.topMargin = topMargin
|
anchors.topMargin = topMargin
|
||||||
anchors.bottomMargin = bottomMargin
|
anchors.bottomMargin = bottomMargin
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue