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
abb17fc6
Commit
abb17fc6
authored
Sep 04, 2016
by
Don Gagne
Committed by
GitHub
Sep 04, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4021 from DonLakeFlyer/DisabledDlgButton
Fix dialog buttons stuck in disabled state
parents
c75cca7d
41da849f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
113 additions
and
174 deletions
+113
-174
QGCView.qml
src/QmlControls/QGCView.qml
+113
-174
No files found.
src/QmlControls/QGCView.qml
View file @
abb17fc6
...
...
@@ -22,12 +22,11 @@ import QGroundControl.FactSystem 1.0
import
QGroundControl
.
FactControls
1.0
FactPanel
{
id
:
_
_
rootItem
id
:
_rootItem
property
var
qgcView
:
_
_rootItem
///< Used by Fact controls for validation dialogs
property
var
qgcView
:
_rootItem
///< Used by Fact controls for validation dialogs
property
bool
completedSignalled
:
false
property
real
topDialogMargin
:
0
///< Set a top margin for dialog
property
var
viewPanel
/// This is signalled when the top level Item reaches Component.onCompleted. This allows
...
...
@@ -35,77 +34,71 @@ FactPanel {
/// to go.
signal
completed
function
_
_
setupDialogButtons
(
buttons
)
{
_
_
acceptButton
.
visible
=
false
_
_
rejectButton
.
visible
=
false
function
_setupDialogButtons
(
buttons
)
{
_acceptButton
.
visible
=
false
_rejectButton
.
visible
=
false
// Accept role buttons
if
(
buttons
&
StandardButton
.
Ok
)
{
_
_
acceptButton
.
text
=
qsTr
(
"
Ok
"
)
_
_
acceptButton
.
visible
=
true
_acceptButton
.
text
=
qsTr
(
"
Ok
"
)
_acceptButton
.
visible
=
true
}
else
if
(
buttons
&
StandardButton
.
Open
)
{
_
_
acceptButton
.
text
=
qsTr
(
"
Open
"
)
_
_
acceptButton
.
visible
=
true
_acceptButton
.
text
=
qsTr
(
"
Open
"
)
_acceptButton
.
visible
=
true
}
else
if
(
buttons
&
StandardButton
.
Save
)
{
_
_
acceptButton
.
text
=
qsTr
(
"
Save
"
)
_
_
acceptButton
.
visible
=
true
_acceptButton
.
text
=
qsTr
(
"
Save
"
)
_acceptButton
.
visible
=
true
}
else
if
(
buttons
&
StandardButton
.
Apply
)
{
_
_
acceptButton
.
text
=
qsTr
(
"
Apply
"
)
_
_
acceptButton
.
visible
=
true
_acceptButton
.
text
=
qsTr
(
"
Apply
"
)
_acceptButton
.
visible
=
true
}
else
if
(
buttons
&
StandardButton
.
Open
)
{
_
_
acceptButton
.
text
=
qsTr
(
"
Open
"
)
_
_
acceptButton
.
visible
=
true
_acceptButton
.
text
=
qsTr
(
"
Open
"
)
_acceptButton
.
visible
=
true
}
else
if
(
buttons
&
StandardButton
.
SaveAll
)
{
_
_
acceptButton
.
text
=
qsTr
(
"
Save All
"
)
_
_
acceptButton
.
visible
=
true
_acceptButton
.
text
=
qsTr
(
"
Save All
"
)
_acceptButton
.
visible
=
true
}
else
if
(
buttons
&
StandardButton
.
Yes
)
{
_
_
acceptButton
.
text
=
qsTr
(
"
Yes
"
)
_
_
acceptButton
.
visible
=
true
_acceptButton
.
text
=
qsTr
(
"
Yes
"
)
_acceptButton
.
visible
=
true
}
else
if
(
buttons
&
StandardButton
.
YesToAll
)
{
_
_
acceptButton
.
text
=
qsTr
(
"
Yes to All
"
)
_
_
acceptButton
.
visible
=
true
_acceptButton
.
text
=
qsTr
(
"
Yes to All
"
)
_acceptButton
.
visible
=
true
}
else
if
(
buttons
&
StandardButton
.
Retry
)
{
_
_
acceptButton
.
text
=
qsTr
(
"
Retry
"
)
_
_
acceptButton
.
visible
=
true
_acceptButton
.
text
=
qsTr
(
"
Retry
"
)
_acceptButton
.
visible
=
true
}
else
if
(
buttons
&
StandardButton
.
Reset
)
{
_
_
acceptButton
.
text
=
qsTr
(
"
Reset
"
)
_
_
acceptButton
.
visible
=
true
_acceptButton
.
text
=
qsTr
(
"
Reset
"
)
_acceptButton
.
visible
=
true
}
else
if
(
buttons
&
StandardButton
.
RestoreToDefaults
)
{
_
_
acceptButton
.
text
=
qsTr
(
"
Restore to Defaults
"
)
_
_
acceptButton
.
visible
=
true
_acceptButton
.
text
=
qsTr
(
"
Restore to Defaults
"
)
_acceptButton
.
visible
=
true
}
else
if
(
buttons
&
StandardButton
.
Ignore
)
{
_
_
acceptButton
.
text
=
qsTr
(
"
Ignore
"
)
_
_
acceptButton
.
visible
=
true
_acceptButton
.
text
=
qsTr
(
"
Ignore
"
)
_acceptButton
.
visible
=
true
}
// Reject role buttons
if
(
buttons
&
StandardButton
.
Cancel
)
{
_
_
rejectButton
.
text
=
qsTr
(
"
Cancel
"
)
_
_
rejectButton
.
visible
=
true
_rejectButton
.
text
=
qsTr
(
"
Cancel
"
)
_rejectButton
.
visible
=
true
}
else
if
(
buttons
&
StandardButton
.
Close
)
{
_
_
rejectButton
.
text
=
qsTr
(
"
Close
"
)
_
_
rejectButton
.
visible
=
true
_rejectButton
.
text
=
qsTr
(
"
Close
"
)
_rejectButton
.
visible
=
true
}
else
if
(
buttons
&
StandardButton
.
No
)
{
_
_
rejectButton
.
text
=
qsTr
(
"
No
"
)
_
_
rejectButton
.
visible
=
true
_rejectButton
.
text
=
qsTr
(
"
No
"
)
_rejectButton
.
visible
=
true
}
else
if
(
buttons
&
StandardButton
.
NoToAll
)
{
_
_
rejectButton
.
text
=
qsTr
(
"
No to All
"
)
_
_
rejectButton
.
visible
=
true
_rejectButton
.
text
=
qsTr
(
"
No to All
"
)
_rejectButton
.
visible
=
true
}
else
if
(
buttons
&
StandardButton
.
Abort
)
{
__rejectButton
.
text
=
qsTr
(
"
Abort
"
)
__rejectButton
.
visible
=
true
}
}
function
__stopAllAnimations
()
{
if
(
__animateHideDialog
.
running
)
{
__animateHideDialog
.
stop
()
_rejectButton
.
text
=
qsTr
(
"
Abort
"
)
_rejectButton
.
visible
=
true
}
}
function
_
_
checkForEarlyDialog
(
title
)
{
function
_checkForEarlyDialog
(
title
)
{
if
(
!
completedSignalled
)
{
console
.
warn
(
qsTr
(
"
showDialog
|Message
called before QGCView.completed signalled
"
),
title
)
console
.
warn
(
qsTr
(
"
showDialog called before QGCView.completed signalled
"
),
title
)
}
}
...
...
@@ -119,77 +112,65 @@ FactPanel {
readonly
property
int
showDialogDefaultWidth
:
40
///< Use for default dialog width
function
showDialog
(
component
,
title
,
charWidth
,
buttons
)
{
if
(
_
_
checkForEarlyDialog
(
title
))
{
if
(
_checkForEarlyDialog
(
title
))
{
return
}
_
_
rejectButton
.
enabled
=
true
_
_
acceptButton
.
enabled
=
true
_rejectButton
.
enabled
=
true
_acceptButton
.
enabled
=
true
__stopAllAnimations
()
_dialogCharWidth
=
charWidth
_dialogTitle
=
title
__dialogCharWidth
=
charWidth
__dialogTitle
=
title
_setupDialogButtons
(
buttons
)
__setupDialogButtons
(
buttons
)
__dialogComponent
=
component
_dialogComponent
=
component
viewPanel
.
enabled
=
false
__dialogOverlay
.
visible
=
true
//__dialogComponentLoader.item.forceActiveFocus()
__animateShowDialog
.
start
()
_dialogOverlay
.
visible
=
true
}
function
showMessage
(
title
,
message
,
buttons
)
{
if
(
_
_
checkForEarlyDialog
(
title
))
{
if
(
_checkForEarlyDialog
(
title
))
{
return
}
__rejectButton
.
enabled
=
true
__acceptButton
.
enabled
=
true
__stopAllAnimations
()
_rejectButton
.
enabled
=
true
_acceptButton
.
enabled
=
true
_
_
dialogCharWidth
=
showDialogDefaultWidth
_
_
dialogTitle
=
title
_
_
messageDialogText
=
message
_dialogCharWidth
=
showDialogDefaultWidth
_dialogTitle
=
title
_messageDialogText
=
message
_
_
setupDialogButtons
(
buttons
)
_setupDialogButtons
(
buttons
)
_
_dialogComponent
=
_
_messageDialog
_
dialogComponent
=
_messageDialog
viewPanel
.
enabled
=
false
__dialogOverlay
.
visible
=
true
__dialogComponentLoader
.
item
.
forceActiveFocus
()
__animateShowDialog
.
start
()
_dialogOverlay
.
visible
=
true
}
function
hideDialog
()
{
//__dialogComponentLoader.item.focus = false
viewPanel
.
enabled
=
true
__animateHideDialog
.
start
()
_dialogComponent
=
null
_dialogOverlay
.
visible
=
false
}
QGCPalette
{
id
:
_
_
qgcPal
;
colorGroupEnabled
:
true
}
QGCLabel
{
id
:
_
_
textMeasure
;
text
:
"
X
"
;
visible
:
false
}
QGCPalette
{
id
:
_qgcPal
;
colorGroupEnabled
:
true
}
QGCLabel
{
id
:
_textMeasure
;
text
:
"
X
"
;
visible
:
false
}
property
real
defaultTextHeight
:
_
_
textMeasure
.
contentHeight
property
real
defaultTextWidth
:
_
_
textMeasure
.
contentWidth
property
real
defaultTextHeight
:
_textMeasure
.
contentHeight
property
real
defaultTextWidth
:
_textMeasure
.
contentWidth
/// The width of the dialog panel in characters
property
int
_
_
dialogCharWidth
:
75
property
int
_dialogCharWidth
:
75
/// The title for the dialog panel
property
string
_
_
dialogTitle
property
string
_dialogTitle
property
string
_
_
messageDialogText
property
string
_messageDialogText
property
Component
_
_
dialogComponent
property
Component
_dialogComponent
function
_
_
signalCompleted
()
{
function
_signalCompleted
()
{
// When we use this control inside a QGCQmlWidgetHolder Component.onCompleted is signalled
// before the width and height are adjusted. So we need to wait for width and heigth to be
// set before we signal our own completed signal.
...
...
@@ -199,160 +180,118 @@ FactPanel {
}
}
Component.onCompleted
:
_
_
signalCompleted
()
onWidthChanged
:
_
_
signalCompleted
()
onHeightChanged
:
_
_
signalCompleted
()
Component.onCompleted
:
_signalCompleted
()
onWidthChanged
:
_signalCompleted
()
onHeightChanged
:
_signalCompleted
()
Connections
{
target
:
_
_
dialogComponentLoader
.
item
target
:
_dialogComponentLoader
.
item
onHideDialog
:
_
_
rootItem
.
hideDialog
()
onHideDialog
:
_rootItem
.
hideDialog
()
}
Item
{
id
:
_
_
dialogOverlay
id
:
_dialogOverlay
visible
:
false
anchors.fill
:
parent
z
:
5000
readonly
property
int
__animationDuration
:
200
ParallelAnimation
{
id
:
__animateShowDialog
NumberAnimation
{
target
:
__transparentSection
properties
:
"
opacity
"
from
:
0.0
to
:
0.8
duration
:
__dialogOverlay
.
__animationDuration
}
NumberAnimation
{
target
:
__transparentSection
properties
:
"
width
"
from
:
__dialogOverlay
.
width
to
:
__dialogOverlay
.
width
-
__dialogPanel
.
width
duration
:
__dialogOverlay
.
__animationDuration
}
}
ParallelAnimation
{
id
:
__animateHideDialog
NumberAnimation
{
target
:
__transparentSection
properties
:
"
opacity
"
from
:
0.8
to
:
0.0
duration
:
__dialogOverlay
.
__animationDuration
}
NumberAnimation
{
target
:
__transparentSection
properties
:
"
width
"
from
:
__dialogOverlay
.
width
-
__dialogPanel
.
width
to
:
__dialogOverlay
.
width
duration
:
__dialogOverlay
.
__animationDuration
}
onRunningChanged
:
{
if
(
!
running
)
{
__dialogComponent
=
null
__dialogOverlay
.
visible
=
false
}
}
}
// This covers the parent with an transparent section
Rectangle
{
id
:
_
_
transparentSection
id
:
_transparentSection
height
:
ScreenTools
.
availableHeight
?
ScreenTools
.
availableHeight
:
parent
.
height
anchors.bottom
:
parent
.
bottom
anchors.left
:
parent
.
left
anchors.right
:
_
_
dialogPanel
.
left
anchors.right
:
_dialogPanel
.
left
opacity
:
0.0
color
:
_
_
qgcPal
.
window
color
:
_qgcPal
.
window
}
// This is the main dialog panel which is anchored to the right edge
Rectangle
{
id
:
_
_
dialogPanel
width
:
_
_dialogCharWidth
==
showDialogFullWidth
?
parent
.
width
:
defaultTextWidth
*
_
_dialogCharWidth
id
:
_dialogPanel
width
:
_
dialogCharWidth
==
showDialogFullWidth
?
parent
.
width
:
defaultTextWidth
*
_dialogCharWidth
anchors.topMargin
:
topDialogMargin
height
:
ScreenTools
.
availableHeight
?
ScreenTools
.
availableHeight
:
parent
.
height
anchors.bottom
:
parent
.
bottom
anchors.right
:
parent
.
right
color
:
_
_
qgcPal
.
windowShadeDark
color
:
_qgcPal
.
windowShadeDark
Rectangle
{
id
:
_
_
header
id
:
_header
width
:
parent
.
width
height
:
_
_acceptButton
.
visible
?
__acceptButton
.
height
:
_
_rejectButton
.
height
color
:
_
_
qgcPal
.
windowShade
height
:
_
acceptButton
.
visible
?
_acceptButton
.
height
:
_rejectButton
.
height
color
:
_qgcPal
.
windowShade
function
_
_
hidePanel
()
{
_
_
fullPanel
.
visible
=
false
function
_hidePanel
()
{
_fullPanel
.
visible
=
false
}
QGCLabel
{
x
:
defaultTextWidth
height
:
parent
.
height
verticalAlignment
:
Text
.
AlignVCenter
text
:
_
_
dialogTitle
text
:
_dialogTitle
}
QGCButton
{
id
:
_
_
rejectButton
anchors.right
:
_
_acceptButton
.
visible
?
_
_acceptButton
.
left
:
parent
.
right
id
:
_rejectButton
anchors.right
:
_
acceptButton
.
visible
?
_acceptButton
.
left
:
parent
.
right
anchors.bottom
:
parent
.
bottom
onClicked
:
{
enabled
=
false
// prevent multiple clicks
__dialogComponentLoader
.
item
.
reject
()
_dialogComponentLoader
.
item
.
reject
()
if
(
!
viewPanel
.
enabled
)
{
// Dialog was not closed, re-enable button
enabled
=
true
}
}
}
QGCButton
{
id
:
_
_
acceptButton
id
:
_acceptButton
anchors.right
:
parent
.
right
primary
:
true
onClicked
:
{
enabled
=
false
// prevent multiple clicks
__dialogComponentLoader
.
item
.
accept
()
_dialogComponentLoader
.
item
.
accept
()
if
(
!
viewPanel
.
enabled
)
{
// Dialog was not closed, re-enable button
enabled
=
true
}
}
}
}
Item
{
id
:
_
_
spacer
id
:
_spacer
width
:
10
height
:
10
anchors.top
:
_
_
header
.
bottom
anchors.top
:
_header
.
bottom
}
Loader
{
id
:
_
_
dialogComponentLoader
id
:
_dialogComponentLoader
anchors.margins
:
5
anchors.left
:
parent
.
left
anchors.right
:
parent
.
right
anchors.top
:
_
_
spacer
.
bottom
anchors.top
:
_spacer
.
bottom
anchors.bottom
:
parent
.
bottom
sourceComponent
:
_
_
dialogComponent
sourceComponent
:
_dialogComponent
property
bool
acceptAllowed
:
_
_
acceptButton
.
visible
property
bool
rejectAllowed
:
_
_
rejectButton
.
visible
property
bool
acceptAllowed
:
_acceptButton
.
visible
property
bool
rejectAllowed
:
_rejectButton
.
visible
}
}
// Rectangle - Dialog panel
}
// Item - Dialog overlay
Component
{
id
:
_
_
messageDialog
id
:
_messageDialog
QGCViewMessage
{
message
:
_
_
messageDialogText
message
:
_messageDialogText
}
}
}
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