MCPcopy Create free account
hub / github.com/KDE/kdevelop / updateFormatTextAction

Method updateFormatTextAction

kdevplatform/shell/sourceformattercontroller.cpp:590–634  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

588}
589
590void SourceFormatterController::updateFormatTextAction()
591{
592 Q_D(const SourceFormatterController);
593
594 const auto [enabled, tool, style] = [d] {
595 auto disabled = std::tuple{false, QString(), QString()};
596
597 const auto* doc = KDevelop::ICore::self()->documentController()->activeDocument();
598 if (!doc) {
599 return disabled;
600 }
601
602 FileFormatter ff(*doc);
603 if (!ff.readFormatterAndStyle(d->sourceFormatters)) {
604 return disabled;
605 }
606
607 return std::tuple{true, ff.formatterCaption(), ff.styleCaption()};
608 }();
609
610 d->formatTextAction->setEnabled(enabled);
611 d->formatLine->setEnabled(enabled);
612
613 if (enabled) {
614 d->formatTextAction->setToolTip(i18nc("@info:tooltip", "Reformat selection or file using <i>%1</i> (<b>%2</b>)",
615 tool, style));
616 d->formatTextAction->setWhatsThis(i18nc("@info:whatsthis",
617 "Reformats selected text or the entire file if nothing is selected, using <i>%1</i> tool with <b>%2</b> style.",
618 tool, style));
619 d->formatLine->setToolTip(i18nc("@info:tooltip", "Reformat current line using <i>%1</i> (<b>%2</b>)",
620 tool, style));
621 d->formatLine->setWhatsThis(i18nc("@info:whatsthis",
622 "Source reformatting of line under cursor using <i>%1</i> tool with <b>%2</b> style.",
623 tool, style));
624 } else {
625 d->formatTextAction->setToolTip(i18nc("@info:tooltip",
626 "Reformat selection or file using the configured source formatter"));
627 d->formatTextAction->setWhatsThis(i18nc("@info:whatsthis",
628 "Reformats selected text or the entire file if nothing is selected, using the configured source formatter."));
629 d->formatLine->setToolTip(i18nc("@info:tooltip",
630 "Reformat current line using the configured source formatter"));
631 d->formatLine->setWhatsThis(i18nc("@info:whatsthis",
632 "Source reformatting of line under cursor using the configured source formatter."));
633 }
634}
635
636void SourceFormatterController::beautifySource()
637{

Callers

nothing calls this directly

Calls 8

activeDocumentMethod · 0.80
documentControllerMethod · 0.80
readFormatterAndStyleMethod · 0.80
formatterCaptionMethod · 0.80
styleCaptionMethod · 0.80
setToolTipMethod · 0.80
QStringClass · 0.70
setEnabledMethod · 0.45

Tested by

no test coverage detected