Changeset View
Changeset View
Standalone View
Standalone View
applet/contents/ui/PopupDialog.qml
Show All 21 Lines | |||||
22 | import QtQuick.Layouts 1.2 | 22 | import QtQuick.Layouts 1.2 | ||
23 | import org.kde.plasma.components 2.0 as PlasmaComponents | 23 | import org.kde.plasma.components 2.0 as PlasmaComponents | ||
24 | import org.kde.plasma.core 2.0 as PlasmaCore | 24 | import org.kde.plasma.core 2.0 as PlasmaCore | ||
25 | import org.kde.plasma.extras 2.0 as PlasmaExtras | 25 | import org.kde.plasma.extras 2.0 as PlasmaExtras | ||
26 | import org.kde.plasma.networkmanagement 0.2 as PlasmaNM | 26 | import org.kde.plasma.networkmanagement 0.2 as PlasmaNM | ||
27 | 27 | | |||
28 | FocusScope { | 28 | FocusScope { | ||
29 | id: full | 29 | id: full | ||
30 | property var notificationInhibitorLock: undefined | 30 | | ||
31 | property alias toolbarValues: toolbar | ||||
31 | 32 | | |||
32 | PlasmaNM.AvailableDevices { | 33 | PlasmaNM.AvailableDevices { | ||
33 | id: availableDevices | 34 | id: availableDevices | ||
34 | } | 35 | } | ||
35 | 36 | | |||
36 | Component { | 37 | Component { | ||
37 | id: networkModelComponent | 38 | id: networkModelComponent | ||
38 | PlasmaNM.NetworkModel {} | 39 | PlasmaNM.NetworkModel {} | ||
Show All 14 Lines | 53 | Toolbar { | |||
53 | id: toolbar | 54 | id: toolbar | ||
54 | Layout.fillWidth: true | 55 | Layout.fillWidth: true | ||
55 | } | 56 | } | ||
56 | 57 | | |||
57 | PlasmaExtras.ScrollArea { | 58 | PlasmaExtras.ScrollArea { | ||
58 | id: scrollView | 59 | id: scrollView | ||
59 | Layout.fillWidth: true | 60 | Layout.fillWidth: true | ||
60 | Layout.fillHeight: true | 61 | Layout.fillHeight: true | ||
62 | frameVisible: false | ||||
63 | | ||||
64 | PlasmaExtras.Heading { | ||||
65 | id: disabledMessage | ||||
66 | anchors.fill: parent | ||||
67 | horizontalAlignment: Text.AlignHCenter | ||||
68 | verticalAlignment: Text.AlignVCenter | ||||
69 | level: 3 | ||||
70 | visible: connectionView.count === 0 && text != "" | ||||
71 | enabled: false | ||||
72 | text: { | ||||
73 | if (toolbarValues.displayplaneModeMessage) { | ||||
74 | return i18n("Airplane mode is enabled") | ||||
75 | } | ||||
76 | if (toolbarValues.displayWifiMessage) { | ||||
77 | if (toolbarValues.displayWwanMessage) { | ||||
78 | return i18n("Wireless and mobile networks are deactivated") | ||||
79 | } | ||||
80 | return i18n("Wireless is deactivated") | ||||
81 | } | ||||
82 | if (toolbarValues.displayWwanMessage) { | ||||
83 | return i18n("Mobile network is deactivated") | ||||
84 | } | ||||
85 | return "" | ||||
86 | } | ||||
87 | } | ||||
88 | | ||||
89 | PlasmaExtras.Heading { | ||||
90 | id: message | ||||
91 | anchors.fill: parent | ||||
92 | horizontalAlignment: Text.AlignHCenter | ||||
93 | verticalAlignment: Text.AlignVCenter | ||||
94 | level: 3 | ||||
95 | opacity: connectionView.count === 0 && !disabledMessage.visible ? 0.6 : 0 | ||||
96 | // Check connectionView.count again, to avoid a small delay. | ||||
97 | visible: opacity >= 0.6 && connectionView.count === 0 | ||||
98 | Behavior on opacity { NumberAnimation { duration: 5000 } } | ||||
99 | text: i18n("No available connections") | ||||
100 | } | ||||
61 | 101 | | |||
62 | ListView { | 102 | ListView { | ||
63 | id: connectionView | 103 | id: connectionView | ||
64 | 104 | | |||
65 | property bool availableConnectionsVisible: false | | |||
66 | property int currentVisibleButtonIndex: -1 | 105 | property int currentVisibleButtonIndex: -1 | ||
106 | property bool showSeparator: false | ||||
67 | 107 | | |||
68 | anchors.fill: parent | 108 | spacing: units.smallSpacing | ||
69 | clip: true | 109 | clip: true | ||
70 | model: appletProxyModel | 110 | model: appletProxyModel | ||
71 | currentIndex: -1 | 111 | currentIndex: -1 | ||
72 | boundsBehavior: Flickable.StopAtBounds | 112 | boundsBehavior: Flickable.StopAtBounds | ||
73 | section.property: showSections ? "Section" : "" | 113 | section.property: showSeparator ? "Section" : "" | ||
74 | section.delegate: Header { text: section } | 114 | section.delegate: ListItem { separator: true } | ||
115 | highlight: PlasmaComponents.Highlight { } | ||||
116 | highlightMoveDuration: 0 | ||||
117 | highlightResizeDuration: 0 | ||||
75 | delegate: ConnectionItem { } | 118 | delegate: ConnectionItem { } | ||
76 | } | 119 | } | ||
77 | } | 120 | } | ||
78 | } | 121 | } | ||
79 | 122 | | |||
80 | Connections { | 123 | Connections { | ||
81 | target: plasmoid | 124 | target: plasmoid | ||
82 | onExpandedChanged: { | 125 | onExpandedChanged: { | ||
83 | connectionView.currentVisibleButtonIndex = -1; | 126 | connectionView.currentVisibleButtonIndex = -1; | ||
84 | if (expanded) { | | |||
85 | var service = notificationsEngine.serviceForSource("notifications"); | | |||
86 | var operation = service.operationDescription("inhibit"); | | |||
87 | operation.hint = "x-kde-appname"; | | |||
88 | operation.value = "networkmanagement"; | | |||
89 | var job = service.startOperationCall(operation); | | |||
90 | job.finished.connect(function(job) { | | |||
91 | if (expanded) { | | |||
92 | notificationInhibitorLock = job.result; | | |||
93 | } | | |||
94 | }); | | |||
95 | handler.requestScan() | | |||
96 | } else { | | |||
97 | notificationInhibitorLock = undefined; | | |||
98 | toolbar.closeSearch() | | |||
99 | } | | |||
100 | 127 | | |||
101 | if (expanded) { | 128 | if (expanded) { | ||
129 | handler.requestScan(); | ||||
102 | full.connectionModel = networkModelComponent.createObject(full) | 130 | full.connectionModel = networkModelComponent.createObject(full) | ||
103 | } else { | 131 | } else { | ||
104 | full.connectionModel.destroy() | 132 | full.connectionModel.destroy() | ||
133 | toolbar.closeSearch(); | ||||
105 | } | 134 | } | ||
106 | } | 135 | } | ||
107 | } | 136 | } | ||
108 | | ||||
109 | PlasmaCore.DataSource { | | |||
110 | id: notificationsEngine | | |||
111 | engine: "notifications" | | |||
112 | } | | |||
113 | } | 137 | } |