Add some enhanced UX around the language update.

pull/2/head
Simon Quigley 1 year ago
parent 27e12337a6
commit 38a8231ae2

@ -3,7 +3,11 @@
LANGUAGE_CODE=$1
COUNTRY_CODE=$2
LOCALE="${LANGUAGE_CODE}_${COUNTRY_CODE}.UTF-8"
ONLY_LXQT=$3
if [ -z "$ONLY_LXQT" ]; then
apt-get -y install language-pack-gnome-$LANGUAGE_CODE language-pack-kde-$LANGUAGE_CODE
fi
update-locale LANGUAGE=$LOCALE LANG=$LOCALE LC_ALL=$LOCALE
systemctl restart sddm

@ -1,3 +1,5 @@
#include <KBusyIndicatorWidget>
#include <KLed>
#include <NetworkManagerQt/ConnectionSettings>
#include <NetworkManagerQt/Manager>
#include <NetworkManagerQt/Device>
@ -13,7 +15,6 @@
#include <QMessageBox>
#include <QUuid>
#include <QDBusPendingReply>
#include <KLed>
#include "installerprompt.h"
#include "./ui_installerprompt.h"
@ -22,8 +23,10 @@ InstallerPrompt::InstallerPrompt(QWidget *parent)
, ui(new Ui::InstallerPrompt) {
ui->setupUi(this);
// Hide the Incorrect Password text
// Hide the Incorrect Password and loading text
ui->incorrectPassword->setVisible(false);
ui->changingLanguageLabel->setVisible(false);
ui->changingLanguageLoader->setVisible(false);
// Set the background image and scale it
QPixmap bg(":/background");
@ -47,11 +50,12 @@ InstallerPrompt::InstallerPrompt(QWidget *parent)
connect(ui->tryLubuntu, &QAbstractButton::clicked, this, &InstallerPrompt::tryLubuntu);
connect(ui->installLubuntu, &QAbstractButton::clicked, this, &InstallerPrompt::installLubuntu);
connect(ui->connectWiFiButton, &QAbstractButton::clicked, this, &InstallerPrompt::onConnectWifiClicked);
connect(ui->confirmButton, &QAbstractButton::clicked, this, &InstallerPrompt::onLanguageConfirm);
// Set up the language combo box with available languages
initLanguageComboBox();
// Connect the language combo box to the onLanguageChanged slot
// Connect the appropriate language slots
connect(ui->languageComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onLanguageChanged(int)));
// Check initial network status and update UI
@ -414,22 +418,54 @@ QStringList InstallerPrompt::getAvailableLanguages() {
}
void InstallerPrompt::onLanguageChanged(int index) {
QString selectedLanguage = ui->languageComboBox->itemText(index);
QString localeName = languageLocaleMap.value(selectedLanguage);
qDebug() << selectedLanguage;
qDebug() << index << languageLocaleMap;
selectedLanguage = ui->languageComboBox->itemText(index);
}
void InstallerPrompt::onLanguageConfirm() {
ui->changingLanguageLabel->setVisible(true);
ui->changingLanguageLoader->setVisible(true);
localeName = languageLocaleMap.value(selectedLanguage);
qDebug() << selectedLanguage << localeName;
// Split the locale name to get language and country code
QStringList localeParts = localeName.split('_');
QString languageCode = localeParts.value(0);
QString countryCode = localeParts.value(1);
// If there is no internet connection and we don't ship the langpack, tell them
//QStringList allowedLanguages = {"zh-hans", "hi", "es", "fr", "ar", "en"};
QStringList allowedLanguages = {"zh-hans", "hi", "fr", "ar", "en"};
bool only_lxqt = false;
if (!allowedLanguages.contains(languageCode) && NetworkManager::status() != NetworkManager::Status::Connected) {
ui->changingLanguageLabel->setText(tr("Unable to download full language support, changing anyway..."));
only_lxqt = true;
} else {
ui->changingLanguageLabel->setText(tr("Changing language..."));
}
// Construct the command to run the script with parameters
QString scriptPath = "/usr/libexec/change-system-language"; // Update with the actual path
QProcess *process = new QProcess(this);
QStringList arguments;
process->setProgram("/usr/libexec/change-system-language");
arguments << languageCode << countryCode;
if (only_lxqt) arguments << "1";
process->setArguments(arguments);
connect(process, static_cast<void(QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), this, &InstallerPrompt::languageProcessFinished);
connect(process, &QProcess::errorOccurred, this, &InstallerPrompt::languageProcessError);
process->start();
}
void InstallerPrompt::languageProcessFinished(int exitCode, QProcess::ExitStatus exitStatus) {
qDebug() << "Process finished. Exit code:" << exitCode << "Exit status:" << exitStatus;
ui->changingLanguageLabel->setVisible(false);
ui->changingLanguageLoader->setVisible(false);
}
QProcess::execute(scriptPath, arguments);
void InstallerPrompt::languageProcessError(QProcess::ProcessError error) {
qDebug() << "Process failed with error:" << error;
}
void InstallerPrompt::tryLubuntu()

@ -9,6 +9,7 @@
#include <QDialog>
#include <QMutex>
#include <QLineEdit>
#include <QProcess>
#include <NetworkManagerQt/Device>
#include <NetworkManagerQt/WirelessDevice>
#include <NetworkManagerQt/WirelessNetwork>
@ -25,11 +26,14 @@ public:
private slots:
void refreshNetworkList();
void onLanguageChanged(int index);
void onLanguageConfirm();
void onConnectWifiClicked();
void updateConnectionStatus();
void handleWiFiConnectionChange(NetworkManager::Device::State newstate, NetworkManager::Device::State oldstate, NetworkManager::Device::StateChangeReason reason);
void tryLubuntu();
void installLubuntu();
void languageProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
void languageProcessError(QProcess::ProcessError error);
private:
Ui::InstallerPrompt *ui;
@ -41,6 +45,8 @@ private:
bool wifiWrongHandling = false;
QLineEdit *passwordLineEdit;
QMap<QString, QString> languageLocaleMap;
QString selectedLanguage = "English (United States)";
QString localeName = "en_US";
void handleWifiConnection(const QString &ssid, bool recoverFromWrongPassword = false);
QString promptForWifiPassword(const QString &ssid, bool isWrongPassword = false);

