chore(users): fixed all the possible bugs and enhanced ui.

This commit is contained in:
Eshan Roy (Eshanized)
2024-05-01 17:36:10 +05:30
parent 1fd824db60
commit bcad1cc806
4 changed files with 72 additions and 70 deletions

View File

@@ -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<int, QProcess::ExitStatus>::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<int, QProcess::ExitStatus>::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<int, QProcess::ExitStatus>::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<int, QProcess::ExitStatus>::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<int, QProcess::ExitStatus>::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<int, QProcess::ExitStatus>::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<int, QProcess::ExitStatus>::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<int, QProcess::ExitStatus>::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);

View File

@@ -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);

View File

@@ -18,7 +18,7 @@
<item row="0" column="0">
<widget class="QStackedWidget" name="mainStackedWidget">
<property name="currentIndex">
<number>0</number>
<number>2</number>
</property>
<widget class="QWidget" name="textWidget">
<layout class="QGridLayout" name="gridLayout_2">
@@ -30,12 +30,15 @@
<property name="standardButtons">
<set>QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set>
</property>
<property name="centerButtons">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QStackedWidget" name="textStackedWidget">
<property name="currentIndex">
<number>4</number>
<number>3</number>
</property>
<widget class="QWidget" name="textWidget_welcome">
<layout class="QGridLayout" name="gridLayout_3">
@@ -48,7 +51,7 @@
</sizepolicy>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:24pt;&quot;&gt;Welcome to Snigdha OS!&lt;/span&gt;&lt;br/&gt;This interactive assistant will help you set up your system to your wishes.&lt;/p&gt;&lt;p&gt;Before the setup assistant can continue, initial system updates have to be applied and the Snigdha OS Assistant updated.&lt;br/&gt;Make sure you have a working internet connection before you continue.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:24pt;&quot;&gt;Welcome to &lt;b&gt;Snigdha OS!&lt;/b&gt;😊&lt;/span&gt;&lt;br/&gt;&lt;b&gt;Snigdha OS Assistant&lt;/b&gt; will help you set up your system to your wishes.&lt;/p&gt;&lt;p&gt;Before the Snigdha OS Assistant can continue, initial system updates have to be applied and the Snigdha OS Assistant is updated.&lt;br/&gt;Make sure you have a working internet connection before you continue.&lt;/p&gt;&lt;/br&gt;This application is inspired from &lt;b&gt;Garuda Linux&lt;/b&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::TextFormat::RichText</enum>
@@ -77,7 +80,7 @@
</sizepolicy>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:20pt;&quot;&gt;Update failed!&lt;/span&gt;&lt;br/&gt;System update failed. Try again?&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;https://forum.snigdhaos.org&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#754ffe;&quot;&gt;Visit the Snigdha OS Forum&lt;/span&gt;&lt;/a&gt; if further issues occour.&lt;br/&gt;Finishing this update via the Snigdha OS Assistant is highly recommended in order to apply release-specific fixes.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:20pt;&quot;&gt;Update failed!😒&lt;/span&gt;&lt;br/&gt;System update failed. Try again?😬&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;https://forum.snigdhaos.org&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#754ffe;&quot;&gt;Visit the Snigdha OS Forum&lt;/span&gt;&lt;/a&gt; if further issues occour.&lt;br/&gt;Finishing this update via the Snigdha OS Assistant is highly recommended in order to apply release-specific fixes.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::TextFormat::RichText</enum>
@@ -173,7 +176,7 @@
</sizepolicy>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:20pt;&quot;&gt;Success!&lt;/span&gt;&lt;br/&gt;Your system is set up and ready to go!&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;https://forum.snigdhais.org&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#754ffe;&quot;&gt;Visit the Snigdha OS Forum&lt;/span&gt;&lt;/a&gt; if issues occour.&lt;br/&gt;&lt;a href=&quot;https://snigdhaos.org/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#754ffe;&quot;&gt;Snigdha OS Documentation&lt;br/&gt;&lt;/span&gt;&lt;/a&gt;&lt;a href=&quot;https://wiki.archlinux.org/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#754ffe;&quot;&gt;Arch Linux Wiki&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:20pt;&quot;&gt;Success!😎&lt;/span&gt;&lt;br/&gt;Your system is set up and ready to go!&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;https://forum.snigdhais.org&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#754ffe;&quot;&gt;Visit the Snigdha OS Forum&lt;/span&gt;&lt;/a&gt; if issues occour.&lt;br/&gt;&lt;a href=&quot;https://snigdhaos.org/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#754ffe;&quot;&gt;Snigdha OS Documentation&lt;br/&gt;&lt;/span&gt;&lt;/a&gt;&lt;a href=&quot;https://wiki.archlinux.org/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#754ffe;&quot;&gt;Arch Linux Wiki&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::TextFormat::RichText</enum>
@@ -205,7 +208,7 @@
</sizepolicy>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:20pt;&quot;&gt;Before you go&lt;/span&gt;&lt;/p&gt;&lt;p&gt;You can restart the setup assistant at any time.&lt;br/&gt;Finishing the Snigdha OS Assistant is recommended in order to apply release-specific fixes.&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;https://forum.snigdhaos.org&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#754ffe;&quot;&gt;Visit the Snigdha OS Forum&lt;/span&gt;&lt;/a&gt; if issues occour.&lt;br/&gt;&lt;a href=&quot;https://snigdhaos.org/documentation/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#754ffe;&quot;&gt;Snigdha OS Documentation&lt;br/&gt;&lt;/span&gt;&lt;/a&gt;&lt;a href=&quot;https://wiki.archlinux.org/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#754ffe;&quot;&gt;Arch Linux Wiki&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:20pt;&quot;&gt;Before you go🧸&lt;/span&gt;&lt;/p&gt;&lt;p&gt;You can restart the Snigdha OS Assistant at any time.&lt;br/&gt;Finishing the Snigdha OS Assistant is recommended in order to apply release-specific fixes.&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;https://forum.snigdhaos.org&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#754ffe;&quot;&gt;Visit the Snigdha OS Forum&lt;/span&gt;&lt;/a&gt; if issues occour.&lt;br/&gt;&lt;a href=&quot;https://snigdhaos.org/documentation/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#754ffe;&quot;&gt;Snigdha OS Documentation&lt;br/&gt;&lt;/span&gt;&lt;/a&gt;&lt;a href=&quot;https://wiki.archlinux.org/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#754ffe;&quot;&gt;Arch Linux Wiki&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::TextFormat::RichText</enum>
@@ -321,7 +324,6 @@
</property>
<property name="packages" stdset="0">
<stringlist notr="true">
<string>garuda-blackarch</string>
<string>blackarch-keyring</string>
<string>blackarch-menus</string>
<string>blackarch-mirrorlist</string>

View File

@@ -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."