diff --git a/addons/externaltools/externaltools.cpp b/addons/externaltools/externaltools.cpp index 1dde07450..99effd938 100644 --- a/addons/externaltools/externaltools.cpp +++ b/addons/externaltools/externaltools.cpp @@ -1,697 +1,696 @@ /* This file is part of the Kate text editor of the KDE project. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. --- Copyright (C) 2004, Anders Lund Copyright (C) 2019 Dominik Haumann */ // TODO // Icons // Direct shortcut setting #include "externaltools.h" #include "kateexternaltool.h" #include "externaltoolsplugin.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // BEGIN KateExternalToolsCommand KateExternalToolsCommand::KateExternalToolsCommand(KateExternalToolsPlugin* plugin) : KTextEditor::Command({/* FIXME */}) , m_plugin(plugin) { reload(); } // FIXME // const QStringList& KateExternalToolsCommand::cmds() // { // return m_list; // } void KateExternalToolsCommand::reload() { m_list.clear(); m_map.clear(); m_name.clear(); KConfig _config(QStringLiteral("externaltools"), KConfig::NoGlobals, QStandardPaths::ApplicationsLocation); KConfigGroup config(&_config, "Global"); const QStringList tools = config.readEntry("tools", QStringList()); for (QStringList::const_iterator it = tools.begin(); it != tools.end(); ++it) { if (*it == QStringLiteral("---")) continue; config = KConfigGroup(&_config, *it); KateExternalTool t = KateExternalTool(config.readEntry(QStringLiteral("name"), ""), config.readEntry("command", ""), config.readEntry(QStringLiteral("icon"), ""), config.readEntry("executable", ""), config.readEntry(QStringLiteral("mimetypes"), QStringList()), config.readEntry(QStringLiteral("acname"), ""), config.readEntry("cmdname", "")); // FIXME test for a command name first! if (t.hasexec && (!t.cmdname.isEmpty())) { m_list.append(QStringLiteral("exttool-") + t.cmdname); m_map.insert(QStringLiteral("exttool-") + t.cmdname, t.acname); m_name.insert(QStringLiteral("exttool-") + t.cmdname, t.name); } } } bool KateExternalToolsCommand::exec(KTextEditor::View* view, const QString& cmd, QString& msg, const KTextEditor::Range& range) { Q_UNUSED(msg) Q_UNUSED(range) auto wv = dynamic_cast(view); if (!wv) { // qDebug()<<"KateExternalToolsCommand::exec: Could not get view widget"; return false; } // qDebug()<<"cmd="<(dmw->action("tools_external")); if (!a) return false;*/ KateExternalToolsPluginView* extview = m_plugin->extView(wv->window()); if (!extview) return false; if (!extview->externalTools) return false; // qDebug()<<"trying to find action"; QAction* a1 = extview->externalTools->actionCollection()->action(actionName); if (!a1) return false; // qDebug()<<"activating action"; a1->trigger(); return true; } bool KateExternalToolsCommand::help(KTextEditor::View*, const QString&, QString&) { return false; } // END KateExternalToolsCommand // BEGIN KateExternalToolAction KateExternalToolAction::KateExternalToolAction(QObject* parent, KateExternalTool* t) : QAction(QIcon::fromTheme(t->icon), t->name, parent) , tool(t) { setText(t->name); if (!t->icon.isEmpty()) setIcon(QIcon::fromTheme(t->icon)); connect(this, SIGNAL(triggered(bool)), SLOT(slotRun())); } bool KateExternalToolAction::expandMacro(const QString& str, QStringList& ret) { KTextEditor::MainWindow* mw = qobject_cast(parent()->parent()); Q_ASSERT(mw); KTextEditor::View* view = mw->activeView(); if (!view) return false; KTextEditor::Document* doc = view->document(); QUrl url = doc->url(); if (str == QStringLiteral("URL")) ret += url.url(); else if (str == QStringLiteral("directory")) // directory of current doc ret += url.toString(QUrl::RemoveScheme | QUrl::RemoveFilename); else if (str == QStringLiteral("filename")) ret += url.fileName(); else if (str == QStringLiteral("line")) // cursor line of current doc ret += QString::number(view->cursorPosition().line()); else if (str == QStringLiteral("col")) // cursor col of current doc ret += QString::number(view->cursorPosition().column()); else if (str == QStringLiteral("selection")) // selection of current doc if any ret += view->selectionText(); else if (str == QStringLiteral("text")) // text of current doc ret += doc->text(); else if (str == QStringLiteral("URLs")) { foreach (KTextEditor::Document* it, KTextEditor::Editor::instance()->application()->documents()) if (!it->url().isEmpty()) ret += it->url().url(); } else return false; return true; } KateExternalToolAction::~KateExternalToolAction() { delete (tool); } void KateExternalToolAction::slotRun() { // expand the macros in command if any, // and construct a command with an absolute path QString cmd = tool->command; auto mw = qobject_cast(parent()->parent()); if (!expandMacrosShellQuote(cmd)) { KMessageBox::sorry(mw->window(), i18n("Failed to expand the command '%1'.", cmd), i18n("Kate External Tools")); return; } qDebug() << "externaltools: Running command: " << cmd; // save documents if requested if (tool->saveMode == KateExternalTool::SaveMode::CurrentDocument) mw->activeView()->document()->save(); else if (tool->saveMode == KateExternalTool::SaveMode::AllDocuments) { foreach (KXMLGUIClient* client, mw->guiFactory()->clients()) { if (QAction* a = client->actionCollection()->action(QStringLiteral("file_save_all"))) { a->trigger(); break; } } } KRun::runCommand(cmd, tool->executable, tool->icon, mw->window()); } // END KateExternalToolAction // BEGIN KateExternalToolsMenuAction KateExternalToolsMenuAction::KateExternalToolsMenuAction(const QString& text, KActionCollection* collection, QObject* parent, KTextEditor::MainWindow* mw) : KActionMenu(text, parent) , mainwindow(mw) { m_actionCollection = collection; // connect to view changed... connect(mw, &KTextEditor::MainWindow::viewChanged, this, &KateExternalToolsMenuAction::slotViewChanged); reload(); } KateExternalToolsMenuAction::~KateExternalToolsMenuAction() { // kDebug() << "deleted KateExternalToolsMenuAction"; } void KateExternalToolsMenuAction::reload() { bool needs_readd = (m_actionCollection->takeAction(this) != nullptr); m_actionCollection->clear(); if (needs_readd) m_actionCollection->addAction(QStringLiteral("tools_external"), this); menu()->clear(); // load all the tools, and create a action for each of them KSharedConfig::Ptr pConfig = KSharedConfig::openConfig(QStringLiteral("externaltools"), KConfig::NoGlobals, QStandardPaths::ApplicationsLocation); KConfigGroup config(pConfig, "Global"); QStringList tools = config.readEntry("tools", QStringList()); // if there are tools that are present but not explicitly removed, // add them to the end of the list pConfig->setReadDefaults(true); QStringList dtools = config.readEntry("tools", QStringList()); int gver = config.readEntry("version", 1); pConfig->setReadDefaults(false); int ver = config.readEntry("version", 0); if (ver <= gver) { QStringList removed = config.readEntry("removed", QStringList()); bool sepadded = false; for (QStringList::iterator itg = dtools.begin(); itg != dtools.end(); ++itg) { if (!tools.contains(*itg) && !removed.contains(*itg)) { if (!sepadded) { tools << QStringLiteral("---"); sepadded = true; } tools << *itg; } } config.writeEntry("tools", tools); config.sync(); config.writeEntry("version", gver); } for (QStringList::const_iterator it = tools.constBegin(); it != tools.constEnd(); ++it) { if (*it == QStringLiteral("---")) { menu()->addSeparator(); // a separator continue; } config = KConfigGroup(pConfig, *it); KateExternalTool* t = new KateExternalTool( config.readEntry("name", ""), config.readEntry("command", ""), config.readEntry("icon", ""), config.readEntry("executable", ""), config.readEntry("mimetypes", QStringList()), config.readEntry("acname", ""), config.readEntry("cmdname", ""), static_cast(config.readEntry("save", 0))); if (t->hasexec) { QAction* a = new KateExternalToolAction(this, t); m_actionCollection->addAction(t->acname, a); addAction(a); } else delete t; } config = KConfigGroup(pConfig, "Shortcuts"); m_actionCollection->readSettings(&config); slotViewChanged(mainwindow->activeView()); } void KateExternalToolsMenuAction::slotViewChanged(KTextEditor::View* view) { // no active view, oh oh if (!view) { return; } // try to enable/disable to match current mime type KTextEditor::Document* doc = view->document(); if (doc) { const QString mimeType = doc->mimeType(); foreach (QAction* kaction, m_actionCollection->actions()) { KateExternalToolAction* action = dynamic_cast(kaction); if (action) { const QStringList l = action->tool->mimetypes; const bool b = (!l.count() || l.contains(mimeType)); action->setEnabled(b); } } } } // END KateExternalToolsMenuAction // BEGIN ToolItem /** * This is a QListBoxItem, that has a KateExternalTool. The text is the Name * of the tool. */ class ToolItem : public QListWidgetItem { public: ToolItem(QListWidget* lb, const QPixmap& icon, KateExternalTool* tool) : QListWidgetItem(icon, tool->name, lb) , tool(tool) { } ~ToolItem() {} KateExternalTool* tool; }; // END ToolItem // BEGIN KateExternalToolServiceEditor KateExternalToolServiceEditor::KateExternalToolServiceEditor(KateExternalTool* tool, QWidget* parent) : QDialog(parent) , tool(tool) { setWindowTitle(i18n("Edit External Tool")); ui = new Ui::ToolDialog(); ui->setupUi(this); ui->btnIcon->setIconSize(KIconLoader::SizeSmall); connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &KateExternalToolServiceEditor::slotOKClicked); connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); connect(ui->btnMimeType, &QToolButton::clicked, this, &KateExternalToolServiceEditor::showMTDlg); if (tool) { ui->edtName->setText(tool->name); if (!tool->icon.isEmpty()) ui->btnIcon->setIcon(tool->icon); ui->edtExecutable->setText(tool->executable); ui->edtInput->setText(tool->command); ui->edtMimeType->setText(tool->mimetypes.join(QStringLiteral("; "))); ui->cmbSave->setCurrentIndex(static_cast(tool->saveMode)); ui->edtCommand->setText(tool->cmdname); } } void KateExternalToolServiceEditor::slotOKClicked() { if (ui->edtName->text().isEmpty() || ui->edtInput->document()->isEmpty()) { QMessageBox::information(this, i18n("External Tool"), i18n("You must specify at least a name and a command")); return; } accept(); } void KateExternalToolServiceEditor::showMTDlg() { QString text = i18n("Select the MimeTypes for which to enable this tool."); QStringList list = ui->edtMimeType->text().split(QRegExp(QStringLiteral("\\s*;\\s*")), QString::SkipEmptyParts); KMimeTypeChooserDialog d(i18n("Select Mime Types"), text, list, QStringLiteral("text"), this); if (d.exec() == QDialog::Accepted) { ui->edtMimeType->setText(d.chooser()->mimeTypes().join(QStringLiteral(";"))); } } // END KateExternalToolServiceEditor // BEGIN KateExternalToolsConfigWidget KateExternalToolsConfigWidget::KateExternalToolsConfigWidget(QWidget* parent, KateExternalToolsPlugin* plugin) : KTextEditor::ConfigPage(parent) - , m_changed(false) , m_plugin(plugin) { setupUi(this); btnMoveUp->setIcon(QIcon::fromTheme(QStringLiteral("go-up"))); btnMoveDown->setIcon(QIcon::fromTheme(QStringLiteral("go-down"))); connect(lbTools, &QListWidget::itemSelectionChanged, this, &KateExternalToolsConfigWidget::slotSelectionChanged); connect(lbTools, &QListWidget::itemDoubleClicked, this, &KateExternalToolsConfigWidget::slotEdit); connect(btnNew, &QPushButton::clicked, this, &KateExternalToolsConfigWidget::slotNew); connect(btnRemove, &QPushButton::clicked, this, &KateExternalToolsConfigWidget::slotRemove); connect(btnEdit, &QPushButton::clicked, this, &KateExternalToolsConfigWidget::slotEdit); connect(btnSeparator, &QPushButton::clicked, this, &KateExternalToolsConfigWidget::slotInsertSeparator); connect(btnMoveUp, &QPushButton::clicked, this, &KateExternalToolsConfigWidget::slotMoveUp); connect(btnMoveDown, &QPushButton::clicked, this, &KateExternalToolsConfigWidget::slotMoveDown); m_config = new KConfig(QStringLiteral("externaltools"), KConfig::NoGlobals, QStandardPaths::ApplicationsLocation); reset(); slotSelectionChanged(); } KateExternalToolsConfigWidget::~KateExternalToolsConfigWidget() { delete m_config; } QString KateExternalToolsConfigWidget::name() const { return i18n("External Tools"); } QString KateExternalToolsConfigWidget::fullName() const { return i18n("External Tools"); } QIcon KateExternalToolsConfigWidget::icon() const { return QIcon(); } void KateExternalToolsConfigWidget::reset() { // m_tools.clear(); lbTools->clear(); // load the files from a KConfig const QStringList tools = m_config->group("Global").readEntry("tools", QStringList()); for (QStringList::const_iterator it = tools.begin(); it != tools.end(); ++it) { if (*it == QStringLiteral("---")) { new QListWidgetItem(QStringLiteral("---"), lbTools); } else { KConfigGroup cg(m_config, *it); KateExternalTool* t = new KateExternalTool(); t->load(cg); if (t->hasexec) // we only show tools that are also in the menu. new ToolItem(lbTools, t->icon.isEmpty() ? blankIcon() : SmallIcon(t->icon), t); else delete t; } } m_changed = false; } QPixmap KateExternalToolsConfigWidget::blankIcon() { QPixmap pm(KIconLoader::SizeSmall, KIconLoader::SizeSmall); pm.fill(); pm.setMask(pm.createHeuristicMask()); return pm; } void KateExternalToolsConfigWidget::apply() { if (!m_changed) return; m_changed = false; // save a new list // save each item QStringList tools; for (int i = 0; i < lbTools->count(); i++) { if (lbTools->item(i)->text() == QStringLiteral("---")) { tools << QStringLiteral("---"); continue; } KateExternalTool* t = static_cast(lbTools->item(i))->tool; // qDebug()<<"adding tool: "<name; tools << t->acname; KConfigGroup cg(m_config, t->acname); t->save(cg); } m_config->group("Global").writeEntry("tools", tools); // if any tools was removed, try to delete their groups, and // add the group names to the list of removed items. if (m_removed.count()) { for (QStringList::iterator it = m_removed.begin(); it != m_removed.end(); ++it) { if (m_config->hasGroup(*it)) m_config->deleteGroup(*it); } QStringList removed = m_config->group("Global").readEntry("removed", QStringList()); removed += m_removed; // clean up the list of removed items, so that it does not contain // non-existing groups (we can't remove groups from a non-owned global file). m_config->sync(); QStringList::iterator it1 = removed.begin(); while (it1 != removed.end()) { if (!m_config->hasGroup(*it1)) it1 = removed.erase(it1); else ++it1; } m_config->group("Global").writeEntry("removed", removed); } m_config->sync(); m_plugin->reload(); } void KateExternalToolsConfigWidget::slotSelectionChanged() { // update button state bool hs = lbTools->currentItem() != nullptr; btnEdit->setEnabled(hs && dynamic_cast(lbTools->currentItem())); btnRemove->setEnabled(hs); btnMoveUp->setEnabled((lbTools->currentRow() > 0) && hs); btnMoveDown->setEnabled((lbTools->currentRow() < (int)lbTools->count() - 1) && hs); } void KateExternalToolsConfigWidget::slotNew() { // display a editor, and if it is OK'd, create a new tool and // create a listbox item for it KateExternalToolServiceEditor editor(nullptr, this); if (editor.exec() == QDialog::Accepted) { KateExternalTool* t = new KateExternalTool( editor.ui->edtName->text(), editor.ui->edtInput->toPlainText(), editor.ui->btnIcon->icon(), editor.ui->edtExecutable->text(), editor.ui->edtMimeType->text().split(QRegExp(QStringLiteral("\\s*;\\s*")), QString::SkipEmptyParts)); // This is sticky, it does not change again, so that shortcuts sticks // TODO check for dups t->acname = QStringLiteral("externaltool_") + QString(t->name).remove(QRegExp(QStringLiteral("\\W+"))); new ToolItem(lbTools, t->icon.isEmpty() ? blankIcon() : SmallIcon(t->icon), t); emit changed(); m_changed = true; } } void KateExternalToolsConfigWidget::slotRemove() { // add the tool action name to a list of removed items, // remove the current listbox item if (lbTools->currentRow() > -1) { ToolItem* i = dynamic_cast(lbTools->currentItem()); if (i) m_removed << i->tool->acname; delete lbTools->takeItem(lbTools->currentRow()); emit changed(); m_changed = true; } } void KateExternalToolsConfigWidget::slotEdit() { if (!dynamic_cast(lbTools->currentItem())) return; // show the item in an editor KateExternalTool* t = static_cast(lbTools->currentItem())->tool; KateExternalToolServiceEditor editor(t, this); editor.resize(m_config->group("Editor").readEntry("Size", QSize())); if (editor.exec() /*== KDialog::Ok*/) { bool elementChanged = ((editor.ui->btnIcon->icon() != t->icon) || (editor.ui->edtName->text() != t->name)); t->name = editor.ui->edtName->text(); t->cmdname = editor.ui->edtCommand->text(); t->command = editor.ui->edtInput->toPlainText(); t->icon = editor.ui->btnIcon->icon(); t->executable = editor.ui->edtExecutable->text(); t->mimetypes = editor.ui->edtMimeType->text().split(QRegExp(QStringLiteral("\\s*;\\s*")), QString::SkipEmptyParts); t->saveMode = static_cast(editor.ui->cmbSave->currentIndex()); // if the icon has changed or name changed, I have to renew the listbox item :S if (elementChanged) { int idx = lbTools->row(lbTools->currentItem()); delete lbTools->takeItem(idx); lbTools->insertItem(idx, new ToolItem(nullptr, t->icon.isEmpty() ? blankIcon() : SmallIcon(t->icon), t)); } emit changed(); m_changed = true; } m_config->group("Editor").writeEntry("Size", editor.size()); m_config->sync(); } void KateExternalToolsConfigWidget::slotInsertSeparator() { lbTools->insertItem(lbTools->currentRow() + 1, QStringLiteral("---")); emit changed(); m_changed = true; } void KateExternalToolsConfigWidget::slotMoveUp() { // move the current item in the listbox upwards if possible QListWidgetItem* item = lbTools->currentItem(); if (!item) return; int idx = lbTools->row(item); if (idx < 1) return; if (dynamic_cast(item)) { KateExternalTool* tool = static_cast(item)->tool; delete lbTools->takeItem(idx); lbTools->insertItem(idx - 1, new ToolItem(nullptr, tool->icon.isEmpty() ? blankIcon() : SmallIcon(tool->icon), tool)); } else // a separator! { delete lbTools->takeItem(idx); lbTools->insertItem(idx - 1, new QListWidgetItem(QStringLiteral("---"))); } lbTools->setCurrentRow(idx - 1); slotSelectionChanged(); emit changed(); m_changed = true; } void KateExternalToolsConfigWidget::slotMoveDown() { // move the current item in the listbox downwards if possible QListWidgetItem* item = lbTools->currentItem(); if (!item) return; int idx = lbTools->row(item); if (idx > lbTools->count() - 1) return; if (dynamic_cast(item)) { KateExternalTool* tool = static_cast(item)->tool; delete lbTools->takeItem(idx); lbTools->insertItem(idx + 1, new ToolItem(nullptr, tool->icon.isEmpty() ? blankIcon() : SmallIcon(tool->icon), tool)); } else // a separator! { delete lbTools->takeItem(idx); lbTools->insertItem(idx + 1, new QListWidgetItem(QStringLiteral("---"))); } lbTools->setCurrentRow(idx + 1); slotSelectionChanged(); emit changed(); m_changed = true; } // END KateExternalToolsConfigWidget ExternalToolRunner::ExternalToolRunner(KateExternalTool * tool) : m_tool(tool) { } ExternalToolRunner::~ExternalToolRunner() { } void ExternalToolRunner::run() { } // kate: space-indent on; indent-width 4; replace-tabs on; diff --git a/addons/externaltools/externaltools.h b/addons/externaltools/externaltools.h index 87de7863d..e1123524a 100644 --- a/addons/externaltools/externaltools.h +++ b/addons/externaltools/externaltools.h @@ -1,228 +1,227 @@ /* This file is part of the Kate text editor of the KDE project. It describes a "external tools" action for kate and provides a dialog page to configure that. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. --- Copyright (C) 2004 Anders Lund Copyright (C) 2019 Dominik Haumann */ #ifndef KTEXTEDITOR_EXTERNALTOOLS_H #define KTEXTEDITOR_EXTERNALTOOLS_H #include "ui_configwidget.h" #include "ui_tooldialog.h" #include #include #include #include #include #include #include #include #include #include #include class KateExternalToolsPlugin; class KateExternalTool; /** * The external tools action * This action creates a menu, in which each item will launch a process * with the provided arguments, which may include the following macros: * - %URLS: the URLs of all open documents. * - %URL: The URL of the active document. * - %filedir: The directory of the current document, if that is a local file. * - %selection: The selection of the active document. * - %text: The text of the active document. * - %line: The line number of the cursor in the active view. * - %column: The column of the cursor in the active view. * * Each item has the following properties: * - Name: The friendly text for the menu * - Exec: The command to execute, including arguments. * - TryExec: the name of the executable, if not available, the * item will not be displayed. * - MimeTypes: An optional list of mimetypes. The item will be disabled or * hidden if the current file is not of one of the indicated types. * */ class KateExternalToolsMenuAction : public KActionMenu { friend class KateExternalToolAction; Q_OBJECT public: KateExternalToolsMenuAction(const QString& text, class KActionCollection* collection, QObject* parent, class KTextEditor::MainWindow* mw = nullptr); virtual ~KateExternalToolsMenuAction(); /** * This will load all the configured services. */ void reload(); class KActionCollection* actionCollection() { return m_actionCollection; } private Q_SLOTS: void slotViewChanged(KTextEditor::View* view); private: class KActionCollection* m_actionCollection; KTextEditor::MainWindow* mainwindow; // for the actions to access view/doc managers }; /** * This Action contains a KateExternalTool */ class KateExternalToolAction : public QAction, public KWordMacroExpander { Q_OBJECT public: KateExternalToolAction(QObject* parent, class KateExternalTool* t); ~KateExternalToolAction(); protected: bool expandMacro(const QString& str, QStringList& ret) override; private Q_SLOTS: void slotRun(); public: class KateExternalTool* tool; }; /** * The config widget. * The config widget allows the user to view a list of services of the type * "Kate/ExternalTool" and add, remove or edit them. */ class KateExternalToolsConfigWidget : public KTextEditor::ConfigPage, public Ui::ExternalToolsConfigWidget { Q_OBJECT public: KateExternalToolsConfigWidget(QWidget* parent, KateExternalToolsPlugin* plugin); virtual ~KateExternalToolsConfigWidget(); QString name() const override; QString fullName() const override; QIcon icon() const override; public Q_SLOTS: void apply() override; void reset() override; void defaults() override { reset(); } // double sigh private Q_SLOTS: void slotNew(); void slotEdit(); void slotRemove(); void slotInsertSeparator(); void slotMoveUp(); void slotMoveDown(); void slotSelectionChanged(); private: QPixmap blankIcon(); QStringList m_removed; class KConfig* m_config = nullptr; - - bool m_changed; + bool m_changed = false; KateExternalToolsPlugin* m_plugin; }; /** * A Singleton class for invoking external tools with the view command line */ class KateExternalToolsCommand : public KTextEditor::Command { public: KateExternalToolsCommand(KateExternalToolsPlugin* plugin); virtual ~KateExternalToolsCommand() {} void reload(); public: // const QStringList& cmds() override; // FIXME bool exec(KTextEditor::View* view, const QString& cmd, QString& msg, const KTextEditor::Range& range = KTextEditor::Range::invalid()) override; bool help(KTextEditor::View* view, const QString& cmd, QString& msg) override; private: QStringList m_list; QHash m_map; QHash m_name; KateExternalToolsPlugin* m_plugin; }; /** * A Dialog to edit a single KateExternalTool object */ class KateExternalToolServiceEditor : public QDialog { Q_OBJECT public: explicit KateExternalToolServiceEditor(KateExternalTool* tool = nullptr, QWidget* parent = nullptr); private Q_SLOTS: /** * Run when the OK button is clicked, to ensure critical values are provided. */ void slotOKClicked(); /** * show a mimetype chooser dialog */ void showMTDlg(); public: Ui::ToolDialog * ui; private: KateExternalTool* tool; }; /** * Helper class to run a KateExternalTool. */ class ExternalToolRunner { public: ExternalToolRunner(KateExternalTool * tool); ExternalToolRunner(const ExternalToolRunner &) = delete; void operator=(const ExternalToolRunner &) = delete; ~ExternalToolRunner(); void run(); private: KateExternalTool * m_tool; QProcess * m_process = nullptr; }; #endif // KTEXTEDITOR_EXTERNALTOOLS_H // kate: space-indent on; indent-width 4; replace-tabs on;