From a156505e911a65c3933d58707ff39ada1476e08c Mon Sep 17 00:00:00 2001
From: peijiankang <peijiankang@kylinos.cn>
Date: Thu, 6 Jul 2023 17:45:41 +0800
Subject: [PATCH] fix date and nm of greeter

---
 ukui-greeter/greeter/greeterwindow.cpp | 36 ++++++++++++++++----------
 ukui-greeter/kylin-nm/src/kylinnm.cpp  |  7 +++++
 ukui-greeter/kylin-nm/src/kylinnm.h    |  2 +-
 3 files changed, 31 insertions(+), 14 deletions(-)

diff --git a/ukui-greeter/greeter/greeterwindow.cpp b/ukui-greeter/greeter/greeterwindow.cpp
index 0fe4080..54e81d9 100644
--- a/ukui-greeter/greeter/greeterwindow.cpp
+++ b/ukui-greeter/greeter/greeterwindow.cpp
@@ -793,16 +793,13 @@ void GreeterWindow::updateLanguage(QString userName)
             qWarning() << "Get User's language error" << languageReply.error();
         else {
             formatsLocale = fomatsLocalReply.value().variant().toString();
-            if(!formatsLocale.isEmpty()){
-                if(formatsLocale.startsWith("zh")){
-                    local = QLocale::Chinese;
-                }
-                else{
-                    local = QLocale::English;
+            if(formatsLocale.isEmpty())
+                formatsLocale = QLocale::system().name();
+            if(formatsLocale.startsWith("zh"))
+                local = QLocale::Chinese;
+            else
+                local = QLocale::English;
         }
-            }
-        }
-
     }
 }
 
@@ -866,9 +863,17 @@ void GreeterWindow::onCurrentUserChanged(const QModelIndex &index)
         }
     }
 
-    if(realName == "*guest" || realName == "*login")
-        return;
-
+    if(realName == "*guest" || realName == "*login"){
+        QString language = QLocale::system().name();
+        onLanguageChanged(language);
+        if(language.startsWith("zh"))
+            local = QLocale::Chinese;
+        else
+            local = QLocale::English;
+        timeType=24;
+        dataType = "cn";
+        return;
+    }
     updateLanguage(realName);
     Q_EMIT currentUserChange(realName);
     if(!m_sessionHasChanged && m_sessionsModel->rowCount() > 1)
@@ -879,6 +884,10 @@ void GreeterWindow::onCurrentUserChanged(const QModelIndex &index)
     m_configuration->getCurrentUser(realName);
     timeType = m_configuration->getTimetp("timeType").toInt();
     dataType = m_configuration->getTimetp("dateType").toString();
+    if(timeType == 0)
+        timeType = 24;
+    if(dataType == "")
+        dataType = "cn";
     timer = new QTimer(this);
     connect(timer, &QTimer::timeout, this, [&]{
         if(timeType == 12){
@@ -1065,7 +1074,8 @@ void GreeterWindow::onLanguageChanged(QString languageCode)
     qApp->installTranslator(m_configuration->m_trans);
 
     m_greeter->setLang(languageCode);
-
+    if(m_kylinNM)
+        m_kylinNM->updatetext();
 }
 
 void GreeterWindow::showSessionWnd()
diff --git a/ukui-greeter/kylin-nm/src/kylinnm.cpp b/ukui-greeter/kylin-nm/src/kylinnm.cpp
index ee3e29e..1ede7aa 100644
--- a/ukui-greeter/kylin-nm/src/kylinnm.cpp
+++ b/ukui-greeter/kylin-nm/src/kylinnm.cpp
@@ -2676,3 +2676,10 @@ void KylinNM::showEvent(QShowEvent *event)
 {
     on_btnWifiList_clicked();
 }
+
+void KylinNM::updatetext()
+{
+    lbNetListText->setText(tr("LAN"));
+    
+    lbWifiListText->setText(tr("WLAN"));
+}
diff --git a/ukui-greeter/kylin-nm/src/kylinnm.h b/ukui-greeter/kylin-nm/src/kylinnm.h
index 28803f7..c459ee9 100644
--- a/ukui-greeter/kylin-nm/src/kylinnm.h
+++ b/ukui-greeter/kylin-nm/src/kylinnm.h
@@ -182,7 +182,7 @@ public:
     void updateNetList();
 
     int getConnectStatus();//获取网络连接状态，返回值 -1 无连接； 0 有线连接； 1无线连接； 2有线和无线都已连接
-
+    void updatetext();
     QIcon iconLanOnline, iconLanOffline;
     QIcon iconWifiFull, iconWifiHigh, iconWifiMedium, iconWifiLow;
     QIcon iconConnecting;
-- 
2.33.0

