From bcad1cc806b3eff73cb75f28b114ebda290f2c7a Mon Sep 17 00:00:00 2001 From: "Eshan Roy (Eshanized)" Date: Wed, 1 May 2024 17:36:10 +0530 Subject: [PATCH] chore(users): fixed all the possible bugs and enhanced ui. --- qt/snigdhaosassistant.cpp | 112 +++++++++++++-------------- qt/snigdhaosassistant.h | 10 +-- qt/snigdhaosassistant.ui | 16 ++-- usr/lib/snigdhaos-assistant/apply.sh | 4 +- 4 files changed, 72 insertions(+), 70 deletions(-) diff --git a/qt/snigdhaosassistant.cpp b/qt/snigdhaosassistant.cpp index 6ce92e1..a54c41c 100644 --- a/qt/snigdhaosassistant.cpp +++ b/qt/snigdhaosassistant.cpp @@ -70,7 +70,7 @@ void SnigdhaOSAssistant::doInternetUpRequest(){ void SnigdhaOSAssistant::doUpdate(){ - if (qEnvironmentVariableIsSet("SETUP_ASSISTANT_SELFUPDATE")) { + if (qEnvironmentVariableIsSet("SNIGDHAOS_ASSISTANT_SELFUPDATE")) { updateState(State::SELECT); return; } @@ -78,7 +78,7 @@ void SnigdhaOSAssistant::doUpdate(){ QTemporaryFile* file = new QTemporaryFile(this); file->open(); file->setAutoRemove(true); - process->start("/usr/bin/gnome-terminal", QStringList() << QString("sudo pacman -Syyu" + file->fileName() + "\"; read -p 'Press enter to exit'")); + process->start("/usr/lib/snigdhaos/launch-terminal", QStringList() << QString("sudo pacman -Syyu 2>&1 && rm \"" + file->fileName() + "\"; read -p 'Press enter to exit'")); connect(process, QOverload::of(&QProcess::finished), this, [this, process, file](int exitcode, QProcess::ExitStatus status) { process->deleteLater(); file->deleteLater(); @@ -140,7 +140,7 @@ void SnigdhaOSAssistant::doApply(){ setupFile->close(); auto process = new QProcess(this); - process->start("/usr/bin/gnome-terminal", QStringList() << QString("/usr/lib/snigdhaos-assistant/apply.sh \"") + prepareFile->fileName() + "\" \"" + packagesFile->fileName() + "\" \"" + setupFile->fileName() + "\""); + process->start("/usr/lib/snigdhaos/launch-terminal", QStringList() << QString("/usr/lib/snigdhaos-assistant/apply.sh \"") + prepareFile->fileName() + "\" \"" + packagesFile->fileName() + "\" \"" + setupFile->fileName() + "\""); connect(process, QOverload::of(&QProcess::finished), this, [this, process, prepareFile, packagesFile, setupFile](int exitcode, QProcess::ExitStatus status) { process->deleteLater(); prepareFile->deleteLater(); @@ -148,44 +148,44 @@ void SnigdhaOSAssistant::doApply(){ setupFile->deleteLater(); if (exitcode == 0 && !packagesFile->exists()) { - updateState(State::SUCCESS); + updateState(State::SELECT); } else { updateState(State::APPLY_RETRY); } }); } -void SnigdhaOSAssistant::doNvidiaCheck(){ - auto process = new QProcess(this); - process->start("mhwd", QStringList() << "-li" - << "--pci"); - connect(process, QOverload::of(&QProcess::finished), this, [this, process](int exitcode, QProcess::ExitStatus status) { - process->deleteLater(); - if (exitcode == 0 && !QString(process->readAllStandardOutput()).contains("nvidia")) { - auto process2 = new QProcess(this); - process2->start("mhwd", QStringList() << "-l" - << "--pci"); - connect(process2, QOverload::of(&QProcess::finished), this, [this, process2](int exitcode, QProcess::ExitStatus status) { - process2->deleteLater(); - if (exitcode == 0 && QString(process2->readAllStandardOutput()).contains("nvidia")) - updateState(State::NVIDIA); - else - updateState(State::SELECT); - }); - } else { - updateState(State::SELECT); - } - }); -} +// void SnigdhaOSAssistant::doNvidiaCheck(){ +// auto process = new QProcess(this); +// process->start("mhwd", QStringList() << "-li" +// << "--pci"); +// connect(process, QOverload::of(&QProcess::finished), this, [this, process](int exitcode, QProcess::ExitStatus status) { +// process->deleteLater(); +// if (exitcode == 0 && !QString(process->readAllStandardOutput()).contains("nvidia")) { +// auto process2 = new QProcess(this); +// process2->start("mhwd", QStringList() << "-l" +// << "--pci"); +// connect(process2, QOverload::of(&QProcess::finished), this, [this, process2](int exitcode, QProcess::ExitStatus status) { +// process2->deleteLater(); +// if (exitcode == 0 && QString(process2->readAllStandardOutput()).contains("nvidia")) +// updateState(State::NVIDIA); +// else +// updateState(State::SELECT); +// }); +// } else { +// updateState(State::SELECT); +// } +// }); +// } -void SnigdhaOSAssistant::doNvidiaApply(){ - auto process = new QProcess(this); - process->start("/usr/bin/gnome-terminal", QStringList() << "sudo mhwd -a pci nonfree 0300; echo; read -p 'Press enter to exit'"); - connect(process, QOverload::of(&QProcess::finished), this, [this, process](int exitcode, QProcess::ExitStatus status) { - process->deleteLater(); - updateState(State::SELECT); - }); -} +// void SnigdhaOSAssistant::doNvidiaApply(){ +// auto process = new QProcess(this); +// process->start("/usr/lib/snigdhaos/launch-terminal", QStringList() << "sudo mhwd -a pci nonfree 0300; echo; read -p 'Press enter to exit'"); +// connect(process, QOverload::of(&QProcess::finished), this, [this, process](int exitcode, QProcess::ExitStatus status) { +// process->deleteLater(); +// updateState(State::SELECT); +// }); +// } void SnigdhaOSAssistant::populateSelectWidget(){ if (ui->selectWidget_tabs->count() > 1) @@ -280,21 +280,21 @@ void SnigdhaOSAssistant::updateState(State state){ ui->textStackedWidget->setCurrentWidget(ui->textWidget_updateRetry); ui->textWidget_buttonBox->setStandardButtons(QDialogButtonBox::Yes | QDialogButtonBox::No); break; - case State::NVIDIA_CHECK: - ui->mainStackedWidget->setCurrentWidget(ui->waitingWidget); - ui->waitingWidget_text->setText("Checking for NVIDIA drivers..."); - doNvidiaCheck(); - break; - case State::NVIDIA: - ui->mainStackedWidget->setCurrentWidget(ui->textWidget); - ui->textStackedWidget->setCurrentWidget(ui->textWidget_nvidia); - ui->textWidget_buttonBox->setStandardButtons(QDialogButtonBox::Yes | QDialogButtonBox::No); - break; - case State::NVIDIA_APPLY: - ui->mainStackedWidget->setCurrentWidget(ui->waitingWidget); - ui->waitingWidget_text->setText("Installing NVIDIA drivers..."); - doNvidiaApply(); - break; + // case State::NVIDIA_CHECK: + // ui->mainStackedWidget->setCurrentWidget(ui->waitingWidget); + // ui->waitingWidget_text->setText("Checking for NVIDIA drivers..."); + // doNvidiaCheck(); + // break; + // case State::NVIDIA: + // ui->mainStackedWidget->setCurrentWidget(ui->textWidget); + // ui->textStackedWidget->setCurrentWidget(ui->textWidget_nvidia); + // ui->textWidget_buttonBox->setStandardButtons(QDialogButtonBox::Yes | QDialogButtonBox::No); + // break; + // case State::NVIDIA_APPLY: + // ui->mainStackedWidget->setCurrentWidget(ui->waitingWidget); + // ui->waitingWidget_text->setText("Installing NVIDIA drivers..."); + // doNvidiaApply(); + // break; case State::QUIT: ui->mainStackedWidget->setCurrentWidget(ui->textWidget); ui->textStackedWidget->setCurrentWidget(ui->textWidget_quit); @@ -325,7 +325,7 @@ void SnigdhaOSAssistant::updateState(State state){ void SnigdhaOSAssistant::updateState(QString state){ if (state == "POST_UPDATE") - updateState(State::NVIDIA_CHECK); + updateState(State::SELECT); else if (state == "UPDATE_RETRY") updateState(State::UPDATE_RETRY); else @@ -354,12 +354,12 @@ void SnigdhaOSAssistant::on_textWidget_buttonBox_clicked(QAbstractButton* button updateState(State::INTERNET); } break; - case State::NVIDIA: - if (ui->textWidget_buttonBox->standardButton(button) == QDialogButtonBox::Yes) - updateState(State::NVIDIA_APPLY); - else - updateState(State::SELECT); - return; + // case State::NVIDIA: + // if (ui->textWidget_buttonBox->standardButton(button) == QDialogButtonBox::Yes) + // updateState(State::NVIDIA_APPLY); + // else + // updateState(State::SELECT); + // return; case State::APPLY_RETRY: if (ui->textWidget_buttonBox->standardButton(button) == QDialogButtonBox::Yes) { updateState(State::APPLY); diff --git a/qt/snigdhaosassistant.h b/qt/snigdhaosassistant.h index 1fd22f4..04d0ae9 100644 --- a/qt/snigdhaosassistant.h +++ b/qt/snigdhaosassistant.h @@ -28,9 +28,9 @@ public: INTERNET, UPDATE, UPDATE_RETRY, - NVIDIA_CHECK, - NVIDIA, - NVIDIA_APPLY, + // NVIDIA_CHECK, + // NVIDIA, + // NVIDIA_APPLY, SELECT, APPLY, APPLY_RETRY, @@ -52,8 +52,8 @@ private: void doInternetUpRequest(); void doUpdate(); void doApply(); - void doNvidiaCheck(); - void doNvidiaApply(); + // void doNvidiaCheck(); + // void doNvidiaApply(); void populateSelectWidget(); void populateSelectWidget(QString filename, QString label); void updateState(State state); diff --git a/qt/snigdhaosassistant.ui b/qt/snigdhaosassistant.ui index 28c99da..7c7c45b 100644 --- a/qt/snigdhaosassistant.ui +++ b/qt/snigdhaosassistant.ui @@ -18,7 +18,7 @@ - 0 + 2 @@ -30,12 +30,15 @@ QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok + + true + - 4 + 3 @@ -48,7 +51,7 @@ - <html><head/><body><p><span style=" font-size:24pt;">Welcome to Snigdha OS!</span><br/>This interactive assistant will help you set up your system to your wishes.</p><p>Before the setup assistant can continue, initial system updates have to be applied and the Snigdha OS Assistant updated.<br/>Make sure you have a working internet connection before you continue.</p></body></html> + <html><head/><body><p><span style=" font-size:24pt;">Welcome to <b>Snigdha OS!</b>😊</span><br/><b>Snigdha OS Assistant</b> will help you set up your system to your wishes.</p><p>Before the Snigdha OS Assistant can continue, initial system updates have to be applied and the Snigdha OS Assistant is updated.<br/>Make sure you have a working internet connection before you continue.</p></br>This application is inspired from <b>Garuda Linux</b></body></html> Qt::TextFormat::RichText @@ -77,7 +80,7 @@ - <html><head/><body><p><span style=" font-size:20pt;">Update failed!</span><br/>System update failed. Try again?</p><p><a href="https://forum.snigdhaos.org"><span style=" text-decoration: underline; color:#754ffe;">Visit the Snigdha OS Forum</span></a> if further issues occour.<br/>Finishing this update via the Snigdha OS Assistant is highly recommended in order to apply release-specific fixes.</p></body></html> + <html><head/><body><p><span style=" font-size:20pt;">Update failed!😒</span><br/>System update failed. Try again?😬</p><p><a href="https://forum.snigdhaos.org"><span style=" text-decoration: underline; color:#754ffe;">Visit the Snigdha OS Forum</span></a> if further issues occour.<br/>Finishing this update via the Snigdha OS Assistant is highly recommended in order to apply release-specific fixes.</p></body></html> Qt::TextFormat::RichText @@ -173,7 +176,7 @@ - <html><head/><body><p><span style=" font-size:20pt;">Success!</span><br/>Your system is set up and ready to go!</p><p><a href="https://forum.snigdhais.org"><span style=" text-decoration: underline; color:#754ffe;">Visit the Snigdha OS Forum</span></a> if issues occour.<br/><a href="https://snigdhaos.org/"><span style=" text-decoration: underline; color:#754ffe;">Snigdha OS Documentation<br/></span></a><a href="https://wiki.archlinux.org/"><span style=" text-decoration: underline; color:#754ffe;">Arch Linux Wiki</span></a></p></body></html> + <html><head/><body><p><span style=" font-size:20pt;">Success!😎</span><br/>Your system is set up and ready to go!</p><p><a href="https://forum.snigdhais.org"><span style=" text-decoration: underline; color:#754ffe;">Visit the Snigdha OS Forum</span></a> if issues occour.<br/><a href="https://snigdhaos.org/"><span style=" text-decoration: underline; color:#754ffe;">Snigdha OS Documentation<br/></span></a><a href="https://wiki.archlinux.org/"><span style=" text-decoration: underline; color:#754ffe;">Arch Linux Wiki</span></a></p></body></html> Qt::TextFormat::RichText @@ -205,7 +208,7 @@ - <html><head/><body><p><span style=" font-size:20pt;">Before you go</span></p><p>You can restart the setup assistant at any time.<br/>Finishing the Snigdha OS Assistant is recommended in order to apply release-specific fixes.</p><p><a href="https://forum.snigdhaos.org"><span style=" text-decoration: underline; color:#754ffe;">Visit the Snigdha OS Forum</span></a> if issues occour.<br/><a href="https://snigdhaos.org/documentation/"><span style=" text-decoration: underline; color:#754ffe;">Snigdha OS Documentation<br/></span></a><a href="https://wiki.archlinux.org/"><span style=" text-decoration: underline; color:#754ffe;">Arch Linux Wiki</span></a></p></body></html> + <html><head/><body><p><span style=" font-size:20pt;">Before you go🧸</span></p><p>You can restart the Snigdha OS Assistant at any time.<br/>Finishing the Snigdha OS Assistant is recommended in order to apply release-specific fixes.</p><p><a href="https://forum.snigdhaos.org"><span style=" text-decoration: underline; color:#754ffe;">Visit the Snigdha OS Forum</span></a> if issues occour.<br/><a href="https://snigdhaos.org/documentation/"><span style=" text-decoration: underline; color:#754ffe;">Snigdha OS Documentation<br/></span></a><a href="https://wiki.archlinux.org/"><span style=" text-decoration: underline; color:#754ffe;">Arch Linux Wiki</span></a></p></body></html> Qt::TextFormat::RichText @@ -321,7 +324,6 @@ - garuda-blackarch blackarch-keyring blackarch-menus blackarch-mirrorlist diff --git a/usr/lib/snigdhaos-assistant/apply.sh b/usr/lib/snigdhaos-assistant/apply.sh index cd866b0..d6b4667 100755 --- a/usr/lib/snigdhaos-assistant/apply.sh +++ b/usr/lib/snigdhaos-assistant/apply.sh @@ -9,7 +9,7 @@ echo "" echo "Installing packages.." echo "" installable_packages=$(comm -12 <(pacman -Slq | sort) <(sed s/\\s/\\n/g - <$2 | sort)) -sudo pacman -S --needed $installable_packages && rm $2 || { read -p "Error! Press enter to return to setup assistant."; exit; } +sudo pacman -S --needed $installable_packages && rm $2 || { read -p "Error! Press enter to return to Snigdha OS Assistant."; exit; } if [ -e "$3" ]; then echo "" @@ -19,4 +19,4 @@ if [ -e "$3" ]; then fi echo "" -read -p "Press enter to return to setup assistant." +read -p "Press enter to return to Snigdha OS Assistant."