From 97162746128e1f8a93ed1150fc93684600d893e3 Mon Sep 17 00:00:00 2001 From: James Turner Date: Thu, 5 Jul 2018 09:02:02 +0100 Subject: [PATCH] Hacking UI for FP entry --- src/GUI/qml/AddOnsHeader.qml | 26 +--- src/GUI/qml/AirportEntry.qml | 7 + src/GUI/qml/DateTimeEdit.qml | 20 ++- src/GUI/qml/FlightPlan.qml | 213 ++++++++++++++++++++++++++ src/GUI/qml/HeaderBox.qml | 23 +++ src/GUI/qml/Launcher.qml | 9 ++ src/GUI/qml/LocationAltitudeRow.qml | 2 +- src/GUI/qml/PlainTextEditBox.qml | 38 +++++ src/GUI/qml/SettingExtraArguments.qml | 34 +--- src/GUI/qml/TimeEdit.qml | 86 +++++++++++ src/GUI/resources.qrc | 5 + 11 files changed, 404 insertions(+), 59 deletions(-) create mode 100644 src/GUI/qml/AirportEntry.qml create mode 100644 src/GUI/qml/FlightPlan.qml create mode 100644 src/GUI/qml/HeaderBox.qml create mode 100644 src/GUI/qml/PlainTextEditBox.qml create mode 100644 src/GUI/qml/TimeEdit.qml diff --git a/src/GUI/qml/AddOnsHeader.qml b/src/GUI/qml/AddOnsHeader.qml index 8df709933..ed9f56f9d 100644 --- a/src/GUI/qml/AddOnsHeader.qml +++ b/src/GUI/qml/AddOnsHeader.qml @@ -6,32 +6,16 @@ Item { property bool showAddButton: false - property alias title: headerTitle.text + property alias title: header.title property alias description: description.text signal add(); implicitWidth: parent.width - implicitHeight: headerRect.height + Style.margin + description.height + implicitHeight: header.height + Style.margin + description.height - Rectangle { - id: headerRect + HeaderBox { + id: header width: parent.width - height: headerTitle.height + (Style.margin * 2) - - color: Style.themeColor - border.width: 1 - border.color: Style.frameColor - - Text { - id: headerTitle - color: "white" - anchors.verticalCenter: parent.verticalCenter - font.bold: true - font.pixelSize: Style.subHeadingFontPixelSize - anchors.left: parent.left - anchors.leftMargin: Style.inset - - } AddButton { id: addButton @@ -46,7 +30,7 @@ Item { StyledText { id: description width: parent.width - anchors.top: headerRect.bottom + anchors.top: header.bottom anchors.topMargin: Style.margin wrapMode: Text.WordWrap } diff --git a/src/GUI/qml/AirportEntry.qml b/src/GUI/qml/AirportEntry.qml new file mode 100644 index 000000000..c41d95fb6 --- /dev/null +++ b/src/GUI/qml/AirportEntry.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +LineEdit +{ + placeholder: "KSFO" + suggestedWidthString: "XXXX" +} diff --git a/src/GUI/qml/DateTimeEdit.qml b/src/GUI/qml/DateTimeEdit.qml index 2005d2fc6..eedfc3f48 100644 --- a/src/GUI/qml/DateTimeEdit.qml +++ b/src/GUI/qml/DateTimeEdit.qml @@ -9,6 +9,7 @@ FocusScope { property var value: new Date() implicitHeight: label.implicitHeight + implicitWidth: label.implicitWidth + Style.margin + editFrame.width function daysInMonth() { @@ -32,14 +33,13 @@ FocusScope { updateCurrentDate(); } - Text { + StyledText { id: label anchors.left: root.left - anchors.leftMargin: 8 + anchors.leftMargin: Style.margin anchors.verticalCenter: parent.verticalCenter horizontalAlignment: Text.AlignRight - // color: mouseArea.containsMouse ? Style.themeColor : - // (root.enabled ? "black" : Style.inactiveThemeColor) + enabled: root.enabled } Rectangle { @@ -82,9 +82,10 @@ FocusScope { onCommit: updateCurrentDate(); } - Text { + StyledText { text: " / " anchors.verticalCenter: parent.verticalCenter + enabled: root.enabled } DateTimeValueEdit { @@ -98,9 +99,10 @@ FocusScope { onCommit: updateCurrentDate(); } - Text { + StyledText { text: " / " anchors.verticalCenter: parent.verticalCenter + enabled: root.enabled } DateTimeValueEdit { @@ -115,9 +117,10 @@ FocusScope { } // spacer here - Text { + StyledText { text: " " anchors.verticalCenter: parent.verticalCenter + enabled: root.enabled } DateTimeValueEdit { @@ -131,9 +134,10 @@ FocusScope { onCommit: updateCurrentDate(); } - Text { + StyledText { text: " : " anchors.verticalCenter: parent.verticalCenter + enabled: root.enabled } DateTimeValueEdit { diff --git a/src/GUI/qml/FlightPlan.qml b/src/GUI/qml/FlightPlan.qml new file mode 100644 index 000000000..2dcabb375 --- /dev/null +++ b/src/GUI/qml/FlightPlan.qml @@ -0,0 +1,213 @@ +import QtQuick 2.4 +import FlightGear.Launcher 1.0 +import "." + +Item { + + Flickable { + id: flick + height: parent.height + width: parent.width - scrollbar.width + flickableDirection: Flickable.VerticalFlick + contentHeight: contents.childrenRect.height + + Column + { + id: contents + width: parent.width - (Style.margin * 2) + x: Style.margin + spacing: Style.margin + + HeaderBox { + title: qsTr("Aircraft & flight information") + width: parent.width + } + + // date of flight << omit for now + + Row { + height: aircraftIdent.height + width: parent.width + spacing: Style.margin + + StyledText { + text: qsTr("Callsign / Flight No.") + anchors.verticalCenter: parent.verticalCenter + } + LineEdit { + // Aircraft identication - callsign (share with MP) + + id: aircraftIdent + placeholder: "D-FGFS" + suggestedWidthString: "XXXXXX"; + anchors.verticalCenter: parent.verticalCenter + } + + Item { width: Style.strutSize; height: 1 } + + StyledText { + text: qsTr("Aircraft type:") + anchors.verticalCenter: parent.verticalCenter + } + LineEdit { + placeholder: "B738" + suggestedWidthString: "XXXX"; + anchors.verticalCenter: parent.verticalCenter + } + } + + Row { + height: childrenRect.height + width: parent.width + spacing: Style.margin + + PopupChoice { + id: flightRules + label: qsTr("Flight rules:") + model: ["VFR", "IFR"] // initially IFR (Y), initially VFR (Z) + } + + Item { width: Style.strutSize; height: 1 } + + PopupChoice { + id: flightType + label: qsTr("Flight type:") + model: [qsTr("Scheduled"), + qsTr("Non-scheduled"), + qsTr("General aviation"), + qsTr("Military"), + qsTr("Other")] + } + } + + Row { + height: childrenRect.height + width: parent.width + spacing: Style.margin + + PopupChoice { + id: wakeTurbulenceCategory + label: qsTr("Wake turbulence category:") + model: [qsTr("Light"), + qsTr("Medium"), + qsTr("Heavy"), + qsTr("Jumbo")] + } + + // equipment + // - ideally prefill from acft + } + + HeaderBox { + title: qsTr("Route") + width: parent.width + } + + Row { + height: childrenRect.height + width: parent.width + spacing: Style.margin + + AirportEntry { + label: qsTr("Departure airport:") + } + + // padding + Item { width: Style.strutSize; height: 1 } + + TimeEdit { + id: departureTime + label: qsTr("Departure time:") + } + + } + + // cruising speed + level + Row { + height: childrenRect.height + width: parent.width + spacing: Style.margin + + IntegerSpinbox { + label: qsTr("Cruise speed:") + suffix: "kts" + min: 0 + max: 10000 // more for spaceships? + step: 5 + maxDigits: 5 + } + + // padding + Item { width: Style.strutSize; height: 1 } + + LocationAltitudeRow { + + } + } + + StyledText { + width: parent.width + text: qsTr("Route") + } + + PlainTextEditBox { + id: route + width: parent.width + + } + + Row { + height: childrenRect.height + width: parent.width + spacing: Style.margin + + AirportEntry { + id: destinationICAO + label: qsTr("Destination airport:") + } + + Item { width: Style.strutSize; height: 1 } + + TimeEdit { + id: enrouteEstimate + label: qsTr("Estimate enroute time:") + } + + Item { width: Style.strutSize; height: 1 } + + AirportEntry { + id: alternate1 + label: qsTr("Alternate airport:") + } + + } + + HeaderBox { + title: qsTr("Additional information") + width: parent.width + } + + StyledText { + width: parent.width + text: qsTr("Remarks") + } + + PlainTextEditBox { + id: remarks + width: parent.width + + } + + // speak to Act-pie guy about passing all this over MP props? + } // of main column + + } // of flickable + + Scrollbar { + id: scrollbar + anchors.right: parent.right + height: parent.height + flickable: flick + visible: flick.contentHeight > flick.height + } +} diff --git a/src/GUI/qml/HeaderBox.qml b/src/GUI/qml/HeaderBox.qml new file mode 100644 index 000000000..d6a1148fa --- /dev/null +++ b/src/GUI/qml/HeaderBox.qml @@ -0,0 +1,23 @@ +import QtQuick 2.4 +import "." + +Rectangle { + id: headerRect + implicitHeight: headerTitle.height + (Style.margin * 2) + + property alias title: headerTitle.text + + color: Style.themeColor + border.width: 1 + border.color: Style.frameColor + + Text { + id: headerTitle + color: "white" + anchors.verticalCenter: parent.verticalCenter + font.bold: true + font.pixelSize: Style.subHeadingFontPixelSize + anchors.left: parent.left + anchors.leftMargin: Style.inset + } +} diff --git a/src/GUI/qml/Launcher.qml b/src/GUI/qml/Launcher.qml index 647bc53e7..3ae4c2a7d 100644 --- a/src/GUI/qml/Launcher.qml +++ b/src/GUI/qml/Launcher.qml @@ -69,6 +69,13 @@ Item { } } + function enterFlightPlan() + { + sidebar.selectedPage = -1; + pageLoader.source = "qrc:///qml/FlightPlan.qml" + root.state = "loader"; + } + Sidebar { id: sidebar width: Style.strutSize * 2 @@ -141,6 +148,8 @@ Item { MenuItem { text:qsTr("Save configuration as..."); shortcut: "Ctrl+S"; onTriggered: _launcher.saveConfigAs(); }, MenuDivider {}, + MenuItem { text:qsTr("Flight-planning"); onTriggered: root.enterFlightPlan(); shortcut: "Ctrl+P"; enabled: false}, + MenuDivider {}, MenuItem { text:qsTr("View command line"); onTriggered: _launcher.viewCommandLine(); shortcut: "Ctrl+L"}, MenuItem { text:qsTr("Select data files location..."); onTriggered: _launcher.requestChangeDataPath(); }, MenuItem { text:qsTr("Restore default settings..."); onTriggered: _launcher.requestRestoreDefaults(); }, diff --git a/src/GUI/qml/LocationAltitudeRow.qml b/src/GUI/qml/LocationAltitudeRow.qml index a533b02d1..183832819 100644 --- a/src/GUI/qml/LocationAltitudeRow.qml +++ b/src/GUI/qml/LocationAltitudeRow.qml @@ -50,7 +50,7 @@ Row { PopupChoice { id: altitudeTypeChoice - enabled: __rowEnabled && (location.altitudeType !== LocationController.Off) + enabled: __rowEnabled && (_location.altitudeType !== LocationController.Off) currentIndex: Math.max(0, _location.altitudeType - 1) readonly property bool isFlightLevel: (currentIndex == 2) diff --git a/src/GUI/qml/PlainTextEditBox.qml b/src/GUI/qml/PlainTextEditBox.qml new file mode 100644 index 000000000..310afb646 --- /dev/null +++ b/src/GUI/qml/PlainTextEditBox.qml @@ -0,0 +1,38 @@ +import QtQuick 2.4 +import FlightGear.Launcher 1.0 +import "." + +Rectangle { + id: editFrame + + property bool enabled: true + property alias placeholder: placeholderText.text + property alias text: edit.text + + implicitHeight: edit.height + Style.margin + border.color: edit.activeFocus ? Style.frameColor : Style.minorFrameColor + border.width: 1 + + TextEdit { + id: edit + enabled: editFrame.enabled + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + anchors.right: parent.right + anchors.margins: Style.margin + height: Math.max(Style.strutSize * 4, implicitHeight) + textFormat: TextEdit.PlainText + font.family: "Courier" + selectByMouse: true + wrapMode: TextEdit.WordWrap + font.pixelSize: Style.baseFontPixelSize + color: Style.baseTextColor + + StyledText { + id: placeholderText + visible: (edit.text.length == 0) && !edit.activeFocus + font.family: "Courier" + color: Style.disabledTextColor + } + } +} diff --git a/src/GUI/qml/SettingExtraArguments.qml b/src/GUI/qml/SettingExtraArguments.qml index 9a51f0f6c..13f9a4de9 100644 --- a/src/GUI/qml/SettingExtraArguments.qml +++ b/src/GUI/qml/SettingExtraArguments.qml @@ -60,36 +60,12 @@ SettingControl { "page (for example, airport or altitude) will be ignored."); } - Rectangle { - id: editFrame - height: edit.height + Style.margin - border.color: edit.activeFocus ? Style.frameColor : Style.minorFrameColor - border.width: 1 + PlainTextEditBox + { + id: edit width: parent.width - - TextEdit { - id: edit - enabled: root.enabled - anchors.verticalCenter: parent.verticalCenter - anchors.left: parent.left - anchors.right: parent.right - anchors.margins: Style.margin - height: Math.max(Style.strutSize * 4, implicitHeight) - textFormat: TextEdit.PlainText - font.family: "Courier" - selectByMouse: true - wrapMode: TextEdit.WordWrap - font.pixelSize: Style.baseFontPixelSize - color: Style.baseTextColor - - StyledText { - id: placeholder - visible: (edit.text.length == 0) && !edit.activeFocus - text: root.placeholder - font.family: "Courier" - color: Style.disabledTextColor - } - } + enabled: root.enabled + placeholder: root.placeholder } } diff --git a/src/GUI/qml/TimeEdit.qml b/src/GUI/qml/TimeEdit.qml new file mode 100644 index 000000000..8e4d2f20d --- /dev/null +++ b/src/GUI/qml/TimeEdit.qml @@ -0,0 +1,86 @@ +import QtQuick 2.4 +import "." + +FocusScope { + id: root + + property alias label: label.text + property bool enabled: true + property var value: new Date() + + implicitHeight: label.implicitHeight + implicitWidth: label.implicitWidth + Style.margin + editFrame.width + + function updateCurrentTime() + { + root.value = new Date(0, 0, 0, hours.value, minutes.value); + } + + function setTime(date) + { + hours.value = date.getHours(); + minutes.value = date.getMinutes(); + updateCurrentTime(); + } + + StyledText { + id: label + anchors.left: root.left + anchors.leftMargin: Style.margin + anchors.verticalCenter: parent.verticalCenter + horizontalAlignment: Text.AlignRight + enabled: root.enabled + } + + Rectangle { + id: editFrame + radius: Style.roundRadius + border.color: root.focus ? Style.themeColor : Style.minorFrameColor + + border.width: 1 + height: 30 + + anchors.left: label.right + anchors.leftMargin: Style.margin + anchors.verticalCenter: parent.verticalCenter + width: editRow.childrenRect.width + Style.roundRadius * 2 + 64 + + Row { + id: editRow + anchors { + left: parent.left + top: parent.top + bottom: parent.bottom + right: parent.right + margins: Style.margin + } + + DateTimeValueEdit { + id: hours + minValue: 0 + maxValue: 23 + widthString: "00" + nextToFocus: minutes + anchors.verticalCenter: parent.verticalCenter + onCommit: updateCurrentTime(); + } + + Text { + text: " : " + anchors.verticalCenter: parent.verticalCenter + enabled: root.enabled + } + + DateTimeValueEdit { + id: minutes + minValue: 0 + maxValue: 59 + widthString: "00" + anchors.verticalCenter: parent.verticalCenter + previousToFocus: hours + onCommit: updateCurrentTime(); + } + } // of time elements row + } + +} diff --git a/src/GUI/resources.qrc b/src/GUI/resources.qrc index d0792b86f..204455a9f 100644 --- a/src/GUI/resources.qrc +++ b/src/GUI/resources.qrc @@ -109,6 +109,11 @@ qml/LocationAltitudeRow.qml qml/CatalogDelegate.qml assets/icons8-clear-symbol-26.png + qml/FlightPlan.qml + qml/PlainTextEditBox.qml + qml/HeaderBox.qml + qml/TimeEdit.qml + qml/AirportEntry.qml preview-close.png