Beispiel #1
0
void WifiTitleItem::createDashBoard()
{
    ODatas datas;
    ODataPtr customize (new OData);
    customize->insert(TAG_COVER, QPixmap(":/images/customize.png"));
    customize->insert(TAG_ID, ID_CUSTOMIZE);
    datas.push_back(customize);

    ODataPtr refresh (new OData);
    refresh->insert(TAG_COVER, QPixmap(":/images/refresh.png"));
    refresh->insert(TAG_ID, ID_REFRESH);

    datas.push_back(refresh);

    dash_board_.setFixedGrid(1, datas.size());
    dash_board_.setData(datas);
    dash_board_.setSubItemBkColor(Qt::transparent);
}
void PowerManagementDialog::createLayout()
{
    content_widget_.setBackgroundRole(QPalette::Button);

    // Retrieve the values from system status.
    sys_standby_interval_ = status_.suspendInterval();
    standby_interval_ = sys_standby_interval_;

    sys_shutdown_interval_ = status_.shutdownInterval();
    shutdown_interval_ = sys_shutdown_interval_;

    updateTitle(QApplication::tr("Power Management"));
    updateTitleIcon(QPixmap(":/images/power.png"));

    // The big layout.
    ver_layout_.setContentsMargins(SPACING, 0, SPACING, 0);
    ver_layout_.addSpacing(10);

    QString t(tr("Battery remaining %1%"));
    int left = 100, status = 0;
    status_.batteryStatus(left, status);
    t = t.arg(left);

    if (isPmExclusive())
    {
        t.clear();
    }
    battery_power_.setText(t);
    ver_layout_.addWidget(&battery_power_);

    // Create display items
    buttons_.setSubItemType(CheckBoxView::type());
    buttons_.setMargin(2, 2, 2, 2);
    buttons_.setPreferItemSize(QSize(0, ITEM_HEIGHT));
    ODatas d;

    const ItemStruct *ITEMS;
    int display_cout;
    if ( qgetenv("CUSTOM_PM").toInt() == 1 )
    {
        display_cout = isPmExclusive() ? 4: ICARUS_DISPLAY_COUNT;
        ITEMS = ICARUS_DISPLAY_ITEMS;
    }
    else
    {
        display_cout = isPmExclusive() ? 4: DISPLAY_COUNT;
        ITEMS = DISPLAY_ITEMS;
    }
    for (int row = 0; row < display_cout; ++row)
    {
        if ( qgetenv("DISABLE_NEVER_STANDBY_SHUTDOWN").toInt() > 0 &&
             ITEMS[row].standby_seconds == 0 &&
             ITEMS[row].shutdown_seconds == 0)
        {
            continue;
        }
        OData * item = new OData;
        item->insert(TAG_TITLE, qApp->translate(SCOPE, ITEMS[row].title));
        item->insert(TITLE_INDEX, row);
        if ( (sys_standby_interval_ == ITEMS[row].standby_seconds) &&
             (sys_shutdown_interval_ == ITEMS[row].shutdown_seconds)
           )
        {
            interval_selected_ = item;
            item->insert(TAG_CHECKED, true);
        }
        d.push_back(item);
    }

    buttons_.setData(d, true);
    buttons_.setMinimumHeight( (ITEM_HEIGHT+2)*d.size());
    buttons_.setFixedGrid(d.size(), 1);
    buttons_.setSpacing(3);
    QObject::connect(&buttons_, SIGNAL(itemActivated(CatalogView *, ContentView *, int)),
                     this, SLOT(onButtonChanged(CatalogView *, ContentView *, int)), Qt::QueuedConnection);

    ver_layout_.addWidget(&buttons_);


    // OK cancel buttons.
    ok_.setSubItemType(ui::CoverView::type());
    ok_.setPreferItemSize(QSize(100, 60));
    ODatas d2;

    OData * item = new OData;
    item->insert(TAG_TITLE, tr("OK"));
    item->insert(TITLE_INDEX, 1);
    d2.push_back(item);


    ok_.setData(d2, true);
    ok_.setMinimumHeight( 60 );
    ok_.setMinimumWidth(100);
    ok_.setFocusPolicy(Qt::TabFocus);
    ok_.setNeighbor(&buttons_, CatalogView::UP);
    connect(&ok_, SIGNAL(itemActivated(CatalogView *, ContentView *, int)), this, SLOT(onOkClicked()));

    hor_layout_.addStretch(0);
    hor_layout_.addWidget(&ok_);


    ver_layout_.addStretch(0);
    ver_layout_.addLayout(&hor_layout_);
    ver_layout_.addSpacing(8);
}