struct v4l2_format V4LConfigurationEngine::encodeConfigurationStringList(QStringList sConfig, v4l2_format old_config) { QRegExp resRegExp("\\d+x\\d+"); struct v4l2_format config, tmpConfig; CLEAR(config); if (sConfig.count() < 2){ #ifdef _DEBUG_CONFIGURATION_OBJECTS qWarning() << "[V4L_CONFIGURATION_ENGINE] - encodeConfigurationStringList() - Too few arguments"; #endif //_DEBUG_CONFIGURATION_OBJECTS return old_config; } QFile captureDevice(sConfig.at(0)); if (!captureDevice.exists()) { #ifdef _DEBUG_CONFIGURATION_OBJECTS qWarning() << "[V4L_CONFIGURATION_ENGINE] - encodeConfigurationStringList() - Invalid device " << captureDevice.fileName(); #endif //_DEBUG_CONFIGURATION_OBJECTS return old_config; } if (!captureDevice.open(QIODevice::ReadWrite)) { #ifdef _DEBUG_CONFIGURATION_OBJECTS qWarning() << "[V4L_CONFIGURATION_ENGINE] - encodeConfigurationStringList() - Unable to open device" << captureDevice.fileName(); #endif //_DEBUG_CONFIGURATION_OBJECTS return old_config; } config = old_config; for (quint8 i = 1; i < sConfig.count(); i++) { if (resRegExp.exactMatch(sConfig.at(i))) { tmpConfig = config; tmpConfig.fmt.pix.width = sConfig.at(i).toLower().split(QChar('x')).at(0).toUInt(); tmpConfig.fmt.pix.height = sConfig.at(i).toLower().split(QChar('x')).at(1).toUInt(); if (V4LSettings::qioctl(captureDevice.handle(), VIDIOC_TRY_FMT, &tmpConfig, "V4LConfigurationEngine::encodeConfigurationStringList()") != 0){ #ifdef _DEBUG_CONFIGURATION_OBJECTS qWarning() << "[V4L_CONFIGURATION_ENGINE] - encodeConfigurationStringList() - Invalid or unsupported frame Size"; #endif //_DEBUG_CONFIGURATION_OBJECTS } else config = tmpConfig; } } captureDevice.close(); return config; }
RenderSettingsDialog::RenderSettingsDialog(QWidget *parent) : QDialog(parent, Qt::Sheet), ui(new Ui::RenderSettingsDialog), m_icNode(NULL), m_aiNode(NULL) { ui->setupUi(this); connect(ui->integratorBox, SIGNAL(highlighted(int)), SLOT(cbHighlighted(int))); connect(ui->integratorBox, SIGNAL(activated(int)), SLOT(update())); connect(ui->samplerBox, SIGNAL(highlighted(int)), SLOT(cbHighlighted(int))); connect(ui->samplerBox, SIGNAL(activated(int)), SLOT(update())); connect(ui->rFilterBox, SIGNAL(highlighted(int)), SLOT(cbHighlighted(int))); connect(ui->rFilterBox, SIGNAL(activated(int)), SLOT(update())); connect(ui->icBox, SIGNAL(pressed()), SLOT(chkBoxPressed())); connect(ui->aiBox, SIGNAL(pressed()), SLOT(chkBoxPressed())); connect(ui->icBox, SIGNAL(toggled(bool)), SLOT(update())); connect(ui->aiBox, SIGNAL(toggled(bool)), SLOT(update())); connect(ui->resolutionBox, SIGNAL(activated(int)), SLOT(refresh())); connect(ui->resolutionBox, SIGNAL(editTextChanged(const QString &)), SLOT(refresh())); QFile file(":/resources/docs.xml"); if (!file.open(QIODevice::ReadOnly) || !m_document.setContent(&file)) SLog(EError, "Unable to read the documentation file!"); file.close(); /* Populate the integrator, rec. filter & sampler combo box widgets */ QDomElement docRoot = m_document.documentElement(); for (QDomElement e = docRoot.firstChildElement("plugin"); !e.isNull(); e = e.nextSiblingElement("plugin")) { QString docString, name = e.attribute("name"); if (!e.firstChildElement("descr").isNull()) { /* Create a HTML-based documentation string */ QDomDocument helpDoc; QDomElement root = helpDoc.createElement("p"); helpDoc.appendChild(root); for (QDomNode child = e.firstChildElement("descr").firstChild(); !child.isNull(); child = child.nextSibling()) root.appendChild(helpDoc.importNode(child, true)); docString = helpDoc.toString(); } if (e.hasAttribute("show") && e.attribute("show") == "true") { QString type = e.attribute("type"), className = e.attribute("className"), readableName = e.attribute("readableName"), name = e.attribute("name"); QList<QVariant> list; list.append(className); list.append(docString); list.append(name); if (type == "integrator") ui->integratorBox->addItem(readableName, list); else if (type == "sampler") ui->samplerBox->addItem(readableName, list); else if (type == "rfilter") ui->rFilterBox->addItem(readableName, list); } if (name == "irrcache") ui->icBox->setProperty("help", docString); else if (name == "adaptive") ui->aiBox->setProperty("help", docString); } m_model = new XMLTreeModel(docRoot, palette(), this); ui->treeView->setModel(m_model); ui->treeView->setAlternatingRowColors(true); ui->treeView->setUniformRowHeights(true); ui->treeView->setColumnWidth(0, 270); ui->treeView->setStyleSheet("QTreeView::item { padding-right: 8px; }"); ui->treeView->setItemDelegate(new PropertyDelegate(this)); connect(ui->treeView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection)), SLOT(onTreeSelectionChange(const QItemSelection &, const QItemSelection &))); connect(m_model, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), this, SLOT(dataChanged())); m_integratorNode = m_model->registerClass("MIPathTracer", "Path tracer"); m_samplerNode = m_model->registerClass("IndependentSampler", "Independent sampler"); m_rFilterNode = m_model->registerClass("BoxFilter", "Box filter"); QRegExp resRegExp("^[1-9]\\d{0,4}x[1-9]\\d{0,4}$"); ui->resolutionBox->setValidator(new QRegExpValidator(resRegExp, this)); QPalette pal = ui->helpViewer->palette(); pal.setColor(QPalette::Text, pal.color(QPalette::Foreground)); pal.setColor(QPalette::Base, pal.color(QPalette::Window)); ui->helpViewer->setPalette(pal); ui->helpViewer->setHtml("Click on any setting for documentation"); }