@ -15,12 +15,11 @@
# include "common/params.h"
# include "common/util.h"
# include "selfdrive/hardware/hw.h"
# include "home.hpp"
QWidget * toggles_panel ( ) {
QVBoxLayout * toggles_list = new QVBoxLayout ( ) ;
toggles_list - > setMargin ( 50 ) ;
toggles_list - > addWidget ( new ParamControl ( " OpenpilotEnabledToggle " ,
" 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. " ,
@ -62,7 +61,7 @@ QWidget * toggles_panel() {
" In this mode openpilot will ignore lanelines and just drive how it thinks a human would. " ,
" ../assets/offroad/icon_road.png " ) ) ;
bool record_lock = Params ( ) . read_db_b ool( " RecordFrontLock " ) ;
bool record_lock = Params ( ) . getB ool( " RecordFrontLock " ) ;
record_toggle - > setEnabled ( ! record_lock ) ;
QWidget * widget = new QWidget ;
@ -72,63 +71,53 @@ QWidget * toggles_panel() {
DevicePanel : : DevicePanel ( QWidget * parent ) : QWidget ( parent ) {
QVBoxLayout * device_layout = new QVBoxLayout ;
device_layout - > setMargin ( 100 ) ;
Params params = Params ( ) ;
std : : vector < std : : pair < std : : string , std : : string > > labels = {
{ " Dongle ID " , params . get ( " DongleId " , false ) } ,
} ;
// get serial number
//std::string cmdline = util::read_file("/proc/cmdline");
//auto delim = cmdline.find("serialno=");
//if (delim != std::string::npos) {
// labels.push_back({"Serial", cmdline.substr(delim, cmdline.find(" ", delim))});
//}
for ( auto & l : labels ) {
device_layout - > addWidget ( new LabelControl ( QString : : fromStdString ( l . first ) ,
QString : : fromStdString ( l . second ) ) ) ;
}
QString dongle = QString : : fromStdString ( params . get ( " DongleId " , false ) ) ;
device_layout - > addWidget ( new LabelControl ( " Dongle ID " , dongle ) ) ;
device_layout - > addWidget ( horizontal_line ( ) ) ;
device_layout - > addWidget ( new ButtonControl ( " Driver Camera " , " PREVIEW " ,
" 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 ) ; } ) ) ;
QString serial = QString : : fromStdString ( params . get ( " HardwareSerial " , false ) ) ;
device_layout - > addWidget ( new LabelControl ( " Serial " , serial ) ) ;
device_layout - > addWidget ( horizontal_line ( ) ) ;
// offroad-only buttons
QList < ButtonControl * > offroad_btns ;
// TODO: show current calibration values
device_layout - > addWidget ( new ButtonControl ( " Reset Calibration " , " RESET " ,
" 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. " ,
[ = ] ( ) {
if ( ConfirmationDialog : : confirm ( " Are you sure you want to reset calibration? " ) ) {
Params ( ) . delete_db_value ( " CalibrationParams " ) ;
}
} ) ) ;
offroad_btns . append ( new ButtonControl ( " Driver Camera " , " PREVIEW " ,
" Preview the driver facing camera to help optimize device mounting position for best driver monitoring experience. (vehicle must be off) " ,
[ = ] ( ) {
Params ( ) . putBool ( " IsDriverViewEnabled " , true ) ;
GLWindow : : ui_state . scene . driver_view = true ; }
) ) ;
device_layout - > addWidget ( horizontal_line ( ) ) ;
offroad_btns . append ( new ButtonControl ( " Reset Calibration " , " RESET " ,
" 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. " , [ = ] ( ) {
if ( ConfirmationDialog : : confirm ( " Are you sure you want to reset calibration? " ) ) {
Params ( ) . remove ( " CalibrationParams " ) ;
}
} ) ) ;
device_layout - > addWidget ( new ButtonControl ( " Review Training Guide " , " REVIEW " ,
" Review the rules, features, and limitations of openpilot " ,
[ = ] ( ) {
if ( ConfirmationDialog : : confirm ( " Are you sure you want to review the training guide? " ) ) {
Params ( ) . delete_db_value ( " CompletedTrainingVersion " ) ;
emit reviewTrainingGuide ( ) ;
}
} ) ) ;
offroad_btns . append ( new ButtonControl ( " Review Training Guide " , " REVIEW " ,
" Review the rules, features, and limitations of openpilot " , [ = ] ( ) {
if ( ConfirmationDialog : : confirm ( " Are you sure you want to review the training guide? " ) ) {
Params ( ) . remove ( " CompletedTrainingVersion " ) ;
emit reviewTrainingGuide ( ) ;
}
} ) ) ;
device_layout - > addWidget ( horizontal_line ( ) ) ;
QString brand = params . getBool ( " Passive " ) ? " dashcam " : " openpilot " ;
offroad_btns . append ( new ButtonControl ( " Uninstall " + brand , " UNINSTALL " , " " , [ = ] ( ) {
if ( ConfirmationDialog : : confirm ( " Are you sure you want to uninstall? " ) ) {
Params ( ) . putBool ( " DoUninstall " , true ) ;
}
} ) ) ;
QString brand = params . read_db_bool ( " Passive " ) ? " dashcam " : " openpilot " ;
device_layout - > addWidget ( new ButtonControl ( " Uninstall " + brand , " UNINSTALL " ,
" " ,
[ = ] ( ) {
if ( ConfirmationDialog : : confirm ( " Are you sure you want to uninstall? " ) ) {
Params ( ) . write_db_value ( " DoUninstall " , " 1 " ) ;
}
} ) ) ;
for ( auto & btn : offroad_btns ) {
device_layout - > addWidget ( horizontal_line ( ) ) ;
QObject : : connect ( parent , SIGNAL ( offroadTransition ( bool ) ) , btn , SLOT ( setEnabled ( bool ) ) ) ;
device_layout - > addWidget ( btn ) ;
}
// power buttons
QHBoxLayout * power_layout = new QHBoxLayout ( ) ;
@ -166,16 +155,15 @@ DevicePanel::DevicePanel(QWidget* parent) : QWidget(parent) {
DeveloperPanel : : DeveloperPanel ( QWidget * parent ) : QFrame ( parent ) {
QVBoxLayout * main_layout = new QVBoxLayout ( this ) ;
main_layout - > setMargin ( 100 ) ;
setLayout ( main_layout ) ;
setStyleSheet ( R " (QLabel {font-size: 50px;}) " ) ;
}
void DeveloperPanel : : showEvent ( QShowEvent * event ) {
Params params = Params ( ) ;
std : : string brand = params . read_db_b ool( " Passive " ) ? " dashcam " : " openpilot " ;
std : : string brand = params . getB ool( " Passive " ) ? " dashcam " : " openpilot " ;
QList < QPair < QString , std : : string > > dev_params = {
{ " Version " , brand + " v " + params . get ( " Version " , false ) } ,
{ " Version " , brand + " v " + params . get ( " Version " , false ) . substr ( 0 , 14 ) } ,
{ " Git Branch " , params . get ( " GitBranch " , false ) } ,
{ " Git Commit " , params . get ( " GitCommit " , false ) . substr ( 0 , 10 ) } ,
{ " Panda Firmware " , params . get ( " PandaFirmwareHex " , false ) } ,
@ -200,25 +188,15 @@ void DeveloperPanel::showEvent(QShowEvent *event) {
QWidget * network_panel ( QWidget * parent ) {
# ifdef QCOM
QVBoxLayout * layout = new QVBoxLayout ;
layout - > setMargin ( 100 ) ;
layout - > setSpacing ( 30 ) ;
// simple wifi + tethering buttons
const char * launch_wifi = " am start -n com.android.settings/.wifi.WifiPickerActivity \
- a android . net . wifi . PICK_WIFI_NETWORK \
- - ez extra_prefs_show_button_bar true \
- - es extra_prefs_set_next_text ' ' " ;
// wifi + tethering buttons
layout - > addWidget ( new ButtonControl ( " WiFi Settings " , " OPEN " , " " ,
[ = ] ( ) { std : : system ( launch_wifi ) ; } ) ) ;
[ = ] ( ) { HardwareEon : : launch_wifi ( ) ; } ) ) ;
layout - > addWidget ( horizontal_line ( ) ) ;
const char * launch_tethering = " am start -n com.android.settings/.TetherSettings \
- - ez extra_prefs_show_button_bar true \
- - es extra_prefs_set_next_text ' ' " ;
layout - > addWidget ( new ButtonControl ( " Tethering Settings " , " OPEN " , " " ,
[ = ] ( ) { std : : system ( launch_tethering ) ; } ) ) ;
[ = ] ( ) { HardwareEon : : launch_tethering ( ) ; } ) ) ;
layout - > addWidget ( horizontal_line ( ) ) ;
// SSH key management
@ -241,6 +219,10 @@ SettingsWindow::SettingsWindow(QWidget *parent) : QFrame(parent) {
QVBoxLayout * sidebar_layout = new QVBoxLayout ( ) ;
sidebar_layout - > setMargin ( 0 ) ;
panel_widget = new QStackedWidget ( ) ;
panel_widget - > setStyleSheet ( R " (
border - radius : 30 px ;
background - color : # 292929 ;
) " );
// close button
QPushButton * close_btn = new QPushButton ( " X " ) ;
@ -273,7 +255,7 @@ SettingsWindow::SettingsWindow(QWidget *parent) : QFrame(parent) {
QPushButton * btn = new QPushButton ( name ) ;
btn - > setCheckable ( true ) ;
btn - > setStyleSheet ( R " (
* {
QPushButton {
color : grey ;
border : none ;
background : none ;
@ -290,8 +272,25 @@ SettingsWindow::SettingsWindow(QWidget *parent) : QFrame(parent) {
nav_btns - > addButton ( btn ) ;
sidebar_layout - > addWidget ( btn , 0 , Qt : : AlignRight ) ;
panel_widget - > addWidget ( panel ) ;
QObject : : connect ( btn , & QPushButton : : released , [ = , w = panel ] ( ) {
panel - > setContentsMargins ( 50 , 25 , 50 , 25 ) ;
QScrollArea * panel_frame = new QScrollArea ;
panel_frame - > setWidget ( panel ) ;
panel_frame - > setWidgetResizable ( true ) ;
panel_frame - > setVerticalScrollBarPolicy ( Qt : : ScrollBarAlwaysOff ) ;
panel_frame - > setHorizontalScrollBarPolicy ( Qt : : ScrollBarAlwaysOff ) ;
panel_frame - > setStyleSheet ( " background-color:transparent; " ) ;
QScroller * scroller = QScroller : : scroller ( panel_frame - > viewport ( ) ) ;
auto sp = scroller - > scrollerProperties ( ) ;
sp . setScrollMetric ( QScrollerProperties : : VerticalOvershootPolicy , QVariant : : fromValue < QScrollerProperties : : OvershootPolicy > ( QScrollerProperties : : OvershootAlwaysOff ) ) ;
scroller - > grabGesture ( panel_frame - > viewport ( ) , QScroller : : LeftMouseButtonGesture ) ;
scroller - > setScrollerProperties ( sp ) ;
panel_widget - > addWidget ( panel_frame ) ;
QObject : : connect ( btn , & QPushButton : : released , [ = , w = panel_frame ] ( ) {
panel_widget - > setCurrentWidget ( w ) ;
} ) ;
}
@ -305,25 +304,7 @@ SettingsWindow::SettingsWindow(QWidget *parent) : QFrame(parent) {
sidebar_widget - > setLayout ( sidebar_layout ) ;
sidebar_widget - > setFixedWidth ( 500 ) ;
settings_layout - > addWidget ( sidebar_widget ) ;
panel_frame = new QScrollArea ;
panel_frame - > setWidget ( panel_widget ) ;
panel_frame - > setWidgetResizable ( true ) ;
panel_frame - > setVerticalScrollBarPolicy ( Qt : : ScrollBarAlwaysOff ) ;
panel_frame - > setHorizontalScrollBarPolicy ( Qt : : ScrollBarAlwaysOff ) ;
panel_frame - > setStyleSheet ( R " (
border - radius : 30 px ;
background - color : # 292929 ;
) " );
settings_layout - > addWidget ( panel_frame ) ;
// setup panel scrolling
QScroller * scroller = QScroller : : scroller ( panel_frame ) ;
auto sp = scroller - > scrollerProperties ( ) ;
sp . setScrollMetric ( QScrollerProperties : : FrameRate , QVariant : : fromValue < QScrollerProperties : : FrameRates > ( QScrollerProperties : : Fps30 ) ) ;
sp . setScrollMetric ( QScrollerProperties : : VerticalOvershootPolicy , QVariant : : fromValue < QScrollerProperties : : OvershootPolicy > ( QScrollerProperties : : OvershootAlwaysOff ) ) ;
scroller - > setScrollerProperties ( sp ) ;
scroller - > grabGesture ( panel_frame - > viewport ( ) , QScroller : : LeftMouseButtonGesture ) ;
settings_layout - > addWidget ( panel_widget ) ;
setLayout ( settings_layout ) ;
setStyleSheet ( R " (