Files
wifipicker/Main.qml
T

87 lines
2.4 KiB
QML

import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
Window {
id: window
width: 640
height: 480
visible: true
title: "WIFI Picker"
signal scanNetworks()
ColumnLayout {
id: layout
property bool isLoading: false
Button {
id: scanbutton
text: "Scan for networks"
onClicked: {
layout.isLoading = true;
window.scanNetworks();
layout.isLoading = false;
}
}
Text {
text: "Loading"
visible: layout.isLoading
}
ListView {
id: listview
visible: !layout.isLoading
model: networksModel
width: 100
height: 1000
delegate: Item {
id: listItem
height: 20
width: 400
property bool hovered: false
required property string name
property bool isConnected: false
MouseArea {
anchors.fill: parent
hoverEnabled: true
onEntered: {
console.log("on hover")
listItem.hovered = true
}
onExited: listItem.hovered = false
onClicked: console.log("Clicked!")
Rectangle {
anchors.fill: parent
color: listItem.hovered ? "blue" : "transparent"
transitions: Transition {
ColorAnimation { target: parent; property: "color"; duration: 200 }
}
RowLayout {
anchors.fill: parent
Text {
Layout.fillWidth: true
text: listItem.name
color: listItem.hovered ? "white" : "black"
}
Button {
visible: !listItem.isConnected
text: "Connect"
onClicked: console.log("connecting to " + listItem.name)
}
}
}
}
}
}
}
}