mirror of https://gitlab.com/pamhyr/pamhyr2
Config, RunSolver: Add editor command and open solver logs into external editor.
parent
e32ef75be7
commit
e474d10dfb
|
|
@ -15,3 +15,6 @@ class GenericSolver(AbstractSolver):
|
|||
lst = super(GenericSolver, cls).default_parameters()
|
||||
|
||||
return lst
|
||||
|
||||
def log_file(self):
|
||||
return ""
|
||||
|
|
|
|||
|
|
@ -127,6 +127,9 @@ class ConfigureWindow(ASubWindow, ListedSubWindow):
|
|||
table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
|
||||
table.setAlternatingRowColors(True)
|
||||
|
||||
# Editor
|
||||
self.set_line_edit_text("lineEdit_editor_cmd", str(self.conf.editor))
|
||||
|
||||
# Language
|
||||
languages = Config.languages()
|
||||
for lang in languages:
|
||||
|
|
@ -190,6 +193,9 @@ class ConfigureWindow(ASubWindow, ListedSubWindow):
|
|||
# Stricklers
|
||||
self.conf.stricklers = deepcopy(self._stricklers)
|
||||
|
||||
# Editor
|
||||
self.conf.editor = self.get_line_edit_text("lineEdit_editor_cmd")
|
||||
|
||||
# Language
|
||||
self.conf.lang = Config.languages()[self.get_combobox_text("comboBox_language")]
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,10 @@ class SolverLogFileWindow(ASubMainWindow, ListedSubWindow):
|
|||
|
||||
def setup_action(self):
|
||||
self.find(QAction, "action_revert").setEnabled(True)
|
||||
self.find(QAction, "action_open_in_editor").setEnabled(True)
|
||||
if self._config.editor != "":
|
||||
self.find(QAction, "action_open_in_editor").setEnabled(True)
|
||||
else:
|
||||
self.find(QAction, "action_open_in_editor").setEnabled(False)
|
||||
|
||||
def setup_connections(self):
|
||||
self.find(QAction, "action_revert").triggered.connect(self.revert)
|
||||
|
|
@ -71,4 +74,15 @@ class SolverLogFileWindow(ASubMainWindow, ListedSubWindow):
|
|||
self.setup_text()
|
||||
|
||||
def open_on_editor(self):
|
||||
print("TODO: open in editor")
|
||||
p = QProcess(self)
|
||||
|
||||
cmd = self._config.editor
|
||||
cmd = cmd.replace("@file", self._file_name)
|
||||
|
||||
cmd = cmd.split()
|
||||
exe = cmd[0]
|
||||
args = cmd[1:]
|
||||
|
||||
p.start(
|
||||
exe, args,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -126,6 +126,7 @@ class SolverLogWindow(ASubMainWindow, ListedSubWindow):
|
|||
self.find(QAction, "action_start").setEnabled(False)
|
||||
self.find(QAction, "action_pause").setEnabled(True)
|
||||
self.find(QAction, "action_stop").setEnabled(True)
|
||||
self.find(QAction, "action_log_file").setEnabled(False)
|
||||
|
||||
def setup_alarm(self):
|
||||
self._alarm = QTimer()
|
||||
|
|
@ -159,7 +160,8 @@ class SolverLogWindow(ASubMainWindow, ListedSubWindow):
|
|||
self.find(QAction, "action_start").setEnabled(True)
|
||||
self.find(QAction, "action_pause").setEnabled(False)
|
||||
self.find(QAction, "action_stop").setEnabled(False)
|
||||
# self.find(QAction, "action_log_file").setEnabled(True)
|
||||
if self._solver.log_file() != "":
|
||||
self.find(QAction, "action_log_file").setEnabled(True)
|
||||
|
||||
while self._output.qsize() != 0:
|
||||
s = self._output.get()
|
||||
|
|
@ -191,7 +193,8 @@ class SolverLogWindow(ASubMainWindow, ListedSubWindow):
|
|||
self.find(QAction, "action_start").setEnabled(True)
|
||||
self.find(QAction, "action_pause").setEnabled(False)
|
||||
self.find(QAction, "action_stop").setEnabled(False)
|
||||
self.find(QAction, "action_log_file").setEnabled(True)
|
||||
if self._solver.log_file() != "":
|
||||
self.find(QAction, "action_log_file").setEnabled(True)
|
||||
|
||||
def log_file(self):
|
||||
file_name = os.path.join(self._workdir, self._solver.log_file())
|
||||
|
|
|
|||
|
|
@ -409,6 +409,56 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_editor">
|
||||
<attribute name="title">
|
||||
<string>Editor</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_8">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_11">
|
||||
<property name="font">
|
||||
<font>
|
||||
<italic>true</italic>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>This value must be used for reading or editing files in speficic case</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Editor command</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_editor_cmd">
|
||||
<property name="inputMask">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<spacer name="verticalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_language">
|
||||
<attribute name="title">
|
||||
<string>Language</string>
|
||||
|
|
|
|||
|
|
@ -13,6 +13,9 @@
|
|||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<property name="locale">
|
||||
<locale language="English" country="Europe"/>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ class Config(object):
|
|||
self.set_default_value()
|
||||
|
||||
def set_default_value(self):
|
||||
print('toto')
|
||||
# Solvers
|
||||
self._solvers = []
|
||||
|
||||
|
|
@ -33,6 +32,9 @@ class Config(object):
|
|||
self.backup_frequence = "00:05:00"
|
||||
self.backup_max = 10
|
||||
|
||||
# Editor
|
||||
self.editor = "emacs @file"
|
||||
|
||||
# Languages
|
||||
self.lang = ""
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue