2013-05-17 16:53:22 +00: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
|
2013-11-04 01:53:05 +00:00
|
|
|
*
|
2013-05-17 16:53:22 +00:00
|
|
|
* 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 22:54:39 +00:00
|
|
|
#include "MultiMC.h"
|
2013-11-04 01:53:05 +00:00
|
|
|
#include "LwjglSelectDialog.h"
|
|
|
|
#include "ui_LwjglSelectDialog.h"
|
|
|
|
#include "gui/Platform.h"
|
2013-05-17 16:53:22 +00:00
|
|
|
|
2013-08-17 11:40:51 +00:00
|
|
|
#include "logic/lists/LwjglVersionList.h"
|
2013-05-17 16:53:22 +00:00
|
|
|
|
2013-11-04 01:53:05 +00:00
|
|
|
LWJGLSelectDialog::LWJGLSelectDialog(QWidget *parent)
|
|
|
|
: QDialog(parent), ui(new Ui::LWJGLSelectDialog)
|
2013-05-17 16:53:22 +00:00
|
|
|
{
|
2013-11-04 01:53:05 +00:00
|
|
|
MultiMCPlatform::fixWM_CLASS(this);
|
2013-05-17 16:53:22 +00:00
|
|
|
ui->setupUi(this);
|
|
|
|
ui->labelStatus->setVisible(false);
|
2013-09-15 22:54:39 +00:00
|
|
|
auto lwjgllist = MMC->lwjgllist();
|
2013-10-05 23:13:40 +00:00
|
|
|
ui->lwjglListView->setModel(lwjgllist.get());
|
2013-11-04 01:53:05 +00:00
|
|
|
|
|
|
|
connect(lwjgllist.get(), SIGNAL(loadingStateUpdated(bool)),
|
|
|
|
SLOT(loadingStateUpdated(bool)));
|
2013-10-05 23:13:40 +00:00
|
|
|
connect(lwjgllist.get(), SIGNAL(loadListFailed(QString)), SLOT(loadingFailed(QString)));
|
2013-09-15 22:54:39 +00:00
|
|
|
loadingStateUpdated(lwjgllist->isLoading());
|
2013-05-17 16:53:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
LWJGLSelectDialog::~LWJGLSelectDialog()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString LWJGLSelectDialog::selectedVersion() const
|
|
|
|
{
|
2013-11-04 01:53:05 +00:00
|
|
|
return MMC->lwjgllist()
|
|
|
|
->data(ui->lwjglListView->selectionModel()->currentIndex(), Qt::DisplayRole)
|
|
|
|
.toString();
|
2013-05-17 16:53:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LWJGLSelectDialog::on_refreshButton_clicked()
|
|
|
|
{
|
2013-09-15 22:54:39 +00:00
|
|
|
if (!MMC->lwjgllist()->isLoading())
|
|
|
|
MMC->lwjgllist()->loadList();
|
2013-05-17 16:53:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LWJGLSelectDialog::loadingStateUpdated(bool loading)
|
|
|
|
{
|
|
|
|
setEnabled(!loading);
|
|
|
|
if (loading)
|
|
|
|
{
|
2013-09-08 16:13:09 +00:00
|
|
|
ui->labelStatus->setText(tr("Loading LWJGL version list..."));
|
2013-05-17 16:53:22 +00: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);
|
|
|
|
}
|