int MDateTimeHelper::hourMode() { bool format12h = false; #if defined(Q_OS_WIN) wchar_t data[10]; GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STIMEFORMAT, data, 10); format12h = QString::fromWCharArray(data).startsWith(QLatin1Char('h')); #elif defined(HAVE_MEEGOTOUCH) format12h = (MLocale().timeFormat24h() == MLocale::TwelveHourTimeFormat24h ? true : (MLocale().timeFormat24h() == MLocale::TwentyFourHourTimeFormat24h ? false : MLocale().defaultTimeFormat24h() == MLocale::TwelveHourTimeFormat24h)); #endif return format12h ? TwelveHours : TwentyFourHours; }
bool StatusIndicatorMenuWindow::event(QEvent *event) { bool windowIsHandlingEvent = MWindow::event(event); // Recreate status menu widget when language changes and window is handling the language change if (event->type() == QEvent::LanguageChange && windowIsHandlingEvent) { QString newLanguage = MLocale().language(); // Check that language actually changed to avoid unnecessary resets if (currentLanguage != newLanguage) { currentLanguage = newLanguage; resetMenuWidget(); } } return windowIsHandlingEvent; }
StatusIndicatorMenuWindow::StatusIndicatorMenuWindow(QWidget *parent) : MWindow(parent), statusBar(new MStatusBar), menuWidget(NULL) { QDBusConnection bus = QDBusConnection::sessionBus(); bus.registerService(SERVICE_NAME); bus.registerObject(OBJECT_NAME, this, QDBusConnection::ExportScriptableSlots); // Show status bar setSceneManager(new MSceneManager); sceneManager()->appearSceneWindowNow(statusBar); currentLanguage = MLocale().language(); statusBar->setStyleName("StatusIndicatorMenuWindowStatusBar"); // Set the X window type, so that the window does not appear in the switcher and // home screen can provide the correct UI flow setAttribute(Qt::WA_X11NetWmWindowTypeMenu); setTranslucentBackground(true); setWindowTitle("Status Indicator Menu"); setProperty("followsCurrentApplicationWindowOrientation", true); connect(this, SIGNAL(displayEntered()), this, SLOT(displayActive())); connect(this, SIGNAL(displayExited()), this, SLOT(displayInActive())); #ifdef HAVE_QMSYSTEM /* * We need to receive updates when device lock state changes * to prevent status indicator menu opening when device lock is on */ connect (&qmLocks, SIGNAL(stateChanged (MeeGo::QmLocks::Lock, MeeGo::QmLocks::State)), this, SLOT(setWindowStateAccordingToDeviceLockState(MeeGo::QmLocks::Lock, MeeGo::QmLocks::State))); if (qmLocks.getState(MeeGo::QmLocks::Device) != MeeGo::QmLocks::Locked) { deviceLocked = false; } else { deviceLocked = true; } #endif resetMenuWidget(); }
MLocale MLocale::createCLocale() { const char *const PosixStr = "en_US_POSIX"; return MLocale(PosixStr); }