@@ -666,6 +666,151 @@ public static (int X, int Y, int W, int H)? LoadNotepadPosition()
666666 return null ;
667667 }
668668
669+ public static void SaveWidgetModules ( Dictionary < string , bool > modules )
670+ {
671+ MergeAndSaveSettings ( new Dictionary < string , object > { [ "widgetModules" ] = modules } ) ;
672+ }
673+
674+ public static Dictionary < string , bool > LoadWidgetModules ( )
675+ {
676+ try
677+ {
678+ if ( File . Exists ( SettingsPath ) )
679+ {
680+ var json = File . ReadAllText ( SettingsPath ) ;
681+ using var doc = JsonDocument . Parse ( json ) ;
682+ if ( doc . RootElement . TryGetProperty ( "widgetModules" , out var prop ) )
683+ {
684+ var result = new Dictionary < string , bool > ( ) ;
685+ foreach ( var p in prop . EnumerateObject ( ) )
686+ result [ p . Name ] = p . Value . GetBoolean ( ) ;
687+ return result ;
688+ }
689+ }
690+ }
691+ catch { }
692+ // Default: clipboard and favorites enabled
693+ return new Dictionary < string , bool >
694+ {
695+ [ "clipboard" ] = true ,
696+ [ "notes" ] = false ,
697+ [ "favorites" ] = true ,
698+ [ "folders" ] = false ,
699+ [ "snippets" ] = false ,
700+ } ;
701+ }
702+
703+ public static void SaveWidgetEnabled ( bool enabled )
704+ {
705+ MergeAndSaveSettings ( new Dictionary < string , object > { [ "widgetEnabled" ] = enabled } ) ;
706+ }
707+
708+ public static bool LoadWidgetEnabled ( )
709+ {
710+ try
711+ {
712+ if ( File . Exists ( SettingsPath ) )
713+ {
714+ var json = File . ReadAllText ( SettingsPath ) ;
715+ using var doc = JsonDocument . Parse ( json ) ;
716+ if ( doc . RootElement . TryGetProperty ( "widgetEnabled" , out var prop ) )
717+ return prop . GetBoolean ( ) ;
718+ }
719+ }
720+ catch { }
721+ return false ;
722+ }
723+
724+ public static void SaveWidgetPosition ( int x , int y )
725+ {
726+ MergeAndSaveSettings ( new Dictionary < string , object > { [ "widgetX" ] = x , [ "widgetY" ] = y } ) ;
727+ }
728+
729+ public static void SaveWidgetSize ( int w , int h )
730+ {
731+ MergeAndSaveSettings ( new Dictionary < string , object > { [ "widgetW" ] = w , [ "widgetH" ] = h } ) ;
732+ }
733+
734+ public static ( int W , int H ) ? LoadWidgetSize ( )
735+ {
736+ try
737+ {
738+ if ( ! File . Exists ( SettingsPath ) ) return null ;
739+ var json = File . ReadAllText ( SettingsPath ) ;
740+ using var doc = JsonDocument . Parse ( json ) ;
741+ if ( doc . RootElement . TryGetProperty ( "widgetW" , out var wProp ) &&
742+ doc . RootElement . TryGetProperty ( "widgetH" , out var hProp ) &&
743+ wProp . TryGetInt32 ( out var w ) &&
744+ hProp . TryGetInt32 ( out var h ) )
745+ {
746+ return ( w , h ) ;
747+ }
748+ }
749+ catch { }
750+ return null ;
751+ }
752+
753+ public static void SaveWidgetOpacity ( double opacity )
754+ {
755+ MergeAndSaveSettings ( new Dictionary < string , object > { [ "widgetOpacity" ] = opacity } ) ;
756+ }
757+
758+ public static double LoadWidgetOpacity ( )
759+ {
760+ try
761+ {
762+ if ( File . Exists ( SettingsPath ) )
763+ {
764+ var json = File . ReadAllText ( SettingsPath ) ;
765+ using var doc = JsonDocument . Parse ( json ) ;
766+ if ( doc . RootElement . TryGetProperty ( "widgetOpacity" , out var prop ) )
767+ return prop . GetDouble ( ) ;
768+ }
769+ }
770+ catch { }
771+ return 1.0 ;
772+ }
773+
774+ public static void SaveWidgetCompact ( bool compact )
775+ {
776+ MergeAndSaveSettings ( new Dictionary < string , object > { [ "widgetCompact" ] = compact } ) ;
777+ }
778+
779+ public static bool LoadWidgetCompact ( )
780+ {
781+ try
782+ {
783+ if ( File . Exists ( SettingsPath ) )
784+ {
785+ var json = File . ReadAllText ( SettingsPath ) ;
786+ using var doc = JsonDocument . Parse ( json ) ;
787+ if ( doc . RootElement . TryGetProperty ( "widgetCompact" , out var prop ) )
788+ return prop . GetBoolean ( ) ;
789+ }
790+ }
791+ catch { }
792+ return false ;
793+ }
794+
795+ public static ( int X , int Y ) ? LoadWidgetPosition ( )
796+ {
797+ try
798+ {
799+ if ( ! File . Exists ( SettingsPath ) ) return null ;
800+ var json = File . ReadAllText ( SettingsPath ) ;
801+ using var doc = JsonDocument . Parse ( json ) ;
802+ if ( doc . RootElement . TryGetProperty ( "widgetX" , out var xProp ) &&
803+ doc . RootElement . TryGetProperty ( "widgetY" , out var yProp ) &&
804+ xProp . TryGetInt32 ( out var x ) &&
805+ yProp . TryGetInt32 ( out var y ) )
806+ {
807+ return ( x , y ) ;
808+ }
809+ }
810+ catch { }
811+ return null ;
812+ }
813+
669814 public static void SaveMainWindowPosition ( Windows . Graphics . PointInt32 position , Windows . Graphics . SizeInt32 size )
670815 {
671816 MergeAndSaveSettings ( new Dictionary < string , object >
0 commit comments