Skip to content

Commit f969ea8

Browse files
committed
[app] Finalize UI for release.
1 parent 885ca1b commit f969ea8

File tree

4 files changed

+21
-73
lines changed

4 files changed

+21
-73
lines changed

dvr_scan/app/about_window.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,6 @@
88
# DVR-Scan is licensed under the BSD 2-Clause License; see the included
99
# LICENSE file, or visit one of the above pages for details.
1010
#
11-
"""DVR-Scan Region Editor handles detection region input and processing.
12-
13-
Regions are represented as a set of closed polygons defined by lists of points.
14-
15-
*NOTE*: The region editor is being transitioned to an offical GUI for DVR-Scan.
16-
During this period, there may still be some keyboard/CLI interaction required to
17-
run the program. Usability and accessibility bugs will be prioritized over feature
18-
development.
19-
20-
The code in this module covers *all* the current UI logic, and consequently is not
21-
well organized. This should be resolved as we develop the UI further and start to
22-
better separate the CLI from the GUI. To facilitate this, a separate entry-point
23-
for the GUI will be developed, and the region editor functionality will be deprecated.
24-
"""
2511

2612
import importlib.resources as resources
2713
import tkinter as tk

dvr_scan/app/application.py

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from pathlib import Path
2121
from tempfile import NamedTemporaryFile
2222

23-
from scenedetect import AVAILABLE_BACKENDS, FrameTimecode, open_video
23+
from scenedetect import AVAILABLE_BACKENDS, FrameTimecode, VideoOpenFailure, open_video
2424

2525
from dvr_scan.app.about_window import AboutWindow
2626
from dvr_scan.app.common import register_icon
@@ -61,25 +61,6 @@
6161

6262
logger = getLogger("dvr_scan")
6363

64-
#
65-
# TODO: This is ALL the controls that should be included in the initial release.
66-
# Any additions or modifications can come in the future. Even overlay settings should
67-
# be ignored for now and added later.
68-
#
69-
# Things that need unblocking for a beta release:
70-
#
71-
# 1. Map all existing UI controls to the DVR-Scan config types (in progress)
72-
# 2. Figure out how to run the scan in the background and report the process
73-
# and status back. (done)
74-
# 3. Handle the video input widget. (requires background task model already)
75-
# A lot of headaches can be solved if we take some time to validate the video,
76-
# and maybe generate some thumbnails or check other metadata, which could take
77-
# a few seconds when adding lots of videos. We can't block the UI for this long
78-
# so we already need to have a task model in place before this. (todo)
79-
#
80-
# At that point DVR-Scan should be ready for a beta release.
81-
#
82-
8364

8465
# TODO: Allow this to be sorted by columns.
8566
# TODO: Should we have a default sort method when bulk adding videos?
@@ -247,12 +228,16 @@ def _add_video(self, path: str = ""):
247228
return
248229
else:
249230
paths = [path]
231+
failed_to_load = False
250232
for path in paths:
251233
if not Path(path).exists():
252234
logger.error(f"File does not exist: {path}")
253235
return
254-
# TODO: error handling
255-
video = open_video(path, backend="opencv")
236+
try:
237+
video = open_video(path, backend="opencv")
238+
except VideoOpenFailure:
239+
failed_to_load = True
240+
continue
256241
duration = video.duration.get_timecode()
257242
framerate = f"{video.frame_rate:g}"
258243
resolution = f"{video.frame_size[0]} x {video.frame_size[1]}"
@@ -263,7 +248,11 @@ def _add_video(self, path: str = ""):
263248
text=video.name,
264249
values=(duration, framerate, resolution, path),
265250
)
266-
self._remove_button["state"] = tk.NORMAL
251+
if failed_to_load:
252+
tkinter.messagebox.showwarning(
253+
"Video Open Failure", "Failed to open one or more videos."
254+
)
255+
self._remove_button["state"] = tk.NORMAL if self._videos.get_children() else tk.DISABLED
267256

268257
@property
269258
def concatenate(self) -> bool:
@@ -310,9 +299,14 @@ def _on_set_time(self):
310299
self._end_time_label.grid_remove()
311300

