@@ -21,6 +21,20 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
2121 QProcess removeFiles;
2222 removeFiles.start (" rm devID.txt currStep.txt cmdOut.txt path.txt file.iso file.img.dmg file.img" );
2323 removeFiles.waitForFinished ();
24+ QFile findDevs (" findDevs.sh" );
25+ if (findDevs.exists ()) findDevs.resize (0 );
26+ if (findDevs.open (QIODevice::WriteOnly)) {
27+ QTextStream out (&findDevs);
28+ out << " diskutil list | grep /dev/disk" ;
29+ findDevs.close ();
30+ }
31+ else {
32+ QMessageBox msgBox;
33+ msgBox.setText (" ERROR: Could Not Write To findDevs.sh\n Application Might Not Be In /Applications Or In Your Desktop Or Documents Folder?" );
34+ msgBox.exec ();
35+ ui->plainTextEdit ->appendPlainText (" ERROR: Could Not Write To findDevs.sh\n Application Might Not Be In /Applications Or In Your Desktop Or Documents Folder?" );
36+ setEnabled (false );
37+ }
2438 QStringList itemsToAdd;
2539 itemsToAdd << " 1. Ubuntu 16.04 (64-Bit)" ;
2640 itemsToAdd << " 2. Debian 8.6.0 (64-Bit, Internet Installer)" ;
@@ -35,9 +49,7 @@ MainWindow::~MainWindow() {
3549 delete process;
3650 delete guihandler;
3751}
38- void MainWindow::setLineLog (QString str) {
39- ui->log ->setText (str);
40- }
52+ void MainWindow::setLineLog (QString str) { ui->log ->setText (str); }
4153void MainWindow::setBigLog (QString str) {
4254 ui->plainTextEdit ->clear ();
4355 ui->plainTextEdit ->appendPlainText (str);
@@ -70,7 +82,7 @@ void MainWindow::on_startStop_clicked() {
7082 }
7183 if (ui->devID ->currentText ().contains (" ERROR" )) {
7284 ui->plainTextEdit ->appendPlainText (" Please Put A USB Drive Into The Computer And Refresh The Device List." );
73- ui->plainTextEdit ->appendPlainText (" If You Got An Error Saying Something Is Not Right, Do Not Continue, And Email The Developer." );
85+ ui->plainTextEdit ->appendPlainText (" If You Got An Error Saying Something Is Not Right, Do Not Continue, And Contact The Developer." );
7486 return ;
7587 }
7688 if (osPath == " " ) {
@@ -101,14 +113,27 @@ void MainWindow::on_startStop_clicked() {
101113
102114 // Print osPath to path.txt
103115 QFile location (" path.txt" );
104- location.open (QIODevice::WriteOnly);
105- QTextStream (&location) << osPath;
106- location.close ();
116+ if (location.open (QIODevice::WriteOnly)) {
117+ QTextStream (&location) << osPath;
118+ location.close ();
119+ }
120+ else {
121+ ui->log ->setText (" ERROR While Passing File Path" );
122+ ui->plainTextEdit ->appendPlainText (" \n An error has occured while passing the file path to the script." );
123+ ui->plainTextEdit ->appendPlainText (" Application Might Not Be In /Applications Or In Your Desktop Or Documents Folder?" );
124+ return ;
125+ }
107126 // Print rdisk device to devID.txt
108127 QFile dev (" devID.txt" );
109- dev.open (QIODevice::WriteOnly);
110- QTextStream (&dev) << " /dev/rdisk" << devIDToInt ();
111- dev.close ();
128+ if (dev.open (QIODevice::WriteOnly)) {
129+ QTextStream (&dev) << " /dev/rdisk" << devIDToInt ();
130+ dev.close ();
131+ }
132+ else {
133+ ui->log ->setText (" ERROR While Passing The Device ID" );
134+ ui->plainTextEdit ->appendPlainText (" \n An error has occured while passing the Device ID to the script." );
135+ ui->plainTextEdit ->appendPlainText (" Application Might Not Be In /Applications Or In Your Desktop Or Documents Folder?" );
136+ }
112137
113138 process->start (" osascript" , QStringList () << " -e" << " do shell script \" sh run.sh\" with administrator privileges" );
114139 guihandler->start ();
@@ -135,16 +160,30 @@ void MainWindow::on_refreshDevs_clicked() {
135160 }
136161 QStringList devs;
137162 QString currLine = " " ;
138- for (int i = 0 ; i < allDevs.length (); ++i) {
139- QString c = allDevs.at (i);
140- if (c != " :" ) {
163+ if (allDevs.contains (" :" )) {
164+ for (int i = 0 ; i < allDevs.length (); ++i) {
165+ QString c = allDevs.at (i);
166+ if (c != " :" ) {
167+ if (c != " \n " ) {
168+ currLine += c;
169+ }
170+ }
171+ else {
172+ devs.append (currLine);
173+ currLine = " " ;
174+ }
175+ }
176+ }
177+ else {
178+ for (int i = 0 ; i < allDevs.length (); ++i) {
179+ QString c = allDevs.at (i);
141180 if (c != " \n " ) {
142181 currLine += c;
143182 }
144- }
145- else {
146- devs. append ( currLine) ;
147- currLine = " " ;
183+ else {
184+ devs. append (currLine);
185+ currLine = " " ;
186+ }
148187 }
149188 }
150189 if (!ui->allowNonExtern ->isChecked ()) {
0 commit comments