on xenial help sign in
updated indicator enums
commit1004a152a732ba3795dbc3811367ef1156972e5d authorNick Dedekind <nicholas.dedekind@gmail.com> dateTue 18 Jun 2013, 18:56 (13 years ago) parent84c6341
5 files changed+37−34
Panel/Indicators/DefaultIndicatorWidget.qml+4−2 Panel/Indicators/NetworkIndicatorWidget.qml+9−9 modules/Unity/Indicators/indicators.h+21−8 modules/Unity/Indicators/plugin.cpp+3−2 modules/Unity/Indicators/qml/IndicatorWidget.qml−13
Panel/Indicators/DefaultIndicatorWidget.qml+4−2
@@ -69,10 +69,12 @@ Indicators.IndicatorWidget {
6969 if (action.state == undefined) {
7070 label = "";
7171 iconSource = "";
72+ enabled = false;
7273 return;
7374 }
7475
75− label = action.state[Indicators.ActionState.Label];
76− iconSource = "image://gicon/" + action.state[Indicators.ActionState.IconSource];
76+ label = action.state[Indicators.DefaultActionState.Label];
77+ iconSource = "image://gicon/" + action.state[Indicators.DefaultActionState.IconSource];
78+ enabled = action.state[Indicators.DefaultActionState.Visible];
7779 }
7880}
Panel/Indicators/NetworkIndicatorWidget.qml+9−9
@@ -27,7 +27,7 @@ Indicators.IndicatorWidget {
2727 width: networkIcon.width + units.gu(1)
2828
2929 property int signalStrength: 0
30− property int connectionState: Indicators.ConnectionState.Initial
30+ property int connectionState: Indicators.NetworkConnection.Initial
3131
3232 // FIXME : Should us Ubuntu.Icon . results in low res images
3333 Image {
@@ -57,9 +57,9 @@ Indicators.IndicatorWidget {
5757 return;
5858 }
5959
60− connectionState = action.state[1];
61− if (connectionState == 2) {
62− signalStrength = action.state[2];
60+ connectionState = action.state[Indicators.NetworkActionState.Connection];
61+ if (connectionState == Indicators.NetworkConnection.Activated) {
62+ signalStrength = action.state[Indicators.NetworkActionState.SignalStrength];
6363 }
6464 }
6565
@@ -76,29 +76,29 @@ Indicators.IndicatorWidget {
7676 states: [
7777 State {
7878 name: "unknown"
79− when: connectionState > Indicators.ConnectionState.Deactivating || connectionState < Indicators.ConnectionState.Activating
79+ when: connectionState < Indicators.NetworkConnection.Activating || connectionState > Indicators.NetworkConnection.Deactivating
8080 PropertyChanges { target: activation_animation; running: false }
8181 },
8282 State {
8383 name: "activating"
84− when: connectionState == Indicators.ConnectionState.Activating
84+ when: connectionState == Indicators.NetworkConnection.Activating
8585 PropertyChanges { target: activation_animation; running: true }
8686 },
8787 State {
8888 name: "activated"
89− when: connectionState == Indicators.ConnectionState.Activated
89+ when: connectionState == Indicators.NetworkConnection.Activated
9090 PropertyChanges { target: activation_animation; running: false }
9191 },
9292 State {
9393 name: "deactivating"
94− when: connectionState == Indicators.ConnectionState.Deactivating
94+ when: connectionState == Indicators.NetworkConnection.Deactivating
9595 PropertyChanges { target: activation_animation; running: true }
9696 }
9797 ]
9898
9999
100100 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) {
102102 if (value == 0) {
103103 return "image://gicon/nm-signal-00";
104104 } else if (value <= 25) {
modules/Unity/Indicators/indicators.h+21−8
@@ -19,34 +19,47 @@
1919#ifndef INDICATORS_H
2020#define INDICATORS_H
2121
22−class ActionState : public QObject
22+class DefaultActionState : public QObject
2323{
2424 Q_OBJECT
2525public:
26− Q_ENUMS(ActionStates)
27− enum ActionStates {
26+ Q_ENUMS(DefaultActionStates)
27+ enum DefaultActionStates {
2828 Label = 0x00,
2929 IconSource = 0x01,
3030 AccessableName = 0x02,
3131 Visible = 0x03,
3232 };
3333
34− ActionState(QObject*parent=0):QObject(parent) {}
34+ DefaultActionState(QObject*parent=0):QObject(parent) {}
3535};
3636
37−class ConnectionState : public QObject
37+class NetworkActionState : public QObject
3838{
3939 Q_OBJECT
4040public:
41− Q_ENUMS(ConnectionStates)
42− enum ConnectionStates {
41+ Q_ENUMS(NetworkActionStates)
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 {
4356 Initial = 0x00,
4457 Activating = 0x01,
4558 Activated = 0x02,
4659 Deactivating = 0x03,
4760 };
4861
49− ConnectionState(QObject*parent=0):QObject(parent) {}
62+ NetworkConnection(QObject*parent=0):QObject(parent) {}
5063};
5164
5265#endif // INDICATORS_H
modules/Unity/Indicators/plugin.cpp+3−2
@@ -35,6 +35,7 @@ void IndicatorsPlugin::registerTypes(const char *uri)
3535 qmlRegisterType<IndicatorsManager>(uri, 0, 1, "IndicatorsManager");
3636 qmlRegisterType<FlatMenuProxyModel>(uri, 0, 1, "FlatMenuProxyModel");
3737 qmlRegisterType<IndicatorsModel>(uri, 0, 1, "IndicatorsModel");
38− qmlRegisterUncreatableType<ActionState>(uri, 0, 1, "ActionState", "Can't create ActionState class");
39− qmlRegisterUncreatableType<ConnectionState>(uri, 0, 1, "ConnectionState", "Can't create ConnectionState 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");
40+ qmlRegisterUncreatableType<NetworkConnection>(uri, 0, 1, "NetworkConnection", "Can't create NetworkConnection class");
4041}
modules/Unity/Indicators/qml/IndicatorWidget.qml−13
@@ -74,17 +74,4 @@ IndicatorBase {
7474 onStateChanged: actionStateChanged()
7575 onValidChanged: actionStateChanged()
7676 }
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− }
9077}