Skip to content

Conversation

@barpavel
Copy link
Contributor

  1. Added real-time date and time display to Dashboard tab
    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:
  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.

  1. Added automatic location detection for map using IP geolocation.
  • 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.
    Users in different locations will now see:
    • Their own geographic area automatically.
    • Regional language labels (e.g., English in USA, Japanese in Japan).
  • Implementation
    • Dual API support with a 3-second timeout per API for fast fallback behavior:
      • Primary: ipapi.co
      • Backup: ip-api.com
      • Fallback: New York City if both APIs fail
    • 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) .
  1. Added --camera-device parameter 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-video parameter (only one video source can be specified).
    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 module.
    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
  1. Removed dead toggle code and simplified video control flow.

  2. Improved UI/UX:

  • Update main menu tab's 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).
    • Selected tab is now disabled (not clickable) and visually distinct (use lighter, more visible text color).
    • Background is slightly greyed-out, while still visible on dark theme.
  • Start/Stop buttons in Map tab.
    • Fixed non-functional buttons, so users can manually control video playback.
    • Implemented button enable/disable logic with visual feedback (disabled buttons are greyed-out).
  1. Replace frozen frame with message on stop and add video resume support.

  2. 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 stopped: Camera Off\n\nPress Start to turn on.
  • Video paused: Video Paused\n\nPress Start to continue.
    This provides a clear visual feedback when video/camera is stopped (no confusion with frozen frame).
  1. Implemented a seamless video resume functionality (pick up where you left off, even across tabs).

  2. Handled a few race conditions:

  • Late-arriving frames were overwriting the stopped/paused message.
  • Camera Off info message overwrites camera initialization failure error message.
  1. Various refactoring & renaming for better clarity, consistency:
  • Follow PEP 8 conventions (i.e., use snake_case style).
  • Removed duplicate code to reduce repetitive code and improve code maintainability and extensibility.
  1. Updated documentation:
  • README.md with a new screenshots and command options.
  • QThread fix documentation updates - modified line numbers to match the latest code.

Co-authored-by: Cursor AI
Signed-off-by: Pavel Bar pbar@redhat.com

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>
@barpavel
Copy link
Contributor Author

barpavel commented Nov 12, 2025

@SihabSahariar Hi 😄

  1. I'm still not sure whether QThread_design folder shall be kept & maintained, IMHO better remove it.
  2. If you going to code review it, I recommend review in the order of commits, they are logically built & separated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant