| 1102 | } |
| 1103 | |
| 1104 | void SourceFormatterSelectionEdit::editStyle() |
| 1105 | { |
| 1106 | Q_D(SourceFormatterSelectionEdit); |
| 1107 | |
| 1108 | auto& currentStyle = d->validCurrentStyle(); |
| 1109 | |
| 1110 | Q_ASSERT_X(d->currentFormatter().formatter().hasEditStyleWidget(), Q_FUNC_INFO, |
| 1111 | "The Edit... button must be disabled if the current style is not editable."); |
| 1112 | KDevelop::ScopedDialog<EditStyleDialog> dlg(d->currentFormatter().formatter(), |
| 1113 | d->currentLanguage().defaultMimeType(), currentStyle, this); |
| 1114 | if (dlg->exec() == QDialog::Rejected) { |
| 1115 | return; // nothing changed |
| 1116 | } |
| 1117 | |
| 1118 | QString updatedContent = dlg->content(); |
| 1119 | const bool updatedUsePreview = dlg->usePreview(); |
| 1120 | if (updatedUsePreview == currentStyle.usePreview() && updatedContent == currentStyle.content()) { |
| 1121 | return; // nothing changed |
| 1122 | } |
| 1123 | |
| 1124 | currentStyle.setContent(std::move(updatedContent)); |
| 1125 | currentStyle.setUsePreview(updatedUsePreview); |
| 1126 | |
| 1127 | // Don't call updateStyleButtons(), because editing a style doesn't affect the buttons. |
| 1128 | d->updatePreview(); |
| 1129 | emit changed(); |
| 1130 | } |
| 1131 | |
| 1132 | void SourceFormatterSelectionEdit::newStyle() |
| 1133 | { |
nothing calls this directly
no test coverage detected