QGraphicsWidget* StatusIndicatorMenuDropDownView::createTopRow()
{
    // Create an extension area for the top row plugins
    settingsPluginsExtensionArea = new MApplicationExtensionArea("com.meego.core.MStatusIndicatorMenuExtensionInterface/1.0");
    connect(settingsPluginsExtensionArea, SIGNAL(extensionInstantiated(MApplicationExtensionInterface*)), controller, SLOT(setStatusIndicatorMenuInterface(MApplicationExtensionInterface*)));
    settingsPluginsExtensionArea->setObjectName("StatusIndicatorMenuTopRowExtensionArea");
    settingsPluginsExtensionArea->setInProcessFilter(QRegExp("/statusindicatormenu-(volume|alarms|internetconnection|presence|profile).desktop$"));
    settingsPluginsExtensionArea->setOutOfProcessFilter(QRegExp("$^"));
    settingsPluginsExtensionArea->setOrder((QStringList()  << "statusindicatormenu-volume.desktop" << "statusindicatormenu-alarms.desktop" << "statusindicatormenu-internetconnection.desktop" << "statusindicatormenu-presence.desktop" << "statusindicatormenu-profile.desktop"));

    // Create a button for accessing the full settings
    //% "Settings"
    MButton *settingsButton = new MButton(qtTrId("qtn_stat_menu_settings"));
    settingsButton->setObjectName("StatusIndicatorMenuTopRowExtensionButton");
    settingsButton->setViewType(MButton::iconType);
    settingsButton->setIconID("icon-m-status-menu-settings");
    connect(settingsButton, SIGNAL(clicked()), controller, SLOT(launchControlPanelAndHide()));

    // Put the extension area and the settings button to a horizontal layout
    QGraphicsLinearLayout *topRowLayout = new QGraphicsLinearLayout(Qt::Horizontal);
    topRowLayout->setContentsMargins(0, 0, 0, 0);
    topRowLayout->setSpacing(0);
    topRowLayout->addStretch();
    topRowLayout->addItem(settingsPluginsExtensionArea);
    topRowLayout->addItem(settingsButton);
    topRowLayout->addStretch();

    // Create a container widget for extension area and settings button layout
    MWidgetController *topRowWidget = new MStylableWidget;
    topRowWidget->setStyleName("StatusIndicatorMenuExtensionAreaWidget");
    topRowWidget->setLayout(topRowLayout);

    return topRowWidget;
}
MPannableViewport* StatusIndicatorMenuDropDownView::createPannableArea()
{
    // Create pannable area contents
    statusIndicatorExtensionArea = createVerticalExtensionArea();

    QGraphicsLinearLayout *contentLayout = new QGraphicsLinearLayout(Qt::Vertical);
    contentLayout->setContentsMargins(0, 0, 0, 0);
    contentLayout->setSpacing(0);
    contentLayout->addItem(statusIndicatorExtensionArea);

    MWidgetController *contentWidget = new MStylableWidget;
    contentWidget->setStyleName("StatusIndicatorMenuContentWidget");
    contentWidget->setLayout(contentLayout);

    QGraphicsLinearLayout *pannableLayout = new QGraphicsLinearLayout(Qt::Vertical);
    pannableLayout->setContentsMargins(0, 0, 0, 0);
    pannableLayout->setSpacing(0);
    pannableLayout->addItem(contentWidget);
    QGraphicsWidget *closeButtonRow = createCloseButtonRow();
    pannableLayout->addItem(closeButtonRow);
    pannableLayout->addStretch();

    // Create a container widget for the pannable area
    PannedWidgetController *pannedWidget = new PannedWidgetController;
    pannedWidget->setLayout(pannableLayout);
    pannedWidget->setBottommostWidget(closeButtonRow);
    connect(pannedWidget, SIGNAL(positionOrSizeChanged()), this, SLOT(setPannabilityAndLayout()));
    connect(pannedWidget, SIGNAL(pressedOutSideContents()), controller, SIGNAL(hideRequested()));

    // Setup the pannable viewport
    MPannableViewport *pannableViewport = new MPannableViewport;
    pannableViewport->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    pannableViewport->setWidget(pannedWidget);
    return pannableViewport;
}
Пример #3
0
void Mt_MLabel::testLabelVsMWidgetController()
{
    // Create MWidgetController + MWidgetView combination
    beginMemoryBenchmark();
    MWidgetModel *m = new MWidgetModel;
    MWidgetController *c = new MWidgetController(m, NULL);
    MWidgetView *view = new MWidgetView(c);
    c->setView(view);
    qDebug() << "Memory consumption of MWidgetController + MWidgetView:";
    outputAllocatedMemorySize();

    delete c; c = NULL;
    QCoreApplication::processEvents();
    endMemoryBenchmark();

    // Create MLabel + MLabelView combination
    beginMemoryBenchmark();
    MLabelModel *lm = new MLabelModel;
    MLabel *l = new MLabel(NULL, lm);
    MLabelView *lv = new MLabelView(l);
    l->setView(lv);
    qDebug() << "Memory consumption of MLabel + MLabelView:";
    outputAllocatedMemorySize();

    delete l; l = NULL;
    QCoreApplication::processEvents();
    endMemoryBenchmark();
}
void MToolBarLayoutPolicy::setLayoutPosition(int widgetIndex, M::Position position)
{
    MWidgetController* widget = dynamic_cast<MWidgetController*>(widgetAt(widgetIndex));
    if (widget) {
        widget->setLayoutPosition(position);
    }
}
void StatusIndicatorMenuVerticalView::setExtensionLayoutPosition(MApplicationExtensionInterface *extension)
{
    MWidgetController *widget = dynamic_cast<MWidgetController*>(extension->widget());

    if (widget) {
        widget->setLayoutPosition(M::VerticalCenterPosition);
    }
}
Пример #6
0
void MScenePrivate::drawStyleNames(QPainter *painter, QList<QGraphicsItem *>::iterator item)
{
    Q_Q(MScene);

    QRectF br = (*item)->boundingRect();
    QPolygonF bp = (*item)->mapToScene(br);

    MWidgetController *widget = 0;
    if ((*item)->isWidget()) {
        widget = qobject_cast<MWidgetController *>(static_cast<QGraphicsWidget*>(*item));
    }

    if (widget) {
        fpsBackgroundBrush.setColor(Qt::transparent);
        painter->setOpacity(1.0);
        QString name = widget->styleName();
        QRectF boundingRect = bp.boundingRect();
        QRect textBoundingRect = metrics.boundingRect(name);
        QPointF center;
        painter->setPen(stylesTextColor);
        if (q->sceneManager()->orientationAngle()== M::Angle0) {
            center = boundingRect.topLeft();
            center += QPointF(0.0 , boundingRect.height() / 4);
            painter->fillRect(textBoundingRect.translated(center.toPoint()), fpsBackgroundBrush);
            painter->drawText(center, name);
        } else if (q->sceneManager()->orientationAngle() == M::Angle90) {
            center = boundingRect.topLeft();
            center += QPointF(boundingRect.width() / 3, 0.0);
            painter->save();
            painter->fillRect(textBoundingRect.translated(center.toPoint()), fpsBackgroundBrush);
            painter->translate(center);
            painter->rotate(90);
            painter->drawText(0, 0, name);
            painter->restore();
        } else if (q->sceneManager()->orientationAngle() == M::Angle180) {
            center = boundingRect.topLeft();
            center += QPointF(0.0 , boundingRect.height() / 4);
            painter->save();
            painter->fillRect(textBoundingRect.translated(center.toPoint()), fpsBackgroundBrush);
            painter->translate(center);
            painter->rotate(180);
            painter->drawText(0, 0, name);
            painter->restore();
        } else if (q->sceneManager()->orientationAngle() == M::Angle270) {
            center = boundingRect.bottomLeft();
            center += QPointF(boundingRect.width() / 3, 0.0);
            painter->save();
            painter->fillRect(textBoundingRect.translated(center.toPoint()), fpsBackgroundBrush);
            painter->translate(center);
            painter->rotate(270);
            painter->drawText(0, 0, name);
            painter->restore();
        }
    }
    fpsBackgroundBrush.setColor(FpsBackgroundColor);
}
void Ut_MPannableViewport::testSignalsOnDestroy()
{
    QFETCH(bool, instantInvalidateEnabled);

    bool oldInstantInvalidateEnabled = QGraphicsLayout::instantInvalidatePropagation();

    QGraphicsLayout::setInstantInvalidatePropagation(instantInvalidateEnabled);

    QGraphicsWidget *panel = new QGraphicsWidget;
    panel->setMinimumSize(500, 500);

    subject->setParentItem(panel);
    subject->setAutoRange(true);
    MWidgetController *widget = new MWidgetController(subject);
    widget->setMinimumHeight(1000);
    subject->resize(panel->minimumSize());
    subject->setWidget(widget);

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

    QCOMPARE(subject->size(), panel->minimumSize());
    QCOMPARE(widget->size().height(), (qreal)1000);

    QSignalSpy rangeChangedSpy(subject, SIGNAL(rangeChanged(QRectF)));
    QSignalSpy positionChangedSpy(subject, SIGNAL(positionChanged(QPointF)));

    QSignalSpy subjectDestroyedSpy(subject, SIGNAL(destroyed()));
    QSignalSpy widgetDestroyedSpy(widget, SIGNAL(destroyed()));

    delete panel;
    subject = 0;

    QCOMPARE(rangeChangedSpy.count(), 0);
    QCOMPARE(positionChangedSpy.count(), 0);
    QCOMPARE(subjectDestroyedSpy.count(), 1);
    QCOMPARE(widgetDestroyedSpy.count(), 1);

    qApp->processEvents();

    QCOMPARE(rangeChangedSpy.count(), 0);
    QCOMPARE(positionChangedSpy.count(), 0);
    QCOMPARE(subjectDestroyedSpy.count(), 1);
    QCOMPARE(widgetDestroyedSpy.count(), 1);

    QGraphicsLayout::setInstantInvalidatePropagation(oldInstantInvalidateEnabled);
}
Пример #8
0
void PeopleApplication::createEditPage(const QModelIndex &index, const QString& title)
{
    if (m_editPage)
        return;

    QModelIndex useIndex;

    if (index.isValid())
        useIndex = index;
    else
        useIndex = m_currentIndex;

    if (useIndex.isValid())
        m_editModel = SeasideSyncModel::createPersonModel(useIndex);
    else  // create empty edit model to add new contact
        m_editModel = new SeasidePersonModel;
    MWidgetController *person = new MWidgetController(m_editModel);
    person->setViewType("personEdit");

    m_editModelModified = false;
    connect(m_editModel, SIGNAL(modified(QList<const char*>)),
            this, SLOT(editModified()));

    m_editPage = new MApplicationPage;
    if (title.isNull())
        m_editPage->setTitle(QObject::tr("Edit Contact","Title for edit screen"));
    else
        m_editPage->setTitle(title);
    m_editPage->setCentralWidget(person);

    MAction *action = new MAction(QObject::tr("<b>Save</b>","Save toolbar button for edit screen"), this);
    action->setLocation(MAction::ApplicationMenuLocation);
    m_editPage->addAction(action);
    connect(action, SIGNAL(triggered()), this, SLOT(editSave()));

    connect(m_editPage, SIGNAL(backButtonClicked()), this, SLOT(editBack()));

    m_editPage->appear(MApplicationPage::DestroyWhenDismissed);
}
QGraphicsWidget* StatusIndicatorMenuDropDownView::createCloseButtonRow()
{
    // Create a close button for the pannable area
    MButton *closeButton = new MButton;
    closeButton->setViewType("icon");
    closeButton->setObjectName("StatusIndicatorMenuCloseButton");
    closeButton->setIconID("icon-m-framework-close");
    connect(closeButton, SIGNAL(clicked()), controller, SIGNAL(hideRequested()));

    // Add two overlay widgets that will not allow mouse events to pass through them next to the close button
    QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Horizontal);
    layout->setContentsMargins(0, 0, 0, 0);
    layout->setSpacing(0);
    layout->addItem(new EventEaterWidget);
    layout->addItem(closeButton);
    layout->addItem(new EventEaterWidget);

    // Create the area itself
    MWidgetController *closeButtonArea = new MStylableWidget;
    closeButtonArea->setStyleName("CloseButtonArea");
    closeButtonArea->setLayout(layout);

    return closeButtonArea;
}
void MLinearLayoutPolicyPrivate::notifyWidgetOfLayoutPosition(int index, M::Position position)
{
    MWidgetController* widget = dynamic_cast<MWidgetController*>(static_cast<ProxyItem *>(engine->itemAt(index))->proxiedItem());
    if (widget)
        widget->setLayoutPosition(position);
}