QList<quint32> MainView2D::selectFixturesRect(QRectF rect) { QList<quint32>fxList; if (rect.width() == 0 || rect.height() == 0) return fxList; QMap<quint32, QQuickItem *>::const_iterator i = m_itemsMap.constBegin(); while (i != m_itemsMap.constEnd()) { QQuickItem *fxItem = i.value(); qreal itemXPos = fxItem->property("x").toReal(); qreal itemYPos = fxItem->property("y").toReal(); qreal itemWidth = fxItem->property("width").toReal(); qreal itemHeight = fxItem->property("height").toReal(); QRectF itemRect(itemXPos, itemYPos, itemWidth, itemHeight); qDebug() << "Rect:" << rect << "itemRect:" << itemRect; if (rect.contains(itemRect)) { if (fxItem->property("isSelected").toBool() == false) { fxItem->setProperty("isSelected", true); fxList.append(i.key()); } } ++i; } return fxList; }
///////////////////////////////////////////////////////// // Goto source location void QmlProfilerTraceView::updateCursorPosition() { QQuickItem *rootObject = d->m_mainView->rootObject(); emit gotoSourceLocation(rootObject->property("fileName").toString(), rootObject->property("lineNumber").toInt(), rootObject->property("columnNumber").toInt()); }
// Goto source location void QmlProfilerTraceView::updateCursorPosition() { QQuickItem *rootObject = d->m_mainView->rootObject(); QString file = rootObject->property("fileName").toString(); if (!file.isEmpty()) emit gotoSourceLocation(file, rootObject->property("lineNumber").toInt(), rootObject->property("columnNumber").toInt()); emit typeSelected(rootObject->property("typeId").toInt()); }
qint64 QmlProfilerTraceView::selectionEnd() const { QQuickItem *rootObject = d->m_mainView->rootObject(); if (rootObject) return rootObject->property("selectionRangeEnd").toLongLong(); return 0; }
void PaperManager::deletePaper(const QVariant & var) { QQuickItem *paper = var.value<QQuickItem*>(); if( !paper ) return; const int paperId = paper->property("paperItem").toInt(); if( paperId == -1 ) return; const int bufferIdx = p->buffer.indexOf(paper); const int currentIdx = (p->current==0)? p->current + bufferIdx : p->current + bufferIdx -1; if( currentIdx != p->current ) return; p->papers.removeAll(paperId); int nextId = (p->current<p->papers.count())? p->papers.at(p->current) : -1; paper->setProperty("paperItem", -1 ); paper->setProperty("paperItem", nextId ); Papyrus::database()->deletePaper(paperId); reindexBuffer(); load_buffers(); emit papersChanged(); }
bool QmlProfilerTraceView::hasValidSelection() const { QQuickItem *rootObject = d->m_mainView->rootObject(); if (rootObject) return rootObject->property("selectionRangeReady").toBool(); return false; }
void QmlProfilerTraceView::toggleLockMode(bool active) { QQuickItem *rootObject = d->m_mainView->rootObject(); bool lockMode = !rootObject->property("selectionLocked").toBool(); if (active != lockMode) { rootObject->setProperty("selectionLocked", QVariant(!active)); rootObject->setProperty("selectedItem", QVariant(-1)); } }
QString ModuleInterface::currentCategory() const { QQuickItem* object = findQmlObject("moduleChooser"); if (object == 0) return ""; int row = object->property("categoryIndex").toInt(); QModelIndex modelIndex = m_categoryModel.index(row,0); QString category = modelIndex.data(TextRole).toString(); return category; }
QString ModuleInterface::currentLanguage() const { QQuickItem* object = findQmlObject("moduleChooser"); if (object == 0) return ""; int row = object->property("languageIndex").toInt(); QModelIndex modelIndex = m_languageModel.index(row,0); QString language = modelIndex.data(TextRole).toString(); return language; }
///////////////////////////////////////////////////////// // Toolbar buttons void QmlProfilerTraceView::toggleRangeMode(bool active) { QQuickItem *rootObject = d->m_mainView->rootObject(); bool rangeMode = rootObject->property("selectionRangeMode").toBool(); if (active != rangeMode) { if (active) d->m_buttonRange->setIcon(QIcon(QLatin1String(":/qmlprofiler/ico_rangeselected.png"))); else d->m_buttonRange->setIcon(QIcon(QLatin1String(":/qmlprofiler/ico_rangeselection.png"))); rootObject->setProperty("selectionRangeMode", QVariant(active)); } }
int MainView2D::itemIDAtPos(QPointF pos) { QMap<quint32, QQuickItem *>::const_iterator i = m_itemsMap.constBegin(); while (i != m_itemsMap.constEnd()) { QQuickItem *fxItem = i.value(); qreal itemXPos = fxItem->property("x").toReal(); qreal itemYPos = fxItem->property("y").toReal(); qreal itemWidth = fxItem->property("width").toReal(); qreal itemHeight = fxItem->property("height").toReal(); QRectF itemRect(itemXPos, itemYPos, itemWidth, itemHeight); qDebug() << "Point:" << pos << "itemRect:" << itemRect; if (itemRect.contains(pos)) return i.key(); ++i; } return -1; }
void PlasmoidProtocol::init() { //this should never happen if (m_containment) { return; } Host* h = qobject_cast<Host*>(parent()); QQuickItem* rootItem = h->rootItem(); if (rootItem) { m_systrayApplet = rootItem->property("_plasma_applet").value<Plasma::Applet*>(); } if (!m_systrayApplet) { qWarning() << "Don't have a parent applet, Can't initialize the Plasmoid protocol!!!"; return; } int containmentId = 0; KConfigGroup cg = m_systrayApplet->config(); cg = KConfigGroup(&cg, "Containments"); if (cg.isValid() && cg.groupList().size()) { containmentId = cg.groupList().first().toInt(); } m_containment = new Plasma::Containment(m_systrayApplet, QStringLiteral("null"), containmentId); m_containment->setImmutability(Plasma::Types::Mutable); m_containment->setFormFactor(Plasma::Types::Horizontal); m_containment->setLocation(m_systrayApplet->location()); m_containment->setContainmentActions(QStringLiteral("RightButton;NoModifier"), QStringLiteral("org.kde.contextmenu")); m_containment->init(); emit m_systrayApplet->containment()->corona()->containmentAdded(m_containment); connect(m_systrayApplet, &Plasma::Applet::locationChanged, this, [=]() { m_containment->setLocation(m_systrayApplet->location()); }); m_systrayApplet->setProperty("containment", QVariant::fromValue(m_containment)); restorePlasmoids(); }
void QuickAndroidTests::drawableProvider() { QQmlApplicationEngine engine; QADrawableProvider* provider = new QADrawableProvider(); provider->setBasePath(QString(SRCDIR) + "/res"); engine.addImageProvider("drawable",provider); engine.load(QUrl::fromLocalFile(QString(SRCDIR) + "/test_drawableprovider.qml")); QObject *rootItem = engine.rootObjects().first(); QVERIFY(rootItem); QStringList images; images << "image1" << "image2" << "image3"; Q_FOREACH(QString image,images) { QQuickItem* item = rootItem->findChild<QQuickItem*>(image); QVERIFY(item); QCOMPARE(item->property("status").toInt() , 1) ; }
void GLWidget::resizeGL(int width, int height) { int x, y, w, h; double this_aspect = (double) width / height; double video_aspect = m_monitorProfile->dar(); // Special case optimisation to negate odd effect of sample aspect ratio // not corresponding exactly with image resolution. if ((int) (this_aspect * 1000) == (int) (video_aspect * 1000)) { w = width; h = height; } // Use OpenGL to normalise sample aspect ratio else if (height * video_aspect > width) { w = width; h = width / video_aspect; } else { w = height * video_aspect; h = height; } x = (width - w) / 2; y = (height - h) / 2; m_rect.setRect(x, y, w, h); double scale = (double) m_rect.width() / m_monitorProfile->width() * m_zoom; QPoint center = m_rect.center(); QQuickItem* rootQml = rootObject(); if (rootQml) { rootQml->setProperty("center", center); rootQml->setProperty("scale", scale); if (rootQml->objectName() == "rootsplit") { // Adjust splitter pos rootQml->setProperty("splitterPos", x + (rootQml->property("realpercent").toDouble() * w)); } } emit rectChanged(); }
void PaperManager::paperEntered( const QVariant & var ) { p->current--; emit currentPaperChanged(); emit currentIndexChanged(); QQuickItem *paper = var.value<QQuickItem*>(); Q_UNUSED(paper) if( p->current == 0 ) return; QQuickItem *btm = p->buffer.takeLast(); p->buffer.prepend( btm ); reindexBuffer(); btm->setProperty( "anim", false ); btm->setProperty( "x", btm->property("closeX") ); btm->setProperty( "opacity", 1 ); btm->setProperty( "visible", true ); load_buffers(); }
void PaperManager::paperClosed( const QVariant & var ) { QQuickItem *paper = var.value<QQuickItem*>(); if( p->buffer.indexOf(paper) == 0 && p->current != 0 ) { paper->setProperty( "x" ,paper->property("closeX") ); return; } if( p->current >= p->papers.count() ) QMetaObject::invokeMethod( paper, "save" ); p->current++; emit currentPaperChanged(); emit currentIndexChanged(); if( p->current == 1 ) { p->buffer.last()->setProperty( "visible" ,true ); load_buffers(); return; } QQuickItem *top = p->buffer.takeFirst(); p->buffer << top; reindexBuffer(); top->setProperty( "anim" ,false ); top->setProperty( "x" ,0 ); top->setProperty( "opacity", 0 ); QMetaObject::invokeMethod( top, "startAnimation" ); top->setProperty( "opacity", 1 ); load_buffers(); }
void tst_applicationwindow::attachedProperties() { QQmlEngine engine; QQmlComponent component(&engine); component.loadUrl(testFileUrl("attachedProperties.qml")); QScopedPointer<QObject> object(component.create()); QVERIFY2(!object.isNull(), qPrintable(component.errorString())); QQuickApplicationWindow *window = qobject_cast<QQuickApplicationWindow *>(object.data()); QVERIFY(window); QQuickItem *childControl = object->property("childControl").value<QQuickItem *>(); QVERIFY(childControl); QCOMPARE(childControl->property("attached_window").value<QQuickApplicationWindow *>(), window); QCOMPARE(childControl->property("attached_contentItem").value<QQuickItem *>(), window->contentItem()); QCOMPARE(childControl->property("attached_activeFocusControl").value<QQuickItem *>(), window->activeFocusControl()); QCOMPARE(childControl->property("attached_header").value<QQuickItem *>(), window->header()); QCOMPARE(childControl->property("attached_footer").value<QQuickItem *>(), window->footer()); QCOMPARE(childControl->property("attached_overlay").value<QQuickItem *>(), window->overlay()); QQuickItem *childItem = object->property("childItem").value<QQuickItem *>(); QVERIFY(childItem); QCOMPARE(childItem->property("attached_window").value<QQuickApplicationWindow *>(), window); QCOMPARE(childItem->property("attached_contentItem").value<QQuickItem *>(), window->contentItem()); QCOMPARE(childItem->property("attached_activeFocusControl").value<QQuickItem *>(), window->activeFocusControl()); QCOMPARE(childItem->property("attached_header").value<QQuickItem *>(), window->header()); QCOMPARE(childItem->property("attached_footer").value<QQuickItem *>(), window->footer()); QCOMPARE(childItem->property("attached_overlay").value<QQuickItem *>(), window->overlay()); QObject *childObject = object->property("childObject").value<QObject *>(); QVERIFY(childObject); QVERIFY(!childObject->property("attached_window").value<QQuickApplicationWindow *>()); QVERIFY(!childObject->property("attached_contentItem").value<QQuickItem *>()); QVERIFY(!childObject->property("attached_activeFocusControl").value<QQuickItem *>()); QVERIFY(!childObject->property("attached_header").value<QQuickItem *>()); QVERIFY(!childObject->property("attached_footer").value<QQuickItem *>()); QVERIFY(!childObject->property("attached_overlay").value<QQuickItem *>()); QQuickWindow *childWindow = object->property("childWindow").value<QQuickWindow *>(); QVERIFY(childWindow); QVERIFY(!childWindow->property("attached_window").value<QQuickApplicationWindow *>()); QVERIFY(!childWindow->property("attached_contentItem").value<QQuickItem *>()); QVERIFY(!childWindow->property("attached_activeFocusControl").value<QQuickItem *>()); QVERIFY(!childWindow->property("attached_header").value<QQuickItem *>()); QVERIFY(!childWindow->property("attached_footer").value<QQuickItem *>()); QVERIFY(!childWindow->property("attached_overlay").value<QQuickItem *>()); QQuickItem *childWindowControl = object->property("childWindowControl").value<QQuickItem *>(); QVERIFY(childWindowControl); QVERIFY(!childWindowControl->property("attached_window").value<QQuickApplicationWindow *>()); QVERIFY(!childWindowControl->property("attached_contentItem").value<QQuickItem *>()); QVERIFY(!childWindowControl->property("attached_activeFocusControl").value<QQuickItem *>()); QVERIFY(!childWindowControl->property("attached_header").value<QQuickItem *>()); QVERIFY(!childWindowControl->property("attached_footer").value<QQuickItem *>()); QVERIFY(!childWindowControl->property("attached_overlay").value<QQuickItem *>()); QQuickItem *childWindowItem = object->property("childWindowItem").value<QQuickItem *>(); QVERIFY(childWindowItem); QVERIFY(!childWindowItem->property("attached_window").value<QQuickApplicationWindow *>()); QVERIFY(!childWindowItem->property("attached_contentItem").value<QQuickItem *>()); QVERIFY(!childWindowItem->property("attached_activeFocusControl").value<QQuickItem *>()); QVERIFY(!childWindowItem->property("attached_header").value<QQuickItem *>()); QVERIFY(!childWindowItem->property("attached_footer").value<QQuickItem *>()); QVERIFY(!childWindowItem->property("attached_overlay").value<QQuickItem *>()); QObject *childWindowObject = object->property("childWindowObject").value<QObject *>(); QVERIFY(childWindowObject); QVERIFY(!childWindowObject->property("attached_window").value<QQuickApplicationWindow *>()); QVERIFY(!childWindowObject->property("attached_contentItem").value<QQuickItem *>()); QVERIFY(!childWindowObject->property("attached_activeFocusControl").value<QQuickItem *>()); QVERIFY(!childWindowObject->property("attached_header").value<QQuickItem *>()); QVERIFY(!childWindowObject->property("attached_footer").value<QQuickItem *>()); QVERIFY(!childWindowObject->property("attached_overlay").value<QQuickItem *>()); QQuickApplicationWindow *childAppWindow = object->property("childAppWindow").value<QQuickApplicationWindow *>(); QVERIFY(childAppWindow); QVERIFY(!childAppWindow->property("attached_window").value<QQuickApplicationWindow *>()); QVERIFY(!childAppWindow->property("attached_contentItem").value<QQuickItem *>()); QVERIFY(!childAppWindow->property("attached_activeFocusControl").value<QQuickItem *>()); QVERIFY(!childAppWindow->property("attached_header").value<QQuickItem *>()); QVERIFY(!childAppWindow->property("attached_footer").value<QQuickItem *>()); QVERIFY(!childAppWindow->property("attached_overlay").value<QQuickItem *>()); QQuickItem *childAppWindowControl = object->property("childAppWindowControl").value<QQuickItem *>(); QVERIFY(childAppWindowControl); QCOMPARE(childAppWindowControl->property("attached_window").value<QQuickApplicationWindow *>(), childAppWindow); QCOMPARE(childAppWindowControl->property("attached_contentItem").value<QQuickItem *>(), childAppWindow->contentItem()); QCOMPARE(childAppWindowControl->property("attached_activeFocusControl").value<QQuickItem *>(), childAppWindow->activeFocusControl()); QCOMPARE(childAppWindowControl->property("attached_header").value<QQuickItem *>(), childAppWindow->header()); QCOMPARE(childAppWindowControl->property("attached_footer").value<QQuickItem *>(), childAppWindow->footer()); QCOMPARE(childAppWindowControl->property("attached_overlay").value<QQuickItem *>(), childAppWindow->overlay()); QQuickItem *childAppWindowItem = object->property("childAppWindowItem").value<QQuickItem *>(); QVERIFY(childAppWindowItem); QCOMPARE(childAppWindowItem->property("attached_window").value<QQuickApplicationWindow *>(), childAppWindow); QCOMPARE(childAppWindowItem->property("attached_contentItem").value<QQuickItem *>(), childAppWindow->contentItem()); QCOMPARE(childAppWindowItem->property("attached_activeFocusControl").value<QQuickItem *>(), childAppWindow->activeFocusControl()); QCOMPARE(childAppWindowItem->property("attached_header").value<QQuickItem *>(), childAppWindow->header()); QCOMPARE(childAppWindowItem->property("attached_footer").value<QQuickItem *>(), childAppWindow->footer()); QCOMPARE(childAppWindowItem->property("attached_overlay").value<QQuickItem *>(), childAppWindow->overlay()); QObject *childAppWindowObject = object->property("childAppWindowObject").value<QObject *>(); QVERIFY(childAppWindowObject); QVERIFY(!childAppWindowObject->property("attached_window").value<QQuickApplicationWindow *>()); QVERIFY(!childAppWindowObject->property("attached_contentItem").value<QQuickItem *>()); QVERIFY(!childAppWindowObject->property("attached_activeFocusControl").value<QQuickItem *>()); QVERIFY(!childAppWindowObject->property("attached_header").value<QQuickItem *>()); QVERIFY(!childAppWindowObject->property("attached_footer").value<QQuickItem *>()); QVERIFY(!childAppWindowObject->property("attached_overlay").value<QQuickItem *>()); window->show(); window->requestActivate(); QVERIFY(QTest::qWaitForWindowActive(window)); QVERIFY(!childControl->hasActiveFocus()); childControl->forceActiveFocus(); QTRY_VERIFY(childControl->hasActiveFocus()); QCOMPARE(window->activeFocusItem(), childControl); QCOMPARE(childControl->property("attached_activeFocusControl").value<QQuickItem *>(), childControl); QQuickItem *header = new QQuickItem; window->setHeader(header); QCOMPARE(window->header(), header); QCOMPARE(childControl->property("attached_header").value<QQuickItem *>(), header); QQuickItem *footer = new QQuickItem; window->setFooter(footer); QCOMPARE(window->footer(), footer); QCOMPARE(childControl->property("attached_footer").value<QQuickItem *>(), footer); childAppWindow->show(); childAppWindow->requestActivate(); QVERIFY(QTest::qWaitForWindowActive(childAppWindow)); QVERIFY(!childAppWindowControl->hasActiveFocus()); childAppWindowControl->forceActiveFocus(); QTRY_VERIFY(childAppWindowControl->hasActiveFocus()); QCOMPARE(childAppWindow->activeFocusItem(), childAppWindowControl); QCOMPARE(childAppWindowControl->property("attached_activeFocusControl").value<QQuickItem *>(), childAppWindowControl); childControl->setParentItem(childAppWindow->contentItem()); QCOMPARE(childControl->window(), childAppWindow); QCOMPARE(childControl->property("attached_window").value<QQuickApplicationWindow *>(), childAppWindow); QCOMPARE(childControl->property("attached_contentItem").value<QQuickItem *>(), childAppWindow->contentItem()); QCOMPARE(childControl->property("attached_activeFocusControl").value<QQuickItem *>(), childAppWindow->activeFocusControl()); QCOMPARE(childControl->property("attached_header").value<QQuickItem *>(), childAppWindow->header()); QCOMPARE(childControl->property("attached_footer").value<QQuickItem *>(), childAppWindow->footer()); QCOMPARE(childControl->property("attached_overlay").value<QQuickItem *>(), childAppWindow->overlay()); childItem->setParentItem(childAppWindow->contentItem()); QCOMPARE(childItem->window(), childAppWindow); QCOMPARE(childItem->property("attached_window").value<QQuickApplicationWindow *>(), childAppWindow); QCOMPARE(childItem->property("attached_contentItem").value<QQuickItem *>(), childAppWindow->contentItem()); QCOMPARE(childItem->property("attached_activeFocusControl").value<QQuickItem *>(), childAppWindow->activeFocusControl()); QCOMPARE(childItem->property("attached_header").value<QQuickItem *>(), childAppWindow->header()); QCOMPARE(childItem->property("attached_footer").value<QQuickItem *>(), childAppWindow->footer()); QCOMPARE(childItem->property("attached_overlay").value<QQuickItem *>(), childAppWindow->overlay()); childControl->setParentItem(Q_NULLPTR); QVERIFY(!childControl->window()); QVERIFY(!childControl->property("attached_window").value<QQuickApplicationWindow *>()); QVERIFY(!childControl->property("attached_contentItem").value<QQuickItem *>()); QVERIFY(!childControl->property("attached_activeFocusControl").value<QQuickItem *>()); QVERIFY(!childControl->property("attached_header").value<QQuickItem *>()); QVERIFY(!childControl->property("attached_footer").value<QQuickItem *>()); QVERIFY(!childControl->property("attached_overlay").value<QQuickItem *>()); childItem->setParentItem(Q_NULLPTR); QVERIFY(!childItem->window()); QVERIFY(!childItem->property("attached_window").value<QQuickApplicationWindow *>()); QVERIFY(!childItem->property("attached_contentItem").value<QQuickItem *>()); QVERIFY(!childItem->property("attached_activeFocusControl").value<QQuickItem *>()); QVERIFY(!childItem->property("attached_header").value<QQuickItem *>()); QVERIFY(!childItem->property("attached_footer").value<QQuickItem *>()); QVERIFY(!childItem->property("attached_overlay").value<QQuickItem *>()); // ### A temporary workaround to unblock the CI until the crash caused // by https://codereview.qt-project.org/#/c/108517/ has been fixed... window->hide(); qApp->processEvents(); }
QMultiHash<int, SceneValue> FixtureManager::setFixtureCapabilities(quint32 fxID, bool enable) { int capDelta = 1; bool hasDimmer = false, hasColor = false, hasPosition = false; QMultiHash<int, SceneValue> channelsMap; Fixture *fixture = m_doc->fixture(fxID); if (fixture == NULL) return channelsMap; if (enable == false) capDelta = -1; for (quint32 ch = 0; ch < fixture->channels(); ch++) { const QLCChannel* channel(fixture->channel(ch)); if(channel == NULL) continue; int chType = channel->group(); switch (channel->group()) { case QLCChannel::Intensity: { QLCChannel::PrimaryColour col = channel->colour(); switch (col) { case QLCChannel::NoColour: hasDimmer = true; break; case QLCChannel::Red: case QLCChannel::Green: case QLCChannel::Blue: case QLCChannel::Cyan: case QLCChannel::Magenta: case QLCChannel::Yellow: case QLCChannel::White: hasColor = true; break; default: break; } chType = col; } break; case QLCChannel::Pan: case QLCChannel::Tilt: hasPosition = true; break; default: break; } if (hasDimmer) { QQuickItem *dimmerCapItem = qobject_cast<QQuickItem*>(m_view->rootObject()->findChild<QObject *>("capIntensity")); dimmerCapItem->setProperty("counter", dimmerCapItem->property("counter").toInt() + capDelta); } if (hasColor) { QQuickItem *colorCapItem = qobject_cast<QQuickItem*>(m_view->rootObject()->findChild<QObject *>("capColor")); colorCapItem->setProperty("counter", colorCapItem->property("counter").toInt() + capDelta); } if (hasPosition) { QQuickItem *positionCapItem = qobject_cast<QQuickItem*>(m_view->rootObject()->findChild<QObject *>("capPosition")); positionCapItem->setProperty("counter", positionCapItem->property("counter").toInt() + capDelta); } channelsMap.insert(chType, SceneValue(fxID, ch)); } return channelsMap; }