示例#1
0
AlbumsFilterBar::AlbumsFilterBar( QGraphicsItem *parent, Qt::WindowFlags wFlags )
    : QGraphicsWidget( parent, wFlags )
    , m_editor( new KLineEdit )
    , m_closeIcon( new Plasma::IconWidget( KIcon("dialog-close"), QString(), this ) )
{
    QGraphicsProxyWidget *editProxy = new QGraphicsProxyWidget( this );
    editProxy->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
    editProxy->setWidget( m_editor );

    m_editor->installEventFilter( this );
    m_editor->setAttribute( Qt::WA_NoSystemBackground );
    m_editor->setAutoFillBackground( true );
    m_editor->setClearButtonShown( true );
    m_editor->setClickMessage( i18n( "Filter Albums" ) );
    m_editor->setContentsMargins( 0, 0, 0, 0 );

    QSizeF iconSize = m_closeIcon->sizeFromIconSize( 16 );
    m_closeIcon->setMaximumSize( iconSize );
    m_closeIcon->setMinimumSize( iconSize );

    QGraphicsLinearLayout *layout = new QGraphicsLinearLayout( Qt::Horizontal, this );
    layout->setSpacing( 1 );
    layout->addItem( editProxy );
    layout->addItem( m_closeIcon );
    layout->setStretchFactor( editProxy, 100 );
    layout->setAlignment( editProxy, Qt::AlignCenter );
    layout->setAlignment( m_closeIcon, Qt::AlignCenter );
    layout->setContentsMargins( 0, 2, 0, 0 );

    m_closeIcon->setToolTip( i18n( "Close" ) );
    connect( m_closeIcon, SIGNAL(clicked()), SIGNAL(closeRequested()) );
    connect( m_editor, SIGNAL(textChanged(QString)), SIGNAL(filterTextChanged(QString)) );
}
void PeopleApplication::initSearch()
{
    m_searchWidget = new MWidgetController;
    m_searchWidget->setViewType("background");
    m_searchWidget->setObjectName("PeopleSearch");
    m_searchWidget->setParentItem(m_mainPage);
    m_searchWidget->setZValue(1);
    m_searchWidget->hide();

    QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Horizontal, m_searchWidget);

    m_searchEdit = new MTextEdit;
    m_searchEdit->setObjectName("PeopleSearchEdit");
    m_searchEdit->setPrompt(QObject::tr("Tap to start searching people","Prompt for search bar text edit field"));
    layout->addItem(m_searchEdit);
    layout->setAlignment(m_searchEdit, Qt::AlignVCenter);
    connect(m_searchEdit, SIGNAL(returnPressed()), this, SLOT(searchCommit()));

    // uncomment this line to enable dynamic search
    //connect(m_searchEdit, SIGNAL(textChanged()), this, SLOT(searchChanged()));

    MButton *button = new MButton();
    button->setIconID("icon-m-framework-close-alt");
    button->setObjectName("PeopleSearchButton");
    layout->addItem(button);
    layout->setAlignment(button, Qt::AlignVCenter);
    connect(button, SIGNAL(clicked()), this, SLOT(searchClear()));

    button = new MButton(QObject::tr("<b>Search</b>","Toolbar button to launch search widget"));
    button->setObjectName("PeopleSearchButton");
    layout->addItem(button);
    layout->setAlignment(button, Qt::AlignVCenter);
    connect(button, SIGNAL(clicked()), this, SLOT(searchCommit()));
}
void ToolBarPage::setupCheckBoxes()
{
    QGraphicsLinearLayout *layoutCheckboxes = new QGraphicsLinearLayout(Qt::Vertical);
    layoutCheckboxes->setContentsMargins(0, 0, 0, 0);
    layoutCheckboxes->setSpacing(0);

    visibleBackButton = new MButton();
    visibleBackButton->setObjectName("visibleBackButton");
    visibleBackButton->setStyleName(inv("CommonRightCheckBox"));
    visibleBackButton->setViewType(MButton::checkboxType);
    visibleBackButton->setCheckable(true);
    visibleBackButton->setChecked(true);
    connect(visibleBackButton, SIGNAL(toggled(bool)), this, SLOT(setBackButtonVisible(bool)));
    visibleBackButtonLabel = new MLabel();
    visibleBackButtonLabel->setObjectName("visibleBackButtonLabel");
    visibleBackButtonLabel->setStyleName(inv("CommonSingleTitle"));
    visibleBackButtonLabel->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
    visibleBackButtonLabel->setWordWrap(false);
    visibleBackButtonLabel->setTextElide(true);

    visibleMenuButton = new MButton();
    visibleMenuButton->setObjectName("visibleMenuButton");
    visibleMenuButton->setStyleName(inv("CommonRightCheckBox"));
    visibleMenuButton->setViewType(MButton::checkboxType);
    visibleMenuButton->setCheckable(true);
    visibleMenuButton->setChecked(true);
    connect(visibleMenuButton, SIGNAL(toggled(bool)), this, SLOT(setMenuActionsVisible(bool)));
    visibleMenuButtonLabel = new MLabel();
    visibleMenuButtonLabel->setObjectName("visibleMenuButtonLabel");
    visibleMenuButtonLabel->setStyleName(inv("CommonSingleTitle"));
    visibleMenuButtonLabel->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
    visibleMenuButtonLabel->setWordWrap(false);
    visibleMenuButtonLabel->setTextElide(true);

    QGraphicsLinearLayout *layoutBackCheckbox = new QGraphicsLinearLayout(Qt::Horizontal);
    layoutBackCheckbox->setContentsMargins(0, 0, 0, 0);
    layoutBackCheckbox->setSpacing(0);
    layoutBackCheckbox->addItem(visibleBackButtonLabel);
    layoutBackCheckbox->addItem(visibleBackButton);
    layoutBackCheckbox->setAlignment(visibleBackButtonLabel, Qt::AlignCenter);
    layoutBackCheckbox->setAlignment(visibleBackButton, Qt::AlignCenter);
    layoutCheckboxes->addItem(layoutBackCheckbox);

    QGraphicsLinearLayout *layoutMenuCheckbox = new QGraphicsLinearLayout(Qt::Horizontal);
    layoutMenuCheckbox->setContentsMargins(0, 0, 0, 0);
    layoutMenuCheckbox->setSpacing(0);
    layoutMenuCheckbox->addItem(visibleMenuButtonLabel);
    layoutMenuCheckbox->addItem(visibleMenuButton);
    layoutMenuCheckbox->setAlignment(visibleMenuButtonLabel, Qt::AlignCenter);
    layoutMenuCheckbox->setAlignment(visibleMenuButton, Qt::AlignCenter);
    layoutCheckboxes->addItem(layoutMenuCheckbox);

    containerPolicy->addItem(layoutCheckboxes);
}
ProfileContainer::ProfileContainer (
        int            id, 
        const QString &title, 
        bool           vibra, 
        MWidget     *parent) :
    MWidgetController (parent),
    m_ProfileId (id),
    m_Button(0),
    m_Label(0)
{
    QGraphicsLinearLayout *layout;
    
    /*
     * The layout.
     */
    layout = new QGraphicsLinearLayout (Qt::Horizontal, this);
    layout->setContentsMargins (0., 0., 0., 0.);
    SYS_DEBUG ("Creating container for %s", SYS_STR(title)); 

    /*
     * The switch button.
     */
    m_Button = new MButton;
    m_Button->setCheckable (true);
    m_Button->setViewType (MButton::switchType);
    m_Button->setStyleName ("CommonRightSwitchInverted");
    m_Button->setChecked (vibra);
    connect (m_Button, SIGNAL (toggled (bool)),
             this, SIGNAL (toggled (bool)));

    /*
     * The label.
     */
    m_Label = new MLabel (title);
    m_Label->setStyleName ("CommonSingleTitleInverted");

    /*
     * Adding these things together.
     */
    layout->addItem (m_Label);
    layout->addItem (m_Button);

    layout->setAlignment (m_Label, Qt::AlignVCenter | Qt::AlignLeft);
    layout->setAlignment (m_Button, Qt::AlignVCenter | Qt::AlignLeft);

    setLayout (layout);

    setContentsMargins (0., 0., 0., 0.);
    setStyleName ("CommonPanelInverted");

    setActive (false);
}
示例#5
0
int HGLayout::insertItem(QGraphicsLayoutItem* item, const HLayoutConfig& conf)
{
    if (!layout()) return -1;

    switch (layoutType()) {
    case HEnums::kVBox:
    case HEnums::kHBox: {
        QGraphicsLinearLayout* l = static_cast<QGraphicsLinearLayout*>(layout());
        l->insertItem(conf.index(),item);
        l->setAlignment(item,alignment());
        break;
    }
    case HEnums::kGrid: {
        QGraphicsGridLayout* l = static_cast<QGraphicsGridLayout*>(layout());
        l->addItem(item,conf.row(),conf.column(),alignment());
        break;
    }
    case HEnums::kAnchor: {
        //anchor layout can't add item here, add item in setAnchor
        QGraphicsAnchorLayout* l = static_cast<QGraphicsAnchorLayout*>(layout());
        Q_UNUSED(l);

        return -1;
    }
    default:
        return -1;
    }
    return 0;
}
/*!
    creates the heading wiget elements that include
    a label for showing the current path and a push button for
    going to the parent directory.
*/
void FmFileDialogPrivate::createHeadingWidget()
{
    mHeadingWidget = new HbWidget( mFileDialog );
    mHeadingWidget->setObjectName( "headingWidget" ); 

    QGraphicsLinearLayout *headingLayout = new QGraphicsLinearLayout;
    headingLayout->setOrientation(Qt::Horizontal);
    mHeadingWidget->setLayout(headingLayout);
    

    QGraphicsLinearLayout *titleLayout = new QGraphicsLinearLayout;
    titleLayout->setOrientation(Qt::Vertical);    

    mTitleLabel = new HbLabel();
    mTitleLabel->setObjectName( "titleLabel" );
    if( mArgs.mTitle.isEmpty() ){
        mTitleLabel->setPlainText( QString( FmPlaceholderString ) );
    } else {
        mTitleLabel->setPlainText( mArgs.mTitle );
    }

    mCurrentPathLabel = new HbLabel( QString( FmPlaceholderString ) );
    mCurrentPathLabel->setObjectName( "currentPathLabel" );
    mCurrentPathLabel->setElideMode(Qt::ElideRight);

    mUpButton  = new HbPushButton;
    mUpButton->setObjectName( "upButton" );
    mUpButton->setIcon(HbIcon(backButtonIcon));

    titleLayout->addItem( mTitleLabel );
    titleLayout->setAlignment( mTitleLabel, Qt::AlignLeft);

    titleLayout->addItem( mCurrentPathLabel );
    titleLayout->setAlignment( mCurrentPathLabel, Qt::AlignLeft);

    headingLayout->addItem(titleLayout);
    headingLayout->addItem( mUpButton ) ;
    headingLayout->setAlignment(mUpButton,Qt::AlignRight);

    mFileDialog->setHeadingWidget( mHeadingWidget );
}
示例#7
0
void HGLayout::setAlignment(QGraphicsLayoutItem* item, Qt::Alignment align)
{
    QGraphicsLayout* ll = layout();
    if (!ll)  return ;

    HEnums::HLayoutType type = layoutType() ;
    if (type == HEnums::kHBox || type == HEnums::kVBox) {
        QGraphicsLinearLayout* l = static_cast<QGraphicsLinearLayout*>(ll);
        l->setAlignment(item, align);
    }
    else if(type == HEnums::kGrid) {
        QGraphicsGridLayout* l = static_cast<QGraphicsGridLayout*>(ll);
        l->setAlignment(item,align);
    }
}
示例#8
0
文件: kwidget.cpp 项目: kxtry/kxmob
void KWidget::setAlignment( Qt::Alignment align )
{
    QGraphicsLayout *tmpLayout = (QGraphicsLayout*)(parentLayout());
    if(tmpLayout == NULL)
        return ;
    LayoutType type = parentLayoutType();
    if(type == VBox || type == HBox)
    {
        QGraphicsLinearLayout *boxLayout = dynamic_cast<QGraphicsLinearLayout*>(tmpLayout);
        if(boxLayout)
        {
            boxLayout->setAlignment(this, align);
        }
    }
}
示例#9
0
MToggleWidget::MToggleWidget(QGraphicsItem *parent, QImage icon, QString iconId, bool isToggle) :
    MWidget(parent),
    m_stateImage(NULL)
{
    QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical, this);
    MFeedback* feedback = new MFeedback(FEEDBACK_PATTERN, this);
    connect(this, SIGNAL(pressed()), feedback, SLOT(play()));

    m_iconWidget = new MImageWidget(this);
    m_iconWidget->setAspectRatioMode(Qt::KeepAspectRatio);
    m_iconWidget->setMinimumSize(64, 64);
    m_iconWidget->setMaximumSize(64, 64);

    setMinimumSize(80, 80);
    setMaximumSize(80, 80);

    bool weHaveAnImage = false;

    if (!iconId.isEmpty()) {
        weHaveAnImage = true;
        m_iconWidget->setImage(iconId);
    }

    if (!icon.isNull() && !weHaveAnImage) {
        weHaveAnImage = true;
        m_iconWidget->setImage(icon);
    }

    layout->addItem(m_iconWidget);
    layout->setSpacing(0.1);

    if (isToggle) {
        m_stateImage = new MImageWidget(this);
        m_stateImage->setMinimumSize(60, 20);
        m_stateImage->setMaximumSize(60, 20);
        m_stateImage->setAspectRatioMode(Qt::KeepAspectRatio);
        m_stateImage->setImage(QImage(OFF_SWITCH));
        layout->addItem(m_stateImage);
        layout->setAlignment(m_stateImage, Qt::AlignHCenter);
    } else {
        layout->addStretch();
    }
}
void FmFindWidget::init()
{
    mLayout = new QGraphicsLinearLayout( this );
    mLayout->setOrientation( Qt::Vertical );
 
    mContentWidget = new HbStackedWidget( this );
    mLayout->addItem( mContentWidget );
    initSearchPanel();
    mLayout->addItem( mSearchPanel );
    setLayout( mLayout );

    mModel = new FmFindResultModel( this );
    mModel->setObjectName( "resultModel" );

    connect( mModel, SIGNAL( modelCountChanged( int )),
        this, SLOT( on_resultModel_modelCountChanged( int )), Qt::QueuedConnection );

    connect( mModel, SIGNAL( findStarteded()),
        this, SLOT( on_resultModel_findStarted()) );

    connect( mModel, SIGNAL( findFinished()),
        this, SLOT( on_resultModel_findFinished()) );
    
    mListView = new HbListView( this );
    mListView->setModel( mModel );

    mEmptyTipWidget = new HbWidget( this );
    QGraphicsLinearLayout *emptyTipLayout = new QGraphicsLinearLayout( mEmptyTipWidget );
    HbLabel *emptyTipLable = new HbLabel( hbTrId( "No found files or folders" ), mEmptyTipWidget );
    emptyTipLayout->addItem( emptyTipLable );
    emptyTipLayout->setAlignment( emptyTipLable, Qt::AlignCenter );
    emptyTipLable->setAlignment( Qt::AlignCenter );
 
    mContentWidget->addWidget( mListView );
    mContentWidget->addWidget( mEmptyTipWidget );
    
    mContentWidget->setCurrentWidget( mEmptyTipWidget );
    connect( mListView, SIGNAL(activated(QModelIndex)), this, SLOT(itemActivated(QModelIndex)));
}
void SwitchPage::createContent()
{
    TemplatePage::createContent();

    //landscapePolicy->insertStretch(1);

    switch1 = new MButton();
    switch1->setViewType(MButton::switchType);
    switch1->setCheckable(true);
    switch1->setChecked(true);
    label1 = new MLabel();
    label1->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
    QGraphicsLinearLayout *l = new QGraphicsLinearLayout(Qt::Horizontal);
    l->addItem(label1);
    l->addItem(switch1);
    l->setAlignment(switch1, Qt::AlignCenter);
    //l->setAlignment(label1, Qt::AlignRight);
    containerPolicy->addItem(l);
    connect(switch1, SIGNAL(toggled(bool)), this, SLOT(switchToggled(bool)));

    switch2 = new MButton();
    switch2->setViewType(MButton::switchType);
    switch2->setCheckable(true);
    label2 = new MLabel();
    label2->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
    l = new QGraphicsLinearLayout(Qt::Horizontal);
    l->addItem(label2);
    l->addItem(switch2);
    l->setAlignment(switch2, Qt::AlignCenter);
    //l->setAlignment(label2, Qt::AlignRight);
    containerPolicy->addItem(l);

    switch3 = new MButton();
    switch3->setViewType(MButton::switchType);
    switch3->setCheckable(true);
    label3 = new MLabel();
    label3->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
    l = new QGraphicsLinearLayout(Qt::Horizontal);
    l->addItem(label3);
    l->addItem(switch3);
    l->setAlignment(switch3, Qt::AlignCenter);
    //l->setAlignment(label3, Qt::AlignRight);
    containerPolicy->addItem(l);

    switch4 = new MButton();
    switch4->setViewType(MButton::switchType);
    switch4->setCheckable(true);
    label4 = new MLabel();
    label4->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
    l = new QGraphicsLinearLayout(Qt::Horizontal);
    l->addItem(label4);
    l->addItem(switch4);
    l->setAlignment(switch4, Qt::AlignCenter);
    //l->setAlignment(label4, Qt::AlignRight);
    containerPolicy->addItem(l);

    switch5 = new MButton();
    switch5->setViewType(MButton::switchType);
    switch5->setCheckable(true);
    switch5->setChecked(true);
    label5 = new MLabel();
    label5->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
    l = new QGraphicsLinearLayout(Qt::Horizontal);
    l->addItem(label5);
    l->addItem(switch5);
    l->setAlignment(switch5, Qt::AlignCenter);
    //l->setAlignment(label5, Qt::AlignRight);
    containerPolicy->addItem(l);

    retranslateUi();
}
示例#12
0
文件: options.cpp 项目: f0x/kcd
Options::Options(QGraphicsWidget *parent)
    : QGraphicsWidget(parent),
     // m_volume(new Plasma::IconWidget(this)),
      //m_meter(new KcdMeter(this)),
      //m_tracklist(new Plasma::IconWidget(this)),
      m_albumText(new Plasma::Label(this)),
      m_random(new Plasma::IconWidget(this)),
      m_loop(new Plasma::IconWidget(this))
{
 
   //m_volume->setIcon("audio-volume-high");
   //connect (m_volume, SIGNAL(clicked()), this, SLOT(handleVolume()));
   //m_volume->setMinimumSize(m_random->sizeFromIconSize(10));

   //m_meter->setMinimum(0);
   //m_meter->setMaximum(10);
   //m_meter->setMeterType(Plasma::Meter::BarMeterHorizontal);
   //connect (m_meter, SIGNAL(valueChanged(int)), this, SIGNAL(volumeChanged(int)));

   //m_tracklist->setIcon("format-list-unordered");
   //m_tracklist->setMinimumSize(m_random->sizeFromIconSize(10));
   //connect(m_tracklist, SIGNAL(clicked()), this, SIGNAL(showTrackList()));

   Plasma::ToolTipContent data;
   //data.setMainText(i18n("Tracklist"));
   //data.setSubText(i18n("View the tracklist"));
   //data.setImage(KIcon("format-list-unordered").pixmap(IconSize(KIconLoader::Desktop)));
   //Plasma::ToolTipManager::self()->setContent(m_tracklist, data);

   m_random->setIcon("roll");
   connect(m_random, SIGNAL(clicked()), this, SLOT(randomTrack()));
   
   data.setMainText(i18n("Random - off"));
   data.setSubText(i18n("Play random track"));
   data.setImage(KIcon("roll").pixmap(IconSize(KIconLoader::Desktop)));
   Plasma::ToolTipManager::self()->setContent(m_random, data);

   m_loop->setIcon("object-rotate-right");
   connect(m_loop, SIGNAL(clicked()), this, SLOT(loopList()));

   data.setMainText(i18n("Repeat - off"));
   data.setSubText(i18n("Play again the tracklist"));
   data.setImage(KIcon("object-rotate-right").pixmap(IconSize(KIconLoader::Desktop)));
   Plasma::ToolTipManager::self()->setContent(m_loop, data);

   QGraphicsLinearLayout *layout = new QGraphicsLinearLayout;
   layout->setOrientation(Qt::Horizontal);
   //layout->addItem(m_volume);
   //layout->addItem(m_meter);
   layout->addItem(m_albumText);
   layout->addItem(m_random);
   layout->addItem(m_loop);
   layout->setAlignment(m_albumText, Qt::AlignLeft);
   layout->setAlignment(m_random, Qt::AlignRight);
   layout->setAlignment(m_loop, Qt::AlignRight);
   layout->setStretchFactor(m_random, 0);
   layout->setStretchFactor(m_loop, 0);
   setPreferredHeight(35);
   
   //layout->setItemSpacing(0, 50);
  
  
   //layout->addItem(m_tracklist);
   //layout->setStretchFactor(m_meter, 20);
   //layout->setSpacing(0);
   //layout->setAlignment(m_random, Qt::AlignRight);
   //layout->setAlignment(m_loop, Qt::AlignRight);
   //layout->setAlignment(m_tracklist, Qt::AlignRight);
   //layout->setItemSpacing(1, 10);
   setLayout(layout);

   randomFlag = false;
   loopFlag = false;
   //volumeFlag = true;

   
}
void
ResetWidget::addButtonContainer (
            MLinearLayoutPolicy *mainLayout,
            MButton             *button1,
            MButton             *button2)
{
    MSeparator          *spacer;
    QGraphicsLinearLayout *layout =
        new QGraphicsLinearLayout (Qt::Vertical);
    layout->setContentsMargins (0,0,0,0);
    layout->setSpacing (0);
    
    /*
     * One spacer
     */
    spacer = new MSeparator;
    spacer->setStyleName ("CommonSpacer");

    /*
     * Button 1 layout
     */
    QGraphicsLinearLayout *button1layout =
        new QGraphicsLinearLayout (Qt::Horizontal);
    button1layout->setContentsMargins (0,0,0,0);
    button1layout->setSpacing (0);

    MStylableWidget *imgSpacer1 = new MStylableWidget;
    imgSpacer1->setStyleName ("CommonLeftIcon");
    button1layout->addItem (imgSpacer1);

    button1layout->addStretch ();

    button1layout->addItem (button1);
    button1layout->setAlignment (button1, Qt::AlignCenter);

    button1layout->addStretch ();

    MHelpButton *hp1 = createHelpButton ("IDUG_MEEGO_SETT_RESTORE.html");
    button1layout->addItem (hp1);
    button1layout->setAlignment (hp1, Qt::AlignVCenter);

    layout->addItem (button1layout);
    layout->setAlignment (button1layout, Qt::AlignCenter);

    layout->addItem (spacer);

    /*
     * Button 2 layout
     */
    QGraphicsLinearLayout *button2layout =
        new QGraphicsLinearLayout (Qt::Horizontal);
    button2layout->setContentsMargins (0,0,0,0);
    button2layout->setSpacing (0);

    MStylableWidget *imgSpacer2 = new MStylableWidget;
    imgSpacer2->setStyleName ("CommonLeftIcon");
    button2layout->addItem (imgSpacer2);
    button2layout->addStretch ();

    button2layout->addItem (button2);
    button2layout->setAlignment (button2, Qt::AlignCenter);

    button2layout->addStretch ();
    MHelpButton *hp2 = createHelpButton ("IDUG_MEEGO_SETT_CLEARDEVICE.html");
    button2layout->addItem (hp2);
    button2layout->setAlignment (hp2, Qt::AlignVCenter);

    layout->addItem (button2layout);
    layout->setAlignment (button2layout, Qt::AlignCenter);

    /*
     *
     */
    mainLayout->addItem (layout);
    mainLayout->setStretchFactor (layout, 0);
}
void 
SliderContainer::createWidgets (MWidget *parent)
{
    QGraphicsLinearLayout   *layout;

    SYS_DEBUG ("");

    /*
     * A container for the two labels.
     */
    setContentsMargins (0, 0, 0, 0);
    //setStyleName ("CommonPanelInverted");

    layout = new QGraphicsLinearLayout (Qt::Vertical);
    layout->setContentsMargins (0,0,0,0);
    layout->setSpacing (0);
    setLayout (layout);

    /*
     * "Auto activate power save" label
     */
    m_AutoPSMLabel = new MLabel (parent);
    // This is needed to select the short translation.
    m_AutoPSMLabel->setWordWrap (true);
    m_AutoPSMLabel->setStyleName ("CommonTitleInverted");
    layout->addItem (m_AutoPSMLabel);
    layout->setAlignment (m_AutoPSMLabel, Qt::AlignLeft);

    /*
     * A subtitle that shows the current value of the slider.
     */
    m_PsmValueLabel = new MLabel (parent);
    m_PsmValueLabel->setStyleName ("CommonSubTitleInverted");
    m_PsmValueLabel->setObjectName ("PsmValueLabel");
    layout->addItem (m_PsmValueLabel);
    layout->setAlignment (m_PsmValueLabel, Qt::AlignLeft);

    /*
     * Power save mode auto activation slider
     */
    m_PSMSlider = new MSlider (parent);
    m_PSMSlider->setObjectName ("PSMSlider");
    m_PSMSlider->setStyleName ("CommonSliderInverted");
    m_PSMSlider->setOrientation (Qt::Horizontal);
    m_PSMSlider->setHandleLabelVisible (true);
    m_PSMSlider->setRange (0, m_SliderValues.size () - 1);
    m_PSMSlider->setMaxLabelIconID ("icon-s-common-add-inverse");
    m_PSMSlider->setMinLabelIconID ("icon-s-common-remove-inverse");
    m_PSMSlider->setMinLabelVisible (true);
    m_PSMSlider->setMaxLabelVisible (true);

    layout->addItem (m_PSMSlider);
    layout->setAlignment (m_PSMSlider, Qt::AlignHCenter);
    
    /*
     * .. and after connect the slidervalue changed signal
     */
    connect (m_PSMSlider, SIGNAL (valueChanged (int)),
            this, SLOT (sliderValueChanged (int)),
            Qt::DirectConnection);

    m_AutoPSMLabel->setText (qtTrId("qtn_ener_activation"));
}