312301
def _on_use_regions(self):
313-
state = tk.NORMAL if self._set_region.get() else tk.DISABLED
314-
self._region_editor_button["state"] = state
315-
# self._load_region_file["state"] = tk.DISABLED #state
302+
if self._set_region.get():
303+
self._region_editor_button["state"] = tk.NORMAL
304+
self._current_region_label.grid(
305+
row=4, column=3, sticky=EXPAND_HORIZONTAL, padx=PADDING, columnspan=2
306+
)
307+
else:
308+
self._region_editor_button["state"] = tk.DISABLED
309+
self._current_region_label.grid_remove()
316310

317311
def _on_edit_regions(self):
318312
videos = self.videos
@@ -1189,7 +1183,6 @@ def save(self, settings: ScanSettings) -> ScanSettings:
11891183
settings.set("output-mode", self._output_mode)
11901184
if self._output_dir:
11911185
settings.set("output-dir", self._output_dir)
1192-
# TODO: Should we save all these settings instead of being dependent on output mode?
11931186
if self._output_mode == OutputMode.FFMPEG:
11941187
settings.set("ffmpeg-input-args", self._ffmpeg_input_args.get())
11951188
settings.set("ffmpeg-output-args", self._ffmpeg_output_args.get())
@@ -1234,7 +1227,6 @@ def __init__(self, root: tk.Tk, frame: tk.Widget):
12341227
pady=(0, PADDING),
12351228
)
12361229
self._scan_only = tk.BooleanVar(frame, value=False)
1237-
# TODO: This should be merged into output-mode to match the config file option.
12381230
self._scan_only_button = ttk.Checkbutton(
12391231
frame,
12401232
text="Scan Only",
@@ -1353,7 +1345,6 @@ def _create_menubar(self):
13531345
underline=0,
13541346
command=self._load_config,
13551347
)
1356-
# TODO: Add functionality to save settings to a config file.
13571348
settings_menu.add_command(label="Save...", underline=0, command=self._on_save_config)
13581349
settings_menu.add_command(
13591350
label="Save As User Default", underline=2, command=self._on_save_config_as_user_default

dvr_scan/app/common.py

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,7 @@
66
#
77
# Copyright (C) 2024 Brandon Castellano <http://www.bcastell.com>.
88
# DVR-Scan is licensed under the BSD 2-Clause License; see the included
9-
# LICENSE file, or visit one of the above pages for details.
10-
#
11-
"""DVR-Scan Region Editor handles detection region input and processing.
12-
13-
Regions are represented as a set of closed polygons defined by lists of points.
14-
15-
*NOTE*: The region editor is being transitioned to an offical GUI for DVR-Scan.
16-
During this period, there may still be some keyboard/CLI interaction required to
17-
run the program. Usability and accessibility bugs will be prioritized over feature
18-
development.
19-
20-
The code in this module covers *all* the current UI logic, and consequently is not
21-
well organized. This should be resolved as we develop the UI further and start to
22-
better separate the CLI from the GUI. To facilitate this, a separate entry-point
23-
for the GUI will be developed, and the region editor functionality will be deprecated.
24-
"""
9+
# LICENSE file, or visi
2510

2611
import importlib.resources as resources
2712
import os

dvr_scan/app/region_editor.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,6 @@
88
# DVR-Scan is licensed under the BSD 2-Clause License; see the included
99
# LICENSE file, or visit one of the above pages for details.
1010
#
11-
"""DVR-Scan Region Editor handles detection region input and processing.
12-
13-
Regions are represented as a set of closed polygons defined by lists of points.
14-
15-
*NOTE*: The region editor is being transitioned to an offical GUI for DVR-Scan.
16-
During this period, there may still be some keyboard/CLI interaction required to
17-
run the program. Usability and accessibility bugs will be prioritized over feature
18-
development.
19-
20-
The code in this module covers *all* the current UI logic, and consequently is not
21-
well organized. This should be resolved as we develop the UI further and start to
22-
better separate the CLI from the GUI. To facilitate this, a separate entry-point
23-
for the GUI will be developed, and the region editor functionality will be deprecated.
24-
"""
2511

2612
import math
2713
import os

0 commit comments

Comments
 (0)