Skip to content

Commit

Permalink
Add poweroff dialog (button&query) to the status menu
Browse files Browse the repository at this point in the history
Implements task NEMO#74: Add poweroff dialog to systemui
  • Loading branch information
sledges committed Aug 20, 2012
1 parent cd3d11d commit ddbbde3
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 1 deletion.
21 changes: 21 additions & 0 deletions src/systemui/statusindicatormenu/statusindicatormenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
**
****************************************************************************/
#include <MApplicationIfProxy>
#include <MMessageBox>
#include "statusindicatormenu.h"
#include "statusindicatormenudropdownview.h"

Expand All @@ -25,6 +26,9 @@ const QString StatusIndicatorMenu::CONTROL_PANEL_SERVICE_NAME = "com.nokia.DuiCo
StatusIndicatorMenu::StatusIndicatorMenu(QGraphicsItem *parent) :
MApplicationMenu()
{
#ifdef HAVE_QMSYSTEM
m_State = NULL;
#endif
Q_UNUSED(parent);
}

Expand All @@ -51,6 +55,23 @@ void StatusIndicatorMenu::launchControlPanelAndHide()
hideStatusIndicatorMenu();
}

void StatusIndicatorMenu::launchPowerOffDialog()
{
// % "Are you sure you want to power off the device?"
MMessageBox box(qtTrId("qtn_stat_menu_poweroff_query"), M::YesButton | M::NoButton);
int result = box.exec();
if (result == QMessageBox::Yes) {
#ifdef HAVE_QMSYSTEM
if (m_State == NULL) {
m_State = new MeeGo::QmSystemState(this);

This comment has been minimized.

Copy link
@ionakka

ionakka Aug 20, 2012

Would be good practice to add deletion into destructor.

}
m_State->set(MeeGo::QmSystemState::ShuttingDown);
#else
start("halt -p");
#endif
}
}

void StatusIndicatorMenu::showStatusIndicatorMenu()
{
emit showRequested();
Expand Down
15 changes: 15 additions & 0 deletions src/systemui/statusindicatormenu/statusindicatormenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
#include <MApplicationMenu>
#include "mstatusindicatormenuextensioninterface.h"

#ifdef HAVE_QMSYSTEM
#include <qmsystemstate.h>
#endif

class StatusIndicatorMenuWindow;

/*!
Expand Down Expand Up @@ -73,11 +77,22 @@ private slots:
*/
void launchControlPanelAndHide();

/*!
* \brief Slot for getting information about poweroff button clicks
*/
void launchPowerOffDialog();


private: // methods

//! The name of the control panel service
const static QString CONTROL_PANEL_SERVICE_NAME;

#ifdef HAVE_QMSYSTEM
//! System state
MeeGo::QmSystemState *m_State;
#endif

#ifdef UNIT_TEST
friend class Ut_StatusIndicatorMenu;
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,22 @@ QGraphicsWidget* StatusIndicatorMenuDropDownView::createTopRow()
settingsButton->setIconID("icon-m-status-menu-settings");
connect(settingsButton, SIGNAL(clicked()), controller, SLOT(launchControlPanelAndHide()));

// Put the extension area and the settings button to a horizontal layout
// Create a button for triggering the powerOff dialog
//% "Power off"
MButton *powerOffButton = new MButton(qtTrId("qtn_stat_menu_poweroff"));
powerOffButton->setObjectName("StatusIndicatorMenuTopRowExtensionButton");
powerOffButton->setViewType(MButton::iconType);
powerOffButton->setIconID("icon-m-status-menu-poweroff");
connect(powerOffButton, SIGNAL(clicked()), controller, SLOT(launchPowerOffDialog()));

// Put the extension area and the buttons to a horizontal layout
QGraphicsLinearLayout *topRowLayout = new QGraphicsLinearLayout(Qt::Horizontal);
topRowLayout->setContentsMargins(0, 0, 0, 0);
topRowLayout->setSpacing(0);
topRowLayout->addStretch();
topRowLayout->addItem(settingsPluginsExtensionArea);
topRowLayout->addItem(settingsButton);
topRowLayout->addItem(powerOffButton);
topRowLayout->addStretch();

// Create a container widget for extension area and settings button layout
Expand Down
3 changes: 3 additions & 0 deletions src/systemui/systemui.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
<allow send_destination="com.nokia.mce"
send_interface="com.nokia.mce.request"
send_member="tklock_callback" />
<allow send_destination="com.nokia.dsme"
send_interface="com.nokia.dsme.request"
send_member="req_shutdown" />
</policy>

</busconfig>
Expand Down
9 changes: 9 additions & 0 deletions tests/stubs/statusindicatormenu_stub.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class StatusIndicatorMenuStub : public StubBase {
virtual void hideStatusIndicatorMenu();
virtual void setStatusIndicatorMenuInterface(MApplicationExtensionInterface *extension);
virtual void launchControlPanelAndHide();
virtual void launchPowerOffDialog();
};

// 2. IMPLEMENT STUB
Expand Down Expand Up @@ -44,6 +45,10 @@ void StatusIndicatorMenuStub::launchControlPanelAndHide() {
stubMethodEntered("launchControlPanelAndHide");
}

void StatusIndicatorMenuStub::launchPowerOffDialog() {
stubMethodEntered("launchPowerOffDialog");
}


// 3. CREATE A STUB INSTANCE
StatusIndicatorMenuStub gDefaultStatusIndicatorMenuStub;
Expand Down Expand Up @@ -76,4 +81,8 @@ void StatusIndicatorMenu::launchControlPanelAndHide() {
gStatusIndicatorMenuStub->launchControlPanelAndHide();
}

void StatusIndicatorMenu::launchPowerOffDialog() {
gStatusIndicatorMenuStub->launchPowerOffDialog();
}

#endif
8 changes: 8 additions & 0 deletions tests/ut_statusindicatormenu/ut_statusindicatormenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ void Ut_StatusIndicatorMenu::init()
{
statusIndicatorMenu = new StatusIndicatorMenu();
connect(this, SIGNAL(settingsButtonClicked()), statusIndicatorMenu, SLOT(launchControlPanelAndHide()));
connect(this, SIGNAL(powerOffButtonClicked()), statusIndicatorMenu, SLOT(launchPowerOffDialog()));
connect(this, SIGNAL(extensionInstantiated(MApplicationExtensionInterface*)), statusIndicatorMenu, SLOT(setStatusIndicatorMenuInterface(MApplicationExtensionInterface*)));
}

Expand Down Expand Up @@ -98,6 +99,13 @@ void Ut_StatusIndicatorMenu::testSettingsButtonClicked()
QVERIFY(mApplicationIfProxyLaunchCalled);
}

void Ut_StatusIndicatorMenu::testPowerOffButtonClicked()
{
emit powerOffButtonClicked();

QVERIFY(mApplicationIfProxyLaunchCalled);
}

void Ut_StatusIndicatorMenu::testExtensionInstantiated()
{
TestStatusIndicatorMenuExtensionInterface extension;
Expand Down
2 changes: 2 additions & 0 deletions tests/ut_statusindicatormenu/ut_statusindicatormenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class Ut_StatusIndicatorMenu : public QObject

signals:
void settingsButtonClicked();
void powerOffButtonClicked();
void extensionInstantiated(MApplicationExtensionInterface*);

private:
Expand All @@ -49,6 +50,7 @@ private slots:

// Test cases
void testSettingsButtonClicked();
void testPowerOffButtonClicked();
void testExtensionInstantiated();
void testSignals();
};
Expand Down

0 comments on commit ddbbde3

Please sign in to comment.