From 6ef90c9783cc6465a8230b35e42fd6be3b918a80 Mon Sep 17 00:00:00 2001 From: Vesa Halttunen Date: Wed, 26 Oct 2011 13:36:39 +0300 Subject: [PATCH] Fixes: NB#284386 - [TASK] DLNA indicator on status area MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: NB#284386 - [TASK] DLNA indicator on status area RevBy: Saija Saarenpää, Anssi Eteläniemi --- debian/changelog | 1 + .../screenlock/lockscreenstatusareaview.cpp | 4 +- .../screenlock/lockscreenstatusareaview.h | 3 + src/systemui/statusarea/statusareaview.cpp | 6 ++ src/systemui/statusarea/statusareaview.h | 4 + src/systemui/statusarea/statusindicator.cpp | 17 +++++ src/systemui/statusarea/statusindicator.h | 26 +++++++ .../statusarea/statusindicatormodel.h | 5 ++ tests/stubs/dlnastatusindicator_stub.h | 76 +++++++++++++++++++ .../ut_lockscreenstatusareaview.cpp | 1 + tests/ut_statusareaview/ut_statusareaview.cpp | 1 + .../ut_statusindicator/ut_statusindicator.cpp | 11 +++ tests/ut_statusindicator/ut_statusindicator.h | 1 + themes/style/statusarea.css | 16 ++++ 14 files changed, 171 insertions(+), 1 deletion(-) create mode 100644 tests/stubs/dlnastatusindicator_stub.h diff --git a/debian/changelog b/debian/changelog index 01cfef96..f4654de1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,7 @@ system-ui (1.2.15~1) unstable; urgency=low * [UNRELEASED] + * Fixes: NB#284386 - [TASK] DLNA indicator on status area -- Artem Egorkine Wed, 26 Oct 2011 10:29:20 +0300 diff --git a/src/extensions/screenlock/lockscreenstatusareaview.cpp b/src/extensions/screenlock/lockscreenstatusareaview.cpp index a7682768..ea482308 100644 --- a/src/extensions/screenlock/lockscreenstatusareaview.cpp +++ b/src/extensions/screenlock/lockscreenstatusareaview.cpp @@ -44,6 +44,7 @@ LockScreenStatusAreaView::LockScreenStatusAreaView(StatusArea *controller) : alarmIndicator(new AlarmStatusIndicator(contextFrameworkContext, controller)), notificationStatusIndicator(new NotificationStatusIndicator(controller)), callForwardingIndicator(new CallForwardingStatusIndicator(contextFrameworkContext, controller)), + dlnaIndicator(new DLNAStatusIndicator(contextFrameworkContext, controller)), transferStatusIndicator(new TransferStatusIndicator(controller)), orientationChangeSignalConnected(false) { @@ -64,13 +65,14 @@ LockScreenStatusAreaView::LockScreenStatusAreaView(StatusArea *controller) : layout->addStretch(); layout->addItem(notificationStatusIndicator); layout->addItem(transferStatusIndicator); + layout->addItem(callIndicator); layout->addItem(tetheringIndicator); layout->addItem(callForwardingIndicator); + layout->addItem(dlnaIndicator); layout->addItem(shortDistanceNetworkIndicator); layout->addItem(gpsIndicator); layout->addItem(presenceIndicator); layout->addItem(profileIndicator); - layout->addItem(callIndicator); layout->addItem(alarmIndicator); controller->setLayout(layout); } diff --git a/src/extensions/screenlock/lockscreenstatusareaview.h b/src/extensions/screenlock/lockscreenstatusareaview.h index 0e5d0efe..928519de 100644 --- a/src/extensions/screenlock/lockscreenstatusareaview.h +++ b/src/extensions/screenlock/lockscreenstatusareaview.h @@ -103,6 +103,9 @@ private slots: //! Call forwarding indicator StatusIndicator *callForwardingIndicator; + //! DLNA indicator + StatusIndicator *dlnaIndicator; + //! Transfer status indicator StatusIndicator *transferStatusIndicator; diff --git a/src/systemui/statusarea/statusareaview.cpp b/src/systemui/statusarea/statusareaview.cpp index 4406be81..ec424489 100644 --- a/src/systemui/statusarea/statusareaview.cpp +++ b/src/systemui/statusarea/statusareaview.cpp @@ -64,6 +64,8 @@ StatusAreaView::StatusAreaView(StatusArea *controller) : portraitNotificationIndicator(new NotificationStatusIndicator(controller)), landscapeCallForwardingIndicator(new CallForwardingStatusIndicator(contextFrameworkContext, controller)), portraitCallForwardingIndicator(new CallForwardingStatusIndicator(contextFrameworkContext, controller)), + landscapeDLNAIndicator(new DLNAStatusIndicator(contextFrameworkContext, controller)), + portraitDLNAIndicator(new DLNAStatusIndicator(contextFrameworkContext, controller)), landscapeTransferStatusIndicator(new TransferStatusIndicator(controller)), portraitTransferStatusIndicator(new TransferStatusIndicator(controller)), landscapeClock(new Clock(controller)), @@ -145,6 +147,8 @@ void StatusAreaView::setupTestability() portraitClock->setParent(portraitWidget); landscapeCallForwardingIndicator->setParent(landscapeWidget); portraitCallForwardingIndicator->setParent(portraitWidget); + landscapeDLNAIndicator->setParent(landscapeWidget); + portraitDLNAIndicator->setParent(portraitWidget); landscapeTransferStatusIndicator->setParent(landscapeWidget); portraitTransferStatusIndicator->setParent(portraitWidget); } @@ -182,6 +186,7 @@ QGraphicsLinearLayout* StatusAreaView::createLandscapeLayout() layout->addItem(landscapeCallIndicator); layout->addItem(landscapeTetheringIndicator); layout->addItem(landscapeCallForwardingIndicator); + layout->addItem(landscapeDLNAIndicator); layout->addItem(landscapeShortDistanceNetworkIndicator); layout->addItem(landscapeGPSIndicator); layout->addItem(landscapePresenceIndicator); @@ -210,6 +215,7 @@ QGraphicsLinearLayout* StatusAreaView::createPortraitLayout() layout->addItem(portraitCallIndicator); layout->addItem(portraitTetheringIndicator); layout->addItem(portraitCallForwardingIndicator); + layout->addItem(portraitDLNAIndicator); layout->addItem(portraitShortDistanceNetworkIndicator); layout->addItem(portraitGPSIndicator); layout->addItem(portraitPresenceIndicator); diff --git a/src/systemui/statusarea/statusareaview.h b/src/systemui/statusarea/statusareaview.h index f275856c..a08f7de5 100644 --- a/src/systemui/statusarea/statusareaview.h +++ b/src/systemui/statusarea/statusareaview.h @@ -131,6 +131,10 @@ private slots: StatusIndicator *landscapeCallForwardingIndicator; StatusIndicator *portraitCallForwardingIndicator; + //! DLNA status indicator + StatusIndicator *landscapeDLNAIndicator; + StatusIndicator *portraitDLNAIndicator; + //! Transfer status indicator StatusIndicator *landscapeTransferStatusIndicator; StatusIndicator *portraitTransferStatusIndicator; diff --git a/src/systemui/statusarea/statusindicator.cpp b/src/systemui/statusarea/statusindicator.cpp index 64ccd8ee..c06f57e5 100644 --- a/src/systemui/statusarea/statusindicator.cpp +++ b/src/systemui/statusarea/statusindicator.cpp @@ -786,3 +786,20 @@ void NotificationStatusIndicator::setIconID(const QString &iconID) setStyleNameAndUpdate(metaObject()->className()); } } + +DLNAStatusIndicator::DLNAStatusIndicator(ApplicationContext &context, QGraphicsItem *parent) : + StatusIndicator(parent), + dlnaEnabled(createContextItem(context, "/com/nokia/dlna/dlnaEnabled")) +{ + connect(dlnaEnabled, SIGNAL(contentsChanged()), this, SLOT(dlnaEnabledChanged())); + dlnaEnabledChanged(); +} + +DLNAStatusIndicator::~DLNAStatusIndicator() +{ +} + +void DLNAStatusIndicator::dlnaEnabledChanged() +{ + setStyleNameAndUpdate(QString(metaObject()->className()) + (dlnaEnabled->value().toBool() ? "Set" : "")); +} diff --git a/src/systemui/statusarea/statusindicator.h b/src/systemui/statusarea/statusindicator.h index 6b316019..abbf8c3f 100644 --- a/src/systemui/statusarea/statusindicator.h +++ b/src/systemui/statusarea/statusindicator.h @@ -612,4 +612,30 @@ public slots: void setIconID(const QString &iconID); }; +/*! + * A status indicator for showing whether DLNA sharing is enabled. + */ +class DLNAStatusIndicator : public StatusIndicator +{ + Q_OBJECT + M_CONTROLLER(DLNAStatusIndicator) + +public: + /*! + * Constructs a DLNAStatusIndicator. + * + * \param context the application context to get status information from + * \param parent parent MWidget + */ + explicit DLNAStatusIndicator(ApplicationContext &context, QGraphicsItem *parent = NULL); + + virtual ~DLNAStatusIndicator(); + +private slots: + void dlnaEnabledChanged(); + +private: + ContextItem *dlnaEnabled; +}; + #endif // STATUSINDICATOR_H diff --git a/src/systemui/statusarea/statusindicatormodel.h b/src/systemui/statusarea/statusindicatormodel.h index df93eddc..fa91c2ea 100644 --- a/src/systemui/statusarea/statusindicatormodel.h +++ b/src/systemui/statusarea/statusindicatormodel.h @@ -108,4 +108,9 @@ class TransferStatusIndicatorModel : public StatusIndicatorModel M_MODEL(TransferStatusIndicatorModel) }; +class DLNAStatusIndicatorModel : public StatusIndicatorModel +{ + M_MODEL(DLNAStatusIndicatorModel) +}; + #endif /* STATUSINDICATORMODEL_H_ */ diff --git a/tests/stubs/dlnastatusindicator_stub.h b/tests/stubs/dlnastatusindicator_stub.h new file mode 100644 index 00000000..5dd671b3 --- /dev/null +++ b/tests/stubs/dlnastatusindicator_stub.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (directui@nokia.com) +** +** This file is part of systemui. +** +** If you have questions regarding the use of this file, please contact +** Nokia at directui@nokia.com. +** +** This library is free software; you can redistribute it and/or +** modify it under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation +** and appearing in the file LICENSE.LGPL included in the packaging +** of this file. +** +****************************************************************************/ +#ifndef DLNASTATUSINDICATOR_STUB +#define DLNASTATUSINDICATOR_STUB + +#include "statusindicator_stub.h" +#include + + +// 1. DECLARE STUB +// FIXME - stubgen is not yet finished +class DLNAStatusIndicatorStub : public StubBase +{ +public: + virtual void DLNAStatusIndicatorConstructor(ApplicationContext &context, QGraphicsItem *parent); + virtual void DLNAStatusIndicatorDestructor(); + virtual void dlnaEnabledChanged(); +}; + +// 2. IMPLEMENT STUB +void DLNAStatusIndicatorStub::DLNAStatusIndicatorConstructor(ApplicationContext &context, QGraphicsItem *parent) +{ + Q_UNUSED(context); + Q_UNUSED(parent); + +} +void DLNAStatusIndicatorStub::DLNAStatusIndicatorDestructor() +{ + +} +void DLNAStatusIndicatorStub::dlnaEnabledChanged() +{ + stubMethodEntered("dlnaEnabledChanged"); +} + + + +// 3. CREATE A STUB INSTANCE +DLNAStatusIndicatorStub gDefaultDLNAStatusIndicatorStub; +DLNAStatusIndicatorStub *gDLNAStatusIndicatorStub = &gDefaultDLNAStatusIndicatorStub; + + +// 4. CREATE A PROXY WHICH CALLS THE STUB +DLNAStatusIndicator::DLNAStatusIndicator(ApplicationContext &context, QGraphicsItem *parent) +{ + gDLNAStatusIndicatorStub->DLNAStatusIndicatorConstructor(context, parent); +} + +DLNAStatusIndicator::~DLNAStatusIndicator() +{ + gDLNAStatusIndicatorStub->DLNAStatusIndicatorDestructor(); +} + +void DLNAStatusIndicator::dlnaEnabledChanged() +{ + gDLNAStatusIndicatorStub->dlnaEnabledChanged(); +} + + +#endif diff --git a/tests/ut_lockscreenstatusareaview/ut_lockscreenstatusareaview.cpp b/tests/ut_lockscreenstatusareaview/ut_lockscreenstatusareaview.cpp index eea45143..7ea44ce4 100644 --- a/tests/ut_lockscreenstatusareaview/ut_lockscreenstatusareaview.cpp +++ b/tests/ut_lockscreenstatusareaview/ut_lockscreenstatusareaview.cpp @@ -44,6 +44,7 @@ #include "callforwardingstatusindicator_stub.h" #include "notificationstatusindicator_stub.h" #include "transferstatusindicator_stub.h" +#include "dlnastatusindicator_stub.h" #include "screenlockextension_stub.h" #include "x11wrapper.h" #include "notificationsink_stub.h" diff --git a/tests/ut_statusareaview/ut_statusareaview.cpp b/tests/ut_statusareaview/ut_statusareaview.cpp index f4447128..91189235 100644 --- a/tests/ut_statusareaview/ut_statusareaview.cpp +++ b/tests/ut_statusareaview/ut_statusareaview.cpp @@ -40,6 +40,7 @@ #include "tetheringstatusindicator_stub.h" #include "profilestatusindicator_stub.h" #include "callforwardingstatusindicator_stub.h" +#include "dlnastatusindicator_stub.h" #include "notificationarea_stub.h" #include "notificationstatusindicator_stub.h" #include "notificationsink_stub.h" diff --git a/tests/ut_statusindicator/ut_statusindicator.cpp b/tests/ut_statusindicator/ut_statusindicator.cpp index 05a437d6..f18901ef 100644 --- a/tests/ut_statusindicator/ut_statusindicator.cpp +++ b/tests/ut_statusindicator/ut_statusindicator.cpp @@ -833,4 +833,15 @@ void Ut_StatusIndicator::testNotification() QCOMPARE(m_subject->styleName().contains("Disabled"), QBool(true)); } +void Ut_StatusIndicator::testDLNA() +{ + m_subject = new DLNAStatusIndicator(*testContext); + + testContextItems["/com/nokia/dlna/dlnaEnabled"]->setValue(QVariant(false)); + QCOMPARE(m_subject->styleName(), QString("DLNAStatusIndicator")); + + testContextItems["/com/nokia/dlna/dlnaEnabled"]->setValue(QVariant(true)); + QCOMPARE(m_subject->styleName(), QString("DLNAStatusIndicatorSet")); +} + QTEST_APPLESS_MAIN(Ut_StatusIndicator) diff --git a/tests/ut_statusindicator/ut_statusindicator.h b/tests/ut_statusindicator/ut_statusindicator.h index 9b25c3d5..1cb1b01c 100644 --- a/tests/ut_statusindicator/ut_statusindicator.h +++ b/tests/ut_statusindicator/ut_statusindicator.h @@ -78,6 +78,7 @@ private slots: void testTransferStatusStateChange(); void testCallForwarding(); void testNotification(); + void testDLNA(); }; #endif //_UT_STATUSINDICATOR_ diff --git a/themes/style/statusarea.css b/themes/style/statusarea.css index ad5cd450..def62fbb 100644 --- a/themes/style/statusarea.css +++ b/themes/style/statusarea.css @@ -672,3 +672,19 @@ StatusIndicatorIconStyle#CallForwardingStatusIndicatorSet { minimum-size: -1 -1; maximum-size: -1 -1; } + +StatusIndicatorIconStyle#DLNAStatusIndicator { + /* The list of IDs of the images to be shown in the status indicator separated by spaces */ + image-list: ""; + preferred-size: 0 -1; + minimum-size: 0 -1; + maximum-size: 0 -1; +} + +StatusIndicatorIconStyle#DLNAStatusIndicatorSet { + /* The list of IDs of the images to be shown in the status indicator separated by spaces */ + image-list: "icon-s-status-dlna-server"; + preferred-size: -1 -1; + minimum-size: -1 -1; + maximum-size: -1 -1; +}