harbour-seaprint/qml/pages/AddPrinterDialog.qml

119 lines
2.8 KiB
QML
Raw Normal View History

2019-12-02 22:23:44 +03:00
import QtQuick 2.0
import Sailfish.Silica 1.0
import seaprint.ippprinter 1.0
Dialog {
id: dialog
2020-08-06 18:34:14 +03:00
allowedOrientations: Orientation.All
2019-12-02 22:23:44 +03:00
property string value
property string ssid
2020-01-03 00:10:58 +03:00
property var printerName: false
canAccept: printerName != false
2019-12-02 22:23:44 +03:00
2021-02-15 20:03:35 +03:00
Connections {
target: wifi
onConnectedChanged: {
if(!wifi.connected) {
dialog.reject()
}
}
}
2021-02-15 19:57:52 +03:00
Component.onCompleted: {
valueField.forceActiveFocus()
}
IppPrinter {
id: printer
url: valueField.text
onAttrsChanged: {
if(printer.attrs["printer-name"]) {
printerName = printer.attrs["printer-name"].value == "" ? qsTr("Unknown") : printer.attrs["printer-name"].value
}
else
{
printerName = false
}
}
}
2019-12-02 22:23:44 +03:00
Column {
2021-02-15 19:57:52 +03:00
id: col
2019-12-02 22:23:44 +03:00
width: parent.width
DialogHeader {
title: qsTr("Add printer")
}
TextField {
id: valueField
width: parent.width
placeholderText: "192.168.1.1/ipp/print"
label: title
}
Row {
x: Theme.paddingLarge
spacing: Theme.paddingMedium
Label {
id: wifi_label
2020-09-21 23:09:12 +03:00
text: qsTr("On WiFi:")
2019-12-02 22:23:44 +03:00
}
Label {
id: ssid_label
color: Theme.secondaryColor
2021-02-15 20:03:35 +03:00
text: wifi.ssid
2019-12-02 22:23:44 +03:00
}
}
Row {
x: Theme.paddingLarge
spacing: Theme.paddingMedium
Label {
id: found_label
2020-01-03 00:10:58 +03:00
text: printerName != false ? qsTr("Found:") : qsTr("No printer found")
2019-12-02 22:23:44 +03:00
}
Label {
id: printer_label
color: Theme.secondaryColor
2020-01-03 00:10:58 +03:00
text: printerName ? printerName : ""
2019-12-02 22:23:44 +03:00
}
}
2021-02-15 19:57:52 +03:00
}
2019-12-02 22:23:44 +03:00
2021-02-15 19:57:52 +03:00
Row {
visible: valueField.text.indexOf(":9100") != -1
anchors.top: col.bottom
anchors.topMargin: Theme.paddingLarge*2
anchors.horizontalCenter: parent.horizontalCenter
width: parent.width-2*Theme.paddingLarge
spacing: Theme.paddingMedium
Icon {
id: warningIcon
source: "image://theme/icon-m-warning"
anchors.verticalCenter: parent.verticalCenter
2019-12-02 22:23:44 +03:00
}
2021-02-15 19:57:52 +03:00
Label {
width: parent.width-warningIcon.width-Theme.paddingMedium
2021-02-16 22:04:04 +03:00
anchors.verticalCenter: parent.verticalCenter
2021-02-15 19:57:52 +03:00
color: Theme.highlightColor
wrapMode: Text.WordWrap
2021-02-16 22:04:04 +03:00
text: qsTr("Port 9100 is not used for IPP.")
2021-02-15 19:57:52 +03:00
}
2019-12-02 22:23:44 +03:00
}
onDone: {
if (result == DialogResult.Accepted) {
value = valueField.text
2021-02-15 20:03:35 +03:00
ssid = wifi.ssid
2019-12-02 22:23:44 +03:00
}
}
}