Ejemplo n.º 1
0
Cell::Cell(MWidget *parent) :
    MListItem(parent)
{
    MLayout *layout = new MLayout(this);
    MLinearLayoutPolicy *policy = new MLinearLayoutPolicy(layout, Qt::Vertical);
    policy->setContentsMargins(0, 0, 0, 0);
    policy->setSpacing(0);
    policy->setNotifyWidgetsOfLayoutPositionEnabled(true);

    line1 = new MLabel();
    line2 = new MLabel();
    line3 = new MLabel();
    date = new MLabel();

    line1->setWordWrap(false);
    line2->setWordWrap(false);
    line3->setWordWrap(false);
    date->setWordWrap(false);

    line1->setTextElide(true);
    line2->setTextElide(true);
    line3->setTextElide(true);
    date->setTextElide(true);

    policy->addItem(line1);
    policy->addItem(line2);
    policy->addItem(line3);
    policy->addItem(date);

    this->setStyleName("NotesPopupListItem");
}
void AccountSetupPage::createContent()
{
    MApplicationPage::createContent();
    setContentsMargins(0, 0, 0, 0);
    setPannable(true);
    //% "Mail"
    setTitle(qtTrId("xx_page_title"));

    MLayout *layout = new MLayout(centralWidget());

    MLinearLayoutPolicy *policy = new MLinearLayoutPolicy(layout, Qt::Vertical);

    //% "New mail account"
    creatLabel (policy, ("<b>" + qtTrId("xx_new_mail_account") + "<b>"), true);

    //% "We need to take some details to setup your account."
    creatLabel (policy, qtTrId("xx_need_account_detail"), true);
     
    // Prompt the user for name
    //% "What's your name?"
    creatLabel(policy, qtTrId("xx_enter_your_name"));
    m_username = new MTextEdit(MTextEditModel::SingleLine, "", this);
    m_username->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    policy->addItem(m_username);
    policy->setItemSpacing(policy->indexOf(m_username), 5);

    // Prompt the user for email address
    //% "Email address"
    creatLabel (policy, qtTrId("xx_email_address"));
    m_emailAddress = new MTextEdit(MTextEditModel::SingleLine, "", this);
    m_emailAddress->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    policy->addItem(m_emailAddress);
    policy->setItemSpacing(policy->indexOf(m_emailAddress), 5);

    // Prompt the user for password
    //% "Password"
    creatLabel(policy, qtTrId("xx_password"));
    m_password = new MTextEdit(MTextEditModel::SingleLine, "", this);
    m_password->setEchoMode(MTextEditModel::Password);
    m_password->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    policy->addItem(m_password);
    policy->setItemSpacing(policy->indexOf(m_password), 5);

    // Setup button
    //% "Setup account"
    MButton *button = new MButton(qtTrId("xx_setup_account_button_label"), this);
    button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    connect(button, SIGNAL(clicked(bool)), this, SLOT(setupAccount()));
    policy->addItem(button);
    policy->addStretch();

    // Settings menu
    //% "Settings"
    MAction *action = new MAction(qtTrId("xx_settings_actions"), this);
    action->setLocation(MAction::ApplicationMenuLocation);
    connect(action, SIGNAL(triggered(bool)), this, SIGNAL(emailSettingsTriggered()));
    addAction(action);
}
void MRichTextEditDialogsManager::initTextStylingDialog()
{
    selectedFontSize = -1;
    selectedFontFamily = QString();
    selectedFontColor = QColor();

    if (dialogs.textStyles.first) {
        return;
    }
    //% "Text styles"
    dialogs.textStyles.first = new MDialog(qtTrId("qtn_comm_text_styles"),M::DoneButton);
    dialogs.textStyles.second = false;

    QGraphicsWidget *centralWidget = dialogs.textStyles.first->centralWidget();
    MLayout *layout = new MLayout(centralWidget);
    MLinearLayoutPolicy *policy = new MLinearLayoutPolicy(layout, Qt::Vertical);

    // Initialize Font Family combo box
    QFontDatabase fontDatabase;
    QStringList fontFamilyValues = fontDatabase.families();

    // NOTE: black listing some ill-behaving fonts temporarily
    fontFamilyValues.removeAll("Webdings");
    fontFamilyValues.removeAll("Wingdings");

    fontFamilyCombo = new MComboBox(centralWidget);
    //% "Font"
    fontFamilyCombo->setTitle(qtTrId("qtn_comm_font"));
    QStringListModel *fontModel = new QStringListModel(centralWidget);
    fontModel->setStringList(fontFamilyValues);
    fontFamilyCombo->setItemModel(fontModel);
    policy->addItem(fontFamilyCombo);

    connect(fontFamilyCombo, SIGNAL(activated(QString)),
            this, SLOT(rememberFontFamily(QString)));

    // Initialize Font Size combo box
    fontSizeCombo = new MComboBox(centralWidget);
    //% "Font size"
    fontSizeCombo->setTitle(qtTrId("qtn_comm_font_size"));
    QStringListModel *sizeModel = new QStringListModel(centralWidget);
    fontSizeCombo->setItemModel(sizeModel);
    policy->addItem(fontSizeCombo);
    connect(fontSizeCombo, SIGNAL(activated(QString)),
            this, SLOT(rememberFontSize()));

    // Initialize Font Color item
    fontColorCombo = new MColorComboBox(centralWidget);
    //% "Font color"
    fontColorCombo->setTitle(qtTrId("qtn_comm_font_color_combobox"));
    policy->addItem(fontColorCombo);
    connect(fontColorCombo, SIGNAL(colorPicked(QColor)),
            this, SLOT(rememberFontColor(QColor)));

    // Selections are applied at pressing button "Done"
    connect(dialogs.textStyles.first, SIGNAL(accepted()),
            this, SLOT(applySelection()));
}
// ----------------------------------------------------------------------------
// CReporterPrivacySettingsWidget::initWidget
// ----------------------------------------------------------------------------
void CReporterPrivacySettingsWidget::initWidget()
{    
    //% "Crash Reporter"
    MLabel *titleLabel = new MLabel(qtTrId("qtn_dcp_crash_reporter").arg(QString(CREPORTERVERSION)));
    titleLabel->setStyleName("CommonApplicationHeaderInverted");

    //% "Version %1"
    MLabel *versionLabel = new MLabel(qtTrId("qtn_dcp_version_%1").arg(QString(CREPORTERVERSION)));
    versionLabel->setStyleName("CommonSubTitleInverted");

    // Create containers.
    CReporterMonitorSettingsContainer *monitorSettings =
            new CReporterMonitorSettingsContainer(this);

    CReporterIncludeSettingsContainer *includeSettings =
            new CReporterIncludeSettingsContainer(this);

	// Button for showing privacy statement.
    MButton *showPrivacyButton = new MButton(this);
    showPrivacyButton->setObjectName("ShowPrivacyButton");
    showPrivacyButton->setStyleName("CommonSingleButtonInverted");
    //% "Privacy Disclaimer"
    showPrivacyButton->setText(qtTrId("qtn_dcp_privacy_statement_button"));

    connect(showPrivacyButton, SIGNAL(clicked()), this, SLOT(openPrivacyDisclaimerDialog()));

    // Button for sending cores via selection
    MButton *sendSelectButton = new MButton(this);
    sendSelectButton->setObjectName("SendSelectButton");
    sendSelectButton->setStyleName("CommonSingleButtonInverted");
    //% "Send/Delete Reports"
    sendSelectButton->setText(qtTrId("qtn_dcp_send_delete_button_text"));
    connect(sendSelectButton, SIGNAL(clicked()), this, SLOT (handleSendSelectButtonClicked()), Qt::DirectConnection);
    connect(sendSelectButton, SIGNAL(clicked()), monitorSettings, SLOT(updateButtons()), Qt::QueuedConnection);

    // Create main layout and policy.
    MLayout *mainLayout = new MLayout(this);
    MLinearLayoutPolicy *mainLayoutPolicy =
            new MLinearLayoutPolicy(mainLayout, Qt::Vertical);
    mainLayoutPolicy->setObjectName("PageMainLayout");
    mainLayout->setPolicy(mainLayoutPolicy);
    mainLayout->setContentsMargins(0,0,0,0);

    mainLayoutPolicy->addItem(titleLabel, Qt::AlignLeft);
    mainLayoutPolicy->addItem(versionLabel, Qt::AlignLeft);
    mainLayoutPolicy->addItem(monitorSettings, Qt::AlignCenter);
    mainLayoutPolicy->addItem(includeSettings, Qt::AlignCenter);
//    mainLayoutPolicy->addItem(bottomLayout, Qt::AlignCenter);
    mainLayoutPolicy->addStretch();
    mainLayoutPolicy->addItem(showPrivacyButton, Qt::AlignCenter);
    mainLayoutPolicy->addItem(sendSelectButton, Qt::AlignCenter);
}
Ejemplo n.º 5
0
void Ut_MWidget::testShowHidePropagation()
{
    QGraphicsScene scene;
    QGraphicsView view(&scene);

    view.resize(500, 500);
    view.show();

    MWidget* topLevel = new MWidget;
    MLayout *layout = new MLayout(topLevel);
    MLinearLayoutPolicy *policy = new MLinearLayoutPolicy(layout, Qt::Vertical);
    policy->addItem(widget);

    scene.addItem(topLevel);
    topLevel->setGeometry(10, 10, 50, 50);

    topLevel->hide();
    m_dummySlotCalled = false;
    connect(widget, SIGNAL(displayEntered()), this, SLOT(dummySlot()));
    topLevel->show();
    QVERIFY(m_dummySlotCalled == true);
    disconnect(widget, SIGNAL(displayEntered()), this, SLOT(dummySlot()));

    m_dummySlotCalled = false;
    connect(widget, SIGNAL(displayExited()), this, SLOT(dummySlot()));
    topLevel->hide();
    QVERIFY(m_dummySlotCalled == true);
    disconnect(widget, SIGNAL(displayExited()), this, SLOT(dummySlot()));
}
MLayout *PhoneBookHeader::createLayout()
{
    if (layout)
        delete layout;

    layout = new MLayout(this);
    MLinearLayoutPolicy *policy = new MLinearLayoutPolicy(layout, Qt::Horizontal);

    policy->addItem(groupTitleLabelWidget());
    policy->addItem(new QGraphicsWidget(this));
    policy->addItem(groupCountLabelWidget());

    layout->setPolicy(policy);

    return layout;
}
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);
}
Ejemplo n.º 8
0
int main(int argc, char **argv)
{
    MApplication app(argc, argv);
    MApplicationWindow window;
    MApplicationPage page;
    MTheme::loadCSS("twocolumns.css");
    /* Create a MLayout that we set the policy for */
    MLayout *layout = new MLayout(page.centralWidget());
    MLinearLayoutPolicy *policy = new MLinearLayoutPolicy(layout, Qt::Horizontal);

    /* Setup first layout with a label and text edit */
    MLayout *nameLayout = new MLayout;
    MLinearLayoutPolicy *namePolicy = new MLinearLayoutPolicy(nameLayout, Qt::Horizontal);
    MLabel *textEditLabel = new MLabel("Name:");
    MTextEdit *textEdit = new MTextEdit(MTextEditModel::MultiLine);
    namePolicy->addItem(textEditLabel);  //Add the label and textedit
    namePolicy->addItem(textEdit);
    textEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);

    /* Setup second layout with a large label */
    MLayout *labelLayout = new MLayout;
    MLinearLayoutPolicy *labelPolicy = new MLinearLayoutPolicy(labelLayout, Qt::Horizontal);
    MLabel *label = new MLabel("Enter the name of the person who likes to listen to music while sorting their socks!");
    label->setObjectName("nameLabel");
    labelPolicy->addItem(label);
    label->setWordWrap(true);

    /* Add the two layouts to the layout */
    policy->addItem(nameLayout);
    policy->addItem(labelLayout);

    /* Make the two layouts have an equal preferred size, so that they get an equal amount of space */
    nameLayout->setPreferredWidth(1);
    labelLayout->setPreferredWidth(1);

    page.appear(&window);
    window.show();

    return app.exec();
}
int main(int argc, char **argv)
{
    MApplication app(argc, argv);
    MTheme::loadCSS("layout_inside_layout.css");
    MApplicationWindow window;
    MApplicationPage page;

    /* Create a MLayout that we set the policies for */
    MLayout *layout = new MLayout;
    MLinearLayoutPolicy *portraitPolicy = new MLinearLayoutPolicy(layout, Qt::Horizontal);
    MLinearLayoutPolicy *landscapePolicy = new MLinearLayoutPolicy(layout, Qt::Horizontal);
    for (int i = 0; i < 3; ++i) {
        MLabel *label = new MLabel(QString("Item %1").arg(i + 1));
        label->setAlignment(Qt::AlignCenter);
        label->setObjectName("item"); //Set CSS name for styling
        portraitPolicy->addItem(label);
        landscapePolicy->addItem(label);
    }
    /* Create a widget to hold the inner layout and to put inside the policy */
    QGraphicsWidget *widget = new QGraphicsWidget;
    /* Create an inner layout.  A QGraphicsGridLayout is used since we don't require
     * multiple policies here, but using a MLayout would also work. */
    QGraphicsGridLayout *innerLayout = new QGraphicsGridLayout(widget);
    for (int i = 0; i < 4; ++i) {
        MLabel *label = new MLabel(QString("Inner Item %1").arg(i + 1));
        label->setAlignment(Qt::AlignCenter);
        label->setObjectName("inneritem"); //Set CSS name for styling
        innerLayout->addItem(label, i / 2, i % 2);
    }
    /* Now add the widget to the landscape policy only, so that the innerLayout is hidden when device is rotated */
    landscapePolicy->addItem(widget);
    layout->setLandscapePolicy(landscapePolicy);
    layout->setPortraitPolicy(portraitPolicy);

    /* Attach the layout to the page */
    page.centralWidget()->setLayout(layout);
    page.appear(&window);
    window.show();
    return app.exec();
}
Ejemplo n.º 10
0
ViewHeaderWithIcon::ViewHeaderWithIcon(QGraphicsItem *parent) :
    MWidgetController(parent),
    linearLayout(0),
    titleWidget(0)
{
    setStyleName("CommonHeaderPanel");
    setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
    MLayout *layout = new MLayout(this);
    MLinearLayoutPolicy *layoutPolicy = new MLinearLayoutPolicy(layout, Qt::Horizontal);
    titleWidget = new MLabel();
    titleWidget->setTextElide(true);
    titleWidget->setStyleName("CommonHeaderInverted");
    layoutPolicy->addItem(titleWidget);

    MButton *refreshButton = new MButton(this);
    refreshButton->setIconID ("icon-m-common-refresh");
    refreshButton->setViewType (MButton::iconType);
    refreshButton->setStyleName("CommonRightIcon");
    layoutPolicy->addItem(refreshButton);
    layoutPolicy->setAlignment(refreshButton, Qt::AlignLeft | Qt::AlignVCenter);
    connect(refreshButton, SIGNAL(clicked()), this, SLOT(onButtonClicked()));
}
void AlbumPage::createContent()
{
    MLayout *layout = new MLayout;
    centralWidget()->setLayout(layout);

    // Build a vertical layout that holds the cover art and the "By: Artist" label.
    QGraphicsLinearLayout *coverAndArtistLayout = new QGraphicsLinearLayout(Qt::Vertical);

    MImageWidget *albumCover = new MImageWidget(new QImage(album->coverArtFilename));
    coverAndArtistLayout->addItem(albumCover);

    QString byArtist = QString("By: %1").arg(album->artist);
    coverAndArtistLayout->addItem(new MLabel(byArtist));

    // Build a vertical layout that will hold the list of songs.
    QGraphicsLinearLayout *songsLayout = new QGraphicsLinearLayout(Qt::Vertical);
    songsLayout->addItem(new MLabel("Songs:"));
    MLabel *songLabel;
    for (int i = 0; i < album->songs.count(); i++) {
        songLabel = new MLabel(album->songs.at(i));
        songsLayout->addItem(songLabel);
    }

    // When in landscape orientation, have the cover and the songs list
    // side-by-side.
    MLinearLayoutPolicy *landscapePolicy = new MLinearLayoutPolicy(layout, Qt::Horizontal);
    landscapePolicy->addItem(coverAndArtistLayout);
    landscapePolicy->addItem(songsLayout);
    layout->setLandscapePolicy(landscapePolicy);

    // When in portrait orientation, have the cover and the songs list
    // on top of each other.
    MLinearLayoutPolicy *portraitPolicy = new MLinearLayoutPolicy(layout, Qt::Vertical);
    portraitPolicy->addItem(coverAndArtistLayout);
    portraitPolicy->addItem(songsLayout);
    layout->setPortraitPolicy(portraitPolicy);
}
// ----------------------------------------------------------------------------
// CReporterSendSelectedDialog::createcontent
// ----------------------------------------------------------------------------
void CReporterSendSelectedDialog::createcontent()
{
    Q_D(CReporterSendSelectedDialog);
    setObjectName("CrashReporterSendSelectedDialog");

    int nbrOfFiles = d_ptr->files.count();
    QString message;

    if (nbrOfFiles == 1) {
        //% "<p>This system has 1 stored crash report. Select reports to send to %1 for analysis or to delete.</p>"
        message = qtTrId("qtn_system_has_1_crash_report_send_to_%s").arg(d->server);

    }
    else {
        //% "<p>This system has %1 stored crash reports. Select reports to send to %2 for analysis or to delete.</p>"
        message = qtTrId("qtn_system_has_%1_crash_reports_send_to_%2").arg(nbrOfFiles).arg(d->server);

    }

    // Create content to be placed on central widget.
    QGraphicsWidget *panel = centralWidget();

    // Create layout and policy.
    MLayout *layout = new MLayout(panel);
    layout->setContentsMargins(0,0,0,0);
    panel->setLayout(layout);
    MLinearLayoutPolicy  *policy = new MLinearLayoutPolicy(layout, Qt::Vertical);
    policy->setObjectName("DialogMainLayout");

    // Create message label and hack it to support wordwrapping
    MLabel *messagelabel = new MLabel(message, panel);
    messagelabel->setWordWrap(true);
    messagelabel->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
    messagelabel->setObjectName("DialogMessageLabel");
    messagelabel->setStyleName("CommonFieldLabelInverted");

    d->list = new MList(panel);
    d->cellCreator = new MContentItemCreator;

    d->list->setCellCreator(d->cellCreator);
    d->model = new CReporterSendFileListModel(d->files);
    d->list->setItemModel(d->model);
    d->list->setSelectionMode(MList::MultiSelection);

    // Add widgets to the layout
    policy->addItem(messagelabel, Qt::AlignLeft | Qt::AlignTop);
    policy->addItem(d->list, Qt::AlignLeft | Qt::AlignTop);

    // Add buttons to button area.
    QSignalMapper *mapper = new QSignalMapper(this);
    //% "Send Selected"
    MButton* dialogButton = new MButton(qtTrId("qtn_send_selected_button"));
    dialogButton->setStyleName("CommonSingleButtonInverted");
    policy->addItem(dialogButton, Qt::AlignCenter);
//    MButtonModel *dialogButton = addButton(qtTrId("qtn_send_selected_button"), M::ActionRole);
    connect(dialogButton, SIGNAL(clicked()), mapper, SLOT(map()));
    mapper->setMapping(dialogButton, static_cast<int>(CReporter::SendSelectedButton));

    //% "Send All"
    dialogButton = new MButton(qtTrId("qtn_send_all_button"));
    dialogButton->setStyleName("CommonSingleButtonInverted");
    policy->addItem(dialogButton, Qt::AlignCenter);
//    dialogButton = addButton(qtTrId("qtn_send_all_button"), M::ActionRole);
    connect(dialogButton, SIGNAL(clicked()), mapper, SLOT(map()));
    mapper->setMapping(dialogButton, static_cast<int>(CReporter::SendAllButton));

    //% "Delete Selected"
    dialogButton = new MButton(qtTrId("qtn_delete_selected_button"));
    dialogButton->setStyleName("CommonSingleButtonInverted");
    policy->addItem(dialogButton, Qt::AlignCenter);
//    dialogButton = addButton(qtTrId("qtn_delete_selected_button"), M::DestructiveRole);
    connect(dialogButton, SIGNAL(clicked()), mapper, SLOT(map()));
    mapper->setMapping(dialogButton, static_cast<int>(CReporter::DeleteSelectedButton));

    connect(mapper, SIGNAL(mapped(int)), SIGNAL(actionPerformed(int)));
    connect(mapper, SIGNAL(mapped(int)), SLOT(accept()));
}
void TextEntryPage::createContent()
{
    MApplicationPage::createContent();
    pannableViewport()->setAcceptGesturesFromAnyDirection(true);
    setStyleName(inv("CommonApplicationPage"));
    QGraphicsWidget *panel = centralWidget();
    MLinearLayoutPolicy *layoutPolicy = TextEntryPage::createAndSetupLinearPolicy(panel);

    pageTitleLabel = new MLabel(centralWidget());
    pageTitleLabel->setObjectName("pageTitleLabel");
    pageTitleLabel->setStyleName(inv("CommonApplicationHeader"));
    layoutPolicy->addItem(pageTitleLabel);

    int row = 0;

    // free text line
    Entries << new MTextEdit(MTextEditModel::SingleLine, "", centralWidget());
    Entries.at(row)->setStyleName(inv("CommonSingleInputFieldLabeled"));
    Entries.at(row)->setObjectName("freeTextTextEdit");
    label0 = new MLabel(centralWidget());
    label0->setObjectName("label0");
    label0->setStyleName(inv("CommonFieldLabel"));
    label0->setWordWrap(true);
    label0->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);

    layoutPolicy->addItem(label0);
    layoutPolicy->addItem(Entries.at(row));
    row++;

    // password line
    Entries << new MTextEdit(MTextEditModel::SingleLine, "", centralWidget());
    Entries.at(row)->setObjectName("passwordTextEdit");
    Entries.at(row)->setStyleName(inv("CommonSingleInputFieldLabeled"));

    label1 = new MLabel(centralWidget());
    label1->setObjectName("label1");
    label1->setStyleName(inv("CommonFieldLabel"));
    label1->setWordWrap(true);
    label1->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);

    Entries.at(row)->setEchoMode(MTextEditModel::Password);
    layoutPolicy->addItem(label1);
    layoutPolicy->addItem(Entries.at(row));
    row++;

    // no echo line
    Entries << new MTextEdit(MTextEditModel::SingleLine, "", centralWidget());
    Entries.at(row)->setObjectName("noEchoTextEdit");
    Entries.at(row)->setStyleName(inv("CommonSingleInputFieldLabeled"));

    labelNoEcho = new MLabel(centralWidget());
    labelNoEcho->setObjectName("labelNoEcho");
    labelNoEcho->setStyleName(inv("CommonFieldLabel"));
    labelNoEcho->setWordWrap(true);
    labelNoEcho->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);

    Entries.at(row)->setEchoMode(MTextEditModel::NoEcho);
    layoutPolicy->addItem(labelNoEcho);
    layoutPolicy->addItem(Entries.at(row));
    row++;

    // passwordEchoOnEdit
    Entries << new MTextEdit(MTextEditModel::SingleLine, "", centralWidget());
    Entries.at(row)->setObjectName("passwordEchoOnEditTextEdit");
    Entries.at(row)->setStyleName(inv("CommonSingleInputFieldLabeled"));

    labelEchoOnEdit = new MLabel(centralWidget());
    labelEchoOnEdit->setObjectName("labelEchoOnEdit");
    labelEchoOnEdit->setStyleName(inv("CommonFieldLabel"));
    labelEchoOnEdit->setWordWrap(true);
    labelEchoOnEdit->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);

    Entries.at(row)->setEchoMode(MTextEditModel::PasswordEchoOnEdit);
    layoutPolicy->addItem(labelEchoOnEdit);
    layoutPolicy->addItem(Entries.at(row));
    row++;

    // number content type
    Entries << new MTextEdit(MTextEditModel::SingleLine, "", centralWidget());
    Entries.at(row)->setObjectName("numberTextEdit");
    Entries.at(row)->setStyleName(inv("CommonSingleInputFieldLabeled"));

    label2 = new MLabel(centralWidget());
    label2->setObjectName("label2");
    label2->setStyleName(inv("CommonFieldLabel"));
    label2->setWordWrap(true);
    label2->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);

    Entries.at(row)->setContentType(M::NumberContentType);
    layoutPolicy->addItem(label2);
    layoutPolicy->addItem(Entries.at(row));
    row++;

    // phone number content type
    Entries << new MTextEdit(MTextEditModel::SingleLine, "", centralWidget());
    Entries.at(row)->setObjectName("phoneTextEdit");
    Entries.at(row)->setStyleName(inv("CommonSingleInputFieldLabeled"));

    label3 = new MLabel(centralWidget());
    label3->setObjectName("label3");
    label3->setStyleName(inv("CommonFieldLabel"));
    label3->setWordWrap(true);
    label3->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);

    Entries.at(row)->setContentType(M::PhoneNumberContentType);
    layoutPolicy->addItem(label3);
    layoutPolicy->addItem(Entries.at(row));
    row++;

    // email content type
    Entries << new MTextEdit(MTextEditModel::SingleLine, "", centralWidget());
    Entries.at(row)->setObjectName("emailTextEdit");
    Entries.at(row)->setStyleName(inv("CommonSingleInputFieldLabeled"));

    label4 = new MLabel(centralWidget());
    label4->setObjectName("label4");
    label4->setStyleName(inv("CommonFieldLabel"));
    label4->setWordWrap(true);
    label4->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);

    Entries.at(row)->setContentType(M::EmailContentType);
    layoutPolicy->addItem(label4);
    layoutPolicy->addItem(Entries.at(row));
    row++;

    // url content type
    Entries << new MTextEdit(MTextEditModel::SingleLine, "", centralWidget());
    Entries.at(row)->setObjectName("urlTextEdit");
    Entries.at(row)->setStyleName(inv("CommonSingleInputFieldLabeled"));

    label5 = new MLabel(centralWidget());
    label5->setObjectName("label5");
    label5->setStyleName(inv("CommonFieldLabel"));
    label5->setWordWrap(true);
    label5->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);

    Entries.at(row)->setContentType(M::UrlContentType);
    layoutPolicy->addItem(label5);
    layoutPolicy->addItem(Entries.at(row));
    row++;

    // multiline
    Entries << new MTextEdit(MTextEditModel::MultiLine, "", centralWidget());
    Entries.at(row)->setObjectName("multilineTextEdit");
    Entries.at(row)->setStyleName(inv("CommonSingleInputFieldLabeled"));

    label6 = new MLabel(centralWidget());
    label6->setObjectName("label6");
    label6->setStyleName(inv("CommonFieldLabel"));
    label6->setWordWrap(true);
    label6->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);

    label6->setAlignment(Qt::AlignTop);
    layoutPolicy->addItem(label6);
    layoutPolicy->addItem(Entries.at(row));
    row++;

    // autoselection line
    Entries << new MTextEdit(MTextEditModel::SingleLine, "", centralWidget());
    Entries.at(row)->setObjectName("autoselectionTextEdit");
    Entries.at(row)->setStyleName(inv("CommonSingleInputFieldLabeled"));
    Entries.at(row)->setAutoSelectionEnabled(true);

    label7 = new MLabel(centralWidget());
    label7->setObjectName("label7");
    label7->setStyleName(inv("CommonFieldLabel"));
    label7->setWordWrap(true);
    label7->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
    label7->setAlignment(Qt::AlignTop);
    layoutPolicy->addItem(label7);
    layoutPolicy->addItem(Entries.at(row));
    row++;

    // completion
    Entries << new MTextEdit(MTextEditModel::MultiLine, "", centralWidget());
    Entries.at(row)->setObjectName("completionTextEdit");
    Entries.at(row)->setStyleName(inv("CommonSingleInputFieldLabeled"));
    QStringList list;
    list << "Betty Brey <*****@*****.**>"
         << "Anne Rodriguez <*****@*****.**>"
         << "Elizabeth Hutchings <*****@*****.**>"
         << "Robert Hornbuckle <*****@*****.**>"
         << "Willie Logan <*****@*****.**>"
         << "Marcia Pineda <*****@*****.**>"
         << "Jessica Schmitt <*****@*****.**>"
         << "Lynda Wan <*****@*****.**>"
         << "Alphonso Stevens <*****@*****.**>"
         << "Patricia Murphy <*****@*****.**>"
         << "Jeff Terry <*****@*****.**>"
         << "Richard Orlando <*****@*****.**>"
         << "Eva Quackenbush <*****@*****.**>"
         << "Tim Parker <*****@*****.**>"
         << "Deborah Sanchez <*****@*****.**>"
         << "Carol Reimer <*****@*****.**>"
         << "Susan Amaya <*****@*****.**>"
         << "Shelia Rudd <*****@*****.**>"
         << "Elizabeth Livingston <*****@*****.**>"
         << "Renee Heard <*****@*****.**>"
         << "Megan Gagne <*****@*****.**>"
         << "Katherine Enos <*****@*****.**>"
         << "Gary Hawkins <*****@*****.**>"
         << "Bianca Sparks <*****@*****.**>"
         << "Cleta Richardson <*****@*****.**>"
         << "Latoya Lawrence <*****@*****.**>"
         << "Ethel Allen <*****@*****.**>"
         << "Maria Austin <*****@*****.**>"
         << "John Smith <*****@*****.**>"
         << "Jane Smith <*****@*****.**>"
         << "Doug Barker <*****@*****.**>"
         << "Sandra Cross <*****@*****.**>"
         << "Debra Roberts <*****@*****.**>"
         << "Mei Copeland <*****@*****.**>"
         << "Raymond Slack <*****@*****.**>"
         << "Martin Vidal <*****@*****.**>"
         << "Patricia Rymer <*****@*****.**>"
         << "Maria Gilbreath <*****@*****.**>"
         << "Mary Ramos <*****@*****.**>"
         << "Michael Haller <*****@*****.**>"
         << "Randall Hood <*****@*****.**>"
         << "Bruce Lindsey <*****@*****.**>"
         << "Heidi Martin <*****@*****.**>"
         << "Helen Kennedy <*****@*****.**>"
         << "Margaret Worsham <*****@*****.**>"
         << "Sun Singleton <*****@*****.**>"
         << "Alberto Prince <*****@*****.**>"
         << "Norman Weiland <*****@*****.**>"
         << "Carolyn Delia <*****@*****.**>"
         << "Lakesha Acosta <*****@*****.**>";

    QStringList cs, c1, c2;

    foreach(const QString & s, list) {
        cs = s.split('<');
        if (cs.count() >= 2) {
            c1 << cs[0].trimmed();
            c2 << QString('<' + cs[1]);
        }
    }
