MCPcopy Create free account
hub / github.com/Kitware/ParaView / generateTabName

Method generateTabName

Qt/Python/pqPythonTabWidget.cxx:372–462  ·  view source on GitHub ↗

-----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

370
371//-----------------------------------------------------------------------------
372void pqPythonTabWidget::generateTabName(const pqPythonTextArea* widget, QString& tabName,
373 QString& elidedTabName, QString& unstyledTabName) const
374{
375 const auto QColorToString = [](const QColor& color) { return color.name(QColor::HexRgb); };
376 const auto ColorText = [&QColorToString](const QColor& color, const QString& text)
377 { return "<span style=\"color:" + QColorToString(color) + "\">" + text + "</span>"; };
378
379 const QString& fileName = widget->getFilename();
380 const QFileInfo fileInfo(fileName);
381 const QString macroDir = pqPythonScriptEditor::getMacrosDir();
382 const QString scriptDir = pqPythonScriptEditor::getScriptsDir();
383
384 // Insert a tag for the tab type
385 QString prefix;
386 QColor prefixColor;
387 if (widget == this->TraceWidget)
388 {
389 prefix = "[Trace]";
390 prefixColor =
391 pqCoreUtilities::isDarkTheme() ? Qt::GlobalColor::cyan : Qt::GlobalColor::darkCyan;
392 }
393 else if (fileName.contains(macroDir))
394 {
395 prefix = "[Macro]";
396 prefixColor =
397 pqCoreUtilities::isDarkTheme() ? Qt::GlobalColor::green : Qt::GlobalColor::darkGreen;
398 }
399 else if (fileName.contains(scriptDir))
400 {
401 prefix = "[Script]";
402 prefixColor =
403 pqCoreUtilities::isDarkTheme() ? Qt::GlobalColor::blue : Qt::GlobalColor::darkBlue;
404 }
405 tabName = ColorText(prefixColor, prefix);
406 unstyledTabName = prefix;
407
408 if (widget->isLinked())
409 {
410 tabName += ColorText(
411 pqCoreUtilities::isDarkTheme() ? Qt::GlobalColor::yellow : Qt::GlobalColor::darkYellow,
412 "[Linked]");
413 unstyledTabName += "[Linked]";
414 }
415
416 tabName += " ";
417 unstyledTabName += " ";
418
419 if (fileName.isEmpty())
420 {
421 tabName += tr("New File");
422 elidedTabName = tabName;
423 unstyledTabName += tr("New File");
424 }
425 else
426 {
427 QString absoluteDirPath = fileInfo.dir().absolutePath();
428
429 // Replace the home folder path with ~

Callers 1

updateTabMethod · 0.95

Calls 5

trFunction · 0.85
nameMethod · 0.45
containsMethod · 0.45
isEmptyMethod · 0.45
isDirtyMethod · 0.45

Tested by

no test coverage detected