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
|
|
|
|
|
|
|
Column {
|
|
|
|
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
|
|
|
|
text: qsTr("On WiFI:")
|
|
|
|
}
|
|
|
|
Label {
|
|
|
|
id: ssid_label
|
|
|
|
color: Theme.secondaryColor
|
|
|
|
text: ssid
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
IppPrinter {
|
|
|
|
id: printer
|
|
|
|
url: valueField.text
|
|
|
|
onAttrsChanged: {
|
|
|
|
if(printer.attrs["printer-name"]) {
|
2020-01-03 00:10:58 +03:00
|
|
|
printerName = printer.attrs["printer-name"].value == "" ? qsTr("Unknown") : printer.attrs["printer-name"].value
|
2019-12-02 22:23:44 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-01-03 00:10:58 +03:00
|
|
|
printerName = false
|
2019-12-02 22:23:44 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
onDone: {
|
|
|
|
if (result == DialogResult.Accepted) {
|
|
|
|
value = valueField.text
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|