Merge lp:~jonas-drange/ubuntu-system-settings/consolidated-devices into lp:ubuntu-system-settings

Proposed by Jonas G. Drange
Status: Needs review
Proposed branch: lp:~jonas-drange/ubuntu-system-settings/consolidated-devices
Merge into: lp:ubuntu-system-settings
Prerequisite: lp:~jonas-drange/ubuntu-system-settings/drop-ld-preload
Diff against target: 405 lines (+146/-133)
4 files modified
plugins/printing/AddPrinter.qml (+16/-8)
plugins/printing/AddPrinterDetails.qml (+130/-53)
plugins/printing/CMakeLists.txt (+0/-1)
plugins/printing/PrinterConnection.qml (+0/-71)
To merge this branch: bzr merge lp:~jonas-drange/ubuntu-system-settings/consolidated-devices
Reviewer Review Type Date Requested Status
system-apps-ci-bot continuous-integration Approve
Andrew Hayzen Pending
Review via email: mp+322105@code.launchpad.net

This proposal supersedes a proposal from 2017-03-31.

Commit message

uses Printers.consolidatedDevices to get a list of consolidated devices (multiple connections to printers of the same make/model)

Description of the change

uses Printers.consolidatedDevices to get a list of consolidated devices (multiple connections to printers of the same make/model)

To post a comment you must log in.
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote : Posted in a previous version of this proposal

PASSED: Continuous integration, rev:1773
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/31/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build/2374
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/2374
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/2187
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/2187/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=zesty/2187
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=zesty/2187/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/2187
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/2187/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=zesty/2187
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=zesty/2187/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/2187
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/2187/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=zesty/2187
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=zesty/2187/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/31/rebuild

review: Approve (continuous-integration)
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote : Posted in a previous version of this proposal

FAILED: Continuous integration, rev:1774
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/32/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/2379/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/2379
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/2192
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/2192/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=zesty/2192
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=zesty/2192/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/2192/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=zesty/2192
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=zesty/2192/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/2192/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=zesty/2192
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=zesty/2192/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/32/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote : Posted in a previous version of this proposal

FAILED: Continuous integration, rev:1775
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/33/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/2382/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/2382
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/2195
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/2195/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=zesty/2195
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=zesty/2195/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/2195/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=zesty/2195
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=zesty/2195/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/2195/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=zesty/2195
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=zesty/2195/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/33/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote : Posted in a previous version of this proposal

FAILED: Continuous integration, rev:1777
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/34/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/2385/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/2385
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/2198
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/2198/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=zesty/2198
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=zesty/2198/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/2198/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=zesty/2198
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=zesty/2198/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/2198/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=zesty/2198
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=zesty/2198/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/34/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Andrew Hayzen (ahayzen) wrote : Posted in a previous version of this proposal

This looks good and resolves my previous feedback.

The only minor comment I see is the following:
1) Go to the add printer page
2) Select one of the found consolidated network printers
3) Notice that the drivers list is filtered to that printer
4) Cancel (Pop the stack) back to the add printer page
5) Click on "Enter URI"
6) Notice that the drivers list is *still* filtered with the network printer, I was expecting the drivers list to be empty or non-filtered. This can be easily worked around by typing in the filter drivers field - so is not a big issue.

Do you want to fix this issue in this branch, or a later one?

review: Needs Information
Revision history for this message
Andrew Hayzen (ahayzen) wrote : Posted in a previous version of this proposal

This looks good now :-)

review: Approve
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote : Posted in a previous version of this proposal

FAILED: Continuous integration, rev:1778
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/35/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/2406/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/2406
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/2218
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/2218/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=zesty/2218
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=zesty/2218/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/2218/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=zesty/2218
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=zesty/2218/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/2218/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=zesty/2218
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=zesty/2218/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/35/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

PASSED: Continuous integration, rev:1780
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/44/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build/2478
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/2478
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/2289
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/2289/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=zesty/2289
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=zesty/2289/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/2289
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/2289/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=zesty/2289
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=zesty/2289/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/2289
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/2289/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=zesty/2289
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=zesty/2289/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/44/rebuild

