!1 登录锁屏添加飞行模式开关(已暂时屏蔽)

Merge pull request !1 from liudunfa/openkylin/nile
This commit is contained in:
杨敏 2024-06-19 05:34:24 +00:00 committed by openkylin-cibot
parent 3f0a5ae516
commit 3f4f95c227
2 changed files with 843 additions and 0 deletions

842
debian/patches/0039-1.patch vendored Normal file
View File

@ -0,0 +1,842 @@
From: =?utf-8?b?5p2o5pWP?= <yangmin@kylinos.cn>
Date: Wed, 19 Jun 2024 05:34:24 +0000
Subject: =?utf-8?b?ITEg55m75b2V6ZSB5bGP5re75Yqg6aOe6KGM5qih5byP5byA5YWz77yI?=
=?utf-8?b?5bey5pqC5pe25bGP6JS977yJIE1lcmdlIHB1bGwgcmVxdWVzdCAhMSBmcm9tIGxp?=
=?utf-8?b?dWR1bmZhL29wZW5reWxpbi9uaWxl?=
---
i18n_ts/mn.ts | 4 +-
src/common/global_utils.cpp | 92 ++++++++++++++++++++++++++++++---
src/lock-backend/dbusupperinterface.cpp | 83 +++++++++++++++++++++++++++++
src/lock-backend/dbusupperinterface.h | 5 ++
src/lock-backend/gsettingshelper.cpp | 47 +++++++++++++++++
src/lock-backend/gsettingshelper.h | 8 +++
src/lock-dialog/backenddbushelper.cpp | 83 +++++++++++++++++++++++++++++
src/lock-dialog/backenddbushelper.h | 4 ++
src/lock-dialog/lockdialogmodel.cpp | 13 +++++
src/lock-dialog/lockdialogmodel.h | 14 +++++
src/lock-dialog/lockdialogperformer.cpp | 10 +++-
src/widgets/lockwidget.cpp | 54 +++++++++++++++++++
src/widgets/lockwidget.h | 10 ++++
src/widgets/powerlistwidget.cpp | 2 +-
14 files changed, 417 insertions(+), 12 deletions(-)
diff --git a/i18n_ts/mn.ts b/i18n_ts/mn.ts
index a5a733d..469fabe 100644
--- a/i18n_ts/mn.ts
+++ b/i18n_ts/mn.ts
@@ -2116,12 +2116,12 @@
<message>
<location filename="../src/widgets/mynetworkwidget.cpp" line="52"/>
<source>LAN</source>
- <translation>ᠤᠳᠠᠰᠤᠳᠤ ᠰᠦᠯᠵᠢᠶ᠎ᠡ</translation>
+ <translation>ᠤᠳᠠᠰᠤᠳᠤ ᠰᠦᠯᠵᠢᠶ᠎ᠡ</translation>
</message>
<message>
<location filename="../src/widgets/mynetworkwidget.cpp" line="54"/>
<source>WLAN</source>
- <translation>ᠤᠳᠠᠰᠤ ᠦᠬᠡᠢ ᠬᠡᠰᠡᠭ ᠬᠡᠪᠴᠢᠶᠡᠨ᠎ᠦ ᠰᠦᠯᠵᠢᠶ᠎ᠡ</translation>
+ <translation>ᠤᠳᠠᠰᠤ ᠦᠬᠡᠢ ᠬᠡᠰᠡᠭ ᠰᠦᠯᠵᠢᠶ᠎ᠡ</translation>
</message>
</context>
<context>
diff --git a/src/common/global_utils.cpp b/src/common/global_utils.cpp
index f4ed7db..57d78a2 100644
--- a/src/common/global_utils.cpp
+++ b/src/common/global_utils.cpp
@@ -29,6 +29,7 @@
#include <QSettings>
#define KYSDK_SYSINFO_DLL "/usr/lib/kysdk/kysdk-system/libkysysinfo.so"
+#define FACEPATH "/usr/share/ukui/faces/"
typedef char *(*PFuncGetHostCloudPlatform)();
bool isGreeterMode()
@@ -193,18 +194,93 @@ bool isCommunity()
}
}
return (bool)(sIsCommunity);
+
+}
+
+static inline void strstrip(char *str, char ch)
+{
+ if (strlen(str) == 0)
+ return;
+ char *startPos = str;
+ while (*startPos != '\0' && *startPos == ch)
+ startPos++;
+ if (*startPos == '\0')
+ {
+ str[0] = 0;
+ return;
+ }
+
+ char *endPos = str + strlen(str) - 1;
+ while (endPos != str && *endPos == ch)
+ endPos --;
+
+ memmove(str, startPos, endPos - startPos + 1);
+ *(str + (endPos - startPos) + 1) = 0;
+}
+
+
+
+char *kdk_system_get_systemName()
+{
+ char *sysname = NULL;
+#ifdef __linux__
+ FILE *fp = fopen("/etc/os-release", "r");
+ if (!fp)
+ return NULL;
+
+ char buf[1024] = {0};
+ while (fgets(buf, 1024, fp))
+ {
+ if (strncmp(buf, "NAME", strlen("NAME")) == 0)
+ {
+ sysname = strdup((char *)buf + strlen("NAME") + 1);
+ break;
+ }
+ }
+
+
+ if (!sysname)
+ return NULL;
+ strstrip(sysname, '\n');
+ strstrip(sysname, '\"');
+
+ fclose(fp);
+#endif
+ return sysname;
+}
+
+
+bool isOpenkylin()
+{
+ QString systemName = QString(QLatin1String(kdk_system_get_systemName()));
+ if (systemName.compare("openkylin", Qt::CaseInsensitive) == 0) {
+ return true;
+ }
+ return false;
}
QString getDefaultFace()
{
- if (isCommunity()) {
- return ":/images/01-default-community.png";
- } else {
- //优先读取控制面板的默认头像文件,保持登录锁屏默认头像和控制面板一致
- QFile faceFile("/usr/share/ukui/faces/default.png");
- if (faceFile.exists()) {
- return "/usr/share/ukui/faces/default.png";
+ // 遍历头像目录
+ QDir facesDir = QDir(FACEPATH);
+ foreach (QString filename, facesDir.entryList(QDir::Files)) {
+ QString fullface = QString("%1%2").arg(FACEPATH).arg(filename);
+ // 社区版不加载商业默认头像
+ if ((isCommunity() || isOpenkylin()) && fullface.endsWith("commercial.png")) {
+ continue;
+ }
+ // 商业版不加载社区默认头像
+ if ((!isCommunity() && !isOpenkylin()) &&fullface.endsWith("community.png")) {
+ continue;
+ }
+ if (fullface.endsWith("default.png")) {
+ continue;
+ }
+
+ if (!fullface.contains("-")) {
+ continue;
}
- return ":/images/01-default-commercial.png";
+ return fullface;
}
+ return "/usr/share/ukui/faces/default.png";
}
diff --git a/src/lock-backend/dbusupperinterface.cpp b/src/lock-backend/dbusupperinterface.cpp
index 227727c..b87aa8c 100644
--- a/src/lock-backend/dbusupperinterface.cpp
+++ b/src/lock-backend/dbusupperinterface.cpp
@@ -140,6 +140,11 @@ void DbusUpperInterface::initConnections()
&GSettingsHelper::usdMediaKeysConfigChanged,
this,
&DbusUpperInterface::onUsdMediaKeysConfigChanged);
+ connect(
+ m_gsettingsHelper,
+ &GSettingsHelper::usdMediaStateKeysConfigChanged,
+ this,
+ &DbusUpperInterface::onUsdMediaStateKeysConfigChanged);
}
if (m_bioAuth) {
connect(m_bioAuth, &BioAuthenticate::bioAuthShowMessage, this, &DbusUpperInterface::onBioAuthShowMessage);
@@ -719,6 +724,10 @@ QString DbusUpperInterface::GetInformation(QString strJson)
retObj["CmdId"] = cmdId;
GetUsdMediaKeys(rootObj, retObj);
break;
+ case LOCK_CMD_ID_GSETTINGS_GET_USD_MEDIA_STATE_KEYS_CONF:
+ retObj["CmdId"] = cmdId;
+ GetUsdMediaStateKeys(rootObj, retObj);
+ break;
case LOCK_CMD_ID_LOGIN1_GET_POWER_MANAGER_CANHIBERNATE:
retObj["CmdId"] = cmdId;
if (m_login1Helper)
@@ -903,6 +912,9 @@ int DbusUpperInterface::SetInformation(QString strJson)
case LOCK_CMD_ID_KWIN_BLOCK_SHORTCUT:
nRet = blockShortcut(rootObj);
break;
+ case LOCK_CMD_ID_GSETTINGS_SET_USD_MEDIA_STATE_KEYS_CONF:
+ nRet = SetUsdMediaStateKeys(rootObj);
+ break;
default:
qInfo() << "不支持的CmdId";
nRet = -2;
@@ -1646,6 +1658,33 @@ void DbusUpperInterface::onUsdMediaKeysConfigChanged(QString strKey, QVariant va
SendUpdateInfoSig(QString(QJsonDocument(retObj).toJson()));
}
+void DbusUpperInterface::onUsdMediaStateKeysConfigChanged(QString strKey, QVariant value)
+{
+ QJsonObject retObj;
+ retObj["CmdId"] = LOCK_CMD_ID_GSETTINGS_USD_MEDIA_STATE_KEYS_CONF_CHANGED;
+ retObj["Key"] = strKey;
+ switch (value.type()) {
+ case QVariant::Bool:
+ retObj["Value"] = value.toBool();
+ break;
+ case QVariant::Int:
+ retObj["Value"] = value.toInt();
+ break;
+ case QVariant::String:
+ retObj["Value"] = value.toString();
+ break;
+ case QVariant::UInt:
+ retObj["Value"] = value.toDouble();
+ break;
+ case QVariant::Double:
+ retObj["Value"] = value.toDouble();
+ break;
+ default:
+ return;
+ }
+ SendUpdateInfoSig(QString(QJsonDocument(retObj).toJson()));
+}
+
void DbusUpperInterface::GetScreenSaverConf(QJsonObject &reqObj, QJsonObject &retObj)
{
QString strKey = reqObj.value("Key").toString();
@@ -2479,6 +2518,50 @@ void DbusUpperInterface::GetUsdMediaKeys(QJsonObject &reqObj, QJsonObject &retOb
retObj["Message"] = "Key is invalid!!";
}
+void DbusUpperInterface::GetUsdMediaStateKeys(QJsonObject &reqObj, QJsonObject &retObj)
+{
+ QString strKey = reqObj.value("Key").toString();
+ if (!strKey.isEmpty()) {
+ QVariant value = m_gsettingsHelper->GetUsdMediaStateKeys(strKey);
+ switch (value.type()) {
+ case QVariant::Bool:
+ retObj[strKey] = value.toBool();
+ return;
+ case QVariant::Int:
+ retObj[strKey] = value.toInt();
+ return;
+ case QVariant::String:
+ retObj[strKey] = value.toString();
+ return;
+ case QVariant::UInt:
+ retObj[strKey] = value.toDouble();
+ return;
+ case QVariant::Double:
+ retObj[strKey] = value.toDouble();
+ return;
+ default:
+ break;
+ }
+ }
+ retObj["Ret"] = -2;
+ retObj["Message"] = "Key is invalid!!";
+}
+
+int DbusUpperInterface::SetUsdMediaStateKeys(const QJsonObject &objInfo)
+{
+ int nRet = -1;
+ QString strKey = objInfo.value("Key").toString();
+ if (!strKey.isEmpty()) {
+ QVariant value = objInfo.value("Value").toVariant();
+ if (value.isValid()) {
+ if (m_gsettingsHelper->SetUsdMediaStateKeys(strKey, value)) {
+ nRet = 0;
+ }
+ }
+ }
+ return nRet;
+}
+
bool DbusUpperInterface::usdExternalDoAction(const QJsonObject &objInfo)
{
int nRet = -1;
diff --git a/src/lock-backend/dbusupperinterface.h b/src/lock-backend/dbusupperinterface.h
index c331650..6fc89c3 100644
--- a/src/lock-backend/dbusupperinterface.h
+++ b/src/lock-backend/dbusupperinterface.h
@@ -211,6 +211,7 @@ public Q_SLOTS:
void onPamAuthCompleted();
void onUsdMediaKeysConfigChanged(QString strKey, QVariant value);
+ void onUsdMediaStateKeysConfigChanged(QString strKey, QVariant value);
// 空闲锁屏
void onSessionIdleReceived();
@@ -324,6 +325,10 @@ private:
void GetUsdMediaKeys(QJsonObject &reqObj, QJsonObject &retObj);
+ void GetUsdMediaStateKeys(QJsonObject &reqObj, QJsonObject &retObj);
+
+ int SetUsdMediaStateKeys(const QJsonObject &objInfo);
+
bool usdExternalDoAction(const QJsonObject &objInfo);
bool blockShortcut(const QJsonObject &objInfo);
diff --git a/src/lock-backend/gsettingshelper.cpp b/src/lock-backend/gsettingshelper.cpp
index b1c1caf..5f1b9af 100644
--- a/src/lock-backend/gsettingshelper.cpp
+++ b/src/lock-backend/gsettingshelper.cpp
@@ -288,6 +288,22 @@ bool GSettingsHelper::initUsdMediaKeys()
return (bool)(m_gsUsdMediaKeys);
}
+bool GSettingsHelper::initUsdMediaStateKeys()
+{
+ if (!m_gsUsdMediaStateKeys) {
+ if(QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA_MEDIAKEY_STATE_SCHEMA)) {
+ m_gsUsdMediaStateKeys = new QGSettings(GSETTINGS_SCHEMA_MEDIAKEY_STATE_SCHEMA, "", this);
+ connect(m_gsUsdMediaStateKeys, &QGSettings::changed,
+ this, &GSettingsHelper::onUsdMediaStateKeysConfigChanged);
+ QStringList keys = m_gsUsdMediaStateKeys->keys();
+ if (keys.contains(KEY_RFKILL_STATE)) {
+ m_rfkillState = m_gsUsdMediaStateKeys->get(KEY_RFKILL_STATE).toInt();
+ }
+ }
+ }
+ return (bool)(m_gsUsdMediaKeys);
+}
+
void GSettingsHelper::onLockScreenConfigChanged(QString strKey)
{
QVariant varValue;
@@ -458,6 +474,15 @@ void GSettingsHelper::onUsdMediaKeysConfigChanged(QString strKey)
Q_EMIT usdMediaKeysConfigChanged(strKey, varValue);
}
+void GSettingsHelper::onUsdMediaStateKeysConfigChanged(QString strKey)
+{
+ QVariant varValue;
+ if (strKey == KEY_RFKILL_STATE) {
+ varValue = m_rfkillState = m_gsUsdMediaStateKeys->get(KEY_RFKILL_STATE).toInt();
+ }
+ Q_EMIT usdMediaStateKeysConfigChanged(strKey, varValue);
+}
+
QVariant GSettingsHelper::GetScreenSaverConf(QString strKey)
{
QVariant varValue;
@@ -730,3 +755,25 @@ QVariant GSettingsHelper::GetUsdMediaKeys(QString strKey)
}
return varValue;
}
+
+QVariant GSettingsHelper::GetUsdMediaStateKeys(QString strKey)
+{
+ QVariant varValue;
+ if (initUsdMediaStateKeys()) {
+ if (strKey == KEY_RFKILL_STATE) {
+ varValue = m_rfkillState;
+ }
+ }
+ return varValue;
+}
+
+bool GSettingsHelper::SetUsdMediaStateKeys(QString strKey, QVariant value)
+{
+ if (initUsdMediaStateKeys()) {
+ if (value.isValid()) {
+ m_gsUsdMediaStateKeys->set(strKey, value);
+ return true;
+ }
+ }
+ return false;
+}
diff --git a/src/lock-backend/gsettingshelper.h b/src/lock-backend/gsettingshelper.h
index 46d88a4..70303a9 100644
--- a/src/lock-backend/gsettingshelper.h
+++ b/src/lock-backend/gsettingshelper.h
@@ -46,6 +46,8 @@ public:
QVariant GetKeyboardConf(QString strKey);
bool SetKeyboardConf(QString strKey, QVariant value);
QVariant GetUsdMediaKeys(QString strKey);
+ QVariant GetUsdMediaStateKeys(QString strKey);
+ bool SetUsdMediaStateKeys(QString strKey, QVariant value);
public Q_SLOTS:
void onLockScreenConfigChanged(QString strKey);
@@ -57,6 +59,7 @@ public Q_SLOTS:
void onSessionConfigChanged(QString strKey);
void onKeyboardConfigChanged(QString strKey);
void onUsdMediaKeysConfigChanged(QString strKey);
+ void onUsdMediaStateKeysConfigChanged(QString strKey);
Q_SIGNALS:
void lockScreenConfigChanged(QString strKey, QVariant value);
@@ -68,6 +71,7 @@ Q_SIGNALS:
void sessionConfigChanged(QString strKey, QVariant value);
void keyboardConfigChanged(QString strKey, QVariant value);
void usdMediaKeysConfigChanged(QString strKey, QVariant value);
+ void usdMediaStateKeysConfigChanged(QString strKey, QVariant value);
void idleLockConfigChanged(int idleLock);
private:
@@ -80,6 +84,7 @@ private:
bool initSession();
bool initKeyboard();
bool initUsdMediaKeys();
+ bool initUsdMediaStateKeys();
private:
QGSettings *m_gsLockScreen = nullptr;
@@ -91,6 +96,7 @@ private:
QGSettings *m_gsSession = nullptr;
QGSettings *m_gsKeyboard = nullptr;
QGSettings *m_gsUsdMediaKeys = nullptr;
+ QGSettings *m_gsUsdMediaStateKeys = nullptr;
bool m_bShowRestTime = false;
bool m_bShowCustomRestTime = false;
@@ -154,6 +160,8 @@ private:
QStringList m_saverTheme;
int m_imageTSEffect;
int m_imageSwitchInterval;
+
+ int m_rfkillState = -1;
};
#endif // GSETTINGSHELPER_H
diff --git a/src/lock-dialog/backenddbushelper.cpp b/src/lock-dialog/backenddbushelper.cpp
index fff34c3..e033858 100644
--- a/src/lock-dialog/backenddbushelper.cpp
+++ b/src/lock-dialog/backenddbushelper.cpp
@@ -1060,6 +1060,10 @@ void BackendDbusHelper::onUpdateInformation(const QString &strJson)
case LOCK_CMD_ID_GSETTINGS_USD_MEDIAKEYS_CONF_CHANGED: {
ParseUsdMediaKeysConf(objRes);
} break;
+ case LOCK_CMD_ID_GSETTINGS_USD_MEDIA_STATE_KEYS_CONF_CHANGED:
+ {
+ ParseUsdMediaStateKeysConf(objRes);
+ } break;
case LOCK_CMD_ID_UPOWER_BATTERY_STATUS: {
ParseBatteryStatusChanged(objRes);
} break;
@@ -1586,6 +1590,13 @@ bool BackendDbusHelper::ParseUsdMediaKeysConf(const QJsonObject &objRes)
return true;
}
+bool BackendDbusHelper::ParseUsdMediaStateKeysConf(const QJsonObject &objRes)
+{
+ QString strKey = objRes.value("Key").toString();
+ Q_EMIT usdMediaStateKeysConfChanged(strKey, objRes.value("Value").toInt());
+ return true;
+}
+
QVariant BackendDbusHelper::getLockScreenConf(QString strKey)
{
QVariant varValue;
@@ -2159,6 +2170,78 @@ bool BackendDbusHelper::setKeyboardConf(QString strKey, QVariant value)
return true;
}
+QVariant BackendDbusHelper::getUsdMediaStateKeys(QString strKey)
+{
+ QVariant varValue;
+ QJsonObject jsonCmd;
+ jsonCmd["CmdId"] = LOCK_CMD_ID_GSETTINGS_GET_USD_MEDIA_STATE_KEYS_CONF;
+ jsonCmd["Key"] = strKey;
+ QJsonObject objRes ;
+ QDBusPendingReply<QString> reply = GetInformation(QString(QJsonDocument(jsonCmd).toJson()));
+ reply.waitForFinished();
+ if (reply.isError()) {
+ qWarning() << "getUsdMediaStateKeys error: " << reply.error().message();
+ } else {
+ QString strResponse = reply.value();
+ QJsonParseError jsonParseError;
+ const QJsonDocument jsonDoc = QJsonDocument::fromJson(strResponse.toUtf8(), &jsonParseError);
+ if (jsonParseError.error != QJsonParseError::NoError) {
+ qInfo()<<"getUsdMediaStateKeys Parse json failed!!";
+ } else {
+ objRes = jsonDoc.object();
+ if (objRes.isEmpty()) {
+ qInfo()<<"getUsdMediaStateKeys Json is null!!";
+ } else {
+ if (objRes.contains("CmdId") && objRes.contains("Ret")) {
+ int nCmdId = objRes.value("CmdId").toInt(-1);
+ int nRet = objRes.value("Ret").toInt(-1);
+ if (nCmdId != LOCK_CMD_ID_GSETTINGS_GET_USD_MEDIA_STATE_KEYS_CONF || nRet != 0) {
+ qInfo()<<"getUsdMediaStateKeys Failed!!";
+ } else {
+ varValue = objRes.value(strKey);
+ }
+ } else {
+ qInfo()<<"getUsdMediaStateKeys Json is invalid!!";
+ }
+ }
+ }
+ }
+ return varValue;
+}
+
+bool BackendDbusHelper::setUsdMediaStateKeys(QString strKey, QVariant value)
+{
+ QJsonObject jsonCmd;
+ jsonCmd["CmdId"] = LOCK_CMD_ID_GSETTINGS_SET_USD_MEDIA_STATE_KEYS_CONF;
+ jsonCmd["Key"] = strKey;
+ switch (value.type()) {
+ case QVariant::Bool:
+ jsonCmd["Value"] = value.toBool();
+ break;
+ case QVariant::Int:
+ jsonCmd["Value"] = value.toInt();
+ break;
+ case QVariant::String:
+ jsonCmd["Value"] = value.toString();
+ break;
+ case QVariant::UInt:
+ jsonCmd["Value"] = value.toDouble();
+ break;
+ case QVariant::Double:
+ jsonCmd["Value"] = value.toDouble();
+ break;
+ default:
+ return false;
+ }
+ QDBusPendingReply<int> reply = SetInformation(QString(QJsonDocument(jsonCmd).toJson()));
+ reply.waitForFinished();
+ if (reply.isError()) {
+ qWarning() << "setUsdMediaStateKeys error: " << reply.error().message();
+ return false;
+ }
+ return true;
+}
+
QVariant BackendDbusHelper::getUsdMediaKeys(QString strKey)
{
QVariant varValue;
diff --git a/src/lock-dialog/backenddbushelper.h b/src/lock-dialog/backenddbushelper.h
index ce2403b..70191b5 100644
--- a/src/lock-dialog/backenddbushelper.h
+++ b/src/lock-dialog/backenddbushelper.h
@@ -102,6 +102,8 @@ public:
bool setKeyboardConf(QString strKey, QVariant value);
QVariant getUsdMediaKeys(QString strKey);
+ QVariant getUsdMediaStateKeys(QString strKey);
+ bool setUsdMediaStateKeys(QString strKey, QVariant value);
QList<QString> getSaverThemes();
@@ -363,6 +365,7 @@ Q_SIGNALS: // SIGNALS
void pamAuthCompleted();
void usdMediaKeysConfChanged(QString strKey, QString value);
+ void usdMediaStateKeysConfChanged(QString strKey, int value);
void bioServiceStatusChanged(bool bValid);
void bioDeviceChanged();
@@ -426,6 +429,7 @@ private:
void ParsePamAuthCompleted(const QJsonObject &objRes);
bool ParseUsdMediaKeysConf(const QJsonObject &objRes);
+ bool ParseUsdMediaStateKeysConf(const QJsonObject &objRes);
void ParseBioServiceStatus(const QJsonObject &objRes);
void ParseBioDeviceChanged(const QJsonObject &objRes);
diff --git a/src/lock-dialog/lockdialogmodel.cpp b/src/lock-dialog/lockdialogmodel.cpp
index 97a6e86..5992118 100644
--- a/src/lock-dialog/lockdialogmodel.cpp
+++ b/src/lock-dialog/lockdialogmodel.cpp
@@ -467,6 +467,11 @@ void LockDialogModel::onCapslockStateChanged(const bool capslockState)
Q_EMIT capslockStateChanged(capslockState);
}
+void LockDialogModel::onUsdMediaStateKeysChanged(const QString &key, const int &value)
+{
+ Q_EMIT usdMediaStateKeysChanged(key, value);
+}
+
void LockDialogModel::onUsdMediaKeysChanged(const QString &key, const QString &value)
{
Q_EMIT usdMediaKeysChanged(key, value);
@@ -509,6 +514,14 @@ void LockDialogModel::updateUsdMediaKeys(QString keys, QString value)
} else if (keys == KEY_WINDOW_SCREENSHOT) {
m_windowScreenshot = value;
}
+
+}
+
+void LockDialogModel::updateUsdMediaStateKeys(QString keys, int value)
+{
+ if (keys == KEY_RFKILL_STATE) {
+ m_rfkillState = value;
+ }
}
void LockDialogModel::updateLockEnabled(bool value)
diff --git a/src/lock-dialog/lockdialogmodel.h b/src/lock-dialog/lockdialogmodel.h
index e8bda6b..9da1586 100644
--- a/src/lock-dialog/lockdialogmodel.h
+++ b/src/lock-dialog/lockdialogmodel.h
@@ -99,6 +99,8 @@ public:
void updateUsdMediaKeys(QString keys, QString value);
+ void updateUsdMediaStateKeys(QString keys, int value);
+
void updateBatteryArgs(QStringList batteryArgs);
void updateBatteryIconName(QString iconName);
@@ -239,6 +241,11 @@ public:
return m_windowScreenshot;
}
+ inline int getUsdMediaRfkillState()
+ {
+ return m_rfkillState;
+ }
+
// inline QString getSaverMode() { return m_saverMode; }
// inline QString getSaverTheme() { return m_saverTheme; }
ScreenSaver *getScreensaver();
@@ -383,6 +390,8 @@ public Q_SLOTS:
void onUsdMediaKeysChanged(const QString &key, const QString &value);
+ void onUsdMediaStateKeysChanged(const QString &key, const int &value);
+
void onSecondRunParam(const QString &str);
void onLockScreenConfChanged(const QString &key, QVariant value);
@@ -528,6 +537,7 @@ Q_SIGNALS:
void bioAuthCompleted(int nUid, bool isSuccess, int nError, int nMaxFailedTime, int nFailedTime);
void usdMediaKeysChanged(const QString &key, const QString &value);
+ void usdMediaStateKeysChanged(const QString &key, const int &value);
void usdExternalDoAction(int actionType);
void setPowerManager(QString strFuncName);
@@ -545,6 +555,8 @@ Q_SIGNALS:
void setUserThemeColor(QString keyStr, QVariant themeColor);
+ void setRfkillState(QString value, int rfkillState);
+
private:
QString getXScreensaverPath(const QString &theme);
@@ -565,6 +577,8 @@ private:
QString m_screenShot2;
QString m_windowScreenshot;
+ int m_rfkillState = -1;
+
QString m_saverMode;
QList<QString> m_saverTheme;
int m_imageTSEffect;
diff --git a/src/lock-dialog/lockdialogperformer.cpp b/src/lock-dialog/lockdialogperformer.cpp
index 0ab512d..092de25 100644
--- a/src/lock-dialog/lockdialogperformer.cpp
+++ b/src/lock-dialog/lockdialogperformer.cpp
@@ -107,7 +107,11 @@ void LockDialogPerformer::initConnections()
&BackendDbusHelper::usdMediaKeysConfChanged,
m_modelLockDialog,
&LockDialogModel::onUsdMediaKeysChanged);
-
+ connect(
+ m_bdHelper,
+ &BackendDbusHelper::usdMediaStateKeysConfChanged,
+ m_modelLockDialog,
+ &LockDialogModel::onUsdMediaStateKeysChanged);
connect(
m_bdHelper, &BackendDbusHelper::tabletModeChanged, m_modelLockDialog, &LockDialogModel::onTabletModeChanged);
///通过信号直接调用槽
@@ -172,6 +176,7 @@ void LockDialogPerformer::initConnections()
connect(m_modelLockDialog, &LockDialogModel::getPublicEncrypt, m_bdHelper, &BackendDbusHelper::getPublicEncrypt);
connect(m_modelLockDialog, &LockDialogModel::sendPassword, m_bdHelper, &BackendDbusHelper::sendPassword);
connect(m_modelLockDialog, &LockDialogModel::setUserThemeColor, m_bdHelper, &BackendDbusHelper::setThemeStyleConf);
+ connect(m_modelLockDialog, &LockDialogModel::setRfkillState, m_bdHelper, &BackendDbusHelper::setUsdMediaStateKeys);
}
void LockDialogPerformer::initData()
@@ -192,6 +197,9 @@ void LockDialogPerformer::initData()
m_modelLockDialog->updateUsdMediaKeys(KEY_SCREEN_SHOT2, m_bdHelper->getUsdMediaKeys(KEY_SCREEN_SHOT2).toString());
m_modelLockDialog->updateUsdMediaKeys(
KEY_WINDOW_SCREENSHOT, m_bdHelper->getUsdMediaKeys(KEY_WINDOW_SCREENSHOT).toString());
+#ifdef USDFIXED
+ m_modelLockDialog->updateUsdMediaStateKeys(KEY_RFKILL_STATE, m_bdHelper->getUsdMediaStateKeys(KEY_RFKILL_STATE).toInt());
+#endif
m_modelLockDialog->updateScreensaverMode(m_bdHelper->getLockScreenConf(KEY_MODE).toString());
m_modelLockDialog->updateScreensaverTheme(m_bdHelper->getSaverThemes());
m_modelLockDialog->updateScreensaverImageTSEffect(
diff --git a/src/widgets/lockwidget.cpp b/src/widgets/lockwidget.cpp
index 53ab590..1442fb3 100644
--- a/src/widgets/lockwidget.cpp
+++ b/src/widgets/lockwidget.cpp
@@ -413,6 +413,9 @@ void LockWidget::initPowerWidget()
void LockWidget::initButtonWidget()
{
+#ifdef USDFIXED
+ initUsdMediaStateKeys();
+#endif
m_pBottomWidget = new QWidget(this);
QHBoxLayout *bottomWidgetLayout = new QHBoxLayout(m_pBottomWidget);
bottomWidgetLayout->setContentsMargins(RIGHT_MARGIN * scale - 16, 0, RIGHT_MARGIN * scale - 16, 0);
@@ -489,6 +492,22 @@ void LockWidget::initButtonWidget()
buttonListWidget->setItemHidden(m_btnItemUser, true);
}
+#ifdef USDFIXED
+ if (m_rfkillState != -1) {
+ m_pRfkillStatusButton = new StatusButton(this, BOTBUTTON);
+ QListWidgetItem *rekillButtonItem = new QListWidgetItem();
+ rekillButtonItem->setSizeHint(QSize(48, 48));
+ buttonListWidget->insertItem(buttonListWidget->count(), rekillButtonItem);
+ buttonListWidget->setItemWidget(rekillButtonItem, m_pRfkillStatusButton);
+ setRfkillBtnIcon();
+ buttonListWidget->addItem(rekillButtonItem);
+ connect(m_pRfkillStatusButton, &StatusButton::clicked, this, [this]() {
+ setRfkillState();
+// setRfkillBtnIcon();
+ });
+ }
+#endif
+
m_networkButton = new NetWorkButton(this);
QListWidgetItem *buttonItem = new QListWidgetItem();
buttonItem->setSizeHint(QSize(48, 48));
@@ -581,6 +600,12 @@ void LockWidget::initUsdMediaKeys()
connect(m_modelLockDialog, &LockDialogModel::usdMediaKeysChanged, this, &LockWidget::onUsdMediaKeysChanged);
}
+void LockWidget::initUsdMediaStateKeys()
+{
+ m_rfkillState = m_modelLockDialog->getUsdMediaRfkillState();
+ connect(m_modelLockDialog, &LockDialogModel::usdMediaStateKeysChanged, this, &LockWidget::onUsdMediaStateKeysChanged);
+}
+
const QKeySequence LockWidget::listFromString(QString keys)
{
keys.replace("<", "");
@@ -814,6 +839,14 @@ void LockWidget::onUsdMediaKeysChanged(const QString &keys, const QString &value
}
}
+void LockWidget::onUsdMediaStateKeysChanged(const QString &keys, const int &value)
+{
+ if (keys == KEY_RFKILL_STATE) {
+ m_rfkillState = value;
+ setRfkillBtnIcon();
+ }
+}
+
void LockWidget::onShowSessionListWidget()
{
initSessionWidget();
@@ -1341,6 +1374,27 @@ void LockWidget::SwitchToUser(QString strUserName)
}
}
+void LockWidget::setRfkillState()
+{
+ if (m_rfkillState == 0) {
+ Q_EMIT m_modelLockDialog->setRfkillState(KEY_RFKILL_STATE, 1);
+ } else if (m_rfkillState == 1) {
+ Q_EMIT m_modelLockDialog->setRfkillState(KEY_RFKILL_STATE, 0);
+ }
+ m_pRfkillStatusButton->setClickedStatus(NORMAL);
+}
+
+void LockWidget::setRfkillBtnIcon()
+{
+ if (m_rfkillState == 0) {
+ QPixmap rfkillOffIcon = drawSymbolicColoredPixmap(QIcon::fromTheme("ukui-airplane-mode-on-symbolic").pixmap(QSize(24, 24)), "gray");
+ m_pRfkillStatusButton->setIcon(rfkillOffIcon);
+ } else if (m_rfkillState == 1) {
+ QPixmap rfkillOnIcon = drawSymbolicColoredPixmap(QIcon::fromTheme("ukui-airplane-mode-on-symbolic").pixmap(QSize(24, 24)), "white");
+ m_pRfkillStatusButton->setIcon(QIcon(rfkillOnIcon));
+ }
+}
+
void LockWidget::refreshTranslate()
{
QLocale local;
diff --git a/src/widgets/lockwidget.h b/src/widgets/lockwidget.h
index 7c07485..61fc763 100644
--- a/src/widgets/lockwidget.h
+++ b/src/widgets/lockwidget.h
@@ -104,6 +104,8 @@ private:
*/
static const QKeySequence listFromString(QString shortcuts);
+ void initUsdMediaStateKeys();
+
void updateBottomButton();
void SwitchToUser(QString strUserName);
@@ -118,6 +120,10 @@ private:
void setBatteryWidgetLocate();
+ void setRfkillState();
+
+ void setRfkillBtnIcon();
+
private Q_SLOTS:
/**
* @brief item选中状态改变
@@ -141,6 +147,7 @@ private Q_SLOTS:
void onUserChangedByManual(const QString &userName);
void onUsdMediaKeysChanged(const QString &keys, const QString &value);
+ void onUsdMediaStateKeysChanged(const QString &keys, const int &value);
void onShowSessionListWidget();
void onShowBatteryWidget();
@@ -223,6 +230,8 @@ private:
QString m_screenShot2;
QString m_windowScreenshot;
+ int m_rfkillState = -1;
+
MyNetworkWidget *m_networkWidget = nullptr;
BatteryWidget *batteryWidget = nullptr;
VirtualKeyboardWidget *m_virtualKeyboardWidget = nullptr;
@@ -241,6 +250,7 @@ private:
NetWorkButton *m_networkButton = nullptr;
StatusButton *m_virKbButton = nullptr;
StatusButton *m_powerManagerButton = nullptr;
+ StatusButton *m_pRfkillStatusButton = nullptr;
// 底部系统监视器按钮
StatusButton *m_systemMonitorBtn = nullptr;
diff --git a/src/widgets/powerlistwidget.cpp b/src/widgets/powerlistwidget.cpp
index db1b990..2f9d44e 100644
--- a/src/widgets/powerlistwidget.cpp
+++ b/src/widgets/powerlistwidget.cpp
@@ -190,7 +190,7 @@ void PowerListWidget::onListItemClicked(QListWidgetItem *item)
if (shutdownLockcheck.count() > 0) {
Q_EMIT showInhibitWarning(shutdownLockcheck, powerBtnList[i].m_inhibitType, false);
break;
- } else if (m_modelLockDialog->getLoggedInUsersCount() > 1) {
+ } else if (m_modelLockDialog->getLoggedInUsersCount() > 1 && powerBtnList[i].setFuncName != "Logout") {
Q_EMIT mulUsersLogined(powerBtnList[i].m_inhibitType, false);
break;
}

View File

@ -36,3 +36,4 @@
0036-88.patch
0037-89.patch
0038-Translated-using-Weblate-Uyghur.patch
0039-1.patch