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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,6 +75,8 @@ class JavaPage : public QWidget, public BasePage {
|
||||
void on_javaDownloadBtn_clicked();
|
||||
void on_addExtraPathButton_clicked();
|
||||
void on_removeExtraPathButton_clicked();
|
||||
void on_downloadJavaButton_clicked();
|
||||
void on_removeJavaButton_clicked();
|
||||
void on_maxMemSpinBox_valueChanged(int i);
|
||||
void checkerFinished();
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="general">
|
||||
<attribute name="title">
|
||||
@@ -317,6 +317,56 @@
|
||||
<string>Management</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Downloaded Java Versions</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="VersionSelectWidget" name="managedJavaList" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="managedJavaBtnLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="downloadJavaButton">
|
||||
<property name="text">
|
||||
<string>Download</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="removeJavaButton">
|
||||
<property name="text">
|
||||
<string>Remove</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="extraJavaPathsGroupBox">
|
||||
<property name="title">
|
||||
@@ -379,6 +429,14 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>VersionSelectWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>ui/widgets/VersionSelectWidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>minMemSpinBox</tabstop>
|
||||
<tabstop>maxMemSpinBox</tabstop>
|
||||
|
||||
Reference in New Issue
Block a user