![]() |
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 00020 #include <MSceneManager> 00021 #include <MScene> 00022 #include "statusindicatormenuwindow.h" 00023 #include "statusindicatormenu.h" 00024 #include <MLocale> 00025 00026 StatusIndicatorMenuWindow::StatusIndicatorMenuWindow(QWidget *parent) : 00027 MWindow(parent), 00028 menuWidget(NULL) 00029 { 00030 currentLanguage = MLocale().language(); 00031 00032 setTranslucentBackground(true); 00033 setWindowTitle("Status Indicator Menu"); 00034 setProperty("followsCurrentApplicationWindowOrientation", true); 00035 connect(this, SIGNAL(displayEntered()), this, SLOT(displayActive())); 00036 connect(this, SIGNAL(displayExited()), this, SLOT(displayInActive())); 00037 00038 #ifdef HAVE_QMSYSTEM 00039 /* 00040 * We need to receive updates when device lock state changes 00041 * to prevent status indicator menu opening when device lock is on 00042 */ 00043 connect (&qmLocks, SIGNAL(stateChanged (MeeGo::QmLocks::Lock, MeeGo::QmLocks::State)), this, 00044 SLOT(setWindowStateAccordingToDeviceLockState(MeeGo::QmLocks::Lock, MeeGo::QmLocks::State))); 00045 if (qmLocks.getState(MeeGo::QmLocks::Device) != MeeGo::QmLocks::Locked) { 00046 deviceLocked = false; 00047 } else { 00048 deviceLocked = true; 00049 } 00050 #endif 00051 00052 // Set the X window type, so that the window does not appear in the switcher and 00053 // home screen can provide the correct UI flow 00054 setAttribute(Qt::WA_X11NetWmWindowTypeMenu); 00055 00056 resetMenuWidget(); 00057 } 00058 00059 StatusIndicatorMenuWindow::~StatusIndicatorMenuWindow() 00060 { 00061 } 00062 00063 void StatusIndicatorMenuWindow::resetMenuWidget() 00064 { 00065 if (menuWidget) { 00066 sceneManager()->dismissSceneWindowNow(menuWidget); 00067 } 00068 00069 menuWidget = new StatusIndicatorMenu(); 00070 // The scene takes ownership of menuWidget 00071 sceneManager()->appearSceneWindowNow(menuWidget, MSceneWindow::DestroyWhenDismissed); 00072 00073 connect(menuWidget, SIGNAL(showRequested()), this, SLOT(makeVisible())); 00074 connect(menuWidget, SIGNAL(hideRequested()), this, SLOT(hide())); 00075 } 00076 00077 void StatusIndicatorMenuWindow::displayActive() 00078 { 00079 emit visibilityChanged(true); 00080 } 00081 00082 void StatusIndicatorMenuWindow::displayInActive() 00083 { 00084 emit visibilityChanged(false); 00085 // Hide the window when the it is obscured by another view 00086 // Note: Dialogs and notifications won't close it anyways, 00087 // as they are not supposed to be full screen and don't completely 00088 // obstruct the status menu window fully. 00089 hide(); 00090 } 00091 00092 void StatusIndicatorMenuWindow::makeVisible() 00093 { 00094 #ifdef HAVE_QMSYSTEM 00095 if (deviceLocked) { 00096 return; 00097 } 00098 #endif 00099 if (!isVisible()) { 00100 // If status indicator window is not visible, then show it 00101 show(); 00102 } 00103 00104 // Raise it on top 00105 raise(); 00106 } 00107 00108 #ifdef HAVE_QMSYSTEM 00109 void StatusIndicatorMenuWindow::setWindowStateAccordingToDeviceLockState(MeeGo::QmLocks::Lock what, MeeGo::QmLocks::State how) 00110 { 00111 if (what == MeeGo::QmLocks::Device) { 00112 if (how == MeeGo::QmLocks::Unlocked) { 00113 deviceLocked = false; 00114 } else { 00115 deviceLocked = true; 00116 if (isVisible()) { 00117 hide(); 00118 } 00119 } 00120 } 00121 } 00122 00123 #endif 00124 00125 bool StatusIndicatorMenuWindow::event(QEvent *event) 00126 { 00127 bool windowIsHandlingEvent = MWindow::event(event); 00128 // Recreate status menu widget when language changes and window is handling the language change 00129 if (event->type() == QEvent::LanguageChange && windowIsHandlingEvent) { 00130 QString newLanguage = MLocale().language(); 00131 // Check that language actually changed to avoid unnecessary resets 00132 if (currentLanguage != newLanguage) { 00133 currentLanguage = newLanguage; 00134 resetMenuWidget(); 00135 } 00136 } 00137 return windowIsHandlingEvent; 00138 }
| Copyright © 2010 Nokia Corporation | Generated on Wed Nov 10 16:04:52 2010 Doxygen 1.6.1 |
MeeGo Touch |
