@@ -638,7 +638,8 @@ internal static Button CreateButton(ActionItem action, Action handler)
638638
639639 public static void ShowVoiceModelsPanel ( Flyout flyout , string ? currentModelId ,
640640 XamlRoot xamlRoot ,
641- Action < SttModelInfo > onSelectModel , Action < SttModelInfo > onDeleteModel , Action onBack , Action onRebuild )
641+ Action < SttModelInfo > onSelectModel , Action < SttModelInfo > onDeleteModel , Action onBack , Action onRebuild ,
642+ AiManager ? aiManager = null )
642643 {
643644 var panel = CreateSubPanelWithHeader ( Lang . T ( "voice_model" ) , onBack ) ;
644645
@@ -664,9 +665,159 @@ public static void ShowVoiceModelsPanel(Flyout flyout, string? currentModelId,
664665 foreach ( var model in SttModels . Available . Where ( m => m . Languages == "Anglais" ) )
665666 panel . Children . Add ( CreateModelItem ( model , currentModelId , flyout , xamlRoot , onSelectModel , onDeleteModel , onRebuild ) ) ;
666667
668+ // Groq Cloud section
669+ if ( aiManager != null )
670+ {
671+ panel . Children . Add ( CreateSeparator ( ) ) ;
672+ panel . Children . Add ( new TextBlock
673+ {
674+ Text = Lang . T ( "groq_cloud_section" ) ,
675+ Style = ( Style ) Application . Current . Resources [ "CaptionTextBlockStyle" ] ,
676+ Opacity = 0.6 ,
677+ Margin = new Thickness ( 10 , 8 , 0 , 4 )
678+ } ) ;
679+
680+ var hasKey = aiManager . HasApiKey ( "groq" ) ;
681+
682+ // API key input
683+ var keyBlock = new StackPanel { Margin = new Thickness ( 10 , 4 , 10 , 4 ) , Spacing = 3 } ;
684+
685+ var nameRow = new Grid ( ) ;
686+ nameRow . ColumnDefinitions . Add ( new ColumnDefinition { Width = new GridLength ( 1 , GridUnitType . Star ) } ) ;
687+ nameRow . ColumnDefinitions . Add ( new ColumnDefinition { Width = GridLength . Auto } ) ;
688+
689+ var nameText = new TextBlock
690+ {
691+ Text = Lang . T ( "groq_api_key" ) ,
692+ FontSize = 12 ,
693+ FontWeight = Microsoft . UI . Text . FontWeights . SemiBold ,
694+ VerticalAlignment = VerticalAlignment . Center ,
695+ } ;
696+ Grid . SetColumn ( nameText , 0 ) ;
697+
698+ var statusIcon = new FontIcon
699+ {
700+ Glyph = hasKey ? "\uE73E " : "\uE785 " ,
701+ FontSize = 12 ,
702+ Foreground = hasKey
703+ ? new SolidColorBrush ( Windows . UI . Color . FromArgb ( 255 , 108 , 203 , 95 ) )
704+ : ( Brush ) Application . Current . Resources [ "TextFillColorTertiaryBrush" ] ,
705+ VerticalAlignment = VerticalAlignment . Center ,
706+ } ;
707+ Grid . SetColumn ( statusIcon , 1 ) ;
708+ nameRow . Children . Add ( nameText ) ;
709+ nameRow . Children . Add ( statusIcon ) ;
710+ keyBlock . Children . Add ( nameRow ) ;
711+
712+ var keyRow = new Grid ( ) ;
713+ keyRow . ColumnDefinitions . Add ( new ColumnDefinition { Width = new GridLength ( 1 , GridUnitType . Star ) } ) ;
714+ keyRow . ColumnDefinitions . Add ( new ColumnDefinition { Width = GridLength . Auto } ) ;
715+
716+ var keyBox = new PasswordBox
717+ {
718+ PlaceholderText = Lang . T ( "groq_api_key_placeholder" ) ,
719+ Password = aiManager . GetApiKey ( "groq" ) ,
720+ FontSize = 11 ,
721+ MaxWidth = 200 ,
722+ HorizontalAlignment = HorizontalAlignment . Stretch ,
723+ } ;
724+ Grid . SetColumn ( keyBox , 0 ) ;
725+
726+ var saveKeyBtn = new Button
727+ {
728+ Content = new FontIcon { Glyph = "\uE73E " , FontSize = 12 } ,
729+ Padding = new Thickness ( 8 , 4 , 8 , 4 ) ,
730+ Margin = new Thickness ( 4 , 0 , 0 , 0 ) ,
731+ } ;
732+ Grid . SetColumn ( saveKeyBtn , 1 ) ;
733+
734+ saveKeyBtn . Click += ( _ , _ ) =>
735+ {
736+ aiManager . SetApiKey ( "groq" , keyBox . Password ) ;
737+ var nowHasKey = aiManager . HasApiKey ( "groq" ) ;
738+ statusIcon . Glyph = nowHasKey ? "\uE73E " : "\uE785 " ;
739+ statusIcon . Foreground = nowHasKey
740+ ? new SolidColorBrush ( Windows . UI . Color . FromArgb ( 255 , 108 , 203 , 95 ) )
741+ : ( Brush ) Application . Current . Resources [ "TextFillColorTertiaryBrush" ] ;
742+ onRebuild ( ) ;
743+ } ;
744+
745+ keyRow . Children . Add ( keyBox ) ;
746+ keyRow . Children . Add ( saveKeyBtn ) ;
747+ keyBlock . Children . Add ( keyRow ) ;
748+ panel . Children . Add ( keyBlock ) ;
749+
750+ // Groq cloud models (only show if key exists)
751+ if ( hasKey )
752+ {
753+ foreach ( var model in SttModels . Available . Where ( m => m . Engine == SttEngine . GroqCloud ) )
754+ panel . Children . Add ( CreateGroqModelItem ( model , currentModelId , onSelectModel , flyout ) ) ;
755+ }
756+ }
757+
667758 flyout . Content = panel ;
668759 }
669760
761+ private static UIElement CreateGroqModelItem ( SttModelInfo model , string ? currentModelId ,
762+ Action < SttModelInfo > onSelect , Flyout parentFlyout )
763+ {
764+ var isCurrent = model . Id == currentModelId ;
765+
766+ var btn = new Button
767+ {
768+ HorizontalAlignment = HorizontalAlignment . Stretch ,
769+ HorizontalContentAlignment = HorizontalAlignment . Stretch ,
770+ Background = new SolidColorBrush ( Microsoft . UI . Colors . Transparent ) ,
771+ BorderThickness = new Thickness ( 0 ) ,
772+ Padding = new Thickness ( 10 , 7 , 10 , 7 ) ,
773+ CornerRadius = new CornerRadius ( 5 ) ,
774+ Tag = model . Name
775+ } ;
776+
777+ var grid = new Grid { ColumnSpacing = 8 } ;
778+ grid . ColumnDefinitions . Add ( new ColumnDefinition { Width = new GridLength ( 1 , GridUnitType . Star ) } ) ;
779+ grid . ColumnDefinitions . Add ( new ColumnDefinition { Width = GridLength . Auto } ) ;
780+
781+ var textPanel = new StackPanel { Spacing = 1 } ;
782+ textPanel . Children . Add ( new TextBlock
783+ {
784+ Text = model . Name ,
785+ FontSize = 13 ,
786+ FontWeight = isCurrent
787+ ? Microsoft . UI . Text . FontWeights . SemiBold
788+ : Microsoft . UI . Text . FontWeights . Normal ,
789+ } ) ;
790+ textPanel . Children . Add ( new TextBlock
791+ {
792+ Text = isCurrent ? $ "Groq — { Lang . T ( "model_active" ) } " : $ "Groq — { Lang . T ( "groq_cloud_model" ) } ",
793+ FontSize = 11 ,
794+ Opacity = isCurrent ? 0.85 : 0.45
795+ } ) ;
796+ Grid . SetColumn ( textPanel , 0 ) ;
797+ grid . Children . Add ( textPanel ) ;
798+
799+ var icon = new FontIcon
800+ {
801+ Glyph = isCurrent ? "\uE73E " : "\uE753 " , // checkmark or cloud
802+ FontSize = isCurrent ? 14 : 12 ,
803+ Foreground = isCurrent
804+ ? new SolidColorBrush ( Windows . UI . Color . FromArgb ( 255 , 108 , 203 , 95 ) )
805+ : ( Brush ) Application . Current . Resources [ "TextFillColorTertiaryBrush" ] ,
806+ VerticalAlignment = VerticalAlignment . Center
807+ } ;
808+ Grid . SetColumn ( icon , 1 ) ;
809+ grid . Children . Add ( icon ) ;
810+
811+ btn . Content = grid ;
812+ btn . Click += ( _ , _ ) =>
813+ {
814+ onSelect ( model ) ;
815+ parentFlyout . Hide ( ) ;
816+ } ;
817+
818+ return btn ;
819+ }
820+
670821 private static UIElement CreateModelItem ( SttModelInfo model , string ? currentModelId ,
671822 Flyout parentFlyout , XamlRoot xamlRoot , Action < SttModelInfo > onSelect , Action < SttModelInfo > onDelete , Action onRebuild )
672823 {
0 commit comments