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

Method charFormatChanged

src/frontend/widgets/LabelWidget.cpp:665–702  ·  view source on GitHub ↗

! * \brief LabelWidget::charFormatChanged * \param format * Used to update the colors, font,... in the color font widgets to show the style of the selected text */

Source from the content-addressed store, hash-verified

663 * Used to update the colors, font,... in the color font widgets to show the style of the selected text
664 */
665void LabelWidget::charFormatChanged(const QTextCharFormat& format) {
666 auto mode = static_cast<TextLabel::Mode>(ui.cbMode->currentIndex());
667 if (mode != TextLabel::Mode::Text)
668 return;
669
670 CONDITIONAL_LOCK_RETURN;
671
672 // update button state
673 ui.tbFontBold->setChecked(ui.teLabel->fontWeight() == QFont::Bold);
674 ui.tbFontItalic->setChecked(ui.teLabel->fontItalic());
675 ui.tbFontUnderline->setChecked(ui.teLabel->fontUnderline());
676 ui.tbFontStrikeOut->setChecked(format.fontStrikeOut());
677 ui.tbFontSuperScript->setChecked(format.verticalAlignment() == QTextCharFormat::AlignSuperScript);
678 ui.tbFontSubScript->setChecked(format.verticalAlignment() == QTextCharFormat::AlignSubScript);
679
680 // font and colors
681 QDEBUG(Q_FUNC_INFO << ", format color = " << format.foreground().color())
682 QDEBUG(Q_FUNC_INFO << ", label color = " << m_label->fontColor())
683 QDEBUG(Q_FUNC_INFO << ", text = " << ui.teLabel->toPlainText())
684 QDEBUG(Q_FUNC_INFO << ", label text = " << m_label->text().text)
685
686 // TEST
687 if (ui.teLabel->toPlainText().isEmpty())
688 return;
689
690 // when text is empty the default color of format is black instead of the theme color!
691 if (m_label->text().isHtml() && format.foreground().color().isValid() && !ui.teLabel->toPlainText().isEmpty())
692 ui.kcbFontColor->setColor(format.foreground().color());
693 else
694 ui.kcbFontColor->setColor(m_label->fontColor());
695
696 if (m_label->text().isHtml() && format.background().color().isValid() && !ui.teLabel->toPlainText().isEmpty())
697 ui.kcbBackgroundColor->setColor(format.background().color());
698 else
699 ui.kcbBackgroundColor->setColor(m_label->backgroundColor());
700
701 ui.kfontRequester->setFont(format.font());
702}
703
704// called when textlabel mode is changed
705void LabelWidget::labelModeChanged(TextLabel::Mode mode) {

Callers

nothing calls this directly

Calls 15

fontItalicMethod · 0.80
fontUnderlineMethod · 0.80
fontStrikeOutMethod · 0.80
verticalAlignmentMethod · 0.80
fontColorMethod · 0.80
isHtmlMethod · 0.80
backgroundColorMethod · 0.80
fontMethod · 0.80
currentIndexMethod · 0.45
colorMethod · 0.45
textMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected