mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-09 14:18:00 +08:00
This commit is contained in:
@@ -7,7 +7,7 @@ from program_widget import ProgramWidget, TabProgramsState
|
||||
from conf import *
|
||||
from programs_conf import Tool
|
||||
import subprocess
|
||||
|
||||
import os
|
||||
|
||||
|
||||
class ConfigurationPanel(QWidget, Ui_ConfigurationPanel):
|
||||
@@ -75,9 +75,13 @@ class ConfigurationPanel(QWidget, Ui_ConfigurationPanel):
|
||||
|
||||
def edit_flightplan_gcs(self, path):
|
||||
if self.flight_plan_editor is not None:
|
||||
cmd = [os.path.join(utils.PAPARAZZI_SRC, self.flight_plan_editor.command)]
|
||||
if self.flight_plan_editor.command.startswith("$"):
|
||||
cmd = [self.flight_plan_editor.command[1:]]
|
||||
else:
|
||||
cmd = [os.path.join(utils.PAPARAZZI_SRC, self.flight_plan_editor.command)]
|
||||
for arg in self.flight_plan_editor.args:
|
||||
cmd += arg.args()
|
||||
|
||||
cmd.append(os.path.join(utils.CONF_DIR, path))
|
||||
subprocess.Popen(cmd)
|
||||
# self.launch_program(self.flight_plan_editor.name, cmd, self.flight_plan_editor.icon)
|
||||
|
||||
@@ -6,7 +6,9 @@ from PyQt5.QtWidgets import *
|
||||
from typing import NamedTuple
|
||||
from PyQt5.QtCore import QSettings
|
||||
import subprocess
|
||||
from shutil import which
|
||||
|
||||
EDITORS = ["gnome-text-editor", "kate"]
|
||||
|
||||
class GConfEntry(NamedTuple):
|
||||
name: str
|
||||
@@ -36,9 +38,10 @@ def remove_suffix(s: str, suffix: str, /) -> str:
|
||||
# TODO: make it work with shell program such as vim.
|
||||
def edit_file(file_path, prefix=CONF_DIR):
|
||||
path = prefix + file_path
|
||||
editor = get_settings().value("text_editor", "", str)
|
||||
if editor == "":
|
||||
editor = "gedit"
|
||||
editor = ""
|
||||
for editor in [get_settings().value("text_editor", "", str), *EDITORS]:
|
||||
if which(editor) is not None:
|
||||
break
|
||||
try:
|
||||
subprocess.Popen([editor, path])
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user