@ -3,128 +3,60 @@ 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					# include  <sstream>  
					 
					 
					 
					# include  <sstream>  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					# include  <cassert>  
					 
					 
					 
					# include  <cassert>  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					# include  <QString>  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					# include  <QVBoxLayout>  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					# include  <QHBoxLayout>  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					# include  <QPushButton>  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					# include  <QLabel>  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					# include  <QPixmap>  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					# ifndef QCOM  
					 
					 
					 
					# ifndef QCOM  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					# include  "networking.hpp"  
					 
					 
					 
					# include  "networking.hpp"  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					# endif  
					 
					 
					 
					# endif  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					# include  "settings.hpp"  
					 
					 
					 
					# include  "settings.hpp"  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					# include  "widgets/input.hpp"  
					 
					 
					 
					# include  "widgets/input.hpp"  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					# include  "widgets/toggle.hpp"  
					 
					 
					 
					# include  "widgets/toggle.hpp"  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					# include  "widgets/offroad_alerts.hpp"  
					 
					 
					 
					# include  "widgets/offroad_alerts.hpp"  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
  
					 
					 
					 
					# include  "widgets/controls.hpp"  
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					# include  "selfdrive/ common/params.h"  
					 
					 
					 
					# include  "common/params.h"  
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					# include  "selfdrive/ common/util.h"  
					 
					 
					 
					# include  "common/util.h"  
				
			 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					# include  "selfdrive/hardware/hw.h"  
					 
					 
					 
					# include  "selfdrive/hardware/hw.h"  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					QFrame *  horizontal_line ( QWidget *  parent  =  0 ) {  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  QFrame *  line  =  new  QFrame ( parent ) ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  line - > setFrameShape ( QFrame : : StyledPanel ) ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  line - > setStyleSheet ( " margin-left: 40px; margin-right: 40px; border-width: 1px; border-bottom-style: solid; border-color: gray; " ) ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  line - > setFixedHeight ( 2 ) ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  return  line ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					}  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					QWidget  * labelWidget ( QString  labelName ,  QString  labelContent ,  QLabel  * * label  =  nullptr )  {  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  QHBoxLayout *  labelLayout  =  new  QHBoxLayout ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  labelLayout - > addWidget ( new  QLabel ( labelName ) ,  0 ,  Qt : : AlignLeft ) ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  QLabel *  paramContent  =  new  QLabel ( labelContent ) ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  paramContent - > setStyleSheet ( " color: #aaaaaa " ) ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  labelLayout - > addWidget ( paramContent ,  0 ,  Qt : : AlignRight ) ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  QWidget *  labelWidget  =  new  QWidget ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  labelWidget - > setLayout ( labelLayout ) ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  if  ( label )  * label  =  paramContent ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  return  labelWidget ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					}  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					ParamsToggle : : ParamsToggle ( QString  param ,  QString  title ,  QString  description ,  QString  icon_path ,  QWidget  * parent ) :  QFrame ( parent )  ,  param ( param )  {  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  QHBoxLayout  * layout  =  new  QHBoxLayout ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  layout - > setMargin ( 0 ) ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  layout - > setSpacing ( 50 ) ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  // Parameter image
   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  const  int  img_size  =  80 ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  if  ( icon_path . length ( ) )  {   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    QPixmap  pix ( icon_path ) ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    QLabel  * icon  =  new  QLabel ( ) ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    icon - > setPixmap ( pix . scaledToWidth ( img_size ,  Qt : : SmoothTransformation ) ) ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    icon - > setSizePolicy ( QSizePolicy ( QSizePolicy : : Fixed ,  QSizePolicy : : Fixed ) ) ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    layout - > addWidget ( icon ) ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  }  else  {   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    layout - > addSpacing ( img_size ) ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  }   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  // Name of the parameter
   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  QLabel  * label  =  new  QLabel ( title ) ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  label - > setStyleSheet ( R " (font-size: 50px;) " ) ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  layout - > addWidget ( label ) ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  // toggle switch
   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  toggle  =  new  Toggle ( this ) ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  toggle - > setFixedSize ( 150 ,  100 ) ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  layout - > addWidget ( toggle ) ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  QObject : : connect ( toggle ,  SIGNAL ( stateChanged ( int ) ) ,  this ,  SLOT ( checkboxClicked ( int ) ) ) ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  // set initial state from param
   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  if  ( Params ( ) . read_db_bool ( param . toStdString ( ) . c_str ( ) ) )  {   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    toggle - > togglePosition ( ) ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  }   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  setLayout ( layout ) ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					}  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					void  ParamsToggle : : checkboxClicked ( int  state )  {  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  char  value  =  state  ?  ' 1 ' :  ' 0 ' ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  Params ( ) . write_db_value ( param . toStdString ( ) . c_str ( ) ,  & value ,  1 ) ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					}  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					QWidget  *  toggles_panel ( )  {  
					 
					 
					 
					QWidget  *  toggles_panel ( )  {  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  QVBoxLayout  * toggles_list  =  new  QVBoxLayout ( ) ;   
					 
					 
					 
					  QVBoxLayout  * toggles_list  =  new  QVBoxLayout ( ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  toggles_list - > setMargin ( 50 ) ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  toggles_list - > addWidget ( new  ParamsToggle ( " OpenpilotEnabledToggle " ,   
					 
					 
					 
					  toggles_list - > setMargin ( 50 ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					  toggles_list - > addWidget ( new  ToggleControl ( " OpenpilotEnabledToggle " ,   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                                            " Enable openpilot " ,   
					 
					 
					 
					                                            " Enable openpilot " ,   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                                            " Use the openpilot system for adaptive cruise control and lane keep driver assistance. Your attention is required at all times to use this feature. Changing this setting takes effect when the car is powered off. " ,   
					 
					 
					 
					                                            " Use the openpilot system for adaptive cruise control and lane keep driver assistance. Your attention is required at all times to use this feature. Changing this setting takes effect when the car is powered off. " ,   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                                            " ../assets/offroad/icon_openpilot.png "   
					 
					 
					 
					                                            " ../assets/offroad/icon_openpilot.png "   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                                              ) ) ;   
					 
					 
					 
					                                              ) ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  toggles_list - > addWidget ( horizontal_line ( ) ) ;   
					 
					 
					 
					  toggles_list - > addWidget ( horizontal_line ( ) ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  toggles_list - > addWidget ( new  Params Toggle( " LaneChangeEnabled " ,   
					 
					 
					 
					  toggles_list - > addWidget ( new  ToggleControl ( " LaneChangeEnabled " ,   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                                            " Enable Lane Change Assist " ,   
					 
					 
					 
					                                            " Enable Lane Change Assist " ,   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                                            " Perform assisted lane changes with openpilot by checking your surroundings for safety, activating the turn signal and gently nudging the steering wheel towards your desired lane. openpilot is not capable of checking if a lane change is safe. You must continuously observe your surroundings to use this feature. " ,   
					 
					 
					 
					                                            " Perform assisted lane changes with openpilot by checking your surroundings for safety, activating the turn signal and gently nudging the steering wheel towards your desired lane. openpilot is not capable of checking if a lane change is safe. You must continuously observe your surroundings to use this feature. " ,   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                                            " ../assets/offroad/icon_road.png "   
					 
					 
					 
					                                            " ../assets/offroad/icon_road.png "   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                                              ) ) ;   
					 
					 
					 
					                                              ) ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  toggles_list - > addWidget ( horizontal_line ( ) ) ;   
					 
					 
					 
					  toggles_list - > addWidget ( horizontal_line ( ) ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  toggles_list - > addWidget ( new  Params Toggle( " IsLdwEnabled " ,   
					 
					 
					 
					  toggles_list - > addWidget ( new  ToggleControl ( " IsLdwEnabled " ,   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                                            " Enable Lane Departure Warnings " ,   
					 
					 
					 
					                                            " Enable Lane Departure Warnings " ,   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                                            " Receive alerts to steer back into the lane when your vehicle drifts over a detected lane line without a turn signal activated while driving over 31mph (50kph). " ,   
					 
					 
					 
					                                            " Receive alerts to steer back into the lane when your vehicle drifts over a detected lane line without a turn signal activated while driving over 31mph (50kph). " ,   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                                            " ../assets/offroad/icon_warning.png "   
					 
					 
					 
					                                            " ../assets/offroad/icon_warning.png "   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                                              ) ) ;   
					 
					 
					 
					                                              ) ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  toggles_list - > addWidget ( horizontal_line ( ) ) ;   
					 
					 
					 
					  toggles_list - > addWidget ( horizontal_line ( ) ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  toggles_list - > addWidget ( new  Params Toggle( " IsRHD " ,   
					 
					 
					 
					  toggles_list - > addWidget ( new  ToggleControl ( " IsRHD " ,   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                                            " Enable Right-Hand Drive " ,   
					 
					 
					 
					                                            " Enable Right-Hand Drive " ,   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                                            " Allow openpilot to obey left-hand traffic conventions and perform driver monitoring on right driver seat. " ,   
					 
					 
					 
					                                            " Allow openpilot to obey left-hand traffic conventions and perform driver monitoring on right driver seat. " ,   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                                            " ../assets/offroad/icon_openpilot_mirrored.png "   
					 
					 
					 
					                                            " ../assets/offroad/icon_openpilot_mirrored.png "   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                                            ) ) ;   
					 
					 
					 
					                                            ) ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  toggles_list - > addWidget ( horizontal_line ( ) ) ;   
					 
					 
					 
					  toggles_list - > addWidget ( horizontal_line ( ) ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  toggles_list - > addWidget ( new  Params Toggle( " IsMetric " ,   
					 
					 
					 
					  toggles_list - > addWidget ( new  ToggleControl ( " IsMetric " ,   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                                            " Use Metric System " ,   
					 
					 
					 
					                                            " Use Metric System " ,   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                                            " Display speed in km/h instead of mp/h. " ,   
					 
					 
					 
					                                            " Display speed in km/h instead of mp/h. " ,   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                                            " ../assets/offroad/icon_metric.png "   
					 
					 
					 
					                                            " ../assets/offroad/icon_metric.png "   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                                            ) ) ;   
					 
					 
					 
					                                            ) ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  toggles_list - > addWidget ( horizontal_line ( ) ) ;   
					 
					 
					 
					  toggles_list - > addWidget ( horizontal_line ( ) ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  toggles_list - > addWidget ( new  Params Toggle( " CommunityFeaturesToggle " ,   
					 
					 
					 
					  toggles_list - > addWidget ( new  ToggleControl ( " CommunityFeaturesToggle " ,   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                                            " Enable Community Features " ,   
					 
					 
					 
					                                            " Enable Community Features " ,   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                                            " Use features from the open source community that are not maintained or supported by comma.ai and have not been confirmed to meet the standard safety model. These features include community supported cars and community supported hardware. Be extra cautious when using these features " ,   
					 
					 
					 
					                                            " Use features from the open source community that are not maintained or supported by comma.ai and have not been confirmed to meet the standard safety model. These features include community supported cars and community supported hardware. Be extra cautious when using these features " ,   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                                            " ../assets/offroad/icon_shell.png "   
					 
					 
					 
					                                            " ../assets/offroad/icon_shell.png "   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                                            ) ) ;   
					 
					 
					 
					                                            ) ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  Params Toggle  * record_toggle  =  new  Params Toggle( " RecordFront " ,   
					 
					 
					 
					  ToggleControl  * record_toggle  =  new  ToggleControl ( " RecordFront " ,   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                                            " Record and Upload Driver Camera " ,   
					 
					 
					 
					                                            " Record and Upload Driver Camera " ,   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                                            " Upload data from the driver facing camera and help improve the driver monitoring algorithm. " ,   
					 
					 
					 
					                                            " Upload data from the driver facing camera and help improve the driver monitoring algorithm. " ,   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                                            " ../assets/offroad/icon_network.png " ) ;   
					 
					 
					 
					                                            " ../assets/offroad/icon_network.png " ) ;   
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					 
					@ -132,7 +64,7 @@ QWidget * toggles_panel() { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  toggles_list - > addWidget ( record_toggle ) ;   
					 
					 
					 
					  toggles_list - > addWidget ( record_toggle ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  bool  record_lock  =  Params ( ) . read_db_bool ( " RecordFrontLock " ) ;   
					 
					 
					 
					  bool  record_lock  =  Params ( ) . read_db_bool ( " RecordFrontLock " ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  record_toggle - > toggle - > setEnabled ( ! record_lock ) ;   
					 
					 
					 
					  record_toggle - > setEnabled ( ! record_lock ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  QWidget  * widget  =  new  QWidget ;   
					 
					 
					 
					  QWidget  * widget  =  new  QWidget ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  widget - > setLayout ( toggles_list ) ;   
					 
					 
					 
					  widget - > setLayout ( toggles_list ) ;   
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					 
					@ -140,10 +72,8 @@ QWidget * toggles_panel() { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					}  
					 
					 
					 
					}  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					QWidget  *  device_panel ( )  {  
					 
					 
					 
					QWidget  *  device_panel ( )  {  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  QVBoxLayout  * device_layout  =  new  QVBoxLayout ;   
					 
					 
					 
					  QVBoxLayout  * device_layout  =  new  QVBoxLayout ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  device_layout - > setMargin ( 100 ) ;   
					 
					 
					 
					  device_layout - > setMargin ( 100 ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  device_layout - > setSpacing ( 30 ) ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  Params  params  =  Params ( ) ;   
					 
					 
					 
					  Params  params  =  Params ( ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  std : : vector < std : : pair < std : : string ,  std : : string > >  labels  =  {   
					 
					 
					 
					  std : : vector < std : : pair < std : : string ,  std : : string > >  labels  =  {   
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					 
					@ -158,26 +88,26 @@ QWidget * device_panel() { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  //}
   
					 
					 
					 
					  //}
   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  for  ( auto  & l  :  labels )  {   
					 
					 
					 
					  for  ( auto  & l  :  labels )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    device_layout - > addWidget ( labelWidget ( QString : : fromStdString ( l . first ) ,   
					 
					 
					 
					    device_layout - > addWidget ( new  LabelControl ( QString : : fromStdString ( l . first ) ,   
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					                             QString : : fromStdString ( l . second ) ) ,  0 ,  Qt : : AlignTop ) ;   
					 
					 
					 
					                             QString : : fromStdString ( l . second ) ) ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					  }   
					 
					 
					 
					  }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  QPushButton *  dcam_view  =  new  QPushButton ( " Driver camera view " ) ;   
					 
					 
					 
					  device_layout - > addWidget ( horizontal_line ( ) ) ;   
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					  device_layout - > addWidget ( dcam_view ,  0 ,  Qt : : AlignBottom ) ;   
					 
					 
					 
					
 
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					  device_layout - > addWidget ( horizontal_line ( ) ,  Qt : : AlignBottom ) ;   
					 
					 
					 
					  device_layout - > addWidget ( new  ButtonControl ( " Driver camera view " ,  " PREVIEW " ,   
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					  QObject : : connect ( dcam_view ,  & QPushButton : : released ,  [ = ] ( )  {   
					 
					 
					 
					                                             " Preview the driver facing camera to help optimize device mounting position for best driver monitoring experience. (vehicle must be off) " ,   
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					    Params ( ) . write_db_value ( " IsDriverViewEnabled " ,  " 1 " ,  1 ) ;   
					 
					 
					 
					                                             [ = ] ( )  {  Params ( ) . write_db_value ( " IsDriverViewEnabled " ,  " 1 " ,  1 ) ;  } ) ) ;   
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					  } ) ;   
					 
					 
					 
					
 
				
			 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					  device_layout - > addWidget ( horizontal_line ( ) ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  // TODO: show current calibration values
   
					 
					 
					 
					  // TODO: show current calibration values
   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  QPushButton  * clear_cal_btn  =  new  QPushButton ( " Reset Calibration " ) ;   
					 
					 
					 
					  device_layout - > addWidget ( new  ButtonControl ( " Reset Calibration " ,  " RESET " ,   
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					  device_layout - > addWidget ( clear_cal_btn ,  0 ,  Qt : : AlignBottom ) ;   
					 
					 
					 
					                                             " openpilot requires the device to be mounted within 4° left or right and within 5° up or down. openpilot is continuously calibrating, resetting is rarely required. " ,   
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					  device_layout - > addWidget ( horizontal_line ( ) ,  Qt : : AlignBottom ) ;   
					 
					 
					 
					                                             [ = ] ( )  {   
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					  QObject : : connect ( clear_cal_btn ,  & QPushButton : : released ,  [ = ] ( )  {   
					 
					 
					 
					                                               if  ( ConfirmationDialog : : confirm ( " Are you sure you want to reset calibration? " ) )  {   
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					    if  ( ConfirmationDialog : : confirm ( " Are you sure you want to reset calibration? " ) )  {   
					 
					 
					 
					                                                 Params ( ) . delete_db_value ( " CalibrationParams " ) ;   
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					      Params ( ) . delete_db_value ( " CalibrationParams " ) ;   
					 
					 
					 
					                                               }   
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					    }   
					 
					 
					 
					                                             } ) ) ;   
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					  } ) ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  // power buttons
   
					 
					 
					 
					  // power buttons
   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
	
		
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
					 
					@ -243,12 +173,11 @@ void DeveloperPanel::showEvent(QShowEvent *event) { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    if  ( labels . size ( )  >  i )  {   
					 
					 
					 
					    if  ( labels . size ( )  >  i )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					      labels [ i ] - > setText ( QString : : fromStdString ( value ) ) ;   
					 
					 
					 
					      labels [ i ] - > setText ( QString : : fromStdString ( value ) ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    }  else  {   
					 
					 
					 
					    }  else  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					      QLabel  * label  =  nullptr ;   
					 
					 
					 
					      labels . push_back ( new  LabelControl ( name ,  QString : : fromStdString ( value ) ) ) ;   
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					      layout ( ) - > addWidget ( labelWidget ( name ,  QString : : fromStdString ( value ) ,  & label )  ) ;   
					 
					 
					 
					      layout ( ) - > addWidget ( labels [ i ]  ) ;   
				
			 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					      if  ( i  <  ( dev_params . size ( )  -  1 ) )  {   
					 
					 
					 
					      if  ( i  <  ( dev_params . size ( )  -  1 ) )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        layout ( ) - > addWidget ( horizontal_line ( ) ) ;   
					 
					 
					 
					        layout ( ) - > addWidget ( horizontal_line ( ) ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					      }   
					 
					 
					 
					      }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					      labels . push_back ( label ) ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    }   
					 
					 
					 
					    }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  }   
					 
					 
					 
					  }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					}  
					 
					 
					 
					}  
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					 
					@ -262,39 +191,27 @@ QWidget * network_panel(QWidget * parent) { 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  // TODO: can probably use the ndk for this
   
					 
					 
					 
					  // TODO: can probably use the ndk for this
   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  // simple wifi + tethering buttons
   
					 
					 
					 
					  // simple wifi + tethering buttons
   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  std : : vector < std : : pair < const  char * ,  const  char * > >  btns  =  {   
					 
					 
					 
					  std : : vector < std : : pair < const  char * ,  const  char * > >  btns  =  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    { " Open WiFi Settings " ,  " am start -n com.android.settings/.wifi.WifiPickerActivity  \
   
					 
					 
					 
					    { " WiFi Settings " ,  " am start -n com.android.settings/.wifi.WifiPickerActivity  \
   
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					                            - a  android . net . wifi . PICK_WIFI_NETWORK  \
  
					 
					 
					 
					                       - a  android . net . wifi . PICK_WIFI_NETWORK  \
  
				
			 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					                       - - ez  extra_prefs_show_button_bar  true  \
  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					                       - - es  extra_prefs_set_next_text  ' ' " },   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					    { " Tethering Settings " ,  " am start -n com.android.settings/.TetherSettings  \
   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                            - - ez  extra_prefs_show_button_bar  true  \
  
					 
					 
					 
					                            - - ez  extra_prefs_show_button_bar  true  \
  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                            - - es  extra_prefs_set_next_text  ' ' " },   
					 
					 
					 
					                            - - es  extra_prefs_set_next_text  ' ' " },   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    { " Open Tethering Settings " ,  " am start -n com.android.settings/.TetherSettings  \
   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                                 - - ez  extra_prefs_show_button_bar  true  \
  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                                 - - es  extra_prefs_set_next_text  ' ' " },   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  } ;   
					 
					 
					 
					  } ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  for  ( auto  & b  :  btns )  {   
					 
					 
					 
					  for  ( auto  & b  :  btns )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    QPushButton  * btn  =  new  QPushButton ( b . first ) ;   
					 
					 
					 
					    layout - > addWidget ( new  ButtonControl ( b . first ,  " OPEN " ,  " " ,  [ = ] ( )  {  std : : system ( b . second ) ;  } ) ) ;   
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					    layout - > addWidget ( btn ,  0 ,  Qt : : AlignTop ) ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    QObject : : connect ( btn ,  & QPushButton : : released ,  [ = ] ( )  {  std : : system ( b . second ) ;  } ) ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					  }   
					 
					 
					 
					  }   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  layout - > addStretch ( 1 ) ;   
					 
					 
					 
					  layout - > addStretch ( 1 ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  QWidget  * w  =  new  QWidget ;   
					 
					 
					 
					  QWidget  * w  =  new  QWidget ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  w - > setLayout ( layout ) ;   
					 
					 
					 
					  w - > setLayout ( layout ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  w - > setStyleSheet ( R " (   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    QPushButton  {   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					      padding :  0 ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					      height :  120 px ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					      border - radius :  15 px ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					      background - color :  # 393939 ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    }   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  ) " );   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					# else  
					 
					 
					 
					# else  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  Networking  * w  =  new  Networking ( parent ) ;   
					 
					 
					 
					  Networking  * w  =  new  Networking ( parent ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					# endif  
					 
					 
					 
					# endif  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  return  w ;   
					 
					 
					 
					  return  w ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					}  
					 
					 
					 
					}  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					SettingsWindow : : SettingsWindow ( QWidget  * parent )  :  QFrame ( parent )  {  
					 
					 
					 
					SettingsWindow : : SettingsWindow ( QWidget  * parent )  :  QFrame ( parent )  {  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  // setup two main layouts
   
					 
					 
					 
					  // setup two main layouts
   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					  QVBoxLayout  * sidebar_layout  =  new  QVBoxLayout ( ) ;   
					 
					 
					 
					  QVBoxLayout  * sidebar_layout  =  new  QVBoxLayout ( ) ;