Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
9f4b6e76
Commit
9f4b6e76
authored
Mar 06, 2015
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix hover state of Button
parent
f743d7d6
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
130 additions
and
24 deletions
+130
-24
qgroundcontrol.pro
qgroundcontrol.pro
+6
-3
QGCApplication.cc
src/QGCApplication.cc
+3
-1
MousePosition.cc
src/QmlControls/MousePosition.cc
+32
-0
MousePosition.h
src/QmlControls/MousePosition.h
+50
-0
QGCButton.qml
src/QmlControls/QGCButton.qml
+39
-20
No files found.
qgroundcontrol.pro
View file @
9f4b6e76
...
...
@@ -270,7 +270,8 @@ INCLUDEPATH += \
src
/
ui
/
main
\
src
/
ui
/
toolbar
\
src
/
VehicleSetup
\
src
/
AutoPilotPlugins
src
/
AutoPilotPlugins
\
src
/
QmlControls
FORMS
+=
\
src
/
ui
/
MainWindow
.
ui
\
...
...
@@ -495,7 +496,8 @@ HEADERS += \
src
/
ui
/
QGCCommConfiguration
.
h
\
src
/
ui
/
QGCUDPLinkConfiguration
.
h
\
src
/
uas
/
UASMessageHandler
.
h
\
src
/
ui
/
toolbar
/
MainToolBar
.
h
src
/
ui
/
toolbar
/
MainToolBar
.
h
\
src
/
QmlControls
/
MousePosition
.
h
SOURCES
+=
\
src
/
main
.
cc
\
...
...
@@ -636,7 +638,8 @@ SOURCES += \
src
/
ui
/
QGCCommConfiguration
.
cc
\
src
/
ui
/
QGCUDPLinkConfiguration
.
cc
\
src
/
uas
/
UASMessageHandler
.
cc
\
src
/
ui
/
toolbar
/
MainToolBar
.
cc
src
/
ui
/
toolbar
/
MainToolBar
.
cc
\
src
/
QmlControls
/
MousePosition
.
cc
#
#
Unit
Test
specific
configuration
goes
here
...
...
src/QGCApplication.cc
View file @
9f4b6e76
...
...
@@ -59,6 +59,7 @@
#include "QGCTemporaryFile.h"
#include "QGCFileDialog.h"
#include "QGCPalette.h"
#include "MousePosition.h"
#ifdef QGC_RTLAB_ENABLED
#include "OpalLink.h"
...
...
@@ -249,8 +250,9 @@ void QGCApplication::_initCommon(void)
// "Warning: Do not use this function in conjunction with Qt Style Sheets."
// setFont(fontDatabase.font(fontFamilyName, "Roman", 12));
// Register our Qml
palette before anyone tries to use it
// Register our Qml
objects
qmlRegisterType
<
QGCPalette
>
(
"QGroundControl.Palette"
,
1
,
0
,
"QGCPalette"
);
qmlRegisterType
<
MousePosition
>
(
"QGroundControl.MousePosition"
,
1
,
0
,
"MousePosition"
);
}
bool
QGCApplication
::
_initForNormalAppBoot
(
void
)
...
...
src/QmlControls/MousePosition.cc
0 → 100644
View file @
9f4b6e76
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/// @file
/// @author Don Gagne <don@thegagnes.com>
#include "MousePosition.h"
MousePosition
::
MousePosition
(
void
)
{
}
src/QmlControls/MousePosition.h
0 → 100644
View file @
9f4b6e76
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/// @file
/// @author Don Gagne <don@thegagnes.com>
#ifndef MOUSEPOSITION_H
#define MOUSEPOSITION_H
#include <QObject>
#include <QCursor>
/// This Qml control is used to return global mouse positions. It is needed to fix
/// a problem with hover state of buttons not being updated correctly if the mouse
/// moves out of a QQuickWidget control.
class
MousePosition
:
public
QObject
{
Q_OBJECT
public:
MousePosition
(
void
);
Q_PROPERTY
(
int
mouseX
READ
mouseX
)
Q_PROPERTY
(
int
mouseY
READ
mouseY
)
int
mouseX
(
void
)
{
return
QCursor
::
pos
().
x
();
}
int
mouseY
(
void
)
{
return
QCursor
::
pos
().
y
();
}
};
#endif
src/QmlControls/QGCButton.qml
View file @
9f4b6e76
...
...
@@ -4,6 +4,7 @@ import QtQuick.Controls.Styles 1.2
import
QtQuick
.
Controls
.
Private
1.0
import
QGroundControl
.
Palette
1.0
import
QGroundControl
.
MousePosition
1.0
Button
{
// primary: true - this is the primary button for this group of buttons
...
...
@@ -11,32 +12,50 @@ Button {
property
var
__qgcPal
:
QGCPalette
{
colorGroupEnabled
:
enabled
}
property
bool
__showHighlight
:
pressed
|
hovered
|
checked
property
bool
__showHighlight
:
(
pressed
|
hovered
|
checked
)
&&
!
__forceHoverOff
style
:
ButtonStyle
{
/*
background: Rectangle {
implicitWidth: 100
implicitHeight: 25
color: __showHighlight ?
control.__qgcPal.buttonHighlight :
(primary ? control.__qgcPal.primaryButton : control.__qgcPal.button)
}
// This fixes the issue with button hover where if a Button is near the edge oa QQuickWidget you can
// move the mouse fast enough such that the MouseArea does not trigger an onExited. This is turn
// cause the hover property to not be cleared correctly.
label: Text {
width: parent.width
height: parent.height
property
bool
__forceHoverOff
:
false
verticalAlignment: TextEdit.AlignVCenter
horizontalAlignment: TextEdit.AlignHCenter
property
int
__lastMouseX
:
__behavior
.
mouseX
property
int
__lastMouseY
:
__behavior
.
mouseY
property
int
__lastCursorX
:
0
property
int
__lastCursorY
:
0
text: control.text
color: __showHighlight ?
control.__qgcPal.buttonHighlightText :
(primary ? control.__qgcPal.primaryButtonText : control.__qgcPal.buttonText)
property
MousePosition
__mousePosition
:
MousePosition
{
}
Connections
{
target
:
__behavior
onMouseXChanged
:
{
__lastCursorX
=
__mousePosition
.
mouseX
__lastCursorY
=
__mousePosition
.
mouseY
}
onMouseYChanged
:
{
__lastCursorX
=
__mousePosition
.
mouseX
__lastCursorY
=
__mousePosition
.
mouseY
}
onEntered
:
{
__forceHoverOff
;
false
;
hoverTimer
.
start
()
}
onExited
:
{
__forceHoverOff
;
false
;
hoverTimer
.
stop
()
}
}
Timer
{
id
:
hoverTimer
interval
:
250
repeat
:
true
onTriggered
:
{
if
(
__lastCursorX
!=
__mousePosition
.
mouseX
||
__lastCursorY
!=
__mousePosition
.
mouseY
)
{
__forceHoverOff
=
true
}
else
{
__forceHoverOff
=
false
}
*/
}
}
style
:
ButtonStyle
{
/*! The padding between the background and the label components. */
padding
{
top
:
4
...
...
Write
Preview
Markdown
is supported
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