Changeset View
Changeset View
Standalone View
Standalone View
src/applet/package/contents/ui/FullRepresentation.qml
Show All 13 Lines | 1 | /* | |||
---|---|---|---|---|---|
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
16 | Lesser General Public License for more details. | 16 | Lesser General Public License for more details. | ||
17 | 17 | | |||
18 | You should have received a copy of the GNU Lesser General Public | 18 | You should have received a copy of the GNU Lesser General Public | ||
19 | License along with this library. If not, see <http://www.gnu.org/licenses/>. | 19 | License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
20 | */ | 20 | */ | ||
21 | 21 | | |||
22 | import QtQuick 2.2 | 22 | import QtQuick 2.4 | ||
23 | import QtQuick.Controls 2.4 | ||||
23 | import org.kde.bluezqt 1.0 as BluezQt | 24 | import org.kde.bluezqt 1.0 as BluezQt | ||
24 | import org.kde.plasma.extras 2.0 as PlasmaExtras | 25 | import org.kde.plasma.extras 2.0 as PlasmaExtras | ||
25 | import org.kde.plasma.components 2.0 as PlasmaComponents | 26 | import org.kde.plasma.components 2.0 as PlasmaComponents | ||
26 | import org.kde.plasma.components 3.0 as PlasmaComponents3 | 27 | import org.kde.plasma.components 3.0 as PlasmaComponents3 | ||
27 | import org.kde.plasma.private.bluetooth 1.0 as PlasmaBt | 28 | import org.kde.plasma.private.bluetooth 1.0 as PlasmaBt | ||
28 | 29 | | |||
30 | import org.kde.kirigami 2.12 as Kirigami | ||||
31 | | ||||
29 | PlasmaComponents3.Page { | 32 | PlasmaComponents3.Page { | ||
30 | 33 | | |||
31 | header: Toolbar { | 34 | Action { | ||
32 | id: toolbar | 35 | id: addBluetoothDeviceAction | ||
33 | } | | |||
34 | 36 | | |||
35 | FocusScope { | 37 | enabled: btManager.devices.length === 0 | ||
36 | anchors.fill: parent | | |||
37 | focus: true | | |||
38 | 38 | | |||
39 | PlasmaBt.DevicesProxyModel { | 39 | text: i18n("Add New Device") | ||
40 | id: devicesModel | 40 | icon.name: "list-add" | ||
41 | sourceModel: BluezQt.DevicesModel { } | | |||
42 | } | | |||
43 | | ||||
44 | PlasmaExtras.Heading { | | |||
45 | id: noAdaptersHeading | | |||
46 | level: 3 | | |||
47 | opacity: 0.6 | | |||
48 | text: i18n("No Adapters Available") | | |||
49 | 41 | | |||
50 | anchors { | 42 | onTriggered: { | ||
51 | top: parent.top | 43 | PlasmaBt.LaunchApp.runCommand("bluedevil-wizard"); | ||
52 | left: parent.left | | |||
53 | } | 44 | } | ||
54 | } | 45 | } | ||
46 | Action { | ||||
47 | id: enableBluetoothAction | ||||
55 | 48 | | |||
56 | Item { | 49 | enabled: btManager.bluetoothBlocked | ||
57 | id: bluetoothDisabledView | | |||
58 | anchors.fill: parent | | |||
59 | | ||||
60 | PlasmaExtras.Heading { | | |||
61 | id: bluetoothDisabledHeading | | |||
62 | level: 3 | | |||
63 | opacity: 0.6 | | |||
64 | text: i18n("Bluetooth is Disabled") | | |||
65 | | ||||
66 | anchors { | | |||
67 | horizontalCenter: parent.horizontalCenter | | |||
68 | bottom: enableBluetoothButton.top | | |||
69 | bottomMargin: units.smallSpacing | | |||
70 | } | | |||
71 | } | | |||
72 | 50 | | |||
73 | PlasmaComponents.Button { | | |||
74 | id: enableBluetoothButton | | |||
75 | text: i18n("Enable Bluetooth") | 51 | text: i18n("Enable Bluetooth") | ||
76 | iconSource: "preferences-system-bluetooth" | 52 | icon.name: "preferences-system-bluetooth" | ||
77 | 53 | | |||
78 | anchors { | 54 | onTriggered: { | ||
79 | horizontalCenter: parent.horizontalCenter | | |||
80 | verticalCenter: parent.verticalCenter | | |||
81 | } | | |||
82 | | ||||
83 | onClicked: { | | |||
84 | toolbar.toggleBluetooth(); | 55 | toolbar.toggleBluetooth(); | ||
85 | } | 56 | } | ||
86 | } | 57 | } | ||
87 | } | | |||
88 | 58 | | |||
89 | PlasmaExtras.ScrollArea { | 59 | header: Toolbar { | ||
90 | id: scrollView | 60 | id: toolbar | ||
91 | visible: toolbar.visible | 61 | visible: !btManager.bluetoothBlocked && btManager.adapters.length > 0 | ||
92 | 62 | } | |||
93 | anchors.fill: parent | | |||
94 | 63 | | |||
95 | Item { | 64 | FocusScope { | ||
96 | id: noDevicesView | | |||
97 | anchors.fill: parent | 65 | anchors.fill: parent | ||
66 | focus: true | ||||
98 | 67 | | |||
99 | PlasmaExtras.Heading { | 68 | PlasmaBt.DevicesProxyModel { | ||
100 | id: noDevicesHeading | 69 | id: devicesModel | ||
101 | level: 3 | 70 | sourceModel: BluezQt.DevicesModel { } | ||
102 | opacity: 0.6 | | |||
103 | text: i18n("No Devices Found") | | |||
104 | | ||||
105 | anchors { | | |||
106 | horizontalCenter: parent.horizontalCenter | | |||
107 | bottom: addDeviceButton.top | | |||
108 | bottomMargin: units.smallSpacing | | |||
109 | } | | |||
110 | } | 71 | } | ||
111 | 72 | | |||
112 | PlasmaComponents.Button { | 73 | PlasmaExtras.ScrollArea { | ||
113 | id: addDeviceButton | 74 | id: scrollView | ||
114 | text: i18n("Add New Device") | | |||
115 | iconSource: "list-add" | | |||
116 | 75 | | |||
117 | anchors { | 76 | anchors.fill: parent | ||
118 | horizontalCenter: parent.horizontalCenter | | |||
119 | verticalCenter: parent.verticalCenter | | |||
120 | } | | |||
121 | 77 | | |||
122 | onClicked: { | 78 | visible: toolbar.visible | ||
123 | PlasmaBt.LaunchApp.runCommand("bluedevil-wizard"); | | |||
124 | } | | |||
125 | } | | |||
126 | } | | |||
127 | 79 | | |||
128 | ListView { | 80 | ListView { | ||
129 | id: devicesView | | |||
130 | anchors.fill: parent | 81 | anchors.fill: parent | ||
131 | clip: true | 82 | clip: true | ||
132 | model: devicesModel | 83 | model: devicesModel | ||
133 | currentIndex: -1 | 84 | currentIndex: -1 | ||
134 | enabled: btManager.bluetoothOperational | 85 | enabled: btManager.bluetoothOperational | ||
135 | boundsBehavior: Flickable.StopAtBounds | 86 | boundsBehavior: Flickable.StopAtBounds | ||
136 | section.property: "Section" | 87 | section.property: "Section" | ||
137 | section.delegate: Header { | 88 | section.delegate: Header { | ||
138 | text: section == "Connected" ? i18n("Connected devices") : i18n("Available devices") | 89 | text: section == "Connected" ? i18n("Connected devices") : i18n("Available devices") | ||
139 | } | 90 | } | ||
140 | highlight: PlasmaComponents.Highlight { } | 91 | highlight: PlasmaComponents.Highlight { } | ||
141 | highlightMoveDuration: units.longDuration | 92 | highlightMoveDuration: units.longDuration | ||
142 | highlightResizeDuration: units.longDuration | 93 | highlightResizeDuration: units.longDuration | ||
143 | delegate: DeviceItem { } | 94 | delegate: DeviceItem { } | ||
144 | } | 95 | } | ||
145 | } | 96 | } | ||
146 | 97 | | |||
147 | states: [ | 98 | // Not inside the ListView because we want the listview to be hidden | ||
148 | State { | 99 | // when Bluetooth is disabled, yet still show an "Enable Bluetooth" | ||
149 | name: "BlockedState" | 100 | // message | ||
150 | when: btManager.bluetoothBlocked | 101 | Kirigami.PlaceholderMessage { | ||
151 | }, | 102 | anchors.centerIn: parent | ||
152 | State { | 103 | anchors.left: parent.left | ||
153 | name: "DevicesState" | 104 | anchors.right: parent.right | ||
154 | when: btManager.devices.length | 105 | anchors.margins: units.largeSpacing | ||
155 | }, | 106 | | ||
156 | State { | 107 | visible: text.length > 0 | ||
157 | name: "NoDevicesState" | 108 | | ||
158 | when: btManager.adapters.length && !btManager.devices.length | 109 | text: { | ||
159 | }, | 110 | if (btManager.adapters.length === 0) { | ||
160 | State { | 111 | return i18n("No Bluetooth Adapters Available") | ||
161 | name: "NoAdaptersState" | 112 | } else if (btManager.bluetoothBlocked) { | ||
162 | when: !btManager.adapters.length | 113 | return i18n("Bluetooth is Disabled") | ||
163 | } | 114 | } else if (btManager.devices.length === 0) { | ||
164 | ] | 115 | return i18n("No Devices Found") | ||
165 | 116 | } | |||
166 | onStateChanged: { | 117 | return "" | ||
167 | noAdaptersHeading.visible = (state == "NoAdaptersState"); | 118 | } | ||
168 | toolbar.visible = (state == "DevicesState" || state == "NoDevicesState"); | 119 | | ||
169 | noDevicesView.visible = (state == "NoDevicesState"); | 120 | helpfulAction: { | ||
170 | bluetoothDisabledView.visible = (state == "BlockedState"); | 121 | if (btManager.bluetoothBlocked) { | ||
171 | devicesView.visible = (state == "DevicesState"); | 122 | return enableBluetoothAction | ||
123 | } else if (btManager.devices.length === 0) { | ||||
124 | return addBluetoothDeviceAction | ||||
125 | } | ||||
126 | return undefined | ||||
127 | } | ||||
172 | } | 128 | } | ||
173 | } | 129 | } | ||
174 | } | 130 | } |