I have made the following changes intended for : CE:UX:MTF / 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/7127 Thank You, Islam Amer [This message was auto-generated] --- Request # 7127: Messages from BOSS: State: review at 2012-10-24T13:46:58 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: Project:MTF:UX / lipstick -> CE:UX:MTF / lipstick changes files: -------------- --- lipstick.changes +++ lipstick.changes @@ -0,0 +1,4 @@ +* Wed Oct 24 2012 Vesa Halttunen <[email protected]> - 0.4.3 +- Request MCE to lock the screen after entering the lock screen from the home screen (from Vesa) +- Calculate the scale in a uniform way so as to not stretch the switcher pixmaps (from Robin) + @@ -2,2 +6,2 @@ -- Notification manager extension for getting an application's notifications -- Support for remote actions in notifications +- Notification manager extension for getting an application's notifications (from Vesa) +- Support for remote actions in notifications (from Vesa) old: ---- lipstick-0.4.2.tar.bz2 new: ---- lipstick-0.4.3.tar.bz2 spec files: ----------- --- lipstick.spec +++ lipstick.spec @@ -9,7 +9,7 @@ # << macros Summary: QML toolkit for homescreen creation -Version: 0.4.2 +Version: 0.4.3 Release: 1 Group: System/Libraries License: LGPLv2.1 other changes: -------------- ++++++ lipstick-0.4.2.tar.bz2 -> lipstick-0.4.3.tar.bz2 --- src/components/switcherpixmapitem.cpp +++ src/components/switcherpixmapitem.cpp @@ -227,9 +227,14 @@ QBrush brush(d->qWindowPixmap); // TODO: take clipping of statusbar (if any) into account here - qreal xScale = width() / d->qWindowPixmap.width(); - qreal yScale = height() / d->qWindowPixmap.height(); - brush.setTransform(QTransform().scale(xScale, yScale)); + qreal scale; + + if (width() > height()) + scale = height() / d->qWindowPixmap.height(); + else + scale = width() / d->qWindowPixmap.width(); + + brush.setTransform(QTransform().scale(scale, scale)); painter->setPen(Qt::NoPen); painter->setBrush(brush); --- src/lipstickdbusinterface.cpp +++ src/lipstickdbusinterface.cpp @@ -38,7 +38,7 @@ DBUSINTERFACE_DEBUG("Received signal to show lockscreen"); LipstickSettings *settings = LipstickSettings::instance(); - settings->setLockscreenVisible(true); + settings->setLockscreenVisible(true, true); } void LipstickDBusInterface::hideLockScreen() @@ -46,7 +46,7 @@ DBUSINTERFACE_DEBUG("Received signal to hide lockscreen"); LipstickSettings *settings = LipstickSettings::instance(); - settings->setLockscreenVisible(false); + settings->setLockscreenVisible(false, true); } void LipstickDBusInterface::lockscreenVisibilityChanged() --- src/lipsticksettings.cpp +++ src/lipsticksettings.cpp @@ -19,6 +19,9 @@ #include <QDeclarativeView> #include <QApplication> #include <QDesktopWidget> +#include <QDBusMessage> +#include <QDBusPendingCall> +#include <QDBusConnection> #include <QDebug> #include <QtSensors/QOrientationSensor> #include <QtSensors/QOrientationReading> @@ -29,12 +32,16 @@ #include <X11/Xatom.h> #include <X11/Xlib.h> +static int LOCK_SCREEN_TIMEOUT = 5000; + Q_GLOBAL_STATIC(LipstickSettings, settingsInstance) LipstickSettings::LipstickSettings() : QObject() , _lockscreenVisible(false) { + requestScreenToBeLockedTimer.setSingleShot(true); + connect(&requestScreenToBeLockedTimer, SIGNAL(timeout()), this, SLOT(requestScreenToBeLocked())); } LipstickSettings *LipstickSettings::instance() @@ -47,7 +54,7 @@ return _lockscreenVisible; } -void LipstickSettings::setLockscreenVisible(bool lockscreenVisible) +void LipstickSettings::setLockscreenVisible(bool lockscreenVisible, bool externallyChanged) { if (lockscreenVisible == _lockscreenVisible) return; @@ -61,8 +68,18 @@ // a lockscreen, so make it happy view->setWindowTitle("Screen Lock"); layer = 2; + + if (!externallyChanged && !requestScreenToBeLockedTimer.isActive()) { + // Lock screen entered from inside the home screen: request screen to be locked in 5 seconds + requestScreenToBeLockedTimer.start(LOCK_SCREEN_TIMEOUT); + } } else { view->setWindowTitle("Lipstick"); + + if (requestScreenToBeLockedTimer.isActive()) { + // Cancel any pending screen locking requests + requestScreenToBeLockedTimer.stop(); + } } // Set the stacking layer @@ -88,3 +105,10 @@ sensor.stop(); return orientation == QtMobility::QOrientationReading::TopUp; } + +void LipstickSettings::requestScreenToBeLocked() +{ + QDBusMessage message = QDBusMessage::createMethodCall("com.nokia.mce", "/com/nokia/mce/request", "com.nokia.mce.request", "req_tklock_mode_change"); + message.setArguments(QVariantList() << "locked"); + QDBusConnection::systemBus().asyncCall(message); +} --- src/lipsticksettings.h +++ src/lipsticksettings.h @@ -20,6 +20,7 @@ #include <QObject> #include <QMetaType> #include <QSize> +#include <QTimer> class LipstickSettings : public QObject { @@ -28,13 +29,14 @@ Q_PROPERTY(QSize screenSize READ screenSize NOTIFY screenSizeChanged) bool _lockscreenVisible; + QTimer requestScreenToBeLockedTimer; public: explicit LipstickSettings(); static LipstickSettings *instance(); bool lockscreenVisible() const; - void setLockscreenVisible(bool lockscreenVisible); + void setLockscreenVisible(bool lockscreenVisible, bool externallyChanged = false); QSize screenSize(); Q_INVOKABLE bool getIsInPortrait(); @@ -43,6 +45,8 @@ void lockscreenVisibleChanged(); void screenSizeChanged(); +private slots: + void requestScreenToBeLocked(); }; Q_DECLARE_METATYPE(LipstickSettings *) --- tests/tests.pro +++ tests/tests.pro @@ -1,5 +1,5 @@ TEMPLATE = subdirs -SUBDIRS = ut_categorydefinitionstore ut_notification ut_notificationmanager ut_notificationlistmodel +SUBDIRS = ut_categorydefinitionstore ut_notification ut_notificationmanager ut_notificationlistmodel ut_lipstickdbusinterface ut_lipsticksettings support_files.commands += $$PWD/gen-tests-xml.sh > $$OUT_PWD/tests.xml support_files.target = support_files --- tests/ut_lipstickdbusinterface +++ tests/ut_lipstickdbusinterface +(directory) --- tests/ut_lipstickdbusinterface/ut_lipstickdbusinterface.cpp +++ tests/ut_lipstickdbusinterface/ut_lipstickdbusinterface.cpp @@ -0,0 +1,51 @@ +/*************************************************************************** +** +** Copyright (C) 2012 Jolla Ltd. +** Contact: Robin Burchell <[email protected]> +** +** This file is part of lipstick. +** +** 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. +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include "ut_lipstickdbusinterface.h" +#include "lipstickdbusinterface.h" +#include "lipsticksettings.h" + +LipstickSettings *LipstickSettings::instance() +{ + return 0; +} + +bool lipstickSettingsLockScreenVisible = false; +bool lipstickSettingsExternallyChanged = false; +void LipstickSettings::setLockscreenVisible(bool lockscreenVisible, bool externallyChanged) +{ + lipstickSettingsLockScreenVisible = lockscreenVisible; + lipstickSettingsExternallyChanged = externallyChanged; +} + +bool LipstickSettings::lockscreenVisible() const +{ + return lipstickSettingsLockScreenVisible; +} + +void Ut_LipstickDBusInterface::testShowAndHideLockScreen() +{ + QObject parent; + LipstickDBusInterface interface(&parent); + interface.showLockScreen(); + QCOMPARE(lipstickSettingsLockScreenVisible, true); + QCOMPARE(lipstickSettingsExternallyChanged, true); + interface.hideLockScreen(); + QCOMPARE(lipstickSettingsLockScreenVisible, false); + QCOMPARE(lipstickSettingsExternallyChanged, true); +} + +QTEST_MAIN(Ut_LipstickDBusInterface) --- tests/ut_lipstickdbusinterface/ut_lipstickdbusinterface.h +++ tests/ut_lipstickdbusinterface/ut_lipstickdbusinterface.h @@ -0,0 +1,28 @@ +/*************************************************************************** +** +** Copyright (C) 2012 Jolla Ltd. +** Contact: Robin Burchell <[email protected]> +** +** This file is part of lipstick. +** +** 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 UT_LIPSTICKDBUSINTERFACE_H +#define UT_LIPSTICKDBUSINTERFACE_H + +#include <QObject> + +class Ut_LipstickDBusInterface : public QObject +{ + Q_OBJECT + +private slots: + void testShowAndHideLockScreen(); +}; + +#endif --- tests/ut_lipstickdbusinterface/ut_lipstickdbusinterface.pro +++ tests/ut_lipstickdbusinterface/ut_lipstickdbusinterface.pro @@ -0,0 +1,13 @@ +include(../common.pri) +TARGET = ut_lipstickdbusinterface +QT += dbus + +# unit test and unit +SOURCES += \ + ut_lipstickdbusinterface.cpp \ + $$SRCDIR/lipstickdbusinterface.cpp + +# unit test and unit +HEADERS += \ + ut_lipstickdbusinterface.h \ + $$SRCDIR/lipstickdbusinterface.h --- tests/ut_lipsticksettings +++ tests/ut_lipsticksettings +(directory) --- tests/ut_lipsticksettings/ut_lipsticksettings.cpp +++ tests/ut_lipsticksettings/ut_lipsticksettings.cpp @@ -0,0 +1,117 @@ +/*************************************************************************** +** +** Copyright (C) 2012 Jolla Ltd. +** Contact: Robin Burchell <[email protected]> +** +** This file is part of lipstick. +** +** 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. +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include <QTimer> +#include <QDBusInterface> +#include <QDBusPendingCall> +#include "ut_lipsticksettings.h" +#include "lipsticksettings.h" +#include "homeapplication.h" + +int qTimerStartMsec = -1; +void QTimer::start(int msec) +{ + qTimerStartMsec = msec; + id = 1; +} + +void QTimer::stop() +{ + qTimerStartMsec = -1; + id = -1; +} + +HomeApplication *HomeApplication::instance() +{ + return 0; +} + +QDeclarativeView *homeApplicationMainWindowInstance = 0; +QDeclarativeView *HomeApplication::mainWindowInstance() +{ + return homeApplicationMainWindowInstance; +} + +QString qDBusConnectionAsyncCallService; +QString qDBusConnectionAsyncCallPath; +QString qDBusConnectionAsyncCallInterface; +QString qDBusConnectionAsyncCallMember; +QVariantList qDBusConnectionAsyncCallArguments; +QDBusPendingCall QDBusConnection::asyncCall(const QDBusMessage &message, int) const +{ + qDBusConnectionAsyncCallService = message.service(); + qDBusConnectionAsyncCallPath = message.path(); + qDBusConnectionAsyncCallInterface = message.interface(); + qDBusConnectionAsyncCallMember = message.member(); + qDBusConnectionAsyncCallArguments = message.arguments(); + return QDBusPendingCall::fromCompletedCall(QDBusMessage()); +} + +void Ut_LipstickSettings::initTestCase() +{ + homeApplicationMainWindowInstance = new QDeclarativeView; +} + +void Ut_LipstickSettings::cleanupTestCase() +{ + delete homeApplicationMainWindowInstance; +} + +void Ut_LipstickSettings::testSetLockScreenVisible() +{ + LipstickSettings settings; + + // Externally making lock screen visible should not start the timer + settings.setLockscreenVisible(true, true); + QCOMPARE(qTimerStartMsec, -1); + settings.setLockscreenVisible(false, true); + + // Internally making lock screen visible should start the timer + settings.setLockscreenVisible(true, false); + QCOMPARE(qTimerStartMsec, 5000); + + // Externally making lock screen invisible should stop the timer + settings.setLockscreenVisible(false, true); + QCOMPARE(qTimerStartMsec, -1); + + // Internally making lock screen invisible should stop the timer + settings.setLockscreenVisible(true, false); + settings.setLockscreenVisible(false, false); + QCOMPARE(qTimerStartMsec, -1); + + // Making the lock screen visible twice should not start the timer twice + settings.setLockscreenVisible(true, false); + qTimerStartMsec = -1; + settings.setLockscreenVisible(true, false); + QCOMPARE(qTimerStartMsec, -1); +} + +void Ut_LipstickSettings::testRequestScreenToBeLocked() +{ + LipstickSettings settings; + connect(this, SIGNAL(timeout()), &settings, SLOT(requestScreenToBeLocked())); + + emit timeout(); + + QCOMPARE(qDBusConnectionAsyncCallService, QString("com.nokia.mce")); + QCOMPARE(qDBusConnectionAsyncCallPath, QString("/com/nokia/mce/request")); + QCOMPARE(qDBusConnectionAsyncCallInterface, QString("com.nokia.mce.request")); + QCOMPARE(qDBusConnectionAsyncCallMember, QString("req_tklock_mode_change")); + QCOMPARE(qDBusConnectionAsyncCallArguments.count(), 1); + QCOMPARE(qDBusConnectionAsyncCallArguments.last(), QVariant("locked")); +} + +QTEST_MAIN(Ut_LipstickSettings) --- tests/ut_lipsticksettings/ut_lipsticksettings.h +++ tests/ut_lipsticksettings/ut_lipsticksettings.h @@ -0,0 +1,34 @@ +/*************************************************************************** +** +** Copyright (C) 2012 Jolla Ltd. +** Contact: Robin Burchell <[email protected]> +** +** This file is part of lipstick. +** +** 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 UT_LIPSTICKSETTINGS_H +#define UT_LIPSTICKSETTINGS_H + +#include <QObject> + +class Ut_LipstickSettings : public QObject +{ + Q_OBJECT + +signals: + void timeout(); + +private slots: + void initTestCase(); + void cleanupTestCase(); + void testSetLockScreenVisible(); + void testRequestScreenToBeLocked(); +}; + +#endif --- tests/ut_lipsticksettings/ut_lipsticksettings.pro +++ tests/ut_lipsticksettings/ut_lipsticksettings.pro @@ -0,0 +1,16 @@ +include(../common.pri) +TARGET = ut_lipsticksettings +QT += dbus declarative +CONFIG += link_pkgconfig mobility +PKGCONFIG += x11 +MOBILITY += sensors + +# unit test and unit +SOURCES += \ + ut_lipsticksettings.cpp \ + $$SRCDIR/lipsticksettings.cpp + +# unit test and unit +HEADERS += \ + ut_lipsticksettings.h \ + $$SRCDIR/lipsticksettings.h ++++++ lipstick.yaml --- lipstick.yaml +++ lipstick.yaml @@ -1,6 +1,6 @@ Name: lipstick Summary: QML toolkit for homescreen creation -Version: 0.4.2 +Version: 0.4.3 Release: 1 Group: System/Libraries License: LGPLv2.1
