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