on xenial help sign in
updated indicator enums
1004a15Nick Dedekind
Panel/Indicators/DefaultIndicatorWidget.qml+4−2
@@ -69,10 +69,12 @@ Indicators.IndicatorWidget {
69 if (action.state == undefined) {
69 if (action.state == undefined) {
70 label = "";
70 label = "";
71 iconSource = "";
71 iconSource = "";
72+ enabled = false;
72 return;
73 return;
73 }
74 }
74
75
75− label = action.state[Indicators.ActionState.Label];
76+ label = action.state[Indicators.DefaultActionState.Label];
76− iconSource = "image://gicon/" + action.state[Indicators.ActionState.IconSource];
77+ iconSource = "image://gicon/" + action.state[Indicators.DefaultActionState.IconSource];
78+ enabled = action.state[Indicators.DefaultActionState.Visible];
77 }
79 }
78}
80}
Panel/Indicators/NetworkIndicatorWidget.qml+9−9
@@ -27,7 +27,7 @@ Indicators.IndicatorWidget {
27 width: networkIcon.width + units.gu(1)
27 width: networkIcon.width + units.gu(1)
28
28
29 property int signalStrength: 0
29 property int signalStrength: 0
30− property int connectionState: Indicators.ConnectionState.Initial
30+ property int connectionState: Indicators.NetworkConnection.Initial
31
31
32 // FIXME : Should us Ubuntu.Icon . results in low res images
32 // FIXME : Should us Ubuntu.Icon . results in low res images
33 Image {
33 Image {
@@ -57,9 +57,9 @@ Indicators.IndicatorWidget {
57 return;
57 return;
58 }
58 }
59
59
60− connectionState = action.state[1];
60+ connectionState = action.state[Indicators.NetworkActionState.Connection];
61− if (connectionState == 2) {
61+ if (connectionState == Indicators.NetworkConnection.Activated) {
62− signalStrength = action.state[2];
62+ signalStrength = action.state[Indicators.NetworkActionState.SignalStrength];
63 }
63 }
64 }
64 }
65
65
@@ -76,29 +76,29 @@ Indicators.IndicatorWidget {
76 states: [
76 states: [
77 State {
77 State {
78 name: "unknown"
78 name: "unknown"
79− when: connectionState > Indicators.ConnectionState.Deactivating || connectionState < Indicators.ConnectionState.Activating
79+ when: connectionState < Indicators.NetworkConnection.Activating || connectionState > Indicators.NetworkConnection.Deactivating
80 PropertyChanges { target: activation_animation; running: false }
80 PropertyChanges { target: activation_animation; running: false }
81 },
81 },
82 State {
82 State {
83 name: "activating"
83 name: "activating"
84− when: connectionState == Indicators.ConnectionState.Activating
84+ when: connectionState == Indicators.NetworkConnection.Activating
85 PropertyChanges { target: activation_animation; running: true }
85 PropertyChanges { target: activation_animation; running: true }
86 },
86 },
87 State {
87 State {
88 name: "activated"
88 name: "activated"
89− when: connectionState == Indicators.ConnectionState.Activated
89+ when: connectionState == Indicators.NetworkConnection.Activated
90 PropertyChanges { target: activation_animation; running: false }
90 PropertyChanges { target: activation_animation; running: false }
91 },
91 },
92 State {
92 State {
93 name: "deactivating"
93 name: "deactivating"
94− when: connectionState == Indicators.ConnectionState.Deactivating
94+ when: connectionState == Indicators.NetworkConnection.Deactivating
95 PropertyChanges { target: activation_animation; running: true }
95 PropertyChanges { target: activation_animation; running: true }
96 }
96 }
97 ]
97 ]
98
98
99
99
100 function get_icon_for_signal(con_state, value) {
100 function get_icon_for_signal(con_state, value) {
101− if (con_state >= 1 && con_state <= 3) {
101+ if (con_state >= Indicators.NetworkConnection.Activating && con_state <= Indicators.NetworkConnection.Deactivating) {
102 if (value == 0) {
102 if (value == 0) {
103 return "image://gicon/nm-signal-00";
103 return "image://gicon/nm-signal-00";
104 } else if (value <= 25) {
104 } else if (value <= 25) {
modules/Unity/Indicators/indicators.h+21−8
@@ -19,34 +19,47 @@
19#ifndef INDICATORS_H
19#ifndef INDICATORS_H
20#define INDICATORS_H
20#define INDICATORS_H
21
21
22−class ActionState : public QObject
22+class DefaultActionState : public QObject
23{
23{
24 Q_OBJECT
24 Q_OBJECT
25public:
25public:
26− Q_ENUMS(ActionStates)
26+ Q_ENUMS(DefaultActionStates)
27− enum ActionStates {
27+ enum DefaultActionStates {
28 Label = 0x00,
28 Label = 0x00,
29 IconSource = 0x01,
29 IconSource = 0x01,
30 AccessableName = 0x02,
30 AccessableName = 0x02,
31 Visible = 0x03,
31 Visible = 0x03,
32 };
32 };
33
33
34− ActionState(QObject*parent=0):QObject(parent) {}
34+ DefaultActionState(QObject*parent=0):QObject(parent) {}
35};
35};
36
36
37−class ConnectionState : public QObject
37+class NetworkActionState : public QObject
38{
38{
39 Q_OBJECT
39 Q_OBJECT
40public:
40public:
41− Q_ENUMS(ConnectionStates)
41+ Q_ENUMS(NetworkActionStates)
42− enum ConnectionStates {
42+ enum NetworkActionStates {
43+ Connection = 0x01,
44+ SignalStrength = 0x02,
45+ };
46+
47+ NetworkActionState(QObject*parent=0):QObject(parent) {}
48+};
49+
50+class NetworkConnection : public QObject
51+{
52+ Q_OBJECT
53+public:
54+ Q_ENUMS(NetworkConnectionStates)
55+ enum NetworkConnectionStates {
43 Initial = 0x00,
56 Initial = 0x00,
44 Activating = 0x01,
57 Activating = 0x01,
45 Activated = 0x02,
58 Activated = 0x02,
46 Deactivating = 0x03,
59 Deactivating = 0x03,
47 };
60 };
48
61
49− ConnectionState(QObject*parent=0):QObject(parent) {}
62+ NetworkConnection(QObject*parent=0):QObject(parent) {}
50};
63};
51
64
52#endif // INDICATORS_H
65#endif // INDICATORS_H
modules/Unity/Indicators/plugin.cpp+3−2
@@ -35,6 +35,7 @@ void IndicatorsPlugin::registerTypes(const char *uri)
35 qmlRegisterType<IndicatorsManager>(uri, 0, 1, "IndicatorsManager");
35 qmlRegisterType<IndicatorsManager>(uri, 0, 1, "IndicatorsManager");
36 qmlRegisterType<FlatMenuProxyModel>(uri, 0, 1, "FlatMenuProxyModel");
36 qmlRegisterType<FlatMenuProxyModel>(uri, 0, 1, "FlatMenuProxyModel");
37 qmlRegisterType<IndicatorsModel>(uri, 0, 1, "IndicatorsModel");
37 qmlRegisterType<IndicatorsModel>(uri, 0, 1, "IndicatorsModel");
38− qmlRegisterUncreatableType<ActionState>(uri, 0, 1, "ActionState", "Can't create ActionState class");
38+ qmlRegisterUncreatableType<DefaultActionState>(uri, 0, 1, "DefaultActionState", "Can't create DefaultActionState class");
39+ qmlRegisterUncreatableType<NetworkActionState>(uri, 0, 1, "NetworkActionState", "Can't create NetworkActionState class");
39− qmlRegisterUncreatableType<ConnectionState>(uri, 0, 1, "ConnectionState", "Can't create ConnectionState class");
40+ qmlRegisterUncreatableType<NetworkConnection>(uri, 0, 1, "NetworkConnection", "Can't create NetworkConnection class");
40}
41}
modules/Unity/Indicators/qml/IndicatorWidget.qml−13
@@ -74,17 +74,4 @@ IndicatorBase {
74 onStateChanged: actionStateChanged()
74 onStateChanged: actionStateChanged()
75 onValidChanged: actionStateChanged()
75 onValidChanged: actionStateChanged()
76 }
76 }
77−
78− onActionStateChanged: {
79− if (action == undefined || !action.valid) {
80− return;
81− }
82−
83− if (action.state == undefined) {
84− enabled = false;
85− return;
86− }
87−
88− enabled = action.state[Indicators.ActionState.Visible];
89− }
90}
77}