Merge lp:~unity-team/unity8/indicators-client into lp:unity8

Proposed by Michał Sawicz
Status: Merged
Approved by: Michał Sawicz
Approved revision: 116
Merged at revision: 102
Proposed branch: lp:~unity-team/unity8/indicators-client
Merge into: lp:unity8
Diff against target: 8866 lines (+7025/-588)
156 files modified
CMakeLists.txt (+3/-1)
Panel/IndicatorItem.qml (+22/-35)
Panel/IndicatorRow.qml (+5/-3)
Panel/Indicators.qml (+3/-7)
Panel/Indicators/DatetimeIndicatorPage.qml (+97/-0)
Panel/Indicators/DatetimeIndicatorWidget.qml (+65/-0)
Panel/Indicators/DefaultIndicatorPage.qml (+25/-0)
Panel/Indicators/DefaultIndicatorWidget.qml (+80/-0)
Panel/Indicators/MessagingIndicatorPage.qml (+35/-0)
Panel/Indicators/MessagingIndicatorWidget.qml (+25/-0)
Panel/Indicators/NetworkIndicatorPage.qml (+80/-0)
Panel/Indicators/NetworkIndicatorWidget.qml (+109/-0)
Panel/Indicators/SoundIndicatorWidget.qml (+25/-0)
Panel/Indicators/client/IndicatorsClient.qml (+42/-0)
Panel/Indicators/client/IndicatorsList.qml (+62/-0)
Panel/Indicators/client/IndicatorsPage.qml (+49/-0)
Panel/IndicatorsDataModel.qml (+66/-0)
Panel/MenuContent.qml (+19/-22)
Panel/Menus/Overview/OverviewGrid.qml (+16/-25)
build (+1/-2)
cmake/modules/autopilot.cmake (+7/-4)
debian/control (+21/-7)
debian/indicators-client.install (+1/-0)
debian/unity8.install (+1/-0)
main.cpp (+1/-2)
paths.h.in (+15/-0)
plugins/Unity/CMakeLists.txt (+2/-0)
plugins/Unity/Indicators/CMakeLists.txt (+52/-0)
plugins/Unity/Indicators/Messaging/CMakeLists.txt (+1/-0)
plugins/Unity/Indicators/Messaging/qml/ActionButton.qml (+43/-0)
plugins/Unity/Indicators/Messaging/qml/ActionTextField.qml (+66/-0)
plugins/Unity/Indicators/Messaging/qml/CMakeLists.txt (+15/-0)
plugins/Unity/Indicators/Messaging/qml/GroupedMessage.qml (+96/-0)
plugins/Unity/Indicators/Messaging/qml/HeroMessage.qml (+120/-0)
plugins/Unity/Indicators/Messaging/qml/HeroMessageHeader.qml (+161/-0)
plugins/Unity/Indicators/Messaging/qml/MessageMenuItem.qml (+96/-0)
plugins/Unity/Indicators/Messaging/qml/QuickReply.qml (+160/-0)
plugins/Unity/Indicators/Messaging/qml/SimpleTextMessage.qml (+97/-0)
plugins/Unity/Indicators/Messaging/qml/SnapDecision.qml (+142/-0)
plugins/Unity/Indicators/Messaging/qml/TextMessage.qml (+35/-0)
plugins/Unity/Indicators/Messaging/qml/qmldir (+12/-0)
plugins/Unity/Indicators/Messaging/qml/utils.js (+27/-0)
plugins/Unity/Indicators/Network/CMakeLists.txt (+42/-0)
plugins/Unity/Indicators/Network/networkagent.cpp (+146/-0)
plugins/Unity/Indicators/Network/networkagent.h (+65/-0)
plugins/Unity/Indicators/Network/plugin.cpp (+31/-0)
plugins/Unity/Indicators/Network/plugin.h (+32/-0)
plugins/Unity/Indicators/Network/qml/AccessPoint.qml (+68/-0)
plugins/Unity/Indicators/Network/qml/CMakeLists.txt (+15/-0)
plugins/Unity/Indicators/Network/qml/PasswordPage.qml (+88/-0)
plugins/Unity/Indicators/Network/qml/PasswordTextField.qml (+68/-0)
plugins/Unity/Indicators/Network/qml/WifiSection.qml (+34/-0)
plugins/Unity/Indicators/Network/qml/qmldir (+8/-0)
plugins/Unity/Indicators/Network/secret-agent.c (+382/-0)
plugins/Unity/Indicators/Network/secret-agent.h (+102/-0)
plugins/Unity/Indicators/flatmenuproxymodel.cpp (+272/-0)
plugins/Unity/Indicators/flatmenuproxymodel.h (+91/-0)
plugins/Unity/Indicators/indicator.cpp (+88/-0)
plugins/Unity/Indicators/indicator.h (+57/-0)
plugins/Unity/Indicators/indicators.h (+103/-0)
plugins/Unity/Indicators/indicatorsmanager.cpp (+285/-0)
plugins/Unity/Indicators/indicatorsmanager.h (+73/-0)
plugins/Unity/Indicators/indicatorsmodel.cpp (+321/-0)
plugins/Unity/Indicators/indicatorsmodel.h (+81/-0)
plugins/Unity/Indicators/plugin.cpp (+44/-0)
plugins/Unity/Indicators/plugin.h (+32/-0)
plugins/Unity/Indicators/qml/BasicMenuItem.qml (+48/-0)
plugins/Unity/Indicators/qml/ButtonMenuItem.qml (+47/-0)
plugins/Unity/Indicators/qml/CMakeLists.txt (+14/-0)
plugins/Unity/Indicators/qml/DivMenuItem.qml (+26/-0)
plugins/Unity/Indicators/qml/HLine.qml (+29/-0)
plugins/Unity/Indicators/qml/IndicatorBase.qml (+59/-0)
plugins/Unity/Indicators/qml/IndicatorPage.qml (+197/-0)
plugins/Unity/Indicators/qml/IndicatorWidget.qml (+68/-0)
plugins/Unity/Indicators/qml/MenuAction.qml (+86/-0)
plugins/Unity/Indicators/qml/MenuActionBinding.qml (+106/-0)
plugins/Unity/Indicators/qml/MenuItem.qml (+40/-0)
plugins/Unity/Indicators/qml/MenuItemFactory.qml (+110/-0)
plugins/Unity/Indicators/qml/ProgressMenuItem.qml (+65/-0)
plugins/Unity/Indicators/qml/RemoveBackground.qml (+55/-0)
plugins/Unity/Indicators/qml/SectionMenuItem.qml (+57/-0)
plugins/Unity/Indicators/qml/SliderMenuItem.qml (+64/-0)
plugins/Unity/Indicators/qml/SwitchMenuItem.qml (+43/-0)
plugins/Unity/Indicators/qml/qmldir (+20/-0)
plugins/Unity/Indicators/resources/artwork/messaging/default_app.svg (+42/-0)
plugins/Unity/Indicators/resources/indicators.qrc (+7/-0)
plugins/Utils/CMakeLists.txt (+1/-0)
plugins/Utils/applicationpaths.h (+38/-0)
plugins/Utils/plugin.cpp (+8/-0)
run (+3/-3)
src/CMakeLists.txt (+1/-0)
src/Panel/CMakeLists.txt (+1/-0)
src/Panel/Indicators/CMakeLists.txt (+2/-0)
src/Panel/Indicators/client/CMakeLists.txt (+25/-0)
src/Panel/Indicators/client/indicatorsclient.cpp (+99/-0)
src/Panel/Indicators/client/indicatorsclient.h (+45/-0)
src/Panel/Indicators/client/main.cpp (+26/-0)
src/Panel/Indicators/servicefiles/CMakeLists.txt (+18/-0)
src/Panel/Indicators/servicefiles/com.canonical.indicator.battery (+9/-0)
src/Panel/Indicators/servicefiles/com.canonical.indicator.messages (+9/-0)
src/Panel/Indicators/servicefiles/com.canonical.indicator.time (+9/-0)
src/Panel/Indicators/servicefiles/com.canonical.settings.network (+9/-0)
src/Panel/Indicators/servicefiles/com.canonical.settings.sound (+9/-0)
tests/autopilot/unity8/__init__.py (+8/-0)
tests/autopilot/unity8/indicators_client/__init__.py (+8/-0)
tests/autopilot/unity8/indicators_client/emulators/__init__.py (+31/-0)
tests/autopilot/unity8/indicators_client/emulators/common.py (+14/-0)
tests/autopilot/unity8/indicators_client/emulators/main_window.py (+27/-0)
tests/autopilot/unity8/indicators_client/tests/__init__.py (+87/-0)
tests/autopilot/unity8/indicators_client/tests/test_battery.py (+99/-0)
tests/autopilot/unity8/shell/__init__.py (+1/-1)
tests/autopilot/unity8/shell/tests/__init__.py (+1/-1)
tests/autopilot/unity8/shell/tests/testbigscreen.py (+1/-1)
tests/autopilot/unity8/shell/tests/testhud.py (+2/-2)
tests/autopilot/unity8/shell/tests/testlockscreen.py (+2/-2)
tests/data/unity/indicators/com.canonical.indicator.fake1 (+9/-0)
tests/data/unity/indicators/com.canonical.indicator.fake2 (+9/-0)
tests/data/unity/indicators/com.canonical.indicator.fake3 (+9/-0)
tests/data/unity/indicators/com.canonical.indicator.fake4 (+9/-0)
tests/mocks/Ubuntu/CMakeLists.txt (+0/-1)
tests/mocks/Ubuntu/ChewieUI/CMakeLists.txt (+0/-33)
tests/mocks/Ubuntu/ChewieUI/fake_chewie_plugin.cpp (+0/-30)
tests/mocks/Ubuntu/ChewieUI/fake_chewie_plugin.h (+0/-31)
tests/mocks/Ubuntu/ChewieUI/fake_pluginmodel.cpp (+0/-206)
tests/mocks/Ubuntu/ChewieUI/fake_pluginmodel.h (+0/-94)
tests/mocks/Ubuntu/ChewieUI/qmldir (+0/-1)
tests/mocks/Unity/CMakeLists.txt (+2/-0)
tests/mocks/Unity/Indicators/CMakeLists.txt (+52/-0)
tests/mocks/Unity/Indicators/IndicatorsModel.qml (+104/-0)
tests/mocks/Unity/Indicators/fakeplugin.cpp (+37/-0)
tests/mocks/Unity/Indicators/fakeplugin.h (+32/-0)
tests/mocks/Unity/Indicators/indicators_fake.qrc (+14/-0)
tests/mocks/Unity/Indicators/qml/fake_menu_page1.qml (+3/-2)
tests/mocks/Unity/Indicators/qml/fake_menu_page2.qml (+3/-2)
tests/mocks/Unity/Indicators/qml/fake_menu_page3.qml (+3/-2)
tests/mocks/Unity/Indicators/qml/fake_menu_page4.qml (+3/-2)
tests/mocks/Unity/Indicators/qml/fake_menu_page5.qml (+3/-2)
tests/mocks/Unity/Indicators/qml/fake_menu_widget1.qml (+23/-0)
tests/mocks/Unity/Indicators/qml/fake_menu_widget2.qml (+23/-0)
tests/mocks/Unity/Indicators/qml/fake_menu_widget3.qml (+23/-0)
tests/mocks/Unity/Indicators/qml/fake_menu_widget4.qml (+23/-0)
tests/mocks/Unity/Indicators/qml/fake_menu_widget5.qml (+23/-0)
tests/mocks/Unity/Indicators/qmldir (+5/-0)
tests/plugins/Unity/CMakeLists.txt (+2/-0)
tests/plugins/Unity/Indicators/CMakeLists.txt (+27/-0)
tests/plugins/Unity/Indicators/indicatorsmanagertest.cpp (+138/-0)
tests/plugins/Unity/Indicators/indicatorsmodeltest.cpp (+102/-0)
tests/qmltests/Panel/tst_IndicatorItem.qml (+16/-31)
tests/qmltests/Panel/tst_IndicatorRow.qml (+4/-3)
tests/qmltests/Panel/tst_Indicators.qml (+1/-2)
tests/qmltests/Panel/tst_MenuContent.qml (+11/-10)
tests/qmltests/Panel/tst_Overview.qml (+5/-17)
tests/qmltests/Panel/tst_Panel.qml (+0/-1)
tests/qmltests/modules/CMakeLists.txt (+1/-0)
tests/qmltests/modules/Unity/CMakeLists.txt (+1/-0)
unity8.qmlproject (+1/-0)
To merge this branch: bzr merge lp:~unity-team/unity8/indicators-client
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Michał Sawicz Approve
Nicolas d'Offay (community) Approve
Review via email: mp+172582@code.launchpad.net

Commit message

Moved indicators-client code into unity8.

Description of the change

Moved indicator-client code into unityNext.
indicator-client uses .indicator files to source indicator model.

To post a comment you must log in.
Revision history for this message
Michał Sawicz (saviq) wrote :

