Widgets Drag&Drop: drop indicator and improved behavior
This commit is contained in:
parent
6ed9a8c5ae
commit
b9dbbf7bdd
1 changed files with 24 additions and 3 deletions
|
|
@ -40,8 +40,8 @@ Loader {
|
||||||
property int buttonWidth: 0
|
property int buttonWidth: 0
|
||||||
property int buttonHeight: 0
|
property int buttonHeight: 0
|
||||||
|
|
||||||
// Whether this panel should accept keyboard focus
|
|
||||||
property bool panelKeyboardFocus: false
|
property bool panelKeyboardFocus: false
|
||||||
|
property bool backgroundClickEnabled: true
|
||||||
|
|
||||||
// Animation properties
|
// Animation properties
|
||||||
readonly property real originalScale: 0.7
|
readonly property real originalScale: 0.7
|
||||||
|
|
@ -62,6 +62,24 @@ Loader {
|
||||||
PanelService.registerPanel(root)
|
PanelService.registerPanel(root)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------
|
||||||
|
// Functions to control background click behavior
|
||||||
|
function disableBackgroundClick() {
|
||||||
|
backgroundClickEnabled = false
|
||||||
|
}
|
||||||
|
|
||||||
|
function enableBackgroundClick() {
|
||||||
|
// Add a small delay to prevent immediate close after drag release
|
||||||
|
enableBackgroundClickTimer.restart()
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: enableBackgroundClickTimer
|
||||||
|
interval: 100
|
||||||
|
repeat: false
|
||||||
|
onTriggered: backgroundClickEnabled = true
|
||||||
|
}
|
||||||
|
|
||||||
// -----------------------------------------
|
// -----------------------------------------
|
||||||
function toggle(aScreen, buttonItem) {
|
function toggle(aScreen, buttonItem) {
|
||||||
// Don't toggle if screen is null or invalid
|
// Don't toggle if screen is null or invalid
|
||||||
|
|
@ -110,6 +128,7 @@ Loader {
|
||||||
|
|
||||||
PanelService.willOpenPanel(root)
|
PanelService.willOpenPanel(root)
|
||||||
|
|
||||||
|
backgroundClickEnabled = true
|
||||||
active = true
|
active = true
|
||||||
root.opened()
|
root.opened()
|
||||||
}
|
}
|
||||||
|
|
@ -125,7 +144,8 @@ Loader {
|
||||||
function closeCompleted() {
|
function closeCompleted() {
|
||||||
root.closed()
|
root.closed()
|
||||||
active = false
|
active = false
|
||||||
useButtonPosition = false // Reset button position usage
|
useButtonPosition = false
|
||||||
|
backgroundClickEnabled = true
|
||||||
PanelService.closedPanel(root)
|
PanelService.closedPanel(root)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -179,6 +199,7 @@ Loader {
|
||||||
// Clicking outside of the rectangle to close
|
// Clicking outside of the rectangle to close
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
enabled: root.backgroundClickEnabled
|
||||||
onClicked: root.close()
|
onClicked: root.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -208,7 +229,7 @@ Loader {
|
||||||
|
|
||||||
return Math.round(Math.max(minX, Math.min(targetX, maxX)))
|
return Math.round(Math.max(minX, Math.min(targetX, maxX)))
|
||||||
} else if (!panelAnchorHorizontalCenter && panelAnchorLeft) {
|
} else if (!panelAnchorHorizontalCenter && panelAnchorLeft) {
|
||||||
return Math.round(marginS * scaling)
|
return Math.round(Style.marginS * scaling)
|
||||||
} else if (!panelAnchorHorizontalCenter && panelAnchorRight) {
|
} else if (!panelAnchorHorizontalCenter && panelAnchorRight) {
|
||||||
return Math.round(panelWindow.width - panelWidth - (Style.marginS * scaling))
|
return Math.round(panelWindow.width - panelWidth - (Style.marginS * scaling))
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue