void Packet::update_dest_pos(Node *node) { std::pair<int,int> dest_loc = location(node); QQuickItem *item = qobject_cast<QQuickItem*>(pac_obj); item->setProperty("dest_x", dest_loc.first+offset); item->setProperty("dest_y", dest_loc.second+offset); }
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(); }
void Fix8Log::aboutSlot() { QDialog *aboutDialog = new QDialog(); QVBoxLayout *aboutLayout = new QVBoxLayout(0); QDialogButtonBox *dialogButtonBox = new QDialogButtonBox(); dialogButtonBox->addButton(QDialogButtonBox::Ok); connect(dialogButtonBox,SIGNAL(clicked(QAbstractButton*)), aboutDialog,SLOT(close())); QQuickView *aboutView = new QQuickView(QUrl("qrc:qml/helpAbout.qml")); QQuickItem *qmlObject = aboutView->rootObject(); qmlObject->setProperty("color",aboutDialog->palette().color(QPalette::Window)); qmlObject->setProperty("bgColor",aboutDialog->palette().color(QPalette::Window)); qmlObject->setProperty("version",QString::number(Globals::version)); aboutView->setResizeMode(QQuickView::SizeRootObjectToView); QWidget *aboutWidget = QWidget::createWindowContainer(aboutView,0); aboutWidget->setPalette(aboutDialog->palette()); aboutWidget->setAutoFillBackground(false); aboutDialog->setLayout(aboutLayout); aboutLayout->addWidget(aboutWidget,1); aboutLayout->addWidget(dialogButtonBox,0); aboutDialog->resize(500,400); aboutDialog->setWindowTitle(GUI::Globals::appName); aboutDialog->exec(); aboutDialog->deleteLater(); }
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)); } }
QQuickItem * DataSetView::createColumnHeader(int col) { //std::cout << "createColumnHeader("<<col<<") called!\n" << std::flush; if(_columnHeaderDelegate == NULL) { _columnHeaderDelegate = new QQmlComponent(qmlEngine(this)); _columnHeaderDelegate->setData("import QtQuick 2.10\nItem {\n" "property alias text: tekst.text\n" "Rectangle { color: \"lightGrey\"; anchors.fill: parent }\n" "Text { id: tekst; anchors.centerIn: parent }\n" "}", QUrl()); } QQuickItem * columnHeader = NULL; if(_columnHeaderItems.count(col) == 0 || _columnHeaderItems[col] == NULL) { if(_columnHeaderStorage.size() > 0) { #ifdef DEBUG_VIEWPORT std::cout << "createColumnHeader("<<col<<") from storage!\n" << std::flush; #endif columnHeader = _columnHeaderStorage.top(); _columnHeaderStorage.pop(); } else { #ifdef DEBUG_VIEWPORT std::cout << "createColumnHeader("<<col<<") ex nihilo!\n" << std::flush; #endif columnHeader = qobject_cast<QQuickItem*>(_columnHeaderDelegate->create()); columnHeader->setParent(this); columnHeader->setParentItem(this); } columnHeader->setProperty("z", 10); columnHeader->setProperty("text", _model->headerData(col, Qt::Orientation::Horizontal).toString()); columnHeader->setZ(-3); columnHeader->setHeight(_dataRowsMaxHeight); columnHeader->setWidth(_dataColsMaxWidth[col]); columnHeader->setVisible(true); _columnHeaderItems[col] = columnHeader; } else columnHeader = _columnHeaderItems[col]; columnHeader->setX(_colXPositions[col]); columnHeader->setY(_viewportY); return columnHeader; }
QQuickItem * DataSetView::createRowNumber(int row) { //std::cout << "createRowNumber("<<row<<") called!\n" << std::flush; if(_rowNumberDelegate == NULL) { _rowNumberDelegate = new QQmlComponent(qmlEngine(this)); _rowNumberDelegate->setData("import QtQuick 2.10\nItem {\n" "property alias text: tekst.text\n" "Rectangle { color: \"lightGrey\"; anchors.fill: parent }\n" "Text { id: tekst; anchors.centerIn: parent }\n" "}", QUrl()); } QQuickItem * rowNumber = NULL; if(_rowNumberItems.count(row) == 0 || _rowNumberItems[row] == NULL) { if(_rowNumberStorage.size() > 0) { #ifdef DEBUG_VIEWPORT std::cout << "createRowNumber("<<row<<") from storage!\n" << std::flush; #endif rowNumber = _rowNumberStorage.top(); _rowNumberStorage.pop(); } else { #ifdef DEBUG_VIEWPORT std::cout << "createRowNumber("<<row<<") ex nihilo!\n" << std::flush; #endif rowNumber = qobject_cast<QQuickItem*>(_rowNumberDelegate->create()); rowNumber->setParent(this); rowNumber->setParentItem(this); } rowNumber->setProperty("z", 10); rowNumber->setProperty("text", QString::fromStdString(std::to_string(row + 1))); //Nobody wants zero-based rows... rowNumber->setY(_dataRowsMaxHeight * (1 + row)); rowNumber->setZ(-3); rowNumber->setHeight(_dataRowsMaxHeight); rowNumber->setWidth(_rowNumberMaxWidth); rowNumber->setVisible(true); _rowNumberItems[row] = rowNumber; } else rowNumber = _rowNumberItems[row]; rowNumber->setX(_viewportX); return _rowNumberItems[row]; }
void Packet::set_source_node(Node* node) { //assign the source node source_node = node; std::pair<int,int> loc = location(node); QQuickItem *item = qobject_cast<QQuickItem*>(pac_obj); item->setProperty("x", loc.first+offset); item->setProperty("y", loc.second+offset); QObject::connect(this->pac_obj, SIGNAL(dest_reached(QString)), this->source_node,SLOT(send_pack(QString)),Qt::UniqueConnection); }
void QmlProfilerTraceView::resizeEvent(QResizeEvent *event) { QWidget::resizeEvent(event); QQuickItem *rootObject = d->m_mainView->rootObject(); if (rootObject) { rootObject->setProperty("width", QVariant(event->size().width())); int newHeight = event->size().height() - d->m_timebar->height() - d->m_overview->height(); rootObject->setProperty("candidateHeight", QVariant(newHeight)); } emit resized(); }
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; }
void KonvergoWindow::playerWindowVisible(bool visible) { // adjust webengineview transparecy depending on player visibility QQuickItem *web = findChild<QQuickItem *>("web"); if (web) web->setProperty("backgroundColor", visible ? "transparent" : "#111111"); }
void QmlProfilerTraceView::changeEvent(QEvent *e) { if (e->type() == QEvent::EnabledChange) { QQuickItem *rootObject = d->m_mainView->rootObject(); rootObject->setProperty("enabled", isEnabled()); } }
QQuickItem * DataSetView::createTextItem(int row, int col) { //std::cout << "createTextItem("<<row<<", "<<col<<") called!\n" << std::flush; if((_cellTextItems.count(col) == 0 && _cellTextItems[col].count(row) == 0) || _cellTextItems[col][row] == NULL) { if(_itemDelegate == NULL) { _itemDelegate = new QQmlComponent(qmlEngine(this)); _itemDelegate->setData("import QtQuick 2.10\nText { property bool active: true; text: \"???\"; color: active ? 'black' : 'grey' }", QUrl()); } QQuickItem * textItem = NULL; if(_textItemStorage.size() > 0) { #ifdef DEBUG_VIEWPORT std::cout << "createTextItem("<<row<<", "<<col<<") from storage!\n" << std::flush; #endif textItem = _textItemStorage.top(); _textItemStorage.pop(); } else { #ifdef DEBUG_VIEWPORT std::cout << "createTextItem("<<row<<", "<<col<<") ex nihilo!\n" << std::flush; #endif textItem = qobject_cast<QQuickItem*>(_itemDelegate->create()); textItem->setParent(this); textItem->setParentItem(this); } QModelIndex ind(_model->index(row, col)); bool active = _model->data(ind, _roleNameToRole["active"]).toBool(); textItem->setProperty("color", active ? "black" : "grey"); textItem->setProperty("text", _model->data(ind)); textItem->setX(_colXPositions[col] + _itemHorizontalPadding); textItem->setY(-2 + _dataRowsMaxHeight + _itemVerticalPadding + row * _dataRowsMaxHeight); textItem->setZ(-4); textItem->setVisible(true); _cellTextItems[col][row] = textItem; } return _cellTextItems[col][row]; }
void MainView2D::updateFixtureRotation(quint32 itemID, QVector3D degrees) { if (isEnabled() == false || m_itemsMap.contains(itemID) == false) return; QQuickItem *fxItem = m_itemsMap[itemID]; fxItem->setProperty("rotation", degrees.y()); }
void MainView2D::setFixtureFlags(quint32 itemID, quint32 flags) { QQuickItem *fxItem = m_itemsMap.value(itemID, NULL); if (fxItem == NULL) return; fxItem->setProperty("visible", (flags & MonitorProperties::HiddenFlag) ? false : true); }
void MainView2D::setUniverseFilter(quint32 universeFilter) { PreviewContext::setUniverseFilter(universeFilter); QMapIterator<quint32, QQuickItem*> it(m_itemsMap); while(it.hasNext()) { it.next(); quint32 fxID = it.key(); QQuickItem *fxItem = it.value(); Fixture *fixture = m_doc->fixture(fxID); if (fixture == NULL) continue; if (universeFilter == Universe::invalid() || fixture->universe() == universeFilter) fxItem->setProperty("visible", "true"); else fxItem->setProperty("visible", "false"); } }
void Packet::create_packet(QString name, QObject *main_panel, QQmlApplicationEngine *engine) { // Load Node QML file QQmlComponent component(engine, QUrl("qrc:/qml_files/packet.qml")); // Create QObject pac_obj = component.create(); // Cast it as a QQuickItem QQuickItem *item = qobject_cast<QQuickItem*>(pac_obj); // Set the parent as the main_panel (this changes when added to a link) item->setParentItem(qobject_cast<QQuickItem*>(main_panel)); item->setProperty("pack_name", name); #ifdef Q_OS_ANDROID item->setProperty("packet_size", 50); offset = 25; #else item->setProperty("packet_size", 20); offset = 13; #endif this->name = name; }
///////////////////////////////////////////////////////// // 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)); } }
void ModuleInterface::updateCategoryAndLanguageModels() { QQuickItem* object = findQmlObject("moduleChooser"); if (object == 0) return; getCategoriesAndLanguages(); setupTextModel(m_categories, &m_categoryModel); setupTextModel(m_languages, &m_languageModel); updateWorksModel(); object->setProperty("categoryModel", QVariant::fromValue(&m_categoryModel)); object->setProperty("languageModel", QVariant::fromValue(&m_languageModel)); }
void PaperManager::init_buffer() { if( p->buffer.length() == BUFFER_SIZE ) return; for( int i=0; i<BUFFER_SIZE; i++ ) { QQuickItem *paper = createPaper(); paper->setProperty( "visible", (BUFFER_SIZE-i <= 2) ); paper->setProperty( "paperZ", i ); connect( paper, SIGNAL(closed(QVariant)) , SLOT(paperClosed(QVariant)) ); connect( paper, SIGNAL(entered(QVariant)) , SLOT(paperEntered(QVariant)) ); connect( paper, SIGNAL(deleted(QVariant)) , SLOT(deletePaper(QVariant)) ); connect( paper, SIGNAL(saved(int)) , SLOT(paperSaved(int)) ); connect( paper, SIGNAL(outMove(QVariant)) , SLOT(outMove(QVariant)) ); connect( paper, SIGNAL(outMoveFinished()) , SLOT(outMoveFinished()) ); p->buffer.prepend( paper ); } }
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 ActionManager::requestActionPopup(ActionManager::ActionType type, QString message, int buttonsMask, QVariantList data) { QQuickItem *popupItem = qobject_cast<QQuickItem*>(m_view->rootObject()->findChild<QObject *>("popupBox")); if (popupItem == NULL) { qDebug() << "popupBox not found !"; return; } qDebug() << "[ActionManager] buttonsMask:" << buttonsMask << data; if (message.startsWith("qrc:")) popupItem->setProperty("resource", message); else popupItem->setProperty("message", message); popupItem->setProperty("buttonsMask", buttonsMask); // save the requested action to be processed when the user // confirms or rejects from the popup m_deferredAction = QPair<ActionType, QVariantList> (type, data); popupItem->setProperty("visible", true); }
void Graph::update_node_position(qreal x, qreal y, QString string) { Node *node = get_node_by_name(string); QObject *obj = node->get_q_object(); std::vector<Link*> lnks = get_link_from_node(node); for (std::vector<Link*>::iterator iter = lnks.begin(); iter != lnks.end(); iter++) { Link *temp = *iter; QQuickItem *tmp = qobject_cast<QQuickItem*>(temp->get_q_object()); QQuickItem *node1 = qobject_cast<QQuickItem*>(obj); int y_off = node1->height(); int x_off = node1->width(); if (temp->get_source()->get_id() == node->get_id()) { tmp->setProperty("x1", x + x_off/2); tmp->setProperty("y1", y + y_off/2); } else { tmp->setProperty("x2", x + x_off/2); tmp->setProperty("y2", y + y_off/2); } } node->set_x(x); node->set_y(y); }
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 Graph::_drawLabel(float x, float y, QString text, QHash<QString, QQuickItem*> &labelCache) { if(labelComponent == NULL) { QQmlEngine * engine = new QQmlEngine(); labelComponent = new QQmlComponent(engine, QUrl("qrc:/src/qml/controls/common/_Text.qml", QUrl::StrictMode)); if( labelComponent->status() != QQmlComponent::Ready) { qDebug() << ("Error:"+ labelComponent->errorString() ); return; // or maybe throw } } if( labelComponent->status() != QQmlComponent::Ready) { return; } QQuickItem * label = labelCache[text]; if (!label) { //TODO: Someday, scene graph might have a better text renderer label= qobject_cast<QQuickItem*>(labelComponent->create()); label->setParentItem(this->parentItem()); //TODO: Who REALLY owns this item? The component? Or the Hash? label->setProperty("text", text); label->setProperty("width", "parent.width"); label->children().first()->setProperty("color", m_primaryLineColor.darker()); labelCache[text] = label; } if (label != NULL) { label->setProperty("x", x); label->setProperty("y", y); } }
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 TelegramImageElement::initImage() { if(p->image) return; QQmlEngine *engine = qmlEngine(this); QQmlContext *context = qmlContext(this); if(!engine || !context) return; QQmlComponent component(engine); QString qmlImageCreationCode = p->qmlImageCreationCode; if(qmlImageCreationCode.isEmpty()) qmlImageCreationCode = QString("import QtQuick %1\n" "Image { anchors.fill: parent; }").arg(p->qtQuickVersion); component.setData(qmlImageCreationCode.toUtf8(), QUrl()); QQuickItem *item = qobject_cast<QQuickItem *>(component.create(context)); if(!item) return; item->setParent(this); item->setParentItem(this); QHashIterator<QString, QVariant> i(p->properties); while(i.hasNext()) { i.next(); item->setProperty(i.key().toUtf8(), i.value()); } connect(item, SIGNAL(asynchronousChanged()), this, SIGNAL(asynchronousChanged())); #if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) connect(item, SIGNAL(autoTransformChanged()), this, SIGNAL(autoTransformChanged())); #endif connect(item, SIGNAL(cacheChanged()), this, SIGNAL(cacheChanged())); connect(item, SIGNAL(fillModeChanged()), this, SIGNAL(fillModeChanged())); connect(item, SIGNAL(mirrorChanged()), this, SIGNAL(mirrorChanged())); connect(item, SIGNAL(sourceSizeChanged()), this, SIGNAL(sourceSizeChanged())); p->image = item; }
void VCButton::render(QQuickView *view, QQuickItem *parent) { if (view == NULL || parent == NULL) return; QQmlComponent *component = new QQmlComponent(view->engine(), QUrl("qrc:/VCButtonItem.qml")); if (component->isError()) { qDebug() << component->errors(); return; } QQuickItem *item = qobject_cast<QQuickItem*>(component->create()); item->setParentItem(parent); item->setProperty("buttonObj", QVariant::fromValue(this)); }
void MainView2D::updateFixturePosition(quint32 itemID, QVector3D pos) { if (isEnabled() == false) return; if (m_itemsMap.contains(itemID) == false) { quint32 fxID = FixtureUtils::itemFixtureID(itemID); quint16 headIndex = FixtureUtils::itemHeadIndex(itemID); quint16 linkedIndex = FixtureUtils::itemLinkedIndex(itemID); createFixtureItem(fxID, headIndex, linkedIndex, pos, false); } else { QQuickItem *fxItem = m_itemsMap[itemID]; QPointF point = FixtureUtils::item2DPosition(m_monProps, m_monProps->pointOfView(), pos); fxItem->setProperty("mmXPos", point.x()); fxItem->setProperty("mmYPos", point.y()); } }
void ModuleInterface::updateWorksModel() { m_worksModel.clear(); m_modules.clear(); QString currentLang = currentLanguage(); QString currentCat = currentCategory(); QHash<int, QByteArray> roleNames; roleNames[TextRole] = "modelText"; m_worksModel.setRoleNames(roleNames); BtBookshelfModel* bookshelfModel = CSwordBackend::instance()->model(); if (bookshelfModel == 0) return; int count = bookshelfModel->rowCount(); for (int row=0; row<count; ++row) { QModelIndex index = bookshelfModel->index(row); CSwordModuleInfo* module = getModule(bookshelfModel, index); CSwordModuleInfo::Category category = module->category(); QString categoryName = module->categoryName(category); const CLanguageMgr::Language* language = module->language(); QString languageName = language->translatedName(); if (languageName == currentLang && categoryName == currentCat) { m_modules << module; QString moduleName = module->name(); QStandardItem* item = new QStandardItem(); item->setData(moduleName, TextRole); m_worksModel.appendRow(item); } } QQuickItem* object = findQmlObject("moduleChooser"); if (object == 0) return; object->setProperty("worksModel", QVariant::fromValue(&m_worksModel)); }
void QmlProfilerTraceView::setAppKilled() { QQuickItem *rootObject = d->m_mainView->rootObject(); if (rootObject) rootObject->setProperty("appKilled",QVariant(true)); }