Initial commit
This commit is contained in:
285
geniusia2/gui/dialogs/README.md
Normal file
285
geniusia2/gui/dialogs/README.md
Normal file
@@ -0,0 +1,285 @@
|
||||
# Dialogues et Notifications GUI
|
||||
|
||||
Ce module contient les dialogues de correction et les systèmes de notification pour RPA Vision V2.
|
||||
|
||||
## Composants
|
||||
|
||||
### 1. CorrectionDialog
|
||||
|
||||
Dialogue permettant à l'utilisateur de corriger une détection incorrecte en sélectionnant l'élément UI correct.
|
||||
|
||||
**Fonctionnalités:**
|
||||
- Affichage de la détection incorrecte
|
||||
- Liste de détections alternatives sélectionnables
|
||||
- Saisie manuelle de correction
|
||||
- Double-clic pour sélection rapide
|
||||
|
||||
**Utilisation:**
|
||||
```python
|
||||
from geniusia2.gui.dialogs import CorrectionDialog
|
||||
|
||||
# Détection incorrecte
|
||||
incorrect = {
|
||||
"label": "annuler_button",
|
||||
"confidence": 0.75,
|
||||
"bbox": (300, 400, 100, 35),
|
||||
"action_type": "click"
|
||||
}
|
||||
|
||||
# Alternatives disponibles
|
||||
alternatives = [
|
||||
{
|
||||
"label": "valider_button",
|
||||
"confidence": 0.92,
|
||||
"bbox": (450, 400, 100, 35),
|
||||
"action_type": "click"
|
||||
},
|
||||
# ... autres alternatives
|
||||
]
|
||||
|
||||
# Afficher le dialogue
|
||||
correction = CorrectionDialog.show_correction_dialog(
|
||||
incorrect,
|
||||
alternatives
|
||||
)
|
||||
|
||||
if correction:
|
||||
corrected_element = correction['corrected_element']
|
||||
method = correction['correction_method'] # "alternative" ou "manual"
|
||||
print(f"Correction: {corrected_element['label']} via {method}")
|
||||
```
|
||||
|
||||
**Exigences satisfaites:** 2.5, 2.6
|
||||
|
||||
### 2. PostActionNotification
|
||||
|
||||
Notification post-action affichant le succès (✔️) ou l'échec (❌) d'une action avec possibilité de retour correctif.
|
||||
|
||||
**Fonctionnalités:**
|
||||
- Affichage animé en haut à droite
|
||||
- Timeout automatique de 5 secondes
|
||||
- Barre de progression visuelle
|
||||
- Bouton de correction pour les échecs
|
||||
- Fermeture par clic
|
||||
|
||||
**Utilisation:**
|
||||
```python
|
||||
from geniusia2.gui.dialogs import PostActionNotification
|
||||
|
||||
# Notification de succès
|
||||
notification = PostActionNotification.show_success(
|
||||
action_type="click",
|
||||
target_element="valider_button",
|
||||
confidence=0.95
|
||||
)
|
||||
|
||||
# Notification d'échec avec correction
|
||||
def on_correction(data):
|
||||
print(f"Correction demandée pour: {data}")
|
||||
|
||||
notification = PostActionNotification.show_failure(
|
||||
action_type="click",
|
||||
target_element="annuler_button",
|
||||
error_message="Élément non trouvé à l'écran",
|
||||
confidence=0.65,
|
||||
allow_correction=True
|
||||
)
|
||||
notification.allow_corrective_feedback(on_correction)
|
||||
|
||||
# Écouter les retours
|
||||
notification.feedback_provided.connect(
|
||||
lambda result: print(f"Retour: {result}")
|
||||
)
|
||||
```
|
||||
|
||||
**Exigences satisfaites:** 3.4, 3.5, 3.6
|
||||
|
||||
### 3. TransitionNotification
|
||||
|
||||
Notifications pour les transitions de mode et alertes système.
|
||||
|
||||
**Types de notifications:**
|
||||
- `TYPE_AUTOPILOT_PROPOSAL`: Proposition de passage en Autopilot
|
||||
- `TYPE_CONFIDENCE_DROP`: Alerte de baisse de confiance
|
||||
- `TYPE_WHITELIST_VIOLATION`: Violation de liste blanche
|
||||
- `TYPE_UI_CHANGE`: Changement d'interface détecté
|
||||
- `TYPE_MODE_TRANSITION`: Transition de mode
|
||||
|
||||
**Utilisation:**
|
||||
```python
|
||||
from geniusia2.gui.dialogs import TransitionNotification
|
||||
|
||||
# Proposition de passage en Autopilot
|
||||
notification = TransitionNotification.show_autopilot_proposal(
|
||||
task_name="Ouvrir Facture",
|
||||
observation_count=25,
|
||||
concordance_rate=0.97
|
||||
)
|
||||
notification.action_taken.connect(
|
||||
lambda action: handle_autopilot_decision(action)
|
||||
)
|
||||
|
||||
# Alerte de baisse de confiance
|
||||
notification = TransitionNotification.show_confidence_drop(
|
||||
task_name="Saisie Données",
|
||||
confidence_score=0.85,
|
||||
threshold=0.90,
|
||||
reason="Changements UI détectés"
|
||||
)
|
||||
|
||||
# Violation de liste blanche
|
||||
notification = TransitionNotification.show_whitelist_violation(
|
||||
window_title="Application Non Autorisée",
|
||||
action_type="click"
|
||||
)
|
||||
notification.action_taken.connect(
|
||||
lambda action: handle_whitelist_decision(action)
|
||||
)
|
||||
|
||||
# Changement d'interface
|
||||
notification = TransitionNotification.show_ui_change(
|
||||
task_name="Navigation Menu",
|
||||
similarity=0.65
|
||||
)
|
||||
notification.action_taken.connect(
|
||||
lambda action: handle_ui_change(action)
|
||||
)
|
||||
|
||||
# Transition de mode
|
||||
notification = TransitionNotification.show_mode_transition(
|
||||
task_name="Export Données",
|
||||
from_mode="auto",
|
||||
to_mode="assist",
|
||||
reason="low_confidence"
|
||||
)
|
||||
```
|
||||
|
||||
**Exigences satisfaites:** 3.1, 4.5, 5.4, 6.2, 6.3, 6.5
|
||||
|
||||
## Intégration avec MinimalGUI
|
||||
|
||||
Les dialogues et notifications peuvent être intégrés dans l'interface principale:
|
||||
|
||||
```python
|
||||
from geniusia2.gui.minimal_gui import MinimalGUI
|
||||
from geniusia2.gui.dialogs import (
|
||||
CorrectionDialog,
|
||||
PostActionNotification,
|
||||
TransitionNotification
|
||||
)
|
||||
|
||||
class EnhancedGUI(MinimalGUI):
|
||||
def __init__(self, orchestrator=None):
|
||||
super().__init__(orchestrator)
|
||||
|
||||
def show_correction_dialog(self, incorrect, alternatives):
|
||||
"""Afficher le dialogue de correction"""
|
||||
correction = CorrectionDialog.show_correction_dialog(
|
||||
incorrect,
|
||||
alternatives,
|
||||
parent=self
|
||||
)
|
||||
return correction
|
||||
|
||||
def show_action_result(self, action_result):
|
||||
"""Afficher le résultat d'une action"""
|
||||
if action_result['result'] == 'success':
|
||||
notification = PostActionNotification.show_success(
|
||||
action_result['action_type'],
|
||||
action_result['target_element'],
|
||||
action_result['confidence'],
|
||||
parent=self
|
||||
)
|
||||
else:
|
||||
notification = PostActionNotification.show_failure(
|
||||
action_result['action_type'],
|
||||
action_result['target_element'],
|
||||
action_result.get('error_message', 'Erreur'),
|
||||
action_result['confidence'],
|
||||
parent=self
|
||||
)
|
||||
notification.correction_requested.connect(
|
||||
self.handle_correction_request
|
||||
)
|
||||
|
||||
def show_autopilot_proposal(self, task_name, obs_count, concordance):
|
||||
"""Afficher proposition autopilot"""
|
||||
notification = TransitionNotification.show_autopilot_proposal(
|
||||
task_name,
|
||||
obs_count,
|
||||
concordance,
|
||||
parent=self
|
||||
)
|
||||
notification.action_taken.connect(self.handle_autopilot_decision)
|
||||
|
||||
def handle_correction_request(self, data):
|
||||
"""Gérer une demande de correction"""
|
||||
# Implémenter la logique de correction
|
||||
pass
|
||||
|
||||
def handle_autopilot_decision(self, action):
|
||||
"""Gérer la décision autopilot"""
|
||||
if action == "accept":
|
||||
# Activer le mode autopilot
|
||||
pass
|
||||
elif action == "reject":
|
||||
# Rester en mode assisté
|
||||
pass
|
||||
```
|
||||
|
||||
## Tests
|
||||
|
||||
Chaque module contient un bloc `if __name__ == "__main__"` avec des tests de démonstration.
|
||||
|
||||
Pour tester individuellement:
|
||||
|
||||
```bash
|
||||
# Test du dialogue de correction
|
||||
python geniusia2/gui/dialogs/correction_dialog.py
|
||||
|
||||
# Test des notifications post-action
|
||||
python geniusia2/gui/dialogs/post_action_notification.py
|
||||
|
||||
# Test des notifications de transition
|
||||
python geniusia2/gui/dialogs/transition_notification.py
|
||||
```
|
||||
|
||||
## Architecture
|
||||
|
||||
```
|
||||
gui/dialogs/
|
||||
├── __init__.py # Exports des composants
|
||||
├── correction_dialog.py # Dialogue de correction
|
||||
├── post_action_notification.py # Notifications post-action
|
||||
├── transition_notification.py # Notifications de transition
|
||||
└── README.md # Cette documentation
|
||||
```
|
||||
|
||||
## Dépendances
|
||||
|
||||
- PyQt5 (QWidget, QDialog, QLabel, QPushButton, etc.)
|
||||
- numpy (pour les captures d'écran optionnelles)
|
||||
- logging (pour la journalisation)
|
||||
|
||||
## Notes d'Implémentation
|
||||
|
||||
### Animations
|
||||
Toutes les notifications utilisent des animations de glissement depuis la droite avec `QPropertyAnimation`.
|
||||
|
||||
### Timeouts
|
||||
- PostActionNotification: 5 secondes par défaut
|
||||
- TransitionNotification: 6-10 secondes selon le type
|
||||
- Les notifications nécessitant une action n'ont pas de timeout
|
||||
|
||||
### Signaux PyQt5
|
||||
Tous les composants utilisent des signaux pour la communication asynchrone:
|
||||
- `correction_made`: Émis quand une correction est effectuée
|
||||
- `feedback_provided`: Émis quand un retour est fourni
|
||||
- `action_taken`: Émis quand une action utilisateur est prise
|
||||
|
||||
### Style
|
||||
Les couleurs et styles sont cohérents avec Material Design:
|
||||
- Vert (#4CAF50): Succès, validation
|
||||
- Rouge (#f44336): Échec, erreur
|
||||
- Orange (#FF9800): Avertissement
|
||||
- Bleu (#2196F3): Information
|
||||
Reference in New Issue
Block a user