# include  "selfdrive/ui/qt/window.h" 
  
						 
					
						
							
								
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  <QFontDatabase> 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  "system/hardware/hw.h" 
  
						 
					
						
							
								
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								MainWindow : : MainWindow ( QWidget  * parent )  :  QWidget ( parent )  { 
 
						 
					
						
							
								
							 
							
								
									
										 
								
							 
							
								 
							
							
								  main_layout  =  new  QStackedLayout ( this ) ; 
  
						 
					
						
							
								
							 
							
								
									
										 
								
							 
							
								 
							
							
								  main_layout - > setMargin ( 0 ) ; 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
									
										 
								
							 
							
								 
							
							
								  homeWindow  =  new  HomeWindow ( this ) ; 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  main_layout - > addWidget ( homeWindow ) ; 
  
						 
					
						
							
								
							 
							
								
									
										 
								
							 
							
								 
							
							
								  QObject : : connect ( homeWindow ,  & HomeWindow : : openSettings ,  this ,  & MainWindow : : openSettings ) ; 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  QObject : : connect ( homeWindow ,  & HomeWindow : : closeSettings ,  this ,  & MainWindow : : closeSettings ) ; 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
									
										 
								
							 
							
								 
							
							
								  settingsWindow  =  new  SettingsWindow ( this ) ; 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  main_layout - > addWidget ( settingsWindow ) ; 
  
						 
					
						
							
								
							 
							
								
									
										 
								
							 
							
								 
							
							
								  QObject : : connect ( settingsWindow ,  & SettingsWindow : : closeSettings ,  this ,  & MainWindow : : closeSettings ) ; 
  
						 
					
						
							
								
							 
							
								
									
										 
								
							 
							
								 
							
							
								  QObject : : connect ( settingsWindow ,  & SettingsWindow : : reviewTrainingGuide ,  [ = ] ( )  { 
  
						 
					
						
							
								
							 
							
								
									
										 
								
							 
							
								 
							
							
								    onboardingWindow - > showTrainingGuide ( ) ; 
  
						 
					
						
							
								
							 
							
								
									
										 
								
							 
							
								 
							
							
								    main_layout - > setCurrentWidget ( onboardingWindow ) ; 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  } ) ; 
  
						 
					
						
							
								
							 
							
								
									
										 
								
							 
							
								 
							
							
								  QObject : : connect ( settingsWindow ,  & SettingsWindow : : showDriverView ,  [ = ]  { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    homeWindow - > showDriverView ( true ) ; 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  } ) ; 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
									
										 
								
							 
							
								 
							
							
								  onboardingWindow  =  new  OnboardingWindow ( this ) ; 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  main_layout - > addWidget ( onboardingWindow ) ; 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  QObject : : connect ( onboardingWindow ,  & OnboardingWindow : : onboardingDone ,  [ = ] ( )  { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    main_layout - > setCurrentWidget ( homeWindow ) ; 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  } ) ; 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  if  ( ! onboardingWindow - > completed ( ) )  { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    main_layout - > setCurrentWidget ( onboardingWindow ) ; 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
									
										 
								
							 
							
								 
							
							
								  QObject : : connect ( uiState ( ) ,  & UIState : : offroadTransition ,  [ = ] ( bool  offroad )  { 
  
						 
					
						
							
								
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( ! offroad )  { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      closeSettings ( ) ; 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  } ) ; 
  
						 
					
						
							
								
							 
							
								
									
										 
								
							 
							
								 
							
							
								  QObject : : connect ( & device ,  & Device : : interactiveTimout ,  [ = ] ( )  { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( main_layout - > currentWidget ( )  = =  settingsWindow )  { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      closeSettings ( ) ; 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
  
						 
					
						
							
								
							 
							
								
									
										 
								
							 
							
								 
							
							
								  } ) ; 
  
						 
					
						
							
								
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
									
										 
								
							 
							
								 
							
							
								  // load fonts
   
						 
					
						
							
								
							 
							
								
									
										 
								
							 
							
								 
							
							
								  QFontDatabase : : addApplicationFont ( " ../assets/fonts/Inter-Black.ttf " ) ; 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  QFontDatabase : : addApplicationFont ( " ../assets/fonts/Inter-Bold.ttf " ) ; 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  QFontDatabase : : addApplicationFont ( " ../assets/fonts/Inter-ExtraBold.ttf " ) ; 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  QFontDatabase : : addApplicationFont ( " ../assets/fonts/Inter-ExtraLight.ttf " ) ; 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  QFontDatabase : : addApplicationFont ( " ../assets/fonts/Inter-Medium.ttf " ) ; 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  QFontDatabase : : addApplicationFont ( " ../assets/fonts/Inter-Regular.ttf " ) ; 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  QFontDatabase : : addApplicationFont ( " ../assets/fonts/Inter-SemiBold.ttf " ) ; 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  QFontDatabase : : addApplicationFont ( " ../assets/fonts/Inter-Thin.ttf " ) ; 
  
						 
					
						
							
								
							 
							
								
									
										 
								
							 
							
								 
							
							
								  QFontDatabase : : addApplicationFont ( " ../assets/fonts/JetBrainsMono-Medium.ttf " ) ; 
  
						 
					
						
							
								
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
									
										 
								
							 
							
								 
							
							
								  // no outline to prevent the focus rectangle
   
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  setStyleSheet ( R " ( 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    *  { 
  
						 
					
						
							
								
							 
							
								
									
										 
								
							 
							
								 
							
							
								      font - family :  Inter ; 
  
						 
					
						
							
								
							 
							
								
									
										 
								
							 
							
								 
							
							
								      outline :  none ; 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  ) " ); 
  
						 
					
						
							
								
							 
							
								
									
										 
								
							 
							
								 
							
							
								  setAttribute ( Qt : : WA_NoSystemBackground ) ; 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} 
 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  MainWindow : : openSettings ( int  index ,  const  QString  & param )  { 
 
						 
					
						
							
								
							 
							
								
									
										 
								
							 
							
								 
							
							
								  main_layout - > setCurrentWidget ( settingsWindow ) ; 
  
						 
					
						
							
								
							 
							
								
									
										 
								
							 
							
								 
							
							
								  settingsWindow - > setCurrentPanel ( index ,  param ) ; 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} 
 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  MainWindow : : closeSettings ( )  { 
 
						 
					
						
							
								
							 
							
								
									
										 
								
							 
							
								 
							
							
								  main_layout - > setCurrentWidget ( homeWindow ) ; 
  
						 
					
						
							
								
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
									
										 
								
							 
							
								 
							
							
								  if  ( uiState ( ) - > scene . started )  { 
  
						 
					
						
							
								
							 
							
								
									
										 
								
							 
							
								 
							
							
								    homeWindow - > showSidebar ( false ) ; 
  
						 
					
						
							
								
							 
							
								
									
										 
								
							 
							
								 
							
							
								  } 
  
						 
					
						
							
								
							 
							
								
									
										 
								
							 
							
								 
							
							
								} 
 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
									
										 
								
							 
							
								 
							
							
								bool  MainWindow : : eventFilter ( QObject  * obj ,  QEvent  * event )  { 
 
						 
					
						
							
								
							 
							
								
									
										 
								
							 
							
								 
							
							
								  const  static  QSet < QEvent : : Type >  evts ( { QEvent : : MouseButtonPress ,  QEvent : : MouseMove , 
  
						 
					
						
							
								
							 
							
								
									
										 
								
							 
							
								 
							
							
								                                 QEvent : : TouchBegin ,  QEvent : : TouchUpdate ,  QEvent : : TouchEnd } ) ; 
  
						 
					
						
							
								
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
									
										 
								
							 
							
								 
							
							
								  if  ( evts . contains ( event - > type ( ) ) )  { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    device . resetInteractiveTimout ( ) ; 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  } 
  
						 
					
						
							
								
							 
							
								
									
										 
								
							 
							
								 
							
							
								  return  false ; 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}