mirror of
https://github.com/naruxde/revpicommander.git
synced 2025-11-08 16:43:53 +01:00
feat: Select start program in developer dialog
In the 'PLC developer', a Python file can now be selected as a start project on the Revolution Pi. This is transferred to the Revolution Pi via the new XML-RPC function 'set_plcprogram'. This version is available from 'revpipyload' 0.11.0.
This commit is contained in:
@@ -48,6 +48,7 @@ class WidgetData(IntEnum):
|
||||
host_name = 267
|
||||
host_name_full = 268
|
||||
file_name = 309
|
||||
is_plc_program = 310
|
||||
revpi_settings = 320
|
||||
|
||||
|
||||
|
||||
@@ -166,6 +166,20 @@ class RevPiFiles(QtWidgets.QMainWindow, Ui_win_files):
|
||||
state_local = len(self.tree_files_local.selectedItems()) > 0
|
||||
state_revpi = len(self.tree_files_revpi.selectedItems()) > 0
|
||||
|
||||
if "set_plcprogram" in helper.cm.xml_funcs:
|
||||
self.btn_mark_plcprogram.setEnabled(False)
|
||||
self.btn_mark_plcprogram.setToolTip(self.tr(
|
||||
"Set as start file"
|
||||
))
|
||||
if len(self.tree_files_revpi.selectedItems()) == 1:
|
||||
item = self.tree_files_revpi.selectedItems()[0]
|
||||
self.btn_mark_plcprogram.setEnabled(not item.data(0, WidgetData.is_plc_program))
|
||||
else:
|
||||
self.btn_mark_plcprogram.setEnabled(False)
|
||||
self.btn_mark_plcprogram.setToolTip(self.tr(
|
||||
"Upgrade your Revolution Pi! This function needs at least 'revpipyload' 0.11.0"
|
||||
))
|
||||
|
||||
self.btn_all.setEnabled(state_local)
|
||||
self.btn_to_right.setEnabled(state_local)
|
||||
|
||||
@@ -357,14 +371,14 @@ class RevPiFiles(QtWidgets.QMainWindow, Ui_win_files):
|
||||
lst_revpi = None
|
||||
else:
|
||||
lst_revpi = helper.cm.call_remote_function("get_filelist")
|
||||
# Just load settings once
|
||||
if not self.dc_settings:
|
||||
self.dc_settings = helper.cm.call_remote_function("get_config", default_value={})
|
||||
self.lbl_path_revpi.setText(
|
||||
self.dc_settings.get("plcworkdir", self.tr("Could not load path of working dir"))
|
||||
)
|
||||
self.lbl_path_revpi.setToolTip(self.lbl_path_revpi.text())
|
||||
|
||||
plc_program = self.dc_settings.get("plcprogram", "")
|
||||
|
||||
if lst_revpi is not None:
|
||||
lst_revpi.sort()
|
||||
|
||||
@@ -409,7 +423,9 @@ class RevPiFiles(QtWidgets.QMainWindow, Ui_win_files):
|
||||
item = QtWidgets.QTreeWidgetItem(NodeType.FILE)
|
||||
item.setText(0, object_name)
|
||||
item.setData(0, WidgetData.file_name, path_file)
|
||||
item.setData(0, WidgetData.is_plc_program, path_file == plc_program)
|
||||
item.setIcon(0, QtGui.QIcon(
|
||||
":/file/ico/autostart.ico" if path_file == plc_program else
|
||||
":/file/ico/file-else.ico" if object_name.find(".py") == -1 else
|
||||
":/file/ico/file-python.ico"
|
||||
))
|
||||
@@ -572,3 +588,23 @@ class RevPiFiles(QtWidgets.QMainWindow, Ui_win_files):
|
||||
)
|
||||
|
||||
self._load_files_revpi()
|
||||
|
||||
@QtCore.pyqtSlot()
|
||||
def on_btn_mark_plcprogram_clicked(self):
|
||||
"""Mark selected file as plc autostart file."""
|
||||
log.debug("RevPiFiles.on_btn_mark_plcprogram_clicked")
|
||||
|
||||
selected_item = self.tree_files_revpi.selectedItems()[0]
|
||||
|
||||
saved = helper.cm.call_remote_function("set_plcprogram", selected_item.data(0, WidgetData.file_name))
|
||||
|
||||
if saved is None:
|
||||
QtWidgets.QMessageBox.critical(
|
||||
self, self.tr("Error"), self.tr(
|
||||
"The settings could not be saved on the Revolution Pi!\n"
|
||||
"Try to save the values one mor time and check the log "
|
||||
"files of RevPiPyLoad if the error rises again."
|
||||
)
|
||||
)
|
||||
|
||||
self._load_files_revpi(True)
|
||||
|
||||
@@ -136,6 +136,15 @@ class Ui_win_files(object):
|
||||
self.hl_revpi.addWidget(self.btn_delete_revpi)
|
||||
spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
|
||||
self.hl_revpi.addItem(spacerItem1)
|
||||
self.btn_mark_plcprogram = QtWidgets.QPushButton(self.gridLayoutWidget_2)
|
||||
self.btn_mark_plcprogram.setText("")
|
||||
icon5 = QtGui.QIcon()
|
||||
icon5.addPixmap(QtGui.QPixmap(":/file/ico/autostart.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||
self.btn_mark_plcprogram.setIcon(icon5)
|
||||
self.btn_mark_plcprogram.setIconSize(QtCore.QSize(24, 24))
|
||||
self.btn_mark_plcprogram.setAutoDefault(False)
|
||||
self.btn_mark_plcprogram.setObjectName("btn_mark_plcprogram")
|
||||
self.hl_revpi.addWidget(self.btn_mark_plcprogram)
|
||||
self.vl_revpi.addLayout(self.hl_revpi)
|
||||
self.tree_files_revpi = QtWidgets.QTreeWidget(self.gridLayoutWidget_2)
|
||||
self.tree_files_revpi.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -269,6 +269,26 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_mark_plcprogram">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="ressources.qrc">
|
||||
<normaloff>:/file/ico/autostart.ico</normaloff>:/file/ico/autostart.ico</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
||||
BIN
ui_dev/ico/autostart.ico
Normal file
BIN
ui_dev/ico/autostart.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
@@ -5,6 +5,7 @@
|
||||
<file>ico/revpipycontrol.ico</file>
|
||||
</qresource>
|
||||
<qresource prefix="file">
|
||||
<file>ico/autostart.ico</file>
|
||||
<file>ico/file-else.ico</file>
|
||||
<file>ico/file-python.ico</file>
|
||||
</qresource>
|
||||
|
||||
Reference in New Issue
Block a user