ui: fixed monitoring processes details

- ui: fixed error getting the icon of an app.
- ui: fixed getting the list of pids of an app.
- ui: improved proc details start/stop icon behaviour.
- daemon: improved error message when we fail getting the details of a
  process.

others:
 - changed icon search by system-search.
This commit is contained in:
Gustavo Iñiguez Goia 2021-03-29 01:36:41 +02:00
parent 8af290e970
commit 879d18f15a
4 changed files with 21 additions and 13 deletions

View file

@ -165,7 +165,7 @@ func (c *Client) handleActionDeleteRule(stream protocol.UI_NotificationsClient,
func (c *Client) handleActionMonitorProcess(stream protocol.UI_NotificationsClient, notification *protocol.Notification) {
pid, err := strconv.Atoi(notification.Data)
if err != nil {
log.Error("parsing PID to monitor")
log.Error("parsing PID to monitor: %d, err: %s", pid, err)
return
}
if !core.Exists(fmt.Sprint("/proc/", pid)) {
@ -178,7 +178,7 @@ func (c *Client) handleActionMonitorProcess(stream protocol.UI_NotificationsClie
func (c *Client) handleActionStopMonitorProcess(stream protocol.UI_NotificationsClient, notification *protocol.Notification) {
pid, err := strconv.Atoi(notification.Data)
if err != nil {
log.Error("parsing PID to stop monitor")
log.Error("parsing PID to stop monitor: %d, err: %s", pid, err)
c.sendNotificationReply(stream, notification.Id, "", fmt.Errorf("Error stopping monitor: %s", notification.Data))
return
}

View file

@ -94,8 +94,8 @@ class ProcessDetailsDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0])
if reply.code == ui_pb2.ERROR:
self._show_message(QtCore.QCoreApplication.translate("proc_details", "<b>Error loading process information:</b> <br><br>\n\n") + reply.data)
self.cmdAction.setChecked(False)
self._pid = ""
self._set_button_running(False)
# if we haven't loaded any data yet, just close the window
if self._data_loaded == False:
@ -113,6 +113,7 @@ class ProcessDetailsDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0])
elif noti.type == ui_pb2.STOP_MONITOR_PROCESS:
if reply.data != "":
self.show_message(QtCore.QCoreApplication.translate("proc_details", "<b>Error stopping monitoring process:</b><br><br>") + reply.data)
self._set_button_running(False)
self._delete_notification(reply.id)
else:
@ -136,9 +137,7 @@ class ProcessDetailsDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0])
def _cb_action_clicked(self):
if not self.cmdAction.isChecked():
self._stop_monitoring()
self.cmdAction.setIcon(self.iconStart)
else:
self.cmdAction.setIcon(self.iconPause)
self._start_monitoring()
def _show_message(self, text):
@ -160,6 +159,14 @@ class ProcessDetailsDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0])
for tidx in range(0, len(self.TABS)):
self.TABS[tidx]['text'].setPlainText("")
def _set_button_running(self, yes):
if yes:
self.cmdAction.setChecked(True)
self.cmdAction.setIcon(self.iconPause)
else:
self.cmdAction.setChecked(False)
self.cmdAction.setIcon(self.iconStart)
def _close(self):
self._stop_monitoring()
self.comboPids.clear()
@ -194,8 +201,7 @@ class ProcessDetailsDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0])
if self._pid == "":
return
self.cmdAction.setIcon(self.iconPause)
self.cmdAction.setChecked(True)
self._set_button_running(True)
noti = ui_pb2.Notification(clientName="", serverName="", type=ui_pb2.MONITOR_PROCESS, data=self._pid, rules=[])
self._nid = self._nodes.send_notification(self._pids[self._pid], noti, self._notification_callback)
self._notifications_sent[self._nid] = noti
@ -206,8 +212,7 @@ class ProcessDetailsDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0])
if self._pid == "":
return
self.cmdAction.setIcon(self.iconStart)
self.cmdAction.setChecked(False)
self._set_button_running(False)
noti = ui_pb2.Notification(clientName="", serverName="", type=ui_pb2.STOP_MONITOR_PROCESS, data=str(self._pid), rules=[])
self._nid = self._nodes.send_notification(self._pids[self._pid], noti, self._notification_callback)
self._notifications_sent[self._nid] = noti
@ -261,7 +266,7 @@ class ProcessDetailsDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0])
if self._app_icon != None:
return
self._app_name, self._app_icon, _ = self._apps_parser.get_info_by_path(proc_path, "terminal")
self._app_name, self._app_icon, _, _ = self._apps_parser.get_info_by_path(proc_path, "terminal")
icon = QtGui.QIcon().fromTheme(self._app_icon)
pixmap = icon.pixmap(icon.actualSize(QtCore.QSize(48, 48)))

View file

@ -52,6 +52,9 @@ class StatsDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
COL_R_OP_TYPE = 6
COL_R_OP_OPERAND = 7
# procs
COL_PID = 9
TAB_MAIN = 0
TAB_NODES = 1
TAB_RULES = 2
@ -565,8 +568,8 @@ class StatsDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
nrows = table.model().rowCount()
pids = {}
for row in range(0, nrows):
pid = table.model().index(row, 6).data()
node = table.model().index(row, 1).data()
pid = table.model().index(row, self.COL_PID).data()
node = table.model().index(row, self.COL_NODE).data()
if pid not in pids:
pids[pid] = node

View file

@ -526,7 +526,7 @@ gnu.org - it'll only match gnu.org, nor www.gnu.org, nor ftp.gnu.org, ..
<string/>
</property>
<property name="icon">
<iconset theme="search"/>
<iconset theme="system-search"/>
</property>
</widget>
</item>