203 Zeilen
7.4 KiB
Python
203 Zeilen
7.4 KiB
Python
"""
|
|
UI Helpers Handler
|
|
Handles UI creation, updates, and helper functions
|
|
"""
|
|
|
|
from typing import TYPE_CHECKING
|
|
from utils.logger import logger
|
|
|
|
if TYPE_CHECKING:
|
|
from gui.main_window import MainWindow
|
|
from project_manager import Project
|
|
|
|
|
|
class UIHelpersHandler:
|
|
"""Handles UI helper operations for MainWindow"""
|
|
|
|
def __init__(self, main_window: 'MainWindow'):
|
|
"""Initialize with reference to main window"""
|
|
self.main_window = main_window
|
|
self.root = main_window.root
|
|
logger.info("UIHelpersHandler initialized")
|
|
|
|
def setup_ui(self) -> None:
|
|
"""Setup the main UI"""
|
|
return self.main_window._original_setup_ui()
|
|
|
|
def create_header(self) -> None:
|
|
"""Create header section"""
|
|
# Direct implementation with proper references
|
|
import customtkinter as ctk
|
|
from gui.styles import COLORS, FONTS
|
|
|
|
header_frame = ctk.CTkFrame(self.main_window.main_container, fg_color=COLORS['bg_secondary'], height=80)
|
|
header_frame.pack(fill="x", padx=0, pady=0)
|
|
header_frame.pack_propagate(False)
|
|
|
|
# Title
|
|
self.main_window.title_label = ctk.CTkLabel(
|
|
header_frame,
|
|
text="IntelSight - Claude Project Manager",
|
|
font=FONTS['heading'],
|
|
text_color=COLORS['text_primary']
|
|
)
|
|
self.main_window.title_label.pack(side="left", padx=30, pady=20)
|
|
|
|
# Toolbar buttons
|
|
toolbar = ctk.CTkFrame(header_frame, fg_color="transparent")
|
|
toolbar.pack(side="right", padx=30, pady=20)
|
|
|
|
# Log download button
|
|
self.main_window.log_btn = ctk.CTkButton(
|
|
toolbar,
|
|
text="📥 Log",
|
|
command=self.main_window.download_log,
|
|
width=80,
|
|
fg_color=COLORS['accent_primary'],
|
|
hover_color=COLORS['accent_hover'],
|
|
text_color="#FFFFFF",
|
|
font=('Segoe UI', 12)
|
|
)
|
|
self.main_window.log_btn.pack(side="left", padx=(0, 10))
|
|
|
|
# Refresh button
|
|
self.main_window.refresh_btn = ctk.CTkButton(
|
|
toolbar,
|
|
text="↻ Refresh",
|
|
command=self.main_window.refresh_projects,
|
|
width=100,
|
|
fg_color=COLORS['bg_tile'],
|
|
hover_color=COLORS['bg_tile_hover'],
|
|
text_color=COLORS['text_primary']
|
|
)
|
|
self.main_window.refresh_btn.pack(side="left", padx=(0, 10))
|
|
logger.debug("Header created")
|
|
|
|
def create_content_area(self) -> None:
|
|
"""Create content area"""
|
|
return self.main_window._original_create_content_area()
|
|
|
|
def create_status_bar(self) -> None:
|
|
"""Create status bar"""
|
|
# Direct implementation
|
|
import customtkinter as ctk
|
|
from gui.styles import COLORS, FONTS
|
|
|
|
self.main_window.status_bar = ctk.CTkFrame(
|
|
self.main_window.main_container,
|
|
fg_color=COLORS['bg_secondary'],
|
|
height=30
|
|
)
|
|
self.main_window.status_bar.pack(fill="x", side="bottom")
|
|
self.main_window.status_bar.pack_propagate(False)
|
|
|
|
self.main_window.status_label = ctk.CTkLabel(
|
|
self.main_window.status_bar,
|
|
text="Ready",
|
|
font=FONTS['small'],
|
|
text_color=COLORS['text_secondary']
|
|
)
|
|
self.main_window.status_label.pack(side="left", padx=20, pady=5)
|
|
|
|
# Project count
|
|
self.main_window.count_label = ctk.CTkLabel(
|
|
self.main_window.status_bar,
|
|
text="0 projects",
|
|
font=FONTS['small'],
|
|
text_color=COLORS['text_secondary']
|
|
)
|
|
self.main_window.count_label.pack(side="right", padx=20, pady=5)
|
|
logger.debug("Status bar created")
|
|
|
|
def create_project_tile(self, project: 'Project', parent) -> 'ProjectTile':
|
|
"""Create a project tile"""
|
|
return self.main_window._original_create_project_tile(project, parent)
|
|
|
|
def create_add_tile(self, parent) -> 'AddProjectTile':
|
|
"""Create add project tile"""
|
|
return self.main_window._original_create_add_tile(parent)
|
|
|
|
def create_project_tile_flow(self, project: 'Project', parent) -> 'ProjectTile':
|
|
"""Create project tile for flow layout"""
|
|
return self.main_window._original_create_project_tile_flow(project, parent)
|
|
|
|
def create_add_tile_flow(self, parent) -> 'AddProjectTile':
|
|
"""Create add tile for flow layout"""
|
|
return self.main_window._original_create_add_tile_flow(parent)
|
|
|
|
def refresh_ui(self) -> None:
|
|
"""Refresh the UI"""
|
|
return self.main_window._original_refresh_ui()
|
|
|
|
def load_and_apply_theme(self) -> None:
|
|
"""Load and apply theme preference"""
|
|
# Direct implementation - very simple method
|
|
import customtkinter as ctk
|
|
ctk.set_appearance_mode('dark')
|
|
logger.info("Theme applied: dark mode")
|
|
|
|
def on_window_resize(self, event) -> None:
|
|
"""Handle window resize event"""
|
|
# Direct implementation
|
|
# Only process resize events from the main window
|
|
if event.widget == self.root:
|
|
# Cancel previous timer
|
|
if self.main_window.resize_timer:
|
|
self.root.after_cancel(self.main_window.resize_timer)
|
|
|
|
# Set new timer to refresh after resize stops with differential update
|
|
self.main_window.resize_timer = self.root.after(
|
|
300,
|
|
lambda: self.main_window.refresh_projects(differential=True)
|
|
)
|
|
logger.debug("Window resize event handled")
|
|
|
|
def setup_interaction_tracking(self) -> None:
|
|
"""Setup interaction tracking"""
|
|
return self.main_window._original_setup_interaction_tracking()
|
|
|
|
def _show_scrollable_info(self, title: str, content: str) -> None:
|
|
"""Show scrollable information dialog"""
|
|
# Direct implementation - standalone UI method
|
|
import customtkinter as ctk
|
|
|
|
dialog = ctk.CTkToplevel(self.root)
|
|
dialog.title(title)
|
|
dialog.geometry("600x500")
|
|
|
|
# Center the dialog
|
|
dialog.transient(self.root)
|
|
dialog.update_idletasks()
|
|
x = (dialog.winfo_screenwidth() - 600) // 2
|
|
y = (dialog.winfo_screenheight() - 500) // 2
|
|
dialog.geometry(f"600x500+{x}+{y}")
|
|
|
|
# Text widget with scrollbar
|
|
text_frame = ctk.CTkFrame(dialog)
|
|
text_frame.pack(fill="both", expand=True, padx=10, pady=10)
|
|
|
|
text_widget = ctk.CTkTextbox(text_frame, width=580, height=450)
|
|
text_widget.pack(fill="both", expand=True)
|
|
text_widget.insert("1.0", content)
|
|
text_widget.configure(state="disabled")
|
|
|
|
# Close button
|
|
close_btn = ctk.CTkButton(
|
|
dialog,
|
|
text="Schließen",
|
|
command=dialog.destroy,
|
|
width=100
|
|
)
|
|
close_btn.pack(pady=(0, 10))
|
|
|
|
dialog.grab_set()
|
|
dialog.focus_set()
|
|
logger.debug(f"Scrollable dialog shown: {title}")
|
|
|
|
def _differential_update(self, current_projects: list, previous_projects: list) -> None:
|
|
"""Perform differential update of projects"""
|
|
return self.main_window._original_differential_update(current_projects, previous_projects)
|
|
|
|
def _update_project_tiles_colors(self) -> None:
|
|
"""Update project tile colors"""
|
|
return self.main_window._original_update_project_tiles_colors() |