@ -15,12 +15,11 @@
# include "common/params.h"
# include "common/params.h"
# include "common/util.h"
# include "common/util.h"
# include "selfdrive/hardware/hw.h"
# include "selfdrive/hardware/hw.h"
# include "home.hpp"
QWidget * toggles_panel ( ) {
QWidget * toggles_panel ( ) {
QVBoxLayout * toggles_list = new QVBoxLayout ( ) ;
QVBoxLayout * toggles_list = new QVBoxLayout ( ) ;
toggles_list - > setMargin ( 50 ) ;
toggles_list - > addWidget ( new ParamControl ( " OpenpilotEnabledToggle " ,
toggles_list - > addWidget ( new ParamControl ( " 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. " ,
@ -62,7 +61,7 @@ QWidget * toggles_panel() {
" In this mode openpilot will ignore lanelines and just drive how it thinks a human would. " ,
" In this mode openpilot will ignore lanelines and just drive how it thinks a human would. " ,
" ../assets/offroad/icon_road.png " ) ) ;
" ../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 ) ;
record_toggle - > setEnabled ( ! record_lock ) ;
QWidget * widget = new QWidget ;
QWidget * widget = new QWidget ;
@ -72,64 +71,54 @@ QWidget * toggles_panel() {
DevicePanel : : DevicePanel ( QWidget * parent ) : QWidget ( parent ) {
DevicePanel : : DevicePanel ( QWidget * parent ) : QWidget ( parent ) {
QVBoxLayout * device_layout = new QVBoxLayout ;
QVBoxLayout * device_layout = new QVBoxLayout ;
device_layout - > setMargin ( 100 ) ;
Params params = Params ( ) ;
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 ( horizontal_line ( ) ) ;
device_layout - > addWidget ( new ButtonControl ( " Driver Camera " , " PREVIEW " ,
QString serial = QString : : fromStdString ( params . get ( " HardwareSerial " , false ) ) ;
" Preview the driver facing camera to help optimize device mounting position for best driver monitoring experience. (vehicle must be off) " ,
device_layout - > addWidget ( new LabelControl ( " Serial " , serial ) ) ;
[ = ] ( ) { Params ( ) . write_db_value ( " IsDriverViewEnabled " , " 1 " , 1 ) ; } ) ) ;
device_layout - > addWidget ( horizontal_line ( ) ) ;
// offroad-only buttons
QList < ButtonControl * > offroad_btns ;
// TODO: show current calibration values
offroad_btns . append ( new ButtonControl ( " Driver Camera " , " PREVIEW " ,
device_layout - > addWidget ( new ButtonControl ( " Reset Calibration " , " RESET " ,
" Preview the driver facing camera to help optimize device mounting position for best driver monitoring experience. (vehicle must be off) " ,
" 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. " ,
[ = ] ( ) {
[ = ] ( ) {
Params ( ) . putBool ( " IsDriverViewEnabled " , true ) ;
GLWindow : : ui_state . scene . driver_view = true ; }
) ) ;
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? " ) ) {
if ( ConfirmationDialog : : confirm ( " Are you sure you want to reset calibration? " ) ) {
Params ( ) . delete_db_value ( " CalibrationParams " ) ;
Params ( ) . remov e( " CalibrationParams " ) ;
}
}
} ) ) ;
} ) ) ;
device_layout - > addWidget ( horizontal_line ( ) ) ;
offroad_btns . append ( new ButtonControl ( " Review Training Guide " , " REVIEW " ,
" Review the rules, features, and limitations of openpilot " , [ = ] ( ) {
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? " ) ) {
if ( ConfirmationDialog : : confirm ( " Are you sure you want to review the training guide? " ) ) {
Params ( ) . delete_db_valu e( " CompletedTrainingVersion " ) ;
Params ( ) . remove ( " CompletedTrainingVersion " ) ;
emit reviewTrainingGuide ( ) ;
emit reviewTrainingGuide ( ) ;
}
}
} ) ) ;
} ) ) ;
device_layout - > addWidget ( horizontal_line ( ) ) ;
QString brand = params . getBool ( " Passive " ) ? " dashcam " : " openpilot " ;
offroad_btns . append ( new ButtonControl ( " Uninstall " + brand , " UNINSTALL " , " " , [ = ] ( ) {
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? " ) ) {
if ( ConfirmationDialog : : confirm ( " Are you sure you want to uninstall? " ) ) {
Params ( ) . write_db_value ( " DoUninstall " , " 1 " ) ;
Params ( ) . putBool ( " DoUninstall " , true ) ;
}
}
} ) ) ;
} ) ) ;
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
// power buttons
QHBoxLayout * power_layout = new QHBoxLayout ( ) ;
QHBoxLayout * power_layout = new QHBoxLayout ( ) ;
power_layout - > setSpacing ( 30 ) ;
power_layout - > setSpacing ( 30 ) ;
@ -166,16 +155,15 @@ DevicePanel::DevicePanel(QWidget* parent) : QWidget(parent) {
DeveloperPanel : : DeveloperPanel ( QWidget * parent ) : QFrame ( parent ) {
DeveloperPanel : : DeveloperPanel ( QWidget * parent ) : QFrame ( parent ) {
QVBoxLayout * main_layout = new QVBoxLayout ( this ) ;
QVBoxLayout * main_layout = new QVBoxLayout ( this ) ;
main_layout - > setMargin ( 100 ) ;
setLayout ( main_layout ) ;
setLayout ( main_layout ) ;
setStyleSheet ( R " (QLabel {font-size: 50px;}) " ) ;
setStyleSheet ( R " (QLabel {font-size: 50px;}) " ) ;
}
}
void DeveloperPanel : : showEvent ( QShowEvent * event ) {
void DeveloperPanel : : showEvent ( QShowEvent * event ) {
Params params = Params ( ) ;
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 = {
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 Branch " , params . get ( " GitBranch " , false ) } ,
{ " Git Commit " , params . get ( " GitCommit " , false ) . substr ( 0 , 10 ) } ,
{ " Git Commit " , params . get ( " GitCommit " , false ) . substr ( 0 , 10 ) } ,
{ " Panda Firmware " , params . get ( " PandaFirmwareHex " , false ) } ,
{ " Panda Firmware " , params . get ( " PandaFirmwareHex " , false ) } ,
@ -200,25 +188,15 @@ void DeveloperPanel::showEvent(QShowEvent *event) {
QWidget * network_panel ( QWidget * parent ) {
QWidget * network_panel ( QWidget * parent ) {
# ifdef QCOM
# ifdef QCOM
QVBoxLayout * layout = new QVBoxLayout ;
QVBoxLayout * layout = new QVBoxLayout ;
layout - > setMargin ( 100 ) ;
layout - > setSpacing ( 30 ) ;
layout - > setSpacing ( 30 ) ;
// simple wifi + tethering buttons
// 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 ' ' " ;
layout - > addWidget ( new ButtonControl ( " WiFi Settings " , " OPEN " , " " ,
layout - > addWidget ( new ButtonControl ( " WiFi Settings " , " OPEN " , " " ,
[ = ] ( ) { std : : system ( launch_wifi ) ; } ) ) ;
[ = ] ( ) { HardwareEon : : launch_wifi ( ) ; } ) ) ;
layout - > addWidget ( horizontal_line ( ) ) ;
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 " , " " ,
layout - > addWidget ( new ButtonControl ( " Tethering Settings " , " OPEN " , " " ,
[ = ] ( ) { std : : system ( launch_tethering ) ; } ) ) ;
[ = ] ( ) { HardwareEon : : launch_tethering ( ) ; } ) ) ;
layout - > addWidget ( horizontal_line ( ) ) ;
layout - > addWidget ( horizontal_line ( ) ) ;
// SSH key management
// SSH key management
@ -241,6 +219,10 @@ SettingsWindow::SettingsWindow(QWidget *parent) : QFrame(parent) {
QVBoxLayout * sidebar_layout = new QVBoxLayout ( ) ;
QVBoxLayout * sidebar_layout = new QVBoxLayout ( ) ;
sidebar_layout - > setMargin ( 0 ) ;
sidebar_layout - > setMargin ( 0 ) ;
panel_widget = new QStackedWidget ( ) ;
panel_widget = new QStackedWidget ( ) ;
panel_widget - > setStyleSheet ( R " (
border - radius : 30 px ;
background - color : # 292929 ;
) " );
// close button
// close button
QPushButton * close_btn = new QPushButton ( " X " ) ;
QPushButton * close_btn = new QPushButton ( " X " ) ;
@ -273,7 +255,7 @@ SettingsWindow::SettingsWindow(QWidget *parent) : QFrame(parent) {
QPushButton * btn = new QPushButton ( name ) ;
QPushButton * btn = new QPushButton ( name ) ;
btn - > setCheckable ( true ) ;
btn - > setCheckable ( true ) ;
btn - > setStyleSheet ( R " (
btn - > setStyleSheet ( R " (
* {
QPushButton {
color : grey ;
color : grey ;
border : none ;
border : none ;
background : none ;
background : none ;
@ -290,8 +272,25 @@ SettingsWindow::SettingsWindow(QWidget *parent) : QFrame(parent) {
nav_btns - > addButton ( btn ) ;
nav_btns - > addButton ( btn ) ;
sidebar_layout - > addWidget ( btn , 0 , Qt : : AlignRight ) ;
sidebar_layout - > addWidget ( btn , 0 , Qt : : AlignRight ) ;
panel_widget - > addWidget ( panel ) ;
panel - > setContentsMargins ( 50 , 25 , 50 , 25 ) ;
QObject : : connect ( btn , & QPushButton : : released , [ = , w = panel ] ( ) {
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 ) ;
panel_widget - > setCurrentWidget ( w ) ;
} ) ;
} ) ;
}
}
@ -305,25 +304,7 @@ SettingsWindow::SettingsWindow(QWidget *parent) : QFrame(parent) {
sidebar_widget - > setLayout ( sidebar_layout ) ;
sidebar_widget - > setLayout ( sidebar_layout ) ;
sidebar_widget - > setFixedWidth ( 500 ) ;
sidebar_widget - > setFixedWidth ( 500 ) ;
settings_layout - > addWidget ( sidebar_widget ) ;
settings_layout - > addWidget ( sidebar_widget ) ;
settings_layout - > addWidget ( panel_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 ) ;
setLayout ( settings_layout ) ;
setLayout ( settings_layout ) ;
setStyleSheet ( R " (
setStyleSheet ( R " (