diff --git a/src/editortab.cpp b/src/editortab.cpp --- a/src/editortab.cpp +++ b/src/editortab.cpp @@ -1478,6 +1478,13 @@ + QString::fromLatin1(QUrl::toPercentEncoding(srcFileRelPath)))); } +static void openLocalSource(const QString& file, int line) +{ + if (Settings::self()->customEditorEnabled()) + QProcess::startDetached(QString(Settings::self()->customEditorCommand()).arg(file).arg(line)); + else + QDesktopServices::openUrl(QUrl::fromLocalFile(file)); +} void EditorTab::dispatchSrcFileOpenRequest(const QString& srcFileRelPath, int line) { @@ -1493,7 +1500,7 @@ relativePath.cdUp(); QString srcAbsolutePath(relativePath.absoluteFilePath(srcFileRelPath)); if (QFile::exists(srcAbsolutePath)) { - QDesktopServices::openUrl(QUrl::fromLocalFile(srcAbsolutePath)); + openLocalSource(srcAbsolutePath, line); return; } @@ -1518,7 +1525,7 @@ Project::instance()->local()->setSourceDir(dir); } if (dir.length()) { - auto doOpen = [srcFileRelPath]() { + auto doOpen = [srcFileRelPath, line]() { auto sourceFilePaths = Project::instance()->sourceFilePaths(); bool found = false; QByteArray fn = srcFileRelPath.midRef(srcFileRelPath.lastIndexOf('/') + 1).toUtf8(); @@ -1530,7 +1537,7 @@ continue; } found = true; - QDesktopServices::openUrl(QUrl::fromLocalFile(absFilePath)); + openLocalSource(absFilePath, line); it++; } if (!found) { diff --git a/src/prefs/lokalize.kcfg b/src/prefs/lokalize.kcfg --- a/src/prefs/lokalize.kcfg +++ b/src/prefs/lokalize.kcfg @@ -91,6 +91,12 @@ true + + false + + + kate %1:%2 + diff --git a/src/prefs/prefs.cpp b/src/prefs/prefs.cpp --- a/src/prefs/prefs.cpp +++ b/src/prefs/prefs.cpp @@ -118,6 +118,8 @@ w = new QWidget(dialog); Ui_prefs_general ui_prefs_general; ui_prefs_general.setupUi(w); + connect(ui_prefs_general.kcfg_CustomEditorEnabled, &QCheckBox::toggled, ui_prefs_general.kcfg_CustomEditorCommand, &QLineEdit::setEnabled); + ui_prefs_general.kcfg_CustomEditorCommand->setEnabled(Settings::self()->customEditorEnabled()); dialog->addPage(w, i18nc("@title:tab", "General"), "preferences-system-windows"); //Editor diff --git a/src/prefs/prefs_general.ui b/src/prefs/prefs_general.ui --- a/src/prefs/prefs_general.ui +++ b/src/prefs/prefs_general.ui @@ -71,6 +71,22 @@ + + + + Use a custom editor to open source files + + + + + + + The following parameters are available +%1 - Path of the source file +%2 - Line number + + +