void VideoQualityJob::onOpenTiggered() { // Parse the XML. QFile file(xmlPath()); file.open(QIODevice::ReadOnly); QDomDocument dom(xmlPath()); dom.setContent(&file); file.close(); // Locate the VQM transition. QDomNodeList transitions = dom.elementsByTagName("transition"); for (int i = 0; i < transitions.length(); i++ ) { QDomElement property = transitions.at(i).firstChildElement("property"); while (!property.isNull()) { // Change the render property to 1. if (property.attribute("name") == "render") { property.firstChild().setNodeValue("1"); // Save the new XML. file.open(QIODevice::WriteOnly); QTextStream textStream(&file); dom.save(textStream, 2); file.close(); MAIN.open(xmlPath().toUtf8().constData()); break; } property = property.nextSiblingElement("property"); } } }
void MeltJob::start() { QString shotcutPath = qApp->applicationDirPath(); #ifdef Q_OS_WIN QFileInfo meltPath(shotcutPath, "qmelt.exe"); #else QFileInfo meltPath(shotcutPath, "qmelt"); #endif setReadChannel(QProcess::StandardError); QStringList args; args << "-verbose"; args << "-progress2"; args << "-abort"; if (m_args.size() > 0) { args.append(m_args); } else if (m_useMultiConsumer) { args << xmlPath() + "?multi:1"; } else { args << xmlPath(); } LOG_DEBUG() << meltPath.absoluteFilePath() << args; #ifdef Q_OS_WIN if (m_isStreaming) args << "-getc"; QProcess::start(meltPath.absoluteFilePath(), args); #else args.prepend(meltPath.absoluteFilePath()); QProcess::start("/usr/bin/nice", args); #endif AbstractJob::start(); }
ShaderSP ShaderToon::Create() { std::string xmlPath("Resources/HLSL/Toon.xml"); CWsbXmlSP xml = CWsbXml::LoadXmlFile(xmlPath); std::string path = xml->GetElement("path")->GetString(); ShaderSP shader; std::unordered_map<std::string, ShaderSP>::iterator it = _shaders.find(path); // 存在したら第二要素を返す if(it != _shaders.end()) { shader = (*it).second; return shader; } // 存在しなければ新しく生成 std::string texturePath = xml->GetElement("ToonTex")->GetString(); float directionX = xml->GetElement("LightDirection")->GetElement("X")->GetFloat(); float directionY = xml->GetElement("LightDirection")->GetElement("Y")->GetFloat(); float directionZ = xml->GetElement("LightDirection")->GetElement("Z")->GetFloat(); auto shaderToon = new ShaderToon(); shaderToon->SetLightDirection(directionX, directionY, directionZ); shaderToon->_toonTexture = Texture::CreateFromFile(texturePath, D3DX_DEFAULT); shader = ShaderSP(shaderToon); // ハッシュマップに挿入 _shaders.insert(std::make_pair(path, shader)); return shader; }
ShaderSP ShaderPhong::Create() { std::string xmlPath("Resources/HLSL/Phong.xml"); CWsbXmlSP xml = CWsbXml::LoadXmlFile(xmlPath); std::string path = xml->GetElement("path")->GetString(); ShaderSP shader; std::unordered_map<std::string, ShaderSP>::iterator it = _shaders.find(path); // 存在したら第二要素を返す if(it != _shaders.end()) { shader = (*it).second; return shader; } // 存在しなければ新しく生成 shader = ShaderSP(new ShaderPhong()); float directionX = xml->GetElement("LightDirection")->GetElement("X")->GetFloat(); float directionY = xml->GetElement("LightDirection")->GetElement("Y")->GetFloat(); float directionZ = xml->GetElement("LightDirection")->GetElement("Z")->GetFloat(); float ambient = xml->GetElement("Ambient")->GetFloat(); float specular = xml->GetElement("Specular")->GetFloat(); float specularpow = xml->GetElement("SpecularPower")->GetFloat(); shader->SetAmbient(ambient); shader->SetLightDirection(directionX, directionY, directionZ); shader->SetSpecular(specular); shader->SetSpecularPower(specularpow); // ハッシュマップに挿入 _shaders.insert(std::make_pair(path, shader)); return shader; }
bool Prj::create(const QString &path, QString *reason) { try { QString absPath = QFileInfo(path).absoluteFilePath(); // create path for icons if (!QDir(iconPath(absPath)).exists()) if (!QDir().mkpath(iconPath(absPath))) throw tr("can't create path \"%1\"").arg(iconPath(absPath)); // create path for screenshots if (!QDir(screenshotPath(absPath)).exists()) if (!QDir().mkpath(screenshotPath(absPath))) throw tr("can't create path \"%1\"").arg(screenshotPath(absPath)); // create path for downloads (webpages, e.t.c.) if (!QDir(downloadsPath(absPath)).exists()) if (!QDir().mkpath(downloadsPath(absPath))) throw tr("can't create path \"%1\"").arg(downloadsPath(absPath)); QFile file(xmlPath(path)); if (!file.open(QIODevice::WriteOnly)) throw file.errorString(); // write empty xml document return PrjXml::saveEmptyXml(&file, reason); } catch (const QString &error) { if (reason) *reason = error; } return false; }
bool Prj::save(QString *reason) { try { if (!isOpen()) throw tr("bookmarks collection is not opened"); QFile file(xmlPath()); if (!file.open(QIODevice::WriteOnly)) throw file.errorString(); bool state = PrjXml::saveXml(m_manager, &file, reason); if (state) m_hasChanges = false; updateActions(); return state; } catch (const QString &error) { if (reason) *reason = error; } return false; }
bool Prj::open(const QString &path, QString *reason) { try { if (isOpen()) throw tr("bookmarks collection is already opened"); QFile file(xmlPath(path)); if (!file.open(QIODevice::ReadOnly)) throw file.errorString(); blockSignals(true); bool state = PrjXml::loadXml(m_manager, &file, reason); blockSignals(false); if (!state) return false; m_path = path; m_hasChanges = false; QList<QUrl> urls; foreach (BookmarkItem *item, m_manager->bookmarkMgr()->bookmarks()) urls.push_back(item->data().url()); m_iconMgr->setIconsPath(iconPath()); m_iconMgr->loadIcons(urls); updateActions(); emit opened(); return true; } catch (const QString &error) { if (reason) *reason = error; } return false; }
void MeltJob::start() { QString shotcutPath = qApp->applicationDirPath(); #ifdef Q_OS_WIN QFileInfo meltPath(shotcutPath, "qmelt.exe"); #else QFileInfo meltPath(shotcutPath, "qmelt"); #endif setReadChannel(QProcess::StandardError); QStringList args; args << "-progress2"; args << "-abort"; args << xmlPath(); qDebug() << meltPath.absoluteFilePath() << args; #ifdef Q_OS_WIN if (m_isStreaming) args << "-getc"; QProcess::start(meltPath.absoluteFilePath(), args); #else args.prepend(meltPath.absoluteFilePath()); QProcess::start("/usr/bin/nice", args); #endif AbstractJob::start(); }