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