MCPcopy Create free account
hub / github.com/KDE/labplot / updateMode

Method updateMode

src/frontend/widgets/LabelWidget.cpp:1492–1564  ·  view source on GitHub ↗

General updater function to update the dock (used also in the load method)

Source from the content-addressed store, hash-verified

1490
1491// General updater function to update the dock (used also in the load method)
1492void LabelWidget::updateMode(TextLabel::Mode mode) {
1493 bool plain = (mode != TextLabel::Mode::Text);
1494
1495 // hide text editing elements if TeX-option is used
1496 ui.tbFontBold->setVisible(!plain);
1497 ui.tbFontItalic->setVisible(!plain);
1498
1499 // TODO: https://bugreports.qt.io/browse/QTBUG-25420
1500 // ui.tbFontUnderline->setVisible(!plain);
1501 // ui.tbFontStrikeOut->setVisible(!plain);
1502
1503 ui.tbFontSubScript->setVisible(!plain);
1504 ui.tbFontSuperScript->setVisible(!plain);
1505
1506 ui.lFont->setVisible(!plain);
1507 ui.kfontRequester->setVisible(!plain);
1508
1509 if (plain) {
1510 // reset all applied formattings when switching from html to tex mode
1511 QTextCursor cursor = ui.teLabel->textCursor();
1512 int position = cursor.position();
1513 ui.teLabel->selectAll();
1514 QTextCharFormat format;
1515 ui.teLabel->setCurrentCharFormat(format);
1516 cursor.movePosition(QTextCursor::Right, QTextCursor::MoveAnchor, position);
1517 ui.teLabel->setTextCursor(cursor);
1518
1519#ifdef HAVE_KF5_SYNTAX_HIGHLIGHTING
1520 m_highlighter->setDocument(ui.teLabel->document());
1521 if (mode == TextLabel::Mode::LaTeX)
1522 m_highlighter->setDefinition(m_repository.definitionForName(QLatin1String("LaTeX")));
1523 else
1524 m_highlighter->setDefinition(m_repository.definitionForName(QLatin1String("Markdown")));
1525#endif
1526 KConfigGroup conf = Settings::group(QLatin1String("Settings_Worksheet"));
1527 QString engine = conf.readEntry(QLatin1String("LaTeXEngine"), "");
1528 if (engine == QLatin1String("xelatex") || engine == QLatin1String("lualatex")) {
1529 ui.lFontTeX->setVisible(true);
1530 ui.kfontRequesterTeX->setVisible(true);
1531 ui.lFontSize->setVisible(false);
1532 ui.sbFontSize->setVisible(false);
1533 } else {
1534 // changing the main font for latex and pdflatex is a cumbersome (https://latex-tutorial.com/changing-font-style/),
1535 // hide this option completely for these engines for now
1536 ui.lFontTeX->setVisible(false);
1537 ui.kfontRequesterTeX->setVisible(false);
1538
1539 ui.lFontSize->setVisible(true);
1540 ui.sbFontSize->setVisible(true);
1541 }
1542
1543 // update colors
1544 ui.kcbFontColor->setColor(m_label->fontColor());
1545 ui.kcbBackgroundColor->setColor(m_label->backgroundColor());
1546 } else {
1547#ifdef HAVE_KF5_SYNTAX_HIGHLIGHTING
1548 m_highlighter->setDocument(nullptr);
1549#endif

Callers 1

loadMethod · 0.95

Calls 8

groupFunction · 0.85
positionMethod · 0.80
fontColorMethod · 0.80
backgroundColorMethod · 0.80
QStringClass · 0.50
setVisibleMethod · 0.45
selectAllMethod · 0.45
setColorMethod · 0.45

Tested by

no test coverage detected