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
709a126f
Commit
709a126f
authored
May 06, 2016
by
dogmaphobic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow users to change base UI font point size.
parent
654a4d6b
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
153 additions
and
40 deletions
+153
-40
QGroundControlQmlGlobal.cc
src/QmlControls/QGroundControlQmlGlobal.cc
+15
-2
QGroundControlQmlGlobal.h
src/QmlControls/QGroundControlQmlGlobal.h
+9
-4
ScreenTools.qml
src/QmlControls/ScreenTools.qml
+54
-29
SetupView.qml
src/VehicleSetup/SetupView.qml
+11
-5
GeneralSettings.qml
src/ui/preferences/GeneralSettings.qml
+64
-0
No files found.
src/QmlControls/QGroundControlQmlGlobal.cc
View file @
709a126f
...
...
@@ -38,6 +38,7 @@ SettingsFact* QGroundControlQmlGlobal::_speedUnitsFact =
FactMetaData
*
QGroundControlQmlGlobal
::
_speedUnitsMetaData
=
NULL
;
const
char
*
QGroundControlQmlGlobal
::
_virtualTabletJoystickKey
=
"VirtualTabletJoystick"
;
const
char
*
QGroundControlQmlGlobal
::
_baseFontPointSizeKey
=
"BaseFontPointSize"
;
QGroundControlQmlGlobal
::
QGroundControlQmlGlobal
(
QGCApplication
*
app
)
:
QGCTool
(
app
)
...
...
@@ -48,9 +49,11 @@ QGroundControlQmlGlobal::QGroundControlQmlGlobal(QGCApplication* app)
,
_multiVehicleManager
(
NULL
)
,
_mapEngineManager
(
NULL
)
,
_virtualTabletJoystick
(
false
)
,
_baseFontPointSize
(
0.0
)
{
QSettings
settings
;
_virtualTabletJoystick
=
settings
.
value
(
_virtualTabletJoystickKey
,
false
).
toBool
();
_virtualTabletJoystick
=
settings
.
value
(
_virtualTabletJoystickKey
,
false
).
toBool
();
_baseFontPointSize
=
settings
.
value
(
_baseFontPointSizeKey
,
0.0
).
toDouble
();
// We clear the parent on this object since we run into shutdown problems caused by hybrid qml app. Instead we let it leak on shutdown.
setParent
(
NULL
);
...
...
@@ -207,6 +210,16 @@ void QGroundControlQmlGlobal::setVirtualTabletJoystick(bool enabled)
}
}
void
QGroundControlQmlGlobal
::
setBaseFontPointSize
(
qreal
size
)
{
if
(
size
>=
6.0
&&
size
<=
48.0
)
{
QSettings
settings
;
settings
.
setValue
(
_baseFontPointSizeKey
,
size
);
_baseFontPointSize
=
size
;
emit
baseFontPointSizeChanged
(
size
);
}
}
bool
QGroundControlQmlGlobal
::
experimentalSurvey
(
void
)
const
{
QSettings
settings
;
...
...
src/QmlControls/QGroundControlQmlGlobal.h
View file @
709a126f
...
...
@@ -86,6 +86,7 @@ public:
Q_PROPERTY
(
bool
isSaveLogPrompt
READ
isSaveLogPrompt
WRITE
setIsSaveLogPrompt
NOTIFY
isSaveLogPromptChanged
)
Q_PROPERTY
(
bool
isSaveLogPromptNotArmed
READ
isSaveLogPromptNotArmed
WRITE
setIsSaveLogPromptNotArmed
NOTIFY
isSaveLogPromptNotArmedChanged
)
Q_PROPERTY
(
bool
virtualTabletJoystick
READ
virtualTabletJoystick
WRITE
setVirtualTabletJoystick
NOTIFY
virtualTabletJoystickChanged
)
Q_PROPERTY
(
qreal
baseFontPointSize
READ
baseFontPointSize
WRITE
setBaseFontPointSize
NOTIFY
baseFontPointSizeChanged
)
// MavLink Protocol
Q_PROPERTY
(
bool
isMultiplexingEnabled
READ
isMultiplexingEnabled
WRITE
setIsMultiplexingEnabled
NOTIFY
isMultiplexingEnabledChanged
)
...
...
@@ -151,6 +152,7 @@ public:
bool
isSaveLogPrompt
()
{
return
_app
->
promptFlightDataSave
();
}
bool
isSaveLogPromptNotArmed
()
{
return
_app
->
promptFlightDataSaveNotArmed
();
}
bool
virtualTabletJoystick
()
{
return
_virtualTabletJoystick
;
}
qreal
baseFontPointSize
()
{
return
_baseFontPointSize
;
}
bool
isMultiplexingEnabled
()
{
return
_toolbox
->
mavlinkProtocol
()
->
multiplexingEnabled
();
}
bool
isVersionCheckEnabled
()
{
return
_toolbox
->
mavlinkProtocol
()
->
versionCheckEnabled
();
}
...
...
@@ -170,6 +172,7 @@ public:
void
setIsSaveLogPrompt
(
bool
prompt
);
void
setIsSaveLogPromptNotArmed
(
bool
prompt
);
void
setVirtualTabletJoystick
(
bool
enabled
);
void
setBaseFontPointSize
(
qreal
size
);
void
setIsMultiplexingEnabled
(
bool
enable
);
void
setIsVersionCheckEnabled
(
bool
enable
);
...
...
@@ -191,6 +194,7 @@ signals:
void
isSaveLogPromptChanged
(
bool
prompt
);
void
isSaveLogPromptNotArmedChanged
(
bool
prompt
);
void
virtualTabletJoystickChanged
(
bool
enabled
);
void
baseFontPointSizeChanged
(
qreal
size
);
void
isMultiplexingEnabledChanged
(
bool
enabled
);
void
isVersionCheckEnabledChanged
(
bool
enabled
);
void
mavlinkSystemIDChanged
(
int
id
);
...
...
@@ -208,7 +212,7 @@ private:
QGCPositionManager
*
_qgcPositionManager
;
bool
_virtualTabletJoystick
;
qreal
_baseFontPointSize
;
QGeoCoordinate
_flightMapPosition
;
double
_flightMapZoom
;
...
...
@@ -221,6 +225,7 @@ private:
static
FactMetaData
*
_speedUnitsMetaData
;
static
const
char
*
_virtualTabletJoystickKey
;
static
const
char
*
_baseFontPointSizeKey
;
};
#endif
src/QmlControls/ScreenTools.qml
View file @
709a126f
...
...
@@ -4,6 +4,7 @@ import QtQuick 2.4
import
QtQuick
.
Controls
1.2
import
QtQuick
.
Window
2.2
import
QGroundControl
1.0
import
QGroundControl
.
ScreenToolsController
1.0
Item
{
...
...
@@ -35,6 +36,17 @@ Item {
readonly
property
string
normalFontFamily
:
"
opensans
"
readonly
property
string
demiboldFontFamily
:
"
opensans-demibold
"
/* This mostly works but for some reason, reflowWidths() in SetupView doesn't change size.
I've disabled (in release builds) until I figure out why. Changes require a restart for now.
*/
Connections
{
target
:
QGroundControl
onBaseFontPointSizeChanged
:
{
if
(
ScreenToolsController
.
isDebug
)
setBasePointSize
(
QGroundControl
.
baseFontPointSize
)
}
}
function
mouseX
()
{
return
ScreenToolsController
.
mouseX
()
}
...
...
@@ -43,48 +55,61 @@ Item {
return
ScreenToolsController
.
mouseY
()
}
function
setBasePointSize
(
pointSize
)
{
_textMeasure
.
font
.
pointSize
=
pointSize
defaultFontPointSize
=
pointSize
defaultFontPixelHeight
=
_textMeasure
.
fontHeight
defaultFontPixelWidth
=
_textMeasure
.
fontWidth
smallFontPointSize
=
defaultFontPointSize
*
_screenTools
.
smallFontPointRatio
mediumFontPointSize
=
defaultFontPointSize
*
_screenTools
.
mediumFontPointRatio
largeFontPointSize
=
defaultFontPointSize
*
_screenTools
.
largeFontPointRatio
}
Text
{
id
:
_defaultFont
text
:
"
X
"
property
real
fontHeight
:
contentHeight
}
Text
{
id
:
_textMeasure
text
:
"
X
"
font.family
:
normalFontFamily
font.pointSize
:
{
property
real
fontWidth
:
contentWidth
property
real
fontHeight
:
contentHeight
Component.onCompleted
:
{
var
baseSize
=
QGroundControl
.
baseFontPointSize
;
//-- If this is the first time (not saved in settings)
if
(
baseSize
<
6
||
baseSize
>
48
)
{
//-- Init base size base on the platform
if
(
ScreenToolsController
.
isMobile
)
{
// Small Devices
if
((
Screen
.
width
/
Screen
.
pixelDensity
)
<
120
)
{
return
11
;
if
((
Screen
.
width
/
Screen
.
pixelDensity
)
<
120
)
baseSize
=
11
;
// iOS
}
else
if
(
ScreenToolsController
.
isiOS
)
{
return
13
;
else
if
(
ScreenToolsController
.
isiOS
)
baseSize
=
13
;
// Android
}
else
{
return
14
;
}
else
baseSize
=
14
;
}
else
{
//-- Mac OS
if
(
ScreenToolsController
.
isMacOS
)
return
_defaultFont
.
font
.
pointSize
-
1
baseSize
=
_defaultFont
.
font
.
pointSize
;
//-- Linux
if
(
ScreenToolsController
.
isLinux
)
return
_defaultFont
.
font
.
pointSize
-
3.25
else
if
(
ScreenToolsController
.
isLinux
)
baseSize
=
_defaultFont
.
font
.
pointSize
-
3.25
;
//-- Windows
else
return
_defaultFont
.
font
.
pointSize
baseSize
=
_defaultFont
.
font
.
pointSize
;
}
QGroundControl
.
baseFontPointSize
=
baseSize
//-- Release build doesn't get signal
if
(
!
ScreenToolsController
.
isDebug
)
_screenTools
.
setBasePointSize
(
baseSize
);
}
else
{
//-- Set size saved in settings
_screenTools
.
setBasePointSize
(
baseSize
);
}
property
real
fontWidth
:
contentWidth
property
real
fontHeight
:
contentHeight
Component
.
onCompleted
:
{
defaultFontPointSize
=
_textMeasure
.
font
.
pointSize
defaultFontPixelHeight
=
_textMeasure
.
fontHeight
defaultFontPixelWidth
=
_textMeasure
.
fontWidth
smallFontPointSize
=
defaultFontPointSize
*
_screenTools
.
smallFontPointRatio
mediumFontPointSize
=
defaultFontPointSize
*
_screenTools
.
mediumFontPointRatio
largeFontPointSize
=
defaultFontPointSize
*
_screenTools
.
largeFontPointRatio
}
}
}
src/VehicleSetup/SetupView.qml
View file @
709a126f
...
...
@@ -238,16 +238,22 @@ Rectangle {
Connections
{
target
:
componentRepeater
onModelChanged
:
buttonColumn
.
reflowWidths
()
}
// I don't know why this does not work
Connections
{
target
:
QGroundControl
onBaseFontPointSizeChanged
:
buttonColumn
.
reflowWidths
()
}
function
reflowWidths
()
{
for
(
var
i
=
0
;
i
<
children
.
length
;
i
++
)
{
_maxButtonWidth
=
Math
.
max
(
_maxButtonWidth
,
children
[
i
].
width
)
buttonColumn
.
_maxButtonWidth
=
0
for
(
var
i
=
0
;
i
<
children
.
length
;
i
++
)
{
buttonColumn
.
_maxButtonWidth
=
Math
.
max
(
buttonColumn
.
_maxButtonWidth
,
children
[
i
].
width
)
}
for
(
var
i
=
0
;
i
<
children
.
length
;
i
++
)
{
children
[
i
].
width
=
_maxButtonWidth
for
(
var
j
=
0
;
j
<
children
.
length
;
j
++
)
{
children
[
j
].
width
=
buttonColumn
.
_maxButtonWidth
}
}
...
...
src/ui/preferences/GeneralSettings.qml
View file @
709a126f
...
...
@@ -71,6 +71,70 @@ Rectangle {
width
:
parent
.
width
}
//-----------------------------------------------------------------
//-- Base UI Font Point Size
Row
{
spacing
:
ScreenTools
.
defaultFontPixelWidth
QGCLabel
{
width
:
_firstLabelWidth
text
:
qsTr
(
"
Base UI font size:
"
)
anchors.verticalCenter
:
parent
.
verticalCenter
}
Row
{
anchors.verticalCenter
:
parent
.
verticalCenter
Rectangle
{
width
:
baseFontEdit
.
height
height
:
width
color
:
qgcPal
.
button
QGCLabel
{
text
:
"
-
"
anchors.centerIn
:
parent
}
MouseArea
{
anchors.fill
:
parent
onClicked
:
{
if
(
ScreenTools
.
defaultFontPointSize
>
6
)
QGroundControl
.
baseFontPointSize
=
QGroundControl
.
baseFontPointSize
-
1
}
}
}
QGCTextField
{
id
:
baseFontEdit
width
:
_editFieldWidth
-
(
height
*
2
)
text
:
QGroundControl
.
baseFontPointSize
showUnits
:
true
unitsLabel
:
"
pt
"
maximumLength
:
6
validator
:
DoubleValidator
{
bottom
:
6.0
;
top
:
48.0
;
decimals
:
2
;}
onEditingFinished
:
{
var
point
=
parseFloat
(
text
)
if
(
point
>=
6.0
&&
point
<=
48.0
)
QGroundControl
.
baseFontPointSize
=
point
;
}
}
Rectangle
{
width
:
baseFontEdit
.
height
height
:
width
color
:
qgcPal
.
button
QGCLabel
{
text
:
"
+
"
anchors.centerIn
:
parent
}
MouseArea
{
anchors.fill
:
parent
onClicked
:
{
if
(
ScreenTools
.
defaultFontPointSize
<
49
)
QGroundControl
.
baseFontPointSize
=
QGroundControl
.
baseFontPointSize
+
1
}
}
}
}
QGCLabel
{
anchors.verticalCenter
:
parent
.
verticalCenter
text
:
qsTr
(
"
(requires reboot to take affect)
"
)
}
}
//-----------------------------------------------------------------
//-- Units
...
...
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