@@ -361,12 +361,41 @@ def argument_parser(self) -> argparse.ArgumentParser:
361361 "--clear-widget-settings" , action = "store_true" ,
362362 help = "Clear stored widget setting/defaults" ,
363363 )
364+ parser .add_argument (
365+ "--clear-all" , action = "store_true" ,
366+ help = "Clear all settings and caches"
367+ )
364368 return parser
365369
366370 def setup_logging (self ):
367371 super ().setup_logging ()
368372 make_sql_logger (self .options .log_level )
369373
374+ @staticmethod
375+ def _rm_tree (path ):
376+ log .debug ("rmtree '%s'" , path )
377+ shutil .rmtree (path , ignore_errors = True )
378+
379+ def clear_widget_settings (self ):
380+ log .info ("Clearing widget settings" )
381+ self ._rm_tree (widget_settings_dir (versioned = True ))
382+ self ._rm_tree (widget_settings_dir (versioned = False ))
383+
384+ def clear_caches (self ): # pylint: disable=import-outside-toplevel
385+ from Orange .misc import environ
386+ log .info ("Clearing caches" )
387+ self ._rm_tree (environ .cache_dir ())
388+ log .info ("Clearing data" )
389+ self ._rm_tree (environ .data_dir (versioned = True ))
390+ self ._rm_tree (environ .data_dir (versioned = False ))
391+
392+ def clear_application_settings (self ): # pylint: disable=no-self-use
393+ s = QSettings ()
394+ log .info ("Clearing application settings" )
395+ log .debug ("clear '%s'" , s .fileName ())
396+ s .clear ()
397+ s .sync ()
398+
370399 def setup_application (self ):
371400 super ().setup_application ()
372401 clear_settings_flag = os .path .join (widget_settings_dir (),
@@ -375,8 +404,12 @@ def setup_application(self):
375404 options = self .options
376405 if options .clear_widget_settings or \
377406 os .path .isfile (clear_settings_flag ):
378- log .info ("Clearing widget settings" )
379- shutil .rmtree (widget_settings_dir (), ignore_errors = True )
407+ self .clear_widget_settings ()
408+
409+ if options .clear_all :
410+ self .clear_widget_settings ()
411+ self .clear_caches ()
412+ self .clear_application_settings ()
380413
381414 notif_server = NotificationServer ()
382415 canvas .notification_server_instance = notif_server
0 commit comments