2015-02-03 03:55:30 +05:30
|
|
|
/* Copyright 2013-2015 MultiMC Contributors
|
2013-05-17 22:23:22 +05:30
|
|
|
*
|
|
|
|
* 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 07:23:05 +05:30
|
|
|
*
|
2013-05-17 22:23:22 +05:30
|
|
|
* 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-11-04 07:23:05 +05:30
|
|
|
#include "LwjglSelectDialog.h"
|
|
|
|
#include "ui_LwjglSelectDialog.h"
|
|
|
|
#include "gui/Platform.h"
|
2013-05-17 22:23:22 +05:30
|
|
|
|
2014-05-09 00:50:10 +05:30
|
|
|
#include "logic/LwjglVersionList.h"
|
2013-05-17 22:23:22 +05:30
|
|
|
|
2013-11-04 07:23:05 +05:30
|
|
|
LWJGLSelectDialog::LWJGLSelectDialog(QWidget *parent)
|
|
|
|
: QDialog(parent), ui(new Ui::LWJGLSelectDialog)
|
2013-05-17 22:23:22 +05:30
|
|
|
{
|
2013-11-04 07:23:05 +05:30
|
|
|
MultiMCPlatform::fixWM_CLASS(this);
|
2013-05-17 22:23:22 +05:30
|
|
|
ui->setupUi(this);
|
|
|
|
ui->labelStatus->setVisible(false);
|
2013-09-16 04:24:39 +05:30
|
|
|
auto lwjgllist = MMC->lwjgllist();
|
2013-10-06 04:43:40 +05:30
|
|
|
ui->lwjglListView->setModel(lwjgllist.get());
|
2013-11-04 07:23:05 +05:30
|
|
|
|
|
|
|
connect(lwjgllist.get(), SIGNAL(loadingStateUpdated(bool)),
|
|
|
|
SLOT(loadingStateUpdated(bool)));
|
2013-10-06 04:43:40 +05:30
|
|
|
connect(lwjgllist.get(), 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-11-04 07:23:05 +05:30
|
|
|
return MMC->lwjgllist()
|
|
|
|
->data(ui->lwjglListView->selectionModel()->currentIndex(), Qt::DisplayRole)
|
|
|
|
.toString();
|
2013-05-17 22:23:22 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|