diff --git a/InstrumentValueIcons.qrc b/InstrumentValueIcons.qrc deleted file mode 100644 index 34c88257a17c63bbb1c26633918421ac5eb5e7c9..0000000000000000000000000000000000000000 --- a/InstrumentValueIcons.qrc +++ /dev/null @@ -1,301 +0,0 @@ - - - resources/InstrumentValueIcons/clipboard.svg - resources/InstrumentValueIcons/credit-card.svg - resources/InstrumentValueIcons/bookmark copy 2.svg - resources/InstrumentValueIcons/library.svg - resources/InstrumentValueIcons/mouse.svg - resources/InstrumentValueIcons/printer.svg - resources/InstrumentValueIcons/thumbs-up.svg - resources/InstrumentValueIcons/arrow-thin-up.svg - resources/InstrumentValueIcons/pause-outline.svg - resources/InstrumentValueIcons/music-artist.svg - resources/InstrumentValueIcons/location-park.svg - resources/InstrumentValueIcons/pen-tool.svg - resources/InstrumentValueIcons/color-palette.svg - resources/InstrumentValueIcons/announcement.svg - resources/InstrumentValueIcons/inbox-check.svg - resources/InstrumentValueIcons/radio.svg - resources/InstrumentValueIcons/close-solid.svg - resources/InstrumentValueIcons/inbox.svg - resources/InstrumentValueIcons/user-add.svg - resources/InstrumentValueIcons/text-box.svg - resources/InstrumentValueIcons/queue.svg - resources/InstrumentValueIcons/minus-outline.svg - resources/InstrumentValueIcons/user-solid-square.svg - resources/InstrumentValueIcons/list-bullet.svg - resources/InstrumentValueIcons/indent-decrease.svg - resources/InstrumentValueIcons/yin-yang.svg - resources/InstrumentValueIcons/share-alt.svg - resources/InstrumentValueIcons/battery-full.svg - resources/InstrumentValueIcons/folder-outline.svg - resources/InstrumentValueIcons/bookmark copy 3.svg - resources/InstrumentValueIcons/browser-window-open.svg - resources/InstrumentValueIcons/wallet.svg - resources/InstrumentValueIcons/box.svg - resources/InstrumentValueIcons/attachment.svg - resources/InstrumentValueIcons/cloud.svg - resources/InstrumentValueIcons/radar copy 2.svg - resources/InstrumentValueIcons/directions.svg - resources/InstrumentValueIcons/view-hide.svg - resources/InstrumentValueIcons/hour-glass.svg - resources/InstrumentValueIcons/globe.svg - resources/InstrumentValueIcons/volume-off.svg - resources/InstrumentValueIcons/station.svg - resources/InstrumentValueIcons/dots-horizontal-triple.svg - resources/InstrumentValueIcons/save-disk.svg - resources/InstrumentValueIcons/star-full.svg - resources/InstrumentValueIcons/mood-sad-solid.svg - resources/InstrumentValueIcons/chat-bubble-dots.svg - resources/InstrumentValueIcons/window-open.svg - resources/InstrumentValueIcons/timer.svg - resources/InstrumentValueIcons/explore.svg - resources/InstrumentValueIcons/step-backward.svg - resources/InstrumentValueIcons/mood-happy-outline.svg - resources/InstrumentValueIcons/add-outline.svg - resources/InstrumentValueIcons/zoom-out.svg - resources/InstrumentValueIcons/fast-forward.svg - resources/InstrumentValueIcons/network.svg - resources/InstrumentValueIcons/light-bulb.svg - resources/InstrumentValueIcons/text-decoration.svg - resources/InstrumentValueIcons/user-group.svg - resources/InstrumentValueIcons/repost.svg - resources/InstrumentValueIcons/key.svg - resources/InstrumentValueIcons/user-solid-circle.svg - resources/InstrumentValueIcons/target.svg - resources/InstrumentValueIcons/date-add.svg - resources/InstrumentValueIcons/dial-pad.svg - resources/InstrumentValueIcons/stand-by.svg - resources/InstrumentValueIcons/flashlight.svg - resources/InstrumentValueIcons/mood-neutral-outline.svg - resources/InstrumentValueIcons/view-column.svg - resources/InstrumentValueIcons/chart.svg - resources/InstrumentValueIcons/bluetooth.svg - resources/InstrumentValueIcons/window-new.svg - resources/InstrumentValueIcons/location-hotel.svg - resources/InstrumentValueIcons/edit-pencil.svg - resources/InstrumentValueIcons/location-gas-station.svg - resources/InstrumentValueIcons/tablet.svg - resources/InstrumentValueIcons/layers.svg - resources/InstrumentValueIcons/brightness-up.svg - resources/InstrumentValueIcons/cloud-upload.svg - resources/InstrumentValueIcons/cheveron-outline-right.svg - resources/InstrumentValueIcons/information-outline.svg - resources/InstrumentValueIcons/chart-pie.svg - resources/InstrumentValueIcons/screen-full.svg - resources/InstrumentValueIcons/education.svg - resources/InstrumentValueIcons/vector.svg - resources/InstrumentValueIcons/load-balancer.svg - resources/InstrumentValueIcons/paste.svg - resources/InstrumentValueIcons/conversation.svg - resources/InstrumentValueIcons/arrow-outline-down.svg - resources/InstrumentValueIcons/airplane.svg - resources/InstrumentValueIcons/cheveron-right.svg - resources/InstrumentValueIcons/swap.svg - resources/InstrumentValueIcons/border-outer.svg - resources/InstrumentValueIcons/watch.svg - resources/InstrumentValueIcons/notifications.svg - resources/InstrumentValueIcons/refresh.svg - resources/InstrumentValueIcons/border-left.svg - resources/InstrumentValueIcons/border-vertical.svg - resources/InstrumentValueIcons/filter.svg - resources/InstrumentValueIcons/brightness-down.svg - resources/InstrumentValueIcons/mic.svg - resources/InstrumentValueIcons/link.svg - resources/InstrumentValueIcons/format-font-size.svg - resources/InstrumentValueIcons/volume-mute.svg - resources/InstrumentValueIcons/bug.svg - resources/InstrumentValueIcons/indent-increase.svg - resources/InstrumentValueIcons/add-solid.svg - resources/InstrumentValueIcons/code.svg - resources/InstrumentValueIcons/arrow-down.svg - resources/InstrumentValueIcons/pause-solid.svg - resources/InstrumentValueIcons/folder.svg - resources/InstrumentValueIcons/shopping-cart.svg - resources/InstrumentValueIcons/inbox-download.svg - resources/InstrumentValueIcons/bookmark-outline-add.svg - resources/InstrumentValueIcons/play-outline.svg - resources/InstrumentValueIcons/music-notes.svg - resources/InstrumentValueIcons/user.svg - resources/InstrumentValueIcons/computer-desktop.svg - resources/InstrumentValueIcons/step-forward.svg - resources/InstrumentValueIcons/inbox-full.svg - resources/InstrumentValueIcons/border-none.svg - resources/InstrumentValueIcons/map.svg - resources/InstrumentValueIcons/information-solid.svg - resources/InstrumentValueIcons/format-text-size.svg - resources/InstrumentValueIcons/location.svg - resources/InstrumentValueIcons/close-outline.svg - resources/InstrumentValueIcons/dots-horizontal-double.svg - resources/InstrumentValueIcons/servers.svg - resources/InstrumentValueIcons/trophy.svg - resources/InstrumentValueIcons/arrow-thick-right.svg - resources/InstrumentValueIcons/radar.svg - resources/InstrumentValueIcons/fast-rewind.svg - resources/InstrumentValueIcons/hard-drive.svg - resources/InstrumentValueIcons/cheveron-outline-down.svg - resources/InstrumentValueIcons/trash.svg - resources/InstrumentValueIcons/forward.svg - resources/InstrumentValueIcons/backspace.svg - resources/InstrumentValueIcons/location-shopping.svg - resources/InstrumentValueIcons/mobile-devices.svg - resources/InstrumentValueIcons/cheveron-left.svg - resources/InstrumentValueIcons/travel-walk.svg - resources/InstrumentValueIcons/computer-laptop.svg - resources/InstrumentValueIcons/dashboard.svg - resources/InstrumentValueIcons/video-camera.svg - resources/InstrumentValueIcons/thermometer.svg - resources/InstrumentValueIcons/cog.svg - resources/InstrumentValueIcons/location-marina.svg - resources/InstrumentValueIcons/location-food.svg - resources/InstrumentValueIcons/reply.svg - resources/InstrumentValueIcons/arrow-thick-left.svg - resources/InstrumentValueIcons/subdirectory-right.svg - resources/InstrumentValueIcons/backward.svg - resources/InstrumentValueIcons/download.svg - resources/InstrumentValueIcons/coffee.svg - resources/InstrumentValueIcons/keyboard.svg - resources/InstrumentValueIcons/film.svg - resources/InstrumentValueIcons/book-reference.svg - resources/InstrumentValueIcons/php-elephant.svg - resources/InstrumentValueIcons/chart-bar.svg - resources/InstrumentValueIcons/backward-step.svg - resources/InstrumentValueIcons/cheveron-outline-up.svg - resources/InstrumentValueIcons/cheveron-outline-left.svg - resources/InstrumentValueIcons/play.svg - resources/InstrumentValueIcons/border-right.svg - resources/InstrumentValueIcons/portfolio.svg - resources/InstrumentValueIcons/bookmark.svg - resources/InstrumentValueIcons/hot.svg - resources/InstrumentValueIcons/align-justified.svg - resources/InstrumentValueIcons/border-horizontal.svg - resources/InstrumentValueIcons/arrow-outline-up.svg - resources/InstrumentValueIcons/apparel.svg - resources/InstrumentValueIcons/arrow-thin-down.svg - resources/InstrumentValueIcons/mood-happy-solid.svg - resources/InstrumentValueIcons/home.svg - resources/InstrumentValueIcons/mood-sad-outline.svg - resources/InstrumentValueIcons/exclamation-solid.svg - resources/InstrumentValueIcons/translate.svg - resources/InstrumentValueIcons/document.svg - resources/InstrumentValueIcons/share-01.svg - resources/InstrumentValueIcons/gift.svg - resources/InstrumentValueIcons/volume-up.svg - resources/InstrumentValueIcons/travel-bus.svg - resources/InstrumentValueIcons/envelope.svg - resources/InstrumentValueIcons/camera.svg - resources/InstrumentValueIcons/view-list.svg - resources/InstrumentValueIcons/time.svg - resources/InstrumentValueIcons/lock-closed.svg - resources/InstrumentValueIcons/ticket.svg - resources/InstrumentValueIcons/edit-cut.svg - resources/InstrumentValueIcons/music-playlist.svg - resources/InstrumentValueIcons/currency-dollar.svg - resources/InstrumentValueIcons/exclamation-outline.svg - resources/InstrumentValueIcons/anchor.svg - resources/InstrumentValueIcons/edit-copy.svg - resources/InstrumentValueIcons/pause.svg - resources/InstrumentValueIcons/photo.svg - resources/InstrumentValueIcons/arrow-outline-right.svg - resources/InstrumentValueIcons/reply-all.svg - resources/InstrumentValueIcons/volume-down.svg - resources/InstrumentValueIcons/notification.svg - resources/InstrumentValueIcons/playlist.svg - resources/InstrumentValueIcons/factory.svg - resources/InstrumentValueIcons/news-paper.svg - resources/InstrumentValueIcons/tuning.svg - resources/InstrumentValueIcons/music-album.svg - resources/InstrumentValueIcons/arrow-thick-down.svg - resources/InstrumentValueIcons/share.svg - resources/InstrumentValueIcons/location-current.svg - resources/InstrumentValueIcons/window.svg - resources/InstrumentValueIcons/artist.svg - resources/InstrumentValueIcons/forward-step.svg - resources/InstrumentValueIcons/zoom-in.svg - resources/InstrumentValueIcons/subdirectory-left.svg - resources/InstrumentValueIcons/duplicate.svg - resources/InstrumentValueIcons/block.svg - resources/InstrumentValueIcons/heart.svg - resources/InstrumentValueIcons/travel-taxi-cab.svg - resources/InstrumentValueIcons/navigation-more.svg - resources/InstrumentValueIcons/arrow-outline-left.svg - resources/InstrumentValueIcons/border-top.svg - resources/InstrumentValueIcons/tools copy.svg - resources/InstrumentValueIcons/compose.svg - resources/InstrumentValueIcons/bookmark-outline.svg - resources/InstrumentValueIcons/hand-stop.svg - resources/InstrumentValueIcons/tag.svg - resources/InstrumentValueIcons/list-add.svg - resources/InstrumentValueIcons/cheveron-up.svg - resources/InstrumentValueIcons/arrow-left.svg - resources/InstrumentValueIcons/view-carousel.svg - resources/InstrumentValueIcons/question.svg - resources/InstrumentValueIcons/search.svg - resources/InstrumentValueIcons/pylon.svg - resources/InstrumentValueIcons/arrow-thin-right.svg - resources/InstrumentValueIcons/phone.svg - resources/InstrumentValueIcons/reload.svg - resources/InstrumentValueIcons/document-add.svg - resources/InstrumentValueIcons/wrench.svg - resources/InstrumentValueIcons/format-bold.svg - resources/InstrumentValueIcons/checkmark.svg - resources/InstrumentValueIcons/send.svg - resources/InstrumentValueIcons/at-symbol.svg - resources/InstrumentValueIcons/flag.svg - resources/InstrumentValueIcons/format-underline.svg - resources/InstrumentValueIcons/calendar.svg - resources/InstrumentValueIcons/notifications-outline.svg - resources/InstrumentValueIcons/list.svg - resources/InstrumentValueIcons/shuffle.svg - resources/InstrumentValueIcons/align-right.svg - resources/InstrumentValueIcons/beverage.svg - resources/InstrumentValueIcons/show-sidebar.svg - resources/InstrumentValueIcons/view-show.svg - resources/InstrumentValueIcons/copy.svg - resources/InstrumentValueIcons/menu.svg - resources/InstrumentValueIcons/minus-solid.svg - resources/InstrumentValueIcons/travel-case.svg - resources/InstrumentValueIcons/stethoscope.svg - resources/InstrumentValueIcons/headphones.svg - resources/InstrumentValueIcons/format-italic.svg - resources/InstrumentValueIcons/browser-window-new.svg - resources/InstrumentValueIcons/pin.svg - resources/InstrumentValueIcons/border-bottom.svg - resources/InstrumentValueIcons/arrow-right.svg - resources/InstrumentValueIcons/bolt.svg - resources/InstrumentValueIcons/shield.svg - resources/InstrumentValueIcons/align-center.svg - resources/InstrumentValueIcons/travel-train.svg - resources/InstrumentValueIcons/arrow-up.svg - resources/InstrumentValueIcons/badge.svg - resources/InstrumentValueIcons/usb.svg - resources/InstrumentValueIcons/plugin.svg - resources/InstrumentValueIcons/checkmark-outline.svg - resources/InstrumentValueIcons/store-front.svg - resources/InstrumentValueIcons/travel.svg - resources/InstrumentValueIcons/align-left.svg - resources/InstrumentValueIcons/border-inner.svg - resources/InstrumentValueIcons/edit-crop.svg - resources/InstrumentValueIcons/adjust.svg - resources/InstrumentValueIcons/mood-neutral-solid.svg - resources/InstrumentValueIcons/arrow-thick-up.svg - resources/InstrumentValueIcons/battery-half.svg - resources/InstrumentValueIcons/location-restroom.svg - resources/InstrumentValueIcons/travel-car.svg - resources/InstrumentValueIcons/border-all.svg - resources/InstrumentValueIcons/browser-window.svg - resources/InstrumentValueIcons/lock-open.svg - resources/InstrumentValueIcons/battery-low.svg - resources/InstrumentValueIcons/folder-outline-add.svg - resources/InstrumentValueIcons/arrow-thin-left.svg - resources/InstrumentValueIcons/close.svg - resources/InstrumentValueIcons/calculator.svg - resources/InstrumentValueIcons/stroke-width.svg - resources/InstrumentValueIcons/thumbs-down.svg - resources/InstrumentValueIcons/album.svg - resources/InstrumentValueIcons/upload.svg - resources/InstrumentValueIcons/buoy.svg - resources/InstrumentValueIcons/cheveron-down.svg - resources/InstrumentValueIcons/view-tile.svg - - diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index b1ee3d094729b6f7fdd6b362cadb9908f644df23..98779b5a334d69abdc5b4b7c9c267fc61ab195c1 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -359,7 +359,7 @@ CustomBuild { $$PWD/qgroundcontrol.qrc \ $$PWD/qgcresources.qrc \ $$PWD/qgcimages.qrc \ - $$PWD/InstrumentValueIcons.qrc \ + $$PWD/resources/InstrumentValueIcons/InstrumentValueIcons.qrc \ } # On Qt 5.9 android versions there is the following bug: https://bugreports.qt.io/browse/QTBUG-61424 @@ -647,8 +647,9 @@ HEADERS += \ src/QmlControls/AppMessages.h \ src/QmlControls/EditPositionDialogController.h \ src/QmlControls/FlightPathSegment.h \ + src/QmlControls/HorizontalFactValueGrid.h \ src/QmlControls/InstrumentValueData.h \ - src/QmlControls/InstrumentValueArea.h \ + src/QmlControls/FactValueGrid.h \ src/QmlControls/ParameterEditorController.h \ src/QmlControls/QGCFileDialogController.h \ src/QmlControls/QGCImageProvider.h \ @@ -661,6 +662,7 @@ HEADERS += \ src/QmlControls/TerrainProfile.h \ src/QmlControls/ToolStripAction.h \ src/QmlControls/ToolStripActionList.h \ + src/QmlControls/VerticalFactValueGrid.h \ src/QtLocationPlugin/QMLControl/QGCMapEngineManager.h \ src/Settings/ADSBVehicleManagerSettings.h \ src/Settings/AppSettings.h \ @@ -857,8 +859,9 @@ SOURCES += \ src/QmlControls/AppMessages.cc \ src/QmlControls/EditPositionDialogController.cc \ src/QmlControls/FlightPathSegment.cc \ + src/QmlControls/HorizontalFactValueGrid.cc \ src/QmlControls/InstrumentValueData.cc \ - src/QmlControls/InstrumentValueArea.cc \ + src/QmlControls/FactValueGrid.cc \ src/QmlControls/ParameterEditorController.cc \ src/QmlControls/QGCFileDialogController.cc \ src/QmlControls/QGCImageProvider.cc \ @@ -871,6 +874,7 @@ SOURCES += \ src/QmlControls/TerrainProfile.cc \ src/QmlControls/ToolStripAction.cc \ src/QmlControls/ToolStripActionList.cc \ + src/QmlControls/VerticalFactValueGrid.cc \ src/QtLocationPlugin/QMLControl/QGCMapEngineManager.cc \ src/Settings/ADSBVehicleManagerSettings.cc \ src/Settings/AppSettings.cc \ diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc index 917bcabe3fbf2a527a448eb01c06151492209bfd..409b814bcbd8eeda28c45b7562b71a7b36bda9b1 100644 --- a/qgroundcontrol.qrc +++ b/qgroundcontrol.qrc @@ -98,9 +98,10 @@ src/PlanView/FWLandingPatternMapVisual.qml src/PlanView/GeoFenceEditor.qml src/PlanView/GeoFenceMapVisuals.qml + src/QmlControls/HorizontalFactValueGrid.qml src/QmlControls/IndicatorButton.qml - src/QmlControls/InstrumentValue.qml - src/QmlControls/InstrumentValueArea.qml + src/QmlControls/InstrumentValueLabel.qml + src/QmlControls/InstrumentValueValue.qml src/QmlControls/InstrumentValueEditDialog.qml src/QmlControls/JoystickThumbPad.qml src/QmlControls/KMLOrSHPFileDialog.qml @@ -182,6 +183,7 @@ src/PlanView/TransectStyleComplexItemStats.qml src/QmlControls/VehicleRotationCal.qml src/QmlControls/VehicleSummaryRow.qml + src/QmlControls/VerticalFactValueGrid.qml src/ViewWidgets/ViewWidget.qml src/FactSystem/FactControls/AltitudeFactTextField.qml src/FactSystem/FactControls/FactBitmask.qml diff --git a/resources/InstrumentValueIcons/InstrumentValueIcons.qrc b/resources/InstrumentValueIcons/InstrumentValueIcons.qrc new file mode 100644 index 0000000000000000000000000000000000000000..59e0140be7145ce2bb4cac7942afb7c242bdf101 --- /dev/null +++ b/resources/InstrumentValueIcons/InstrumentValueIcons.qrc @@ -0,0 +1,301 @@ + + + clipboard.svg + credit-card.svg + bookmark copy 2.svg + library.svg + mouse.svg + printer.svg + thumbs-up.svg + arrow-thin-up.svg + pause-outline.svg + music-artist.svg + location-park.svg + pen-tool.svg + color-palette.svg + announcement.svg + inbox-check.svg + radio.svg + close-solid.svg + inbox.svg + user-add.svg + text-box.svg + queue.svg + minus-outline.svg + user-solid-square.svg + list-bullet.svg + indent-decrease.svg + yin-yang.svg + share-alt.svg + battery-full.svg + folder-outline.svg + bookmark copy 3.svg + browser-window-open.svg + wallet.svg + box.svg + attachment.svg + cloud.svg + radar copy 2.svg + directions.svg + view-hide.svg + hour-glass.svg + globe.svg + volume-off.svg + station.svg + dots-horizontal-triple.svg + save-disk.svg + star-full.svg + mood-sad-solid.svg + chat-bubble-dots.svg + window-open.svg + timer.svg + explore.svg + step-backward.svg + mood-happy-outline.svg + add-outline.svg + zoom-out.svg + fast-forward.svg + network.svg + light-bulb.svg + text-decoration.svg + user-group.svg + repost.svg + key.svg + user-solid-circle.svg + target.svg + date-add.svg + dial-pad.svg + stand-by.svg + flashlight.svg + mood-neutral-outline.svg + view-column.svg + chart.svg + bluetooth.svg + window-new.svg + location-hotel.svg + edit-pencil.svg + location-gas-station.svg + tablet.svg + layers.svg + brightness-up.svg + cloud-upload.svg + cheveron-outline-right.svg + information-outline.svg + chart-pie.svg + screen-full.svg + education.svg + vector.svg + load-balancer.svg + paste.svg + conversation.svg + arrow-outline-down.svg + airplane.svg + cheveron-right.svg + swap.svg + border-outer.svg + watch.svg + notifications.svg + refresh.svg + border-left.svg + border-vertical.svg + arrow-base-up.svg + filter.svg + brightness-down.svg + mic.svg + link.svg + format-font-size.svg + volume-mute.svg + bug.svg + indent-increase.svg + add-solid.svg + code.svg + pause-solid.svg + folder.svg + shopping-cart.svg + inbox-download.svg + bookmark-outline-add.svg + play-outline.svg + music-notes.svg + user.svg + computer-desktop.svg + step-forward.svg + inbox-full.svg + border-none.svg + map.svg + information-solid.svg + format-text-size.svg + location.svg + close-outline.svg + dots-horizontal-double.svg + servers.svg + trophy.svg + arrow-thick-right.svg + radar.svg + fast-rewind.svg + hard-drive.svg + cheveron-outline-down.svg + trash.svg + forward.svg + backspace.svg + location-shopping.svg + mobile-devices.svg + cheveron-left.svg + travel-walk.svg + computer-laptop.svg + dashboard.svg + video-camera.svg + thermometer.svg + cog.svg + location-marina.svg + location-food.svg + reply.svg + arrow-thick-left.svg + subdirectory-right.svg + backward.svg + coffee.svg + keyboard.svg + film.svg + book-reference.svg + php-elephant.svg + chart-bar.svg + backward-step.svg + cheveron-outline-up.svg + cheveron-outline-left.svg + play.svg + border-right.svg + portfolio.svg + bookmark.svg + hot.svg + align-justified.svg + border-horizontal.svg + arrow-outline-up.svg + apparel.svg + arrow-thin-down.svg + mood-happy-solid.svg + home.svg + mood-sad-outline.svg + exclamation-solid.svg + translate.svg + document.svg + share-01.svg + gift.svg + volume-up.svg + travel-bus.svg + envelope.svg + camera.svg + view-list.svg + time.svg + lock-closed.svg + ticket.svg + edit-cut.svg + music-playlist.svg + currency-dollar.svg + exclamation-outline.svg + anchor.svg + edit-copy.svg + pause.svg + photo.svg + arrow-outline-right.svg + arrow-simple-right.svg + reply-all.svg + volume-down.svg + notification.svg + playlist.svg + factory.svg + arrow-simple-up.svg + news-paper.svg + tuning.svg + music-album.svg + arrow-thick-down.svg + share.svg + location-current.svg + window.svg + artist.svg + forward-step.svg + zoom-in.svg + subdirectory-left.svg + duplicate.svg + block.svg + heart.svg + travel-taxi-cab.svg + navigation-more.svg + arrow-outline-left.svg + border-top.svg + tools copy.svg + compose.svg + bookmark-outline.svg + hand-stop.svg + tag.svg + list-add.svg + cheveron-up.svg + view-carousel.svg + question.svg + arrow-simple-left.svg + search.svg + pylon.svg + arrow-thin-right.svg + phone.svg + reload.svg + arrow-simple-down.svg + arrow-base-down.svg + document-add.svg + wrench.svg + format-bold.svg + checkmark.svg + send.svg + at-symbol.svg + flag.svg + format-underline.svg + calendar.svg + notifications-outline.svg + list.svg + shuffle.svg + align-right.svg + beverage.svg + show-sidebar.svg + view-show.svg + copy.svg + menu.svg + minus-solid.svg + travel-case.svg + stethoscope.svg + headphones.svg + format-italic.svg + browser-window-new.svg + pin.svg + border-bottom.svg + bolt.svg + shield.svg + align-center.svg + travel-train.svg + badge.svg + usb.svg + plugin.svg + checkmark-outline.svg + store-front.svg + travel.svg + align-left.svg + border-inner.svg + edit-crop.svg + adjust.svg + mood-neutral-solid.svg + arrow-thick-up.svg + battery-half.svg + location-restroom.svg + travel-car.svg + border-all.svg + browser-window.svg + lock-open.svg + battery-low.svg + folder-outline-add.svg + arrow-thin-left.svg + close.svg + calculator.svg + stroke-width.svg + thumbs-down.svg + album.svg + buoy.svg + cheveron-down.svg + view-tile.svg + + diff --git a/resources/InstrumentValueIcons/UpdateResourceFile.py b/resources/InstrumentValueIcons/UpdateResourceFile.py index 2cd0369257950d5c9af85e04b3384a2dab792364..4ec3c13aa8a3c66052c5aa5f080097fc545f131b 100644 --- a/resources/InstrumentValueIcons/UpdateResourceFile.py +++ b/resources/InstrumentValueIcons/UpdateResourceFile.py @@ -10,7 +10,7 @@ def main(): files = os.listdir(".") for filename in files: if filename.endswith(".svg"): - qrcFile.write("\t\tresources/InstrumentValueIcons/%s\n" % (filename, filename)) + qrcFile.write("\t\t%s\n" % (filename, filename)) qrcFile.write("\t\n") qrcFile.write("\n") diff --git a/resources/InstrumentValueIcons/download.svg b/resources/InstrumentValueIcons/arrow-base-down.svg similarity index 100% rename from resources/InstrumentValueIcons/download.svg rename to resources/InstrumentValueIcons/arrow-base-down.svg diff --git a/resources/InstrumentValueIcons/upload.svg b/resources/InstrumentValueIcons/arrow-base-up.svg similarity index 100% rename from resources/InstrumentValueIcons/upload.svg rename to resources/InstrumentValueIcons/arrow-base-up.svg diff --git a/resources/InstrumentValueIcons/arrow-down.svg b/resources/InstrumentValueIcons/arrow-simple-down.svg similarity index 100% rename from resources/InstrumentValueIcons/arrow-down.svg rename to resources/InstrumentValueIcons/arrow-simple-down.svg diff --git a/resources/InstrumentValueIcons/arrow-left.svg b/resources/InstrumentValueIcons/arrow-simple-left.svg similarity index 100% rename from resources/InstrumentValueIcons/arrow-left.svg rename to resources/InstrumentValueIcons/arrow-simple-left.svg diff --git a/resources/InstrumentValueIcons/arrow-right.svg b/resources/InstrumentValueIcons/arrow-simple-right.svg similarity index 100% rename from resources/InstrumentValueIcons/arrow-right.svg rename to resources/InstrumentValueIcons/arrow-simple-right.svg diff --git a/resources/InstrumentValueIcons/arrow-up.svg b/resources/InstrumentValueIcons/arrow-simple-up.svg similarity index 100% rename from resources/InstrumentValueIcons/arrow-up.svg rename to resources/InstrumentValueIcons/arrow-simple-up.svg diff --git a/src/FlightMap/Widgets/ValuePageWidget.qml b/src/FlightMap/Widgets/ValuePageWidget.qml index 14e2d0eb8ccba48bd7be85b7c611bc4cd93bbea6..7c8c30d4cd8bc482153aa409f92fcdd0ddf32058 100644 --- a/src/FlightMap/Widgets/ValuePageWidget.qml +++ b/src/FlightMap/Widgets/ValuePageWidget.qml @@ -23,12 +23,11 @@ import QGroundControl.FlightMap 1.0 import QGroundControl 1.0 /// Value page for InstrumentPanel PageView -InstrumentValueArea { +VerticalFactValueGrid { id: _root width: pageWidth userSettingsGroup: valuePageUserSettingsGroup defaultSettingsGroup: valuePageDefaultSettingsGroup - orientation: InstrumentValueArea.VerticalOrientation property bool showSettingsIcon: true property bool showLockIcon: true diff --git a/src/QGCApplication.cc b/src/QGCApplication.cc index 526fab0aabc868c89b48a47c243b3ae283edf6d0..3b70f54c29838ec38c18517e95073b8a2646fd61 100644 --- a/src/QGCApplication.cc +++ b/src/QGCApplication.cc @@ -78,7 +78,8 @@ #if defined(QGC_ENABLE_MAVLINK_INSPECTOR) #include "MAVLinkInspectorController.h" #endif -#include "InstrumentValueArea.h" +#include "HorizontalFactValueGrid.h" +#include "VerticalFactValueGrid.h" #include "InstrumentValueData.h" #include "AppMessages.h" #include "SimulatedPosition.h" @@ -543,7 +544,9 @@ void QGCApplication::_initCommon() qmlRegisterUncreatableType ("QGroundControl.FlightMap", 1, 0, "QGCGeoBoundingCube", kRefOnly); qmlRegisterUncreatableType ("QGroundControl.FlightMap", 1, 0, "TrajectoryPoints", kRefOnly); - qmlRegisterType (kQGCTemplates, 1, 0, "InstrumentValueArea"); + qmlRegisterUncreatableType (kQGCTemplates, 1, 0, "FactValueGrid", kRefOnly); + qmlRegisterType (kQGCTemplates, 1, 0, "HorizontalFactValueGrid"); + qmlRegisterType (kQGCTemplates, 1, 0, "VerticalFactValueGrid"); qmlRegisterType ("QGroundControl.FlightMap", 1, 0, "QGCMapCircle"); @@ -551,7 +554,6 @@ void QGCApplication::_initCommon() qmlRegisterType (kQGCControllers, 1, 0, "ESP8266ComponentController"); qmlRegisterType (kQGCControllers, 1, 0, "ScreenToolsController"); qmlRegisterType (kQGCControllers, 1, 0, "PlanMasterController"); - qmlRegisterType (kQGCTemplates, 1, 0, "InstrumentValueArea"); qmlRegisterType (kQGCControllers, 1, 0, "QGCFileDialogController"); qmlRegisterType (kQGCControllers, 1, 0, "RCChannelMonitorController"); qmlRegisterType (kQGCControllers, 1, 0, "JoystickConfigController"); diff --git a/src/QmlControls/FactValueGrid.cc b/src/QmlControls/FactValueGrid.cc new file mode 100644 index 0000000000000000000000000000000000000000..3f3b6ab1dde0ff2486f157251ba614dec39bdc29 --- /dev/null +++ b/src/QmlControls/FactValueGrid.cc @@ -0,0 +1,343 @@ +/**************************************************************************** + * + * (c) 2009-2020 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + +#include "FactValueGrid.h" +#include "InstrumentValueData.h" +#include "QGCApplication.h" +#include "QGCCorePlugin.h" + +#include + +const char* FactValueGrid::_rowsKey = "rows"; +const char* FactValueGrid::_columnsKey = "columns"; +const char* FactValueGrid::_fontSizeKey = "fontSize"; +const char* FactValueGrid::_orientationKey = "orientation"; +const char* FactValueGrid::_versionKey = "version"; +const char* FactValueGrid::_factGroupNameKey = "groupName"; +const char* FactValueGrid::_factNameKey = "factName"; +const char* FactValueGrid::_textKey = "text"; +const char* FactValueGrid::_showUnitsKey = "showUnits"; +const char* FactValueGrid::_iconKey = "icon"; +const char* FactValueGrid::_rangeTypeKey = "rangeType"; +const char* FactValueGrid::_rangeValuesKey = "rangeValues"; +const char* FactValueGrid::_rangeColorsKey = "rangeColors"; +const char* FactValueGrid::_rangeIconsKey = "rangeIcons"; +const char* FactValueGrid::_rangeOpacitiesKey = "rangeOpacities"; + +const char* FactValueGrid::_deprecatedGroupKey = "ValuesWidget"; + +QStringList FactValueGrid::_iconNames; + +// Important: The indices of these strings must match the FactValueGrid::FontSize enum +const QStringList FactValueGrid::_fontSizeNames = { + QT_TRANSLATE_NOOP("FactValueGrid", "Default"), + QT_TRANSLATE_NOOP("FactValueGrid", "Small"), + QT_TRANSLATE_NOOP("FactValueGrid", "Medium"), + QT_TRANSLATE_NOOP("FactValueGrid", "Large"), +}; + +FactValueGrid::FactValueGrid(QQuickItem* parent) + : QQuickItem(parent) + , _rows (new QmlObjectListModel(this)) +{ + if (_iconNames.isEmpty()) { + QDir iconDir(":/InstrumentValueIcons/"); + _iconNames = iconDir.entryList(); + } + + _connectSignals(); +} + +FactValueGrid::FactValueGrid(const QString& defaultSettingsGroup) + : QQuickItem (nullptr) + , _defaultSettingsGroup (defaultSettingsGroup) + , _rows (new QmlObjectListModel(this)) +{ + _connectSignals(); +} + +void FactValueGrid::_connectSignals(void) +{ + connect(this, &FactValueGrid::fontSizeChanged, this, &FactValueGrid::_saveSettings); +} + +void FactValueGrid::componentComplete(void) +{ + QQuickItem::componentComplete(); + + // We should know settingsGroup/defaultSettingsGroup now so we can load settings + _loadSettings(); +} + +void FactValueGrid::resetToDefaults(void) +{ + QSettings settings; + settings.remove(_userSettingsGroup); + _loadSettings(); +} + +QString FactValueGrid::_pascalCase(const QString& text) +{ + return text[0].toUpper() + text.right(text.length() - 1); +} + +void FactValueGrid::setFontSize(FontSize fontSize) +{ + if (fontSize != _fontSize) { + _fontSize = fontSize; + emit fontSizeChanged(fontSize); + } +} + +void FactValueGrid::_saveValueData(QSettings& settings, InstrumentValueData* value) +{ + settings.setValue(_textKey, value->text()); + settings.setValue(_showUnitsKey, value->showUnits()); + settings.setValue(_iconKey, value->icon()); + settings.setValue(_rangeTypeKey, value->rangeType()); + + if (value->rangeType() != InstrumentValueData::NoRangeInfo) { + settings.setValue(_rangeValuesKey, value->rangeValues()); + } + + switch (value->rangeType()) { + case InstrumentValueData::NoRangeInfo: + break; + case InstrumentValueData::ColorRange: + settings.setValue(_rangeColorsKey, value->rangeColors()); + break; + case InstrumentValueData::OpacityRange: + settings.setValue(_rangeOpacitiesKey, value->rangeOpacities()); + break; + case InstrumentValueData::IconSelectRange: + settings.setValue(_rangeIconsKey, value->rangeIcons()); + break; + } + + if (value->fact()) { + settings.setValue(_factGroupNameKey, value->factGroupName()); + settings.setValue(_factNameKey, value->factName()); + } else { + settings.setValue(_factGroupNameKey, ""); + settings.setValue(_factNameKey, ""); + } +} + +void FactValueGrid::_loadValueData(QSettings& settings, InstrumentValueData* value) +{ + QString factName = settings.value(_factNameKey).toString(); + if (!factName.isEmpty()) { + value->setFact(settings.value(_factGroupNameKey).toString(), factName); + } + + value->setText (settings.value(_textKey).toString()); + value->setShowUnits (settings.value(_showUnitsKey, true).toBool()); + value->setIcon (settings.value(_iconKey).toString()); + value->setRangeType (settings.value(_rangeTypeKey, InstrumentValueData::NoRangeInfo).value()); + + if (value->rangeType() != InstrumentValueData::NoRangeInfo) { + value->setRangeValues(settings.value(_rangeValuesKey).value()); + } + switch (value->rangeType()) { + case InstrumentValueData::NoRangeInfo: + break; + case InstrumentValueData::ColorRange: + value->setRangeColors(settings.value(_rangeColorsKey).value()); + break; + case InstrumentValueData::OpacityRange: + value->setRangeOpacities(settings.value(_rangeOpacitiesKey).value()); + break; + case InstrumentValueData::IconSelectRange: + value->setRangeIcons(settings.value(_rangeIconsKey).value()); + break; + } +} + +void FactValueGrid::_connectSaveSignals(InstrumentValueData* value) +{ + connect(value, &InstrumentValueData::factNameChanged, this, &FactValueGrid::_saveSettings); + connect(value, &InstrumentValueData::factGroupNameChanged, this, &FactValueGrid::_saveSettings); + connect(value, &InstrumentValueData::textChanged, this, &FactValueGrid::_saveSettings); + connect(value, &InstrumentValueData::showUnitsChanged, this, &FactValueGrid::_saveSettings); + connect(value, &InstrumentValueData::iconChanged, this, &FactValueGrid::_saveSettings); + connect(value, &InstrumentValueData::rangeTypeChanged, this, &FactValueGrid::_saveSettings); + connect(value, &InstrumentValueData::rangeValuesChanged, this, &FactValueGrid::_saveSettings); + connect(value, &InstrumentValueData::rangeColorsChanged, this, &FactValueGrid::_saveSettings); + connect(value, &InstrumentValueData::rangeOpacitiesChanged, this, &FactValueGrid::_saveSettings); + connect(value, &InstrumentValueData::rangeIconsChanged, this, &FactValueGrid::_saveSettings); +} + +void FactValueGrid::appendColumn(void) +{ + for (int rowIndex=0; rowIndex<_rows->count(); rowIndex++) { + QmlObjectListModel* list = _rows->value(rowIndex); + list->append(_createNewInstrumentValueWorker(list)); + + } + _columnCount++; + emit columnCountChanged(_columnCount); + _saveSettings(); +} + +void FactValueGrid::deleteLastColumn(void) +{ + if (_columnCount <= 1) { + return; + } + for (int rowIndex=0; rowIndex<_rows->count(); rowIndex++) { + QmlObjectListModel* list = _rows->value(rowIndex); + list->removeAt(list->count() - 1)->deleteLater(); + } + _columnCount--; + emit columnCountChanged(_columnCount); + _saveSettings(); +} + +QmlObjectListModel* FactValueGrid::appendRow(void) +{ + QmlObjectListModel* newList = new QmlObjectListModel(_rows); + _rows->append(newList); + + // If this is the first row then we automatically add the first column as well + int cColsToAdd = qMax(_columnCount, 1); + for (int i=0; iappend(_createNewInstrumentValueWorker(newList)); + } + + if (cColsToAdd != _columnCount) { + _columnCount = cColsToAdd; + emit columnCountChanged(_columnCount); + } + + _saveSettings(); + + return newList; +} + +void FactValueGrid::deleteLastRow(void) +{ + if (_rows->count() > 1) { + _rows->removeAt(_rows->count() - 1)->deleteLater(); + } +} + +InstrumentValueData* FactValueGrid::_createNewInstrumentValueWorker(QObject* parent) +{ + InstrumentValueData* value = new InstrumentValueData(this, parent); + value->setFact(InstrumentValueData::vehicleFactGroupName, "AltitudeRelative"); + value->setText(value->fact()->shortDescription()); + _connectSaveSignals(value); + return value; + +} + +void FactValueGrid::_saveSettings(void) +{ + if (_preventSaveSettings) { + return; + } + + QSettings settings; + if (_userSettingsGroup.isEmpty()) { + // This means we are setting up default settings + settings.beginGroup(_defaultSettingsGroup); + } else { + // This means we are saving user modifications + settings.remove(_defaultSettingsGroup); + settings.beginGroup(_userSettingsGroup); + } + + settings.remove(""); // Remove any previous settings + + settings.setValue(_versionKey, 1); + settings.setValue(_fontSizeKey, _fontSize); + settings.setValue(_orientationKey, _orientation); + settings.setValue(_columnsKey, _columnCount); + + settings.beginWriteArray(_rowsKey); + for (int rowIndex=0; rowIndex<_rows->count(); rowIndex++) { + QmlObjectListModel* columns = _rows->value(rowIndex); + + settings.setArrayIndex(rowIndex); + settings.beginWriteArray(_columnsKey); + + for (int colIndex=0; colIndexcount(); colIndex++) { + InstrumentValueData* value = columns->value(colIndex); + settings.setArrayIndex(colIndex); + _saveValueData(settings, value); + } + + settings.endArray(); + } + settings.endArray(); +} + +void FactValueGrid::_loadSettings(void) +{ + _rows->deleteLater(); + _rows = new QmlObjectListModel(this); + emit rowsChanged(_rows); + + QSettings settings; + if (!settings.childGroups().contains(_userSettingsGroup)) { + qgcApp()->toolbox()->corePlugin()->factValueGridCreateDefaultSettings(_defaultSettingsGroup); + } + + _preventSaveSettings = true; + + if (settings.childGroups().contains(_defaultSettingsGroup)) { + settings.beginGroup(_defaultSettingsGroup); + } else { + settings.beginGroup(_userSettingsGroup); + } + + int version = settings.value(_versionKey, 0).toInt(); + if (version != 1) { + qgcApp()->showAppMessage(tr("Settings version %1 for %2 is not supported. Setup will be reset to defaults.").arg(version).arg(_userSettingsGroup), tr("Load Settings")); + settings.remove(""); + qgcApp()->toolbox()->corePlugin()->factValueGridCreateDefaultSettings(_defaultSettingsGroup); + } + _fontSize = settings.value(_fontSizeKey, DefaultFontSize).value(); + _orientation = settings.value(_orientationKey, VerticalOrientation).value(); + + // Initial setup of empty items + int cColumns = settings.value(_columnsKey).toInt(); + int cModelLists = settings.beginReadArray(_rowsKey); + if (cModelLists && cColumns) { + appendRow(); + for (int itemIndex=1; itemIndexvalue(rowIndex); + InstrumentValueData* value = list->value(itemIndex); + settings.setArrayIndex(itemIndex); + _loadValueData(settings, value); + } + settings.endArray(); + } + settings.endArray(); + + _preventSaveSettings = false; + + // Use defaults if nothing there + if (_rows->count() == 0) { + _rows->deleteLater(); + emit rowsChanged(_rows); + } +} diff --git a/src/QmlControls/InstrumentValueArea.h b/src/QmlControls/FactValueGrid.h similarity index 58% rename from src/QmlControls/InstrumentValueArea.h rename to src/QmlControls/FactValueGrid.h index 1d8943b8b0cecb7a6d5d0d06d7434de932e7b22c..a382c078833e02ee8fd0e37bf9fc5743eee40019 100644 --- a/src/QmlControls/InstrumentValueArea.h +++ b/src/QmlControls/FactValueGrid.h @@ -13,17 +13,18 @@ #include "QmlObjectListModel.h" #include "QGCApplication.h" -#include +#include +#include class InstrumentValueData; -class InstrumentValueArea : public QQuickItem +class FactValueGrid : public QQuickItem { Q_OBJECT public: - InstrumentValueArea(QQuickItem *parent = nullptr); - InstrumentValueArea(const QString& defaultSettingsGroup); + FactValueGrid(QQuickItem *parent = nullptr); + FactValueGrid(const QString& defaultSettingsGroup); enum Orientation { HorizontalOrientation=0, // Labels will be to the left of the value @@ -39,77 +40,72 @@ public: }; Q_ENUMS(FontSize) - // valuePageDefaultSettingsGroup: + // defaultSettingsGroup: // This is the setting group name for default settings which are used when the user has not modified anything from the default setup. These settings will be overwritten - // prior to each use by the call to QGCCorePlugin::instrumentValueAreaCreateDefaultSettings. + // prior to each use by the call to QGCCorePlugin::FactValueGridCreateDefaultSettings. - // valuePageUserSettingsGroup: + // userSettingsGroup: // This is the settings group name for user modified settings. Settings will be saved to here whenever the user modified anything. Also at that point in time the // defaults settings group will be removed. - // The combination of the two valuePage*SettingsGroup values allows each InstrumentValueArea to have it's own persistence space. + // The combination of the two valuePage*SettingsGroup values allows each FactValueGrid to have it's own persistence space. - Q_PROPERTY(QString valuePageDefaultSettingsGroup MEMBER valuePageDefaultSettingsGroup CONSTANT) - Q_PROPERTY(QString valuePageUserSettingsGroup MEMBER _valuePageUserSettingsGroup CONSTANT) + Q_PROPERTY(QmlObjectListModel* rows MEMBER _rows NOTIFY rowsChanged) + Q_PROPERTY(int columnCount MEMBER _columnCount NOTIFY columnCountChanged) Q_PROPERTY(QString userSettingsGroup MEMBER _userSettingsGroup NOTIFY userSettingsGroupChanged) Q_PROPERTY(QString defaultSettingsGroup MEMBER _defaultSettingsGroup NOTIFY defaultSettingsGroupChanged) - Q_PROPERTY(Orientation orientation MEMBER _orientation NOTIFY orientationChanged) + Q_PROPERTY(Orientation orientation MEMBER _orientation CONSTANT) Q_PROPERTY(QStringList iconNames READ iconNames CONSTANT) Q_PROPERTY(FontSize fontSize READ fontSize WRITE setFontSize NOTIFY fontSizeChanged) Q_PROPERTY(QStringList fontSizeNames MEMBER _fontSizeNames CONSTANT) - Q_PROPERTY(QmlObjectListModel* rowValues MEMBER _rowValues NOTIFY rowValuesChanged) - Q_INVOKABLE InstrumentValueData* appendColumn (int rowIndex); - Q_INVOKABLE void deleteLastColumn (int rowIndex); - Q_INVOKABLE QmlObjectListModel* appendRow (bool addBlanksColumn = true); - Q_INVOKABLE QmlObjectListModel* insertRow (int atIndex, bool addBlanksColumn = true); - Q_INVOKABLE void deleteRow (int rowIndex); - Q_INVOKABLE void resetToDefaults (void); + Q_INVOKABLE void resetToDefaults (void); + Q_INVOKABLE QmlObjectListModel* appendRow (void); + Q_INVOKABLE void deleteLastRow (void); + Q_INVOKABLE void appendColumn (void); + Q_INVOKABLE void deleteLastColumn (void); - FontSize fontSize (void) const { return _fontSize; } - QmlObjectListModel* rowValues (void) { return _rowValues; } - QStringList iconNames (void) const { return _iconNames; } + FontSize fontSize (void) const { return _fontSize; } + QStringList iconNames (void) const { return _iconNames; } void setFontSize(FontSize fontSize); // Override from QQmlParserStatus void componentComplete(void) final; - static const QString valuePageDefaultSettingsGroup; - signals: void userSettingsGroupChanged (const QString& userSettingsGroup); void defaultSettingsGroupChanged(const QString& defaultSettingsGroup); - void rowValuesChanged (QmlObjectListModel* rowValues); - void orientationChanged (Orientation orientation); void fontSizeChanged (FontSize fontSize); + void rowsChanged (QmlObjectListModel* model); + void columnCountChanged (int columnCount); -private slots: - void _saveSettings(void); - -private: - void _connectSignals (void); - void _checkForDeprecatedSettings (void); - bool _validRowIndex (int rowIndex); - InstrumentValueData* _createNewInstrumentValueWorker (QmlObjectListModel* rowModel); - void _loadSettings (void); - QString _pascalCase (const QString& text); +protected: - Q_DISABLE_COPY(InstrumentValueArea) + Q_DISABLE_COPY(FactValueGrid) QString _defaultSettingsGroup; // Settings group to read from if the user has not modified from the default settings QString _userSettingsGroup; // Settings group to read from for user modified settings Orientation _orientation = VerticalOrientation; FontSize _fontSize = DefaultFontSize; - QmlObjectListModel* _rowValues = nullptr; bool _preventSaveSettings = false; + QmlObjectListModel* _rows = nullptr; + int _columnCount = 0; + +private: + InstrumentValueData* _createNewInstrumentValueWorker (QObject* parent); + void _saveSettings (void); + void _loadSettings (void); + void _connectSignals (void); + void _connectSaveSignals (InstrumentValueData* value); + QString _pascalCase (const QString& text); + void _saveValueData (QSettings& settings, InstrumentValueData* value); + void _loadValueData (QSettings& settings, InstrumentValueData* value); // These are user facing string for the various enums. static QStringList _iconNames; static const QStringList _fontSizeNames; - static const QString _valuePageUserSettingsGroup; - static const char* _versionKey; static const char* _rowsKey; static const char* _columnsKey; @@ -129,7 +125,7 @@ private: static const char* _deprecatedGroupKey; }; -QML_DECLARE_TYPE(InstrumentValueArea) +QML_DECLARE_TYPE(FactValueGrid) -Q_DECLARE_METATYPE(InstrumentValueArea::FontSize) -Q_DECLARE_METATYPE(InstrumentValueArea::Orientation) +Q_DECLARE_METATYPE(FactValueGrid::FontSize) +Q_DECLARE_METATYPE(FactValueGrid::Orientation) diff --git a/src/QmlControls/HorizontalFactValueGrid.cc b/src/QmlControls/HorizontalFactValueGrid.cc new file mode 100644 index 0000000000000000000000000000000000000000..51d2e2b545f0b7ef8f32665e6c2df246452c5172 --- /dev/null +++ b/src/QmlControls/HorizontalFactValueGrid.cc @@ -0,0 +1,30 @@ +/**************************************************************************** + * + * (c) 2009-2020 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + +#include "HorizontalFactValueGrid.h" +#include "InstrumentValueData.h" +#include "QGCApplication.h" +#include "QGCCorePlugin.h" + +#include + +const QString HorizontalFactValueGrid::_toolbarUserSettingsGroup ("ToolbarUserSettings2"); +const QString HorizontalFactValueGrid::toolbarDefaultSettingsGroup ("ToolbarDefaultSettings2"); + +HorizontalFactValueGrid::HorizontalFactValueGrid(QQuickItem* parent) + : FactValueGrid(parent) +{ + _orientation = HorizontalOrientation; +} + +HorizontalFactValueGrid::HorizontalFactValueGrid(const QString& defaultSettingsGroup) + : FactValueGrid(defaultSettingsGroup) +{ + _orientation = HorizontalOrientation; +} diff --git a/src/QmlControls/HorizontalFactValueGrid.h b/src/QmlControls/HorizontalFactValueGrid.h new file mode 100644 index 0000000000000000000000000000000000000000..cb563ee4009acd5cac1b58ab4366ebc8f1ff8f4e --- /dev/null +++ b/src/QmlControls/HorizontalFactValueGrid.h @@ -0,0 +1,38 @@ +/**************************************************************************** + * + * (c) 2009-2020 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + +#pragma once + +#include "FactSystem.h" +#include "QmlObjectListModel.h" +#include "QGCApplication.h" +#include "FactValueGrid.h" + +class InstrumentValueData; + +class HorizontalFactValueGrid : public FactValueGrid +{ + Q_OBJECT + +public: + HorizontalFactValueGrid(QQuickItem *parent = nullptr); + HorizontalFactValueGrid(const QString& defaultSettingsGroup); + + Q_PROPERTY(QString toolbarDefaultSettingsGroup MEMBER toolbarDefaultSettingsGroup CONSTANT) + Q_PROPERTY(QString toolbarUserSettingsGroup MEMBER _toolbarUserSettingsGroup CONSTANT) + + static const QString toolbarDefaultSettingsGroup; + +private: + Q_DISABLE_COPY(HorizontalFactValueGrid) + + static const QString _toolbarUserSettingsGroup; +}; + +QML_DECLARE_TYPE(HorizontalFactValueGrid) diff --git a/src/QmlControls/HorizontalFactValueGrid.qml b/src/QmlControls/HorizontalFactValueGrid.qml new file mode 100644 index 0000000000000000000000000000000000000000..21ba635bf43721e9cec5bfe844082c45ae544346 --- /dev/null +++ b/src/QmlControls/HorizontalFactValueGrid.qml @@ -0,0 +1,197 @@ +/**************************************************************************** + * + * (c) 2009-2020 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + +import QtQuick 2.12 +import QtQuick.Layouts 1.2 +import QtQuick.Controls 2.5 +import QtQml 2.12 + +import QGroundControl.Templates 1.0 as T +import QGroundControl.Controls 1.0 +import QGroundControl.ScreenTools 1.0 +import QGroundControl.Controllers 1.0 +import QGroundControl.Palette 1.0 +import QGroundControl.FlightMap 1.0 +import QGroundControl 1.0 + +// Note: This control will spit out qWarnings like this: "QGridLayoutEngine::addItem: Cell (0, 1) already taken" +// This is due to Qt bug https://bugreports.qt.io/browse/QTBUG-65121 +// If this becomes a problem I'll implement our own grid layout control + +T.HorizontalFactValueGrid { + id: _root + width: topLevelRowLayout.width + + property bool settingsUnlocked: false + + property real _margins: ScreenTools.defaultFontPixelWidth / 2 + property int _rowMax: 2 + property real _rowButtonWidth: ScreenTools.minTouchPixels + property real _rowButtonHeight: ScreenTools.minTouchPixels / 2 + property real _editButtonSpacing: 2 + + QGCPalette { id: qgcPal; colorGroupEnabled: enabled } + + RowLayout { + id: topLevelRowLayout + height: parent.height + + Item { + id: lockItem + Layout.fillHeight: true + width: ScreenTools.minTouchPixels + visible: settingsUnlocked + enabled: settingsUnlocked + + QGCColoredImage { + anchors.centerIn: parent + source: "/res/LockOpen.svg" + mipmap: true + width: parent.width * 0.75 + height: width + sourceSize.width: width + color: qgcPal.text + fillMode: Image.PreserveAspectFit + } + + QGCMouseArea { + fillItem: parent + onClicked: settingsUnlocked = false + } + } + + ColumnLayout { + Layout.fillHeight: true + + GridLayout { + id: valueGrid + Layout.preferredHeight: _root.height + rows: _root.rows.count + rowSpacing: 0 + + Repeater { + model: _root.rows + + Repeater { + id: labelRepeater + model: object + + property real _index: index + + InstrumentValueLabel { + Layout.row: labelRepeater._index + Layout.column: index * 2 + Layout.fillHeight: true + Layout.alignment: Qt.AlignRight + instrumentValueData: object + } + } + } + + Repeater { + model: _root.rows + + Repeater { + id: valueRepeater + model: object + + property real _index: index + + InstrumentValueValue { + Layout.row: valueRepeater._index + Layout.column: index * 2 + 1 + Layout.fillHeight: true + Layout.alignment: Qt.AlignLeft + instrumentValueData: object + } + } + } + } + + RowLayout { + id: rowButtons + height: ScreenTools.minTouchPixels / 2 + Layout.fillWidth: true + spacing: 1 + visible: settingsUnlocked + enabled: settingsUnlocked + + QGCButton { + Layout.fillWidth: true + Layout.preferredHeight: parent.height + text: qsTr("+") + onClicked: appendRow() + } + + QGCButton { + Layout.fillWidth: true + Layout.preferredHeight: parent.height + text: qsTr("-") + enabled: _root.rows.count > 1 + onClicked: deleteLastRow() + } + } + } + + ColumnLayout { + Layout.fillHeight: true + Layout.bottomMargin: rowButtons.height + Layout.preferredWidth: ScreenTools.minTouchPixels / 2 + spacing: 1 + visible: settingsUnlocked + enabled: settingsUnlocked + + QGCButton { + Layout.fillHeight: true + Layout.preferredHeight: ScreenTools.minTouchPixels + Layout.preferredWidth: parent.width + text: qsTr("+") + onClicked: appendColumn() + } + + QGCButton { + Layout.fillHeight: true + Layout.preferredHeight: ScreenTools.minTouchPixels + Layout.preferredWidth: parent.width + text: qsTr("-") + enabled: _root.columnCount > 1 + onClicked: deleteLastColumn() + } + } + } + + QGCMouseArea { + x: valueGrid.x + lockItem.width + topLevelRowLayout.spacing + y: valueGrid.y + width: valueGrid.width + height: valueGrid.height + visible: settingsUnlocked + onClicked: { + var item = valueGrid.childAt(mouse.x, mouse.y) + //console.log(item, item ? item.instrumentValueData : "null", item && item.parent ? item.parent.instrumentValueData : "null") + if (item && item.instrumentValueData !== undefined) { + mainWindow.showPopupDialog(valueEditDialog, { instrumentValueData: item.instrumentValueData }) + } + } + + /*Rectangle { + anchors.fill: parent + border.color: "green" + border.width: 1 + color: "transparent" + }*/ + } + + Component { + id: valueEditDialog + + InstrumentValueEditDialog { } + } +} + diff --git a/src/QmlControls/InstrumentValue.qml b/src/QmlControls/InstrumentValue.qml deleted file mode 100644 index c722d78856d8d514638fd783f93dfc052f980f32..0000000000000000000000000000000000000000 --- a/src/QmlControls/InstrumentValue.qml +++ /dev/null @@ -1,156 +0,0 @@ -/**************************************************************************** - * - * (c) 2009-2020 QGROUNDCONTROL PROJECT - * - * QGroundControl is licensed according to the terms in the file - * COPYING.md in the root of the source code directory. - * - ****************************************************************************/ - -import QtQuick 2.12 -import QtQuick.Layouts 1.2 -import QtQuick.Controls 2.5 - -import QGroundControl 1.0 -import QGroundControl.Controls 1.0 -import QGroundControl.ScreenTools 1.0 -import QGroundControl.Palette 1.0 - -Item { - id: root - height: value.y + value.height - - property var instrumentValueData: null - property bool recalcOk: false - - property var _rgFontSizes: [ ScreenTools.defaultFontPointSize, ScreenTools.smallFontPointSize, ScreenTools.mediumFontPointSize, ScreenTools.largeFontPointSize ] - property var _rgFontSizeRatios: [ 1, ScreenTools.smallFontPointRatio, ScreenTools.mediumFontPointRatio, ScreenTools.largeFontPointRatio ] - property real _doubleDescent: ScreenTools.defaultFontDescent * 2 - property real _tightDefaultFontHeight: ScreenTools.defaultFontPixelHeight - _doubleDescent - property var _rgFontSizeTightHeights: [ _tightDefaultFontHeight * _rgFontSizeRatios[0] + 2, _tightDefaultFontHeight * _rgFontSizeRatios[1] + 2, _tightDefaultFontHeight * _rgFontSizeRatios[2] + 2, _tightDefaultFontHeight * _rgFontSizeRatios[3] + 2 ] - property real _tightHeight: _rgFontSizeTightHeights[instrumentValueData.instrumentValueArea.fontSize] - property real _fontSize: _rgFontSizes[instrumentValueData.instrumentValueArea.fontSize] - property real _horizontalLabelSpacing: ScreenTools.defaultFontPixelWidth - property real _blankEntryHeight: ScreenTools.defaultFontPixelHeight * 2 - property bool _showIcon: instrumentValueData.icon || instrumentValueData.rangeType === InstrumentValueData.IconSelectRange - - // After fighting with using layout and/or anchors I gave up and just do a manual recalc to position items which ends up being much simpler - function recalcPositions() { - if (!recalcOk) { - return - } - var smallVerticalSpacing = 2 - var halfWidth = width / 2 - var halfHorizontalSpacing = _horizontalLabelSpacing / 2 - if (_showIcon) { - if (instrumentValueData.instrumentValueArea.orientation === InstrumentValueArea.VerticalOrientation) { - valueIcon.x = (width - valueIcon.width) / 2 - valueIcon.y = 0 - value.x = (width - value.width) / 2 - value.y = valueIcon.height + smallVerticalSpacing - } else { - value.y = 0 // value assumed to be taller - valueIcon.y = (value.height - valueIcon.height) / 2 - value.x = halfWidth + halfHorizontalSpacing - valueIcon.x = halfWidth - halfHorizontalSpacing - valueIcon.width - } - label.x = label.y = 0 - } else { - if (instrumentValueData.text) { - if (instrumentValueData.instrumentValueArea.orientation === InstrumentValueArea.VerticalOrientation) { - label.x = (width - label.width) / 2 - label.y = 0 - value.x = (width - value.width) / 2 - value.y = label.height + smallVerticalSpacing - } else { - value.y = 0 // value assumed to be taller - label.y = (value.height - label.height) / 2 - value.x = halfWidth + halfHorizontalSpacing - label.x = halfWidth - halfHorizontalSpacing - label.width - } - } else { - value.x = (width - value.width) / 2 - value.y = (height - value.height) / 2 - } - valueIcon.x = valueIcon.y = 0 - } - } - - onRecalcOkChanged: recalcPositions() - onWidthChanged: recalcPositions() - - Connections { - target: instrumentValueData - onIconChanged: recalcPositions() - } - - QGCColoredImage { - id: valueIcon - height: _tightHeight - width: height - source: icon - sourceSize.height: height - fillMode: Image.PreserveAspectFit - mipmap: true - smooth: true - color: instrumentValueData.isValidColor(instrumentValueData.currentColor) ? instrumentValueData.currentColor : qgcPal.text - opacity: instrumentValueData.currentOpacity - visible: _showIcon - onWidthChanged: root.recalcPositions() - onHeightChanged: root.recalcPositions() - - property string icon - readonly property string iconPrefix: "/InstrumentValueIcons/" - - function updateIcon() { - if (instrumentValueData.rangeType === InstrumentValueData.IconSelectRange) { - icon = iconPrefix + instrumentValueData.currentIcon - } else if (instrumentValueData.icon) { - icon = iconPrefix + instrumentValueData.icon - } else { - icon = "" - } - } - - Connections { - target: instrumentValueData - onRangeTypeChanged: valueIcon.updateIcon() - onCurrentIconChanged: valueIcon.updateIcon() - onIconChanged: valueIcon.updateIcon() - } - Component.onCompleted: updateIcon(); - } - - QGCLabel { - id: blank - anchors.horizontalCenter: parent.horizontalCenter - height: _columnButtonsTotalHeight - font.pointSize: ScreenTools.smallFontPointSize - text: _settingsUnlocked ? qsTr("BLANK") : "" - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - visible: !instrumentValueData.fact - onWidthChanged: root.recalcPositions() - onHeightChanged: root.recalcPositions() - } - - QGCLabel { - id: label - height: _tightHeight - text: instrumentValueData.text - verticalAlignment: Text.AlignVCenter - visible: !_showIcon - onWidthChanged: root.recalcPositions() - onHeightChanged: root.recalcPositions() - } - - QGCLabel { - id: value - font.pointSize: _fontSize - text: visible ? (instrumentValueData.fact.enumOrValueString + (instrumentValueData.showUnits ? instrumentValueData.fact.units : "")) : "" - verticalAlignment: Text.AlignVCenter - visible: instrumentValueData.fact - onWidthChanged: root.recalcPositions() - onHeightChanged: root.recalcPositions() - } -} diff --git a/src/QmlControls/InstrumentValueArea.cc b/src/QmlControls/InstrumentValueArea.cc deleted file mode 100644 index 7118d7d22d168bf62d8b27d736ad33ca9d10efb1..0000000000000000000000000000000000000000 --- a/src/QmlControls/InstrumentValueArea.cc +++ /dev/null @@ -1,363 +0,0 @@ -/**************************************************************************** - * - * (c) 2009-2020 QGROUNDCONTROL PROJECT - * - * QGroundControl is licensed according to the terms in the file - * COPYING.md in the root of the source code directory. - * - ****************************************************************************/ - -#include "InstrumentValueArea.h" -#include "InstrumentValueData.h" -#include "QGCApplication.h" -#include "QGCCorePlugin.h" - -#include - -const QString InstrumentValueArea::_valuePageUserSettingsGroup ("ValuePage.userSettings"); -const QString InstrumentValueArea::valuePageDefaultSettingsGroup ("ValuePage.defaultSettings"); - -const char* InstrumentValueArea::_rowsKey = "rows"; -const char* InstrumentValueArea::_columnsKey = "columns"; -const char* InstrumentValueArea::_fontSizeKey = "fontSize"; -const char* InstrumentValueArea::_orientationKey = "orientation"; -const char* InstrumentValueArea::_versionKey = "version"; -const char* InstrumentValueArea::_factGroupNameKey = "groupName"; -const char* InstrumentValueArea::_factNameKey = "factName"; -const char* InstrumentValueArea::_textKey = "text"; -const char* InstrumentValueArea::_showUnitsKey = "showUnits"; -const char* InstrumentValueArea::_iconKey = "icon"; -const char* InstrumentValueArea::_rangeTypeKey = "rangeType"; -const char* InstrumentValueArea::_rangeValuesKey = "rangeValues"; -const char* InstrumentValueArea::_rangeColorsKey = "rangeColors"; -const char* InstrumentValueArea::_rangeIconsKey = "rangeIcons"; -const char* InstrumentValueArea::_rangeOpacitiesKey = "rangeOpacities"; - -const char* InstrumentValueArea::_deprecatedGroupKey = "ValuesWidget"; - -QStringList InstrumentValueArea::_iconNames; - -// Important: The indices of these strings must match the InstrumentValueArea::FontSize enum -const QStringList InstrumentValueArea::_fontSizeNames = { - QT_TRANSLATE_NOOP("InstrumentValueArea", "Default"), - QT_TRANSLATE_NOOP("InstrumentValueArea", "Small"), - QT_TRANSLATE_NOOP("InstrumentValueArea", "Medium"), - QT_TRANSLATE_NOOP("InstrumentValueArea", "Large"), -}; - -InstrumentValueArea::InstrumentValueArea(QQuickItem* parent) - : QQuickItem(parent) - , _rowValues(new QmlObjectListModel(this)) -{ - if (_iconNames.isEmpty()) { - QDir iconDir(":/InstrumentValueIcons/"); - _iconNames = iconDir.entryList(); - } - - _connectSignals(); -} - -InstrumentValueArea::InstrumentValueArea(const QString& defaultSettingsGroup) - : QQuickItem (nullptr) - , _defaultSettingsGroup (defaultSettingsGroup) - , _rowValues (new QmlObjectListModel(this)) -{ - - _connectSignals(); -} - -void InstrumentValueArea::_connectSignals(void) -{ - connect(this, &InstrumentValueArea::fontSizeChanged, this, &InstrumentValueArea::_saveSettings); - connect(this, &InstrumentValueArea::orientationChanged, this, &InstrumentValueArea::_saveSettings); -} - -void InstrumentValueArea::componentComplete(void) -{ - QQuickItem::componentComplete(); - - // We should know settingsGroup/defaultSettingsGroup now so we can load settings - _loadSettings(); -} - -InstrumentValueData* InstrumentValueArea::_createNewInstrumentValueWorker(QmlObjectListModel* rowModel) -{ - InstrumentValueData* value = new InstrumentValueData(this, rowModel); - - connect(value, &InstrumentValueData::factNameChanged, this, &InstrumentValueArea::_saveSettings); - connect(value, &InstrumentValueData::factGroupNameChanged, this, &InstrumentValueArea::_saveSettings); - connect(value, &InstrumentValueData::textChanged, this, &InstrumentValueArea::_saveSettings); - connect(value, &InstrumentValueData::showUnitsChanged, this, &InstrumentValueArea::_saveSettings); - connect(value, &InstrumentValueData::iconChanged, this, &InstrumentValueArea::_saveSettings); - connect(value, &InstrumentValueData::rangeTypeChanged, this, &InstrumentValueArea::_saveSettings); - connect(value, &InstrumentValueData::rangeValuesChanged, this, &InstrumentValueArea::_saveSettings); - connect(value, &InstrumentValueData::rangeColorsChanged, this, &InstrumentValueArea::_saveSettings); - connect(value, &InstrumentValueData::rangeOpacitiesChanged, this, &InstrumentValueArea::_saveSettings); - connect(value, &InstrumentValueData::rangeIconsChanged, this, &InstrumentValueArea::_saveSettings); - - return value; -} - -InstrumentValueData* InstrumentValueArea::appendColumn(int rowIndex) -{ - InstrumentValueData* newValue = nullptr; - - if (rowIndex >= 0 && rowIndex < _rowValues->count()) { - QmlObjectListModel* row = _rowValues->value(rowIndex); - newValue = _createNewInstrumentValueWorker(row); - row->append(newValue); - } - _saveSettings(); - - return newValue; -} - -void InstrumentValueArea::deleteLastColumn(int rowIndex) -{ - if (rowIndex >= 0 && rowIndex < _rowValues->count()) { - QmlObjectListModel* row = _rowValues->value(rowIndex); - - if (rowIndex != 0 || row->count() > 1) { - row->removeAt(row->count() - 1); - } - if (row->count() == 0) { - // Last column was deleted, delete the row as well - _rowValues->removeAt(rowIndex); - } - } - _saveSettings(); -} - -QmlObjectListModel* InstrumentValueArea::appendRow(bool addBlanksColumn) -{ - QmlObjectListModel* newRow = new QmlObjectListModel(_rowValues); - _rowValues->append(newRow); - int rowIndex = _rowValues->count() - 1; - if (addBlanksColumn) { - appendColumn(rowIndex); - } - _saveSettings(); - return newRow; -} - -QmlObjectListModel* InstrumentValueArea::insertRow(int atIndex, bool addBlanksColumn) -{ - QmlObjectListModel* newRow = nullptr; - - if (atIndex >= 0 && atIndex < _rowValues->count() + 1) { - QmlObjectListModel* newRow = new QmlObjectListModel(_rowValues); - _rowValues->insert(atIndex, newRow); - if (addBlanksColumn) { - appendColumn(atIndex); - } - _saveSettings(); - } - return newRow; -} - -void InstrumentValueArea::deleteRow(int rowIndex) -{ - if (rowIndex >= 0 && rowIndex < _rowValues->count()) { - if (_rowValues->count() > 1) { - _rowValues->removeAt(rowIndex); - } - _saveSettings(); - } -} - -bool InstrumentValueArea::_validRowIndex(int rowIndex) -{ - return rowIndex >= 0 && rowIndex < _rowValues->count(); -} - -void InstrumentValueArea::_checkForDeprecatedSettings(void) -{ - QSettings settings; - - if (settings.childGroups().contains(_deprecatedGroupKey)) { - settings.remove(_deprecatedGroupKey); - qgcApp()->showAppMessage(tr("The support for custom instrument value display has changed. The display will be reset to the new default setup. You will need to modify it again to suit your needs."), tr("Instrument Values")); - } -} - -void InstrumentValueArea::_saveSettings(void) -{ - if (_preventSaveSettings) { - return; - } - - QSettings settings; - - if (_userSettingsGroup.isEmpty()) { - // This means we are setting up default settings - settings.beginGroup(_defaultSettingsGroup); - } else { - // This means we are saving user modifications - settings.remove(_defaultSettingsGroup); - settings.beginGroup(_userSettingsGroup); - } - - settings.remove(""); // Remove any previous settings - - settings.setValue(_versionKey, 1); - settings.setValue(_fontSizeKey, _fontSize); - settings.setValue(_orientationKey, _orientation); - - settings.beginWriteArray(_rowsKey); - - for (int rowIndex=0; rowIndex<_rowValues->count(); rowIndex++) { - QmlObjectListModel* colValues = _rowValues->value(rowIndex); - - settings.setArrayIndex(rowIndex); - settings.beginWriteArray(_columnsKey); - - for (int colIndex=0; colIndexcount(); colIndex++) { - InstrumentValueData* value = colValues->value(colIndex); - - settings.setArrayIndex(colIndex); - - settings.setValue(_textKey, value->text()); - settings.setValue(_showUnitsKey, value->showUnits()); - settings.setValue(_iconKey, value->icon()); - settings.setValue(_rangeTypeKey, value->rangeType()); - - if (value->rangeType() != InstrumentValueData::NoRangeInfo) { - settings.setValue(_rangeValuesKey, value->rangeValues()); - } - - switch (value->rangeType()) { - case InstrumentValueData::NoRangeInfo: - break; - case InstrumentValueData::ColorRange: - settings.setValue(_rangeColorsKey, value->rangeColors()); - break; - case InstrumentValueData::OpacityRange: - settings.setValue(_rangeOpacitiesKey, value->rangeOpacities()); - break; - case InstrumentValueData::IconSelectRange: - settings.setValue(_rangeIconsKey, value->rangeIcons()); - break; - } - - if (value->fact()) { - settings.setValue(_factGroupNameKey, value->factGroupName()); - settings.setValue(_factNameKey, value->factName()); - } else { - settings.setValue(_factGroupNameKey, ""); - settings.setValue(_factNameKey, ""); - } - } - - settings.endArray(); - } - - settings.endArray(); -} - -void InstrumentValueArea::_loadSettings(void) -{ - _checkForDeprecatedSettings(); - - QSettings settings; - - _rowValues->deleteLater(); - _rowValues = new QmlObjectListModel(this); - emit rowValuesChanged(_rowValues); - - if (!settings.childGroups().contains(_userSettingsGroup)) { - qgcApp()->toolbox()->corePlugin()->instrumentValueAreaCreateDefaultSettings(_defaultSettingsGroup); - } - - _preventSaveSettings = true; - - if (settings.childGroups().contains(_defaultSettingsGroup)) { - settings.beginGroup(_defaultSettingsGroup); - } else { - settings.beginGroup(_userSettingsGroup); - } - - int version = settings.value(_versionKey, 0).toInt(); - if (version != 1) { - qgcApp()->showAppMessage(tr("Load Settings"), tr("Settings version %1 for %2 is not supported. Setup will be reset to defaults.").arg(version).arg(_userSettingsGroup)); - settings.remove(""); - qgcApp()->toolbox()->corePlugin()->instrumentValueAreaCreateDefaultSettings(_defaultSettingsGroup); - } - _fontSize = settings.value(_fontSizeKey, DefaultFontSize).value(); - _orientation = settings.value(_orientationKey, VerticalOrientation).value(); - - int cRows = settings.beginReadArray(_rowsKey); - - for (int rowIndex=0; rowIndexsetFact(settings.value(_factGroupNameKey).toString(), factName); - } - - value->setText (settings.value(_textKey).toString()); - value->setShowUnits (settings.value(_showUnitsKey, true).toBool()); - value->setIcon (settings.value(_iconKey).toString()); - value->setRangeType (settings.value(_rangeTypeKey, InstrumentValueData::NoRangeInfo).value()); - - if (value->rangeType() != InstrumentValueData::NoRangeInfo) { - value->setRangeValues(settings.value(_rangeValuesKey).value()); - } - switch (value->rangeType()) { - case InstrumentValueData::NoRangeInfo: - break; - case InstrumentValueData::ColorRange: - value->setRangeColors(settings.value(_rangeColorsKey).value()); - break; - case InstrumentValueData::OpacityRange: - value->setRangeOpacities(settings.value(_rangeOpacitiesKey).value()); - break; - case InstrumentValueData::IconSelectRange: - value->setRangeIcons(settings.value(_rangeIconsKey).value()); - break; - } - } - - settings.endArray(); - } - - settings.endArray(); - - _preventSaveSettings = false; - - // Use defaults if nothing there - if (_rowValues->count() == 0) { - _rowValues->deleteLater(); - emit rowValuesChanged(_rowValues); - } -} - -void InstrumentValueArea::resetToDefaults(void) -{ - QSettings settings; - - settings.remove(_userSettingsGroup); - - _loadSettings(); -} - -QString InstrumentValueArea::_pascalCase(const QString& text) -{ - return text[0].toUpper() + text.right(text.length() - 1); -} - -void InstrumentValueArea::setFontSize(FontSize fontSize) -{ - if (fontSize != _fontSize) { - _fontSize = fontSize; - emit fontSizeChanged(fontSize); - } -} diff --git a/src/QmlControls/InstrumentValueData.cc b/src/QmlControls/InstrumentValueData.cc index 6421a11f3ffa28a321ab8fc357109fa047acc445..c17606ff8e94ee32a79cce87d0a3edf00dae3d36 100644 --- a/src/QmlControls/InstrumentValueData.cc +++ b/src/QmlControls/InstrumentValueData.cc @@ -8,13 +8,13 @@ ****************************************************************************/ #include "InstrumentValueData.h" -#include "InstrumentValueArea.h" +#include "FactValueGrid.h" #include "QGCApplication.h" #include "QGCCorePlugin.h" #include -const char* InstrumentValueData::_vehicleFactGroupName = "Vehicle"; +const char* InstrumentValueData::vehicleFactGroupName = "Vehicle"; // Important: The indices of these strings must match the InstrumentValueData::RangeType enum const QStringList InstrumentValueData::_rangeTypeNames = { @@ -24,9 +24,9 @@ const QStringList InstrumentValueData::_rangeTypeNames = { QT_TRANSLATE_NOOP("InstrumentValue", "Icon"), }; -InstrumentValueData::InstrumentValueData(InstrumentValueArea* instrumentValueArea, QObject *parent) - : QObject (parent) - , _instrumentValueArea (instrumentValueArea) +InstrumentValueData::InstrumentValueData(FactValueGrid* factValueGrid, QObject* parent) + : QObject (parent) + , _factValueGrid(factValueGrid) { MultiVehicleManager* multiVehicleManager = qgcApp()->toolbox()->multiVehicleManager(); connect(multiVehicleManager, &MultiVehicleManager::activeVehicleChanged, this, &InstrumentValueData::_activeVehicleChanged); @@ -57,14 +57,14 @@ void InstrumentValueData::_activeVehicleChanged(Vehicle* activeVehicle) for (QString& name: _factGroupNames) { name[0] = name[0].toUpper(); } - _factGroupNames.prepend(_vehicleFactGroupName); + _factGroupNames.prepend(vehicleFactGroupName); emit factGroupNamesChanged(_factGroupNames); if (_fact) { _fact = nullptr; FactGroup* factGroup = nullptr; - if (_factGroupName == _vehicleFactGroupName) { + if (_factGroupName == vehicleFactGroupName) { factGroup = _activeVehicle; } else { factGroup = _activeVehicle->getFactGroup(_factGroupName); @@ -108,7 +108,7 @@ void InstrumentValueData::setFact(const QString& factGroupName, const QString& f } FactGroup* factGroup = nullptr; - if (factGroupName == _vehicleFactGroupName) { + if (factGroupName == vehicleFactGroupName) { factGroup = _activeVehicle; } else { factGroup = _activeVehicle->getFactGroup(factGroupName); @@ -225,7 +225,7 @@ void InstrumentValueData::_resetRangeInfo(void) _rangeOpacities.append(1.0); break; case IconSelectRange: - _rangeIcons.append(_instrumentValueArea->iconNames()[0]); + _rangeIcons.append(_factValueGrid->iconNames()[0]); break; } } @@ -250,7 +250,7 @@ void InstrumentValueData::addRangeValue(void) _rangeOpacities.append(1.0); break; case IconSelectRange: - _rangeIcons.append(_instrumentValueArea->iconNames()[0]); + _rangeIcons.append(_factValueGrid->iconNames()[0]); break; } diff --git a/src/QmlControls/InstrumentValueData.h b/src/QmlControls/InstrumentValueData.h index d636608e045c97ad03009e7edd2e10e5895df720..cb6489dbf5cf4dcc7fa1172e6d5b6a11dd7ce228 100644 --- a/src/QmlControls/InstrumentValueData.h +++ b/src/QmlControls/InstrumentValueData.h @@ -15,7 +15,7 @@ #include -class InstrumentValueArea; +class FactValueGrid; class InstrumentValueData : public QObject { @@ -30,9 +30,9 @@ public: }; Q_ENUMS(RangeType) - explicit InstrumentValueData(InstrumentValueArea* instrumentValueArea, QObject *parent = nullptr); + explicit InstrumentValueData(FactValueGrid* factValueGrid, QObject* parent); - Q_PROPERTY(InstrumentValueArea* instrumentValueArea MEMBER _instrumentValueArea CONSTANT) + Q_PROPERTY(FactValueGrid* factValueGrid MEMBER _factValueGrid CONSTANT) Q_PROPERTY(QStringList factGroupNames MEMBER _factGroupNames NOTIFY factGroupNamesChanged) Q_PROPERTY(QStringList factValueNames MEMBER _factValueNames NOTIFY factValueNamesChanged) Q_PROPERTY(QString factGroupName READ factGroupName NOTIFY factGroupNameChanged) @@ -78,6 +78,9 @@ public: void setRangeIcons (const QVariantList& rangeIcons); void setRangeOpacities (const QVariantList& rangeOpacities); + + static const char* vehicleFactGroupName; + signals: void factChanged (Fact* fact); void factNameChanged (const QString& factName); @@ -107,7 +110,7 @@ private: void _updateIcon (void); void _updateOpacity (void); - InstrumentValueArea* _instrumentValueArea = nullptr; + FactValueGrid* _factValueGrid = nullptr; Vehicle* _activeVehicle = nullptr; QmlObjectListModel* _rowModel = nullptr; Fact* _fact = nullptr; @@ -139,7 +142,6 @@ private: // These are user facing string for the various enums. static const QStringList _rangeTypeNames; - static const char* _vehicleFactGroupName; }; QML_DECLARE_TYPE(InstrumentValueData) diff --git a/src/QmlControls/InstrumentValueEditDialog.qml b/src/QmlControls/InstrumentValueEditDialog.qml index 81382c69776b03a753c2ee7c9830134a15d9a3b6..13d891efe213f9d61352ff81cb98a611ba8d331d 100644 --- a/src/QmlControls/InstrumentValueEditDialog.qml +++ b/src/QmlControls/InstrumentValueEditDialog.qml @@ -33,27 +33,13 @@ QGCPopupDialog { GridLayout { rowSpacing: _margins columnSpacing: _margins - columns: 3 - - QGCCheckBox { - id: valueCheckBox - text: qsTr("Value") - checked: instrumentValueData.fact - onClicked: { - if (checked) { - instrumentValueData.setFact(instrumentValueData.factGroupNames[0], instrumentValueData.factValueNames[0]) - } else { - instrumentValueData.clearFact() - } - } - } + columns: 2 QGCComboBox { id: factGroupCombo Layout.fillWidth: true model: instrumentValueData.factGroupNames sizeToContents: true - enabled: valueCheckBox.checked Component.onCompleted: currentIndex = find(instrumentValueData.factGroupName) onActivated: { instrumentValueData.setFact(currentText, "") @@ -71,7 +57,6 @@ QGCPopupDialog { Layout.fillWidth: true model: instrumentValueData.factValueNames sizeToContents: true - enabled: valueCheckBox.checked Component.onCompleted: currentIndex = find(instrumentValueData.factName) onActivated: { instrumentValueData.setFact(instrumentValueData.factGroupName, currentText) @@ -90,17 +75,18 @@ QGCPopupDialog { Component.onCompleted: checked = instrumentValueData.icon != "" onClicked: { instrumentValueData.text = "" - instrumentValueData.icon = instrumentValueData.iconNames[0] + instrumentValueData.icon = instrumentValueData.factValueGrid.iconNames[0] var updateFunction = function(icon){ instrumentValueData.icon = icon } - mainWindow.showPopupDialog(iconPickerDialog, { iconNames: instrumentValueData.instrumentValueArea.iconNames, icon: instrumentValueData.icon, updateIconFunction: updateFunction }) + mainWindow.showPopupDialog(iconPickerDialog, { iconNames: instrumentValueData.factValueGrid.iconNames, icon: instrumentValueData.icon, updateIconFunction: updateFunction }) } } QGCColoredImage { + id: valueIcon Layout.alignment: Qt.AlignHCenter height: ScreenTools.implicitComboBoxHeight width: height - source: "/InstrumentValueIcons/" + (instrumentValueData.icon ? instrumentValueData.icon : instrumentValueData.instrumentValueArea.iconNames[0]) + source: "/InstrumentValueIcons/" + (instrumentValueData.icon ? instrumentValueData.icon : instrumentValueData.factValueGrid.iconNames[0]) sourceSize.height: height fillMode: Image.PreserveAspectFit mipmap: true @@ -112,12 +98,16 @@ QGCPopupDialog { anchors.fill: parent onClicked: { var updateFunction = function(icon){ instrumentValueData.icon = icon } - mainWindow.showPopupDialog(iconPickerDialog, { iconNames: instrumentValueData.instrumentValueArea.iconNames, icon: instrumentValueData.icon, updateIconFunction: updateFunction }) + mainWindow.showPopupDialog(iconPickerDialog, { iconNames: instrumentValueData.factValueGrid.iconNames, icon: instrumentValueData.icon, updateIconFunction: updateFunction }) } } - } - Item { height: 1; width: 1 } + Rectangle { + anchors.fill: valueIcon + color: qgcPal.text + visible: valueIcon.status === Image.Error + } + } QGCRadioButton { id: textRadio @@ -132,7 +122,6 @@ QGCPopupDialog { QGCTextField { id: labelTextField Layout.fillWidth: true - Layout.columnSpan: 2 Layout.preferredWidth: ScreenTools.defaultFontPixelWidth * 10 text: instrumentValueData.text enabled: textRadio.checked @@ -144,13 +133,14 @@ QGCPopupDialog { QGCComboBox { id: fontSizeCombo Layout.fillWidth: true - model: instrumentValueData.instrumentValueArea.fontSizeNames - currentIndex: instrumentValueData.instrumentValueArea.fontSize + model: instrumentValueData.factValueGrid.fontSizeNames + currentIndex: instrumentValueData.factValueGrid.fontSize sizeToContents: true - onActivated: instrumentValueData.instrumentValueArea.fontSize = index + onActivated: instrumentValueData.factValueGrid.fontSize = index } QGCCheckBox { + Layout.columnSpan: 2 text: qsTr("Show Units") checked: instrumentValueData.showUnits onClicked: instrumentValueData.showUnits = checked @@ -160,7 +150,6 @@ QGCPopupDialog { QGCComboBox { id: rangeTypeCombo - Layout.columnSpan: 2 Layout.fillWidth: true model: instrumentValueData.rangeTypeNames currentIndex: instrumentValueData.rangeType @@ -170,7 +159,7 @@ QGCPopupDialog { Loader { id: rangeLoader - Layout.columnSpan: 3 + Layout.columnSpan: 2 Layout.fillWidth: true Layout.preferredWidth: item ? item.width : 0 Layout.preferredHeight: item ? item.height : 0 @@ -403,7 +392,7 @@ QGCPopupDialog { anchors.fill: parent onClicked: { var updateFunction = function(icon){ updateIconValue(index, icon) } - mainWindow.showPopupDialog(iconPickerDialog, { iconNames: instrumentValueData.instrumentValueArea.iconNames, icon: modelData, updateIconFunction: updateFunction }) + mainWindow.showPopupDialog(iconPickerDialog, { iconNames: instrumentValueData.factValueGrid.iconNames, icon: modelData, updateIconFunction: updateFunction }) } } } diff --git a/src/QmlControls/InstrumentValueLabel.qml b/src/QmlControls/InstrumentValueLabel.qml new file mode 100644 index 0000000000000000000000000000000000000000..4d3a05456717205acf53dadb81ce8de4caf69f98 --- /dev/null +++ b/src/QmlControls/InstrumentValueLabel.qml @@ -0,0 +1,82 @@ +/**************************************************************************** + * + * (c) 2009-2020 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + +import QtQuick 2.12 +import QtQuick.Layouts 1.2 +import QtQuick.Controls 2.5 + +import QGroundControl 1.0 +import QGroundControl.Controls 1.0 +import QGroundControl.Templates 1.0 +import QGroundControl.ScreenTools 1.0 +import QGroundControl.Palette 1.0 + +ColumnLayout { + property var instrumentValueData: null + + property bool _verticalOrientation: instrumentValueData.factValueGrid.orientation === FactValueGrid.VerticalOrientation + property var _rgFontSizes: [ ScreenTools.defaultFontPointSize, ScreenTools.smallFontPointSize, ScreenTools.mediumFontPointSize, ScreenTools.largeFontPointSize ] + property var _rgFontSizeRatios: [ 1, ScreenTools.smallFontPointRatio, ScreenTools.mediumFontPointRatio, ScreenTools.largeFontPointRatio ] + property real _doubleDescent: ScreenTools.defaultFontDescent * 2 + property real _tightDefaultFontHeight: ScreenTools.defaultFontPixelHeight - _doubleDescent + property var _rgFontSizeTightHeights: [ _tightDefaultFontHeight * _rgFontSizeRatios[0] + 2, _tightDefaultFontHeight * _rgFontSizeRatios[1] + 2, _tightDefaultFontHeight * _rgFontSizeRatios[2] + 2, _tightDefaultFontHeight * _rgFontSizeRatios[3] + 2 ] + property real _tightHeight: _rgFontSizeTightHeights[instrumentValueData.factValueGrid.fontSize] + property bool _iconVisible: instrumentValueData.rangeType === InstrumentValueData.IconSelectRange || instrumentValueData.icon + + QGCPalette { id: qgcPal; colorGroupEnabled: enabled } + + QGCColoredImage { + id: valueIcon + Layout.alignment: _verticalOrientation ? Qt.AlignHCenter : Qt.AlignVCenter + height: _tightHeight * 0.75 + width: height + sourceSize.height: height + fillMode: Image.PreserveAspectFit + mipmap: true + smooth: true + color: instrumentValueData.isValidColor(instrumentValueData.currentColor) ? instrumentValueData.currentColor : qgcPal.text + opacity: instrumentValueData.currentOpacity + visible: _iconVisible + + + readonly property string iconPrefix: "/InstrumentValueIcons/" + + function updateIcon() { + if (instrumentValueData.rangeType === InstrumentValueData.IconSelectRange) { + valueIcon.source = iconPrefix + instrumentValueData.currentIcon + } else if (instrumentValueData.icon) { + valueIcon.source = iconPrefix + instrumentValueData.icon + } else { + valueIcon.source = "" + } + } + + Connections { + target: instrumentValueData + onRangeTypeChanged: valueIcon.updateIcon() + onCurrentIconChanged: valueIcon.updateIcon() + onIconChanged: valueIcon.updateIcon() + } + Component.onCompleted: updateIcon(); + + Rectangle { + anchors.fill: valueIcon + color: qgcPal.text + visible: valueIcon.status === Image.Error + } + } + + QGCLabel { + Layout.alignment: _verticalOrientation ? Qt.AlignHCenter : Qt.AlignVCenter + height: _tightHeight + font.pointSize: ScreenTools.smallFontPointSize + text: instrumentValueData.text + visible: !_iconVisible + } +} diff --git a/src/QmlControls/InstrumentValueValue.qml b/src/QmlControls/InstrumentValueValue.qml new file mode 100644 index 0000000000000000000000000000000000000000..dd63bb79855048d62d118054e9f7a13c3b2cfb6a --- /dev/null +++ b/src/QmlControls/InstrumentValueValue.qml @@ -0,0 +1,46 @@ +/**************************************************************************** + * + * (c) 2009-2020 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + +import QtQuick 2.12 +import QtQuick.Layouts 1.2 +import QtQuick.Controls 2.5 + +import QGroundControl 1.0 +import QGroundControl.Controls 1.0 +import QGroundControl.Templates 1.0 +import QGroundControl.Templates 1.0 +import QGroundControl.ScreenTools 1.0 +import QGroundControl.Palette 1.0 + +ColumnLayout { + property var instrumentValueData: null + property bool settingsUnlocked: false + + property bool _verticalOrientation: instrumentValueData.factValueGrid.orientation === FactValueGrid.VerticalOrientation + property var _rgFontSizes: [ ScreenTools.defaultFontPointSize, ScreenTools.smallFontPointSize, ScreenTools.mediumFontPointSize, ScreenTools.largeFontPointSize ] + property var _rgFontSizeRatios: [ 1, ScreenTools.smallFontPointRatio, ScreenTools.mediumFontPointRatio, ScreenTools.largeFontPointRatio ] + property real _doubleDescent: ScreenTools.defaultFontDescent * 2 + property real _tightDefaultFontHeight: ScreenTools.defaultFontPixelHeight - _doubleDescent + property var _rgFontSizeTightHeights: [ _tightDefaultFontHeight * _rgFontSizeRatios[0] + 2, _tightDefaultFontHeight * _rgFontSizeRatios[1] + 2, _tightDefaultFontHeight * _rgFontSizeRatios[2] + 2, _tightDefaultFontHeight * _rgFontSizeRatios[3] + 2 ] + property real _tightHeight: _rgFontSizeTightHeights[instrumentValueData.factValueGrid.fontSize] + property real _fontSize: _rgFontSizes[instrumentValueData.factValueGrid.fontSize] + property real _horizontalLabelSpacing: ScreenTools.defaultFontPixelWidth + property bool _valueVisible: instrumentValueData.fact + property real _width: 0 + property real _height: 0 + + QGCLabel { + Layout.alignment: _verticalOrientation ? Qt.AlignHCenter : Qt.AlignVCenter + font.pointSize: _fontSize + text: instrumentValueData.fact.enumOrValueString + (instrumentValueData.showUnits ? " " + instrumentValueData.fact.units : "") + visible: _valueVisible + + QGCPalette { id: qgcPal; colorGroupEnabled: enabled } + } +} diff --git a/src/QmlControls/QGCControlDebug.qml b/src/QmlControls/QGCControlDebug.qml index 35f95fd6a75ba6fbe07cfece288b1a59fa49586a..60227c4ba5c00f879e81ad4fb657075828b53bb6 100644 --- a/src/QmlControls/QGCControlDebug.qml +++ b/src/QmlControls/QGCControlDebug.qml @@ -9,19 +9,30 @@ import QtQuick 2.12 -Item { - property string name: "control" +Rectangle { + id: _root + border.width: borderColor === undefined ? 0 : 1 + border.color: borderColor + color: "transparent" - Component.onCompleted: console.log("QGCControlDebug.onCompleted name,x,y,width,height,visible,z,parent", name, x, y, width, height, visible, z, parent) + property string name + property color borderColor + + function logEverything() { + console.log(qsTr("%1 x:%2 y:%3 width:%4 height:%5 visible: %6 enabled: %7 z:%8 parent:%9 implicitWidth/Height:%10:%11", "Do not translate").arg(name).arg(parent.x).arg(parent.y).arg(parent.width).arg(parent.height).arg(parent.visible).arg(parent.enabled).arg(parent.z).arg(parent.parent)) + } + + Component.onCompleted: logEverything() Connections { target: parent - onXChanged: console.log(name, "xChanged", parent.x) - onYChanged: console.log(name, "yChanged", parent.y) - onWidthChanged: console.log(name, "widthChanged", parent.width) - onHeightChanged: console.log(name, "heightChanged", parent.height) - onVisibleChanged: console.log(name, "visibleChanged", parent.visible) - onZChanged: console.log(name, "zChanged", parent.z) - onParentChanged: console.log(name, "parentChanged", parent.parent) + onXChanged: { console.log(name, "xChanged", parent.x); logEverything() } + onYChanged: { console.log(name, "yChanged", parent.y); logEverything() } + onWidthChanged: { console.log(name, "widthChanged", parent.width); logEverything() } + onHeightChanged: { console.log(name, "heightChanged", parent.height); logEverything() } + onVisibleChanged: { console.log(name, "visibleChanged", parent.visible); logEverything() } + onZChanged: { console.log(name, "zChanged", parent.z); logEverything() } + onParentChanged: { console.log(name, "parentChanged", parent.parent); logEverything() } + onEnabledChanged: { console.log(name, "enabledChanged", parent.enabled); logEverything() } } } diff --git a/src/QmlControls/QGroundControl/Controls/qmldir b/src/QmlControls/QGroundControl/Controls/qmldir index d1d19cc3eca594e0797e624710ad77dc198f63e0..3fd6b4b5843f556df4dd9dcebf7b81056b727f45 100644 --- a/src/QmlControls/QGroundControl/Controls/qmldir +++ b/src/QmlControls/QGroundControl/Controls/qmldir @@ -1,108 +1,110 @@ Module QGroundControl.Controls -AnalyzePage 1.0 AnalyzePage.qml -AppMessages 1.0 AppMessages.qml -AxisMonitor 1.0 AxisMonitor.qml -CameraCalcCamera 1.0 CameraCalcCamera.qml -CameraCalcGrid 1.0 CameraCalcGrid.qml -ContentAreaCalc 1.0 ContentAreaCalc.qml -APMSubMotorDisplay 1.0 APMSubMotorDisplay.qml -CameraSection 1.0 CameraSection.qml -ClickableColor 1.0 ClickableColor.qml -DeadMouseArea 1.0 DeadMouseArea.qml -DropButton 1.0 DropButton.qml -DropPanel 1.0 DropPanel.qml -EditPositionDialog 1.0 EditPositionDialog.qml -ExclusiveGroupItem 1.0 ExclusiveGroupItem.qml -FactSliderPanel 1.0 FactSliderPanel.qml -FileButton 1.0 FileButton.qml -FlightModeDropdown 1.0 FlightModeDropdown.qml -FlightModeMenu 1.0 FlightModeMenu.qml -GeoFenceEditor 1.0 GeoFenceEditor.qml -GeoFenceMapVisuals 1.0 GeoFenceMapVisuals.qml -HackFileDialog 1.0 HackFileDialog.qml -HeightIndicator 1.0 HeightIndicator.qml -IndicatorButton 1.0 IndicatorButton.qml -InstrumentValue 1.0 InstrumentValue.qml -InstrumentValueArea 1.0 InstrumentValueArea.qml -InstrumentValueEditDialog 1.0 InstrumentValueEditDialog.qml -JoystickThumbPad 1.0 JoystickThumbPad.qml -KMLOrSHPFileDialog 1.0 KMLOrSHPFileDialog.qml -LogReplayStatusBar 1.0 LogReplayStatusBar.qml -MainWindowSavedState 1.0 MainWindowSavedState.qml -MAVLinkMessageButton 1.0 MAVLinkMessageButton.qml -MissionCommandDialog 1.0 MissionCommandDialog.qml -MissionItemEditor 1.0 MissionItemEditor.qml -MissionItemIndexLabel 1.0 MissionItemIndexLabel.qml -MissionItemMapVisual 1.0 MissionItemMapVisual.qml -MissionItemStatus 1.0 MissionItemStatus.qml -ModeSwitchDisplay 1.0 ModeSwitchDisplay.qml -MultiRotorMotorDisplay 1.0 MultiRotorMotorDisplay.qml -OfflineMapButton 1.0 OfflineMapButton.qml -PageView 1.0 PageView.qml -ParameterEditor 1.0 ParameterEditor.qml -ParameterEditorDialog 1.0 ParameterEditorDialog.qml -PIDTuning 1.0 PIDTuning.qml -PlanEditToolbar 1.0 PlanEditToolbar.qml -PreFlightCheckButton 1.0 PreFlightCheckButton.qml -PreFlightCheckGroup 1.0 PreFlightCheckGroup.qml -PreFlightCheckModel 1.0 PreFlightCheckModel.qml -QGCButton 1.0 QGCButton.qml -QGCCheckBox 1.0 QGCCheckBox.qml -QGCColoredImage 1.0 QGCColoredImage.qml -QGCComboBox 1.0 QGCComboBox.qml -QGCControlDebug 1.0 QGCControlDebug.qml -QGCDynamicObjectManager 1.0 QGCDynamicObjectManager.qml -QGCFileDialog 1.0 QGCFileDialog.qml -QGCFlickable 1.0 QGCFlickable.qml -QGCGroupBox 1.0 QGCGroupBox.qml -QGCLabel 1.0 QGCLabel.qml -QGCListView 1.0 QGCListView.qml -QGCMapCircleVisuals 1.0 QGCMapCircleVisuals.qml -QGCMapLabel 1.0 QGCMapLabel.qml -QGCMapPolygonVisuals 1.0 QGCMapPolygonVisuals.qml -QGCMapPolylineVisuals 1.0 QGCMapPolylineVisuals.qml -QGCMenu 1.0 QGCMenu.qml -QGCMenuItem 1.0 QGCMenuItem.qml -QGCMenuSeparator 1.0 QGCMenuSeparator.qml -QGCMouseArea 1.0 QGCMouseArea.qml -QGCMovableItem 1.0 QGCMovableItem.qml -QGCOptionsComboBox 1.0 QGCOptionsComboBox.qml -QGCPipOverlay 1.0 QGCPipOverlay.qml -QGCPipState 1.0 QGCPipState.qml -QGCPopupDialog 1.0 QGCPopupDialog.qml -QGCPopupDialogContainer 1.0 QGCPopupDialogContainer.qml -QGCRadioButton 1.0 QGCRadioButton.qml -QGCSlider 1.0 QGCSlider.qml -QGCSwitch 1.0 QGCSwitch.qml -QGCTabBar 1.0 QGCTabBar.qml -QGCTabButton 1.0 QGCTabButton.qml -QGCTextField 1.0 QGCTextField.qml -QGCToolBarButton 1.0 QGCToolBarButton.qml -QGCToolInsets 1.0 QGCToolInsets.qml -QGCViewDialog 1.0 QGCViewDialog.qml -QGCViewDialogContainer 1.0 QGCViewDialogContainer.qml -QGCViewMessage 1.0 QGCViewMessage.qml -RallyPointEditorHeader 1.0 RallyPointEditorHeader.qml -RallyPointItemEditor 1.0 RallyPointItemEditor.qml -RallyPointMapVisuals 1.0 RallyPointMapVisuals.qml -RCChannelMonitor 1.0 RCChannelMonitor.qml -RCToParamDialog 1.0 RCToParamDialog.qml -RoundButton 1.0 RoundButton.qml -SectionHeader 1.0 SectionHeader.qml -SetupPage 1.0 SetupPage.qml -SignalStrength 1.0 SignalStrength.qml -SimpleItemMapVisuals 1.0 SimpleItemMapVisuals.qml -SliderSwitch 1.0 SliderSwitch.qml -SubMenuButton 1.0 SubMenuButton.qml -SurveyMapVisuals 1.0 SurveyMapVisuals.qml -TerrainStatus 1.0 TerrainStatus.qml -TransectStyleComplexItemStats 1.0 TransectStyleComplexItemStats.qml -TransectStyleMapVisuals 1.0 TransectStyleMapVisuals.qml -ToolBarBase 1.0 ToolBarBase.qml -ToolStrip 1.0 ToolStrip.qml -VehicleRotationCal 1.0 VehicleRotationCal.qml -VehicleSummaryRow 1.0 VehicleSummaryRow.qml -ViewWidget 1.0 ViewWidget.qml -QGCHoverButton 1.0 QGCHoverButton.qml -MAVLinkChart 1.0 MAVLinkChart.qml +AnalyzePage 1.0 AnalyzePage.qml +AppMessages 1.0 AppMessages.qml +AxisMonitor 1.0 AxisMonitor.qml +CameraCalcCamera 1.0 CameraCalcCamera.qml +CameraCalcGrid 1.0 CameraCalcGrid.qml +ContentAreaCalc 1.0 ContentAreaCalc.qml +APMSubMotorDisplay 1.0 APMSubMotorDisplay.qml +CameraSection 1.0 CameraSection.qml +ClickableColor 1.0 ClickableColor.qml +DeadMouseArea 1.0 DeadMouseArea.qml +DropButton 1.0 DropButton.qml +DropPanel 1.0 DropPanel.qml +EditPositionDialog 1.0 EditPositionDialog.qml +ExclusiveGroupItem 1.0 ExclusiveGroupItem.qml +FactSliderPanel 1.0 FactSliderPanel.qml +FileButton 1.0 FileButton.qml +FlightModeDropdown 1.0 FlightModeDropdown.qml +FlightModeMenu 1.0 FlightModeMenu.qml +GeoFenceEditor 1.0 GeoFenceEditor.qml +GeoFenceMapVisuals 1.0 GeoFenceMapVisuals.qml +HackFileDialog 1.0 HackFileDialog.qml +HeightIndicator 1.0 HeightIndicator.qml +HorizontalFactValueGrid 1.0 HorizontalFactValueGrid.qml +IndicatorButton 1.0 IndicatorButton.qml +InstrumentValueLabel 1.0 InstrumentValueLabel.qml +InstrumentValueValue 1.0 InstrumentValueValue.qml +InstrumentValueEditDialog 1.0 InstrumentValueEditDialog.qml +JoystickThumbPad 1.0 JoystickThumbPad.qml +KMLOrSHPFileDialog 1.0 KMLOrSHPFileDialog.qml +LogReplayStatusBar 1.0 LogReplayStatusBar.qml +MainWindowSavedState 1.0 MainWindowSavedState.qml +MAVLinkMessageButton 1.0 MAVLinkMessageButton.qml +MissionCommandDialog 1.0 MissionCommandDialog.qml +MissionItemEditor 1.0 MissionItemEditor.qml +MissionItemIndexLabel 1.0 MissionItemIndexLabel.qml +MissionItemMapVisual 1.0 MissionItemMapVisual.qml +MissionItemStatus 1.0 MissionItemStatus.qml +ModeSwitchDisplay 1.0 ModeSwitchDisplay.qml +MultiRotorMotorDisplay 1.0 MultiRotorMotorDisplay.qml +OfflineMapButton 1.0 OfflineMapButton.qml +PageView 1.0 PageView.qml +ParameterEditor 1.0 ParameterEditor.qml +ParameterEditorDialog 1.0 ParameterEditorDialog.qml +PIDTuning 1.0 PIDTuning.qml +PlanEditToolbar 1.0 PlanEditToolbar.qml +PreFlightCheckButton 1.0 PreFlightCheckButton.qml +PreFlightCheckGroup 1.0 PreFlightCheckGroup.qml +PreFlightCheckModel 1.0 PreFlightCheckModel.qml +QGCButton 1.0 QGCButton.qml +QGCCheckBox 1.0 QGCCheckBox.qml +QGCColoredImage 1.0 QGCColoredImage.qml +QGCComboBox 1.0 QGCComboBox.qml +QGCControlDebug 1.0 QGCControlDebug.qml +QGCDynamicObjectManager 1.0 QGCDynamicObjectManager.qml +QGCFileDialog 1.0 QGCFileDialog.qml +QGCFlickable 1.0 QGCFlickable.qml +QGCGroupBox 1.0 QGCGroupBox.qml +QGCLabel 1.0 QGCLabel.qml +QGCListView 1.0 QGCListView.qml +QGCMapCircleVisuals 1.0 QGCMapCircleVisuals.qml +QGCMapLabel 1.0 QGCMapLabel.qml +QGCMapPolygonVisuals 1.0 QGCMapPolygonVisuals.qml +QGCMapPolylineVisuals 1.0 QGCMapPolylineVisuals.qml +QGCMenu 1.0 QGCMenu.qml +QGCMenuItem 1.0 QGCMenuItem.qml +QGCMenuSeparator 1.0 QGCMenuSeparator.qml +QGCMouseArea 1.0 QGCMouseArea.qml +QGCMovableItem 1.0 QGCMovableItem.qml +QGCOptionsComboBox 1.0 QGCOptionsComboBox.qml +QGCPipOverlay 1.0 QGCPipOverlay.qml +QGCPipState 1.0 QGCPipState.qml +QGCPopupDialog 1.0 QGCPopupDialog.qml +QGCPopupDialogContainer 1.0 QGCPopupDialogContainer.qml +QGCRadioButton 1.0 QGCRadioButton.qml +QGCSlider 1.0 QGCSlider.qml +QGCSwitch 1.0 QGCSwitch.qml +QGCTabBar 1.0 QGCTabBar.qml +QGCTabButton 1.0 QGCTabButton.qml +QGCTextField 1.0 QGCTextField.qml +QGCToolBarButton 1.0 QGCToolBarButton.qml +QGCToolInsets 1.0 QGCToolInsets.qml +QGCViewDialog 1.0 QGCViewDialog.qml +QGCViewDialogContainer 1.0 QGCViewDialogContainer.qml +QGCViewMessage 1.0 QGCViewMessage.qml +RallyPointEditorHeader 1.0 RallyPointEditorHeader.qml +RallyPointItemEditor 1.0 RallyPointItemEditor.qml +RallyPointMapVisuals 1.0 RallyPointMapVisuals.qml +RCChannelMonitor 1.0 RCChannelMonitor.qml +RCToParamDialog 1.0 RCToParamDialog.qml +RoundButton 1.0 RoundButton.qml +SectionHeader 1.0 SectionHeader.qml +SetupPage 1.0 SetupPage.qml +SignalStrength 1.0 SignalStrength.qml +SimpleItemMapVisuals 1.0 SimpleItemMapVisuals.qml +SliderSwitch 1.0 SliderSwitch.qml +SubMenuButton 1.0 SubMenuButton.qml +SurveyMapVisuals 1.0 SurveyMapVisuals.qml +TerrainStatus 1.0 TerrainStatus.qml +TransectStyleComplexItemStats 1.0 TransectStyleComplexItemStats.qml +TransectStyleMapVisuals 1.0 TransectStyleMapVisuals.qml +ToolBarBase 1.0 ToolBarBase.qml +ToolStrip 1.0 ToolStrip.qml +VehicleRotationCal 1.0 VehicleRotationCal.qml +VehicleSummaryRow 1.0 VehicleSummaryRow.qml +VerticalFactValueGrid 1.0 VerticalFactValueGrid.qml +ViewWidget 1.0 ViewWidget.qml +QGCHoverButton 1.0 QGCHoverButton.qml +MAVLinkChart 1.0 MAVLinkChart.qml diff --git a/src/QmlControls/VerticalFactValueGrid.cc b/src/QmlControls/VerticalFactValueGrid.cc new file mode 100644 index 0000000000000000000000000000000000000000..55d448a52cf99ab265d8309e2b133129c96bb553 --- /dev/null +++ b/src/QmlControls/VerticalFactValueGrid.cc @@ -0,0 +1,30 @@ +/**************************************************************************** + * + * (c) 2009-2020 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + +#include "VerticalFactValueGrid.h" +#include "InstrumentValueData.h" +#include "QGCApplication.h" +#include "QGCCorePlugin.h" + +#include + +const QString VerticalFactValueGrid::_valuePageUserSettingsGroup ("ValuePageUserSettings2"); +const QString VerticalFactValueGrid::valuePageDefaultSettingsGroup("ValuePageDefaultSettings2"); + +VerticalFactValueGrid::VerticalFactValueGrid(QQuickItem* parent) + : FactValueGrid(parent) +{ + _orientation = VerticalOrientation; +} + +VerticalFactValueGrid::VerticalFactValueGrid(const QString& defaultSettingsGroup) + : FactValueGrid(defaultSettingsGroup) +{ + _orientation = VerticalOrientation; +} diff --git a/src/QmlControls/VerticalFactValueGrid.h b/src/QmlControls/VerticalFactValueGrid.h new file mode 100644 index 0000000000000000000000000000000000000000..f022be138378a73366fa9047eb5154bcccd3ebd7 --- /dev/null +++ b/src/QmlControls/VerticalFactValueGrid.h @@ -0,0 +1,38 @@ +/**************************************************************************** + * + * (c) 2009-2020 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + +#pragma once + +#include "FactSystem.h" +#include "QmlObjectListModel.h" +#include "QGCApplication.h" +#include "FactValueGrid.h" + +class InstrumentValueData; + +class VerticalFactValueGrid : public FactValueGrid +{ + Q_OBJECT + +public: + VerticalFactValueGrid(QQuickItem *parent = nullptr); + VerticalFactValueGrid(const QString& defaultSettingsGroup); + + Q_PROPERTY(QString valuePageDefaultSettingsGroup MEMBER valuePageDefaultSettingsGroup CONSTANT) + Q_PROPERTY(QString valuePageUserSettingsGroup MEMBER _valuePageUserSettingsGroup CONSTANT) + + static const QString valuePageDefaultSettingsGroup; + +private: + Q_DISABLE_COPY(VerticalFactValueGrid) + + static const QString _valuePageUserSettingsGroup; +}; + +QML_DECLARE_TYPE(VerticalFactValueGrid) diff --git a/src/QmlControls/VerticalFactValueGrid.qml b/src/QmlControls/VerticalFactValueGrid.qml new file mode 100644 index 0000000000000000000000000000000000000000..ea9fbbcfca070a34c838423ad71a167ffe1fd2c1 --- /dev/null +++ b/src/QmlControls/VerticalFactValueGrid.qml @@ -0,0 +1,165 @@ +/**************************************************************************** + * + * (c) 2009-2020 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + +import QtQuick 2.12 +import QtQuick.Layouts 1.2 +import QtQuick.Controls 2.5 +import QtQml 2.12 + +import QGroundControl.Templates 1.0 as T +import QGroundControl.Controls 1.0 +import QGroundControl.ScreenTools 1.0 +import QGroundControl.Controllers 1.0 +import QGroundControl.Palette 1.0 +import QGroundControl.FlightMap 1.0 +import QGroundControl 1.0 + +// Note: This control will spit out qWarnings like this: "QGridLayoutEngine::addItem: Cell (0, 1) already taken" +// This is due to Qt bug https://bugreports.qt.io/browse/QTBUG-65121 +// If this becomes a problem I'll implement our own grid layout control + +T.VerticalFactValueGrid { + id: _root + height: childrenRect.height + + property bool settingsUnlocked: false + + QGCPalette { id: qgcPal; colorGroupEnabled: enabled } + + RowLayout { + id: topLevelRowLayout + width: parent.width + + ColumnLayout { + Layout.fillWidth: true + + GridLayout { + id: valueGrid + Layout.preferredWidth: _root.width + rows: _root.rows.count * 2 + rowSpacing: 0 + + Repeater { + model: _root.rows + + Repeater { + id: labelRepeater + model: object + + property real _index: index + + InstrumentValueLabel { + Layout.row: labelRepeater._index * 2 + Layout.column: index + Layout.fillWidth: true + Layout.alignment: Qt.AlignHCenter + instrumentValueData: object + } + } + } + + Repeater { + model: _root.rows + + Repeater { + id: valueRepeater + model: object + + property real _index: index + + InstrumentValueValue { + Layout.row: valueRepeater._index * 2 + 1 + Layout.column: index + Layout.fillWidth: true + Layout.alignment: Qt.AlignHCenter + instrumentValueData: object + } + } + } + } + + RowLayout { + id: rowButtons + height: ScreenTools.minTouchPixels / 2 + Layout.fillWidth: true + spacing: 1 + visible: settingsUnlocked + + QGCButton { + Layout.fillWidth: true + Layout.preferredHeight: parent.height + text: qsTr("+") + onClicked: appendRow() + } + + QGCButton { + Layout.fillWidth: true + Layout.preferredHeight: parent.height + text: qsTr("-") + enabled: _root.rows.count > 1 + onClicked: deleteLastRow() + } + } + } + + ColumnLayout { + Layout.fillHeight: true + Layout.bottomMargin: rowButtons.height + width: ScreenTools.minTouchPixels / 2 + spacing: 1 + visible: settingsUnlocked + + QGCButton { + Layout.fillHeight: true + Layout.preferredHeight: ScreenTools.minTouchPixels + Layout.preferredWidth: parent.width + text: qsTr("+") + onClicked: appendColumn() + } + + QGCButton { + Layout.fillHeight: true + Layout.preferredHeight: ScreenTools.minTouchPixels + Layout.preferredWidth: parent.width + text: qsTr("-") + enabled: _root.columnCount > 1 + onClicked: deleteLastColumn() + } + } + } + + QGCMouseArea { + x: valueGrid.x + y: valueGrid.y + width: valueGrid.width + height: valueGrid.height + visible: settingsUnlocked + onClicked: { + var item = valueGrid.childAt(mouse.x, mouse.y) + //console.log(item, item ? item.instrumentValueData : "null", item && item.parent ? item.parent.instrumentValueData : "null") + if (item && item.instrumentValueData !== undefined) { + mainWindow.showPopupDialog(valueEditDialog, { instrumentValueData: item.instrumentValueData }) + } + } + + /*Rectangle { + anchors.fill: parent + border.color: "green" + border.width: 1 + color: "transparent" + }*/ + } + + Component { + id: valueEditDialog + + InstrumentValueEditDialog { } + } +} + diff --git a/src/api/QGCCorePlugin.cc b/src/api/QGCCorePlugin.cc index 8597bffa873819e609214f93bb780a9a7277acef..b72625ade688ea7820ca7ec2f7d11665dca31187 100644 --- a/src/api/QGCCorePlugin.cc +++ b/src/api/QGCCorePlugin.cc @@ -22,7 +22,8 @@ #endif #include "QGCLoggingCategory.h" #include "QGCCameraManager.h" -#include "InstrumentValueArea.h" +#include "HorizontalFactValueGrid.h" +#include "VerticalFactValueGrid.h" #include "InstrumentValueData.h" #include @@ -220,55 +221,55 @@ QVariantList &QGCCorePlugin::settingsPages() { if(!_p->pGeneral) { _p->pGeneral = new QmlComponentInfo(tr("General"), - QUrl::fromUserInput("qrc:/qml/GeneralSettings.qml"), - QUrl::fromUserInput("qrc:/res/gear-white.svg")); + QUrl::fromUserInput("qrc:/qml/GeneralSettings.qml"), + QUrl::fromUserInput("qrc:/res/gear-white.svg")); _p->settingsList.append(QVariant::fromValue(reinterpret_cast(_p->pGeneral))); _p->pCommLinks = new QmlComponentInfo(tr("Comm Links"), - QUrl::fromUserInput("qrc:/qml/LinkSettings.qml"), - QUrl::fromUserInput("qrc:/res/waves.svg")); + QUrl::fromUserInput("qrc:/qml/LinkSettings.qml"), + QUrl::fromUserInput("qrc:/res/waves.svg")); _p->settingsList.append(QVariant::fromValue(reinterpret_cast(_p->pCommLinks))); _p->pOfflineMaps = new QmlComponentInfo(tr("Offline Maps"), - QUrl::fromUserInput("qrc:/qml/OfflineMap.qml"), - QUrl::fromUserInput("qrc:/res/waves.svg")); + QUrl::fromUserInput("qrc:/qml/OfflineMap.qml"), + QUrl::fromUserInput("qrc:/res/waves.svg")); _p->settingsList.append(QVariant::fromValue(reinterpret_cast(_p->pOfflineMaps))); #if defined(QGC_GST_TAISYNC_ENABLED) _p->pTaisync = new QmlComponentInfo(tr("Taisync"), - QUrl::fromUserInput("qrc:/qml/TaisyncSettings.qml"), - QUrl::fromUserInput("")); + QUrl::fromUserInput("qrc:/qml/TaisyncSettings.qml"), + QUrl::fromUserInput("")); _p->settingsList.append(QVariant::fromValue(reinterpret_cast(_p->pTaisync))); #endif #if defined(QGC_GST_MICROHARD_ENABLED) _p->pMicrohard = new QmlComponentInfo(tr("Microhard"), - QUrl::fromUserInput("qrc:/qml/MicrohardSettings.qml"), - QUrl::fromUserInput("")); + QUrl::fromUserInput("qrc:/qml/MicrohardSettings.qml"), + QUrl::fromUserInput("")); _p->settingsList.append(QVariant::fromValue(reinterpret_cast(_p->pMicrohard))); #endif #if defined(QGC_AIRMAP_ENABLED) _p->pAirmap = new QmlComponentInfo(tr("AirMap"), - QUrl::fromUserInput("qrc:/qml/AirmapSettings.qml"), - QUrl::fromUserInput("")); + QUrl::fromUserInput("qrc:/qml/AirmapSettings.qml"), + QUrl::fromUserInput("")); _p->settingsList.append(QVariant::fromValue(reinterpret_cast(_p->pAirmap))); #endif _p->pMAVLink = new QmlComponentInfo(tr("MAVLink"), - QUrl::fromUserInput("qrc:/qml/MavlinkSettings.qml"), - QUrl::fromUserInput("qrc:/res/waves.svg")); + QUrl::fromUserInput("qrc:/qml/MavlinkSettings.qml"), + QUrl::fromUserInput("qrc:/res/waves.svg")); _p->settingsList.append(QVariant::fromValue(reinterpret_cast(_p->pMAVLink))); _p->pConsole = new QmlComponentInfo(tr("Console"), - QUrl::fromUserInput("qrc:/qml/QGroundControl/Controls/AppMessages.qml")); + QUrl::fromUserInput("qrc:/qml/QGroundControl/Controls/AppMessages.qml")); _p->settingsList.append(QVariant::fromValue(reinterpret_cast(_p->pConsole))); _p->pHelp = new QmlComponentInfo(tr("Help"), - QUrl::fromUserInput("qrc:/qml/HelpSettings.qml")); + QUrl::fromUserInput("qrc:/qml/HelpSettings.qml")); _p->settingsList.append(QVariant::fromValue(reinterpret_cast(_p->pHelp))); #if defined(QT_DEBUG) //-- These are always present on Debug builds _p->pMockLink = new QmlComponentInfo(tr("Mock Link"), - QUrl::fromUserInput("qrc:/qml/MockLink.qml")); + QUrl::fromUserInput("qrc:/qml/MockLink.qml")); _p->settingsList.append(QVariant::fromValue(reinterpret_cast(_p->pMockLink))); _p->pDebug = new QmlComponentInfo(tr("Debug"), - QUrl::fromUserInput("qrc:/qml/DebugWindow.qml")); + QUrl::fromUserInput("qrc:/qml/DebugWindow.qml")); _p->settingsList.append(QVariant::fromValue(reinterpret_cast(_p->pDebug))); _p->pQmlTest = new QmlComponentInfo(tr("Palette Test"), - QUrl::fromUserInput("qrc:/qml/QmlTest.qml")); + QUrl::fromUserInput("qrc:/qml/QmlTest.qml")); _p->settingsList.append(QVariant::fromValue(reinterpret_cast(_p->pQmlTest))); #endif } @@ -361,7 +362,7 @@ bool QGCCorePlugin::adjustSettingMetaData(const QString& settingsGroup, FactMeta #endif metaData.setRawDefaultValue(outdoorPalette); return true; - //-- Auto Save Telemetry Logs + //-- Auto Save Telemetry Logs } else if (metaData.name() == AppSettings::telemetrySaveName) { #if defined (__mobile__) metaData.setRawDefaultValue(false); @@ -397,10 +398,9 @@ void QGCCorePlugin::setShowAdvancedUI(bool show) } } -void QGCCorePlugin::paletteOverride(QString colorName, QGCPalette::PaletteColorInfo_t& colorInfo) +void QGCCorePlugin::paletteOverride(QString /*colorName*/, QGCPalette::PaletteColorInfo_t& /*colorInfo*/) { - Q_UNUSED(colorName); - Q_UNUSED(colorInfo); + } QString QGCCorePlugin::showAdvancedUIMessage() const @@ -411,30 +411,47 @@ QString QGCCorePlugin::showAdvancedUIMessage() const "Are you sure you want to enable Advanced Mode?"); } -void QGCCorePlugin::instrumentValueAreaCreateDefaultSettings(const QString& defaultSettingsGroup) +void QGCCorePlugin::factValueGridCreateDefaultSettings(const QString& defaultSettingsGroup) { - if (defaultSettingsGroup == InstrumentValueArea::valuePageDefaultSettingsGroup) { - InstrumentValueArea instrumentValueArea(defaultSettingsGroup); + if (defaultSettingsGroup == VerticalFactValueGrid::valuePageDefaultSettingsGroup) { + VerticalFactValueGrid factValueGrid(defaultSettingsGroup); + + factValueGrid.setFontSize(FactValueGrid::LargeFontSize); + + QmlObjectListModel* row = factValueGrid.appendRow(); + InstrumentValueData* value = row->value(0); + value->setFact("Vehicle", "DistanceToHome"); + value->setText(value->fact()->shortDescription()); + value->setShowUnits(true); + + row = factValueGrid.appendRow(); + value = row->value(0); + value->setFact("Vehicle", "FlightDistance"); + value->setText(value->fact()->shortDescription()); + value->setShowUnits(true); - instrumentValueArea.setFontSize(InstrumentValueArea::LargeFontSize); + row = factValueGrid.appendRow(); + value = row->value(0); + value->setFact("Vehicle", "FlightTime"); + value->setText(value->fact()->shortDescription()); + value->setShowUnits(false); + } else if (defaultSettingsGroup == HorizontalFactValueGrid::toolbarDefaultSettingsGroup) { + HorizontalFactValueGrid factValueGrid(defaultSettingsGroup); - QmlObjectListModel* columnModel = instrumentValueArea.appendRow(); - InstrumentValueData* colValue = columnModel->value(0); - colValue->setFact("Vehicle", "AltitudeRelative"); - colValue->setText(colValue->fact()->shortDescription()); - colValue->setShowUnits(true); + factValueGrid.setFontSize(FactValueGrid::LargeFontSize); - columnModel = instrumentValueArea.appendRow(); - colValue = columnModel->value(0); - colValue->setFact("Vehicle", "GroundSpeed"); - colValue->setText(colValue->fact()->shortDescription()); - colValue->setShowUnits(true); + QmlObjectListModel* row = factValueGrid.appendRow(); + InstrumentValueData* value = row->value(0); + value->setFact("Vehicle", "AltitudeRelative"); + value->setIcon("arrow-thick-up.svg"); + value->setText(value->fact()->shortDescription()); + value->setShowUnits(true); - columnModel = instrumentValueArea.appendRow(); - colValue = columnModel->value(0); - colValue->setFact("Vehicle", "FlightTime"); - colValue->setText(colValue->fact()->shortDescription()); - colValue->setShowUnits(false); + row = factValueGrid.appendRow(); + value = row->value(0); + value->setFact("Vehicle", "GroundSpeed"); + value->setIcon("arrow-thick-right.svg"); + value->setShowUnits(true); } } @@ -526,8 +543,8 @@ const QVariantList &QGCCorePlugin::toolBarIndicators(void) //-- Default list of indicators for all vehicles. if(_toolBarIndicatorList.size() == 0) { _toolBarIndicatorList = QVariantList({ - QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/GPSRTKIndicator.qml")), - }); + QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/GPSRTKIndicator.qml")), + }); } return _toolBarIndicatorList; } diff --git a/src/api/QGCCorePlugin.h b/src/api/QGCCorePlugin.h index 5c4f3bfbdca66c6813e5cb7474b951b2068a9827..3aca7e6947a2758874167c39b309c2e9bd318f30 100644 --- a/src/api/QGCCorePlugin.h +++ b/src/api/QGCCorePlugin.h @@ -108,7 +108,7 @@ public: /// Allows a plugin to override the specified color name from the palette virtual void paletteOverride(QString colorName, QGCPalette::PaletteColorInfo_t& colorInfo); - virtual void instrumentValueAreaCreateDefaultSettings(const QString& defaultSettingsGroup); + virtual void factValueGridCreateDefaultSettings(const QString& defaultSettingsGroup); /// Allows the plugin to override or get access to the QmlApplicationEngine to do things like add import /// path or stuff things into the context prior to window creation. diff --git a/src/ui/MainRootWindow.qml b/src/ui/MainRootWindow.qml index ed9ab02c4840aa870158f11109f1f28ee6f84b31..a3645d2e30d930e9a8a29c8524e47b3c09bdb613 100644 --- a/src/ui/MainRootWindow.qml +++ b/src/ui/MainRootWindow.qml @@ -7,7 +7,6 @@ * ****************************************************************************/ - import QtQuick 2.11 import QtQuick.Controls 2.4 import QtQuick.Dialogs 1.3 diff --git a/src/ui/toolbar/MainToolBar.qml b/src/ui/toolbar/MainToolBar.qml index 63466c7802db1da5b2b74b01d2c8266f9552ff19..e349d2a16d0523630cc7d731307e68cd1fe9f1ff 100644 --- a/src/ui/toolbar/MainToolBar.qml +++ b/src/ui/toolbar/MainToolBar.qml @@ -209,15 +209,31 @@ Item { id: toolsFlickable anchors.leftMargin: ScreenTools.defaultFontPixelHeight / 2 anchors.left: separator.right - anchors.right: connectionStatus.visible ? connectionStatus.left : parent.right anchors.bottomMargin: 1 anchors.top: parent.top anchors.bottom: parent.bottom - contentWidth: indicatorLoader.width + anchors.right: connectionStatus.visible ? connectionStatus.left : parent.right + contentWidth: indicatorLoader.x + indicatorLoader.width flickableDirection: Flickable.HorizontalFlick + clip: !valueArea.settingsUnlocked + + HorizontalFactValueGrid { + id: valueArea + anchors.top: parent.top + anchors.bottom: parent.bottom + userSettingsGroup: toolbarUserSettingsGroup + defaultSettingsGroup: toolbarDefaultSettingsGroup + + QGCMouseArea { + anchors.fill: parent + visible: !parent.settingsUnlocked + onClicked: parent.settingsUnlocked = true + } + } Loader { id: indicatorLoader + anchors.left: valueArea.right anchors.top: parent.top anchors.bottom: parent.bottom source: "qrc:/toolbar/MainToolBarIndicators.qml"