void Ut_MGridLayoutPolicy::testLayoutInLayoutRefresh()
{
    m_policy->setSpacing(0);
    m_mockLayout->activate();

    QGraphicsWidget *widget = new QGraphicsWidget;
    MLayout *layout = new MLayout(widget);
    layout->setContentsMargins(0,0,0,0);
    MGridLayoutPolicy *policy = new MGridLayoutPolicy(layout);
    m_policy->addItem(widget,0,0);

    QGraphicsWidget *leftSpacerWithWidget = new QGraphicsWidget;
    policy->addItem(leftSpacerWithWidget, 0, 0);
    policy->addItem(m_mockItem100, 0, 1);
    policy->addItem(new QGraphicsWidget, 0, 2);
    policy->addItem(m_mockItem200, 0, 3);

    m_form->resize(400,200);

    qApp->processEvents();
    qApp->processEvents();

    QCOMPARE(m_mockItem100->geometry(), QRectF(50,0,100,100));
    QCOMPARE(m_mockItem200->geometry(), QRectF(200,0,200,200));

    leftSpacerWithWidget->setMaximumWidth(0);

    qApp->processEvents();

    QCOMPARE(m_mockItem100->geometry(), QRectF(0,0,100,100));
    QCOMPARE(m_mockItem200->geometry(), QRectF(200,0,200,200));
}
void ApplicationMenuPage::createContent()
{
    MApplicationPage::createContent();
    pannableViewport()->setAcceptGesturesFromAnyDirection(true);

    setStyleName(inv("CommonApplicationPage"));

    QGraphicsWidget *panel = centralWidget();

    infoLabel = new MLabel(panel);
    infoLabel->setObjectName("infoLabel");
    infoLabel->setStyleName(inv("CommonBodyText"));
    infoLabel->setWordWrap(true);
    infoLabel->setAlignment(Qt::AlignTop);

    actionItalic = new MAction(panel);
    actionItalic->setObjectName("actionItalic");
    actionItalic->setLocation(MAction::ApplicationMenuLocation);
    addAction(actionItalic);
    connect(actionItalic, SIGNAL(triggered()), this, SLOT(makeTextItalic()));

    actionNormal = new MAction(panel);
    actionNormal->setObjectName("actionNormal");
    actionNormal->setLocation(MAction::ApplicationMenuLocation);
    addAction(actionNormal);
    connect(actionNormal, SIGNAL(triggered()), this, SLOT(makeTextNormal()));

    MWidgetAction *widgetAction = new MWidgetAction(panel);
    widgetAction->setLocation(MAction::ApplicationMenuLocation);

    QStringList list;
    for (int i = 0; i < 5; ++i) {
        list << QString::number(100 + i);
    }
    comboBox = new MComboBox;
    comboBox->setObjectName("comboBox");
    comboBox->addItems(list);

    comboBox->setIconVisible(false);
    comboBox->setTitle("ComboBox");
    comboBox->setCurrentIndex(0);
    widgetAction->setWidget(comboBox);
    addAction(widgetAction);

    MLayout *layout = new MLayout(panel);
    layout->setContentsMargins(0, 0, 0, 0);
    panel->setLayout(layout);
    policy = new MLinearLayoutPolicy(layout, Qt::Vertical);
    policy->setContentsMargins(0, 0, 0, 0);
    policy->setSpacing(0);

    policy->addItem(infoLabel);

    retranslateUi();
}
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);
}
// ----------------------------------------------------------------------------
// 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
ImageLabel::ImageLabel(MWidget *parent): MStylableWidget(parent)
{
    MLayout *layout = new MLayout();
    layout->setAnimation(NULL);
    m_policy = new MLinearLayoutPolicy(layout, Qt::Horizontal);
    setLayout(layout);

    m_image = NULL;
    m_label = new MLabel;
    m_label->setTextElide(true);
    m_label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);

    m_policy->addItem(m_label);
}
void Ut_LauncherPageView::testUpdateData()
{
    QSharedPointer<LauncherButton> widget1(new LauncherButton(""));
    QSharedPointer<LauncherButton> widget2(new LauncherButton(""));
    LauncherPageModel::LauncherButtonList widgets;
    widgets.append(widget1);
    widgets.append(widget2);
    controller->model()->setLauncherButtons(widgets);

    MLayout* mainLayout = dynamic_cast<MLayout *>(controller->layout());
    QVERIFY(mainLayout != NULL);
    QCOMPARE(mainLayout->count(), 2);
    mainLayout->removeItem(widget1.data());
    mainLayout->removeItem(widget2.data());
    QCOMPARE(mainLayout->count(), 0);

    QList<const char*> modifications;
    modifications.append(LauncherPageModel::LauncherButtons);
    emit updateDataRequested(modifications);
    QCOMPARE(mainLayout->count(), 2);

    mainLayout->removeItem(widget1.data());
    mainLayout->removeItem(widget2.data());
    QCOMPARE(mainLayout->count(), 0);

    QList<const char*> modifications2;
    modifications.append("does not match");
    emit updateDataRequested(modifications2);
    QCOMPARE(mainLayout->count(), 0);
}
void
WarrantyWidget::createContent ()
{
    MLayout             *layout;
    MLinearLayoutPolicy *policy;

    layout = new MLayout;
    layout->setContentsMargins (0,0,0,0);

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

    /*
     * Add the title-bar
     */
    addHeaderContainer (policy);
#ifdef APP_TITLE_USES_SPACER
    addStretcher (policy, APP_TITLE_DIVIDER_STYLE_NAME);
#endif

    if (m_warrantyTimer) {
        // The label that shows the expiration date
        m_labelExpiration = new MLabel;
        m_labelExpiration->setObjectName ("WarrantyAppletExpirationLabel");
        m_labelExpiration->setStyleName ("CommonTitleInverted");
        m_labelExpiration->setWordWrap (true);
    }

    // The label that shows the terms of the warranty
    m_labelTerms = new MLabel;
    m_labelTerms->setObjectName ("WarrantyAppletTermsLabel");
    m_labelTerms->setStyleName ("CommonBodyTextInverted");
    m_labelTerms->setWordWrap (true);

    /*
     * Adding the two labels with a new container
     */
    addLabelContainer (policy, m_labelExpiration, m_labelTerms);

    policy->addStretch ();

    retranslateUi ();

    layout->setPolicy (policy);
    setLayout (layout);
}
Ejemplo n.º 8
0
void SheetsPage::createContent()
{
    MApplicationPage::createContent();

    QGraphicsWidget *panel = centralWidget();

    MLayout *layout = new MLayout(panel);
    layout->setContentsMargins(0, 0, 0, 0);
    panel->setLayout(layout);
    policy = new MLinearLayoutPolicy(layout, Qt::Vertical);
    policy->setContentsMargins(0, 0, 0, 0);
    policy->setSpacing(0);

    populateLayout();

    retranslateUi();
}
void MMashupCanvasViewPrivate::init()
{
    MLayout *dl = new MLayout;
    dl->setAnimation(NULL);
    layout = dl;
    mainLayout->addItem(layout);
    layoutPolicy = new MFlowLayoutPolicy(dl);
    appletInventoryButton = new MButton;
    appletInventory = new MAppletInventory;
    appletInventoryWindow = new MModalSceneWindow;
    appletInventoryViewport = new MPannableViewport(appletInventoryWindow);

    // Put the applet inventory inside a viewport
    appletInventoryViewport->setWidget(appletInventory);

    // TODO: FIXME - this needs to have the scene specified,
    // temporarily uses currently active MWindow's scene.
    QSize sceneSize = MApplication::activeWindow()->visibleSceneSize();

    appletInventoryViewport->setMinimumSize(sceneSize);
    appletInventoryViewport->setMaximumSize(sceneSize);

    // Create a dialog layout
    QGraphicsLinearLayout *dialogLayout = new QGraphicsLinearLayout();
    dialogLayout->setContentsMargins(0, 0, 0, 0);
    dialogLayout->addItem(appletInventoryViewport);
    appletInventoryWindow->setLayout(dialogLayout);
    appletInventoryWindow->setObjectName("MAppletInventoryWindow");

    // Create an applet inventory button
    appletInventoryButton->setObjectName("MAppletInventoryButton");
    //~ uispec-document ??? FIXME
    //% "Applet Library"
    appletInventoryButton->setText(qtTrId("qtn_appl_inventory"));

    // Add the applet inventory button to a horizontal layout for centering
    QGraphicsLinearLayout *l = new QGraphicsLinearLayout(Qt::Horizontal);
    l->setContentsMargins(0, 0, 0, 0);
    l->addStretch();
    l->addItem(appletInventoryButton);
    l->addStretch();

    // Add the horizontal layout to the main layout
    mainLayout->addItem(l);
}
void Ut_LauncherPageView::testRemovingButtonFromLayout()
{
    QSharedPointer<LauncherButton> widget1(new LauncherButton(""));
    QSharedPointer<LauncherButton> widget2(new LauncherButton(""));
    LauncherPageModel::LauncherButtonList widgets;
    widgets.append(widget1);
    widgets.append(widget2);
    controller->model()->setLauncherButtons(widgets);

    widgets.removeOne(widget1);
    controller->model()->setLauncherButtons(widgets);

    MLayout* mainLayout = dynamic_cast<MLayout *>(controller->layout());
    QVERIFY(mainLayout != NULL);
    QCOMPARE(mainLayout->count(), 1);
    QCOMPARE(mainLayout->itemAt(0), widget2.data());
    // verify that button destructor has not been called when there is still ref in QSharedPointer
    QCOMPARE(gLauncherButtonStub->stubCallCount("~LauncherButton"), 0);
}
Ejemplo n.º 11
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();
}
Ejemplo n.º 12
0
void CountryPage::createContent()
{
  if (m_pageMode == CountryModel::BY_ARTIST)
    m_countryModel = new CountryModel(m_dbStorage, m_artistID);
  else
    m_countryModel = new CountryModel(m_dbStorage);

  QGraphicsWidget *panel = centralWidget();
  MLayout *layout = new MLayout(panel);
  layout->setAnimation(NULL);
  panel->setLayout(layout);
  m_policy = new MLinearLayoutPolicy(layout, Qt::Vertical);

  // No country label
  m_noCountryLabel = new MLabel(tr("No events to show.<br/>"
                                   "Possible reasons:<br/>"
                                   "<ul>"
                                   "<li>None of your artist is on tour.</li>"
                                   "<li>You don't have added an artist yet.</li>"
                                   "</ul>"));
  m_noCountryLabel->setAlignment(Qt::AlignJustify);
  if (m_countryModel->rowCount() == 0) {
    m_policy->addItem(m_noCountryLabel);
    m_noCountryLabelVisible = true;
  } else
    m_noCountryLabelVisible = false;

  MList *countryList = new MList();
  countryList->setSelectionMode(MList::SingleSelection);

  CountryItemCreator *cellCreator = new CountryItemCreator();
  countryList->setCellCreator(cellCreator);
  countryList->setItemModel(m_countryModel);
  m_policy->addItem(countryList);

  connect (countryList, SIGNAL(itemClicked(QModelIndex)),
           this, SLOT(slotCountryClicked(QModelIndex)));
  connect (DBManager::instance(m_dbStorage), SIGNAL(locationCreated(int)),
           this, SLOT(slotLocationCreated(int)));
}
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();
}
void Ut_LauncherPageView::testAddButtonsToPage()
{
    QSharedPointer<LauncherButton> widget1(new LauncherButton(""));
    QSharedPointer<LauncherButton> widget2(new LauncherButton(""));
    QSharedPointer<LauncherButton> widget3(new LauncherButton(""));
    QSharedPointer<LauncherButton> widget4(new LauncherButton(""));
    LauncherPageModel::LauncherButtonList widgets;
    widgets.append(widget1);
    controller->model()->setLauncherButtons(widgets);
    // add several widgets so that the order is tested better
    widgets.append(widget2);
    widgets.append(widget3);
    widgets.append(widget4);
    controller->model()->setLauncherButtons(widgets);

    MLayout* mainLayout = dynamic_cast<MLayout *>(controller->layout());
    QVERIFY(mainLayout != NULL);

    QCOMPARE(mainLayout->count(), widgets.count());
    for (int i = 0; i < mainLayout->count(); i++) {
        QCOMPARE(mainLayout->itemAt(i), widgets.at(i).data());
    }
}
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);
}
MColorListViewPrivate::MColorListViewPrivate(MColorListView *p, MColorList *controller)
    : q_ptr(p), controller(controller), landscapePolicy(0), portraitPolicy(0), buttonGroup(0)
{
    QGraphicsGridLayout *layout = new QGraphicsGridLayout();
    layout->setContentsMargins(0, 0, 0, 0);
    layout->setSpacing(0);
    controller->setLayout(layout);

    MStylableWidget* container = new MStylableWidget();
    container->setStyleName("ColorSelectionContainer");
    MLayout *containerLayout = new MLayout();
    container->setLayout(containerLayout);

    landscapePolicy = new MGridLayoutPolicy(containerLayout);
    landscapePolicy->setContentsMargins(0, 0, 0, 0);
    landscapePolicy->setSpacing(0);
    containerLayout->setLandscapePolicy(landscapePolicy);

    portraitPolicy = new MGridLayoutPolicy(containerLayout);
    portraitPolicy->setContentsMargins(0, 0, 0, 0);
    portraitPolicy->setSpacing(0);
    containerLayout->setPortraitPolicy(portraitPolicy);

    layout->addItem(container, 0, 0);

    // Current color list
    colors << QColor(0x95, 0xE8, 0x5D);
    colors << QColor(0x73, 0xC0, 0xF5);
    colors << QColor(0xCB, 0xA4, 0xDE);
    colors << QColor(0xE9, 0x48, 0xA3);
    colors << QColor(0xFF, 0x9E, 0x9E);
    colors << QColor(0xFF, 0xF6, 0x57);
    colors << QColor(0x9C, 0x9C, 0x9C);

    colors << QColor(0x74, 0xD9, 0x41);
    colors << QColor(0x31, 0xB0, 0xDE);
    colors << QColor(0xBC, 0x79, 0xDE);
    colors << QColor(0xE9, 0x48, 0xA3);
    colors << QColor(0xFF, 0x79, 0x4D);
    colors << QColor(0xFB, 0xFF, 0x14);
    colors << QColor(0x80, 0x80, 0x80);

    colors << QColor(0x55, 0xD5, 0x00);
    colors << QColor(0x00, 0x88, 0xE6);
    colors << QColor(0xAE, 0x4E, 0xDE);
    colors << QColor(0xE9, 0x48, 0xA3);
    colors << QColor(0xFF, 0x40, 0x00);
    colors << QColor(0xFF, 0xE6, 0x00);
    colors << QColor(0x4D, 0x4D, 0x4D);

    colors << QColor(0x45, 0x90, 0x27);
    colors << QColor(0x00, 0x6F, 0xBA);
    colors << QColor(0x89, 0x3D, 0xAF);
    colors << QColor(0xE9, 0x48, 0xA3);
    colors << QColor(0xCC, 0x33, 0x00);
    colors << QColor(0xFF, 0x90, 0x00);
    colors << QColor(0x33, 0x33, 0x33);

    colors << QColor(0x00, 0x73, 0x00);
    colors << QColor(0x00, 0x41, 0x82);
    colors << QColor(0x5E, 0x2A, 0x78);
    colors << QColor(0xE9, 0x48, 0xA3);
    colors << QColor(0xB5, 0x2D, 0x00);
    colors << QColor(0xFF, 0x6A, 0x00);
    colors << QColor(0x1A, 0x1A, 0x1A);
}
CalculatorWidget::CalculatorWidget()
{
    mValue = 0;

    //Prevent the layout from changing in right-to-left.
    //The calculation line will still be reversed however.
    setLayoutDirection(Qt::LeftToRight);

    /* Create a MLayout attached to this widget */
    MLayout *layout = new MLayout(this);

    MGridLayoutPolicy *landscapePolicy = new MGridLayoutPolicy(layout);
    MGridLayoutPolicy *portraitPolicy = new MGridLayoutPolicy(layout);
    layout->setPortraitPolicy(portraitPolicy);
    layout->setLandscapePolicy(landscapePolicy);

    landscapePolicy->setObjectName("calculatorLandscape");
    portraitPolicy->setObjectName("calculatorPortrait");

    mCalculationLine = new MLabel;
    mCalculationLine->setObjectName("calculationLine");
    mCalculationLine->setAlignment(Qt::AlignRight);

    QList<CalculatorButton *> buttons;
    CalculatorButton *button;
    for (int i = 0; i < 10; i++) {
        button = new CalculatorButton(CalculatorButton::Button((int)CalculatorButton::Num0 + i), this);
        if (i == 0) {
            landscapePolicy->addItem(button, 3, 4);
            portraitPolicy->addItem(button, 6, 0);
        } else {
            landscapePolicy->addItem(button, 2 - (i - 1) / 3, 4 + (i - 1) % 3);
            portraitPolicy->addItem(button, 5 - (i - 1) / 3, (i - 1) % 3);
        }
    }

    CalculatorButton *buttonC = new CalculatorButton(CalculatorButton::Clear, this);
    CalculatorButton *buttonBackspace = new CalculatorButton(CalculatorButton::Backspace, this);
    CalculatorButton *buttonSign = new CalculatorButton(CalculatorButton::Sign, this);
    CalculatorButton *buttonDecimal = new CalculatorButton(CalculatorButton::Decimal, this);
    CalculatorButton *buttonReciprocal = new CalculatorButton(CalculatorButton::Reciprocal, this);
    CalculatorButton *buttonPower = new CalculatorButton(CalculatorButton::Power, this);
    CalculatorButton *buttonSqrt = new CalculatorButton(CalculatorButton::Sqrt, this);
    CalculatorButton *buttonPercentage = new CalculatorButton(CalculatorButton::Percentage, this);
    CalculatorButton *buttonDivide = new CalculatorButton(CalculatorButton::Divide, this);
    CalculatorButton *buttonMultiply = new CalculatorButton(CalculatorButton::Multiply, this);
    CalculatorButton *buttonSubtract = new CalculatorButton(CalculatorButton::Subtract, this);
    CalculatorButton *buttonAdd = new CalculatorButton(CalculatorButton::Add, this);
    CalculatorButton *buttonEquals = new CalculatorButton(CalculatorButton::Equals, this);
    buttonEquals->setObjectName("calculatorButtonEquals");

    landscapePolicy->addItem(mCalculationLine, 0, 0, 1, 4);
    landscapePolicy->addItem(buttonC, 1, 0);
    landscapePolicy->addItem(buttonBackspace, 1, 1);
    landscapePolicy->addItem(buttonSign, 1, 2);
    landscapePolicy->addItem(buttonDecimal, 1, 3);
    landscapePolicy->addItem(buttonReciprocal, 2, 0);
    landscapePolicy->addItem(buttonPower, 2, 1);
    landscapePolicy->addItem(buttonSqrt, 2, 2);
    landscapePolicy->addItem(buttonPercentage, 2, 3);
    landscapePolicy->addItem(buttonDivide, 3, 0);
    landscapePolicy->addItem(buttonMultiply, 3, 1);
    landscapePolicy->addItem(buttonSubtract, 3, 2);
    landscapePolicy->addItem(buttonAdd, 3, 3);
    landscapePolicy->addItem(buttonEquals, 3, 5, 1, 2);

    portraitPolicy->addItem(mCalculationLine, 0, 0, 1, 4);
    portraitPolicy->addItem(buttonC, 1, 0);
    portraitPolicy->addItem(buttonBackspace, 1, 1);
    portraitPolicy->addItem(buttonReciprocal, 1, 2);
    portraitPolicy->addItem(buttonDivide, 1, 3);
    portraitPolicy->addItem(buttonPower, 2, 0);
    portraitPolicy->addItem(buttonSqrt, 2, 1);
    portraitPolicy->addItem(buttonPercentage, 2, 2);
    portraitPolicy->addItem(buttonMultiply, 2, 3);
    portraitPolicy->addItem(buttonSubtract, 3, 3);
    portraitPolicy->addItem(buttonAdd, 4, 3);
    portraitPolicy->addItem(buttonEquals, 5, 3, 2, 1);
    portraitPolicy->addItem(buttonDecimal, 6, 1);
    portraitPolicy->addItem(buttonSign, 6, 2);

    setValue(mValue);
}
Ejemplo n.º 18
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;
}
SwAcctEditPage::SwAcctEditPage(SwClientService *swService, QGraphicsItem *parent) :
        MApplicationPage(parent),
        mService(swService),
        mServiceConfig(mService->getServiceConfig()),
        mFlickrClicked(false)
{
    int adj = 0;
    setEscapeMode(MApplicationPageModel::EscapeManualBack);
    connect(this, SIGNAL(backButtonClicked()),
            this, SLOT(dismiss()));

    connect(mService,
            SIGNAL(CredsStateChanged(SwClientService*,SwClientService::CredsState)),
            this,
            SLOT(onCredsStateChanged(SwClientService *, SwClientService::CredsState)));
    if (!mServiceConfig->isValid())
        dismiss();
    mParams = mServiceConfig->getConfigParams();

    MLayout *layout = new MLayout;
    MGridLayoutPolicy *policy = new MGridLayoutPolicy(layout);

    QString link = mServiceConfig->getLink();
    MLabel *lblServiceName = new MLabel();
    if (!link.isEmpty())
        lblServiceName->setText(QString("<a href=\"%1\">%2</a>").arg(link, mServiceConfig->getDisplayName()));
    else
        lblServiceName->setText(mServiceConfig->getDisplayName());
    lblServiceName->setObjectName("SwAcctEditPageServiceNameLabel");
    policy->addItem(lblServiceName, 0, 0, 1, 2, Qt::AlignHCenter);

    connect(lblServiceName,
            SIGNAL(linkActivated(QString)),
            this,
            SLOT(onLinkClicked(QString)));

    QString desc = mServiceConfig->getDescription();
    if (!desc.isEmpty()) {
        MLabel *lblServiceDesc = new MLabel();
        lblServiceDesc->setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
        lblServiceDesc->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
        //Have to insert a random HTML tag to make word wrap actually work...
        //Should be able to remove at some point once MTF word wrap works properly
        lblServiceDesc->setText(QString("<b></b>").append(desc));
        lblServiceDesc->setObjectName("SwAcctEditPageServiceDescLabel");
        policy->addItem(lblServiceDesc, 1, 0, 1, 2, Qt::AlignLeft);
    } else {
        adj -= 1;
    }

    //This is *ugly*
    if (mServiceConfig->getAuthtype() == SwClientServiceConfig::AuthTypeFlickr) {
        if (!mParams.value(USER_KEY).isEmpty()) {
            //% "User %1"
            MLabel *lblUsername = new MLabel(qtTrId("label_flickr_username").arg(mParams.value(USER_KEY)));
            lblUsername->setObjectName("SwAcctEditPageFlickrUserLabel");
            policy->addItem(lblUsername, 2+adj, 0, 1, 2, Qt::AlignHCenter);
            adj += 1;
        }

        mFlickrButton = new MButton();
        mFlickrButton->setObjectName("SwAcctEditPageFlickrButton");
        policy->addItem(mFlickrButton, 2+adj, 0, 1, 2, Qt::AlignHCenter);

        connect(mFlickrButton,
                SIGNAL(clicked()),
                this,
                SLOT(onFlickrClicked()));

        adj += 1;
    } else {
        MLabel *lblUsername = new MLabel();
        lblUsername->setObjectName("SwAcctEditPageUsernameLabel");
        lblUsername->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
        //% "Username:"******"label_username"));
        policy->addItem(lblUsername, 2+adj, 0);

        mEdtUsername = new MTextEdit(MTextEditModel::SingleLine);
        mEdtUsername->setObjectName("SwAcctEditPageUsernameButton");
        mEdtUsername->setText(mParams.value(USER_KEY));
        //qDebug() << QString("Set username to %1").arg(mParams.value(USER_KEY));
        policy->addItem(mEdtUsername, 2+adj, 1);

        if (mServiceConfig->getAuthtype() == SwClientServiceConfig::AuthTypePassword) {
            MLabel *lblPassword = new MLabel();
            lblPassword->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
            //% "Password:"******"label_password"));
            lblPassword->setObjectName("SwAcctEditPagePasswordLabel");
            policy->addItem(lblPassword, 3+adj, 0);
            mEdtPassword = new MTextEdit(MTextEditModel::SingleLine);
            mEdtPassword->setText(mParams.value(PASS_KEY));
            mEdtPassword->setEchoMode(MTextEditModel::Password);
            mEdtPassword->setObjectName("SwAcctEditPagePasswordButton");
    //        qDebug() << QString("Set password to %1").arg(mParams.value(PASS_KEY));
            policy->addItem(mEdtPassword, 3+adj, 1);
            connect(mEdtPassword,
                    SIGNAL(textChanged()),
                    this,
                    SLOT(onLoginChanged()));
            adj += 1;
        }
    }

    mLblStatus = new MLabel(STATUS_TEXT_UNCONFIGURED);
    mLblStatus->setObjectName("SwAcctEditPageStatusLabel");
    policy->addItem(mLblStatus, 3+adj, 0, 1, 2, Qt::AlignHCenter);

    onCredsStateChanged(mService, mService->credsState());

    MLabel *lblServiceHint = new MLabel();
    lblServiceHint->setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
    lblServiceHint->setObjectName("SwAcctEditPageServiceHintLabel");
    lblServiceHint->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    lblServiceHint->setText(SERVICE_HINT_TEXT.arg(mService->getDisplayName()));
    policy->addItem(lblServiceHint, 4+adj, 0, 1, 2);


    //This, also, is *ugly*
    if (mServiceConfig->getAuthtype() != SwClientServiceConfig::AuthTypeFlickr) {
        //% "Apply"
        mBtnApply = new MButton(qtTrId("button_apply"));
        mBtnApply->setObjectName("SwAcctEditPageApplyButton");
        policy->addItem(mBtnApply, 5+adj, 0, 1, 2, Qt::AlignHCenter);

        //% "Cancel"
        mBtnCancel = new MButton(qtTrId("button_cancel"));
        mBtnCancel->setObjectName("SwAcctEditPageCancelButton");
        policy->addItem(mBtnCancel, 6+adj, 0, 1, 2, Qt::AlignHCenter);

        connect(mEdtUsername,
                SIGNAL(textChanged()),
                this,
                SLOT(onLoginChanged()));

        connect(mBtnApply,
                SIGNAL(clicked()),
                this,
                SLOT(onApplyClicked()));
        connect(mBtnCancel,
                SIGNAL(clicked()),
                this,
                SLOT(dismiss()));
    }


    layout->setPolicy(policy);
    centralWidget()->setLayout(layout);
}
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();
}
Ejemplo n.º 22
0
void ArtistPage::createContent()
{
  MApplicationPage::createContent();

  QGraphicsWidget *panel = centralWidget();
  MLayout* layout = new MLayout(panel);
  m_policy = new MLinearLayoutPolicy(layout, Qt::Vertical);
  layout->setAnimation(NULL);
  panel->setLayout(layout);
  layout->setLandscapePolicy(m_policy);
  layout->setPortraitPolicy(m_policy);

  if (m_pageMode == ALL_ARTISTS) {
    // Menu Actions
    MAction* actionImportLastfm = new MAction(panel);
    actionImportLastfm->setText(tr("Import from Last.fm"));
    actionImportLastfm->setLocation(MAction::ApplicationMenuLocation);
    addAction(actionImportLastfm);
    connect(actionImportLastfm, SIGNAL(triggered()), this, SLOT(slotImportLastfm()));

    MAction* actionAddArtist = new MAction(panel);
    actionAddArtist->setText(tr("Add artist"));
    actionAddArtist->setLocation(MAction::ApplicationMenuLocation);
    addAction(actionAddArtist);
    connect(actionAddArtist, SIGNAL(triggered()), this, SLOT(slotAddArtist()));

    // Toolbar Actions
    MAction* actionFilter = new MAction("icon-m-toolbar-filter", "", this);
    actionFilter->setLocation(MAction::ToolBarLocation);
    addAction(actionFilter);
    connect(actionFilter, SIGNAL(triggered()), this, SLOT(slotShowFilter()));
  }

  MAction* actionRefresh = new MAction("icon-m-toolbar-refresh", "", this);
  actionRefresh->setLocation(MAction::ToolBarLocation);
  addAction(actionRefresh);
  connect(actionRefresh, SIGNAL(triggered()), this, SLOT(slotRefreshEvents()));

  MAction* actionSearch = new MAction("icon-m-toolbar-search", "", this);
  actionSearch->setLocation(MAction::ToolBarLocation);
  addAction(actionSearch);
  connect(actionSearch, SIGNAL(triggered()), this, SLOT(slotShowSearch()));

  // setup model
  m_artistsModel = new ArtistModel(m_dbStorage, artistsModelQuery());

  // filtering text box
  QGraphicsLinearLayout *containerLayout = new QGraphicsLinearLayout(Qt::Horizontal);

  MLabel* filterLabel = new MLabel(tr("Filter artist:"));
  containerLayout->addItem(filterLabel);

  m_filter = new MTextEdit(MTextEditModel::SingleLine, QString());
  containerLayout->addItem(m_filter);
  m_filter->setObjectName("CommonSingleInputField");
  connect(m_filter, SIGNAL(textChanged()), this, SLOT(slotFilterChanged()));

  m_filterWidget = new MWidget();
  m_filterWidget->setLayout(containerLayout);

  // No artist found label
  m_noArtistLabel = new MLabel(tr("No artist available, add them using one of "
                                  "menu options."));
  m_noArtistLabel->setAlignment(Qt::AlignCenter);
  if (m_artistsModel->rowCount() == 0)
    m_policy->addItem(m_noArtistLabel);

  // MList with fast view
  MList* artistsList = new MList();
  artistsList->setSelectionMode(MList::SingleSelection);

  // Content item creator and item model for the list
  artistsList->setCellCreator(new ArtistItemCreator(m_pageMode, m_dbStorage,
                                                    m_country));
  artistsList->setItemModel(m_artistsModel);
  m_policy->addItem(artistsList);

  connect(artistsList, SIGNAL(itemClicked(QModelIndex)),
           this, SLOT(slotArtistClicked(QModelIndex)));
  connect(DBManager::instance(m_dbStorage), SIGNAL(artistAdded(int,bool)),
           this, SLOT(slotArtistAdded(int,bool)));

  if (m_pageMode == ARTIST_NEAR_LOCATION_SEARCH) {
    //overwrite history
    MApplicationWindow* appWindow = applicationWindow();
    MScene* scene = appWindow->scene();
    MSceneManager* sceneManager = scene->sceneManager();
    QList<MSceneWindow*> history = sceneManager->pageHistory();
    if (history.last()->metaObject()->className() == NearLocationSearchPage::staticMetaObject.className()) {
      // overwrite history only if the last page is NearLocationSearchPage
      history.removeAt(history.size()-1);
      if (history.last()->metaObject()->className() != NearLocationMainPage::staticMetaObject.className()) {
        MApplicationPage* prevPage = new NearLocationMainPage();
        history << prevPage;
      }
      sceneManager->setPageHistory(history);
    }

    //search events
    m_lastfm->getEventsNearLocation(m_latitude, m_longitude, m_distance);
  }

  if (m_dbStorage == DBManager::DISK) {
    DBManager* db = DBManager::instance(m_dbStorage);
    QStringList incompleteArtists = db->incompleteArtists();
    foreach(QString artist, incompleteArtists) {
      m_lastfm->getEventsForArtist(artist);
    }
// ----------------------------------------------------------------------------
// 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 ConversationPage::createContent()
{
    MApplicationPage::createContent();
    setContentsMargins(0, 0, 0, 0);
    setPannable(true);

    createActions();
    //% "Mail"
    setTitle(qtTrId("xx_page_title"));

    MLayout *layout = new MLayout(centralWidget());
    layout->setContentsMargins(0, 0, 0, 0);
    layout->setAnimation(0);

    m_policy = new MLinearLayoutPolicy(layout, Qt::Vertical);
    m_policy->setObjectName("VerticalPolicy");
    m_policy->setContentsMargins(0, 0, 0, 0);
    m_policy->setSpacing(0);

    QMailMessage message(m_id);
    //% "From"
    QString body = qtTrId("xx_from") + ": " + message.from().address() + "\n";
    QStringList addresses = QMailAddress::toStringList(message.to());
    //% "To"
    body.append(qtTrId("xx_to") + ": "  + addresses.join("; ") + "\n");
    addresses = QMailAddress::toStringList(message.cc());
    if (addresses.size() > 0)
        //% "Cc"
        body.append(qtTrId("xx_cc" ) + ": " + addresses.join("; ") + "\n");
    addresses = QMailAddress::toStringList(message.bcc());
    if (addresses.size() > 0)
        //% "Bcc"
        body.append(qtTrId("xx_bcc" ) + ": " + addresses.join("; ") + "\n");

    QMailAddress replyTo = message.replyTo();
    if (!replyTo.isNull())
        //% "Reply-To"
        body.append(qtTrId("xx_reply_to") + ": " + replyTo.toString() + "\n");

    //% "Subject"
    body.append(qtTrId("xx_subject") + ": " + message.subject() + "\n");
    //% "Date: %1"
    body.append(qtTrId("xx_date").arg(message.date().toLocalTime().toString(Qt::SystemLocaleShortDate)));
    MLabel *messageBody = new MLabel(body);
    messageBody->setWordWrap(true);
    messageBody->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    messageBody->setObjectName("BodyText");
    m_policy->addItem(messageBody);

    MSeparator *separator = new MSeparator();
    separator->setObjectName("Separator");
    m_policy->addItem(separator);

    messageBody = new MLabel("\n" + Utils::bodyPlainText(&message));
    messageBody->setWordWrap(true);
    messageBody->setObjectName("BodyText");
    messageBody->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);

    m_policy->addItem (messageBody);
    processAttachments(message);

    centralWidget()->setLayout(layout);
}
Ejemplo n.º 25
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);
}