![]() |
Home · All Namespaces · All Classes |
00001 /**************************************************************************** 00002 ** 00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 00004 ** All rights reserved. 00005 ** Contact: Nokia Corporation (directui@nokia.com) 00006 ** 00007 ** This file is part of systemui. 00008 ** 00009 ** If you have questions regarding the use of this file, please contact 00010 ** Nokia at directui@nokia.com. 00011 ** 00012 ** This library is free software; you can redistribute it and/or 00013 ** modify it under the terms of the GNU Lesser General Public 00014 ** License version 2.1 as published by the Free Software Foundation 00015 ** and appearing in the file LICENSE.LGPL included in the packaging 00016 ** of this file. 00017 ** 00018 ****************************************************************************/ 00019 #include "shutdownui.h" 00020 #include "sysuid.h" 00021 00022 #include <MLabel> 00023 #include <MFeedback> 00024 #include <MApplication> 00025 #include <QTimer> 00026 #include <QGraphicsLinearLayout> 00027 #include <MSceneManager> 00028 #include <MStylableWidget> 00029 #include <MLocale> 00030 00031 #ifdef HAVE_QMSYSTEM 00032 #include <qmdisplaystate.h> 00033 #endif 00034 00035 #include "mwidgetcreator.h" 00036 M_REGISTER_WIDGET_NO_CREATE(ShutdownUI) 00037 00038 // For WM_SET_NAME: 00039 #include <X11/Xlib.h> 00040 #include <X11/Xatom.h> 00041 00042 ShutdownUI::ShutdownUI () : 00043 m_Realized (false), 00044 m_SceneWindow (0), 00045 m_Timer (new QTimer), 00046 m_Label1 (0), 00047 m_Label2 (0), 00048 m_logo (0), 00049 m_layout (0), 00050 m_Feedback (0) 00051 { 00052 setObjectName ("ShutdownUIWindow"); 00053 /* 00054 * We have to pre-created/load the shutdown ui content because when it 00055 * should show, the in should show quickly 00056 */ 00057 QTimer::singleShot (500, this, SLOT (realize())); 00058 00059 connect (m_Timer, SIGNAL (timeout ()), 00060 this, SLOT (showLogo ())); 00061 } 00062 00063 ShutdownUI::~ShutdownUI () 00064 { 00065 delete m_Timer; 00066 00067 if (m_SceneWindow) { 00068 delete m_SceneWindow; 00069 } 00070 // FIXME: What about m_Feedback? 00071 } 00072 00073 /* 00074 * Here we create the widgets that we use, and we put them into the layout that 00075 * we use. The logo will not be shown yet. 00076 */ 00077 void 00078 ShutdownUI::realize () 00079 { 00080 if (m_Realized) 00081 return; 00082 00083 // Initilaize non-graphical feedback 00084 m_Feedback = new MFeedback (this); 00085 m_Feedback->setName ("power-off"); 00086 00087 //% "Shutting down" 00088 m_Label1 = new MLabel (qtTrId ("qtn_shut_down")); 00089 m_Label1->setAlignment (Qt::AlignCenter); 00090 m_Label1->setObjectName ("shutdownTextFirst"); 00091 00092 //% "Good bye!" 00093 m_Label2 = new MLabel (qtTrId ("qtn_shut_greeting")); 00094 m_Label2->setAlignment (Qt::AlignCenter); 00095 m_Label2->setObjectName ("shutdownTextSecond"); 00096 00097 /* 00098 * A full screen logo that we show when the labels are already gone. 00099 */ 00100 m_logo = new MStylableWidget; 00101 m_logo->setObjectName ("shutdownLogo"); 00102 00103 m_layout = new QGraphicsLinearLayout (Qt::Vertical); 00104 m_layout->setContentsMargins (0., 0., 0., 0.); 00105 m_layout->setSpacing (0.); 00106 00107 m_layout->addItem (m_Label1); 00108 m_layout->addItem (m_Label2); 00109 00110 /* 00111 * Creating a scene window and putting everything into it. 00112 */ 00113 m_SceneWindow = new MSceneWindow; 00114 m_SceneWindow->setObjectName ("shutdownWindow"); 00115 m_SceneWindow->setContentsMargins (0., 0., 0., 0.); 00116 m_SceneWindow->setLayout (m_layout); 00117 m_SceneWindow->appear (this); 00118 00119 m_Realized = true; 00120 } 00121 00122 // Hack for RFS/CUD 00123 #ifdef NOTDEFINED 00124 static const char * const ids [] = 00125 { 00126 //% "Restoring settings" 00127 QT_TRID_NOOP("qtn_rset_restore_down"), 00128 //% "Clearing device" 00129 QT_TRID_NOOP("qtn_rset_clear_down"), 00130 //% "Please wait!" 00131 QT_TRID_NOOP("qtn_rset_wait"), 00132 0, 00133 }; 00134 #endif 00135 00145 void 00146 ShutdownUI::showWindow ( 00147 const QString &text1, 00148 const QString &text2, 00149 int timeout) 00150 { 00151 /* 00152 * If the widgets are not created we create them now. 00153 */ 00154 if (!m_Realized) 00155 realize (); 00156 00157 /* 00158 * We set the labels to show the text strings that we got. 00159 */ 00160 if (! (text1.isEmpty () && text2.isEmpty ())) { 00161 if (text1.startsWith ("qtn")) 00162 m_Label1->setText (qtTrId (text1.toLatin1 ().constData ())); 00163 else 00164 m_Label1->setText (text1); 00165 00166 if (text2.startsWith ("qtn")) 00167 m_Label2->setText (qtTrId (text2.toLatin1 ().constData ())); 00168 else 00169 m_Label2->setText (text2); 00170 } 00171 00172 00173 // Stop the previous timer... 00174 m_Timer->stop (); 00175 00176 /* 00177 * It is as simple as this when we use MWindow. 00178 */ 00179 show (); 00180 00181 m_Feedback->play (); 00182 00183 // Set the interval and start the timer to the next phase: hiding the labels 00184 // and showing the logo. 00185 m_Timer->setInterval (timeout); 00186 m_Timer->start (); 00187 } 00188 00189 /* 00190 * Hides the labels, shows the logo image and starts up a timer to turn off the 00191 * screen. 00192 */ 00193 void 00194 ShutdownUI::showLogo () 00195 { 00196 m_Timer->stop (); 00197 00198 /* 00199 * We hide the labels and show the image. 00200 */ 00201 for (int i = m_layout->count (); i > 0; i--) 00202 m_layout->removeAt (0); 00203 00204 #if 0 00205 /* Logo available only for portait ATM */ 00206 sceneManager ()->setOrientationAngle (M::Angle0, MSceneManager::ImmediateTransition); 00207 lockOrientation (); 00208 #endif 00209 00210 m_layout->addItem (m_logo); 00211 00212 delete m_Label1; 00213 delete m_Label2; 00214 00215 QTimer::singleShot (2000, this, SLOT (turnOffScreen ())); 00216 } 00217 00225 void 00226 ShutdownUI::turnOffScreen () 00227 { 00228 bool success = false; 00229 00230 /* 00231 * No way dimming or turning off the screen inside scratchbox. 00232 */ 00233 #if defined(HAVE_QMSYSTEM) 00234 MeeGo::QmDisplayState display; 00235 00236 // Try to dim 00237 success = display.set (MeeGo::QmDisplayState::Dimmed); 00238 00239 // Try to turn off 00240 success = display.set (MeeGo::QmDisplayState::Off); 00241 #endif 00242 00243 if (!success) { 00244 QPalette Palette (palette()); 00245 00246 Palette.setColor(QPalette::Background, QColor ("black")); 00247 setPalette(Palette); 00248 00249 setBackgroundRole (QPalette::Background); 00250 m_logo->hide (); 00251 } 00252 } 00253 00254 /* 00255 * Set the highest stacking layer here 00256 * and the window-name for debugging purposes 00257 */ 00258 void 00259 ShutdownUI::showEvent ( 00260 QShowEvent *event) 00261 { 00262 Q_UNUSED (event); 00263 00264 Window windowID; 00265 Display *display; 00266 Atom nameAtom; 00267 Atom utf8StringAtom; 00268 Atom stackingLayerAtom; 00269 const char *windowName = "ShutdownUI"; 00270 long layer = 6; 00271 00272 display = QX11Info::display (); 00273 if (!display) { 00274 return; 00275 } 00276 00277 stackingLayerAtom = XInternAtom (display, "_MEEGO_STACKING_LAYER", False); 00278 nameAtom = XInternAtom (display, "_NET_WM_NAME", False); 00279 utf8StringAtom = XInternAtom (display, "UTF8_STRING", False); 00280 00281 windowID = internalWinId(); 00282 if (windowID == None) { 00283 return; 00284 } 00285 00286 /* 00287 * Setting the stacking layer. 00288 */ 00289 if (stackingLayerAtom != None) 00290 XChangeProperty (display, windowID, stackingLayerAtom, XA_CARDINAL, 00291 32, PropModeReplace, (unsigned char*)&layer, 1); 00292 00293 /* 00294 * Setting the name. 00295 */ 00296 if (nameAtom != None && utf8StringAtom != None) 00297 XChangeProperty (display, windowID, nameAtom, utf8StringAtom, 00298 8, PropModeReplace, 00299 (unsigned char *) windowName, strlen(windowName)); 00300 } 00301
| Copyright © 2010 Nokia Corporation | Generated on Thu Nov 4 2010 18:19:34 Doxygen 1.7.1 |
MeeGo Touch |
