|
|
@ -29,6 +29,7 @@
|
|
|
|
#include <QTimer>
|
|
|
|
#include <QTimer>
|
|
|
|
#include <QFile>
|
|
|
|
#include <QFile>
|
|
|
|
#include <QUuid>
|
|
|
|
#include <QUuid>
|
|
|
|
|
|
|
|
#include <QPainter>
|
|
|
|
#include <QDBusPendingReply>
|
|
|
|
#include <QDBusPendingReply>
|
|
|
|
#include "installerprompt.h"
|
|
|
|
#include "installerprompt.h"
|
|
|
|
#include "wifipassworddialog.h"
|
|
|
|
#include "wifipassworddialog.h"
|
|
|
@ -75,28 +76,25 @@ InstallerPrompt::~InstallerPrompt()
|
|
|
|
void InstallerPrompt::activateBackground()
|
|
|
|
void InstallerPrompt::activateBackground()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Set the background image and scale it
|
|
|
|
// Set the background image and scale it
|
|
|
|
QImage image(":/background");
|
|
|
|
QImage rawImage(":/background");
|
|
|
|
if (image.isNull()) {
|
|
|
|
if (rawImage.isNull()) {
|
|
|
|
WarningDialog::showWarning(tr("Background image cannot be loaded."));
|
|
|
|
WarningDialog::showWarning(tr("Background image cannot be loaded."));
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
qreal imgRatio = static_cast<qreal>(image.width()) / image.height();
|
|
|
|
qreal imgRatio = static_cast<qreal>(rawImage.width()) / rawImage.height();
|
|
|
|
qreal screenRatio = static_cast<qreal>(this->width()) / this->height();
|
|
|
|
qreal screenRatio = static_cast<qreal>(this->width()) / this->height();
|
|
|
|
QImage scaled;
|
|
|
|
QImage scaled;
|
|
|
|
if (imgRatio < screenRatio) {
|
|
|
|
if (imgRatio < screenRatio) {
|
|
|
|
scaled = image.scaledToWidth(this->width(), Qt::SmoothTransformation);
|
|
|
|
scaled = rawImage.scaledToWidth(this->width(), Qt::SmoothTransformation);
|
|
|
|
int yGap = (scaled.height() - this->height()) / 2;
|
|
|
|
int yGap = (scaled.height() - this->height()) / 2;
|
|
|
|
scaled = scaled.copy(0, yGap, scaled.width(), this->height());
|
|
|
|
scaled = scaled.copy(0, yGap, scaled.width(), this->height());
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
scaled = image.scaledToHeight(this->height(), Qt::SmoothTransformation);
|
|
|
|
scaled = rawImage.scaledToHeight(this->height(), Qt::SmoothTransformation);
|
|
|
|
int xGap = (scaled.width() - this->width()) / 2;
|
|
|
|
int xGap = (scaled.width() - this->width()) / 2;
|
|
|
|
scaled = scaled.copy(xGap, 0, this->width(), scaled.height());
|
|
|
|
scaled = scaled.copy(xGap, 0, this->width(), scaled.height());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
QPixmap bg = QPixmap::fromImage(scaled);
|
|
|
|
background = scaled;
|
|
|
|
QPalette palette;
|
|
|
|
|
|
|
|
palette.setBrush(QPalette::Window, bg);
|
|
|
|
|
|
|
|
this->setPalette(palette);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InstallerPrompt::onTryClicked()
|
|
|
|
void InstallerPrompt::onTryClicked()
|
|
|
@ -175,7 +173,7 @@ void InstallerPrompt::onNetworkSelected(int index)
|
|
|
|
QString networkId = ui->networkComboBox->itemData(index).toString();
|
|
|
|
QString networkId = ui->networkComboBox->itemData(index).toString();
|
|
|
|
if (!networkId.isNull()) {
|
|
|
|
if (!networkId.isNull()) {
|
|
|
|
if (networkId.left(4) == "UNI_") { // this is an Ethernet device
|
|
|
|
if (networkId.left(4) == "UNI_") { // this is an Ethernet device
|
|
|
|
QString deviceUni = networkId.right(networkId.count() - 4);
|
|
|
|
QString deviceUni = networkId.right(networkId.length() - 4);
|
|
|
|
NetworkManager::WiredDevice wiredDevice(deviceUni);
|
|
|
|
NetworkManager::WiredDevice wiredDevice(deviceUni);
|
|
|
|
QDBusPendingReply reply = wiredDevice.disconnectInterface();
|
|
|
|
QDBusPendingReply reply = wiredDevice.disconnectInterface();
|
|
|
|
reply.waitForFinished();
|
|
|
|
reply.waitForFinished();
|
|
|
@ -430,9 +428,9 @@ QString InstallerPrompt::getDisplayNameForLocale(const QLocale &locale) {
|
|
|
|
|
|
|
|
|
|
|
|
QLocale currentAppLocale = QLocale::system();
|
|
|
|
QLocale currentAppLocale = QLocale::system();
|
|
|
|
QString nativeName = locale.nativeLanguageName();
|
|
|
|
QString nativeName = locale.nativeLanguageName();
|
|
|
|
QString nativeCountryName = sanitize(locale.nativeCountryName());
|
|
|
|
QString nativeCountryName = sanitize(locale.nativeTerritoryName());
|
|
|
|
QString englishLanguageName = currentAppLocale.languageToString(locale.language());
|
|
|
|
QString englishLanguageName = currentAppLocale.languageToString(locale.language());
|
|
|
|
QString englishCountryName = sanitize(currentAppLocale.countryToString(locale.country()));
|
|
|
|
QString englishCountryName = sanitize(currentAppLocale.territoryToString(locale.territory()));
|
|
|
|
|
|
|
|
|
|
|
|
if (nativeName.isEmpty() || nativeCountryName.isEmpty()) {
|
|
|
|
if (nativeName.isEmpty() || nativeCountryName.isEmpty()) {
|
|
|
|
return QString();
|
|
|
|
return QString();
|
|
|
@ -452,3 +450,8 @@ QString InstallerPrompt::getDisplayNameForLocale(const QLocale &locale) {
|
|
|
|
|
|
|
|
|
|
|
|
return displayName;
|
|
|
|
return displayName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void InstallerPrompt::paintEvent(QPaintEvent *event) {
|
|
|
|
|
|
|
|
QPainter painter(this);
|
|
|
|
|
|
|
|
painter.drawImage(0, 0, background);
|
|
|
|
|
|
|
|
}
|
|
|
|