! * \brief LabelWidget::charFormatChanged * \param format * Used to update the colors, font,... in the color font widgets to show the style of the selected text */
| 663 | * Used to update the colors, font,... in the color font widgets to show the style of the selected text |
| 664 | */ |
| 665 | void 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 |
| 705 | void LabelWidget::labelModeChanged(TextLabel::Mode mode) { |
nothing calls this directly
no test coverage detected