@ -62,6 +62,10 @@ QLabel#logoLabel {
QLabel#incorrectPassword {
color: red;
}
KBusyIndicatorWidget {
color: blue;
}</string>
</property>
<widget class="QWidget" name="centralwidget">
@ -171,6 +175,19 @@ QLabel#incorrectPassword {
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_7">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<spacer name="WiFiSpacer">
<property name="orientation">
@ -186,54 +203,68 @@ QLabel#incorrectPassword {
</item>
<item>
<layout class="QGridLayout" name="WiFiLayout">
<item row="0" column="3">
<widget class="QPushButton" name="pushButton">
<item row="2" column="2">
<widget class="QComboBox" name="languageComboBox">
<property name="minimumSize">
<size>
<width>175</width>
<height>65</height>
<width>352</width>
<height>50</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>175</width>
<height>65</height>
<width>550</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
<pointsize>16</pointsize>
</font>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="translationsLabel">
<property name="font">
<font>
<pointsize>18</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>✅ Confirm</string>
<string>Select Your Language:</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QComboBox" name="languageComboBox">
<item row="2" column="4">
<widget class="QPushButton" name="confirmButton">
<property name="minimumSize">
<size>
<width>352</width>
<height>50</height>
<width>175</width>
<height>65</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>550</width>
<height>50</height>
<width>175</width>
<height>65</height>
</size>
</property>
<property name="font">
<font>
<pointsize>16</pointsize>
<pointsize>14</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>✅ Confirm</string>
</property>
</widget>
</item>
<item row="3" column="2">
<item row="5" column="2">
<widget class="QLabel" name="incorrectPassword">
<property name="enabled">
<bool>true</bool>
@ -250,7 +281,33 @@ QLabel#incorrectPassword {
</property>
</widget>
</item>
<item row="4" column="1">
<item row="3" column="2">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="6" column="6">
<spacer name="networkSpacer2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="6" column="1">
<widget class="QLabel" name="WiFiLabel">
<property name="font">
<font>
@ -264,7 +321,7 @@ QLabel#incorrectPassword {
</property>
</widget>
</item>
<item row="5" column="1">
<item row="7" column="1">
<spacer name="advancedSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -277,33 +334,28 @@ QLabel#incorrectPassword {
</property>
</spacer>
</item>
<item row="4" column="3">
<widget class="QPushButton" name="connectWiFiButton">
<item row="6" column="2">
<widget class="QComboBox" name="networkComboBox">
<property name="minimumSize">
<size>
<width>175</width>
<height>65</height>
<width>352</width>
<height>50</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>175</width>
<height>65</height>
<width>550</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
<weight>75</weight>
<bold>true</bold>
<pointsize>16</pointsize>
</font>
</property>
<property name="text">
<string>✅ Connect</string>
</property>
</widget>
</item>
<item row="4" column="0">
<item row="6" column="0">
<spacer name="networkSpacer1">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -316,21 +368,20 @@ QLabel#incorrectPassword {
</property>
</spacer>
</item>
<item row="0" column="1">
<widget class="QLabel" name="translationsLabel">
<item row="7" column="2">
<widget class="QLabel" name="WiFiInfoLabel">
<property name="font">
<font>
<pointsize>18</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Select Your Language:</string>
<string>(For advanced network configuration, select &quot;Try Lubuntu&quot;)</string>
</property>
</widget>
</item>
<item row="5" column="3">
<item row="7" column="4">
<spacer name="advancedSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -343,65 +394,67 @@ QLabel#incorrectPassword {
</property>
</spacer>
</item>
<item row="1" column="2">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="2">
<widget class="QComboBox" name="networkComboBox">
<item row="6" column="4">
<widget class="QPushButton" name="connectWiFiButton">
<property name="minimumSize">
<size>
<width>352</width>
<height>50</height>
<width>175</width>
<height>65</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>550</width>
<height>50</height>
<width>175</width>
<height>65</height>
</size>
</property>
<property name="font">
<font>
<pointsize>16</pointsize>
<pointsize>14</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>✅ Connect</string>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QLabel" name="WiFiInfoLabel">
<item row="1" column="2">
<widget class="QLabel" name="changingLanguageLabel">
<property name="font">
<font>
<pointsize>16</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>(For advanced network configuration, select &quot;Try Lubuntu&quot;)</string>
<string>Changing language...</string>
</property>
</widget>
</item>
<item row="4" column="4">
<spacer name="networkSpacer2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<item row="1" column="4">
<widget class="KBusyIndicatorWidget" name="changingLanguageLoader">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="sizeHint" stdset="0">
<property name="minimumSize">
<size>
<width>40</width>
<height>20</height>
<width>35</width>
<height>35</height>
</size>
</property>
</spacer>
<property name="maximumSize">
<size>
<width>35</width>
<height>35</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
@ -710,6 +763,11 @@ QToolTip {
<widget class="QStatusBar" name="statusbar"/>
</widget>
<customwidgets>
<customwidget>
<class>KBusyIndicatorWidget</class>
<extends>QWidget</extends>
<header>kbusyindicatorwidget.h</header>
</customwidget>
<customwidget>
<class>KLed</class>
<extends>QWidget</extends>

Loading…
Cancel
Save