| 106 | } |
| 107 | |
| 108 | FormatPluginView::FormatPluginView(FormatPlugin *plugin, KTextEditor::MainWindow *mainWin) |
| 109 | : QObject(plugin) |
| 110 | , m_plugin(plugin) |
| 111 | , m_mainWindow(mainWin) |
| 112 | { |
| 113 | KXMLGUIClient::setComponentName(QStringLiteral("formatplugin"), i18n("Formatting")); |
| 114 | |
| 115 | connect(m_plugin, &FormatPlugin::configChanged, this, &FormatPluginView::onConfigChanged); |
| 116 | |
| 117 | auto ac = actionCollection(); |
| 118 | auto a = ac->addAction(QStringLiteral("format_document"), this, &FormatPluginView::format); |
| 119 | a->setText(i18n("Format Document")); |
| 120 | connect(mainWin, &KTextEditor::MainWindow::viewChanged, this, &FormatPluginView::onActiveViewChanged); |
| 121 | |
| 122 | setXMLFile(QStringLiteral("ui.rc")); |
| 123 | |
| 124 | a = actionCollection()->addAction(QStringLiteral("format_on_save"), this, [this](bool b) { |
| 125 | m_plugin->formatOnSave = b; |
| 126 | onActiveViewChanged(nullptr); |
| 127 | onActiveViewChanged(m_mainWindow->activeView()); |
| 128 | }); |
| 129 | a->setText(i18n("Format on Save")); |
| 130 | a->setCheckable(true); |
| 131 | a->setChecked(formatOnSave()); |
| 132 | a->setToolTip(i18n("Disable formatting on save without persisting it in settings")); |
| 133 | |
| 134 | m_mainWindow->guiFactory()->addClient(this); |
| 135 | } |
| 136 | |
| 137 | FormatPluginView::~FormatPluginView() |
| 138 | { |
nothing calls this directly
no test coverage detected