void
ResetWidget::createContent ()
{
    MLayout             *layout;
    MLinearLayoutPolicy *policy;
    MButton             *restoreButton;
    MButton             *clearButton;
    MSeparator          *spacer;

    /*
     *
     */
    layout = new MLayout;
    policy = new MLinearLayoutPolicy (layout, Qt::Vertical);
    policy->setContentsMargins (0., 0., 0., 0.);
    policy->setSpacing (0.);
    
    /*
     *
     */
    spacer = new MSeparator;
    // Using this one instead of "CommonSpacer", margins look even.
    spacer->setStyleName ("CommonLargeSpacer");
    policy->addItem (spacer);

    /*
     * The first button.
     */
    //% "Restore original settings"
    restoreButton = new MButton (qtTrId("qtn_rset_restore"));
    restoreButton->setStyleName ("CommonSingleButtonInverted");
    restoreButton->setObjectName ("ResetAppletRFSButton");
    connect (restoreButton, SIGNAL(clicked()), 
            this, SLOT(restoreActivated()));

    
    /*
     * The second button.
     */
    //% "Clear device"
    clearButton = new MButton (qtTrId("qtn_rset_clear"));
    clearButton->setStyleName ("CommonSingleButtonInverted");
    clearButton->setObjectName ("ResetAppletCUDButton");
    connect (clearButton, SIGNAL(clicked()), 
            this, SLOT(clearActivated()));

    addButtonContainer (policy, restoreButton, clearButton);
    policy->addStretch();
    /*
     *
     */
    layout->setPolicy (policy);
    setLayout (layout);
}
void
WarrantyWidget::addStretcher (
    MLinearLayoutPolicy *mainLayout,
    const QString       &styleName)
{
    MSeparator *stretcher;

    Q_ASSERT (mainLayout);

    stretcher = new MSeparator ();
    stretcher->setStyleName (styleName);
    mainLayout->addItem (stretcher);
}
void
WarrantyWidget::addLabelContainer (
    MLinearLayoutPolicy *mainLayout,
    MLabel              *label1,
    MLabel              *label2)
{
    Q_ASSERT (mainLayout);

    /*
     * Adding the label to the layout.
     */
    mainLayout->addItem (label1);
    mainLayout->setAlignment (label1, Qt::AlignLeft);

    MSeparator *separator = new MSeparator;
    separator->setStyleName ("CommonSpacer");

    mainLayout->addItem (separator);

    mainLayout->addItem (label2);
    mainLayout->setAlignment (label2, Qt::AlignLeft);
}
Exemplo n.º 4
0
void SettingsPage::createContent()
{
    Q_D(SettingsPage);

    setStyleName("AccountsUiPage");

    //% "%1 settings"
    setTitle(qtTrId("qtn_acc_ser_prof_set_title").arg(d->context->service().name()));

    MWidget *upperWidget = new MWidget(this);
    MLayout *upperLayout = new MLayout(upperWidget);
    MLinearLayoutPolicy *upperLayoutPolicy = new MLinearLayoutPolicy(upperLayout, Qt::Vertical);
    upperLayoutPolicy->setSpacing(0);

    MLayout *horizontalLayout = new MLayout();
    MLinearLayoutPolicy *horizontalLayoutPolicy = new MLinearLayoutPolicy(horizontalLayout, Qt::Horizontal);

    QString providerName(d->context->account()->providerName());
    QString providerIconId;
    // xml file that describes the ui elements for the provider
    Accounts::Provider provider = AccountsManager::instance()->provider(providerName);
    if (provider.isValid()) {
        QDomElement root = provider.domDocument().documentElement();
        QDomElement providerIcon = root.firstChildElement("icon");
        providerIconId = providerIcon.text();
    }

    ServiceHelper *serviceHepler =
        new ServiceHelper(d->context->service(), this);
    BasicHeaderWidget *usernameAndStatus = 0;

    if (d->context->account()->id() == 0) {
        usernameAndStatus = new BasicHeaderWidget(BasicHeaderWidget::IconWithTitle, this);
        usernameAndStatus->createLayout();
    } else {
        usernameAndStatus = new BasicHeaderWidget(BasicHeaderWidget::IconWithTitleAndSubTitle, this);
        usernameAndStatus->createLayout();
        usernameAndStatus->setSubtitle(qtTrId(d->context->account()->displayName().toLatin1()));
    }

    usernameAndStatus->setImage(providerIconId);
    usernameAndStatus->setTitle(serviceHepler->prettyName());

    MSeparator *separatorTop = new MSeparator(this);
    separatorTop->setStyleName("CommonHeaderDividerInverted");
    separatorTop->setOrientation(Qt::Horizontal);

    d->context->account()->selectService(d->context->service());

    horizontalLayoutPolicy->addItem(usernameAndStatus, Qt::AlignLeft | Qt::AlignVCenter);
    upperLayoutPolicy->addItem(horizontalLayout);
    upperLayoutPolicy->addItem(separatorTop);

    MWidget *widget = d->context->widget(this);

    MWidget *centralWidget = new MWidget(this);
    MLayout *layout = new MLayout(centralWidget);
    MLinearLayoutPolicy *layoutPolicy = new MLinearLayoutPolicy(layout, Qt::Vertical);
    layoutPolicy->addItem(upperWidget);

    layoutPolicy->addItem(widget);
    layoutPolicy->addStretch();

    setCentralWidget(centralWidget);
}
Exemplo n.º 5
0
void CreateEditPage::createContent(void)
{
	MApplicationPage::createContent();
	setStyleName("CommonApplicationPage");
	setPannable(false);

	createActions();

	QGraphicsAnchorLayout *anchor = new QGraphicsAnchorLayout();
	anchor->setContentsMargins(0, 0, 0, 0);
	anchor->setSizePolicy(QSizePolicy::Minimum, 
			      QSizePolicy::Minimum);

	ViewHeader *header = 
		new ViewHeader(m_tag == TagStorage::NULL_TAG 
			       ? tr("Create tag contents")
			       : tr("Edit tag contents"));
	anchor->addCornerAnchors(header, Qt::TopLeftCorner,
				 anchor, Qt::TopLeftCorner);

#ifdef LABEL_SIZE
	m_size = new MLabel();
	m_size->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
	m_size->setAlignment(Qt::AlignRight);
	anchor->addAnchor(m_size, Qt::AnchorBottom, anchor, Qt::AnchorBottom);
	anchor->addAnchor(m_size, Qt::AnchorRight, anchor, Qt::AnchorRight);
#endif

	MWidget *layoutContainer = new MWidget();
	layoutContainer->setSizePolicy(QSizePolicy::Preferred, 
				       QSizePolicy::Minimum);
	m_layout = new QGraphicsLinearLayout(Qt::Vertical, layoutContainer);
	m_layout->setSizePolicy(QSizePolicy::Preferred, 
				QSizePolicy::Minimum);

	m_name = new LabeledTextEdit(tr("Ok"),
				     LabeledTextEdit::SingleLineEditAndLabel);
	m_name->setLabel(tr("Tag name"));
	m_name->setPrompt(tr("Enter tag name"));
	m_name->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
	m_layout->addItem(m_name);
	m_layout->setAlignment(m_name, Qt::AlignLeft);
	connect(m_name, SIGNAL(contentsChanged(void)),
		this, SLOT(nameChanged(void)));

	MSeparator *sep = new MSeparator;
	sep->setStyleName("CommonHorizontalSeparator");
	sep->setOrientation(Qt::Horizontal);
	layout()->addItem(sep);

	createPageSpecificContent();

	MPannableViewport *view = new MPannableViewport();
	view->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
	view->setPanDirection(Qt::Vertical);
	view->setMinimumSize(100, 100);
	view->setWidget(layoutContainer);

	anchor->addAnchor(view, Qt::AnchorTop, header, Qt::AnchorBottom);
#ifdef LABEL_SIZE
	anchor->addAnchor(view, Qt::AnchorBottom, m_size, Qt::AnchorTop);
#else
	anchor->addAnchor(view, Qt::AnchorBottom, anchor, Qt::AnchorBottom);
#endif
	anchor->addAnchor(view, Qt::AnchorLeft, anchor, Qt::AnchorLeft);
	anchor->addAnchor(view, Qt::AnchorRight, anchor, Qt::AnchorRight);

	centralWidget()->setLayout(anchor);

	if (m_tag == TagStorage::NULL_TAG) {
		setContentValidity(false);
		setNameValidity(false);
		setupNewData();
	} else {
		load();
	}
}
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);
}