mirror of
https://github.com/zoriya/noctalia-shell.git
synced 2026-05-29 17:12:04 +00:00
Merge pull request #460 from DuckySoLucky/feat/ability-to-ignore-intial-mouse-position
feat(Application Launcher): add option to ignore initial mouse position
This commit is contained in:
@@ -35,6 +35,7 @@ NPanel {
|
||||
property var plugins: []
|
||||
property var activePlugin: null
|
||||
property bool resultsReady: false
|
||||
property bool ignoreMouseHover: false
|
||||
|
||||
readonly property int badgeSize: Math.round(Style.baseWidgetSize * 1.6 * scaling)
|
||||
readonly property int entryHeight: Math.round(badgeSize + Style.marginM * 2 * scaling)
|
||||
@@ -94,6 +95,7 @@ NPanel {
|
||||
// Lifecycle
|
||||
onOpened: {
|
||||
resultsReady = false
|
||||
ignoreMouseHover = true
|
||||
|
||||
// Notify plugins
|
||||
for (let plugin of plugins) {
|
||||
@@ -110,6 +112,7 @@ NPanel {
|
||||
onClosed: {
|
||||
// Reset search text
|
||||
searchText = ""
|
||||
ignoreMouseHover = true
|
||||
|
||||
// Notify plugins
|
||||
for (let plugin of plugins) {
|
||||
@@ -154,6 +157,49 @@ NPanel {
|
||||
color: Color.transparent
|
||||
opacity: resultsReady ? 1.0 : 0.0
|
||||
|
||||
// Global MouseArea to detect mouse movement
|
||||
MouseArea {
|
||||
id: mouseMovementDetector
|
||||
anchors.fill: parent
|
||||
z: -999
|
||||
hoverEnabled: true
|
||||
propagateComposedEvents: true
|
||||
acceptedButtons: Qt.NoButton
|
||||
|
||||
property real lastX: 0
|
||||
property real lastY: 0
|
||||
property bool initialized: false
|
||||
|
||||
onPositionChanged: mouse => {
|
||||
// Store initial position
|
||||
if (!initialized) {
|
||||
lastX = mouse.x
|
||||
lastY = mouse.y
|
||||
initialized = true
|
||||
return
|
||||
}
|
||||
|
||||
// Check if mouse actually moved
|
||||
const deltaX = Math.abs(mouse.x - lastX)
|
||||
const deltaY = Math.abs(mouse.y - lastY)
|
||||
if (deltaX > 1 || deltaY > 1) {
|
||||
root.ignoreMouseHover = false
|
||||
lastX = mouse.x
|
||||
lastY = mouse.y
|
||||
}
|
||||
}
|
||||
|
||||
// Reset when launcher opens
|
||||
Connections {
|
||||
target: root
|
||||
function onOpenedChanged() {
|
||||
if (root.opened) {
|
||||
mouseMovementDetector.initialized = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Behavior on opacity {
|
||||
NumberAnimation {
|
||||
duration: Style.animationFast
|
||||
@@ -321,7 +367,7 @@ NPanel {
|
||||
delegate: Rectangle {
|
||||
id: entry
|
||||
|
||||
property bool isSelected: mouseArea.containsMouse || (index === selectedIndex)
|
||||
property bool isSelected: (!root.ignoreMouseHover && mouseArea.containsMouse) || (index === selectedIndex)
|
||||
// Accessor for app id
|
||||
property string appId: (modelData && modelData.appId) ? String(modelData.appId) : ""
|
||||
|
||||
@@ -523,7 +569,9 @@ NPanel {
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onEntered: {
|
||||
selectedIndex = index
|
||||
if (!root.ignoreMouseHover) {
|
||||
selectedIndex = index
|
||||
}
|
||||
}
|
||||
onClicked: mouse => {
|
||||
if (mouse.button === Qt.LeftButton) {
|
||||
|
||||
Reference in New Issue
Block a user