2013-05-17 17:53:22 +01:00
|
|
|
/* Copyright 2013 MultiMC Contributors
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2013-09-15 23:54:39 +01:00
|
|
|
#include "MultiMC.h"
|
2013-05-17 17:53:22 +01:00
|
|
|
#include "lwjglselectdialog.h"
|
|
|
|
#include "ui_lwjglselectdialog.h"
|
|
|
|
|
2013-08-17 12:40:51 +01:00
|
|
|
#include "logic/lists/LwjglVersionList.h"
|
2013-05-17 17:53:22 +01:00
|
|
|
|
|
|
|
LWJGLSelectDialog::LWJGLSelectDialog(QWidget *parent) :
|
|
|
|
QDialog(parent),
|
|
|
|
ui(new Ui::LWJGLSelectDialog)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
ui->labelStatus->setVisible(false);
|
2013-09-15 23:54:39 +01:00
|
|
|
auto lwjgllist = MMC->lwjgllist();
|
2013-10-06 00:13:40 +01:00
|
|
|
ui->lwjglListView->setModel(lwjgllist.get());
|
2013-05-17 17:53:22 +01:00
|
|
|
|
2013-10-06 00:13:40 +01:00
|
|
|
connect(lwjgllist.get(), SIGNAL(loadingStateUpdated(bool)), SLOT(loadingStateUpdated(bool)));
|
|
|
|
connect(lwjgllist.get(), SIGNAL(loadListFailed(QString)), SLOT(loadingFailed(QString)));
|
2013-09-15 23:54:39 +01:00
|
|
|
loadingStateUpdated(lwjgllist->isLoading());
|
2013-05-17 17:53:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
LWJGLSelectDialog::~LWJGLSelectDialog()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString LWJGLSelectDialog::selectedVersion() const
|
|
|
|
{
|
2013-09-15 23:54:39 +01:00
|
|
|
return MMC->lwjgllist()->data(
|
2013-05-17 17:53:22 +01:00
|
|
|
ui->lwjglListView->selectionModel()->currentIndex(),
|
|
|
|
Qt::DisplayRole).toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void LWJGLSelectDialog::on_refreshButton_clicked()
|
|
|
|
{
|
2013-09-15 23:54:39 +01:00
|
|
|
if (!MMC->lwjgllist()->isLoading())
|
|
|
|
MMC->lwjgllist()->loadList();
|
2013-05-17 17:53:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void LWJGLSelectDialog::loadingStateUpdated(bool loading)
|
|
|
|
{
|
|
|
|
setEnabled(!loading);
|
|
|
|
if (loading)
|
|
|
|
{
|
2013-09-08 17:13:09 +01:00
|
|
|
ui->labelStatus->setText(tr("Loading LWJGL version list..."));
|
2013-05-17 17:53:22 +01:00
|
|
|
ui->labelStatus->setStyleSheet("QLabel { color: black; }");
|
|
|
|
}
|
|
|
|
ui->labelStatus->setVisible(loading);
|
|
|
|
}
|
|
|
|
|
|
|
|
void LWJGLSelectDialog::loadingFailed(QString error)
|
|
|
|
{
|
|
|
|
ui->labelStatus->setText(error);
|
|
|
|
ui->labelStatus->setStyleSheet("QLabel { color: red; }");
|
|
|
|
ui->labelStatus->setVisible(true);
|
|
|
|
}
|