MCPcopy Create free account
hub / github.com/OpenBoard-org/OpenBoard / createHtmlWrapperInDir

Method createHtmlWrapperInDir

src/domain/UBGraphicsWidgetItem.cpp:1346–1414  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1344}
1345
1346QString UBGraphicsW3CWidgetItem::createHtmlWrapperInDir(const QString& html, const QDir& pDir, const QSize& sizeHint, const QString& pName)
1347{
1348 QString widgetPath = pDir.path() + "/" + pName + ".wgt";
1349 widgetPath = UBFileSystemUtils::nextAvailableFileName(widgetPath);
1350 QDir widgetDir(widgetPath);
1351
1352 if (!widgetDir.exists())
1353 widgetDir.mkpath(widgetDir.path());
1354
1355 QFile configFile(widgetPath + "/" + "config.xml");
1356
1357 if (configFile.exists())
1358 configFile.remove(configFile.fileName());
1359
1360 if (!configFile.open(QIODevice::WriteOnly)) {
1361 qWarning() << "Cannot open file " << configFile.fileName();
1362 return "";
1363 }
1364
1365 QTextStream outConfig(&configFile);
1366#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
1367 outConfig.setCodec("UTF-8");
1368#endif
1369 outConfig << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << '\n';
1370 outConfig << "<widget xmlns=\"http://www.w3.org/ns/widgets\"" << '\n';
1371 outConfig << " xmlns:ub=\"http://uniboard.mnemis.com/widgets\"" << '\n';
1372 outConfig << " id=\"http://uniboard.mnemis.com/" << pName << "\"" <<'\n';
1373
1374 outConfig << " version=\"2.0\"" << '\n';
1375 outConfig << " width=\"" << sizeHint.width() << "\"" << '\n';
1376 outConfig << " height=\"" << sizeHint.height() << "\"" << '\n';
1377 outConfig << " ub:resizable=\"true\">" << '\n';
1378
1379 outConfig << " <name>" << pName << "</name>" << '\n';
1380 outConfig << " <content src=\"" << pName << ".html\"/>" << '\n';
1381
1382 outConfig << "</widget>" << '\n';
1383
1384 configFile.close();
1385
1386 const QString fullHtmlFileName = widgetPath + "/" + pName + ".html";
1387
1388 QFile widgetHtmlFile(fullHtmlFileName);
1389 if (widgetHtmlFile.exists())
1390 widgetHtmlFile.remove(widgetHtmlFile.fileName());
1391 if (!widgetHtmlFile.open(QIODevice::WriteOnly)) {
1392 qWarning() << "cannot open file " << widgetHtmlFile.fileName();
1393 return QString();
1394 }
1395
1396 QTextStream outStartFile(&widgetHtmlFile);
1397#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
1398 outStartFile.setCodec("UTF-8");
1399#endif
1400
1401 outStartFile << "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">" << '\n';
1402 outStartFile << "<html>" << '\n';
1403 outStartFile << "<head>" << '\n';

Callers

nothing calls this directly

Calls 5

pathMethod · 0.45
removeMethod · 0.45
widthMethod · 0.45
heightMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected