Skip to content
This repository was archived by the owner on Mar 14, 2020. It is now read-only.

Commit 1432283

Browse files
author
ETCG
committed
Version 3
1 parent 2311af4 commit 1432283

13 files changed

Lines changed: 236 additions & 103 deletions

File tree

.DS_Store

6 KB
Binary file not shown.
9.31 KB
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
diskutil list | grep /dev/disk &> connectedDevs.txt
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
echo $USER &> username.txt
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
rm *.txt
3+
rm file*

source/.DS_Store

0 Bytes
Binary file not shown.

source/findDevs.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
diskutil list | grep /dev/disk &> connectedDevs.txt

source/findUsername.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
echo $USER &> username.txt

source/mainwindow.cpp

Lines changed: 77 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ MainWindow::MainWindow(QWidget *parent) :
1919
connect(guihandler,SIGNAL(setBigLog(QString)),this,SLOT(setBigLog(QString)));
2020
connect(guihandler,SIGNAL(autoScroll()),this,SLOT(autoScroll()));
2121
connect(process,SIGNAL(finished(int,QProcess::ExitStatus)),guihandler,SLOT(done(int,QProcess::ExitStatus)));
22-
isoPath = "";
22+
osPath = "";
23+
on_refreshDevs_clicked();
24+
QProcess removeFiles;
25+
removeFiles.start("sh removeFiles.sh");
26+
removeFiles.waitForFinished();
2327
}
2428
MainWindow::~MainWindow() {
2529
delete ui;
@@ -41,7 +45,7 @@ void MainWindow::done(int exitCode, QProcess::ExitStatus exitStatus) {
4145
}
4246
else {
4347
ui->log->setText("Process Finished.");
44-
ui->plainTextEdit->appendPlainText("\n\nProcess Finished.");
48+
ui->plainTextEdit->appendPlainText("\nProcess Finished.");
4549
}
4650
}
4751
void MainWindow::on_ubuntu_clicked() {
@@ -54,13 +58,29 @@ void MainWindow::on_debian_clicked() {
5458
ui->plainTextEdit->appendPlainText("Failed To Open URL.");
5559
}
5660
}
57-
void MainWindow::on_openFile_clicked() {
58-
isoPath = QFileDialog::getOpenFileName(this,tr("Select An Operating System (ISO)"),"/Users/","ISO (*.iso)");
59-
ui->pathReadOut->setText(isoPath);
61+
void MainWindow::on_openISO_clicked() {
62+
QProcess getUsername;
63+
getUsername.start("sh findUsername.sh");
64+
getUsername.waitForFinished();
65+
QFile file("username.txt");
66+
file.open(QIODevice::ReadOnly);
67+
QTextStream in(&file);
68+
osPath = QFileDialog::getOpenFileName(this,tr("Select An Operating System File"),"/Users/" + in.readLine() + "/Downloads","ISO (*.iso)");
69+
ui->pathReadOut->setText(osPath);
70+
}
71+
void MainWindow::on_openIMG_clicked() {
72+
QProcess getUsername;
73+
getUsername.start("sh findUsername.sh");
74+
getUsername.waitForFinished();
75+
QFile file("username.txt");
76+
file.open(QIODevice::ReadOnly);
77+
QTextStream in(&file);
78+
osPath = QFileDialog::getOpenFileName(this,tr("Select An Operating System File"),"/Users/" + in.readLine() + "/Downloads","IMG (*.img)");
79+
ui->pathReadOut->setText(osPath);
6080
}
6181
void MainWindow::on_startStop_clicked() {
62-
if (isoPath == "") {
63-
ui->plainTextEdit->appendPlainText("You need to select an ISO file first.");
82+
if (osPath == "") {
83+
ui->plainTextEdit->appendPlainText("You need to select a file first.");
6484
return;
6585
}
6686
if (hasStarted) {
@@ -70,20 +90,22 @@ void MainWindow::on_startStop_clicked() {
7090
hasStarted = true;
7191
ui->log->setText("Starting...");
7292
ui->startStop->setText("Cancel");
73-
ui->deviceID->setReadOnly(true);
74-
ui->openFile->setEnabled(false);
93+
ui->devID->setEnabled(false);
94+
ui->openISO->setEnabled(false);
95+
ui->openIMG->setEnabled(false);
7596
ui->ubuntu->setEnabled(false);
7697
ui->debian->setEnabled(false);
98+
ui->refreshDevs->setEnabled(false);
7799

78-
//Print isoPath to path.txt
100+
//Print osPath to path.txt
79101
QFile location("path.txt");
80102
location.open(QIODevice::WriteOnly);
81-
QTextStream(&location) << isoPath;
103+
QTextStream(&location) << osPath;
82104
location.close();
83-
//Print "/dev/rdisk" + ui->deviceID->value() to devID.txt
105+
//Print rdisk device to devID.txt
84106
QFile dev("devID.txt");
85107
dev.open(QIODevice::WriteOnly);
86-
QTextStream(&dev) <<"/dev/rdisk" << ui->deviceID->value();
108+
QTextStream(&dev) << "/dev/rdisk" << devIDToInt();
87109
dev.close();
88110

89111
process->start("osascript", QStringList() << "-e" << "do shell script \"sh run.sh\" with administrator privileges");
@@ -94,3 +116,45 @@ void MainWindow::autoScroll() {
94116
c.movePosition(QTextCursor::End);
95117
ui->plainTextEdit->setTextCursor(c);
96118
}
119+
void MainWindow::on_refreshDevs_clicked() {
120+
QProcess getDevs;
121+
getDevs.start("sh findDevs.sh");
122+
getDevs.waitForFinished();
123+
QFile file("connectedDevs.txt");
124+
file.open(QIODevice::ReadOnly);
125+
QTextStream in(&file);
126+
QString allDevs = in.readAll(), currLine = "";
127+
file.close();
128+
QStringList devs;
129+
for (int i = 0; i < allDevs.length(); ++i) {
130+
QString c = allDevs.at(i);
131+
if (c != ":") {
132+
if (c != "\n") {
133+
currLine += c;
134+
}
135+
}
136+
else {
137+
devs.append(currLine);
138+
currLine = "";
139+
}
140+
}
141+
ui->devID->clear();
142+
ui->devID->addItems(devs);
143+
}
144+
QString MainWindow::devIDToInt() {
145+
QString newStr = "";
146+
for (int i = 0; i < ui->devID->currentText().length(); ++i) {
147+
QString curr = ui->devID->currentText().at(i);
148+
if (curr == "0") newStr += "0";
149+
else if (curr == "1") newStr += curr;
150+
else if (curr == "2") newStr += curr;
151+
else if (curr == "3") newStr += curr;
152+
else if (curr == "4") newStr += curr;
153+
else if (curr == "5") newStr += curr;
154+
else if (curr == "6") newStr += curr;
155+
else if (curr == "7") newStr += curr;
156+
else if (curr == "8") newStr += curr;
157+
else if (curr == "9") newStr += curr;
158+
}
159+
return newStr;
160+
}

source/mainwindow.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,19 @@ class MainWindow : public QMainWindow
2020
bool hasStarted;
2121
QProcess *process;
2222
guiHandler *guihandler;
23-
QString isoPath;
23+
QString osPath;
24+
QString devIDToInt();
2425
private slots:
2526
void setLineLog(QString);
2627
void setBigLog(QString);
2728
void done(int,QProcess::ExitStatus);
2829
void on_ubuntu_clicked();
2930
void on_debian_clicked();
30-
void on_openFile_clicked();
3131
void on_startStop_clicked();
3232
void autoScroll();
33+
void on_refreshDevs_clicked();
34+
void on_openISO_clicked();
35+
void on_openIMG_clicked();
3336
};
3437

3538
#endif // MAINWINDOW_H

0 commit comments

Comments
 (0)