Commit 621494eb authored by Alexander Lohnau's avatar Alexander Lohnau 💬
Browse files

Run clang-format

If you want git blame to ignore formatting revisions run:
git config blame.ignoreRevsFile .git-blame-ignore-revs
parent 9961ef38
......@@ -32,8 +32,8 @@
K_PLUGIN_FACTORY_WITH_JSON(KateBtBrowserFactory, "katebacktracebrowserplugin.json", registerPlugin<KateBtBrowserPlugin>();)
KateBtBrowserPlugin *KateBtBrowserPlugin::s_self = nullptr;
static QStringList fileExtensions = QStringList() << QStringLiteral("*.cpp") << QStringLiteral("*.cxx") << QStringLiteral("*.c") << QStringLiteral("*.cc") << QStringLiteral("*.h") << QStringLiteral("*.hpp") << QStringLiteral("*.hxx")
<< QStringLiteral("*.moc");
static QStringList fileExtensions = QStringList() << QStringLiteral("*.cpp") << QStringLiteral("*.cxx") << QStringLiteral("*.c") << QStringLiteral("*.cc")
<< QStringLiteral("*.h") << QStringLiteral("*.hpp") << QStringLiteral("*.hxx") << QStringLiteral("*.moc");
KateBtBrowserPlugin::KateBtBrowserPlugin(QObject *parent, const QList<QVariant> &)
: KTextEditor::Plugin(parent)
......@@ -110,7 +110,11 @@ KateBtBrowserPluginView::KateBtBrowserPluginView(KateBtBrowserPlugin *plugin, KT
, m_plugin(plugin)
{
// init console
QWidget *toolview = mainWindow->createToolView(plugin, QStringLiteral("kate_private_plugin_katebacktracebrowserplugin"), KTextEditor::MainWindow::Bottom, QIcon::fromTheme(QStringLiteral("tools-report-bug")), i18n("Backtrace Browser"));
QWidget *toolview = mainWindow->createToolView(plugin,
QStringLiteral("kate_private_plugin_katebacktracebrowserplugin"),
KTextEditor::MainWindow::Bottom,
QIcon::fromTheme(QStringLiteral("tools-report-bug")),
i18n("Backtrace Browser"));
m_widget = new KateBtBrowserWidget(mainWindow, toolview);
connect(plugin, &KateBtBrowserPlugin::newStatus, m_widget, &KateBtBrowserWidget::setStatus);
......
......@@ -130,7 +130,9 @@ void CloseExceptPluginView::appendActionsFrom(const std::set<QUrl> &paths, actio
QString action = path.path() + QLatin1Char('*');
actions[action] = QPointer<QAction>(new QAction(action, menu));
menu->addAction(actions[action]);
connect(actions[action].data(), &QAction::triggered, this, [this, closeFunction, action]() { (this->*closeFunction)(action); });
connect(actions[action].data(), &QAction::triggered, this, [this, closeFunction, action]() {
(this->*closeFunction)(action);
});
}
}
......@@ -140,11 +142,17 @@ void CloseExceptPluginView::appendActionsFrom(const std::set<QString> &masks, ac
QString action = mask.startsWith(QLatin1Char('*')) ? mask : mask + QLatin1Char('*');
actions[action] = QPointer<QAction>(new QAction(action, menu));
menu->addAction(actions[action]);
connect(actions[action].data(), &QAction::triggered, this, [this, closeFunction, action]() { (this->*closeFunction)(action); });
connect(actions[action].data(), &QAction::triggered, this, [this, closeFunction, action]() {
(this->*closeFunction)(action);
});
}
}
void CloseExceptPluginView::updateMenu(const std::set<QUrl> &paths, const std::set<QString> &masks, actions_map_type &actions, KActionMenu *menu, CloseFunction closeFunction)
void CloseExceptPluginView::updateMenu(const std::set<QUrl> &paths,
const std::set<QString> &masks,
actions_map_type &actions,
KActionMenu *menu,
CloseFunction closeFunction)
{
// turn menu ON or OFF depending on collected results
menu->setEnabled(!paths.empty());
......@@ -236,7 +244,8 @@ void CloseExceptPluginView::close(const QString &item, const bool close_if_match
return;
}
// Show confirmation dialog if needed
const bool removeNeeded = !m_plugin->showConfirmationNeeded() || CloseConfirmDialog(docs2close, m_show_confirmation_action, qobject_cast<QWidget *>(this)).exec();
const bool removeNeeded =
!m_plugin->showConfirmationNeeded() || CloseConfirmDialog(docs2close, m_show_confirmation_action, qobject_cast<QWidget *>(this)).exec();
if (removeNeeded) {
if (docs2close.isEmpty()) {
displayMessage(i18nc("@title:window", "Error"), i18nc("@info:tooltip", "No files to close ..."), KTextEditor::Message::Error);
......
......@@ -8,10 +8,10 @@
#include "colorpickerconfigpage.h"
#include <KTextEditor/ConfigPage>
#include <KLocalizedString>
#include <KConfigGroup>
#include <KLocalizedString>
#include <KSharedConfig>
#include <KTextEditor/ConfigPage>
#include <QApplication>
#include <QCheckBox>
......@@ -36,7 +36,8 @@ KateColorPickerConfigPage::KateColorPickerConfigPage(QWidget *parent, KateColorP
layout->setContentsMargins(0, 0, 0, 0);
chkNamedColors = new QCheckBox(i18n("Show preview for known color names"), this);
chkNamedColors->setToolTip(i18n("Also show the color picker for known color names (e.g. skyblue).\nSee https://www.w3.org/TR/SVG11/types.html#ColorKeywords for the list of colors."));
chkNamedColors->setToolTip(i18n(
"Also show the color picker for known color names (e.g. skyblue).\nSee https://www.w3.org/TR/SVG11/types.html#ColorKeywords for the list of colors."));
layout->addWidget(chkNamedColors);
chkPreviewAfterColor = new QCheckBox(i18n("Place preview after text color"), this);
......
......@@ -37,7 +37,7 @@ public:
private:
QCheckBox *chkNamedColors;
QCheckBox *chkPreviewAfterColor;
QMap <int, QCheckBox*> chkHexLengths;
QMap<int, QCheckBox *> chkHexLengths;
KateColorPickerPlugin *m_plugin;
bool m_colorConfigChanged = false;
};
......
......@@ -12,15 +12,15 @@
#include <algorithm>
#include <KTextEditor/Document>
#include <KTextEditor/InlineNoteProvider>
#include <KTextEditor/InlineNoteInterface>
#include <KTextEditor/MainWindow>
#include <KTextEditor/View>
#include <KConfigGroup>
#include <KLocalizedString>
#include <KPluginFactory>
#include <KSharedConfig>
#include <KTextEditor/Document>
#include <KTextEditor/InlineNoteInterface>
#include <KTextEditor/InlineNoteProvider>
#include <KTextEditor/MainWindow>
#include <KTextEditor/View>
#include <QColor>
#include <QColorDialog>
......@@ -41,17 +41,17 @@ ColorPickerInlineNoteProvider::ColorPickerInlineNoteProvider(KTextEditor::Docume
s_colorRegEx.setPatternOptions(QRegularExpression::DontCaptureOption);
for (auto view : m_doc->views()) {
qobject_cast<KTextEditor::InlineNoteInterface*>(view)->registerInlineNoteProvider(this);
qobject_cast<KTextEditor::InlineNoteInterface *>(view)->registerInlineNoteProvider(this);
}
connect(m_doc, &KTextEditor::Document::viewCreated, this, [this](KTextEditor::Document *, KTextEditor::View *view) {
qobject_cast<KTextEditor::InlineNoteInterface*>(view)->registerInlineNoteProvider(this);
connect(m_doc, &KTextEditor::Document::viewCreated, this, [this](KTextEditor::Document *, KTextEditor::View *view) {
qobject_cast<KTextEditor::InlineNoteInterface *>(view)->registerInlineNoteProvider(this);
});
// textInserted and textRemoved are emitted per line, then the last line is followed by a textChanged signal
connect(m_doc, &KTextEditor::Document::textInserted, this, [this](KTextEditor::Document *, const KTextEditor::Cursor &cur, const QString &) {
int line = cur.line();
if (m_startChangedLines == -1 || m_startChangedLines > line) {
if (m_startChangedLines == -1 || m_startChangedLines > line) {
m_startChangedLines = line;
}
});
......@@ -71,7 +71,7 @@ ColorPickerInlineNoteProvider::ColorPickerInlineNoteProvider(KTextEditor::Docume
updateNotes();
} else {
// if the change involves the insertion/deletion of lines, all lines after it get shifted, so we need to update all of them
int endLine = m_previousNumLines != newNumLines ? newNumLines-1 : -1;
int endLine = m_previousNumLines != newNumLines ? newNumLines - 1 : -1;
updateNotes(m_startChangedLines, endLine);
}
......@@ -85,7 +85,7 @@ ColorPickerInlineNoteProvider::ColorPickerInlineNoteProvider(KTextEditor::Docume
ColorPickerInlineNoteProvider::~ColorPickerInlineNoteProvider()
{
for (auto view : m_doc->views()) {
qobject_cast<KTextEditor::InlineNoteInterface*>(view)->unregisterInlineNoteProvider(this);
qobject_cast<KTextEditor::InlineNoteInterface *>(view)->unregisterInlineNoteProvider(this);
}
}
......@@ -94,7 +94,7 @@ void ColorPickerInlineNoteProvider::updateColorMatchingCriteria()
QString colorRegex;
KConfigGroup config(KSharedConfig::openConfig(), "ColorPicker");
QList <int> matchHexLengths = config.readEntry("HexLengths", QList<int>{12, 9, 8, 6, 3});
QList<int> matchHexLengths = config.readEntry("HexLengths", QList<int>{12, 9, 8, 6, 3});
// sort by decreasing number of digits to maximize matched hex
std::sort(matchHexLengths.rbegin(), matchHexLengths.rend());
if (matchHexLengths.size() > 0) {
......@@ -111,7 +111,7 @@ void ColorPickerInlineNoteProvider::updateColorMatchingCriteria()
colorRegex = QStringLiteral("(%1)|").arg(colorRegex);
}
QHash <int, QStringList> colorsByLength;
QHash<int, QStringList> colorsByLength;
int numColors = 0;
for (const QString &color : QColor::colorNames()) {
const int colorLength = color.length();
......@@ -143,10 +143,11 @@ void ColorPickerInlineNoteProvider::updateColorMatchingCriteria()
s_putPreviewAfterColor = config.readEntry("PreviewAfterColor", true);
}
void ColorPickerInlineNoteProvider::updateNotes(int startLine, int endLine) {
void ColorPickerInlineNoteProvider::updateNotes(int startLine, int endLine)
{
int maxLine = m_doc->lines() - 1;
startLine = startLine < -1 ? -1 : startLine;
endLine = endLine > maxLine ? maxLine : endLine;
endLine = endLine > maxLine ? maxLine : endLine;
if (startLine == -1) {
startLine = 0;
......@@ -161,7 +162,6 @@ void ColorPickerInlineNoteProvider::updateNotes(int startLine, int endLine) {
m_colorNoteIndices.remove(line);
emit inlineNotesChanged(line);
}
}
QVector<int> ColorPickerInlineNoteProvider::inlineNotes(int line) const
......@@ -191,7 +191,7 @@ QSize ColorPickerInlineNoteProvider::inlineNoteSize(const KTextEditor::InlineNot
return QSize(note.lineHeight(), note.lineHeight());
}
void ColorPickerInlineNoteProvider::paintInlineNote(const KTextEditor::InlineNote &note, QPainter& painter) const
void ColorPickerInlineNoteProvider::paintInlineNote(const KTextEditor::InlineNote &note, QPainter &painter) const
{
const auto line = note.position().line();
auto colorEnd = note.position().column();
......@@ -205,7 +205,7 @@ void ColorPickerInlineNoteProvider::paintInlineNote(const KTextEditor::InlineNot
auto penColor = color;
penColor.setAlpha(255);
// ensure that the border color is always visible
painter.setPen( (penColor.value() < 128 ? penColor.lighter(150) : penColor.darker(150)) );
painter.setPen((penColor.value() < 128 ? penColor.lighter(150) : penColor.darker(150)));
painter.setBrush(color);
painter.setRenderHint(QPainter::Antialiasing, false);
const QFontMetricsF fm(note.font());
......@@ -233,13 +233,13 @@ void ColorPickerInlineNoteProvider::inlineNoteActivated(const KTextEditor::Inlin
dialogOptions |= QColorDialog::NoButtons;
title = i18n("View Color [Read only]");
}
const auto newColor = QColorDialog::getColor(oldColor, const_cast<KTextEditor::View*>(note.view()), title, dialogOptions);
const auto newColor = QColorDialog::getColor(oldColor, const_cast<KTextEditor::View *>(note.view()), title, dialogOptions);
if (!newColor.isValid()) {
return;
}
// include alpha channel if the new color has transparency or the old color included transparency (#AARRGGBB, 9 hex digits)
auto colorNameFormat = (newColor.alpha() != 255 || colorEnd-colorStart == 9) ? QColor::HexArgb : QColor::HexRgb;
auto colorNameFormat = (newColor.alpha() != 255 || colorEnd - colorStart == 9) ? QColor::HexArgb : QColor::HexRgb;
m_doc->replaceText({line, colorStart, line, colorEnd}, newColor.name(colorNameFormat));
}
......@@ -269,7 +269,8 @@ QObject *KateColorPickerPlugin::createView(KTextEditor::MainWindow *mainWindow)
return nullptr;
}
void KateColorPickerPlugin::addDocument(KTextEditor::Document *doc) {
void KateColorPickerPlugin::addDocument(KTextEditor::Document *doc)
{
if (!m_inlineColorNoteProviders.contains(doc)) {
m_inlineColorNoteProviders.insert(doc, new ColorPickerInlineNoteProvider(doc));
}
......@@ -279,7 +280,8 @@ void KateColorPickerPlugin::addDocument(KTextEditor::Document *doc) {
});
}
void KateColorPickerPlugin::readConfig() {
void KateColorPickerPlugin::readConfig()
{
ColorPickerInlineNoteProvider::updateColorMatchingCriteria();
for (auto colorNoteProvider : m_inlineColorNoteProviders.values()) {
colorNoteProvider->updateNotes();
......
......@@ -29,7 +29,7 @@ public:
static void updateColorMatchingCriteria();
// if startLine == -1, update all notes. endLine is inclusive and optional
void updateNotes(int startLine=-1, int endLine=-1);
void updateNotes(int startLine = -1, int endLine = -1);
QVector<int> inlineNotes(int line) const override;
QSize inlineNoteSize(const KTextEditor::InlineNote &note) const override;
......@@ -69,8 +69,7 @@ private:
KTextEditor::ConfigPage *configPage(int number = 0, QWidget *parent = nullptr) override;
KTextEditor::MainWindow *m_mainWindow;
QHash<KTextEditor::Document*, ColorPickerInlineNoteProvider*> m_inlineColorNoteProviders;
QHash<KTextEditor::Document *, ColorPickerInlineNoteProvider *> m_inlineColorNoteProviders;
};
#endif // KATE_COLORPICKER_H
......@@ -38,7 +38,7 @@ void ExternalToolTest::testLoadSave()
tool.arguments = QStringLiteral("none");
tool.input = QStringLiteral("in");
tool.workingDir = QStringLiteral("/usr/bin");
tool.mimetypes = QStringList {QStringLiteral("everything")};
tool.mimetypes = QStringList{QStringLiteral("everything")};
tool.hasexec = true;
tool.actionName = QStringLiteral("asdf");
tool.cmdname = QStringLiteral("git-cola");
......@@ -65,7 +65,7 @@ void ExternalToolTest::testRunListDirectory()
tool->executable = QStringLiteral("ls");
tool->arguments = QStringLiteral("/usr");
tool->workingDir = QStringLiteral("/tmp");
tool->mimetypes = QStringList {};
tool->mimetypes = QStringList{};
tool->hasexec = true;
tool->actionName = QStringLiteral("ls");
tool->cmdname = QStringLiteral("ls");
......
......@@ -141,8 +141,9 @@ QString KateExternalTool::translatedCategory() const
bool operator==(const KateExternalTool &lhs, const KateExternalTool &rhs)
{
return lhs.category == rhs.category && lhs.name == rhs.name && lhs.icon == rhs.icon && lhs.executable == rhs.executable && lhs.arguments == rhs.arguments && lhs.input == rhs.input && lhs.workingDir == rhs.workingDir &&
lhs.mimetypes == rhs.mimetypes && lhs.actionName == rhs.actionName && lhs.cmdname == rhs.cmdname && lhs.saveMode == rhs.saveMode && lhs.reload == rhs.reload && lhs.outputMode == rhs.outputMode;
return lhs.category == rhs.category && lhs.name == rhs.name && lhs.icon == rhs.icon && lhs.executable == rhs.executable && lhs.arguments == rhs.arguments
&& lhs.input == rhs.input && lhs.workingDir == rhs.workingDir && lhs.mimetypes == rhs.mimetypes && lhs.actionName == rhs.actionName
&& lhs.cmdname == rhs.cmdname && lhs.saveMode == rhs.saveMode && lhs.reload == rhs.reload && lhs.outputMode == rhs.outputMode;
}
// kate: space-indent on; indent-width 4; replace-tabs on;
......@@ -34,7 +34,16 @@ public:
/**
* Defines where to redirect stdout from the tool.
*/
enum class OutputMode { Ignore, InsertAtCursor, ReplaceSelectedText, ReplaceCurrentDocument, AppendToCurrentDocument, InsertInNewDocument, CopyToClipboard, DisplayInPane };
enum class OutputMode {
Ignore,
InsertAtCursor,
ReplaceSelectedText,
ReplaceCurrentDocument,
AppendToCurrentDocument,
InsertInNewDocument,
CopyToClipboard,
DisplayInPane
};
public:
/// The category used in the menu to categorize the tool.
......
......@@ -70,7 +70,9 @@ static void makeActionNameUnique(KateExternalTool *tool, const std::vector<KateE
QString name = tool->actionName;
int i = 1;
while (true) {
auto it = std::find_if(tools.cbegin(), tools.cend(), [tool, &name](const KateExternalTool *t) { return (t != tool) && (t->actionName == name); });
auto it = std::find_if(tools.cbegin(), tools.cend(), [tool, &name](const KateExternalTool *t) {
return (t != tool) && (t->actionName == name);
});
if (it == tools.cend()) {
break;
}
......@@ -93,7 +95,9 @@ void makeEditorCommandUnique(KateExternalTool *tool, const std::vector<KateExter
QString cmdname = tool->cmdname;
int i = 1;
while (true) {
auto it = std::find_if(tools.cbegin(), tools.cend(), [tool, &cmdname](const KateExternalTool *t) { return (t != tool) && (t->cmdname == cmdname); });
auto it = std::find_if(tools.cbegin(), tools.cend(), [tool, &cmdname](const KateExternalTool *t) {
return (t != tool) && (t->cmdname == cmdname);
});
if (it == tools.cend()) {
break;
}
......@@ -105,7 +109,9 @@ void makeEditorCommandUnique(KateExternalTool *tool, const std::vector<KateExter
static KateExternalTool defaultTool(const QString &actionName, const QVector<KateExternalTool> &defaultTools)
{
auto it = std::find_if(defaultTools.cbegin(), defaultTools.cend(), [actionName](const KateExternalTool &defaultTool) { return actionName == defaultTool.actionName; });
auto it = std::find_if(defaultTools.cbegin(), defaultTools.cend(), [actionName](const KateExternalTool &defaultTool) {
return actionName == defaultTool.actionName;
});
return (it != defaultTools.cend()) ? *it : KateExternalTool();
}
......@@ -244,13 +250,17 @@ KateExternalToolsConfigWidget::KateExternalToolsConfigWidget(QWidget *parent, Ka
addMenu->addSeparator();
auto addCategoryAction = addMenu->addAction(i18n("Add Category"));
btnAdd->setMenu(addMenu);
connect(addDefaultsMenu, &QMenu::aboutToShow, [this, addDefaultsMenu]() { lazyInitDefaultsMenu(addDefaultsMenu); });
connect(addDefaultsMenu, &QMenu::aboutToShow, [this, addDefaultsMenu]() {
lazyInitDefaultsMenu(addDefaultsMenu);
});
connect(addCategoryAction, &QAction::triggered, this, &KateExternalToolsConfigWidget::slotAddCategory);
connect(addToolAction, &QAction::triggered, this, &KateExternalToolsConfigWidget::slotAddTool);
connect(btnRemove, &QPushButton::clicked, this, &KateExternalToolsConfigWidget::slotRemove);
connect(btnEdit, &QPushButton::clicked, this, &KateExternalToolsConfigWidget::slotEdit);
connect(lbTools->selectionModel(), &QItemSelectionModel::currentChanged, [this]() { slotSelectionChanged(); });
connect(lbTools->selectionModel(), &QItemSelectionModel::currentChanged, [this]() {
slotSelectionChanged();
});
connect(lbTools, &QTreeView::doubleClicked, this, &KateExternalToolsConfigWidget::slotEdit);
m_config = new KConfig(QStringLiteral("externaltools"), KConfig::NoGlobals, QStandardPaths::ApplicationsLocation);
......@@ -415,7 +425,9 @@ void KateExternalToolsConfigWidget::lazyInitDefaultsMenu(QMenu *defaultsMenu)
auto a = categoryMenu->addAction(QIcon::fromTheme(tool.icon), tool.translatedName());
a->setData(defaultToolsIndex);
connect(a, &QAction::triggered, [this, a]() { slotAddDefaultTool(a->data().toInt()); });
connect(a, &QAction::triggered, [this, a]() {
slotAddDefaultTool(a->data().toInt());
});
++defaultToolsIndex;
}
}
......
......@@ -32,7 +32,10 @@
#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)
......@@ -66,7 +69,9 @@ 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()) {
......@@ -109,7 +114,7 @@ void KateExternalToolsMenuAction::slotViewChanged(KTextEditor::View *view)
}
disconnect(m_docUrlChangedConnection);
m_docUrlChangedConnection = connect(view->document(), &KTextEditor::Document::documentUrlChanged, this, [this](KTextEditor::Document* doc) {
m_docUrlChangedConnection = connect(view->document(), &KTextEditor::Document::documentUrlChanged, this, [this](KTextEditor::Document *doc) {
updateActionState(doc);
});
......@@ -195,7 +200,11 @@ 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);
......
......@@ -42,7 +42,10 @@ class KateExternalToolsMenuAction : public KActionMenu
{
Q_OBJECT
public:
KateExternalToolsMenuAction(const QString &text, KActionCollection *collection, KateExternalToolsPlugin *plugin, class KTextEditor::MainWindow *mw = nullptr);
KateExternalToolsMenuAction(const QString &text,
KActionCollection *collection,
KateExternalToolsPlugin *plugin,
class KTextEditor::MainWindow *mw = nullptr);
virtual ~KateExternalToolsMenuAction();
/**
......
......@@ -50,10 +50,17 @@ 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]() {
......
......@@ -16,7 +16,6 @@
#include <ktexteditor/document.h>
#include <ktexteditor/view.h>
#include <kwidgetsaddons_version.h>
#include <KActionCollection>
#include <KActionMenu>
#include <KConfigGroup>
......@@ -28,6 +27,7 @@
#include <KSharedConfig>
#include <KToolBar>
#include <KUrlNavigator>
#include <kwidgetsaddons_version.h>
#include <QAbstractItemView>
#include <QAction>
......@@ -38,15 +38,14 @@
#include <kio_version.h>
#if KIO_VERSION < QT_VERSION_CHECK(5, 71, 0)
# include <KOpenWithDialog>
# include <KRun>
#include <KOpenWithDialog>
#include <KRun>
#else
# include <KIO/ApplicationLauncherJob>
# include <KIO/JobUiDelegate>
#include <KIO/ApplicationLauncherJob>
#include <KIO/JobUiDelegate>
#endif
#include <KApplicationTrader>
// END Includes
KateFileBrowser::KateFileBrowser(KTextEditor::MainWindow *mainWindow, QWidget *parent)
......@@ -108,7 +107,10 @@ KateFileBrowser::KateFileBrowser(KTextEditor::MainWindow *mainWindow, QWidget *p
connect(m_filter, &KHistoryComboBox::editTextChanged, this, &KateFileBrowser::slotFilterChange);
connect(m_filter, static_cast<void (KHistoryComboBox::*)(const QString &)>(&KHistoryComboBox::returnPressed), m_filter, &KHistoryComboBox::addToHistory);
connect(m_filter, static_cast<void (KHistoryComboBox::*)(const QString &)>(&KHistoryComboBox::returnPressed), m_dirOperator, static_cast<void (KDirOperator::*)()>(&KDirOperator::setFocus));
connect(m_filter,
static_cast<void (KHistoryComboBox::*)(const QString &)>(&KHistoryComboBox::returnPressed),
m_dirOperator,
static_cast<void (KDirOperator::*)()>(&KDirOperator::setFocus));
connect(m_dirOperator, &KDirOperator::urlEntered, this, &KateFileBrowser::updateUrlNavigator);
// Connect the bookmark handler
......@@ -133,7 +135,8 @@ void KateFileBrowser::setupToolbar()
KConfigGroup config(KSharedConfig::openConfig(), "filebrowser");
QStringList actions = config.readEntry("toolbar actions", QStringList());
if (actions.isEmpty()) // default toolbar
actions << QStringLiteral("back") << QStringLiteral("forward") << QStringLiteral("bookmarks") << QStringLiteral("sync_dir") << QStringLiteral("configure");
actions << QStringLiteral("back") << QStringLiteral("forward") << QStringLiteral("bookmarks") << QStringLiteral("sync_dir")
<< QStringLiteral("configure");
// remove all actions from the toolbar (there should be none)
m_toolbar->clear();
......@@ -228,7 +231,7 @@ void KateFileBrowser::setDir(const QUrl &u)
void KateFileBrowser::contextMenuAboutToShow(const KFileItem &item, QMenu *menu)
{
if(m_openWithMenu == nullptr) {
if (m_openWithMenu == nullptr) {
m_openWithMenu = new KateFileBrowserOpenWithMenu(i18nc("@action:inmenu", "Open With"), this);
menu->insertMenu(menu->actions().at(1), m_openWithMenu);
menu->insertSeparator(menu->actions().at(2));
......@@ -259,7 +262,6 @@ void KateFileBrowser::fixOpenWithMenu()
// append "Other..." to call the KDE "open with" dialog.
a = menu->addAction(i18n("&Other..."));
a->setData(QVariant(QList<QString>({QString(), menu->item().url().toString()})));
}
void KateFileBrowser::openWithMenuAction(QAction *a)
......@@ -292,7 +294,6 @@ void KateFileBrowser::openWithMenuAction(QAction *a)
job->setUiDelegate(new KIO::JobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, this));
job->start();
#endif
}
// END Public Slots
......@@ -308,7 +309,9 @@ void KateFileBrowser::openSelectedFiles()
const KFileItemList list = m_dirOperator->selectedItems();
if (list.count() > 20) {
if (KMessageBox::questionYesNo(this, i18np("You are trying to open 1 file, are you sure?", "You are trying to open %1 files, are you sure?", list.count())) == KMessageBox::No)
if (KMessageBox::questionYesNo(this,
i18np("You are trying to open 1 file, are you sure?", "You are trying to open %1 files, are you sure?", list.count()))
== KMessageBox::No)
return;
}
......
......@@ -15,9 +15,9 @@
#include <KFile>
#include <QMenu>
#include <QUrl>
#include <QWidget>
#include <QMenu>
#include "katefilebrowseropenwithmenu.h"
......@@ -83,7 +83,6 @@ private Q_SLOTS:
void fixOpenWithMenu();
void openWithMenuAction(QAction *a);
protected:
QUrl activeDocumentUrl();
void openSelectedFiles();
......
......@@ -129,23 +129,23 @@ void KateFileBrowserConfigPage::init()
l << QStringLiteral("back") << QStringLiteral("forward") << QStringLiteral("bookmarks") << QStringLiteral("sync_dir") << QStringLiteral("configure");
// actions from diroperator + two of our own
const QStringList allActions {QStringLiteral("up"),
QStringLiteral("back"),