From 7f35db3338eb9bdb4f6b0fab1c9e6f314e3641b1 Mon Sep 17 00:00:00 2001 From: Gus Grubba Date: Fri, 26 Jan 2018 00:01:26 -0500 Subject: [PATCH] Ruleset picker container Added an "unknown" weather icon for when I get "valid" data and no icon --- src/Airmap/AirMapManager.cc | 4 +-- src/Airmap/AirMapWeatherInformation.cc | 6 +++- src/Airmap/AirspaceControl.qml | 38 ++++++++++++++++++++- src/Airmap/AirspaceWeather.qml | 17 ++++----- src/Airmap/airmap.qrc | 2 ++ src/Airmap/images/right-arrow.svg | 9 +++++ src/Airmap/images/weather-icons/unknown.svg | 14 ++++++++ 7 files changed, 78 insertions(+), 12 deletions(-) create mode 100644 src/Airmap/images/right-arrow.svg create mode 100644 src/Airmap/images/weather-icons/unknown.svg diff --git a/src/Airmap/AirMapManager.cc b/src/Airmap/AirMapManager.cc index 7b41ea3da..9a1cafdf5 100644 --- a/src/Airmap/AirMapManager.cc +++ b/src/Airmap/AirMapManager.cc @@ -35,8 +35,8 @@ AirMapManager::AirMapManager(QGCApplication* app, QGCToolbox* toolbox) { _logger = std::make_shared(); qt::register_types(); // TODO: still needed?s - _logger->logging_category().setEnabled(QtDebugMsg, true); - _logger->logging_category().setEnabled(QtInfoMsg, true); + _logger->logging_category().setEnabled(QtDebugMsg, false); + _logger->logging_category().setEnabled(QtInfoMsg, false); _logger->logging_category().setEnabled(QtWarningMsg, true); _dispatchingLogger = std::make_shared(_logger); connect(&_shared, &AirMapSharedState::error, this, &AirMapManager::_error); diff --git a/src/Airmap/AirMapWeatherInformation.cc b/src/Airmap/AirMapWeatherInformation.cc index 90f7e77d4..756ad2bcb 100644 --- a/src/Airmap/AirMapWeatherInformation.cc +++ b/src/Airmap/AirMapWeatherInformation.cc @@ -57,7 +57,11 @@ AirMapWeatherInformation::_requestWeatherUpdate(const QGeoCoordinate& coordinate if (result) { const Status::Weather& weather = result.value().weather; _valid = true; - _icon = QStringLiteral("qrc:/airmapweather/") + QString::fromStdString(weather.icon) + QStringLiteral(".svg"); + if(weather.icon.empty()) { + _icon = QStringLiteral("qrc:/airmapweather/unknown.svg"); + } else { + _icon = QStringLiteral("qrc:/airmapweather/") + QString::fromStdString(weather.icon) + QStringLiteral(".svg"); + } qCDebug(AirMapManagerLog) << "Weather Info: " << _valid << "Icon:" << QString::fromStdString(weather.icon) << "Condition:" << QString::fromStdString(weather.condition) << "Temp:" << weather.temperature; } else { _valid = false; diff --git a/src/Airmap/AirspaceControl.qml b/src/Airmap/AirspaceControl.qml index 5446cf6d3..92ff9ba4e 100644 --- a/src/Airmap/AirspaceControl.qml +++ b/src/Airmap/AirspaceControl.qml @@ -228,6 +228,7 @@ Item { color: _colorGray anchors.verticalCenter: parent.verticalCenter QGCColoredImage { + id: pencilIcon width: height height: parent.height * 0.5 sourceSize.height: height @@ -301,6 +302,7 @@ Item { color: Qt.rgba(0,0,0,0.1) MouseArea { anchors.fill: parent + onWheel: { wheel.accepted = true; } onClicked: { mainWindow.enableToolbar() rootLoader.sourceComponent = null @@ -325,11 +327,12 @@ Item { } Rectangle { id: ruleSelectorRect + x: 0 + y: 0 color: qgcPal.window width: rulesCol.width + ScreenTools.defaultFontPixelWidth height: rulesCol.height + ScreenTools.defaultFontPixelHeight radius: ScreenTools.defaultFontPixelWidth - anchors.centerIn: parent Column { id: rulesCol spacing: ScreenTools.defaultFontPixelHeight * 0.5 @@ -388,8 +391,41 @@ Item { } } } + //-- Arrow + QGCColoredImage { + id: arrowIconShadow + anchors.fill: arrowIcon + sourceSize.height: height + source: "qrc:/airmap/right-arrow.svg" + color: qgcPal.window + visible: false + } + DropShadow { + anchors.fill: arrowIconShadow + visible: ruleSelectorRect.visible + horizontalOffset: 4 + verticalOffset: 4 + radius: 32.0 + samples: 65 + color: Qt.rgba(0,0,0,0.75) + source: arrowIconShadow + } + QGCColoredImage { + id: arrowIcon + width: height + height: ScreenTools.defaultFontPixelHeight * 2 + sourceSize.height: height + source: "qrc:/airmap/right-arrow.svg" + color: ruleSelectorRect.color + anchors.left: ruleSelectorRect.right + anchors.top: ruleSelectorRect.top + anchors.topMargin: (ScreenTools.defaultFontPixelHeight * 4) - (height * 0.5) + (pencilIcon.height * 0.5) + } Component.onCompleted: { mainWindow.disableToolbar() + var target = mainWindow.mapFromItem(pencilIcon, 0, 0) + ruleSelectorRect.x = target.x - ruleSelectorRect.width - (ScreenTools.defaultFontPixelWidth * 7) + ruleSelectorRect.y = target.y - (ScreenTools.defaultFontPixelHeight * 4) } } } diff --git a/src/Airmap/AirspaceWeather.qml b/src/Airmap/AirspaceWeather.qml index f173f83c4..3e4d60f7f 100644 --- a/src/Airmap/AirspaceWeather.qml +++ b/src/Airmap/AirspaceWeather.qml @@ -12,30 +12,31 @@ import QGroundControl.Airmap 1.0 import QGroundControl.SettingsManager 1.0 Item { - height: _activeVehicle && _activeVehicle.airspaceController.hasWeather ? weatherRow.height : 0 - width: _activeVehicle && _activeVehicle.airspaceController.hasWeather ? weatherRow.width : 0 + height: _valid ? weatherRow.height : 0 + width: _valid ? weatherRow.width : 0 property var iconHeight: ScreenTools.defaultFontPixelWidth * 4 + property bool _valid: _activeVehicle && _activeVehicle.airspaceController.weatherInfo.valid property color _colorWhite: "#ffffff" property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle property bool _celcius: QGroundControl.settingsManager.unitsSettings.temperatureUnits.rawValue === UnitsSettings.TemperatureUnitsCelsius - property int _tempC: _activeVehicle && _activeVehicle.airspaceController.weatherInfo.valid ? _activeVehicle.airspaceController.weatherInfo.temperature : 0 + property int _tempC: _valid ? _activeVehicle.airspaceController.weatherInfo.temperature : 0 property string _tempS: (_celcius ? _tempC : _tempC * 1.8 + 32).toFixed(0) + (_celcius ? "°C" : "°F") Row { - id: weatherRow - spacing: ScreenTools.defaultFontPixelHeight * 0.5 + id: weatherRow + spacing: ScreenTools.defaultFontPixelHeight * 0.5 QGCColoredImage { width: height height: iconHeight sourceSize.height: height - source: _activeVehicle && _activeVehicle.airspaceController.weatherInfo.valid ? _activeVehicle.airspaceController.weatherInfo.icon : "" + source: _valid ? _activeVehicle.airspaceController.weatherInfo.icon : "" color: _colorWhite - visible: _activeVehicle && _activeVehicle.airspaceController.weatherInfo.valid + visible: _valid anchors.verticalCenter: parent.verticalCenter } QGCLabel { text: _tempS color: _colorWhite - visible: _activeVehicle && _activeVehicle.airspaceController.weatherInfo.valid + visible: _valid anchors.verticalCenter: parent.verticalCenter } } diff --git a/src/Airmap/airmap.qrc b/src/Airmap/airmap.qrc index a41b7e271..2fe095857 100644 --- a/src/Airmap/airmap.qrc +++ b/src/Airmap/airmap.qrc @@ -14,6 +14,7 @@ images/colapse.svg images/expand.svg images/pencil.svg + images/right-arrow.svg images/weather-icons/clear.svg @@ -45,6 +46,7 @@ images/weather-icons/sunny.svg images/weather-icons/thunderstorm.svg images/weather-icons/tornado.svg + images/weather-icons/unknown.svg images/weather-icons/windy.svg diff --git a/src/Airmap/images/right-arrow.svg b/src/Airmap/images/right-arrow.svg new file mode 100644 index 000000000..811093e67 --- /dev/null +++ b/src/Airmap/images/right-arrow.svg @@ -0,0 +1,9 @@ + + + + + + diff --git a/src/Airmap/images/weather-icons/unknown.svg b/src/Airmap/images/weather-icons/unknown.svg new file mode 100644 index 000000000..4533afdb1 --- /dev/null +++ b/src/Airmap/images/weather-icons/unknown.svg @@ -0,0 +1,14 @@ + + + +sunny +Created with Sketch. + + + + -- 2.22.0