mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-06-21 22:12:05 +08:00
UI touchups (#20243)
* do that automatically * move that * catch failures in factory reset Co-authored-by: Comma Device <device@comma.ai>
This commit is contained in:
@@ -68,7 +68,7 @@ void Networking::attemptInitialization(){
|
||||
vlayout->addSpacing(10);
|
||||
}
|
||||
|
||||
wifiWidget = new WifiUI(0, 5, wifi);
|
||||
wifiWidget = new WifiUI(0, wifi);
|
||||
connect(wifiWidget, SIGNAL(connectToNetwork(Network)), this, SLOT(connectToNetwork(Network)));
|
||||
vlayout->addWidget(wifiWidget, 1);
|
||||
|
||||
@@ -264,7 +264,7 @@ void AdvancedNetworking::toggleSSH(int enable) {
|
||||
|
||||
// WifiUI functions
|
||||
|
||||
WifiUI::WifiUI(QWidget *parent, int page_length, WifiManager* wifi) : QWidget(parent), networks_per_page(page_length), wifi(wifi) {
|
||||
WifiUI::WifiUI(QWidget *parent, WifiManager* wifi) : QWidget(parent), wifi(wifi) {
|
||||
vlayout = new QVBoxLayout;
|
||||
|
||||
// Scan on startup
|
||||
@@ -285,8 +285,9 @@ void WifiUI::refresh() {
|
||||
connectButtons = new QButtonGroup(this); // TODO check if this is a leak
|
||||
QObject::connect(connectButtons, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(handleButton(QAbstractButton*)));
|
||||
|
||||
int networks_per_page = height() / 180;
|
||||
|
||||
int i = 0;
|
||||
int countWidgets = 0;
|
||||
int pageCount = (wifi->seen_networks.size() - 1) / networks_per_page;
|
||||
page = std::max(0, std::min(page, pageCount));
|
||||
for (Network &network : wifi->seen_networks) {
|
||||
@@ -298,7 +299,7 @@ void WifiUI::refresh() {
|
||||
if(ssid.length() > 20){
|
||||
ssid = ssid.left(20 - 3) + "…";
|
||||
}
|
||||
|
||||
|
||||
QLabel *ssid_label = new QLabel(ssid);
|
||||
ssid_label->setStyleSheet(R"(
|
||||
font-size: 55px;
|
||||
@@ -328,7 +329,6 @@ void WifiUI::refresh() {
|
||||
if (page * networks_per_page <= i+1 && i+1 < (page + 1) * networks_per_page && i+1 < wifi->seen_networks.size()) {
|
||||
vlayout->addWidget(hline(), 0);
|
||||
}
|
||||
countWidgets++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
@@ -17,11 +17,10 @@ class WifiUI : public QWidget {
|
||||
|
||||
public:
|
||||
int page;
|
||||
explicit WifiUI(QWidget *parent = 0, int page_length = 5, WifiManager* wifi = 0);
|
||||
explicit WifiUI(QWidget *parent = 0, WifiManager* wifi = 0);
|
||||
|
||||
private:
|
||||
WifiManager *wifi = nullptr;
|
||||
int networks_per_page;
|
||||
QVBoxLayout *vlayout;
|
||||
|
||||
QButtonGroup *connectButtons;
|
||||
|
||||
@@ -11,12 +11,20 @@
|
||||
#define NVME "/dev/nvme0n1"
|
||||
|
||||
|
||||
void do_reset() {
|
||||
std::system("sudo umount " NVME);
|
||||
std::system("yes | sudo mkfs.ext4 " NVME);
|
||||
std::system("sudo umount " USERDATA);
|
||||
std::system("yes | sudo mkfs.ext4 " USERDATA);
|
||||
std::system("sudo reboot");
|
||||
bool do_reset() {
|
||||
std::vector<const char*> cmds = {
|
||||
"sudo umount " NVME,
|
||||
"yes | sudo mkfs.ext4 " NVME,
|
||||
"sudo umount " USERDATA,
|
||||
"yes | sudo mkfs.ext4 " USERDATA,
|
||||
"sudo reboot",
|
||||
};
|
||||
|
||||
for (auto &cmd : cmds) {
|
||||
int ret = std::system(cmd);
|
||||
if (ret != 0) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
@@ -58,7 +66,11 @@ int main(int argc, char *argv[]) {
|
||||
confirm_btn->hide();
|
||||
QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
|
||||
#ifdef __aarch64__
|
||||
do_reset();
|
||||
bool ret = do_reset();
|
||||
if (!ret) {
|
||||
body->setText("Reset failed.");
|
||||
cancel_btn->show();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
});
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
#define USER_AGENT "AGNOSSetup-0.1"
|
||||
|
||||
void Setup::download(QString url) {
|
||||
setCurrentIndex(count() - 2);
|
||||
QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
|
||||
setCurrentIndex(count() - 2);
|
||||
|
||||
CURL *curl = curl_easy_init();
|
||||
if (!curl) {
|
||||
@@ -53,7 +53,7 @@ QLabel * title_label(QString text) {
|
||||
|
||||
QWidget * Setup::build_page(QString title, QWidget *content, bool next, bool prev) {
|
||||
QVBoxLayout *main_layout = new QVBoxLayout();
|
||||
main_layout->setContentsMargins(50, 50, 50, 50);
|
||||
main_layout->setMargin(50);
|
||||
main_layout->addWidget(title_label(title), 0, Qt::AlignLeft | Qt::AlignTop);
|
||||
|
||||
main_layout->addWidget(content);
|
||||
|
||||
Reference in New Issue
Block a user