Yeah, and the hit to our code coverage with this is bad :/ We need to improve that soon after this is merged.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Nick Dedekind (nick-dedekind) wrote :
Download full text (4.4 KiB)

    5652 + \qmltype MenuItemActionValue
    5653 + \inqmlmodule Indicators 0.1
    5654 + \brief Helper class to connect dbus action state with qml components property

    5656 + Exampiles:

    5672 +Item {

    It's "MenuItemAction" here, should be "MenuAction", even? And the \brief is copied from MenuItemActionValue, should say something different?

    Exampiles ← typo.

    Could it be a QtObject instead?

    =====

    5695 + // internal
    5696 + property QtObject __actionObject: null

    5707 + Item {
    5708 + id: priv
    5709 + property var actionObject: null
    5710 +
    5711 + Connections {

    Seems like priv.actionObject was supposed to replace __actionObject? Please complete that, and use "id: d" for the private object. There should be no need for the wrapping Item, either. Please use the Connections object as the private one.

    Now I see it's used in MenuItemActionValue, so I wonder if just exposing actionObject as public API of MenuItemAction wouldn't be cleaner...

Made a public property.

    =====

    5750 + \qmltype MenuItemActionValue

    Should this maybe be "MenuActionBinding"?

Renamed

    =====

    5783 + property string property: propertyBinding.property

    Couldn't this be an alias, too?

I has some issues with this. Apparently you dont get notifications for changes to binding properties, so I needed to make them root properties in order to update the connections. I've updated the target to be a property rather than an alias for the same reason.

    =====

    5795 + Item {
    5796 + id: priv
    5797 + property alias actionObject : dbusActionState.__actionObject
    5798 +
    5799 + property var currentTarget: undefined
    5800 + property string currentSignal
    5801 +
    5802 +
    5803 + Binding {

    Could be flattened to just Binding { }.

Removed the actionObject. The currentTarget/Signal is used to disconnect old property updates in connectViewChanges. Will be removed one we fix up the on%1Changed part.

    =====

    5821 + var signal = "on%1Changed".arg(property.charAt(0).toUpperCase() + property.slice(1));

    I wonder if this could be cleaner - I'd maybe even move this to C++ to mimic Binding { } more. Please add a TODO to re-evaluate at some point.

It's a bit of a mess. Added TODO

    =====

    5867 + id: __menuFactory

    5914 + id: __loader

    5980 + id: _progressMenu

    6047 + id: __backgroundItem

    6052 + id: __backgroundText

    6115 + id: __sectionMenu

    No need to prefix those with _.

    =====

    5995 + color: "#00000000"

    color: "transparent"

    =====

    6069 + anchors.rightMargin: __backgroundText.slidingMargin
    6070 + anchors.leftMargin: 0

    6079 + anchors.rightMargin: 0
    6080 + anchors.leftMargin: __backgroundText.slidingMargin

    These could just be static margins, no?

yep.

    =====

    6122 + anchors {
    6123 + left: parent ? parent.left : undefined
    6124 + right: parent ? parent.right : undefined
    6125 + }

    Didn't you say that no menu items have that? ;)

I may have said that :). removed.

    =====

    Do we have a use for SectionMenuItem yet?

It's used by the WifiSection. Shows the spinner while waiting f...

Read more...

Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

 6304 + id: _textMenu

 6334 + id: _showPassword

 Remove prefixes.

removed

 =====

 6307 + property alias password: _showPassword.visible

 I wonder if we should instead have a separate password entry MenuItem... Right now you couldn't use it as a password entry from the MenuItemFactory. OTOH not sure it's meant to be supported, either.

I've changed it to just an Item and moved it into Network/PasswordTextField, and wrapped in a parent MenuItem in the Password page.

 =====

 6309 + implicitHeight: password ? units.gu(10) : units.gu(7)

 Should probably use contentColumn.height?

Yep. +units.gu(1) on the menu border.

 =====

 6488 + }
 6489 + else {

 Single line please.

Done.

 =====

 6572 + qmlRegisterType<ApplicationPaths>(uri, 0, 1, "ApplicationPaths");

 This should probably be a singleton instead.

Yep. Done.

 =====

 Hmm something weird, po/is.po got added as a new file?

Icelandic? Dont know why it isnt in try but was added in mine.
Should i remove?

 =====

 7046 +# copy indicators file into build directory for shadow builds
 7047 +file(COPY ${INDICATOR_FILES}
 7048 + DESTINATION ${CMAKE_BINARY_DIR}/share/unity/indicators
 7049 +)

 Same as before - use a custom command to make sure new versions are copied.

Done.

 =====

 7932 + wait(1000)

 Could we get rid of that?

Removed.

 =====

 8131 + ${GOBJECT_LDFLAGS}
 8132 + ${QMENUMODEL_LDFLAGS}

 Shouldn't the test also pkg_check_modules for those, if it's requiring them?

Links not needed.
Removed and fixed up some other cmake deps.

 =====

 DONE!

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

Hey, I installed the packages from above, and I only get the date/time indicator content. Is that expected?

review: Needs Information
Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

> Hey, I installed the packages from above, and I only get the date/time
> indicator content. Is that expected?

Shouldn't do, but confirmed.
Was missing the install target for the Network indicators, causing the MenuFactory to fail to load.
Should be fixed now. Will confirm when jenkins pops arm build out.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

W dniu 03.07.2013 19:36, Nick Dedekind pisze:
> 5783 + property string property: propertyBinding.property
>
> Couldn't this be an alias, too?
>
> I has some issues with this. Apparently you dont get notifications for changes to binding properties, so I needed to make them root properties in order to update the connections. I've updated the target to be a property rather than an alias for the same reason.

Can you confirm that's the case and find / file a bug with Qt?

> 5795 + Item {
> 5796 + id: priv
> 5797 + property alias actionObject : dbusActionState.__actionObject
> 5798 +
> 5799 + property var currentTarget: undefined
> 5800 + property string currentSignal
> 5801 +
> 5802 +
> 5803 + Binding {
>
> Could be flattened to just Binding { }.
>
> Removed the actionObject. The currentTarget/Signal is used to disconnect old property updates in connectViewChanges. Will be removed one we fix up the on%1Changed part.

Yeah, but we can move the currentTarget/Signal props to the Binding, or
is it the same issue as above?

> Do we have a use for SectionMenuItem yet?
>
> It's used by the WifiSection. Shows the spinner while waiting for wifi access points.

Not sure I like the spinner there, let's revisit.

> 6191 + width: _sliderMenu.text ? units.gu(20) : _sliderMenu.width - units.gu(4)
>
> Is that desired? I.e. do we want only 20GU-wide slider in that case? Do we have a usecase?
>
> It's used by the volume menu in the sound indicator. Possibly should be using the width of text, but we don't have access to that.
> May have to speak with SDK. This control will may be replaced with the ubuntu-settings-components control.

Right, we could arguably add a ListItem.Slider to the SDK.

> 6307 + property alias password: _showPassword.visible
>
> I wonder if we should instead have a separate password entry MenuItem... Right now you couldn't use it as a password entry from the MenuItemFactory. OTOH not sure it's meant to be supported, either.
>
> I've changed it to just an Item and moved it into Network/PasswordTextField, and wrapped in a parent MenuItem in the Password page.

Cool, this whole thing with the custom Network page... We'll have to see
if we can make it more generic.

> Icelandic? Dont know why it isnt in try but was added in mine.
> Should i remove?

It might've resulted from the lp:unity/8.0lp:unity8 move. Yes, please
remove, Launchpad will take care of it.

--
Michał (Saviq) Sawicz <email address hidden>
Canonical Services Ltd.

Revision history for this message
Michał Sawicz (saviq) wrote :

Last functional issue: "Show password" logic is reversed.

review: Needs Fixing
Revision history for this message
Nicolas d'Offay (nicolas-doffay) wrote :

Tried for a while to break something in the indicators to no avail.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

The indicators_client AP tests failed with:

file:///usr/share/unity8/Panel/Indicators/client/IndicatorsList.qml:23 module "Unity.Indicators" is not installed

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

Two tests in the indicators_client AP suite failed with:

  File "/usr/lib/python2.7/dist-packages/indicators_client/tests/test_power.py", line 30, in setUp
    self.assertThat(page_loader.progress, Eventually(Equals(1.0)))
AttributeError: 'NoneType' object has no attribute 'progress'

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

1145 + libnm-glib-dev \
1146 + libnm-util-dev \
1147 + libqmenumodel-dev \

These shouldn't be here, mk-build-deps handles build deps.

review: Needs Fixing
Revision history for this message
Michał Sawicz (saviq) wrote :

qmenumodel-qml should be added to ./build, though, as we can't install runtime deps otherwise

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

I wonder if we should move indicators_client under the unity8 suite - even if they're not run with "autopilot run unity8", I think referencing them with "autopilot run unity8.indicators_client" would be better. What do you think?

review: Needs Information
Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

> I wonder if we should move indicators_client under the unity8 suite - even if
> they're not run with "autopilot run unity8", I think referencing them with
> "autopilot run unity8.indicators_client" would be better. What do you think?

While it would be cool to have them under the unity8 folder, mzanetti says no :) We want multiple suites, and putting indicators_client in the unity8 folder will import all the tests.
Perhaps we can move to unity8/shell & unity8/indicators_client

I've added split autopilot build targets. we now have:
autopilot - runs all tests
autopilot-unity8 - just the shell tests
autopilot-inidcators_client - just the indicators_client tests

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

We don't need the imports in the new __init__.py file, do we?

review: Needs Information
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

> We don't need the imports in the new __init__.py file, do we?

Apparently not.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

Fixed debian/control conflict

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) :
review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2013-07-10 17:13:28 +0000
+++ CMakeLists.txt 2013-07-11 14:53:26 +0000
@@ -91,7 +91,8 @@
9191
92# Autopilot tests92# Autopilot tests
93include(autopilot)93include(autopilot)
94declare_autopilot_test(unity8 ${CMAKE_SOURCE_DIR}/tests/autopilot/)94declare_autopilot_test(shell unity8.shell ${CMAKE_SOURCE_DIR}/tests/autopilot/)
95declare_autopilot_test(indicators_client unity8.indicators_client ${CMAKE_SOURCE_DIR}/tests/autopilot/)
9596
96set(SHELL_APP unity8)97set(SHELL_APP unity8)
9798
@@ -132,6 +133,7 @@
132# add subdirectories to build133# add subdirectories to build
133add_subdirectory(tests)134add_subdirectory(tests)
134add_subdirectory(plugins)135add_subdirectory(plugins)
136add_subdirectory(src)
135137
136# install subdirectories138# install subdirectories
137set(QML_DIRS139set(QML_DIRS
138140
=== modified file 'Panel/IndicatorItem.qml'
--- Panel/IndicatorItem.qml 2013-06-05 22:03:08 +0000
+++ Panel/IndicatorItem.qml 2013-07-11 14:53:26 +0000
@@ -16,55 +16,42 @@
1616
17import QtQuick 2.017import QtQuick 2.0
18import Ubuntu.Components 0.118import Ubuntu.Components 0.1
19import Unity.Indicators 0.1 as Indicators
1920
20Item {21Item {
21 id: indicatorItem22 id: indicatorItem
2223
23 property alias iconSource: itemImage.source24 property alias widgetSource: loader.source
24 property alias label: itemLabel.text
25 property bool highlighted: false25 property bool highlighted: false
26 property bool dimmed: false26 property bool dimmed: false
27 property var indicatorProperties: undefined
28
29 opacity: dimmed ? 0.4 : 1
2730
28 // only visible when non-empty31 // only visible when non-empty
29 visible: label != "" || iconSource != ""32 visible: loader.item != undefined && loader.status == Loader.Ready ? loader.item.enabled : false
30 width: itemRow.width + units.gu(1)33 width: visible ? loader.item.width : 0
34
35 Loader {
36 id: loader
37
38 onLoaded: {
39 item.height = Qt.binding(function() { return indicatorItem.height; });
40
41 for(var pName in indicatorProperties) {
42 if (item.hasOwnProperty(pName)) {
43 item[pName] = indicatorProperties[pName];
44 }
45 }
46 }
47 }
3148
32 Rectangle {49 Rectangle {
33 color: "#dd4814"50 color: "#dd4814"
51 objectName: "highlight"
34 height: units.dp(2)52 height: units.dp(2)
35 width: parent.width53 width: parent.width
36 anchors.top: parent.bottom54 anchors.top: parent.bottom
37 visible: highlighted55 visible: highlighted
38 }56 }
39
40 Row {
41 id: itemRow
42 objectName: "itemRow"
43 anchors {
44 top: parent.top
45 bottom: parent.bottom
46 horizontalCenter: parent.horizontalCenter
47 }
48 spacing: units.gu(0.5)
49 opacity: dimmed ? 0.4 : 1
50
51 Image {
52 id: itemImage
53 objectName: "itemImage"
54 visible: source != ""
55 height: units.gu(2.5)
56 width: units.gu(2.5)
57 anchors.verticalCenter: parent.verticalCenter
58 }
59
60 Label {
61 id: itemLabel
62 objectName: "itemLabel"
63 color: "#f3f3e7"
64 opacity: 0.8
65 font.family: "Ubuntu"
66 fontSize: "medium"
67 anchors.verticalCenter: parent.verticalCenter
68 }
69 }
70}57}
7158
=== modified file 'Panel/IndicatorRow.qml'
--- Panel/IndicatorRow.qml 2013-06-05 22:03:08 +0000
+++ Panel/IndicatorRow.qml 2013-07-11 14:53:26 +0000
@@ -21,7 +21,7 @@
21 id: indicatorRow21 id: indicatorRow
2222
23 property QtObject currentItem : null23 property QtObject currentItem : null
24 property int currentItemIndex: currentItem ? currentItem.ownIndex : -124 readonly property int currentItemIndex: currentItem ? currentItem.ownIndex : -1
25 property alias row: row25 property alias row: row
26 property QtObject indicatorsModel: null26 property QtObject indicatorsModel: null
27 property bool overviewActive: false // "state of the menu"27 property bool overviewActive: false // "state of the menu"
@@ -54,13 +54,15 @@
54 id: rowRepeater54 id: rowRepeater
55 objectName: "rowRepeater"55 objectName: "rowRepeater"
56 model: indicatorsModel ? indicatorsModel : undefined56 model: indicatorsModel ? indicatorsModel : undefined
57
57 IndicatorItem {58 IndicatorItem {
58 id: indicatorItem59 id: indicatorItem
5960
60 property int ownIndex: index61 property int ownIndex: index
6162
62 label: model.label63 widgetSource: model.widgetSource
63 iconSource: model.iconSource64
65 indicatorProperties : model.indicatorProperties
64 highlighted: indicatorRow.state == "reveal" || indicatorRow.state == "locked" || indicatorRow.state == "commit" ? ownIndex == indicatorRow.currentItemIndex : false66 highlighted: indicatorRow.state == "reveal" || indicatorRow.state == "locked" || indicatorRow.state == "commit" ? ownIndex == indicatorRow.currentItemIndex : false
65 dimmed: { //See FIXME in Indicators regarding the "states" change67 dimmed: { //See FIXME in Indicators regarding the "states" change
66 if (indicatorRow.state == "initial" || indicatorRow.state == "") {68 if (indicatorRow.state == "initial" || indicatorRow.state == "") {
6769
=== added directory 'Panel/Indicators'
=== modified file 'Panel/Indicators.qml'
--- Panel/Indicators.qml 2013-07-02 21:22:50 +0000
+++ Panel/Indicators.qml 2013-07-11 14:53:26 +0000
@@ -17,7 +17,6 @@
17import QtQuick 2.017import QtQuick 2.0
18import Ubuntu.Components 0.118import Ubuntu.Components 0.1
19import Ubuntu.Gestures 0.119import Ubuntu.Gestures 0.1
20import Ubuntu.ChewieUI 0.1 as ChewieUI
2120
22import "../Components"21import "../Components"
23import "../Components/ListItems"22import "../Components/ListItems"
@@ -70,8 +69,7 @@
70 // we dont want to switch to a indicator menu until we hit reveal state.69 // we dont want to switch to a indicator menu until we hit reveal state.
71 if (menuContent.overviewActive) {70 if (menuContent.overviewActive) {
72 menuContent.showOverview()71 menuContent.showOverview()
73 }72 } else {
74 else {
75 menuContent.showMenu()73 menuContent.showMenu()
76 }74 }
77 indicators.state = "locked"75 indicators.state = "locked"
@@ -272,9 +270,8 @@
272270
273 }271 }
274272
275 ChewieUI.PluginModel {273 IndicatorsDataModel {
276 id: indicatorsModel274 id: indicatorsModel
277 Component.onCompleted: load()
278 }275 }
279276
280 Connections {277 Connections {
@@ -294,8 +291,7 @@
294 if (showAnimation.running) {291 if (showAnimation.running) {
295 if (indicators.state == "initial") {292 if (indicators.state == "initial") {
296 openOverview()293 openOverview()
297 }294 } else {
298 else {
299 indicators.calculateCurrentItem(dragHandle.touchX, false)295 indicators.calculateCurrentItem(dragHandle.touchX, false)
300 menuContent.showMenu()296 menuContent.showMenu()
301 }297 }
302298
=== added file 'Panel/Indicators/DatetimeIndicatorPage.qml'
--- Panel/Indicators/DatetimeIndicatorPage.qml 1970-01-01 00:00:00 +0000
+++ Panel/Indicators/DatetimeIndicatorPage.qml 2013-07-11 14:53:26 +0000
@@ -0,0 +1,97 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
18 * Ubo Riboni <ugo.riboni@canonical.com>
19 */
20
21import QtQuick 2.0
22import Ubuntu.Components 0.1
23
24Flickable {
25 id: page
26
27 contentHeight: image.height
28
29 Image {
30 id: image
31 anchors {
32 left: parent.left
33 right: parent.right
34 }
35 source: "../graphics/time_and_date@18.png"
36 fillMode: Image.PreserveAspectFit
37 }
38
39 Item {
40 anchors {
41 top: parent.top
42 topMargin: units.gu(5)
43 left: parent.left
44 right: parent.right
45 }
46
47 height: units.gu(30)
48
49 Label {
50 id: timeLabel
51 anchors {
52 horizontalCenter: parent.horizontalCenter
53 verticalCenter: parent.verticalCenter
54 }
55
56 text: ""
57 color: "#f3f3e7"
58 font.weight: Font.Light
59 font.pixelSize: units.gu(6)
60 }
61
62 Label {
63 id: dateLabel
64
65 anchors {
66 left: parent.left
67 leftMargin: units.gu(2)
68 bottom: parent.bottom
69 bottomMargin: units.gu(1.5)
70 }
71 text: ""
72 color: "#f3f3e7"
73 fontSize: "small"
74 }
75 }
76
77 Timer {
78 interval: 1000 * 10 // 10 seconds
79 running: true
80 repeat: true
81 triggeredOnStart: true
82 onTriggered: updateTime();
83 }
84
85 function updateTime() {
86 var dt = new Date();
87 var time = Qt.formatTime(dt);
88 var space = time.indexOf(" ");
89 timeLabel.text = time.substr(0, space > 0 ? space : 5);
90 dateLabel.text = Qt.formatDateTime(dt, "dddd,\ndd MMMM");
91 }
92
93 // Make it compatible with the PluginItem interface
94 function start() {}
95 function stop() {}
96 function reset() {}
97}
098
=== added file 'Panel/Indicators/DatetimeIndicatorWidget.qml'
--- Panel/Indicators/DatetimeIndicatorWidget.qml 1970-01-01 00:00:00 +0000
+++ Panel/Indicators/DatetimeIndicatorWidget.qml 2013-07-11 14:53:26 +0000
@@ -0,0 +1,65 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Nick Dedekind <nick.dedekind@canonical.com>
18 */
19
20import QtQuick 2.0
21import Ubuntu.Components 0.1
22import Unity.Indicators 0.1 as Indicators
23
24Indicators.IndicatorWidget {
25 id: indicatorWidget
26
27 width: timeLabel.width + units.gu(1)
28
29 property alias label: timeLabel.text
30
31 Label {
32 id: timeLabel
33 objectName: "timeLabel"
34 color: "#f3f3e7"
35 opacity: 0.8
36 font.family: "Ubuntu"
37 fontSize: "medium"
38 anchors.centerIn: parent
39 text: Qt.formatTime(timer.dateNow)
40 }
41
42 Timer {
43 id: timer
44 interval: 1000 * 10
45 running: indicatorWidget.visible
46 repeat: true
47 triggeredOnStart: true
48 property date dateNow
49
50 onTriggered: dateNow = new Date
51 }
52
53 onActionStateChanged: {
54 if (action == undefined || !action.valid) {
55 return;
56 }
57
58 if (action.state == undefined) {
59 visible = false;
60 return;
61 }
62
63 indicatorWidget.visible = action.state[3];
64 }
65}
066
=== added file 'Panel/Indicators/DefaultIndicatorPage.qml'
--- Panel/Indicators/DefaultIndicatorPage.qml 1970-01-01 00:00:00 +0000
+++ Panel/Indicators/DefaultIndicatorPage.qml 2013-07-11 14:53:26 +0000
@@ -0,0 +1,25 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Nick Dedekind <nick.dedekind@canonical.com>
18 */
19
20import QtQuick 2.0
21import Unity.Indicators 0.1 as Indicators
22
23Indicators.IndicatorPage {
24 anchors.fill: parent
25}
026
=== added file 'Panel/Indicators/DefaultIndicatorWidget.qml'
--- Panel/Indicators/DefaultIndicatorWidget.qml 1970-01-01 00:00:00 +0000
+++ Panel/Indicators/DefaultIndicatorWidget.qml 2013-07-11 14:53:26 +0000
@@ -0,0 +1,80 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Nick Dedekind <nick.dedekind@canonical.com>
18 */
19
20import QtQuick 2.0
21import Ubuntu.Components 0.1
22import Unity.Indicators 0.1 as Indicators
23
24Indicators.IndicatorWidget {
25 id: indicatorWidget
26
27 width: itemRow.width + units.gu(1)
28
29 property alias label: itemLabel.text
30 property alias iconSource: itemImage.source
31
32 Row {
33 id: itemRow
34 objectName: "itemRow"
35 anchors {
36 top: parent.top
37 bottom: parent.bottom
38 horizontalCenter: parent.horizontalCenter
39 }
40 spacing: units.gu(0.5)
41
42 // FIXME : Should us Ubuntu.Icon . results in low res images
43 Image {
44 id: itemImage
45 objectName: "itemImage"
46 visible: source != ""
47 height: indicatorWidget.iconSize
48 width: indicatorWidget.iconSize
49 anchors.verticalCenter: parent.verticalCenter
50 }
51
52 Label {
53 id: itemLabel
54 objectName: "itemLabel"
55 color: "#f3f3e7"
56 opacity: 0.8
57 font.family: "Ubuntu"
58 fontSize: "medium"
59 anchors.verticalCenter: parent.verticalCenter
60 visible: text != ""
61 }
62 }
63
64 onActionStateChanged: {
65 if (action == undefined || !action.valid) {
66 return;
67 }
68
69 if (action.state == undefined) {
70 label = "";
71 iconSource = "";
72 enabled = false;
73 return;
74 }
75
76 label = action.state[Indicators.ActionState.Label];
77 iconSource = "image://gicon/" + action.state[Indicators.ActionState.IconSource];
78 enabled = action.state[Indicators.ActionState.Visible];
79 }
80}
081
=== added file 'Panel/Indicators/MessagingIndicatorPage.qml'
--- Panel/Indicators/MessagingIndicatorPage.qml 1970-01-01 00:00:00 +0000
+++ Panel/Indicators/MessagingIndicatorPage.qml 2013-07-11 14:53:26 +0000
@@ -0,0 +1,35 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Nick Dedekind <nick.dedekind@canonical.com>
18 */
19
20import QtQuick 2.0
21import Ubuntu.Components 0.1
22import Unity.Indicators 0.1 as Indicators
23
24Indicators.IndicatorPage {
25 anchors.fill: parent
26
27 highlightFollowsCurrentItem: false
28 emptyText: "You have no more outstanding messages."
29
30 function stop() {
31 // never stops the service
32 // this will keep all objects in memory, consume more memory
33 // but will optimize the menu contruction on the screen
34 }
35}
036
=== added file 'Panel/Indicators/MessagingIndicatorWidget.qml'
--- Panel/Indicators/MessagingIndicatorWidget.qml 1970-01-01 00:00:00 +0000
+++ Panel/Indicators/MessagingIndicatorWidget.qml 2013-07-11 14:53:26 +0000
@@ -0,0 +1,25 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Nick Dedekind <nick.dedekind@canonical.com>
18 */
19
20import QtQuick 2.0
21
22DefaultIndicatorWidget {
23 // default the icon so we have something to show when we don't have the bus.
24 iconSource: "image://gicon/indicator-messages"
25}
026
=== added file 'Panel/Indicators/NetworkIndicatorPage.qml'
--- Panel/Indicators/NetworkIndicatorPage.qml 1970-01-01 00:00:00 +0000
+++ Panel/Indicators/NetworkIndicatorPage.qml 2013-07-11 14:53:26 +0000
@@ -0,0 +1,80 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
18 */
19
20import QtQuick 2.0
21import Unity.Indicators 0.1 as Indicators
22import Unity.Indicators.Network 0.1 as ICNetwork
23import Ubuntu.Components 0.1
24
25PageStack {
26 id: _network
27
28 property alias title: _mainPage.title
29 property alias emptyText: _pluginItem.emptyText
30 property alias busType: _pluginItem.busType
31 property alias busName: _pluginItem.busName
32 property alias actionsObjectPath : _pluginItem.actionsObjectPath
33 property alias menuObjectPaths : _pluginItem.menuObjectPaths
34
35 __showHeader: false
36 anchors.fill: parent
37
38 Page {
39 id: _mainPage
40
41 Indicators.IndicatorPage {
42 id: _pluginItem
43 anchors.fill: parent
44 }
45 }
46
47 Component {
48 id: passwordPageComponent
49
50 ICNetwork.PasswordPage {
51 agent: networkAgent
52 token: token
53 }
54 }
55
56 ICNetwork.NetworkAgent {
57 id: networkAgent
58
59 onSecretRequested: {
60 _network.push(passwordPageComponent);
61 }
62 }
63
64 function start()
65 {
66 push(_mainPage);
67 _pluginItem.start();
68 }
69
70 function stop()
71 {
72 clear();
73 _pluginItem.stop();
74 }
75
76 function reset()
77 {
78 _pluginItem.reset();
79 }
80}
081
=== added file 'Panel/Indicators/NetworkIndicatorWidget.qml'
--- Panel/Indicators/NetworkIndicatorWidget.qml 1970-01-01 00:00:00 +0000
+++ Panel/Indicators/NetworkIndicatorWidget.qml 2013-07-11 14:53:26 +0000
@@ -0,0 +1,109 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Nick Dedekind <nick.dedekind@canonical.com>
18 */
19
20import QtQuick 2.0
21import Ubuntu.Components 0.1
22import Unity.Indicators 0.1 as Indicators
23
24Indicators.IndicatorWidget {
25 id: indicatorWidget
26
27 width: networkIcon.width + units.gu(1)
28
29 property int signalStrength: 0
30 property int connectionState: Indicators.NetworkConnection.Initial
31 rootMenuType: "com.canonical.indicator.root.network"
32
33 // FIXME : Should us Ubuntu.Icon . results in low res images
34 Image {
35 id: networkIcon
36 objectName: "itemImage"
37 source: get_icon_for_signal(connectionState, signalStrength)
38 visible: source != ""
39 height: indicatorWidget.iconSize
40 width: indicatorWidget.iconSize
41 anchors.centerIn: parent
42 }
43
44 onActionStateChanged: {
45 if (action == undefined || !action.valid) {
46 return;
47 }
48
49 if (action.state == undefined) {
50 connectionState = 0;
51 return;
52 }
53
54 connectionState = action.state[Indicators.NetworkActionState.Connection];
55 if (connectionState == Indicators.NetworkConnection.Activated) {
56 signalStrength = action.state[Indicators.NetworkActionState.SignalStrength];
57 }
58 }
59
60 NumberAnimation {
61 id: activation_animation
62 target: indicatorWidget
63 property: "signalStrength"
64 from: 0
65 to: 100
66 duration: 2500 // 5 states in 2.5 seconds
67 loops: Animation.Infinite
68 }
69
70 states: [
71 State {
72 name: "unknown"
73 when: connectionState < Indicators.NetworkConnection.Activating || connectionState > Indicators.NetworkConnection.Deactivating
74 PropertyChanges { target: activation_animation; running: false }
75 },
76 State {
77 name: "activating"
78 when: connectionState == Indicators.NetworkConnection.Activating
79 PropertyChanges { target: activation_animation; running: true }
80 },
81 State {
82 name: "activated"
83 when: connectionState == Indicators.NetworkConnection.Activated
84 PropertyChanges { target: activation_animation; running: false }
85 },
86 State {
87 name: "deactivating"
88 when: connectionState == Indicators.NetworkConnection.Deactivating
89 PropertyChanges { target: activation_animation; running: true }
90 }
91 ]
92
93
94 function get_icon_for_signal(con_state, value) {
95 if (con_state >= Indicators.NetworkConnection.Activating && con_state <= Indicators.NetworkConnection.Deactivating) {
96 if (value == 0) {
97 return "image://gicon/nm-signal-00";
98 } else if (value <= 25) {
99 return "image://gicon/nm-signal-25";
100 } else if (value <= 50) {
101 return "image://gicon/nm-signal-50";
102 } else if (value <= 75) {
103 return "image://gicon/nm-signal-75";
104 }
105 return "image://gicon/nm-signal-100";
106 }
107 return "image://gicon/wifi-none";
108 }
109}
0110
=== added file 'Panel/Indicators/SoundIndicatorWidget.qml'
--- Panel/Indicators/SoundIndicatorWidget.qml 1970-01-01 00:00:00 +0000
+++ Panel/Indicators/SoundIndicatorWidget.qml 2013-07-11 14:53:26 +0000
@@ -0,0 +1,25 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Nick Dedekind <nick.dedekind@canonical.com>
18 */
19
20import QtQuick 2.0
21
22DefaultIndicatorWidget {
23 // default the icon so we have something to show when we don't have the bus.
24 iconSource: "image://gicon/audio-volume-high"
25}
026
=== added directory 'Panel/Indicators/client'
=== added file 'Panel/Indicators/client/IndicatorsClient.qml'
--- Panel/Indicators/client/IndicatorsClient.qml 1970-01-01 00:00:00 +0000
+++ Panel/Indicators/client/IndicatorsClient.qml 2013-07-11 14:53:26 +0000
@@ -0,0 +1,42 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
18 */
19
20import QtQuick 2.0
21import Ubuntu.Components 0.1
22import Ubuntu.Components.ListItems 0.1 as ListItem
23
24Rectangle {
25 color: "black"
26 id: root
27
28 PageStack {
29 id: pages
30
31 anchors.fill: parent
32 Component.onCompleted: root.reset()
33 }
34
35 function reset() {
36 pages.clear();
37 var component = Qt.createComponent("IndicatorsList.qml");
38 var page = component.createObject(pages);
39 console.log(component.errorString());
40 pages.push(page);
41 }
42}
043
=== added file 'Panel/Indicators/client/IndicatorsList.qml'
--- Panel/Indicators/client/IndicatorsList.qml 1970-01-01 00:00:00 +0000
+++ Panel/Indicators/client/IndicatorsList.qml 2013-07-11 14:53:26 +0000
@@ -0,0 +1,62 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
18 */
19
20import QtQuick 2.0
21import Ubuntu.Components 0.1
22import Ubuntu.Components.ListItems 0.1 as ListItem
23import Unity.Indicators 0.1 as Indicators
24import "../.."
25
26Page {
27 id: page
28 anchors.fill: parent
29 title: "Plugin list"
30
31 IndicatorsDataModel {
32 id: indicatorsModel
33 }
34
35 ListView {
36 id: mainMenu
37 objectName: "mainMenu"
38 anchors.fill: parent
39 model: indicatorsModel
40
41 delegate: Indicators.MenuItem {
42 anchors.left: parent.left
43 anchors.right: parent.right
44 progression: isValid
45 objectName: identifier
46
47 Label {
48 anchors.left: parent.left
49 anchors.leftMargin: units.gu(0.5)
50 anchors.verticalCenter: parent.verticalCenter
51 text: title
52 }
53
54 onClicked: {
55 if (progression) {
56 var new_page = Qt.createComponent("IndicatorsPage.qml");
57 page.pageStack.push(new_page.createObject(pages), {"indicatorProperties" : model.indicatorProperties, "pageSource" : model.pageSource});
58 }
59 }
60 }
61 }
62}
063
=== added file 'Panel/Indicators/client/IndicatorsPage.qml'
--- Panel/Indicators/client/IndicatorsPage.qml 1970-01-01 00:00:00 +0000
+++ Panel/Indicators/client/IndicatorsPage.qml 2013-07-11 14:53:26 +0000
@@ -0,0 +1,49 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
18 */
19
20import QtQuick 2.0
21import Ubuntu.Components 0.1
22
23Page {
24 id: _page
25
26 title: indicatorProperties && indicatorProperties.title ? indicatorProperties.title : ""
27 property variant indicatorProperties
28 property alias pageSource : page_loader.source
29
30 anchors.fill: parent
31
32 Loader {
33 id: page_loader
34 objectName: "page_loader"
35
36 anchors.fill: parent
37
38 onStatusChanged: {
39 if (status == Loader.Ready) {
40 for(var pName in indicatorProperties) {
41 if (item.hasOwnProperty(pName)) {
42 item[pName] = indicatorProperties[pName];
43 }
44 }
45 item.start();
46 }
47 }
48 }
49}
050
=== added file 'Panel/IndicatorsDataModel.qml'
--- Panel/IndicatorsDataModel.qml 1970-01-01 00:00:00 +0000
+++ Panel/IndicatorsDataModel.qml 2013-07-11 14:53:26 +0000
@@ -0,0 +1,66 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
18 */
19
20import QtQuick 2.0
21import Unity.Indicators 0.1 as Indicators
22import Utils 0.1
23
24Indicators.IndicatorsModel {
25 id: ic_model
26
27 Component.onCompleted: load()
28
29 indicatorData : {
30 'indicator-messaging' : {
31 'title': 'Messaging',
32 'description' : '',
33 'priority': 10,
34 'widgetSource' : ApplicationPaths.shellAppDirectory()+'/Panel/Indicators/MessagingIndicatorWidget.qml',
35 'pageSource' : ApplicationPaths.shellAppDirectory()+'/Panel/Indicators/MessagingIndicatorPage.qml'
36 },
37 'indicator-sound' : {
38 'title': 'Sound',
39 'description' : '',
40 'priority': 20,
41 'widgetSource' : ApplicationPaths.shellAppDirectory()+'/Panel/Indicators/SoundIndicatorWidget.qml',
42 'pageSource' : ApplicationPaths.shellAppDirectory()+'/Panel/Indicators/DefaultIndicatorPage.qml'
43 },
44 'indicator-network' : {
45 'title': 'Networks',
46 'description' : '',
47 'priority': 30,
48 'widgetSource' : ApplicationPaths.shellAppDirectory()+'/Panel/Indicators/NetworkIndicatorWidget.qml',
49 'pageSource' : ApplicationPaths.shellAppDirectory()+'/Panel/Indicators/NetworkIndicatorPage.qml'
50 },
51 'indicator-battery' : {
52 'title': 'Battery',
53 'description' : '',
54 'priority': 40,
55 'widgetSource' : ApplicationPaths.shellAppDirectory()+'/Panel/Indicators/DefaultIndicatorWidget.qml',
56 'pageSource' : ApplicationPaths.shellAppDirectory()+'/Panel/Indicators/DefaultIndicatorPage.qml'
57 },
58 'indicator-time' : {
59 'title': 'Date and Time',
60 'description' : '',
61 'priority': 100,
62 'widgetSource' : ApplicationPaths.shellAppDirectory()+'/Panel/Indicators/DatetimeIndicatorWidget.qml',
63 'pageSource' : ApplicationPaths.shellAppDirectory()+'/Panel/Indicators/DatetimeIndicatorPage.qml'
64 }
65 }
66}
067
=== modified file 'Panel/MenuContent.qml'
--- Panel/MenuContent.qml 2013-07-02 20:33:09 +0000
+++ Panel/MenuContent.qml 2013-07-11 14:53:26 +0000
@@ -16,6 +16,7 @@
1616
17import QtQuick 2.017import QtQuick 2.0
18import Ubuntu.Components 0.118import Ubuntu.Components 0.1
19import Unity.Indicators 0.1 as Indicators
19import "Menus"20import "Menus"
20import "../Components"21import "../Components"
2122
@@ -29,7 +30,7 @@
29 property bool __contentActive: false30 property bool __contentActive: false
30 property alias currentIndex : menus.currentIndex31 property alias currentIndex : menus.currentIndex
31 property color backgroundColor: "#221e1c"32 property color backgroundColor: "#221e1c"
32 property int contentReleaseInterval: 500033 property int contentReleaseInterval: 20000
3334
34 width: units.gu(40)35 width: units.gu(40)
35 height: units.gu(42)36 height: units.gu(42)
@@ -94,7 +95,7 @@
9495
95 width: menus.width96 width: menus.width
96 height: menus.height97 height: menus.height
97 sourceComponent: component98 source: pageSource
98 visible: content.__shown99 visible: content.__shown
99 onVisibleChanged: {100 onVisibleChanged: {
100 // Reset the indicator states101 // Reset the indicator states
@@ -104,25 +105,15 @@
104 }105 }
105 asynchronous: true106 asynchronous: true
106107
107 onStatusChanged: {108 onLoaded: {
108 if (status == Loader.Ready) {109 for(var pName in indicatorProperties) {
109 if (indicatorsModel.widgetsMap && item.hasOwnProperty("widgetsMap")) {110 if (item.hasOwnProperty(pName)) {
110 item["widgetsMap"] = indicatorsModel.widgetsMap111 item[pName] = indicatorProperties[pName]
111 }112 }
112 for(var pName in initialProperties) {113 }
113 if (item.hasOwnProperty(pName)) {114 if (contentActive && menus.visible) {
114 item[pName] = initialProperties[pName]115 item.start()
115 }116 }
116 }
117 if (contentActive && menus.visible) {
118 item.start()
119 }
120 }
121 }
122
123 // FIXME: QTBUG-30632 - asynchronous loader crashes when changing index quickly.
124 Component.onDestruction: {
125 active = false;
126 }117 }
127118
128 // Need to use a binding because the handle height changes.119 // Need to use a binding because the handle height changes.
@@ -189,7 +180,13 @@
189 left: parent.left180 left: parent.left
190 right: parent.right181 right: parent.right
191 }182 }
192 text: content.overviewActive ? i18n.tr("Device") : (indicatorsModel && menus.currentIndex >= 0 && menus.currentIndex < indicatorsModel.count) ? indicatorsModel.get(menus.currentIndex).title : ""183 text: {
184 if (content.overviewActive)
185 return i18n.tr("Device");
186 if (indicatorsModel && menus.currentIndex >= 0 && menus.currentIndex < indicatorsModel.count)
187 return indicatorsModel.data(menus.currentIndex, Indicators.IndicatorsModelRole.Title);
188 return "";
189 }
193 opacity: __shown ? 1 : 0190 opacity: __shown ? 1 : 0
194 Behavior on opacity {NumberAnimation{duration: 100}}191 Behavior on opacity {NumberAnimation{duration: 100}}
195 }192 }
196193
=== modified file 'Panel/Menus/Overview/OverviewGrid.qml'
--- Panel/Menus/Overview/OverviewGrid.qml 2013-06-05 22:03:08 +0000
+++ Panel/Menus/Overview/OverviewGrid.qml 2013-07-11 14:53:26 +0000
@@ -59,31 +59,22 @@
59 objectName: "overviewGridButton" + index59 objectName: "overviewGridButton" + index
60 width: grid.cellWidth60 width: grid.cellWidth
61 height: grid.cellHeight61 height: grid.cellHeight
62 Image {62
63 id: imageIcon63 Loader {
64 objectName: "overviewGridButtonImage"64 id: loader
65 source: iconSource65 source: widgetSource
66 width: units.gu(4)66
67 height: units.gu(4)67 width: units.gu(5)
68 anchors {68 height: units.gu(5)
69 centerIn: parent69 anchors.centerIn: parent
70 verticalCenterOffset: -units.gu(1)70 anchors.verticalCenterOffset: -units.gu(1)
71 }71
72 sourceSize.width: width72 onLoaded: {
73 sourceSize.height: height73 for(var pName in indicatorProperties) {
74 visible: labelIcon.text === ""74 if (item.hasOwnProperty(pName)) {
75 }75 item[pName] = indicatorProperties[pName]
7676 }
77 Label {77 }
78 id: labelIcon
79 text: label
80 color: "#f3f3e7"
81 opacity: 0.8
82 font.family: "Ubuntu"
83 fontSize: "large"
84 anchors {
85 centerIn: parent
86 verticalCenterOffset: -units.gu(1)
87 }78 }
88 }79 }
8980
9081
=== added file 'Panel/graphics/time_and_date@18.png'
91Binary files Panel/graphics/time_and_date@18.png 1970-01-01 00:00:00 +0000 and Panel/graphics/time_and_date@18.png 2013-07-11 14:53:26 +0000 differ82Binary files Panel/graphics/time_and_date@18.png 1970-01-01 00:00:00 +0000 and Panel/graphics/time_and_date@18.png 2013-07-11 14:53:26 +0000 differ
=== modified file 'build'
--- build 2013-07-03 10:33:48 +0000
+++ build 2013-07-11 14:53:26 +0000
@@ -43,10 +43,9 @@
43 echo "Installing Unity 8 dependencies.."43 echo "Installing Unity 8 dependencies.."
44 sudo apt-get install devscripts \44 sudo apt-get install devscripts \
45 equivs \45 equivs \
46 qmenumodel-qml \
46 qtdeclarative5-ubuntu-ui-toolkit-plugin \47 qtdeclarative5-ubuntu-ui-toolkit-plugin \
47 qtdeclarative5-dee-plugin \48 qtdeclarative5-dee-plugin \
48 indicators-client \
49 indicators-client-plugin-* \
50 ubuntu-mobile-icons \49 ubuntu-mobile-icons \
51 unity-notifications-impl-1 \50 unity-notifications-impl-1 \
52 unity-scope-home \51 unity-scope-home \
5352
=== modified file 'cmake/modules/autopilot.cmake'
--- cmake/modules/autopilot.cmake 2013-06-05 22:03:08 +0000
+++ cmake/modules/autopilot.cmake 2013-07-11 14:53:26 +0000
@@ -1,7 +1,10 @@
1add_custom_target(autopilot)1add_custom_target(autopilot)
22
3function(declare_autopilot_test TEST_NAME WORKING_DIR)3function(declare_autopilot_test TEST_NAME TEST_SUITE WORKING_DIR)
4 add_custom_command(TARGET autopilot4 add_custom_target(autopilot-${TEST_NAME}
5 COMMAND autopilot run ${TEST_NAME}5 COMMAND autopilot run ${TEST_SUITE}
6 WORKING_DIRECTORY ${WORKING_DIR})6 WORKING_DIRECTORY ${WORKING_DIR}
7 )
8
9 add_dependencies(autopilot autopilot-${TEST_NAME})
7endfunction()10endfunction()
811
=== modified file 'debian/control'
--- debian/control 2013-07-11 13:49:23 +0000
+++ debian/control 2013-07-11 14:53:26 +0000
@@ -10,7 +10,10 @@
10 libgles2-mesa-dev[armhf],10 libgles2-mesa-dev[armhf],
11 libhud-client2-dev,11 libhud-client2-dev,
12 libjson-perl,12 libjson-perl,
13 libnm-glib-dev,
14 libnm-util-dev,
13 libpulse-dev,15 libpulse-dev,
16 libqmenumodel-dev,
14 libqt5v8-5-private-dev,17 libqt5v8-5-private-dev,
15 libunity-api-dev (>= 7.80.3),18 libunity-api-dev (>= 7.80.3),
16 libunity-core-6.0-dev (<< 7.80),19 libunity-core-6.0-dev (<< 7.80),
@@ -41,9 +44,19 @@
41Vcs-Bzr: https://code.launchpad.net/unity844Vcs-Bzr: https://code.launchpad.net/unity8
42Vcs-Browser: https://bazaar.launchpad.net/~unity-team/unity8/trunk45Vcs-Browser: https://bazaar.launchpad.net/~unity-team/unity8/trunk
4346
47Package: indicators-client
48Architecture: amd64 armhf i386
49Depends: qmenumodel-qml,
50 qtdeclarative5-ubuntu-ui-toolkit-plugin | qt-components-ubuntu,
51 unity8 (= ${binary:Version}),
52 ${misc:Depends},
53 ${shlibs:Depends},
54Description: Indicators client test application
55 This package contains the client application for indicators used by autopilot
56
44Package: unity857Package: unity8
45Architecture: any58Architecture: any
46Depends: indicators-client (>= 0.6.1),59Depends: qmenumodel-qml,
47 qtdeclarative5-dee-plugin,60 qtdeclarative5-dee-plugin,
48 qtdeclarative5-ubuntu-ui-toolkit-plugin,61 qtdeclarative5-ubuntu-ui-toolkit-plugin,
49 qtdeclarative5-unity-notifications-plugin | unity-notifications-impl,62 qtdeclarative5-unity-notifications-plugin | unity-notifications-impl,
@@ -55,18 +68,19 @@
55 unity8-private | unity-launcher-impl,68 unity8-private | unity-launcher-impl,
56 ${misc:Depends},69 ${misc:Depends},
57 ${shlibs:Depends},70 ${shlibs:Depends},
58Recommends: indicators-client-plugin-datetime (>= 0.6.1),71Recommends: indicator-battery,
59 indicators-client-plugin-messaging (>= 0.6.1),72 indicator-messages,
60 indicators-client-plugin-network (>= 0.6.1),73 indicator-network,
61 indicators-client-plugin-power (>= 0.6.1),74 indicator-sound,
62 indicators-client-plugin-sound (>= 0.6.1),75 indicator-time,
63 ${unity-default-masterscopes},76 ${unity-default-masterscopes},
64Description: Unity 8 shell77Description: Unity 8 shell
65 The Unity 8 shell is the primary user interface for Ubuntu devices.78 The Unity 8 shell is the primary user interface for Ubuntu devices.
6679
67Package: unity8-autopilot80Package: unity8-autopilot
68Architecture: all81Architecture: all
69Depends: libautopilot-qt,82Depends: indicators-client (>= ${source:Version}),
83 libautopilot-qt,
70 libqt5test5,84 libqt5test5,
71 libqt5widgets5,85 libqt5widgets5,
72 python-evdev,86 python-evdev,
7387
=== added file 'debian/indicators-client.install'
--- debian/indicators-client.install 1970-01-01 00:00:00 +0000
+++ debian/indicators-client.install 2013-07-11 14:53:26 +0000
@@ -0,0 +1,1 @@
1/usr/bin/indicators-client
02
=== modified file 'debian/unity8.install'
--- debian/unity8.install 2013-07-02 14:44:34 +0000
+++ debian/unity8.install 2013-07-11 14:53:26 +0000
@@ -13,3 +13,4 @@
13usr/share/unity8/Shell.qml13usr/share/unity8/Shell.qml
14usr/share/unity8/SideStage14usr/share/unity8/SideStage
15usr/share/unity8/graphics15usr/share/unity8/graphics
16usr/share/unity8/unity/indicators/*
1617
=== modified file 'main.cpp'
--- main.cpp 2013-07-03 09:23:56 +0000
+++ main.cpp 2013-07-11 14:53:26 +0000
@@ -22,6 +22,7 @@
22#include <QtGui/QIcon>22#include <QtGui/QIcon>
23#include <QtGui/QGuiApplication>23#include <QtGui/QGuiApplication>
24#include <QtQml/QQmlEngine>24#include <QtQml/QQmlEngine>
25#include <QtQml/QQmlContext>
25#include <qpa/qplatformnativeinterface.h>26#include <qpa/qplatformnativeinterface.h>
26#include <QLibrary>27#include <QLibrary>
27#include <libintl.h>28#include <libintl.h>
@@ -131,8 +132,6 @@
131 nativeInterface->setProperty("ubuntuSessionType", 1);132 nativeInterface->setProperty("ubuntuSessionType", 1);
132 view->setProperty("role", 2); // INDICATOR_ACTOR_ROLE133 view->setProperty("role", 2); // INDICATOR_ACTOR_ROLE
133134
134 QObject::connect(view->engine(), SIGNAL(quit()), qApp, SLOT(quit()));
135
136 QUrl source("Shell.qml");135 QUrl source("Shell.qml");
137 prependImportPaths(view->engine(), ::overrideImportPaths());136 prependImportPaths(view->engine(), ::overrideImportPaths());
138 appendImportPaths(view->engine(), ::fallbackImportPaths());137 appendImportPaths(view->engine(), ::fallbackImportPaths());
139138
=== modified file 'paths.h.in'
--- paths.h.in 2013-06-28 13:14:29 +0000
+++ paths.h.in 2013-07-11 14:53:26 +0000
@@ -23,6 +23,7 @@
23// Qt23// Qt
24#include <QtCore/QCoreApplication>24#include <QtCore/QCoreApplication>
25#include <QtCore/QDir>25#include <QtCore/QDir>
26#include <QStandardPaths>
2627
27inline bool isRunningInstalled() {28inline bool isRunningInstalled() {
28 static bool installed = (QCoreApplication::applicationDirPath() ==29 static bool installed = (QCoreApplication::applicationDirPath() ==
@@ -65,6 +66,20 @@
65 return paths;66 return paths;
66}67}
6768
69inline QStringList shellDataDirs() {
70 QStringList dirs = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation);
71 if (!isRunningInstalled()) {
72 if (getenv("UNITY_TEST_ENV")==NULL) {
73 dirs.prepend("@CMAKE_BINARY_DIR@/share");
74 }
75 }
76 else {
77 // append so by default we use xdg files.
78 dirs.append(shellAppDirectory());
79 }
80 return dirs;
81}
82
68inline QString sourceDirectory() {83inline QString sourceDirectory() {
69 return QString("@CMAKE_SOURCE_DIR@/");84 return QString("@CMAKE_SOURCE_DIR@/");
70}85}
7186
=== modified file 'plugins/Unity/CMakeLists.txt'
--- plugins/Unity/CMakeLists.txt 2013-07-11 08:19:10 +0000
+++ plugins/Unity/CMakeLists.txt 2013-07-11 14:53:26 +0000
@@ -1,6 +1,8 @@
1# export_qmlplugin macro1# export_qmlplugin macro
2include(Plugins)2include(Plugins)
33
4add_subdirectory(Indicators)
5
4# Dependencies6# Dependencies
5include(FindPkgConfig)7include(FindPkgConfig)
6pkg_check_modules(QTDEE REQUIRED libdee-qt5)8pkg_check_modules(QTDEE REQUIRED libdee-qt5)
79
=== added directory 'plugins/Unity/Indicators'
=== added file 'plugins/Unity/Indicators/CMakeLists.txt'
--- plugins/Unity/Indicators/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ plugins/Unity/Indicators/CMakeLists.txt 2013-07-11 14:53:26 +0000
@@ -0,0 +1,52 @@
1project(IndicatorsQml)
2
3pkg_check_modules(QMENUMODEL REQUIRED qmenumodel)
4find_package(Qt5Core REQUIRED)
5find_package(Qt5Quick REQUIRED)
6
7add_subdirectory(qml)
8add_subdirectory(Messaging)
9add_subdirectory(Network)
10
11include_directories(
12 ${CMAKE_CURRENT_SOURCE_DIR}
13 ${CMAKE_CURRENT_BINARY_DIR}
14 ${QMENUMODEL_INCLUDE_DIRS}
15)
16
17set(IndicatorsQML_SOURCES
18 flatmenuproxymodel.cpp
19 indicator.cpp
20 indicators.h
21 indicatorsmanager.cpp
22 indicatorsmodel.cpp
23 plugin.cpp
24)
25
26set(IndicatorsQML_RESOURCES
27 resources/indicators.qrc
28)
29
30qt5_add_resources(IndicatorsQML_RESOURCES_RCC
31 ${IndicatorsQML_RESOURCES}
32)
33
34add_library(IndicatorsQml SHARED
35 ${IndicatorsQML_RESOURCES_RCC}
36 ${IndicatorsQML_SOURCES}
37)
38# Because this is an internal support library, we want
39# to expose all symbols in it. Consider changing this
40# either to a static library or just using the
41# files directly in targets.
42set_target_properties(IndicatorsQml PROPERTIES COMPILE_FLAGS -fvisibility=default)
43
44target_link_libraries(IndicatorsQml
45 ${QMENUMODEL_LDFLAGS}
46)
47
48qt5_use_modules(IndicatorsQml Core Qml Quick)
49
50install(TARGETS IndicatorsQml
51 DESTINATION ${SHELL_PRIVATE_LIBDIR}/qml/Unity/Indicators
52 )
053
=== added directory 'plugins/Unity/Indicators/Messaging'
=== added file 'plugins/Unity/Indicators/Messaging/CMakeLists.txt'
--- plugins/Unity/Indicators/Messaging/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ plugins/Unity/Indicators/Messaging/CMakeLists.txt 2013-07-11 14:53:26 +0000
@@ -0,0 +1,1 @@
1add_subdirectory(qml)
02
=== added directory 'plugins/Unity/Indicators/Messaging/qml'
=== added file 'plugins/Unity/Indicators/Messaging/qml/ActionButton.qml'
--- plugins/Unity/Indicators/Messaging/qml/ActionButton.qml 1970-01-01 00:00:00 +0000
+++ plugins/Unity/Indicators/Messaging/qml/ActionButton.qml 2013-07-11 14:53:26 +0000
@@ -0,0 +1,43 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
18 * Olivier Tilloy <olivier.tilloy@canonical.com>
19 */
20
21import QtQuick 2.0
22import Ubuntu.Components 0.1
23import Unity.Indicators 0.1 as Indicators
24
25Button {
26 id: button
27 property QtObject actionGroup: null
28 property string action
29
30 property var actionParameter: null
31
32 Indicators.MenuAction {
33 id: menuAction
34 actionGroup: button.actionGroup
35 action: button.action
36 }
37
38 onClicked: {
39 if (menuAction.valid) {
40 menuAction.activate(actionParameter);
41 }
42 }
43}
044
=== added file 'plugins/Unity/Indicators/Messaging/qml/ActionTextField.qml'
--- plugins/Unity/Indicators/Messaging/qml/ActionTextField.qml 1970-01-01 00:00:00 +0000
+++ plugins/Unity/Indicators/Messaging/qml/ActionTextField.qml 2013-07-11 14:53:26 +0000
@@ -0,0 +1,66 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
18 * Olivier Tilloy <olivier.tilloy@canonical.com>
19 */
20
21import QtQuick 2.0
22import Ubuntu.Components 0.1
23
24Item {
25 property alias actionGroup: sendButton.actionGroup
26 property alias action: sendButton.action
27
28 property alias text: replyField.text
29 property alias buttonText: sendButton.text
30
31 TextField {
32 id: replyField
33
34 anchors {
35 top: parent.top
36 bottom: parent.bottom
37 left: parent.left
38 right: sendButton.left
39 rightMargin: units.gu(1)
40 }
41 placeholderText: "Reply"
42 hasClearButton: false
43
44 onEnabledChanged: {
45 //Make sure that the component lost focus when enabled = false,
46 //otherwise it will get focus again when enable = true
47 if (!enabled) {
48 focus = false;
49 }
50 }
51 }
52
53 ActionButton {
54 id: sendButton
55
56 actionParameter: replyField.text
57 anchors {
58 top: parent.top
59 bottom: parent.bottom
60 right: parent.right
61 }
62 width: units.gu(9)
63 enabled: replyField.text !== ""
64 color: enabled ? "#c94212" : "#bababa"
65 }
66}
067
=== added file 'plugins/Unity/Indicators/Messaging/qml/CMakeLists.txt'
--- plugins/Unity/Indicators/Messaging/qml/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ plugins/Unity/Indicators/Messaging/qml/CMakeLists.txt 2013-07-11 14:53:26 +0000
@@ -0,0 +1,15 @@
1file(GLOB IndicatorsMessaging_QMLFILES
2 *.qml
3 *.js
4 qmldir
5)
6
7# copy qml & qmldir files into build directory for shadow builds
8add_custom_target(UnityIndicatorsMessagingQmlFiles ALL
9 COMMAND cp ${IndicatorsMessaging_QMLFILES} ${CMAKE_BINARY_DIR}/plugins/Unity/Indicators/Messaging
10 DEPENDS ${IndicatorsMessaging_QMLFILES}
11)
12
13install(FILES ${IndicatorsMessaging_QMLFILES}
14 DESTINATION ${SHELL_PRIVATE_LIBDIR}/qml/Unity/Indicators/Messaging
15)
016
=== added file 'plugins/Unity/Indicators/Messaging/qml/GroupedMessage.qml'
--- plugins/Unity/Indicators/Messaging/qml/GroupedMessage.qml 1970-01-01 00:00:00 +0000
+++ plugins/Unity/Indicators/Messaging/qml/GroupedMessage.qml 2013-07-11 14:53:26 +0000
@@ -0,0 +1,96 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
18 * Olivier Tilloy <olivier.tilloy@canonical.com>
19 */
20
21import QtQuick 2.0
22import Ubuntu.Components 0.1
23import Unity.Indicators 0.1 as Indicators
24
25Indicators.BasicMenuItem {
26 id: groupedMessage
27 property alias count: label.text
28
29 color: "#221e1b"
30 implicitHeight: units.gu(10)
31
32 Indicators.MenuAction {
33 id: menuAction
34 actionGroup: groupedMessage.actionGroup
35 action: menu ? menu.action : ""
36 }
37
38 Row {
39 anchors.fill: parent
40 anchors.margins: units.gu(2)
41 spacing: units.gu(4)
42
43 UbuntuShape {
44 height: units.gu(6)
45 width: units.gu(6)
46 image: Image {
47 source: menu && (menu.extra.canonical_icon.length > 0) ? "image://gicon/" + encodeURI(menu.extra.canonical_icon) : "qrc:/indicators/artwork/messaging/default_app.svg"
48 fillMode: Image.PreserveAspectFit
49 }
50 }
51
52 Label {
53 anchors.verticalCenter: parent.verticalCenter
54 color: "#e8e1d0"
55 font.weight: Font.DemiBold
56 fontSize: "medium"
57 text: menu && menu.label ? menu.label : ""
58 }
59
60 Label {
61 id: label
62 anchors.verticalCenter: parent.verticalCenter
63 width: parent.width - x
64 horizontalAlignment: Text.AlignRight
65 color: "#e8e1d0"
66 font.weight: Font.DemiBold
67 fontSize: "medium"
68 text: menuAction.valid ? menuAction.state[0] : "0"
69 }
70 }
71
72 Indicators.HLine {
73 anchors.top: parent.top
74 color: "#403b37"
75 }
76
77 Indicators.HLine {
78 anchors.bottom: parent.bottom
79 color: "#060606"
80 }
81
82 MouseArea {
83 anchors.fill: parent
84 onClicked: {
85 if (menuAction.valid) {
86 menuAction.activate(true);
87 }
88 }
89 }
90
91 onItemRemoved: {
92 if (menuAction.valid) {
93 menuAction.activate(false);
94 }
95 }
96}
097
=== added file 'plugins/Unity/Indicators/Messaging/qml/HeroMessage.qml'
--- plugins/Unity/Indicators/Messaging/qml/HeroMessage.qml 1970-01-01 00:00:00 +0000
+++ plugins/Unity/Indicators/Messaging/qml/HeroMessage.qml 2013-07-11 14:53:26 +0000
@@ -0,0 +1,120 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
18 * Olivier Tilloy <olivier.tilloy@canonical.com>
19 */
20
21import QtQuick 2.0
22import Ubuntu.Components 0.1
23import Unity.Indicators 0.1 as Indicators
24
25Indicators.BasicMenuItem {
26 id: heroMessage
27
28 property variant actionsDescription: null
29 property alias heroMessageHeader: __heroMessageHeader
30 property real collapsedHeight: heroMessageHeader.y + heroMessageHeader.bodyBottom + units.gu(2)
31 property real expandedHeight: collapsedHeight
32
33 color: "#221e1c"
34
35 removable: state !== "expanded"
36 implicitHeight: collapsedHeight
37
38 Indicators.MenuAction {
39 id: menuAction
40 actionGroup: heroMessage.actionGroup
41 action: menu ? menu.action : ""
42 }
43
44 HeroMessageHeader {
45 id: __heroMessageHeader
46
47 anchors.top: parent.top
48 anchors.left: parent.left
49 anchors.right: parent.right
50
51 avatar: menu && (menu.extra.canonical_icon.length > 0) ? "image://gicon/" + encodeURI(menu.extra.canonical_icon) : "qrc:/indicators/artwork/messaging/default_contact.png"
52 icon: menu && (menu.extra.canonical_app_icon.length > 0) ? "image://gicon/" + encodeURI(menu.extra.canonical_app_icon) : ""
53 appIcon: icon
54
55 state: heroMessage.state
56
57 onAppIconClicked: {
58 if (menuAction.valid) {
59 deactivateMenu();
60 action.activate(true);
61 }
62 }
63 }
64
65 onClicked: {
66 if (menuActivated) {
67 deactivateMenu();
68 } else {
69 activateMenu();
70 }
71 }
72
73 Indicators.HLine {
74 id: __topHLine
75 anchors.top: parent.top
76 color: "#403b37"
77 }
78
79 Indicators.HLine {
80 id: __bottomHLine
81 anchors.bottom: parent.bottom
82 color: "#060606"
83 }
84
85 states: State {
86 name: "expanded"
87 when: menuActivated
88
89 PropertyChanges {
90 target: heroMessage
91 color: "#333130"
92 implicitHeight: heroMessage.expandedHeight
93 }
94 PropertyChanges {
95 target: __topHLine
96 opacity: 0.0
97 }
98 PropertyChanges {
99 target: __bottomHLine
100 opacity: 0.0
101 }
102 }
103
104 transitions: Transition {
105 ParallelAnimation {
106 NumberAnimation {
107 properties: "opacity,implicitHeight"
108 duration: 200
109 easing.type: Easing.OutQuad
110 }
111 ColorAnimation {}
112 }
113 }
114
115 onItemRemoved: {
116 if (menuAction.valid) {
117 menuAction.activate(false);
118 }
119 }
120}
0121
=== added file 'plugins/Unity/Indicators/Messaging/qml/HeroMessageHeader.qml'
--- plugins/Unity/Indicators/Messaging/qml/HeroMessageHeader.qml 1970-01-01 00:00:00 +0000
+++ plugins/Unity/Indicators/Messaging/qml/HeroMessageHeader.qml 2013-07-11 14:53:26 +0000
@@ -0,0 +1,161 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
18 * Olivier Tilloy <olivier.tilloy@canonical.com>
19 */
20
21import QtQuick 2.0
22import Ubuntu.Components 0.1
23
24Item {
25 id: heroMessageHeader
26
27 property alias avatar: avatarImage.source
28 property alias icon: iconImage.source
29 property alias appIcon: appIconImage.source
30 property alias titleText: __titleText
31 property alias subtitleText: __subtitleText
32 property alias bodyText: __bodyText
33 property real bodyBottom: bodyText.y + bodyText.height
34
35 signal appIconClicked()
36
37 height: units.gu(9)
38
39 UbuntuShape {
40 id: avatarImageContainer
41 anchors {
42 top: parent.top
43 topMargin: units.gu(2)
44 left: parent.left
45 leftMargin: units.gu(2)
46 }
47 height: units.gu(6)
48 width: units.gu(6)
49 image: Image {
50 id: avatarImage
51 fillMode: Image.PreserveAspectFit
52 }
53 }
54
55 Image {
56 id: iconImage
57 anchors {
58 top: parent.top
59 topMargin: units.gu(2)
60 left: avatarImageContainer.right
61 leftMargin: units.gu(1)
62 }
63 height: units.gu(1.5)
64 width: units.gu(2)
65 horizontalAlignment: Image.AlignHCenter
66 verticalAlignment: Image.AlignBottom
67 fillMode: Image.PreserveAspectFit
68 }
69
70 Label {
71 id: __titleText
72 anchors {
73 baseline: iconImage.bottom
74 left: iconImage.right
75 leftMargin: units.gu(1)
76 right: __appIcon.left
77 rightMargin: units.gu(2)
78 }
79 elide: Text.ElideRight
80 color: "#e8e1d0"
81 font.weight: Font.DemiBold
82 fontSize: "medium"
83 }
84
85 Label {
86 id: __subtitleText
87 anchors {
88 baseline: __titleText.baseline
89 baselineOffset: units.gu(2.5)
90 left: __titleText.left
91 right: __titleText.right
92 }
93 elide: Text.ElideRight
94 color: "#8f8f88"
95 fontSize: "small"
96 }
97
98 Label {
99 id: __bodyText
100 anchors {
101 baseline: __subtitleText.baseline
102 baselineOffset: units.gu(2.5)
103 left: __titleText.left
104 right: parent.right
105 rightMargin: units.gu(2)
106 }
107 maximumLineCount: 2
108 wrapMode: Text.WordWrap
109 elide: Text.ElideRight
110 color: "#e8e1d0"
111 fontSize: "small"
112 }
113
114 Item {
115 id: __appIcon
116 width: units.gu(7)
117 height: units.gu(7)
118 anchors {
119 top: parent.top
120 right: parent.right
121 }
122 opacity: 0.0
123 enabled: heroMessageHeader.state === "expanded"
124
125 Image {
126 id: appIconImage
127 height: width
128 anchors {
129 left: parent.left
130 leftMargin: units.gu(2)
131 right: parent.right
132 rightMargin: units.gu(2)
133 topMargin: units.gu(1)
134 verticalCenter: parent.verticalCenter
135 }
136 fillMode: Image.PreserveAspectFit
137 }
138
139 MouseArea {
140 anchors.fill: parent
141 onClicked: heroMessageHeader.appIconClicked()
142 }
143 }
144
145 states: State {
146 name: "expanded"
147
148 PropertyChanges {
149 target: __appIcon
150 opacity: 1.0
151 }
152 }
153
154 transitions: Transition {
155 NumberAnimation {
156 property: "opacity"
157 duration: 200
158 easing.type: Easing.OutQuad
159 }
160 }
161}
0162
=== added file 'plugins/Unity/Indicators/Messaging/qml/MessageMenuItem.qml'
--- plugins/Unity/Indicators/Messaging/qml/MessageMenuItem.qml 1970-01-01 00:00:00 +0000
+++ plugins/Unity/Indicators/Messaging/qml/MessageMenuItem.qml 2013-07-11 14:53:26 +0000
@@ -0,0 +1,96 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
18 * Olivier Tilloy <olivier.tilloy@canonical.com>
19 */
20
21import QtQuick 2.0
22import Ubuntu.Components 0.1
23import Unity.Indicators 0.1 as Indicators
24
25Indicators.BasicMenuItem {
26 property variant actionsDescription: menu ? menu.extra.canonical_message_actions : undefined
27
28 onActionGroupChanged: loadItem()
29 onActionsDescriptionChanged: loadItem()
30 implicitHeight: contents.status == Loader.Ready ? contents.item.implicitHeight : 0
31
32 Loader {
33 id: contents
34
35 anchors.fill: parent
36 // Binding all properties for the item, to make sure that any change in the
37 // property will be propagated to the contents.item at any time
38 Binding {
39 target: contents.item
40 property: "menuActivated"
41 value: menuActivated
42 when: (contents.status == Loader.Ready)
43 }
44
45 Binding {
46 target: contents.item
47 property: "actionGroup"
48 value: actionGroup
49 when: (contents.status == Loader.Ready)
50 }
51
52 Binding {
53 target: contents.item
54 property: "menu"
55 value: menu
56 when: (contents.status == Loader.Ready)
57 }
58
59 Binding {
60 target: contents.item
61 property: "actionsDescription"
62 value: actionsDescription
63 when: (contents.status == Loader.Ready)
64 }
65
66 Connections {
67 target: contents.item ? contents.item : null
68 onActivateMenu: activateMenu()
69 onDeactivateMenu: deactivateMenu()
70 }
71 }
72
73
74 function loadItem()
75 {
76 var parameterType = ""
77 for (var actIndex in actionsDescription) {
78 var desc = actionsDescription[actIndex];
79 if (desc["parameter-type"] !== undefined) {
80 parameterType += desc["parameter-type"];
81 } else {
82 parameterType += "_";
83 }
84 }
85
86 if (parameterType === "") {
87 contents.source = "SimpleTextMessage.qml";
88 } else if (parameterType === "s") {
89 contents.source = "TextMessage.qml";
90 } else if (parameterType === "_s") {
91 contents.source = "SnapDecision.qml";
92 } else {
93 console.debug("Unknown paramater type: " + parameterType);
94 }
95 }
96}
097
=== added file 'plugins/Unity/Indicators/Messaging/qml/QuickReply.qml'
--- plugins/Unity/Indicators/Messaging/qml/QuickReply.qml 1970-01-01 00:00:00 +0000
+++ plugins/Unity/Indicators/Messaging/qml/QuickReply.qml 2013-07-11 14:53:26 +0000
@@ -0,0 +1,160 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
18 * Olivier Tilloy <olivier.tilloy@canonical.com>
19 */
20
21import QtQuick 2.0
22import Ubuntu.Components 0.1
23import Unity.Indicators 0.1 as Indicators
24
25Item {
26 property alias actionGroup: actionTextField.actionGroup
27 property alias action: actionTextField.action
28
29 property alias buttonText: actionTextField.buttonText
30 property real expandedHeight: childrenRect.height
31 property alias messages : messagelistRepeater.model
32
33 Item {
34 id: header
35 anchors.top: parent.top
36 anchors.left: parent.left
37 anchors.right: parent.right
38 height: units.gu(4)
39
40 Row {
41 anchors {
42 fill: parent
43 leftMargin: units.gu(2)
44 rightMargin: units.gu(2)
45 topMargin: units.gu(1)
46 bottomMargin: units.gu(1)
47 }
48 spacing: units.gu(1)
49
50 Image {
51 width: units.gu(2)
52 height: width
53 fillMode: Image.PreserveAspectFit
54 source: "qrc:/indicators/artwork/messaging/message_sms01_54px.png"
55 }
56
57 Label {
58 height: parent.height
59 verticalAlignment: Text.AlignVCenter
60 fontSize: "small"
61 color: "#8f8f88"
62 text: "Quick reply with:"
63 }
64 }
65
66 Indicators.HLine {
67 anchors.bottom: parent.bottom
68 color: "#20201F"
69 }
70 }
71
72 Column {
73 id: messagelist
74 anchors {
75 left: parent.left
76 right: parent.right
77 top: header.bottom
78 }
79 height: childrenRect.height
80
81 Repeater {
82 id: messagelistRepeater
83
84 height: childrenRect.height
85
86 Rectangle {
87 width: messagelist.width
88 height: units.gu(5)
89 color: "#333230"
90
91 Label {
92 id: __label
93
94 anchors {
95 fill: parent
96 leftMargin: units.gu(2)
97 rightMargin: units.gu(2)
98 }
99 verticalAlignment: Text.AlignVCenter
100 fontSize: "medium"
101 color: "#e8e1d0"
102 text: modelData
103 }
104
105 Indicators.HLine {
106 anchors.top: parent.top
107 color: "#464543"
108 }
109
110 Indicators.HLine {
111 anchors.bottom: parent.bottom
112 color: "#20201F"
113 }
114
115 MouseArea {
116 id: __mouseArea
117
118 anchors.fill: parent
119 onClicked: {
120 actionTextField.text = modelData;
121 }
122 }
123
124 Rectangle {
125 id: __mask
126
127 anchors.fill: parent
128 color: "black"
129 opacity: __mouseArea.pressed ? 0.3 : 0.0
130 Behavior on opacity {
131 NumberAnimation {
132 duration: 200
133 easing.type: Easing.OutQuad
134 }
135 }
136 }
137 }
138
139 }
140 }
141
142 Item {
143 anchors.top: messagelist.bottom
144 anchors.left: parent.left
145 anchors.right: parent.right
146 height: units.gu(6)
147
148 ActionTextField {
149 id: actionTextField
150
151 anchors.fill: parent
152 anchors.margins: units.gu(1)
153 }
154
155 Indicators.HLine {
156 anchors.top: parent.top
157 color: "#464543"
158 }
159 }
160}
0161
=== added file 'plugins/Unity/Indicators/Messaging/qml/SimpleTextMessage.qml'
--- plugins/Unity/Indicators/Messaging/qml/SimpleTextMessage.qml 1970-01-01 00:00:00 +0000
+++ plugins/Unity/Indicators/Messaging/qml/SimpleTextMessage.qml 2013-07-11 14:53:26 +0000
@@ -0,0 +1,97 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
18 * Olivier Tilloy <olivier.tilloy@canonical.com>
19 */
20
21import QtQuick 2.0
22import Ubuntu.Components 0.1
23import "utils.js" as Utils
24
25HeroMessage {
26 id: __heroMessage
27
28 property alias footer: footerLoader.sourceComponent
29
30 expandedHeight: fullMessage.y + fullMessage.height + units.gu(2)
31 heroMessageHeader.titleText.text: menu ? menu.label : ""
32 heroMessageHeader.subtitleText.text: menu ? Utils.formatDate(menu.extra.canonical_time) : ""
33 heroMessageHeader.bodyText.text: menu ? menu.extra.canonical_text : ""
34
35 Item {
36 id: fullMessage
37
38 anchors {
39 left: parent.left
40 leftMargin: units.gu(2)
41 right: parent.right
42 rightMargin: units.gu(2)
43 top: heroMessageHeader.bottom
44 }
45 height: childrenRect.height
46 opacity: 0.0
47 enabled: false
48
49 Label {
50 id: bodyText
51 anchors {
52 top: parent.top
53 left: parent.left
54 right: parent.right
55 }
56 wrapMode: Text.WordWrap
57 elide: Text.ElideRight
58 color: "#e8e1d0"
59 fontSize: "medium"
60 text: heroMessageHeader.bodyText.text
61 }
62
63 Loader {
64 id: footerLoader
65
66 anchors {
67 top: bodyText.bottom
68 topMargin: units.gu(2)
69 left: parent.left
70 right: parent.right
71 }
72 height: item != undefined ? units.gu(4) : 0
73 }
74
75 states: State {
76 name: "expanded"
77 when: __heroMessage.state === "expanded"
78
79 PropertyChanges {
80 target: heroMessageHeader.bodyText
81 opacity: 0.0
82 }
83
84 PropertyChanges {
85 target: fullMessage
86 opacity: 1.0
87 enabled: true
88 }
89 }
90 transitions: Transition {
91 NumberAnimation {
92 property: "opacity"
93 duration: 200
94 }
95 }
96 }
97}
098
=== added file 'plugins/Unity/Indicators/Messaging/qml/SnapDecision.qml'
--- plugins/Unity/Indicators/Messaging/qml/SnapDecision.qml 1970-01-01 00:00:00 +0000
+++ plugins/Unity/Indicators/Messaging/qml/SnapDecision.qml 2013-07-11 14:53:26 +0000
@@ -0,0 +1,142 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
18 * Olivier Tilloy <olivier.tilloy@canonical.com>
19 */
20
21import QtQuick 2.0
22import Ubuntu.Components 0.1
23import Unity.Indicators 0.1 as Indicators
24import "utils.js" as Utils
25
26HeroMessage {
27 id: snapDecision
28
29 expandedHeight: buttons.y + buttons.height + quickreply.height + units.gu(2)
30 heroMessageHeader.titleText.text: menu ? menu.label : ""
31 heroMessageHeader.subtitleText.text: menu ? menu.extra.canonical_text : ""
32 heroMessageHeader.subtitleText.color: "#e8e1d0"
33 heroMessageHeader.bodyText.text: menu ? Utils.formatDate(menu.extra.canonical_time) : ""
34 heroMessageHeader.bodyText.color: "#8f8f88"
35
36 Item {
37 id: buttons
38
39 anchors.left: parent.left
40 anchors.leftMargin: units.gu(2)
41 anchors.right: parent.right
42 anchors.rightMargin: units.gu(2)
43 anchors.top: heroMessageHeader.bottom
44 anchors.topMargin: units.gu(1)
45 height: units.gu(4)
46 opacity: 0.0
47
48 Button {
49 text: "Message"
50 color: "#bababa"
51 anchors.left: parent.left
52 anchors.top: parent.top
53 anchors.bottom: parent.bottom
54 width: (parent.width - units.gu(1)) / 2
55
56 onClicked: {
57 if (quickreply.state === "") {
58 quickreply.state = "expanded";
59 } else {
60 quickreply.state = "";
61 }
62 }
63 }
64
65 ActionButton {
66 actionGroup: snapDecision.actionGroup
67 action: actionsDescription[0].name
68
69 text: actionsDescription ? actionsDescription[0].label : "Call back"
70 color: "#c94212"
71 anchors.right: parent.right
72 anchors.top: parent.top
73 anchors.bottom: parent.bottom
74 width: (parent.width - units.gu(1)) / 2
75 }
76
77 states: State {
78 name: "expanded"
79 when: snapDecision.state === "expanded"
80
81 PropertyChanges {
82 target: buttons
83 opacity: 1.0
84 }
85 }
86 transitions: Transition {
87 NumberAnimation {
88 property: "opacity"
89 duration: 200
90 easing.type: Easing.OutQuad
91 }
92 }
93 }
94
95 QuickReply {
96 id: quickreply
97
98 actionGroup: snapDecision.actionGroup
99 action: actionsDescription[1].name
100
101 messages: actionsDescription ? actionsDescription[1]["parameter-hint"] : ""
102 buttonText: actionsDescription ? actionsDescription[1].label : "send"
103 anchors {
104 top: buttons.bottom
105 topMargin: units.gu(2)
106 left: parent.left
107 right: parent.right
108 }
109 height: 0
110 opacity: 0.0
111 enabled: false
112
113 states: State {
114 name: "expanded"
115
116 PropertyChanges {
117 target: quickreply
118 height: expandedHeight
119 opacity: 1.0
120 }
121
122 PropertyChanges {
123 target: quickreply
124 enabled: true
125 }
126 }
127
128 transitions: Transition {
129 NumberAnimation {
130 properties: "opacity,height"
131 duration: 200
132 easing.type: Easing.OutQuad
133 }
134 }
135 }
136
137 onStateChanged: {
138 if (state === "") {
139 quickreply.state = "";
140 }
141 }
142}
0143
=== added file 'plugins/Unity/Indicators/Messaging/qml/TextMessage.qml'
--- plugins/Unity/Indicators/Messaging/qml/TextMessage.qml 1970-01-01 00:00:00 +0000
+++ plugins/Unity/Indicators/Messaging/qml/TextMessage.qml 2013-07-11 14:53:26 +0000
@@ -0,0 +1,35 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
18 * Olivier Tilloy <olivier.tilloy@canonical.com>
19 */
20
21import QtQuick 2.0
22import Ubuntu.Components 0.1
23import Unity.Indicators 0.1 as Indicators
24
25SimpleTextMessage {
26 id: simpleMessage
27
28 footer: ActionTextField {
29 anchors.fill: parent
30 actionGroup: simpleMessage.actionGroup
31 action: actionsDescription[0].name
32
33 buttonText: actionsDescription ? actionsDescription[0].label : "Send"
34 }
35}
036
=== added file 'plugins/Unity/Indicators/Messaging/qml/qmldir'
--- plugins/Unity/Indicators/Messaging/qml/qmldir 1970-01-01 00:00:00 +0000
+++ plugins/Unity/Indicators/Messaging/qml/qmldir 2013-07-11 14:53:26 +0000
@@ -0,0 +1,12 @@
1module Unity.Indicators.Messaging
2
3ActionButton 0.1 ActionButton.qml
4ActionTextField 0.1 ActionTextField.qml
5GroupedMessage 0.1 GroupedMessage.qml
6HeroMessage 0.1 HeroMessage.qml
7HeroMessageHeader 0.1 HeroMessageHeader.qml
8MessageMenuItem 0.1 MessageMenuItem.qml
9QuickReply 0.1 QuickReply.qml
10SimpleTextMessage 0.1 SimpleTextMessage.qml
11SnapDecision 0.1 SnapDecision.qml
12TextMessage 0.1 TextMessage.qml
0\ No newline at end of file13\ No newline at end of file
114
=== added file 'plugins/Unity/Indicators/Messaging/qml/utils.js'
--- plugins/Unity/Indicators/Messaging/qml/utils.js 1970-01-01 00:00:00 +0000
+++ plugins/Unity/Indicators/Messaging/qml/utils.js 2013-07-11 14:53:26 +0000
@@ -0,0 +1,27 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
18 * Olivier Tilloy <olivier.tilloy@canonical.com>
19 */
20
21.pragma library
22
23function formatDate(timestamp) {
24 // timestamp is in microseconds since epoch
25 var date = new Date(timestamp / 1000);
26 return Qt.formatDateTime(date, "hh:mm - MMM dd");
27}
028
=== added directory 'plugins/Unity/Indicators/Network'
=== added file 'plugins/Unity/Indicators/Network/CMakeLists.txt'
--- plugins/Unity/Indicators/Network/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ plugins/Unity/Indicators/Network/CMakeLists.txt 2013-07-11 14:53:26 +0000
@@ -0,0 +1,42 @@
1project(IndicatorsNetworkQml)
2
3pkg_check_modules(GLIB glib-2.0>=2.32)
4pkg_check_modules(LIBNM_GLIB libnm-glib>=0.9.6)
5pkg_check_modules(LIBNM_UTIL libnm-util>=0.9.6)
6
7if(LIBNM_GLIB_FOUND AND LIBNM_UTIL_FOUND AND GLIB_FOUND)
8 set(INDICATORS_NETWORK_SRC
9 networkagent.cpp
10 plugin.cpp
11 secret-agent.c
12 )
13
14 add_library(IndicatorsNetworkQml MODULE
15 ${INDICATORS_NETWORK_SRC}
16 )
17
18 qt5_use_modules(IndicatorsNetworkQml Core Qml Widgets)
19
20 set_target_properties(IndicatorsNetworkQml PROPERTIES COMPILE_FLAGS -fPIC)
21
22 include_directories(
23 ${CMAKE_CURRENT_SOURCE_DIR}
24 ${GLIB_INCLUDE_DIRS}
25 ${LIBNM_GLIB_INCLUDE_DIRS}
26 ${LIBNM_UTIL_INCLUDE_DIRS}
27 )
28
29 target_link_libraries(IndicatorsNetworkQml
30 ${GLIB_LIBRARIES}
31 ${LIBNM_GLIB_LIBRARIES}
32 ${LIBNM_UTIL_LIBRARIES}
33 )
34
35 install(TARGETS IndicatorsNetworkQml
36 DESTINATION ${SHELL_PRIVATE_LIBDIR}/qml/Unity/Indicators/Network
37 )
38else()
39 message(WARNING "Missing glib or libnm dependency for the network plugin, not building")
40endif()
41
42add_subdirectory(qml)
043
=== added file 'plugins/Unity/Indicators/Network/networkagent.cpp'
--- plugins/Unity/Indicators/Network/networkagent.cpp 1970-01-01 00:00:00 +0000
+++ plugins/Unity/Indicators/Network/networkagent.cpp 2013-07-11 14:53:26 +0000
@@ -0,0 +1,146 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Alberto Ruiz <alberto.ruiz@canonical.com>
18 * Renato Araujo Oliveira Filho <renato@canonical.com>
19 */
20
21#include "networkagent.h"
22
23#include <QVariant>
24#include <QApplication>
25#include <QDebug>
26
27class NetworkAgentToken
28{
29public:
30 NMConnection *connection;
31 NMSettingWirelessSecurity *wisec;
32 guint id;
33 QByteArray keyMgmt;
34
35 NetworkAgentToken(NMConnection *connection,
36 NMSettingWirelessSecurity *wisec,
37 guint id,
38 QByteArray keyMgmt)
39 : connection(connection),
40 wisec(wisec),
41 id(id),
42 keyMgmt(keyMgmt)
43 {
44 if (connection) {
45 g_object_ref(connection);
46 } else {
47 qWarning() << "invalid connection object";
48 }
49 }
50
51 ~NetworkAgentToken()
52 {
53 if (connection) {
54 g_object_unref(connection);
55 }
56 }
57};
58
59NetworkAgent::NetworkAgent(QObject *parent)
60 : QObject(parent)
61{
62 m_agent = unity_settings_secret_agent_new();
63 g_signal_connect(G_OBJECT(m_agent),
64 UNITY_SETTINGS_SECRET_AGENT_SECRET_REQUESTED,
65 G_CALLBACK(onSecretRequested),
66 this);
67
68 g_signal_connect(G_OBJECT(m_agent),
69 UNITY_SETTINGS_SECRET_AGENT_REQUEST_CANCELLED,
70 G_CALLBACK(onSecretRequestCancelled),
71 this);
72}
73
74NetworkAgent::~NetworkAgent()
75{
76 nm_secret_agent_unregister(NM_SECRET_AGENT(m_agent));
77 g_object_unref(m_agent);
78}
79
80void NetworkAgent::authenticate(const QVariant &token, const QString &key)
81{
82 NetworkAgentToken *pToken = (NetworkAgentToken *) token.value<void *>();
83 if (pToken == NULL) {
84 return;
85 }
86
87 if ((pToken->keyMgmt == "wpa-none") || (pToken->keyMgmt == "wpa-psk")) {
88 g_object_set(G_OBJECT(pToken->wisec),
89 NM_SETTING_WIRELESS_SECURITY_PSK, qPrintable(key),
90 NULL);
91 } else if (pToken->keyMgmt == "none") {
92 g_object_set(G_OBJECT(pToken->wisec),
93 NM_SETTING_WIRELESS_SECURITY_WEP_KEY0, qPrintable(key),
94 NULL);
95 }
96
97 GHashTable *settings = nm_connection_to_hash(pToken->connection,
98 NM_SETTING_HASH_FLAG_ALL);
99
100 unity_settings_secret_agent_provide_secret(m_agent,
101 pToken->id, settings);
102 g_hash_table_unref(settings);
103 delete pToken;
104}
105
106void NetworkAgent::cancel(const QVariant &token)
107{
108 NetworkAgentToken *pToken = (NetworkAgentToken *) token.value<void *>();
109 if (pToken != NULL) {
110 unity_settings_secret_agent_cancel_request(m_agent, pToken->id);
111 delete pToken;
112 }
113}
114
115void NetworkAgent::onSecretRequested(UnitySettingsSecretAgent* /*agent*/,
116 guint id,
117 NMConnection* connection,
118 const char* /*setting_name*/,
119 const char** /*hints*/,
120 NMSecretAgentGetSecretsFlags /*flags*/,
121 NetworkAgent* self)
122{
123 NetworkAgentToken *token = new NetworkAgentToken(connection,
124 NULL,
125 id,
126 NULL);
127
128 token->wisec = nm_connection_get_setting_wireless_security(connection);
129 if (token->wisec) {
130 token->keyMgmt = nm_setting_wireless_security_get_key_mgmt(token->wisec);
131 }
132
133 QVariant varToken = qVariantFromValue((void *) token);
134 Q_EMIT self->secretRequested(varToken);
135}
136
137void NetworkAgent::onSecretRequestCancelled(UnitySettingsSecretAgent* /*agent*/,
138 guint /*id*/,
139 NMConnection* /*connection*/,
140 const char* /*setting_name*/,
141 const char** /*hints*/,
142 NMSecretAgentGetSecretsFlags /*flags*/,
143 NetworkAgent* /*self*/)
144{
145 //Do nothing for now
146}
0147
=== added file 'plugins/Unity/Indicators/Network/networkagent.h'
--- plugins/Unity/Indicators/Network/networkagent.h 1970-01-01 00:00:00 +0000
+++ plugins/Unity/Indicators/Network/networkagent.h 2013-07-11 14:53:26 +0000
@@ -0,0 +1,65 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Alberto Ruiz <alberto.ruiz@canonical.com>
18 * Renato Araujo Oliveira Filho <renato@canonical.com>
19 */
20
21#ifndef NETWORKAGENT_H
22#define NETWORKAGENT_H
23
24#include "secret-agent.h"
25
26#include <QObject>
27
28class NetworkAgentToken;
29
30class NetworkAgent : public QObject
31{
32 Q_OBJECT
33public:
34 NetworkAgent(QObject *parent=0);
35 ~NetworkAgent();
36
37 Q_INVOKABLE void authenticate(const QVariant &token, const QString &key);
38 Q_INVOKABLE void cancel(const QVariant &token);
39
40Q_SIGNALS:
41 void secretRequested(const QVariant &token);
42 void secretRequestCancelled();
43
44private:
45 UnitySettingsSecretAgent *m_agent;
46
47 static void onSecretRequested(UnitySettingsSecretAgent *agent,
48 guint id,
49 NMConnection *connection,
50 const char *setting_name,
51 const char **hints,
52 NMSecretAgentGetSecretsFlags flags,
53 NetworkAgent *self);
54
55 static void onSecretRequestCancelled(UnitySettingsSecretAgent *agent,
56 guint id,
57 NMConnection *connection,
58 const char *setting_name,
59 const char **hints,
60 NMSecretAgentGetSecretsFlags flags,
61 NetworkAgent *self);
62
63};
64
65#endif
066
=== added file 'plugins/Unity/Indicators/Network/plugin.cpp'
--- plugins/Unity/Indicators/Network/plugin.cpp 1970-01-01 00:00:00 +0000
+++ plugins/Unity/Indicators/Network/plugin.cpp 2013-07-11 14:53:26 +0000
@@ -0,0 +1,31 @@
1/*
2 * Copyright (C) 2012 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Author: Nick Dedekind <nick.dedekind@canonical.com>
17 */
18
19// Qt
20#include <QtQml>
21
22// self
23#include "plugin.h"
24
25// local
26#include "networkagent.h"
27
28void IndicatorsNetworkPlugin::registerTypes(const char *uri)
29{
30 qmlRegisterType<NetworkAgent>(uri, 0, 1, "NetworkAgent");
31}
032
=== added file 'plugins/Unity/Indicators/Network/plugin.h'
--- plugins/Unity/Indicators/Network/plugin.h 1970-01-01 00:00:00 +0000
+++ plugins/Unity/Indicators/Network/plugin.h 2013-07-11 14:53:26 +0000
@@ -0,0 +1,32 @@
1/*
2 * Copyright (C) 2012 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Author: Nick Dedekind <nick.dedekind@canonical.com>
17 */
18
19#ifndef INDICATORS_NETWORK_PLUGIN_H
20#define INDICATORS_NETWORK_PLUGIN_H
21
22#include <QtQml/QQmlExtensionPlugin>
23
24class IndicatorsNetworkPlugin : public QQmlExtensionPlugin
25{
26 Q_OBJECT
27 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
28public:
29 void registerTypes(const char *uri);
30};
31
32#endif // INDICATORS_NETWORK_PLUGIN_H
033
=== added directory 'plugins/Unity/Indicators/Network/qml'
=== added file 'plugins/Unity/Indicators/Network/qml/AccessPoint.qml'
--- plugins/Unity/Indicators/Network/qml/AccessPoint.qml 1970-01-01 00:00:00 +0000
+++ plugins/Unity/Indicators/Network/qml/AccessPoint.qml 2013-07-11 14:53:26 +0000
@@ -0,0 +1,68 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
18 */
19
20import QtQuick 2.0
21import Ubuntu.Components 0.1
22import Ubuntu.Components.ListItems 0.1 as ListItem
23import Unity.Indicators 0.1 as Indicators
24
25Indicators.MenuItem {
26 id: accessPoint
27 property variant actionWifiApStrength : menu && actionGroup ? actionGroup.action(menu.extra.canonical_wifi_ap_strength_action) : null
28 property variant wifiApStrength : actionWifiApStrength && actionWifiApStrength.valid ? actionWifiApStrength.state : "0"
29
30 function getNetworkIcon(data) {
31 var imageName = "nm-signal-100"
32 var signalStrength = parseInt(wifiApStrength)
33
34 if (data.extra.canonical_wifi_ap_is_adhoc) {
35 imageName = "nm-adhoc";
36 } else if (signalStrength == 0) {
37 imageName = "nm-signal-00";
38 } else if (signalStrength <= 25) {
39 imageName = "nm-signal-25";
40 } else if (signalStrength <= 50) {
41 imageName = "nm-signal-50";
42 } else if (signalStrength <= 75) {
43 imageName = "nm-signal-75";
44 }
45
46 if (data.extra.canonical_wifi_ap_is_secure) {
47 imageName += "-secure";
48 }
49
50 return "image://gicon/" + imageName;
51 }
52
53 icon: menu && wifiApStrength ? getNetworkIcon(menu) : "image://gicon/wifi-none"
54 iconFrame: false
55 control: CheckBox {
56 id: checkBoxActive
57 height: units.gu(4)
58 width: units.gu(4)
59 anchors.centerIn: parent
60 }
61
62 Indicators.MenuActionBinding {
63 actionGroup: accessPoint.actionGroup
64 action: menu ? menu.action : ""
65 target: checkBoxActive
66 property: "checked"
67 }
68}
069
=== added file 'plugins/Unity/Indicators/Network/qml/CMakeLists.txt'
--- plugins/Unity/Indicators/Network/qml/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ plugins/Unity/Indicators/Network/qml/CMakeLists.txt 2013-07-11 14:53:26 +0000
@@ -0,0 +1,15 @@
1file(GLOB IndicatorsNetwork_QMLFILES
2 *.qml
3 *.js
4 qmldir
5)
6
7# copy qml & qmldir files into build directory for shadow builds
8add_custom_target(UnityIndicatorsNetworkQmlFiles ALL
9 COMMAND cp ${IndicatorsNetwork_QMLFILES} ${CMAKE_BINARY_DIR}/plugins/Unity/Indicators/Network
10 DEPENDS ${IndicatorsNetwork_QMLFILES}
11)
12
13install(FILES ${IndicatorsNetwork_QMLFILES}
14 DESTINATION ${SHELL_PRIVATE_LIBDIR}/qml/Unity/Indicators/Network
15)
016
=== added file 'plugins/Unity/Indicators/Network/qml/PasswordPage.qml'
--- plugins/Unity/Indicators/Network/qml/PasswordPage.qml 1970-01-01 00:00:00 +0000
+++ plugins/Unity/Indicators/Network/qml/PasswordPage.qml 2013-07-11 14:53:26 +0000
@@ -0,0 +1,88 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
18 */
19
20import QtQuick 2.0
21import Ubuntu.Components 0.1
22import Ubuntu.Components.ListItems 0.1 as ListItem
23import Unity.Indicators 0.1 as Indicators
24
25Page {
26 id: pagePassword
27
28 property variant agent
29 property variant token
30
31 anchors.fill: parent
32 title: "Network Authentication"
33
34 Column {
35 anchors {
36 left: parent.left
37 right: parent.right
38 }
39
40 Indicators.SectionMenuItem {
41 label: "Authentication"
42 }
43
44 Indicators.MenuItem {
45 implicitHeight: password.height + units.gu(1)
46
47 PasswordTextField {
48 id: password
49 anchors {
50 left: parent.left
51 right: parent.right
52 margins: units.gu(3)
53 verticalCenter: parent.verticalCenter
54 }
55 }
56 }
57
58 Indicators.MenuItem {
59 Row {
60 anchors {
61 right: parent.right
62 verticalCenter: parent.verticalCenter
63 margins: units.gu(3)
64 }
65
66 spacing: units.gu(1)
67
68 Button {
69 text: "Cancel"
70 width: units.gu(10)
71 onClicked: {
72 agent.cancel(token);
73 pageStack.pop();
74 }
75 }
76
77 Button {
78 text: "Ok"
79 width: units.gu(10)
80 onClicked: {
81 agent.authenticate(token, password.text);
82 pageStack.pop();
83 }
84 }
85 }
86 }
87 }
88}
089
=== added file 'plugins/Unity/Indicators/Network/qml/PasswordTextField.qml'
--- plugins/Unity/Indicators/Network/qml/PasswordTextField.qml 1970-01-01 00:00:00 +0000
+++ plugins/Unity/Indicators/Network/qml/PasswordTextField.qml 2013-07-11 14:53:26 +0000
@@ -0,0 +1,68 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
18 */
19
20import QtQuick 2.0
21import Ubuntu.Components 0.1
22
23Item {
24 id: textMenu
25
26 property alias text: textField.text
27
28 height: contentColumn.height
29
30 Column {
31 id: contentColumn
32 spacing: units.gu(0.5)
33 anchors {
34 left: parent.left
35 right: parent.right
36 }
37
38 TextField {
39 id: textField
40
41 anchors {
42 left: parent.left
43 right: parent.right
44 }
45
46 placeholderText: "Password"
47 echoMode: showPassword.checked ? TextInput.Normal : TextInput.Password
48 }
49
50 Row {
51 anchors {
52 left: parent.left
53 right: parent.right
54 }
55
56 spacing: units.gu(1)
57
58 CheckBox {
59 id: showPassword
60 }
61
62 Label {
63 text: "Show password"
64 anchors.verticalCenter: showPassword.verticalCenter
65 }
66 }
67 }
68}
069
=== added file 'plugins/Unity/Indicators/Network/qml/WifiSection.qml'
--- plugins/Unity/Indicators/Network/qml/WifiSection.qml 1970-01-01 00:00:00 +0000
+++ plugins/Unity/Indicators/Network/qml/WifiSection.qml 2013-07-11 14:53:26 +0000
@@ -0,0 +1,34 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
18 */
19
20import QtQuick 2.0
21import Ubuntu.Components 0.1
22import Unity.Indicators 0.1 as Indicators
23
24Indicators.SectionMenuItem {
25 id: wifiSectionMenu
26
27 Indicators.MenuAction {
28 id: busyAction
29 actionGroup: wifiSectionMenu.actionGroup
30 action: menu ? menu.extra.canonical_busy_action : ""
31 }
32
33 busy: busyAction.valid ? busyAction.state : false
34}
035
=== added file 'plugins/Unity/Indicators/Network/qml/qmldir'
--- plugins/Unity/Indicators/Network/qml/qmldir 1970-01-01 00:00:00 +0000
+++ plugins/Unity/Indicators/Network/qml/qmldir 2013-07-11 14:53:26 +0000
@@ -0,0 +1,8 @@
1module Unity.Indicators.Network
2plugin IndicatorsNetworkQml
3
4NetworkPage 0.1 NetworkPage.qml
5AccessPoint 0.1 AccessPoint.qml
6PasswordPage 0.1 PasswordPage.qml
7PasswordTextField 0.1 PasswordTextField.qml
8WifiSection 0.1 WifiSection.qml
0\ No newline at end of file9\ No newline at end of file
110
=== added file 'plugins/Unity/Indicators/Network/secret-agent.c'
--- plugins/Unity/Indicators/Network/secret-agent.c 1970-01-01 00:00:00 +0000
+++ plugins/Unity/Indicators/Network/secret-agent.c 2013-07-11 14:53:26 +0000
@@ -0,0 +1,382 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Alberto Ruiz <alberto.ruiz@canonical.com>
18 * Renato Araujo Oliveira Filho <renato@canonical.com>
19 */
20
21
22#include <glib.h>
23#include <glib-object.h>
24#include <nm-secret-agent.h>
25#include "secret-agent.h"
26
27#define UNITY_SETTINGS_TYPE_SECRET_AGENT (unity_settings_secret_agent_get_type ())
28#define UNITY_SETTINGS_SECRET_AGENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_SETTINGS_TYPE_SECRET_AGENT, UnitySettingsSecretAgent))
29#define UNITY_SETTINGS_SECRET_AGENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_SETTINGS_TYPE_SECRET_AGENT, UnitySettingsSecretAgentClass))
30#define UNITY_SETTINGS_IS_SECRET_AGENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_SETTINGS_TYPE_SECRET_AGENT))
31#define UNITY_SETTINGS_IS_SECRET_AGENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_SETTINGS_TYPE_SECRET_AGENT))
32#define UNITY_SETTINGS_SECRET_AGENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_SETTINGS_TYPE_SECRET_AGENT, UnitySettingsSecretAgentClass))
33#define UNITY_SETTINGS_SECRET_AGENT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UNITY_SETTINGS_TYPE_SECRET_AGENT, UnitySettingsSecretAgentPrivate))
34
35#define AGENT_ID "com.canonical.settings.network.nm-agent"
36
37static gpointer unity_settings_secret_agent_parent_class = NULL;
38
39typedef struct _UnitySettingsSecretAgentPrivate UnitySettingsSecretAgentPrivate;
40
41struct _UnitySettingsSecretAgentPrivate {
42 GQueue *requests;
43};
44
45typedef struct _SecretRequest {
46 gint id;
47 NMSecretAgent *agent;
48 NMConnection *connection;
49 const char *connection_path;
50 const char *setting_name;
51 const char **hints;
52 NMSecretAgentGetSecretsFlags flags;
53 NMSecretAgentGetSecretsFunc callback;
54 gpointer callback_data;
55} SecretRequest;
56
57GType unity_settings_secret_agent_get_type (void) G_GNUC_CONST;
58enum {
59 UNITY_SETTINGS_SECRET_AGENT_DUMMY_PROPERTY
60};
61
62enum {
63 SECRET_REQUESTED,
64 REQUEST_CANCELLED,
65 LAST_SIGNAL
66};
67
68static guint signals[LAST_SIGNAL] = { 0 };
69
70UnitySettingsSecretAgent* unity_settings_secret_agent_new (void);
71UnitySettingsSecretAgent* unity_settings_secret_agent_construct (GType object_type);
72
73int
74secret_request_find (SecretRequest *req,
75 guint *id)
76{
77 if (req->id > *id)
78 return -1;
79
80 if (req->id < *id)
81 return 1;
82
83 return 0;
84}
85
86void
87unity_settings_secret_agent_provide_secret (UnitySettingsSecretAgent *agent,
88 guint request,
89 GHashTable *secrets)
90{
91 GList *iter;
92 SecretRequest *req;
93 UnitySettingsSecretAgentPrivate *priv = agent->priv;
94
95 iter = g_queue_find_custom (priv->requests,
96 &request,
97 (GCompareFunc)secret_request_find);
98
99 if (iter == NULL || iter->data == NULL)
100 {
101 g_warning ("Secret request with id <%d> was not found", (int)request);
102 return;
103 }
104
105 req = iter->data;
106
107 req->callback (NM_SECRET_AGENT (agent),
108 req->connection,
109 secrets,
110 NULL,
111 req->callback_data);
112
113 g_queue_remove_all (priv->requests, req);
114 g_free (req);
115 return;
116}
117
118void
119free_request (SecretRequest *req)
120{
121 g_object_unref (req->connection);
122 g_free (req);
123}
124
125void
126unity_settings_secret_agent_cancel_request (UnitySettingsSecretAgent *agent,
127 guint request)
128{
129 GList *iter;
130 SecretRequest *req;
131 UnitySettingsSecretAgentPrivate *priv = agent->priv;
132 GError *error;
133
134 iter = g_queue_find_custom (priv->requests,
135 &request,
136 (GCompareFunc)secret_request_find);
137
138 if (iter == NULL || iter->data == NULL)
139 {
140 g_warning ("Secret request with id <%d> was not found", (int)request);
141 return;
142 }
143
144 req = iter->data;
145 error = g_error_new (NM_SECRET_AGENT_ERROR,
146 NM_SECRET_AGENT_ERROR_INTERNAL_ERROR,
147 "This secret request was canceled by the user.");
148
149 req->callback (NM_SECRET_AGENT (agent),
150 req->connection,
151 NULL,
152 error,
153 req->callback_data);
154
155 g_queue_remove_all (priv->requests, req);
156 free_request (req);
157 return;
158}
159
160static void
161delete_secrets (NMSecretAgent *agent,
162 NMConnection *connection,
163 const char *connection_path,
164 NMSecretAgentDeleteSecretsFunc callback,
165 gpointer callback_data)
166{
167 g_debug ("delete secrets");
168}
169
170/* If it returns G_MAXUINT it's considered an error */
171static guint
172find_available_id (UnitySettingsSecretAgentPrivate *priv)
173{
174 guint i = 0;
175 guint candidate = 0;
176
177 if (g_queue_get_length (priv->requests) == G_MAXUINT)
178 return G_MAXUINT;
179
180 while (i < g_queue_get_length (priv->requests))
181 {
182 SecretRequest *req = (SecretRequest*)g_queue_peek_nth (priv->requests, i);
183
184 if (req->id == candidate)
185 {
186 candidate++;
187 i = 0;
188 }
189 else
190 {
191 i++;
192 }
193 }
194
195 return i;
196}
197
198static void
199get_secrets (NMSecretAgent *agent,
200 NMConnection *connection,
201 const char *connection_path,
202 const char *setting_name,
203 const char **hints,
204 NMSecretAgentGetSecretsFlags flags,
205 NMSecretAgentGetSecretsFunc callback,
206 gpointer callback_data)
207{
208 guint id;
209 UnitySettingsSecretAgentPrivate *priv = UNITY_SETTINGS_SECRET_AGENT_GET_PRIVATE (agent);
210 SecretRequest *req = NULL;
211
212 if (flags == NM_SECRET_AGENT_GET_SECRETS_FLAG_NONE)
213 {
214 GError *error = g_error_new (NM_SECRET_AGENT_ERROR,
215 NM_SECRET_AGENT_ERROR_INTERNAL_ERROR,
216 "No password found for this connection.");
217 callback (agent, connection, NULL, error, callback_data);
218 g_error_free (error);
219 return;
220 }
221
222 id = find_available_id (priv);
223 if (id == G_MAXUINT)
224 {
225 GError *error = g_error_new (NM_SECRET_AGENT_ERROR,
226 NM_SECRET_AGENT_ERROR_INTERNAL_ERROR,
227 "Reached maximum number of requests.");
228 callback (agent, connection, NULL, error, callback_data);
229 g_error_free (error);
230 return;
231 }
232
233 /* Adding a request */
234 req = (SecretRequest*) g_malloc0 (sizeof (SecretRequest));
235 *req = ((SecretRequest)
236 { id,
237 agent,
238 connection,
239 connection_path,
240 setting_name,
241 hints,
242 flags,
243 callback,
244 callback_data });
245
246 g_object_ref (connection);
247
248 g_queue_push_tail (priv->requests, req);
249
250 g_signal_emit_by_name (agent,
251 UNITY_SETTINGS_SECRET_AGENT_SECRET_REQUESTED,
252 id,
253 connection,
254 setting_name,
255 hints,
256 flags);
257}
258
259static void
260save_secrets (NMSecretAgent *agent,
261 NMConnection *connection,
262 const char *connection_path,
263 NMSecretAgentSaveSecretsFunc callback,
264 gpointer callback_data)
265{
266 g_debug ("save secrets");
267}
268
269static void
270cancel_get_secrets (NMSecretAgent *agent,
271 const char *connection_path,
272 const char *setting_name)
273{
274 g_debug ("cancel get secrets");
275}
276
277UnitySettingsSecretAgent*
278unity_settings_secret_agent_construct (GType object_type)
279{
280 UnitySettingsSecretAgent * self = NULL;
281 self = (UnitySettingsSecretAgent*) g_object_new (object_type,
282 NM_SECRET_AGENT_IDENTIFIER, AGENT_ID,
283 NULL);
284 return self;
285}
286
287
288UnitySettingsSecretAgent*
289unity_settings_secret_agent_new (void)
290{
291 return unity_settings_secret_agent_construct (UNITY_SETTINGS_TYPE_SECRET_AGENT);
292}
293
294static void
295destroy_pending_request (gpointer data)
296{
297 SecretRequest* req = (SecretRequest*)data;
298 /* Reporting the cancellation of all pending requests */
299 g_signal_emit_by_name (req->agent,
300 UNITY_SETTINGS_SECRET_AGENT_REQUEST_CANCELLED,
301 req->id);
302
303 free_request (req);
304}
305
306static void
307unity_settings_secret_agent_finalize (GObject *agent)
308{
309 UnitySettingsSecretAgentPrivate *priv = UNITY_SETTINGS_SECRET_AGENT_GET_PRIVATE (agent);
310
311 g_queue_free_full (priv->requests, destroy_pending_request);
312}
313
314static void
315unity_settings_secret_agent_class_init (UnitySettingsSecretAgentClass *klass)
316{
317 unity_settings_secret_agent_parent_class = g_type_class_peek_parent (klass);
318 NMSecretAgentClass *parent_class = NM_SECRET_AGENT_CLASS (klass);
319 parent_class->get_secrets = get_secrets;
320 parent_class->save_secrets = save_secrets;
321 parent_class->delete_secrets = delete_secrets;
322 parent_class->cancel_get_secrets = cancel_get_secrets;
323
324 g_type_class_add_private (klass, sizeof(UnitySettingsSecretAgentPrivate));
325 G_OBJECT_CLASS (klass)->finalize = unity_settings_secret_agent_finalize;
326
327
328 signals[SECRET_REQUESTED] = g_signal_new (UNITY_SETTINGS_SECRET_AGENT_SECRET_REQUESTED,
329 G_OBJECT_CLASS_TYPE (G_OBJECT_CLASS (klass)),
330 G_SIGNAL_RUN_FIRST,
331 G_STRUCT_OFFSET (UnitySettingsSecretAgentClass, secret_requested),
332 NULL, NULL, NULL,
333 G_TYPE_NONE, 5,
334 G_TYPE_UINT, G_TYPE_POINTER, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_UINT);
335
336 signals[REQUEST_CANCELLED] = g_signal_new (UNITY_SETTINGS_SECRET_AGENT_REQUEST_CANCELLED,
337 G_OBJECT_CLASS_TYPE (G_OBJECT_CLASS (klass)),
338 G_SIGNAL_RUN_FIRST,
339 G_STRUCT_OFFSET (UnitySettingsSecretAgentClass, request_cancelled),
340 NULL, NULL, NULL,
341 G_TYPE_NONE, 1,
342 G_TYPE_UINT);
343}
344
345
346static void
347unity_settings_secret_agent_instance_init (UnitySettingsSecretAgent *self)
348{
349 self->priv = UNITY_SETTINGS_SECRET_AGENT_GET_PRIVATE (self);
350 self->priv->requests = g_queue_new ();
351}
352
353GType
354unity_settings_secret_agent_get_type (void)
355{
356 static volatile gsize unity_settings_secret_agent_type_id__volatile = 0;
357 if (g_once_init_enter (&unity_settings_secret_agent_type_id__volatile))
358 {
359 static const GTypeInfo g_define_type_info =
360 {
361 sizeof (UnitySettingsSecretAgentClass),
362 (GBaseInitFunc) NULL,
363 (GBaseFinalizeFunc) NULL,
364 (GClassInitFunc) unity_settings_secret_agent_class_init,
365 (GClassFinalizeFunc) NULL,
366 NULL,
367 sizeof (UnitySettingsSecretAgent),
368 0,
369 (GInstanceInitFunc) unity_settings_secret_agent_instance_init,
370 NULL
371 };
372 GType unity_settings_secret_agent_type_id;
373 unity_settings_secret_agent_type_id = g_type_register_static (NM_TYPE_SECRET_AGENT,
374 "UnitySettingsSecretAgent",
375 &g_define_type_info,
376 0);
377 g_once_init_leave (&unity_settings_secret_agent_type_id__volatile,
378 unity_settings_secret_agent_type_id);
379 }
380
381 return unity_settings_secret_agent_type_id__volatile;
382}
0383
=== added file 'plugins/Unity/Indicators/Network/secret-agent.h'
--- plugins/Unity/Indicators/Network/secret-agent.h 1970-01-01 00:00:00 +0000
+++ plugins/Unity/Indicators/Network/secret-agent.h 2013-07-11 14:53:26 +0000
@@ -0,0 +1,102 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Alberto Ruiz <alberto.ruiz@canonical.com>
18 * Renato Araujo Oliveira Filho <renato@canonical.com>
19 */
20
21#ifndef __SECRET_AGENT_H__
22#define __SECRET_AGENT_H__
23
24#include <glib.h>
25#include <glib-object.h>
26#include <nm-secret-agent.h>
27
28/*
29 * This class is a basic implementation of the NetworkManager SecretAgent base class.
30 *
31 * The purpose of this class is to handle credential requests from the network,
32 * for example, from a WiFi hotspot or a VPN network.
33 *
34 * It queues requests objects (SecretRequest) on a GQueue in the private struct
35 * of the class. And notifies the consumer of the class through the "secret-request"
36 * and the "request-cancelled" signals with the following callback prototypes:
37 *
38 * void (*secret_requested) (UnitySettingsSecretAgent *self,
39 * guint id,
40 * NMConnection *connection,
41 * const char *setting_name,
42 * const char **hints,
43 * NMSecretAgentGetSecretsFlags flags,
44 * gpointer user_data);
45 *
46 * void (*request_cancelled) (UnitySettingsSecretAgent *self,
47 * guint id,
48 * gpointer user_data);
49 *
50 */
51
52
53G_BEGIN_DECLS
54
55
56#define UNITY_SETTINGS_TYPE_SECRET_AGENT (unity_settings_secret_agent_get_type ())
57#define UNITY_SETTINGS_SECRET_AGENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_SETTINGS_TYPE_SECRET_AGENT, UnitySettingsSecretAgent))
58#define UNITY_SETTINGS_SECRET_AGENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_SETTINGS_TYPE_SECRET_AGENT, UnitySettingsSecretAgentClass))
59#define UNITY_SETTINGS_IS_SECRET_AGENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_SETTINGS_TYPE_SECRET_AGENT))
60#define UNITY_SETTINGS_IS_SECRET_AGENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_SETTINGS_TYPE_SECRET_AGENT))
61#define UNITY_SETTINGS_SECRET_AGENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_SETTINGS_TYPE_SECRET_AGENT, UnitySettingsSecretAgentClass))
62
63#define UNITY_SETTINGS_SECRET_AGENT_SECRET_REQUESTED "secret-requested"
64#define UNITY_SETTINGS_SECRET_AGENT_REQUEST_CANCELLED "request-cancelled"
65
66typedef struct _UnitySettingsSecretAgent UnitySettingsSecretAgent;
67typedef struct _UnitySettingsSecretAgentClass UnitySettingsSecretAgentClass;
68typedef struct _UnitySettingsSecretAgentPrivate UnitySettingsSecretAgentPrivate;
69
70struct _UnitySettingsSecretAgent {
71 NMSecretAgent parent_instance;
72 UnitySettingsSecretAgentPrivate * priv;
73};
74
75struct _UnitySettingsSecretAgentClass {
76 NMSecretAgentClass parent_class;
77
78 void (*secret_requested) (UnitySettingsSecretAgent *self,
79 guint id,
80 NMConnection *connection,
81 const char *setting_name,
82 const char **hints,
83 NMSecretAgentGetSecretsFlags flags);
84
85 void (*request_cancelled) (UnitySettingsSecretAgent *self,
86 guint id);
87};
88
89
90GType unity_settings_secret_agent_get_type (void) G_GNUC_CONST;
91UnitySettingsSecretAgent* unity_settings_secret_agent_new (void);
92UnitySettingsSecretAgent* unity_settings_secret_agent_construct (GType object_type);
93
94void unity_settings_secret_agent_provide_secret (UnitySettingsSecretAgent *agent,
95 guint request,
96 GHashTable *secrets);
97void unity_settings_secret_agent_cancel_request (UnitySettingsSecretAgent *agent,
98 guint request);
99
100G_END_DECLS
101
102#endif
0103
=== added file 'plugins/Unity/Indicators/flatmenuproxymodel.cpp'
--- plugins/Unity/Indicators/flatmenuproxymodel.cpp 1970-01-01 00:00:00 +0000
+++ plugins/Unity/Indicators/flatmenuproxymodel.cpp 2013-07-11 14:53:26 +0000
@@ -0,0 +1,272 @@
1/*
2 * Copyright 2012 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
18 */
19
20extern "C" {
21#include <gio/gio.h>
22}
23
24#include "flatmenuproxymodel.h"
25#include <QString>
26#include <QStringList>
27
28FlatMenuProxyModel::FlatMenuProxyModel(QAbstractItemModel *source)
29 : QAbstractProxyModel(source),
30 m_rowCount(0)
31{
32 m_model = new QDBusMenuModel;
33 setSourceModel(m_model);
34}
35
36/*! \internal */
37FlatMenuProxyModel::~FlatMenuProxyModel()
38{
39 delete m_model;
40}
41
42void FlatMenuProxyModel::setSourceModel(QAbstractItemModel *source)
43{
44 if (sourceModel()) {
45 QAbstractItemModel *oldSource = sourceModel();
46 if (oldSource == source) {
47 return;
48 }
49
50 oldSource->disconnect(this);
51 }
52
53 QAbstractProxyModel::setSourceModel(source);
54
55 if (source) {
56
57 // FIXME - not working correctly with dynamic inserts/removes
58
59 connect(source,
60 SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)),
61 SLOT(onModelAboutToBeReset()));
62 connect(source,
63 SIGNAL(rowsInserted(QModelIndex,int,int)),
64 SLOT(onModelReset()));
65
66 connect(source,
67 SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
68 SLOT(onModelAboutToBeReset()));
69 connect(source,
70 SIGNAL(rowsRemoved(QModelIndex,int,int)),
71 SLOT(onModelReset()));
72
73 connect(source,
74 SIGNAL(modelAboutToBeReset()),
75 SLOT(onModelAboutToBeReset()));
76 connect(source,
77 SIGNAL(modelReset()),
78 SLOT(onModelReset()));
79
80 connect(source,
81 SIGNAL(statusChanged(DBusEnums::ConnectionStatus)),
82 SIGNAL(statusChanged()));
83
84 // initiliaze rowCount
85 QModelIndex lastItem = source->index(source->rowCount() - 1, 0);
86 m_rowCount = recursiveRowCount(lastItem);
87 } else {
88 m_rowCount = 0;
89 }
90
91 Q_EMIT countChanged();
92}
93
94void FlatMenuProxyModel::setBusName(const QString &busName)
95{
96 m_model->setBusName(busName);
97}
98
99QString FlatMenuProxyModel::busName() const
100{
101 return m_model->busName();
102}
103
104void FlatMenuProxyModel::setObjectPath(const QString &busPath)
105{
106 m_model->setObjectPath(busPath);
107}
108
109QString FlatMenuProxyModel::objectPath() const
110{
111 return m_model->objectPath();
112}
113
114int FlatMenuProxyModel::status() const
115{
116 return m_model->status();
117}
118
119DBusEnums::BusType FlatMenuProxyModel::busType() const
120{
121 return m_model->busType();
122}
123
124void FlatMenuProxyModel::setIntBusType(int type)
125{
126 m_model->setBusType((DBusEnums::BusType) type);
127}
128
129void FlatMenuProxyModel::start()
130{
131 m_model->start();
132}
133
134void FlatMenuProxyModel::stop()
135{
136 m_model->stop();
137}
138
139QModelIndex FlatMenuProxyModel::mapFromSource(const QModelIndex &index) const
140{
141 if (!index.isValid()) {
142 return QModelIndex();
143 }
144
145 QModelIndex result = createIndex(rowOffsetOf(index, index.row()), 0);
146 return result;
147}
148
149QModelIndex FlatMenuProxyModel::mapToSource(const QModelIndex &index) const
150{
151 if (sourceModel() && m_indexCache.contains(index.row())) {
152 QString key = m_indexCache.value(index.row());
153 QStringList sections = key.split('.', QString::SkipEmptyParts);
154 QModelIndex sourceIndex = QModelIndex();
155 for(int i=0; i < sections.size(); i++) {
156 sourceIndex = sourceModel()->index(sections.at(i).toInt(), 9, sourceIndex);
157 }
158 return sourceIndex;
159 } else {
160 return QModelIndex();
161 }
162}
163
164QModelIndex FlatMenuProxyModel::index(int row, int sectionRow, const QModelIndex &parent, const QString &key) const
165{
166 for (int i = 0, count = 0; i < sourceModel()->rowCount(parent); i++) {
167 QModelIndex sourceIndex = sourceModel()->index(i, 0, parent);
168 int indexCount = recursiveRowCount(sourceIndex);
169
170 if (count == sectionRow) {
171 QString sectionKey = key + "." + QString::number(i);
172 m_indexCache.insert(row, sectionKey);
173 return createIndex(row, 0);
174 } else if ((count + indexCount) >= sectionRow) {
175 count++;
176 return index(row, sectionRow - count, sourceIndex, key + "." + QString::number(i));
177 }
178
179 count += indexCount + 1;
180 }
181 return QModelIndex();
182}
183
184QModelIndex FlatMenuProxyModel::index(int row, int, const QModelIndex &) const
185{
186 return index(row, row, QModelIndex(), "");
187}
188
189QModelIndex FlatMenuProxyModel::parent(const QModelIndex &) const
190{
191 return QModelIndex();
192}
193
194int FlatMenuProxyModel::columnCount(const QModelIndex &) const
195{
196 return 1;
197}
198
199int FlatMenuProxyModel::rowCount(const QModelIndex &) const
200{
201 return m_rowCount;
202}
203
204int FlatMenuProxyModel::count() const
205{
206 return rowCount(QModelIndex());
207}
208
209void FlatMenuProxyModel::onModelAboutToBeReset()
210{
211 beginResetModel();
212}
213
214void FlatMenuProxyModel::onModelReset()
215{
216 // initiliaze rowCount
217 m_rowCount = 0;
218 for (int i = 0, iMax = sourceModel()->rowCount(); i < iMax; i++) {
219 QModelIndex index = sourceModel()->index(i, 0);
220 m_rowCount += recursiveRowCount(index) + 1;
221 }
222 m_indexCache.clear();
223 endResetModel();
224 Q_EMIT countChanged();
225}
226
227int FlatMenuProxyModel::recursiveRowCount(const QModelIndex &index) const
228{
229 int size = sourceModel()->rowCount(index);
230 for (int i=0, iMax=size; i < iMax; i++) {
231 QModelIndex currentIndex = sourceModel()->index(i, 0, index);
232 size += recursiveRowCount(currentIndex);
233 }
234
235 return size;
236}
237
238int FlatMenuProxyModel::rowOffsetOf(const QModelIndex &index, int row, bool inclusive) const
239{
240 int offset = 0;
241
242 QModelIndex parent = index.parent();
243
244 // Check row 0 offset
245 while(parent.isValid()) {
246 offset += 1;
247 for (int i = 0; i < parent.row(); i++) {
248 QModelIndex currentIndex = sourceModel()->index(i, 0, parent);
249 offset += recursiveRowCount(currentIndex) + 1;
250 }
251 parent = parent.parent();
252 }
253
254 // Check index.row() offset
255 for(int i = 0; i < row; i++) {
256 QModelIndex currentIndex = sourceModel()->index(i, 0, index.parent());
257 offset += recursiveRowCount(currentIndex) + 1;
258 }
259
260 if (inclusive) {
261 // itself
262 QModelIndex currentIndex = sourceModel()->index(row, 0, index.parent());
263 offset += recursiveRowCount(currentIndex);
264 }
265
266 return offset;
267}
268
269QVariant FlatMenuProxyModel::data(int row, int role) const
270{
271 return QAbstractProxyModel::data(index(row, 0), role);
272}
0\ No newline at end of file273\ No newline at end of file
1274
=== added file 'plugins/Unity/Indicators/flatmenuproxymodel.h'
--- plugins/Unity/Indicators/flatmenuproxymodel.h 1970-01-01 00:00:00 +0000
+++ plugins/Unity/Indicators/flatmenuproxymodel.h 2013-07-11 14:53:26 +0000
@@ -0,0 +1,91 @@
1/*
2 * Copyright 2012 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
18 */
19
20#ifndef FLATMENUPROXYMODEL_H
21#define FLATMENUPROXYMODEL_H
22
23#include <QAbstractProxyModel>
24#include <qdbusmenumodel.h>
25
26class SectionInfo;
27
28class FlatMenuProxyModel : public QAbstractProxyModel
29{
30 Q_OBJECT
31 Q_PROPERTY(int count READ count NOTIFY countChanged)
32 Q_PROPERTY(int busType READ busType WRITE setIntBusType NOTIFY busTypeChanged)
33 Q_PROPERTY(QString busName READ busName WRITE setBusName NOTIFY busNameChanged)
34 Q_PROPERTY(QString objectPath READ objectPath WRITE setObjectPath NOTIFY objectPathChanged)
35 Q_PROPERTY(int status READ status NOTIFY statusChanged)
36
37 Q_ENUMS(Roles)
38public:
39 FlatMenuProxyModel(QAbstractItemModel *source=0);
40 ~FlatMenuProxyModel();
41
42 void setSourceModel(QAbstractItemModel * sourceModel);
43
44 Q_INVOKABLE QVariant data(int row, int role = Qt::DisplayRole) const;
45
46 QModelIndex mapFromSource(const QModelIndex &index) const;
47 QModelIndex mapToSource(const QModelIndex &index) const;
48
49 QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const;
50 QModelIndex parent(const QModelIndex &index) const;
51 int rowCount(const QModelIndex &parent = QModelIndex()) const;
52 int count() const;
53 int columnCount(const QModelIndex &parent) const;
54
55 void setBusName(const QString &busName);
56 QString busName() const;
57
58 void setObjectPath(const QString &busName);
59 QString objectPath() const;
60
61 DBusEnums::BusType busType() const;
62 void setIntBusType(int type);
63
64 int status() const;
65
66public Q_SLOTS:
67 void onModelAboutToBeReset();
68 void onModelReset();
69
70 void start();
71 void stop();
72
73Q_SIGNALS:
74 void countChanged();
75
76 void busTypeChanged();
77 void busNameChanged();
78 void objectPathChanged();
79 void statusChanged();
80
81private:
82 QDBusMenuModel *m_model;
83 mutable QMap<int, QString> m_indexCache;
84 int m_rowCount;
85
86 int rowOffsetOf(const QModelIndex &index, int row, bool inclusive = false) const;
87 int recursiveRowCount(const QModelIndex &index) const;
88 QModelIndex index(int row, int rowCount, const QModelIndex &parent, const QString &key) const;
89};
90
91#endif
092
=== added file 'plugins/Unity/Indicators/indicator.cpp'
--- plugins/Unity/Indicators/indicator.cpp 1970-01-01 00:00:00 +0000
+++ plugins/Unity/Indicators/indicator.cpp 2013-07-11 14:53:26 +0000
@@ -0,0 +1,88 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
18 */
19
20#include "indicator.h"
21
22#include <QStringList>
23
24Indicator::Indicator(QObject *parent)
25 : QObject(parent)
26{
27}
28
29Indicator::~Indicator()
30{
31}
32
33void Indicator::init(const QString& busName, const QSettings& settings)
34{
35 setId(settings.value("Indicator Service/Name").toString());
36
37 QString actionObjectPath = settings.value("Indicator Service/ObjectPath").toString();
38
39 QVariantMap mapMenuObjectPaths;
40 Q_FOREACH(const QString& childGroup, settings.childGroups())
41 {
42 if (childGroup == "Indicator Service")
43 continue;
44
45 QString menuPath = childGroup+"/ObjectPath";
46 if (settings.contains(menuPath))
47 {
48 mapMenuObjectPaths[childGroup] = settings.value(menuPath).toString();
49 }
50 }
51
52
53 QVariantMap properties;
54 properties.clear();
55 properties.insert("busType", 1);
56 properties.insert("busName", busName);
57 properties.insert("actionsObjectPath", actionObjectPath);
58 properties.insert("menuObjectPaths", mapMenuObjectPaths);
59 setIndicatorProperties(properties);
60}
61
62QString Indicator::identifier() const
63{
64 return m_identifier;
65}
66
67void Indicator::setId(const QString &identifier)
68{
69 if (identifier != m_identifier) {
70 m_identifier = identifier;
71 Q_EMIT identifierChanged(m_identifier);
72 }
73}
74
75
76QVariant Indicator::indicatorProperties() const
77{
78 return m_properties;
79}
80
81void Indicator::setIndicatorProperties(const QVariant &properties)
82{
83 if (m_properties != properties)
84 {
85 m_properties = properties;
86 Q_EMIT indicatorPropertiesChanged(m_properties);
87 }
88}
089
=== added file 'plugins/Unity/Indicators/indicator.h'
--- plugins/Unity/Indicators/indicator.h 1970-01-01 00:00:00 +0000
+++ plugins/Unity/Indicators/indicator.h 2013-07-11 14:53:26 +0000
@@ -0,0 +1,57 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
18 * Nick Dedekind <nick.dedekind@canonical.com>
19 */
20
21#ifndef INDICATOR_H
22#define INDICATOR_H
23
24#include <QObject>
25#include <QSettings>
26
27class Indicator : public QObject
28{
29 Q_OBJECT
30 Q_PROPERTY(QString identifier READ identifier NOTIFY identifierChanged)
31 Q_PROPERTY(QVariant indicatorProperties READ indicatorProperties NOTIFY indicatorPropertiesChanged)
32
33public:
34 typedef QSharedPointer<Indicator> Ptr;
35
36 Indicator(QObject *parent = 0);
37 virtual ~Indicator();
38
39 void init(const QString& busName, const QSettings& settings);
40
41 QString identifier() const;
42 QVariant indicatorProperties() const;
43
44Q_SIGNALS:
45 void identifierChanged(const QString &identifier);
46 void indicatorPropertiesChanged(const QVariant &properties);
47
48protected:
49 void setId(const QString &id);
50 void setIndicatorProperties(const QVariant &properties);
51
52private:
53 QString m_identifier;
54 QVariant m_properties;
55};
56
57#endif // INDICATOR_H
058
=== added file 'plugins/Unity/Indicators/indicators.h'
--- plugins/Unity/Indicators/indicators.h 1970-01-01 00:00:00 +0000
+++ plugins/Unity/Indicators/indicators.h 2013-07-11 14:53:26 +0000
@@ -0,0 +1,103 @@
1/*
2 * Copyright (C) 2012 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Author: Nick Dedekind <nick.dedekind@canonical.com>
17 */
18
19#ifndef INDICATORS_H
20#define INDICATORS_H
21
22#include <QObject>
23
24class ActionState : public QObject
25{
26 Q_OBJECT
27public:
28 Q_ENUMS(ActionStates)
29 enum ActionStates {
30 Label = 0x00,
31 IconSource = 0x01,
32 AccessableName = 0x02,
33 Visible = 0x03,
34 };
35
36 ActionState(QObject*parent=0):QObject(parent) {}
37};
38
39class NetworkActionState : public QObject
40{
41 Q_OBJECT
42public:
43 Q_ENUMS(NetworkActionStates)
44 enum NetworkActionStates {
45 Connection = 0x01,
46 SignalStrength = 0x02,
47 };
48
49 NetworkActionState(QObject*parent=0):QObject(parent) {}
50};
51
52class NetworkConnection : public QObject
53{
54 Q_OBJECT
55public:
56 Q_ENUMS(NetworkConnectionStates)
57 enum NetworkConnectionStates {
58 Initial = 0x00,
59 Activating = 0x01,
60 Activated = 0x02,
61 Deactivating = 0x03,
62 };
63
64 NetworkConnection(QObject*parent=0):QObject(parent) {}
65};
66
67class IndicatorsModelRole : public QObject
68{
69 Q_OBJECT
70public:
71 Q_ENUMS(Roles)
72 enum Roles {
73 Identifier = 0,
74 Priority,
75 Title,
76 Description,
77 WidgetSource,
78 PageSource,
79 IndicatorProperties,
80 IsValid
81 };
82
83 IndicatorsModelRole(QObject*parent=0):QObject(parent) {}
84};
85
86class FlatMenuProxyModelRole : public QObject
87{
88 Q_OBJECT
89public:
90 Q_ENUMS(Roles)
91 enum Roles {
92 Action = Qt::DisplayRole + 1,
93 Label,
94 Extra,
95 Depth,
96 hasSection,
97 hasSubMenu
98 };
99
100 FlatMenuProxyModelRole(QObject*parent=0):QObject(parent) {}
101};
102
103#endif // INDICATORS_H
0104
=== added file 'plugins/Unity/Indicators/indicatorsmanager.cpp'
--- plugins/Unity/Indicators/indicatorsmanager.cpp 1970-01-01 00:00:00 +0000
+++ plugins/Unity/Indicators/indicatorsmanager.cpp 2013-07-11 14:53:26 +0000
@@ -0,0 +1,285 @@
1/*
2 * Copyright (C) 2013 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Author: Nick Dedekind <nick.dedekind@canonical.com>
17 */
18
19#include "indicatorsmanager.h"
20
21#include <QSettings>
22#include <QDebug>
23
24#include "paths.h"
25
26
27class IndicatorsManager::IndicatorData
28{
29public:
30 IndicatorData(const QString& name, const QFileInfo& fileInfo)
31 : m_name(name)
32 , m_fileInfo(fileInfo)
33 , m_verified (true)
34 {}
35
36 QString m_name;
37 QFileInfo m_fileInfo;
38
39 bool m_verified;
40 Indicator::Ptr m_indicator;
41};
42
43IndicatorsManager::IndicatorsManager(QObject* parent)
44 : QObject(parent)
45 , m_loaded(false)
46{
47}
48
49IndicatorsManager::~IndicatorsManager()
50{
51 unload();
52}
53
54void IndicatorsManager::load()
55{
56 unload();
57 QStringList xdgLocations = shellDataDirs();//QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation);
58
59 m_fsWatcher.reset(new QFileSystemWatcher(this));
60
61 Q_FOREACH(const QString& xdgLocation, xdgLocations)
62 {
63 QString indicator_path = QDir::cleanPath(xdgLocation + "/unity/indicators");
64 QDir indicator_dir(indicator_path);
65 if (indicator_dir.exists())
66 {
67 // watch folder for changes.
68 m_fsWatcher->addPath(indicator_path);
69
70 loadDir(indicator_dir);
71 }
72 }
73
74 QObject::connect(m_fsWatcher.data(), SIGNAL(directoryChanged(const QString&)), this, SLOT(onDirectoryChanged(const QString&)));
75 QObject::connect(m_fsWatcher.data(), SIGNAL(fileChanged(const QString&)), this, SLOT(onFileChanged(const QString&)));
76 setLoaded(true);
77}
78
79void IndicatorsManager::onDirectoryChanged(const QString& directory)
80{
81 loadDir(QDir(directory));
82}
83
84void IndicatorsManager::onFileChanged(const QString& file)
85{
86 QFileInfo file_info(file);
87 if (!file_info.exists())
88 {
89 unloadFile(file_info);
90 return;
91 }
92 else
93 {
94 loadFile(QFileInfo(file));
95 }
96}
97
98void IndicatorsManager::loadDir(const QDir& dir)
99{
100 startVerify(dir.canonicalPath());
101
102 QFileInfoList indicator_files = dir.entryInfoList(QStringList(), QDir::Files|QDir::NoDotAndDotDot);
103 Q_FOREACH(const QFileInfo& indicator_file, indicator_files)
104 {
105 loadFile(indicator_file);
106 }
107
108 endVerify(dir.canonicalPath());
109}
110
111void IndicatorsManager::loadFile(const QFileInfo& file_info)
112{
113 QSettings indicator_settings(file_info.absoluteFilePath(), QSettings::IniFormat, this);
114 QString name = indicator_settings.value("Indicator Service/Name").toString();
115
116 auto iter = m_indicatorsData.find(name);
117 if (iter != m_indicatorsData.end())
118 {
119 QString newFileInfoDir = QDir::cleanPath(file_info.canonicalPath());
120 IndicatorData* currentData = (*iter);
121 currentData->m_verified = true;
122
123 int file_info_location = -1;
124 int current_data_location = -1;
125
126 QString currentDataDir = QDir::cleanPath(currentData->m_fileInfo.canonicalPath());
127
128 // if we've already got this indicator, we need to make sure we're not overwriting data which is
129 // from a lower priority standard path
130 QStringList xdgLocations = shellDataDirs();
131 for (int i = 0; i < xdgLocations.size(); i++)
132 {
133 QString indicatorDir = QDir::cleanPath(xdgLocations[i] + "/unity/indicators");
134
135 if (newFileInfoDir == indicatorDir)
136 {
137 file_info_location = i;
138 }
139 if (currentDataDir == indicatorDir)
140 {
141 current_data_location = i;
142 }
143
144 if (file_info_location != -1 && current_data_location != -1)
145 {
146 break;
147 }
148 }
149
150 // file location is higher (or of equal) priority. overwrite.
151 if (file_info_location <= current_data_location &&
152 file_info != currentData->m_fileInfo)
153 {
154 currentData->m_fileInfo = file_info;
155 Q_EMIT indicatorLoaded(name);
156 }
157 }
158 else
159 {
160 IndicatorData* data = new IndicatorData(name, file_info);
161 data->m_verified = true;
162 m_indicatorsData[name]= data;
163 Q_EMIT indicatorLoaded(name);
164 }
165}
166
167void IndicatorsManager::unload()
168{
169 QHashIterator<QString, IndicatorData*> iter(m_indicatorsData);
170 while(iter.hasNext())
171 {
172 iter.next();
173 Q_EMIT indicatorAboutToBeUnloaded(iter.key());
174 }
175
176 qDeleteAll(m_indicatorsData);
177 m_indicatorsData.clear();
178
179 setLoaded(false);
180}
181
182void IndicatorsManager::unloadFile(const QFileInfo& file)
183{
184 QMutableHashIterator<QString, IndicatorData*> iter(m_indicatorsData);
185 while(iter.hasNext())
186 {
187 iter.next();
188 IndicatorData* data = iter.value();
189 if (data->m_fileInfo.absoluteFilePath() == file.absoluteFilePath())
190 {
191 if (!data->m_verified)
192 {
193 QString name = data->m_name;
194 Q_EMIT indicatorAboutToBeUnloaded(name);
195
196 delete data;
197 iter.remove();
198 }
199 }
200 }
201
202 setLoaded(m_indicatorsData.size() > 0);
203}
204
205void IndicatorsManager::setLoaded(bool loaded)
206{
207 if (loaded != m_loaded)
208 {
209 m_loaded = loaded;
210 Q_EMIT loadedChanged(m_loaded);
211 }
212}
213
214void IndicatorsManager::startVerify(const QString& path)
215{
216 QHashIterator<QString, IndicatorData*> iter(m_indicatorsData);
217 while(iter.hasNext())
218 {
219 iter.next();
220 IndicatorData* data = iter.value();
221 if (data->m_fileInfo.canonicalPath() == path)
222 {
223 data->m_verified = false;
224 }
225 }
226}
227
228void IndicatorsManager::endVerify(const QString& path)
229{
230 QMutableHashIterator<QString, IndicatorData*> iter(m_indicatorsData);
231 while(iter.hasNext())
232 {
233 iter.next();
234 IndicatorData* data = iter.value();
235 if (data->m_fileInfo.canonicalPath() == path)
236 {
237 if (!data->m_verified)
238 {
239 QString name = data->m_name;
240 Q_EMIT indicatorAboutToBeUnloaded(name);
241
242 delete data;
243 iter.remove();
244 }
245 }
246 }
247}
248
249Indicator::Ptr IndicatorsManager::indicator(const QString& indicator_name)
250{
251 if (!m_indicatorsData.contains(indicator_name))
252 {
253 qWarning() << Q_FUNC_INFO << "Invalid indicator name: " << indicator_name;
254 return Indicator::Ptr();
255 }
256
257 IndicatorData *data = m_indicatorsData[indicator_name];
258 if (data->m_indicator)
259 {
260 return data->m_indicator;
261 }
262
263 Indicator::Ptr new_indicator(new Indicator(this));
264 data->m_indicator = new_indicator;
265 QSettings settings(data->m_fileInfo.absoluteFilePath(), QSettings::IniFormat, this);
266 new_indicator->init(data->m_fileInfo.fileName(), settings);
267 return new_indicator;
268}
269
270QList<Indicator::Ptr> IndicatorsManager::indicators()
271{
272 QList<Indicator::Ptr> list;
273 Q_FOREACH(IndicatorData* data, m_indicatorsData)
274 {
275 Indicator::Ptr ret = indicator(data->m_name);
276 if (ret)
277 list.append(ret);
278 }
279 return list;
280}
281
282bool IndicatorsManager::isLoaded() const
283{
284 return m_loaded;
285}
0286
=== added file 'plugins/Unity/Indicators/indicatorsmanager.h'
--- plugins/Unity/Indicators/indicatorsmanager.h 1970-01-01 00:00:00 +0000
+++ plugins/Unity/Indicators/indicatorsmanager.h 2013-07-11 14:53:26 +0000
@@ -0,0 +1,73 @@
1/*
2 * Copyright (C) 2013 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Author: Nick Dedekind <nick.dedekind@canonical.com>
17 */
18
19#ifndef INDICATORS_MANAGER_H
20#define INDICATORS_MANAGER_H
21
22#include <QObject>
23#include <QFileSystemWatcher>
24#include <QDir>
25#include <QHash>
26#include <QSharedPointer>
27
28#include "indicator.h"
29
30class IndicatorsManager : public QObject
31{
32 Q_OBJECT
33 Q_PROPERTY(bool loaded READ isLoaded NOTIFY loadedChanged)
34public:
35 explicit IndicatorsManager(QObject* parent = 0);
36 ~IndicatorsManager();
37
38 Q_INVOKABLE void load();
39 Q_INVOKABLE void unload();
40
41 Indicator::Ptr indicator(const QString& indicator_name);
42
43 QList<Indicator::Ptr> indicators();
44
45 bool isLoaded() const;
46
47Q_SIGNALS:
48 void loadedChanged(bool);
49
50 void indicatorLoaded(const QString& indicator_name);
51 void indicatorAboutToBeUnloaded(const QString& indicator_name);
52
53private Q_SLOTS:
54 void onDirectoryChanged(const QString& directory);
55 void onFileChanged(const QString& file);
56
57private:
58 void loadDir(const QDir& dir);
59 void loadFile(const QFileInfo& file);
60 void unloadFile(const QFileInfo& dir);
61
62 void startVerify(const QString& path);
63 void endVerify(const QString& path);
64
65 void setLoaded(bool);
66
67 class IndicatorData;
68 QHash<QString, IndicatorData*> m_indicatorsData;
69 QSharedPointer<QFileSystemWatcher> m_fsWatcher;
70 bool m_loaded;
71};
72
73#endif // INDICATORS_MANAGER_H
074
=== added file 'plugins/Unity/Indicators/indicatorsmodel.cpp'
--- plugins/Unity/Indicators/indicatorsmodel.cpp 1970-01-01 00:00:00 +0000
+++ plugins/Unity/Indicators/indicatorsmodel.cpp 2013-07-11 14:53:26 +0000
@@ -0,0 +1,321 @@
1/*
2 * Copyright 2012 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
18 */
19
20#include "indicatorsmodel.h"
21#include "indicatorsmanager.h"
22#include "indicator.h"
23#include "indicators.h"
24#include "paths.h"
25
26#include <QQmlContext>
27#include <QQmlEngine>
28#include <QDebug>
29
30/*!
31 \qmltype IndicatorsModel
32 \inherits QAbstractListModel
33
34 \brief The IndicatorsModel class defines the list model for indicators
35
36 \b {This component is under heavy development.}
37
38 This class expose the available indicators.
39
40 \code
41 IndicatorsModel {
42 id: menuModel
43 }
44
45 ListView {
46 id: view
47 model: menuModel
48 Component.onCompleted: menuModel.load()
49 }
50 \endcode
51*/
52IndicatorsModel::IndicatorsModel(QObject *parent)
53 : QAbstractListModel(parent)
54{
55 m_manager = new IndicatorsManager(this);
56 QObject::connect(m_manager, SIGNAL(indicatorLoaded(const QString&)), this, SLOT(onIndicatorLoaded(const QString&)));
57 QObject::connect(m_manager, SIGNAL(indicatorAboutToBeUnloaded(const QString&)), this, SLOT(onIndicatorAboutToBeUnloaded(const QString&)));
58
59 QObject::connect(this, SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SIGNAL(countChanged()));
60 QObject::connect(this, SIGNAL(rowsRemoved(const QModelIndex &, int, int)), this, SIGNAL(countChanged()));
61 QObject::connect(this, SIGNAL(modelReset()), this, SIGNAL(countChanged()));
62}
63
64/*! \internal */
65IndicatorsModel::~IndicatorsModel()
66{
67 disconnect(m_manager, 0, 0, 0);
68 m_manager->deleteLater();
69}
70
71/*!
72 \qmlproperty IndicatorsModel::count
73 The number of data entries in the model.
74
75 \b Note: methods should only be called after the Component has completed.
76*/
77int IndicatorsModel::count() const
78{
79 return rowCount();
80}
81
82/*!
83 \qmlmethod IndicatorsModel::unload()
84
85 Load all indicators.
86*/
87void IndicatorsModel::load()
88{
89 m_indicators.clear();
90 m_manager->load();
91}
92
93/*!
94 \qmlmethod IndicatorsModel::unload()
95
96 Unload all indicators.
97*/
98void IndicatorsModel::unload()
99{
100 m_manager->unload();
101}
102
103/*! \internal */
104void IndicatorsModel::onIndicatorLoaded(const QString& indicator_name)
105{
106 Indicator::Ptr indicator = m_manager->indicator(indicator_name);
107 if (!indicator)
108 {
109 return;
110 }
111
112 if (m_indicators.indexOf(indicator) >= 0)
113 {
114 return;
115 }
116
117 // find the insert position
118 int pos = 0;
119 while (pos < count())
120 {
121 // keep going while the existing priority is less.
122 if (indicatorData(indicator, IndicatorsModelRole::Priority).toInt() < data(index(pos), IndicatorsModelRole::Priority).toInt())
123 break;
124 pos++;
125 }
126
127 QObject::connect(indicator.data(), SIGNAL(identifierChanged(const QString&)), this, SLOT(onIdentifierChanged()));
128 QObject::connect(indicator.data(), SIGNAL(indicatorPropertiesChanged(const QVariant&)), this, SLOT(onIndicatorPropertiesChanged()));
129
130 beginInsertRows(QModelIndex(), pos, pos);
131
132 m_indicators.insert(pos, indicator);
133 endInsertRows();
134}
135
136/*! \internal */
137void IndicatorsModel::onIndicatorAboutToBeUnloaded(const QString& indicator_name)
138{
139 Indicator::Ptr indicator = m_manager->indicator(indicator_name);
140 if (!indicator)
141 {
142 return;
143 }
144
145 int i = 0;
146 QMutableListIterator<Indicator::Ptr> iter(m_indicators);
147 while(iter.hasNext())
148 {
149 if (indicator == iter.next())
150 {
151 beginRemoveRows(QModelIndex(), i, i);
152 iter.remove();
153 endRemoveRows();
154 break;
155 }
156 i++;
157 }
158
159}
160
161/*! \internal */
162void IndicatorsModel::onIdentifierChanged()
163{
164 notifyDataChanged(QObject::sender(), IndicatorsModelRole::Identifier);
165}
166
167/*! \internal */
168void IndicatorsModel::onIndicatorPropertiesChanged()
169{
170 notifyDataChanged(QObject::sender(), IndicatorsModelRole::IndicatorProperties);
171}
172
173/*! \internal */
174void IndicatorsModel::notifyDataChanged(QObject *sender, int role)
175{
176 Indicator* indicator = qobject_cast<Indicator*>(sender);
177 if (!indicator)
178 {
179 return;
180 }
181
182 int index = 0;
183 QMutableListIterator<Indicator::Ptr> iter(m_indicators);
184 while(iter.hasNext())
185 {
186 if (indicator == iter.next())
187 {
188 QModelIndex changedIndex = this->index(index);
189 dataChanged(changedIndex, changedIndex, QVector<int>() << role);
190 break;
191 }
192 index++;
193 }
194}
195
196/*! \internal */
197QHash<int, QByteArray> IndicatorsModel::roleNames() const
198{
199 static QHash<int, QByteArray> roles;
200 if (roles.isEmpty())
201 {
202 roles[IndicatorsModelRole::Identifier] = "identifier";
203 roles[IndicatorsModelRole::Priority] = "priority";
204 roles[IndicatorsModelRole::Title] = "title";
205 roles[IndicatorsModelRole::Description] = "description";
206 roles[IndicatorsModelRole::WidgetSource] = "widgetSource";
207 roles[IndicatorsModelRole::PageSource] = "pageSource";
208 roles[IndicatorsModelRole::IndicatorProperties] = "indicatorProperties";
209 roles[IndicatorsModelRole::IsValid] = "isValid";
210 }
211 return roles;
212}
213
214/*! \internal */
215int IndicatorsModel::columnCount(const QModelIndex &) const
216{
217 return 1;
218}
219
220/*! \internal */
221QVariant IndicatorsModel::defaultData(Indicator::Ptr indicator, int role)
222{
223 switch (role)
224 {
225 case IndicatorsModelRole::Priority:
226 return 0;
227 case IndicatorsModelRole::Title:
228 return indicator ? indicator->identifier() : "Unknown";
229 case IndicatorsModelRole::Description:
230 return "";
231 case IndicatorsModelRole::WidgetSource:
232 return shellAppDirectory()+"/Panel/Indicators/DefaultIndicatorWidget.qml";
233 case IndicatorsModelRole::PageSource:
234 return shellAppDirectory()+"/Panel/Indicators/DefaultIndicatorPage.qml";
235 }
236 return QVariant();
237}
238
239Q_INVOKABLE QVariant IndicatorsModel::data(int row, int role) const
240{
241 return data(index(row, 0), role);
242}
243
244/*! \internal */
245QVariant IndicatorsModel::data(const QModelIndex &index, int role) const
246{
247 if (!index.isValid() || index.row() >= m_indicators.size())
248 return QVariant();
249
250 Indicator::Ptr indicator = m_indicators[index.row()];
251
252 switch (role)
253 {
254 case IndicatorsModelRole::Identifier:
255 if (indicator)
256 {
257 return QVariant(indicator->identifier());
258 }
259 break;
260 case IndicatorsModelRole::IndicatorProperties:
261 if (indicator)
262 {
263 return QVariant(indicator->indicatorProperties());
264 }
265 break;
266 case IndicatorsModelRole::IsValid:
267 return (indicator ? true : false);
268 case IndicatorsModelRole::Priority:
269 case IndicatorsModelRole::Title:
270 case IndicatorsModelRole::Description:
271 case IndicatorsModelRole::WidgetSource:
272 case IndicatorsModelRole::PageSource:
273 return indicatorData(indicator, role);
274 default:
275 break;
276 }
277 return QVariant();
278}
279
280QVariant IndicatorsModel::indicatorData(const Indicator::Ptr& indicator, int role) const
281{
282 if (indicator && m_parsed_indicator_data.contains(indicator->identifier()))
283 {
284 QVariantMap data = m_parsed_indicator_data[indicator->identifier()];
285 return data.value(roleNames()[role], QVariant());
286 }
287 return defaultData(indicator, role);
288}
289
290/*! \internal */
291QModelIndex IndicatorsModel::parent(const QModelIndex&) const
292{
293 return QModelIndex();
294}
295
296/*! \internal */
297int IndicatorsModel::rowCount(const QModelIndex&) const
298{
299 return m_indicators.count();
300}
301
302void IndicatorsModel::setIndicatorData(const QVariant& data)
303{
304 m_indicator_data = data;
305
306 m_parsed_indicator_data.clear();
307 QMap<QString, QVariant> map = data.toMap();
308 QMapIterator<QString, QVariant> iter(map);
309 while(iter.hasNext())
310 {
311 iter.next();
312 m_parsed_indicator_data[iter.key()] = iter.value().toMap();
313 }
314
315 Q_EMIT indicatorDataChanged(m_indicator_data);
316}
317
318QVariant IndicatorsModel::indicatorData() const
319{
320 return m_indicator_data;
321}
0322
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches