Program Listing for File FkinDecisionIndicator.qml

Return to documentation for file (src/qml/components/FkinDecisionIndicator.qml)

import QtQuick 2.11
import QtQuick.Controls 2.4
import QtQuick.Controls.Material 2.4
import QtQuick.Layouts 1.11

import fkin.Dds 1.0

RowLayout {
  id: root;
  Layout.topMargin: 10;
  Layout.bottomMargin: 10;
  Layout.fillWidth: true;

  FkinStyle { id: fkinStyle; }
  property alias value: indicator.value;
  property alias valueText: indicator.text;
  property bool running: false;
  property alias entity: icon_.text;
  property alias description: icon_.toolTipText;
  property string unit: "";

  Label {
    id: icon_;
    text: "\uef50"; // info
    font: fkinStyle.iconFontHuge;
    property string toolTipText: qsTr("Info");
    ToolTip.text: toolTipText;
    ToolTip.visible: toolTipText ? ma_rot.containsMouse : false;
    MouseArea {
      id: ma_rot;
      anchors.fill: parent;
      hoverEnabled: true;
    }
  }

  Pane {
    id: status_;
    Layout.leftMargin: 10;
    Layout.rightMargin: 20;
    Layout.preferredWidth: 120;
    background: Rectangle {
      color: 'transparent';
      border.color: Material.foreground;
      radius: 2;
    }
    Label {
      id: indicator;
      font.pointSize: fkinStyle.numberFont.pointSize;
      property real value: 0;
      property int decimals: 1;
      text: isNaN(indicator.value) || !root.running ? "-" + root.unit :
        Number(indicator.value).toLocaleString(Qt.locale(), 'f', indicator.decimals) + root.unit;

      //Layout.alignment: Qt.AlignCenter;
      horizontalAlignment: Text.AlignHCenter;
      width: parent.width;
    }
  }
}