• File: C_weather_01_forecast.qml
  • Full Path: /home/insbudnet/domains/insbud.net/public_html/download/software/qml/sieniczno_nowak/qml/pl/commons/C_weather_01_forecast.qml
  • File size: 7.15 KB
  • MIME-type: text/plain
  • Charset: utf-8
 
Open Back
import QtQuick 2.3
import QtQuick.Layouts 1.1

Core {
    id: container


    property int prop__date_year: 0
    property int prop__date_month: 0
    property int prop__date_day: 0
    property int prop__max_temp_c: 0
    property int prop__max_temp_f: 0
    property int prop__min_temp_c: 0
    property int prop__min_temp_f: 0
    property int prop__wind_speed_miles: 0
    property int prop__wind_speed_kmph: 0
    property int prop__wind_dir_degree: 0
    property int prop__weather_code: 0
    property int prop__precip_mm: 0

    property string str_max_temp: ""
    property string str_min_temp: ""
    property string str_wind_speed: ""

    function update() {
        if (cfg_temperature_unit == "°F") {
            str_max_temp = funct_getValue(2, prop__max_temp_f, 10, cfg_temperature_unit, 1, 0);
            str_min_temp = funct_getValue(2, prop__min_temp_f, 10, cfg_temperature_unit, 1, 0);
        } else {
            str_max_temp = funct_getValue(2, prop__max_temp_c, 10, cfg_temperature_unit, 1, 0)
            str_min_temp = funct_getValue(2, prop__min_temp_c, 10, cfg_temperature_unit, 1, 0)
        }

        if (cfg_speed_unit == "mph") {
            str_wind_speed = funct_getValue(2, prop__wind_speed_miles, 0, cfg_speed_unit, 0, 1)
        } else {
            str_wind_speed = funct_getValue(2, prop__wind_speed_kmph, 0, cfg_speed_unit, 0, 1)
        }
    }

    Component.onCompleted: {
        update();
    }

    Layout.fillWidth: true
    Layout.preferredHeight: layout.implicitHeight

    ColumnLayout {
        id: layout
        anchors.fill: parent


        Rectangle {
            id: rec_weather_forecast_header

            Layout.fillWidth: true
            Layout.preferredHeight: layout_weather_forecast_header.implicitHeight + 10

            color: "lightgray"
            border.color: "gray"
            radius: 5

            RowLayout {
                id: layout_weather_forecast_header
                anchors.fill: parent
                spacing: 10

                Item {
                    Layout.preferredWidth: 5
                }

                Image {
                    id: img_weather_forecast_icon
                    Layout.preferredWidth: 64
                    sourceSize.height: height
                    fillMode: Image.PreserveAspectFit

                    source: "../images/C_weather_01/wsymbol_0002_sunny_intervals.png"
                }

                ColumnLayout {
                    id: layout_weather_forecast_description
                    Layout.fillWidth: true
                    Layout.fillHeight: true

                    Text {
                        id: txt_weather_forecast_date
                        font.pixelSize: 17
                        font.bold: true
                        textFormat: Text.RichText

                        text: funct_getValue(4, prop__date_year, prop__date_month, prop__date_day, 0, 0)
                    }


                    Text {
                        id: txt_weather_forecast_description
                        Layout.fillWidth: true
                        font.pixelSize: 12
                        wrapMode: Text.WordWrap
                        clip: true
                        //textFormat: Text.RichText

                        text: "<b>" + lang_forecast + "</b>: Częściowe zachmurznenie asdfsdf asfsdfag sdafadfg asdafgasdf asgdfagdf"
                    }

                }

                Item {
                    Layout.preferredWidth: 5
                }

            }
        }


        Rectangle {
            id: rec_weather_forecast_content
            height: layout_weather_forecast_content.implicitHeight + 2 * layout_weather_forecast_content.y

            Layout.fillWidth: true
            color: "lightgray"
            border.color: "gray"
            radius: 5

            ColumnLayout {
                id: layout_weather_forecast_content
                x: 10
                y: 10
                width: parent.width - x * 2
                height: parent.height - y * 2
                spacing: 4

                RowLayout{

                    Text {
                        Layout.fillWidth: true
                        font.pixelSize: 14
                        horizontalAlignment: Text.AlignLeft
                        textFormat: Text.RichText

                        text: lang_max_temperature + ":"
                    }

                    Text {
                        Layout.alignment: Qt.AlignRight
                        font.pixelSize: 14
                        horizontalAlignment: Text.AlignRight
                        textFormat: Text.RichText
                        font.bold: true

                        text: str_max_temp
                    }
                }

                RowLayout{

                    Text {
                        Layout.fillWidth: true
                        font.pixelSize: 14
                        horizontalAlignment: Text.AlignLeft
                        textFormat: Text.RichText

                        text: lang_min_temperature + ":"
                    }

                    Text {
                        Layout.alignment: Qt.AlignRight
                        font.pixelSize: 14
                        horizontalAlignment: Text.AlignRight
                        textFormat: Text.RichText
                        font.bold: true

                        text: str_min_temp
                    }
                }

                RowLayout{

                    Text {
                        id: txt_weather_forecast_content_wind_title
                        Layout.fillWidth: true
                        font.pixelSize: 14
                        horizontalAlignment: Text.AlignLeft
                        textFormat: Text.RichText

                        text: lang_wind + ":"
                    }

                    Image {
                        source: "../images/arrow_blue.svg"
                        sourceSize.height: txt_weather_forecast_content_wind_title.height
                        rotation: 180 + prop__wind_dir_degree

                        fillMode: Image.PreserveAspectFit
                    }


                    Text {
                        Layout.alignment: Qt.AlignRight
                        font.pixelSize: 14
                        horizontalAlignment: Text.AlignRight
                        textFormat: Text.RichText
                        font.bold: true

                        text: str_wind_speed
                    }
                }

                RowLayout{

                    Text {
                        Layout.fillWidth: true
                        font.pixelSize: 14
                        horizontalAlignment: Text.AlignLeft
                        textFormat: Text.RichText

                        text: lang_precipitation + ":"
                    }

                    Text {
                        Layout.alignment: Qt.AlignRight
                        font.pixelSize: 14
                        horizontalAlignment: Text.AlignRight
                        textFormat: Text.RichText
                        font.bold: true

                        text: funct_getValue(2, prop__precip_mm, 10, "mm", 1, 1)
                    }
                }
            }
        }
    }
}