Ejemplo n.º 14
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);
}
Ejemplo n.º 15
0
void Pt_MLayout::heightForWidthPerformance()
{
    QFETCH(bool, qtOnly);
    QFETCH(bool, hfw);
    QFETCH(bool, nested);

    QGraphicsLinearLayout *outerlayout = NULL;
    if(nested) {
       outerlayout = new QGraphicsLinearLayout(m_form);
       for(int i = 0; i < 5; i++) {
           QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical);
           outerlayout->addItem(layout);
           outerlayout = layout;
       }
    }

    QGraphicsLinearLayout *qlayout = NULL;
    MLayout *layout = NULL;
    MLinearLayoutPolicy *policy = NULL;
    if(qtOnly) {
        qlayout = new QGraphicsLinearLayout(Qt::Vertical);
        if (nested)
            outerlayout->addItem(qlayout);
        else
            m_form->setLayout(qlayout);
    } else {
        layout = new MLayout;
        policy = new MLinearLayoutPolicy(layout, Qt::Vertical);
        if (nested)
            outerlayout->addItem(layout);
        else
            m_form->setLayout(layout);
    }

    for(int i = 0; i < 1; i++) {
        MySquareWidget *widget = new MySquareWidget;
        QSizePolicy sizepolicy = widget->sizePolicy();
        sizepolicy.setHeightForWidth(hfw);
        widget->setSizePolicy(sizepolicy);
        if (qtOnly)
            qlayout->addItem(widget);
        else
            policy->addItem(widget);
    }

    while (MTheme::hasPendingRequests()) {
        usleep(10);
        QCoreApplication::processEvents();
    }

    QBENCHMARK {
        if (qtOnly) {
            qlayout->invalidate();
            QCoreApplication::processEvents();
            (void)qlayout->preferredSize();
        } else {
            layout->invalidate();
            QCoreApplication::processEvents();
            (void)layout->preferredSize();
        }
    }
}
void Ut_MGridLayoutPolicy::testHeightForWidthInSubLayout()
{
    QFETCH(bool, useMLayout);
    QFETCH(bool, useInnerMLayout);
    QFETCH(bool, putInnerWidgetInWidget);

    QGraphicsWidget *form = new QGraphicsWidget;


    MGridLayoutPolicy *mpolicy = NULL;
    QGraphicsGridLayout *qlayout = NULL;

    if (useMLayout) {
        MLayout *mlayout = new MLayout(form);
        mlayout->setContentsMargins(0, 0, 0, 0);
        mpolicy = new MGridLayoutPolicy(mlayout);
        mpolicy->setSpacing(0);
    } else {
        qlayout = new QGraphicsGridLayout(form);
        qlayout->setContentsMargins(0, 0, 0, 0);
        qlayout->setSpacing(0);
    }

    QGraphicsWidget *topSpacer = createSpacer();
    QGraphicsWidget *leftSpacer = createSpacer();
    QGraphicsWidget *rightSpacer = createSpacer();
    leftSpacer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
    rightSpacer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);

    QGraphicsWidget *square = new SquareWidget;

    QGraphicsLayout *innerLayout = NULL;
    if (useInnerMLayout) {
        innerLayout = new MLayout();
        MLinearLayoutPolicy *policy = new MLinearLayoutPolicy(static_cast<MLayout *>(innerLayout), Qt::Horizontal);
        policy->addItem(square);
    } else {
        innerLayout = new QGraphicsLinearLayout(Qt::Horizontal);
        static_cast<QGraphicsLinearLayout *>(innerLayout)->addItem(square);
    }
    innerLayout->setContentsMargins(0,0,0,0);

    QGraphicsLayoutItem *innerItem;
    if (putInnerWidgetInWidget) {
        QGraphicsWidget *innerWidget = new QGraphicsWidget;
        innerWidget->setLayout(innerLayout);
        innerItem = innerWidget;
    } else {
        innerItem = innerLayout;
    }

    if (useMLayout) {
        mpolicy->addItem(topSpacer, 0, 1);
        mpolicy->addItem(leftSpacer, 1, 0);
        mpolicy->addItem(rightSpacer, 1, 2);
        mpolicy->addItem(innerItem, 1, 1);
    } else {
        qlayout->addItem(topSpacer, 0, 1);
        qlayout->addItem(leftSpacer, 1, 0);
        qlayout->addItem(rightSpacer, 1, 2);
        qlayout->addItem(innerItem, 1, 1);
    }


    QCOMPARE(form->preferredSize(), QSizeF(500,500));
    QCOMPARE(form->effectiveSizeHint(Qt::PreferredSize, QSizeF(100,-1)), QSizeF(100,100));

    delete form;
}
Ejemplo n.º 17
0
OpenDialog::OpenDialog(QGraphicsWidget*, const QString &currentFileName)
{
    MWidget *centralWidget = new MWidget;
    MLayout *layout = new MLayout();
    layout->setContentsMargins(0,0,0,0);

    MLinearLayoutPolicy* landscapePolicy = new MLinearLayoutPolicy(layout, Qt::Vertical);
    MLinearLayoutPolicy* portraitPolicy = new MLinearLayoutPolicy(layout, Qt::Vertical);

  //  m_itemSize.setWidth(100);
  //  m_itemSize.setHeight(100);

    m_columnsPortrait = 4;
    m_columnsLandscape = 5;
    m_columnsLandscapeSlider = 0;
    m_columnsPortraitSlider = 0;


    list = new MList(this);
    list->setObjectName("list");
    landscapePolicy->addItem(list);
    portraitPolicy->addItem(list);

    landscapePolicy->setContentsMargins(20, 12, 20, 0);
    portraitPolicy->setContentsMargins(20, 24, 20, 0);

    layout->setLandscapePolicy(landscapePolicy);
    layout->setPortraitPolicy(portraitPolicy);


    //int initialWidth = MApplication::activeWindow()->visibleSceneSize().width();

  /*  if(MApplication::activeWindow()->orientation() == M::Portrait) {
        list->setColumns(m_columnsPortrait);
        m_itemSize.setWidth(initialWidth / m_columnsPortrait);
        m_itemSize.setHeight(m_itemSize.width());
    }
    else {
        list->setColumns(m_columnsLandscape);
        m_itemSize.setWidth(initialWidth / m_columnsLandscape);
        m_itemSize.setHeight(m_itemSize.width());
    }*/

    m_itemSize.setWidth(110);
    m_itemSize.setHeight(110);

    ContentItemCreator *cellCreator = new ContentItemCreator(this);
    list->setCellCreator(cellCreator);

    QStringList mediaDirs;
    mediaDirs << APP_CATALOG;

    model = new OpenDialogModel(this, m_itemSize.toSize(), mediaDirs, currentFileName);
    model->setObjectName("gridModel");
    list->setItemModel(model);

    connect(list, SIGNAL(itemClicked(QModelIndex)), this, SLOT(itemClicked(QModelIndex)));
    connect(list, SIGNAL(panningStarted()), this, SLOT(pauseLoaders()));
    connect(list, SIGNAL(panningStopped()), this, SLOT(resumeLoaders()));

    centralWidget->setLayout(layout);
    this->setTitle("Choose an image");
    this->setModal(true);
    this->setCentralWidget(centralWidget);
}
void ScreenShotPage::createContent()
{
    TemplatePage::createContent();

    QGraphicsWidget *panel = centralWidget();
    panel->setContentsMargins(0,0,0,0);

    setContentsMargins(0,0,0,0);

    layout = new MLayout(panel);

    layoutPolicy = new MLinearLayoutPolicy(layout, Qt::Vertical);
    layoutPolicy->setSpacing(0);
    layoutPolicy->setContentsMargins(0,0,0,0);

    layout->setPortraitPolicy(layoutPolicy);
    layout->setLandscapePolicy(layoutPolicy);

    MLayout * elementsLayout = new MLayout;

    MLinearLayoutPolicy* elementsPolicyL = new MLinearLayoutPolicy(elementsLayout,Qt::Vertical);
    elementsLayout->setLandscapePolicy(elementsPolicyL);
    elementsPolicyL->setSpacing(0);
    elementsPolicyL->setContentsMargins(0, 0, 0, 0);

    MLinearLayoutPolicy* elementsPolicyP = new MLinearLayoutPolicy(elementsLayout,Qt::Vertical);
    elementsLayout->setLandscapePolicy(elementsPolicyP);
    elementsPolicyP->setSpacing(0);
    elementsPolicyP->setContentsMargins(0, 0, 0, 0);

    label1 = new MLabel ("Take a screenshot");
    label1->setObjectName("label1");
    label1->setStyleName(inv("CommonApplicationHeader"));

    elementsPolicyL->addItem(label1);
    elementsPolicyP->addItem(label1);

    labelDescription = new MLabel ();
    labelDescription->setObjectName("descriptionLabel");
    labelDescription->setWordWrap(true);
    labelDescription->setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
    labelDescription->setStyleName(inv("CommonBodyText"));

    elementsPolicyL->addItem(labelDescription);
    elementsPolicyP->addItem(labelDescription);

    QGraphicsGridLayout * gridSecs = new QGraphicsGridLayout();

    entrySeconds = new MTextEdit(MTextEditModel::SingleLine,"");
    entrySeconds->setObjectName("secondsTextEntry");
    entrySeconds->setMaxLength(2);
    entrySeconds->setStyleName(inv("CommonSingleInputField"));
    entrySeconds->setContentType(M::NumberContentType);
    entrySeconds->setText("8");
    entrySeconds->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
    MLabel * secsLabel = new MLabel();
    secsLabel->setObjectName("secsLabel");
    secsLabel->setText("seconds");
    secsLabel->setStyleName(inv("CommonSingleTitle"));

    gridSecs->addItem(entrySeconds, 0 , 0 , Qt::AlignVCenter);
    gridSecs->addItem(secsLabel, 0 , 1, Qt::AlignVCenter);

    elementsPolicyL->addItem(gridSecs);
    elementsPolicyP->addItem(gridSecs);

    buttonScreenshot = new MButton("Take it!");
    buttonScreenshot->setObjectName("screenshotButton");
    buttonScreenshot->setStyleName(inv("CommonSingleButton"));

    elementsPolicyL->addItem(buttonScreenshot);
    elementsPolicyP->addItem(buttonScreenshot);

    connect(buttonScreenshot, SIGNAL(clicked()), this, SLOT(screenshotDelay()));
    elementsPolicyL->addStretch();
    elementsPolicyP->addStretch();

    layoutPolicy->addItem(elementsLayout);

    retranslateUi();
}