Skip to content

Commit

Permalink
Added loading gif when user selects yes after hitting Wifi/Ethernet t…
Browse files Browse the repository at this point in the history
…oggle
  • Loading branch information
erinharrington-12 committed Jun 14, 2024
1 parent 743a864 commit 9fc9e4d
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 3 deletions.
1 change: 1 addition & 0 deletions include/botui/Create3Widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ private slots:
void toggleChanged();
void indexChanged(int index);
void run();
void rebootBox();

private:
Ui::Create3Widget *ui;
Expand Down
65 changes: 62 additions & 3 deletions src/Create3Widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,20 @@
#include <stdio.h>
#include <iostream>
#include <QRegularExpression>
#include <QProcess>
#include <QHeaderView>
#include <cmath>
#include <QTimer>
#include <QPainter>
#include <QItemDelegate>
#include "RootController.h"
#include "kipr/create3/create3.capnp.h"
#include <QMessageBox>
#include <QLabel>
#include <QMovie>
#include <QSize>
#include <QProcess>
#include <QVBoxLayout>
#include <QGridLayout>
int exampleIndex;
QStringList programList;

Expand Down Expand Up @@ -110,6 +116,7 @@ void Create3Widget::toggleChanged()
QString ipOutput = QString(output);

qDebug() << "IP OUTPUT: " << ipOutput; // Get current IP output


if (ipOutput.contains("192.168.125.1"))
{
Expand All @@ -129,6 +136,7 @@ void Create3Widget::toggleChanged()
}
else
{
rebootBox();
QProcess process;
process.startDetached("/bin/sh", QStringList() << "/home/kipr/wombat-os/configFiles/create3_interface_swap.sh"
<< "eth");
Expand All @@ -151,13 +159,66 @@ void Create3Widget::toggleChanged()
}
else
{
rebootBox();
QProcess process;
process.startDetached("/bin/sh", QStringList() << "/home/kipr/wombat-os/configFiles/create3_interface_swap.sh"
<< "wifi");
}
}
}

void Create3Widget::rebootBox()
{

QMessageBox msgBox(this);
msgBox.setWindowTitle("Reboot");
msgBox.setText("Rebooting now...");

// msgBox.setText("Rebooting...");
msgBox.setMaximumSize(500, 480);
// msgBox.setStyleSheet("QLabel{min-width: 450px; min-height: 280px;}");
msgBox.setStandardButtons(QMessageBox::NoButton);

QLabel *gifLabel = new QLabel();
QLabel *messageLabel = new QLabel(msgBox.text());

QGridLayout *msgBoxLayout = qobject_cast<QGridLayout *>(msgBox.layout());

msgBoxLayout->setVerticalSpacing(0);

QWidget *container = new QWidget();
QVBoxLayout *vLayout = new QVBoxLayout(container);

vLayout->addWidget(gifLabel);

vLayout->addWidget(messageLabel);
vLayout->setAlignment(Qt::AlignCenter);
gifLabel->setAlignment(Qt::AlignCenter);
messageLabel->setAlignment(Qt::AlignCenter);

msgBoxLayout->setSpacing(0);
vLayout->setSpacing(10);

container->setLayout(vLayout);

if (msgBoxLayout)
{
msgBoxLayout->addWidget(container, 0, 0, 1, msgBoxLayout->columnCount());
}

gifLabel->move(200, -50);
gifLabel->resize(400, 1100);

QMovie *movie = new QMovie("://qml/botguy_noMargin.gif");
movie->setScaledSize(QSize(200, 240));
gifLabel->setMovie(movie);
movie->start();
gifLabel->show();

msgBox.setText("");
msgBox.exec();
}

QString Create3Widget::getIP()
{

Expand Down Expand Up @@ -545,8 +606,6 @@ void Create3Widget::run()
create3_wait();

printf("Done!\n");


}
// catch (const std::exception &e)
catch (const std::exception &e)
Expand Down

0 comments on commit 9fc9e4d

Please sign in to comment.