2013-05-17 22:23:22 +05:30
|
|
|
/* 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-16 04:24:39 +05:30
|
|
|
#include "MultiMC.h"
|
2013-05-17 22:23:22 +05:30
|
|
|
#include "lwjglselectdialog.h"
|
|
|
|
#include "ui_lwjglselectdialog.h"
|
|
|
|
|
2013-08-17 17:10:51 +05:30
|
|
|
#include "logic/lists/LwjglVersionList.h"
|
2013-05-17 22:23:22 +05:30
|
|
|
|
|
|
|
LWJGLSelectDialog::LWJGLSelectDialog(QWidget *parent) :
|
|
|
|
QDialog(parent),
|
|
|
|
ui(new Ui::LWJGLSelectDialog)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
ui->labelStatus->setVisible(false);
|
2013-09-16 04:24:39 +05:30
|
|
|
auto lwjgllist = MMC->lwjgllist();
|
2013-09-22 07:51:36 +05:30
|
|
|
ui->lwjglListView->setModel(lwjgllist.data());
|
2013-05-17 22:23:22 +05:30
|
|
|
|
2013-09-22 07:51:36 +05:30
|
|
|
connect(lwjgllist.data(), SIGNAL(loadingStateUpdated(bool)), SLOT(loadingStateUpdated(bool)));
|
|
|
|
connect(lwjgllist.data(), SIGNAL(loadListFailed(QString)), SLOT(loadingFailed(QString)));
|
2013-09-16 04:24:39 +05:30
|
|
|
loadingStateUpdated(lwjgllist->isLoading());
|
2013-05-17 22:23:22 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
LWJGLSelectDialog::~LWJGLSelectDialog()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString LWJGLSelectDialog::selectedVersion() const
|
|
|
|
{
|
2013-09-16 04:24:39 +05:30
|
|
|
return MMC->lwjgllist()->data(
|
2013-05-17 22:23:22 +05:30
|
|
|
ui->lwjglListView->selectionModel()->currentIndex(),
|
|
|
|
Qt::DisplayRole).toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void LWJGLSelectDialog::on_refreshButton_clicked()
|
|
|
|
{
|
2013-09-16 04:24:39 +05:30
|
|
|
if (!MMC->lwjgllist()->isLoading())
|
|
|
|
MMC->lwjgllist()->loadList();
|
2013-05-17 22:23:22 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
void LWJGLSelectDialog::loadingStateUpdated(bool loading)
|
|
|
|
{
|
|
|
|
setEnabled(!loading);
|
|
|
|
if (loading)
|
|
|
|
{
|
2013-09-08 21:43:09 +05:30
|
|
|
ui->labelStatus->setText(tr("Loading LWJGL version list..."));
|
2013-05-17 22:23:22 +05:30
|
|
|
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);
|
|
|
|
}
|