From 6ef5ad15f7f5be5fe1a0d5b6954d2aa1089becd9 Mon Sep 17 00:00:00 2001 From: Daniele Verducci Date: Tue, 30 Apr 2024 08:56:28 +0200 Subject: [PATCH] Sensor readings callbacks in all pages --- src/widgets/aperture_priority_page.py | 5 +++++ src/widgets/manual_exposure_page.py | 6 ++++++ src/widgets/time_priority_page.py | 7 ++++++- src/window.py | 14 +++++++++++++- src/window.ui | 8 ++++---- 5 files changed, 34 insertions(+), 6 deletions(-) diff --git a/src/widgets/aperture_priority_page.py b/src/widgets/aperture_priority_page.py index 1e2867d..843ed1b 100644 --- a/src/widgets/aperture_priority_page.py +++ b/src/widgets/aperture_priority_page.py @@ -24,3 +24,8 @@ from gi.repository import Gtk class AperturePriorityPage(Gtk.Box): __gtype_name__ = 'AperturePriorityPage' + def onValuesChanged(self, isoSpeed: int, sensorValue: float, sensorUnit: str): + # Check the unit is absolute ("lux") + if sensorUnit != "lux": + return + diff --git a/src/widgets/manual_exposure_page.py b/src/widgets/manual_exposure_page.py index 5f82220..c3cbdcd 100644 --- a/src/widgets/manual_exposure_page.py +++ b/src/widgets/manual_exposure_page.py @@ -24,3 +24,9 @@ from gi.repository import Gtk class ManualExposurePage(Gtk.Box): __gtype_name__ = 'ManualExposurePage' + + def onValuesChanged(self, isoSpeed: int, sensorValue: float, sensorUnit: str): + # Check the unit is absolute ("lux") + if sensorUnit != "lux": + return + diff --git a/src/widgets/time_priority_page.py b/src/widgets/time_priority_page.py index f6618c4..9529bc8 100644 --- a/src/widgets/time_priority_page.py +++ b/src/widgets/time_priority_page.py @@ -23,4 +23,9 @@ from gi.repository import Gtk @Gtk.Template(resource_path='/eu/ichibi/Lumos/widgets/time_priority_page.ui') class TimePriorityPage(Gtk.Box): __gtype_name__ = 'TimePriorityPage' - + + def onValuesChanged(self, isoSpeed: int, sensorValue: float, sensorUnit: str): + # Check the unit is absolute ("lux") + if sensorUnit != "lux": + return + diff --git a/src/window.py b/src/window.py index 59b632f..c147af1 100644 --- a/src/window.py +++ b/src/window.py @@ -28,7 +28,12 @@ class LumosWindow(Adw.ApplicationWindow): error_banner = Gtk.Template.Child() sensor_unit_error_banner = Gtk.Template.Child() # Pages + aperture_priority_page_widget = Gtk.Template.Child() + time_priority_page_widget = Gtk.Template.Child() + manual_page_widget = Gtk.Template.Child() sensor_readings_page_widget = Gtk.Template.Child() + # ISO selector in title bar + iso_dropdown = Gtk.Template.Child() def __init__(self, **kwargs): super().__init__(**kwargs) @@ -49,8 +54,15 @@ class LumosWindow(Adw.ApplicationWindow): def onSensorRead(self, value: float, unit: str): # Called when the light value changed: notify all pages + isoSpeed = int(self.iso_dropdown.get_selected_item().get_string()[4:]) + if self.aperture_priority_page_widget: + self.aperture_priority_page_widget.onValuesChanged(isoSpeed, value, unit) + if self.time_priority_page_widget: + self.time_priority_page_widget.onValuesChanged(isoSpeed, value, unit) + if self.manual_page_widget: + self.manual_page_widget.onValuesChanged(isoSpeed, value, unit) if self.sensor_readings_page_widget: - self.sensor_readings_page_widget.onValuesChanged(100, value, unit) + self.sensor_readings_page_widget.onValuesChanged(isoSpeed, value, unit) # Check the unit is absolute ("lux"), otherwise there's no way to convert to an absolute EV value if unit != "lux": diff --git a/src/window.ui b/src/window.ui index f5596da..9041d67 100644 --- a/src/window.ui +++ b/src/window.ui @@ -11,7 +11,7 @@ - + @@ -70,7 +70,7 @@ camera-shutter-symbolic true - + @@ -84,7 +84,7 @@ camera-timer-symbolic true - + @@ -98,7 +98,7 @@ encoder-knob-symbolic true - +