diff --git a/include/botui/Create3Widget.h b/include/botui/Create3Widget.h index d7c0e8af..67bb9ac9 100644 --- a/include/botui/Create3Widget.h +++ b/include/botui/Create3Widget.h @@ -27,6 +27,7 @@ private slots: void sensorList(); void exampleList(); QString getIP(); + void indexChanged(); private: diff --git a/src/Create3Widget.cpp b/src/Create3Widget.cpp index b61fb8df..df19bc64 100644 --- a/src/Create3Widget.cpp +++ b/src/Create3Widget.cpp @@ -30,6 +30,8 @@ class Create3SensorItemDelegate : public QItemDelegate const QPixmap _down; }; +QByteArray output; + Create3Widget::Create3Widget(Device *device, QWidget *parent) : StandardWidget(device, parent), ui(new Ui::Create3Widget), _model(new Create3SensorModel(this)) @@ -41,8 +43,26 @@ Create3Widget::Create3Widget(Device *device, QWidget *parent) // connect(ui->ResetServerButton, SIGNAL(clicked()), SLOT(resetServer())); connect(ui->Create3SensorListButton, SIGNAL(clicked()), SLOT(sensorList())); connect(ui->Create3ExampleProgramButton, SIGNAL(clicked()), SLOT(exampleList())); - ui->create3IP->setText(getIP()); + + QStringList arguments; + arguments << "/home/erin/Desktop/qt6Upgrade/wombat-os/configFiles/create3_server_ip.txt"; + + QProcess *myProcess = new QProcess(parent); + myProcess->start("cat", arguments); + myProcess->waitForFinished(); + output = myProcess->readAllStandardOutput(); + + qDebug() << output; + + QString ipOutput = QString(output); + + if(ipOutput == "192.168.125.1"){ + ui->toggleSwitch->setChecked(false); + } + else if (ipOutput == "192.168.186.3") { + ui->toggleSwitch->setChecked(true); + } } Create3Widget::~Create3Widget() @@ -50,10 +70,25 @@ Create3Widget::~Create3Widget() delete ui; } +void Create3Widget::indexChanged() +{ + + bool isChecked = ui->toggleSwitch->isChecked(); + + if (isChecked) + { + qDebug() << "toggle: Ethernet"; + } + else + { + qDebug() << "toggle: WiFi"; + } +} + QString Create3Widget::getIP() { - // The command to execute + // The command to execute const char *command = "arp -a | grep 'iRobot' | awk -F '[()]' '{print $2}'"; // Open a pipe to the command @@ -81,78 +116,11 @@ QString Create3Widget::getIP() std::cout << "Output:\n" << result << std::endl; - QString output = QString::fromStdString(result); return output; } -// void Create3Widget::resetServer() -// { -// QProcess stopCreate3Service; -// QString stopCommand = "systemctl"; -// QStringList stopArgs = { -// "stop", -// "create3_server.service" -// }; - -// stopCreate3Service.start(stopCommand, stopArgs); -// if(stopCreate3Service.waitForFinished()) -// { -// QByteArray data = stopCreate3Service.readAllStandardOutput(); -// qDebug() << "Create3 Server successfully stopped\n" << data; -// } -// else -// { -// QByteArray data = stopCreate3Service.readAllStandardError(); -// qDebug() << "Create3 Server failed to stop or crashed\n" << data; -// } - -// // Need a command to run between start and stop for some reason for things to work -// QProcess statusCreate3Service; -// QString statusCommand = "systemctl"; -// QStringList statusArgs = { -// "status", -// "create3_server.service", -// "--no-pager" -// }; - -// statusCreate3Service.start(statusCommand, statusArgs); -// if(statusCreate3Service.waitForFinished()) -// { -// QByteArray data = statusCreate3Service.readAllStandardOutput(); -// qDebug() << "Create3 Server status\n" << data; -// } -// else -// { -// QByteArray data = statusCreate3Service.readAllStandardError(); -// qDebug() << "Create3 Server failed to get status\n" << data; -// } - - - -// QProcess startCreate3Service; -// QString startCommand = "systemctl"; -// QStringList startArgs = { -// "start", -// "create3_server.service" -// }; - -// startCreate3Service.start(startCommand, startArgs); -// if(startCreate3Service.waitForFinished()) -// { -// QByteArray data = startCreate3Service.readAllStandardOutput(); -// qDebug() << "Create3 Server successfully started\n" << data; -// } -// else -// { -// QByteArray data = startCreate3Service.readAllStandardError(); -// qDebug() << "Create3 Server failed to start or crashed\n" << data; -// } - -// RootController::ref().dismissWidget(); -// } - void Create3Widget::sensorList() { RootController::ref().presentWidget(new Create3SensorListWidget(device())); diff --git a/ui/Create3Widget.ui b/ui/Create3Widget.ui index fba536f4..a331009b 100644 --- a/ui/Create3Widget.ui +++ b/ui/Create3Widget.ui @@ -129,7 +129,7 @@ QCheckBox::indicator:unchecked{ - 140 + 134 16777215