mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2025-06-12 05:07:46 +02:00
Added management for downloaded javas from prism
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
@ -36,6 +36,8 @@
|
||||
|
||||
#include "JavaPage.h"
|
||||
#include "JavaCommon.h"
|
||||
#include "java/JavaInstall.h"
|
||||
#include "ui/dialogs/CustomMessageBox.h"
|
||||
#include "ui/java/JavaDownloader.h"
|
||||
#include "ui_JavaPage.h"
|
||||
|
||||
@ -59,6 +61,11 @@ JavaPage::JavaPage(QWidget* parent) : QWidget(parent), ui(new Ui::JavaPage)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->managedJavaList->initialize(new JavaInstallList(this, true));
|
||||
ui->managedJavaList->selectCurrent();
|
||||
ui->managedJavaList->setEmptyString(tr("No java versions are currently available in the meta"));
|
||||
ui->managedJavaList->setEmptyErrorString(tr("Couldn't load or download the java version lists!"));
|
||||
|
||||
loadSettings();
|
||||
updateThresholds();
|
||||
}
|
||||
@ -244,3 +251,36 @@ void JavaPage::on_removeExtraPathButton_clicked()
|
||||
}
|
||||
APPLICATION->settings()->set("JavaExtraSearchPaths", m_extra_paths->stringList());
|
||||
}
|
||||
|
||||
void JavaPage::on_downloadJavaButton_clicked()
|
||||
{
|
||||
on_javaDownloadBtn_clicked();
|
||||
}
|
||||
|
||||
void JavaPage::on_removeJavaButton_clicked()
|
||||
{
|
||||
auto version = ui->managedJavaList->selectedVersion();
|
||||
auto dcast = std::dynamic_pointer_cast<JavaInstall>(version);
|
||||
if (!dcast) {
|
||||
return;
|
||||
}
|
||||
QDir dir(APPLICATION->javaPath());
|
||||
|
||||
auto entries = dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
for (auto& entry : entries) {
|
||||
if (dcast->path.startsWith(entry.canonicalFilePath())) {
|
||||
auto response = CustomMessageBox::selectable(this, tr("Confirm Deletion"),
|
||||
tr("You are about to remove \"%1\" java version.\n"
|
||||
"Are you sure?")
|
||||
.arg(entry.fileName()),
|
||||
QMessageBox::Warning, QMessageBox::Yes | QMessageBox::No, QMessageBox::No)
|
||||
->exec();
|
||||
|
||||
if (response == QMessageBox::Yes) {
|
||||
FS::deletePath(entry.canonicalFilePath());
|
||||
ui->managedJavaList->loadList();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user