
    e/                         d Z ddlZddlZddlmZ ddlmZ ddlmZm	Z	m
Z
mZmZmZmZmZmZmZ ddlmZmZmZmZmZ ddlmZ ddlmZ d	Z G d
 de      Zy)z
General entry in Preferences.

For historical reasons (dating back to Spyder 2) the main class here is called
`MainConfigPage` and its associated entry in our config system is called
`main`.
    N)from_qvariant)Qt)
QApplicationQButtonGroupQGridLayout	QGroupBoxQHBoxLayoutQLabelQMessageBox
QTabWidgetQVBoxLayoutQWidget)_DISABLED_LANGUAGESLANGUAGE_CODESrunning_in_mac_appsave_lang_conf)PluginConfigPage)to_text_stringz#https://doc.qt.io/qt-5/highdpi.htmlc                   0     e Zd Z fdZd Zd Zd Z xZS )ApplicationConfigPagec                 H    t         |   ||       | j                  | _        y N)super__init__perform_checkspre_apply_callback)selfpluginparent	__class__s      E/usr/lib/python3/dist-packages/spyder/plugins/application/confpage.pyr   zApplicationConfigPage.__init__"   s     ("&"5"5    c           
      "  )* | j                   }t        j                         }t        D ]  }|j	                  |        |j                         }t        |D cg c]	  \  }}||f c}}      }| j                  t        d      |dd      }g d}	t        t        |	|	D 
cg c]  }
|
j                          c}
            }| j                  t        d      |dd      } |t        d      d	t        d
            } |t        d      d      } |t        d      d      }t               r#| j                  d	d       |j                  d       t               }t!               }|j#                  |j$                  dd       |j#                  |j&                  dd       |j#                  |j$                  dd       |j#                  |j&                  dd       |j)                  |       |j+                  d       t-               }|j)                  |       |j#                  |       |j#                  |       |j#                  |       t/               }|j1                  |       t3        t        d            } |t        d      d      } |t        d      d      }| j5                  dt        d      dddd      }|j6                  j9                  |j:                  j                         |j6                  j9                  |j<                  j                         |j:                  j                  | j?                  d             |j<                  j                  | j?                  d              |t        d      d      }| j5                  dt        d      d tA        jB                         dd!d"#      }|j6                  j9                  |j:                  j                         |j6                  j9                  |j<                  j                         |j:                  j                  | j?                  d             |j<                  j                  | j?                  d             t!               }|j#                  |dd       |j#                  |j:                  dd       |j#                  |j<                  dd$       |j#                  |dd       |j#                  |j:                  dd       |j#                  |j<                  dd$       |jE                  d$d"       t-               }|j#                  |       |j)                  |       |j1                  |       tF        jH                  d%k(  rt               sdd&l%m&)m'* dd l(})*fd'}t3        t        d(            } |t        d)      d*t        d+            }|j6                  j9                  |       t-               } | j#                  |       |jS                         4|jU                  d       | j#                  tW        t        d,                   |j1                  |        t3        t        d-            }!tY        |!      }"tW        t        d.      j[                  t\                    }#|#j_                  d       |#ja                  d       | jc                  t        d/      d0|"1      | _2        | jc                  t        d2      d3|"t        d4      d5      }$| jc                  t        d6      d7|"t        d8      d5      | _3        | ji                  dd9t        d:      tj        jl                  d;d<      | _7        | jd                  j6                  j9                  | jn                  jT                         |$j6                  j9                  | jn                  jT                         | jf                  j6                  j9                  | jn                  j                         t-               }%|%j#                  |#       t!               }&|&j#                  | jd                  dd       |&j#                  |$dd       |&j#                  | jf                  d$d       |&j#                  | jn                  d$d       |%j)                  |&       |!j1                  |%       tF        jH                  d%k(  rt               s| jq                  |!|      }'n| jq                  |!|      }'ts               | _:        | jt                  jw                  |'t        d=             | jt                  jw                  | jq                  |      t        d>             t-               }(|(j#                  | jt                         | j1                  |(       y c c}}w c c}
w )?Nz	Language:interface_languageT)restart)	AutomaticDesktopSoftwareGLESzRendering engine:openglzUse a single instancesingle_instancez^Set this to open external<br> Python files in an already running instance (Requires a restart))tipzPrompt when exitingprompt_on_exitz4Show internal Spyder errors to report them to Githubshow_internal_errorsFr      PaneszVertical tabs in panesvertical_tabszCustom margin for panes:use_custom_margin pixelscustom_margin   )defaultmin_max_zCursor blinking:use_custom_cursor_blinkingmscustom_cursor_blinkingi  d   )r8   r9   r:   step   darwin)register_app_launchservicesrestore_launchservicesc                 (    | r         y          y r    )staterB   rC   s    r"   set_open_filez7ApplicationConfigPage.setup_page.<locals>.set_open_file   s    /1*,r#   zmacOS integrationz"Open files from Finder with Spydermac_open_filez(Register Spyder with the Launch ServiceszNLaunch Spyder with <code>python.app</code> to enable Apple event integrations.zScreen resolutionzConfiguration for high DPI screens<br><br>Please see <a href="{0}">{0}</a><> for more information about these options (in English).Normalnormal_screen_resolution)button_groupzEnable auto high DPI scalinghigh_dpi_scalingzSet this for high DPI displays)rK   r-   r&   zSet a custom high DPI scalinghigh_dpi_custom_scale_factorz>Set this for high DPI displays when auto scaling does not workhigh_dpi_custom_scale_factorsz[Enter values for different screens separated by semicolons ';'.
 Float values are supportedz([1-9]+(?:\.[0-9]*)(;[1-9]+(?:\.[0-9]*))*)r-   	alignmentregexr&   	InterfacezAdvanced settings)<create_checkboxr   copyr   popitemssortedcreate_comboboxr   listziplowerr   
