From 6475ae32b1d6be5bf14ed3d8a0414492c44c7571 Mon Sep 17 00:00:00 2001 From: James Turner Date: Mon, 2 Jul 2018 11:49:34 +0100 Subject: [PATCH] Launcher: nicer min-window-size computation --- src/GUI/LauncherController.cxx | 9 +++++++++ src/GUI/LauncherController.hxx | 15 +++++++++++++-- src/GUI/LauncherMainWindow.cxx | 2 -- src/GUI/qml/Launcher.qml | 5 +++++ src/GUI/qml/Sidebar.qml | 3 +++ 5 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/GUI/LauncherController.cxx b/src/GUI/LauncherController.cxx index 8620acac5..1c3c2ca20 100644 --- a/src/GUI/LauncherController.cxx +++ b/src/GUI/LauncherController.cxx @@ -790,3 +790,12 @@ void LauncherController::saveConfigAs() m_config->saveConfigToFile(file); } + +void LauncherController::setMinWindowSize(QSize sz) +{ + if (sz == m_minWindowSize) + return; + + m_window->setMinimumSize(sz); + emit minWindowSizeChanged(); +} diff --git a/src/GUI/LauncherController.hxx b/src/GUI/LauncherController.hxx index ef826a8d2..46564867c 100644 --- a/src/GUI/LauncherController.hxx +++ b/src/GUI/LauncherController.hxx @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -78,6 +79,9 @@ class LauncherController : public QObject Q_PROPERTY(bool canFly READ canFly NOTIFY canFlyChanged) Q_PROPERTY(AircraftType aircraftType READ aircraftType NOTIFY selectedAircraftChanged) + + Q_PROPERTY(QSize minimumWindowSize READ minWindowSize WRITE setMinWindowSize NOTIFY minWindowSizeChanged) + public: explicit LauncherController(QObject *parent, QWindow* win); @@ -168,6 +172,13 @@ public: void setInAppMode(); bool keepRunningInAppMode() const; bool inAppResult() const; + + QSize minWindowSize() const + { + return m_minWindowSize; + } + + void setMinWindowSize(QSize sz); signals: void selectedAircraftChanged(QUrl selectedAircraft); @@ -175,7 +186,7 @@ signals: void searchChanged(); void summaryChanged(); - + void minWindowSizeChanged(); void canFlyChanged(); void viewCommandLine(); @@ -245,7 +256,7 @@ private: QStringList m_settingsSummary, m_environmentSummary; RecentAircraftModel* m_aircraftHistory = nullptr; RecentLocationsModel* m_locationHistory = nullptr; - + QSize m_minWindowSize; QTimer* m_subsystemIdleTimer = nullptr; bool m_inAppMode = false; diff --git a/src/GUI/LauncherMainWindow.cxx b/src/GUI/LauncherMainWindow.cxx index 2ecc194c5..d8dd9edd4 100644 --- a/src/GUI/LauncherMainWindow.cxx +++ b/src/GUI/LauncherMainWindow.cxx @@ -94,8 +94,6 @@ LauncherMainWindow::LauncherMainWindow() : ctx->setContextProperty("_weatherScenarios", weatherScenariosModel); setSource(QUrl("qrc:///qml/Launcher.qml")); - - setMinimumSize(QSize(300, 400)); } #if 0 diff --git a/src/GUI/qml/Launcher.qml b/src/GUI/qml/Launcher.qml index 4cc099c38..4fbad999d 100644 --- a/src/GUI/qml/Launcher.qml +++ b/src/GUI/qml/Launcher.qml @@ -27,6 +27,11 @@ Item { } + Component.onCompleted: + { + _launcher.minimumWindowSize = Qt.size(Style.strutSize * 12, sidebar.minimumHeight); + } + Connections { target: _location onSkipFromArgsChanged: pagesModel.setProperty(2, "buttonDisabled", _location.skipFromArgs) diff --git a/src/GUI/qml/Sidebar.qml b/src/GUI/qml/Sidebar.qml index 0e7b12a2d..e382f4280 100644 --- a/src/GUI/qml/Sidebar.qml +++ b/src/GUI/qml/Sidebar.qml @@ -10,6 +10,8 @@ Rectangle { property int selectedPage: 0 property alias showMenuIcon: menuIcon.visible + readonly property int minimumHeight: mainColumn.childrenRect.height + flyButton.height + signal selectPage(var pageSource); signal showMenu(); @@ -20,6 +22,7 @@ Rectangle { } Column { + id: mainColumn width: parent.width anchors.top: parent.top anchors.bottom: flyButton.top