Skip to content

Commit

Permalink
[app] Finalize UI for release.
Browse files Browse the repository at this point in the history
  • Loading branch information
Breakthrough committed Feb 24, 2025
1 parent 885ca1b commit f969ea8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 73 deletions.
14 changes: 0 additions & 14 deletions dvr_scan/app/about_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,6 @@
# DVR-Scan is licensed under the BSD 2-Clause License; see the included
# LICENSE file, or visit one of the above pages for details.
#
"""DVR-Scan Region Editor handles detection region input and processing.
Regions are represented as a set of closed polygons defined by lists of points.
*NOTE*: The region editor is being transitioned to an offical GUI for DVR-Scan.
During this period, there may still be some keyboard/CLI interaction required to
run the program. Usability and accessibility bugs will be prioritized over feature
development.
The code in this module covers *all* the current UI logic, and consequently is not
well organized. This should be resolved as we develop the UI further and start to
better separate the CLI from the GUI. To facilitate this, a separate entry-point
for the GUI will be developed, and the region editor functionality will be deprecated.
"""

import importlib.resources as resources
import tkinter as tk
Expand Down
49 changes: 20 additions & 29 deletions dvr_scan/app/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from pathlib import Path
from tempfile import NamedTemporaryFile

from scenedetect import AVAILABLE_BACKENDS, FrameTimecode, open_video
from scenedetect import AVAILABLE_BACKENDS, FrameTimecode, VideoOpenFailure, open_video

from dvr_scan.app.about_window import AboutWindow
from dvr_scan.app.common import register_icon
Expand Down Expand Up @@ -61,25 +61,6 @@

logger = getLogger("dvr_scan")

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


# TODO: Allow this to be sorted by columns.
# TODO: Should we have a default sort method when bulk adding videos?
Expand Down Expand Up @@ -247,12 +228,16 @@ def _add_video(self, path: str = ""):
return
else:
paths = [path]
failed_to_load = False
for path in paths:
if not Path(path).exists():
logger.error(f"File does not exist: {path}")
return
# TODO: error handling
video = open_video(path, backend="opencv")
try:
video = open_video(path, backend="opencv")
except VideoOpenFailure:
failed_to_load = True
continue
duration = video.duration.get_timecode()
framerate = f"{video.frame_rate:g}"
resolution = f"{video.frame_size[0]} x {video.frame_size[1]}"
Expand All @@ -263,7 +248,11 @@ def _add_video(self, path: str = ""):
text=video.name,
values=(duration, framerate, resolution, path),
)
self._remove_button["state"] = tk.NORMAL
if failed_to_load:
tkinter.messagebox.showwarning(
"Video Open Failure", "Failed to open one or more videos."
)
self._remove_button["state"] = tk.NORMAL if self._videos.get_children() else tk.DISABLED

@property
def concatenate(self) -> bool:
Expand Down Expand Up @@ -310,9 +299,14 @@ def _on_set_time(self):
self._end_time_label.grid_remove()

def _on_use_regions(self):
state = tk.NORMAL if self._set_region.get() else tk.DISABLED
self._region_editor_button["state"] = state
# self._load_region_file["state"] = tk.DISABLED #state
if self._set_region.get():
self._region_editor_button["state"] = tk.NORMAL
self._current_region_label.grid(
row=4, column=3, sticky=EXPAND_HORIZONTAL, padx=PADDING, columnspan=2
)
else:
self._region_editor_button["state"] = tk.DISABLED
self._current_region_label.grid_remove()

def _on_edit_regions(self):
videos = self.videos
Expand Down Expand Up @@ -1189,7 +1183,6 @@ def save(self, settings: ScanSettings) -> ScanSettings:
settings.set("output-mode", self._output_mode)
if self._output_dir:
settings.set("output-dir", self._output_dir)
# TODO: Should we save all these settings instead of being dependent on output mode?
if self._output_mode == OutputMode.FFMPEG:
settings.set("ffmpeg-input-args", self._ffmpeg_input_args.get())
settings.set("ffmpeg-output-args", self._ffmpeg_output_args.get())
Expand Down Expand Up @@ -1234,7 +1227,6 @@ def __init__(self, root: tk.Tk, frame: tk.Widget):
pady=(0, PADDING),
)
self._scan_only = tk.BooleanVar(frame, value=False)
# TODO: This should be merged into output-mode to match the config file option.
self._scan_only_button = ttk.Checkbutton(
frame,
text="Scan Only",
Expand Down Expand Up @@ -1353,7 +1345,6 @@ def _create_menubar(self):
underline=0,
command=self._load_config,
)
# TODO: Add functionality to save settings to a config file.
settings_menu.add_command(label="Save...", underline=0, command=self._on_save_config)
settings_menu.add_command(
label="Save As User Default", underline=2, command=self._on_save_config_as_user_default
Expand Down
17 changes: 1 addition & 16 deletions dvr_scan/app/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,7 @@
#
# Copyright (C) 2024 Brandon Castellano <http://www.bcastell.com>.
# DVR-Scan is licensed under the BSD 2-Clause License; see the included
# LICENSE file, or visit one of the above pages for details.
#
"""DVR-Scan Region Editor handles detection region input and processing.
Regions are represented as a set of closed polygons defined by lists of points.
*NOTE*: The region editor is being transitioned to an offical GUI for DVR-Scan.
During this period, there may still be some keyboard/CLI interaction required to
run the program. Usability and accessibility bugs will be prioritized over feature
development.
The code in this module covers *all* the current UI logic, and consequently is not
well organized. This should be resolved as we develop the UI further and start to
better separate the CLI from the GUI. To facilitate this, a separate entry-point
for the GUI will be developed, and the region editor functionality will be deprecated.
"""
# LICENSE file, or visi

import importlib.resources as resources
import os
Expand Down
14 changes: 0 additions & 14 deletions dvr_scan/app/region_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,6 @@
# DVR-Scan is licensed under the BSD 2-Clause License; see the included
# LICENSE file, or visit one of the above pages for details.
#
"""DVR-Scan Region Editor handles detection region input and processing.
Regions are represented as a set of closed polygons defined by lists of points.
*NOTE*: The region editor is being transitioned to an offical GUI for DVR-Scan.
During this period, there may still be some keyboard/CLI interaction required to
run the program. Usability and accessibility bugs will be prioritized over feature
development.
The code in this module covers *all* the current UI logic, and consequently is not
well organized. This should be resolved as we develop the UI further and start to
better separate the CLI from the GUI. To facilitate this, a separate entry-point
for the GUI will be developed, and the region editor functionality will be deprecated.
"""

import math
import os
Expand Down

0 comments on commit f969ea8

Please sign in to comment.