review: Approve (continuous-integration)
1781. By Jonas G. Drange

include connections when there's only one

1782. By Jonas G. Drange

picks a perfect hit on driver automatically

1783. By Jonas G. Drange

disables the selectors

Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

PASSED: Continuous integration, rev:1781
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/45/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build/2480
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/2480
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/2291
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/2291/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=zesty/2291
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=zesty/2291/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/2291
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/2291/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=zesty/2291
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=zesty/2291/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/2291
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/2291/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=zesty/2291
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=zesty/2291/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/45/rebuild

review: Approve (continuous-integration)
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

PASSED: Continuous integration, rev:1783
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/46/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build/2482
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/2482
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/2293
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/2293/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=zesty/2293
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=zesty/2293/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/2293
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/2293/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=zesty/2293
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=zesty/2293/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/2293
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/2293/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=zesty/2293
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=zesty/2293/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/46/rebuild

review: Approve (continuous-integration)

Unmerged revisions

1783. By Jonas G. Drange

disables the selectors

1782. By Jonas G. Drange

picks a perfect hit on driver automatically

1781. By Jonas G. Drange

include connections when there's only one

1780. By Jonas G. Drange

merges prereq

1779. By Jonas G. Drange

brings back protocol selector

1778. By Jonas G. Drange

clear driver filter after popping AddPrinterDetails

1777. By Jonas G. Drange

drops unused PrinterConnection

1776. By Jonas G. Drange

shows over what protocol a printer can be reached

1775. By Jonas G. Drange

selects the first connection in the list, also removes some hacky code

1774. By Jonas G. Drange

