Commit f58af567 authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #5655 from bluerobotics/pr-brand-image

Allow user-selectable brand image
parents 54a181e8 ab798f87
......@@ -554,6 +554,7 @@ HEADERS += \
src/QtLocationPlugin/QMLControl/QGCMapEngineManager.h \
src/Settings/AppSettings.h \
src/Settings/AutoConnectSettings.h \
src/Settings/BrandImageSettings.h \
src/Settings/FlightMapSettings.h \
src/Settings/GuidedSettings.h \
src/Settings/RTKSettings.h \
......@@ -736,6 +737,7 @@ SOURCES += \
src/QtLocationPlugin/QMLControl/QGCMapEngineManager.cc \
src/Settings/AppSettings.cc \
src/Settings/AutoConnectSettings.cc \
src/Settings/BrandImageSettings.cc \
src/Settings/FlightMapSettings.cc \
src/Settings/GuidedSettings.cc \
src/Settings/RTKSettings.cc \
......
......@@ -222,6 +222,7 @@
<file alias="Vehicle/VibrationFact.json">src/Vehicle/VibrationFact.json</file>
<file alias="Vehicle/TemperatureFact.json">src/Vehicle/TemperatureFact.json</file>
<file alias="Vehicle/SubmarineFact.json">src/Vehicle/SubmarineFact.json</file>
<file alias="BrandImage.SettingsGroup.json">src/Settings/BrandImage.SettingsGroup.json</file>
</qresource>
<qresource prefix="/MockLink">
<file alias="APMArduCopterMockLink.params">src/comm/APMArduCopterMockLink.params</file>
......
......@@ -143,6 +143,20 @@
"type": "string",
"defaultValue": ""
},
{
"name": "UserBrandImageIndoor",
"shortDescription": "User-selected brand image",
"longDescription": "Location in file system of user-selected brand image (indoor)",
"type": "string",
"defaultValue": ""
},
{
"name": "UserBrandImageOutdoor",
"shortDescription": "User-selected brand image",
"longDescription": "Location in file system of user-selected brand image (outdoor)",
"type": "string",
"defaultValue": ""
},
{
"name": "MapboxToken",
"shortDescription": "Access token to Mapbox maps",
......
[
{
"name": "UserBrandImageIndoor",
"shortDescription": "User-selected brand image",
"longDescription": "Location in file system of user-selected brand image (indoor)",
"type": "string",
"defaultValue": ""
},
{
"name": "UserBrandImageOutdoor",
"shortDescription": "User-selected brand image",
"longDescription": "Location in file system of user-selected brand image (outdoor)",
"type": "string",
"defaultValue": ""
}
]
/****************************************************************************
*
* (c) 2009-2017 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
#include "BrandImageSettings.h"
#include <QQmlEngine>
#include <QtQml>
const char* BrandImageSettings::brandImageSettingsGroupName = "BrandImage";
const char* BrandImageSettings::userBrandImageIndoorName = "UserBrandImageIndoor";
const char* BrandImageSettings::userBrandImageOutdoorName = "UserBrandImageOutdoor";
BrandImageSettings::BrandImageSettings(QObject* parent)
: SettingsGroup(brandImageSettingsGroupName, QString() /* root settings group */, parent)
, _userBrandImageIndoorFact(NULL)
, _userBrandImageOutdoorFact(NULL)
{
QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
qmlRegisterUncreatableType<BrandImageSettings>("QGroundControl.SettingsManager", 1, 0, "BrandImageSettings", "Reference only");
}
Fact* BrandImageSettings::userBrandImageIndoor(void)
{
if (!_userBrandImageIndoorFact) {
_userBrandImageIndoorFact = _createSettingsFact(userBrandImageIndoorName);
}
return _userBrandImageIndoorFact;
}
Fact* BrandImageSettings::userBrandImageOutdoor(void)
{
if (!_userBrandImageOutdoorFact) {
_userBrandImageOutdoorFact = _createSettingsFact(userBrandImageOutdoorName);
}
return _userBrandImageOutdoorFact;
}
/****************************************************************************
*
* (c) 2009-2017 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
#ifndef BrandImageSettings_H
#define BrandImageSettings_H
#include "SettingsGroup.h"
class BrandImageSettings : public SettingsGroup
{
Q_OBJECT
public:
BrandImageSettings(QObject* parent = NULL);
Q_PROPERTY(Fact* userBrandImageIndoor READ userBrandImageIndoor CONSTANT)
Q_PROPERTY(Fact* userBrandImageOutdoor READ userBrandImageOutdoor CONSTANT)
Fact* userBrandImageIndoor (void);
Fact* userBrandImageOutdoor (void);
static const char* brandImageSettingsGroupName;
static const char* userBrandImageIndoorName;
static const char* userBrandImageOutdoorName;
private:
SettingsFact* _userBrandImageIndoorFact;
SettingsFact* _userBrandImageOutdoorFact;
};
#endif
......@@ -21,6 +21,7 @@ SettingsManager::SettingsManager(QGCApplication* app, QGCToolbox* toolbox)
, _flightMapSettings (NULL)
, _rtkSettings (NULL)
, _guidedSettings (NULL)
, _brandImageSettings (NULL)
{
}
......@@ -38,4 +39,5 @@ void SettingsManager::setToolbox(QGCToolbox *toolbox)
_flightMapSettings = new FlightMapSettings(this);
_rtkSettings = new RTKSettings(this);
_guidedSettings = new GuidedSettings(this);
_brandImageSettings = new BrandImageSettings(this);
}
......@@ -21,6 +21,7 @@
#include "FlightMapSettings.h"
#include "RTKSettings.h"
#include "GuidedSettings.h"
#include "BrandImageSettings.h"
#include <QVariantList>
......@@ -39,6 +40,7 @@ public:
Q_PROPERTY(QObject* flightMapSettings READ flightMapSettings CONSTANT)
Q_PROPERTY(QObject* rtkSettings READ rtkSettings CONSTANT)
Q_PROPERTY(QObject* guidedSettings READ guidedSettings CONSTANT)
Q_PROPERTY(QObject* brandImageSettings READ brandImageSettings CONSTANT)
// Override from QGCTool
virtual void setToolbox(QGCToolbox *toolbox);
......@@ -50,6 +52,7 @@ public:
FlightMapSettings* flightMapSettings (void) { return _flightMapSettings; }
RTKSettings* rtkSettings (void) { return _rtkSettings; }
GuidedSettings* guidedSettings (void) { return _guidedSettings; }
BrandImageSettings* brandImageSettings (void) { return _brandImageSettings; }
private:
AppSettings* _appSettings;
......@@ -59,6 +62,7 @@ private:
FlightMapSettings* _flightMapSettings;
RTKSettings* _rtkSettings;
GuidedSettings* _guidedSettings;
BrandImageSettings* _brandImageSettings;
};
#endif
......@@ -35,6 +35,8 @@ QGCView {
property Fact _percentRemainingAnnounce: QGroundControl.settingsManager.appSettings.batteryPercentRemainingAnnounce
property Fact _savePath: QGroundControl.settingsManager.appSettings.savePath
property Fact _appFontPointSize: QGroundControl.settingsManager.appSettings.appFontPointSize
property Fact _userBrandImageIndoor: QGroundControl.settingsManager.brandImageSettings.userBrandImageIndoor
property Fact _userBrandImageOutdoor: QGroundControl.settingsManager.brandImageSettings.userBrandImageOutdoor
property real _labelWidth: ScreenTools.defaultFontPixelWidth * 15
property real _editFieldWidth: ScreenTools.defaultFontPixelWidth * 30
property Fact _mapProvider: QGroundControl.settingsManager.flightMapSettings.mapProvider
......@@ -656,6 +658,112 @@ QGCView {
}
}
//-----------------------------------------------------------------
//-- Custom Brand Image
Item {
width: _qgcView.width * 0.8
height: userBrandImageLabel.height
anchors.margins: ScreenTools.defaultFontPixelWidth
anchors.horizontalCenter: parent.horizontalCenter
visible: QGroundControl.settingsManager.brandImageSettings.visible && !ScreenTools.isMobile
QGCLabel {
id: userBrandImageLabel
text: qsTr("Brand Image")
font.family: ScreenTools.demiboldFontFamily
}
}
Rectangle {
height: userBrandImageCol.height + (ScreenTools.defaultFontPixelHeight * 2)
width: _qgcView.width * 0.8
color: qgcPal.windowShade
anchors.margins: ScreenTools.defaultFontPixelWidth
anchors.horizontalCenter: parent.horizontalCenter
visible: QGroundControl.settingsManager.brandImageSettings.visible && !ScreenTools.isMobile
Column {
id: userBrandImageCol
spacing: ScreenTools.defaultFontPixelWidth
anchors.centerIn: parent
Row {
spacing: ScreenTools.defaultFontPixelWidth
visible: _userBrandImageIndoor.visible
QGCLabel {
anchors.baseline: userBrandImageIndoorBrowse.baseline
width: _labelWidth*1.5
text: qsTr("Indoor Brand Image Path:")
}
QGCTextField {
anchors.baseline: userBrandImageIndoorBrowse.baseline
readOnly: true
width: _editFieldWidth
text: _userBrandImageIndoor.valueString.replace("file:///","")
}
QGCButton {
id: userBrandImageIndoorBrowse
text: "Browse"
onClicked: userBrandImageIndoorBrowseDialog.openForLoad()
QGCFileDialog {
id: userBrandImageIndoorBrowseDialog
qgcView: _qgcView
title: qsTr("Choose custom brand image file:")
folder: _userBrandImageIndoor.rawValue.replace("file:///","")
selectExisting: true
selectFolder: false
onAcceptedForLoad: _userBrandImageIndoor.rawValue = "file:///" + file
}
}
}
Row {
spacing: ScreenTools.defaultFontPixelWidth
visible: _userBrandImageOutdoor.visible
QGCLabel {
anchors.baseline: userBrandImageOutdoorBrowse.baseline
width: _labelWidth*1.5
text: qsTr("Outdoor Brand Image Path:")
}
QGCTextField {
anchors.baseline: userBrandImageOutdoorBrowse.baseline
readOnly: true
width: _editFieldWidth
text: _userBrandImageOutdoor.valueString.replace("file:///","")
}
QGCButton {
id: userBrandImageOutdoorBrowse
text: "Browse"
onClicked: userBrandImageOutdoorBrowseDialog.openForLoad()
QGCFileDialog {
id: userBrandImageOutdoorBrowseDialog
qgcView: _qgcView
title: qsTr("Choose custom brand image file:")
folder: _userBrandImageOutdoor.rawValue.replace("file:///","")
selectExisting: true
selectFolder: false
onAcceptedForLoad: _userBrandImageOutdoor.rawValue = "file:///" + file
}
}
}
Row {
spacing: ScreenTools.defaultFontPixelWidth
visible: _userBrandImageIndoor.visible
QGCButton {
id: userBrandImageReset
text: "Reset Default Brand Image"
onClicked: {
_userBrandImageIndoor.rawValue = ""
_userBrandImageOutdoor.rawValue = ""
}
}
}
}
}
QGCLabel {
anchors.horizontalCenter: parent.horizontalCenter
text: qsTr("%1 Version: %2").arg(QGroundControl.appName).arg(QGroundControl.qgcVersion)
......
......@@ -92,11 +92,30 @@ Item {
visible: x > indicatorRow.width && !_communicationLost
fillMode: Image.PreserveAspectFit
source: _outdoorPalette ? _brandImageOutdoor : _brandImageIndoor
mipmap: true
property bool _outdoorPalette: qgcPal.globalTheme === QGCPalette.Light
property bool _corePluginBranding: QGroundControl.corePlugin.brandImageIndoor.length != 0
property string _brandImageIndoor: _corePluginBranding ? QGroundControl.corePlugin.brandImageIndoor : (_activeVehicle ? _activeVehicle.brandImageIndoor : "")
property string _brandImageOutdoor: _corePluginBranding ? QGroundControl.corePlugin.brandImageOutdoor : (_activeVehicle ? _activeVehicle.brandImageOutdoor : "")
property string _userBrandImageIndoor: QGroundControl.settingsManager.brandImageSettings.userBrandImageIndoor.value
property string _userBrandImageOutdoor: QGroundControl.settingsManager.brandImageSettings.userBrandImageOutdoor.value
property bool _userBrandingIndoor: _userBrandImageIndoor.length != 0
property bool _userBrandingOutdoor: _userBrandImageOutdoor.length != 0
property string _brandImageIndoor: _userBrandingIndoor ?
_userBrandImageIndoor : (_userBrandingOutdoor ?
_userBrandImageOutdoor : (_corePluginBranding ?
QGroundControl.corePlugin.brandImageIndoor : (_activeVehicle ?
_activeVehicle.brandImageIndoor : ""
)
)
)
property string _brandImageOutdoor: _userBrandingOutdoor ?
_userBrandImageOutdoor : (_userBrandingIndoor ?
_userBrandImageIndoor : (_corePluginBranding ?
QGroundControl.corePlugin.brandImageOutdoor : (_activeVehicle ?
_activeVehicle.brandImageOutdoor : ""
)
)
)
}
Row {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment