Commit 9fae1c23 authored by Dominik Haumann's avatar Dominik Haumann

Run clang-format on external tools plugin

parent 29983d9f
......@@ -56,10 +56,9 @@ static QVector<KateExternalTool> readDefaultTools()
return tools;
}
K_PLUGIN_FACTORY_WITH_JSON(KateExternalToolsFactory, "externaltoolsplugin.json",
registerPlugin<KateExternalToolsPlugin>();)
K_PLUGIN_FACTORY_WITH_JSON(KateExternalToolsFactory, "externaltoolsplugin.json", registerPlugin<KateExternalToolsPlugin>();)
KateExternalToolsPlugin::KateExternalToolsPlugin(QObject* parent, const QList<QVariant>&)
KateExternalToolsPlugin::KateExternalToolsPlugin(QObject *parent, const QList<QVariant> &)
: KTextEditor::Plugin(parent)
{
// read built-in external tools from compiled-in resource file
......@@ -75,9 +74,9 @@ KateExternalToolsPlugin::~KateExternalToolsPlugin()
m_command = nullptr;
}
QObject* KateExternalToolsPlugin::createView(KTextEditor::MainWindow* mainWindow)
QObject *KateExternalToolsPlugin::createView(KTextEditor::MainWindow *mainWindow)
{
KateExternalToolsPluginView* view = new KateExternalToolsPluginView(mainWindow, this);
KateExternalToolsPluginView *view = new KateExternalToolsPluginView(mainWindow, this);
connect(this, &KateExternalToolsPlugin::externalToolsChanged, view, &KateExternalToolsPluginView::rebuildMenu);
return view;
}
......@@ -106,7 +105,7 @@ void KateExternalToolsPlugin::reload()
}
} else {
// first start -> use system config
for (const auto & tool : m_defaultTools) {
for (const auto &tool : m_defaultTools) {
m_tools.push_back(new KateExternalTool(tool));
}
}
......@@ -130,7 +129,7 @@ QStringList KateExternalToolsPlugin::commands() const
return m_commands;
}
const KateExternalTool* KateExternalToolsPlugin::toolForCommand(const QString& cmd) const
const KateExternalTool *KateExternalToolsPlugin::toolForCommand(const QString &cmd) const
{
for (auto tool : m_tools) {
if (tool->cmdname == cmd) {
......@@ -140,7 +139,7 @@ const KateExternalTool* KateExternalToolsPlugin::toolForCommand(const QString& c
return nullptr;
}
const QVector<KateExternalTool*> & KateExternalToolsPlugin::tools() const
const QVector<KateExternalTool *> &KateExternalToolsPlugin::tools() const
{
return m_tools;
}
......@@ -150,7 +149,7 @@ QVector<KateExternalTool> KateExternalToolsPlugin::defaultTools() const
return m_defaultTools;
}
void KateExternalToolsPlugin::runTool(const KateExternalTool& tool, KTextEditor::View* view)
void KateExternalToolsPlugin::runTool(const KateExternalTool &tool, KTextEditor::View *view)
{
// expand the macros in command if any,
// and construct a command with an absolute path
......@@ -163,8 +162,8 @@ void KateExternalToolsPlugin::runTool(const KateExternalTool& tool, KTextEditor:
view->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"))) {
foreach (KXMLGUIClient *client, mw->guiFactory()->clients()) {
if (QAction *a = client->actionCollection()->action(QStringLiteral("file_save_all"))) {
a->trigger();
break;
}
......@@ -199,7 +198,7 @@ void KateExternalToolsPlugin::runTool(const KateExternalTool& tool, KTextEditor:
runner->run();
}
void KateExternalToolsPlugin::handleToolFinished(KateToolRunner* runner, int exitCode, bool crashed)
void KateExternalToolsPlugin::handleToolFinished(KateToolRunner *runner, int exitCode, bool crashed)
{
auto view = runner->view();
if (view && !runner->outputData().isEmpty()) {
......@@ -246,7 +245,7 @@ void KateExternalToolsPlugin::handleToolFinished(KateToolRunner* runner, int exi
view->setUpdatesEnabled(wereUpdatesEnabled);
}
KateExternalToolsPluginView* pluginView = runner->view() ? viewForMainWindow(runner->view()->mainWindow()) : nullptr;
KateExternalToolsPluginView *pluginView = runner->view() ? viewForMainWindow(runner->view()->mainWindow()) : nullptr;
if (pluginView) {
bool hasOutputInPane = false;
if (runner->tool()->outputMode == KateExternalTool::OutputMode::DisplayInPane) {
......@@ -283,7 +282,7 @@ int KateExternalToolsPlugin::configPages() const
return 1;
}
KTextEditor::ConfigPage* KateExternalToolsPlugin::configPage(int number, QWidget* parent)
KTextEditor::ConfigPage *KateExternalToolsPlugin::configPage(int number, QWidget *parent)
{
if (number == 0) {
return new KateExternalToolsConfigWidget(parent, this);
......@@ -291,19 +290,19 @@ KTextEditor::ConfigPage* KateExternalToolsPlugin::configPage(int number, QWidget
return nullptr;
}
void KateExternalToolsPlugin::registerPluginView(KateExternalToolsPluginView * view)
void KateExternalToolsPlugin::registerPluginView(KateExternalToolsPluginView *view)
{
Q_ASSERT(!m_views.contains(view));
m_views.push_back(view);
}
void KateExternalToolsPlugin::unregisterPluginView(KateExternalToolsPluginView * view)
void KateExternalToolsPlugin::unregisterPluginView(KateExternalToolsPluginView *view)
{
Q_ASSERT(m_views.contains(view));
m_views.removeAll(view);
}
KateExternalToolsPluginView* KateExternalToolsPlugin::viewForMainWindow(KTextEditor::MainWindow* mainWindow) const
KateExternalToolsPluginView *KateExternalToolsPlugin::viewForMainWindow(KTextEditor::MainWindow *mainWindow) const
{
for (auto view : m_views) {
if (view->mainWindow() == mainWindow) {
......
......@@ -75,12 +75,12 @@ bool KateExternalTool::checkExec() const
return !QStandardPaths::findExecutable(executable).isEmpty();
}
bool KateExternalTool::matchesMimetype(const QString& mt) const
bool KateExternalTool::matchesMimetype(const QString &mt) const
{
return mimetypes.isEmpty() || mimetypes.contains(mt);
}
void KateExternalTool::load(const KConfigGroup& cg)
void KateExternalTool::load(const KConfigGroup &cg)
{
category = cg.readEntry("category", "");
name = cg.readEntry("name", "");
......@@ -99,7 +99,7 @@ void KateExternalTool::load(const KConfigGroup& cg)
hasexec = checkExec();
}
void KateExternalTool::save(KConfigGroup& cg) const
void KateExternalTool::save(KConfigGroup &cg) const
{
cg.writeEntry("category", category);
cg.writeEntry("name", name);
......@@ -116,7 +116,7 @@ void KateExternalTool::save(KConfigGroup& cg) const
cg.writeEntry("output", toString(outputMode));
}
bool operator==(const KateExternalTool & lhs, const KateExternalTool & rhs)
bool operator==(const KateExternalTool &lhs, const KateExternalTool &rhs)
{
return lhs.category == rhs.category
&& lhs.name == rhs.name
......
......@@ -23,14 +23,13 @@
#include <KLocalizedString>
KateExternalToolsCommand::KateExternalToolsCommand(KateExternalToolsPlugin* plugin)
KateExternalToolsCommand::KateExternalToolsCommand(KateExternalToolsPlugin *plugin)
: KTextEditor::Command(plugin->commands())
, m_plugin(plugin)
{
}
bool KateExternalToolsCommand::exec(KTextEditor::View* view, const QString& cmd, QString& msg,
const KTextEditor::Range& range)
bool KateExternalToolsCommand::exec(KTextEditor::View *view, const QString &cmd, QString &msg, const KTextEditor::Range &range)
{
Q_UNUSED(msg)
Q_UNUSED(range)
......@@ -44,7 +43,7 @@ bool KateExternalToolsCommand::exec(KTextEditor::View* view, const QString& cmd,
return false;
}
bool KateExternalToolsCommand::help(KTextEditor::View*, const QString& cmd, QString& msg)
bool KateExternalToolsCommand::help(KTextEditor::View *, const QString &cmd, QString &msg)
{
const QString command = cmd.trimmed();
const auto tool = m_plugin->toolForCommand(command);
......
......@@ -44,10 +44,8 @@
#include <map>
#include <vector>
// BEGIN KateExternalToolsMenuAction
KateExternalToolsMenuAction::KateExternalToolsMenuAction(const QString& text, KActionCollection* collection,
KateExternalToolsPlugin* plugin, KTextEditor::MainWindow* mw)
KateExternalToolsMenuAction::KateExternalToolsMenuAction(const QString &text, KActionCollection *collection, KateExternalToolsPlugin *plugin, KTextEditor::MainWindow *mw)
: KActionMenu(text, mw)
, m_plugin(plugin)
, m_mainwindow(mw)
......@@ -71,8 +69,8 @@ void KateExternalToolsMenuAction::reload()
menu()->clear();
// create tool actions
std::map<QString, KActionMenu*> categories;
std::vector<QAction*> uncategorizedActions;
std::map<QString, KActionMenu *> categories;
std::vector<QAction *> uncategorizedActions;
// first add categorized actions, such that the submenus appear at the top
for (auto tool : m_plugin->tools()) {
......@@ -81,9 +79,7 @@ void KateExternalToolsMenuAction::reload()
a->setIcon(QIcon::fromTheme(tool->icon));
a->setData(QVariant::fromValue(tool));
connect(a, &QAction::triggered, [this, a]() {
m_plugin->runTool(*a->data().value<KateExternalTool*>(), m_mainwindow->activeView());
});
connect(a, &QAction::triggered, [this, a]() { m_plugin->runTool(*a->data().value<KateExternalTool *>(), m_mainwindow->activeView()); });
m_actionCollection->addAction(tool->actionName, a);
if (!tool->category.isEmpty()) {
......@@ -106,15 +102,14 @@ void KateExternalToolsMenuAction::reload()
}
// load shortcuts
KSharedConfig::Ptr pConfig = KSharedConfig::openConfig(QStringLiteral("externaltools"), KConfig::NoGlobals,
QStandardPaths::ApplicationsLocation);
KSharedConfig::Ptr pConfig = KSharedConfig::openConfig(QStringLiteral("externaltools"), KConfig::NoGlobals, QStandardPaths::ApplicationsLocation);
KConfigGroup config(pConfig, "Global");
config = KConfigGroup(pConfig, "Shortcuts");
m_actionCollection->readSettings(&config);
slotViewChanged(m_mainwindow->activeView());
}
void KateExternalToolsMenuAction::slotViewChanged(KTextEditor::View* view)
void KateExternalToolsMenuAction::slotViewChanged(KTextEditor::View *view)
{
// no active view, oh oh
if (!view) {
......@@ -123,22 +118,17 @@ void KateExternalToolsMenuAction::slotViewChanged(KTextEditor::View* view)
// try to enable/disable to match current mime type
const QString mimeType = view->document()->mimeType();
foreach (QAction* action, m_actionCollection->actions()) {
if (action && action->data().value<KateExternalTool*>()) {
auto tool = action->data().value<KateExternalTool*>();
foreach (QAction *action, m_actionCollection->actions()) {
if (action && action->data().value<KateExternalTool *>()) {
auto tool = action->data().value<KateExternalTool *>();
action->setEnabled(tool->matchesMimetype(mimeType));
}
}
}
// END KateExternalToolsMenuAction
// BEGIN KateExternalToolsPluginView
KateExternalToolsPluginView::KateExternalToolsPluginView(KTextEditor::MainWindow* mainWindow,
KateExternalToolsPlugin* plugin)
KateExternalToolsPluginView::KateExternalToolsPluginView(KTextEditor::MainWindow *mainWindow, KateExternalToolsPlugin *plugin)
: QObject(mainWindow)
, m_plugin(plugin)
, m_mainWindow(mainWindow)
......@@ -159,7 +149,7 @@ KateExternalToolsPluginView::KateExternalToolsPluginView(KTextEditor::MainWindow
mainWindow->guiFactory()->addClient(this);
// ESC should close & hide ToolView
connect(m_mainWindow, &KTextEditor::MainWindow::unhandledShortcutOverride, [this](QEvent* event) {
connect(m_mainWindow, &KTextEditor::MainWindow::unhandledShortcutOverride, [this](QEvent *event) {
auto keyEvent = static_cast<QKeyEvent *>(event);
if (keyEvent->key() == Qt::Key_Escape && keyEvent->modifiers() == Qt::NoModifier) {
deleteToolView();
......@@ -182,7 +172,7 @@ KateExternalToolsPluginView::~KateExternalToolsPluginView()
void KateExternalToolsPluginView::rebuildMenu()
{
if (m_externalToolsMenu) {
KXMLGUIFactory* f = factory();
KXMLGUIFactory *f = factory();
f->removeClient(this);
reloadXML();
m_externalToolsMenu->reload();
......@@ -190,7 +180,7 @@ void KateExternalToolsPluginView::rebuildMenu()
}
}
KTextEditor::MainWindow* KateExternalToolsPluginView::mainWindow() const
KTextEditor::MainWindow *KateExternalToolsPluginView::mainWindow() const
{
return m_mainWindow;
}
......@@ -198,8 +188,7 @@ KTextEditor::MainWindow* KateExternalToolsPluginView::mainWindow() const
void KateExternalToolsPluginView::createToolView()
{
if (!m_toolView) {
m_toolView = mainWindow()->createToolView(m_plugin, QStringLiteral("ktexteditor_plugin_externaltools"),
KTextEditor::MainWindow::Bottom, QIcon::fromTheme(QStringLiteral("system-run")), i18n("External Tools"));
m_toolView = mainWindow()->createToolView(m_plugin, QStringLiteral("ktexteditor_plugin_externaltools"), KTextEditor::MainWindow::Bottom, QIcon::fromTheme(QStringLiteral("system-run")), i18n("External Tools"));
m_ui = new Ui::ToolView();
m_ui->setupUi(m_toolView);
......@@ -241,7 +230,7 @@ void KateExternalToolsPluginView::clearToolView()
m_statusDoc->clear();
}
void KateExternalToolsPluginView::addToolStatus(const QString& message)
void KateExternalToolsPluginView::addToolStatus(const QString &message)
{
QTextCursor cursor(m_statusDoc);
cursor.movePosition(QTextCursor::End);
......@@ -249,7 +238,7 @@ void KateExternalToolsPluginView::addToolStatus(const QString& message)
cursor.insertText(QStringLiteral("\n"));
}
void KateExternalToolsPluginView::setOutputData(const QString& data)
void KateExternalToolsPluginView::setOutputData(const QString &data)
{
QTextCursor cursor(m_outputDoc);
cursor.movePosition(QTextCursor::End);
......
......@@ -26,7 +26,7 @@
#include <KTextEditor/View>
#include <KLocalizedString>
KateToolRunner::KateToolRunner(std::unique_ptr<KateExternalTool> tool, KTextEditor::View * view, QObject* parent)
KateToolRunner::KateToolRunner(std::unique_ptr<KateExternalTool> tool, KTextEditor::View *view, QObject *parent)
: QObject(parent)
, m_view(view)
, m_tool(std::move(tool))
......@@ -39,12 +39,12 @@ KateToolRunner::~KateToolRunner()
{
}
KTextEditor::View* KateToolRunner::view() const
KTextEditor::View *KateToolRunner::view() const
{
return m_view;
}
KateExternalTool* KateToolRunner::tool() const
KateExternalTool *KateToolRunner::tool() const
{
return m_tool.get();
}
......@@ -62,16 +62,10 @@ void KateToolRunner::run()
}
}
QObject::connect(m_process.get(), &QProcess::readyReadStandardOutput, [this]() {
m_stdout += m_process->readAllStandardOutput();
});
QObject::connect(m_process.get(), &QProcess::readyReadStandardError, [this]() {
m_stderr += m_process->readAllStandardError();
});
QObject::connect(m_process.get(), static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished),
[this](int exitCode, QProcess::ExitStatus exitStatus) {
Q_EMIT toolFinished(this, exitCode, exitStatus == QProcess::CrashExit);
});
QObject::connect(m_process.get(), &QProcess::readyReadStandardOutput, [this]() { m_stdout += m_process->readAllStandardOutput(); });
QObject::connect(m_process.get(), &QProcess::readyReadStandardError, [this]() { m_stderr += m_process->readAllStandardError(); });
QObject::connect(
m_process.get(), static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), [this](int exitCode, QProcess::ExitStatus exitStatus) { Q_EMIT toolFinished(this, exitCode, exitStatus == QProcess::CrashExit); });
// Write stdin to process, if applicable, then close write channel
QObject::connect(m_process.get(), &QProcess::started, [this]() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment