From 7b7e50741f2b39f47b7b7f067eca825c68de188f Mon Sep 17 00:00:00 2001 From: James Turner Date: Tue, 6 Mar 2018 18:34:54 +0000 Subject: [PATCH] Launcher: fix preview image aspect ratio Accidentally left in a hard-coded 16:9 ratio, no wonder some images got squished. Shuttle is now re-elongated verticallitaly :) --- src/GUI/PreviewImageItem.cxx | 5 +++++ src/GUI/PreviewImageItem.hxx | 3 +++ src/GUI/qml/AircraftPreviewPanel.qml | 3 ++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/GUI/PreviewImageItem.cxx b/src/GUI/PreviewImageItem.cxx index 975c679a4..1480993ca 100644 --- a/src/GUI/PreviewImageItem.cxx +++ b/src/GUI/PreviewImageItem.cxx @@ -73,6 +73,11 @@ bool PreviewImageItem::isLoading() const return m_requestActive; } +float PreviewImageItem::aspectRatio() const +{ + return static_cast(m_image.width()) / m_image.height(); +} + void PreviewImageItem::setImageUrl( QUrl url) { if (m_imageUrl == url) diff --git a/src/GUI/PreviewImageItem.hxx b/src/GUI/PreviewImageItem.hxx index bd27f26a8..3d8970450 100644 --- a/src/GUI/PreviewImageItem.hxx +++ b/src/GUI/PreviewImageItem.hxx @@ -20,6 +20,7 @@ class PreviewImageItem : public QQuickItem Q_PROPERTY(bool isLoading READ isLoading NOTIFY isLoadingChanged) + Q_PROPERTY(float aspectRatio READ aspectRatio NOTIFY sourceSizeChanged) public: PreviewImageItem(QQuickItem* parent = nullptr); ~PreviewImageItem(); @@ -34,6 +35,8 @@ public: bool isLoading() const; + float aspectRatio() const; + signals: void imageUrlChanged(); void sourceSizeChanged(); diff --git a/src/GUI/qml/AircraftPreviewPanel.qml b/src/GUI/qml/AircraftPreviewPanel.qml index 9344139f2..445b2d757 100644 --- a/src/GUI/qml/AircraftPreviewPanel.qml +++ b/src/GUI/qml/AircraftPreviewPanel.qml @@ -11,7 +11,7 @@ Rectangle { activePreview = 0 } - height: width / (16/9) + height: width / preview.aspectRatio color: "#7f7f7f" border.width: 1 @@ -22,6 +22,7 @@ Rectangle { } PreviewImage { + id: preview width: parent.width height: parent.height imageUrl: __havePreviews ? root.previews[root.activePreview] : ""