Skip to content

Commit

Permalink
Fix re-adding the same plot line to the graph; add a TODO
Browse files Browse the repository at this point in the history
Signed-off-by: Aleksa Savic <[email protected]>
  • Loading branch information
aleksamagicka committed Nov 1, 2023
1 parent 4435642 commit dcd7c99
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ def update_sensors(self):
self.hwmon_source.update_sensors()
self.liquidctl_source.update_sensors()

# TODO: Settings: add dummy entries to plot if not change? Either: do nothing, continue same value or set 0


class App(QMainWindow):
def __init__(self):
Expand Down Expand Up @@ -97,17 +99,24 @@ def sensor_row_changed(self, item: SensorTreeItem, column):
name=f"{sensor._device.name if type(sensor._device) is HwmonSensors.HwmonDevice else sensor._device.description}/{sensor.label}",
)

sensor.is_plot_shown = True

# TODO: Based on settings
self.graphing_window.show()
else:
# Update data
sensor.plot_data_item.setData(
list(sensor._values_over_time.keys()),
list(sensor._values_over_time.values()),
)
# Is widget plotted?
if sensor.is_plot_shown:
sensor.plot_data_item.setData(
list(sensor._values_over_time.keys()),
list(sensor._values_over_time.values()),
)
else:
sensor.is_plot_shown = True
self.graphing_window.graphWidget.addItem(sensor.plot_data_item)
else:
if sensor.plot_data_item:
self.graphing_window.graphWidget.removeItem(sensor.plot_data_item)
sensor.is_plot_shown = False

def init_sensors_tab(self):
if self.hwmon is None:
Expand Down
1 change: 1 addition & 0 deletions src/sensors_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def __init__(self, label, internal_data, device):

# Plotting
self.plot_data_item = None
self.is_plot_shown = False
self._values_over_time = dict()

self._value = 0
Expand Down

0 comments on commit dcd7c99

Please sign in to comment.