I have made the following changes intended for : CE:MW:Shared / lipstick Please review and accept or decline. BOSS has already run some checks on this request. See the "Messages from BOSS" section below.
https://build.pub.meego.com//request/show/8431 Thank You, vesuri [This message was auto-generated] --- Request # 8431: Messages from BOSS: State: review at 2013-03-14T15:12:51 by bossbot Reviews: accepted by bossbot : Prechecks succeeded. new for CE-maintainers : Please replace this text with a review and approve/reject the review (not the SR). BOSS will take care of the rest Changes: submit: home:vesuri:branches:CE:MW:Shared / lipstick -> CE:MW:Shared / lipstick changes files: -------------- --- lipstick.changes +++ lipstick.changes @@ -0,0 +1,4 @@ +* Thu Mar 14 2013 Vesa Halttunen <[email protected]> - 0.10.4 +- Don't show notification previews for non-critical notifications if the touch screen or device is locked (from Vesa) +- Remove system notifications after they've been shown (from Vesa) + old: ---- lipstick-0.10.3.tar.bz2 new: ---- lipstick-0.10.4.tar.bz2 spec files: ----------- --- lipstick.spec +++ lipstick.spec @@ -9,7 +9,7 @@ # << macros Summary: QML toolkit for homescreen creation -Version: 0.10.3 +Version: 0.10.4 Release: 1 Group: System/Libraries License: LGPLv2.1 other changes: -------------- ++++++ lipstick-0.10.3.tar.bz2 -> lipstick-0.10.4.tar.bz2 --- src/homeapplication.cpp +++ src/homeapplication.cpp @@ -81,7 +81,7 @@ // Initialize the notification manager NotificationManager::instance(); - NotificationPreviewPresenter *notificationPreviewPresenter = new NotificationPreviewPresenter(this); + new NotificationPreviewPresenter(this); new NotificationFeedbackPlayer(this); // Initialize the home window monitor @@ -91,7 +91,6 @@ screenLock = new ScreenLock; LipstickSettings::instance()->setScreenLock(screenLock); new ScreenLockAdaptor(screenLock); - connect(screenLock, SIGNAL(screenIsLocked(bool)), notificationPreviewPresenter, SLOT(setPresentOnlyCriticalNotifications(bool))); volumeControl = new VolumeControl; batteryNotifier = new BatteryNotifier(this); --- src/notifications/notificationpreviewpresenter.cpp +++ src/notifications/notificationpreviewpresenter.cpp @@ -30,7 +30,6 @@ QObject(parent), window(0), currentNotification(0), - presentOnlyCriticalNotifications(false), locks(new MeeGo::QmLocks(this)), displayState(new MeeGo::QmDisplayState(this)) { @@ -51,19 +50,13 @@ window->hide(); } - if (currentNotification != 0) { - currentNotification = 0; - emit notificationChanged(); - } + setCurrentNotification(0); } else { if (locks->getState(MeeGo::QmLocks::TouchAndKeyboard) == MeeGo::QmLocks::Locked && displayState->get() == MeeGo::QmDisplayState::Off) { // Screen locked and off: don't show the notification but just remove it from the queue notificationQueue.removeFirst(); - if (currentNotification != 0) { - currentNotification = 0; - emit notificationChanged(); - } + setCurrentNotification(0); showNextNotification(); } else { @@ -73,8 +66,7 @@ window->show(); } - currentNotification = notificationQueue.takeFirst(); - emit notificationChanged(); + setCurrentNotification(notificationQueue.takeFirst()); } } } @@ -87,6 +79,7 @@ void NotificationPreviewPresenter::updateNotification(uint id) { Notification *notification = NotificationManager::instance()->notification(id); + notification->setProperty("id", id); if (notificationShouldBeShown(notification)) { // Add the notification to the queue if not already there or the current notification if (currentNotification != notification && !notificationQueue.contains(notification)) { @@ -140,7 +133,11 @@ bool NotificationPreviewPresenter::notificationShouldBeShown(Notification *notification) { - return !notification->hints().value(NotificationManager::HINT_HIDDEN).toBool() && !(notification->previewBody().isEmpty() && notification->previewSummary().isEmpty()) && (!presentOnlyCriticalNotifications || notification->hints().value(NotificationManager::HINT_URGENCY).toInt() >= 2); + bool screenOrDeviceLocked = locks->getState(MeeGo::QmLocks::TouchAndKeyboard) == MeeGo::QmLocks::Locked || locks->getState(MeeGo::QmLocks::Device) == MeeGo::QmLocks::Locked; + bool notificationHidden = notification->hints().value(NotificationManager::HINT_HIDDEN).toBool(); + bool notificationHasPreviewText = !(notification->previewBody().isEmpty() && notification->previewSummary().isEmpty()); + int notificationIsCritical = notification->hints().value(NotificationManager::HINT_URGENCY).toInt() >= 2; + return !notificationHidden && notificationHasPreviewText && (!screenOrDeviceLocked || notificationIsCritical); } void NotificationPreviewPresenter::setNotificationPreviewRect(qreal x1, qreal y1, qreal x2, qreal y2) @@ -157,7 +154,14 @@ X11Wrapper::XSync(dpy, False); } -void NotificationPreviewPresenter::setPresentOnlyCriticalNotifications(bool onlyCritical) +void NotificationPreviewPresenter::setCurrentNotification(Notification *notification) { - presentOnlyCriticalNotifications = onlyCritical; + if (currentNotification != notification) { + if (currentNotification != 0 && currentNotification->hints().value(NotificationManager::HINT_URGENCY).toInt() >= 2) { + NotificationManager::instance()->CloseNotification(currentNotification->property("id").toUInt()); + } + + currentNotification = notification; + emit notificationChanged(); + } } --- src/notifications/notificationpreviewpresenter.h +++ src/notifications/notificationpreviewpresenter.h @@ -87,13 +87,6 @@ */ void showNextNotification(); - /*! - * Sets whether only the critical urgency (level 2) notifications are shown. - * - * \param onlyUrgent if \c true, only notifications with critical urgency are shown, otherwise all notifications are shown - */ - void setPresentOnlyCriticalNotifications(bool onlyCritical); - private slots: /*! * Updates the notification with the given ID. @@ -116,6 +109,9 @@ //! Checks whether the given notification has a preview body and a preview summary. bool notificationShouldBeShown(Notification *notification); + //! Sets the given notification as the current notification + void setCurrentNotification(Notification *notification); + //! The notification window QDeclarativeView *window; @@ -125,9 +121,6 @@ //! Notification currently being shown Notification *currentNotification; - //! Whether only notifications of critical urgency should be shown - bool presentOnlyCriticalNotifications; - //! For getting information about the touch screen lock state MeeGo::QmLocks *locks; --- src/src.pro +++ src/src.pro @@ -3,7 +3,7 @@ TEMPLATE = lib TARGET = lipstick -VERSION = 0.10.3 +VERSION = 0.10.4 DEFINES += LIPSTICK_BUILD_LIBRARY VERSION=\\\"$$VERSION\\\" --- tests/ut_notificationpreviewpresenter/ut_notificationpreviewpresenter.cpp +++ tests/ut_notificationpreviewpresenter/ut_notificationpreviewpresenter.cpp @@ -113,6 +113,12 @@ { } +QList<uint> notificationManagerCloseNotificationIds; +void NotificationManager::CloseNotification(uint id, NotificationClosedReason) +{ + notificationManagerCloseNotificationIds.append(id); +} + NotificationManager *notificationManagerInstance = 0; NotificationManager *NotificationManager::instance() { @@ -132,12 +138,13 @@ { } -Notification *createNotification(uint id) +Notification *createNotification(uint id, int urgency = 0) { Notification *notification = new Notification; QVariantHash hints; hints.insert(NotificationManager::HINT_PREVIEW_SUMMARY, "summary"); hints.insert(NotificationManager::HINT_PREVIEW_BODY, "body"); + hints.insert(NotificationManager::HINT_URGENCY, urgency); notification->setHints(hints); notificationManagerNotification.insert(id, notification); return notification; @@ -155,6 +162,9 @@ qWidgetVisible.clear(); qDeleteAll(notificationManagerNotification); notificationManagerNotification.clear(); + notificationManagerCloseNotificationIds.clear(); + gQmLocksStub->stubReset(); + gQmDisplayStateStub->stubReset(); } void Ut_NotificationPreviewPresenter::testSignalConnections() @@ -399,8 +409,8 @@ notification->setHints(hints); notificationManagerNotification.insert(1, notification); - // Urgency is not high enough, so the notification shouldn't be shown - presenter.setPresentOnlyCriticalNotifications(true); + // When the screen or device is locked and the urgency is not high enough, so the notification shouldn't be shown + gQmLocksStub->stubSetReturnValue("getState", MeeGo::QmLocks::Locked); presenter.updateNotification(1); QCOMPARE(spy.count(), 0); QCOMPARE(qWidgetVisible[static_cast<QWidget *>(qDeclarativeViews.first())], false); @@ -465,10 +475,29 @@ NotificationPreviewPresenter presenter; QSignalSpy spy(&presenter, SIGNAL(notificationChanged())); - createNotification(1); + createNotification(1, 2); presenter.updateNotification(1); QCOMPARE(qDeclarativeViews.count(), notifications); QCOMPARE(spy.count(), notifications); } +void Ut_NotificationPreviewPresenter::testCriticalNotificationIsClosedAfterShowing() +{ + NotificationPreviewPresenter presenter; + createNotification(1, 2); + createNotification(2); + createNotification(3); + presenter.updateNotification(1); + presenter.updateNotification(2); + presenter.updateNotification(3); + QCOMPARE(notificationManagerCloseNotificationIds.count(), 0); + + presenter.showNextNotification(); + QCOMPARE(notificationManagerCloseNotificationIds.count(), 1); + QCOMPARE(notificationManagerCloseNotificationIds.at(0), (uint)1); + + presenter.showNextNotification(); + QCOMPARE(notificationManagerCloseNotificationIds.count(), 1); +} + QTEST_MAIN(Ut_NotificationPreviewPresenter) --- tests/ut_notificationpreviewpresenter/ut_notificationpreviewpresenter.h +++ tests/ut_notificationpreviewpresenter/ut_notificationpreviewpresenter.h @@ -39,6 +39,7 @@ void testUpdateNotificationRemovesNotificationFromQueueIfNotShowable(); void testNotificationNotShownIfTouchScreenIsLockedAndDisplayIsOff_data(); void testNotificationNotShownIfTouchScreenIsLockedAndDisplayIsOff(); + void testCriticalNotificationIsClosedAfterShowing(); }; #endif ++++++ lipstick.yaml --- lipstick.yaml +++ lipstick.yaml @@ -1,6 +1,6 @@ Name: lipstick Summary: QML toolkit for homescreen creation -Version: 0.10.3 +Version: 0.10.4 Release: 1 Group: System/Libraries License: LGPLv2.1