uses makemodel instead of info on driverFilter filtering

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/printing/AddPrinter.qml'
2--- plugins/printing/AddPrinter.qml 2017-03-23 13:17:28 +0000
3+++ plugins/printing/AddPrinter.qml 2017-04-07 13:01:36 +0000
4@@ -87,7 +87,7 @@
5
6 }
7 property var target
8- Component.onCompleted: target = Printers.devices
9+ Component.onCompleted: target = Printers.consolidatedDevices
10 running: target.searching
11 }
12 }
13@@ -99,14 +99,13 @@
14 Repeater {
15 id: remotePrintersList
16 anchors { left: parent.left; right: parent.right }
17- model: Printers.devices
18+ model: Printers.consolidatedDevices
19 delegate: ListItem {
20 height: modelLayout.height + (divider.visible ? divider.height : 0)
21 anchors { left: parent.left; right: parent.right }
22 ListItemLayout {
23 id: modelLayout
24- title.text: displayName ? displayName : info
25- subtitle.text: info
26+ title.text: displayName
27
28 Icon {
29 id: icon
30@@ -119,11 +118,20 @@
31 ProgressionSlot {}
32 }
33 onClicked: {
34+ var props = {
35+ plugin: plugin
36+ };
37+ if (connectionsCount > 0) {
38+ props["connections"] = model;
39+ props["device"] = model.devices.get(0);
40+ } else if (connectionsCount >= 1) {
41+ props["device"] = model.devices.get(0);
42+ }
43 detailsPageObserver.target = pageStack.addFileToNextColumnSync(
44- addPrinterPage, Qt.resolvedUrl("AddPrinterDetails.qml"), {
45- device: model, plugin: plugin
46- }
47- )
48+ addPrinterPage,
49+ Qt.resolvedUrl("AddPrinterDetails.qml"),
50+ props
51+ );
52 }
53 }
54 }
55
56=== modified file 'plugins/printing/AddPrinterDetails.qml'
57--- plugins/printing/AddPrinterDetails.qml 2017-03-22 17:58:05 +0000
58+++ plugins/printing/AddPrinterDetails.qml 2017-04-07 13:01:36 +0000
59@@ -29,9 +29,22 @@
60 ItemPage {
61 id: describePrinterPage
62 objectName: "printingPage"
63+ property var connections: null
64 property var device: null
65 signal printerAdded()
66
67+ function updateSettingsFromDevice(device) {
68+ var suggestedName;
69+ driverFilter.field.text = device.makeModel;
70+
71+ suggestedName = (" " + device.info).slice(1);
72+ suggestedName = suggestedName.replace(/\ /g, "\-");
73+ nameField.field.text = suggestedName;
74+ hostField.field.text = device.uri;
75+ descriptionField.field.text = device.info;
76+ locationField.field.text = device.location;
77+ }
78+
79 header: PageHeader {
80 id: printerHeader
81 title: i18n.tr("Describe printer")
82@@ -52,15 +65,19 @@
83 id: addAction
84 iconName: "ok"
85 text: i18n.tr("Add printer")
86- enabled: connectionsSelector.selectedIndex > 0
87 onTriggered: {
88 describePrinterPage.state = "adding";
89 var ret;
90 if (driverSelector.selectedIndex == 0) {
91+ var driver = driversView.selectedDriver;
92+
93+ if (!driver && Printers.drivers.count == 1) {
94+ driver = Printers.drivers.get(0).name;
95+ }
96 ret = Printers.addPrinter(
97 nameField.field.text,
98- driversView.selectedDriver,
99- connection.host,
100+ driver,
101+ hostField.field.text,
102 descriptionField.field.text,
103 locationField.field.text
104 );
105@@ -68,7 +85,7 @@
106 ret = Printers.addPrinterWithPpdFile(
107 nameField.field.text,
108 pddFileField.field.text,
109- connection.host,
110+ hostField.field.text,
111 descriptionField.field.text,
112 locationField.field.text
113 );
114@@ -86,31 +103,23 @@
115 }
116
117 Component.onCompleted: {
118- var suggestedName;
119-
120 if (device) {
121- driverFilter.field.text = device.displayName;
122-
123- suggestedName = (" " + device.displayName).slice(1);
124- suggestedName = suggestedName.replace(/\ /g, "\-");
125- nameField.field.text = suggestedName;
126-
127- connectionsSelector.selectedIndex = connectionsSelector.values.indexOf(connection.typeToString(device.type));
128- connection.host = device.uri;
129-
130- descriptionField.field.text = device.info;
131- locationField.field.text = device.location;
132+ updateSettingsFromDevice(device);
133 }
134 }
135
136+ Component.onDestruction: Printers.driverFilter = ""
137+
138 states: [
139 State {
140 name: "adding"
141 PropertyChanges { target: closeAction; enabled: false }
142 PropertyChanges { target: addAction; enabled: false }
143 PropertyChanges { target: successTimer; running: true }
144- PropertyChanges { target: connection; enabled: false }
145+ PropertyChanges { target: hostField; enabled: false }
146 PropertyChanges { target: fieldsColumn; enabled: false }
147+ PropertyChanges { target: connectionsSelector; enabled: false }
148+ PropertyChanges { target: protocolSelector; enabled: false }
149 },
150 State {
151 name: "failure"
152@@ -126,37 +135,110 @@
153 Column {
154 id: fieldsColumn
155 anchors { left: parent.left; right: parent.right }
156- visible: connectionsSelector.selectedIndex > 0
157
158 clip: true
159 property bool enabled: true
160
161- ListItems.ValueSelector {
162+
163+ SettingsItemTitle {
164+ anchors {
165+ left: parent.left
166+ right: parent.right
167+ }
168+ text: i18n.tr("Connection")
169+ }
170+
171+ OptionSelector {
172 id: connectionsSelector
173- anchors { left: parent.left; right: parent.right }
174- text: i18n.tr("Connection")
175- values: [
176- i18n.tr("Choose a connection"),
177- "ipp",
178- "lpd",
179- "ipps",
180- "ipp14",
181- "http",
182- "beh",
183- "socket",
184- "https",
185- "ipp",
186- "hp",
187- "usb",
188- "hpfax",
189- "dnssd",
190+ anchors {
191+ margins: units.gu(2)
192+ left: parent.left
193+ right: parent.right
194+ }
195+ model: connections ? connections.devices : null
196+ visible: connections && connections.devices.count > 0
197+ delegate: OptionSelectorDelegate {
198+ property var device: model
199+ anchors { left: parent.left; right: parent.right }
200+ text: displayName
201+ subText: {
202+ var protocol = i18n.tr("Unknown");
203+ switch (Number(model.type)) {
204+ case PrinterEnum.LPDType:
205+ protocol = "LPD";
206+ break;
207+ case PrinterEnum.IppType:
208+ case PrinterEnum.IppSType:
209+ case PrinterEnum.Ipp14Type:
210+ protocol = "IPP";
211+ break;
212+ case PrinterEnum.BehType:
213+ protocol = "BEH";
214+ break;
215+ case PrinterEnum.SocketType:
216+ protocol = i18n.tr("AppSocket/HP JetDirect");
217+ break;
218+ case PrinterEnum.HttpType:
219+ case PrinterEnum.HttpsType:
220+ protocol = "HTTP";
221+ break;
222+ case PrinterEnum.HPType:
223+ protocol = i18n.tr("HP Linux Imaging and Printing (HPLIP)");
224+ break;
225+ case PrinterEnum.USBType:
226+ protocol = "USB";
227+ break;
228+ case PrinterEnum.HPFaxType:
229+ protocol = i18n.tr("Fax — HP Linux Imaging and Printing (HPLIP)");
230+ break;
231+ case PrinterEnum.DNSSDType:
232+ protocol = "DNS-SD";
233+ break;
234+ }
235+
236+ /* TRANSLATORS: %1 is the way we identify the printer,
237+ and %2 is the protocol via which we can connect to it.
238+ So e.g. “Mark's HP LaserJet 5000 via USB”. */
239+ return i18n.tr("%1 via %2").arg(info || makeModel).arg(protocol);
240+ }
241+ }
242+ onDelegateClicked: updateSettingsFromDevice(
243+ connections.devices.get(index)
244+ )
245+ }
246+
247+ OptionSelector {
248+ id: protocolSelector
249+ anchors {
250+ margins: units.gu(2)
251+ left: parent.left
252+ right: parent.right
253+ }
254+ model: [
255+ i18n.tr("Choose a connection"),
256+ "ipp",
257+ "lpd",
258+ "ipps",
259+ "http",
260+ "beh",
261+ "socket",
262+ "https",
263+ "ipp",
264+ "hp",
265+ "usb",
266+ "hpfax",
267+ "dnssd",
268 ]
269- onSelectedIndexChanged: {
270- if (selectedIndex === 0) {
271- connection.type = PrinterEnum.IppType;
272- } else {
273- connection.type = connection.stringToType(values[selectedIndex]);
274+ visible: !connections
275+ onDelegateClicked: {
276+ var host = hostField.field.text;
277+ var newText = "";
278+
279+ if (index > 0) {
280+ newText = model[index];
281 }
282+
283+ hostField.field.text = newText;
284 }
285 }
286
287@@ -185,16 +267,10 @@
288 }
289 }
290
291- PrinterConnection {
292- id: connection
293- anchors { left: parent.left; right: parent.right }
294- onTypeChanged: {
295- var selIndex = connectionsSelector.values.indexOf(typeToString(type));
296- if (selIndex < 0) {
297- selIndex = 0;
298- }
299- connectionsSelector.selectedIndex = selIndex;
300- }
301+ TextBoxListItem {
302+ id: hostField
303+ text: i18n.tr("Host")
304+ enabled: fieldsColumn.enabled
305 }
306
307 TextBoxListItem {
308@@ -275,7 +351,8 @@
309 width: units.gu(2)
310 height: width
311 SlotsLayout.position: SlotsLayout.Trailing
312- visible: model.name == driversView.selectedDriver
313+ visible: (model.name == driversView.selectedDriver) ||
314+ (Printers.drivers.count == 1)
315 }
316 }
317 onClicked: {
318
319=== modified file 'plugins/printing/CMakeLists.txt'
320--- plugins/printing/CMakeLists.txt 2017-03-22 16:00:27 +0000
321+++ plugins/printing/CMakeLists.txt 2017-04-07 13:01:36 +0000
322@@ -10,7 +10,6 @@
323 AddPrinterDetails.qml
324 PageComponent.qml
325 Printer.qml
326- PrinterConnection.qml
327 Setting.qml
328 TextBoxListItem.qml
329 )
330
331=== removed file 'plugins/printing/PrinterConnection.qml'
332--- plugins/printing/PrinterConnection.qml 2017-03-22 16:00:27 +0000
333+++ plugins/printing/PrinterConnection.qml 1970-01-01 00:00:00 +0000
334@@ -1,71 +0,0 @@
335-/*
336- * This file is part of system-settings
337- *
338- * Copyright (C) 2017 Canonical Ltd.
339- *
340- * This program is free software: you can redistribute it and/or modify it
341- * under the terms of the GNU General Public License version 3, as published
342- * by the Free Software Foundation.
343- *
344- * This program is distributed in the hope that it will be useful, but
345- * WITHOUT ANY WARRANTY; without even the implied warranties of
346- * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
347- * PURPOSE. See the GNU General Public License for more details.
348- *
349- * You should have received a copy of the GNU General Public License along
350- * with this program. If not, see <http://www.gnu.org/licenses/>.
351- *
352- * Authored by Jonas G. Drange <jonas.drange@canonical.com>
353- */
354-
355-import QtQuick 2.4
356-import SystemSettings 1.0
357-import Ubuntu.Components 1.3
358-import Ubuntu.Components.Extras.Printers 0.1
359-import SystemSettings.ListItems 1.0 as SettingsListItems
360-
361-Column {
362- id: root
363- property alias host: hostField.textFieldText
364- property bool enabled: true
365-
366- function stringToType(str) {
367- if (str == "lpd") return PrinterEnum.LPDType;
368- if (str == "ipps") return PrinterEnum.IppSType;
369- if (str == "ipp14") return PrinterEnum.Ipp14Type;
370- if (str == "http") return PrinterEnum.HttpType;
371- if (str == "beh") return PrinterEnum.BehType;
372- if (str == "socket") return PrinterEnum.SocketType;
373- if (str == "https") return PrinterEnum.HttpsType;
374- if (str == "ipp") return PrinterEnum.IppType;
375- if (str == "hp") return PrinterEnum.HPType;
376- if (str == "usb") return PrinterEnum.USBType;
377- if (str == "hpfax") return PrinterEnum.HPFaxType;
378- if (str == "dnssd") return PrinterEnum.DNSSDType;
379- return PrinterEnum.UnknownType;
380- }
381-
382- function typeToString(type) {
383- if (type == PrinterEnum.LPDType) return "lpd";
384- if (type == PrinterEnum.IppSType) return "ipps";
385- if (type == PrinterEnum.Ipp14Type) return "ipp14";
386- if (type == PrinterEnum.HttpType) return "http";
387- if (type == PrinterEnum.BehType) return "beh";
388- if (type == PrinterEnum.SocketType) return "socket";
389- if (type == PrinterEnum.HttpsType) return "https";
390- if (type == PrinterEnum.IppType) return "ipp";
391- if (type == PrinterEnum.HPType) return "hp";
392- if (type == PrinterEnum.USBType) return "usb";
393- if (type == PrinterEnum.HPFaxType) return "hpfax";
394- if (type == PrinterEnum.DNSSDType) return "dnssd";
395- }
396-
397- property var type: PrinterEnum.IppType
398-
399- TextBoxListItem {
400- id: hostField
401- text: i18n.tr("Host")
402- enabled: root.enabled
403- placeholderText: "%1://printer.mydomain/%1".arg(typeToString(type))
404- }
405-}

Subscribers

People subscribed via source and target branches