aboutsummaryrefslogtreecommitdiff
path: root/installer/mainwindow.cpp
diff options
context:
space:
mode:
authorVictor Tran <vicr12345@gmail.com>2018-10-13 19:11:46 +1100
committerVictor Tran <vicr12345@gmail.com>2018-10-13 19:11:46 +1100
commit88837708068dbbaa6c965a8026ddf80487b2d7d8 (patch)
treea34bb6d45aedc2d8ac8d8c98e4abb57d89b88337 /installer/mainwindow.cpp
parenta6bf3d213523f73bf889ccaaf787a107c3d52774 (diff)
downloadtheInstaller-88837708068dbbaa6c965a8026ddf80487b2d7d8.tar.gz
theInstaller-88837708068dbbaa6c965a8026ddf80487b2d7d8.tar.bz2
theInstaller-88837708068dbbaa6c965a8026ddf80487b2d7d8.zip
Add licenses
Diffstat (limited to 'installer/mainwindow.cpp')
-rw-r--r--installer/mainwindow.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/installer/mainwindow.cpp b/installer/mainwindow.cpp
index 46e8bee..a739455 100644
--- a/installer/mainwindow.cpp
+++ b/installer/mainwindow.cpp
@@ -4,6 +4,7 @@
#include <QSettings>
#include <QDirIterator>
#include <QFileDialog>
+#include <QJsonArray>
extern float getDPIScaling();
@@ -15,6 +16,8 @@ MainWindow::MainWindow(QWidget *parent) :
this->setFixedSize(this->size() * getDPIScaling());
backgroundImage = QIcon(":/background.svg").pixmap(this->size());
+ licenseWidget = new LicenseWidget(this);
+ licenseWidget->hide();
ui->topSpacer1->changeSize(ui->topSpacer1->sizeHint().width(), ui->topSpacer1->sizeHint().height() * getDPIScaling(), QSizePolicy::Preferred, QSizePolicy::Fixed);
ui->topSpacer2->changeSize(ui->topSpacer2->sizeHint().width(), ui->topSpacer2->sizeHint().height() * getDPIScaling(), QSizePolicy::Preferred, QSizePolicy::Fixed);
@@ -23,6 +26,8 @@ MainWindow::MainWindow(QWidget *parent) :
ui->topSpacer5->changeSize(ui->topSpacer5->sizeHint().width(), ui->topSpacer5->sizeHint().height() * getDPIScaling(), QSizePolicy::Preferred, QSizePolicy::Fixed);
ui->topSpacer6->changeSize(ui->topSpacer6->sizeHint().width(), ui->topSpacer6->sizeHint().height() * getDPIScaling(), QSizePolicy::Preferred, QSizePolicy::Fixed);
ui->topSpacer7->changeSize(ui->topSpacer7->sizeHint().width(), ui->topSpacer7->sizeHint().height() * getDPIScaling(), QSizePolicy::Preferred, QSizePolicy::Fixed);
+ ui->leftSpacer->changeSize(ui->leftSpacer->sizeHint().width() * getDPIScaling(), ui->leftSpacer->sizeHint().height(), QSizePolicy::Fixed, QSizePolicy::Preferred);
+ ui->rightSpacer->changeSize(ui->rightSpacer->sizeHint().width() * getDPIScaling(), ui->rightSpacer->sizeHint().height(), QSizePolicy::Fixed, QSizePolicy::Preferred);
taskbarButton = new QWinTaskbarButton(this);
@@ -105,6 +110,48 @@ void MainWindow::getInstallerMetadata() {
}
}
+ //Check the license
+ if (obj.contains("license")) {
+ QJsonArray licenses = obj.value("license").toArray();
+
+ QStringList licenseLinks;
+ for (QJsonValue l : licenses) {
+ QJsonObject license = l.toObject();
+ QString type = license.value("type").toString();
+
+ if (type == "GPL3") {
+ QFile text(":/licenses/gpl3.html");
+ text.open(QFile::ReadOnly);
+ this->licenses.insert(tr("GNU General Public License, version 3"), text.readAll());
+ licenseLinks.append(QString("<a href=\"%1\">%1</a>").arg(tr("GNU General Public License, version 3")));
+ } else if (type == "GPL3+") {
+ QFile text(":/licenses/gpl3.html");
+ text.open(QFile::ReadOnly);
+ this->licenses.insert(tr("GNU General Public License, version 3, or later"), text.readAll());
+ licenseLinks.append(QString("<a href=\"%1\">%1</a>").arg(tr("GNU General Public License, version 3, or later")));
+ } else if (type == "GPL2") {
+ QFile text(":/licenses/gpl2.html");
+ text.open(QFile::ReadOnly);
+ this->licenses.insert(tr("GNU General Public License, version 2"), text.readAll());
+ licenseLinks.append(QString("<a href=\"%1\">%1</a>").arg(tr("GNU General Public License, version 2")));
+ } else if (type == "GPL2+") {
+ QFile text(":/licenses/gpl2.html");
+ text.open(QFile::ReadOnly);
+ this->licenses.insert(tr("GNU General Public License, version 2, or later"), text.readAll());
+ licenseLinks.append(QString("<a href=\"%1\">%1</a>").arg(tr("GNU General Public License, version 2, or later")));
+ } else {
+ this->licenses.insert(type, license.value("text").toString());
+ licenseLinks.append(QString("<a href=\"%1\">%1</a>").arg(type));
+ }
+ }
+
+ ui->licenseLabel->setText(tr("By installing %1, you're indicating agreement to the terms of the %2.").arg(obj.value("name").toString(), licenseLinks.join(", ")));
+ ui->licenseLabel->setVisible(true);
+ } else {
+ //No license available
+ ui->licenseLabel->setVisible(false);
+ }
+
ui->stack->setCurrentIndex(2);
});
connect(reply, QOverload<QNetworkReply::NetworkError>::of(&QNetworkReply::error), [=](QNetworkReply::NetworkError code) {
@@ -388,3 +435,8 @@ void MainWindow::on_browseInstallPathButton_clicked()
ui->installPathLineEdit->setText(d.selectedFiles().first());
}
}
+
+void MainWindow::on_licenseLabel_linkActivated(const QString &link)
+{
+ licenseWidget->show(link, this->licenses.value(link));
+}