-
Notifications
You must be signed in to change notification settings - Fork 18
Multiple fixes, new features & improvements #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
barpavel
wants to merge
10
commits into
SihabSahariar:main
Choose a base branch
from
barpavel:start-stop-buttons
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Remove dead toggle code and simplify video control flow:
- "controlTimer()" method had toggle logic
(if video running, stop; else start).
- Analysis revealed the "if" branch was unreachable dead code:
- "controlTimer()" was only called from "show_Map()".
- Video is always OFF when entering the "Map" tab
(other tabs stop it).
- Therefore, it always took the "else" branch.
- Removed the dead code under the "if" branch.
2. Video control logic refactoring for better clarity and consistency:
- After removing the dead toggle code, the "controlTimer()"
method was renamed to "start_video()".
- "quit_video()" was renamed to "stop_video()".
Co-authored-by: Cursor AI
Signed-off-by: Pavel Bar <pbar@redhat.com>
Video control logic refactoring for better clarity and consistency:
1. Rename generic button names to descriptive, self-documenting names.
Consistent naming convention with other buttons ("btn_dash", "btn_ac", etc.):
- "pushButton_5" to "btn_start"
- "pushButton_6" to "btn_stop"
2. Reorder "start_video()" & "stop_video()".
Signed-off-by: Pavel Bar <pbar@redhat.com>
1. Fix non-functional Start/Stop buttons in "Map" tab, so users
can manually control video playback:
- Root cause: "btn_start" and "btn_stop" were created,
but never connected to any click handlers.
- Solution: connected "Start" button to "start_video()"
and "Stop" button to "stop_video()".
2. Add visual state management for Start/Stop buttons in "Map" tab.
Implemented button enable/disable logic with visual feedback to improve UX.
- Button state management.
Prevents user confusion and accidental redundant clicks (can't start
when running, can't stop when stopped) by providing a clear visual
indication of current video state without hovering.
- "start_video()": disable Start button, enable Stop button.
- "stop_video()": enable Start button, disable Stop button.
- Handled camera initialization / video file loading failure corner case,
including a detailed comment explaining why button updates must happen
regardless of thread state.
- Disabled button styling.
Added "QPushButton:disabled" CSS state to "frame_map"
stylesheet maintaining the existing color theme (visible against
dark UI background while clearly distinguishable from enabled state).
- Background: "rgba(0,100,98,50)" - dimmed teal.
- Text: "rgba(200,220,240,180)" - lighter, more visible text color.
Co-authored-by: Cursor AI
Signed-off-by: Pavel Bar <pbar@redhat.com>
…support
When stopping camera or video, the last displayed frame stays frozen.
Replace it with an informative message indicating the paused state.
This provides a clear visual feedback when video/camera is stopped
(no confusion with frozen frame).
Additionally implemented a seamless video resume experience
(pick up where you left off, even across tabs).
1. Add pause/stop message display:
- Created "_display_message()" internal helper for
unified message rendering. Its logic mostly comes from
an existing "display_error_message()" which was
extracted & parameterized (in accordance with DRY principle).
- Refactored "display_error_message()" to use the new
helper (red border).
- Implemented "display_info_message()" using the same helper to
show teal-bordered messages for pause states. This is consistent
with UI theme (teal border matching button colors).
- Messages:
- Camera stopped: "Camera Off\n\nPress Start to turn on".
- Video paused: "Video Paused\n\nPress Start to continue".
2. Implement video resume functionality:
- Camera always starts fresh (no position concept for live streams).
- Video resumes from exact frame where it was paused in both scenarios:
- Clicking Stop then Start (while staying on "Map" tab).
- Leaving "Map" tab and returning to it (position preserved across tabs).
3. Handle a few race conditions:
- "stop_video()" method needs to disconnect "frame_captured" and
"error_occurred" signals before stopping the video thread in order to:
- Prevent late-arriving frames from overwriting the stopped/paused message.
- Ensure that the stopped/paused message is always displayed correctly.
- Reorder "on_video_error()" to call "stop_video()" before calling
"display_error_message()" in order to to prevent race condition where
"Camera Off" info message overwrites camera initialization failure error message.
Co-authored-by: Cursor AI
Signed-off-by: Pavel Bar <pbar@redhat.com>
Previously, the date/time label in the Dashboard tab showed a static placeholder text "Date - Time-" instead of actual date and time values. Changes made: 1. Created "update_datetime()" method that formats and updates the display using "datetime" module. 2. Initialized "QTimer" in "setupUi()" to call the "update_datetime()" every second (periodic updates) and set an initial date/time value on application startup. The display now shows: Line 1: November 10, 2025 Line 2: 14:35:42 The date/time updates automatically every second. The two-line format ensures both date and time are fully visible within the UI constraints. Co-authored-by: Cursor AI Signed-off-by: Pavel Bar <pbar@redhat.com>
1. Improve naming consistency and follow PEP 8 conventions
(use snake_case style):
- "btn_dash" to "btn_dashboard"
- "frame_AC" to "frame_ac"
- "show_AC()" method to "show_ac()" method
- "show_Music()" method to "show_music()" method
- "show_Map()" method to "show_map()" method
2. Refactor repetitive show_*() methods into a single "_switch_tab()"
helper method in order to reduce repetitive code and improve
code maintainability and extensibility.
- Simplify video control logic based on "enable_video" parameter.
- Centralizes all tab switching logic in one place, thus:
- Adding new tabs requires minimal changes.
- Future enhancements (enable/disable state, animations, logging, etc.)
can be added once in "_switch_tab()" vs. modifying 4+ methods.
Co-authored-by: Cursor AI
Signed-off-by: Pavel Bar <pbar@redhat.com>
Update tab switching logic to automatically disable active tab button in order to provide clear visual feedback of current location for main navigation tabs (Dashboard, AC, Music, Map): 1. Selected tab is now disabled (not clickable) and visually distinct (use lighter, more visible text color "rgba(200,220,240,180)") 2. Background is slightly greyed-out, while still visible on dark theme. Co-authored-by: Cursor AI Signed-off-by: Pavel Bar <pbar@redhat.com>
Old behavior: Previously, the map was hardcoded to Rajshahi Division, Bangladesh (24.41°N, 88.97°E), causing all users to see the same location with Bengali (বাংলা) labels regardless of where they were located. New behavior: Now the map automatically detects the user's location via IP address and centers on it at startup. Users will see their own city/region with appropriate regional language labels from "OpenStreetMap". Users in different locations will now see: - Their own geographic area automatically. - Regional language labels (e.g., English in USA, Japanese in Japan). Implementation: - Added "get_current_location()" function with dual API support (3-second timeout per API for fast fallback behavior). - Primary: ipapi.co - Backup: ip-api.com - Fallback: New York City if both APIs fail - Updated "requirements.txt" to install "requests" library. - Map now uses detected coordinates instead of static Bangladesh location. - Improved error handling with detailed console logging. - HTTP errors (if geolocation fails) display user-friendly messages (e.g., "429 (Too Many Requests)" instead of just "429") using Python's built-in "http.client.responses". Updated "README.md" with a new screenshots. Co-authored-by: Cursor AI Signed-off-by: Pavel Bar <pbar@redhat.com>
…eo source selection Added an optional command-line parameter "--camera-device" (integer with default value of 0) to allow users to specify which camera device index to use (default: 0). This parameter is mutually exclusive with the existing "--play-video" parameter (only one video source can be specified), enforced using mutually exclusive group feature of "argparse" module. Backward compatibility: - No parameters provided → uses camera device 0 (existing behavior preserved) - Single "--camera-device <idx>" → uses specified camera device index - Single "--play-video <path>" → uses video file (existing behavior preserved) - Both parameters → error with clear message from "argparse" Usage examples (valid): ------------------------------------------------------------------- $ python app.py # camera device 0 (default) $ python app.py --camera-device 1 # camera device 1 $ python app.py --play-video video.mp4 # video file playback ------------------------------------------------------------------- Usage examples (invalid): ------------------------------------------------------------------------------- $ python app.py --camera-device 0 --play-video file.mp4 usage: app.py [-h] [--camera-device idx | --play-video path] app.py: error: argument --play-video: not allowed with argument --camera-device ------------------------------------------------------------------------------- Co-authored-by: Cursor AI Signed-off-by: Pavel Bar <pbar@redhat.com>
Also update line numbers to match the latest code. Co-authored-by: Cursor AI Signed-off-by: Pavel Bar <pbar@redhat.com>
Contributor
Author
|
@SihabSahariar Hi 😄
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously, the date/time label in the Dashboard tab showed a static placeholder text
Date - Time-instead of actual date and time values.The display now shows:
The date/time updates automatically every second. The two-line format ensures both date and time are fully visible within the UI constraints.
Previously, the map was hardcoded to Rajshahi Division, Bangladesh (24.41°N, 88.97°E), causing all users to see the same location with Bengali (বাংলা) labels regardless of where they were located.
Now the map automatically detects the user's location via IP address and centers on it at startup.
Users will see their own city/region with appropriate regional language labels.
Users in different locations will now see:
ipapi.coip-api.comNew York Cityif both APIs fail429 (Too Many Requests)instead of just429) .--camera-deviceparameter for video source selection.A new optional command-line parameter
--camera-device(integer with default value of 0) to allow users to specify which camera device index to use (default:0).This parameter is mutually exclusive with the existing
--play-videoparameter (only one video source can be specified).Backward compatibility:
--camera-device <idx>→ uses specified camera device index.--play-video <path>→ uses video file (existing behavior preserved).argparsemodule.Usage examples (valid):
Usage examples (invalid):
Removed dead toggle code and simplified video control flow.
Improved UI/UX:
Dashboard,AC,Music,Map).Maptab.Replace frozen frame with message on stop and add video resume support.
Handled camera initialization / video file loading failure corner cases.
When stopping camera or video, the last displayed frame stays frozen.
Replaced it with an informative messages indicating the paused state.
Camera Off\n\nPress Start to turn on.Video Paused\n\nPress Start to continue.This provides a clear visual feedback when video/camera is stopped (no confusion with frozen frame).
Implemented a seamless video resume functionality (pick up where you left off, even across tabs).
Handled a few race conditions:
Camera Offinfo message overwrites camera initialization failure error message.PEP 8conventions (i.e., use snake_case style).README.mdwith a new screenshots and command options.QThreadfix documentation updates - modified line numbers to match the latest code.Co-authored-by: Cursor AI
Signed-off-by: Pavel Bar pbar@redhat.com