mirror of
https://github.com/moonlight-stream/moonlight-qt
synced 2024-11-10 05:34:17 +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 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
|
||||
focus: true
|
||||
activeFocusOnTab: true
|
||||
topMargin: 20
|
||||
bottomMargin: 5
|
||||
leftMargin: contentHeight > cellHeight && parent.width > cellWidth ? (parent.width % cellWidth) / 2 : 10
|
||||
rightMargin: leftMargin
|
||||
leftMargin: horizontalMargin
|
||||
rightMargin: horizontalMargin
|
||||
cellWidth: 230; cellHeight: 297;
|
||||
|
||||
function computerLost()
|
||||
|
@ -24,6 +31,13 @@ GridView {
|
|||
stackView.pop()
|
||||
}
|
||||
|
||||
onHorizontalMarginChanged: {
|
||||
if (this.synchronousDrag === undefined) {
|
||||
anchors.leftMargin = horizontalMargin
|
||||
anchors.rightMargin = horizontalMargin
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
// Don't show any highlighted item until interacting with them.
|
||||
// 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.
|
||||
if (this.synchronousDrag === undefined) {
|
||||
anchors.fill = parent
|
||||
anchors.leftMargin = leftMargin
|
||||
anchors.rightMargin = rightMargin
|
||||
anchors.topMargin = topMargin
|
||||
anchors.bottomMargin = bottomMargin
|
||||
}
|
||||
|
|
|
@ -9,16 +9,30 @@ import StreamingPreferences 1.0
|
|||
GridView {
|
||||
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
|
||||
focus: true
|
||||
activeFocusOnTab: true
|
||||
topMargin: 20
|
||||
bottomMargin: 5
|
||||
leftMargin: contentHeight > cellHeight && parent.width > cellWidth ? (parent.width % cellWidth) / 2 : 10
|
||||
rightMargin: leftMargin
|
||||
leftMargin: horizontalMargin
|
||||
rightMargin: horizontalMargin
|
||||
cellWidth: 310; cellHeight: 350;
|
||||
objectName: "Computers"
|
||||
|
||||
onHorizontalMarginChanged: {
|
||||
if (this.synchronousDrag === undefined) {
|
||||
anchors.leftMargin = horizontalMargin
|
||||
anchors.rightMargin = horizontalMargin
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
// Don't show any highlighted item until interacting with them.
|
||||
// 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.
|
||||
if (this.synchronousDrag === undefined) {
|
||||
anchors.fill = parent
|
||||
anchors.leftMargin = leftMargin
|
||||
anchors.rightMargin = rightMargin
|
||||
anchors.topMargin = topMargin
|
||||
anchors.bottomMargin = bottomMargin
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue