示例#1
0
// Check the buttons on the LCD shield
void CheckLCDButtons()
{
    gv_lcd_button = LCDbutton();

    // Only do one button event no matter how long button is held
    // down. Reset the button flag when button is released.
    if (gv_lcd_button != LCD_BTN_NONE) {
        displayActive();    // enable display if button pressed
        if (!gv_aux_button) {
            gv_aux_button = true;
            gv_show_adj = true;         // enable adj values display
            if (gv_lcd_button == LCD_BTN_SELECT) {
                resetGVData();
                gv_show_adj = false;    // but not for this
            }
            else if (gv_lcd_button == LCD_BTN_UP)
                gv_temp_adj += 0.5;
            else if (gv_lcd_button == LCD_BTN_DOWN)
                gv_temp_adj -= 0.5;
            else if (gv_lcd_button == LCD_BTN_RIGHT)
                gv_hum_adj++;
            else if (gv_lcd_button == LCD_BTN_LEFT)
                gv_hum_adj--;
        }
    }
    else {
        // if no button active then reset the button flag
        gv_aux_button = false;
    }
}
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();
}
void Ut_StatusIndicatorMenuWindow::testInitialization()
{
    QVERIFY(statusIndicatorMenuWindow->menuWidget);

    QVERIFY(disconnect(statusIndicatorMenuWindow, SIGNAL(displayExited()), statusIndicatorMenuWindow, SLOT(displayInActive())));
    QVERIFY(disconnect(statusIndicatorMenuWindow, SIGNAL(displayEntered()), statusIndicatorMenuWindow, SLOT(displayActive())));

    QVERIFY(disconnect(statusIndicatorMenuWindow->menuWidget, SIGNAL(showRequested()), statusIndicatorMenuWindow, SLOT(makeVisible())));
    QVERIFY(disconnect(statusIndicatorMenuWindow->menuWidget, SIGNAL(hideRequested()), statusIndicatorMenuWindow->menuWidget, SLOT(disappear())));
    QVERIFY(disconnect(statusIndicatorMenuWindow->menuWidget, SIGNAL(disappeared()), statusIndicatorMenuWindow, SLOT(hideWindow())));

    QVERIFY(gSceneWindowStateMap.contains(statusIndicatorMenuWindow->menuWidget));
    QCOMPARE(gSceneWindowStateMap[statusIndicatorMenuWindow->menuWidget], MSceneWindow::Disappeared);
}