Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
9143c8c5
Commit
9143c8c5
authored
Oct 13, 2013
by
John Tapsell
Browse files
Improve the UI for editing the Text Label
parent
42d68e1d
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/ui/designer/QGCTextLabel.cc
View file @
9143c8c5
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
#include
"UASManager.h"
#include
"UASManager.h"
QGCTextLabel
::
QGCTextLabel
(
QWidget
*
parent
)
:
QGCTextLabel
::
QGCTextLabel
(
QWidget
*
parent
)
:
QGCToolWidgetItem
(
"
Command Button
"
,
parent
),
QGCToolWidgetItem
(
"
Text Label
"
,
parent
),
ui
(
new
Ui
::
QGCTextLabel
)
ui
(
new
Ui
::
QGCTextLabel
)
{
{
uas
=
0
;
uas
=
0
;
...
@@ -15,11 +15,15 @@ QGCTextLabel::QGCTextLabel(QWidget *parent) :
...
@@ -15,11 +15,15 @@ QGCTextLabel::QGCTextLabel(QWidget *parent) :
ui
->
setupUi
(
this
);
ui
->
setupUi
(
this
);
connect
(
ui
->
editFinishButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
endEditMode
()));
connect
(
ui
->
editFinishButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
endEditMode
()));
connect
(
ui
->
isMavCommand
,
SIGNAL
(
toggled
(
bool
)),
this
,
SLOT
(
update_isMavCommand
()));
// Hide all edit items
// Hide all edit items
ui
->
editFinishButton
->
hide
();
ui
->
editFinishButton
->
hide
();
ui
->
editNameLabel
->
hide
();
ui
->
editNameLabel
->
hide
();
ui
->
editLine1
->
hide
();
ui
->
editLine1
->
hide
();
ui
->
editLine2
->
hide
();
ui
->
isMavCommand
->
hide
();
ui
->
textLabel
->
setText
(
QString
());
}
}
QGCTextLabel
::~
QGCTextLabel
()
QGCTextLabel
::~
QGCTextLabel
()
...
@@ -30,10 +34,11 @@ QGCTextLabel::~QGCTextLabel()
...
@@ -30,10 +34,11 @@ QGCTextLabel::~QGCTextLabel()
void
QGCTextLabel
::
startEditMode
()
void
QGCTextLabel
::
startEditMode
()
{
{
// Hide elements
// Hide elements
ui
->
nameLabel
->
hide
();
ui
->
editFinishButton
->
show
();
ui
->
editFinishButton
->
show
();
ui
->
editNameLabel
->
show
();
ui
->
editNameLabel
->
show
();
ui
->
editLine1
->
show
();
ui
->
editLine1
->
show
();
ui
->
editLine2
->
show
();
ui
->
isMavCommand
->
show
();
// Attempt to undock the dock widget
// Attempt to undock the dock widget
QWidget
*
p
=
this
;
QWidget
*
p
=
this
;
...
@@ -55,10 +60,12 @@ void QGCTextLabel::startEditMode()
...
@@ -55,10 +60,12 @@ void QGCTextLabel::startEditMode()
void
QGCTextLabel
::
endEditMode
()
void
QGCTextLabel
::
endEditMode
()
{
{
update_isMavCommand
();
ui
->
editFinishButton
->
hide
();
ui
->
editFinishButton
->
hide
();
ui
->
editNameLabel
->
hide
();
ui
->
editNameLabel
->
hide
();
ui
->
editLine1
->
hide
();
ui
->
editLine1
->
hide
();
ui
->
nameLabel
->
show
();
ui
->
editLine2
->
hide
();
ui
->
isMavCommand
->
hide
();
// Write to settings
// Write to settings
emit
editingFinished
();
emit
editingFinished
();
...
@@ -83,25 +90,17 @@ void QGCTextLabel::endEditMode()
...
@@ -83,25 +90,17 @@ void QGCTextLabel::endEditMode()
void
QGCTextLabel
::
writeSettings
(
QSettings
&
settings
)
void
QGCTextLabel
::
writeSettings
(
QSettings
&
settings
)
{
{
qDebug
()
<<
"COMMAND BUTTON WRITING SETTINGS"
;
settings
.
setValue
(
"TYPE"
,
"TEXT"
)
;
settings
.
setValue
(
"
TYPE"
,
"COMMANDBUTTON"
);
settings
.
setValue
(
"
QGC_TEXT_TEXT"
,
ui
->
editNameLabel
->
text
()
);
settings
.
setValue
(
"QGC_
COMMAND_BUTTON_DESCRIPTION"
,
ui
->
nameLabel
->
text
()
);
settings
.
setValue
(
"QGC_
TEXT_SOURCE"
,
ui
->
isMavCommand
->
isChecked
()
?
"MAV"
:
"NONE"
);
settings
.
sync
();
settings
.
sync
();
}
}
void
QGCTextLabel
::
readSettings
(
const
QString
&
pre
,
const
QVariantMap
&
settings
)
void
QGCTextLabel
::
readSettings
(
const
QString
&
pre
,
const
QVariantMap
&
settings
)
{
{
ui
->
editNameLabel
->
setText
(
settings
.
value
(
pre
+
"QGC_TEXT_TEXT"
,
""
).
toString
());
ui
->
isMavCommand
->
setChecked
(
settings
.
value
(
pre
+
"QGC_TEXT_SOURCE"
,
"NONE"
).
toString
()
==
"MAV"
);
ui
->
isMavCommand
->
setChecked
(
settings
.
value
(
pre
+
"QGC_TEXT_SOURCE"
,
"NONE"
).
toString
()
==
"MAV"
);
if
(
!
ui
->
isMavCommand
->
isChecked
())
update_isMavCommand
();
{
ui
->
editNameLabel
->
setText
(
settings
.
value
(
pre
+
"QGC_TEXT_TEXT"
,
""
).
toString
());
ui
->
nameLabel
->
setText
(
ui
->
editNameLabel
->
text
());
}
else
{
//MAV command text
connect
(
uas
,
SIGNAL
(
textMessageReceived
(
int
,
int
,
int
,
QString
)),
this
,
SLOT
(
textMessageReceived
(
int
,
int
,
int
,
QString
)));
}
}
}
void
QGCTextLabel
::
textMessageReceived
(
int
uasid
,
int
component
,
int
severity
,
QString
message
)
void
QGCTextLabel
::
textMessageReceived
(
int
uasid
,
int
component
,
int
severity
,
QString
message
)
{
{
...
@@ -128,28 +127,40 @@ void QGCTextLabel::textMessageReceived(int uasid, int component, int severity, Q
...
@@ -128,28 +127,40 @@ void QGCTextLabel::textMessageReceived(int uasid, int component, int severity, Q
void
QGCTextLabel
::
readSettings
(
const
QSettings
&
settings
)
void
QGCTextLabel
::
readSettings
(
const
QSettings
&
settings
)
{
{
ui
->
editNameLabel
->
setText
(
settings
.
value
(
"QGC_TEXT_TEXT"
,
""
).
toString
());
//Place this before setting isMavCommand
ui
->
isMavCommand
->
setChecked
(
settings
.
value
(
"QGC_TEXT_SOURCE"
,
"NONE"
).
toString
()
==
"MAV"
);
ui
->
isMavCommand
->
setChecked
(
settings
.
value
(
"QGC_TEXT_SOURCE"
,
"NONE"
).
toString
()
==
"MAV"
);
ui
->
editNameLabel
->
setText
(
settings
.
value
(
"QGC_TEXT_TEXT"
,
""
).
toString
());
update_isMavCommand
();
if
(
!
ui
->
isMavCommand
->
isChecked
())
{
ui
->
textLabel
->
setText
(
ui
->
editNameLabel
->
text
());
ui
->
nameLabel
->
setText
(
""
);
}
else
{
//MAV command text
ui
->
nameLabel
->
setText
(
ui
->
editNameLabel
->
text
());
ui
->
textLabel
->
setText
(
""
);
connect
(
uas
,
SIGNAL
(
textMessageReceived
(
int
,
int
,
int
,
QString
)),
this
,
SLOT
(
textMessageReceived
(
int
,
int
,
int
,
QString
)));
}
}
}
void
QGCTextLabel
::
enableText
(
int
num
)
void
QGCTextLabel
::
enableText
(
int
num
)
{
{
enabledNum
=
num
;
enabledNum
=
num
;
}
}
void
QGCTextLabel
::
setActiveUAS
(
UASInterface
*
uas
)
void
QGCTextLabel
::
setActiveUAS
(
UASInterface
*
uas
)
{
{
if
(
this
->
uas
)
this
->
uas
->
disconnect
(
this
);
this
->
uas
=
uas
;
this
->
uas
=
uas
;
update_isMavCommand
();
//Might need to update the signal connections
}
void
QGCTextLabel
::
update_isMavCommand
()
{
ui
->
textLabel
->
setText
(
""
);
if
(
!
ui
->
isMavCommand
->
isChecked
())
{
ui
->
nameLabel
->
setText
(
ui
->
editNameLabel
->
text
());
if
(
this
->
uas
)
disconnect
(
uas
,
SIGNAL
(
textMessageReceived
(
int
,
int
,
int
,
QString
)),
this
,
SLOT
(
textMessageReceived
(
int
,
int
,
int
,
QString
)));
if
(
ui
->
nameLabel
->
text
().
isEmpty
())
ui
->
nameLabel
->
setText
(
tr
(
"Text Label"
));
//Show something, so that we don't end up with just an empty label
}
else
{
//MAV command text
ui
->
nameLabel
->
setText
(
ui
->
editNameLabel
->
text
());
if
(
this
->
uas
)
connect
(
uas
,
SIGNAL
(
textMessageReceived
(
int
,
int
,
int
,
QString
)),
this
,
SLOT
(
textMessageReceived
(
int
,
int
,
int
,
QString
)));
}
}
}
src/ui/designer/QGCTextLabel.h
View file @
9143c8c5
...
@@ -27,6 +27,9 @@ public slots:
...
@@ -27,6 +27,9 @@ public slots:
void
readSettings
(
const
QString
&
pre
,
const
QVariantMap
&
settings
);
void
readSettings
(
const
QString
&
pre
,
const
QVariantMap
&
settings
);
void
textMessageReceived
(
int
uasid
,
int
componentId
,
int
severity
,
QString
message
);
void
textMessageReceived
(
int
uasid
,
int
componentId
,
int
severity
,
QString
message
);
private
slots
:
void
update_isMavCommand
();
private:
private:
int
enabledNum
;
int
enabledNum
;
Ui
::
QGCTextLabel
*
ui
;
Ui
::
QGCTextLabel
*
ui
;
...
...
src/ui/designer/QGCTextLabel.ui
View file @
9143c8c5
...
@@ -14,6 +14,19 @@
...
@@ -14,6 +14,19 @@
<string>
Form
</string>
<string>
Form
</string>
</property>
</property>
<layout
class=
"QVBoxLayout"
name=
"verticalLayout"
>
<layout
class=
"QVBoxLayout"
name=
"verticalLayout"
>
<item>
<widget
class=
"Line"
name=
"editLine1"
>
<property
name=
"minimumSize"
>
<size>
<width>
0
</width>
<height>
0
</height>
</size>
</property>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
</widget>
</item>
<item>
<item>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout"
>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout"
>
<item>
<item>
...
@@ -28,6 +41,9 @@
...
@@ -28,6 +41,9 @@
</item>
</item>
<item>
<item>
<widget
class=
"QCheckBox"
name=
"isMavCommand"
>
<widget
class=
"QCheckBox"
name=
"isMavCommand"
>
<property
name=
"toolTip"
>
<string>
This is only for advanced use, and allows a label to display the results of a Command Button.
</string>
</property>
<property
name=
"text"
>
<property
name=
"text"
>
<string>
Mav Command
</string>
<string>
Mav Command
</string>
</property>
</property>
...
@@ -35,19 +51,6 @@
...
@@ -35,19 +51,6 @@
</item>
</item>
</layout>
</layout>
</item>
</item>
<item>
<widget
class=
"Line"
name=
"editLine1"
>
<property
name=
"minimumSize"
>
<size>
<width>
0
</width>
<height>
0
</height>
</size>
</property>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
</widget>
</item>
<item>
<item>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_2"
>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_2"
>
<item>
<item>
...
@@ -59,7 +62,7 @@
...
@@ -59,7 +62,7 @@
</size>
</size>
</property>
</property>
<property
name=
"text"
>
<property
name=
"text"
>
<string>
Description
</string>
<string>
Text Label
</string>
</property>
</property>
<property
name=
"alignment"
>
<property
name=
"alignment"
>
<set>
Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
</set>
<set>
Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
</set>
...
@@ -69,7 +72,7 @@
...
@@ -69,7 +72,7 @@
<item>
<item>
<widget
class=
"QLabel"
name=
"textLabel"
>
<widget
class=
"QLabel"
name=
"textLabel"
>
<property
name=
"text"
>
<property
name=
"text"
>
<string>
TextLabel
</string>
<string>
mav result
</string>
</property>
</property>
</widget>
</widget>
</item>
</item>
...
@@ -99,6 +102,19 @@
...
@@ -99,6 +102,19 @@
</item>
</item>
</layout>
</layout>
</item>
</item>
<item>
<widget
class=
"Line"
name=
"editLine2"
>
<property
name=
"minimumSize"
>
<size>
<width>
0
</width>
<height>
0
</height>
</size>
</property>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
</widget>
</item>
</layout>
</layout>
</widget>
</widget>
<resources/>
<resources/>
...
@@ -119,5 +135,21 @@
...
@@ -119,5 +135,21 @@
</hint>
</hint>
</hints>
</hints>
</connection>
</connection>
<connection>
<sender>
editNameLabel
</sender>
<signal>
returnPressed()
</signal>
<receiver>
editFinishButton
</receiver>
<slot>
animateClick()
</slot>
<hints>
<hint
type=
"sourcelabel"
>
<x>
136
</x>
<y>
20
</y>
</hint>
<hint
type=
"destinationlabel"
>
<x>
498
</x>
<y>
86
</y>
</hint>
</hints>
</connection>
</connections>
</connections>
</ui>
</ui>
src/ui/designer/QGCToolWidget.cc
View file @
9143c8c5
...
@@ -296,7 +296,7 @@ void QGCToolWidget::loadSettings(QVariantMap& settings)
...
@@ -296,7 +296,7 @@ void QGCToolWidget::loadSettings(QVariantMap& settings)
else
if
(
type
==
"COMBO"
)
else
if
(
type
==
"COMBO"
)
{
{
item
=
new
QGCComboBox
(
this
);
item
=
new
QGCComboBox
(
this
);
//qDebug() << "CREATED
PARAM
COMBOBOX";
//qDebug() << "CREATED COMBOBOX";
}
}
if
(
item
)
if
(
item
)
{
{
...
@@ -482,6 +482,7 @@ void QGCToolWidget::contextMenuEvent (QContextMenuEvent* event)
...
@@ -482,6 +482,7 @@ void QGCToolWidget::contextMenuEvent (QContextMenuEvent* event)
QMenu
menu
(
this
);
QMenu
menu
(
this
);
menu
.
addAction
(
addParamAction
);
menu
.
addAction
(
addParamAction
);
menu
.
addAction
(
addCommandAction
);
menu
.
addAction
(
addCommandAction
);
menu
.
addAction
(
addLabelAction
);
menu
.
addSeparator
();
menu
.
addSeparator
();
menu
.
addAction
(
setTitleAction
);
menu
.
addAction
(
setTitleAction
);
menu
.
addAction
(
exportAction
);
menu
.
addAction
(
exportAction
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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