set_option
setEnabledr	   r   	addWidgetlabelcombobox	addLayout
addStretchr   r   	setLayoutr   create_spinboxtoggledconnectspinboxslabel
get_optionr   cursorFlashTimesetColumnStretchsysplatformspyder.utils.qthelpersrB   rC   applaunchservicesget_bundle_identifiersetDisabledr
   r   formatHDPI_QT_PAGEsetWordWrapsetOpenExternalLinkscreate_radiobuttonnormal_radiocustom_scaling_radiocreate_lineeditr   
Horizontalcustom_scaling_edit
create_tabr   tabsaddTab)+r   newcblanguage_codeslang	languageskeyvallanguage_choiceslanguage_comboopengl_optionscopengl_choicesopengl_combosingle_instance_box
prompt_boxpopup_console_boxcomboboxes_advanced_layoutcbs_adv_gridadvanced_layoutadvanced_widgetinterface_groupverttabs_box
margin_boxmargin_spin
cursor_boxcursor_spinmargins_cursor_layoutinterface_layoutalsrG   macOS_groupmac_open_file_boxmacOS_layoutscreen_resolution_groupscreen_resolution_bgscreen_resolution_labelauto_scale_radioscreen_resolution_layoutscreen_resolution_inner_layoutinterface_tabvlayoutrB   rC   s+                                            @@r"   
setup_pagez ApplicationConfigPage.setup_page&   s   $$ (,,.& 	%Dt$	% #((*	!i"H(#sC:"HI--an.>.B6: . <
 Fc.6D"E1779"EG H++A.A,B,:,448 , :
 $A&=$>$5() +J )KL 1235EF
!! %5 #67MO OO-t4**51%0]""}~33Q:~661=|111a8|44a;",,\:"--a0%-!!"<=!!"56!!*-!!"34 ")!!/2 $AgJ/Q78,.178.0
))"ak?23!" * F"";#6#6#A#AB"";#5#5#@#@A&&t7J'KL%%doo6I&JK1/079
))$$ 002C	 * )
 	"";#6#6#A#AB"";#5#5#@#@A&&OO89	;%%OO89	; !,''
Aq9''(;(;QB''(:(:AqA''
Aq9''(;(;QB''(:(:AqA..q#6 '=""<0""#89!!"23<<8#,>,@H+- $A&9$:;K %67@A!C %%--m<&=L""#45((*2!--d3&&v 3 4(5 6 !!,/ #,A.A,B"C+,CD"( ,7 *8 9?|8L#N 	 ++D144T: 33hK&- 4 

  22,--23 3 
 %)$;$;-.*-   %< %
! $(#7#7+ 6 7mm= $8 $
  	!!))$*B*B*N*NO  (()A)A)M)MN!!))11$$//	

 $/=  **+BC)4&&001B1BAqI&001A1aH&00%%q!	-&00$$a	, 	!**+IJ))*BC<<8#,>,@ OO,C,;[JM !OO,C,;=M L			+7		9./	1 -$))$wW #I #Fs   f
 fc                     | j                   j                         ra| j                  j                  j	                         }|dk(  r7| j
                  j                  d       | j                  j                  d       y y y )Nr4   TrN   )	rw   	isCheckedrz   textboxtextrv   
setCheckedchanged_optionsadd)r   scale_factors     r"   r   z$ApplicationConfigPage.perform_checks   sk     $$..033;;@@BLr!!!,,T2$$(()HI " 1r#   c           	         t        | j                  j                               D ]?  \  }\  }}}|dk(  s|j                  |j	                               }t        |t              } n 	 t               | j                  d|       y# t        $ r\ t        j                  | t        d      t        d      j                  t        j                               t        j                          Y yw xY w)zX
        Get selected language setting and save to language configuration file.
        r%   ErrorzkWe're sorry but the following error occurred while trying to set your selected language:<br><br><tt>{}</tt>N)rX   
comboboxesrU   itemDatacurrentIndexr   r   r   r[   	Exceptionr   criticalr   rq   	traceback
format_excOk)r   r_   secopt_defaultdatavalues          r"   
_save_langz ApplicationConfigPage._save_lang  s     /34??3H3H3J.K 	*H*sC**(()>)>)@A%dN;		
	5!OO0%8 		  '
   !!'	(<(<(>!? 		s   'B A"C*)C*)__name__
__module____qualname__r   r   r   r   __classcell__)r!   s   @r"   r   r       s    6U nJr#   r   )__doc__r   rk   qtpy.compatr   qtpy.QtCorer   qtpy.QtWidgetsr   r   r   r   r	   r
   r   r   r   r   spyder.config.baser   r   r   r   r   spyder.api.preferencesr   spyder.py3compatr   rr   r   rE   r#   r"   <module>r      sM     
 % 2 2 2D D 3 +4{, {r#   