Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Network
KDE Connect
Commits
91c05d0f
Commit
91c05d0f
authored
Jul 16, 2021
by
Piyush Aggarwal
🎮
Browse files
mousepad: add drag support and better click registration
parent
a92112ad
Pipeline
#70560
passed with stage
in 4 minutes and 48 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
app/qml/mousepad.qml
View file @
91c05d0f
...
...
@@ -29,6 +29,8 @@ Kirigami.Page
Layout.fillWidth
:
true
Layout.fillHeight
:
true
property
var
lastPos
:
Qt
.
point
(
-
1
,
-
1
)
property
var
pressedPos
:
Qt
.
point
(
-
1
,
-
1
)
property
var
releasedPos
:
Qt
.
point
(
-
1
,
-
1
)
acceptedButtons
:
Qt
.
LeftButton
|
Qt
.
RightButton
|
Qt
.
MiddleButton
...
...
@@ -37,7 +39,11 @@ Kirigami.Page
var
packet
=
{};
switch
(
mouse
.
button
)
{
case
Qt
.
LeftButton
:
clickType
=
"
singleclick
"
;
if
(
pressedPos
==
releasedPos
)
{
clickType
=
"
singleclick
"
;
pressedPos
=
Qt
.
point
(
-
1
,
-
1
);
releasedPos
=
Qt
.
point
(
-
1
,
-
1
);
}
break
;
case
Qt
.
RightButton
:
clickType
=
"
rightclick
"
;
...
...
@@ -56,6 +62,24 @@ Kirigami.Page
}
}
onDoubleClicked
:
{
var
clickType
=
""
;
var
packet
=
{};
switch
(
mouse
.
button
)
{
case
Qt
.
LeftButton
:
clickType
=
"
singlehold
"
;
break
;
default
:
console
.
log
(
"
This click input is not handled yet!
"
);
break
;
}
if
(
clickType
)
{
packet
[
clickType
]
=
true
;
mousepad
.
pluginInterface
.
sendCommand
(
packet
);
}
}
onPositionChanged
:
{
if
(
lastPos
.
x
>
-
1
)
{
// console.log("move", mouse.x, mouse.y, lastPos)
...
...
@@ -66,6 +90,10 @@ Kirigami.Page
lastPos
=
Qt
.
point
(
mouse
.
x
,
mouse
.
y
);
}
onPressed
:
{
pressedPos
=
Qt
.
point
(
mouse
.
x
,
mouse
.
y
);
}
onWheel
:
{
var
packet
=
{};
packet
[
"
scroll
"
]
=
true
;
...
...
@@ -76,6 +104,8 @@ Kirigami.Page
onReleased
:
{
lastPos
=
Qt
.
point
(
-
1
,
-
1
)
releasedPos
=
Qt
.
point
(
mouse
.
x
,
mouse
.
y
);
mousepad
.
pluginInterface
.
sendCommand
({
"
singlerelease
"
:
true
});
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment