|
1 | | -"""openadapt.app.cards module. |
| 1 | +"""openadapt.deprecated.app.cards module. |
2 | 2 |
|
3 | 3 | This module provides functions for managing UI cards in the OpenAdapt application. |
4 | 4 | """ |
|
7 | 7 | import multiprocessing |
8 | 8 | import time |
9 | 9 |
|
10 | | -from nicegui import ui |
11 | | - |
12 | | -from openadapt.app.objects.local_file_picker import LocalFilePicker |
13 | | -from openadapt.app.util import get_scrub, set_dark, set_scrub, sync_switch |
14 | 10 | from openadapt.record import record |
15 | 11 | from openadapt.utils import WrapStdout |
16 | 12 |
|
@@ -67,55 +63,6 @@ def start(self, func: callable, args: tuple, kwargs: dict) -> None: |
67 | 63 | record_proc = RecordProc() |
68 | 64 |
|
69 | 65 |
|
70 | | -def settings(dark_mode: bool) -> None: |
71 | | - """Display the settings dialog. |
72 | | -
|
73 | | - Args: |
74 | | - dark_mode (bool): Current dark mode setting. |
75 | | - """ |
76 | | - with ui.dialog() as settings, ui.card(): |
77 | | - dark_switch = ui.switch( |
78 | | - "Dark mode", on_change=lambda: set_dark(dark_mode, dark_switch.value) |
79 | | - ) |
80 | | - sync_switch(dark_switch, dark_mode) |
81 | | - |
82 | | - scrub_switch = ui.switch( |
83 | | - "Scrubbing", on_change=lambda: set_scrub(scrub_switch.value) |
84 | | - ) |
85 | | - sync_switch(scrub_switch, get_scrub()) |
86 | | - |
87 | | - ui.button("Close", on_click=lambda: settings.close()) |
88 | | - settings.open() |
89 | | - |
90 | | - |
91 | | -def select_import(f: callable) -> None: |
92 | | - """Display the import file selection dialog. |
93 | | -
|
94 | | - Args: |
95 | | - f (callable): Function to call when import button is clicked. |
96 | | - """ |
97 | | - |
98 | | - async def pick_file() -> None: |
99 | | - result = await LocalFilePicker(".") |
100 | | - ui.notify(f"Selected {result[0]}" if result else "No file selected.") |
101 | | - selected_file.text = result[0] if result else "" |
102 | | - import_button.enabled = True if result else False |
103 | | - |
104 | | - with ui.dialog() as import_dialog, ui.card(): |
105 | | - with ui.column(): |
106 | | - ui.button("Select File", on_click=pick_file).props("icon=folder") |
107 | | - selected_file = ui.label("") |
108 | | - selected_file.visible = False |
109 | | - import_button = ui.button( |
110 | | - "Import", |
111 | | - on_click=lambda: f(selected_file.text, delete.value), |
112 | | - ) |
113 | | - import_button.enabled = False |
114 | | - delete = ui.checkbox("Delete file after import") |
115 | | - |
116 | | - import_dialog.open() |
117 | | - |
118 | | - |
119 | 66 | def stop_record() -> None: |
120 | 67 | """Stop the current recording session.""" |
121 | 68 | global record_proc |
@@ -152,60 +99,3 @@ def quick_record( |
152 | 99 | "log_memory": False, |
153 | 100 | }, |
154 | 101 | ) |
155 | | - |
156 | | - |
157 | | -def recording_prompt(options: list[str], record_button: ui.button) -> None: |
158 | | - """Display the recording prompt dialog. |
159 | | -
|
160 | | - Args: |
161 | | - options (list): List of autocomplete options. |
162 | | - record_button (nicegui.widgets.Button): Record button widget. |
163 | | - """ |
164 | | - if not record_proc.is_running(): |
165 | | - with ui.dialog() as dialog, ui.card(): |
166 | | - ui.label("Enter a name for the recording: ") |
167 | | - ui.input( |
168 | | - label="Name", |
169 | | - placeholder="test", |
170 | | - autocomplete=options, |
171 | | - on_change=lambda e: result.set_text(e), |
172 | | - ) |
173 | | - result = ui.label() |
174 | | - |
175 | | - with ui.row(): |
176 | | - ui.button("Close", on_click=dialog.close) |
177 | | - ui.button("Enter", on_click=lambda: on_record()) |
178 | | - |
179 | | - dialog.open() |
180 | | - |
181 | | - def terminate() -> None: |
182 | | - global record_proc |
183 | | - record_proc.set_terminate_processing() |
184 | | - |
185 | | - # wait for process to terminate |
186 | | - record_proc.wait() |
187 | | - ui.notify("Stopped recording") |
188 | | - record_button._props["name"] = "radio_button_checked" |
189 | | - record_button.on("click", lambda: recording_prompt(options, record_button)) |
190 | | - |
191 | | - record_proc.reset() |
192 | | - |
193 | | - def begin() -> None: |
194 | | - name = result.text.__getattribute__("value") |
195 | | - |
196 | | - ui.notify( |
197 | | - f"Recording {name}... Press CTRL + C in terminal window to cancel", |
198 | | - ) |
199 | | - global record_proc |
200 | | - record_proc.start( |
201 | | - record, |
202 | | - (name, record_proc.terminate_processing, record_proc.terminate_recording), |
203 | | - ) |
204 | | - record_button._props["name"] = "stop" |
205 | | - record_button.on("click", lambda: terminate()) |
206 | | - record_button.update() |
207 | | - |
208 | | - def on_record() -> None: |
209 | | - global record_proc |
210 | | - dialog.close() |
211 | | - begin() |
0 commit comments