tools/hhtracer/Main.qml
author unC0Rr
Fri, 10 Jan 2025 17:37:34 +0100
changeset 16084 2d65bd46c92f
permissions -rw-r--r--
Start work on hedgehog tracer

import QtQuick
import QtQuick.Controls
import QtQuick.Dialogs
import QtQuick.Layouts

ApplicationWindow {
  height: 900
  title: qsTr("Tracer")
  visible: true
  width: 1200

  header: ToolBar {
    RowLayout {
      Button {
        text: qsTr("Choose Image...")

        onClicked: fileDialog.open()
      }

      Button {
        text: qsTr("Start")

        onClicked: {
          stepTimer.start();
        }
      }

      Button {
        text: qsTr("Stop")

        onClicked: {
          stepTimer.stop();
        }
      }
    }
  }

  FileDialog {
    id: fileDialog

    nameFilters: ["Hedgehog images (*.png)"]

    onAccepted: {
      console.log("Hello")
      baseImage.source = selectedFile;
      tracer.start(fileDialog.selectedFile);
    }
  }

  Tracer {
    id: tracer
  }


  Timer {
    id: stepTimer

    interval: 1500
    repeat: true
    running: false
    triggeredOnStart: true

    onTriggered: tracer.step()
  }

  ColumnLayout {
    anchors.fill: parent

    Image {
      id: baseImage

      Layout.fillWidth: true
      Layout.preferredHeight: 128
      fillMode: Image.PreserveAspectFit
    }

    GridLayout {
      Layout.fillWidth: true
      Layout.fillHeight: true
      columns: 10

      Repeater {
        model: tracer.solutions

        Image {
          width: 32
          height: 32
          source: "file://" + modelData
          fillMode: Image.PreserveAspectFit

          Rectangle {
            border.width: 1
            border.color: "black"
            color: "transparent"
            anchors.fill: parent
          }
        }
      }
    }
  }
}