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 LANGUAGE_CODE=$1
COUNTRY_CODE=$2 COUNTRY_CODE=$2
LOCALE="${LANGUAGE_CODE}_${COUNTRY_CODE}.UTF-8" 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
apt-get -y install language-pack-gnome-$LANGUAGE_CODE language-pack-kde-$LANGUAGE_CODE
update-locale LANGUAGE=$LOCALE LANG=$LOCALE LC_ALL=$LOCALE update-locale LANGUAGE=$LOCALE LANG=$LOCALE LC_ALL=$LOCALE
systemctl restart sddm systemctl restart sddm

@ -1,3 +1,5 @@
#include <KBusyIndicatorWidget>
#include <KLed>
#include <NetworkManagerQt/ConnectionSettings> #include <NetworkManagerQt/ConnectionSettings>
#include <NetworkManagerQt/Manager> #include <NetworkManagerQt/Manager>
#include <NetworkManagerQt/Device> #include <NetworkManagerQt/Device>
@ -13,7 +15,6 @@
#include <QMessageBox> #include <QMessageBox>
#include <QUuid> #include <QUuid>
#include <QDBusPendingReply> #include <QDBusPendingReply>
#include <KLed>
#include "installerprompt.h" #include "installerprompt.h"
#include "./ui_installerprompt.h" #include "./ui_installerprompt.h"
@ -22,8 +23,10 @@ InstallerPrompt::InstallerPrompt(QWidget *parent)
, ui(new Ui::InstallerPrompt) { , ui(new Ui::InstallerPrompt) {
ui->setupUi(this); ui->setupUi(this);
// Hide the Incorrect Password text // Hide the Incorrect Password and loading text
ui->incorrectPassword->setVisible(false); ui->incorrectPassword->setVisible(false);
ui->changingLanguageLabel->setVisible(false);
ui->changingLanguageLoader->setVisible(false);
// Set the background image and scale it // Set the background image and scale it
QPixmap bg(":/background"); QPixmap bg(":/background");
@ -47,11 +50,12 @@ InstallerPrompt::InstallerPrompt(QWidget *parent)
connect(ui->tryLubuntu, &QAbstractButton::clicked, this, &InstallerPrompt::tryLubuntu); connect(ui->tryLubuntu, &QAbstractButton::clicked, this, &InstallerPrompt::tryLubuntu);
connect(ui->installLubuntu, &QAbstractButton::clicked, this, &InstallerPrompt::installLubuntu); connect(ui->installLubuntu, &QAbstractButton::clicked, this, &InstallerPrompt::installLubuntu);
connect(ui->connectWiFiButton, &QAbstractButton::clicked, this, &InstallerPrompt::onConnectWifiClicked); 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 // Set up the language combo box with available languages
initLanguageComboBox(); 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))); connect(ui->languageComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onLanguageChanged(int)));
// Check initial network status and update UI // Check initial network status and update UI
@ -414,22 +418,54 @@ QStringList InstallerPrompt::getAvailableLanguages() {
} }
void InstallerPrompt::onLanguageChanged(int index) { void InstallerPrompt::onLanguageChanged(int index) {
QString selectedLanguage = ui->languageComboBox->itemText(index); selectedLanguage = ui->languageComboBox->itemText(index);
QString localeName = languageLocaleMap.value(selectedLanguage); }
qDebug() << selectedLanguage;
qDebug() << index << languageLocaleMap; 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 // Split the locale name to get language and country code
QStringList localeParts = localeName.split('_'); QStringList localeParts = localeName.split('_');
QString languageCode = localeParts.value(0); QString languageCode = localeParts.value(0);
QString countryCode = localeParts.value(1); 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 // 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; QStringList arguments;
process->setProgram("/usr/libexec/change-system-language");
arguments << languageCode << countryCode; 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() void InstallerPrompt::tryLubuntu()

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

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

Loading…
Cancel
Save