diff --git a/BiometricAuth/BiometricAuth.pri b/BiometricAuth/BiometricAuth.pri deleted file mode 100644 index cbb2ea1..0000000 --- a/BiometricAuth/BiometricAuth.pri +++ /dev/null @@ -1,9 +0,0 @@ -SOURCES += \ - $$PWD/biometricproxy.cpp \ - $$PWD/biometricauthwidget.cpp \ - $$PWD/biometricdeviceswidget.cpp - -HEADERS += \ - $$PWD/biometricproxy.h \ - $$PWD/biometricauthwidget.h \ - $$PWD/biometricdeviceswidget.h diff --git a/BiometricAuth/BiometricAuth.pro b/BiometricAuth/BiometricAuth.pro deleted file mode 100644 index 00bc543..0000000 --- a/BiometricAuth/BiometricAuth.pro +++ /dev/null @@ -1,37 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2018-12-06T09:17:41 -# -#------------------------------------------------- - -QT += core gui dbus - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -TARGET = BiometricAuth -TEMPLATE = app - -# The following define makes your compiler emit warnings if you use -# any feature of Qt which has been marked as deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if you use deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - - -SOURCES += \ - main.cpp \ - biometricauthwidget.cpp \ - biometricproxy.cpp \ - biometricdeviceswidget.cpp - -HEADERS += \ - biometricauthwidget.h \ - biometricproxy.h \ - biometricdeviceswidget.h - -FORMS += diff --git a/BiometricAuth/CMakeLists.txt b/BiometricAuth/CMakeLists.txt deleted file mode 100644 index e1b52a5..0000000 --- a/BiometricAuth/CMakeLists.txt +++ /dev/null @@ -1,27 +0,0 @@ -qt5_wrap_cpp(BiometricAuth_SRC - biometricdeviceinfo.h - biometricproxy.h - giodbus.h - uniauthservice.h - ) - -set(BiometricAuth_SRC - ${BiometricAuth_SRC} - biometricdeviceinfo.cpp - biometricproxy.cpp - giodbus.cpp - uniauthservice.cpp - ) - -include_directories( - ${Qt5Core_INCLUDE_DIRS} - ${Qt5Widgets_INCLUDE_DIRS} - ${Qt5DBus_INCLUDE_DIRS} - ${GLIB2_INCLUDE_DIRS} - ${GIOUNIX2_INCLUDE_DIRS} - ) - - -add_library(BiometricAuth STATIC ${BiometricAuth_SRC}) -target_link_libraries(BiometricAuth Qt5::Core Qt5::DBus Qt5::Widgets - ${GIOUNIX2_LIBRARIES}) diff --git a/BiometricAuth/biometricauthwidget.cpp b/BiometricAuth/biometricauthwidget.cpp deleted file mode 100644 index 4a03938..0000000 --- a/BiometricAuth/biometricauthwidget.cpp +++ /dev/null @@ -1,343 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#include "biometricauthwidget.h" -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "giodbus.h" - -BiometricAuthWidget::BiometricAuthWidget(BiometricProxy *proxy, QWidget *parent) : - QWidget(parent), - proxy(proxy), - isInAuth(false), - movieTimer(nullptr), - failedCount(0), - timeoutCount(0), - beStopped(false), - retrytimer(nullptr), - usebind(false) -{ - usebind = getAuthDouble(); - initUI(); - resize(400, 260); - - if(this->proxy) - { - connect(this->proxy, &BiometricProxy::StatusChanged, - this, &BiometricAuthWidget::onStatusChanged); - - connect(this->proxy, &BiometricProxy::FrameWritten, - this, &BiometricAuthWidget::onFrameWritten); - } - -} - -void BiometricAuthWidget::initUI() -{ - //显示提示信息 - lblNotify = new QLabel(this); - lblNotify->setWordWrap(true); - lblNotify->setAlignment(Qt::AlignHCenter | Qt::AlignBottom); - - //显示当前设备 - lblDevice = new QLabel(this); - lblDevice->setWordWrap(true); - lblDevice->setAlignment(Qt::AlignCenter); - - //显示图片 - lblImage = new QLabel(this); - lblImage->setFixedSize(100, 100); - -} - - -void BiometricAuthWidget::resizeEvent(QResizeEvent */*event*/) -{ - lblNotify->setGeometry(0, 0, width(), 45); - lblDevice->setGeometry(0, lblNotify->geometry().bottom()+5, width(), 30); - lblImage->setGeometry((width() - lblImage->width()) / 2, - lblDevice->geometry().bottom() + 10, - lblImage->width(), lblImage->height()); - //qDebug() -} - -void BiometricAuthWidget::startAuth(DeviceInfoPtr device, int uid) -{ - if(!proxy) - { - qWarning() << "BiometricProxy doesn't exist."; - return; - } - - if(isInAuth) - { - qDebug() << "Identification is currently under way, stop it"; - stopAuth(); - } - - this->device = device; - this->uid = uid; - this->userName = getpwuid(uid)->pw_name; - this->failedCount = 0; - this->timeoutCount = 0; - this->beStopped = false; - proxy->StopOps(device->id); - startAuth_(); - - if(device->deviceType != DeviceType::Type::Face){ - updateImage(1); - } - -} - -void BiometricAuthWidget::startAuth_() -{ - lblDevice->setText(tr("Current device: ") + device->shortName); - - //qDebug().noquote() << QString("Identify:[drvid: %1, uid: %2]").arg(1).arg(2); - - isInAuth = true; - dup_fd = -1; - - QDBusPendingCall call = proxy->Identify(device->id, uid); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this); - connect(watcher, &QDBusPendingCallWatcher::finished, - this, &BiometricAuthWidget::onIdentifyComplete); - -} - -void BiometricAuthWidget::stopAuth() -{ - beStopped = true; - if(!isInAuth) - { - return; - } - - proxy->StopOps(device->id); - if(retrytimer&&retrytimer->isActive()){ - retrytimer->stop(); - delete retrytimer; - retrytimer = nullptr; - } - isInAuth = false; - updateImage(0); -} - -void BiometricAuthWidget::onIdentifyComplete(QDBusPendingCallWatcher *watcher) -{ - QDBusPendingReply reply = *watcher; - if(reply.isError()) - { - qWarning() << "Identify error: " << reply.error().message(); - Q_EMIT authComplete(false); - updateImage(0); - return; - } - int result = reply.argumentAt(0).toInt(); - int authUid = reply.argumentAt(1).toInt(); - - // 特征识别成功,而且用户id匹配 - if(result == DBUS_RESULT_SUCCESS && authUid == uid) - { - qDebug() << "Identify success"; - Q_EMIT authComplete(true); - } - // 特征识别不匹配 - else if(result == DBUS_RESULT_NOTMATCH) - { - if(usebind){ - Q_EMIT authComplete(false); - return; - } - qDebug() << "Identify failed"; - failedCount++; - if(failedCount >= GetMaxFailedAutoRetry(userName)) - { - Q_EMIT authComplete(false); - } - else - { - lblNotify->setText(tr("Identify failed, Please retry.")); - if(!beStopped){ - // QTimer::singleShot(1000, this, &BiometricAuthWidget::startAuth_); - if(!retrytimer){ - retrytimer = new QTimer(this); - retrytimer->setSingleShot(true); - connect(retrytimer, &QTimer::timeout, this, &BiometricAuthWidget::startAuth_); - } - retrytimer->start(1000); - } - } - } - //识别发生错误 - else if(result == DBUS_RESULT_ERROR) - { - if(usebind){ - Q_EMIT authComplete(false); - return; - } - StatusReslut ret = proxy->UpdateStatus(device->id); - //识别操作超时 - if(ret.result == 0 && ret.opsStatus == OPS_IDENTIFY_TIMEOUT) - { - timeoutCount++; - if(timeoutCount >= GetMaxTimeoutAutoRetry(userName)) - { - Q_EMIT authComplete(false); - } - else - { - QTimer::singleShot(1000, [&]{ - if(!beStopped) - { - startAuth_(); - } - }); - } - }else{ - Q_EMIT authComplete(false); - } - }else{ - Q_EMIT authComplete(false); - } - updateImage(0); -} - -void BiometricAuthWidget::onFrameWritten(int drvid) -{ - - if(dup_fd == -1){ - dup_fd = get_server_gvariant_stdout(drvid); - } - - if(dup_fd <= 0) - return ; - - cv::Mat img; - lseek(dup_fd, 0, SEEK_SET); - char base64_bufferData[1024*1024]; - int rc = read(dup_fd, base64_bufferData, 1024*1024); - printf("rc = %d\n", rc); - - cv::Mat mat2(1, sizeof(base64_bufferData), CV_8U, base64_bufferData); - img = cv::imdecode(mat2, cv::IMREAD_COLOR); - cv::cvtColor(img,img,cv::COLOR_BGR2RGB); - - QImage srcQImage = QImage((uchar*)(img.data), img.cols, img.rows, QImage::Format_RGB888); - lblImage->setFixedSize(160,160); - lblImage->setGeometry((width() - lblImage->width()) / 2, - lblDevice->geometry().bottom() + 10, - lblImage->width(), lblImage->height()); - lblImage->setPixmap(QPixmap::fromImage(srcQImage).scaled(lblImage->size())); - -} - -void BiometricAuthWidget::onStatusChanged(int drvid, int status) -{ - if(!isInAuth) - { - return; - } - if(drvid != device->id) - { - return; - } - - // 显示来自服务的提示信息 - if(status == STATUS_NOTIFY) - { - QString notifyMsg = proxy->GetNotifyMesg(drvid); - lblNotify->setText(notifyMsg); - } -} - -static int count = 0; -void BiometricAuthWidget::updateImage(int type) -{ - if(device->deviceType == DeviceType::Type::Face) - return ; - - if(type == 0) - { - if(movieTimer && movieTimer->isActive()) - { - movieTimer->stop(); - } - - QString imagePath = QString(UKUI_BIOMETRIC_IMAGES_PATH "%1/01.png") - .arg(DeviceType::getDeviceType(device->deviceType)); - setImage(imagePath); - } - else - { - if(!movieTimer) - { - movieTimer = new QTimer(this); - movieTimer->setInterval(100); - connect(movieTimer, &QTimer::timeout, - this, &BiometricAuthWidget::onMoviePixmapUpdate); - } - count = 0; - movieTimer->start(); - } -} - -void BiometricAuthWidget::onMoviePixmapUpdate() -{ - if(count >= 18) - { - count = 0; - } - count++; - QString fileName = (count < 10 ? "0" : "") + QString::number(count); - QString imagePath = QString(UKUI_BIOMETRIC_IMAGES_PATH "%1/%2.png") - .arg(DeviceType::getDeviceType(device->deviceType)) - .arg(fileName); - setImage(imagePath); -} - -void BiometricAuthWidget::setImage(const QString &path) -{ - QPixmap image(path); - image = image.scaled(lblImage->width(), lblImage->height(), - Qt::IgnoreAspectRatio, Qt::SmoothTransformation); - - lblImage->setPixmap(image); -} - -bool BiometricAuthWidget::getAuthDouble() -{ - QSettings settings("/etc/biometric-auth/ukui-biometric.conf", QSettings::IniFormat); - bool distribId = settings.value("DoubleAuth").toBool(); - return distribId; -} - -void BiometricAuthWidget::setMinImage(float val) -{ - resize(400,100+100*val); - lblImage->setFixedSize(100*val, 100*val); -} diff --git a/BiometricAuth/biometricauthwidget.h b/BiometricAuth/biometricauthwidget.h deleted file mode 100644 index 8390a02..0000000 --- a/BiometricAuth/biometricauthwidget.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#ifndef BIOMETRICAUTHWIDGET_H -#define BIOMETRICAUTHWIDGET_H - -#include -#include "biometricproxy.h" - -class QLabel; -//class QDBusPendingCallWatcher; -//class BiometricProxy; -//class DeviceIdentityPtr; -class BiometricAuthWidget : public QWidget -{ - Q_OBJECT -public: - explicit BiometricAuthWidget(BiometricProxy *proxy, QWidget *parent = 0); - - /** - * @brief 进行生物识别认证 - * @param deviceInfo 使用的设备 - * @param uid 待认证的用户id - */ - void startAuth(DeviceInfoPtr device, int uid); - - /** - * @brief 终止生物识别认证 - */ - void stopAuth(); - - bool isAuthenticating() { return isInAuth; } - - void setMinImage(float val); - -protected: - void resizeEvent(QResizeEvent *event); - -Q_SIGNALS: - /** - * @brief 认证完成 - * @param result 认证结果 - */ - void authComplete(bool result); - -private Q_SLOTS: - void onIdentifyComplete(QDBusPendingCallWatcher *watcher); - void onStatusChanged(int drvid, int status); - void onFrameWritten(int drvid); - void onMoviePixmapUpdate(); - void startAuth_(); - -private: - void initUI(); - void updateImage(int type = 0); - void setImage(const QString &path); - bool getAuthDouble(); - -private: - QLabel *lblNotify; - QLabel *lblDevice; - QLabel *lblImage; - - BiometricProxy *proxy; - int uid; - QString userName; - DeviceInfoPtr device; - bool isInAuth; - QTimer *movieTimer; - int failedCount; - int timeoutCount; - bool beStopped; - QTimer *retrytimer; - bool usebind; - int fd = -1; - int dup_fd = -1; -}; - -#endif // BIOMETRICAUTHWIDGET_H diff --git a/BiometricAuth/biometricdeviceinfo.cpp b/BiometricAuth/biometricdeviceinfo.cpp deleted file mode 100644 index 881c79a..0000000 --- a/BiometricAuth/biometricdeviceinfo.cpp +++ /dev/null @@ -1,291 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#include "biometricdeviceinfo.h" - -#include -#include -#include -//#include - -QString DeviceType::getDeviceType(int deviceType) -{ - if(deviceType >= __MAX_NR_TYPES) - { - return ""; - } - QMetaEnum meta = QMetaEnum::fromType(); - const char *typeString = meta.valueToKey(deviceType); - return QString(typeString); -} - -int DeviceType::getBioType(int bioType) -{ - switch(bioType) - { - case Face: - return 0; - case FingerPrint: - return 1; - case FingerVein: - return 2; - case Iris: - return 3; - case VoicePrint: - return 4; - default: - return -1; - } -} - -QString DeviceType::getDeviceType_tr(int deviceType) -{ - switch(deviceType) - { - case FingerPrint: - return tr("FingerPrint"); - case FingerVein: - return tr("FingerVein"); - case Iris: - return tr("Iris"); - case Face: - return tr("Face"); - case VoicePrint: - return tr("VoicePrint"); - case LOGINOPT_TYPE_GENERAL_UKEY: - return tr("Ukey"); - case REMOTE_QRCODE_TYPE: - return tr("QRCode"); - default: - return ""; - } -} - -QDebug operator <<(QDebug stream, const DeviceInfo &deviceInfo) -{ - stream << "[" - << deviceInfo.id - << deviceInfo.shortName - << deviceInfo.fullName - << deviceInfo.deviceType - << deviceInfo.driverEnable - << deviceInfo.deviceNum - << "]"; - return stream; -} - -QDBusArgument &operator <<(QDBusArgument &arg, const DeviceInfo &deviceInfo) -{ - arg.beginStructure(); - arg << deviceInfo.id - << deviceInfo.shortName - << deviceInfo.fullName - << deviceInfo.driverEnable - << deviceInfo.deviceNum - << deviceInfo.deviceType - << deviceInfo.storageType - << deviceInfo.eigType - << deviceInfo.verifyType - << deviceInfo.identifyType - << deviceInfo.busType - << deviceInfo.deviceStatus - << deviceInfo.OpsStatus; - arg.endStructure(); - return arg; -} -const QDBusArgument &operator >>(const QDBusArgument &arg, DeviceInfo &deviceInfo) -{ - arg.beginStructure(); - arg >> deviceInfo.id - >> deviceInfo.shortName - >> deviceInfo.fullName - >> deviceInfo.driverEnable - >> deviceInfo.deviceNum - >> deviceInfo.deviceType - >> deviceInfo.storageType - >> deviceInfo.eigType - >> deviceInfo.verifyType - >> deviceInfo.identifyType - >> deviceInfo.busType - >> deviceInfo.deviceStatus - >> deviceInfo.OpsStatus; - arg.endStructure(); - return arg; -} - -/* For the type FeatureInfo */ -QDBusArgument &operator<<(QDBusArgument &argument, const FeatureInfo &featureInfo) -{ - argument.beginStructure(); - argument << featureInfo.uid << featureInfo.biotype - << featureInfo.device_shortname << featureInfo.index - << featureInfo.index_name; - argument.endStructure(); - return argument; -} - -const QDBusArgument &operator>>(const QDBusArgument &argument, FeatureInfo &featureInfo) -{ - argument.beginStructure(); - argument >> featureInfo.uid >> featureInfo.biotype - >> featureInfo.device_shortname >> featureInfo.index - >> featureInfo.index_name; - argument.endStructure(); - return argument; -} - -void registerMetaType() -{ - qRegisterMetaType("DeviceInfo"); - qDBusRegisterMetaType(); - qRegisterMetaType("FeatureInfo"); - qDBusRegisterMetaType(); -} - - -QString GetDefaultDevice(const QString &userName) -{ - //QString configPath = QString("/home/%1/" UKUI_BIOMETRIC_CONFIG_PATH).arg(userName); - QString configPath = QDir::homePath() + "/" + UKUI_BIOMETRIC_CONFIG_PATH; - QSettings settings(configPath, QSettings::IniFormat); - qDebug() << "configure path: " << settings.fileName(); - - QString defaultDevice = settings.value("DefaultDevice").toString(); - if(defaultDevice.isEmpty()) - { - QSettings sysSettings(UKUI_BIOMETRIC_SYS_CONFIG_PATH, QSettings::IniFormat); - defaultDevice = sysSettings.value("DefaultDevice").toString(); - } - - return defaultDevice; -} - -int GetLastDevice(const QString &userName) -{ - int nLastDevId = -1; - QSettings sysSettings(QString(SHARE_BIOMETRIC_CONFIG_PATH).arg(userName), QSettings::IniFormat); - sysSettings.beginGroup("Common"); - if (sysSettings.allKeys().contains("LastDeviceId")) { - nLastDevId = sysSettings.value("LastDeviceId").toInt(); - } - sysSettings.endGroup(); - return nLastDevId; -} - -void SetLastDevice(const QString &userName, int drvid) -{ - if (drvid < 0) { - return; - } - QString desConfPath = QString(SHARE_BIOMETRIC_CONFIG_PATH).arg(userName); - QFile fileConf(desConfPath); - if (fileConf.exists()) { - QSettings sysSettings(desConfPath, QSettings::IniFormat); - sysSettings.beginGroup("Common"); - sysSettings.setValue("LastDeviceId", drvid); - sysSettings.endGroup(); - } else { - QSettings sysSettings(desConfPath, QSettings::IniFormat); - sysSettings.beginGroup("Common"); - sysSettings.setValue("LastDeviceId", drvid); - sysSettings.endGroup(); - sysSettings.sync(); - QFile file(desConfPath); - file.setPermissions(QFile::WriteUser | QFile::ReadUser | QFile::WriteOther | QFile::ReadOther); - } -} - -static int getValueFromSettings(const QString &userName, const QString &key, int defaultValue = 3) -{ - //从家目录下的配置文件中获取 - //QString configPath = QString("/home/%1/" UKUI_BIOMETRIC_CONFIG_PATH).arg(userName); - QString configPath = QDir::homePath() + "/" + UKUI_BIOMETRIC_CONFIG_PATH; - QSettings settings(configPath, QSettings::IniFormat); - QString valueStr = settings.value(key).toString(); - - //如果没有获取到,则从系统配置文件中获取 - if(valueStr.isEmpty()) - { - QSettings sysSettings(UKUI_BIOMETRIC_SYS_CONFIG_PATH, QSettings::IniFormat); - valueStr = sysSettings.value(key).toString(); - } - - bool ok; - int value = valueStr.toInt(&ok); - if( (value == 0 && !ok) || valueStr.isEmpty() ) - { - value = defaultValue; - } - return value; -} - -bool GetHiddenSwitchButton() -{ - QSettings sysSettings(UKUI_BIOMETRIC_SYS_CONFIG_PATH, QSettings::IniFormat); - if(sysSettings.contains("HiddenSwitchButton")) - return sysSettings.value("HiddenSwitchButton").toBool(); - else - return false; -} - -int GetFailedTimes() -{ - QSettings sysSettings(UKUI_BIOMETRIC_SYS_CONFIG_PATH, QSettings::IniFormat); - if(sysSettings.contains("MaxFailedTimes")) - return sysSettings.value("MaxFailedTimes").toInt(); - else - return 3; -} - -bool GetAuthEnable() -{ - bool isEnable = false; - QSettings sysSettings(UKUI_BIOMETRIC_SYS_CONFIG_PATH, QSettings::IniFormat); - if(sysSettings.contains("EnableAuth")) - isEnable = sysSettings.value("EnableAuth").toBool(); - else - isEnable = false; - - if(isEnable && sysSettings.allKeys().contains("EnableAuthApp")){ - int isEnableApp = sysSettings.value("EnableAuthApp").toInt(); - isEnable = isEnableApp & (1<<1); - } - - return isEnable; -} - -bool GetQRCodeEnable() -{ - bool isEnable = false; - QSettings sysSettings(UKUI_BIOMETRIC_SYS_CONFIG_PATH, QSettings::IniFormat); - sysSettings.beginGroup("Functions"); - if (sysSettings.allKeys().contains("EnableQRCode")) { - isEnable = sysSettings.value("EnableQRCode").toBool(); - } - sysSettings.endGroup(); - return isEnable; -} - -int GetMaxFailedAutoRetry(const QString &userName) -{ - return getValueFromSettings(userName, "MaxFailedAutoRetry"); -} - -int GetMaxTimeoutAutoRetry(const QString &userName) -{ - return getValueFromSettings(userName, "MaxTimeoutAutoRetry"); -} diff --git a/BiometricAuth/biometricdeviceswidget.cpp b/BiometricAuth/biometricdeviceswidget.cpp deleted file mode 100644 index 0766ae3..0000000 --- a/BiometricAuth/biometricdeviceswidget.cpp +++ /dev/null @@ -1,279 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#include "biometricdeviceswidget.h" -#include -#include -#include -#include -#include -#include - - -BiometricDevicesWidget::BiometricDevicesWidget(BiometricProxy *proxy, int uid,QWidget *parent) - : QWidget(parent), - proxy(proxy), - m_uid(uid) -{ - initUI(); - if(proxy && proxy->isValid()) - { - connect(proxy, &BiometricProxy::USBDeviceHotPlug, - this, &BiometricDevicesWidget::onUSBDeviceHotPlug); - updateDevice(); - } - - resize(500, 500); -} - -void BiometricDevicesWidget::initUI() -{ - lblPrompt = new QLabel(this); - lblPrompt->setObjectName(QStringLiteral("lblBioetricDevicesPrompt")); - lblPrompt->setText(tr("Please select the biometric device")); - lblPrompt->setAlignment(Qt::AlignHCenter); - - lblDeviceType = new QLabel(this); - lblDeviceType->setObjectName(QStringLiteral("lblDeviceType")); - lblDeviceType->setText(tr("Device type:")); - lblDeviceType->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); - - QStyledItemDelegate* itemDelegate = new QStyledItemDelegate(); - - cmbDeviceType = new QComboBox(this); - cmbDeviceType->view()->parentWidget()->setWindowFlags(Qt::Popup|Qt::FramelessWindowHint); - cmbDeviceType->view()->parentWidget()->setAttribute(Qt::WA_TranslucentBackground); - cmbDeviceType->setObjectName(QStringLiteral("cmbDeviceType")); - cmbDeviceType->setMaxVisibleItems(5); - cmbDeviceType->setItemDelegate(itemDelegate); - connect(cmbDeviceType, SIGNAL(currentIndexChanged(int)), - this, SLOT(onCmbDeviceTypeCurrentIndexChanged(int))); - - lblDeviceName = new QLabel(this); - lblDeviceName->setObjectName(QStringLiteral("lblDeviceName")); - lblDeviceName->setText(tr("Device name:")); - lblDeviceName->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); - - cmbDeviceName = new QComboBox(this); - cmbDeviceName->view()->parentWidget()->setWindowFlags(Qt::Popup|Qt::FramelessWindowHint); - cmbDeviceName->view()->parentWidget()->setAttribute(Qt::WA_TranslucentBackground); - cmbDeviceName->setObjectName(QStringLiteral("cmbDeviceName")); - cmbDeviceName->setMaxVisibleItems(5); - cmbDeviceName->setItemDelegate(itemDelegate); - - btnOK = new QPushButton(tr("OK"), this); - btnOK->setObjectName(QStringLiteral("OKButton")); - btnOK->setCursor(Qt::PointingHandCursor); - connect(btnOK, &QPushButton::clicked, - this, &BiometricDevicesWidget::onOKButtonClicked); -} - -void BiometricDevicesWidget::setUser(int user) -{ - m_uid = user; -} - -void BiometricDevicesWidget::resizeEvent(QResizeEvent */*event*/) -{ - lblPrompt->setGeometry(0, 0, width(), 40); - lblDeviceType->setGeometry(100, lblPrompt->geometry().bottom() + 40, - 120, 20); - cmbDeviceType->setGeometry(100, lblDeviceType->geometry().bottom() + 15, - 300, 40); - lblDeviceName->setGeometry(100, cmbDeviceType->geometry().bottom() + 80, - 120, 20); - cmbDeviceName->setGeometry(100, lblDeviceName->geometry().bottom() + 15, - 300, 40); - btnOK->setGeometry(100, cmbDeviceName->geometry().bottom() + 80, 140, 38); - -} - -void BiometricDevicesWidget::updateDevice() -{ - deviceMap.clear(); - DeviceList deviceList = proxy->GetDevList(); - for(auto pDeviceInfo : deviceList) - { - qDebug() << *pDeviceInfo; - if(proxy->GetUserDevFeatureCount(m_uid,pDeviceInfo->id) > 0) - deviceMap[pDeviceInfo->deviceType].push_back(pDeviceInfo); - } - cmbDeviceType->clear(); - for(int type : deviceMap.keys()) - { - QString iconPath = QString(UKUI_BIOMETRIC_IMAGES_PATH"icon/%1.png") - .arg(DeviceType::getDeviceType(type)); - qDebug() << iconPath; - cmbDeviceType->addItem(QIcon(iconPath), DeviceType::getDeviceType_tr(type), type); - } - if(deviceMap.size() > 0) - { - int index = deviceMap.keys().at(0); - setCurrentDevice(deviceMap[index].at(0)); - } - -} - - -void BiometricDevicesWidget::setCurrentDevice(int drvid) -{ - DeviceInfoPtr pDeviceInfo = findDeviceById(drvid); - if(pDeviceInfo) - { - setCurrentDevice(pDeviceInfo); - } -} - -void BiometricDevicesWidget::setCurrentDevice(const QString &deviceName) -{ - DeviceInfoPtr pDeviceInfo = findDeviceByName(deviceName); - if(pDeviceInfo) - { - setCurrentDevice(pDeviceInfo); - } -} - -void BiometricDevicesWidget::setCurrentDevice(const DeviceInfoPtr &pDeviceInfo) -{ - this->currentDevice = pDeviceInfo; - cmbDeviceType->setCurrentText(DeviceType::getDeviceType_tr(pDeviceInfo->deviceType)); - cmbDeviceName->setCurrentText(pDeviceInfo->shortName); -} - -bool BiometricDevicesWidget::deviceExists(int drvid) -{ - return (findDeviceById(drvid) != nullptr); -} - -bool BiometricDevicesWidget::deviceExists(const QString &deviceName) -{ - return (findDeviceByName(deviceName) != nullptr); -} - -DeviceInfoPtr BiometricDevicesWidget::findDeviceById(int drvid) -{ - for(int type : deviceMap.keys()) - { - DeviceList &deviceList = deviceMap[type]; - auto iter = std::find_if(deviceList.begin(), deviceList.end(), - [&](DeviceInfoPtr ptr){ - return ptr->id == drvid; - }); - if(iter != deviceList.end()) - { - return *iter; - } - } - return DeviceInfoPtr(); -} - -DeviceInfoPtr BiometricDevicesWidget::findDeviceByName(const QString &name) -{ - for(int type : deviceMap.keys()) - { - DeviceList &deviceList = deviceMap[type]; - auto iter = std::find_if(deviceList.begin(), deviceList.end(), - [&](DeviceInfoPtr ptr){ - return ptr->shortName == name; - }); - if(iter != deviceList.end()) - { - return *iter; - } - } - return DeviceInfoPtr(); -} - -void BiometricDevicesWidget::onCmbDeviceTypeCurrentIndexChanged(int index) -{ - if(index < 0 || index >= deviceMap.keys().size()) - { - return; - } - int type = cmbDeviceType->itemData(index).toInt(); - cmbDeviceName->clear(); - for(auto &deviceInfo : deviceMap.value(type)) - { - cmbDeviceName->addItem(deviceInfo->shortName); - } -} - -void BiometricDevicesWidget::onOKButtonClicked() -{ - int type = cmbDeviceType->currentData().toInt(); - int index = cmbDeviceName->currentIndex(); - qDebug() << type << index; - DeviceInfoPtr deviceInfo = deviceMap.value(type).at(index); - Q_EMIT deviceChanged(deviceInfo); - hide(); -} - -void BiometricDevicesWidget::onUSBDeviceHotPlug(int drvid, int action, int /*devNum*/) -{ - int savedDeviceId = currentDevice->id; - int savedCount = 0; - for(int type : deviceMap.keys()) - savedCount += deviceMap.value(type).count(); - - switch(action) - { - case ACTION_ATTACHED: - { - //插入设备后,需要更新设备列表 - deviceMap.clear(); - updateDevice(); - setCurrentDevice(savedDeviceId); - break; - } - case ACTION_DETACHED: - { - DeviceInfoPtr pDeviceInfo = findDeviceById(drvid); - if(pDeviceInfo) - { - int type = pDeviceInfo->deviceType; - deviceMap[type].removeOne(pDeviceInfo); - int index = cmbDeviceName->findText(pDeviceInfo->shortName); - cmbDeviceName->removeItem(index); - - //如果该类型的设备全被移除,删除该类型相关的列表 - if(deviceMap[type].isEmpty()) - { - deviceMap.remove(type); - index = cmbDeviceType->findData(type); - cmbDeviceType->removeItem(index); - } - } - if(savedDeviceId != drvid) - { - setCurrentDevice(savedDeviceId); - } - break; - } - } - - int count = 0; - for(int type : deviceMap.keys()) - count += deviceMap.value(type).count(); - - //设备数量发生了变化 - if(count != savedCount) - { - Q_EMIT deviceCountChanged(count); - } -} - - diff --git a/BiometricAuth/biometricdeviceswidget.h b/BiometricAuth/biometricdeviceswidget.h deleted file mode 100644 index bdef3da..0000000 --- a/BiometricAuth/biometricdeviceswidget.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#ifndef BIOMETRICDEVICESWIDGET_H -#define BIOMETRICDEVICESWIDGET_H - -#include -#include "biometricproxy.h" - -class QLabel; -class QPushButton; -class QComboBox; - - -class BiometricDevicesWidget : public QWidget -{ - Q_OBJECT -public: - explicit BiometricDevicesWidget(BiometricProxy *proxy, int uid,QWidget *parent = nullptr); - void setCurrentDevice(int drvid); - void setCurrentDevice(const QString &deviceName); - void setCurrentDevice(const DeviceInfoPtr &pDeviceInfo); - DeviceInfoPtr findDeviceById(int drvid); - DeviceInfoPtr findDeviceByName(const QString &name); - bool deviceExists(int drvid); - bool deviceExists(const QString &deviceName); - void setUser(int user); - -protected: - void resizeEvent(QResizeEvent *event); - -Q_SIGNALS: - void deviceChanged(const DeviceInfoPtr &pDeviceInfo); - void deviceCountChanged(int newCount); - -public Q_SLOTS: - void onOKButtonClicked(); - -private Q_SLOTS: - void onCmbDeviceTypeCurrentIndexChanged(int index); - void onUSBDeviceHotPlug(int drvid, int action, int devNum); - -private: - void initUI(); - void updateDevice(); - -private: - typedef QMap QButtonMap; - - QLabel *lblPrompt; - QLabel *lblDeviceType; - QLabel *lblDeviceName; - QComboBox *cmbDeviceType; - QComboBox *cmbDeviceName; - QPushButton *btnOK; - QPushButton *btnCancel; - - BiometricProxy *proxy; - DeviceMap deviceMap; - DeviceInfoPtr currentDevice; - int m_uid; -}; - -#endif // BIOMETRICDEVICESWIDGET_H diff --git a/BiometricAuth/main.cpp b/BiometricAuth/main.cpp deleted file mode 100644 index cd780b5..0000000 --- a/BiometricAuth/main.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#include -#include -#include "biometricproxy.h" -#include "biometricauthwidget.h" -#include "biometricdeviceswidget.h" - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - - BiometricProxy proxy; - BiometricAuthWidget biometricAuthWidget(&proxy); - biometricAuthWidget.hide(); - BiometricDevicesWidget biometricDeviceWidget(&proxy); - QObject::connect(&biometricDeviceWidget, &BiometricDevicesWidget::deviceChanged, - &a, [&](const DeviceInfoPtr &pDeviceInfo){ - biometricAuthWidget.startAuth(pDeviceInfo, 1000); - biometricAuthWidget.show(); - }); - QObject::connect(&biometricDeviceWidget, &BiometricDevicesWidget::deviceCountChanged, - &a, [&](int count){ - qDebug() << "device count changed: " << count; - }); - biometricDeviceWidget.show(); - - return a.exec(); -} diff --git a/CMakeLists.txt b/CMakeLists.txt index 6113071..37e601e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,55 +1,24 @@ cmake_minimum_required(VERSION 2.6) project(ukui-screensaver) -find_package(Qt5 COMPONENTS Core Widgets DBus X11Extras Xml Network Svg Multimedia MultimediaWidgets) -find_package(PkgConfig REQUIRED) -find_package(OpenCV REQUIRED) -find_package(PkgConfig) -find_package(KF5Screen REQUIRED) -find_package(KF5Wayland REQUIRED) -find_package(LayerShellQt REQUIRED) - -pkg_check_modules(GIOUNIX2 REQUIRED gio-unix-2.0) -pkg_check_modules(GLIB2 REQUIRED glib-2.0 gio-2.0) -pkg_check_modules(kylin-nm-base REQUIRED kylin-nm-base) -pkg_check_modules(KScreen REQUIRED kscreen2) - -# 是否是intel项目 -option (USE_INTEL "intel项目" OFF) -# 用于测试替换用的变量 -set(TEST_ON 1) -set(TEST_OF 0) -set(VAR "VAR_NEW") - -# 加入一个配置头文件,用于处理 CMake 对源码的设置 -configure_file ( - "${CMAKE_CURRENT_SOURCE_DIR}/config.h.in" - "${CMAKE_CURRENT_BINARY_DIR}/config.h" -) - -set(TS_FILES - ${CMAKE_CURRENT_SOURCE_DIR}/i18n_ts/zh_CN.ts - ${CMAKE_CURRENT_SOURCE_DIR}/i18n_ts/es.ts - ${CMAKE_CURRENT_SOURCE_DIR}/i18n_ts/fr.ts - ${CMAKE_CURRENT_SOURCE_DIR}/i18n_ts/bo_CN.ts - ${CMAKE_CURRENT_SOURCE_DIR}/i18n_ts/pt.ts - ${CMAKE_CURRENT_SOURCE_DIR}/i18n_ts/ru.ts - ${CMAKE_CURRENT_SOURCE_DIR}/i18n_ts/tr.ts - ${CMAKE_CURRENT_SOURCE_DIR}/i18n_ts/nm.ts - ) +## 更新翻译字段 +file(GLOB TS_FILES ./i18n_ts/*.ts) add_custom_command( - OUTPUT ${TS_FILES} - COMMAND lupdate src/ screensaver/ -ts ${TS_FILES} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - ) + OUTPUT ${TS_FILES} + COMMAND lupdate src/ screensaver/ -ts ${TS_FILES} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + ) add_custom_target( - i18n_ts - DEPENDS ${TS_FILES} - ) + i18n_ts + DEPENDS ${TS_FILES} + ) + add_compile_options(-fPIC) #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror") set(CMAKE_CXX_STANDARD 11) +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_INSTALL_PREFIX /usr) @@ -58,17 +27,9 @@ if(Debug) set(CMAKE_BUILD_TYPE "Debug") endif() -#add_subdirectory(BioAuth) -add_subdirectory(BiometricAuth) -add_subdirectory(VirtualKeyboard) add_subdirectory(src) add_subdirectory(i18n_ts) -add_subdirectory(set4kScale) add_subdirectory(data) -add_subdirectory(screensaver) -add_subdirectory(screensaver-focus-helper) -add_subdirectory(Common) -add_subdirectory(KylinNM) -add_dependencies(ukui-screensaver-dialog BiometricAuth VirtualKeyboard Common Screensaver) -add_dependencies(ukui-screensaver-default Common) +# 让主目标依赖翻译文件,这样才会执行i18n +add_dependencies(ukui-screensaver-dialog i18n) diff --git a/Common/CMakeLists.txt b/Common/CMakeLists.txt deleted file mode 100644 index 1f4d3b7..0000000 --- a/Common/CMakeLists.txt +++ /dev/null @@ -1,31 +0,0 @@ -pkg_check_modules(GLIB REQUIRED glib-2.0) -find_package(X11 REQUIRED) -find_package(KF5WindowSystem) - -include_directories( - ${Qt5Core_INCLUDE_DIRS} - ${Qt5Widgets_INCLUDE_DIRS} - ${Qt5DBus_INCLUDE_DIRS} - ${GLIB2_INCLUDE_DIRS} - ${KF5Wayland_LIBRARIES} - ) - -qt5_wrap_cpp(Common_SRC - autoresize.h - checkbutton.h - commonfunc.h - glibinterface.h - plasma-shell-manager.h - ) - -set(Common_SRC - ${Common_SRC} - autoresize.cpp - checkbutton.cpp - commonfunc.cpp - glibinterface.cpp - plasma-shell-manager.cpp - ) - -add_library(Common STATIC ${Common_SRC}) -target_link_libraries(Common Qt5::Core Qt5::DBus Qt5::Widgets Qt5::X11Extras ${GIOUNIX2_LIBRARIES} ${KF5Wayland_LIBRARIES} -lKF5WaylandClient -lKF5WaylandServer KF5::WindowSystem) diff --git a/Common/autoresize.cpp b/Common/autoresize.cpp deleted file mode 100644 index c5301e9..0000000 --- a/Common/autoresize.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ - -#include "autoresize.h" - -AutoResize::AutoResize(QWidget* obj,int baseWidth,int baseHeight): - obj(obj), - baseWidth(baseWidth), - baseHeight(baseHeight) -{ - -} - -AutoResize::~AutoResize(void) -{ -} - diff --git a/Common/autoresize.h b/Common/autoresize.h deleted file mode 100644 index 610a2f9..0000000 --- a/Common/autoresize.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ - -#ifndef AUTORESIZE_H -#define AUTORESIZE_H - -#include - -struct AutoResizeOriginalData -{ - QRect data_rect; - QFont data_font; -}; -class AutoResize -{ -public: - AutoResize(QWidget* obj,int baseWidth,int baseHeight); - ~AutoResize(void); -private: - QWidget *obj; - int baseWidth; - int baseHeight; - -}; - -#endif diff --git a/Common/commonfunc.cpp b/Common/commonfunc.cpp deleted file mode 100644 index 844791d..0000000 --- a/Common/commonfunc.cpp +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright (C) 2019 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "commonfunc.h" - -#define DRM_DIR "/sys/class/leds/" - -/** - * @brief 判断大写键状态 - * @return true: 大写锁定 - */ -bool checkCapsLockState() -{ - QDir ledDir(DRM_DIR); - QStringList leds = ledDir.entryList(QDir::Dirs); - QString capsFile; - - for(int i = 0;i width) - { - strInfo= QFontMetrics(font).elidedText(strInfo, Qt::ElideRight, width); - } - return strInfo; -} - -/*修改图片缩放机制,图片长宽不一致时,先取图片中央的部分*/ -QPixmap scaledPixmap(QPixmap src) -{ - QPixmap rectPixmap; - if (src.width() > src.height()) { - QPixmap iconPixmap = src.copy((src.width() - src.height())/2, 0, src.height(), src.height()); - // 根据label高度等比例缩放图片 - rectPixmap = iconPixmap.scaledToHeight(src.height()); - } else { - QPixmap iconPixmap = src.copy(0, (src.height() - src.width())/2, src.width(), src.width()); - // 根据label宽度等比例缩放图片 - rectPixmap = iconPixmap.scaledToWidth(src.width()); - } - return rectPixmap; -} - -QPixmap PixmapToRound(const QPixmap &src, int radius) -{ - if (src.isNull()) { - return QPixmap(); - } - - QPixmap pixmapa(src); - QPixmap pixmap(radius*2,radius*2); - pixmap.fill(Qt::transparent); - QPainter painter(&pixmap); - painter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); - QPainterPath path; - path.addEllipse(0, 0, radius*2, radius*2); - painter.setClipPath(path); - painter.drawPixmap(0, 0, radius*2, radius*2, pixmapa); - return pixmap; -} diff --git a/Common/commonfunc.h b/Common/commonfunc.h deleted file mode 100644 index c42f31b..0000000 --- a/Common/commonfunc.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2019 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ - -#ifndef COMMONFUNC_H -#define COMMONFUNC_H - -#include -#include -#include - -#define G_FONT_SIZE (11.0) - -bool checkCapsLockState(); -bool ispicture(QString filepath); -QString getSystemVersion(); -QString getSystemDistrib(); -bool getUseFirstDevice(); -QString ElideText(QFont font,int width,QString strInfo); -QPixmap scaledPixmap(QPixmap src); -QPixmap PixmapToRound(const QPixmap &src, int radius); - -class commonFunc -{ -public: - commonFunc(); -}; - -#endif // COMMONFUNC_H diff --git a/Common/glibinterface.cpp b/Common/glibinterface.cpp deleted file mode 100644 index 25cdcff..0000000 --- a/Common/glibinterface.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#include "glibinterface.h" -#include -#include - -#define STYLE_TYPE_SCHEMA "org.ukui.style" -#define KEY_SYSTEM_FONT_SIZE "system-font-size" -#define DEFAULT_FONT_SIZE (10.0) - -double getDefaultFontSize() -{ - GSettingsSchemaSource *schema_source = NULL; - GSettingsSchema *schema = NULL; - double defaultFontSize = DEFAULT_FONT_SIZE; - - schema_source = g_settings_schema_source_get_default(); - if (schema_source) { - schema = g_settings_schema_source_lookup(schema_source,STYLE_TYPE_SCHEMA,TRUE); - if (schema) { - GSettings *gs = g_settings_new(STYLE_TYPE_SCHEMA); - if (gs) { - GVariant *size = g_settings_get_default_value(gs, KEY_SYSTEM_FONT_SIZE); - QString fontsize(g_variant_get_string(size, NULL)); - g_variant_unref(size); - g_object_unref(gs); - defaultFontSize = fontsize.toDouble(); - } - g_settings_schema_unref(schema); - } - } - return defaultFontSize; -} diff --git a/KylinNM/CMakeLists.txt b/KylinNM/CMakeLists.txt deleted file mode 100644 index f9577ea..0000000 --- a/KylinNM/CMakeLists.txt +++ /dev/null @@ -1,95 +0,0 @@ -find_package(Qt5 COMPONENTS Core Widgets REQUIRED) -find_package(X11 REQUIRED) - -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTOUIC ON) -set(CMAKE_AUTORCC ON) -#pkg_check_modules(X11 REQUIRED x11) - -qt5_wrap_ui(Kylin_NM_SRC - src/confform.ui - src/kylinnm.ui - src/oneconnform.ui - src/onelancform.ui - wireless-security/dlgconnhidwifi.ui - wireless-security/dlgconnhidwifisecfast.ui - wireless-security/dlgconnhidwifisectunneltls.ui - wireless-security/dlgconnhidwifisecpeap.ui - wireless-security/dlgconnhidwifisectls.ui - wireless-security/dlgconnhidwifisecleap.ui - wireless-security/dlgconnhidwifisecpwd.ui - wireless-security/dlgconnhidwifiwep.ui - wireless-security/dlgconnhidwifileap.ui - wireless-security/dlgconnhidwifiwpa.ui - hot-spot/dlghotspotcreate.ui - ) - -#qt5_wrap_cpp(Kylin_NM_SRC -# src/backthread.h -# src/confform.h -# src/ksimplenm.h -# src/kylin-dbus-interface.h -# src/kylin-network-interface.h -# src/loadingdiv.h -# src/kylinnm.h -# src/oneconnform.h -# src/onelancform.h -# src/switchbutton.h -# src/utils.h -# wireless-security/dlgconnhidwifi.h -# wireless-security/dlgconnhidwifisecfast.h -# wireless-security/dlgconnhidwifisectunneltls.h -# wireless-security/dlgconnhidwifisecpeap.h -# wireless-security/dlgconnhidwifisectls.h -# wireless-security/dlgconnhidwifisecleap.h -# wireless-security/dlgconnhidwifisecpwd.h -# wireless-security/dlgconnhidwifiwep.h -# wireless-security/dlgconnhidwifileap.h -# wireless-security/dlgconnhidwifiwpa.h -# wireless-security/kylinheadfile.h -# hot-spot/dlghotspotcreate.h -# ) - -qt5_add_resources(Kylin_NM_SRC - nmqrc.qrc - res.qrc) - -set(Kylin_NM_SRC - ${Kylin_NM_SRC} - src/backthread.cpp - src/confform.cpp - src/ksimplenm.cpp - src/kylin-dbus-interface.cpp - src/kylin-network-interface.c - src/loadingdiv.cpp - src/kylinnm.cpp - src/oneconnform.cpp - src/onelancform.cpp - src/switchbutton.cpp - src/utils.cpp - src/swipegesturerecognizer.cpp - wireless-security/dlgconnhidwifi.cpp - wireless-security/dlgconnhidwifisecfast.cpp - wireless-security/dlgconnhidwifisectunneltls.cpp - wireless-security/dlgconnhidwifisecpeap.cpp - wireless-security/dlgconnhidwifisectls.cpp - wireless-security/dlgconnhidwifisecleap.cpp - wireless-security/dlgconnhidwifisecpwd.cpp - wireless-security/dlgconnhidwifiwep.cpp - wireless-security/dlgconnhidwifileap.cpp - wireless-security/dlgconnhidwifiwpa.cpp - wireless-security/kylinheadfile.cpp - hot-spot/dlghotspotcreate.cpp - nmqrc.qrc - ) - -include_directories( - ${Qt5Core_INCLUDE_DIRS} - ${Qt5Widgets_INCLUDE_DIRS} - ${Qt5DBus_INCLUDE_DIRS} - ) - -find_package(KF5WindowSystem) - -add_library(Kylin-nm STATIC ${Kylin_NM_SRC}) -target_link_libraries(Kylin-nm Qt5::Core Qt5::Widgets KF5::WindowSystem Qt5::DBus Qt5::X11Extras) diff --git a/KylinNM/README.md b/KylinNM/README.md deleted file mode 100644 index a59ec5e..0000000 --- a/KylinNM/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# NAME - kylin-nm - kylin network monitor used in ubuntu-kylin operation system - -# DESCRIPTION - kylin-nm is a Qt based applet and uses some interface provided by NetworkManager. - It provides a GUI for users to connect or disconnect wired or wireless network which managed by NetworkManager. - Users can also create new wired network and configure a old network. - By click button at left bottom in the main window, a network configure window of NetworkManager will show in the screen. - Users can get some information about network directly by clicking one item in the network list, these information shown in extension area. - -# BUILD KYLIN-NM - down the source sode - install dependency packages(see cntrol files in the debian directory) - execute debuild command in the root directory of project - execute sudo dpkg -i packagename.deb to install diff --git a/KylinNM/hot-spot/dlghotspotcreate.cpp b/KylinNM/hot-spot/dlghotspotcreate.cpp deleted file mode 100644 index a64e249..0000000 --- a/KylinNM/hot-spot/dlghotspotcreate.cpp +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see setupUi(this); - - this->setWindowFlags(Qt::FramelessWindowHint); - this->setStyleSheet("background-color:white;"); - - ui->lbLeftup->setStyleSheet("QLabel{background-color:#266ab5;}"); - ui->lbLeftupIcon->setStyleSheet("QLabel{background-image:url(:/res/h/no-pwd-wifi.png);background-color:transparent;}"); - ui->lbLeftupTitle->setStyleSheet("QLabel{font-size:12px;color:#ffffff;background-color:transparent;}"); - ui->btnCancel->setStyleSheet("QPushButton{border:1px solid #aaaaaa;background-color:#f5f5f5;}" - "QPushButton:Hover{border:2px solid #629ee8;background-color:#eeeeee;}" - "QPushButton:Pressed{border:1px solid #aaaaaa;background-color:#d8d8d8;}"); - ui->btnOk->setStyleSheet("QPushButton{border:1px solid #aaaaaa;background-color:#f5f5f5;}" - "QPushButton:Hover{border:2px solid #629ee8;background-color:#eeeeee;}" - "QPushButton:Pressed{border:1px solid #aaaaaa;background-color:#d8d8d8;}"); - ui->checkBoxPwd->setStyleSheet("QCheckBox::indicator {width: 18px; height: 9px;}" - "QCheckBox::indicator:checked {image: url(:/res/h/show-pwd.png);}" - "QCheckBox::indicator:unchecked {image: url(:/res/h/hide-pwd.png);}"); - - ui->lbLeftupTitle->setText(tr("Create Hotspot")); //创建个人热点 - ui->lbNetName->setText(tr("Network name")); //网络名称: - ui->lbSecurity->setText(tr("Wi-Fi security")); //Wi-Fi 安全性: - ui->lbPassword->setText(tr("Password")); //密码: - ui->btnCancel->setText(tr("Cancel")); //取消 - ui->btnOk->setText(tr("Ok")); //确定 - ui->btnOk->setEnabled(false); - - ui->cbxSecurity->addItem(tr("None")); //无 - ui->cbxSecurity->addItem(tr("WPA & WPA2 Personal")); //WPA 及 WPA2 个人 - ui->cbxSecurity->setCurrentIndex(1); - connect(ui->cbxSecurity,SIGNAL(currentIndexChanged(QString)),this,SLOT(changeDialog())); -} - -DlgHotspotCreate::~DlgHotspotCreate() -{ - delete ui; -} - -void DlgHotspotCreate::mousePressEvent(QMouseEvent *event){ - if(event->button() == Qt::LeftButton){ - this->isPress = true; - this->winPos = this->pos(); - this->dragPos = event->globalPos(); - event->accept(); - } -} -void DlgHotspotCreate::mouseReleaseEvent(QMouseEvent *event){ - this->isPress = false; - this->setWindowOpacity(1); -} -void DlgHotspotCreate::mouseMoveEvent(QMouseEvent *event){ - if(this->isPress){ - this->move(this->winPos - (this->dragPos - event->globalPos())); - this->setWindowOpacity(0.9); - event->accept(); - } -} - -void DlgHotspotCreate::on_btnCancel_clicked() -{ - this->close(); - emit btnHotspotState(); -} - -void DlgHotspotCreate::on_btnOk_clicked() -{ - //nmcli device wifi hotspot [ifname ifname] [con-name name] [ssid SSID] [band {a | bg}] [channel channel] [password password] - //example: nmcli device wifi hotspot ifname wlan0 con-name MyHostspot ssid MyHostspotSSID password 12345678 - QString str; - if(ui->cbxSecurity->currentIndex() == 0 ){ - str = "nmcli device wifi hotspot ifname " + wirelessCardName + " con-name " + ui->leNetName->text() + " ssid " + ui->leNetName->text() + "SSID"; - }else{ - str = "nmcli device wifi hotspot ifname " + wirelessCardName + " con-name " + ui->leNetName->text() + " ssid " + ui->leNetName->text() + " password " + ui->lePassword->text(); - } - Utils::m_system(str.toUtf8().data()); -// int status = system(str.toUtf8().data()); -// if (status != 0){ syslog(LOG_ERR, "execute 'nmcli device wifi hotspot' in function 'on_btnOk_clicked' failed");} - - this->close(); - emit updateHotspotList(); -} - -void DlgHotspotCreate::on_checkBoxPwd_stateChanged(int arg1) -{ - if (arg1 == 0) { - ui->lePassword ->setEchoMode(QLineEdit::Password); - } else { - ui->lePassword->setEchoMode(QLineEdit::Normal); - } -} - -void DlgHotspotCreate::on_leNetName_textEdited(const QString &arg1) -{ - if(ui->cbxSecurity->currentIndex() == 0 ){ - if (ui->leNetName->text() == ""){ - ui->btnOk->setEnabled(false); - } else { - ui->btnOk->setEnabled(true); - } - }else{ - if (ui->leNetName->text() == "" || ui->lePassword->text().size() < 5){ - ui->btnOk->setEnabled(false); - } else { - ui->btnOk->setEnabled(true); - } - } -} - -void DlgHotspotCreate::on_lePassword_textEdited(const QString &arg1) -{ - if (ui->leNetName->text() == "" || ui->lePassword->text().size() < 5){ - ui->btnOk->setEnabled(false); - } else { - ui->btnOk->setEnabled(true); - } -} - -void DlgHotspotCreate::changeDialog() -{ - if(ui->cbxSecurity->currentIndex()==0){ - ui->lbPassword->setEnabled(false); - ui->lePassword->setEnabled(false); - ui->checkBoxPwd->setEnabled(false); - } else { - ui->lbPassword->setEnabled(true); - ui->lePassword->setEnabled(true); - ui->checkBoxPwd->setEnabled(true); - } -} diff --git a/KylinNM/hot-spot/dlghotspotcreate.h b/KylinNM/hot-spot/dlghotspotcreate.h deleted file mode 100644 index 11a884d..0000000 --- a/KylinNM/hot-spot/dlghotspotcreate.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see - -#include -#include -#include - -namespace Ui { -class DlgHotspotCreate; -} - -class DlgHotspotCreate : public QDialog -{ - Q_OBJECT - -public: - explicit DlgHotspotCreate(QString wiFiCardName, QWidget *parent = nullptr); - ~DlgHotspotCreate(); - -public Q_SLOTS: - void changeDialog(); - -private Q_SLOTS: - void on_btnCancel_clicked(); - - void on_btnOk_clicked(); - - void on_checkBoxPwd_stateChanged(int arg1); - - void on_leNetName_textEdited(const QString &arg1); - - void on_lePassword_textEdited(const QString &arg1); - -private: - Ui::DlgHotspotCreate *ui; - - QString wirelessCardName; - - void mousePressEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - bool isPress; - QPoint winPos; - QPoint dragPos; - -Q_SIGNALS: - void updateHotspotList(); - void btnHotspotState(); -}; - -#endif // DLGHOTSPOTCREATE_H diff --git a/KylinNM/hot-spot/dlghotspotcreate.ui b/KylinNM/hot-spot/dlghotspotcreate.ui deleted file mode 100644 index 989108f..0000000 --- a/KylinNM/hot-spot/dlghotspotcreate.ui +++ /dev/null @@ -1,169 +0,0 @@ - - - DlgHotspotCreate - - - - 0 - 0 - 432 - 250 - - - - Dialog - - - - - 0 - 0 - 120 - 32 - - - - - - - - - - 9 - 9 - 16 - 16 - - - - - - - - - - 34 - 6 - 80 - 20 - - - - - - - - - - 215 - 210 - 90 - 30 - - - - - - - - - - 315 - 210 - 90 - 30 - - - - - - - - - - 76 - 60 - 90 - 20 - - - - - - - - - - 175 - 55 - 200 - 32 - - - - - - - 76 - 105 - 90 - 20 - - - - - - - - - - 175 - 100 - 200 - 32 - - - - - - - 76 - 150 - 90 - 20 - - - - - - - - - - 175 - 145 - 200 - 32 - - - - QLineEdit::Password - - - - - - 350 - 157 - 18 - 9 - - - - - - - - - - diff --git a/KylinNM/kylin-nm.pri b/KylinNM/kylin-nm.pri deleted file mode 100644 index e124796..0000000 --- a/KylinNM/kylin-nm.pri +++ /dev/null @@ -1,70 +0,0 @@ -SOURCES += \ - $$PWD/src/backthread.cpp \ - $$PWD/src/confform.cpp \ - $$PWD/src/ksimplenm.cpp \ - $$PWD/src/kylin-dbus-interface.cpp \ - $$PWD/src/kylin-network-interface.c \ - $$PWD/src/loadingdiv.cpp \ - $$PWD/src/kylinnm.cpp \ - $$PWD/src/oneconnform.cpp \ - $$PWD/src/onelancform.cpp \ - $$PWD/src/switchbutton.cpp \ - $$PWD/src/utils.cpp \ - $$PWD/wireless-security/dlgconnhidwifi.cpp \ - $$PWD/wireless-security/dlgconnhidwifisecfast.cpp \ - $$PWD/wireless-security/dlgconnhidwifisectunneltls.cpp \ - $$PWD/wireless-security/dlgconnhidwifisecpeap.cpp \ - $$PWD/wireless-security/dlgconnhidwifisectls.cpp \ - $$PWD/wireless-security/dlgconnhidwifisecleap.cpp \ - $$PWD/wireless-security/dlgconnhidwifisecpwd.cpp \ - $$PWD/wireless-security/dlgconnhidwifiwep.cpp \ - $$PWD/wireless-security/dlgconnhidwifileap.cpp \ - $$PWD/wireless-security/dlgconnhidwifiwpa.cpp \ - $$PWD/wireless-security/kylinheadfile.cpp \ - $$PWD/hot-spot/dlghotspotcreate.cpp - -HEADERS += \ - $$PWD/src/backthread.h \ - $$PWD/src/confform.h \ - $$PWD/src/ksimplenm.h \ - $$PWD/src/kylin-dbus-interface.h \ - $$PWD/src/kylin-network-interface.h \ - $$PWD/src/loadingdiv.h \ - $$PWD/src/kylinnm.h \ - $$PWD/src/oneconnform.h \ - $$PWD/src/onelancform.h \ - $$PWD/src/switchbutton.h \ - $$PWD/src/utils.h \ - $$PWD/wireless-security/dlgconnhidwifi.h \ - $$PWD/wireless-security/dlgconnhidwifisecfast.h \ - $$PWD/wireless-security/dlgconnhidwifisectunneltls.h \ - $$PWD/wireless-security/dlgconnhidwifisecpeap.h \ - $$PWD/wireless-security/dlgconnhidwifisectls.h \ - $$PWD/wireless-security/dlgconnhidwifisecleap.h \ - $$PWD/wireless-security/dlgconnhidwifisecpwd.h \ - $$PWD/wireless-security/dlgconnhidwifiwep.h \ - $$PWD/wireless-security/dlgconnhidwifileap.h \ - $$PWD/wireless-security/dlgconnhidwifiwpa.h \ - $$PWD/wireless-security/kylinheadfile.h \ - $$PWD/hot-spot/dlghotspotcreate.h - -FORMS += \ - $$PWD/src/confform.ui \ - $$PWD/src/kylinnm.ui \ - $$PWD/src/oneconnform.ui \ - $$PWD/src/onelancform.ui \ - $$PWD/wireless-security/dlgconnhidwifi.ui \ - $$PWD/wireless-security/dlgconnhidwifisecfast.ui \ - $$PWD/wireless-security/dlgconnhidwifisectunneltls.ui \ - $$PWD/wireless-security/dlgconnhidwifisecpeap.ui \ - $$PWD/wireless-security/dlgconnhidwifisectls.ui \ - $$PWD/wireless-security/dlgconnhidwifisecleap.ui \ - $$PWD/wireless-security/dlgconnhidwifisecpwd.ui \ - $$PWD/wireless-security/dlgconnhidwifiwep.ui \ - $$PWD/wireless-security/dlgconnhidwifileap.ui \ - $$PWD/wireless-security/dlgconnhidwifiwpa.ui \ - $$PWD/hot-spot/dlghotspotcreate.ui - -RESOURCES += \ - $$PWD/nmqrc.qrc - diff --git a/KylinNM/kylin-nm.pro b/KylinNM/kylin-nm.pro deleted file mode 100644 index b8af2ba..0000000 --- a/KylinNM/kylin-nm.pro +++ /dev/null @@ -1,129 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2018-10-19T15:29:47 -# -#------------------------------------------------- - -QT += core gui x11extras dbus - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -TARGET = kylin-nm -TEMPLATE = app -LANGUAGE = C++ - -CONFIG += c++11 - -# CONFIG += link_pkgconfig -# PKGCONFIG += gsettings-qt -LIBS += -L/usr/lib/ -lgsettings-qt -lX11 - -target.path = /usr/bin -target.source += $$TARGET -desktop.path = /etc/xdg/autostart/ -desktop.files = kylin-nm.desktop - -INSTALLS += target \ - desktop - -# The following define makes your compiler emit warnings if you use -# any feature of Qt which has been marked as deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if you use deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - -# QMAKE_CXXFLAGS += -Wno-unused-parameter -QMAKE_CPPFLAGS *= $(shell dpkg-buildflags --get CPPFLAGS) -QMAKE_CFLAGS *= $(shell dpkg-buildflags --get CFLAGS) -QMAKE_CXXFLAGS *= $(shell dpkg-buildflags --get CXXFLAGS) -QMAKE_LFLAGS *= $(shell dpkg-buildflags --get LDFLAGS) - - -SOURCES += \ - src/backthread.cpp \ - src/confform.cpp \ - src/ksimplenm.cpp \ - src/kylin-dbus-interface.cpp \ - src/kylin-network-interface.c \ - src/loadingdiv.cpp \ - src/main.cpp \ - src/kylinnm.cpp \ - src/oneconnform.cpp \ - src/onelancform.cpp \ - src/switchbutton.cpp \ - src/utils.cpp \ - wireless-security/dlgconnhidwifi.cpp \ - wireless-security/dlgconnhidwifisecfast.cpp \ - wireless-security/dlgconnhidwifisectunneltls.cpp \ - wireless-security/dlgconnhidwifisecpeap.cpp \ - wireless-security/dlgconnhidwifisectls.cpp \ - wireless-security/dlgconnhidwifisecleap.cpp \ - wireless-security/dlgconnhidwifisecpwd.cpp \ - wireless-security/dlgconnhidwifiwep.cpp \ - wireless-security/dlgconnhidwifileap.cpp \ - wireless-security/dlgconnhidwifiwpa.cpp \ - wireless-security/kylinheadfile.cpp \ - hot-spot/dlghotspotcreate.cpp - - -HEADERS += \ - src/backthread.h \ - src/confform.h \ - src/ksimplenm.h \ - src/kylin-dbus-interface.h \ - src/kylin-network-interface.h \ - src/loadingdiv.h \ - src/kylinnm.h \ - src/oneconnform.h \ - src/onelancform.h \ - src/switchbutton.h \ - src/utils.h \ - wireless-security/dlgconnhidwifi.h \ - wireless-security/dlgconnhidwifisecfast.h \ - wireless-security/dlgconnhidwifisectunneltls.h \ - wireless-security/dlgconnhidwifisecpeap.h \ - wireless-security/dlgconnhidwifisectls.h \ - wireless-security/dlgconnhidwifisecleap.h \ - wireless-security/dlgconnhidwifisecpwd.h \ - wireless-security/dlgconnhidwifiwep.h \ - wireless-security/dlgconnhidwifileap.h \ - wireless-security/dlgconnhidwifiwpa.h \ - wireless-security/kylinheadfile.h \ - hot-spot/dlghotspotcreate.h - -FORMS += \ - src/confform.ui \ - src/kylinnm.ui \ - src/oneconnform.ui \ - src/onelancform.ui \ - wireless-security/dlgconnhidwifi.ui \ - wireless-security/dlgconnhidwifisecfast.ui \ - wireless-security/dlgconnhidwifisectunneltls.ui \ - wireless-security/dlgconnhidwifisecpeap.ui \ - wireless-security/dlgconnhidwifisectls.ui \ - wireless-security/dlgconnhidwifisecleap.ui \ - wireless-security/dlgconnhidwifisecpwd.ui \ - wireless-security/dlgconnhidwifiwep.ui \ - wireless-security/dlgconnhidwifileap.ui \ - wireless-security/dlgconnhidwifiwpa.ui \ - hot-spot/dlghotspotcreate.ui - -RESOURCES += \ - nmqrc.qrc - -unix { - UI_DIR = .ui - MOC_DIR = .moc - OBJECTS_DIR = .obj -} - -TRANSLATIONS = translations/kylin-nm_zh_CN.ts \ - translations/kylin-nm_tr.ts \ - translations/kylin-nm_bo.ts - -DISTFILES += diff --git a/KylinNM/nmqrc.qrc b/KylinNM/nmqrc.qrc deleted file mode 100644 index f2349b6..0000000 --- a/KylinNM/nmqrc.qrc +++ /dev/null @@ -1,102 +0,0 @@ - - - res/s/conning-b/1.png - res/s/conning-b/2.png - res/s/conning-b/3.png - res/s/conning-b/4.png - res/s/conning-b/5.png - res/s/conning-b/6.png - res/s/conning-b/7.png - res/s/conning-b/8.png - res/s/conning-b/9.png - res/s/conning-b/10.png - res/s/conning-b/11.png - res/s/conning-b/12.png - res/g/down_arrow.png - res/g/checkbox-checked.svg - res/g/checkbox-unchecked.svg - res/s/rescan/1.png - res/s/rescan/2.png - res/s/rescan/3.png - res/s/rescan/4.png - res/s/rescan/5.png - res/s/rescan/6.png - res/s/rescan/7.png - res/s/rescan/8.png - res/s/rescan/9.png - res/s/rescan/10.png - res/s/rescan/11.png - res/s/rescan/12.png - res/h/hide-pwd.png - res/h/right-pwd.png - res/h/show-pwd.png - res/h/no-pwd-wifi.png - res/x/fly-mode-off.svg - res/x/fly-mode-on.svg - res/x/hot-spot-off.svg - res/x/hot-spot-on.svg - res/x/net-list-bg.svg - res/x/wifi-list-bg.svg - res/x/load-down.png - res/x/load-up.png - res/l/network-offline.png - res/l/network-offline.svg - res/l/network-online.png - res/l/network-online.svg - res/w/wifi-full.png - res/w/wifi-full-pwd.png - res/w/wifi-high.png - res/w/wifi-high-pwd.png - res/w/wifi-low.png - res/w/wifi-low-pwd.png - res/w/wifi-medium.png - res/w/wifi-medium-pwd.png - res/w/wifi-none.png - res/w/wifi-none-pwd.png - res/s/conning-a/1.png - res/s/conning-a/2.png - res/s/conning-a/3.png - res/s/conning-a/4.png - res/s/conning-a/5.png - res/s/conning-a/6.png - res/s/conning-a/7.png - res/s/conning-a/8.png - qss/style.qss - res/g/close_black.png - res/g/close_white.png - res/s/conning-s/1.png - res/s/conning-s/2.png - res/s/conning-s/3.png - res/s/conning-s/4.png - res/s/conning-s/5.png - res/s/conning-s/6.png - res/s/conning-s/7.png - res/s/conning-s/8.png - res/s/conning-s/9.png - res/s/conning-s/10.png - res/s/conning-s/11.png - res/s/conning-s/12.png - res/x/setup.png - res/x/pb-wifi-n.png - res/x/pb-wifi-y.png - res/x/pb-conn-dis.png - res/l/pb-network-online.png - res/l/pb-network-info.png - res/l/pb-network-offline.png - res/x/pb-newConn.png - res/x/pb-close.png - res/l/pb-top-network-offline.png - res/w/pb-all-wifi-offline.png - res/w/pb-top-wifi-offline.png - res/w/wifi-full-off.png - res/w/wifi-high-off.png - res/w/wifi-low-off.png - res/w/wifi-medium-off.png - res/w/wifi-low-pwd-off.png - res/w/wifi-full-pwd-off.png - res/w/wifi-high-pwd-off.png - res/w/wifi-medium-pwd-off.png - res/w/wifi-none-off.png - res/w/wifi-none-pwd-off.png - - diff --git a/KylinNM/qss/style.qss b/KylinNM/qss/style.qss deleted file mode 100644 index 741e632..0000000 --- a/KylinNM/qss/style.qss +++ /dev/null @@ -1,10 +0,0 @@ -QScrollBar:vertical{margin:0px 2px 0px 2px;width:10px;background:rgba(48,48,51,0);border-radius:6px;} -QScrollBar::up-arrow:vertical{height:0px;} -QScrollBar::sub-line:vertical{border:0px solid;height:0px} -QScrollBar::sub-page:vertical{background:transparent;} -QScrollBar::handle:vertical{width:6px;background:rgba(72,72,76,1);border-radius:3px;} -QScrollBar::handle:vertical:hover{width:6px;background:rgba(97,97,102,1);border-radius:3px;} -QScrollBar::handle:vertical:pressed{width:6px;background:rgba(133,133,140,1);border-radius:3px;} -QScrollBar::add-page:vertical{background:transparent;} -QScrollBar::add-line:vertical{border:0px solid;height:0px} -QScrollBar::down-arrow:vertical{height:0px;} diff --git a/KylinNM/res.qrc b/KylinNM/res.qrc deleted file mode 100644 index 7646d2b..0000000 --- a/KylinNM/res.qrc +++ /dev/null @@ -1 +0,0 @@ - diff --git a/KylinNM/res/g/checkbox-checked.svg b/KylinNM/res/g/checkbox-checked.svg deleted file mode 100644 index b9ee316..0000000 --- a/KylinNM/res/g/checkbox-checked.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/KylinNM/res/g/checkbox-unchecked.svg b/KylinNM/res/g/checkbox-unchecked.svg deleted file mode 100644 index 0df442d..0000000 --- a/KylinNM/res/g/checkbox-unchecked.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/KylinNM/res/g/close_black.png b/KylinNM/res/g/close_black.png deleted file mode 100644 index 237e555..0000000 Binary files a/KylinNM/res/g/close_black.png and /dev/null differ diff --git a/KylinNM/res/g/close_white.png b/KylinNM/res/g/close_white.png deleted file mode 100644 index 0943a4b..0000000 Binary files a/KylinNM/res/g/close_white.png and /dev/null differ diff --git a/KylinNM/res/g/down_arrow.png b/KylinNM/res/g/down_arrow.png deleted file mode 100644 index c7a343b..0000000 Binary files a/KylinNM/res/g/down_arrow.png and /dev/null differ diff --git a/KylinNM/res/h/hide-pwd.png b/KylinNM/res/h/hide-pwd.png deleted file mode 100644 index c1d3044..0000000 Binary files a/KylinNM/res/h/hide-pwd.png and /dev/null differ diff --git a/KylinNM/res/h/no-pwd-wifi.png b/KylinNM/res/h/no-pwd-wifi.png deleted file mode 100644 index dbec54a..0000000 Binary files a/KylinNM/res/h/no-pwd-wifi.png and /dev/null differ diff --git a/KylinNM/res/h/right-pwd.png b/KylinNM/res/h/right-pwd.png deleted file mode 100644 index 1bbc00d..0000000 Binary files a/KylinNM/res/h/right-pwd.png and /dev/null differ diff --git a/KylinNM/res/h/show-pwd.png b/KylinNM/res/h/show-pwd.png deleted file mode 100644 index 08c4de5..0000000 Binary files a/KylinNM/res/h/show-pwd.png and /dev/null differ diff --git a/KylinNM/res/l/network-offline.png b/KylinNM/res/l/network-offline.png deleted file mode 100644 index a288fc3..0000000 Binary files a/KylinNM/res/l/network-offline.png and /dev/null differ diff --git a/KylinNM/res/l/network-offline.svg b/KylinNM/res/l/network-offline.svg deleted file mode 100644 index ca9dcea..0000000 --- a/KylinNM/res/l/network-offline.svg +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - diff --git a/KylinNM/res/l/network-online.png b/KylinNM/res/l/network-online.png deleted file mode 100644 index b8c5fe4..0000000 Binary files a/KylinNM/res/l/network-online.png and /dev/null differ diff --git a/KylinNM/res/l/network-online.svg b/KylinNM/res/l/network-online.svg deleted file mode 100644 index 7f10bfd..0000000 --- a/KylinNM/res/l/network-online.svg +++ /dev/null @@ -1 +0,0 @@ -gnome-dev-ethernet32 \ No newline at end of file diff --git a/KylinNM/res/l/pb-network-info.png b/KylinNM/res/l/pb-network-info.png deleted file mode 100644 index 23fa16c..0000000 Binary files a/KylinNM/res/l/pb-network-info.png and /dev/null differ diff --git a/KylinNM/res/l/pb-network-offline.png b/KylinNM/res/l/pb-network-offline.png deleted file mode 100644 index 77be9f0..0000000 Binary files a/KylinNM/res/l/pb-network-offline.png and /dev/null differ diff --git a/KylinNM/res/l/pb-network-online.png b/KylinNM/res/l/pb-network-online.png deleted file mode 100644 index d65dcd5..0000000 Binary files a/KylinNM/res/l/pb-network-online.png and /dev/null differ diff --git a/KylinNM/res/l/pb-top-network-offline.png b/KylinNM/res/l/pb-top-network-offline.png deleted file mode 100644 index b5822b9..0000000 Binary files a/KylinNM/res/l/pb-top-network-offline.png and /dev/null differ diff --git a/KylinNM/res/s/conning-a/1.png b/KylinNM/res/s/conning-a/1.png deleted file mode 100644 index cd0fafa..0000000 Binary files a/KylinNM/res/s/conning-a/1.png and /dev/null differ diff --git a/KylinNM/res/s/conning-a/2.png b/KylinNM/res/s/conning-a/2.png deleted file mode 100644 index 38b549a..0000000 Binary files a/KylinNM/res/s/conning-a/2.png and /dev/null differ diff --git a/KylinNM/res/s/conning-a/3.png b/KylinNM/res/s/conning-a/3.png deleted file mode 100644 index c002abd..0000000 Binary files a/KylinNM/res/s/conning-a/3.png and /dev/null differ diff --git a/KylinNM/res/s/conning-a/4.png b/KylinNM/res/s/conning-a/4.png deleted file mode 100644 index ec398d0..0000000 Binary files a/KylinNM/res/s/conning-a/4.png and /dev/null differ diff --git a/KylinNM/res/s/conning-a/5.png b/KylinNM/res/s/conning-a/5.png deleted file mode 100644 index df58230..0000000 Binary files a/KylinNM/res/s/conning-a/5.png and /dev/null differ diff --git a/KylinNM/res/s/conning-a/6.png b/KylinNM/res/s/conning-a/6.png deleted file mode 100644 index 44fbf5d..0000000 Binary files a/KylinNM/res/s/conning-a/6.png and /dev/null differ diff --git a/KylinNM/res/s/conning-a/7.png b/KylinNM/res/s/conning-a/7.png deleted file mode 100644 index 1dcfb6d..0000000 Binary files a/KylinNM/res/s/conning-a/7.png and /dev/null differ diff --git a/KylinNM/res/s/conning-a/8.png b/KylinNM/res/s/conning-a/8.png deleted file mode 100644 index 0178595..0000000 Binary files a/KylinNM/res/s/conning-a/8.png and /dev/null differ diff --git a/KylinNM/res/s/conning-b/1.png b/KylinNM/res/s/conning-b/1.png deleted file mode 100644 index 6255abf..0000000 Binary files a/KylinNM/res/s/conning-b/1.png and /dev/null differ diff --git a/KylinNM/res/s/conning-b/10.png b/KylinNM/res/s/conning-b/10.png deleted file mode 100644 index 37e465b..0000000 Binary files a/KylinNM/res/s/conning-b/10.png and /dev/null differ diff --git a/KylinNM/res/s/conning-b/11.png b/KylinNM/res/s/conning-b/11.png deleted file mode 100644 index d4f8d0e..0000000 Binary files a/KylinNM/res/s/conning-b/11.png and /dev/null differ diff --git a/KylinNM/res/s/conning-b/12.png b/KylinNM/res/s/conning-b/12.png deleted file mode 100644 index 1fa952b..0000000 Binary files a/KylinNM/res/s/conning-b/12.png and /dev/null differ diff --git a/KylinNM/res/s/conning-b/2.png b/KylinNM/res/s/conning-b/2.png deleted file mode 100644 index a226b69..0000000 Binary files a/KylinNM/res/s/conning-b/2.png and /dev/null differ diff --git a/KylinNM/res/s/conning-b/3.png b/KylinNM/res/s/conning-b/3.png deleted file mode 100644 index 31b1b89..0000000 Binary files a/KylinNM/res/s/conning-b/3.png and /dev/null differ diff --git a/KylinNM/res/s/conning-b/4.png b/KylinNM/res/s/conning-b/4.png deleted file mode 100644 index eddd9a8..0000000 Binary files a/KylinNM/res/s/conning-b/4.png and /dev/null differ diff --git a/KylinNM/res/s/conning-b/5.png b/KylinNM/res/s/conning-b/5.png deleted file mode 100644 index b0a7062..0000000 Binary files a/KylinNM/res/s/conning-b/5.png and /dev/null differ diff --git a/KylinNM/res/s/conning-b/6.png b/KylinNM/res/s/conning-b/6.png deleted file mode 100644 index a970490..0000000 Binary files a/KylinNM/res/s/conning-b/6.png and /dev/null differ diff --git a/KylinNM/res/s/conning-b/7.png b/KylinNM/res/s/conning-b/7.png deleted file mode 100644 index c58bde1..0000000 Binary files a/KylinNM/res/s/conning-b/7.png and /dev/null differ diff --git a/KylinNM/res/s/conning-b/8.png b/KylinNM/res/s/conning-b/8.png deleted file mode 100644 index f3980b3..0000000 Binary files a/KylinNM/res/s/conning-b/8.png and /dev/null differ diff --git a/KylinNM/res/s/conning-b/9.png b/KylinNM/res/s/conning-b/9.png deleted file mode 100644 index 80a8f7e..0000000 Binary files a/KylinNM/res/s/conning-b/9.png and /dev/null differ diff --git a/KylinNM/res/s/conning-s/1.png b/KylinNM/res/s/conning-s/1.png deleted file mode 100644 index 6974725..0000000 Binary files a/KylinNM/res/s/conning-s/1.png and /dev/null differ diff --git a/KylinNM/res/s/conning-s/10.png b/KylinNM/res/s/conning-s/10.png deleted file mode 100644 index 964a300..0000000 Binary files a/KylinNM/res/s/conning-s/10.png and /dev/null differ diff --git a/KylinNM/res/s/conning-s/11.png b/KylinNM/res/s/conning-s/11.png deleted file mode 100644 index d4659b5..0000000 Binary files a/KylinNM/res/s/conning-s/11.png and /dev/null differ diff --git a/KylinNM/res/s/conning-s/12.png b/KylinNM/res/s/conning-s/12.png deleted file mode 100644 index cb0272e..0000000 Binary files a/KylinNM/res/s/conning-s/12.png and /dev/null differ diff --git a/KylinNM/res/s/conning-s/1x/1.png b/KylinNM/res/s/conning-s/1x/1.png deleted file mode 100644 index 258bd70..0000000 Binary files a/KylinNM/res/s/conning-s/1x/1.png and /dev/null differ diff --git a/KylinNM/res/s/conning-s/1x/10.png b/KylinNM/res/s/conning-s/1x/10.png deleted file mode 100644 index 88398b8..0000000 Binary files a/KylinNM/res/s/conning-s/1x/10.png and /dev/null differ diff --git a/KylinNM/res/s/conning-s/1x/11.png b/KylinNM/res/s/conning-s/1x/11.png deleted file mode 100644 index 7157960..0000000 Binary files a/KylinNM/res/s/conning-s/1x/11.png and /dev/null differ diff --git a/KylinNM/res/s/conning-s/1x/12.png b/KylinNM/res/s/conning-s/1x/12.png deleted file mode 100644 index 60b88e9..0000000 Binary files a/KylinNM/res/s/conning-s/1x/12.png and /dev/null differ diff --git a/KylinNM/res/s/conning-s/1x/2.png b/KylinNM/res/s/conning-s/1x/2.png deleted file mode 100644 index 45eedb2..0000000 Binary files a/KylinNM/res/s/conning-s/1x/2.png and /dev/null differ diff --git a/KylinNM/res/s/conning-s/1x/3.png b/KylinNM/res/s/conning-s/1x/3.png deleted file mode 100644 index 96cfdad..0000000 Binary files a/KylinNM/res/s/conning-s/1x/3.png and /dev/null differ diff --git a/KylinNM/res/s/conning-s/1x/4.png b/KylinNM/res/s/conning-s/1x/4.png deleted file mode 100644 index c8a9a98..0000000 Binary files a/KylinNM/res/s/conning-s/1x/4.png and /dev/null differ diff --git a/KylinNM/res/s/conning-s/1x/5.png b/KylinNM/res/s/conning-s/1x/5.png deleted file mode 100644 index 0595e6b..0000000 Binary files a/KylinNM/res/s/conning-s/1x/5.png and /dev/null differ diff --git a/KylinNM/res/s/conning-s/1x/6.png b/KylinNM/res/s/conning-s/1x/6.png deleted file mode 100644 index 274f5a8..0000000 Binary files a/KylinNM/res/s/conning-s/1x/6.png and /dev/null differ diff --git a/KylinNM/res/s/conning-s/1x/7.png b/KylinNM/res/s/conning-s/1x/7.png deleted file mode 100644 index c49a271..0000000 Binary files a/KylinNM/res/s/conning-s/1x/7.png and /dev/null differ diff --git a/KylinNM/res/s/conning-s/1x/8.png b/KylinNM/res/s/conning-s/1x/8.png deleted file mode 100644 index 94946d6..0000000 Binary files a/KylinNM/res/s/conning-s/1x/8.png and /dev/null differ diff --git a/KylinNM/res/s/conning-s/1x/9.png b/KylinNM/res/s/conning-s/1x/9.png deleted file mode 100644 index 87f7419..0000000 Binary files a/KylinNM/res/s/conning-s/1x/9.png and /dev/null differ diff --git a/KylinNM/res/s/conning-s/2.png b/KylinNM/res/s/conning-s/2.png deleted file mode 100644 index eb6a4a4..0000000 Binary files a/KylinNM/res/s/conning-s/2.png and /dev/null differ diff --git a/KylinNM/res/s/conning-s/3.png b/KylinNM/res/s/conning-s/3.png deleted file mode 100644 index f985e8c..0000000 Binary files a/KylinNM/res/s/conning-s/3.png and /dev/null differ diff --git a/KylinNM/res/s/conning-s/4.png b/KylinNM/res/s/conning-s/4.png deleted file mode 100644 index e8645dc..0000000 Binary files a/KylinNM/res/s/conning-s/4.png and /dev/null differ diff --git a/KylinNM/res/s/conning-s/5.png b/KylinNM/res/s/conning-s/5.png deleted file mode 100644 index 089e671..0000000 Binary files a/KylinNM/res/s/conning-s/5.png and /dev/null differ diff --git a/KylinNM/res/s/conning-s/6.png b/KylinNM/res/s/conning-s/6.png deleted file mode 100644 index aee7edf..0000000 Binary files a/KylinNM/res/s/conning-s/6.png and /dev/null differ diff --git a/KylinNM/res/s/conning-s/7.png b/KylinNM/res/s/conning-s/7.png deleted file mode 100644 index 914deea..0000000 Binary files a/KylinNM/res/s/conning-s/7.png and /dev/null differ diff --git a/KylinNM/res/s/conning-s/8.png b/KylinNM/res/s/conning-s/8.png deleted file mode 100644 index b3de287..0000000 Binary files a/KylinNM/res/s/conning-s/8.png and /dev/null differ diff --git a/KylinNM/res/s/conning-s/9.png b/KylinNM/res/s/conning-s/9.png deleted file mode 100644 index ffbdb73..0000000 Binary files a/KylinNM/res/s/conning-s/9.png and /dev/null differ diff --git a/KylinNM/res/s/rescan/1.png b/KylinNM/res/s/rescan/1.png deleted file mode 100644 index 19c4f77..0000000 Binary files a/KylinNM/res/s/rescan/1.png and /dev/null differ diff --git a/KylinNM/res/s/rescan/10.png b/KylinNM/res/s/rescan/10.png deleted file mode 100644 index 2b4c501..0000000 Binary files a/KylinNM/res/s/rescan/10.png and /dev/null differ diff --git a/KylinNM/res/s/rescan/11.png b/KylinNM/res/s/rescan/11.png deleted file mode 100644 index c43ee8c..0000000 Binary files a/KylinNM/res/s/rescan/11.png and /dev/null differ diff --git a/KylinNM/res/s/rescan/12.png b/KylinNM/res/s/rescan/12.png deleted file mode 100644 index b3c08be..0000000 Binary files a/KylinNM/res/s/rescan/12.png and /dev/null differ diff --git a/KylinNM/res/s/rescan/2.png b/KylinNM/res/s/rescan/2.png deleted file mode 100644 index 4062892..0000000 Binary files a/KylinNM/res/s/rescan/2.png and /dev/null differ diff --git a/KylinNM/res/s/rescan/3.png b/KylinNM/res/s/rescan/3.png deleted file mode 100644 index d6a64bc..0000000 Binary files a/KylinNM/res/s/rescan/3.png and /dev/null differ diff --git a/KylinNM/res/s/rescan/4.png b/KylinNM/res/s/rescan/4.png deleted file mode 100644 index f92092f..0000000 Binary files a/KylinNM/res/s/rescan/4.png and /dev/null differ diff --git a/KylinNM/res/s/rescan/5.png b/KylinNM/res/s/rescan/5.png deleted file mode 100644 index 279fd34..0000000 Binary files a/KylinNM/res/s/rescan/5.png and /dev/null differ diff --git a/KylinNM/res/s/rescan/6.png b/KylinNM/res/s/rescan/6.png deleted file mode 100644 index cea2f89..0000000 Binary files a/KylinNM/res/s/rescan/6.png and /dev/null differ diff --git a/KylinNM/res/s/rescan/7.png b/KylinNM/res/s/rescan/7.png deleted file mode 100644 index f9b384a..0000000 Binary files a/KylinNM/res/s/rescan/7.png and /dev/null differ diff --git a/KylinNM/res/s/rescan/8.png b/KylinNM/res/s/rescan/8.png deleted file mode 100644 index 3930bef..0000000 Binary files a/KylinNM/res/s/rescan/8.png and /dev/null differ diff --git a/KylinNM/res/s/rescan/9.png b/KylinNM/res/s/rescan/9.png deleted file mode 100644 index bd22fa1..0000000 Binary files a/KylinNM/res/s/rescan/9.png and /dev/null differ diff --git a/KylinNM/res/w/pb-all-wifi-offline.png b/KylinNM/res/w/pb-all-wifi-offline.png deleted file mode 100644 index fb2cb35..0000000 Binary files a/KylinNM/res/w/pb-all-wifi-offline.png and /dev/null differ diff --git a/KylinNM/res/w/pb-top-wifi-offline.png b/KylinNM/res/w/pb-top-wifi-offline.png deleted file mode 100644 index 89310de..0000000 Binary files a/KylinNM/res/w/pb-top-wifi-offline.png and /dev/null differ diff --git a/KylinNM/res/w/wifi-full-off.png b/KylinNM/res/w/wifi-full-off.png deleted file mode 100644 index 54e83d6..0000000 Binary files a/KylinNM/res/w/wifi-full-off.png and /dev/null differ diff --git a/KylinNM/res/w/wifi-full-pwd-off.png b/KylinNM/res/w/wifi-full-pwd-off.png deleted file mode 100644 index 7949090..0000000 Binary files a/KylinNM/res/w/wifi-full-pwd-off.png and /dev/null differ diff --git a/KylinNM/res/w/wifi-full-pwd.png b/KylinNM/res/w/wifi-full-pwd.png deleted file mode 100644 index 292c031..0000000 Binary files a/KylinNM/res/w/wifi-full-pwd.png and /dev/null differ diff --git a/KylinNM/res/w/wifi-full.png b/KylinNM/res/w/wifi-full.png deleted file mode 100644 index a858240..0000000 Binary files a/KylinNM/res/w/wifi-full.png and /dev/null differ diff --git a/KylinNM/res/w/wifi-high-off.png b/KylinNM/res/w/wifi-high-off.png deleted file mode 100644 index cc5fa77..0000000 Binary files a/KylinNM/res/w/wifi-high-off.png and /dev/null differ diff --git a/KylinNM/res/w/wifi-high-pwd-off.png b/KylinNM/res/w/wifi-high-pwd-off.png deleted file mode 100644 index 2ca3038..0000000 Binary files a/KylinNM/res/w/wifi-high-pwd-off.png and /dev/null differ diff --git a/KylinNM/res/w/wifi-high-pwd.png b/KylinNM/res/w/wifi-high-pwd.png deleted file mode 100644 index 3b1f477..0000000 Binary files a/KylinNM/res/w/wifi-high-pwd.png and /dev/null differ diff --git a/KylinNM/res/w/wifi-high.png b/KylinNM/res/w/wifi-high.png deleted file mode 100644 index f6ab167..0000000 Binary files a/KylinNM/res/w/wifi-high.png and /dev/null differ diff --git a/KylinNM/res/w/wifi-low-off.png b/KylinNM/res/w/wifi-low-off.png deleted file mode 100644 index 60e238a..0000000 Binary files a/KylinNM/res/w/wifi-low-off.png and /dev/null differ diff --git a/KylinNM/res/w/wifi-low-pwd-off.png b/KylinNM/res/w/wifi-low-pwd-off.png deleted file mode 100644 index 1c6860d..0000000 Binary files a/KylinNM/res/w/wifi-low-pwd-off.png and /dev/null differ diff --git a/KylinNM/res/w/wifi-low-pwd.png b/KylinNM/res/w/wifi-low-pwd.png deleted file mode 100644 index 9cc769e..0000000 Binary files a/KylinNM/res/w/wifi-low-pwd.png and /dev/null differ diff --git a/KylinNM/res/w/wifi-low.png b/KylinNM/res/w/wifi-low.png deleted file mode 100644 index 3631505..0000000 Binary files a/KylinNM/res/w/wifi-low.png and /dev/null differ diff --git a/KylinNM/res/w/wifi-medium-off.png b/KylinNM/res/w/wifi-medium-off.png deleted file mode 100644 index c823649..0000000 Binary files a/KylinNM/res/w/wifi-medium-off.png and /dev/null differ diff --git a/KylinNM/res/w/wifi-medium-pwd-off.png b/KylinNM/res/w/wifi-medium-pwd-off.png deleted file mode 100644 index a9e96d8..0000000 Binary files a/KylinNM/res/w/wifi-medium-pwd-off.png and /dev/null differ diff --git a/KylinNM/res/w/wifi-medium-pwd.png b/KylinNM/res/w/wifi-medium-pwd.png deleted file mode 100644 index cc2d363..0000000 Binary files a/KylinNM/res/w/wifi-medium-pwd.png and /dev/null differ diff --git a/KylinNM/res/w/wifi-medium.png b/KylinNM/res/w/wifi-medium.png deleted file mode 100644 index 82cdf40..0000000 Binary files a/KylinNM/res/w/wifi-medium.png and /dev/null differ diff --git a/KylinNM/res/w/wifi-none-off.png b/KylinNM/res/w/wifi-none-off.png deleted file mode 100644 index 65dceb2..0000000 Binary files a/KylinNM/res/w/wifi-none-off.png and /dev/null differ diff --git a/KylinNM/res/w/wifi-none-pwd-off.png b/KylinNM/res/w/wifi-none-pwd-off.png deleted file mode 100644 index 0cdd769..0000000 Binary files a/KylinNM/res/w/wifi-none-pwd-off.png and /dev/null differ diff --git a/KylinNM/res/w/wifi-none-pwd.png b/KylinNM/res/w/wifi-none-pwd.png deleted file mode 100644 index c3fd701..0000000 Binary files a/KylinNM/res/w/wifi-none-pwd.png and /dev/null differ diff --git a/KylinNM/res/w/wifi-none.png b/KylinNM/res/w/wifi-none.png deleted file mode 100644 index b4927dc..0000000 Binary files a/KylinNM/res/w/wifi-none.png and /dev/null differ diff --git a/KylinNM/res/x/fly-mode-off.svg b/KylinNM/res/x/fly-mode-off.svg deleted file mode 100644 index 408b7b0..0000000 --- a/KylinNM/res/x/fly-mode-off.svg +++ /dev/null @@ -1,19 +0,0 @@ - - - - -画板 1 - - - - - diff --git a/KylinNM/res/x/fly-mode-on.svg b/KylinNM/res/x/fly-mode-on.svg deleted file mode 100644 index 9f5e543..0000000 --- a/KylinNM/res/x/fly-mode-on.svg +++ /dev/null @@ -1,14 +0,0 @@ - - - - -画板 1 - - diff --git a/KylinNM/res/x/hot-spot-off.svg b/KylinNM/res/x/hot-spot-off.svg deleted file mode 100644 index cf39cad..0000000 --- a/KylinNM/res/x/hot-spot-off.svg +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - diff --git a/KylinNM/res/x/hot-spot-on.svg b/KylinNM/res/x/hot-spot-on.svg deleted file mode 100644 index 2041db9..0000000 --- a/KylinNM/res/x/hot-spot-on.svg +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - diff --git a/KylinNM/res/x/load-down.png b/KylinNM/res/x/load-down.png deleted file mode 100644 index a96298a..0000000 Binary files a/KylinNM/res/x/load-down.png and /dev/null differ diff --git a/KylinNM/res/x/load-up.png b/KylinNM/res/x/load-up.png deleted file mode 100644 index e5ec581..0000000 Binary files a/KylinNM/res/x/load-up.png and /dev/null differ diff --git a/KylinNM/res/x/net-list-bg.svg b/KylinNM/res/x/net-list-bg.svg deleted file mode 100644 index c17c1fd..0000000 --- a/KylinNM/res/x/net-list-bg.svg +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - diff --git a/KylinNM/res/x/pb-close.png b/KylinNM/res/x/pb-close.png deleted file mode 100644 index c5cc8ad..0000000 Binary files a/KylinNM/res/x/pb-close.png and /dev/null differ diff --git a/KylinNM/res/x/pb-conn-dis.png b/KylinNM/res/x/pb-conn-dis.png deleted file mode 100644 index 3726203..0000000 Binary files a/KylinNM/res/x/pb-conn-dis.png and /dev/null differ diff --git a/KylinNM/res/x/pb-newConn.png b/KylinNM/res/x/pb-newConn.png deleted file mode 100644 index 86a18e0..0000000 Binary files a/KylinNM/res/x/pb-newConn.png and /dev/null differ diff --git a/KylinNM/res/x/pb-wifi-n.png b/KylinNM/res/x/pb-wifi-n.png deleted file mode 100644 index 54e83d6..0000000 Binary files a/KylinNM/res/x/pb-wifi-n.png and /dev/null differ diff --git a/KylinNM/res/x/pb-wifi-y.png b/KylinNM/res/x/pb-wifi-y.png deleted file mode 100644 index a858240..0000000 Binary files a/KylinNM/res/x/pb-wifi-y.png and /dev/null differ diff --git a/KylinNM/res/x/setup.png b/KylinNM/res/x/setup.png deleted file mode 100644 index fe242f8..0000000 Binary files a/KylinNM/res/x/setup.png and /dev/null differ diff --git a/KylinNM/res/x/wifi-list-bg.svg b/KylinNM/res/x/wifi-list-bg.svg deleted file mode 100644 index 43f1866..0000000 --- a/KylinNM/res/x/wifi-list-bg.svg +++ /dev/null @@ -1,15 +0,0 @@ - - - - -画板 1 - - - - - - - diff --git a/KylinNM/src/backthread.cpp b/KylinNM/src/backthread.cpp deleted file mode 100644 index 5af20e0..0000000 --- a/KylinNM/src/backthread.cpp +++ /dev/null @@ -1,464 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see -#include -#include -#include -#include - -#include -#include -#include - -#include "kylinnm.h" //逼不得已,引入kylinnm头文件 - -BackThread::BackThread(QObject *parent) : QObject(parent) -{ -} - -BackThread::~BackThread() -{ - if (cmdConnWifi) { - cmdConnWifi->close(); - } -} - -//get the connection state of wired and wireles network -IFace BackThread::execGetIface() -{ - IFace iface; - - QString tmpPath = "/tmp/kylin-nm-iface-" + QDir::home().dirName(); - QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli -f TYPE,DEVICE,STATE device > " + tmpPath; - Utils::m_system(cmd.toUtf8().data()); - - // int status = system(cmd.toUtf8().data()); - // if (status != 0){ syslog(LOG_ERR, "execute 'nmcli device' in function 'execGetIface' failed");} - - QFile file(tmpPath); - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { - // print information if can not open file ~/.config/kylin-nm-iface - syslog(LOG_ERR, "Can't open the file ~/.config/kylin-nm-iface!"); - qDebug()<<"Can't open the file ~/.config/kylin-nm-iface!"; - } - QString txt = file.readAll(); - QStringList txtList = txt.split("\n"); - file.close(); - - iface.lstate = 2; - iface.wstate = 2; - - for (int i = 1; i < txtList.size(); i ++) { - QString line = txtList.at(i); - if (line != "") { - int index1 = line.indexOf(" "); - QString type = line.left(index1); - QString lastStr = line.mid(index1).trimmed(); - int index2 = lastStr.indexOf(" "); - QString iname = lastStr.left(index2); - QString istateStr = lastStr.mid(index2).trimmed(); - - if (type == "ethernet" && iface.lstate != 0) { - // if type is wired network - iface.lname = iname; - - if (istateStr == "unmanaged") { - iface.lstate = 2; //switch of wired device is off - } - if (istateStr == "disconnected" || istateStr == "unavailable") { - iface.lstate = 1; //wired network is disconnected - } - if (istateStr == "connected") { - iface.lstate = 0; //wired network is connected - } - } - if (type == "wifi" && iface.wstate != 0) { - // if type is wireless network - iface.wname = iname; - - if (istateStr == "unmanaged" || istateStr == "unavailable") { - iface.wstate = 2; //switch of wireless device is off - } - if (istateStr == "disconnected") { - iface.wstate = 1; //wireless network is disconnected - } - if (istateStr == "connected") { - iface.wstate = 0; //wireless network is connected - } - } - } - } - - return iface; -} - -//turn on the switch of network -void BackThread::execEnNet() -{ - char *chr = "nmcli networking on"; - Utils::m_system(chr); - - // int status = system("nmcli networking on"); - // if (status != 0){ syslog(LOG_ERR, "execute 'nmcli networking on' in function 'execEnNet' failed");} - while (1) { - if (execGetIface().lstate != 2) { - sleep(3); - emit enNetDone(); - emit btFinish(); - break; - } - sleep(1); - } -} - -//turn off the switch of wireless network first, then turn off the switch of network -void BackThread::execDisNet() -{ - if (execGetIface().wstate != 2) { - char *chr = "nmcli radio wifi off"; - Utils::m_system(chr); - - // int status = system("nmcli radio wifi off"); - // if (status != 0){ syslog(LOG_ERR, "execute 'nmcli radio wifi off' in function 'execDisNet' failed");} - while (1) { - if (execGetIface().wstate == 2) { - emit disWifiDone(); - emit btFinish(); - break; - } - sleep(1); - } - } - - char *chr1 = "nmcli networking off"; - Utils::m_system(chr1); - // int status1 = system("nmcli networking off"); - // if (status1 != 0){ syslog(LOG_ERR, "execute 'nmcli networking off' in function 'execDisNet' failed");} - while (1) { - if (execGetIface().lstate == 2) { - emit disNetDone(); - emit btFinish(); - break; - } - sleep(1); - } -} - -//turn on the switch of wireless network -void BackThread::execEnWifi() -{ - //if (execGetIface()->lstate == 2){ - // char *chr = "nmcli networking on"; - // Utils::m_system(chr); - // //int status = system("nmcli networking on"); - // //if (status != 0){ syslog(LOG_ERR, "execute 'nmcli networking on' in function 'execEnWifi' failed");} - // while(1){ - // if (execGetIface()->lstate != 2){ - // emit launchLanDone(); - // break; - // } - // sleep(1); - // } - //} - - char *chr1 = "nmcli radio wifi on"; - Utils::m_system(chr1); - //int status1 = system("nmcli radio wifi on"); - //if (status1 != 0){ syslog(LOG_ERR, "execute 'nmcli radio wifi on' in function 'execEnWifi' failed");} - while (1) { - if (execGetIface().wstate != 2) { - KylinDBus objKyDbus; - while (1) { - if (objKyDbus.getAccessPointsNumber() > 0) { - // objKyDbus.getAccessPointsNumber()>0 standard can get wireless accesspoints now - KylinNM::reflashWifiUi(); - emit enWifiDone(); - emit btFinish(); - break; - } - sleep(2); - } - break; - } - sleep(1); - } -} - -//turn off the switch of wireless network -void BackThread::execDisWifi() -{ - char *chr = "nmcli radio wifi off"; - Utils::m_system(chr); - // int status = system("nmcli radio wifi off"); - // if (status != 0){ syslog(LOG_ERR, "execute 'nmcli radio wifi off' in function 'execDisWifi' failed");} - while (1) { - if (execGetIface().wstate == 2) { - KylinNM::reflashWifiUi(); - emit disWifiDone(); - emit btFinish(); - break; - } - sleep(1); - } -} - -//to connect wired network -void BackThread::execConnLan(QString connName) -{ - disConnLanOrWifi("ethernet"); - - KylinDBus objKyDbus; - if (objKyDbus.isWiredCableOn) { - // only if wired cable is plug in, can connect wired network - QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection up \"" + connName.replace("\"","\\\"") + "\""; - Utils::m_system(cmd.toUtf8().data()); - // int status = system(cmd.toUtf8().data()); - // if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection up' in function 'execConnLan' failed");} - qDebug()<<"debug: in function execConnLan, wired net state is: "< " + tmpPath; - Utils::m_system(cmdStr.toUtf8().data()); - // int status = system(cmdStr.toUtf8().data()); - // if (status != 0){ syslog(LOG_ERR, "execute 'nmcli device wifi connect' in function 'execConnWifiPWD' failed");} - QFile file(tmpPath); - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { - syslog(LOG_DEBUG, "Can't open the file /tmp/kylin-nm-btoutput !"); - qDebug()<<"Can't open the file /tmp/kylin-nm-btoutput !"<start("bash"); - cmdConnWifi->waitForStarted(); - } - QString cmdStr = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection up \"" + connName.replace("\"","\\\"") + "\"\n"; - cmdConnWifi->write(cmdStr.toUtf8().data()); -} - -void BackThread::on_readoutput() -{ - QString str = cmdConnWifi->readAllStandardOutput(); - cmdConnWifi->close(); - qDebug()<<"on_readoutput: "<< str; - if (str.indexOf("successfully") != -1) { - emit connDone(0); //send this signal if connect net successfully - qDebug()<<"debug: in function on_readoutput, wireless net state is: "<readAllStandardError(); - cmdConnWifi->close(); - qDebug()<<"on_readerror: "<< str; - if (str.indexOf("successfully") != -1) { - emit connDone(0); - } else if(str.indexOf("unknown") != -1 || str.indexOf("not exist") != -1) { - emit connDone(2); //send this signal if the network we want to connect has not a configuration file - } else { - emit connDone(1); //send this signal if connect net failed - } - - emit btFinish(); -} - -//get property of connected network -QString BackThread::getConnProp(QString connName) -{ - QString tmpPath = "/tmp/kylin-nm-connprop-" + QDir::home().dirName(); - QString cmd = "export LANG='zh_CN.UTF-8';export LANGUAGE='zh_CN';nmcli connection show \"" + connName.replace("\"","\\\"") + "\" > " + tmpPath; - Utils::m_system(cmd.toUtf8().data()); - // int status = system(cmd.toUtf8().data()); - // if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection show' in function 'getConnProp' failed");} - - QFile file(tmpPath); - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { - syslog(LOG_ERR, "Can't open the file /tmp/kylin-nm-connprop!"); - qDebug()<<"Can't open the file /tmp/kylin-nm-connprop!"< " + tmpPath; - Utils::m_system(cmd.toUtf8().data()); - // int status = system(cmd.toUtf8().data()); - // if (status != 0){ syslog(LOG_ERR, "execute 'ethtool' in function 'execChkLanWidth' failed");} - - QFile file(tmpPath); - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { - syslog(LOG_ERR, "Can't open the file /tmp/kylin-nm-bandwidth!"); - qDebug()<<"Can't open the file /tmp/kylin-nm-bandwidth!"< -#include -#include -#include -#include -#include -#include - -class IFace{ -public: - QString lname = ""; - QString wname = ""; - int lstate = 2; // 0已连接 1未连接 2已关闭 - int wstate = 2; // 0已连接 1未连接 2已关闭 -}; - -class BackThread : public QObject -{ - Q_OBJECT -public: - explicit BackThread(QObject *parent = nullptr); - ~BackThread(); - - IFace execGetIface(); - QString getConnProp(QString connName); - QString execChkLanWidth(QString ethName); - QProcess *cmdConnWifi = nullptr; - -public Q_SLOTS: - void execEnNet(); - void execDisNet(); - void execEnWifi(); - void execDisWifi(); - void execConnLan(QString connName); - void execConnWifi(QString connName); - void execConnWifiPWD(QString connName, QString password); - - void disConnSparedNetSlot(QString type); - void disConnLanOrWifi(QString type); - - void on_readoutput(); - void on_readerror(); - -Q_SIGNALS: - void enNetDone(); - void disNetDone(); - void enWifiDone(); - void launchLanDone(); - void disWifiDone(); - - void connDone(int connFlag); - - void btFinish(); - void disFinish(); - void ttFinish(); -}; - -#endif // BACKTHREAD_H diff --git a/KylinNM/src/confform.cpp b/KylinNM/src/confform.cpp deleted file mode 100644 index 493c50a..0000000 --- a/KylinNM/src/confform.cpp +++ /dev/null @@ -1,552 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see -#include -#include - -extern QString llname, lwname; - -ConfForm::ConfForm(QWidget *parent) : - QWidget(parent), - ui(new Ui::ConfForm) -{ - ui->setupUi(this); - this->setWindowFlags(Qt::FramelessWindowHint); //Qt::WindowStaysOnTopHint - this->setWindowTitle(tr("edit network"));//"网络设置" - this->setAttribute(Qt::WA_TranslucentBackground); - //需要添加 void paintEvent(QPaintEvent *event) 函数 - - QPainterPath path; - auto rect = this->rect(); - rect.adjust(1, 1, -1, -1); - path.addRoundedRect(rect, 6, 6); - setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon())); - - this->setStyleSheet("QWidget{border-radius:16px;border:none;}"); -// KylinDBus mkylindbus; - - QString strTrans; - strTrans = QString::number(1, 10, 2); - QString sty = "#centralWidget{border:1px solid rgba(255,255,255,0.05);border-radius:16px;background:rgba(255,255,255," + strTrans + ");}"; - ui->centralWidget->setStyleSheet(sty); - - labelQss = "QLabel{border:0px;color:rgba(38,38,38,1);background-color:transparent;}"; - cbxQss = "QComboBox{padding-left:20px;font-size:13px;color:rgba(38,38,38,1);" - "border:1px solid rgba(255, 255, 255, 0.05);border-radius:4px;background:rgba(255,255,255,0.08);}" - "QComboBox::drop-down{border:0px;width:30px;}" - "QComboBox::down-arrow{image:url(:/res/g/down_arrow.png);}" - "QComboBox QAbstractItemView {margin:0px 0px 0px 0px;padding: 0px 0px;border-radius:0px;background-color:#48484C;outline:0px;}" - "QComboBox QAbstractItemView::item{padding-left:17px;border-radius:0px;font-size:13px;color:rgba(255,255,255,0.91);height: 32px;background-color:#48484C;outline:0px;}" - "QComboBox QAbstractItemView::item:hover{padding-left:17px;border-radius:0px;font-size:13px;color:rgba(255,255,255,0.91);background-color:#3D6BE5;outline:0px;}"; - leQss = "QLineEdit{padding-left:20px;color:rgba(38,38,38,1);background:rgba(245,245,245,1);}"; - btnOffQss = "QPushButton{border:1px solid rgba(44,44,44,1);border-radius:4px;background-color:rgba(255,255,255,0.12);color:rgba(44,44,44,1);font-size:14px;}"; - // "QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(255,255,255,0.2);}" - // "QPushButton:Pressed{border-radius:4px;background-color:rgba(255,255,255,0.08);}"; - btnOnQss = "QPushButton{border:0px;border-radius:4px;background-color:rgba(61,107,229,1);color:white;font-size:14px;}" - "QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(107,142,235,1);}" - "QPushButton:Pressed{border-radius:4px;background-color:rgba(50,87,202,1);}"; - lineQss = "background:rgba(255,255,255,0.08);"; - - // ui->centralWidget->setStyleSheet("#centralWidget{border:1px solid #297a97;background-color:#ffffff;}"); - ui->wdHead->setStyleSheet("#wdHead{border:none}"); - ui->wgManual->setStyleSheet("#wgManual{border:none}"); - ui->wdBottom->setStyleSheet("#wdBottom{border:none}"); - ui->lbLeftupTitle->setStyleSheet("QLabel{border:0px;font-size:14px;color:rgba(38,38,38,1);background-color:transparent;}"); - ui->lbName->setStyleSheet(labelQss); - ui->lbTxt1->setStyleSheet(labelQss); - ui->lbTxt2->setStyleSheet(labelQss); - ui->lbTxt3->setStyleSheet(labelQss); - ui->lbTxt4->setStyleSheet(labelQss); - ui->lbTxt5->setStyleSheet(labelQss); - ui->lbTxt6->setStyleSheet(labelQss); - - //YYF - ui->btnClose->setStyleSheet("border-image:url(:/res/x/pb-close.png);"); - connect(ui->btnClose,&QPushButton::clicked,ui->btnCancel,&QPushButton::clicked); - ui->isDHCP->setStyleSheet("QCheckBox::indicator {width: 16px; height: 16px;}" - "QCheckBox::indicator:checked {image: url(:/res/g/checkbox-checked.svg);}" - "QCheckBox::indicator:unchecked {image: url(:/res/g/checkbox-unchecked.svg);}"); - ui->notDHCP->setStyleSheet("QCheckBox::indicator {width: 16px; height: 16px;}" - "QCheckBox::indicator:checked {image: url(:/res/g/checkbox-checked.svg);}" - "QCheckBox::indicator:unchecked {image: url(:/res/g/checkbox-unchecked.svg);}"); - - ui->cbType->setStyleSheet(cbxQss); - ui->cbType->setView(new QListView()); - ui->cbType->hide(); - ui->cbMask->setStyleSheet(cbxQss); - ui->cbMask->setView(new QListView()); - - ui->leName->setStyleSheet(leQss); - ui->leAddr->setStyleSheet(leQss); - ui->leGateway->setStyleSheet(leQss); - ui->leDns->setStyleSheet(leQss); - ui->leDns2->setStyleSheet(leQss); - - ui->btnCancel->setStyleSheet(btnOffQss); - ui->btnOk->setStyleSheet(btnOnQss); - ui->btnCreate->setStyleSheet(btnOnQss); - ui->lineUp->setStyleSheet(lineQss); - ui->lineDown->setStyleSheet(lineQss); - ui->lineUp->hide(); - ui->lineDown->hide(); - - ui->lbName->setText(tr("LAN name: "));//"网络名称:" - ui->lbTxt1->setText(tr("Method: "));//"编辑IP设置:" - ui->lbTxt2->setText(tr("Address: "));//"IP地址:" - ui->lbTxt3->setText(tr("Netmask: "));//"子网掩码:" - ui->lbTxt4->setText(tr("Gateway: "));//"默认网关:" - ui->lbTxt5->setText(tr("DNS 1: "));//"首选DNS:" - ui->lbTxt6->setText(tr("DNS 2: "));//"备选DNS:" - - ui->lbLeftupTitle->setText(tr("Edit Conn"));//"网络设置" - ui->cbType->addItem(tr("Auto(DHCP)"));//"自动(DHCP)" - ui->cbType->addItem(tr("Manual"));//"手动" - ui->isDHCP->setText(tr("Auto(DHCP)")); - ui->notDHCP->setText(tr("Manual")); - - connect(ui->cbType, SIGNAL(currentIndexChanged(int)), this, SLOT(cbTypeChanged(int))); - - ui->cbMask->addItem("255.255.255.0"); //24 - ui->cbMask->addItem("255.255.254.0"); //23 - ui->cbMask->addItem("255.255.252.0"); //22 - ui->cbMask->addItem("255.255.0.0"); //16 - ui->cbMask->addItem("255.0.0.0"); //8 -// ui->cbMask->setWindowFlags(Qt::X11BypassWindowManagerHint); - ui->cbMask->view()->setWindowFlags(Qt::Popup | Qt::X11BypassWindowManagerHint); - ui->cbMask->view()->setParent(this); - ui->cbMask->view()->hide(); - - ui->cbMask->installEventFilter(this); - ui->cbMask->view()->installEventFilter(this); - - connect(ui->cbMask->view(), &QAbstractItemView::pressed, this, [=](QModelIndex index){ -// qDebug() << "-----------------------pressed:" << index.row(); -// qDebug() << "-----------------------itemText:" << ui->cbMask->itemText(index.row()); - Q_EMIT ui->cbMask->setCurrentIndex(index.row()); - ui->cbMask->view()->hide(); - }); - -// connect(ui->cbMask->view(), &QAbstractItemView::entered, this, [=](QModelIndex index){ -// qDebug() << "-----------------------entered:" << index.row(); -// }); - - ui->cbMask->view()->setGeometry(QRect(ui->cbMask->geometry().left(), ui->wgManual->geometry().top() + ui->cbMask->geometry().bottom(), ui->cbMask->view()->width(), ui->cbMask->view()->height())); - - ui->btnCancel->setText(tr("Cancel"));//"取消" - ui->btnOk->setText(tr("Save"));//"保存" - ui->btnCreate->setText(tr("Ok"));//"确定" - - ui->btnCancel->setFocusPolicy(Qt::NoFocus); - ui->btnOk->setFocusPolicy(Qt::NoFocus); - ui->btnCreate->setFocusPolicy(Qt::NoFocus); - - // IP的正则格式限制 - QRegExp rx("\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b"); - ui->leAddr->setValidator(new QRegExpValidator(rx, this)); - ui->leGateway->setValidator(new QRegExpValidator(rx, this)); - ui->leDns->setValidator(new QRegExpValidator(rx, this)); - ui->leDns2->setValidator(new QRegExpValidator(rx, this)); - -} - -void ConfForm::setMainWindow(KylinNM *mainwindow) -{ - this->mw = mainwindow; -} - -ConfForm::~ConfForm() -{ - delete ui; -} - -bool ConfForm::eventFilter(QObject *obj, QEvent *ev) -{ - if(obj == ui->cbMask) - { - if(ev->type() == QEvent::MouseButtonPress) - { - ui->cbMask->view()->setVisible(!ui->cbMask->view()->isVisible()); - if(ui->cbMask->view()->isVisible()) - ui->cbMask->view()->setFocus(); - } - } else if (obj != ui->cbMask->view()) - { - ui->cbMask->view()->hide(); - } - return false; -} - -void ConfForm::mousePressEvent(QMouseEvent *event) -{ - if (event->button() == Qt::LeftButton) { - this->isPress = true; - this->winPos = this->pos(); - this->dragPos = event->globalPos(); - event->accept(); - } -} -void ConfForm::mouseReleaseEvent(QMouseEvent *event) -{ - this->isPress = false; -} -void ConfForm::mouseMoveEvent(QMouseEvent *event) -{ - if (this->isPress) { - this->move(this->winPos - (this->dragPos - event->globalPos())); - event->accept(); - } -} - -void ConfForm::tabletStyle(bool isTablet) -{ - isTabletStyle = isTablet; - - ui->leName->resize(290+194*isTabletStyle,48); - ui->leName->resize(290+194*isTabletStyle,48); - ui->btnOk->move(312+194*isTabletStyle,25); - ui->btnCreate->move(312+194*isTabletStyle,25); - ui->btnCancel->move(180+194*isTabletStyle,25); - ui->btnClose->move(408+194*isTabletStyle,8); - ui->isDHCP->move(180+194*isTabletStyle,130); - ui->notDHCP->move(356+194*isTabletStyle,130); - - ui->wdBottom->setFixedWidth(446+194*isTabletStyle); - ui->wdHead->setFixedWidth(446+194*isTabletStyle); - ui->wgManual->setFixedWidth(446+194*isTabletStyle); - ui->upTitle->setFixedWidth(446+194*isTabletStyle); -} - -//网络配置参数设置界面的显示内容 -void ConfForm::setProp(QString connName, QString v4method, QString addr, QString mask, QString gateway, QString dns, bool isActConf) -{ - this->isActConf = isActConf; - ui->leName->setText(connName); - - if (v4method == "auto" || v4method == "") { - ui->isDHCP->setChecked(true); - ui->notDHCP->setChecked(false); - ui->cbType->setCurrentIndex(0); - cbTypeChanged(0); - } else { - ui->isDHCP->setChecked(false); - ui->notDHCP->setChecked(true); - ui->cbType->setCurrentIndex(1); - cbTypeChanged(1); - } - - ui->leAddr->setText(addr); - ui->leGateway->setText(gateway); - - // 配置中有多个DNS,只处理前两个 - if (dns.indexOf(",") != -1) { - QStringList dnss = dns.split(","); - ui->leDns->setText(dnss.at(0)); - ui->leDns2->setText(dnss.at(1)); - } else { - ui->leDns->setText(dns); - ui->leDns2->setText(""); - } - - if (mask == "24") { - ui->cbMask->setCurrentIndex(0); - } else if(mask == "23") { - ui->cbMask->setCurrentIndex(1); - } else if(mask == "22") { - ui->cbMask->setCurrentIndex(2); - } else if(mask == "16") { - ui->cbMask->setCurrentIndex(3); - } else if(mask == "8") { - ui->cbMask->setCurrentIndex(4); - } else { - ui->cbMask->setCurrentIndex(0); - } -} - -//点击了创建新的网络的按钮 -void ConfForm::on_btnCreate_clicked() -{ - if (mw->lanNameList.contains(ui->leName->text())) { - qWarning() << "Warn : 已有同名LAN存在:" << ui->leName->text(); - // ui->tipLabel->show(); - return; - } - KylinDBus kylindbus; - kylindbus.getWiredCardName(); - QString mIfname = kylindbus.dbusLanCardName; - - if (mIfname == "") { - QString tip(tr("Can not create new wired network for without wired card")); -// kylindbus.showDesktopNotify(tip); - this->hide(); - return; - } - - QString name = ui->leName->text(); - QString cmdStr = "nmcli connection add con-name \"" + name.replace("\"","\\\"") + "\" type ethernet"; //由于样机存在veth虚拟网卡,故不指定有线设备,将自动选择 - Utils::m_system(cmdStr.toUtf8().data()); - //int status = system(cmdStr.toUtf8().data()); - //if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection add con-name' in function 'on_btnCreate_clicked' failed");} - - if (ui->cbType->currentIndex() == 1) { - //config the ipv4 and netmask and gateway if select Manual - this->isCreateNewNet = true; - this->on_btnOk_clicked(); - } else { - QString txt(tr("New network already created")); -// kylindbus.showDesktopNotify(txt); - } - - this->hide(); -} - -//点击了保存更改网络设置的按钮 -void ConfForm::on_btnOk_clicked() -{ - QString mask = ""; - if (ui->cbMask->currentIndex() == 0) { - mask = "24"; - } else if(ui->cbMask->currentIndex() == 1) { - mask = "23"; - } else if(ui->cbMask->currentIndex() == 2) { - mask = "22"; - } else if(ui->cbMask->currentIndex() == 3) { - mask = "16"; - } else if(ui->cbMask->currentIndex() == 4) { - mask = "8"; - } else { - mask = "24"; - } - - if (ui->cbType->currentIndex() == 0) { - QString name = ui->leName->text(); - name.replace("\"","\\\""); - kylin_network_set_automethod(name.toUtf8().data()); - } else { - QString dnss = ui->leDns->text(); - if (ui->leDns2->text() != "") { - dnss.append(","); - dnss.append(ui->leDns2->text()); - } - QString name = ui->leName->text(); - name.replace("\"","\\\""); - kylin_network_set_manualall(name.toUtf8().data(), ui->leAddr->text().toUtf8().data(), mask.toUtf8().data(), ui->leGateway->text().toUtf8().data(), dnss.toUtf8().data()); - } - - KylinDBus kylindbus; - - this->hide(); - - QString txt(tr("New network settings already finished")); - kylindbus.showDesktopNotify(txt); - - if (!this->isCreateNewNet) { - if (this->isActConf == true) { - // 如果是修改当前连接的网络,则修改设置后简略重连网络 - //QString cmd = "/usr/share/kylin-nm/shell/connup.sh '" + ui->leName->text() + "'"; - kylindbus.connectWiredNet(ui->leName->text()); //reconnect this wired network - - QString m_txt(tr("New settings already effective")); - kylindbus.showDesktopNotify(m_txt); //show desktop notify - } - - //需要更新一下有线网界面 - qDebug()<<"debug: request refresh Lan list"; - emit requestRefreshLanList(0); - } - this->isCreateNewNet = false; -} - -//点击取消按钮 -void ConfForm::on_btnCancel_clicked() -{ - this->hide(); -} - -//根据需要设置的种类(自动或手动等)显示界面内容 -void ConfForm::cbTypeChanged(int index) -{ - if (isShowSaveBtn) { - ui->leName->setEnabled(false); - ui->btnOk->show(); //显示保存按钮 - ui->btnCreate->hide(); //隐藏创建按钮 - ui->lbLeftupTitle->setText(tr("Edit Network")); - } - - if (index == 0) { - ui->lineUp->hide(); - ui->lineDown->hide(); - ui->wgManual->hide(); - ui->centralWidget->resize(446+194*isTabletStyle, 443); - ui->wdBottom->move(0, 347); - - this->setEnableOfBtn(); - - this->resize(446+194*isTabletStyle,443); - } - if (index == 1) { - ui->lineUp->show(); - ui->lineDown->show(); - ui->wgManual->show(); - ui->centralWidget->resize(446+194*isTabletStyle, 576); - ui->wdBottom->move(0, 480); - - this->setEnableOfBtn(); - - this->resize(446+194*isTabletStyle, 576); - } - if (index == 3) { - ui->isDHCP->setChecked(true); - ui->notDHCP->setChecked(false); - ui->btnOk->setStyleSheet(btnOffQss); - ui->btnOk->setEnabled(false); - ui->btnCreate->setStyleSheet(btnOffQss); - ui->btnCreate->setEnabled(false); - - ui->leName->setEnabled(true); - ui->btnOk->hide(); - ui->btnCreate->show(); - ui->lbLeftupTitle->setText(tr("Add Wired Network")); - isShowSaveBtn = false; - - ui->lineUp->hide(); - ui->lineDown->hide(); - ui->wgManual->hide(); - ui->centralWidget->resize(446+194*isTabletStyle, 443); - ui->wdBottom->move(0, 347); - this->resize(446+194*isTabletStyle, 443); - } -} - -//编辑网络名称 -void ConfForm::on_leName_textEdited(const QString &arg1) -{ - this->setEnableOfBtn(); -} - -//编辑网络ip -void ConfForm::on_leAddr_textEdited(const QString &arg1) -{ - this->setEnableOfBtn(); -} - -//编辑网络网关 -void ConfForm::on_leGateway_textEdited(const QString &arg1) -{ - this->setEnableOfBtn(); -} - -//编辑网络DNS -void ConfForm::on_leDns_textEdited(const QString &arg1) -{ - this->setEnableOfBtn(); -} - -//编辑网络备用DNS -void ConfForm::on_leDns2_textEdited(const QString &arg1) -{ - // this->setEnableOfBtn(); -} - -//设置界面按钮是否可点击 -void ConfForm::setEnableOfBtn() -{ - if (ui->leName->text().size() == 0 ) { - this->setBtnEnableFalse(); - return; - } - - if (ui->cbType->currentIndex() == 1) { - if (!this->getTextEditState(ui->leAddr->text()) ) { - this->setBtnEnableFalse(); - return; - } - - if (!this->getTextEditState(ui->leGateway->text()) ) { - this->setBtnEnableFalse(); - return; - } - - if (!this->getTextEditState(ui->leDns->text()) ) { - this->setBtnEnableFalse(); - return; - } - } - - ui->btnOk->setStyleSheet(btnOnQss); - ui->btnOk->setEnabled(true); - - ui->btnCreate->setStyleSheet(btnOnQss); - ui->btnCreate->setEnabled(true); -} - -//文本的输入要符合ip的格式要求 -bool ConfForm::getTextEditState(QString text) -{ - QRegExp rx("\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b"); - - bool match = false; - match = rx.exactMatch(text); - // qDebug()<<"the match result is: " << match; - - return match; -} - -//设置创建或保存按钮不可点击 -void ConfForm::setBtnEnableFalse() -{ - ui->btnOk->setStyleSheet(btnOffQss); - ui->btnOk->setEnabled(false); - - ui->btnCreate->setStyleSheet(btnOffQss); - ui->btnCreate->setEnabled(false); -} - -void ConfForm::paintEvent(QPaintEvent *event) -{ - QStyleOption opt; - opt.init(this); - QPainter p(this); - style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); - QWidget::paintEvent(event); -} - -void ConfForm::on_isDHCP_clicked() -{ - ui->isDHCP->setEnabled(false); - ui->notDHCP->setEnabled(true); - ui->notDHCP->setChecked(false); - ui->cbType->setCurrentIndex(0); - cbTypeChanged(0); -} - -void ConfForm::on_notDHCP_clicked() -{ - ui->notDHCP->setEnabled(false); - ui->isDHCP->setEnabled(true); - ui->isDHCP->setChecked(false); - ui->cbType->setCurrentIndex(1); - cbTypeChanged(1); -} diff --git a/KylinNM/src/confform.h b/KylinNM/src/confform.h deleted file mode 100644 index 73999d4..0000000 --- a/KylinNM/src/confform.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see -#include -#include -#include -#include -#include -#include - -namespace Ui { -class ConfForm; -} -class KylinNM; - -class ConfForm : public QWidget -{ - Q_OBJECT - -public: - explicit ConfForm(QWidget *parent = 0); - ~ConfForm(); - - void setProp(QString connName, QString v4method, QString addr, QString mask, QString gateway, QString dns, bool isActConf ); - void setMainWindow(KylinNM *mainwindow); - -public Q_SLOTS: - void tabletStyle(bool isTablet);//YYF 平板桌面模式特有设置 - void cbTypeChanged(int index); - -protected: - void paintEvent(QPaintEvent *event); - bool eventFilter(QObject *obj, QEvent *ev) override; - -private Q_SLOTS: - void on_btnOk_clicked(); - void on_btnCancel_clicked(); - - void on_btnCreate_clicked(); - - void on_leName_textEdited(const QString &arg1); - - void on_leAddr_textEdited(const QString &arg1); - - void on_leGateway_textEdited(const QString &arg1); - - void on_leDns_textEdited(const QString &arg1); - - void on_leDns2_textEdited(const QString &arg1); - - void setEnableOfBtn(); - bool getTextEditState(QString text); - void setBtnEnableFalse(); - - void on_isDHCP_clicked(); - - void on_notDHCP_clicked(); - -private: - Ui::ConfForm *ui; - - void mousePressEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - - bool isPress; - QPoint winPos; - QPoint dragPos; - bool isActConf; //是否对已经连接的网络进行的更改 - bool isCreateNewNet = false; //是否是创建的新网络 - bool isShowSaveBtn = true; //是否显示保存按钮,即是否是编辑网络界面 - - bool isTabletStyle=false;//YYF 平板桌面模式特有设置 - - QString labelQss, cbxQss, leQss, lineQss, btnOnQss, btnOffQss; - - KylinNM *mw = nullptr; - -Q_SIGNALS: - void requestRefreshLanList(int updateType); -}; - -#endif // CONFFORM_H diff --git a/KylinNM/src/confform.ui b/KylinNM/src/confform.ui deleted file mode 100644 index 08ff5b4..0000000 --- a/KylinNM/src/confform.ui +++ /dev/null @@ -1,434 +0,0 @@ - - - ConfForm - - - - 0 - 0 - 446 - 576 - - - - - - - - - 0 - 0 - 446 - 581 - - - - - - 0 - 200 - 446 - 280 - - - - - - 175 - 15 - 250 - 32 - - - - - 10 - - - - - - - 175 - 60 - 250 - 32 - - - - - 10 - - - - - - - 175 - 105 - 250 - 32 - - - - - 10 - - - - - - - 175 - 150 - 250 - 32 - - - - - 10 - - - - - - - 20 - 20 - 80 - 20 - - - - - Noto Sans CJK SC - 11 - - - - - - - - - - 20 - 65 - 80 - 20 - - - - - Noto Sans CJK SC - 11 - - - - - - - - - - 20 - 110 - 80 - 20 - - - - - Noto Sans CJK SC - 11 - - - - - - - - - - 20 - 155 - 80 - 20 - - - - - Noto Sans CJK SC - 11 - - - - - - - - - - 175 - 195 - 250 - 32 - - - - - 10 - - - - - - - 20 - 200 - 80 - 20 - - - - - Noto Sans CJK SC - 11 - - - - - - - - - - - 0 - 0 - 446 - 200 - - - - - - 170 - 60 - 182 - 32 - - - - - 10 - - - - - - - 20 - 135 - 80 - 20 - - - - - Noto Sans CJK SC - 11 - - - - - - - - - - 20 - 90 - 80 - 20 - - - - - Noto Sans CJK SC - 11 - - - - - - - - - - 135 - 75 - 290 - 48 - - - - - 10 - - - - - - - 0 - 0 - 446 - 48 - - - - - - 408 - 8 - 24 - 24 - - - - - - - - - - 24 - 10 - 240 - 22 - - - - - - - - - - - 180 - 130 - 111 - 28 - - - - - - - - - - 356 - 130 - 50 - 28 - - - - - - - - - - - 0 - 480 - 446 - 96 - - - - - - 312 - 25 - 112 - 48 - - - - - 10 - - - - - - - - - - 180 - 25 - 112 - 48 - - - - - 10 - - - - - - - - - - 312 - 25 - 112 - 48 - - - - - - - - - - - 10 - 200 - 426 - 1 - - - - Qt::Horizontal - - - - - - 10 - 480 - 426 - 1 - - - - Qt::Horizontal - - - - - - - diff --git a/KylinNM/src/ksimplenm.cpp b/KylinNM/src/ksimplenm.cpp deleted file mode 100644 index d5be6e3..0000000 --- a/KylinNM/src/ksimplenm.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see -#include -#include - -#define MAX_LEN 2048 -#define MAX_PATH 1024 - -KSimpleNM::KSimpleNM(QObject *parent) : QObject(parent) -{ - runShellProcess = new QProcess(this); - - connect(runShellProcess, &QProcess::readyRead, this, &KSimpleNM::readProcess); - connect(runShellProcess, SIGNAL(finished(int)), this, SLOT(finishedProcess(int))); -} - -//获取有线网络列表数据 -void KSimpleNM::execGetLanList() -{ - if (isExecutingGetWifiList) { - syslog(LOG_DEBUG, "It is running getting wifi list when getting lan list"); - qDebug()<<"debug: it is running getting wifi list when getting lan list"; - isUseOldLanSlist = true; - } - isExecutingGetLanList = true; - shellOutput = ""; - type = 0; - qDebug() << "runShellProcess->start ---1"; - runShellProcess->start("nmcli -f type,device,name connection show"); - qDebug() << "runShellProcess->start ---2"; -} - -//获取无线网络列表数据 -void KSimpleNM::execGetWifiList() -{ - isExecutingGetWifiList = true; - shellOutput = ""; - type = 1; - runShellProcess->start("nmcli -f in-use,signal,security,freq,bssid,ssid,dbus-path device wifi"); -} - -//读取获取到的结果 -void KSimpleNM::readProcess() -{ - QString output = runShellProcess->readAll(); - shellOutput += output; -} - -//读取完所有列表数据后发信号,将数据发往mainwindow用于显示网络列表 -void KSimpleNM::finishedProcess(int msg) -{ - QStringList slist = shellOutput.split("\n"); - if (type == 0) { - emit getLanListFinished(slist); - isExecutingGetLanList = false; - } else { - emit getWifiListFinished(slist); - isExecutingGetWifiList = false; - } -} diff --git a/KylinNM/src/ksimplenm.h b/KylinNM/src/ksimplenm.h deleted file mode 100644 index fd1a427..0000000 --- a/KylinNM/src/ksimplenm.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see - -#include -#include -#include - -class KSimpleNM : public QObject -{ - Q_OBJECT -public: - explicit KSimpleNM(QObject *parent = nullptr); - - QProcess *runShellProcess = nullptr; - QString shellOutput; - int type; - bool isExecutingGetLanList = false; //是否正在执行获取有线网列表 - bool isExecutingGetWifiList = false; //是否正在执行获取无线网列表 - bool isUseOldLanSlist = false; //是否应该要用上一次获取的有线列表 - - void execGetLanList(); - void execGetWifiList(); - -Q_SIGNALS: - void getLanListFinished(QStringList slist); - void getWifiListFinished(QStringList slist); - -public Q_SLOTS: - void readProcess(); - void finishedProcess(int msg); -}; - -#endif // KSIMPLENM_H diff --git a/KylinNM/src/kylin-dbus-interface.cpp b/KylinNM/src/kylin-dbus-interface.cpp deleted file mode 100644 index ddaba02..0000000 --- a/KylinNM/src/kylin-dbus-interface.cpp +++ /dev/null @@ -1,1105 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see - -#include -#include - - -namespace { - -void quitThread(QThread *thread) -{ - Q_ASSERT(thread); - if (thread) { - thread->quit(); - if (!thread->wait(2000)) { - thread->terminate(); - thread->wait(); - } - } -} - -} // namespace - -KylinDBus::KylinDBus(KylinNM *mainWindow, QObject *parent) :QObject(parent) -{ - this->mw = mainWindow; - - getObjectPath(); //获取dbus中 lan 与 WiFi 的device路径 - getPhysicalCarrierState(0); //初始化获取网线插入状态 - getLanHwAddressState(); //获取有线网Mac地址 - getWiredCardName(); //获取有线网卡名称 - //initTaskbarGsetting(); //初始化taskbar的GSetting方法 - getWifiSwitchState(); //初始化wifi开关GSetting通信方法 - initTransparentState(); //初始化窗口透明度的GSetting方法 - - QDBusConnection::systemBus().connect(QString("org.freedesktop.NetworkManager"), - QString("/org/freedesktop/NetworkManager"), - QString("org.freedesktop.NetworkManager"), - QString("PropertiesChanged"), this, SLOT(onPropertiesChanged(QVariantMap) ) ); - - QDBusConnection::systemBus().connect(QString("org.freedesktop.NetworkManager"), - QString("/org/freedesktop/NetworkManager"), - QString("org.freedesktop.NetworkManager"), - QString("DeviceAdded"), mw, SLOT(onNetworkDeviceAdded(QDBusObjectPath) ) ); - - QDBusConnection::systemBus().connect(QString("org.freedesktop.NetworkManager"), - QString("/org/freedesktop/NetworkManager"), - QString("org.freedesktop.NetworkManager"), - QString("DeviceRemoved"), mw, SLOT(onNetworkDeviceRemoved(QDBusObjectPath) ) ); - - QDBusConnection::systemBus().connect(QString("org.freedesktop.NetworkManager"), - QString("/org/freedesktop/NetworkManager/Settings"), - QString("org.freedesktop.NetworkManager.Settings"), - QString("NewConnection"), this, SLOT(onNewConnection(QDBusObjectPath) ) ); - - QDBusConnection::systemBus().connect(QString("org.freedesktop.NetworkManager"), - QString("/org/freedesktop/NetworkManager/Settings"), - QString("org.freedesktop.NetworkManager.Settings"), - QString("ConnectionRemoved"), this, SLOT(onConnectionRemoved(QDBusObjectPath) ) ); - - if (wiredPath.path() != "") { - QDBusConnection::systemBus().connect(QString("org.freedesktop.NetworkManager"), - QString(wiredPath.path()), - QString("org.freedesktop.NetworkManager.Device.Wired"), - QString("PropertiesChanged"), this, SLOT(onLanPropertyChanged(QVariantMap) ) ); - } else { - qDebug()<<"Can not find wired device object path when using dbus."; - } - - if (wirelessPath.path() != "") { - QDBusConnection::systemBus().connect(QString("org.freedesktop.NetworkManager"), - QString(wirelessPath.path()), - QString("org.freedesktop.NetworkManager.Device.Wireless"), - QString("PropertiesChanged"), this, SLOT(onWifiPropertyChanged(QVariantMap) ) ); - - QDBusConnection::systemBus().connect(QString("org.freedesktop.NetworkManager"), - QString(wirelessPath.path()), - QString("org.freedesktop.NetworkManager.Device.Wireless"), - QString("AccessPointAdded"), this, SLOT(onAccessPointAdded(QDBusObjectPath) ) ); - getWirelessCardName();//获取无线网卡名称 - } else { - qDebug()<<"Can not find wireless device object path when using dbus."; - } - - time = new QTimer(this); - time->setTimerType(Qt::PreciseTimer); - QObject::connect(time, SIGNAL(timeout()), this, SLOT(slot_timeout())); - - QObject::connect(this, SIGNAL(updateWiredList(int)), mw, SLOT(onBtnNetListClicked(int))); - - mUtils = new Utils(); - mUtilsThread = new QThread(this); - mUtils->moveToThread(mUtilsThread); - connect(mUtilsThread, &QThread::finished, mUtils, &Utils::deleteLater); - connect(this, SIGNAL(requestSendDesktopNotify(QString)), mUtils, SLOT(onRequestSendDesktopNotify(QString)), Qt::QueuedConnection); - QTimer::singleShot(1, this, [=] { - mUtilsThread->start(); - }); -} - -KylinDBus::~KylinDBus() -{ - quitThread(mUtilsThread); -} - - -/////////////////////////////////////////////////////////////////////////////// -//下方使用Dbus 进程通信方法 - -//获取dbus中 lan 与 WiFi 的device路径 -void KylinDBus::getObjectPath() -{ - foreach (QDBusObjectPath mPath, multiWiredPaths) { - multiWiredPaths.removeOne(mPath); - } - - QDBusInterface m_interface( "org.freedesktop.NetworkManager", - "/org/freedesktop/NetworkManager", - "org.freedesktop.NetworkManager", - QDBusConnection::systemBus() ); - - //先获取所有的网络设备的设备路径 - QDBusReply> obj_reply = m_interface.call("GetAllDevices"); - if (!obj_reply.isValid()) { - qDebug()<<"execute dbus method 'GetAllDevices' is invalid in func getObjectPath()"; - } - - QList obj_paths = obj_reply.value(); - - //再判断有无有线设备和无线设备的路径 - foreach (QDBusObjectPath obj_path, obj_paths) { - QDBusInterface interface( "org.freedesktop.NetworkManager", - obj_path.path(), - "org.freedesktop.DBus.Introspectable", - QDBusConnection::systemBus() ); - - QDBusReply reply = interface.call("Introspect"); - if (!reply.isValid()) { - qDebug()<<"execute dbus method 'Introspect' is invalid in func getObjectPath()"; - } - - if(reply.value().indexOf("org.freedesktop.NetworkManager.Device.Wired") != -1) { - //表明有有线网设备 - wiredPath = obj_path; - multiWiredPaths.append(obj_path); - } else if (reply.value().indexOf("org.freedesktop.NetworkManager.Device.Wireless") != -1) { - //表明有wifi设备 - wirelessPath = obj_path; - isWirelessCardOn = true; - } - } -} - -//获取是否连接有线网网线 -void KylinDBus::getPhysicalCarrierState(int n) -{ - multiWiredCableState.clear(); - - foreach (QDBusObjectPath localPath, multiWiredPaths) { - QDBusInterface interface( "org.freedesktop.NetworkManager", - localPath.path(), - "org.freedesktop.DBus.Properties", - QDBusConnection::systemBus() ); - - //Carrier值为true,插了网线;为false,未插网线 - QDBusReply reply = interface.call("Get", "org.freedesktop.NetworkManager.Device.Wired", "Carrier"); - - try { - if (reply.value().toString() == "true") { - //isWiredCableOn = true; - QDBusReply managed = interface.call("Get", "org.freedesktop.NetworkManager.Device", "Managed"); - //针对intel特殊环境的二次判断,当设备未托管时,即时carrier为true,仍认为有线设备未连接 - if (managed.value().toString() == "true") { - //isWiredCableOn = true; - multiWiredCableState.append("true"); - } else { - multiWiredCableState.append("false"); - } - } else if (reply.value().toString() == "false") { - //isWiredCableOn = false; - multiWiredCableState.append("false"); - //if (n == 1){ this->mw->onPhysicalCarrierChanged(isWiredCableOn);} - } else { - throw -1; //出现异常 - } - } catch(...) { - syslog(LOG_ERR, "Error occurred when get the property 'Carrier' of Wired"); - qDebug()<<"Error occurred when get the property 'Carrier' of Wired"; - } - } - - isWiredCableOn = false; - foreach (QString state, multiWiredCableState) { - if (state == "true") { - isWiredCableOn = true; - } - } - - if (n == 1) { this->mw->onPhysicalCarrierChanged(isWiredCableOn);} -} - -//获取有线网Mac地址 -void KylinDBus::getLanHwAddressState() -{ - QDBusInterface lanInterface( "org.freedesktop.NetworkManager", - wiredPath.path(), - "org.freedesktop.DBus.Properties", - QDBusConnection::systemBus() ); - - QDBusReply lanReply = lanInterface.call("Get", "org.freedesktop.NetworkManager.Device.Wired", "HwAddress"); - if (!lanReply.isValid()) { - qDebug()<<"can not get the attribute 'HwAddress' in func getLanHwAddressState()"; - } else { - dbusLanMac = lanReply.value().toString(); - } -} - -//获取有线网卡名称 -void KylinDBus::getWiredCardName() -{ - if (wiredPath.path() == "") { - dbusLanCardName = ""; - } else { - QDBusInterface lanInterface( "org.freedesktop.NetworkManager", - wiredPath.path(), - "org.freedesktop.DBus.Properties", - QDBusConnection::systemBus() ); - - QDBusReply lanReply = lanInterface.call("Get", "org.freedesktop.NetworkManager.Device", "Interface"); - if (!lanReply.isValid()) { - qDebug()<<"can not get the attribute 'Interface' in func getWiredCardName()"; - dbusLanCardName = ""; - } else { - dbusLanCardName = lanReply.value().toString(); - } - } -} - -//获取无线网卡名称 -void KylinDBus::getWirelessCardName() -{ - QDBusInterface lanInterface( "org.freedesktop.NetworkManager", - wirelessPath.path(), - "org.freedesktop.DBus.Properties", - QDBusConnection::systemBus() ); - - QDBusReply lanReply = lanInterface.call("Get", "org.freedesktop.NetworkManager.Device", "Interface"); - if (!lanReply.isValid()) { - qDebug()<<"can not get the attribute 'Interface' in func getWirelessCardName()"; - } else { - dbusWiFiCardName = lanReply.value().toString(); - } -} - -//获取没有连接的有线网ip -void KylinDBus::getLanIp(QString netName) -{ - QDBusInterface m_interface("org.freedesktop.NetworkManager", - "/org/freedesktop/NetworkManager/Settings", - "org.freedesktop.NetworkManager.Settings", - QDBusConnection::systemBus() ); - QDBusReply> m_reply = m_interface.call("ListConnections"); - - QList m_objNets = m_reply.value(); - foreach (QDBusObjectPath objNet, m_objNets) { - QDBusInterface m_interface("org.freedesktop.NetworkManager", - objNet.path(), - "org.freedesktop.NetworkManager.Settings.Connection", - QDBusConnection::systemBus()); - QDBusMessage result = m_interface.call("GetSettings"); //get information of this network - - const QDBusArgument &dbusArg1st = result.arguments().at( 0 ).value(); - //DBus type : a{sa{sv}}, a map with a key of QString, which maps to another map of QString,QVariant - QMap> map; - dbusArg1st >> map; - - for (QString outside_key : map.keys() ) { - QMap outsideMap = map.value(outside_key); - if (outside_key == "connection") { - for (QString search_key : outsideMap.keys()) { - if (search_key == "id") { - //const QDBusArgument &dbusArg2nd = innerMap.value(inner_key).value(); - if (netName == outsideMap.value(search_key).toString()) { - // qDebug()<<"aaaaaa"< innerMap = map.value(key); - //qDebug() << "Key: " << key; - if (key == "ipv4") { - for (QString inner_key : innerMap.keys()) { - if (inner_key == "address-data") { - const QDBusArgument &dbusArg2nd = innerMap.value(inner_key).value(); - QMap m_map; - - dbusArg2nd.beginArray(); - while (!dbusArg2nd.atEnd()) { - dbusArg2nd >> m_map;// append map to a vector here if you want to keep it - } - dbusArg2nd.endArray(); - - //qDebug()<<" " << m_map.value("address").toString(); - dbusLanIpv4 = m_map.value("address").toString(); - } - } - } - - if (key == "ipv6") { - for (QString inner_key : innerMap.keys()) { - if (inner_key == "address-data"){ - const QDBusArgument &dbusArg2nd = innerMap.value(inner_key).value(); - QMap m_map; - - dbusArg2nd.beginArray(); - while (!dbusArg2nd.atEnd()) { - dbusArg2nd >> m_map;// append map to a vector here if you want to keep it - } - dbusArg2nd.endArray(); - - //qDebug()<<" " << m_map.value("address").toString(); - dbusLanIpv6 = m_map.value("address").toString(); - } - } - } - } //end for(QString key : map.keys() ) - - } - } - } //end for (QString search_key : outsideMap.keys()) - } - } // end for(QString outside_key : map.keys() ) - - } //end foreach (QDBusObjectPath objNet, m_objNets) -} - -//获取已经连接的有线网ip -void KylinDBus::getConnectNetIp() -{ - QDBusInterface interface( "org.freedesktop.NetworkManager", - "/org/freedesktop/NetworkManager", - "org.freedesktop.DBus.Properties", - QDBusConnection::systemBus() ); - - //获取已经连接了那些网络,及这些网络对应的网络类型(ethernet or wifi) - QDBusMessage result = interface.call("Get", "org.freedesktop.NetworkManager", "ActiveConnections"); - QList outArgs = result.arguments(); - QVariant first = outArgs.at(0); - QDBusVariant dbvFirst = first.value(); - QVariant vFirst = dbvFirst.variant(); - QDBusArgument dbusArgs = vFirst.value(); - - QDBusObjectPath objPath; - dbusArgs.beginArray(); - while (!dbusArgs.atEnd()) { - dbusArgs >> objPath; - - QDBusInterface interfacePro( "org.freedesktop.NetworkManager", - objPath.path(), - "org.freedesktop.DBus.Properties", - QDBusConnection::systemBus() ); - - QDBusReply reply = interfacePro.call("Get", "org.freedesktop.NetworkManager.Connection.Active", "Type"); - if (reply.value().toString() == "ethernet" || reply.value().toString() == "802-3-ethernet") { - //ipv4的路径信息和ip信息 - QDBusInterface interfaceIp4( "org.freedesktop.NetworkManager", - objPath.path(), - "org.freedesktop.DBus.Properties", - QDBusConnection::systemBus() ); - QDBusMessage replyIp4 = interfaceIp4.call("Get", "org.freedesktop.NetworkManager.Connection.Active", "Ip4Config"); - QList outArgsIp4 = replyIp4.arguments(); - QVariant firstIp4 = outArgsIp4.at(0); - QDBusVariant dbvFirstIp4 = firstIp4.value(); - QVariant vFirstIp4 = dbvFirstIp4.variant(); - QDBusObjectPath dbusPathIp4 = vFirstIp4.value(); - - QDBusInterface interfaceIpv4( "org.freedesktop.NetworkManager", - dbusPathIp4.path(), - "org.freedesktop.DBus.Properties", - QDBusConnection::systemBus() ); - QDBusMessage replyIpv4 = interfaceIpv4.call("Get", "org.freedesktop.NetworkManager.IP4Config", "AddressData"); - - QList outArgsIpv4 = replyIpv4.arguments(); - if(outArgsIp4.count() >= 0){ - QVariant firstIpv4 = outArgsIpv4.at(0); - QDBusVariant dbvFirstIpv4 = firstIpv4.value(); - QVariant vFirstIpv4 = dbvFirstIpv4.variant(); - - const QDBusArgument &dbusArgIpv4 = vFirstIpv4.value(); - QList mDatasIpv4; - dbusArgIpv4 >> mDatasIpv4; - - foreach (QVariantMap mDataIpv4, mDatasIpv4) { - dbusActiveLanIpv4 = mDataIpv4.value("address").toString(); - } - } - //ipv6的路径信息和ip信息 - QDBusInterface interfaceIp6( "org.freedesktop.NetworkManager", - objPath.path(), - "org.freedesktop.DBus.Properties", - QDBusConnection::systemBus() ); - QDBusMessage replyIp6 = interfaceIp6.call("Get", "org.freedesktop.NetworkManager.Connection.Active", "Ip6Config"); - QList outArgsIp6 = replyIp6.arguments(); - QVariant firstIp6 = outArgsIp6.at(0); - QDBusVariant dbvFirstIp6 = firstIp6.value(); - QVariant vFirstIp6 = dbvFirstIp6.variant(); - QDBusObjectPath dbusPathIp6 = vFirstIp6.value(); - - QDBusInterface interfaceIpv6( "org.freedesktop.NetworkManager", - dbusPathIp6.path(), - "org.freedesktop.DBus.Properties", - QDBusConnection::systemBus() ); - QDBusMessage replyIpv6 = interfaceIpv6.call("Get", "org.freedesktop.NetworkManager.IP6Config", "AddressData"); - - QList outArgsIpv6 = replyIpv6.arguments(); - if(outArgsIp6.count() >= 0){ - QVariant firstIpv6 = outArgsIpv6.at(0); - QDBusVariant dbvFirstIpv6 = firstIpv6.value(); - QVariant vFirstIpv6 = dbvFirstIpv6.variant(); - - const QDBusArgument &dbusArgIpv6 = vFirstIpv6.value(); - QList mDatasIpv6; - dbusArgIpv6 >> mDatasIpv6; - - foreach (QVariantMap mDataIpv6, mDatasIpv6) { - dbusActiveLanIpv6 = mDataIpv6.value("address").toString(); - } - } - } - } - dbusArgs.endArray(); -} - -//获取wifi的mac地址 -void KylinDBus::getWifiMac(QString netName) -{ - dbusWifiMac = ""; - - QDBusInterface interface( "org.freedesktop.NetworkManager", - wirelessPath.path(), - "org.freedesktop.NetworkManager.Device.Wireless", - QDBusConnection::systemBus() ); - - QDBusReply> reply = interface.call("GetAllAccessPoints"); //get accesspoint for each wifi - QList objPaths = reply.value(); - - foreach (QDBusObjectPath objPath, objPaths) { - QDBusInterface ssid_interface( "org.freedesktop.NetworkManager", - objPath.path(), - "org.freedesktop.DBus.Properties", - QDBusConnection::systemBus() ); - - QDBusReply ssid_replys = ssid_interface.call("Get", "org.freedesktop.NetworkManager.AccessPoint", "Ssid"); - QString str_name = ssid_replys.value().toString(); - - if (str_name == netName) { - //if the ssid of the accesspoint is just the netName, we can get this hardware address - QDBusInterface path_interface( "org.freedesktop.NetworkManager", - objPath.path(), - "org.freedesktop.DBus.Properties", - QDBusConnection::systemBus() ); - - QDBusReply path_reply = path_interface.call("Get", "org.freedesktop.NetworkManager.AccessPoint", "HwAddress"); - dbusWifiMac = path_reply.value().toString(); - } - } -} - -//获取当前能获取到的wifi的数量, 每个accesspoint 代表一个wifi -int KylinDBus::getAccessPointsNumber() -{ - QDBusInterface interface( "org.freedesktop.NetworkManager", - wirelessPath.path(), - "org.freedesktop.NetworkManager.Device.Wireless", - QDBusConnection::systemBus() ); - - QDBusReply> reply = interface.call("GetAllAccessPoints"); - QList objPaths = reply.value(); - - return objPaths.size(); -} - -//新增了一个网络,伴随着多了一个网络配置文件 -void KylinDBus::onNewConnection(QDBusObjectPath objPath) -{ - QDBusInterface m_interface("org.freedesktop.NetworkManager", - objPath.path(), - "org.freedesktop.NetworkManager.Settings.Connection", - QDBusConnection::systemBus()); - QDBusMessage result = m_interface.call("GetSettings"); - - const QDBusArgument &dbusArg1st = result.arguments().at( 0 ).value(); - QMap> map; - dbusArg1st >> map; - - for(QString key : map.keys() ) { - if (key == "802-3-ethernet") { - emit this->updateWiredList(0); //send this signal to update wired network list - syslog(LOG_DEBUG, "A new wired network was created."); - qDebug()<<"A new wired network was created."; - } - } -} - -//减少了一个网络,伴随着减少了一个网络配置文件 -void KylinDBus::onConnectionRemoved(QDBusObjectPath objPath) -{ - syslog(LOG_DEBUG, "An old network was removed from configure directory."); - qDebug()<<"An old network was removed from configure directory."; - - if (mw->is_btnNetList_clicked == 1) { - emit this->updateWiredList(0); //send this signal to update wired network list - } -} - -//应用启动时,获取已经连接的网络信息,包括该网络的路径和类型 -void KylinDBus::initConnectionInfo() -{ - QDBusInterface interface( "org.freedesktop.NetworkManager", - "/org/freedesktop/NetworkManager", - "org.freedesktop.DBus.Properties", - QDBusConnection::systemBus() ); - - //获取已经连接了那些网络,及这些网络对应的网络类型(ethernet or wifi) - QDBusMessage result = interface.call("Get", "org.freedesktop.NetworkManager", "ActiveConnections"); - QList outArgs = result.arguments(); - QVariant first = outArgs.at(0); - QDBusVariant dbvFirst = first.value(); - QVariant vFirst = dbvFirst.variant(); - QDBusArgument dbusArgs = vFirst.value(); - - QDBusObjectPath objPath; - // qDebug()<<" "; - dbusArgs.beginArray(); - while (!dbusArgs.atEnd()) { - dbusArgs >> objPath; - oldPaths.append(objPath); - // qDebug() <<"debug: *****path is: "<< objPath.path(); - - QDBusInterface interface( "org.freedesktop.NetworkManager", - objPath.path(), - "org.freedesktop.DBus.Properties", - QDBusConnection::systemBus() ); - - QDBusReply reply = interface.call("Get", "org.freedesktop.NetworkManager.Connection.Active", "Type"); - // qDebug()<<"debug: *****connection type is: "< m_result = interface.call("Get", "org.freedesktop.NetworkManager", "WirelessEnabled"); - qDebug()<<"debug: *****初始的无线网络开关状态是: "<(); - QList newPaths; - dbusArg >> newPaths; - QStringList newPathInfo; - qDebug()<<" "; - foreach (QDBusObjectPath objPath, newPaths) { - qDebug()<<"dbug: bbbbb "< reply = interface.call("Get", "org.freedesktop.NetworkManager.Connection.Active", "Type"); - qDebug()<<"dbug: ccccc "<onExternalConnectionChange(oldPathInfo.at(i)); - } else { - for (int j=0; jonExternalConnectionChange(oldPathInfo.at(i)); - } - } - } - } - } - - // 第三步 同上一次获取的已连接网络相比较,处理相比于上次增加的网络连接 - for (int i=0; ionExternalConnectionChange(newPathInfo.at(i)); - } else { - for (int j=0; jonExternalConnectionChange(newPathInfo.at(i)); - } - } - } - } - - bool isChangeOldPathInfo = true; - for (int k=0; konExternalWifiSwitchChange(true); - setBtnWifiGsetting(true); - } - if (oldWifiSwitchState == true && newWifiSwitchState == false) { - qDebug()<<"debug: wifi开关已经关闭"; - is_wificonnected = false; - mw->onExternalWifiSwitchChange(false); - setBtnWifiGsetting(false); - } - - oldWifiSwitchState = newWifiSwitchState; //更新状态用于下一次 - } - } -} - -//有线网属性变化时,执行该函数。由于可能在短时间收到几条相同属性变化信息,所以在短时间内,执行一次 -void KylinDBus::onLanPropertyChanged(QVariantMap qvm) -{ - if (!isRunningFunction) { - syslog(LOG_DEBUG, "kylin-nm receive a signal 'Device.Wired PropertiesChanged' about interface."); - qDebug()<<"kylin-nm receive a signal 'Device.Wired PropertiesChanged' about interface."; - isRunningFunction = true; //function onLanPropertyChanged is running - time->start(3000); - - QString str = qvm.value("Carrier").toString(); - if (str == "false" || str == "true") { - getPhysicalCarrierState(1); - } - } else { a = 0; } -} -void KylinDBus::slot_timeout() -{ - isRunningFunction = false; - time->stop(); -} - -//无线网属性变化时,执行该函数 -void KylinDBus::onWifiPropertyChanged(QVariantMap qvm) -{ - //qDebug()<<"debug: *************"<> m_reply = m_interface.call("ListConnections"); - - QDBusObjectPath active_connection; - active_connection.setPath("/"); - - QList m_objNets = m_reply.value(); - foreach (QDBusObjectPath objNet, m_objNets) { - QDBusInterface m_interface("org.freedesktop.NetworkManager", - objNet.path(), - "org.freedesktop.NetworkManager.Settings.Connection", - QDBusConnection::systemBus()); - QDBusMessage result = m_interface.call("GetSettings"); - - const QDBusArgument &dbusArg1st = result.arguments().at( 0 ).value(); - QMap> map; - dbusArg1st >> map; - - for (QString outside_key : map.keys() ) { - QMap outsideMap = map.value(outside_key); - if (outside_key == "connection") { - for (QString search_key : outsideMap.keys()) { - if (search_key == "id") { - if (netName == outsideMap.value(search_key).toString()) { - - QDBusInterface m_interface("org.freedesktop.NetworkManager", - "/org/freedesktop/NetworkManager", - "org.freedesktop.NetworkManager", - QDBusConnection::systemBus() ); - QDBusReply connectionReply = m_interface.call("ActivateConnection", - QVariant::fromValue(objNet), - QVariant::fromValue(wiredPath), - QVariant::fromValue(active_connection)); - } - } - } - } - } // end for(QString outside_key : map.keys() ) - - } //end foreach (QDBusObjectPath objNet, m_objNets) -} - -//显示桌面通知 -void KylinDBus::showDesktopNotify(QString message) -{ - //锁屏不发送该通知 -// emit requestSendDesktopNotify(message); -} - -//获取任务栏位置,上下左右 -int KylinDBus::getTaskBarPos(QString str) -{ - QDBusInterface interface( "com.ukui.panel.desktop", - "/", - "com.ukui.panel.desktop", - QDBusConnection::sessionBus() ); - - QDBusReply reply = interface.call("GetPanelPosition", str); - if (reply.isValid()) { - return reply; - } else { - return 0; //如果没有成功获取,返回一个默认值 - } -} - -//获取任务栏高度 -int KylinDBus::getTaskBarHeight(QString str) -{ - QDBusInterface interface( "com.ukui.panel.desktop", - "/", - "com.ukui.panel.desktop", - QDBusConnection::sessionBus() ); - - QDBusReply reply = interface.call("GetPanelSize", str); - if (reply.isValid()) { - return reply; - } else { - return 46; //如果没有成功获取,返回一个默认值 - } -} - -/////////////////////////////////////////////////////////////////////////////// -//下方使用Gsetting 进程通信方法 - -//创建获取任务栏信息的GSetting对象 -void KylinDBus::initTaskbarGsetting() -{ - if (QGSettings::isSchemaInstalled("org.ukui.panel.settings")) { - m_tastbar_gsettings = new QGSettings("org.ukui.panel.settings"); - } - if (QGSettings::isSchemaInstalled("org.kylinnm.settings")) { - m_nm_gsettings = new QGSettings("org.kylinnm.settings"); - if (m_nm_gsettings->keys().contains("wifiswitch")) { - m_nm_gsettings->set("wifiswitch",oldWifiSwitchState); - } - } -} - -//使用GSetting方法获取任务栏高度 -int KylinDBus::getTaskbarHeight() -{ - if (!m_tastbar_gsettings) { - return 46; - } - - QStringList keys = m_tastbar_gsettings->keys(); - if (keys.contains("panelsize")) { - int hh = m_tastbar_gsettings->get("panelsize").toInt(); - return hh; - } else { - return 46; - } -} - -//使用GSetting方法写入WIFW信号强度 -void KylinDBus::setWifiSignal(int wifiSignal, QString wifiname) -{ if(!m_tastbar_gsettings || !m_nm_gsettings) - return; - - if (m_tastbar_gsettings->keys().contains("wifisignal")) { - m_tastbar_gsettings->set("wifisignal",wifiSignal); - } - if (m_nm_gsettings->keys().contains("wifisignal")) { - m_nm_gsettings->set("wifisignal",wifiSignal); - } - if (m_nm_gsettings->keys().contains("wifiname")) { - m_nm_gsettings->set("wifiname",wifiname); - } -} -//使用GSetting方法获取任务栏位置,上下左右 -int KylinDBus::getTaskbarPos() -{ - if (!m_tastbar_gsettings) { - return 0; - } - - QStringList keys = m_tastbar_gsettings->keys(); - if (keys.contains("panelposition")) { - int pp = m_tastbar_gsettings->get("panelposition").toInt(); - return pp; - } else { - return 0; - } -} - -//创建监听wifi打开或关闭信息的GSetting对象 -void KylinDBus::getWifiSwitchState() -{ - if (QGSettings::isSchemaInstalled("org.ukui.control-center.wifi.switch")) { - - m_gsettings = new QGSettings("org.ukui.control-center.wifi.switch"); - - // 监听key的value是否发生了变化 - connect(m_gsettings, &QGSettings::changed, this, [=] (const QString &key) { - - if (key == "switch") { - if (isWirelessCardOn) { - bool judge = getSwitchStatus(key); - if (judge) { - mw->onBtnWifiClicked(2); //打开wifi开关 - qDebug()<<"receive a signal to turn on wifi switch from control-center"; - syslog(LOG_DEBUG, "receive a signal to turn on wifi switch from control-center"); - } else { - if (!is_wificonnected) { - return; - } - mw->onBtnWifiClicked(3); //关闭wifi开关 - qDebug()<<"receive a signal to turn off wifi switch from control-center"; - syslog(LOG_DEBUG, "receive a signal to turn off wifi switch from control-center"); - } - } - } - }); - } -} - -//收到控制面板发来的消息后,获取wifi开关信息 -bool KylinDBus::getSwitchStatus(QString key) { - if (!m_gsettings) { - return true; - } - const QStringList list = m_gsettings->keys(); - if (!list.contains(key)) { - return true; - } - bool res = m_gsettings->get(key).toBool(); - return res; -} - -//通知控制面板wifi开关的信息 -void KylinDBus::setWifiSwitchState(bool signal) -{ - if (!m_gsettings) { - return ; - } - - const QStringList list = m_gsettings->keys(); - - if (!list.contains("switchor")) { - return ; - } - m_gsettings->set("switchor",signal); - - if (!m_nm_gsettings) { - return ; - } - if (m_nm_gsettings->keys().contains("wifiswitch")) { - m_nm_gsettings->set("wifiswitch",signal); - } -} - -void KylinDBus::setWifiConnStatus(bool is_wifi_connected) -{ -// qDebug()<<"WIFI连接状态:"<keys().contains("wificonn")) { - m_nm_gsettings->set("wificonn",is_wifi_connected); - } -} - -void KylinDBus::setLanConnStatus(bool is_lan_connected) -{ -// qDebug()<<"LAN连接状态:"<keys().contains("lanconn")) { - m_nm_gsettings->set("lanconn",is_lan_connected); - } -} - -//通知控制面板无线网卡的状态信息 -void KylinDBus::setWifiCardState(bool signal) -{ - if (!m_gsettings) { - return ; - } - - const QStringList list = m_gsettings->keys(); - - if (!list.contains("wificard")) { - return ; - } - m_gsettings->set("wificard",signal); -} - -//创建获取窗口透明度信息的GSetting的对象 -void KylinDBus::initTransparentState() -{ - if (QGSettings::isSchemaInstalled("org.ukui.control-center.personalise")) { - m_transparency_gsettings = new QGSettings("org.ukui.control-center.personalise"); - } -} - -//创建WIFI开关状态的GSetting的对象 -void KylinDBus::initBtnWifiGsetting() -{ - if (QGSettings::isSchemaInstalled("org.ukui.control-center.wifi.switch")) { - m_btnWifi_gsettings = new QGSettings("org.ukui.control-center.wifi.switch"); - } -} -void KylinDBus::setBtnWifiGsetting(bool bl) -{ - if(m_btnWifi_gsettings->get("switch").toBool()!=bl) - { - m_btnWifi_gsettings->set("switch",bl); - } -} - -//根据Dbus路径获取wifi的ssid(排除空格干扰) -QString KylinDBus::getWifiSsid(QString accessPointPath) -{ - QDBusInterface interface( "org.freedesktop.NetworkManager", - accessPointPath, - "org.freedesktop.DBus.Properties", - QDBusConnection::systemBus() ); - QDBusMessage result = interface.call("Get", "org.freedesktop.NetworkManager.AccessPoint", "Ssid"); - if (result.arguments().isEmpty()) return ""; - return result.arguments().at(0).value().variant().toString(); -} - -//获取已经连接无线网络的ssid和uuid -QList KylinDBus::getAtiveWifiBSsidUuid(QStringList wifilist) -{ - QList strBSsidUuid; - - QDBusInterface interface( "org.freedesktop.NetworkManager", - "/org/freedesktop/NetworkManager", - "org.freedesktop.DBus.Properties", - QDBusConnection::systemBus() ); - //获取已经连接了那些网络,及这些网络对应的网络类型(ethernet or wifi) - QDBusMessage result = interface.call("Get", "org.freedesktop.NetworkManager", "ActiveConnections"); - QList outArgs = result.arguments(); - QVariant first = outArgs.at(0); - QDBusVariant dbvFirst = first.value(); - QVariant vFirst = dbvFirst.variant(); - QDBusArgument dbusArgs = vFirst.value(); - - QDBusObjectPath objPath; - dbusArgs.beginArray(); - while (!dbusArgs.atEnd()) { - dbusArgs >> objPath; - - QDBusInterface interfaceType( "org.freedesktop.NetworkManager", - objPath.path(), - "org.freedesktop.DBus.Properties", - QDBusConnection::systemBus() ); - QDBusReply reply = interfaceType.call("Get", "org.freedesktop.NetworkManager.Connection.Active", "Type"); - - if (reply.value().toString() == "wifi" || reply.value().toString() == "802-11-wireless") { - QDBusInterface interfaceInfo( "org.freedesktop.NetworkManager", - objPath.path(), - "org.freedesktop.DBus.Properties", - QDBusConnection::systemBus() ); - - //获取已经连接wifi的uuid - QDBusReply replyUuid = interfaceInfo.call("Get", "org.freedesktop.NetworkManager.Connection.Active", "Uuid"); - //qDebug() << "wifi uuid : "<< replyUuid.value().toString(); - strBSsidUuid.append(replyUuid.value().toString()); - - - //再获取bssid - QDBusMessage resultConnection = interfaceInfo.call("Get", "org.freedesktop.NetworkManager.Connection.Active", "Connection"); - - QList outArgsConnection = resultConnection.arguments(); - QVariant firstConnection = outArgsConnection.at(0); - QDBusVariant dbvFirstConnection = firstConnection.value(); - QVariant vFirstConnection = dbvFirstConnection.variant(); - QDBusObjectPath dbusArgsConnection = vFirstConnection.value(); - - QDBusInterface interfaceSet("org.freedesktop.NetworkManager", - dbusArgsConnection.path(), - "org.freedesktop.NetworkManager.Settings.Connection", - QDBusConnection::systemBus()); - QDBusMessage resultSet = interfaceSet.call("GetSettings"); - - const QDBusArgument &dbusArg1stSet = resultSet.arguments().at( 0 ).value(); - QMap> mapSet; - dbusArg1stSet >> mapSet; - - for (QString setKey : mapSet.keys() ) { - QMap subSetMap = mapSet.value(setKey); - if (setKey == "802-11-wireless") { - for (QString searchKey : subSetMap.keys()) { - if (searchKey == "seen-bssids") { - //qDebug() << "wifi bssid : "<keys(); - if (keys.contains("transparency")) { - double tp = m_transparency_gsettings->get("transparency").toDouble(); - return tp; - } else { - return 0.7; - } -} diff --git a/KylinNM/src/kylin-dbus-interface.h b/KylinNM/src/kylin-dbus-interface.h deleted file mode 100644 index b62c4c5..0000000 --- a/KylinNM/src/kylin-dbus-interface.h +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class KylinNM; -class Utils; - -class KylinDBus : public QObject -{ - Q_OBJECT -public: - explicit KylinDBus(KylinNM *mw = 0, QObject *parent = nullptr); - ~KylinDBus(); - - void getObjectPath(); - int getAccessPointsNumber(); - void showDesktopNotify(QString message); - void initConnectionInfo(); - void connectWiredNet(QString netName); - void getConnectNetIp(); - - int getTaskBarPos(QString str); - int getTaskBarHeight(QString str); - void initTaskbarGsetting(); - int getTaskbarHeight(); - int getTaskbarPos(); - - void getWifiSwitchState(); - bool getSwitchStatus(QString key); - void setWifiSwitchState(bool signal); - void setWifiCardState(bool signal); - - void initTransparentState(); - double getTransparentData(); - - void initBtnWifiGsetting(); - void setBtnWifiGsetting(bool bl); - QString getWifiSsid(QString accessPointPath); - QList getAtiveWifiBSsidUuid(QStringList wifilist); - - QDBusObjectPath wiredPath; //有线设备的路径 - QDBusObjectPath wirelessPath; //无线设备的路径 - QList multiWiredPaths; //已连接网络的对象路径列表 - - QList multiWiredCableState; - bool isWiredCableOn = false; //是否插入了网线 - bool isWirelessCardOn = false; //是否插入了无线网卡 - - QString dbusLanCardName = ""; - QString dbusLanIpv4 = ""; - QString dbusLanIpv6 = ""; - QString dbusActiveLanIpv4 = ""; - QString dbusActiveLanIpv6 = ""; - QString dbusLanGateway = ""; - QString dbusLanMac = ""; - QString dbusWiFiCardName = ""; - QString dbusWifiMac = ""; - -public Q_SLOTS: - void onNewConnection(QDBusObjectPath objPath); - void onConnectionRemoved(QDBusObjectPath objPath); - void onPropertiesChanged(QVariantMap qvm); - void onLanPropertyChanged(QVariantMap qvm); - void onWifiPropertyChanged(QVariantMap qvm); - void onAccessPointAdded(QDBusObjectPath objPath); - void getPhysicalCarrierState(int n); - void getLanHwAddressState(); - void getWiredCardName(); - void getWirelessCardName(); - void getLanIp(QString netName); - void getWifiMac(QString netName); - void slot_timeout(); - void setWifiSignal(int wifiSignal, QString wifiname); - void setWifiConnStatus(bool is_wifi_connected); - void setLanConnStatus(bool is_lan_connected); - -private: - KylinNM *mw; - Utils *mUtils; - QThread *mUtilsThread; - - int a = 0; - bool isRunningFunction = false; - QTimer *time = nullptr; - QList oldPaths; //已连接网络的对象路径列表 - QStringList oldPathInfo; //某个已连接网络对象路径对应的网络类型(ethernet or wifi) - bool oldWifiSwitchState; //上一次获取到的wifi开关状态 - - QGSettings *m_tastbar_gsettings = nullptr; - QGSettings *m_nm_gsettings = nullptr; - QGSettings *m_gsettings = nullptr; - QGSettings *m_transparency_gsettings = nullptr; - QGSettings *m_btnWifi_gsettings = nullptr; - - bool is_wificonnected = false; - -Q_SIGNALS: - void updateWiredList(int n); - void requestSendDesktopNotify(QString message); -}; - -#endif // KYLINDBUSINTERFACE_H diff --git a/KylinNM/src/kylin-network-interface.c b/KylinNM/src/kylin-network-interface.c deleted file mode 100644 index 5f69bd0..0000000 --- a/KylinNM/src/kylin-network-interface.c +++ /dev/null @@ -1,998 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -//获取网络接口名 -ifname *kylin_network_get_ifacename() -{ - int i = 0; - int sockfd; - struct ifconf ifconf; - struct ifreq *ifreq; - unsigned char buf[1024]; - - //初始化ifconf - ifconf.ifc_len = 1024; - //字符串指针ifconf.ifc_buf指向buf - ifconf.ifc_buf = buf; - - if((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) - { - perror("socket error"); - return 0; - } - - //获取所有接口信息 - ioctl(sockfd, SIOCGIFCONF, &ifconf); - // printf("%s\n",ifconf.ifc_buf); - - //逐个获取Ip地址 - //结构体指针ifreq指向buf,即ifconf.ifc_buf - ifreq = (struct ifreq*)buf; - int number=ifconf.ifc_len/sizeof(struct ifreq); - // printf("%d\n",number); - - ifname *ifn=(ifname *)malloc(sizeof(ifname)*(number+1)); - - for(i = number; i>0; i--) - { - // printf("name = [%s] \n",ifreq->ifr_name); - - int j=number-i; - ifn[j].if_name=(char *)malloc(sizeof(char)*10); - strcpy(ifn[j].if_name,ifreq->ifr_name); - // ifn[j].if_name=ifreq->ifr_name; - // printf("if_name[%d]:%s\n",j,if_name[j]); - - ifreq++; - } - ifn[number].if_name=NULL; - - - return ifn; -} - -//获取所有网络连接 -conlist *kylin_network_get_conlist_info() -{ - int status = system("nmcli connection show > /tmp/conlist.txt"); - if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection show' in function 'kylin_network_get_conlist_info' failed");} - char *filename="/tmp/conlist.txt"; - - FILE *confp; - int connum=0; - char ConStrLine[1024]; - if((confp=fopen(filename,"r"))==NULL) - { - printf("error!"); - - } - fgets(ConStrLine,1024,confp); - while(!feof(confp)) - { - fgets(ConStrLine,1024,confp); - connum++; - } - // printf("%d\n",connum); - fclose(confp); - conlist *clist=(conlist *)malloc(sizeof(conlist)*connum); - - int count=0; - FILE *fp; - char StrLine[1024]; - if((fp=fopen(filename,"r"))==NULL) - { - printf("error!"); - - } - fgets(StrLine,1024,fp); - while(!feof(fp)) - { - if(count==connum-1)break; - - fgets(StrLine,1024,fp); - - char *index=StrLine; - char conname[100]; - - //截取连接名称 - int num=0; - for(index;*index!='\n';index++) - { - if(*index==' ') - { - if(*(index+1)==' ') - break; - } - num++; - } - - // printf("连接名称长度:%d\n",num); - clist[count].con_name=(char *)malloc(sizeof(char)*(num+1)); - strncpy(conname,StrLine,num+1); - conname[num]='\0'; - strncpy(clist[count].con_name,conname,num+1); - // printf("%s\n",clist[count].con_name); - - //截取连接类型 - char type[100]; - for(index;*index!='\n';index++) - { - if(*index==' ') - { - if(*(index+1)=' ') - if(*(index+2)!=' ') - break; - - } - } - char *index1=index+2; - for(index1;*index1!='\n';index1++) - { - if(*index1==' ') - { - if(*(index1+1)==' ') - break; - } - } - int num1=0; - char *index2=index1+2; - for(index2;*index2!='\n';index2++) - { - if(*index2==' ')break; - num1++; - } - clist[count].type=(char *)malloc(sizeof(char)*(num1+1)); - strncpy(type,index1+2,num1+1); - type[num1]='\0'; - strncpy(clist[count].type,type,num1+1); - // printf("%s\n",clist[count].type); - count++; - } - fclose(fp); - - clist[count].con_name=NULL; - clist[count].type=NULL; - - return clist; -} - -//获取当前活动网络连接 -int kylin_network_get_activecon_info(activecon** activelist, int* count) -{ - if (*activelist != NULL || !count) { - return -1; - } - struct passwd *pwd; - pwd = getpwuid(getuid()); - char *name = pwd->pw_name; - char *tmpPrefix = "/tmp/kylin-nm-activecon-"; - char *chr = "nmcli connection show -active > "; - - char *cmd; - asprintf(&cmd, "%s%s%s", chr, tmpPrefix, name); - char *path; - asprintf(&path, "%s%s", tmpPrefix, name); - int status = system(cmd); - //int status = system("nmcli connection show -active > /tmp/activecon.txt"); - if (status != 0) - syslog(LOG_ERR, "execute 'nmcli connection show -active' in function 'kylin_network_get_activecon_info' failed"); - free(cmd); - - char *filename = path; - - FILE *activefp; - int activenum=0; - char activeStrLine[1024]; - if((activefp=fopen(filename,"r"))==NULL) - { - printf("error!"); - return -1; - } - fgets(activeStrLine,1024,activefp); - while(!feof(activefp)) - { - fgets(activeStrLine,1024,activefp); - activenum++; - } - // printf("%d\n",activenum); - fclose(activefp); - *activelist=(activecon *)malloc(sizeof(activecon)*activenum); - - *count=0; - FILE *fp; - char StrLine[1024]; - if((fp=fopen(filename,"r"))==NULL) - { - printf("error!"); - return -1; - } - free(path); - - fgets(StrLine,1024,fp); - while(!feof(fp)) - { - if(*count==activenum-1)break; - - fgets(StrLine,1024,fp); - - char *index=StrLine; - char conname[100]; - - //截取连接名称 - int num=0; - for(index;*index!='\n';index++) - { - if(*index==' ') - { - if(*(index+1)==' ') - break; - } - num++; - } - - // printf("连接名称长度:%d\n",num); - strncpy(conname,StrLine,num+1); - conname[num]='\0'; - strncpy((*activelist)[*count].con_name,conname,num+1); - // printf("%s\n",activelist[count].con_name); - - //截取连接类型 - char type[100]; - for(index;*index!='\n';index++) - { - if(*index==' ') - { - if(*(index+1)=' ') - if(*(index+2)!=' ') - break; - - } - } - char *index1=index+2; - for(index1;*index1!='\n';index1++) - { - if(*index1==' ') - { - if(*(index1+1)==' ') - break; - } - } - int num1=0; - char *index2=index1+2; - for(index2;*index2!='\n';index2++) - { - if(*index2==' ')break; - num1++; - } - strncpy(type,index1+2,num1+1); - type[num1]='\0'; - strncpy((*activelist)[*count].type,type,num1+1); - // printf("%s\n",activelist[count].type); - - //截取连接所属设备 - char *index3=index2; - char dev[100]; - for(index3;*index3!='\n';index3++) - { - if(*index3==' ') - { - if(*(index3+1)!=' ') - break; - } - } - int num2=0; - char *index4=index3+1; - for(index4;*index4!='\n';index4++) - { - if(*index4==' ')break; - num2++; - } - strncpy(dev,index3+1,num2+1); - dev[num2]='\0'; - strncpy((*activelist)[*count].dev,dev,num2+1); - // printf("%s\n",activelist[count].dev); - (*count)++; - } - fclose(fp); - return 0; -} - -//创建新的以太网连接 -void kylin_network_create_new_ethernet(char *con_name,char *if_name) -{ - char str[100]; - char *net_type="ethernet"; - sprintf(str,"nmcli connection add con-name \"%s\" ifname %s type %s",con_name,if_name,net_type); - int status = system(str); - if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection add con-name' in function 'kylin_network_create_new_ethernet' failed");} -} - -// 创建新的wifi连接配置 -void kylin_network_create_new_wifi(char *con_name, char *if_name) -{ - char str[200]; - sprintf(str, "nmcli connection add con-name \"%s\" ifname \"%s\" type wifi ssid \"%s\"", - con_name, if_name, con_name); - int status = system(str); - if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection add con-name' in function 'kylin_network_create_new_wifi' failed");} -} - -//删除以太网连接 -void kylin_network_del_ethernet_con(char *con_name) -{ - char str[100]; - sprintf(str,"nmcli connection delete \"%s\"",con_name); - int status = system(str); - if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection delete' in function 'kylin_network_del_ethernet_con' failed");} -} - -//设置动态分配ip -void kylin_network_set_automethod(char *con_name) -{ - char str[100]; - char *automethod="auto"; - sprintf(str,"nmcli connection modify \"%s\" ipv4.method %s ipv4.address '' ipv4.gateway ''",con_name,automethod); - int status = system(str); - if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection modify' in function 'kylin_network_set_automethod' failed");} -} - -//设置手动分配ip -void kylin_network_set_manualmethod(char *con_name,char *ip) -{ - char str[100]; - char *method="manual"; - sprintf(str,"nmcli connection modify \"%s\" ipv4.method %s ipv4.address %s",con_name,method,ip); - int status = system(str); - if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection modify' in function 'kylin_network_set_manualmethod' failed");} -} - -// 设置手动分配all -void kylin_network_set_manualall(char *con_name, char *addr, char *mask, char *gateway, char *dns){ - char str[200]; - sprintf(str, "nmcli connection modify \"%s\" ipv4.method manual ipv4.address %s/%s ipv4.gateway %s ipv4.dns %s", - con_name, addr, mask, gateway, dns); - int status = system(str); - if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection modify' in function 'kylin_network_set_manualall' failed");} -} - -//设置是否自动连接 -void kylin_network_set_autoconnect(char *con_name,bool autocon) -{ - char str[200]; - if(autocon==false) - { - char *ac="no"; - sprintf(str,"export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection modify \"%s\" connection.autoconnect %s",con_name,ac); - } - else{ - char *ac="yes"; - sprintf(str,"export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection modify \"%s\" connection.autoconnect %s",con_name,ac); - } - int status = system(str); - if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection modify' in function 'kylin_network_set_autoconnect' failed");} -} - -//修改ip -void kylin_network_mod_ip(char *con_name,char *ip) -{ - char str[100]; - sprintf(str,"nmcli connection modify \"%s\" ipv4.address %s",con_name,ip); - int status = system(str); - if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection modify' in function 'kylin_network_mod_ip' failed");} -} - -//修改网关 -void kylin_network_mod_gateway(char *con_name,char *gw) -{ - char str[100]; - sprintf(str,"nmcli connection modify \"%s\" ipv4.gateway %s",con_name,gw); - int status = system(str); - if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection modify' in function 'kylin_network_mod_gateway' failed");} -} - -//修改dns -void kylin_network_mod_dns(char *con_name,char *dns) -{ - char str[100]; - sprintf(str,"nmcli connection modify \"%s\" ipv4.dns %s",con_name,dns); - int status = system(str); - if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection modify' in function 'kylin_network_mod_dns' failed");} -} - -//连接以太网 -void kylin_network_set_con_up(char *con_name) -{ - char str[100]; - sprintf(str,"nmcli connection up \"%s\"",con_name); - int status = system(str); - if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection up' in function 'kylin_network_set_con_up' failed");} -} - -//断开以太网 -void kylin_network_set_con_down(char *con_name) -{ - char str[100]; - sprintf(str,"nmcli connection down \"%s\"",con_name); - int status = system(str); - if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection down' in function 'kylin_network_set_con_down' failed");} -} - -//连接wifi -void kylin_network_set_wifi_up(char *con_name,char *passwd) -{ - char str[100]; - sprintf(str,"export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli device wifi connect \"%s\" password \"%s\"", con_name,passwd); - int status = system(str); - if (status != 0){ syslog(LOG_ERR, "execute 'nmcli device wifi connect' in function 'kylin_network_set_wifi_up' failed");} -} - -//断开wifi连接 -void kylin_network_set_wifi_down(char *if_name) -{ - char str[100]; - sprintf(str,"nmcli device disconnect \"%s\"",if_name); - int status = system(str); - if (status != 0){ syslog(LOG_ERR, "execute 'nmcli device disconnect' in function 'kylin_network_set_wifi_down' failed");} -} - -//获取wifi列表信息 -wifilist *kylin_network_get_wifilist_info() -{ - int status = system("nmcli device wifi > /tmp/wflist.txt"); - if (status != 0){ syslog(LOG_ERR, "execute 'nmcli device wifi' in function 'kylin_network_get_wifilist_info' failed");} - char *filename="/tmp/wflist.txt"; - - FILE *wffp; - int wfnum=0; - char WfStrLine[1024]; - if((wffp=fopen(filename,"r"))==NULL) - { - printf("error!"); - - } - fgets(WfStrLine,1024,wffp); - while(!feof(wffp)) - { - fgets(WfStrLine,1024,wffp); - wfnum++; - } - // printf("wifi数量:%d\n",wfnum); - fclose(wffp); - //wifi实际数量是wfnum-1 - wifilist *wflist=(wifilist *)malloc(sizeof(wifilist)*wfnum); - - int count=0; - FILE *fp; - char StrLine[1024]; - if((fp=fopen(filename,"r"))==NULL) - { - printf("error!"); - - } - fgets(StrLine,1024,fp); - while(!feof(fp)) - { - if(count==wfnum-1)break; - - fgets(StrLine,1024,fp); - - // printf("%s\n",StrLine+3); - char *index=StrLine+3; - - //截取ssid - char *str1="Infra"; - int num=0; - for(index;strcmp(index+5,"\n")!=0;index++) - { - int result=strncmp(index,str1,5); - if(result==0) - { - // printf("%s\n",index); - break; - - } - num++; - - } - char ssid[100]; - char *ssidindex=index-1; - int ssidnum=0; - for(ssidindex;*ssidindex==' ';ssidindex--)ssidnum++; - // printf("空格数量:%d\n",ssidnum); - // if(ssidnum==1) - strncpy(ssid,StrLine+3,num-1); - ssid[num-ssidnum]='\0'; - // printf("-6666--%s---\n",ssid); - - wflist[count].ssid=(char *)malloc(sizeof(char)*(num-ssidnum)); - strncpy(wflist[count].ssid,ssid,num-ssidnum+1); - // printf("第%d个:%s ",count,wflist[count].ssid); - - - //截取信号强度 - char *str2="Mbit/s"; - for(index;strcmp(index+6,"\n")!=0;index++) - { - int result=strncmp(index,str2,6); - if(result==0) - { - // printf("%s\n",index); - break; - } - } - - char signal[10]; - char *signalindex=index+8; - int signalnum=0; - for(signalindex;*signalindex!=' ';signalindex++)signalnum++; - strncpy(signal,index+8,signalnum); - signal[signalnum]='\0'; - // printf("-7777--%s---\n",signal); - - wflist[count].signal=atoi(signal); - // printf("%d ",wflist[count].signal); - - //截取安全性 - char *str3="WPA"; - for(index;strcmp(index+3,"\n")!=0;index++) - { - int result=strncmp(index,str3,3); - if(result==0) - { - // printf("%s\n",index); - break; - } - } - - char safety[20]; - char *safetyindex=index; - int safetynum=0; - for(safetyindex;strcmp(safetyindex+2,"\n")!=0;safetyindex++) - { - int result=strncmp(safetyindex," ",2); - if(result==0)break; - safetynum++; - } - strncpy(safety,index,safetynum+1); - safety[safetynum+1]='\0'; - // printf("-8888--%s---\n",safety); - - wflist[count].safety=(char *)malloc(sizeof(char)*(safetynum+1)); - strncpy(wflist[count].safety,safety,safetynum+2); - // printf("%s\n",wflist[count].safety); - - count++; - - } - - fclose(fp); - - wflist[count].ssid=NULL; - wflist[count].signal=0; - wflist[count].safety=NULL; - - return wflist; -} - -//启用联网 -void kylin_network_enable_networking() -{ - int status = system("nmcli networking on"); - if (status != 0){ syslog(LOG_ERR, "execute 'nmcli networking on' in function 'kylin_network_enable_networking' failed");} -} - -//禁用联网 -void kylin_network_disable_networking() -{ - int status = system("nmcli networking off"); - if (status != 0){ syslog(LOG_ERR, "execute 'nmcli networking off' in function 'kylin_network_disable_networking' failed");} -} - -//启用wifi -void kylin_network_enable_wifi() -{ - int status = system("nmcli radio wifi on;sleep 3"); - if (status != 0){ syslog(LOG_ERR, "execute 'nmcli radio wifi on' in function 'kylin_network_enable_wifi' failed");} -} - -//禁用wifi -void kylin_network_disable_wifi() -{ - int status = system("nmcli radio wifi off;sleep 2"); - if (status != 0){ syslog(LOG_ERR, "execute 'nmcli radio wifi off' in function 'kylin_network_disable_wifi' failed");} -} - -//获取ip地址 -int kylin_network_get_ipaddr(char *if_name,char *ipaddr) -{ - int sock_ip; - struct sockaddr_in sin_ip; - struct ifreq ifr_ip; - if((sock_ip=socket(AF_INET,SOCK_STREAM,0))<0) - { - perror("sockket error"); - return -1; - } - - strcpy(ifr_ip.ifr_name,if_name); - - if(ioctl(sock_ip,SIOCGIFADDR,&ifr_ip)<0)//直接获取ip地址 - { - perror("Not setup interface\n"); - return -1; - } - - memcpy(&sin_ip,&ifr_ip.ifr_addr,sizeof(sin_ip)); - strcpy(ipaddr,inet_ntoa(sin_ip.sin_addr));//#include - close(sock_ip); - return 0; - -} - -//获取广播地址 -int kylin_network_get_brdaddr(char *if_name,char *brdaddr) -{ - int sock_brdaddr; - struct sockaddr_in sin_brd; - struct ifreq ifr_brd; - if((sock_brdaddr=socket(AF_INET,SOCK_STREAM,0))<0) - { - perror("sockket error"); - return -1; - } - - strcpy(ifr_brd.ifr_name,if_name); - - if(ioctl(sock_brdaddr,SIOCGIFBRDADDR,&ifr_brd)<0)//直接获取广播地址 - { - perror("Not setup interface\n"); - return -1; - } - - memcpy(&sin_brd,&ifr_brd.ifr_broadaddr,sizeof(sin_brd)); - strcpy(brdaddr,inet_ntoa(sin_brd.sin_addr)); - close(sock_brdaddr); - return 0; - -} - -//获取子网掩码 -int kylin_network_get_netmask(char *if_name,char *netmask) -{ - int sock_mask; - struct sockaddr_in sin_netmask; - struct ifreq ifr_mask; - if((sock_mask=socket(AF_INET,SOCK_STREAM,0))<0) - { - perror("sockket error"); - return -1; - } - - strcpy(ifr_mask.ifr_name,if_name); - - if(ioctl(sock_mask,SIOCGIFNETMASK,&ifr_mask)<0)//直接获取子网掩码 - { - perror("Not setup interface\n"); - return -1; - } - - memcpy(&sin_netmask,&ifr_mask.ifr_netmask,sizeof(sin_netmask)); - strcpy(netmask,inet_ntoa(sin_netmask.sin_addr)); - close(sock_mask); - return 0; - -} - -//获取MAC -int kylin_network_get_mac(char *if_name,char *macaddr) -{ - int sock_mac; - struct ifreq ifr_mac; - struct sockaddr_in sin_mac; - struct ether_addr ethaddr;//#include - - sock_mac=socket(AF_INET,SOCK_STREAM,0); - - strcpy(ifr_mac.ifr_name,if_name); - - if(-1==ioctl(sock_mac,SIOCGIFHWADDR,&ifr_mac)) - { - perror("Not setup interface\n"); - return -1; - } - memcpy(ðaddr,&ifr_mac.ifr_hwaddr.sa_data,sizeof(ethaddr)); - strcpy(macaddr,ether_ntoa(ðaddr));//#include - - // strcpy(macaddr,ether_ntoa((struct ether_addr*)ifr_mac.ifr_hwaddr.sa_data)); - - close(sock_mac); - return 0; - -} - -//获取MTU -int kylin_network_get_mtu(char *if_name) -{ - int sock_mtu; -// struct sockaddr_in sin_ip; - struct ifreq ifr_MTU; - if((sock_mtu=socket(AF_INET,SOCK_STREAM,0))<0) - { - perror("sockket error"); - return -1; - } - - strcpy(ifr_MTU.ifr_name,if_name); - - if(ioctl(sock_mtu,SIOCGIFMTU,&ifr_MTU)) - { - perror("Not setup interface\n"); - return -1; - } - - int mtu=ifr_MTU.ifr_mtu; - // printf("%d\n",ifr_MTU.ifr_mtu); - // printf("%d\n",mtu); - - close(sock_mtu); - return mtu; - -} - -static void getBuf(char *bufstr) -{ - //O_RDONLY以只读方式打开文件 - int fd=open("/proc/net/dev", O_RDONLY); - if(-1==fd) - { - printf("/proc/net/dev not exists!\n"); - } - - char buf[1024*2]; - //将读写位置移到文件开头 - lseek(fd,0,SEEK_SET); - int nBytes=read(fd,buf,sizeof(buf)-1); - if(-1==nBytes) - { - perror("read error"); - close(fd); - } - - buf[nBytes]='\0'; - strcpy(bufstr,buf); -} - -//总计上传下载数据量 -long *kylin_network_get_bytes(char *if_name) -{ - char buf[1024*2]; - getBuf(buf); - - //返回第一次指向if_name位置的指针 - char *pDev=strstr(buf,if_name); - if(NULL==pDev) - { - printf("don't find dev %s\n",if_name); - return NULL; - } - - char *p; - char *value; - int i=0; - static long rtbyt[2]; - /*去除空格,制表符,换行符等不需要的字段*/ - for (p = strtok(pDev, " \t\r\n"); p; p = strtok(NULL, " \t\r\n")) - { - i++; - value = (char*)malloc(20); - strcpy(value, p); - /*得到的字符串中的第二个字段是接收流量*/ - if(i == 2) - { - rtbyt[0] = atol(value); - } - /*得到的字符串中的第十个字段是发送流量*/ - if(i == 10) - { - rtbyt[1] = atol(value); - free(value); - break; - } - free(value); - } - return rtbyt; -} - -//总计上传下载数据包 -long *kylin_network_get_packets(char *if_name) -{ - char buf[1024*2]; - getBuf(buf); - - //返回第一次指向if_name位置的指针 - char *pDev=strstr(buf,if_name); - if(NULL==pDev) - { - printf("don't find dev %s\n",if_name); - return NULL; - } - - char *p; - char *value; - int i=0; - static long rtpkt[2]; - /*去除空格,制表符,换行符等不需要的字段*/ - for (p = strtok(pDev, " \t\r\n"); p; p = strtok(NULL, " \t\r\n")) - { - i++; - value = (char*)malloc(20); - strcpy(value, p); - /*得到的字符串中的第三个字段是接收流量*/ - if(i == 3) - { - rtpkt[0] = atol(value); - } - /*得到的字符串中的第十一个字段是发送流量*/ - if(i == 11) - { - rtpkt[1] = atol(value); - free(value); - break; - } - free(value); - } - return rtpkt; -} - -//总计上传下载错误数据包数量 -long *kylin_network_get_errs(char *if_name) -{ - char buf[1024*2]; - getBuf(buf); - - //返回第一次指向if_name位置的指针 - char *pDev=strstr(buf,if_name); - if(NULL==pDev) - { - printf("don't find dev %s\n",if_name); - return NULL; - } - - char *p; - char *value; - int i=0; - static long rterrs[2]; - /*去除空格,制表符,换行符等不需要的字段*/ - for (p = strtok(pDev, " \t\r\n"); p; p = strtok(NULL, " \t\r\n")) - { - i++; - value = (char*)malloc(20); - strcpy(value, p); - /*得到的字符串中的第四个字段是接收流量*/ - if(i == 4) - { - rterrs[0] = atol(value); - } - /*得到的字符串中的第十二个字段是发送流量*/ - if(i == 12) - { - rterrs[1] = atol(value); - free(value); - break; - } - free(value); - } - return rterrs; -} - -//总计上传下载丢弃数据包数量 -long *kylin_network_get_drop(char *if_name) -{ - char buf[1024*2]; - getBuf(buf); - - //返回第一次指向if_name位置的指针 - char *pDev=strstr(buf,if_name); - if(NULL==pDev) - { - printf("don't find dev %s\n",if_name); - return NULL; - } - - char *p; - char *value; - int i=0; - static long rtdrop[2]; - /*去除空格,制表符,换行符等不需要的字段*/ - for (p = strtok(pDev, " \t\r\n"); p; p = strtok(NULL, " \t\r\n")) - { - i++; - value = (char*)malloc(20); - strcpy(value, p); - /*得到的字符串中的第五个字段是接收流量*/ - if(i == 5) - { - rtdrop[0] = atol(value); - } - /*得到的字符串中的第十三个字段是发送流量*/ - if(i == 13) - { - rtdrop[1] = atol(value); - free(value); - break; - } - free(value); - } - return rtdrop; -} - -//总计上传下载过载数据包数量 -long *kylin_network_get_fifo(char *if_name) -{ - char buf[1024*2]; - getBuf(buf); - - //返回第一次指向if_name位置的指针 - char *pDev=strstr(buf,if_name); - if(NULL==pDev) - { - printf("don't find dev %s\n",if_name); - return NULL; - } - - char *p; - char *value; - int i=0; - static long rtfifo[2]; - /*去除空格,制表符,换行符等不需要的字段*/ - for (p = strtok(pDev, " \t\r\n"); p; p = strtok(NULL, " \t\r\n")) - { - i++; - value = (char*)malloc(20); - strcpy(value, p); - /*得到的字符串中的第六个字段是接收流量*/ - if(i == 6) - { - rtfifo[0] = atol(value); - } - /*得到的字符串中的第十四个字段是发送流量*/ - if(i == 14) - { - rtfifo[1] = atol(value); - free(value); - break; - } - free(value); - } - return rtfifo; -} diff --git a/KylinNM/src/kylin-network-interface.h b/KylinNM/src/kylin-network-interface.h deleted file mode 100644 index db18a52..0000000 --- a/KylinNM/src/kylin-network-interface.h +++ /dev/null @@ -1,267 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C"{ -#endif - -typedef struct -{ - char *if_name; -}ifname; - -typedef struct -{ - char *ssid;//wifi名称 - int signal;//信号强度 - char *safety;//安全性 - -}wifilist;//存放wifi信息的结构体 - -typedef struct -{ - char *con_name;//网络连接名称 - char *type;//网络连接类型 -}conlist;//存放所有网络连接 - -typedef struct -{ - char con_name[128];//活动网络连接名称 - char type[128];//活动网络连接类型 - char dev[128];//活动网络所属设备 -}activecon;//存放当前活动网络连接 - -/* - * Get the network interface name. - * return the struct pointer. - */ -ifname *kylin_network_get_ifacename(); - -/* - * Get the all network connection. - * return the struct pointer. - */ -conlist *kylin_network_get_conlist_info(); - -/* - * Get the active network connection. - * return the struct pointer and list count. - */ -int kylin_network_get_activecon_info(activecon** activelist, int* count); - -/* - * Create a new Ethernet connection. - * @con_name is the connection name. - * @if_name is the interface name. - */ -void kylin_network_create_new_ethernet(char *con_name,char *if_name); - -/* - * Create a new Wifi connection. - * @con_name is the connection name. - * @if_name is the interface name. - */ -void kylin_network_create_new_wifi(char *con_name, char *if_name); - -/* - * Delete ethernet connection. - * @con_name is the connection name. - */ -void kylin_network_del_ethernet_con(char *con_name); - -/* - * Set up dynamic IP allocation. - * @con_name is the connection name. - */ -void kylin_network_set_automethod(char *con_name); - -/* - * Set up manual IP assignment. - * @con_name is the connection name. - * @ip is the ip address(for example,"192.168.68.160/16") - */ -void kylin_network_set_manualmethod(char *con_name,char *ip); - -/* - * Set up manual all prop. - */ -void kylin_network_set_manualall(char *con_name, char *addr, char *mask, char *gateway, char *dns); - -/* - * Sets whether the connection is automatic. - * @con_name is the connection name. - * @autocon is the automatic connection option. - */ -void kylin_network_set_autoconnect(char *con_name,bool autocon); - -/* - * Modify the ip address. - * @con_name is the connection name. - * @ip is the ip address(for example,"192.168.68.160/16") - */ -void kylin_network_mod_ip(char *con_name,char *ip); - -/* - * Modify the gateway. - * @con_name is the connection name. - * @gw is the gateway address. - */ -void kylin_network_mod_gateway(char *con_name,char *gw); - -/* - * Modify the dns address. - * @con_name is the connection name. - * @dns is the dns address. - */ -void kylin_network_mod_dns(char *con_name,char *dns); - -/* - * Connect the ethernet. - * @con_name is the connection name. - */ -void kylin_network_set_con_up(char *con_name); - -/* - * Disconnect the ethernet. - * @con_name is the connection name. - */ -void kylin_network_set_con_down(char *con_name); - -/* - * Connect the wifi. - * @con_name is the wifi name. - * @passwd is the wifi password. - */ -void kylin_network_set_wifi_up(char *con_name,char *passwd); - -/* - * Disconnect the wifi. - * @if_name is the network interface name. - */ -void kylin_network_set_wifi_down(char *if_name); - -/* - * Get wifi list information. - * Return the struct pointer. - */ -wifilist *kylin_network_get_wifilist_info(); - -/* - * Enable networking. - */ -void kylin_network_enable_networking(); - -/* - * Disable networking. - */ -void kylin_network_disable_networking(); - -/* - * Enable wifi. - */ -void kylin_network_enable_wifi(); - -/* - * Disable wifi. - */ -void kylin_network_disable_wifi(); - -/* Get the ip address. - * @if_name is the interface name. - * @ipaddr is used to save the ip address. - */ -int kylin_network_get_ipaddr(char *if_name,char *ipaddr); - -/* - * Get the broadcast address. - * @if_name is the interface name. - * @brdaddr is used to save the broadcast address. - */ -int kylin_network_get_brdaddr(char *if_name,char *brdaddr); - -/* - * Get the subnet mask. - * @if_name is the interface name. - * @netmask is used to save the subnet mask. - */ -int kylin_network_get_netmask(char *if_name,char *netmask); - -/* - * Get MAC address. - * @if_name is the interface name. - * @macaddr is used to save the MAC address. - */ -int kylin_network_get_mac(char *if_name,char *macaddr); - -/* Get the MTU. - * @if_name is the interface name. - * return the MTU value. - */ -int kylin_network_get_mtu(char *if_name); - -/* - * Total upload and download data volume. - * @if_name is the network interface name. - * return the address of the first element of a one-dimensional long integer array. - */ -long *kylin_network_get_bytes(char *if_name); - -/* - * Total upload and download data packets. - * @if_name is the network interface name. - * return the address of the first element of a one-dimensional long integer array. - */ -long *kylin_network_get_packets(char *if_name); - -/* - * Total wrong data packets number of uploading and downloading. - * @if_name is the network interface name. - * return the address of the first element of a one-dimensional long integer array. - */ -long *kylin_network_get_errs(char *if_name); - -/* - * Total discarded data packets number of uploading and downloading. - * @if_name is the network interface name. - * return the address of the first element of a one-dimensional long integer array. - */ -long *kylin_network_get_drop(char *if_name); - -/* - * Total overloaded data packets number of uploading and downloading. - * @if_name is the network interface name. - * return the address of the first element of a one-dimensional long integer array. - */ -long *kylin_network_get_fifo(char *if_name); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/KylinNM/src/kylinnm.cpp b/KylinNM/src/kylinnm.cpp deleted file mode 100644 index aa6ca7e..0000000 --- a/KylinNM/src/kylinnm.cpp +++ /dev/null @@ -1,2799 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see -#include -#include -#include - -#include "kylinnm.h" -#include "ui_kylinnm.h" -#include "swipegesturerecognizer.h" - -QString llname, lwname, hideWiFiConn; -int currentActWifiSignalLv, count_loop; - -bool KylinNM::m_is_reflashWifiUi = false; -QMutex mutexIsReflashWifi; - -KylinNM::KylinNM(QWidget *parent) : - QWidget(parent), - ui(new Ui::KylinNM) -{ - ui->setupUi(this); - qDebug() << "99999999999999999999999999--------------9"; - //checkSingle(); - - syslog(LOG_DEBUG, "Using the icon theme named 'ukui-icon-theme-default'"); - //QIcon::setThemeName("ukui-icon-theme-default"); - - // 如果使用Qt::Popup 任务栏不显示且保留X事件如XCB_FOCUS_OUT, 但如果indicator点击鼠标右键触发,XCB_FOCUS_OUT事件依然会失效 - // 如果使用Qt::ToolTip, Qt::Tool + Qt::WindowStaysOnTopHint, Qt::X11BypassWindowManagerHint等flag则会导致X事件失效 - // this->setWindowFlags(Qt::FramelessWindowHint | Qt::Tool | Qt::WindowStaysOnTopHint); - this->setWindowFlags(Qt::FramelessWindowHint);//QTool - this->setAttribute(Qt::WA_TranslucentBackground);//设置窗口背景透明 - - //UseQssFile::setStyle("style.qss"); - - QPainterPath path; - auto rect = this->rect(); - rect.adjust(1, 1, -1, -1); - path.addRoundedRect(rect, 6, 6); - setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon())); - - this->setStyleSheet("#centralWidget{border:none;border-radius:16px;}"); - - ui->centralWidget->setStyleSheet("#centralWidget{border:none;border-radius:16px;background:rgba(255,255,255,1);}"); - - editQssString(); //编辑部分控件QSS - createTopLanUI(); //创建顶部有线网item - createTopWifiUI(); //创建顶部无线网item - createOtherUI(); //创建上传下载控件,列表区无item时的说明控件 - createListAreaUI(); //创建列表区域的控件 - createLeftAreaUI(); //创建左侧区域控件 - - lname = "-1"; - wname = "-1"; - llname = "-1"; - lwname = "-1"; - hideWiFiConn = "Connect to Hidden Wi-Fi Network"; - currentActWifiSignalLv = -1; - count_loop = 0; - - createTrayIcon(); - connect(trayIcon, &QSystemTrayIcon::activated, this, &KylinNM::iconActivated); - connect(mShowWindow,SIGNAL(triggered()),this,SLOT(on_showWindowAction())); - connect(mAdvConf,SIGNAL(triggered()),this,SLOT(on_btnAdvConf_clicked())); - trayIcon->show(); - - objKyDBus = new KylinDBus(this); - objKyDBus->initBtnWifiGsetting(); - objKyDBus->initConnectionInfo(); - - objKyDBus->initTaskbarGsetting(); -// objKyDBus->setWifiSignal(-1, ""); - - objNetSpeed = new NetworkSpeed(); - - this->confForm = new ConfForm(this->parentWidget()); - this->confForm->setMainWindow(this); - this->confForm->hide(); - - this->ksnm = new KSimpleNM(); - connect(ksnm, SIGNAL(getLanListFinished(QStringList)), this, SLOT(getLanListDone(QStringList))); - connect(ksnm, SIGNAL(getWifiListFinished(QStringList)), this, SLOT(getWifiListDone(QStringList))); - - loading = new LoadingDiv(this); - connect(loading, SIGNAL(toStopLoading() ), this, SLOT(on_checkOverTime() )); - - checkIsWirelessDeviceOn(); //检测无线网卡是否插入 - getInitLanSlist(); //初始化有线网列表 - initNetwork(); //初始化网络 - initTimer(); //初始化定时器 - - connect(ui->btnNetList, &QPushButton::clicked, this, &KylinNM::onBtnNetListClicked); - connect(btnWireless, &SwitchButton::clicked,this, &KylinNM::onBtnWifiClicked); - - //auto app = static_cast(QCoreApplication::instance()); - //app->setStyle(new CustomStyle()); //设置自定义主题 - - ui->btnNetList->setAttribute(Qt::WA_Hover,true); - ui->btnNetList->installEventFilter(this); - ui->btnWifiList->setAttribute(Qt::WA_Hover,true); - ui->btnWifiList->installEventFilter(this); - - SwipeGestureRecognizer *fftRecognizer = new SwipeGestureRecognizer(this); - Qt::GestureType fftType = QGestureRecognizer::registerRecognizer(fftRecognizer); -// grabGesture(fftType); - connect(fftRecognizer, &SwipeGestureRecognizer::onSwipeGesture, this, &KylinNM::onSwipeGesture); -} - -KylinNM::~KylinNM() -{ - trayIcon->deleteLater(); - trayIconMenu->deleteLater(); - delete ui; -} - -void KylinNM::onSwipeGesture(int dx, int dy) -{ - // qDebug() << "info: [KylinNM] onSwipeGesture dy=" << dy; - if(scrollAreal->isVisible()) { - // qDebug() << "info: [KylinNM] onSwipeGesture before moved " << scrollAreal->verticalScrollBar()->value(); - scrollAreal->verticalScrollBar()->setValue(scrollAreal->verticalScrollBar()->value() - dy/5); - // qDebug() << "info: [KylinNM] onSwipeGesture after moved " << scrollAreal->verticalScrollBar()->value(); - } else if (scrollAreaw->isVisible()) { - // qDebug() << "info: [KylinNM] onSwipeGesture before moved " << scrollAreaw->verticalScrollBar()->value(); - scrollAreaw->verticalScrollBar()->setValue(scrollAreaw->verticalScrollBar()->value() - dy/5); - // qDebug() << "info: [KylinNM] onSwipeGesture after moved " << scrollAreaw->verticalScrollBar()->value(); - } -} - -void KylinNM::checkSingle() -{ - int fd = 0; - try { - QStringList homePath = QStandardPaths::standardLocations(QStandardPaths::HomeLocation); - QString lockPath = homePath.at(0) + "/.config/kylin-nm-lock"; - fd = open(lockPath.toUtf8().data(), O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR); - - if (fd < 0) { - throw -1; - } - } catch(...) { - fd = open("/tmp/kylin-nm-lock", O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR); - if (fd < 0) { - exit(0); - } - } - - - if (lockf(fd, F_TLOCK, 0)) { - syslog(LOG_ERR, "Can't lock single file, kylin-network-manager is already running!"); - qDebug()<<"Can't lock single file, kylin-network-manager is already running!"; - exit(0); - } -} - -bool KylinNM::nativeEvent(const QByteArray &eventType, void *message, long *result) -{ - Q_UNUSED(result); - if (eventType != "xcb_generic_event_t") { - return false; - } - - xcb_generic_event_t *event = (xcb_generic_event_t*)message; - - switch (event->response_type & ~0x80) { - case XCB_FOCUS_OUT: - //this->hide(); - break; - } - - return false; -} - -bool KylinNM::eventFilter(QObject *obj, QEvent *event) -{ - if (obj == ui->btnNetList) { - if (event->type() == QEvent::HoverEnter) { - if (!is_btnNetList_clicked) { - ui->lbNetListBG->setStyleSheet(btnBgHoverQss); - } - return true; - } else if(event->type() == QEvent::HoverLeave) { - if (!is_btnNetList_clicked) { - ui->lbNetListBG->setStyleSheet(btnBgLeaveQss); - } - return true; - } - } - - if (obj == ui->btnWifiList) { - if (event->type() == QEvent::HoverEnter) { - if (!is_btnWifiList_clicked) { - ui->lbWifiListBG->setStyleSheet(btnBgHoverQss); - } - return true; - } else if(event->type() == QEvent::HoverLeave) { - if (!is_btnWifiList_clicked) { - ui->lbWifiListBG->setStyleSheet(btnBgLeaveQss); - } - return true; - } - } - - return QWidget::eventFilter(obj,event); -} - -/////////////////////////////////////////////////////////////////////////////// - -void KylinNM::tabletStyle()//平板桌面模式特有设置 -{ - this->setFixedWidth(446+194*isTabletStyle); - ui->centralWidget->setFixedWidth(446+194*isTabletStyle); - ui->btnNetList->setFixedWidth(223+97*isTabletStyle); - ui->btnWifiList->setFixedWidth(223+97*isTabletStyle); - ui->btnWifiList->move(223+97*isTabletStyle,0); - ui->lbWifiListBG->move(223+97*isTabletStyle,0); - ui->lbNetListImg->move(16+95*isTabletStyle,17); - ui->lbWifiListImg->move(288+144*isTabletStyle,17); - scrollAreal->resize(W_SCROLL_AREA+194*isTabletStyle, H_SCROLL_AREA); - scrollAreaw->resize(W_SCROLL_AREA+194*isTabletStyle, H_SCROLL_AREA); - lbNetListText->move(98+48*isTabletStyle,2); - lbWifiListText->move(98+48*isTabletStyle,2); - confForm->tabletStyle(isTabletStyle); - btnWireless->move(385+194*isTabletStyle,73); - lbNoItemTip->move(this->width()/2 - lbNoItemTip->width()/2, this->height()/2+30); - if(isTabletStyle) - { - btnOffQss = "QLabel{min-width: 320px; min-height: 56px;max-width:320px; max-height: 56px;border-radius: 16px; background-color:rgba(255,255,255,0);}"; - btnOnQss = "QLabel{min-width: 320px; min-height: 56px;max-width:320px; max-height: 56px;border-radius: 16px; background-color:rgba(61,107,229,1);}"; - } - else - { - btnOffQss = "QLabel{min-width: 221px; min-height: 56px;max-width:221px; max-height: 56px;border-radius: 16px; background-color:rgba(255,255,255,0)}"; - btnOnQss = "QLabel{min-width: 221px; min-height: 56px;max-width:221px; max-height: 56px;border-radius: 16px; background-color:rgba(61,107,229,1);}"; - } - if(scrollAreal->isHidden())//首次运行初始化大按钮状态 - { - ui->btnNetList->setStyleSheet(btnOffQss); - ui->btnWifiList->setStyleSheet(btnOnQss); - ui->lbNetListBG->setStyleSheet(btnOffQss); - ui->lbWifiListBG->setStyleSheet(btnOnQss); - ui->lbNetListImg->setStyleSheet("QLabel{border-image:url(:/res/l/pb-network-offline.png);background-position:center;background-repeat:no-repeat;}"); - ui->lbWifiListImg->setStyleSheet("QLabel{border-image:url(:/res/x/pb-wifi-y.png);background-position:center;background-repeat:no-repeat;}"); - lbNetListText->setStyleSheet("QLabel{color:rgba(38, 38, 38, 0.75);background-color:transparent;}"); - lbWifiListText->setStyleSheet("QLabel{color:rgba(47, 179, 232, 1);background-color:transparent;}"); - } -} - -// 初始化控件、网络、定时器 - -// 初始化界面各控件 -void KylinNM::editQssString() -{ - btnOffQss = "QLabel{min-width: 221px; min-height: 56px;max-width:221px; max-height: 56px;border-radius: 16px; background-color:rgba(38,38,38,0.15)}"; - btnOnQss = "QLabel{min-width: 221px; min-height: 56px;max-width:221px; max-height: 56px;border-radius: 16px; background-color:rgba(255,255,255,0.2)}"; - btnBgOffQss = "QLabel{min-width: 48px; min-height: 22px;max-width:48px; max-height: 22px;border-radius: 16px; background-color:rgba(38,38,38,0.15)}"; - btnBgOnQss = "QLabel{min-width: 48px; min-height: 22px;max-width:48px; max-height: 22px;border-radius: 16px; background-color:rgba(255,255,255,0.2);}"; - btnBgHoverQss = "QLabel{border-radius: 16px; background-color:rgba(38,38,38,0.2)}"; - btnBgLeaveQss = "QLabel{border-radius: 16px; background-color:rgba(38,38,38,0.15)}"; - leftBtnQss = "QPushButton{border:0px;border-radius:4px;background-color:rgba(255,255,255,0);}" - "QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(255,255,255,0.12);}" - "QPushButton:Pressed{border-radius:4px;background-color:rgba(255,255,255,0.12);}"; -// funcBtnQss = "QPushButton{border:0px;border-radius:4px;background-color:rgba(255,255,255,0);color:rgba(107,142,235,0.97);font-size:14px;}" -// "QPushButton:Hover{border:0px;border-radius:4px;background-color:rgba(255,255,255,0);color:rgba(151,175,241,0.97);font-size:14px;}" -// "QPushButton:Pressed{border-radius:4px;background-color:rgba(255,255,255,0);color:rgba(61,107,229,0.97);font-size:14px;}"; - funcBtnQss="QPushButton{border:0px;border-radius:4px;background-color:rgba(255,255,255,0);color:rgba(38,38,38,1);font-size:14px;text-align:left;}"; -} - -void KylinNM::createTopLanUI() -{ - topLanListWidget = new QWidget(ui->centralWidget); - topLanListWidget->move(W_LEFT_AREA, Y_TOP_ITEM); - topLanListWidget->resize(W_TOP_LIST_WIDGET, H_NORMAL_ITEM + H_GAP_UP + X_ITEM); - /*顶部的一个item*/ - lbTopLanList = new QLabel(topLanListWidget); - lbTopLanList->setText(tr("Inactivated LAN"));//"可用网络列表" - lbTopLanList->resize(W_MIDDLE_WORD, H_MIDDLE_WORD); - lbTopLanList->move(X_MIDDLE_WORD, H_NORMAL_ITEM + H_GAP_UP); - lbTopLanList->setStyleSheet("QLabel{font-size:14px;color:rgba(38, 38, 38, 0.45);}"); - lbTopLanList->show(); - /*新建有线网按钮*/ -// btnCreateNet = new QPushButton(ui->centralWidget); -// btnCreateNet->resize(W_BTN_FUN, H_BTN_FUN); -// btnCreateNet->move(X_BTN_FUN, Y_BTN_FUN); -// btnCreateNet->setText(" "+tr("New LAN"));//"新建网络" -// btnCreateNet->setIcon(QIcon(":/res/x/pb-newConn.png")); -// btnCreateNet->setStyleSheet(funcBtnQss); -// btnCreateNet->setFocusPolicy(Qt::NoFocus); -// btnCreateNet->show(); -// connect(btnCreateNet,SIGNAL(clicked()),this,SLOT(onBtnCreateNetClicked())); -} - -void KylinNM::createTopWifiUI() -{ - topWifiListWidget = new QWidget(ui->centralWidget); - topWifiListWidget->move(W_LEFT_AREA, Y_TOP_ITEM); - topWifiListWidget->resize(W_TOP_LIST_WIDGET+194*isTabletStyle, H_NORMAL_ITEM + H_GAP_UP + X_ITEM); - /*顶部的一个item*/ - lbTopWifiList = new QLabel(topWifiListWidget); - lbTopWifiList->setText(tr("Other WLAN"));//"可用网络列表" - lbTopWifiList->resize(W_MIDDLE_WORD, H_MIDDLE_WORD); - lbTopWifiList->move(X_MIDDLE_WORD, H_NORMAL_ITEM + H_GAP_UP); - lbTopWifiList->setStyleSheet("QLabel{font-size:14px;color:rgba(38, 38, 38, 0.45);}"); - lbTopWifiList->show(); - -// /*新建无线网按钮*/ -// if(!btnAddNet){ -// btnAddNet = new QPushButton(ui->centralWidget); -// connect(btnAddNet,SIGNAL(clicked()),this,SLOT(onBtnAddNetClicked())); -// } -// btnAddNet->resize(W_BTN_FUN, H_BTN_FUN); -// btnAddNet->move(X_BTN_FUN, Y_BTN_FUN); -// btnAddNet->setText(" "+tr("Hide WiFi"));//"加入网络" -// btnAddNet->setIcon(QIcon(":/res/x/pb-newConn.png")); -// btnAddNet->setStyleSheet(funcBtnQss); -// btnAddNet->setFocusPolicy(Qt::NoFocus); -} - -void KylinNM::createOtherUI() -{ - lbLoadDown = new QLabel(ui->centralWidget); - lbLoadDown->move(X_ITEM + 129, Y_TOP_ITEM + 32); - lbLoadDown->resize(65, 20); - lbLoadDownImg = new QLabel(ui->centralWidget); - lbLoadDownImg->move(X_ITEM + 112, Y_TOP_ITEM + 35); - lbLoadDownImg->resize(16, 16); - - lbLoadUp = new QLabel(ui->centralWidget); - lbLoadUp->move(X_ITEM + 187, Y_TOP_ITEM + 32); - lbLoadUp->resize(65, 20); - lbLoadUpImg = new QLabel(ui->centralWidget); - lbLoadUpImg->move(X_ITEM + 170, Y_TOP_ITEM + 35); - lbLoadUpImg->resize(16, 16); - -//YYF lbLoadDownImg->setStyleSheet("QLabel{background-image:url(:/res/x/load-down.png);}"); -//YYF lbLoadUpImg->setStyleSheet("QLabel{background-image:url(:/res/x/load-up.png);}"); - - lbNoItemTip = new QLabel(ui->centralWidget); - lbNoItemTip->resize(W_NO_ITEM_TIP, H_NO_ITEM_TIP); - lbNoItemTip->move(this->width()/2 - W_NO_ITEM_TIP/2 + W_LEFT_AREA/2, this->height()/2); - lbNoItemTip->setStyleSheet("QLabel{border:none;background:transparent;font-size:14px;color:rgba(38, 38, 38, 0.45);}"); - lbNoItemTip->setText(tr("No usable network in the list"));//列表暂无可连接网络 - lbNoItemTip->setAlignment(Qt::AlignCenter); - lbNoItemTip->hide(); -} - -void KylinNM::createListAreaUI() -{ - scrollAreal = new QScrollArea(ui->centralWidget); - scrollAreal->move(W_LEFT_AREA, Y_TOP_ITEM + H_NORMAL_ITEM + H_GAP_UP + X_ITEM + H_GAP_DOWN); - scrollAreal->resize(W_SCROLL_AREA, H_SCROLL_AREA); - scrollAreal->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - scrollAreal->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); - - scrollAreaw = new QScrollArea(ui->centralWidget); - scrollAreaw->move(W_LEFT_AREA, Y_TOP_ITEM + H_NORMAL_ITEM + H_GAP_UP + X_ITEM + H_GAP_DOWN); - scrollAreaw->resize(W_SCROLL_AREA, H_SCROLL_AREA); - scrollAreaw->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - scrollAreaw->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); - - lanListWidget = new QWidget(scrollAreal); - wifiListWidget = new QWidget(scrollAreaw); - lbLanList = new QLabel(lanListWidget); - lbWifiList = new QLabel(wifiListWidget); - - ui->lbNetwork->setStyleSheet("QLabel{font-size:14px;color:rgba(38, 38, 38, 0.45);}"); - ui->lbNetwork->show(); - - topLanListWidget->setStyleSheet("QWidget{border:none;}"); - topLanListWidget->setStyleSheet("background-color:transparent;"); - - topWifiListWidget->setStyleSheet("QWidget{border:none;}"); - topWifiListWidget->setStyleSheet("background-color:transparent;"); - - lbLoadUp->setStyleSheet("QLabel{font-size:14px;color:rgba(38, 38, 38, 0.45);}"); - lbLoadDown->setStyleSheet("QLabel{font-size:14px;color:rgba(38, 38, 38, 0.45);}"); -//YYF lbLoadUp->setText("0KB/s"); -//YYF lbLoadDown->setText("0KB/s "); -//YYF this->on_setNetSpeed(); - scrollAreal->setStyleSheet("QScrollArea{border:none;}"); - scrollAreal->viewport()->setStyleSheet("background-color:transparent;"); - //scrollAreal->verticalScrollBar()->setStyleSheet(scrollBarQss); - scrollAreal->verticalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu); - - scrollAreaw->setStyleSheet("QScrollArea{border:none;}"); - scrollAreaw->viewport()->setStyleSheet("background-color:transparent;"); - //scrollAreaw->verticalScrollBar()->setStyleSheet(scrollBarQss); - scrollAreaw->verticalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu); -} - -void KylinNM::createLeftAreaUI() -{ - btnWireless = new SwitchButton(this); - // btnWireless->setStyleSheet("SwitchButton{border:none;background-color:rgba(255,255,255,0.12);}"); - ui->btnNetList->setFocusPolicy(Qt::NoFocus); - QString txtEthernet(tr("LAN")); - ui->lbNetListBG->setStyleSheet(btnOffQss); - lbNetListText =new QLabel(ui->lbNetListBG); - lbNetListText->setFocusPolicy(Qt::NoFocus); - lbNetListText->setText(tr("LAN")); - lbNetListText->move(98,2); - lbNetListText->setStyleSheet("QLabel{color:rgba(47, 179, 232, 1);background-color:transparent;}"); - ui->lbNetListImg->setStyleSheet("QLabel{border-image:url(:/res/l/pb-network-online.png);background-position:center;background-repeat:no-repeat;}"); - - ui->btnWifiList->setFocusPolicy(Qt::NoFocus); - QString txtWifi(tr("WLAN")); - ui->lbWifiListBG->setStyleSheet(btnOffQss); - lbWifiListText =new QLabel(ui->lbWifiListBG); - lbWifiListText->setFocusPolicy(Qt::NoFocus); - lbWifiListText->setText(tr("WLAN")); - lbWifiListText->move(98,2); - lbWifiListText->setStyleSheet("QLabel{color:rgba(38, 38, 38, 0.75);background-color:transparent;}"); - ui->lbWifiListImg->setStyleSheet("QLabel{border-image:url(:/res/x/pb-wifi-n.png);background-position:center;background-repeat:no-repeat;}"); - - ui->btnNet->hide(); - - btnWireless->move(385,73); - - ui->btnHotspot->setStyleSheet(leftBtnQss); - ui->btnHotspot->setFocusPolicy(Qt::NoFocus); - QString txtHotSpot(tr("HotSpot")); - ui->btnHotspot->hide(); - ui->lbHotImg->hide(); - ui->lbHotImg->setStyleSheet("QLabel{background-image:url(:/res/x/hot-spot-off.svg);}"); - ui->lbHotBG->hide(); - ui->lbHotBG->setStyleSheet(btnOffQss); - - ui->btnFlyMode->setStyleSheet(leftBtnQss); - ui->btnFlyMode->setFocusPolicy(Qt::NoFocus); - QString txtFlyMode(tr("FlyMode")); - ui->btnFlyMode->hide(); - ui->lbFlyImg->hide(); - ui->lbFlyImg->setStyleSheet("QLabel{background-image:url(:/res/x/fly-mode-off.svg);}"); - ui->lbFlyBG->hide(); - ui->lbFlyBG->setStyleSheet(btnOffQss); - - ui->btnAdvConf->setStyleSheet(leftBtnQss); - ui->btnAdvConf->setFocusPolicy(Qt::NoFocus); - QString txtAdvanced(tr("Advanced")); - //ui->lbBtnConfImg->setStyleSheet("QLabel{background-image:url(:/res/x/setup.png);}"); - ui->btnConfImg->setStyleSheet("QPushButton{background-image:url(:/res/x/setup.png);}"); - //ui->btnConfImg->setIcon(QIcon::fromTheme("settings-app-symbolic.svg", QIcon(":/res/x/setup.png")) ); -} - -// 初始化有线网列表 -void KylinNM::getInitLanSlist() -{ - const int BUF_SIZE = 1024; - char buf[BUF_SIZE]; - - FILE * p_file = NULL; - - p_file = popen("export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli -f type,device,name connection show", "r"); - if (!p_file) { - syslog(LOG_ERR, "Error occurred when popen cmd 'nmcli connection show'"); - qDebug()<<"Error occurred when popen cmd 'nmcli connection show"; - } - while (fgets(buf, BUF_SIZE, p_file) != NULL) { - QString strSlist = ""; - QString line(buf); - strSlist = line.trimmed(); - if (strSlist.indexOf("UUID") != -1 || strSlist.indexOf("NAME") != -1) { - oldLanSlist.append(strSlist); - } - if (strSlist.indexOf("802-3-ethernet") != -1 || strSlist.indexOf("ethernet") != -1) { - oldLanSlist.append(strSlist); - } - } - pclose(p_file); -} - -// 初始化网络 -void KylinNM::initNetwork() -{ - BackThread bt; - IFace iface = bt.execGetIface(); - - wname = iface.wname; - lwname = iface.wname; - lname = iface.lname; - llname = iface.lname; - - mwBandWidth = bt.execChkLanWidth(lname); - - // 开关状态 - qDebug()<<"==="; - qDebug()<<"state of network: '0' is connected, '1' is disconnected, '2' is net device switch off"; - syslog(LOG_DEBUG, "state of network: '0' is connected, '1' is disconnected, '2' is net device switch off"); - qDebug()<<"current network state: lan state ="<lbBtnNetBG->setStyleSheet(btnOnQss); - if (iface.wstate == 0 || iface.wstate == 1 || iface.wstate == 3) { - // ui->lbBtnWifiBG->setStyleSheet(btnBgOnQss); - //ui->lbBtnWifiBall->move(X_RIGHT_WIFI_BALL, Y_WIFI_BALL); - btnWireless->setSwitchStatus(true); - } else { - btnWireless->setSwitchStatus(false); - //ui->lbBtnWifiBG->setStyleSheet(btnBgOffQss); - //ui->lbBtnWifiBall->move(X_LEFT_WIFI_BALL, Y_WIFI_BALL); - } - - // 初始化网络列表 - if (iface.wstate != 2) { - if (iface.wstate == 0) { - connWifiDone(3); - } else { - if (iface.lstate == 0) { - connLanDone(3); - } - } - on_btnWifiList_clicked(); - - ui->btnNetList->setStyleSheet("QPushButton{border:0px solid rgba(255,255,255,0);background-color:rgba(255,255,255,0);}"); - ui->btnWifiList->setStyleSheet("QPushButton{border:none;}"); - } else { - objKyDBus->setWifiSwitchState(false); //通知控制面板wifi未开启 - if (iface.lstate != 2) { - if (iface.lstate == 0) { - connLanDone(3); - } - onBtnNetListClicked(); - - ui->btnNetList->setStyleSheet("QPushButton{border:0px solid rgba(255,255,255,0);background-color:rgba(255,255,255,0);}"); - ui->btnWifiList->setStyleSheet("QPushButton{border:none;}"); - } else { - /*没看懂这段断开连接是什么意思,暂时关闭这段操作,会导致页面卡顿、某些情景还会自动断开网络 -// BackThread *m_bt = new BackThread(); -// m_bt->execGetIface(); - -// m_bt->disConnLanOrWifi("ethernet"); -// sleep(1); -// m_bt->disConnLanOrWifi("ethernet"); -// sleep(1); -// m_bt->disConnLanOrWifi("ethernet"); - -// m_bt->deleteLater(); - */ - - char *chr = "nmcli networking on"; - Utils::m_system(chr); - } - } - //第一次加载时,加载完lan列表会继续加载WIFI列表,先加载lan后加载WIFI是为了保证在加载WIFI时打开的计时器不会被直接关闭 - onBtnNetListClicked(); - //平板上默认展示wifi界面 -// on_btnWifiList_clicked(); -} - -// 初始化定时器 -void KylinNM::initTimer() -{ - //循环检测wifi列表的变化,可用于更新wifi列表 - checkWifiListChanged = new QTimer(this); - checkWifiListChanged->setTimerType(Qt::PreciseTimer); - QObject::connect(checkWifiListChanged, SIGNAL(timeout()), this, SLOT(on_checkWifiListChanged())); - checkWifiListChanged->start(7000); - - //网线插入时定时执行 - wiredCableUpTimer = new QTimer(this); - wiredCableUpTimer->setTimerType(Qt::PreciseTimer); - QObject::connect(wiredCableUpTimer, SIGNAL(timeout()), this, SLOT(onCarrierUpHandle())); - - //网线拔出时定时执行 - wiredCableDownTimer = new QTimer(this); - wiredCableDownTimer->setTimerType(Qt::PreciseTimer); - QObject::connect(wiredCableDownTimer, SIGNAL(timeout()), this, SLOT(onCarrierDownHandle())); - - //定时处理异常网络,即当点击Lan列表按钮时,若lstate=2,但任然有有线网连接的情况 - deleteLanTimer = new QTimer(this); - deleteLanTimer->setTimerType(Qt::PreciseTimer); - QObject::connect(deleteLanTimer, SIGNAL(timeout()), this, SLOT(onDeleteLan())); - - //定时获取网速 - setNetSpeed = new QTimer(this); - setNetSpeed->setTimerType(Qt::PreciseTimer); -//YYF QObject::connect(setNetSpeed, SIGNAL(timeout()), this, SLOT(on_setNetSpeed())); - setNetSpeed->start(3000); -} - - -/////////////////////////////////////////////////////////////////////////////// -// 任务栏托盘管理、托盘图标处理 - -void KylinNM::createTrayIcon() -{ - trayIcon = new QSystemTrayIcon(); - - trayIconMenu = new QMenu(); - - mShowWindow = new QAction(tr("Show KylinNM"),this); - mAdvConf = new QAction(tr("Advanced"),this); - mAdvConf->setIcon(QIcon::fromTheme("document-page-setup", QIcon(":/res/x/setup.png")) ); - - trayIconMenu->addAction(mShowWindow); - //trayIconMenu->addSeparator(); - trayIconMenu->addAction(mAdvConf); - //trayIconMenu->setAttribute(Qt::WA_TranslucentBackground);//设置窗口背景透明 - //trayIconMenu->setWindowOpacity(0.8); - trayIcon->setContextMenu(trayIconMenu); - - // 初始化托盘所有Icon - iconLanOnline = QIcon::fromTheme("network-wired-symbolic"); - iconLanOffline = QIcon::fromTheme("network-wired-offline-symbolic"); - iconWifiFull = QIcon::fromTheme("network-wireless-signal-excellent-symbolic"); - iconWifiHigh = QIcon::fromTheme("network-wireless-signal-good-symbolic"); - iconWifiMedium = QIcon::fromTheme("network-wireless-signal-ok"); - iconWifiLow = QIcon::fromTheme("network-wireless-signal-low"); - - loadIcons.append(QIcon::fromTheme("kylin-network-1")); - loadIcons.append(QIcon::fromTheme("kylin-network-2")); - loadIcons.append(QIcon::fromTheme("kylin-network-3")); - loadIcons.append(QIcon::fromTheme("kylin-network-4")); - loadIcons.append(QIcon::fromTheme("kylin-network-5")); - loadIcons.append(QIcon::fromTheme("kylin-network-6")); - loadIcons.append(QIcon::fromTheme("kylin-network-7")); - loadIcons.append(QIcon::fromTheme("kylin-network-8")); - loadIcons.append(QIcon::fromTheme("kylin-network-9")); - loadIcons.append(QIcon::fromTheme("kylin-network-10")); - loadIcons.append(QIcon::fromTheme("kylin-network-11")); - loadIcons.append(QIcon::fromTheme("kylin-network-12")); - - iconTimer = new QTimer(this); - connect(iconTimer, SIGNAL(timeout()), this, SLOT(iconStep())); - - setTrayIcon(iconLanOnline); -} - -void KylinNM::iconStep() -{ - if (currentIconIndex < 0) { - currentIconIndex = 11; - } - setTrayIcon(loadIcons.at(currentIconIndex)); - currentIconIndex --; -} - -void KylinNM::setTrayIcon(QIcon icon) -{ - trayIcon->setIcon(icon); -} - -void KylinNM::setTrayLoading(bool isLoading) -{ - if (isLoading) { - currentIconIndex = 11; - iconTimer->start(60); - } else { - iconTimer->stop(); - } -} - -void KylinNM::updateNetList() -{ - QString strTrans; - strTrans = QString::number(1, 10, 2); - //QString sty = "#centralWidget{background:rgba(19,19,20," + strTrans + ");}"; //YYF - QString sty = "#centralWidget{background:rgba(255,255,255," + strTrans + ");}"; - ui->centralWidget->setStyleSheet(sty); - - this->showNormal(); - if (is_btnNetList_clicked == 1) { - onBtnNetListClicked(0); - } - is_stop_check_net_state = 1; - if (is_btnWifiList_clicked == 1) { - BackThread loop_bt; - IFace loop_iface = loop_bt.execGetIface(); - - if (loop_iface.wstate != 2) { - is_update_wifi_list = 1; - this->ksnm->execGetWifiList(); //更新wifi列表 - } - } - is_stop_check_net_state = 0; -} - -void KylinNM::updateWifiList() -{ - //每次展示都要显示无线 - on_btnWifiList_clicked(); -} - -void KylinNM::iconActivated(QSystemTrayIcon::ActivationReason reason) -{ - switch (reason) { - case QSystemTrayIcon::Trigger: - case QSystemTrayIcon::MiddleClick: - - handleIconClicked(); - - if (this->isHidden()) { - QString strTrans; - strTrans = QString::number(1, 10, 2); - //QString sty = "#centralWidget{background:rgba(19,19,20," + strTrans + ");}"; //YYF - QString sty = "#centralWidget{background:rgba(255,255,255," + strTrans + ");}"; - ui->centralWidget->setStyleSheet(sty); - - this->showNormal(); - if (is_btnNetList_clicked == 1) { - onBtnNetListClicked(0); - } - is_stop_check_net_state = 1; - if (is_btnWifiList_clicked == 1) { - BackThread loop_bt; - IFace loop_iface = loop_bt.execGetIface(); - - if (loop_iface.wstate != 2) { - is_update_wifi_list = 1; - this->ksnm->execGetWifiList(); //更新wifi列表 - } - } - is_stop_check_net_state = 0; - } else { - //this->hide(); - } - break; - case QSystemTrayIcon::DoubleClick: - //this->hide(); - break; - case QSystemTrayIcon::Context: - //右键点击托盘图标弹出菜单 - showTrayIconMenu(); - break; - default: - break; - } -} - -void KylinNM::handleIconClicked() -{ - tabletStyle(); - if(isTabletStyle)//平板桌面模式 - { - //在屏幕中央显示 - QRect availableGeometry = qApp->primaryScreen()->availableGeometry(); - this->move((availableGeometry.width() - this->width())/2, (availableGeometry.height() - this->height())/2); - return; - } - - QRect availableGeometry = qApp->primaryScreen()->availableGeometry(); - QRect screenGeometry = qApp->primaryScreen()->geometry(); - - QDesktopWidget* desktopWidget = QApplication::desktop(); - QRect deskMainRect = desktopWidget->availableGeometry(0);//获取可用桌面大小 - QRect screenMainRect = desktopWidget->screenGeometry(0);//获取设备屏幕大小 - QRect deskDupRect = desktopWidget->availableGeometry(1);//获取可用桌面大小 - QRect screenDupRect = desktopWidget->screenGeometry(1);//获取设备屏幕大小 - - int n = objKyDBus->getTaskBarPos("position"); - int m = objKyDBus->getTaskBarHeight("height"); - int d = 2; //窗口边沿到任务栏距离 - - if (screenGeometry.width() == availableGeometry.width() && screenGeometry.height() == availableGeometry.height()) { - if (n == 0) { - //任务栏在下侧 - this->move(availableGeometry.x() + availableGeometry.width() - this->width(), screenMainRect.y() + availableGeometry.height() - this->height() - m - d); - } else if(n == 1) { - //任务栏在上侧 - this->move(availableGeometry.x() + availableGeometry.width() - this->width(), screenMainRect.y() + screenGeometry.height() - availableGeometry.height() + m + d); - } else if (n == 2) { - //任务栏在左侧 - if (screenGeometry.x() == 0) {//主屏在左侧 - this->move(m + d, screenMainRect.y() + screenMainRect.height() - this->height()); - } else {//主屏在右侧 - this->move(screenMainRect.x() + m + d, screenMainRect.y() + screenMainRect.height() - this->height()); - } - } else if (n == 3) { - //任务栏在右侧 - if (screenGeometry.x() == 0) {//主屏在左侧 - this->move(screenMainRect.width() - this->width() - m - d, screenMainRect.y() + screenMainRect.height() - this->height()); - } else {//主屏在右侧 - this->move(screenMainRect.x() + screenMainRect.width() - this->width() - m - d, screenMainRect.y() + screenMainRect.height() - this->height()); - } - } - } else if(screenGeometry.width() == availableGeometry.width() ) { - if (trayIcon->geometry().y() > availableGeometry.height()/2) { - //任务栏在下侧 - this->move(availableGeometry.x() + availableGeometry.width() - this->width(), screenMainRect.y() + availableGeometry.height() - this->height() - d); - } else { - //任务栏在上侧 - this->move(availableGeometry.x() + availableGeometry.width() - this->width(), screenMainRect.y() + screenGeometry.height() - availableGeometry.height() + d); - } - } else if (screenGeometry.height() == availableGeometry.height()) { - if (trayIcon->geometry().x() > availableGeometry.width()/2) { - //任务栏在右侧 - this->move(availableGeometry.x() + availableGeometry.width() - this->width() - d, screenMainRect.y() + screenGeometry.height() - this->height()); - } else { - //任务栏在左侧 - this->move(screenGeometry.width() - availableGeometry.width() + d, screenMainRect.y() + screenGeometry.height() - this->height()); - } - } -} - -void KylinNM::showTrayIconMenu() -{ - QRect availableGeometry = qApp->primaryScreen()->availableGeometry(); - QRect screenGeometry = qApp->primaryScreen()->geometry(); - - QDesktopWidget* desktopWidget = QApplication::desktop(); - // QRect deskMainRect = desktopWidget->availableGeometry(0);//获取可用桌面大小 - QRect screenMainRect = desktopWidget->screenGeometry(0);//获取设备屏幕大小 - // QRect deskDupRect = desktopWidget->availableGeometry(1);//获取可用桌面大小 - QRect screenDupRect = desktopWidget->screenGeometry(1);//获取设备屏幕大小 - - QPoint cursorPoint = QCursor::pos();//返回相对显示器的全局坐标 - int cursor_x = cursorPoint.x(); - int cursor_y = cursorPoint.y(); - - int n = objKyDBus->getTaskBarPos("position"); - int m = objKyDBus->getTaskBarHeight("height"); - int d = 0; //窗口边沿到任务栏距离 - int s = 80; //窗口边沿到屏幕边沿距离 - - if (screenGeometry.width() == availableGeometry.width() && screenGeometry.height() == availableGeometry.height()) { - if (n == 0) { //任务栏在下侧 - trayIconMenu->move(availableGeometry.x() + cursor_x - trayIconMenu->width()/2, screenMainRect.y() + availableGeometry.height() - trayIconMenu->height() - m - d); - } else if(n == 1) { //任务栏在上侧 - trayIconMenu->move(availableGeometry.x() + cursor_x - trayIconMenu->width()/2, screenMainRect.y() + screenGeometry.height() - availableGeometry.height() + m + d); - } else if (n == 2) { //任务栏在左侧 - trayIconMenu->move(m + d, cursor_y - trayIconMenu->height()/2); - //if (screenGeometry.x() == 0){//主屏在左侧 - // trayIconMenu->move(screenGeometry.width() - availableGeometry.width() + m + d, screenMainRect.y() + screenMainRect.height() - trayIconMenu->height() - s); - //}else{//主屏在右侧 - // trayIconMenu->move(screenGeometry.width() - availableGeometry.width() + m + d,screenDupRect.y() + screenDupRect.height() - trayIconMenu->height() - s); - //} - } else if (n == 3) { //任务栏在右侧 - trayIconMenu->move(screenMainRect.width() - trayIconMenu->width() - m - d, cursor_y - trayIconMenu->height()/2); - //if (screenGeometry.x() == 0){//主屏在左侧 - // trayIconMenu->move(screenMainRect.width() + screenDupRect.width() - trayIconMenu->width() - m - d, screenDupRect.y() + screenDupRect.height() - trayIconMenu->height() - s); - //}else{//主屏在右侧 - // trayIconMenu->move(availableGeometry.x() + availableGeometry.width() - trayIconMenu->width() - m - d, screenMainRect.y() + screenMainRect.height() - trayIconMenu->height() - s); - //} - } - } else if(screenGeometry.width() == availableGeometry.width() ) { - if (trayIcon->geometry().y() > availableGeometry.height()/2) { //任务栏在下侧 - trayIconMenu->move(availableGeometry.x() + cursor_x - trayIconMenu->width()/2, screenMainRect.y() + availableGeometry.height() - trayIconMenu->height() - d); - } else { //任务栏在上侧 - trayIconMenu->move(availableGeometry.x() + cursor_x - trayIconMenu->width()/2, screenMainRect.y() + screenGeometry.height() - availableGeometry.height() + d); - } - } else if (screenGeometry.height() == availableGeometry.height()) { - if (trayIcon->geometry().x() > availableGeometry.width()/2) { //任务栏在右侧 - trayIconMenu->move(availableGeometry.x() + availableGeometry.width() - trayIconMenu->width() - d, cursor_y - trayIconMenu->height()/2); - } else { //任务栏在左侧 - trayIconMenu->move(screenGeometry.width() - availableGeometry.width() + d, cursor_y - trayIconMenu->height()/2); - } - } -} - -void KylinNM::on_showWindowAction() -{ - handleIconClicked(); - this->showNormal(); -} - - -/////////////////////////////////////////////////////////////////////////////// -//加载动画,获取当前连接的网络和状态并设置图标 - -void KylinNM::startLoading() -{ -// loading->startLoading(); - setTrayLoading(true); -} - -void KylinNM::stopLoading() -{ - loading->stopLoading(); - setTrayLoading(false); - getActiveInfo(); -} - -void KylinNM::on_checkOverTime() -{ - QString cmd = "kill -9 $(pidof nmcli)"; //杀掉当前正在进行的有关nmcli命令的进程 - int status = system(cmd.toUtf8().data()); - if (status != 0) { - qDebug()<<"execute 'kill -9 $(pidof nmcli)' in function 'on_checkOverTime' failed"; - syslog(LOG_ERR, "execute 'kill -9 $(pidof nmcli)' in function 'on_checkOverTime' failed"); - } - this->stopLoading(); //超时停止等待动画 - is_stop_check_net_state = 0; -} - -void KylinNM::getActiveInfo() -{ - QString actLanName = "--"; - QString actWifiName = "--"; - - activecon *act = NULL; - int count = 0; - kylin_network_get_activecon_info(&act, &count); - if(!act) - return ; - int index = 0; - while (act && index < count) { - if (QString(act[index].type) == "ethernet" || QString(act[index].type) == "802-3-ethernet") { - actLanName = QString(act[index].con_name); - } - if (QString(act[index].type) == "wifi" || QString(act[index].type) == "802-11-wireless") { - actWifiName = QString(act[index].con_name); - } - index ++; - } - if (act) { - free(act); - } - - //ukui3.0中获取currentActWifiSignalLv的值 - if (activeWifiSignalLv > 75) { - currentActWifiSignalLv = 1; - } else if(activeWifiSignalLv > 55 && activeWifiSignalLv <= 75) { - currentActWifiSignalLv = 2; - } else if(activeWifiSignalLv > 35 && activeWifiSignalLv <= 55) { - currentActWifiSignalLv = 3; - } else if( activeWifiSignalLv <= 35) { - currentActWifiSignalLv = 4; - } - - // 设置图标 - if (actLanName != "--") { - setTrayIcon(iconLanOnline); - } else if (actWifiName != "--") { - switch (currentActWifiSignalLv) { - case 1: - setTrayIcon(iconWifiFull); - break; - case 2: - setTrayIcon(iconWifiHigh); - break; - case 3: - setTrayIcon(iconWifiMedium); - break; - case 4: - setTrayIcon(iconWifiLow); - break; - default: - setTrayIcon(iconWifiFull); - break; - } - } else { - setTrayIcon(iconLanOffline); - } -} - - -/////////////////////////////////////////////////////////////////////////////// -//网络设备管理 - -//网线插拔处理,由kylin-dbus-interface.cpp调用 -void KylinNM::onPhysicalCarrierChanged(bool flag) -{ - this->startLoading(); - if (flag) { - is_stop_check_net_state = 1; - qDebug()<<"插入了有线网的网线"; - syslog(LOG_DEBUG,"wired physical cable is already plug in"); - wiredCableUpTimer->start(2000); - } else { - qDebug()<<"拔出了有线网的网线"; - syslog(LOG_DEBUG,"wired physical cable is already plug out"); - - BackThread bt; - IFace iface = bt.execGetIface(); - if (iface.lstate != 0) { - is_stop_check_net_state = 1; - wiredCableDownTimer->start(2000); - } - } -} - -void KylinNM::onCarrierUpHandle() -{ - wiredCableUpTimer->stop(); - //BackThread *up_bt = new BackThread(); - //up_bt->disConnLanOrWifi("ethernet"); - //sleep(1); - //up_bt->disConnLanOrWifi("ethernet"); - //sleep(1); - //up_bt->disConnLanOrWifi("ethernet"); - //up_bt->deleteLater(); - - this->stopLoading(); - onBtnNetListClicked(1); - is_stop_check_net_state = 0; -} - -void KylinNM::onCarrierDownHandle() -{ - wiredCableDownTimer->stop(); - this->stopLoading(); - onBtnNetListClicked(0); - is_stop_check_net_state = 0; -} - -void KylinNM::onDeleteLan() -{ - deleteLanTimer->stop(); - BackThread btn_bt; - btn_bt.disConnLanOrWifi("ethernet"); - sleep(1); - btn_bt.disConnLanOrWifi("ethernet"); - sleep(1); - btn_bt.disConnLanOrWifi("ethernet"); - - this->stopLoading(); - onBtnNetListClicked(0); - is_stop_check_net_state = 0; -} - -//无线网卡插拔处理 -void KylinNM::onNetworkDeviceAdded(QDBusObjectPath objPath) -{ - //仅处理无线网卡插入情况 - objKyDBus->isWirelessCardOn = false; - objKyDBus->getObjectPath(); - - if (objKyDBus->wirelessPath.path() == objPath.path()) { //证明添加的是无线网卡 - is_wireless_adapter_ready = 0; - if (objKyDBus->isWirelessCardOn) { - syslog(LOG_DEBUG,"wireless device is already plug in"); - qDebug()<<"wireless device is already plug in"; - is_wireless_adapter_ready = 1; - onBtnWifiClicked(4); - } - } -} - -void KylinNM::onNetworkDeviceRemoved(QDBusObjectPath objPath) -{ - //仅处理无线网卡拔出情况 - if (objKyDBus->wirelessPath.path() == objPath.path()) { - objKyDBus->isWirelessCardOn = false; - objKyDBus->getObjectPath(); //检查是不是还有无线网卡 - if (!objKyDBus->isWirelessCardOn) { - syslog(LOG_DEBUG,"wireless device is already plug out"); - qDebug()<<"wireless device is already plug out"; - is_wireless_adapter_ready = 0; - onBtnWifiClicked(5); - } else { - syslog(LOG_DEBUG,"wireless device is already plug out, but one more wireless exist"); - qDebug()<<"wireless device is already plug out, but one more wireless exist"; - } - } -} - -void KylinNM::checkIsWirelessDeviceOn() -{ - //启动时判断是否有无线网卡 - //KylinDBus kDBus3; - if (objKyDBus->isWirelessCardOn) { - is_wireless_adapter_ready = 1; - } else { - is_wireless_adapter_ready = 0; - } -} - -void KylinNM::getLanBandWidth() -{ - BackThread bt; - IFace iface = bt.execGetIface(); - - lname = iface.lname; - - mwBandWidth = bt.execChkLanWidth(lname); -} - -//检测网络设备状态 -bool KylinNM::checkLanOn() -{ - BackThread bt; - IFace iface = bt.execGetIface(); - - if (iface.lstate == 2) { - return false; - } else { - return true; - } -} - -bool KylinNM::checkWlOn() -{ - BackThread bt; - IFace iface = bt.execGetIface(); - - bool ret = true; - if (iface.wstate == 2) { - ret = false; - } - return ret; -} - - -/////////////////////////////////////////////////////////////////////////////// -//有线网与无线网按钮响应 - -void KylinNM::on_btnNet_clicked() -{ - if (checkLanOn()) { - QThread *t = new QThread(); - BackThread *bt = new BackThread(); - bt->moveToThread(t); - connect(t, SIGNAL(finished()), t, SLOT(deleteLater())); - connect(t, SIGNAL(started()), bt, SLOT(execDisNet())); - connect(bt, SIGNAL(disNetDone()), this, SLOT(disNetDone())); - connect(bt, SIGNAL(btFinish()), t, SLOT(quit())); - t->start(); - - } else { - is_stop_check_net_state = 1; - QThread *t = new QThread(); - BackThread *bt = new BackThread(); - bt->moveToThread(t); - connect(t, SIGNAL(finished()), t, SLOT(deleteLater())); - connect(t, SIGNAL(started()), bt, SLOT(execEnNet())); - connect(bt, SIGNAL(enNetDone()), this, SLOT(enNetDone())); - connect(bt, SIGNAL(btFinish()), t, SLOT(quit())); - t->start(); - } - - this->startLoading(); -} - -void KylinNM::onBtnWifiClicked(int flag) -{ - qDebug()<<"Value of flag passed into function 'onBtnWifiClicked' is: "<setWifiSwitchState(false); - lbTopWifiList->hide(); -// btnAddNet->hide(); - - QThread *t = new QThread(); - BackThread *bt = new BackThread(); - bt->moveToThread(t); - btnWireless->setSwitchStatus(true); - connect(t, SIGNAL(finished()), t, SLOT(deleteLater())); - connect(t, SIGNAL(started()), bt, SLOT(execDisWifi())); - connect(bt, SIGNAL(disWifiDone()), this, SLOT(disWifiDone())); - connect(bt, SIGNAL(btFinish()), t, SLOT(quit())); - - /**锁屏多线程信号槽消息传递异常,暂时以定时器方式检测,需调整pam验证的fork方式 - */ - QTimer *timer = new QTimer(this); - connect(timer, &QTimer::timeout, this, [=]{ - if(m_is_reflashWifiUi) { - disWifiDone(); - mutexIsReflashWifi.lock(); - m_is_reflashWifiUi = false; - mutexIsReflashWifi.unlock(); - timer->stop(); - } - }); - timer->start(200); - QTimer::singleShot(8*1000, this, [=]{ - if(timer->isActive()) - timer->stop(); - }); - /**锁屏多线程信号槽消息传递异常,暂时以定时器方式检测,需调整pam验证的fork方式 - */ - t->start(); - this->startLoading(); - } - } else { - if (is_fly_mode_on == 0) { - //on_btnWifiList_clicked(); - is_stop_check_net_state = 1; - qDebug() << "aaa222"; - objKyDBus->setWifiCardState(true); - objKyDBus->setWifiSwitchState(true); - //lbTopWifiList->show(); - //btnAddNet->show(); - - QThread *t = new QThread(); - BackThread *bt = new BackThread(); - bt->moveToThread(t); - btnWireless->setSwitchStatus(true); - connect(t, SIGNAL(finished()), t, SLOT(deleteLater())); - connect(t, SIGNAL(started()), bt, SLOT(execEnWifi())); - connect(bt, SIGNAL(enWifiDone()), this, SLOT(enWifiDone())); - connect(bt, SIGNAL(launchLanDone()), this, SLOT(launchLanDone())); - connect(bt, SIGNAL(btFinish()), t, SLOT(quit())); - - /**锁屏多线程信号槽消息传递异常,暂时以定时器方式检测,需调整pam验证的fork方式 - */ - QTimer *timer = new QTimer(this); - connect(timer, &QTimer::timeout, this, [=]{ - if(m_is_reflashWifiUi) { - enWifiDone(); - mutexIsReflashWifi.lock(); - m_is_reflashWifiUi = false; - mutexIsReflashWifi.unlock(); - timer->stop(); - } - }); - timer->start(200); - QTimer::singleShot(8*1000, this, [=]{ - if(timer->isActive()) - timer->stop(); - }); - t->start(); - this->startLoading(); - } - } - } else if(flag == 2) { - if (is_fly_mode_on == 0) { - //on_btnWifiList_clicked(); - is_stop_check_net_state = 1; - lbTopWifiList->show(); -// btnAddNet->show(); - - QThread *t = new QThread(); - BackThread *bt = new BackThread(); - btnWireless->setSwitchStatus(true); - bt->moveToThread(t); - connect(t, SIGNAL(finished()), t, SLOT(deleteLater())); - connect(t, SIGNAL(started()), bt, SLOT(execEnWifi())); - connect(bt, SIGNAL(enWifiDone()), this, SLOT(enWifiDone())); - connect(bt, SIGNAL(launchLanDone()), this, SLOT(launchLanDone())); - connect(bt, SIGNAL(btFinish()), t, SLOT(quit())); - t->start(); - this->startLoading(); - } - } else if(flag == 3) { - is_stop_check_net_state = 1; - lbTopWifiList->hide(); -// btnAddNet->hide(); - - QThread *t = new QThread(); - BackThread *bt = new BackThread(); - btnWireless->setSwitchStatus(true); - bt->moveToThread(t); - connect(t, SIGNAL(finished()), t, SLOT(deleteLater())); - connect(t, SIGNAL(started()), bt, SLOT(execDisWifi())); - connect(bt, SIGNAL(disWifiDone()), this, SLOT(disWifiDone())); - connect(bt, SIGNAL(btFinish()), t, SLOT(quit())); - t->start(); - this->startLoading(); - } else { - qDebug()<<"receive an invalid value in function onBtnWifiClicked"; - syslog(LOG_DEBUG, "receive an invalid value in function onBtnWifiClicked"); - } - - } else { - lbTopWifiList->hide(); -// btnAddNet->hide(); - - if (flag == 0) { - objKyDBus->setWifiSwitchState(false); - objKyDBus->setWifiCardState(false); - } - - QString txt(tr("No wireless card detected")); //未检测到无线网卡 - objKyDBus->showDesktopNotify(txt); - qDebug()<<"No wireless card detected"; - syslog(LOG_DEBUG, "No wireless card detected"); - //QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';notify-send '" + txt + "' -t 3800"; - //int status = system(cmd.toUtf8().data()); - //if (status != 0){ syslog(LOG_ERR, "execute 'notify-send' in function 'onBtnWifiClicked' failed");} - - disWifiStateKeep(); - } - -} - -void KylinNM::onBtnNetListClicked(int flag) -{ - this->is_btnNetList_clicked = 1; - this->is_btnWifiList_clicked = 0; - - ui->lbNetListBG->setStyleSheet(btnOnQss); - ui->lbWifiListBG->setStyleSheet(btnOffQss); - - BackThread bt; - IFace iface = bt.execGetIface(); - - lbLoadDown->show(); - lbLoadUp->show(); - lbLoadDownImg->show(); - lbLoadUpImg->show(); - if (iface.lstate != 0) { - lbLoadDown->hide(); - lbLoadUp->hide(); - lbLoadDownImg->hide(); - lbLoadUpImg->hide(); - } - - lbNoItemTip->hide(); - - ui->lbNetwork->setText(tr("Activated LAN")); - btnWireless->hide(); - //ui->lbBtnWifiBG->hide(); - //ui->lbBtnWifiBall->hide(); - - // 强行设置为打开 - if (flag == 1) { - this->startLoading(); - this->ksnm->execGetLanList(); - this->scrollAreal->show(); - this->topLanListWidget->show(); - this->scrollAreaw->hide(); - this->topWifiListWidget->hide(); - on_btnNetList_pressed(); - return; - } - - if (iface.lstate != 2) { - this->startLoading(); - this->ksnm->execGetLanList(); - } else { - this->startLoading(); - this->ksnm->execGetLanList(); - } - -// btnCreateNet->show(); -// btnAddNet->hide(); - this->scrollAreal->show(); - this->topLanListWidget->show(); - this->scrollAreaw->hide(); - this->topWifiListWidget->hide(); - on_btnNetList_pressed(); - //YYF - ui->lbNetListImg->setStyleSheet("QLabel{border-image:url(:/res/l/pb-network-online.png);background-position:center;background-repeat:no-repeat;}"); - ui->lbWifiListImg->setStyleSheet("QLabel{border-image:url(:/res/x/pb-wifi-n.png);background-position:center;background-repeat:no-repeat;}"); - lbNetListText->setStyleSheet("QLabel{color:rgba(47, 179, 232, 1);background-color:transparent;}"); - lbWifiListText->setStyleSheet("QLabel{color:rgba(38, 38, 38, 0.75);background-color:transparent;}"); -} - -// 当点击wifi标题的时候执行 -void KylinNM::on_btnWifiList_clicked() -{ - this->is_btnWifiList_clicked = 1; - this->is_btnNetList_clicked = 0; - - BackThread bt; - IFace iface = bt.execGetIface(); - - lbLoadDown->show(); - lbLoadUp->show(); - lbLoadDownImg->show(); - lbLoadUpImg->show(); - if (iface.wstate != 0) { - lbLoadDown->hide(); - lbLoadUp->hide(); - lbLoadDownImg->hide(); - lbLoadUpImg->hide(); - } - - ui->lbNetListBG->setStyleSheet(btnOffQss); - ui->lbWifiListBG->setStyleSheet(btnOnQss); - - lbNoItemTip->hide(); - ui->lbNetwork->setText(tr("Activated WLAN")); - btnWireless->show(); - //ui->lbBtnWifiBG->show(); - //ui->lbBtnWifiBall->show(); - if (iface.wstate == 0 || iface.wstate == 1 || iface.wstate == 3) { - //ui->lbBtnWifiBG->setStyleSheet(btnBgOnQss); - //ui->lbBtnWifiBall->move(X_RIGHT_WIFI_BALL, Y_WIFI_BALL); - btnWireless->setSwitchStatus(true); - } else { - //ui->lbBtnWifiBG->setStyleSheet(btnBgOffQss); - //ui->lbBtnWifiBall->move(X_LEFT_WIFI_BALL, Y_WIFI_BALL); - btnWireless->setSwitchStatus(false); - } - - if (iface.wstate != 2) { - //ui->lbBtnWifiBG->setStyleSheet(btnBgOnQss); - //ui->lbBtnWifiBall->move(X_RIGHT_WIFI_BALL, Y_WIFI_BALL); - btnWireless->setSwitchStatus(true); - lbTopWifiList->show(); -// btnAddNet->show(); - - this->startLoading(); - this->ksnm->execGetWifiList(); - } else { - //ui->lbBtnWifiBG->setStyleSheet(btnBgOffQss); - //ui->lbBtnWifiBall->move(X_LEFT_WIFI_BALL, Y_WIFI_BALL); - btnWireless->setSwitchStatus(false); - delete topWifiListWidget; //清空top列表 - createTopWifiUI(); //创建顶部无线网item - lbTopWifiList->hide(); - ui->lbNetListImg->setStyleSheet("QLabel{border-image:url(:/res/l/pb-network-offline.png);background-position:center;background-repeat:no-repeat;}"); - ui->lbWifiListImg->setStyleSheet("QLabel{border-image:url(:/res/x/pb-wifi-y.png);background-position:center;background-repeat:no-repeat;}"); - lbNetListText->setStyleSheet("QLabel{color:rgba(38, 38, 38, 0.75);background-color:transparent;}"); - lbWifiListText->setStyleSheet("QLabel{color:rgba(47, 179, 232, 1);background-color:transparent;}"); - - // 清空wifi列表 - wifiListWidget = new QWidget(scrollAreaw); - wifiListWidget->resize(W_LIST_WIDGET+173*isTabletStyle, H_WIFI_ITEM_BIG_EXTEND); - scrollAreaw->setWidget(wifiListWidget); - scrollAreaw->move(W_LEFT_AREA, Y_SCROLL_AREA); - - - // 当前连接的wifi - OneConnForm *ccf = new OneConnForm(topWifiListWidget, this, confForm, ksnm); - ccf->setName(tr("Not connected"));//"当前未连接任何 Wifi" - ccf->setSignal("0", "--"); - ccf->setRate("0"); - ccf->setConnedString(1, tr("Disconnected"), "");//"未连接" - ccf->isConnected = false; - ccf->setTopItem(false); - ccf->setAct(true); - ccf->move(L_VERTICAL_LINE_TO_ITEM, 0); - ccf->show(); - - this->lanListWidget->hide(); - this->wifiListWidget->show(); - - getActiveInfo(); - is_stop_check_net_state = 0; - } - -// btnCreateNet->hide(); -// if(is_wireless_adapter_ready == 1) -// { -// btnAddNet->show(); -// } - - this->scrollAreal->hide(); - this->topLanListWidget->hide(); - this->scrollAreaw->show(); - this->topWifiListWidget->show(); - on_btnWifiList_pressed(); -} - -void KylinNM::on_btnNetList_pressed() -{ - //ui->btnNetList->setStyleSheet("#btnNetList{font-size:12px;color:white;border:1px solid rgba(255,255,255,0.1);border:1px solid rgba(255,255,255,0.5);background:transparent;background-color:rgba(255,255,255,0.1);}"); - //ui->btnWifiList->setStyleSheet("#btnWifiList{font-size:12px;color:white;border:1px solid rgba(255,255,255,0.1);background:transparent;background-color:rgba(0,0,0,0.2);}" - // "#btnWifiList:Pressed{border:1px solid rgba(255,255,255,0.5);background:transparent;background-color:rgba(255,255,255,0.1);}"); -} - -void KylinNM::on_btnWifiList_pressed() -{ - //YYF 复制自tabletStyle方法,后期考虑合并 - ui->btnNetList->setStyleSheet(btnOffQss); - ui->btnWifiList->setStyleSheet(btnOnQss); - ui->lbNetListBG->setStyleSheet(btnOffQss); - ui->lbWifiListBG->setStyleSheet(btnOnQss); - ui->lbNetListImg->setStyleSheet("QLabel{border-image:url(:/res/l/pb-network-offline.png);background-position:center;background-repeat:no-repeat;}"); - ui->lbWifiListImg->setStyleSheet("QLabel{border-image:url(:/res/x/pb-wifi-y.png);background-position:center;background-repeat:no-repeat;}"); - lbNetListText->setStyleSheet("QLabel{color:rgba(38, 38, 38, 0.75);background-color:transparent;}"); - lbWifiListText->setStyleSheet("QLabel{color:rgba(47, 179, 232, 1);background-color:transparent;}"); - - //ui->btnWifiList->setStyleSheet("#btnWifiList{font-size:12px;color:white;border:1px solid rgba(255,255,255,0.1);border:1px solid rgba(255,255,255,0.5);background:transparent;background-color:rgba(255,255,255,0.1);}"); - //ui->btnNetList->setStyleSheet("#btnNetList{font-size:12px;color:white;border:1px solid rgba(255,255,255,0.1);background:transparent;background-color:rgba(0,0,0,0.2);}" - // "#btnNetList:Pressed{border:1px solid rgba(255,255,255,0.5);background:transparent;background-color:rgba(255,255,255,0.1);}"); -} - - -/////////////////////////////////////////////////////////////////////////////// -//网络列表加载与更新 - -// 获取lan列表回调 -void KylinNM::getLanListDone(QStringList slist) -{ - if (this->ksnm->isUseOldLanSlist) { - slist = oldLanSlist; - this->ksnm->isUseOldLanSlist = false; - } - - delete topLanListWidget; // 清空top列表 - - createTopLanUI(); //创建顶部有线网item - - // 清空lan列表 - lanListWidget = new QWidget(scrollAreal); - lanListWidget->resize(W_LIST_WIDGET, H_NORMAL_ITEM + H_LAN_ITEM_EXTEND); - scrollAreal->setWidget(lanListWidget); - scrollAreal->move(W_LEFT_AREA, Y_SCROLL_AREA); - lanNameList.clear(); - - // 获取当前连接的lan name - QString actLanName = "--"; - activecon *act = NULL; - int count = 0; - kylin_network_get_activecon_info(&act, &count); - int index = 0; - while (act && index < count) { - if (QString(act[index].type) == "ethernet" || QString(act[index].type) == "802-3-ethernet") { - actLanName = QString(act[index].con_name); - break; - } - index ++; - } - if (act) { - free(act); - } - - // 若当前lan name为"--",设置OneConnForm - OneLancForm *ccf = new OneLancForm(topLanListWidget, this, confForm, ksnm); - topLanListWidget->resize(W_TOP_LIST_WIDGET+173*isTabletStyle, H_NORMAL_ITEM + H_GAP_UP + X_ITEM); - ccf->setFixedWidth(414+194*isTabletStyle); - if (actLanName == "--") { - ccf->setName(tr("Not connected"), "");//"当前未连接任何 以太网" - ccf->setIcon(false); - ccf->setConnedString(1, tr("Disconnected"));//"未连接" - ccf->isConnected = false; - ifLanConnected = false; - lbLoadDown->hide(); - lbLoadUp->hide(); - lbLoadDownImg->hide(); - lbLoadUpImg->hide(); - ccf->setTopItem(false); - ccf->setAct(false); - } - else - ccf->setAct(true); - ccf->move(L_VERTICAL_LINE_TO_ITEM, 0); - ccf->show(); - // 填充可用网络列表 - QString headLine; - if(slist.count() > 0) - headLine = slist.at(0); - else - headLine = ""; - int indexDevice, indexName; - headLine = headLine.trimmed(); - - bool isChineseExist = headLine.contains(QRegExp("[\\x4e00-\\x9fa5]+")); - if (isChineseExist) { - indexDevice = headLine.indexOf("设备") + 2; - indexName = headLine.indexOf("名称") + 4; - } else { - indexDevice = headLine.indexOf("DEVICE"); - indexName = headLine.indexOf("NAME"); - } - - QString order = "a"; //为避免同名情况,这里给每一个有线网设定一个唯一标志 - for(int i = 1, j = 0; i < slist.size(); i ++) { - QString line = slist.at(i); - QString ltype = line.mid(0, indexDevice).trimmed(); - QString nname = line.mid(indexName).trimmed(); - - if (ltype != "802-11-wireless" && ltype != "wifi" && ltype != "" && ltype != "--") { - lanNameList.append(nname); - // 当前连接的lan - if (nname == actLanName) { - //objKyDBus->getConnectNetIp(); - actLanName = "--"; - if (mwBandWidth == "Unknown!") { getLanBandWidth(); } - - connect(ccf, SIGNAL(selectedOneLanForm(QString, QString)), this, SLOT(oneTopLanFormSelected(QString, QString))); - connect(ccf, SIGNAL(disconnActiveLan()), this, SLOT(activeLanDisconn())); - ccf->setName(nname, nname + order); - ccf->setIcon(true); - ccf->setLanInfo(objKyDBus->dbusActiveLanIpv4, objKyDBus->dbusActiveLanIpv6, mwBandWidth, objKyDBus->dbusLanMac); - ccf->setConnedString(1, tr("NetOn,"));//"已连接" - ccf->isConnected = true; - ifLanConnected = true; - lbLoadDown->show(); - lbLoadUp->show(); - lbLoadDownImg->show(); - lbLoadUpImg->show(); - ccf->setTopItem(false); - currSelNetName = ""; - objKyDBus->dbusActiveLanIpv4 = ""; - objKyDBus->dbusActiveLanIpv6 = ""; - syslog(LOG_DEBUG, "already insert an active lannet in the top of lan list"); - } else { - objKyDBus->getLanIp(nname); - OneLancForm *ocf = new OneLancForm(lanListWidget, this, confForm, ksnm); -// connect(ocf, SIGNAL(selectedOneLanForm(QString, QString)), this, SLOT(oneLanFormSelected(QString, QString))); - ocf->setName(nname, nname + order); - ocf->setIcon(false); //YYF - ocf->setLine(true); - ocf->setLanInfo(objKyDBus->dbusLanIpv4, objKyDBus->dbusLanIpv6, tr("Disconnected"), objKyDBus->dbusLanMac); - ocf->setConnedString(0, tr("Disconnected"));//"未连接" - ocf->move(L_VERTICAL_LINE_TO_ITEM, j * H_NORMAL_ITEM); - lanListWidget->resize(W_LIST_WIDGET+194*isTabletStyle, lanListWidget->height() + H_NORMAL_ITEM); - ocf->setFixedWidth(W_LIST_WIDGET+194*isTabletStyle); //YYF - ocf->setSelected(false, false); - ocf->show(); - j ++; - } - order += "a"; - } - } - - QList itemList = lanListWidget->findChildren(); - int n = itemList.size(); - if (n >= 1) { - OneLancForm *lastItem = itemList.at(n-1); - lastItem->setLine(false); - lbNoItemTip->hide(); - } else { - if (!ifLanConnected) { - lbNoItemTip->hide(); -// lbTopLanList->hide(); -// btnCreateNet->hide(); - } else { - lbNoItemTip->show(); - lbNoItemTip->setText(tr("No Other Wired Network Scheme")); - } - } - - this->lanListWidget->show(); - this->topLanListWidget->show(); - this->wifiListWidget->hide(); - this->topWifiListWidget->hide(); - - this->stopLoading(); - oldLanSlist = slist; - is_stop_check_net_state = 0; -} - -// 获取wifi列表回调 -void KylinNM::getWifiListDone(QStringList slist) -{ - qDebug()<<"debug: oldWifiSlist.size()="< 1) { - actWifiuuid = currConnWifiBSsidUuid.at(0); - for (int i=1; isetName(tr("Not connected"));//"当前未连接任何 Wifi" - ccf->setSignal("0", "--"); - activeWifiSignalLv = 0; - ccf->setConnedString(1, tr("Disconnected"), "");//"未连接" - ccf->isConnected = false; - ifWLanConnected = false; - lbLoadDown->hide(); - lbLoadUp->hide(); - lbLoadDownImg->hide(); - lbLoadUpImg->hide(); - ccf->setTopItem(false); - } - ccf->setAct(true); - ccf->move(L_VERTICAL_LINE_TO_ITEM, 0); - ccf->show(); - // 填充可用网络列表 - QString headLine = slist.at(0); - int indexSignal,indexSecu, indexFreq, indexBSsid, indexName, indexPath; - headLine = headLine.trimmed(); - - bool isChineseExist = headLine.contains(QRegExp("[\\x4e00-\\x9fa5]+")); - if (isChineseExist) { - indexSignal = headLine.indexOf("SIGNAL"); - indexSecu = headLine.indexOf("安全性"); - indexFreq = headLine.indexOf("频率") + 4; - indexBSsid = headLine.indexOf("BSSID") + 6; - indexName = indexBSsid + 19; - indexPath = headLine.indexOf("DBUS-PATH"); - } else { - indexSignal = headLine.indexOf("SIGNAL"); - indexSecu = headLine.indexOf("SECURITY"); - indexFreq = headLine.indexOf("FREQ"); - indexBSsid = headLine.indexOf("BSSID"); - indexName = indexBSsid + 19; - indexPath = headLine.indexOf("DBUS-PATH"); - } - QStringList wnames; - int count = 0; - QString actWifiBssid = " "; - for (int i = 1; i < slist.size(); i ++) { - QString line = slist.at(i); - QString wbssid = line.mid(indexBSsid, 17).trimmed(); - QString wname = line.mid(indexName, indexPath - indexName).trimmed(); - - if (actWifiBssidList.contains(wbssid)) { - actWifiName = wname; - } - if ("*" == line.mid(0,indexSignal).trimmed()){ - actWifiBssid = wbssid; - } - } - - if (actWifiBssidList.size()==1 && actWifiBssidList.at(0)=="--") { - actWifiId = actWifiName; - actWifiName = "--"; - } - for (int i = 1, j = 0; i < slist.size(); i ++) { - QString line = slist.at(i); - //QString wsignal = line.mid(0, indexRate).trimmed(); - //QString wrate = line.mid(indexRate, indexSecu - indexRate).trimmed(); - QString wsignal = line.mid(indexSignal, 3).trimmed(); - QString wsecu = line.mid(indexSecu, indexFreq - indexSecu).trimmed(); - QString wbssid = line.mid(indexBSsid, 17).trimmed(); - QString wname = line.mid(indexName, indexPath - indexName).trimmed(); - - bool isContinue = false; - foreach (QString addName, wnames) { - // 重复的网络名称,跳过不处理 - if(addName == wname){ isContinue = true; } - } - if(isContinue){ continue; } - - if (actWifiName != "--" && actWifiName == wname) { - if (!actWifiBssidList.contains(wbssid)) { - continue; //若当前热点ssid名称和已经连接的wifi的ssid名称相同,但bssid不同,则跳过 - } - } - - if (wname != "" && wname != "--") { - // 当前连接的wifi - if (wname == actWifiName) { - connect(ccf, SIGNAL(selectedOneWifiForm(QString,int)), this, SLOT(oneTopWifiFormSelected(QString,int))); - connect(ccf, SIGNAL(disconnActiveWifi()), this, SLOT(activeWifiDisconn())); - QString path = line.mid(indexPath).trimmed(); - QString m_name = this->objKyDBus->getWifiSsid(QString("/org/freedesktop/NetworkManager/AccessPoint/%1").arg(path.mid(path.lastIndexOf("/") + 1))); -// ccf->setName(m_name); - if (m_name.isEmpty() || m_name == "") { - ccf->setName(wname); - } else { - ccf->setName(m_name); - } - //ccf->setRate(wrate); - int signal = wsignal.toInt() + 11; - ccf->setSignal(QString::number(signal), wsecu); - activeWifiSignalLv = wsignal.toInt(); - objKyDBus->getWifiMac(wname); - ccf->setWifiInfo(wsecu, wsignal, objKyDBus->dbusWifiMac); - ccf->setConnedString(1, tr("NetOn,"), wsecu);//"已连接" - ccf->isConnected = true; - ifWLanConnected = true; - lbLoadDown->show(); - lbLoadUp->show(); - lbLoadDownImg->show(); - lbLoadUpImg->show(); - ccf->setTopItem(false); - currSelNetName = ""; - - syslog(LOG_DEBUG, "already insert an active wifi in the top of wifi list"); - } else { - wifiListWidget->resize(W_LIST_WIDGET+173*isTabletStyle, wifiListWidget->height() + H_NORMAL_ITEM); - - OneConnForm *ocf = new OneConnForm(wifiListWidget, this, confForm, ksnm); - connect(ocf, SIGNAL(selectedOneWifiForm(QString,int)), this, SLOT(oneWifiFormSelected(QString,int))); - connect(ocf,&OneConnForm::onLineEditClicked, this, &KylinNM::onLineEditClicked); - QString path = line.mid(indexPath).trimmed(); - QString m_name = this->objKyDBus->getWifiSsid(QString("/org/freedesktop/NetworkManager/AccessPoint/%1").arg(path.mid(path.lastIndexOf("/") + 1))); -// ocf->setName(m_name); - if (m_name.isEmpty() || m_name == "") { - ocf->setName(wname); - } else { - ocf->setName(m_name); - } - //ocf->setRate(wrate); - ocf->setLine(true); - ocf->setSignal(wsignal, wsecu); - objKyDBus->getWifiMac(wname); - ocf->setWifiInfo(wsecu, wsignal, objKyDBus->dbusWifiMac); - ocf->setConnedString(0, tr("Disconnected"), wsecu); - ocf->move(L_VERTICAL_LINE_TO_ITEM, j * H_NORMAL_ITEM); - ocf->setSelected(false, false); - ocf->show(); - - j ++; - count ++; - } - - wnames.append(wname); - } - } - QList itemList = wifiListWidget->findChildren(); - int n = itemList.size(); - if (n >= 1) { - OneConnForm *lastItem = itemList.at(n-1); - lastItem->setLine(false); - lbNoItemTip->hide(); - } else { - if (ifWLanConnected) { - lbNoItemTip->show(); - lbNoItemTip->setText(tr("No Other Wireless Network Scheme")); - } else { - lbNoItemTip->hide(); - lbTopWifiList->hide(); -// btnAddNet->hide(); - } - } - - this->lanListWidget->hide(); - this->topLanListWidget->hide(); - this->wifiListWidget->show(); - this->topWifiListWidget->show(); - - this->stopLoading(); - is_stop_check_net_state = 0; - - actWifiBssidList.clear(); - wnames.clear(); -} - -// 更新wifi列表 -void KylinNM::updateWifiListDone(QStringList slist) -{ - if (this->ksnm->isExecutingGetLanList){ return;} - - //获取表头信息 - QString lastHeadLine = oldWifiSlist.at(0); - //int lastIndexName = lastHeadLine.indexOf("SSID"); - int lastIndexName, lastIndexPath; - lastHeadLine = lastHeadLine.trimmed(); - bool isChineseInIt = lastHeadLine.contains(QRegExp("[\\x4e00-\\x9fa5]+")); - if (isChineseInIt) { - lastIndexName = lastHeadLine.indexOf("BSSID") + 6 + 19; - } else { - lastIndexName = lastHeadLine.indexOf("BSSID") + 19; - } - lastIndexPath = lastHeadLine.indexOf("DBUS-PATH"); - - QString headLine = slist.at(0); - int indexSecu, indexFreq, indexBSsid, indexName, indexPath; - headLine = headLine.trimmed(); - bool isChineseExist = headLine.contains(QRegExp("[\\x4e00-\\x9fa5]+")); - if (isChineseExist) { - indexSecu = headLine.indexOf("安全性"); - indexFreq = headLine.indexOf("频率") + 4; - indexBSsid = headLine.indexOf("BSSID") + 6; - //indexName = headLine.indexOf("SSID") + 6; - indexName = indexBSsid + 19; - indexPath = headLine.indexOf("DBUS-PATH"); - } else { - indexSecu = headLine.indexOf("SECURITY"); - indexFreq = headLine.indexOf("FREQ"); - indexBSsid = headLine.indexOf("BSSID"); - indexName = indexBSsid + 19; - indexPath = headLine.indexOf("DBUS-PATH"); - } - - //列表中去除已经减少的wifi - for (int i=1; i wifiList = wifiListWidget->findChildren(); - for (int pos = 0; pos < wifiList.size(); pos ++) { - OneConnForm *ocf = wifiList.at(pos); - if (ocf->getName() == lastWname) { - if (ocf->isActive == true){break; - } else { - delete ocf; - //删除元素下面的的所有元素上移 - for (int after_pos = pos+1; after_pos < wifiList.size(); after_pos ++) { - OneConnForm *after_ocf = wifiList.at(after_pos); - if (lastWname == currSelNetName) {after_ocf->move(L_VERTICAL_LINE_TO_ITEM, after_ocf->y() - H_NORMAL_ITEM - H_WIFI_ITEM_BIG_EXTEND);} - else {after_ocf->move(L_VERTICAL_LINE_TO_ITEM, after_ocf->y() - H_NORMAL_ITEM);} - } - wifiListWidget->resize(W_LIST_WIDGET+173*isTabletStyle, wifiListWidget->height() - H_NORMAL_ITEM); - break; - } - } - } - - } //end if (j == slist.size()-1) - } //end (int j=1; j wifiList = wifiListWidget->findChildren(); - int n = wifiList.size(); - int posY = 0; - if (n >= 1) { - OneConnForm *lastOcf = wifiList.at(n-1); - lastOcf->setLine(true); - if (lastOcf->wifiName == currSelNetName) { - posY = lastOcf->y()+H_NORMAL_ITEM + H_WIFI_ITEM_BIG_EXTEND; - } else { - posY = lastOcf->y()+H_NORMAL_ITEM; - } - } - - wifiListWidget->resize(W_LIST_WIDGET+173*isTabletStyle, wifiListWidget->height() + H_NORMAL_ITEM); - OneConnForm *addItem = new OneConnForm(wifiListWidget, this, confForm, ksnm); - connect(addItem, SIGNAL(selectedOneWifiForm(QString,int)), this, SLOT(oneWifiFormSelected(QString,int))); - connect(addItem,&OneConnForm::onLineEditClicked, this, &KylinNM::onLineEditClicked); - QString path = slist.at(i).mid(indexPath).trimmed(); - QString m_name = this->objKyDBus->getWifiSsid(QString("/org/freedesktop/NetworkManager/AccessPoint/%1").arg(path.mid(path.lastIndexOf("/") + 1))); - if (m_name.isEmpty() || m_name == "") { - addItem->setName(wname); - } else { - addItem->setName(m_name); - } - addItem->setLine(false); - addItem->setSignal(wsignal, wsecu); - objKyDBus->getWifiMac(wname); - addItem->setWifiInfo(wsecu, wsignal, objKyDBus->dbusWifiMac); - addItem->setConnedString(0, tr("Disconnected"), wsecu);//"未连接" - addItem->move(L_VERTICAL_LINE_TO_ITEM, posY); - addItem->setSelected(false, false); - addItem->show(); - - count += 1; - } - } - } - - this->lanListWidget->hide(); - this->topLanListWidget->hide(); - this->wifiListWidget->show(); - this->topWifiListWidget->show(); - this->stopLoading(); -} - - -/////////////////////////////////////////////////////////////////////////////// -//主窗口其他按钮点击响应 - -void KylinNM::on_btnAdvConf_clicked() -{ - QProcess *qprocess = new QProcess(this); - qprocess->start("nm-connection-editor &"); - // int status = system("nm-connection-editor &"); - // if (status != 0){ syslog(LOG_ERR, "execute 'nm-connection-editor &' in function 'on_btnAdvConf_clicked' failed");} -} - -void KylinNM::on_btnAdvConf_pressed() -{ - //ui->lbBtnConfBG->setStyleSheet(btnOnQss); -} - -void KylinNM::on_btnAdvConf_released() -{ - //ui->lbBtnConfBG->setStyleSheet(btnOffQss); -} - -void KylinNM::on_btnFlyMode_clicked() -{ - if (is_fly_mode_on == 0) { - ui->lbFlyImg->setStyleSheet("QLabel{background-image:url(:/res/x/fly-mode-on.svg);}"); - ui->lbFlyBG->setStyleSheet(btnOnQss); - is_fly_mode_on = 1; - - onBtnWifiClicked(0); - on_btnWifiList_clicked(); - } else { - ui->lbFlyImg->setStyleSheet("QLabel{background-image:url(:/res/x/fly-mode-off.svg);}"); - ui->lbFlyBG->setStyleSheet(btnOffQss); - is_fly_mode_on = 0; - } -} - -void KylinNM::on_btnHotspot_clicked() -{ - if (is_wireless_adapter_ready == 1) { - if (is_hot_sopt_on == 0) { - ui->lbHotImg->setStyleSheet("QLabel{background-image:url(:/res/x/hot-spot-on.svg);}"); - ui->lbHotBG->setStyleSheet(btnOnQss); - is_hot_sopt_on = 1; - - QApplication::setQuitOnLastWindowClosed(false); - DlgHotspotCreate *hotCreate = new DlgHotspotCreate(objKyDBus->dbusWiFiCardName); - connect(hotCreate,SIGNAL(updateHotspotList()),this,SLOT(on_btnWifiList_clicked() )); - connect(hotCreate,SIGNAL(btnHotspotState()),this,SLOT(on_btnHotspotState() )); - hotCreate->show(); - } else { - on_btnHotspotState(); - - BackThread objBT; - objBT.disConnLanOrWifi("wifi"); - - sleep(2); - on_btnWifiList_clicked(); - } - } -} - -void KylinNM::onBtnAddNetClicked() -{ -// QApplication::setQuitOnLastWindowClosed(false); - DlgConnHidWifi *connHidWifi = new DlgConnHidWifi(0, this, this->parentWidget()); - connect(connHidWifi, SIGNAL(reSetWifiList() ), this, SLOT(on_btnWifiList_clicked()) ); - connHidWifi->show(); -} - -void KylinNM::onBtnCreateNetClicked() -{ - QPoint pos = QCursor::pos(); - QRect primaryGeometry; - for (QScreen *screen : qApp->screens()) { - if (screen->geometry().contains(pos)) { - primaryGeometry = screen->geometry(); - } - } - - if (primaryGeometry.isEmpty()) { - primaryGeometry = qApp->primaryScreen()->geometry(); - } - - ConfForm *m_cf = new ConfForm(this->parentWidget()); - m_cf->setMainWindow(this); - m_cf->cbTypeChanged(3); - m_cf->move(primaryGeometry.width() / 2 - m_cf->width() / 2, primaryGeometry.height() / 2 - m_cf->height() / 2); - m_cf->show(); -} - - -/////////////////////////////////////////////////////////////////////////////// -//处理窗口变化、网络状态变化 - -//列表中item的扩展与收缩 -void KylinNM::oneLanFormSelected(QString lanName, QString uniqueName) -{ - QList topLanList = topLanListWidget->findChildren(); - QList lanList = lanListWidget->findChildren(); - - //**********************先处理下方列表********************// - // 下方所有元素回到原位 - for (int i = 0, j = 0;i < lanList.size(); i ++) { - OneLancForm *ocf = lanList.at(i); - if (ocf->isActive == true) { - ocf->move(L_VERTICAL_LINE_TO_ITEM, 0); - } - if (ocf->isActive == false) { - ocf->move(L_VERTICAL_LINE_TO_ITEM, j * H_NORMAL_ITEM); - j ++; - } - } - - //是否与上一次选中同一个网络框 - if (currSelNetName == uniqueName) { - // 缩小所有选项卡 - for (int i = 0;i < lanList.size(); i ++) { - OneLancForm *ocf = lanList.at(i); - if (ocf->uniqueName == uniqueName) { - ocf->setSelected(false, true); - } else { - ocf->setSelected(false, false); - } - } - - currSelNetName = ""; - } else { - int selectY = 0; - for (int i = 0;i < lanList.size(); i ++) { - OneLancForm *ocf = lanList.at(i); - if (ocf->uniqueName == uniqueName) { - selectY = ocf->y(); //获取选中item的y坐标 - break; - } - } - - // 选中元素下面的所有元素下移 H_LAN_ITEM_EXTEND - for (int i = 0;i < lanList.size(); i ++) { - OneLancForm *ocf = lanList.at(i); - if (ocf->y() > selectY) { - ocf->move(L_VERTICAL_LINE_TO_ITEM, ocf->y() + H_LAN_ITEM_EXTEND); - } - } - - for (int i = 0;i < lanList.size(); i ++) { - OneLancForm *ocf = lanList.at(i); - if (ocf->uniqueName == uniqueName) { - ocf->setSelected(true, false); - selectY = ocf->y(); - } else { - ocf->setSelected(false, false); - } - } - - currSelNetName = uniqueName; - } - - QList itemList = lanListWidget->findChildren(); - int n = itemList.size(); - if (n >= 1) { - OneLancForm *lastItem = itemList.at(n-1); - lastItem->setLine(false); - } - - //**********************处理上方列表-界面所有控件回原位********************// - topLanListWidget->resize(W_TOP_LIST_WIDGET, H_NORMAL_ITEM + H_GAP_UP + X_ITEM); // 顶部的item缩小 - lbTopLanList->move(X_MIDDLE_WORD, H_NORMAL_ITEM + H_GAP_UP); -// btnCreateNet->move(X_BTN_FUN, Y_BTN_FUN); - scrollAreal->move(W_LEFT_AREA, Y_SCROLL_AREA); - lbNoItemTip->move(this->width()/2 - W_NO_ITEM_TIP/2 + W_LEFT_AREA/2, this->height()/2); - - OneLancForm *ocf = topLanList.at(0); - ocf->setTopItem(false); -} -void KylinNM::oneTopLanFormSelected(QString lanName, QString uniqueName) -{ - currSelNetName = uniqueName; -} - -void KylinNM::oneWifiFormSelected(QString wifiName, int extendLength) -{ - QListtopWifiList = topWifiListWidget->findChildren(); - QList wifiList = wifiListWidget->findChildren(); - - //******************先处理下方列表****************// - // 下方所有元素回到原位 - for (int i = 0, j = 0;i < wifiList.size(); i ++) { - OneConnForm *ocf = wifiList.at(i); - if (ocf->isActive == true) { - ocf->move(L_VERTICAL_LINE_TO_ITEM, 0); - } - if (ocf->isActive == false) { - ocf->move(L_VERTICAL_LINE_TO_ITEM, j * H_NORMAL_ITEM); - j ++; - } - } - - //是否与上一次选中同一个网络框 - if (currSelNetName == wifiName) { - // 缩小所有选项卡 - for (int i = 0;i < wifiList.size(); i ++) { - OneConnForm *ocf = wifiList.at(i); - if (ocf->wifiName == wifiName) { - if (ocf->wifiName == hideWiFiConn) { - ocf->setHideItem(true, true); - } else { - ocf->setSelected(false, true); - } - } else { - if (ocf->wifiName == hideWiFiConn) { - ocf->setHideItem(true, true); - } else { - ocf->setSelected(false, false); - } - } - - } - currSelNetName = ""; - } else { - int selectY = 0; - for (int i = 0;i < wifiList.size(); i ++) { - OneConnForm *ocf = wifiList.at(i); - if (ocf->wifiName == wifiName) { - selectY = ocf->y(); //获取选中item的y坐标 - this->scrollAreaw->verticalScrollBar()->setValue(selectY); - break; - } - } - - // 选中元素下面的所有元素下移 H_WIFI_ITEM_BIG_EXTEND - for (int i = 0;i < wifiList.size(); i ++) { - OneConnForm *ocf = wifiList.at(i); - if (ocf->y() > selectY) { - ocf->move(L_VERTICAL_LINE_TO_ITEM, ocf->y() + extendLength); - } - } - - for (int i = 0;i < wifiList.size(); i ++) { - OneConnForm *ocf = wifiList.at(i); - if (ocf->wifiName == wifiName) { - if (ocf->wifiName == hideWiFiConn) { - ocf->setHideItem(true, true); - } else { - ocf->setSelected(true, false); - } - } else { - if (ocf->wifiName == hideWiFiConn) { - ocf->setHideItem(true, true); - } else { - ocf->setSelected(false, false); - } - } - } - - currSelNetName = wifiName; - } - - //最后一个item没有下划线 - QList itemList = wifiListWidget->findChildren(); - int n = itemList.size(); - if (n >= 1) { - OneConnForm *lastItem = itemList.at(n-1); - lastItem->setLine(false); - } - - //********************处理上方列表-界面所有控件回原位******************// - // 顶部的item缩小 - topWifiListWidget->resize(W_TOP_LIST_WIDGET+194*isTabletStyle, H_NORMAL_ITEM + H_GAP_UP + X_ITEM); - lbTopWifiList->move(X_MIDDLE_WORD, H_NORMAL_ITEM + H_GAP_UP); -// btnAddNet->move(X_BTN_FUN, Y_BTN_FUN); - scrollAreaw->move(W_LEFT_AREA, Y_SCROLL_AREA); - lbNoItemTip->move(this->width()/2 - W_NO_ITEM_TIP/2 + W_LEFT_AREA/2, this->height()/2); - - OneConnForm *ocf = topWifiList.at(0); - ocf->setTopItem(false); -} -void KylinNM::oneTopWifiFormSelected(QString wifiName, int extendLength) -{ - QListtopWifiList = topWifiListWidget->findChildren(); - QList wifiList = wifiListWidget->findChildren(); - - if (currSelNetName == wifiName) { - // 与上一次选中同一个网络框,缩小当前选项卡 - topWifiListWidget->resize(W_TOP_LIST_WIDGET+194*isTabletStyle, H_NORMAL_ITEM + H_GAP_UP + X_ITEM); - lbTopWifiList->move(X_MIDDLE_WORD, H_NORMAL_ITEM + H_GAP_UP); -// btnAddNet->move(X_BTN_FUN, Y_BTN_FUN); - scrollAreaw->move(W_LEFT_AREA, Y_SCROLL_AREA); - lbNoItemTip->move(this->width()/2 - W_NO_ITEM_TIP/2 + W_LEFT_AREA/2, this->height()/2); - - OneConnForm *ocf = topWifiList.at(0); - ocf->setTopItem(false); - - currSelNetName = ""; - } else { - // 没有与上一次选中同一个网络框,放大当前选项卡 - - for(int i = 0;i < wifiList.size(); i ++) { - // 所有元素回到原位 - OneConnForm *ocf = wifiList.at(i); - ocf->setSelected(false, false); - ocf->move(L_VERTICAL_LINE_TO_ITEM, i * H_NORMAL_ITEM); - } - - topWifiListWidget->resize(W_TOP_LIST_WIDGET+194*isTabletStyle, H_NORMAL_ITEM + H_WIFI_ITEM_BIG_EXTEND + H_GAP_UP + X_ITEM); - lbTopWifiList->move(X_MIDDLE_WORD, H_NORMAL_ITEM + H_WIFI_ITEM_BIG_EXTEND + H_GAP_UP); -// btnAddNet->move(X_BTN_FUN, Y_BTN_FUN + H_WIFI_ITEM_BIG_EXTEND); - scrollAreaw->move(W_LEFT_AREA, Y_SCROLL_AREA + H_WIFI_ITEM_BIG_EXTEND); - lbNoItemTip->move(this->width()/2 - W_NO_ITEM_TIP/2 + W_LEFT_AREA/2, this->height()/2 + 65); - - OneConnForm *ocf = topWifiList.at(0); - ocf->setTopItem(true); - - currSelNetName = wifiName; - } -} - -//断开网络处理 -void KylinNM::activeLanDisconn() -{ - syslog(LOG_DEBUG, "Wired net is disconnected"); - - QString txt(tr("Wired net is disconnected")); - objKyDBus->showDesktopNotify(txt); - //QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';notify-send '" + txt + "...' -t 3800"; - //int status1 = system(cmd.toUtf8().data()); - //if (status1 != 0){ syslog(LOG_ERR, "execute 'notify-send' in function 'execConnWifiPWD' failed");} - - currSelNetName = ""; - //this->startLoading(); - emit this->waitLanStop(); - this->ksnm->execGetLanList(); - QTimer::singleShot(200, this, &KylinNM::onConnectChanged); -} - -void KylinNM::activeWifiDisconn() -{ - QThread *tt = new QThread(); - BackThread *btt = new BackThread(); - btt->moveToThread(tt); - connect(tt, SIGNAL(finished()), tt, SLOT(deleteLater())); - connect(this, SIGNAL(disConnSparedNet(QString)), btt, SLOT(disConnSparedNetSlot(QString)),Qt::DirectConnection); - connect(btt, SIGNAL(disFinish()), this, SLOT(activeGetWifiList()), Qt::DirectConnection); - connect(btt, SIGNAL(ttFinish()), tt, SLOT(quit()),Qt::DirectConnection); - - tt->start(); - activeStartLoading(); - QTimer::singleShot(200, this, &KylinNM::onConnectChanged); -} - -void KylinNM::reflashWifiUi() -{ - mutexIsReflashWifi.lock(); - m_is_reflashWifiUi = true; - mutexIsReflashWifi.unlock(); -} - -void KylinNM::activeStartLoading() -{ - syslog(LOG_DEBUG, "Wi-Fi is disconnected"); - emit this->disConnSparedNet("wifi"); -} -void KylinNM::activeGetWifiList() -{ - emit this->waitWifiStop(); - this->ksnm->execGetWifiList(); -} - -//网络开关处理,打开与关闭网络 -void KylinNM::enNetDone() -{ - BackThread bt; - mwBandWidth = bt.execChkLanWidth(lname); - - ui->lbBtnNetBG->setStyleSheet(btnOnQss); - - // 打开网络开关时如果Wifi开关是打开的,设置其样式 - if (checkWlOn()) { - btnWireless->setSwitchStatus(true); - //ui->lbBtnWifiBG->setStyleSheet(btnBgOnQss); - //ui->lbBtnWifiBall->move(X_RIGHT_WIFI_BALL, Y_WIFI_BALL); - } - - onBtnNetListClicked(1); - is_stop_check_net_state = 0; - - qDebug()<<"debug: already turn on the switch of lan network"; - syslog(LOG_DEBUG, "Already turn on the switch of lan network"); -} -void KylinNM::disNetDone() -{ - this->is_btnNetList_clicked = 1; - this->is_btnWifiList_clicked = 0; - - ui->lbNetListBG->setStyleSheet(btnOnQss); - ui->lbWifiListBG->setStyleSheet(btnOffQss); - - ui->lbNetwork->setText("Activated LAN"); - btnWireless->hide(); - //ui->lbBtnWifiBG->hide(); - //ui->lbBtnWifiBall->hide(); - - delete topLanListWidget; // 清空top列表 - createTopLanUI(); //创建顶部有线网item - - // 清空lan列表 - lanListWidget = new QWidget(scrollAreal); - lanListWidget->resize(W_LIST_WIDGET, H_NORMAL_ITEM + H_LAN_ITEM_EXTEND); - scrollAreal->setWidget(lanListWidget); - scrollAreal->move(W_LEFT_AREA, Y_SCROLL_AREA); - - // 当前连接的lan - OneLancForm *ccf = new OneLancForm(topLanListWidget, this, confForm, ksnm); - ccf->setName(tr("Not connected"), "");//"当前未连接任何 以太网" - ccf->setIcon(false); - ccf->setConnedString(1, tr("Disconnected"));//"未连接" - ccf->isConnected = false; - ccf->setTopItem(false); - ccf->setAct(true); - ccf->move(L_VERTICAL_LINE_TO_ITEM, 0); - ccf->show(); - - ui->lbBtnNetBG->setStyleSheet(btnOffQss); - - btnWireless->setSwitchStatus(false); - - this->lanListWidget->show(); - this->wifiListWidget->hide(); - this->scrollAreal->show(); - this->topLanListWidget->show(); - this->scrollAreaw->hide(); - this->topWifiListWidget->hide(); - - on_btnNetList_pressed(); - - qDebug()<<"debug: already turn off the switch of lan network"; - syslog(LOG_DEBUG, "Already turn off the switch of lan network"); - - this->stopLoading(); - QTimer::singleShot(200, this, &KylinNM::onConnectChanged); -} -void KylinNM::launchLanDone() -{ - ui->lbBtnNetBG->setStyleSheet(btnOnQss); -} - -void KylinNM::enWifiDone() -{ - //ui->lbBtnWifiBG->setStyleSheet(btnBgOnQss); - //ui->lbBtnWifiBall->move(X_RIGHT_WIFI_BALL, Y_WIFI_BALL); - - is_update_wifi_list = 0; - if (is_btnWifiList_clicked) { - this->ksnm->execGetWifiList(); - } else { - on_btnWifiList_clicked(); - } - - qDebug()<<"debug: already turn on the switch of wifi network"; - syslog(LOG_DEBUG, "Already turn on the switch of wifi network"); -} -void KylinNM::disWifiDone() -{ - disWifiDoneChangeUI(); - - on_btnWifiList_pressed(); - - qDebug()<<"debug: already turn off the switch of wifi network"; - syslog(LOG_DEBUG, "Already turn off the switch of wifi network"); - - this->stopLoading(); - is_stop_check_net_state = 0; - QTimer::singleShot(200, this, &KylinNM::onConnectChanged); -} -void KylinNM::disWifiStateKeep() -{ - if (this->is_btnNetList_clicked == 1) { - btnWireless->setSwitchStatus(false); - //ui->lbBtnWifiBG->setStyleSheet(btnBgOffQss); - //ui->lbBtnWifiBall->move(X_LEFT_WIFI_BALL, Y_WIFI_BALL); - } - if (this->is_btnWifiList_clicked== 1) { - disWifiDoneChangeUI(); - - // this->stopLoading(); - getActiveInfo(); - } -} -void KylinNM::disWifiDoneChangeUI() -{ - wifiListWidget = new QWidget(scrollAreaw); - wifiListWidget->resize(W_LIST_WIDGET+173*isTabletStyle, H_WIFI_ITEM_BIG_EXTEND); - scrollAreaw->setWidget(wifiListWidget); - scrollAreaw->move(W_LEFT_AREA, Y_SCROLL_AREA); - - lbTopWifiList->move(X_MIDDLE_WORD, H_NORMAL_ITEM + H_GAP_UP); -// btnAddNet->move(X_BTN_FUN, Y_BTN_FUN); - topWifiListWidget->resize(W_TOP_LIST_WIDGET+194*isTabletStyle, H_NORMAL_ITEM + H_GAP_UP + X_ITEM); - - QList wifiList = topWifiListWidget->findChildren(); - for (int i = 0; i < wifiList.size(); i ++) { - OneConnForm *ocf = wifiList.at(i); - if (ocf->isActive == true) { - ocf->setSelected(false, false); - ocf->setName(tr("Not connected"));//"当前未连接任何 Wifi" - ocf->setSignal("0", "--"); - ocf->setConnedString(1, tr("Disconnected"), "");//"未连接" - lbLoadDown->hide(); - lbLoadUp->hide(); - lbLoadDownImg->hide(); - lbLoadUpImg->hide(); - ocf->isConnected = false; - ocf->setTopItem(false); - disconnect(ocf, SIGNAL(selectedOneWifiForm(QString,int)), this, SLOT(oneTopWifiFormSelected(QString,int))); - } else { - ocf->deleteLater(); - } - } - - btnWireless->setSwitchStatus(false); - //ui->lbBtnWifiBG->setStyleSheet(btnBgOffQss); - //ui->lbBtnWifiBall->move(X_LEFT_WIFI_BALL, Y_WIFI_BALL); - - this->lanListWidget->hide(); - this->topLanListWidget->hide(); - this->wifiListWidget->show(); - this->topWifiListWidget->show(); - this->scrollAreal->hide(); - this->scrollAreaw->show(); -} - -void KylinNM::on_btnHotspotState() -{ - ui->lbHotImg->setStyleSheet("QLabel{background-image:url(:/res/x/hot-spot-off.svg);}"); - ui->lbHotBG->setStyleSheet(btnOffQss); - is_hot_sopt_on = 0; -} - -//处理外界对网络的连接与断开 -void KylinNM::onExternalConnectionChange(QString type) -{ - qDebug() <is_btnWifiList_clicked==1 && this->isVisible()) { - BackThread loop_bt; - IFace loop_iface = loop_bt.execGetIface(); - - if (loop_iface.wstate != 2) { - is_update_wifi_list = 1; - this->ksnm->execGetWifiList(); //更新wifi列表 - } - } -} - -void KylinNM::on_setNetSpeed() -{ - if (this->isVisible() && is_stop_check_net_state==0) { - if (is_btnWifiList_clicked == 1) { - if ( objNetSpeed->getCurrentDownloadRates(objKyDBus->dbusWiFiCardName.toUtf8().data(), &start_rcv_rates, &start_tx_rates) == -1) { - start_rcv_rates = end_rcv_rates; - } - } else if(is_btnNetList_clicked == 1) { - if ( objNetSpeed->getCurrentDownloadRates(objKyDBus->dbusLanCardName.toUtf8().data(), &start_rcv_rates, &start_tx_rates) == -1) { - start_tx_rates = end_tx_rates; - } - } - - long int delta_rcv = (start_rcv_rates - end_rcv_rates)/800; - long int delta_tx = (start_tx_rates - end_tx_rates)/8; - if (delta_rcv>=10000 || delta_rcv<0){delta_rcv = 0;} - if (delta_tx>=10000 || delta_tx<0){delta_tx = 0;} - - int rcv_num = delta_rcv/3; - int tx_num = delta_tx/3; - - QString str_rcv; - QString str_tx; - - if (rcv_num < 1000) { - str_rcv = QString::number(rcv_num) + "KB/s."; - } else { - int remainder; - if (rcv_num%1000 < 100) { - remainder = 0; - } else { - remainder = (rcv_num%1000)/100; - } - str_rcv = QString::number(rcv_num/1000) + "." + QString::number(remainder) + "MB/s."; - } - - if (tx_num < 1000) { - str_tx = QString::number(tx_num) + "KB/s"; - } else { - int remainder; - if (tx_num%1000 < 100) { - remainder = 0; - } else { - remainder = (tx_num%1000)/100; - } - str_tx = QString::number(tx_num/1000) + "." + QString::number(remainder) + "MB/s"; - } - - lbLoadDown->setText(str_rcv); - lbLoadUp->setText(str_tx); - - switch (str_rcv.size()) { - case 6: - lbLoadUp->move(X_ITEM + 187, Y_TOP_ITEM + 32); - lbLoadUpImg->move(X_ITEM + 170, Y_TOP_ITEM + 35); - break; - case 7: - lbLoadUp->move(X_ITEM + 194, Y_TOP_ITEM + 32); - lbLoadUpImg->move(X_ITEM + 176, Y_TOP_ITEM + 35); - break; - case 8: - lbLoadUp->move(X_ITEM + 199, Y_TOP_ITEM + 32); - lbLoadUpImg->move(X_ITEM + 186, Y_TOP_ITEM + 35); - break; - default: - break; - } - - end_rcv_rates = start_rcv_rates; - end_tx_rates = start_tx_rates; - } -} - -void KylinNM::connLanDone(int connFlag) -{ - emit this->waitLanStop(); //停止加载动画 - - // Lan连接结果,0点击连接成功 1失败 3开机启动网络工具时已经连接 - if (connFlag == 0) { - syslog(LOG_DEBUG, "Wired net already connected by clicking button"); - this->is_wired_line_ready = 1; - this->is_by_click_connect = 1; - this->ksnm->execGetLanList(); - - QString txt(tr("Conn Ethernet Success")); - objKyDBus->showDesktopNotify(txt); - //QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';notify-send '" + txt + "' -t 3800"; - //int status = system(cmd.toUtf8().data()); - //if (status != 0){ syslog(LOG_ERR, "execute 'notify-send' in function 'connLanDone' failed");} - } - - if (connFlag == 1) { - qDebug()<<"without net line connect to computer"; - this->is_wired_line_ready = 0; //without net line connect to computer - is_stop_check_net_state = 0; - - QString txt(tr("Conn Ethernet Fail")); - objKyDBus->showDesktopNotify(txt); - //QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';notify-send '" + txt + "' -t 3800"; - //int status = system(cmd.toUtf8().data()); - //if (status != 0){ syslog(LOG_ERR, "execute 'notify-send' in function 'connLanDone' failed");} - } - - if (connFlag == 3) { - syslog(LOG_DEBUG, "Launch kylin-nm, Lan already connected"); - this->is_wired_line_ready = 1; - } - - this->stopLoading(); - QTimer::singleShot(200, this, &KylinNM::onConnectChanged); -} - -void KylinNM::connWifiDone(int connFlag) -{ - emit this->waitWifiStop(); //停止加载动画 - // Wifi连接结果,0点击连接成功 1失败 2没有配置文件 3开机启动网络工具时已经连接 - if (connFlag == 0) { - syslog(LOG_DEBUG, "Wi-Fi already connected by clicking button"); - this->is_by_click_connect = 1; - this->ksnm->execGetWifiList(); - - QString txt(tr("Conn Wifi Success")); - objKyDBus->showDesktopNotify(txt); - //QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';notify-send '" + txt + "' -t 3800"; - //int status = system(cmd.toUtf8().data()); - //if (status != 0){ syslog(LOG_ERR, "execute 'notify-send' in function 'connWifiDone' failed");} - } else if (connFlag == 1) { - is_stop_check_net_state = 0; - is_connect_wifi_failed = 1; - - QString txt(tr("Confirm your Wi-Fi password or usable of wireless card")); - objKyDBus->showDesktopNotify(txt); - //QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';notify-send '" + txt + "...' -t 3800"; - //int status1 = system(cmd.toUtf8().data()); - //if (status1 != 0){ syslog(LOG_ERR, "execute 'notify-send' in function 'execConnWifiPWD' failed");} - } else if (connFlag == 3) { - syslog(LOG_DEBUG, "Launch kylin-nm, Wi-Fi already connected"); - } - QTimer::singleShot(200, this, &KylinNM::onConnectChanged); -} - -int KylinNM::getConnectStatus() -{ - int ret = -1; - QString actLanName = "--"; - QString actWifiName = "--"; - - activecon *act = NULL; - int count = 0; - kylin_network_get_activecon_info(&act, &count); - int index = 0; - if(!act){ - return -1; - } - while (act && index < count) { - if (QString(act[index].type) == "ethernet" || QString(act[index].type) == "802-3-ethernet") { - actLanName = QString(act[index].con_name); - } - if (QString(act[index].type) == "wifi" || QString(act[index].type) == "802-11-wireless") { - actWifiName = QString(act[index].con_name); - } - index ++; - } - if (act) { - free(act); - } - - //ukui3.0中获取currentActWifiSignalLv的值 - if (activeWifiSignalLv > 75) { - currentActWifiSignalLv = 1; - } else if(activeWifiSignalLv > 55 && activeWifiSignalLv <= 75) { - currentActWifiSignalLv = 2; - } else if(activeWifiSignalLv > 35 && activeWifiSignalLv <= 55) { - currentActWifiSignalLv = 3; - } else if( activeWifiSignalLv <= 35) { - currentActWifiSignalLv = 4; - } - - // 设置图标 - if (actLanName != "--") { - ret = 0; - } else if (actWifiName != "--") { - ret = 1; - } else { - ret = -1; - } - - return ret; -} diff --git a/KylinNM/src/kylinnm.h b/KylinNM/src/kylinnm.h deleted file mode 100644 index 3ed9ce6..0000000 --- a/KylinNM/src/kylinnm.h +++ /dev/null @@ -1,353 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "oneconnform.h" -#include "onelancform.h" -#include "hot-spot/dlghotspotcreate.h" -#include "wireless-security/dlgconnhidwifi.h" - -#define W_LEFT_AREA 16 -//#define W_VERTICAL_LINE 1 //左边竖线宽度 -#define W_RIGHT_AREA 438 //41 + 1 + 438 = 480 -#define L_VERTICAL_LINE_TO_ITEM 4 //竖线到item左侧的距离 - -#define X_LEFT_WIFI_BALL 416 //白色小球在左边 -#define X_RIGHT_WIFI_BALL 440 //白色小球在右边 -#define Y_WIFI_BALL 23 //白色小球y坐标 -#define X_ITEM 46 //item到窗口左侧的距离 41 + 1 + 4 = 46 -#define W_ITEM 424 - -#define Y_TOP_ITEM 100 //顶部item、topLanListWidget、topWifiListWidget的y坐标 -#define H_NORMAL_ITEM 56 -#define H_GAP_UP -5 -#define H_MIDDLE_WORD 46 //"显示‘可用网络列表’的label" -#define H_GAP_DOWN 5 //57 + 60 + 10 + 46 + 5 = 178 -#define X_MIDDLE_WORD 0 -#define W_MIDDLE_WORD 260 - -#define H_LAN_ITEM_EXTEND 102 //162 - 60 -#define H_WIFI_ITEM_BIG_EXTEND 90 //150 - 60 -#define H_WIFI_ITEM_SMALL_EXTEND 100 //156 - 56 - -#define Y_SCROLL_AREA 192//列表纵坐标 -#define W_SCROLL_AREA 414 -//#define H_SCROLL_AREA 200 -#define H_SCROLL_AREA H_NORMAL_ITEM*4 //平板中去掉了添加新网络按钮,设置为4倍的item,防止最后一栏被遮挡 - -#define W_TOP_LIST_WIDGET 435 -#define W_LIST_WIDGET 414 - -#define W_BTN_FUN 128 -#define H_BTN_FUN 24 - -#define X_BTN_FUN 36 -#define Y_BTN_FUN 400 //新建网络,加入网络按钮的宽高、x坐标、y坐标 - -#define W_NO_ITEM_TIP 220 -#define H_NO_ITEM_TIP 20 - -class OneConnForm; -class ConfForm; - -namespace Ui { -class KylinNM; -} - -class KylinNM : public QWidget -{ - Q_OBJECT - -public Q_SLOTS: - void onPhysicalCarrierChanged(bool flag); - void onCarrierUpHandle(); - void onCarrierDownHandle(); - void onDeleteLan(); - void onNetworkDeviceAdded(QDBusObjectPath objPath); - void onNetworkDeviceRemoved(QDBusObjectPath objPath); - void getLanBandWidth(); - - void onExternalConnectionChange(QString type); - void onExternalLanChange(); - void onExternalWifiChange(); - void onExternalWifiSwitchChange(bool wifiEnabled); - - void oneLanFormSelected(QString lanName, QString uniqueName); - void oneTopLanFormSelected(QString lanName, QString uniqueName); - void oneWifiFormSelected(QString wifiName, int extendLength); - void oneTopWifiFormSelected(QString wifiName, int extendLength); - - void on_btnHotspot_clicked(); - void on_btnHotspotState(); - - //flag =0或1为普通点击、2为收到打开信息、3为收到关闭信息、4为无线网卡插入、5为无线网卡拔出 - void onBtnWifiClicked(int flag = 0); - - void connLanDone(int connFlag); - void connWifiDone(int connFlag); - - void activeGetWifiList(); - -protected: - bool eventFilter(QObject *obj, QEvent *event); - -public: - explicit KylinNM(QWidget *parent = 0); - ~KylinNM(); - - void onSwipeGesture(int dx, int dy); - void editQssString(); - void createTopLanUI(); - void createTopWifiUI(); - void createOtherUI(); - void createListAreaUI(); - void createLeftAreaUI(); - - void startLoading(); - void stopLoading(); - - void setTrayIcon(QIcon icon); - void setTrayLoading(bool isLoading); - void getActiveInfo(); - - void initTimer(); - void checkIsWirelessDeviceOn(); - void updateNetList(); - void updateWifiList(); - - int getConnectStatus();//获取网络连接状态,返回值 -1 无连接; 0 有线连接; 1无线连接; 2有线和无线都已连接 - - QIcon iconLanOnline, iconLanOffline; - QIcon iconWifiFull, iconWifiHigh, iconWifiMedium, iconWifiLow; - QIcon iconConnecting; - QList loadIcons; - QString mwBandWidth; - KylinDBus *objKyDBus = nullptr; - NetworkSpeed *objNetSpeed = nullptr; - SwitchButton *btnWireless; - - QStringList lanNameList; - - //状态设置,0为假,1为真 - int is_update_wifi_list = 0; //是否是update wifi列表,而不是load wifi列表 - int is_by_click_connect = 0; //是否是通过点击连接按钮进行的连接 - int is_btnNetList_clicked = 1; //是否处于有线网界面 - int is_btnWifiList_clicked = 0; //是否处于无线网界面 - int is_wired_line_ready = 1; //主机是否连接网线 - int is_wireless_adapter_ready = 1; //主机是否插入无线网卡 - int is_keep_wifi_turn_on_state = 1; //是否要执行wifi开关变为打开样式 - int is_stop_check_net_state = 0; //是否要在进行其他操作时停止检查网络状态 - int is_connect_wifi_failed = 0; //刚才是否连接wifi失败 - int is_fly_mode_on = 0; //是否已经打开飞行模式 - int is_hot_sopt_on = 0; //是否已经打开热点 - - QString currSelNetName = ""; //当前ScrollArea中选中的网络名称 - int currSelNetNum = 0; //当前选中的item序号 - - bool isTabletStyle=false;//YYF 平板桌面模式 - - static void reflashWifiUi(); - static bool m_is_reflashWifiUi; -private: - void tabletStyle();//YYF 平板桌面模式特有设置 - - void checkSingle(); - void initNetwork(); - void createTrayIcon(); - void handleIconClicked(); - void showTrayIconMenu(); - bool checkLanOn(); - bool checkWlOn(); - void getLanList(); - void getWifiList(); - void getInitLanSlist(); - - Ui::KylinNM *ui; - - LoadingDiv *loading = nullptr; - - QDesktopWidget desktop; - KSimpleNM *ksnm = nullptr; - ConfForm *confForm = nullptr; - QWidget *topLanListWidget = nullptr; - QWidget *topWifiListWidget = nullptr; - QWidget *lanListWidget = nullptr; - QWidget *wifiListWidget = nullptr; - QWidget *optWifiWidget = nullptr; - - QLabel *lbLoadDown = nullptr; - QLabel *lbLoadDownImg = nullptr; - QLabel *lbLoadUp = nullptr; - QLabel *lbLoadUpImg = nullptr; - - QLabel *lbNoItemTip = nullptr; - bool ifLanConnected; - bool ifWLanConnected; - - QScrollArea *scrollAreal = nullptr; - QScrollArea *scrollAreaw = nullptr; - QLabel *lbTopLanList = nullptr; - QLabel *lbTopWifiList = nullptr; - QLabel *lbLanList = nullptr; - QLabel *lbWifiList = nullptr; - QPushButton *btnAddNet = nullptr; - QPushButton *btnCreateNet = nullptr; - - QSystemTrayIcon *trayIcon = nullptr; - QMenu *trayIconMenu = nullptr; - QAction *mShowWindow = nullptr; - QAction *mAdvConf = nullptr; - QWidget *widShowWindow = nullptr; - QWidget *widAdvConf = nullptr; - - QString lname, wname; // 以太网卡和无线网卡名称 - - QString btnOffQss, btnOnQss, btnBgOffQss, btnBgOnQss, btnBgHoverQss, btnBgLeaveQss; // 主界面按钮底色 - QString scrollBarQss, leftBtnQss, funcBtnQss; - - QStringList oldLanSlist; //上一次获取Lan列表 - - QStringList oldWifiSlist; //上一次获取wifi列表 - - //平板 - QLabel *lbNetListText=nullptr;//有线网络 - QLabel *lbWifiListText=nullptr;//无线网络 - - - //循环检测网络连接状态 - QTimer *iconTimer = nullptr; - QTimer *wiredCableUpTimer = nullptr; - QTimer *wiredCableDownTimer = nullptr; - QTimer *deleteLanTimer = nullptr; - QTimer *checkWifiListChanged = nullptr; - QTimer *checkIfLanConnect = nullptr; - QTimer *checkIfWifiConnect = nullptr; - QTimer *checkIfNetworkOn = nullptr; - QTimer *setNetSpeed = nullptr; - - int currentIconIndex; - int activeWifiSignalLv; - - long int start_rcv_rates = 0; //保存开始时的流量计数 - long int end_rcv_rates = 0; //保存结束时的流量计数 - long int start_tx_rates = 0; //保存开始时的流量计数 - long int end_tx_rates = 0; //保存结束时的流量计数 - - QString actWifissid = "--";//当前连接wifi的ssid - QString actWifiuuid = "--";//当前连接wifi的uuid - QStringList actWifiBssidList; //当前连接wifi的bssid - -private Q_SLOTS: - void iconActivated(QSystemTrayIcon::ActivationReason reason); - - bool nativeEvent(const QByteArray &eventType, void *message, long *result); - - void on_btnNet_clicked(); - void on_btnWifiList_clicked(); - void onBtnNetListClicked(int flag=0); - - void getLanListDone(QStringList slist); - void getWifiListDone(QStringList slist); - void loadWifiListDone(QStringList slist); - void updateWifiListDone(QStringList slist); - - void on_showWindowAction(); - void on_btnAdvConf_clicked(); - void on_btnNetList_pressed(); - void on_btnWifiList_pressed(); - - void activeLanDisconn(); - void activeWifiDisconn(); - void activeStartLoading(); - void on_btnAdvConf_pressed(); - void on_btnAdvConf_released(); - void on_checkWifiListChanged(); - void on_setNetSpeed(); - void on_checkOverTime(); - - // 后台回调 - void enNetDone(); - void disNetDone(); - void enWifiDone(); - void launchLanDone(); - void disWifiDone(); - void disWifiStateKeep(); - void disWifiDoneChangeUI(); - - void iconStep(); - void on_btnFlyMode_clicked(); - - void onBtnAddNetClicked(); - void onBtnCreateNetClicked(); - -Q_SIGNALS: - void disConnSparedNet(QString type); - - void waitWifiStop(); - void waitLanStop(); - void onLineEditClicked(); - void onConnectChanged(); // 网络连接变化时发送该信号 -}; - -#endif diff --git a/KylinNM/src/kylinnm.ui b/KylinNM/src/kylinnm.ui deleted file mode 100644 index a3aee92..0000000 --- a/KylinNM/src/kylinnm.ui +++ /dev/null @@ -1,296 +0,0 @@ - - - KylinNM - - - - 0 - 0 - 441 - 443 - - - - kylin-nm - - - - - 0 - 0 - 442 - 437 - - - - - - 1 - 200 - 37 - 37 - - - - - - - - - - 2 - 200 - 37 - 37 - - - - - - - - - - 385 - 73 - 50 - 24 - - - - - - - - - - 400 - 400 - 37 - 37 - - - - - - - - - - 2 - 348 - 37 - 37 - - - - - - - - - - 2 - 395 - 37 - 37 - - - - - - - - - - 16 - 72 - 171 - 20 - - - - - - - - - - 413 - 75 - 20 - 20 - - - - - - - - - - 11 - 359 - 19 - 19 - - - - - - - - - - 11 - 405 - 19 - 19 - - - - - - - - - - 0 - 0 - 37 - 37 - - - - - - - - - - 221 - 0 - 37 - 37 - - - - - - - - - - 63 - 17 - 24 - 24 - - - - - - - - - - 288 - 16 - 24 - 24 - - - - - - - - - - 2 - 348 - 37 - 37 - - - - - - - - - - 2 - 395 - 37 - 37 - - - - - - - - - - 0 - 0 - 221 - 56 - - - - - - - - - - 221 - 0 - 221 - 56 - - - - - - - - - - 409 - 409 - 19 - 19 - - - - - - - btnConfImg - lbFlyBG - lbHotBG - lbFlyImg - lbHotImg - lbBtnNetBG - btnNet - lbBtnWifiBG - btnAdvConf - btnHotspot - btnFlyMode - lbBtnWifiBall - lbNetListBG - lbWifiListBG - lbWifiListImg - lbNetListImg - btnNetList - btnWifiList - lbNetwork - - - - - - diff --git a/KylinNM/src/loadingdiv.cpp b/KylinNM/src/loadingdiv.cpp deleted file mode 100644 index bf1b0c4..0000000 --- a/KylinNM/src/loadingdiv.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see resize(480, 538); - - this->loadingGif = new QLabel(this); - this->loadingGif->resize(96, 96); - this->loadingGif->move(this->width()/2 - 96/2 + 41/2, this->height()/2 + 20); - this->loadingGif->show(); - - this->switchTimer = new QTimer(this); //QTimer对象,控制等待动画播放 - connect(switchTimer, SIGNAL(timeout()), this, SLOT(switchAnimStep())); - - this->raise(); - this->hide(); -} - -//加载动画控件'loadingGif' -void LoadingDiv::switchAnimStep() -{ - QString qpmQss = "QLabel{background-image:url(':/res/s/conning-b/"; - qpmQss.append(QString::number(this->currentPage)); - qpmQss.append(".png');}"); - loadingGif->setStyleSheet(qpmQss); - - this->currentPage --; - - if (this->currentPage < 1) { - this->currentPage = 12; //循环播放 - } - - this->countCurrentTime += FRAMESPEED; - if (this->countCurrentTime >= ALLTIME) { - emit this->toStopLoading(); //发出信号停止主界面和托盘区的等待动画 - } -} - -//开始播放动画 -void LoadingDiv::startLoading() -{ - this->currentPage = 12; - this->countCurrentTime = 0; - this->switchTimer->start(FRAMESPEED); - this->show(); -} - -//结束播放动画 -void LoadingDiv::stopLoading() -{ - this->switchTimer->stop(); - this->hide(); -} diff --git a/KylinNM/src/loadingdiv.h b/KylinNM/src/loadingdiv.h deleted file mode 100644 index f8ee9e3..0000000 --- a/KylinNM/src/loadingdiv.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see -#include -#include -#include -#include -#include - -class LoadingDiv : public QWidget -{ - Q_OBJECT -public: - explicit LoadingDiv(QWidget *parent = nullptr); - -Q_SIGNALS: - void toStopLoading(); - -public Q_SLOTS: - void switchAnimStep(); - void startLoading(); - void stopLoading(); - -private: - QLabel *loadingGif = nullptr; - QTimer *switchTimer = nullptr; - - int currentPage; - int countCurrentTime; -}; - -#endif // LOADINGDIV_H diff --git a/KylinNM/src/main.cpp b/KylinNM/src/main.cpp deleted file mode 100644 index 0929685..0000000 --- a/KylinNM/src/main.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see -#include -#include -#include -#include -#include - -#define LOG_IDENT "ukui_kylin_nm" - - -int main(int argc, char *argv[]) -{ - //QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); - Display *disp = XOpenDisplay(NULL); - Screen *scrn = DefaultScreenOfDisplay(disp); - if (NULL == scrn) { - return 0; - } - int width = scrn->width; - - if (width > 2560) { - #if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) - QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); - QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); - #endif - } - if (NULL != disp) { - XCloseDisplay(disp); - } - - QApplication a(argc, argv); - - - openlog(LOG_IDENT, LOG_NDELAY | LOG_NOWAIT | LOG_PID, LOG_USER); - - syslog(LOG_DEBUG, "Kylin Network Manager Is Already Launched"); - - // Internationalization - QString locale = QLocale::system().name(); - QTranslator trans_global; - if (locale == "zh_CN") { - trans_global.load(":/translations/kylin-nm_zh_CN.qm"); - //trans_global.load(":/translations/kylin-nm_bo.qm"); - a.installTranslator(&trans_global); - } - if (locale == "tr_TR") { - trans_global.load(":/translations/kylin-nm_tr.qm"); - a.installTranslator(&trans_global); - } - - KylinNM w; - return a.exec(); -} diff --git a/KylinNM/src/oneconnform.cpp b/KylinNM/src/oneconnform.cpp deleted file mode 100644 index 9a82926..0000000 --- a/KylinNM/src/oneconnform.cpp +++ /dev/null @@ -1,939 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see -#include -#include -#include -#include -#include -#include - -extern int currentActWifiSignalLv; - -OneConnForm::OneConnForm(QWidget *parent, KylinNM *mainWindow, ConfForm *confForm, KSimpleNM *ksnm) : - QWidget(parent), - ui(new Ui::OneConnForm) -{ - ui->setupUi(this); - - ui->btnConnSub->setText(tr("Connect"));//"设置" - ui->btnConn->setText(tr("Connect"));//"连接" - ui->btnConnPWD->setText(tr("Connect"));//"连接" - ui->btnDisConn->setText(tr("Disconnect"));//"断开连接" - ui->btnHideConn->setText(tr("Connect"));//"连接" - ui->lePassword->setPlaceholderText(tr("Input Password..."));//"输入密码..." - ui->lePassword->setContextMenuPolicy(Qt::NoContextMenu); - ui->lePassword->setTextMargins(0,0,20,0); - - ui->lbConned->setAlignment(Qt::AlignLeft); - ui->lePassword->setEchoMode(QLineEdit::Normal); - ui->btnConnPWD->setEnabled(false); - - leQssLow = "QLineEdit{border:none;background:transparent;font-size:14px;color:rgba(255,255,255,0.57);font-family:Noto Sans CJK SC;}"; - leQssHigh = "QLineEdit{border:none;background:transparent;font-size:14px;color:rgba(255,255,255,0.91);font-family:Noto Sans CJK SC;}"; - - ui->leInfo_1->setStyleSheet(leQssLow); - ui->leInfo_2->setStyleSheet(leQssLow); - ui->leInfo_3->setStyleSheet(leQssLow); - ui->leInfo_1->setEnabled(false); - ui->leInfo_2->setEnabled(false); - ui->leInfo_3->setEnabled(false); - ui->btnInfo->setStyleSheet("QPushButton{border:none;background:transparent;}"); - ui->wbg->setStyleSheet("#wbg{border-radius:8px;background-color:rgba(255,255,255,0);}"); - ui->wbg_2->setStyleSheet("#wbg_2{border-radius:8px;background-color:rgba(38, 38, 38, 0.1)}"); - ui->wbg_3->setStyleSheet("#wbg_3{border-radius:4px;background-color:rgba(255,255,255,0.1);}"); - ui->lbName->setStyleSheet("QLabel{font-size:14px;color:rgba(38,38,38,1);}"); - ui->lbConned->setStyleSheet("QLabel{font-size:14px;color:rgba(255,255,255,0.57);}"); - ui->lePassword->setStyleSheet("QLineEdit{border:2px solid rgba(47, 179, 232, 1);border-radius:4px;" - "background:rgba(255,255,255,1);color:rgba(38, 38, 38, 1);font-size:14px;}"); - ui->checkBoxPwd->setStyleSheet("QCheckBox::indicator {width: 18px; height: 9px;}" - "QCheckBox::indicator:checked {image: url(:/res/h/show-pwd.png);}" - "QCheckBox::indicator:unchecked {image: url(:/res/h/hide-pwd.png);}"); - ui->btnConnSub->setStyleSheet("QPushButton{border:0px;border-radius:4px;background-color:rgba(61,107,229,1);color:white;font-size:14px;}" - "QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(107,142,235,1);}" - "QPushButton:Pressed{border-radius:4px;background-color:rgba(50,87,202,1);}"); - ui->btnConn->setStyleSheet("QPushButton{border:0px;border-radius:4px;background-color:rgba(61,107,229,1);color:white;font-size:14px;}" - "QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(107,142,235,1);}" - "QPushButton:Pressed{border-radius:4px;background-color:rgba(50,87,202,1);}"); - ui->btnConnPWD->setStyleSheet("QPushButton{border:0px;border-radius:4px;background-color:rgba(47, 179, 232, 1);color:rgba(255, 255, 255, 1);font-size:14px;}" - "QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(70, 193, 243, 1);}" - "QPushButton:Pressed{border-radius:4px;background-color:rgba(27, 160, 213, 1);}" - "QPushButton:Disabled{border-radius:4px;background-color:rgba(168, 168, 168, 1)}"); - ui->btnDisConn->setStyleSheet("#btnDisConn{font-family: NotoSansCJKsc-Regular, NotoSansCJKsc;" - "font-weight: 400;color: rgba(38,38,38,0.75);line-height: 20px;font-size:14px;" - "border:0px;background-color:rgba(38,38,38,0.1);border-radius:8px;}" - "#btnDisConn:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:8px;background-color:rgba(38,38,38,0.2);}" - "#btnDisConn:Pressed{border-radius:8px;background-color:rgba(38,38,38,0.06);}");//断开链接按钮 - ui->btnInfo_2->setStyleSheet("border:0px;border-radius:8px;border-image:url(:/res/l/pb-network-info.png);"); - ui->btnHideConn->setStyleSheet("QPushButton{border:0px;border-radius:4px;background-color:rgba(61,107,229,1);color:white;font-size:14px;}" - "QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(107,142,235,1);}" - "QPushButton:Pressed{border-radius:4px;background-color:rgba(50,87,202,1);}"); - ui->lbWaiting->setStyleSheet("QLabel{border:0px;border-radius:10px;background-color:rgba(61,107,229,1);}"); - ui->lbWaitingIcon->setStyleSheet("QLabel{border:0px;background-color:transparent;}"); - ui->autoConn->setStyleSheet("QCheckBox::indicator {width: 16px; height: 16px;}" - "QCheckBox::indicator:checked {image: url(:/res/g/checkbox-checked.svg);}" - "QCheckBox::indicator:unchecked {image: url(:/res/g/checkbox-unchecked.svg);}"); - - ui->btnInfo->setCursor(QCursor(Qt::PointingHandCursor)); - ui->btnInfo->setFocusPolicy(Qt::NoFocus); - ui->checkBoxPwd->setFocusPolicy(Qt::NoFocus); - ui->btnConnSub->setFocusPolicy(Qt::NoFocus); - ui->btnConn->setFocusPolicy(Qt::NoFocus); - ui->btnConnPWD->setFocusPolicy(Qt::NoFocus); - ui->btnDisConn->setFocusPolicy(Qt::NoFocus); - ui->btnHideConn->setFocusPolicy(Qt::NoFocus); - - ui->wbg->show(); - ui->wbg_2->hide(); - ui->wbg_3->hide(); - ui->lbName->show(); - ui->leInfo_1->hide(); - ui->leInfo_2->hide(); - ui->leInfo_3->hide(); - ui->lePassword->hide(); - ui->checkBoxPwd->hide(); - ui->checkBoxPwd->setChecked(false); - ui->lePassword ->setEchoMode(QLineEdit::Password); - ui->btnConnSub->hide(); - ui->btnConn->hide(); - ui->btnDisConn->hide(); - ui->btnConnPWD->hide(); - ui->btnHideConn->hide(); - ui->line->show(); - ui->autoConn->hide(); - ui->lbWaiting->hide(); - ui->lbWaitingIcon->hide(); - ui->btnInfo->hide(); - - this->mw = mainWindow; - this->cf = confForm; - this->ks = ksnm; - - this->isSelected = false; - this->isActive = false; - - this->setAttribute(Qt::WA_Hover,true); - this->installEventFilter(this); - ui->lePassword->setAttribute(Qt::WA_Hover,true); - ui->lePassword->installEventFilter(this); - ui->btnInfo->setAttribute(Qt::WA_Hover,true); - ui->btnInfo->installEventFilter(this); - - //m_notify = new NotifySend(); - - connect(ui->lePassword, SIGNAL(returnPressed()), this, SLOT(on_btnConnPWD_clicked())); - ui->btnConn->setShortcut(Qt::Key_Return);//将字母区回车键与登录按钮绑定在一起 - - this->waitTimer = new QTimer(this); - connect(waitTimer, SIGNAL(timeout()), this, SLOT(waitAnimStep())); - - connect(mw, SIGNAL(waitWifiStop()), this, SLOT(stopWaiting())); - connect(ui->btnInfo_2,&QPushButton::clicked,this,&OneConnForm::on_btnInfo_2_clicked); - ui->btnInfo_2->hide(); - // connect(ui->autoConn,&QCheckBox::toggled,this,&OneConnForm::on_autoConn_toggled); - - ui->autoConn->setText(tr("Automatically join the network")); -// ui->autoConn->setText(tr("自动连接")); - - ui->lbWaitingIcon->move(316+194*mw->isTabletStyle,20);// YYF - tabletStyle();//平板模式PC桌面样式 -} - -void OneConnForm::tabletStyle()//平板桌面模式特有设置 -{ - this->setFixedWidth(414+194*mw->isTabletStyle); - ui->wbg->setFixedWidth(414+194*mw->isTabletStyle); - ui->wbg_2->setFixedWidth(414+194*mw->isTabletStyle); - ui->wbg_3->setFixedWidth(414+194*mw->isTabletStyle); - ui->lbName->setFixedWidth(190+194*mw->isTabletStyle); - ui->btnInfo->setFixedWidth(230+194*mw->isTabletStyle); - ui->leInfo_1->setFixedWidth(230+194*mw->isTabletStyle); - ui->leInfo_2->setFixedWidth(230+194*mw->isTabletStyle); - ui->leInfo_3->setFixedWidth(230+194*mw->isTabletStyle); - ui->lePassword->setFixedWidth(254+172*mw->isTabletStyle); - ui->checkBoxPwd->move(286+172*mw->isTabletStyle,75); - ui->btnConnPWD->move(318+172*mw->isTabletStyle,56); - ui->btnDisConn->move(316+194*mw->isTabletStyle,8 + 18*mw->isTabletStyle); - ui->btnInfo_2->move(364+194*mw->isTabletStyle,18); - ui->lbName->move(63,18); -} - -OneConnForm::~OneConnForm() -{ - delete ui; -} - -void OneConnForm::mousePressEvent(QMouseEvent *event) -{ - if (event->button() != Qt::LeftButton) { - event->ignore(); - return; - } - // emit selectedOneWifiForm(wifiName, H_WIFI_ITEM_BIG_EXTEND); - ui->wbg_2->setStyleSheet("#wbg_2{border-radius:8px;background-color:rgba(38,38,38,0.1);}"); -} - -void OneConnForm::mouseReleaseEvent(QMouseEvent *event) -{ - if (event->button() != Qt::LeftButton || !rect().contains(event->pos())) { - event->ignore(); - return; - } - if(ui->lePassword->isVisible()){ - Q_EMIT selectedOneWifiForm(wifiName, H_WIFI_ITEM_BIG_EXTEND); - }else{ - if (!this->isTopItem) { - if (!is_connecting) { - toConnectWirelessNetwork(); - } - } - } - ui->wbg_2->setStyleSheet("#wbg_2{border-radius:8px;background-color:rgba(255,255,255,0);}"); -} - -//事件过滤器 -bool OneConnForm::eventFilter(QObject *obj, QEvent *event) -{ - if (obj == ui->btnInfo) { - if (event->type() == QEvent::HoverEnter) { - ui->leInfo_1->setStyleSheet(leQssHigh); - ui->leInfo_2->setStyleSheet(leQssHigh); - ui->leInfo_3->setStyleSheet(leQssHigh); - return true; - } else if(event->type() == QEvent::HoverLeave) { - ui->leInfo_1->setStyleSheet(leQssLow); - ui->leInfo_2->setStyleSheet(leQssLow); - ui->leInfo_3->setStyleSheet(leQssLow); - return true; - } - } else if (obj == this) { - if(event->type() == QEvent::HoverEnter) { - if (!this->isTopItem) { - if (!this->isSelected) { - //ui->btnConn->show(); - ui->wbg->setStyleSheet("#wbg{border-radius:8px;background-color:rgba(38,38,38,0.05);}"); - ui->wbg->show(); - } - } - return true; - } else if (event->type() == QEvent::HoverLeave) { - ui->btnConn->hide(); - ui->wbg->setStyleSheet("#wbg{border-radius:8px;background-color:rgba(255,255,255,0);}"); - ui->wbg->hide(); - return true; - } - } - - if (obj == ui->lePassword) { - if (event->type() == QEvent::MouseButtonPress) { - Q_EMIT onLineEditClicked(); - } - } - - return QWidget::eventFilter(obj,event); -} - -void OneConnForm::on_autoConn_toggled(bool val) -{ -// kylin_network_set_autoconnect(wifiName.toLatin1().data(),val); -} - -// 是否当前连接的网络,字体设置不同 -void OneConnForm::setAct(bool isAct) -{ - if (isAct) { - ui->lbConned->hide(); - } else { - ui->lbConned->hide(); - } - ui->lbName->move(63,18); - isActive = isAct; -} - -//点击窗口最上面的item时 -void OneConnForm::setTopItem(bool isSelected) -{ - if (isSelected) { - resize(W_ITEM+194*mw->isTabletStyle, H_ITEM_BIG); - ui->wbg_3->show(); - ui->leInfo_1->show(); - ui->leInfo_2->show(); - ui->leInfo_3->show(); - - this->isSelected = true; - } else { - resize(W_ITEM+194*mw->isTabletStyle, H_ITEM); - ui->lePassword->setText(""); - ui->wbg_3->hide(); - ui->leInfo_1->hide(); - ui->leInfo_2->hide(); - ui->leInfo_3->hide(); - - - this->isSelected = false; - } - - ui->wbg->hide(); - ui->wbg_2->hide(); - ui->lbSignal->show(); - ui->lePassword->hide(); - ui->checkBoxPwd->hide(); - ui->line->hide(); - ui->btnConn->hide(); - ui->btnConnPWD->hide(); - ui->btnHideConn->hide(); - ui->btnInfo->show(); - - if (isConnected) { - if (this->isWaiting) { - ui->lbName->setStyleSheet("QLabel{font-size:14px;color:rgba(38,38,38,0.45);}"); - ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;border-image:url(:/res/w/pb-top-wifi-offline.png);}"); - ui->btnDisConn->hide(); -// ui->btnInfo_2->hide(); - } else { - ui->lbName->setStyleSheet("QLabel{font-size:14px;color:rgba(47, 179, 232, 1);}"); - setSignalOn(signalStrong,signalHasPw); - ui->btnDisConn->show(); -// ui->btnInfo_2->show(); - } - ui->btnInfo_2->hide(); - } else { - ui->lbName->setStyleSheet("QLabel{font-size:14px;color:rgba(38,38,38,0.45);}"); - ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;border-image:url(:/res/w/pb-top-wifi-offline.png);}"); - ui->btnDisConn->hide(); - ui->btnInfo_2->hide(); - } - - this->isTopItem = true; -} -// 点击窗口下面的item时 -void OneConnForm::setSelected(bool isSelected, bool isCurrName) -{ - if (isSelected) { - resize(W_ITEM+194*mw->isTabletStyle, H_ITEM_BIG); - ui->line->move(X_LINE_BIG_EXTEND, Y_LINE_BIG_EXTEND); - ui->wbg->hide(); - ui->wbg_2->hide(); - ui->wbg_3->show(); - ui->leInfo_1->show(); - ui->leInfo_2->show(); - ui->leInfo_3->show(); - ui->btnConn->hide(); - ui->btnConnSub->show(); - - this->isSelected = true; - } else { - resize(W_ITEM+194*mw->isTabletStyle, H_ITEM); - ui->lePassword->setStyleSheet("QLineEdit{border:2px solid rgba(47, 179, 232, 1);border-radius:4px;" - "background:rgba(255,255,255,1);color:rgba(38, 38, 38, 1);font-size:14px;}"); - - ui->line->move(X_LINE, Y_LINE); - ui->wbg->show(); - ui->wbg_2->hide(); - ui->wbg_3->hide(); - ui->leInfo_1->hide(); - ui->leInfo_2->hide(); - ui->leInfo_3->hide(); - - if (isCurrName) { - //ui->btnConn->show(); - } else { - ui->btnConn->hide(); - } - ui->btnConnSub->hide(); - - this->isSelected = false; - } - - ui->lePassword->hide(); - ui->checkBoxPwd->hide(); - ui->btnConnPWD->hide(); - ui->lbSignal->show(); - ui->btnDisConn->hide(); - ui->btnHideConn->hide(); - ui->btnInfo->hide(); - - this->isTopItem = false; -} -// 点击连接隐藏wifi的item时 -void OneConnForm::setHideItem(bool isHideItem, bool isShowHideBtn) -{ - if (isHideItem) { - ui->lbName->move(14, 30); - ui->wbg->hide(); - ui->btnConn->hide(); - } else { - ui->lbName->move(62, 18); - ui->wbg->show(); - //ui->btnConn->show(); - } - - if (isShowHideBtn) { - ui->btnHideConn->show(); - } else{ - ui->btnHideConn->hide(); - } -} - -void OneConnForm::setConnedString(bool showLable, QString str, QString str1) -{ - if (!showLable) { - ui->lbConned->setText(str1); - ui->lbConned->hide(); - } else { - ui->lbConned->setText(str); - } - ui->lbName->move(63, 18); -} - -void OneConnForm::setName(QString name) -{ - ui->lbName->setText(name); - wifiName = name; -} -void OneConnForm::setSpecialName(QString name) -{ - ui->lbName->setText(tr("Connect to Hidden Wi-Fi Network")); //连接到隐藏的 Wi-Fi 网络 - wifiName = name; -} - -QString OneConnForm::getName() -{ - return ui->lbName->text(); -} - -void OneConnForm::setRate(QString rate) -{ -// QString txt(tr("Rate"));//"速率" -// this->setToolTip("  " + txt + ": " + rate + "  "); -// this->setToolTip(txt + ":" + rate); -} - -void OneConnForm::setLine(bool isShow) -{ - if (isShow) { - ui->line->show(); - } else { - ui->line->hide(); - } -} - -void OneConnForm::setSignalOn(QString lv, QString secu) -{ - - int signal = lv.toInt(); - if (secu == "--" || secu == "") { - hasPwd = false; - } else { - hasPwd = true; - } - - if (signal > 75) { - if (hasPwd) { - ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;border-image:url(:/res/w/wifi-full-pwd.png);}"); - } else { - ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;border-image:url(:/res/w/wifi-full.png);}"); - } - signalLv = 1; - } - if (signal > 55 && signal <= 75) { - if (hasPwd) { - ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;border-image:url(:/res/w/wifi-high-pwd.png);}"); - } else { - ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;border-image:url(:/res/w/wifi-high.png);}"); - } - signalLv = 2; - } - if (signal > 35 && signal <= 55) { - if (hasPwd) { - ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;border-image:url(:/res/w/wifi-medium-pwd.png);}"); - } else { - ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;border-image:url(:/res/w/wifi-medium.png);}"); - } - signalLv = 3; - } - if (signal > 15 && signal <= 35) { - if (hasPwd) { - ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;border-image:url(:/res/w/wifi-low-pwd.png);}"); - } else { - ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;border-image:url(:/res/w/wifi-low.png);}"); - } - signalLv = 4; - } - if (signal <= 15) { - if (hasPwd) { - ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;border-image:url(:/res/w/wifi-none-pwd.png);}"); - } else { - ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;border-image:url(:/res/w/wifi-none.png);}"); - } - signalLv = 4; - } -} - -void OneConnForm::setSignal(QString lv, QString secu) -{ - signalStrong=lv; - signalHasPw=secu; - - int signal = lv.toInt(); - if (secu == "--" || secu == "") { - hasPwd = false; - } else { - hasPwd = true; - } - - if (signal > 75) { - if (hasPwd) { - ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;border-image:url(:/res/w/wifi-full-pwd-off.png);}"); - } else { - ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;border-image:url(:/res/w/wifi-full-off.png);}"); - } - signalLv = 1; - } - if (signal > 55 && signal <= 75) { - if (hasPwd) { - ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;border-image:url(:/res/w/wifi-high-pwd-off.png);}"); - } else { - ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;border-image:url(:/res/w/wifi-high-off.png);}"); - } - signalLv = 2; - } - if (signal > 35 && signal <= 55) { - if (hasPwd) { - ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;border-image:url(:/res/w/wifi-medium-pwd-off.png);}"); - } else { - ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;border-image:url(:/res/w/wifi-medium-off.png);}"); - } - signalLv = 3; - } - if (signal > 15 && signal <= 35) { - if (hasPwd) { - ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;border-image:url(:/res/w/wifi-low-pwd-off.png);}"); - } else { - ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;border-image:url(:/res/w/wifi-low-off.png);}"); - } - signalLv = 4; - } - if (signal <= 15) { - if (hasPwd) { - ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;border-image:url(:/res/w/wifi-none-pwd-off.png);}"); - } else { - ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;border-image:url(:/res/w/wifi-none-off.png);}"); - } - signalLv = 4; - } -} - -void OneConnForm::setWifiInfo(QString str1, QString str2, QString str3) -{ - if (str1 == "--" || str1 == ""){ str1 = tr("None"); }; - - QString strSecurity = QString(tr("WiFi Security:")); - QString strSignal = QString(tr("Signal:")); - QString strMAC = QString(tr("MAC:")); - - ui->leInfo_1->setText(strSecurity + str1); - ui->leInfo_2->setText(strSignal + str2); - ui->leInfo_3->setText(strMAC + str3); -} - -void OneConnForm::slotConnWifi() -{ - //mw->startLoading(); - this->startWaiting(true); - emit sigConnWifi(ui->lbName->text()); -} -void OneConnForm::slotConnWifiPWD() -{ - //mw->startLoading(); - this->startWaiting(true); - emit sigConnWifiPWD(ui->lbName->text(), ui->lePassword->text()); -} - -//点击后断开wifi网络 -void OneConnForm::on_btnDisConn_clicked() -{ - syslog(LOG_DEBUG, "DisConnect button about wifi net is clicked, current wifi name is %s .", ui->lbName->text().toUtf8().data()); - qDebug()<<"DisConnect button about wifi net is clicked, current wifi name is "<lbName->text(); - - this->startWaiting(false); - - mw->is_stop_check_net_state = 1; - mw->on_btnHotspotState(); - QString name = ui->lbName->text(); - kylin_network_set_con_down(name.replace("\"","\\\"").toUtf8().data()); - disconnect(this, SIGNAL(selectedOneWifiForm(QString,int)), mw, SLOT(oneWifiFormSelected(QString,int))); - emit disconnActiveWifi(); -} - -//点击列表item扩展时会出现该按钮 用于连接网络 -void OneConnForm::on_btnConnSub_clicked() -{ - syslog(LOG_DEBUG, "A button named on_btnConnSub about wifi net is clicked."); - qDebug()<<"A button named on_btnConnSub about wifi net is clicked."; - toConnectWirelessNetwork(); -} - -//无需密码的wifi连接 -void OneConnForm::on_btnConn_clicked() -{ -// syslog(LOG_DEBUG, "A button named btnConn about wifi net is clicked."); -// qDebug()<<"A button named btnConn about wifi net is clicked."; -// toConnectWirelessNetwork(); - on_btnInfo_clicked(); -} - -void OneConnForm::toConnectWirelessNetwork() -{ - if (ui->lbConned->text() == "--" || ui->lbConned->text() == " ") { - if (!isWifiConfExist(ui->lbName->text())) { - //没有配置文件,使用有密码的wifi连接 - on_btnConnPWD_clicked(); - return; - } - } - - mw->is_stop_check_net_state = 1; - QThread *t = new QThread(); - BackThread *bt = new BackThread(); - bt->moveToThread(t); - connect(t, SIGNAL(finished()), t, SLOT(deleteLater())); - connect(t, SIGNAL(started()), this, SLOT(slotConnWifi())); - connect(this, SIGNAL(sigConnWifi(QString)), bt, SLOT(execConnWifi(QString))); - connect(bt, &BackThread::connDone, this,[=](int t) { - mw->connWifiDone(t); - }); - connect(bt, SIGNAL(connDone(int)), this, SLOT(slotConnWifiResult(int))); - connect(bt, SIGNAL(btFinish()), t, SLOT(quit())); - t->start(); - is_connecting = true; -} - -//需要密码的wifi连接 -void OneConnForm::on_btnConnPWD_clicked() -{ - syslog(LOG_DEBUG, "A button named btnConnPWD about wifi net is clicked."); - qDebug()<<"A button named btnConnPWD about wifi net is clicked."; - - ui->btnConnPWD->setStyleSheet("QPushButton{border:0px;border-radius:4px;background-color:rgba(47, 179, 232, 1);color:white;font-size:14px;}" - "QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(70, 193, 243, 1);}" - "QPushButton:Pressed{border-radius:4px;background-color:rgba(27,160,213,1);}" - "QPushButton:Disabled{border-radius:4px;background-color:#BEBEBE;}"); - ui->btnConnPWD->setEnabled(false); - - //调用kylinnm的接口,屏蔽输错密码框后弹出提示框 - QDBusInterface interface("com.kylin.network", - "/com/kylin/network", - "com.kylin.network", - QDBusConnection::sessionBus()); - QDBusMessage result = interface.call("keyRingClear"); - - mw->is_stop_check_net_state = 1; - QThread *t = new QThread(); - BackThread *bt = new BackThread(); - bt->moveToThread(t); - connect(t, SIGNAL(finished()), t, SLOT(deleteLater())); - connect(t, SIGNAL(started()), this, SLOT(slotConnWifiPWD())); - connect(this, SIGNAL(sigConnWifiPWD(QString, QString)), bt, SLOT(execConnWifiPWD(QString, QString))); - connect(bt, SIGNAL(connDone(int)), mw, SLOT(connWifiDone(int))); - connect(bt, SIGNAL(connDone(int)), this, SLOT(slotConnWifiResult(int))); - connect(bt, SIGNAL(btFinish()), t, SLOT(quit())); - ui->lePassword->setEnabled(false); - t->start(); -} - -//点击后弹出连接隐藏wifi网络窗口 -void OneConnForm::on_btnHideConn_clicked() -{ -// QApplication::setQuitOnLastWindowClosed(false); - DlgConnHidWifi *connHidWifi = new DlgConnHidWifi(0, mw, this->parentWidget()); - connect(connHidWifi, SIGNAL(reSetWifiList() ), mw, SLOT(on_btnWifiList_clicked()) ); - connHidWifi->show(); -} - -bool OneConnForm::isWifiConfExist(QString netName) -{ - //dbusWifiMac = ""; //这个函数之前是用来获取已经连接的wifi的MAC地址 - - QDBusInterface m_interface("org.freedesktop.NetworkManager", - "/org/freedesktop/NetworkManager/Settings", - "org.freedesktop.NetworkManager.Settings", - QDBusConnection::systemBus() ); - QDBusReply> m_reply = m_interface.call("ListConnections"); - - QList m_objNets = m_reply.value(); - foreach (QDBusObjectPath objNet, m_objNets){ - QDBusInterface m_interface("org.freedesktop.NetworkManager", - objNet.path(), - "org.freedesktop.NetworkManager.Settings.Connection", - QDBusConnection::systemBus()); - QDBusMessage reply = m_interface.call("GetSettings"); - const QDBusArgument &dbusArg = reply.arguments().at( 0 ).value(); - QMap> map; - dbusArg >> map; - - for(QString key : map.keys() ){ - QMap innerMap = map.value(key); - if (key == "connection") { - for (QString inner_key : innerMap.keys()) { - if (inner_key == "id"){ - if (netName == innerMap.value(inner_key).toString()) { - return true; - } - } - } - } - } - - } // end foreach (QDBusObjectPath objNet, m_objNets) - - return false; -} - -//设置密码隐藏或可见 -void OneConnForm::on_checkBoxPwd_stateChanged(int arg1) -{ - if (arg1 == 0) { - ui->lePassword ->setEchoMode(QLineEdit::Password); - } else { - ui->lePassword->setEchoMode(QLineEdit::Normal); - } -} - -void OneConnForm::on_lePassword_textEdited(const QString &arg1) -{ - ui->lePassword->setStyleSheet("QLineEdit{border:2px solid rgba(47, 179, 232, 1);border-radius:4px;" - "background:rgba(255,255,255,1);color:rgba(38, 38, 38, 1);font-size:14px;}"); - - if (ui->lePassword->text().size() < 8){ - ui->btnConnPWD->setStyleSheet("QPushButton{border:0px;border-radius:4px;background-color:rgba(47, 179, 232, 1);color:white;font-size:14px;}" - "QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(70, 193, 243, 1);}" - "QPushButton:Pressed{border-radius:4px;background-color:rgba(27,160,213,1);}" - "QPushButton:Disabled{border-radius:4px;background-color:rgba(168, 168, 168, 1)}"); - ui->btnConnPWD->setEnabled(false);//连接时设置为不可点击 - if (ui->lePassword->text().size() == 0){ - ui->lePassword->setStyleSheet("QLineEdit{border:2px solid rgba(47, 179, 232, 1);border-radius:4px;" - "background:rgba(255,255,255,1);color:red;font-size:14px;}"); - } - } else { - ui->btnConnPWD->setStyleSheet("QPushButton{border:0px;border-radius:4px;background-color:rgba(47, 179, 232, 1);color:white;font-size:14px;}" - "QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(70,193,243,1);}" - "QPushButton:Pressed{border-radius:4px;background-color:rgba(27,160,213,1);}"); - ui->btnConnPWD->setEnabled(true); - } -} - -void OneConnForm::on_btnInfo_2_clicked(){ - on_btnInfo_clicked(); -} - -void OneConnForm::on_btnInfo_clicked() -{ - QPoint pos = QCursor::pos(); - QRect primaryGeometry; - for (QScreen *screen : qApp->screens()) { - if (screen->geometry().contains(pos)) { - primaryGeometry = screen->geometry(); - } - } - - if (primaryGeometry.isEmpty()) { - primaryGeometry = qApp->primaryScreen()->geometry(); - } - - BackThread *bt = new BackThread(); - QString connProp = bt->getConnProp(ui->lbName->text()); - QStringList propList = connProp.split("|"); - QString v4method, addr, mask, gateway, dns; - foreach (QString line, propList) { - if (line.startsWith("method:")) { - v4method = line.split(":").at(1); - } - if (line.startsWith("addr:")) { - addr = line.split(":").at(1); - } - if (line.startsWith("mask:")) { - mask = line.split(":").at(1); - } - if (line.startsWith("gateway:")) { - gateway= line.split(":").at(1); - } - if (line.startsWith("dns:")) { - dns = line.split(":").at(1); - } - } - // qDebug()<<"v4method:"<setProp(ui->lbName->text(), v4method, addr, mask, gateway, dns, this->isActive); - - cf->move(primaryGeometry.width() / 2 - cf->width() / 2, primaryGeometry.height() / 2 - cf->height() / 2); - cf->show(); - cf->raise(); - - bt->deleteLater(); -} - -// Wifi连接结果,0成功 1失败 2没有配置文件 -void OneConnForm::slotConnWifiResult(int connFlag) -{ - mw->connWifiDone(connFlag); - qDebug()<<"Function slotConnWifiResult receives a number: "<currSelNetName = ""; - emit selectedOneWifiForm(ui->lbName->text(), H_WIFI_ITEM_SMALL_EXTEND); - - resize(W_ITEM, H_ITEM_MIDDLE); - ui->wbg->hide(); - ui->wbg_2->show(); - ui->wbg_3->hide(); - ui->leInfo_1->hide(); - ui->leInfo_2->hide(); - ui->leInfo_3->hide(); - ui->btnHideConn->hide(); - ui->btnDisConn->hide(); - ui->btnConn->hide(); - ui->btnConnSub->hide(); - // ui->line->move(X_LINE_SMALL_EXTEND, Y_LINE_SMALL_EXTEND); - - ui->lePassword->show(); - ui->lePassword->setFocus(); - Q_EMIT onLineEditClicked(); - ui->checkBoxPwd->show(); - ui->btnConnPWD->show(); - ui->autoConn->show(); - ui->autoConn->setChecked(true); - this->isSelected = true; - } - - if (connFlag == 1) { - // 使用配置文件连接失败,需要删除该配置文件 - QString txt(tr("Conn Wifi Failed"));//"连接 Wifi 失败" - syslog(LOG_DEBUG, "Try to connect wifi named %s, but failed, will delete it's configuration file", ui->lbName->text().toUtf8().data()); - - //YYF 20200922 -// ui->lePassword->setText(""); - - KylinDBus kylindbus; - kylindbus.showDesktopNotify(txt); - //QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection delete '" + ui->lbName->text() + "';notify-send '" + txt + "...' -t 3800"; - QString name = ui->lbName->text(); - QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection delete \"" + name.replace("\"","\\\"") + "\""; - int status = system(cmd.toUtf8().data()); - if (status != 0) { - syslog(LOG_ERR, "execute 'nmcli connection delete' in function 'slotConnWifiResult' failed"); - } -// ui->btnConnPWD->setStyleSheet("QPushButton{border:0px;border-radius:4px;background-color:rgba(47, 179, 232, 1);color:white;font-size:14px;}" -// "QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(70,193,243,1);}" -// "QPushButton:Pressed{border-radius:4px;background-color:rgba(27,160,213,1);}"); -// ui->btnConnPWD->setEnabled(true); - ui->lePassword->setEnabled(true); - ui->lePassword->setFocus(); - Q_EMIT onLineEditClicked(); - ui->lePassword->selectAll(); - ui->lePassword->setStyleSheet("QLineEdit{border:2px solid rgba(255, 0, 0, 0.5);border-radius:4px;" - "background:palette(base);color:rgba(38, 38, 38, 1);font-size:14px;" - "selection-background-color: rgba(255, 0, 0, 0.5);}"); - } - if (connFlag == 0){ - //连接成功,配置是否自启动 - //若含中文的QString直接转换,会出现乱码,使用如下转换方式解决此问题(必须分两句转换) - QString wifi_name = wifiName; - wifi_name.replace("\"","\\\""); - QByteArray ba = wifi_name.toLocal8Bit(); - char *name = ba.data(); - if (ui->autoConn->isVisible()) { - //仅当首次连接配置时执行此操作 - kylin_network_set_autoconnect(name,ui->autoConn->isChecked()); - } - } - // 设置全局变量,当前连接Wifi的信号强度 - currentActWifiSignalLv = signalLv; - - this->stopWaiting(); - is_connecting = false; - //if (connFlag != 0){ - // mw->stopLoading(); - //} -} - -void OneConnForm::waitAnimStep() -{ - //YYF 平板模式设计稿中没有此图标 -// QString qpmQss = "QLabel{background-image:url(':/res/s/conning-a/"; -// qpmQss.append(QString::number(this->waitPage)); -// qpmQss.append(".png');}"); -// ui->lbWaitingIcon->setStyleSheet(qpmQss); - -// this->waitPage --; -// if (this->waitPage < 1) { -// this->waitPage = TOTAL_PAGE; //循环播放8张图片 -// } - -// this->countCurrentTime += FRAME_SPEED; -// if (this->countCurrentTime >= LIMIT_TIME) { -// QString cmd = "kill -9 $(pidof nmcli)"; //杀掉当前正在进行的有关nmcli命令的进程 -// int status = system(cmd.toUtf8().data()); -// if (status != 0) { -// qDebug()<<"execute 'kill -9 $(pidof nmcli)' in function 'waitAnimStep' failed"; -// syslog(LOG_ERR, "execute 'kill -9 $(pidof nmcli)' in function 'waitAnimStep' failed"); -// } - -// this->stopWaiting(); //动画超出时间限制,强制停止动画 - -// mw->is_stop_check_net_state = 0; -// } -} - -void OneConnForm::startWaiting(bool isConn) -{ - //YYF 平板模式设计稿中没有此图标 -// this->isWaiting = true; -// if (isConn) { -// ui->lbWaiting->setStyleSheet("QLabel{border:0px;border-radius:10px;background-color:rgba(61,107,229,1);}"); -// } else { -// ui->btnDisConn->hide(); -// ui->lbWaiting->setStyleSheet("QLabel{border:0px;border-radius:10px;background-color:rgba(255,255,255,0.12);}"); -// } -// this->countCurrentTime = 0; -// this->waitPage = TOTAL_PAGE; //总共有8张图片 -// this->waitTimer->start(FRAME_SPEED); -// ui->lbWaiting->show(); -// ui->lbWaitingIcon->show(); - -// mw->setTrayLoading(true); -} - -void OneConnForm::stopWaiting() -{ - //YYF 平板模式设计稿中没有此图标 -// this->isWaiting = false; -// this->waitTimer->stop(); -// ui->lbWaiting->hide(); -// ui->lbWaitingIcon->hide(); - -// mw->setTrayLoading(false); -// mw->getActiveInfo(); -} diff --git a/KylinNM/src/oneconnform.h b/KylinNM/src/oneconnform.h deleted file mode 100644 index 70bbbd8..0000000 --- a/KylinNM/src/oneconnform.h +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see -#include -#include -#include -#include -#include -#include - -#include "confform.h" -#include "backthread.h" -#include "ksimplenm.h" - -#define FRAME_SPEED 150 -#define LIMIT_TIME 20*1000 -#define TOTAL_PAGE 8 - -#define W_ITEM 414 -#define H_ITEM 60 -#define H_ITEM_BIG 138 -#define H_ITEM_MIDDLE 156 -#define H_WIFI_ITEM_BIG_EXTEND 78 //138 - 60 -#define H_WIFI_ITEM_SMALL_EXTEND 96 //156 - 56 -#define Y_LINE 59 -#define X_LINE 2 -#define Y_LINE_SMALL_EXTEND 105 -#define X_LINE_SMALL_EXTEND 2 -#define Y_LINE_BIG_EXTEND 137 -#define X_LINE_BIG_EXTEND 2 - -class KylinNM; - -namespace Ui { -class OneConnForm; -} - -class OneConnForm : public QWidget -{ - Q_OBJECT - -public: - explicit OneConnForm(QWidget *parent = 0, KylinNM *mw = 0, ConfForm *confForm = 0, KSimpleNM *ksnm = 0); - ~OneConnForm(); - - void setSignal(QString lv, QString secu); - void setSignalOn(QString lv, QString secu); - void setName(QString name); - void setSpecialName(QString name); - QString getName(); - void setRate(QString rate); - void setLine(bool isShow); - void setWifiInfo(QString str1, QString str2, QString str3); - - void setSelected(bool isSelected, bool isCurrName); - void setHideItem(bool isHideItem, bool isShowHideBtn); - void setTopItem(bool isSelected); - void setAct(bool isAct); - - void setConnedString(bool showLable, QString str, QString str1); - - bool isWifiConfExist(QString netName); - - QString wifiName; - bool isSelected; - bool isActive; - bool isConnected; - bool isTopItem; - int signalLv; - -protected: - void mousePressEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event) override; - bool eventFilter(QObject *obj, QEvent *event); - -private Q_SLOTS: - void tabletStyle(); - void on_btnConn_clicked(); - void on_btnConnSub_clicked(); - void on_btnDisConn_clicked(); - void on_btnInfo_2_clicked(); - void toConnectWirelessNetwork(); - void on_autoConn_toggled(bool val); - - void slotConnWifi(); - void slotConnWifiPWD(); - void slotConnWifiResult(int connFlag); - - void on_btnConnPWD_clicked(); - - void on_btnHideConn_clicked(); - - void on_checkBoxPwd_stateChanged(int arg1); - - void on_lePassword_textEdited(const QString &arg1); - - void waitAnimStep(); - void startWaiting(bool isConn); - void stopWaiting(); - - void on_btnInfo_clicked(); - -private: - QTimer *waitTimer = nullptr; - int waitPage; - int countCurrentTime; - bool isWaiting = false; - - Ui::OneConnForm *ui = nullptr; - KylinNM *mw = nullptr; - ConfForm *cf = nullptr; - KSimpleNM *ks = nullptr; - bool hasPwd; - - QString leQssLow, leQssHigh; - - QString signalStrong="0"; - QString signalHasPw="--"; - bool is_connecting = false; - -Q_SIGNALS: - void selectedOneWifiForm(QString wifiName, int extendLength); - void connDone(int connFlag); - void disconnActiveWifi(); - - void sigConnWifi(QString); - void sigConnWifiPWD(QString, QString); - - void onLineEditClicked(); -}; - -#endif // ONECONNFORM_H diff --git a/KylinNM/src/oneconnform.ui b/KylinNM/src/oneconnform.ui deleted file mode 100644 index 77e347e..0000000 --- a/KylinNM/src/oneconnform.ui +++ /dev/null @@ -1,306 +0,0 @@ - - - OneConnForm - - - - 0 - 0 - 424 - 156 - - - - Form - - - - - 63 - 8 - 190 - 20 - - - - - - - - - - 316 - 14 - 100 - 34 - - - - - - - - - - 316 - 14 - 100 - 34 - - - - - - - - - - 14 - 14 - 28 - 28 - - - - - - - - - - 63 - 31 - 140 - 20 - - - - - - - - - - 0 - 0 - 424 - 156 - - - - - - 56 - 56 - 254 - 48 - - - - - - - 286 - 75 - 16 - 8 - - - - - - - - - - 56 - 110 - 414 - 40 - - - - - - - - - - - 326 - 14 - 80 - 40 - - - - - - - - - - 318 - 56 - 80 - 48 - - - - - - - - - - 316 - 14 - 100 - 34 - - - - - - - - - - 0 - 0 - 424 - 138 - - - - - - 63 - 64 - 230 - 56 - - - - - - - - - - 63 - 62 - 230 - 20 - - - - - - - 63 - 86 - 230 - 20 - - - - - - - 63 - 110 - 230 - 20 - - - - leInfo_1 - leInfo_2 - leInfo_3 - btnInfo - - - - - 2 - 59 - 421 - 2 - - - - background-color: rgba(255, 255, 255,0.05); - - - Qt::Horizontal - - - - - - 0 - 0 - 414 - 56 - - - - - - - 280 - 20 - 20 - 20 - - - - - - - - - - 280 - 20 - 20 - 20 - - - - - - - - - - 372 - 14 - 16 - 16 - - - - - - - wbg_3 - wbg_2 - lbName - lbSignal - lbConned - line - wbg - btnConnSub - btnConn - btnConnPWD - btnDisConn - btnHideConn - lbWaiting - lbWaitingIcon - btnInfo_2 - - - - diff --git a/KylinNM/src/onelancform.cpp b/KylinNM/src/onelancform.cpp deleted file mode 100644 index b297910..0000000 --- a/KylinNM/src/onelancform.cpp +++ /dev/null @@ -1,482 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see - -OneLancForm::OneLancForm(QWidget *parent, KylinNM *mainWindow, ConfForm *confForm, KSimpleNM *ksnm) : - QWidget(parent), - ui(new Ui::OneLancForm) -{ - ui->setupUi(this); - - ui->btnConnSub->setText(tr("Connect"));//"设置" - ui->btnConn->setText(tr("Connect"));//"连接" - ui->btnConn->hide();//YYF - ui->btnDisConn->setText(tr("Disconnect"));//"断开连接" - - ui->lbConned->setAlignment(Qt::AlignLeft); - - leQssLow = "QLineEdit{border:none;background:transparent;font-size:14px;color:rgba(255,255,255,0.57);font-family:Noto Sans CJK SC;}"; - leQssHigh = "QLineEdit{border:none;background:transparent;font-size:14px;color:rgba(255,255,255,0.91);font-family:Noto Sans CJK SC;}"; - - ui->leInfo_1->setStyleSheet(leQssLow); - ui->leInfo_2->setStyleSheet(leQssLow); - ui->leInfo_3->setStyleSheet(leQssLow); - ui->leInfo_4->setStyleSheet(leQssLow); - ui->btnInfo->setStyleSheet("QPushButton{border:none;background:transparent;}"); - ui->wbg->setStyleSheet("#wbg{border-radius:8px;background-color:rgba(255,255,255,0.1);border:1px solid red;}");//主窗口(展开) - ui->wbg_2->setStyleSheet("#wbg_2{border-radius:8px;background-color:rgba(255,255,255,0);}");//列表窗口(闭合) - ui->lbName->setStyleSheet("QLabel{font-size:14px;color:rgba(38, 38, 38, 1);}");//列表名称 - ui->lbConned->setStyleSheet("QLabel{font-size:14px;color:rgba(47, 179, 232, 1);}");//已连接 - ui->btnConnSub->setStyleSheet("QPushButton{border:0px;border-radius:4px;background-color:rgba(61,107,229,1);color:white;font-size:14px;}" - "QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(107,142,235,1);}" - "QPushButton:Pressed{border-radius:4px;background-color:rgba(50,87,202,1);}"); - ui->btnConn->setStyleSheet("QPushButton{border:0px;border-radius:4px;background-color:rgba(61,107,229,1);color:white;font-size:14px;}" //连接按钮 - "QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(107,142,235,1);}" - "QPushButton:Pressed{border-radius:4px;background-color:rgba(50,87,202,1);}"); -// ui->btnDisConn->setStyleSheet("QPushButton{border:0px;border-radius:4px;background-color:rgba(255,255,255,0.12);color:white;font-size:14px;}" -// "QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(255,255,255,0.2);}" -// "QPushButton:Pressed{border-radius:8px;background-color:rgba(255,255,255,0.08);}"); - ui->btnDisConn->setStyleSheet("#btnDisConn{font-family: NotoSansCJKsc-Regular, NotoSansCJKsc;" - "font-weight: 400;color: rgba(38,38,38,0.75);line-height: 20px;font-size:14px;" - "border:0px;background-color:rgba(38,38,38,0.1);border-radius:8px;}" - "#btnDisConn:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:8px;background-color:rgba(38,38,38,0.2);}" - "#btnDisConn:Pressed{border-radius:8px;background-color:rgba(38,38,38,0.06);}");//断开链接按钮 - ui->btnConnCfg->setStyleSheet("border:0px;border-radius:4px;border-image:url(:/res/l/pb-network-info.png);");//链接详情按钮 - connect(ui->btnConnCfg,&QPushButton::clicked,this,&OneLancForm::on_btnInfo_clicked); - ui->btnConnCfg->hide(); - - - ui->btnInfo->setCursor(QCursor(Qt::PointingHandCursor)); - ui->btnInfo->setFocusPolicy(Qt::NoFocus); - ui->btnConnSub->setFocusPolicy(Qt::NoFocus); - ui->btnConn->setFocusPolicy(Qt::NoFocus); - ui->btnDisConn->setFocusPolicy(Qt::NoFocus); - - ui->wbg->hide(); - ui->wbg_2->show(); - ui->lbName->show(); - ui->btnConnSub->hide(); - //YYF ui->btnConn->hide(); - ui->btnDisConn->hide(); - ui->line->show(); - ui->lbWaiting->hide(); - ui->lbWaitingIcon->hide(); - - this->mw = mainWindow; - this->cf = confForm; - this->ks = ksnm; - - this->isSelected = false; - this->isActive = false; - - this->setAttribute(Qt::WA_Hover,true); - this->installEventFilter(this); - ui->btnInfo->setAttribute(Qt::WA_Hover,true); - ui->btnInfo->installEventFilter(this); - - this->waitTimer = new QTimer(this); - connect(waitTimer, SIGNAL(timeout()), this, SLOT(waitAnimStep())); - - connect(mw, SIGNAL(waitLanStop()), this, SLOT(stopWaiting())); - - srand((unsigned)time(NULL)); - - ui->lbWaiting->setStyleSheet("QLabel{border:0px;border-radius:4px;background-color:rgba(61,107,229,1);}"); - //ui->lbWaitingIcon->setStyleSheet("QLabel{border:0px;background-color:transparent;}"); - ui->lbWaitingIcon->setStyleSheet("QLabel{border:0px;background-color:transparent;}"); - ui->lbWaitingIcon->move(316+194*mw->isTabletStyle,20);// YYF - tabletStyle();//平板模式PC桌面样式 -} - -void OneLancForm::tabletStyle()//平板桌面模式特有设置 -{ - ui->lbName->setFixedWidth(190+194*mw->isTabletStyle); - ui->btnInfo->setFixedWidth(414+194*mw->isTabletStyle); - ui->wbg_2->setFixedWidth(414+194*mw->isTabletStyle); - ui->btnDisConn->move(316+194*mw->isTabletStyle,8 + 18*mw->isTabletStyle); - ui->btnConnCfg->move(364+194*mw->isTabletStyle,18 + 18*mw->isTabletStyle); -} - -OneLancForm::~OneLancForm() -{ - delete ui; -} - -void OneLancForm::mousePressEvent(QMouseEvent *event) -{ - if (event->button() != Qt::LeftButton) { - event->ignore(); - return; - } - ui->wbg_2->setStyleSheet("#wbg_2{border-radius:8px;background-color:rgba(38,38,38,0.1);}"); -} - -void OneLancForm::mouseReleaseEvent(QMouseEvent *event) -{ - if (event->button() != Qt::LeftButton || !rect().contains(event->pos())) { - event->ignore(); - return; - } - if(ui->btnDisConn->isHidden()) { - on_btnConn_clicked();// YYF - } - ui->wbg_2->setStyleSheet("#wbg_2{border-radius:8px;background-color:rgba(255,255,255,0);}"); -} - -//事件过滤器 -bool OneLancForm::eventFilter(QObject *obj, QEvent *event) -{ - if (obj == ui->btnInfo) { - if(event->type() == QEvent::HoverEnter) { - ui->leInfo_1->setStyleSheet(leQssHigh); - ui->leInfo_2->setStyleSheet(leQssHigh); - ui->leInfo_3->setStyleSheet(leQssHigh); - ui->leInfo_4->setStyleSheet(leQssHigh); - return true; - } else if(event->type() == QEvent::HoverLeave) { - ui->leInfo_1->setStyleSheet(leQssLow); - ui->leInfo_2->setStyleSheet(leQssLow); - ui->leInfo_3->setStyleSheet(leQssLow); - ui->leInfo_4->setStyleSheet(leQssLow); - return true; - } - } else if (obj == this) { - if (event->type() == QEvent::HoverEnter) { - if (!this->isTopItem) { - if (!this->isSelected) { - //YYF ui->btnConn->show(); - ui->wbg_2->setStyleSheet("#wbg_2{border-radius:8px;background-color:rgba(38,38,38,0.05);}"); - ui->wbg_2->show(); - } - } - return true; - } else if(event->type() == QEvent::HoverLeave) { - //YYF ui->btnConn->hide(); - ui->wbg_2->setStyleSheet("#wbg_2{border-radius:8px;background-color:rgba(255,255,255,0);}"); - ui->wbg_2->hide(); - return true; - } - } - - return QWidget::eventFilter(obj,event); -} - -// 是否当前连接的网络,字体设置不同 -void OneLancForm::setAct(bool isAct) -{ - if (isAct) { - ui->lbName->setStyleSheet("QLabel{font-size:14px;color:rgba(47, 179, 232, 1);}"); - ui->lbConned->show(); - ui->btnConnSub->hide(); - } else { - ui->lbName->setStyleSheet("QLabel{font-size:14px;color:rgba(38, 38, 38, 0.45);}"); - ui->lbConned->hide(); - ui->btnConnSub->hide(); - } - isActive = isAct; -} - -// 是否选中 -void OneLancForm::setSelected(bool isSelected, bool isCurrName) -{ - if (isSelected) { - resize(W_ITEM, H_ITEM_EXTEND); - ui->wbg->show(); - ui->wbg_2->hide(); - ui->line->move(X_LINE_EXTEND, Y_LINE_EXTEND); - //YYF ui->btnConn->hide(); - ui->btnConnSub->show(); - - this->isSelected = true; - } else { - resize(W_ITEM, H_ITEM); - ui->wbg->hide(); - ui->wbg_2->show(); - ui->line->move(X_LINE, Y_LINE); - if(isCurrName){ - //YYF ui->btnConn->show(); - }else{ - //YYF ui->btnConn->hide(); - } - ui->btnConnSub->hide(); - - this->isSelected = false; - } - - ui->btnDisConn->hide(); - - this->isTopItem = false; -} - -//设置顶部这个item的显示 -void OneLancForm::setTopItem(bool isSelected) -{ -// if (isSelected) { -// resize(W_ITEM, H_ITEM_EXTEND); -// ui->wbg->show(); -// ui->btnConnSub->hide(); -// this->isSelected = true; -// } else { -// resize(W_ITEM, H_ITEM); -// ui->wbg->hide(); -// ui->btnConnSub->hide(); -// this->isSelected = false; -// } - - if (isConnected) { - ui->lbIcon->setStyleSheet("QLabel{border-radius:0px;border-image:url(:/res/l/pb-network-online.png);}"); - ui->btnDisConn->show(); -// ui->btnConnCfg->show(); - } else { - ui->lbIcon->setStyleSheet("QLabel{border-radius:0px;border-image:url(:/res/l/pb-top-network-offline.png);}"); -// ui->btnConnCfg->hide(); - ui->btnDisConn->hide(); - } - ui->btnConnCfg->hide(); - - //YYF ui->btnConn->hide(); - ui->wbg_2->hide(); - ui->line->hide(); - - this->isTopItem = true; -} - -//设置网络名称 -void OneLancForm::setName(QString name, QString uniName) -{ - ui->lbName->setText(name); - lanName = name; - uniqueName = uniName; -} - -//根据有线网络连接与否,设置显示'已连接'文字的控件的可见与否 -void OneLancForm::setConnedString(bool showLable, QString str) -{ - if (!showLable) { - ui->lbConned->hide(); - ui->lbName->move(63, 18); - } else { - str="";//YYF 平板模式 - ui->lbConned->setText(str); - ui->lbName->move(63, 18); //YYF - } -} - -//设置item被扩展后出现的网络信息 -void OneLancForm::setLanInfo(QString str1, QString str2, QString str3, QString str4) -{ - if (str1 == "" || str1 == "auto") { - str1 = tr("No Configuration"); - } - - if (str2 == "" || str2 == "auto") { - str2 = tr("No Configuration"); - } - - QString strIPv4 = QString(tr("IPv4:")); - QString strIPv6 = QString(tr("IPv6:")); - QString strBW = QString(tr("BandWidth:")); - QString strMAC = QString(tr("MAC:")); - - ui->leInfo_1->setText(strIPv4 + str1); - ui->leInfo_2->setText(strIPv6 + str2); - ui->leInfo_3->setText(strBW + str3); - ui->leInfo_4->setText(strMAC + str4); -} - -//根据网络是否连接,设置网络状态图标 -void OneLancForm::setIcon(bool isOn) -{ - if (isOn) { - ui->lbIcon->setStyleSheet("QLabel{border-radius:0px;border-image:url(:/res/l/pb-network-online.png);}"); - } else { - ui->lbIcon->setStyleSheet("QLabel{border-radius:0px;border-image:url(:/res/l/pb-network-offline.png);}"); - } -} - -//设置item下方横线的可见与否 -void OneLancForm::setLine(bool isShow) -{ - if (isShow) { - ui->line->show(); - } else { - ui->line->hide(); - } -} - -void OneLancForm::slotConnLan() -{ - //mw->startLoading(); - this->startWaiting(true); - emit sigConnLan(ui->lbName->text()); -} - -//点击网络断开按钮,执行该函数 -void OneLancForm::on_btnDisConn_clicked() -{ - syslog(LOG_DEBUG, "DisConnect button about lan net is clicked, current wired net name is %s .", ui->lbName->text().toUtf8().data()); - qDebug()<<"DisConnect button about lan net is clicked, current wired net name is "<lbName->text(); - - this->startWaiting(false); - mw->is_stop_check_net_state = 1; - - kylin_network_set_con_down(ui->lbName->text().toUtf8().data()); - - disconnect(this, SIGNAL(selectedOneLanForm(QString, QString)), mw, SLOT(oneTopLanFormSelected(QString, QString))); - - emit disconnActiveLan(); -} - -//点击了连接网络按钮,执行该函数 -void OneLancForm::on_btnConn_clicked() -{ - syslog(LOG_DEBUG, "A button named btnConn about lan net is clicked."); - qDebug()<<"A button named btnConn about lan net is clicked."; - toConnectWiredNetwork(); -} - -//点击了item被扩展中的连接网络按钮,执行该函数 -void OneLancForm::on_btnConnSub_clicked() -{ - syslog(LOG_DEBUG, "A button named btnConnSub about lan net is clicked."); - qDebug()<<"A button named btnConnSub about lan net is clicked."; - toConnectWiredNetwork(); -} - -void OneLancForm::toConnectWiredNetwork() -{ - mw->is_stop_check_net_state = 1; - QThread *t = new QThread(); - BackThread *bt = new BackThread(); - bt->moveToThread(t); - connect(t, SIGNAL(finished()), t, SLOT(deleteLater())); - connect(t, SIGNAL(started()), this, SLOT(slotConnLan())); - connect(this, SIGNAL(sigConnLan(QString)), bt, SLOT(execConnLan(QString))); -// connect(bt, SIGNAL(connDone(int)), mw, SLOT(connLanDone(int))); - connect(bt, &BackThread::connDone, this, [=](int f) { - mw->connLanDone(f); - }); - connect(bt, SIGNAL(btFinish()), t, SLOT(quit())); - t->start(); -} - -//点击列表中item扩展后显示信息的位置时,执行该函数,用于显示网络配置界面 -void OneLancForm::on_btnInfo_clicked() -{ - QPoint pos = QCursor::pos(); - QRect primaryGeometry; - for (QScreen *screen : qApp->screens()) { - if (screen->geometry().contains(pos)) { - primaryGeometry = screen->geometry(); - } - } - - if (primaryGeometry.isEmpty()) { - primaryGeometry = qApp->primaryScreen()->geometry(); - } - - BackThread *bt = new BackThread(); - QString connProp = bt->getConnProp(ui->lbName->text()); - QStringList propList = connProp.split("|"); - QString v4method, addr, mask, gateway, dns; - foreach (QString line, propList) { - if (line.startsWith("method:")) { - v4method = line.split(":").at(1); - } - if (line.startsWith("addr:")) { - addr = line.split(":").at(1); - } - if (line.startsWith("mask:")) { - mask = line.split(":").at(1); - } - if (line.startsWith("gateway:")) { - gateway= line.split(":").at(1); - } - if (line.startsWith("dns:")) { - dns = line.split(":").at(1); - } - } - // qDebug()<setProp(ui->lbName->text(), v4method, addr, mask, gateway, dns, this->isActive); - connect(cf, SIGNAL(requestRefreshLanList(int)), mw, SLOT(onBtnNetListClicked(int))); - - cf->move(primaryGeometry.width() / 2 - cf->width() / 2, primaryGeometry.height() / 2 - cf->height() / 2); - cf->show(); - cf->raise(); - cf->activateWindow(); -} - -void OneLancForm::waitAnimStep() -{ - QString qpmQss = "QLabel{background-image:url(':/res/s/conning-a/"; - qpmQss.append(QString::number(this->waitPage)); - qpmQss.append(".png');}"); - ui->lbWaitingIcon->setStyleSheet(qpmQss); - - this->waitPage --; - if (this->waitPage < 1) { - this->waitPage = TOTAL_PAGE; //循环播放8张图片 - } - - this->countCurrentTime += FRAME_SPEED; - if (this->countCurrentTime >= LIMIT_TIME) { - QString cmd = "kill -9 $(pidof nmcli)"; //杀掉当前正在进行的有关nmcli命令的进程 - int status = system(cmd.toUtf8().data()); - if (status != 0) { - qDebug()<<"execute 'kill -9 $(pidof nmcli)' in function 'waitAnimStep' failed"; - syslog(LOG_ERR, "execute 'kill -9 $(pidof nmcli)' in function 'waitAnimStep' failed"); - } - - this->stopWaiting(); //动画超出时间限制,强制停止动画 - - mw->is_stop_check_net_state = 0; - } -} - -void OneLancForm::startWaiting(bool isConn) -{ - if (isConn) { - ui->lbWaiting->setStyleSheet("QLabel{border:0px;border-radius:4px;background-color:rgba(61,107,229,1);}"); - } else { - ui->btnDisConn->hide(); - ui->lbWaiting->setStyleSheet("QLabel{border:0px;border-radius:4px;background-color:rgba(255,255,255,0.12);}"); - } - this->countCurrentTime = 0; - this->waitPage = TOTAL_PAGE; //总共有8张图片 - this->waitTimer->start(FRAME_SPEED); -// ui->lbWaiting->show(); YYF - ui->lbWaitingIcon->show(); - - mw->setTrayLoading(true); -} - -void OneLancForm::stopWaiting() -{ - this->waitTimer->stop(); - ui->lbWaiting->hide(); - ui->lbWaitingIcon->hide(); - - mw->setTrayLoading(false); - mw->getActiveInfo(); -} diff --git a/KylinNM/src/onelancform.h b/KylinNM/src/onelancform.h deleted file mode 100644 index 3d1f196..0000000 --- a/KylinNM/src/onelancform.h +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see -#include -#include -#include - -#include "confform.h" -#include "kylin-network-interface.h" -#include "backthread.h" -#include "ksimplenm.h" - -#define FRAME_SPEED 150 -#define LIMIT_TIME 20*1000 -#define TOTAL_PAGE 8 - -#define W_ITEM 424 -#define H_ITEM 60 -#define H_ITEM_EXTEND 162 -#define Y_LINE 59 -#define X_LINE 2 -#define Y_LINE_EXTEND 161 -#define X_LINE_EXTEND 2 - -class KylinNM; - -namespace Ui { -class OneLancForm; -} - -class OneLancForm : public QWidget -{ - Q_OBJECT - -public: - explicit OneLancForm(QWidget *parent = 0, KylinNM *mw = 0, ConfForm *confForm = 0, KSimpleNM *ksnm = 0); - ~OneLancForm(); - - void setName(QString name, QString uniName); - void setIcon(bool isOn); - void setLine(bool isShow); - void setLanInfo(QString str1, QString str2, QString str3, QString str4); - - void setSelected(bool isSelected, bool isCurrName); - void setTopItem(bool isSelected); - void setAct(bool isAct); - - void setConnedString(bool showLable, QString str); - - bool isSelected; - bool isTopItem; - bool isActive; - bool isConnected; - QString lanName; - QString uniqueName; - -protected: - void mousePressEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event) override; - bool eventFilter(QObject *obj, QEvent *event); - -private Q_SLOTS: - void on_btnConn_clicked(); - void on_btnConnSub_clicked(); - void on_btnDisConn_clicked(); - void toConnectWiredNetwork(); - - void slotConnLan(); - - void waitAnimStep(); - void startWaiting(bool isConn); - void stopWaiting(); - - void on_btnInfo_clicked(); - -private: - void tabletStyle();//YYF 平板桌面模式特有设置 - - QTimer *waitTimer = nullptr; - int waitPage; - int countCurrentTime; - - Ui::OneLancForm *ui = nullptr; - KylinNM *mw = nullptr; - ConfForm *cf = nullptr; - KSimpleNM *ks = nullptr; - - QString leQssLow, leQssHigh; - -Q_SIGNALS: - void selectedOneLanForm(QString lanName, QString uniqueName); - void connDone(int connFlag); - void disconnActiveLan(); - - void sigConnLan(QString); -}; - -#endif // ONELANCFORM_H diff --git a/KylinNM/src/onelancform.ui b/KylinNM/src/onelancform.ui deleted file mode 100644 index f57060f..0000000 --- a/KylinNM/src/onelancform.ui +++ /dev/null @@ -1,242 +0,0 @@ - - - OneLancForm - - - - 0 - 0 - 424 - 250 - - - - Form - - - - - 63 - 8 - 190 - 20 - - - - - - - - - - 316 - 14 - 100 - 34 - - - - - - - - - - 316 - 14 - 100 - 34 - - - - - - - - - - 316 - 18 - 80 - 40 - - - - - - - - - - 63 - 31 - 52 - 20 - - - - - - - - - - 0 - 0 - 424 - 162 - - - - - - 63 - 64 - 238 - 85 - - - - - - - - - - 63 - 62 - 238 - 20 - - - - - - - 63 - 86 - 250 - 20 - - - - - - - 63 - 110 - 238 - 20 - - - - - - - 63 - 134 - 238 - 20 - - - - leInfo_1 - leInfo_2 - leInfo_3 - leInfo_4 - btnInfo - - - - - 14 - 14 - 24 - 24 - - - - - - - - - - 2 - 59 - 421 - 2 - - - - background-color: rgba(255, 255, 255,0.05); - - - Qt::Horizontal - - - - - - 0 - 0 - 340 - 56 - - - - - - - 316 - 14 - 100 - 34 - - - - - - - - - - 356 - 20 - 20 - 20 - - - - - - - - - - 364 - 18 - 16 - 16 - - - - - - - lbName - lbConned - lbIcon - line - wbg - wbg_2 - btnConnSub - btnDisConn - btnConn - lbWaiting - lbWaitingIcon - btnConnCfg - - - - diff --git a/KylinNM/src/swipegesturerecognizer.cpp b/KylinNM/src/swipegesturerecognizer.cpp deleted file mode 100644 index dd888c3..0000000 --- a/KylinNM/src/swipegesturerecognizer.cpp +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#include -#include - -#include -#include "swipegesturerecognizer.h" - -SwipeGestureRecognizer::SwipeGestureRecognizer(QObject *parent) : QObject(parent) -{ -} - -bool -SwipeGestureRecognizer::IsValidMove(int dx, int dy) -{ - // The moved distance is to small to count as not just a glitch. - if ((qAbs(dx) < MINIMUM_DISTANCE) && (qAbs(dy) < MINIMUM_DISTANCE)) { - return false; - } - - return true; -} - - -// virtual -QGesture* -SwipeGestureRecognizer::create(QObject* pTarget) -{ - QGesture *pGesture = new QSwipeGesture(pTarget); - return pGesture; -} - - -// virtual -QGestureRecognizer::Result -SwipeGestureRecognizer::recognize(QGesture* pGesture, QObject *pWatched, QEvent *pEvent) -{ - QGestureRecognizer::Result result = QGestureRecognizer::Ignore; - QSwipeGesture *pSwipe = static_cast(pGesture); - - switch(pEvent->type()) { - case QEvent::MouseButtonPress: { - QMouseEvent* pMouseEvent = static_cast(pEvent); -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) - pSwipe->setProperty("startPoint", pMouseEvent->posF()); -#else - pSwipe->setProperty("startPoint", pMouseEvent->localPos()); -#endif - result = QGestureRecognizer::MayBeGesture; - //qDebug() << "Swipe gesture started (start point=" << pSwipe->property("startPoint").toPointF() << ")"; - } - break; - case QEvent::MouseButtonRelease: { - QMouseEvent* pMouseEvent = static_cast(pEvent); - const QVariant& propValue = pSwipe->property("startPoint"); - QPointF startPoint = propValue.toPointF(); -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) - QPointF endPoint = pMouseEvent->posF(); -#else - QPointF endPoint = pMouseEvent->localPos(); -#endif - - // process distance and direction - int dx = endPoint.x() - startPoint.x(); - int dy = endPoint.y() - startPoint.y(); - - //bugfix: startPoint.isNull because we sometimes get false events with startpoint 0 -> wrong swipe detected! - if ( (!IsValidMove(dx, dy)) || ( startPoint.isNull() ) ) { - // Just a click, so no gesture. - result = QGestureRecognizer::CancelGesture; - //qDebug("Swipe gesture canceled"); - } else { - // Compute the angle. - // qDebug() << " startPoint= " << startPoint << " endPoint=" << endPoint << " dx=" << dx << " dy=" << dy; - Q_EMIT onSwipeGesture(dx, dy); - qreal angle = ComputeAngle(dx, dy); - pSwipe->setSwipeAngle(angle); - result = QGestureRecognizer::FinishGesture; - //qDebug("Swipe gesture finished"); - } - } - break; - default: - break; - } - - return result; -} - -void -SwipeGestureRecognizer::reset(QGesture *pGesture) -{ - pGesture->setProperty("startPoint", QVariant(QVariant::Invalid)); - parent::reset(pGesture); -} - -qreal -SwipeGestureRecognizer::ComputeAngle(int dx, int dy) -{ - double PI = 3.14159265; - - // Need to convert from screen coordinates direction - // into classical coordinates direction. - dy = -dy; - - double result = atan2((double)dy, (double)dx) ; - result = (result * 180) / PI; - - // Always return positive angle. - if (result < 0) { - result += 360; - } - - return result; -} - - - -/* -========================================================================== -*/ - -QSwipeGesture::SwipeDirection -SwipeGestureUtil::GetHorizontalDirection(QSwipeGesture *pSwipeGesture) -{ - qreal angle = pSwipeGesture->swipeAngle(); - if (0 <= angle && angle <= 45) { - return QSwipeGesture::Right; - } - - if (135 <= angle && angle <= 225) { - return QSwipeGesture::Left; - } - - if (315 <= angle && angle <= 360) { - return QSwipeGesture::Right; - } - - return QSwipeGesture::NoDirection; -} - -QSwipeGesture::SwipeDirection -SwipeGestureUtil::GetVerticalDirection(QSwipeGesture *pSwipeGesture) -{ - qreal angle = pSwipeGesture->swipeAngle(); - - if (45 < angle && angle < 135) { - return QSwipeGesture::Up; - } - - if (225 < angle && angle < 315) { - return QSwipeGesture::Down; - } - - return QSwipeGesture::NoDirection; -} diff --git a/KylinNM/src/swipegesturerecognizer.h b/KylinNM/src/swipegesturerecognizer.h deleted file mode 100644 index 4b6c7b8..0000000 --- a/KylinNM/src/swipegesturerecognizer.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#ifndef SWIPEGESTURERECOGNIZER_H -#define SWIPEGESTURERECOGNIZER_H - -#include -#include -#include -#include "kylinnm.h" - -/** - * @brief The SwipeGestureRecognizer class - * needed because the defalt implementation of swipe is a little bit odd: it only triggers on 3 finger swipes! (5.3) - * - * http://developer.android.com/design/patterns/gestures.html - * http://qt-project.org/doc/qt-5/gestures-overview.html - */ -class SwipeGestureRecognizer :public QObject, public QGestureRecognizer -{ - Q_OBJECT -public: - SwipeGestureRecognizer(QObject *parent = nullptr); -private: - static const int MINIMUM_DISTANCE = 10; - - typedef QGestureRecognizer parent; - - bool IsValidMove(int dx, int dy); - - qreal ComputeAngle(int dx, int dy); - - virtual QGesture* create(QObject* pTarget); - - virtual QGestureRecognizer::Result recognize(QGesture* pGesture, QObject *pWatched, QEvent *pEvent); - - void reset (QGesture *pGesture); -signals: - void onSwipeGesture(int dx, int dy); -}; - - -class SwipeGestureUtil { -public: - static QSwipeGesture::SwipeDirection GetHorizontalDirection(QSwipeGesture *pSwipeGesture); - static QSwipeGesture::SwipeDirection GetVerticalDirection(QSwipeGesture *pSwipeGesture); -}; - -#endif // SWIPEGESTURERECOGNIZER_H diff --git a/KylinNM/src/switchbutton.cpp b/KylinNM/src/switchbutton.cpp deleted file mode 100644 index 43ad098..0000000 --- a/KylinNM/src/switchbutton.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#include "switchbutton.h" - -SwitchButton::SwitchButton(QWidget *parent) : QWidget(parent) -{ - - setFixedSize(50,24); - m_fWidth = (float)width(); - m_fHeight = (float)height(); - m_cTimer = new QTimer(this); - m_cTimer->setInterval(5); - - if(m_bIsOn == 1) { - m_fCurrentValue = m_fWidth - 16 - 4; - } - else { - m_fCurrentValue = 4; - } - connect(m_cTimer,SIGNAL(timeout()),this,SLOT(startAnimation())); - - -} - -void SwitchButton::setSwitchStatus(bool check) { - if(check == true) { - m_bIsOn = 1; - } else { - m_bIsOn = 0; - } - - m_cTimer->start(); //开始播放动画 -} - - -/* 播放按钮开启关闭动画 */ -void SwitchButton::startAnimation() { //滑动按钮动作播放 - int pos = 4; - int size = m_fWidth - 16; - if(m_bIsOn) { - m_fCurrentValue ++; //往右滑动 - if(m_fCurrentValue >= size - pos) { //到达边界停下来 - m_fCurrentValue = size - pos; - m_cTimer->stop(); - } - - } else { - m_fCurrentValue --; - if(m_fCurrentValue <= pos) { //到达最小值,停止继续前进 - m_fCurrentValue = pos; - m_cTimer->stop(); - } - } - update(); -} - -/* 按钮按下处理 */ -void SwitchButton::mousePressEvent(QMouseEvent *event) { - Q_UNUSED(event); - m_bIsOn = !m_bIsOn; - - Q_EMIT clicked(m_bIsOn); - - return QWidget::mousePressEvent(event); -} - -/* 绘制滑动按钮主体 */ -void SwitchButton::paintEvent(QPaintEvent *event) { - Q_UNUSED(event); - QPainter painter(this); - painter.setRenderHint(QPainter::SmoothPixmapTransform); - painter.setRenderHint(QPainter::Antialiasing); //抗锯齿效果 - painter.setPen(Qt::NoPen); - QColor colorActive(61,107,229); - QColor colorInactive(111,111,111); - colorInactive.setAlphaF(0.12); - if(m_bIsOn) { - painter.save(); - painter.setBrush(colorActive); - QRectF active_rect = QRectF(0,0,m_fWidth,m_fHeight); - painter.drawRoundedRect(active_rect, 0.5 * m_fHeight, 0.5 * m_fHeight); //画开启状态 - } else { - painter.save(); - painter.setBrush(colorInactive); - QRectF inactive_rect = QRectF(0 ,0,m_fWidth,m_fHeight); - painter.drawRoundedRect(inactive_rect, 0.5 * m_fHeight, 0.5 * m_fHeight); //画关闭状态 - } - painter.restore(); - painter.save(); - painter.setBrush(Qt::white); - painter.drawEllipse(m_fCurrentValue,4, 16, 16); - painter.restore(); -} - diff --git a/KylinNM/src/switchbutton.h b/KylinNM/src/switchbutton.h deleted file mode 100644 index 8c86bc2..0000000 --- a/KylinNM/src/switchbutton.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#ifndef SWITCHBUTTON_H -#define SWITCHBUTTON_H - -#include -#include -#include -#include - -class SwitchButton : public QWidget -{ - Q_OBJECT -public: - explicit SwitchButton(QWidget *parent = nullptr); - void setSwitchStatus(bool check); - -private: - int m_bIsOn = 1; - QTimer *m_cTimer; - float m_fWidth; - float m_fHeight; - float m_fCurrentValue; - void paintEvent(QPaintEvent *event); - void mousePressEvent(QMouseEvent *event); - -Q_SIGNALS: - void clicked(int check); -private Q_SLOTS: - void startAnimation(); - -}; - -#endif // SWITCHBUTTON_H diff --git a/KylinNM/src/utils.cpp b/KylinNM/src/utils.cpp deleted file mode 100644 index 7821508..0000000 --- a/KylinNM/src/utils.cpp +++ /dev/null @@ -1,267 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see -#include -#include -#include -#include - -#include -#include -#include -#include - -/////////////////////////////////////////////////////////////////////////////// -// The Utils class - -Utils::Utils(){} - -int Utils::m_system(char *cmd) -{ - int status = 0; - pid_t pid; - - if ((pid = vfork()) <0) { - qDebug()<<"failed to create a subprocess by using vfork"; - syslog(LOG_ERR, "failed to create a subprocess by using vfork"); - status = -1; - } else if (pid==0) { - const char *new_argv[4]; - struct sigaction sa_cld; - sa_cld.sa_handler = SIG_DFL; - sa_cld.sa_flags = 0; - - // 在子进程中放开SIGINT信号 - sigemptyset(&sa_cld.sa_mask); - sigaction (SIGINT, &sa_cld, NULL); - sigaction (SIGQUIT, &sa_cld, NULL); - - new_argv[0] = "sh"; - new_argv[1] = "-c"; - new_argv[2] = cmd; - new_argv[3] = NULL; - - // execl("/bin/sh","sh","-c" ,cmd,(char *)0); - if (execve("/bin/sh",(char *const *) new_argv, NULL) <0) { - qDebug()<<"failed to execve a shell command in function m_system"; - syslog(LOG_ERR, "failed to execve %s! errno: %d\n",cmd, errno); - exit(1); - } else { - exit(0); - } - } else { - waitpid(pid,&status,0); - } - - return status; -} - -void Utils::onRequestSendDesktopNotify(QString message) -{ - QDBusInterface iface("org.freedesktop.Notifications", - "/org/freedesktop/Notifications", - "org.freedesktop.Notifications", - QDBusConnection::sessionBus()); - QList args; - args<<(QCoreApplication::applicationName()) - <<((unsigned int) 0) - < -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - - -/////////////////////////////////////////////////////////////////////////////// -// The Utils class, used to do some assist function - -class Utils : public QObject -{ - Q_OBJECT -public: - Utils(); - - static int m_system(char *cmd); - -public Q_SLOTS: - void onRequestSendDesktopNotify(QString message); - -}; - - -/////////////////////////////////////////////////////////////////////////////// -// The UseQssFile class, set control style by using .qss file - -class UseQssFile -{ -public: - static void setStyle(const QString &style) - { - QString styleName = ":/qss/" + style; - - QFile qss(styleName); - qss.open(QFile::ReadOnly); - qApp->setStyleSheet(qss.readAll()); - qss.close(); - } -}; - - -/////////////////////////////////////////////////////////////////////////////// -// The NetworkSpeed class, get the network upload and download speed - -class NetworkSpeed : public QObject -{ - Q_OBJECT -public: - explicit NetworkSpeed(QObject *parent = nullptr); - - int getCurrentDownloadRates(char *netname,long int * save_rate,long int * tx_rate); //获取当前的流量,参数为将获取到的流量保 -}; - - - - -/////////////////////////////////////////////////////////////////////////////// -// The CustomStyle class, inherit from class QProxyStyle, to change control style customize - -class CustomStyle : public QProxyStyle -{ - Q_OBJECT -public: - explicit CustomStyle(const QString &proxyStyleName = "windows", QObject *parent = nullptr); - - - virtual void drawComplexControl(QStyle::ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget = nullptr) const; - - virtual void drawControl(QStyle::ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = nullptr) const; - virtual void drawItemPixmap(QPainter *painter, const QRect &rectangle, int alignment, const QPixmap &pixmap) const; - virtual void drawItemText(QPainter *painter, const QRect &rectangle, int alignment, const QPalette &palette, bool enabled, const QString &text, QPalette::ColorRole textRole = QPalette::NoRole) const; - - virtual void drawPrimitive(QStyle::PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = nullptr) const; - virtual QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *option) const; - virtual QStyle::SubControl hitTestComplexControl(QStyle::ComplexControl control, const QStyleOptionComplex *option, const QPoint &position, const QWidget *widget = nullptr) const; - virtual QRect itemPixmapRect(const QRect &rectangle, int alignment, const QPixmap &pixmap) const; - virtual QRect itemTextRect(const QFontMetrics &metrics, const QRect &rectangle, int alignment, bool enabled, const QString &text) const; - //virtual int layoutSpacing(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2, Qt::Orientation orientation, const QStyleOption *option, const QWidget *widget); - virtual int pixelMetric(QStyle::PixelMetric metric, const QStyleOption *option = nullptr, const QWidget *widget = nullptr) const; - - virtual void polish(QWidget *widget); - virtual void polish(QApplication *application); - virtual void polish(QPalette &palette); - virtual void unpolish(QWidget *widget); - virtual void unpolish(QApplication *application); - - virtual QSize sizeFromContents(QStyle::ContentsType type, const QStyleOption *option, const QSize &contentsSize, const QWidget *widget = nullptr) const; - virtual QIcon standardIcon(QStyle::StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget) const; - virtual QPalette standardPalette() const; - - virtual int styleHint(QStyle::StyleHint hint, const QStyleOption *option = nullptr, const QWidget *widget = nullptr, QStyleHintReturn *returnData = nullptr) const; - - virtual QRect subControlRect(QStyle::ComplexControl control, const QStyleOptionComplex *option, QStyle::SubControl subControl, const QWidget *widget = nullptr) const; - - virtual QRect subElementRect(QStyle::SubElement element, const QStyleOption *option, const QWidget *widget = nullptr) const; - -Q_SIGNALS: - -public Q_SLOTS: -}; - -#endif // UTILS_H diff --git a/KylinNM/wireless-security/dlgconnhidwifi.cpp b/KylinNM/wireless-security/dlgconnhidwifi.cpp deleted file mode 100644 index 3901449..0000000 --- a/KylinNM/wireless-security/dlgconnhidwifi.cpp +++ /dev/null @@ -1,379 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see - -#include -#include - -DlgConnHidWifi::DlgConnHidWifi(int type, KylinNM *mainWindow, QWidget *parent) : - isUsed(type), - QDialog(parent), - ui(new Ui::DlgConnHidWifi()) -{ - ui->setupUi(this); - - this->setWindowFlags(Qt::FramelessWindowHint); - this->setAttribute(Qt::WA_TranslucentBackground); - //需要添加 void paintEvent(QPaintEvent *event) 函数 - - QPainterPath path; - auto rect = this->rect(); - rect.adjust(1, 1, -1, -1); - path.addRoundedRect(rect, 6, 6); - setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon())); - - KylinDBus mkylindbus; - QString strTrans; - strTrans = QString::number(1, 10, 2); - QString sty = "QWidget{border-radius:6px;background-color:rgba(255,255,255,1);border:1px solid rgba(255, 255, 255, 1);}"; - this->setStyleSheet(sty); - //this->setStyleSheet("QWidget{border-radius:6px;background-color:rgba(19,19,20,0.7);border:1px solid rgba(255, 255, 255, 0.05);}"); - - MyQss objQss; - - ui->lbBoder->setStyleSheet("QLabel{border-radius:6px;background-color:rgba(19,19,20,0.95);border:1px solid rgba(255, 255, 255, 0.05);}"); - ui->lbBoder->hide(); - ui->lbLeftupTitle->setStyleSheet("QLabel{border:0px;font-size:20px;color:rgba(255,255,255,0.97);background-color:transparent;}"); - ui->lbConn->setStyleSheet(objQss.labelQss); - ui->lbNetName->setStyleSheet(objQss.labelQss); - ui->lbSecurity->setStyleSheet(objQss.labelQss); - - ui->cbxConn->setStyleSheet(objQss.cbxQss); - ui->cbxConn->setView(new QListView()); - ui->leNetName->setStyleSheet(objQss.leQss); - ui->cbxSecurity->setStyleSheet(objQss.cbxQss); - ui->cbxSecurity->setView(new QListView()); - - ui->btnConnect->setStyleSheet(objQss.btnConnQss); - ui->btnCancel->setStyleSheet(objQss.btnCancelQss); - ui->lineUp->setStyleSheet(objQss.lineQss); - ui->lineDown->setStyleSheet(objQss.lineQss); - - ui->lbLeftupTitle->setText(tr("Add Hidden Wi-Fi")); //加入隐藏Wi-Fi - ui->lbConn->setText(tr("Connection")); //连接设置: - ui->lbNetName->setText(tr("Wi-Fi name")); //网络名称: - ui->lbSecurity->setText(tr("Wi-Fi security")); //Wi-Fi安全性: - ui->btnCancel->setText(tr("Cancel")); //取消 - ui->btnConnect->setText(tr("Connect")); //连接 - - ui->cbxConn->addItem(tr("C_reate…")); //新建... - QString tmpPath = "/tmp/kylin-nm-connshow-" + QDir::home().dirName(); - QString cmd = "nmcli connection show>" + tmpPath; - int status = system(cmd.toUtf8().data()); - if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection show' in function 'DlgConnHidWifi' failed");} - QFile file(tmpPath); - if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){ - qDebug()<<"Can't open the file!"; - } - QString txt = file.readAll(); - QStringList txtLine = txt.split("\n"); - file.close(); - foreach (QString line, txtLine) { - if (line.indexOf("wifi") != -1 || line.indexOf("802-11-wireless") != -1) { - QStringList subLine = line.split(" "); - ui->cbxConn->addItem(subLine[0]); - } - } - ui->cbxConn->setCurrentIndex(0); - connect(ui->cbxConn,SIGNAL(currentIndexChanged(QString)),this,SLOT(changeWindow())); - - ui->cbxSecurity->addItem(tr("None")); //无 - ui->cbxSecurity->addItem(tr("WPA & WPA2 Personal")); //WPA 及 WPA2 个人 - //ui->cbxSecurity->addItem(tr("WEP 40/128-bit Key (Hex or ASCII)")); //WEP 40/128 位密钥(十六进制或ASCII) - //ui->cbxSecurity->addItem(tr("WEP 128-bit Passphrase")); //WEP 128 位密码句 - //ui->cbxSecurity->addItem("LEAP"); - //ui->cbxSecurity->addItem(tr("Dynamic WEP (802.1X)")); //动态 WEP (802.1x) - //ui->cbxSecurity->addItem(tr("WPA & WPA2 Enterprise")); //WPA 及 WPA2 企业 - ui->cbxSecurity->setCurrentIndex(0); - connect(ui->cbxSecurity,SIGNAL(currentIndexChanged(QString)),this,SLOT(changeDialog())); - - if (isUsed == 0){ - ui->btnConnect->setEnabled(false); - }else{ - ui->cbxConn->setCurrentIndex(isUsed); - ui->leNetName->setText(ui->cbxConn->currentText()); - ui->lbNetName->setEnabled(false); - ui->leNetName->setEnabled(false); - ui->lbSecurity->setEnabled(false); - ui->cbxSecurity->setEnabled(false); - ui->btnConnect->setEnabled(true); - } - - this->setFixedSize(432,358); - - this->mw = mainWindow; - - /**解决锁屏设置 X11BypassWindowManagerHint 属性导致QCombox弹框异常的问题---START---- - ** 手动绑定下拉框视图和下拉框 - **/ - ui->cbxConn->view()->setWindowFlags(Qt::Popup | Qt::X11BypassWindowManagerHint); - ui->cbxConn->view()->setParent(this); - ui->cbxConn->view()->hide(); - ui->cbxConn->installEventFilter(this); - - ui->cbxSecurity->view()->setWindowFlags(Qt::Popup | Qt::X11BypassWindowManagerHint); - ui->cbxSecurity->view()->setParent(this); - ui->cbxSecurity->view()->hide(); - ui->cbxSecurity->installEventFilter(this); - - connect(ui->cbxConn->view(), &QAbstractItemView::pressed, this, [=](QModelIndex index){ - Q_EMIT ui->cbxConn->setCurrentIndex(index.row()); - ui->cbxConn->view()->hide(); - }); - - connect(ui->cbxSecurity->view(), &QAbstractItemView::pressed, this, [=](QModelIndex index){ - ui->cbxSecurity->view()->hide(); - Q_EMIT ui->cbxSecurity->setCurrentIndex(index.row()); - }); - - ui->cbxConn->view()->setGeometry(QRect(ui->cbxConn->geometry().left(), ui->cbxConn->geometry().bottom(), ui->cbxConn->view()->width(), ui->cbxConn->view()->height())); - ui->cbxSecurity->view()->setGeometry(QRect(ui->cbxSecurity->geometry().left(), ui->cbxSecurity->geometry().bottom(), ui->cbxSecurity->view()->width(), ui->cbxSecurity->view()->height())); - /**解决锁屏设置 X11BypassWindowManagerHint 属性导致QCombox弹框异常的问题---END---- - ** 手动绑定下拉框视图和下拉框 - **/ -} - -DlgConnHidWifi::~DlgConnHidWifi() -{ - delete ui; -} - -/**解决锁屏设置 X11BypassWindowManagerHint 属性导致QCombox弹框异常的问题---START---- -** 手动绑定下拉框视图和下拉框 -**/ -bool DlgConnHidWifi::eventFilter(QObject *obj, QEvent *ev) -{ - if(ev->type() == QEvent::MouseButtonPress) - { - if(obj == ui->cbxConn) - { - ui->cbxConn->view()->setVisible(!ui->cbxConn->view()->isVisible()); - if(ui->cbxConn->view()->isVisible()) - ui->cbxConn->view()->setFocus(); - } else if (obj == ui->cbxSecurity) - { - ui->cbxSecurity->view()->setVisible(!ui->cbxSecurity->view()->isVisible()); - if(ui->cbxSecurity->view()->isVisible()) - ui->cbxSecurity->view()->setFocus(); - } - } - return false; -} -/**解决锁屏设置 X11BypassWindowManagerHint 属性导致QCombox弹框异常的问题---END---- -** 手动绑定下拉框视图和下拉框 -**/ - -void DlgConnHidWifi::mousePressEvent(QMouseEvent *event){ - if(event->button() == Qt::LeftButton){ - this->isPress = true; - this->winPos = this->pos(); - this->dragPos = event->globalPos(); - event->accept(); - } -} -void DlgConnHidWifi::mouseReleaseEvent(QMouseEvent *event){ - this->isPress = false; -} -void DlgConnHidWifi::mouseMoveEvent(QMouseEvent *event){ - if(this->isPress){ - this->move(this->winPos - (this->dragPos - event->globalPos())); - event->accept(); - } -} - -//切换到其他Wi-Fi安全类型 -void DlgConnHidWifi::changeDialog() -{ - if(ui->cbxSecurity->currentIndex()==0){ - qDebug()<<"it's not need to change dialog"; - } else if(ui->cbxSecurity->currentIndex()==1) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiWpa *connHidWifiWpa = new DlgConnHidWifiWpa(0, mw, this->parentWidget()); - connHidWifiWpa->show(); - connect(connHidWifiWpa, SIGNAL(reSetWifiList() ), mw, SLOT(on_btnWifiList_clicked()) ); - } else if(ui->cbxSecurity->currentIndex()==2) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiWep *connHidWifiWep = new DlgConnHidWifiWep(0,this->parentWidget()); - connHidWifiWep->show(); - } else if(ui->cbxSecurity->currentIndex()==3) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiWep *connHidWifiWep = new DlgConnHidWifiWep(1,this->parentWidget()); - connHidWifiWep->show(); - } else if(ui->cbxSecurity->currentIndex()==4) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiLeap *connHidWifiLeap = new DlgConnHidWifiLeap(this->parentWidget()); - connHidWifiLeap->show(); - } else if(ui->cbxSecurity->currentIndex()==5) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiSecTls *connHidWifiSecTls = new DlgConnHidWifiSecTls(0,this->parentWidget()); - connHidWifiSecTls->show(); - } else { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiSecTls *connHidWifiSecTls = new DlgConnHidWifiSecTls(1,this->parentWidget()); - connHidWifiSecTls->show(); - } -} - -//同一 Wi-Fi安全类型的窗口变换 -void DlgConnHidWifi::changeWindow(){ - if (ui->cbxConn->currentIndex() == 0){ - isUsed = ui->cbxConn->currentIndex(); - ui->cbxConn->setCurrentIndex(0); - ui->leNetName->setText(""); - ui->lbNetName->setEnabled(true); - ui->leNetName->setEnabled(true); - ui->lbSecurity->setEnabled(true); - ui->cbxSecurity->setEnabled(true); - ui->btnConnect->setEnabled(false); - }else if (ui->cbxConn->currentIndex() >= 1){ - QString tmpPath = "/tmp/kylin-nm-connshow-" + QDir::home().dirName(); - QString name = ui->cbxConn->currentText(); - QString currStr = "nmcli connection show \"" + name.replace("\"","\\\"") + "\" >" + tmpPath; - - int status = system(currStr.toUtf8().data()); - if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection show' in function 'changeWindow' failed");} - - QFile file(tmpPath); - if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){ - qDebug()<<"Can't open the file!"; - } - QString txt = file.readAll(); - file.close(); - if (txt.indexOf("802-11-wireless-security.key-mgmt:") != -1){ -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiWpa *connHidWifiWpa = new DlgConnHidWifiWpa(ui->cbxConn->currentIndex(), mw, this->parentWidget()); - connHidWifiWpa->show(); - connect(connHidWifiWpa, SIGNAL(reSetWifiList() ), mw, SLOT(on_btnWifiList_clicked()) ); - }else { - isUsed = ui->cbxConn->currentIndex(); - ui->leNetName->setText(ui->cbxConn->currentText()); - ui->lbNetName->setEnabled(false); - ui->leNetName->setEnabled(false); - ui->lbSecurity->setEnabled(false); - ui->cbxSecurity->setEnabled(false); - ui->btnConnect->setEnabled(true); - } - } -} - -void DlgConnHidWifi::on_btnCancel_clicked() -{ - this->close(); -} - -void DlgConnHidWifi::on_btnConnect_clicked() -{ - QThread *t = new QThread(); - connect(t, SIGNAL(finished()), t, SLOT(deleteLater())); - connect(t, SIGNAL(started()), this, SLOT(slotStartLoading())); - connect(this, SIGNAL(stopSignal()), t, SLOT(quit())); - t->start(); - - QString wifiName = ui->leNetName->text(); - BackThread *bt = new BackThread(); - strWifiname = wifiName; - //点击连接按钮以连接隐藏WiFi - if (isUsed == 0) { - int x = 0; - do { - sleep(1); - QString tmpPath = "/tmp/kylin-nm-btoutput-" + QDir::home().dirName(); - QString cmd = "nmcli device wifi connect \"" + wifiName.replace("\"","\\\"") + "\" password '' hidden yes > " + tmpPath; - - int status = system(cmd.toUtf8().data()); - if (status != 0) - syslog(LOG_ERR, "execute 'nmcli device wifi connect' in function 'on_btnConnect_clicked' failed"); - - QFile file(tmpPath); - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { - qDebug()<<"Can't open the file!"<execConnWifi(wifiName); - connect(this, SIGNAL(sendMessage()), this,SLOT(emitSignal() )); - QTimer::singleShot(4*1000, this, SLOT(emitSignal() )); - } - this->close(); -} - -void DlgConnHidWifi::on_leNetName_textEdited(const QString &arg1) -{ - if (ui->leNetName->text() == ""){ - ui->btnConnect->setEnabled(false); - } else { - ui->btnConnect->setEnabled(true); - } -} - -void DlgConnHidWifi::slotStartLoading() -{ - mw->startLoading(); -} - -void DlgConnHidWifi::on_execSecConn() -{ - QString name = strWifiname; - QString str = "nmcli device wifi connect \"" + name.replace("\"","\\\"") + "\" password ''"; - int status = system(str.toUtf8().data()); - if (status != 0){ syslog(LOG_ERR, "execute 'nmcli device wifi connect' in function 'on_execSecConn' failed");} - connect(this, SIGNAL(sendMessage()), this,SLOT(emitSignal() )); - QTimer::singleShot(3*1000, this, SLOT(emitSignal() )); -} - -void DlgConnHidWifi::emitSignal() -{ - emit reSetWifiList(); - mw->stopLoading(); - emit this->stopSignal(); -} - -void DlgConnHidWifi::paintEvent(QPaintEvent *event) -{ - QStyleOption opt; - opt.init(this); - QPainter p(this); - style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); - QWidget::paintEvent(event); -} diff --git a/KylinNM/wireless-security/dlgconnhidwifi.h b/KylinNM/wireless-security/dlgconnhidwifi.h deleted file mode 100644 index 33d4c42..0000000 --- a/KylinNM/wireless-security/dlgconnhidwifi.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see -#include -#include -#include -#include - -class KylinNM; - -namespace Ui { -class DlgConnHidWifi; -} - -class DlgConnHidWifi : public QDialog -{ - Q_OBJECT - -public: - explicit DlgConnHidWifi(int type, KylinNM *mw = 0, QWidget *parent = 0); - ~DlgConnHidWifi(); - -protected: - void paintEvent(QPaintEvent *event); - - /**解决锁屏设置 X11BypassWindowManagerHint 属性导致QCombox弹框异常的问题---START---- - ** 手动绑定下拉框视图和下拉框 过滤点击事件 - **/ - bool eventFilter(QObject *obj, QEvent *ev) override; - -public Q_SLOTS: - void changeDialog(); - void changeWindow(); - void emitSignal(); - void on_execSecConn(); - void slotStartLoading(); - -private Q_SLOTS: - void on_btnCancel_clicked(); - - void on_btnConnect_clicked(); - - void on_leNetName_textEdited(const QString &arg1); - -Q_SIGNALS: - void reSetWifiList(); - void sendMessage(); - void execSecConn(); - void stopSignal(); - -private: - Ui::DlgConnHidWifi *ui; - int isUsed;//=0 current wifi not used before; >=1 used - KylinNM *mw; - QString strWifiname; -// QString labelQss, cbxQss, leQss, btnConnQss, btnCancelQss, lineQss; - - void mousePressEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - - bool isPress; - QPoint winPos; - QPoint dragPos; -}; - -#endif // DLGCONNHIDWIFI_H diff --git a/KylinNM/wireless-security/dlgconnhidwifi.ui b/KylinNM/wireless-security/dlgconnhidwifi.ui deleted file mode 100644 index 1d23ac6..0000000 --- a/KylinNM/wireless-security/dlgconnhidwifi.ui +++ /dev/null @@ -1,238 +0,0 @@ - - - DlgConnHidWifi - - - - 0 - 0 - 432 - 358 - - - - Connect to Hidden Wi-Fi Network - - - - - 76 - 80 - 90 - 20 - - - - - 10 - - - - Qt::LeftToRight - - - - - - - - - 175 - 75 - 182 - 32 - - - - - 10 - - - - - - - - - - 76 - 221 - 90 - 20 - - - - - 10 - - - - - - - - - - 175 - 170 - 182 - 32 - - - - - 10 - - - - - - - - - - 76 - 176 - 90 - 20 - - - - - 10 - - - - - - - - - - 175 - 215 - 182 - 32 - - - - - 10 - - - - - - - 315 - 310 - 90 - 30 - - - - - 10 - - - - - - - - - - 215 - 310 - 90 - 30 - - - - - 10 - - - - - - - - - - 30 - 30 - 240 - 22 - - - - - 9 - - - - - - - - - - 0 - 0 - 432 - 358 - - - - - - - - - - 10 - 140 - 412 - 1 - - - - - - - Qt::Horizontal - - - - - - 10 - 280 - 412 - 1 - - - - - - - Qt::Horizontal - - - lbBoder - lbConn - cbxConn - lbNetName - cbxSecurity - lbSecurity - leNetName - btnConnect - btnCancel - lbLeftupTitle - lineUp - lineDown - - - - diff --git a/KylinNM/wireless-security/dlgconnhidwifileap.cpp b/KylinNM/wireless-security/dlgconnhidwifileap.cpp deleted file mode 100644 index 5926b12..0000000 --- a/KylinNM/wireless-security/dlgconnhidwifileap.cpp +++ /dev/null @@ -1,290 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see - -DlgConnHidWifiLeap::DlgConnHidWifiLeap(QWidget *parent) : - QDialog(parent), - ui(new Ui::DlgConnHidWifiLeap) -{ - ui->setupUi(this); - - this->setWindowFlags(Qt::FramelessWindowHint); - this->setAttribute(Qt::WA_TranslucentBackground); - //需要添加 void paintEvent(QPaintEvent *event) 函数 - - QPainterPath path; - auto rect = this->rect(); - rect.adjust(1, 1, -1, -1); - path.addRoundedRect(rect, 6, 6); - setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon())); - - this->setStyleSheet("QWidget{border-radius:6px;background-color:rgba(19,19,20,0.7);border:1px solid rgba(255, 255, 255, 0.05);}"); - - MyQss objQss; - - ui->lbBoder->setStyleSheet("QLabel{border-radius:6px;background-color:rgba(19,19,20,0.95);border:1px solid rgba(255, 255, 255, 0.05);}"); - ui->lbBoder->hide(); - ui->lbLeftupTitle->setStyleSheet("QLabel{border:0px;font-size:20px;color:rgba(255,255,255,0.97);background-color:transparent;}"); - ui->lbConn->setStyleSheet(objQss.labelQss); - ui->lbNetName->setStyleSheet(objQss.labelQss); - ui->lbSecurity->setStyleSheet(objQss.labelQss); - ui->lbUserName->setStyleSheet(objQss.labelQss); - ui->lbPassword->setStyleSheet(objQss.labelQss); - - ui->cbxConn->setStyleSheet(objQss.cbxQss); - ui->cbxConn->setView(new QListView()); - ui->leNetName->setStyleSheet(objQss.leQss); - ui->leUserName->setStyleSheet(objQss.leQss); - ui->lePassword->setStyleSheet(objQss.leQss); - ui->cbxSecurity->setStyleSheet(objQss.cbxQss); - ui->cbxSecurity->setView(new QListView()); - ui->checkBoxPwd->setStyleSheet(objQss.checkBoxQss); - - ui->btnCancel->setStyleSheet(objQss.btnCancelQss); - ui->btnConnect->setStyleSheet(objQss.btnConnQss); - ui->lineUp->setStyleSheet(objQss.lineQss); - ui->lineDown->setStyleSheet(objQss.lineQss); - - ui->lbLeftupTitle->setText(tr("Add hidden Wi-Fi")); //加入隐藏Wi-Fi - ui->lbConn->setText(tr("Connection")); //连接设置: - ui->lbNetName->setText(tr("Network name")); //网络名称: - ui->lbSecurity->setText(tr("Wi-Fi security")); //Wi-Fi安全性: - ui->lbUserName->setText(tr("Username")); //用户名: - ui->lbPassword->setText(tr("Password")); //密码: - ui->btnCancel->setText(tr("Cancel")); //取消 - ui->btnConnect->setText(tr("Connect")); //连接 - - ui->cbxConn->addItem(tr("C_reate…")); //新建... - int status = system("nmcli connection show>/tmp/kylin-nm-connshow"); - if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection show' in function 'DlgConnHidWifiLeap' failed");} - QFile file("/tmp/kylin-nm-connshow"); - if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){ - qDebug()<<"Can't open the file!"; - } - QString txt = file.readAll(); - QStringList txtLine = txt.split("\n"); - file.close(); - foreach (QString line, txtLine) { - if(line.indexOf("wifi") != -1){ - QStringList subLine = line.split(" "); - ui->cbxConn->addItem(subLine[0]); - } - } - ui->cbxConn->setCurrentIndex(0); - - ui->cbxSecurity->addItem(tr("None")); //无 - ui->cbxSecurity->addItem(tr("WPA & WPA2 Personal")); //WPA 及 WPA2 个人 - ui->cbxSecurity->addItem(tr("WEP 40/128-bit Key (Hex or ASCII)")); //WEP 40/128 位密钥(十六进制或ASCII) - ui->cbxSecurity->addItem(tr("WEP 128-bit Passphrase")); //WEP 128 位密码句 - ui->cbxSecurity->addItem("LEAP"); - ui->cbxSecurity->addItem(tr("Dynamic WEP (802.1X)")); //动态 WEP (802.1x) - ui->cbxSecurity->addItem(tr("WPA & WPA2 Enterprise")); //WPA 及 WPA2 企业 - ui->cbxSecurity->setCurrentIndex(4); - connect(ui->cbxSecurity,SIGNAL(currentIndexChanged(QString)),this,SLOT(changeDialog())); - - ui->btnConnect->setEnabled(false); - - this->setFixedSize(432,434); - - /**解决锁屏设置 X11BypassWindowManagerHint 属性导致QCombox弹框异常的问题---START---- - ** 手动绑定下拉框视图和下拉框 - **/ - ui->cbxConn->view()->setWindowFlags(Qt::Popup | Qt::X11BypassWindowManagerHint); - ui->cbxConn->view()->setParent(this); - ui->cbxConn->view()->hide(); - ui->cbxConn->installEventFilter(this); - - ui->cbxSecurity->view()->setWindowFlags(Qt::Popup | Qt::X11BypassWindowManagerHint); - ui->cbxSecurity->view()->setParent(this); - ui->cbxSecurity->view()->hide(); - ui->cbxSecurity->installEventFilter(this); - - connect(ui->cbxConn->view(), &QAbstractItemView::pressed, this, [=](QModelIndex index){ - Q_EMIT ui->cbxConn->setCurrentIndex(index.row()); - ui->cbxConn->view()->hide(); - }); - - connect(ui->cbxSecurity->view(), &QAbstractItemView::pressed, this, [=](QModelIndex index){ - ui->cbxSecurity->view()->hide(); - Q_EMIT ui->cbxSecurity->setCurrentIndex(index.row()); - }); - - ui->cbxConn->view()->setGeometry(QRect(ui->cbxConn->geometry().left(), ui->cbxConn->geometry().bottom(), ui->cbxConn->view()->width(), ui->cbxConn->view()->height())); - ui->cbxSecurity->view()->setGeometry(QRect(ui->cbxSecurity->geometry().left(), ui->cbxSecurity->geometry().bottom(), ui->cbxSecurity->view()->width(), ui->cbxSecurity->view()->height())); - /**解决锁屏设置 X11BypassWindowManagerHint 属性导致QCombox弹框异常的问题---END---- - ** 手动绑定下拉框视图和下拉框 - **/ -} - -DlgConnHidWifiLeap::~DlgConnHidWifiLeap() -{ - delete ui; -} - -/**解决锁屏设置 X11BypassWindowManagerHint 属性导致QCombox弹框异常的问题---START---- -** 手动绑定下拉框视图和下拉框 -**/ -bool DlgConnHidWifiLeap::eventFilter(QObject *obj, QEvent *ev) -{ - if(ev->type() == QEvent::MouseButtonPress) - { - if(obj == ui->cbxConn) - { - ui->cbxConn->view()->setVisible(!ui->cbxConn->view()->isVisible()); - if(ui->cbxConn->view()->isVisible()) - ui->cbxConn->view()->setFocus(); - } else if (obj == ui->cbxSecurity) - { - ui->cbxSecurity->view()->setVisible(!ui->cbxSecurity->view()->isVisible()); - if(ui->cbxSecurity->view()->isVisible()) - ui->cbxSecurity->view()->setFocus(); - } - } - return false; -} -/**解决锁屏设置 X11BypassWindowManagerHint 属性导致QCombox弹框异常的问题---END---- -** 手动绑定下拉框视图和下拉框 -**/ - -void DlgConnHidWifiLeap::mousePressEvent(QMouseEvent *event){ - if(event->button() == Qt::LeftButton){ - this->isPress = true; - this->winPos = this->pos(); - this->dragPos = event->globalPos(); - event->accept(); - } -} -void DlgConnHidWifiLeap::mouseReleaseEvent(QMouseEvent *event){ - this->isPress = false; -} -void DlgConnHidWifiLeap::mouseMoveEvent(QMouseEvent *event){ - if(this->isPress){ - this->move(this->winPos - (this->dragPos - event->globalPos())); - event->accept(); - } -} - -//切换到其他Wi-Fi安全类型 -void DlgConnHidWifiLeap::changeDialog() -{ - if(ui->cbxSecurity->currentIndex()==0){ -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifi *connHidWifi = new DlgConnHidWifi(0, 0,this->parentWidget()); - connHidWifi->show(); - } else if(ui->cbxSecurity->currentIndex()==1) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiWpa *connHidWifiWpa = new DlgConnHidWifiWpa(0, 0, this->parentWidget()); - connHidWifiWpa->show(); - } else if(ui->cbxSecurity->currentIndex()==2) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiWep *connHidWifiWep = new DlgConnHidWifiWep(0, this->parentWidget()); - connHidWifiWep->show(); - } else if(ui->cbxSecurity->currentIndex()==3) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiWep *connHidWifiWep = new DlgConnHidWifiWep(1, this->parentWidget()); - connHidWifiWep->show(); - } else if(ui->cbxSecurity->currentIndex()==4) { - qDebug()<<"it's not need to change dialog"; - } else if(ui->cbxSecurity->currentIndex()==5) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiSecTls *connHidWifiSecTls = new DlgConnHidWifiSecTls(0, this->parentWidget()); - connHidWifiSecTls->show(); - } else { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiSecTls *connHidWifiSecTls = new DlgConnHidWifiSecTls(1, this->parentWidget()); - connHidWifiSecTls->show(); - } -} - -void DlgConnHidWifiLeap::on_btnCancel_clicked() -{ - this->close(); -} - -void DlgConnHidWifiLeap::on_btnConnect_clicked() -{ - this->close(); -} - -void DlgConnHidWifiLeap::on_checkBoxPwd_stateChanged(int arg1) -{ - if (arg1 == 0) { - ui->lePassword ->setEchoMode(QLineEdit::Password); - } else { - ui->lePassword->setEchoMode(QLineEdit::Normal); - } -} - -void DlgConnHidWifiLeap::on_leNetName_textEdited(const QString &arg1) -{ - if (ui->leNetName->text() == "" || ui->lePassword->text() == ""){ - ui->btnConnect->setEnabled(false); - } else if (ui->leNetName->text() == "" || ui->leUserName->text() == ""){ - ui->btnConnect->setEnabled(false); - } else if (ui->lePassword->text() == "" || ui->leUserName->text() == ""){ - ui->btnConnect->setEnabled(false); - } else { - ui->btnConnect->setEnabled(true); - } -} - -void DlgConnHidWifiLeap::on_leUserName_textEdited(const QString &arg1) -{ - if (ui->leNetName->text() == ""){ - ui->btnConnect->setEnabled(false); - } else if (ui->leUserName->text() == ""){ - ui->btnConnect->setEnabled(false); - } else if (ui->lePassword->text() == ""){ - ui->btnConnect->setEnabled(false); - } else { - ui->btnConnect->setEnabled(true); - } -} - -void DlgConnHidWifiLeap::on_lePassword_textEdited(const QString &arg1) -{ - if (ui->leNetName->text() == ""){ - ui->btnConnect->setEnabled(false); - } else if (ui->leUserName->text() == ""){ - ui->btnConnect->setEnabled(false); - } else if (ui->lePassword->text() == ""){ - ui->btnConnect->setEnabled(false); - } else { - ui->btnConnect->setEnabled(true); - } -} - -void DlgConnHidWifiLeap::paintEvent(QPaintEvent *event) -{ - QStyleOption opt; - opt.init(this); - QPainter p(this); - style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); - QWidget::paintEvent(event); -} diff --git a/KylinNM/wireless-security/dlgconnhidwifileap.h b/KylinNM/wireless-security/dlgconnhidwifileap.h deleted file mode 100644 index de96ce2..0000000 --- a/KylinNM/wireless-security/dlgconnhidwifileap.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see -#include - -namespace Ui { -class DlgConnHidWifiLeap; -} - -class DlgConnHidWifiLeap : public QDialog -{ - Q_OBJECT - -public: - explicit DlgConnHidWifiLeap(QWidget *parent = 0); - ~DlgConnHidWifiLeap(); - -protected: - void paintEvent(QPaintEvent *event); - - /**解决锁屏设置 X11BypassWindowManagerHint 属性导致QCombox弹框异常的问题---START---- - ** 手动绑定下拉框视图和下拉框 过滤点击事件 - **/ - bool eventFilter(QObject *obj, QEvent *ev) override; - -public slots: - void changeDialog(); - -private slots: - void on_btnCancel_clicked(); - - void on_btnConnect_clicked(); - - void on_checkBoxPwd_stateChanged(int arg1); - - void on_leNetName_textEdited(const QString &arg1); - - void on_leUserName_textEdited(const QString &arg1); - - void on_lePassword_textEdited(const QString &arg1); - -private: - Ui::DlgConnHidWifiLeap *ui; - - void mousePressEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - -// QString labelQss, cbxQss, leQss, btnConnQss, btnCancelQss, lineQss, checkBoxQss; - - bool isPress; - QPoint winPos; - QPoint dragPos; -}; - -#endif // DLGCONNHIDWIFILEAP_H diff --git a/KylinNM/wireless-security/dlgconnhidwifileap.ui b/KylinNM/wireless-security/dlgconnhidwifileap.ui deleted file mode 100644 index b8a5b4b..0000000 --- a/KylinNM/wireless-security/dlgconnhidwifileap.ui +++ /dev/null @@ -1,319 +0,0 @@ - - - DlgConnHidWifiLeap - - - - 0 - 0 - 432 - 434 - - - - Connect to Hidden Wi-Fi Network - - - - - 175 - 264 - 182 - 32 - - - - - 10 - - - - - - - 175 - 219 - 182 - 32 - - - - - 10 - - - - - - - - - - 215 - 390 - 90 - 30 - - - - - 10 - - - - - - - - - - 76 - 84 - 90 - 20 - - - - - 10 - - - - Qt::LeftToRight - - - - - - - - - 175 - 79 - 182 - 32 - - - - - 10 - - - - - - - - - - 76 - 270 - 90 - 20 - - - - - 10 - - - - - - - - - - 332 - 321 - 18 - 9 - - - - - 10 - - - - - - - - - - 76 - 315 - 90 - 20 - - - - - 10 - - - - - - - - - - 76 - 180 - 90 - 20 - - - - - 10 - - - - - - - - - - 76 - 225 - 90 - 20 - - - - - 10 - - - - - - - - - - 315 - 390 - 90 - 30 - - - - - 10 - - - - - - - - - - 175 - 309 - 182 - 32 - - - - - 10 - - - - QLineEdit::Password - - - - - - 175 - 174 - 182 - 32 - - - - - 10 - - - - - - - 0 - 0 - 432 - 434 - - - - - - - - - - 30 - 32 - 140 - 22 - - - - - - - - - - 10 - 134 - 412 - 1 - - - - Qt::Horizontal - - - - - - 10 - 364 - 412 - 1 - - - - Qt::Horizontal - - - lbBoder - leUserName - cbxSecurity - btnCancel - lbConn - cbxConn - lbUserName - lbPassword - lbNetName - lbSecurity - btnConnect - lePassword - leNetName - checkBoxPwd - lbLeftupTitle - lineUp - lineDown - - - - diff --git a/KylinNM/wireless-security/dlgconnhidwifisecfast.cpp b/KylinNM/wireless-security/dlgconnhidwifisecfast.cpp deleted file mode 100644 index b4d07f5..0000000 --- a/KylinNM/wireless-security/dlgconnhidwifisecfast.cpp +++ /dev/null @@ -1,403 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see - -DlgConnHidWifiSecFast::DlgConnHidWifiSecFast(int type, QWidget *parent) : - WepOrWpa(type), - QDialog(parent), - ui(new Ui::DlgConnHidWifiSecFast) -{ - ui->setupUi(this); - - this->setWindowFlags(Qt::FramelessWindowHint); - this->setAttribute(Qt::WA_TranslucentBackground); - //需要添加 void paintEvent(QPaintEvent *event) 函数 - - QPainterPath path; - auto rect = this->rect(); - rect.adjust(1, 1, -1, -1); - path.addRoundedRect(rect, 6, 6); - setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon())); - - this->setStyleSheet("QWidget{border-radius:6px;background-color:rgba(19,19,20,0.7);border:1px solid rgba(255, 255, 255, 0.05);}"); - - MyQss objQss; - - ui->lbBoder->setStyleSheet("QLabel{border-radius:6px;background-color:rgba(19,19,20,0.95);border:1px solid rgba(255, 255, 255, 0.05);}"); - ui->lbBoder->hide(); - ui->lbLeftupTitle->setStyleSheet("QLabel{border:0px;font-size:20px;color:rgba(255,255,255,0.97);background-color:transparent;}"); - ui->lbConn->setStyleSheet(objQss.labelQss); - ui->lbNetName->setStyleSheet(objQss.labelQss); - ui->lbSecurity->setStyleSheet(objQss.labelQss); - ui->lbAuth->setStyleSheet(objQss.labelQss); - ui->lbAnonyId->setStyleSheet(objQss.labelQss); - ui->checkBoxAutoPCA->setStyleSheet(objQss.checkBoxCAQss); - ui->lbPCAfile->setStyleSheet(objQss.labelQss); - ui->lbInnerAuth->setStyleSheet(objQss.labelQss); - ui->lbUserName->setStyleSheet(objQss.labelQss); - ui->lbPassword->setStyleSheet(objQss.labelQss); - - ui->cbxConn->setStyleSheet(objQss.cbxQss); - ui->cbxConn->setView(new QListView()); - ui->leNetName->setStyleSheet(objQss.leQss); - ui->cbxSecurity->setStyleSheet(objQss.cbxQss); - ui->cbxSecurity->setView(new QListView()); - ui->cbxAuth->setStyleSheet(objQss.cbxQss); - ui->cbxAuth->setView(new QListView()); - ui->leAnonyId->setStyleSheet(objQss.leQss); - ui->cbxAutoPCA->setStyleSheet(objQss.cbxQss); - ui->cbxAutoPCA->setView(new QListView()); - ui->lePCAfile->setStyleSheet(objQss.leQss); - ui->cbxInnerAuth->setStyleSheet(objQss.cbxQss); - ui->cbxInnerAuth->setView(new QListView()); - ui->leUserName->setStyleSheet(objQss.leQss); - ui->lePassword->setStyleSheet(objQss.leQss); - ui->checkBoxPwd->setStyleSheet(objQss.checkBoxQss); - - ui->btnCancel->setStyleSheet(objQss.btnCancelQss); - ui->btnConnect->setStyleSheet(objQss.btnConnQss); - ui->lineUp->setStyleSheet(objQss.lineQss); - ui->lineDown->setStyleSheet(objQss.lineQss); - - ui->lbLeftupTitle->setText(tr("Add hidden Wi-Fi")); //加入隐藏Wi-Fi - ui->lbConn->setText(tr("Connection")); //连接设置: - ui->lbNetName->setText(tr("Network name")); //网络名称: - ui->lbSecurity->setText(tr("Wi-Fi security")); //Wi-Fi安全性: - ui->lbAuth->setText(tr("Authentication")); //认证: - ui->lbAnonyId->setText(tr("Anonymous identity")); //匿名身份: - ui->checkBoxAutoPCA->setText(tr("Allow automatic PAC pro_visioning")); //自动PAC配置: - ui->lbPCAfile->setText(tr("PAC file"));//PAC文件: - ui->lbInnerAuth->setText(tr("Inner authentication")); //内部认证: - ui->lbUserName->setText(tr("Username")); //用户名: - ui->lbPassword->setText(tr("Password")); //密码: - ui->btnCancel->setText(tr("Cancel")); //取消 - ui->btnConnect->setText(tr("Connect")); //连接 - - ui->checkBoxAutoPCA->setFocusPolicy(Qt::NoFocus); - ui->checkBoxPwd->setFocusPolicy(Qt::NoFocus); - - ui->cbxConn->addItem(tr("C_reate…")); //新建... - int status = system("nmcli connection show>/tmp/kylin-nm-connshow"); - if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection show' in function 'DlgConnHidWifiSecFast' failed");} - QFile file("/tmp/kylin-nm-connshow"); - if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){ - qDebug()<<"Can't open the file!"; - } - QString txt = file.readAll(); - QStringList txtLine = txt.split("\n"); - file.close(); - foreach (QString line, txtLine) { - if(line.indexOf("wifi") != -1){ - QStringList subLine = line.split(" "); - ui->cbxConn->addItem(subLine[0]); - } - } - ui->cbxConn->setCurrentIndex(0); - - ui->cbxSecurity->addItem(tr("None")); //无 - ui->cbxSecurity->addItem(tr("WPA & WPA2 Personal")); //WPA 及 WPA2 个人 - ui->cbxSecurity->addItem(tr("WEP 40/128-bit Key (Hex or ASCII)")); //WEP 40/128 位密钥(十六进制或ASCII) - ui->cbxSecurity->addItem(tr("WEP 128-bit Passphrase")); //WEP 128 位密码句 - ui->cbxSecurity->addItem("LEAP"); - ui->cbxSecurity->addItem(tr("Dynamic WEP (802.1X)")); //动态 WEP (802.1x) - ui->cbxSecurity->addItem(tr("WPA & WPA2 Enterprise")); //WPA 及 WPA2 企业 - if (WepOrWpa == 0) { - ui->cbxSecurity->setCurrentIndex(5); - } else if (WepOrWpa == 1) { - ui->cbxSecurity->setCurrentIndex(6); - } - connect(ui->cbxSecurity,SIGNAL(currentIndexChanged(QString)),this,SLOT(changeDialogSecu())); - - ui->cbxAuth->addItem("TLS"); - ui->cbxAuth->addItem("LEAP"); - ui->cbxAuth->addItem("PWD"); - ui->cbxAuth->addItem("FAST"); - ui->cbxAuth->addItem(tr("Tunneled TLS"));//隧道 TLS - ui->cbxAuth->addItem(tr("Protected EAP (PEAP)")); //受保护的 EAP - ui->cbxAuth->setCurrentIndex(3); - connect(ui->cbxAuth,SIGNAL(currentIndexChanged(QString)),this,SLOT(changeDialogAuth())); - - ui->checkBoxAutoPCA->setCheckState(Qt::Checked); - - ui->cbxAutoPCA->addItem(tr("Anonymous")); //匿名 - ui->cbxAutoPCA->addItem(tr("Authenticated")); //已认证 - ui->cbxAutoPCA->addItem(tr("Both")); //两者兼用 - ui->cbxAutoPCA->setCurrentIndex(0); - - ui->lePCAfile->setText(tr("None")); //(无) - - ui->cbxInnerAuth->addItem("GTC"); - ui->cbxInnerAuth->addItem("MSCHAPv2"); - ui->cbxInnerAuth->setCurrentIndex(0); - - ui->btnConnect->setEnabled(false); - - this->setFixedSize(432,673); - - /**解决锁屏设置 X11BypassWindowManagerHint 属性导致QCombox弹框异常的问题---START---- - ** 手动绑定下拉框视图和下拉框 - **/ - ui->cbxConn->view()->setWindowFlags(Qt::Popup | Qt::X11BypassWindowManagerHint); - ui->cbxConn->view()->setParent(this); - ui->cbxConn->view()->hide(); - ui->cbxConn->installEventFilter(this); - - ui->cbxSecurity->view()->setWindowFlags(Qt::Popup | Qt::X11BypassWindowManagerHint); - ui->cbxSecurity->view()->setParent(this); - ui->cbxSecurity->view()->hide(); - ui->cbxSecurity->installEventFilter(this); - - connect(ui->cbxConn->view(), &QAbstractItemView::pressed, this, [=](QModelIndex index){ - Q_EMIT ui->cbxConn->setCurrentIndex(index.row()); - ui->cbxConn->view()->hide(); - }); - - connect(ui->cbxSecurity->view(), &QAbstractItemView::pressed, this, [=](QModelIndex index){ - ui->cbxSecurity->view()->hide(); - Q_EMIT ui->cbxSecurity->setCurrentIndex(index.row()); - }); - - ui->cbxConn->view()->setGeometry(QRect(ui->cbxConn->geometry().left(), ui->cbxConn->geometry().bottom(), ui->cbxConn->view()->width(), ui->cbxConn->view()->height())); - ui->cbxSecurity->view()->setGeometry(QRect(ui->cbxSecurity->geometry().left(), ui->cbxSecurity->geometry().bottom(), ui->cbxSecurity->view()->width(), ui->cbxSecurity->view()->height())); - /**解决锁屏设置 X11BypassWindowManagerHint 属性导致QCombox弹框异常的问题---END---- - ** 手动绑定下拉框视图和下拉框 - **/ -} - -DlgConnHidWifiSecFast::~DlgConnHidWifiSecFast() -{ - delete ui; -} - -/**解决锁屏设置 X11BypassWindowManagerHint 属性导致QCombox弹框异常的问题---START---- -** 手动绑定下拉框视图和下拉框 -**/ -bool DlgConnHidWifiSecFast::eventFilter(QObject *obj, QEvent *ev) -{ - if(ev->type() == QEvent::MouseButtonPress) - { - if(obj == ui->cbxConn) - { - ui->cbxConn->view()->setVisible(!ui->cbxConn->view()->isVisible()); - if(ui->cbxConn->view()->isVisible()) - ui->cbxConn->view()->setFocus(); - } else if (obj == ui->cbxSecurity) - { - ui->cbxSecurity->view()->setVisible(!ui->cbxSecurity->view()->isVisible()); - if(ui->cbxSecurity->view()->isVisible()) - ui->cbxSecurity->view()->setFocus(); - } - } - return false; -} -/**解决锁屏设置 X11BypassWindowManagerHint 属性导致QCombox弹框异常的问题---END---- -** 手动绑定下拉框视图和下拉框 -**/ - -void DlgConnHidWifiSecFast::mousePressEvent(QMouseEvent *event){ - if(event->button() == Qt::LeftButton){ - this->isPress = true; - this->winPos = this->pos(); - this->dragPos = event->globalPos(); - event->accept(); - } -} -void DlgConnHidWifiSecFast::mouseReleaseEvent(QMouseEvent *event){ - this->isPress = false; -} -void DlgConnHidWifiSecFast::mouseMoveEvent(QMouseEvent *event){ - if(this->isPress){ - this->move(this->winPos - (this->dragPos - event->globalPos())); - event->accept(); - } -} - -void DlgConnHidWifiSecFast::changeDialogSecu() -{ - if(ui->cbxSecurity->currentIndex()==0){ -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifi *connHidWifi = new DlgConnHidWifi(0, 0, this->parentWidget()); - connHidWifi->show(); - } else if(ui->cbxSecurity->currentIndex()==1) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiWpa *connHidWifiWpa = new DlgConnHidWifiWpa(0, 0, this->parentWidget()); - connHidWifiWpa->show(); - } else if(ui->cbxSecurity->currentIndex()==2) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiWep *connHidWifiWep = new DlgConnHidWifiWep(0, this->parentWidget()); - connHidWifiWep->show(); - } else if(ui->cbxSecurity->currentIndex()==3) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiWep *connHidWifiWep = new DlgConnHidWifiWep(1, this->parentWidget()); - connHidWifiWep->show(); - } else if(ui->cbxSecurity->currentIndex()==4) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiLeap *connHidWifiLeap = new DlgConnHidWifiLeap(this->parentWidget()); - connHidWifiLeap->show(); - } else if(ui->cbxSecurity->currentIndex()==5) { - if (WepOrWpa == 1) { - ui->cbxSecurity->setCurrentIndex(5); - WepOrWpa = 0; - } - } else { - if (WepOrWpa == 0){ - ui->cbxSecurity->setCurrentIndex(6); - WepOrWpa = 1; - } - } -} - -void DlgConnHidWifiSecFast::changeDialogAuth() -{ - if(ui->cbxAuth->currentIndex()==0){ -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiSecTls *connHidWifiSecTls = new DlgConnHidWifiSecTls(WepOrWpa, this->parentWidget()); - connHidWifiSecTls->show(); - } else if(ui->cbxAuth->currentIndex()==1) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiSecLeap *connHidWifiSecLeap = new DlgConnHidWifiSecLeap(WepOrWpa, this->parentWidget()); - connHidWifiSecLeap->show(); - } else if(ui->cbxAuth->currentIndex()==2) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiSecPwd *connHidWifiSecPwd = new DlgConnHidWifiSecPwd(WepOrWpa, this->parentWidget()); - connHidWifiSecPwd->show(); - } else if(ui->cbxAuth->currentIndex()==3) { - qDebug()<<"it's not need to change dialog"; - } else if(ui->cbxAuth->currentIndex()==4) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiSecTunnelTLS *connHidWifiSecTuTls = new DlgConnHidWifiSecTunnelTLS(WepOrWpa, this->parentWidget()); - connHidWifiSecTuTls->show(); - } else { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiSecPeap *connHidWifiSecPeap = new DlgConnHidWifiSecPeap(WepOrWpa); - connHidWifiSecPeap->show(); - } -} - -void DlgConnHidWifiSecFast::on_btnCancel_clicked() -{ - this->close(); -} - -void DlgConnHidWifiSecFast::on_btnConnect_clicked() -{ - this->close(); -} - -void DlgConnHidWifiSecFast::on_checkBoxAutoPCA_stateChanged(int arg1) -{ - if (arg1 == 0) { - ui->cbxAutoPCA->setEnabled(false); - } else { - ui->cbxAutoPCA->setEnabled(true); - } -} - -void DlgConnHidWifiSecFast::on_checkBoxPwd_stateChanged(int arg1) -{ - if (arg1 == 0) { - ui->lePassword ->setEchoMode(QLineEdit::Password); - } else { - ui->lePassword->setEchoMode(QLineEdit::Normal); - } -} - -void DlgConnHidWifiSecFast::on_leNetName_textEdited(const QString &arg1) -{ - if (ui->leNetName->text() == ""){ - ui->btnConnect->setEnabled(false); - } else if(ui->leAnonyId->text() == ""){ - ui->btnConnect->setEnabled(false); - } else if (ui->leUserName->text() == ""){ - ui->btnConnect->setEnabled(false); - } else if (ui->lePassword->text() == ""){ - ui->btnConnect->setEnabled(false); - } else { - ui->btnConnect->setEnabled(true); - } -} - -void DlgConnHidWifiSecFast::on_leAnonyId_textEdited(const QString &arg1) -{ - if (ui->leNetName->text() == ""){ - ui->btnConnect->setEnabled(false); - } else if(ui->leAnonyId->text() == ""){ - ui->btnConnect->setEnabled(false); - } else if (ui->leUserName->text() == ""){ - ui->btnConnect->setEnabled(false); - } else if (ui->lePassword->text() == ""){ - ui->btnConnect->setEnabled(false); - } else { - ui->btnConnect->setEnabled(true); - } -} - -void DlgConnHidWifiSecFast::on_leUserName_textEdited(const QString &arg1) -{ - if (ui->leNetName->text() == ""){ - ui->btnConnect->setEnabled(false); - } else if(ui->leAnonyId->text() == ""){ - ui->btnConnect->setEnabled(false); - } else if (ui->leUserName->text() == ""){ - ui->btnConnect->setEnabled(false); - } else if (ui->lePassword->text() == ""){ - ui->btnConnect->setEnabled(false); - } else { - ui->btnConnect->setEnabled(true); - } -} - -void DlgConnHidWifiSecFast::on_lePassword_textEdited(const QString &arg1) -{ - if (ui->leNetName->text() == ""){ - ui->btnConnect->setEnabled(false); - } else if(ui->leAnonyId->text() == ""){ - ui->btnConnect->setEnabled(false); - } else if (ui->leUserName->text() == ""){ - ui->btnConnect->setEnabled(false); - } else if (ui->lePassword->text() == ""){ - ui->btnConnect->setEnabled(false); - } else { - ui->btnConnect->setEnabled(true); - } -} - -void DlgConnHidWifiSecFast::paintEvent(QPaintEvent *event) -{ - QStyleOption opt; - opt.init(this); - QPainter p(this); - style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); - QWidget::paintEvent(event); -} diff --git a/KylinNM/wireless-security/dlgconnhidwifisecfast.h b/KylinNM/wireless-security/dlgconnhidwifisecfast.h deleted file mode 100644 index 7a1491a..0000000 --- a/KylinNM/wireless-security/dlgconnhidwifisecfast.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see -#include - -namespace Ui { -class DlgConnHidWifiSecFast; -} - -class DlgConnHidWifiSecFast : public QDialog -{ - Q_OBJECT - -public: - explicit DlgConnHidWifiSecFast(int type, QWidget *parent = 0); - ~DlgConnHidWifiSecFast(); - -protected: - void paintEvent(QPaintEvent *event); - - /**解决锁屏设置 X11BypassWindowManagerHint 属性导致QCombox弹框异常的问题---START---- - ** 手动绑定下拉框视图和下拉框 过滤点击事件 - **/ - bool eventFilter(QObject *obj, QEvent *ev) override; - -public slots: - void changeDialogSecu(); - void changeDialogAuth(); - -private slots: - void on_btnCancel_clicked(); - - void on_btnConnect_clicked(); - - void on_checkBoxAutoPCA_stateChanged(int arg1); - - void on_checkBoxPwd_stateChanged(int arg1); - - void on_leNetName_textEdited(const QString &arg1); - - void on_leAnonyId_textEdited(const QString &arg1); - - void on_leUserName_textEdited(const QString &arg1); - - void on_lePassword_textEdited(const QString &arg1); - -private: - Ui::DlgConnHidWifiSecFast *ui; - int WepOrWpa = 0;//0 WEP;1WPA - - void mousePressEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - -// QString labelQss, cbxQss, leQss, btnConnQss, btnCancelQss, lineQss, checkBoxQss; - - bool isPress; - QPoint winPos; - QPoint dragPos; -}; - -#endif // DLGCONNHIDWIFISECFAST_H diff --git a/KylinNM/wireless-security/dlgconnhidwifisecfast.ui b/KylinNM/wireless-security/dlgconnhidwifisecfast.ui deleted file mode 100644 index 8b91563..0000000 --- a/KylinNM/wireless-security/dlgconnhidwifisecfast.ui +++ /dev/null @@ -1,505 +0,0 @@ - - - DlgConnHidWifiSecFast - - - - 0 - 0 - 432 - 673 - - - - Connect to Hidden Wi-Fi Network - - - - - 332 - 542 - 18 - 9 - - - - - 11 - - - - - - - - - - 76 - 176 - 90 - 20 - - - - - 10 - - - - - - - - - - 180 - 170 - 182 - 30 - - - - - 10 - - - - - - - 76 - 80 - 90 - 20 - - - - - 10 - - - - - - - - - - 180 - 260 - 182 - 30 - - - - - 10 - - - - - - - - - - 180 - 530 - 182 - 32 - - - - - 10 - - - - QLineEdit::Password - - - - - - 180 - 485 - 182 - 30 - - - - - 10 - - - - - - - 76 - 491 - 90 - 20 - - - - - 10 - - - - - - - - - - 180 - 215 - 182 - 30 - - - - - 10 - - - - - - - - - - 76 - 536 - 90 - 20 - - - - - 10 - - - - - - - - - - 315 - 620 - 90 - 30 - - - - - 10 - - - - - - - - - - 180 - 75 - 182 - 32 - - - - - 10 - - - - - - - - - - 76 - 266 - 90 - 20 - - - - - 10 - - - - - - - - - - 76 - 221 - 90 - 20 - - - - - 10 - - - - - - - - - - 215 - 620 - 90 - 30 - - - - - 10 - - - - - - - - - - 76 - 311 - 90 - 20 - - - - - 10 - - - - - - - - - - 180 - 305 - 182 - 32 - - - - - 10 - - - - - - - 76 - 356 - 100 - 25 - - - - - 10 - - - - - - - - - - 180 - 350 - 182 - 32 - - - - - 10 - - - - - - - - - - 76 - 401 - 90 - 20 - - - - - 10 - - - - - - - - - - 180 - 395 - 182 - 32 - - - - - 10 - - - - - - - 76 - 446 - 90 - 20 - - - - - 10 - - - - - - - - - - 180 - 440 - 182 - 32 - - - - - 10 - - - - - - - - - - 30 - 30 - 140 - 22 - - - - - 9 - - - - - - - - - - 0 - 0 - 432 - 673 - - - - - - - - - - 10 - 140 - 412 - 1 - - - - Qt::Horizontal - - - - - - 10 - 590 - 412 - 1 - - - - Qt::Horizontal - - - lbBoder - lbNetName - leNetName - lbConn - cbxAuth - lePassword - leUserName - lbUserName - cbxSecurity - lbPassword - btnConnect - cbxConn - lbAuth - lbSecurity - btnCancel - lbAnonyId - leAnonyId - checkBoxAutoPCA - cbxAutoPCA - lbPCAfile - lePCAfile - lbInnerAuth - cbxInnerAuth - checkBoxPwd - lbLeftupTitle - lineUp - lineDown - - - - diff --git a/KylinNM/wireless-security/dlgconnhidwifisecleap.cpp b/KylinNM/wireless-security/dlgconnhidwifisecleap.cpp deleted file mode 100644 index a9d9e41..0000000 --- a/KylinNM/wireless-security/dlgconnhidwifisecleap.cpp +++ /dev/null @@ -1,343 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see - -DlgConnHidWifiSecLeap::DlgConnHidWifiSecLeap(int type, QWidget *parent) : - WepOrWpa(type), - QDialog(parent), - ui(new Ui::DlgConnHidWifiSecLeap) -{ - ui->setupUi(this); - - this->setWindowFlags(Qt::FramelessWindowHint); - this->setAttribute(Qt::WA_TranslucentBackground); - //需要添加 void paintEvent(QPaintEvent *event) 函数 - - QPainterPath path; - auto rect = this->rect(); - rect.adjust(1, 1, -1, -1); - path.addRoundedRect(rect, 6, 6); - setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon())); - - this->setStyleSheet("QWidget{border-radius:6px;background-color:rgba(19,19,20,0.7);border:1px solid rgba(255, 255, 255, 0.05);}"); - - MyQss objQss; - - ui->lbBoder->setStyleSheet("QLabel{border-radius:6px;background-color:rgba(19,19,20,0.95);border:1px solid rgba(255, 255, 255, 0.05);}"); - ui->lbBoder->hide(); - ui->lbLeftupTitle->setStyleSheet("QLabel{border:0px;font-size:20px;color:rgba(255,255,255,0.97);background-color:transparent;}"); - ui->lbConn->setStyleSheet(objQss.labelQss); - ui->lbNetName->setStyleSheet(objQss.labelQss); - ui->lbSecurity->setStyleSheet(objQss.labelQss); - ui->lbAuth->setStyleSheet(objQss.labelQss); - ui->lbUserName->setStyleSheet(objQss.labelQss); - ui->lbPassword->setStyleSheet(objQss.labelQss); - - ui->cbxConn->setStyleSheet(objQss.cbxQss); - ui->cbxConn->setView(new QListView()); - ui->leNetName->setStyleSheet(objQss.leQss); - ui->cbxSecurity->setStyleSheet(objQss.cbxQss); - ui->cbxSecurity->setView(new QListView()); - ui->cbxAuth->setStyleSheet(objQss.cbxQss); - ui->cbxAuth->setView(new QListView()); - ui->leUserName->setStyleSheet(objQss.leQss); - ui->lePassword->setStyleSheet(objQss.leQss); - ui->checkBox->setStyleSheet(objQss.checkBoxQss); - - ui->btnCancel->setStyleSheet(objQss.btnCancelQss); - ui->btnConnect->setStyleSheet(objQss.btnConnQss); - ui->lineUp->setStyleSheet(objQss.lineQss); - ui->lineDown->setStyleSheet(objQss.lineQss); - - ui->lbLeftupTitle->setText(tr("Add hidden Wi-Fi")); //加入隐藏Wi-Fi - ui->lbConn->setText(tr("Connection")); //连接设置: - ui->lbNetName->setText(tr("Network name")); //网络名称: - ui->lbSecurity->setText(tr("Wi-Fi security")); //Wi-Fi安全性: - ui->lbAuth->setText(tr("Authentication")); //认证: - ui->lbUserName->setText(tr("Username")); //用户名: - ui->lbPassword->setText(tr("Password")); //密码: - ui->btnCancel->setText(tr("Cancel")); //取消 - ui->btnConnect->setText(tr("Connect")); //连接 - - ui->cbxConn->addItem(tr("C_reate…")); //新建... - int status = system("nmcli connection show>/tmp/kylin-nm-connshow"); - if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection show' in function 'DlgConnHidWifiSecLeap' failed");} - QFile file("/tmp/kylin-nm-connshow"); - if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){ - qDebug()<<"Can't open the file!"; - } - QString txt = file.readAll(); - QStringList txtLine = txt.split("\n"); - file.close(); - foreach (QString line, txtLine) { - if(line.indexOf("wifi") != -1){ - QStringList subLine = line.split(" "); - ui->cbxConn->addItem(subLine[0]); - } - } - ui->cbxConn->setCurrentIndex(0); - - ui->cbxSecurity->addItem(tr("None")); //无 - ui->cbxSecurity->addItem(tr("WPA & WPA2 Personal")); //WPA 及 WPA2 个人 - ui->cbxSecurity->addItem(tr("WEP 40/128-bit Key (Hex or ASCII)")); //WEP 40/128 位密钥(十六进制或ASCII) - ui->cbxSecurity->addItem(tr("WEP 128-bit Passphrase")); //WEP 128 位密码句 - ui->cbxSecurity->addItem("LEAP"); - ui->cbxSecurity->addItem(tr("Dynamic WEP (802.1X)")); //动态 WEP (802.1x) - ui->cbxSecurity->addItem(tr("WPA & WPA2 Enterprise")); //WPA 及 WPA2 企业 - if (WepOrWpa == 0) { - ui->cbxSecurity->setCurrentIndex(5); - } else if (WepOrWpa == 1) { - ui->cbxSecurity->setCurrentIndex(6); - } - connect(ui->cbxSecurity,SIGNAL(currentIndexChanged(QString)),this,SLOT(changeDialogSecu())); - - ui->cbxAuth->addItem("TLS"); - ui->cbxAuth->addItem("LEAP"); - ui->cbxAuth->addItem("PWD"); - ui->cbxAuth->addItem("FAST"); - ui->cbxAuth->addItem(tr("Tunneled TLS"));//隧道 TLS - ui->cbxAuth->addItem(tr("Protected EAP (PEAP)")); //受保护的 EAP - ui->cbxAuth->setCurrentIndex(1); - connect(ui->cbxAuth,SIGNAL(currentIndexChanged(QString)),this,SLOT(changeDialogAuth())); - - ui->btnConnect->setEnabled(false); - - this->setFixedSize(432,487); - - /**解决锁屏设置 X11BypassWindowManagerHint 属性导致QCombox弹框异常的问题---START---- - ** 手动绑定下拉框视图和下拉框 - **/ - ui->cbxConn->view()->setWindowFlags(Qt::Popup | Qt::X11BypassWindowManagerHint); - ui->cbxConn->view()->setParent(this); - ui->cbxConn->view()->hide(); - ui->cbxConn->installEventFilter(this); - - ui->cbxSecurity->view()->setWindowFlags(Qt::Popup | Qt::X11BypassWindowManagerHint); - ui->cbxSecurity->view()->setParent(this); - ui->cbxSecurity->view()->hide(); - ui->cbxSecurity->installEventFilter(this); - - connect(ui->cbxConn->view(), &QAbstractItemView::pressed, this, [=](QModelIndex index){ - Q_EMIT ui->cbxConn->setCurrentIndex(index.row()); - ui->cbxConn->view()->hide(); - }); - - connect(ui->cbxSecurity->view(), &QAbstractItemView::pressed, this, [=](QModelIndex index){ - ui->cbxSecurity->view()->hide(); - Q_EMIT ui->cbxSecurity->setCurrentIndex(index.row()); - }); - - ui->cbxConn->view()->setGeometry(QRect(ui->cbxConn->geometry().left(), ui->cbxConn->geometry().bottom(), ui->cbxConn->view()->width(), ui->cbxConn->view()->height())); - ui->cbxSecurity->view()->setGeometry(QRect(ui->cbxSecurity->geometry().left(), ui->cbxSecurity->geometry().bottom(), ui->cbxSecurity->view()->width(), ui->cbxSecurity->view()->height())); - /**解决锁屏设置 X11BypassWindowManagerHint 属性导致QCombox弹框异常的问题---END---- - ** 手动绑定下拉框视图和下拉框 - **/ -} - -DlgConnHidWifiSecLeap::~DlgConnHidWifiSecLeap() -{ - delete ui; -} - -/**解决锁屏设置 X11BypassWindowManagerHint 属性导致QCombox弹框异常的问题---START---- -** 手动绑定下拉框视图和下拉框 -**/ -bool DlgConnHidWifiSecLeap::eventFilter(QObject *obj, QEvent *ev) -{ - if(ev->type() == QEvent::MouseButtonPress) - { - if(obj == ui->cbxConn) - { - ui->cbxConn->view()->setVisible(!ui->cbxConn->view()->isVisible()); - if(ui->cbxConn->view()->isVisible()) - ui->cbxConn->view()->setFocus(); - } else if (obj == ui->cbxSecurity) - { - ui->cbxSecurity->view()->setVisible(!ui->cbxSecurity->view()->isVisible()); - if(ui->cbxSecurity->view()->isVisible()) - ui->cbxSecurity->view()->setFocus(); - } - } - return false; -} -/**解决锁屏设置 X11BypassWindowManagerHint 属性导致QCombox弹框异常的问题---END---- -** 手动绑定下拉框视图和下拉框 -**/ - -void DlgConnHidWifiSecLeap::mousePressEvent(QMouseEvent *event){ - if(event->button() == Qt::LeftButton){ - this->isPress = true; - this->winPos = this->pos(); - this->dragPos = event->globalPos(); - event->accept(); - } -} -void DlgConnHidWifiSecLeap::mouseReleaseEvent(QMouseEvent *event){ - this->isPress = false; -} -void DlgConnHidWifiSecLeap::mouseMoveEvent(QMouseEvent *event){ - if(this->isPress){ - this->move(this->winPos - (this->dragPos - event->globalPos())); - event->accept(); - } -} - -void DlgConnHidWifiSecLeap::changeDialogSecu() -{ - if(ui->cbxSecurity->currentIndex()==0){ -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifi *connHidWifi = new DlgConnHidWifi(0, 0, this->parentWidget()); - connHidWifi->show(); - } else if(ui->cbxSecurity->currentIndex()==1) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiWpa *connHidWifiWpa = new DlgConnHidWifiWpa(0, 0, this->parentWidget()); - connHidWifiWpa->show(); - } else if(ui->cbxSecurity->currentIndex()==2) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiWep *connHidWifiWep = new DlgConnHidWifiWep(0, this->parentWidget()); - connHidWifiWep->show(); - } else if(ui->cbxSecurity->currentIndex()==3) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiWep *connHidWifiWep = new DlgConnHidWifiWep(1, this->parentWidget()); - connHidWifiWep->show(); - } else if(ui->cbxSecurity->currentIndex()==4) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiLeap *connHidWifiLeap = new DlgConnHidWifiLeap(this->parentWidget()); - connHidWifiLeap->show(); - } else if(ui->cbxSecurity->currentIndex()==5) { - if (WepOrWpa == 1) { - ui->cbxSecurity->setCurrentIndex(5); - WepOrWpa = 0; - } - } else { - if (WepOrWpa == 0){ - ui->cbxSecurity->setCurrentIndex(6); - WepOrWpa = 1; - } - } -} - -void DlgConnHidWifiSecLeap::changeDialogAuth() -{ - if(ui->cbxAuth->currentIndex()==0){ -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiSecTls *connHidWifiSecTls = new DlgConnHidWifiSecTls(WepOrWpa, this->parentWidget()); - connHidWifiSecTls->show(); - } else if(ui->cbxAuth->currentIndex()==1) { - qDebug()<<"it's not need to change dialog"; - } else if(ui->cbxAuth->currentIndex()==2) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiSecPwd *connHidWifiSecPwd = new DlgConnHidWifiSecPwd(WepOrWpa, this->parentWidget()); - connHidWifiSecPwd->show(); - } else if(ui->cbxAuth->currentIndex()==3) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiSecFast *connHidWifiSecFast = new DlgConnHidWifiSecFast(WepOrWpa, this->parentWidget()); - connHidWifiSecFast->show(); - } else if(ui->cbxAuth->currentIndex()==4) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiSecTunnelTLS *connHidWifiSecTuTls = new DlgConnHidWifiSecTunnelTLS(WepOrWpa, this->parentWidget()); - connHidWifiSecTuTls->show(); - } else { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiSecPeap *connHidWifiSecPeap = new DlgConnHidWifiSecPeap(WepOrWpa, this->parentWidget()); - connHidWifiSecPeap->show(); - } -} - -void DlgConnHidWifiSecLeap::on_btnCancel_clicked() -{ - this->close(); -} - -void DlgConnHidWifiSecLeap::on_btnConnect_clicked() -{ - this->close(); -} - -void DlgConnHidWifiSecLeap::on_checkBox_stateChanged(int arg1) -{ - if (arg1 == 0) { - ui->lePassword ->setEchoMode(QLineEdit::Password); - } else { - ui->lePassword->setEchoMode(QLineEdit::Normal); - } -} - -void DlgConnHidWifiSecLeap::on_leNetName_textEdited(const QString &arg1) -{ - if (ui->leNetName->text() == ""){ - ui->btnConnect->setEnabled(false); - } else if (ui->leUserName->text() == ""){ - ui->btnConnect->setEnabled(false); - } else if (ui->lePassword->text() == ""){ - ui->btnConnect->setEnabled(false); - } else { - ui->btnConnect->setEnabled(true); - } -} - -void DlgConnHidWifiSecLeap::on_leUserName_textEdited(const QString &arg1) -{ - if (ui->leNetName->text() == ""){ - ui->btnConnect->setEnabled(false); - } else if (ui->leUserName->text() == ""){ - ui->btnConnect->setEnabled(false); - } else if (ui->lePassword->text() == ""){ - ui->btnConnect->setEnabled(false); - } else { - ui->btnConnect->setEnabled(true); - } -} - -void DlgConnHidWifiSecLeap::on_lePassword_textEdited(const QString &arg1) -{ - if (ui->leNetName->text() == ""){ - ui->btnConnect->setEnabled(false); - } else if (ui->leUserName->text() == ""){ - ui->btnConnect->setEnabled(false); - } else if (ui->lePassword->text() == ""){ - ui->btnConnect->setEnabled(false); - } else { - ui->btnConnect->setEnabled(true); - } -} - -void DlgConnHidWifiSecLeap::paintEvent(QPaintEvent *event) -{ - QStyleOption opt; - opt.init(this); - QPainter p(this); - style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); - QWidget::paintEvent(event); -} diff --git a/KylinNM/wireless-security/dlgconnhidwifisecleap.h b/KylinNM/wireless-security/dlgconnhidwifisecleap.h deleted file mode 100644 index 4336b65..0000000 --- a/KylinNM/wireless-security/dlgconnhidwifisecleap.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see -#include - -namespace Ui { -class DlgConnHidWifiSecLeap; -} - -class DlgConnHidWifiSecLeap : public QDialog -{ - Q_OBJECT - -public: - explicit DlgConnHidWifiSecLeap(int type, QWidget *parent = 0); - ~DlgConnHidWifiSecLeap(); - -protected: - void paintEvent(QPaintEvent *event); - - /**解决锁屏设置 X11BypassWindowManagerHint 属性导致QCombox弹框异常的问题---START---- - ** 手动绑定下拉框视图和下拉框 过滤点击事件 - **/ - bool eventFilter(QObject *obj, QEvent *ev) override; - -public slots: - void changeDialogSecu(); - void changeDialogAuth(); - -private slots: - void on_btnCancel_clicked(); - - void on_btnConnect_clicked(); - - void on_checkBox_stateChanged(int arg1); - - void on_leNetName_textEdited(const QString &arg1); - - void on_leUserName_textEdited(const QString &arg1); - - void on_lePassword_textEdited(const QString &arg1); - -private: - Ui::DlgConnHidWifiSecLeap *ui; - int WepOrWpa = 0;//0 WEP;1WPA - - void mousePressEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - -// QString labelQss, cbxQss, leQss, btnConnQss, btnCancelQss, lineQss, checkBoxQss, checkBoxCAQss; - - bool isPress; - QPoint winPos; - QPoint dragPos; -}; - -#endif // DLGCONNHIDWIFISECLEAP_H diff --git a/KylinNM/wireless-security/dlgconnhidwifisecleap.ui b/KylinNM/wireless-security/dlgconnhidwifisecleap.ui deleted file mode 100644 index 9664fd8..0000000 --- a/KylinNM/wireless-security/dlgconnhidwifisecleap.ui +++ /dev/null @@ -1,354 +0,0 @@ - - - DlgConnHidWifiSecLeap - - - - 0 - 0 - 432 - 487 - - - - Connect to Hidden Wi-Fi Network - - - - - 175 - 215 - 182 - 32 - - - - - 10 - - - - - - - - - - 175 - 350 - 182 - 32 - - - - - 10 - - - - QLineEdit::Password - - - - - - 332 - 362 - 18 - 9 - - - - - 10 - - - - - - - - - - 76 - 176 - 90 - 20 - - - - - 10 - - - - - - - - - - 76 - 221 - 90 - 20 - - - - - 10 - - - - - - - - - - 175 - 305 - 182 - 32 - - - - - 10 - - - - - - - 315 - 440 - 90 - 30 - - - - - 10 - - - - - - - - - - 175 - 75 - 182 - 32 - - - - - 10 - - - - - - - - - - 76 - 311 - 90 - 20 - - - - - 10 - - - - - - - - - - 215 - 440 - 90 - 30 - - - - - 10 - - - - - - - - - - 175 - 260 - 182 - 32 - - - - - 10 - - - - - - - - - - 76 - 266 - 90 - 20 - - - - - 10 - - - - - - - - - - 175 - 170 - 182 - 32 - - - - - 10 - - - - - - - 76 - 356 - 90 - 20 - - - - - 10 - - - - - - - - - - 76 - 80 - 90 - 20 - - - - - 10 - - - - - - - - - - 30 - 30 - 140 - 22 - - - - - - - - - - 0 - 0 - 432 - 487 - - - - - - - - - - 10 - 140 - 412 - 1 - - - - Qt::Horizontal - - - - - - 10 - 410 - 412 - 1 - - - - Qt::Horizontal - - - lbBoder - cbxSecurity - lePassword - checkBox - lbNetName - lbSecurity - leUserName - btnConnect - cbxConn - lbUserName - btnCancel - cbxAuth - lbAuth - leNetName - lbPassword - lbConn - lbLeftupTitle - lineUp - lineDown - - - - diff --git a/KylinNM/wireless-security/dlgconnhidwifisecpeap.cpp b/KylinNM/wireless-security/dlgconnhidwifisecpeap.cpp deleted file mode 100644 index 50a0c9f..0000000 --- a/KylinNM/wireless-security/dlgconnhidwifisecpeap.cpp +++ /dev/null @@ -1,461 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see - -DlgConnHidWifiSecPeap::DlgConnHidWifiSecPeap(int type, QWidget *parent) : - WepOrWpa(type), - QDialog(parent), - ui(new Ui::DlgConnHidWifiSecPeap) -{ - ui->setupUi(this); - - this->setWindowFlags(Qt::FramelessWindowHint); - this->setAttribute(Qt::WA_TranslucentBackground); - //需要添加 void paintEvent(QPaintEvent *event) 函数 - - QPainterPath path; - auto rect = this->rect(); - rect.adjust(1, 1, -1, -1); - path.addRoundedRect(rect, 6, 6); - setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon())); - - this->setStyleSheet("QWidget{border-radius:6px;background-color:rgba(19,19,20,0.7);border:1px solid rgba(255, 255, 255, 0.05);}"); - - MyQss objQss; - - ui->lbBoder->setStyleSheet("QLabel{border-radius:6px;background-color:rgba(19,19,20,0.95);border:1px solid rgba(255, 255, 255, 0.05);}"); - ui->lbBoder->hide(); - ui->lbLeftupTitle->setStyleSheet("QLabel{border:0px;font-size:20px;color:rgba(255,255,255,0.97);background-color:transparent;}"); - ui->lbConn->setStyleSheet(objQss.labelQss); - ui->lbNetName->setStyleSheet(objQss.labelQss); - ui->lbSecurity->setStyleSheet(objQss.labelQss); - ui->lbAuth->setStyleSheet(objQss.labelQss); - ui->lbAnonyId->setStyleSheet(objQss.labelQss); - ui->lbDomain->setStyleSheet(objQss.labelQss); - ui->lbCA->setStyleSheet(objQss.labelQss); - ui->lbCaPwd->setStyleSheet(objQss.labelQss); - ui->lbPEAPver->setStyleSheet(objQss.labelQss); - ui->lbInnerAuth->setStyleSheet(objQss.labelQss); - ui->lbUserName->setStyleSheet(objQss.labelQss); - ui->lbPassword->setStyleSheet(objQss.labelQss); - - ui->cbxConn->setStyleSheet(objQss.cbxQss); - ui->cbxConn->setView(new QListView()); - ui->leNetName->setStyleSheet(objQss.leQss); - ui->cbxSecurity->setStyleSheet(objQss.cbxQss); - ui->cbxSecurity->setView(new QListView()); - ui->cbxAuth->setStyleSheet(objQss.cbxQss); - ui->cbxAuth->setView(new QListView()); - ui->leAnonyId->setStyleSheet(objQss.leQss); - ui->leDomain->setStyleSheet(objQss.leQss); - ui->cbxCA->setStyleSheet(objQss.cbxQss); - ui->cbxCA->setView(new QListView()); - ui->leCaPwd->setStyleSheet(objQss.leQss); - ui->checkBoxPwd->setStyleSheet(objQss.checkBoxQss); - ui->checkBoxCA->setStyleSheet(objQss.checkBoxCAQss); - ui->cbxPEAPver->setStyleSheet(objQss.cbxQss); - ui->cbxPEAPver->setView(new QListView()); - ui->cbxInnerAuth->setStyleSheet(objQss.cbxQss); - ui->cbxInnerAuth->setView(new QListView()); - ui->leUserName->setStyleSheet(objQss.leQss); - ui->lePassword->setStyleSheet(objQss.leQss); - ui->checkBoxPwdSec->setStyleSheet(objQss.checkBoxQss); - - ui->btnCancel->setStyleSheet(objQss.btnCancelQss); - ui->btnConnect->setStyleSheet(objQss.btnConnQss); - ui->lineUp->setStyleSheet(objQss.lineQss); - ui->lineDown->setStyleSheet(objQss.lineQss); - - - ui->lbLeftupTitle->setText(tr("Add hidden Wi-Fi")); //加入隐藏Wi-Fi - ui->lbConn->setText(tr("Connection")); //连接设置: - ui->lbNetName->setText(tr("Network name")); //网络名称: - ui->lbSecurity->setText(tr("Wi-Fi security")); //Wi-Fi安全性: - ui->lbAuth->setText(tr("Authentication")); //认证: - ui->lbAnonyId->setText(tr("Anonymous identity")); //匿名身份: - ui->lbDomain->setText(tr("Domain")); //域名: - ui->lbCA->setText(tr("CA certificate")); //CA 证书: - ui->lbCaPwd->setText(tr("CA certificate password")); //CA 证书密码: - ui->checkBoxCA->setText(tr("No CA certificate is required")); //不需要CA证书 - ui->lbPEAPver->setText(tr("PEAP version")); //PEAP版本: - ui->lbInnerAuth->setText(tr("Inner authentication")); //内部认证: - ui->lbUserName->setText(tr("Username")); //用户名: - ui->lbPassword->setText(tr("Password")); //密码: - ui->btnCancel->setText(tr("Cancel")); //取消 - ui->btnConnect->setText(tr("Connect")); //连接 - - ui->cbxConn->addItem("新建..."); - int status = system("nmcli connection show>/tmp/kylin-nm-connshow"); - if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection show' in function 'DlgConnHidWifiSecPeap' failed");} - QFile file("/tmp/kylin-nm-connshow"); - if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){ - qDebug()<<"Can't open the file!"; - } - QString txt = file.readAll(); - QStringList txtLine = txt.split("\n"); - file.close(); - foreach (QString line, txtLine) { - if(line.indexOf("wifi") != -1){ - QStringList subLine = line.split(" "); - ui->cbxConn->addItem(subLine[0]); - } - } - ui->cbxConn->setCurrentIndex(0); - - ui->cbxSecurity->addItem(tr("None")); //无 - ui->cbxSecurity->addItem(tr("WPA & WPA2 Personal")); //WPA 及 WPA2 个人 - ui->cbxSecurity->addItem(tr("WEP 40/128-bit Key (Hex or ASCII)")); //WEP 40/128 位密钥(十六进制或ASCII) - ui->cbxSecurity->addItem(tr("WEP 128-bit Passphrase")); //WEP 128 位密码句 - ui->cbxSecurity->addItem("LEAP"); - ui->cbxSecurity->addItem(tr("Dynamic WEP (802.1X)")); //动态 WEP (802.1x) - ui->cbxSecurity->addItem(tr("WPA & WPA2 Enterprise")); //WPA 及 WPA2 企业 - if (WepOrWpa == 0) { - ui->cbxSecurity->setCurrentIndex(5); - } else if (WepOrWpa == 1) { - ui->cbxSecurity->setCurrentIndex(6); - } - connect(ui->cbxSecurity,SIGNAL(currentIndexChanged(QString)),this,SLOT(changeDialogSecu())); - - ui->cbxAuth->addItem("TLS"); - ui->cbxAuth->addItem("LEAP"); - ui->cbxAuth->addItem("PWD"); - ui->cbxAuth->addItem("FAST"); - ui->cbxAuth->addItem(tr("Tunneled TLS"));//隧道 TLS - ui->cbxAuth->addItem(tr("Protected EAP (PEAP)")); //受保护的 EAP - ui->cbxAuth->setCurrentIndex(5); - connect(ui->cbxAuth,SIGNAL(currentIndexChanged(QString)),this,SLOT(changeDialogAuth())); - - ui->cbxCA->addItem(tr("None")); //无 - ui->cbxCA->addItem(tr("Choose from file")); //从文件选择... - ui->cbxCA->setCurrentIndex(0); - - ui->cbxPEAPver->addItem(tr("Automatic")); //自动 - ui->cbxPEAPver->addItem(tr("Version 0")); //版本 0 - ui->cbxPEAPver->addItem(tr("Version 1")); //版本 1 - ui->cbxPEAPver->setCurrentIndex(0); - - ui->cbxInnerAuth->addItem("MSCHAPv2"); - ui->cbxInnerAuth->addItem("MDS"); - ui->cbxInnerAuth->addItem("GTC"); - ui->cbxInnerAuth->setCurrentIndex(0); - - ui->btnConnect->setEnabled(false); - - this->setFixedSize(432,700); - -} - -DlgConnHidWifiSecPeap::~DlgConnHidWifiSecPeap() -{ - delete ui; -} - -void DlgConnHidWifiSecPeap::mousePressEvent(QMouseEvent *event){ - if(event->button() == Qt::LeftButton){ - this->isPress = true; - this->winPos = this->pos(); - this->dragPos = event->globalPos(); - event->accept(); - } -} -void DlgConnHidWifiSecPeap::mouseReleaseEvent(QMouseEvent *event){ - this->isPress = false; -} -void DlgConnHidWifiSecPeap::mouseMoveEvent(QMouseEvent *event){ - if(this->isPress){ - this->move(this->winPos - (this->dragPos - event->globalPos())); - event->accept(); - } -} - -void DlgConnHidWifiSecPeap::changeDialogSecu() -{ - if(ui->cbxSecurity->currentIndex()==0){ -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifi *connHidWifi = new DlgConnHidWifi(0, 0,this->parentWidget()); - connHidWifi->show(); - } else if(ui->cbxSecurity->currentIndex()==1) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiWpa *connHidWifiWpa = new DlgConnHidWifiWpa(0, 0, this->parentWidget()); - connHidWifiWpa->show(); - } else if(ui->cbxSecurity->currentIndex()==2) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiWep *connHidWifiWep = new DlgConnHidWifiWep(0, this->parentWidget()); - connHidWifiWep->show(); - } else if(ui->cbxSecurity->currentIndex()==3) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiWep *connHidWifiWep = new DlgConnHidWifiWep(1, this->parentWidget()); - connHidWifiWep->show(); - } else if(ui->cbxSecurity->currentIndex()==4) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiLeap *connHidWifiLeap = new DlgConnHidWifiLeap(this->parentWidget()); - connHidWifiLeap->show(); - } else if(ui->cbxSecurity->currentIndex()==5) { - if (WepOrWpa == 1) { - ui->cbxSecurity->setCurrentIndex(5); - WepOrWpa = 0; - } - } else { - if (WepOrWpa == 0){ - ui->cbxSecurity->setCurrentIndex(6); - WepOrWpa = 1; - } - } -} - -void DlgConnHidWifiSecPeap::changeDialogAuth() -{ - if(ui->cbxAuth->currentIndex()==0){ -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiSecTls *connHidWifiSecTls = new DlgConnHidWifiSecTls(WepOrWpa, this->parentWidget()); - connHidWifiSecTls->show(); - } else if(ui->cbxAuth->currentIndex()==1) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiSecLeap *connHidWifiSecLeap = new DlgConnHidWifiSecLeap(WepOrWpa, this->parentWidget()); - connHidWifiSecLeap->show(); - } else if(ui->cbxAuth->currentIndex()==2) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiSecPwd *connHidWifiSecPwd = new DlgConnHidWifiSecPwd(WepOrWpa); - connHidWifiSecPwd->show(); - } else if(ui->cbxAuth->currentIndex()==3) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiSecFast *connHidWifiSecFast = new DlgConnHidWifiSecFast(WepOrWpa); - connHidWifiSecFast->show(); - } else if(ui->cbxAuth->currentIndex()==4) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiSecTunnelTLS *connHidWifiSecTuTls = new DlgConnHidWifiSecTunnelTLS(WepOrWpa); - connHidWifiSecTuTls->show(); - } else { - qDebug()<<"it's not need to change dialog"; - } -} - -void DlgConnHidWifiSecPeap::on_cbxCA_currentIndexChanged(const QString &arg1) -{ - if (ui->cbxCA->currentIndex() == 0){ - ui->leCaPwd->setText(""); - ui->lbCaPwd->setEnabled(false); - ui->leCaPwd->setEnabled(false); - } else { - ui->leCaPwd->setText(""); - ui->lbCaPwd->setEnabled(true); - ui->leCaPwd->setEnabled(true); - } -} - -void DlgConnHidWifiSecPeap::on_btnCancel_clicked() -{ - this->close(); -} - -void DlgConnHidWifiSecPeap::on_btnConnect_clicked() -{ - this->close(); -} - -void DlgConnHidWifiSecPeap::on_checkBoxPwd_stateChanged(int arg1) -{ - if (arg1 == 0) { - ui->leCaPwd->setEchoMode(QLineEdit::Password); - } else { - ui->leCaPwd->setEchoMode(QLineEdit::Normal); - } -} - -void DlgConnHidWifiSecPeap::on_checkBoxCA_stateChanged(int arg1) -{ - if (arg1 == 0) { - ui->cbxCA->setCurrentIndex(0); - ui->leCaPwd->setText(""); - ui->lbCA->setEnabled(true); - ui->cbxCA->setEnabled(true); - } else { - ui->cbxCA->setCurrentIndex(0); - ui->leCaPwd->setText(""); - ui->lbCA->setEnabled(false); - ui->cbxCA->setEnabled(false); - } -} - -void DlgConnHidWifiSecPeap::on_checkBoxPwdSec_stateChanged(int arg1) -{ - if (arg1 == 0) { - ui->lePassword->setEchoMode(QLineEdit::Password); - } else { - ui->lePassword->setEchoMode(QLineEdit::Normal); - } -} - -void DlgConnHidWifiSecPeap::on_leNetName_textEdited(const QString &arg1) -{ - if (ui->leNetName->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->leAnonyId->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->leDomain->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->leUserName->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->lePassword->text() == ""){ - ui->btnConnect->setEnabled(false); - }else{ - if (ui->cbxCA->currentIndex() == 0){ - ui->btnConnect->setEnabled(true); - }else if(ui->leCaPwd->text() == ""){ - ui->btnConnect->setEnabled(false); - }else{ - ui->btnConnect->setEnabled(true); - } - } -} - -void DlgConnHidWifiSecPeap::on_leAnonyId_textEdited(const QString &arg1) -{ - if (ui->leNetName->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->leAnonyId->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->leDomain->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->leUserName->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->lePassword->text() == ""){ - ui->btnConnect->setEnabled(false); - }else{ - if (ui->cbxCA->currentIndex() == 0){ - ui->btnConnect->setEnabled(true); - }else if(ui->leCaPwd->text() == ""){ - ui->btnConnect->setEnabled(false); - }else{ - ui->btnConnect->setEnabled(true); - } - } -} - -void DlgConnHidWifiSecPeap::on_leDomain_textEdited(const QString &arg1) -{ - if (ui->leNetName->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->leAnonyId->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->leDomain->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->leUserName->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->lePassword->text() == ""){ - ui->btnConnect->setEnabled(false); - }else{ - if (ui->cbxCA->currentIndex() == 0){ - ui->btnConnect->setEnabled(true); - }else if(ui->leCaPwd->text() == ""){ - ui->btnConnect->setEnabled(false); - }else{ - ui->btnConnect->setEnabled(true); - } - } -} - -void DlgConnHidWifiSecPeap::on_leCaPwd_textEdited(const QString &arg1) -{ - if (ui->leNetName->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->leAnonyId->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->leDomain->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->leUserName->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->lePassword->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->leCaPwd->text() == ""){ - ui->btnConnect->setEnabled(false); - }else{ - ui->btnConnect->setEnabled(true); - } -} - -void DlgConnHidWifiSecPeap::on_leUserName_textEdited(const QString &arg1) -{ - if (ui->leNetName->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->leAnonyId->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->leDomain->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->leUserName->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->lePassword->text() == ""){ - ui->btnConnect->setEnabled(false); - }else{ - if (ui->cbxCA->currentIndex() == 0){ - ui->btnConnect->setEnabled(true); - }else if(ui->leCaPwd->text() == ""){ - ui->btnConnect->setEnabled(false); - }else{ - ui->btnConnect->setEnabled(true); - } - } -} - -void DlgConnHidWifiSecPeap::on_lePassword_textEdited(const QString &arg1) -{ - if (ui->leNetName->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->leAnonyId->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->leDomain->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->leUserName->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->lePassword->text() == ""){ - ui->btnConnect->setEnabled(false); - }else{ - if (ui->cbxCA->currentIndex() == 0){ - ui->btnConnect->setEnabled(true); - }else if(ui->leCaPwd->text() == ""){ - ui->btnConnect->setEnabled(false); - }else{ - ui->btnConnect->setEnabled(true); - } - } -} - -void DlgConnHidWifiSecPeap::paintEvent(QPaintEvent *event) -{ - QStyleOption opt; - opt.init(this); - QPainter p(this); - style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); - QWidget::paintEvent(event); -} diff --git a/KylinNM/wireless-security/dlgconnhidwifisecpeap.h b/KylinNM/wireless-security/dlgconnhidwifisecpeap.h deleted file mode 100644 index d0361df..0000000 --- a/KylinNM/wireless-security/dlgconnhidwifisecpeap.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see -#include - -namespace Ui { -class DlgConnHidWifiSecPeap; -} - -class DlgConnHidWifiSecPeap : public QDialog -{ - Q_OBJECT - -public: - explicit DlgConnHidWifiSecPeap(int type, QWidget *parent = 0); - ~DlgConnHidWifiSecPeap(); - -protected: - void paintEvent(QPaintEvent *event); - -public slots: - void changeDialogSecu(); - void changeDialogAuth(); - -private slots: - void on_btnCancel_clicked(); - - void on_btnConnect_clicked(); - - void on_cbxCA_currentIndexChanged(const QString &arg1); - - void on_checkBoxPwd_stateChanged(int arg1); - - void on_checkBoxCA_stateChanged(int arg1); - - void on_checkBoxPwdSec_stateChanged(int arg1); - - void on_leNetName_textEdited(const QString &arg1); - - void on_leAnonyId_textEdited(const QString &arg1); - - void on_leDomain_textEdited(const QString &arg1); - - void on_leCaPwd_textEdited(const QString &arg1); - - void on_leUserName_textEdited(const QString &arg1); - - void on_lePassword_textEdited(const QString &arg1); - -private: - Ui::DlgConnHidWifiSecPeap *ui; - int WepOrWpa = 0;//0 WEP;1WPA - - void mousePressEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - -// QString labelQss, cbxQss, leQss, btnConnQss, btnCancelQss, lineQss, checkBoxQss, checkBoxCAQss; - - bool isPress; - QPoint winPos; - QPoint dragPos; -}; - -#endif // DLGCONNHIDWIFISECPEAP_H diff --git a/KylinNM/wireless-security/dlgconnhidwifisecpeap.ui b/KylinNM/wireless-security/dlgconnhidwifisecpeap.ui deleted file mode 100644 index 82bc354..0000000 --- a/KylinNM/wireless-security/dlgconnhidwifisecpeap.ui +++ /dev/null @@ -1,614 +0,0 @@ - - - DlgConnHidWifiSecPeap - - - - 0 - 0 - 432 - 700 - - - - Connect to Hidden Wi-Fi Network - - - - - 180 - 141 - 200 - 32 - - - - - 10 - - - - - - - 180 - 341 - 200 - 32 - - - - - 10 - - - - - - - - - - 76 - 76 - 90 - 20 - - - - - 10 - - - - - - - - - - 180 - 301 - 200 - 32 - - - - - 10 - - - - - - - 180 - 71 - 200 - 32 - - - - - 10 - - - - - - - - - - 180 - 381 - 200 - 32 - - - - - 10 - - - - QLineEdit::Password - - - - - - 315 - 650 - 90 - 30 - - - - - 10 - - - - - - - - - - 180 - 181 - 200 - 32 - - - - - 10 - - - - - - - - - - 180 - 261 - 200 - 32 - - - - - 10 - - - - - - - 183 - 421 - 200 - 25 - - - - - 10 - - - - - - - - - - 76 - 146 - 90 - 20 - - - - - 10 - - - - - - - - - - 215 - 650 - 90 - 30 - - - - - 10 - - - - - - - - - - 76 - 306 - 90 - 20 - - - - - 10 - - - - - - - - - - 76 - 386 - 90 - 20 - - - - - 10 - - - - - - - - - - 357 - 593 - 18 - 9 - - - - - 10 - - - - - - - - - - 357 - 393 - 18 - 9 - - - - - 10 - - - - - - - - - - 76 - 186 - 90 - 20 - - - - - 10 - - - - - - - - - - 180 - 461 - 200 - 32 - - - - - 10 - - - - - - - - - - 76 - 226 - 90 - 20 - - - - - 10 - - - - - - - - - - 76 - 466 - 90 - 20 - - - - - 10 - - - - - - - - - - 180 - 221 - 200 - 32 - - - - - 10 - - - - - - - - - - 76 - 346 - 90 - 20 - - - - - 10 - - - - - - - - - - 76 - 266 - 90 - 20 - - - - - 10 - - - - - - - - - - 76 - 586 - 90 - 20 - - - - - 10 - - - - - - - - - - 180 - 541 - 200 - 32 - - - - - 10 - - - - - - - 180 - 501 - 200 - 32 - - - - - 10 - - - - - - - - - - 180 - 581 - 200 - 32 - - - - - 10 - - - - QLineEdit::Password - - - - - - 76 - 506 - 90 - 20 - - - - - 10 - - - - - - - - - - 76 - 546 - 90 - 20 - - - - - 10 - - - - - - - - - - 0 - 0 - 432 - 700 - - - - - - - - - - 30 - 28 - 140 - 22 - - - - - - - - - - 10 - 121 - 412 - 1 - - - - Qt::Horizontal - - - - - - 10 - 631 - 412 - 1 - - - - Qt::Horizontal - - - lbBoder - leNetName - cbxCA - lbConn - leDomain - cbxConn - leCaPwd - btnConnect - cbxSecurity - leAnonyId - checkBoxCA - lbNetName - btnCancel - lbDomain - lbCaPwd - checkBoxPwd - lbSecurity - cbxPEAPver - lbAuth - lbPEAPver - cbxAuth - lbCA - lbAnonyId - lbPassword - leUserName - cbxInnerAuth - lePassword - lbInnerAuth - lbUserName - checkBoxPwdSec - lbLeftupTitle - lineUp - lineDown - - - - diff --git a/KylinNM/wireless-security/dlgconnhidwifisecpwd.cpp b/KylinNM/wireless-security/dlgconnhidwifisecpwd.cpp deleted file mode 100644 index 94b90d7..0000000 --- a/KylinNM/wireless-security/dlgconnhidwifisecpwd.cpp +++ /dev/null @@ -1,291 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see - -DlgConnHidWifiSecPwd::DlgConnHidWifiSecPwd(int type, QWidget *parent) : - WepOrWpa(type), - QDialog(parent), - ui(new Ui::DlgConnHidWifiSecPwd) -{ - ui->setupUi(this); - - this->setWindowFlags(Qt::FramelessWindowHint); - this->setAttribute(Qt::WA_TranslucentBackground); - //需要添加 void paintEvent(QPaintEvent *event) 函数 - - QPainterPath path; - auto rect = this->rect(); - rect.adjust(1, 1, -1, -1); - path.addRoundedRect(rect, 6, 6); - setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon())); - - this->setStyleSheet("QWidget{border-radius:6px;background-color:rgba(19,19,20,0.7);border:1px solid rgba(255, 255, 255, 0.05);}"); - - MyQss objQss; - - ui->lbBoder->setStyleSheet("QLabel{border-radius:6px;background-color:rgba(19,19,20,0.95);border:1px solid rgba(255, 255, 255, 0.05);}"); - ui->lbBoder->hide(); - ui->lbLeftupTitle->setStyleSheet("QLabel{border:0px;font-size:20px;color:rgba(255,255,255,0.97);background-color:transparent;}"); - ui->lbConn->setStyleSheet(objQss.labelQss); - ui->lbNetName->setStyleSheet(objQss.labelQss); - ui->lbSecurity->setStyleSheet(objQss.labelQss); - ui->lbAuth->setStyleSheet(objQss.labelQss); - ui->lbUserName->setStyleSheet(objQss.labelQss); - ui->lbPassword->setStyleSheet(objQss.labelQss); - - ui->cbxConn->setStyleSheet(objQss.cbxQss); - ui->cbxConn->setView(new QListView()); - ui->leNetName->setStyleSheet(objQss.leQss); - ui->cbxSecurity->setStyleSheet(objQss.cbxQss); - ui->cbxSecurity->setView(new QListView()); - ui->cbxAuth->setStyleSheet(objQss.cbxQss); - ui->cbxAuth->setView(new QListView()); - ui->leUserName->setStyleSheet(objQss.leQss); - ui->lePassword->setStyleSheet(objQss.leQss); - ui->checkBox->setStyleSheet(objQss.checkBoxQss); - - ui->btnCancel->setStyleSheet(objQss.btnCancelQss); - ui->btnConnect->setStyleSheet(objQss.btnConnQss); - ui->lineUp->setStyleSheet(objQss.lineQss); - ui->lineDown->setStyleSheet(objQss.lineQss); - - - ui->lbLeftupTitle->setText(tr("Add hidden Wi-Fi")); //加入隐藏Wi-Fi - ui->lbConn->setText(tr("Connection")); //连接设置: - ui->lbNetName->setText(tr("Network name")); //网络名称: - ui->lbSecurity->setText(tr("Wi-Fi security")); //Wi-Fi安全性: - ui->lbAuth->setText(tr("Authentication")); //认证: - ui->lbUserName->setText(tr("Username")); //用户名: - ui->lbPassword->setText(tr("Password")); //密码: - ui->btnCancel->setText(tr("Cancel")); //取消 - ui->btnConnect->setText(tr("Connect")); //连接 - - ui->cbxConn->addItem(tr("C_reate…")); //新建... - int status = system("nmcli connection show>/tmp/kylin-nm-connshow"); - if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection show' in function 'DlgConnHidWifiSecPwd' failed");} - QFile file("/tmp/kylin-nm-connshow"); - if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){ - qDebug()<<"Can't open the file!"; - } - QString txt = file.readAll(); - QStringList txtLine = txt.split("\n"); - file.close(); - foreach (QString line, txtLine) { - if(line.indexOf("wifi") != -1){ - QStringList subLine = line.split(" "); - ui->cbxConn->addItem(subLine[0]); - } - } - ui->cbxConn->setCurrentIndex(0); - - ui->cbxSecurity->addItem(tr("None")); //无 - ui->cbxSecurity->addItem(tr("WPA & WPA2 Personal")); //WPA 及 WPA2 个人 - ui->cbxSecurity->addItem(tr("WEP 40/128-bit Key (Hex or ASCII)")); //WEP 40/128 位密钥(十六进制或ASCII) - ui->cbxSecurity->addItem(tr("WEP 128-bit Passphrase")); //WEP 128 位密码句 - ui->cbxSecurity->addItem("LEAP"); - ui->cbxSecurity->addItem(tr("Dynamic WEP (802.1X)")); //动态 WEP (802.1x) - ui->cbxSecurity->addItem(tr("WPA & WPA2 Enterprise")); //WPA 及 WPA2 企业 - if (WepOrWpa == 0) { - ui->cbxSecurity->setCurrentIndex(5); - } else if (WepOrWpa == 1) { - ui->cbxSecurity->setCurrentIndex(6); - } - connect(ui->cbxSecurity,SIGNAL(currentIndexChanged(QString)),this,SLOT(changeDialogSecu())); - - ui->cbxAuth->addItem("TLS"); - ui->cbxAuth->addItem("LEAP"); - ui->cbxAuth->addItem("PWD"); - ui->cbxAuth->addItem("FAST"); - ui->cbxAuth->addItem(tr("Tunneled TLS"));//隧道 TLS - ui->cbxAuth->addItem(tr("Protected EAP (PEAP)")); //受保护的 EAP - ui->cbxAuth->setCurrentIndex(2); - connect(ui->cbxAuth,SIGNAL(currentIndexChanged(QString)),this,SLOT(changeDialogAuth())); - - ui->btnConnect->setEnabled(false); - - this->setFixedSize(432,487); - -} - -DlgConnHidWifiSecPwd::~DlgConnHidWifiSecPwd() -{ - delete ui; -} - -void DlgConnHidWifiSecPwd::mousePressEvent(QMouseEvent *event){ - if(event->button() == Qt::LeftButton){ - this->isPress = true; - this->winPos = this->pos(); - this->dragPos = event->globalPos(); - event->accept(); - } -} -void DlgConnHidWifiSecPwd::mouseReleaseEvent(QMouseEvent *event){ - this->isPress = false; -} -void DlgConnHidWifiSecPwd::mouseMoveEvent(QMouseEvent *event){ - if(this->isPress){ - this->move(this->winPos - (this->dragPos - event->globalPos())); - event->accept(); - } -} - -void DlgConnHidWifiSecPwd::changeDialogSecu() -{ - if(ui->cbxSecurity->currentIndex()==0){ -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifi *connHidWifi = new DlgConnHidWifi(0, 0, this->parentWidget()); - connHidWifi->show(); - } else if(ui->cbxSecurity->currentIndex()==1) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiWpa *connHidWifiWpa = new DlgConnHidWifiWpa(0, 0, this->parentWidget()); - connHidWifiWpa->show(); - } else if(ui->cbxSecurity->currentIndex()==2) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiWep *connHidWifiWep = new DlgConnHidWifiWep(0, this->parentWidget()); - connHidWifiWep->show(); - } else if(ui->cbxSecurity->currentIndex()==3) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiWep *connHidWifiWep = new DlgConnHidWifiWep(1, this->parentWidget()); - connHidWifiWep->show(); - } else if(ui->cbxSecurity->currentIndex()==4) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiLeap *connHidWifiLeap = new DlgConnHidWifiLeap(this->parentWidget()); - connHidWifiLeap->show(); - } else if(ui->cbxSecurity->currentIndex()==5) { - if (WepOrWpa == 1) { - ui->cbxSecurity->setCurrentIndex(5); - WepOrWpa = 0; - } - } else { - if (WepOrWpa == 0){ - ui->cbxSecurity->setCurrentIndex(6); - WepOrWpa = 1; - } - } -} - -void DlgConnHidWifiSecPwd::changeDialogAuth() -{ - if(ui->cbxAuth->currentIndex()==0){ -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiSecTls *connHidWifiSecTls = new DlgConnHidWifiSecTls(WepOrWpa, this->parentWidget()); - connHidWifiSecTls->show(); - } else if(ui->cbxAuth->currentIndex()==1) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiSecLeap *connHidWifiSecLeap = new DlgConnHidWifiSecLeap(WepOrWpa, this->parentWidget()); - connHidWifiSecLeap->show(); - } else if(ui->cbxAuth->currentIndex()==2) { - qDebug()<<"it's not need to change dialog"; - } else if(ui->cbxAuth->currentIndex()==3) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiSecFast *connHidWifiSecFast = new DlgConnHidWifiSecFast(WepOrWpa); - connHidWifiSecFast->show(); - } else if(ui->cbxAuth->currentIndex()==4) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiSecTunnelTLS *connHidWifiSecTuTls = new DlgConnHidWifiSecTunnelTLS(WepOrWpa); - connHidWifiSecTuTls->show(); - } else { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiSecPeap *connHidWifiSecPeap = new DlgConnHidWifiSecPeap(WepOrWpa); - connHidWifiSecPeap->show(); - } -} - -void DlgConnHidWifiSecPwd::on_btnCancel_clicked() -{ - this->close(); -} - -void DlgConnHidWifiSecPwd::on_btnConnect_clicked() -{ - this->close(); -} - -void DlgConnHidWifiSecPwd::on_checkBox_stateChanged(int arg1) -{ - if (arg1 == 0) { - ui->lePassword ->setEchoMode(QLineEdit::Password); - } else { - ui->lePassword->setEchoMode(QLineEdit::Normal); - } -} - -void DlgConnHidWifiSecPwd::on_leNetName_textEdited(const QString &arg1) -{ - if (ui->leNetName->text() == ""){ - ui->btnConnect->setEnabled(false); - } else if (ui->leUserName->text() == ""){ - ui->btnConnect->setEnabled(false); - } else if (ui->lePassword->text() == ""){ - ui->btnConnect->setEnabled(false); - } else { - ui->btnConnect->setEnabled(true); - } -} - -void DlgConnHidWifiSecPwd::on_leUserName_textEdited(const QString &arg1) -{ - if (ui->leNetName->text() == ""){ - ui->btnConnect->setEnabled(false); - } else if (ui->leUserName->text() == ""){ - ui->btnConnect->setEnabled(false); - } else if (ui->lePassword->text() == ""){ - ui->btnConnect->setEnabled(false); - } else { - ui->btnConnect->setEnabled(true); - } -} - -void DlgConnHidWifiSecPwd::on_lePassword_textEdited(const QString &arg1) -{ - if (ui->leNetName->text() == ""){ - ui->btnConnect->setEnabled(false); - } else if (ui->leUserName->text() == ""){ - ui->btnConnect->setEnabled(false); - } else if (ui->lePassword->text() == ""){ - ui->btnConnect->setEnabled(false); - } else { - ui->btnConnect->setEnabled(true); - } -} - -void DlgConnHidWifiSecPwd::paintEvent(QPaintEvent *event) -{ - QStyleOption opt; - opt.init(this); - QPainter p(this); - style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); - QWidget::paintEvent(event); -} diff --git a/KylinNM/wireless-security/dlgconnhidwifisecpwd.h b/KylinNM/wireless-security/dlgconnhidwifisecpwd.h deleted file mode 100644 index d44250d..0000000 --- a/KylinNM/wireless-security/dlgconnhidwifisecpwd.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see -#include - -namespace Ui { -class DlgConnHidWifiSecPwd; -} - -class DlgConnHidWifiSecPwd : public QDialog -{ - Q_OBJECT - -public: - explicit DlgConnHidWifiSecPwd(int type, QWidget *parent = 0); - ~DlgConnHidWifiSecPwd(); - -protected: - void paintEvent(QPaintEvent *event); - -public slots: - void changeDialogSecu(); - void changeDialogAuth(); - -private slots: - void on_btnCancel_clicked(); - - void on_btnConnect_clicked(); - - void on_checkBox_stateChanged(int arg1); - - void on_leNetName_textEdited(const QString &arg1); - - void on_leUserName_textEdited(const QString &arg1); - - void on_lePassword_textEdited(const QString &arg1); - -private: - Ui::DlgConnHidWifiSecPwd *ui; - int WepOrWpa = 0;//0 WEP;1WPA - - void mousePressEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - -// QString labelQss, cbxQss, leQss, btnConnQss, btnCancelQss, lineQss, checkBoxQss, checkBoxCAQss; - - bool isPress; - QPoint winPos; - QPoint dragPos; -}; - -#endif // DLGCONNHIDWIFISECPWD_H diff --git a/KylinNM/wireless-security/dlgconnhidwifisecpwd.ui b/KylinNM/wireless-security/dlgconnhidwifisecpwd.ui deleted file mode 100644 index 7dc8cba..0000000 --- a/KylinNM/wireless-security/dlgconnhidwifisecpwd.ui +++ /dev/null @@ -1,354 +0,0 @@ - - - DlgConnHidWifiSecPwd - - - - 0 - 0 - 432 - 487 - - - - Connect to Hidden Wi-Fi Network - - - - - 333 - 363 - 18 - 9 - - - - - 10 - - - - - - - - - - 215 - 440 - 90 - 30 - - - - - 10 - - - - - - - - - - 0 - 0 - 432 - 487 - - - - - - - - - - 30 - 30 - 140 - 22 - - - - - - - - - - 175 - 170 - 182 - 32 - - - - - 10 - - - - - - - 76 - 266 - 90 - 20 - - - - - 10 - - - - - - - - - - 76 - 311 - 90 - 20 - - - - - 10 - - - - - - - - - - 76 - 80 - 90 - 20 - - - - - 10 - - - - - - - - - - 175 - 75 - 182 - 32 - - - - - 10 - - - - - - - - - - 315 - 440 - 90 - 30 - - - - - 10 - - - - - - - - - - 175 - 215 - 182 - 32 - - - - - 10 - - - - - - - - - - 175 - 305 - 182 - 32 - - - - - 10 - - - - - - - 175 - 350 - 182 - 32 - - - - - 10 - - - - QLineEdit::Password - - - - - - 76 - 176 - 90 - 20 - - - - - 10 - - - - - - - - - - 76 - 221 - 90 - 20 - - - - - 10 - - - - - - - - - - 76 - 356 - 90 - 20 - - - - - 10 - - - - - - - - - - 175 - 260 - 182 - 32 - - - - - 10 - - - - - - - - - - 10 - 140 - 412 - 1 - - - - Qt::Horizontal - - - - - - 10 - 410 - 412 - 1 - - - - Qt::Horizontal - - - lbBoder - btnCancel - leNetName - lbAuth - lbUserName - lbConn - cbxConn - btnConnect - cbxSecurity - leUserName - lePassword - lbNetName - lbSecurity - lbPassword - cbxAuth - lbLeftupTitle - lineUp - lineDown - checkBox - - - - diff --git a/KylinNM/wireless-security/dlgconnhidwifisectls.cpp b/KylinNM/wireless-security/dlgconnhidwifisectls.cpp deleted file mode 100644 index 5a61d76..0000000 --- a/KylinNM/wireless-security/dlgconnhidwifisectls.cpp +++ /dev/null @@ -1,628 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see - -DlgConnHidWifiSecTls::DlgConnHidWifiSecTls(int type, QWidget *parent) : - WepOrWpa(type), - QDialog(parent), - ui(new Ui::DlgConnHidWifiSecTls) -{ - ui->setupUi(this); - - this->setWindowFlags(Qt::FramelessWindowHint); - this->setAttribute(Qt::WA_TranslucentBackground); - //需要添加 void paintEvent(QPaintEvent *event) 函数 - - QPainterPath path; - auto rect = this->rect(); - rect.adjust(1, 1, -1, -1); - path.addRoundedRect(rect, 6, 6); - setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon())); - - this->setStyleSheet("QWidget{border-radius:6px;background-color:rgba(19,19,20,0.7);border:1px solid rgba(255, 255, 255, 0.05);}"); - - MyQss objQss; - - ui->lbBoder->setStyleSheet("QLabel{border-radius:6px;background-color:rgba(19,19,20,0.95);border:1px solid rgba(255, 255, 255, 0.05);}"); - ui->lbBoder->hide(); - ui->lbLeftupTitle->setStyleSheet("QLabel{border:0px;font-size:20px;color:rgba(255,255,255,0.97);background-color:transparent;}"); - ui->lbConn->setStyleSheet(objQss.labelQss); - ui->lbNetName->setStyleSheet(objQss.labelQss); - ui->lbSecurity->setStyleSheet(objQss.labelQss); - ui->lbAuth->setStyleSheet(objQss.labelQss); - ui->lbIdentity->setStyleSheet(objQss.labelQss); - ui->lbDomain->setStyleSheet(objQss.labelQss); - ui->lbCA->setStyleSheet(objQss.labelQss); - ui->lbCaPwd->setStyleSheet(objQss.labelQss); - ui->lbUserCertify->setStyleSheet(objQss.labelQss); - ui->lbUserCertifyPwd->setStyleSheet(objQss.labelQss); - ui->lbUserPriKey->setStyleSheet(objQss.labelQss); - ui->lbUserKeyPwd->setStyleSheet(objQss.labelQss); - - ui->cbxConn->setStyleSheet(objQss.cbxQss); - ui->cbxConn->setView(new QListView()); - ui->leNetName->setStyleSheet(objQss.leQss); - ui->cbxSecurity->setStyleSheet(objQss.cbxQss); - ui->cbxSecurity->setView(new QListView()); - ui->cbxAuth->setStyleSheet(objQss.cbxQss); - ui->cbxAuth->setView(new QListView()); - ui->leIdentity->setStyleSheet(objQss.leQss); - ui->leDomain->setStyleSheet(objQss.leQss); - ui->cbxCA->setStyleSheet(objQss.cbxQss); - ui->cbxCA->setView(new QListView()); - ui->leCaPwd->setStyleSheet(objQss.leQss); - ui->checkBoxPwd->setStyleSheet(objQss.checkBoxQss); - ui->checkBoxCA->setStyleSheet(objQss.checkBoxCAQss); - ui->cbxUserCertify->setStyleSheet(objQss.cbxQss); - ui->cbxUserCertify->setView(new QListView()); - ui->leUserCertifyPwd->setStyleSheet(objQss.leQss); - ui->cbxUserPriKey->setStyleSheet(objQss.cbxQss); - ui->cbxUserPriKey->setView(new QListView()); - ui->leUserKeyPwd->setStyleSheet(objQss.leQss); - ui->checkBoxPwdSec->setStyleSheet(objQss.checkBoxQss); - - ui->btnCancel->setStyleSheet(objQss.btnCancelQss); - ui->btnConnect->setStyleSheet(objQss.btnCancelQss); - ui->lineUp->setStyleSheet(objQss.lineQss); - ui->lineDown->setStyleSheet(objQss.lineQss); - ui->checkBoxCA->setFocusPolicy(Qt::NoFocus); - - ui->lbLeftupTitle->setText(tr("Add hidden Wi-Fi")); //加入隐藏Wi-Fi - ui->lbConn->setText(tr("Connection")); //连接设置: - ui->lbNetName->setText(tr("Network name")); //网络名称: - ui->lbSecurity->setText(tr("Wi-Fi security")); //Wi-Fi安全性: - ui->lbAuth->setText(tr("Authentication")); //认证: - ui->lbIdentity->setText(tr("Identity")); //身份: - ui->lbDomain->setText(tr("Domain")); //域名: - ui->lbCA->setText(tr("CA certificate")); //CA 证书: - ui->lbCaPwd->setText(tr("CA certificate password")); //CA 证书密码: - ui->checkBoxCA->setText(tr("No CA certificate is required")); //不需要CA证书 - ui->lbUserCertify->setText(tr("User certificate")); //用户证书: - ui->lbUserCertifyPwd->setText(tr("User certificate password")); //用户证书密码: - ui->lbUserPriKey->setText(tr("User private key")); //用户私钥: - ui->lbUserKeyPwd->setText(tr("User key password")); //用户密钥密码: - ui->btnCancel->setText(tr("Cancel")); //取消 - ui->btnConnect->setText(tr("Connect")); //连接 - - ui->cbxConn->addItem(tr("C_reate…")); //新建... - int status = system("nmcli connection show>/tmp/kylin-nm-connshow"); - if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection show' in function 'DlgConnHidWifiSecTls' failed");} - QFile file("/tmp/kylin-nm-connshow"); - if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){ - qDebug()<<"Can't open the file!"; - } - QString txt = file.readAll(); - QStringList txtLine = txt.split("\n"); - file.close(); - foreach (QString line, txtLine) { - if(line.indexOf("wifi") != -1){ - QStringList subLine = line.split(" "); - ui->cbxConn->addItem(subLine[0]); - } - } - ui->cbxConn->setCurrentIndex(0); - - ui->cbxSecurity->addItem(tr("None")); //无 - ui->cbxSecurity->addItem(tr("WPA & WPA2 Personal")); //WPA 及 WPA2 个人 - ui->cbxSecurity->addItem(tr("WEP 40/128-bit Key (Hex or ASCII)")); //WEP 40/128 位密钥(十六进制或ASCII) - ui->cbxSecurity->addItem(tr("WEP 128-bit Passphrase")); //WEP 128 位密码句 - ui->cbxSecurity->addItem("LEAP"); - ui->cbxSecurity->addItem(tr("Dynamic WEP (802.1X)")); //动态 WEP (802.1x) - ui->cbxSecurity->addItem(tr("WPA & WPA2 Enterprise")); //WPA 及 WPA2 企业 - if (WepOrWpa == 0) { - ui->cbxSecurity->setCurrentIndex(5); - } else if (WepOrWpa == 1) { - ui->cbxSecurity->setCurrentIndex(6); - } - connect(ui->cbxSecurity,SIGNAL(currentIndexChanged(QString)),this,SLOT(changeDialogSecu())); - - ui->cbxAuth->addItem("TLS"); - ui->cbxAuth->addItem("LEAP"); - ui->cbxAuth->addItem("PWD"); - ui->cbxAuth->addItem("FAST"); - ui->cbxAuth->addItem(tr("Tunneled TLS"));//隧道 TLS - ui->cbxAuth->addItem(tr("Protected EAP (PEAP)")); //受保护的 EAP - ui->cbxAuth->setCurrentIndex(0); - connect(ui->cbxAuth,SIGNAL(currentIndexChanged(QString)),this,SLOT(changeDialogAuth())); - - ui->cbxCA->addItem(tr("None")); //无 - ui->cbxCA->addItem(tr("Choose from file")); //从文件选择... - ui->cbxCA->setCurrentIndex(0); - - ui->cbxUserCertify->addItem(tr("None")); //无 - ui->cbxUserCertify->addItem(tr("Choose from file")); //从文件选择... - ui->cbxUserCertify->setCurrentIndex(0); - - ui->cbxUserPriKey->addItem(tr("None")); //无 - ui->cbxUserPriKey->addItem(tr("Choose from file")); //从文件选择... - ui->cbxUserPriKey->setCurrentIndex(0); - - ui->btnConnect->setEnabled(false); - - ui->lbCaPwd->setEnabled(false); - ui->leCaPwd->setEnabled(false); - - ui->lbUserCertifyPwd->setEnabled(false); - ui->leUserCertifyPwd->setEnabled(false); - - ui->lbUserPriKey->setEnabled(false); - ui->cbxUserPriKey->setEnabled(false); - - ui->lbUserKeyPwd->setEnabled(false); - ui->leUserKeyPwd->setEnabled(false); - - this->setFixedSize(432,705); - -} - -DlgConnHidWifiSecTls::~DlgConnHidWifiSecTls() -{ - delete ui; -} - -void DlgConnHidWifiSecTls::mousePressEvent(QMouseEvent *event){ - if(event->button() == Qt::LeftButton){ - this->isPress = true; - this->winPos = this->pos(); - this->dragPos = event->globalPos(); - event->accept(); - } -} -void DlgConnHidWifiSecTls::mouseReleaseEvent(QMouseEvent *event){ - this->isPress = false; -} -void DlgConnHidWifiSecTls::mouseMoveEvent(QMouseEvent *event){ - if(this->isPress){ - this->move(this->winPos - (this->dragPos - event->globalPos())); - event->accept(); - } -} - -void DlgConnHidWifiSecTls::changeDialogSecu() -{ - if(ui->cbxSecurity->currentIndex()==0){ -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifi *connHidWifi = new DlgConnHidWifi(0, 0, this->parentWidget()); - connHidWifi->show(); - } else if(ui->cbxSecurity->currentIndex()==1) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiWpa *connHidWifiWpa = new DlgConnHidWifiWpa(0, 0, this->parentWidget()); - connHidWifiWpa->show(); - } else if(ui->cbxSecurity->currentIndex()==2) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiWep *connHidWifiWep = new DlgConnHidWifiWep(0, this->parentWidget()); - connHidWifiWep->show(); - } else if(ui->cbxSecurity->currentIndex()==3) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiWep *connHidWifiWep = new DlgConnHidWifiWep(1, this->parentWidget()); - connHidWifiWep->show(); - } else if(ui->cbxSecurity->currentIndex()==4) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiLeap *connHidWifiLeap = new DlgConnHidWifiLeap(this->parentWidget()); - connHidWifiLeap->show(); - } else if(ui->cbxSecurity->currentIndex()==5) { - if (WepOrWpa == 1) { - ui->cbxSecurity->setCurrentIndex(5); - WepOrWpa = 0; - } - } else { - if (WepOrWpa == 0){ - ui->cbxSecurity->setCurrentIndex(6); - WepOrWpa = 1; - } - } -} - -void DlgConnHidWifiSecTls::changeDialogAuth() -{ - if(ui->cbxAuth->currentIndex()==0){ - qDebug()<<"it's not need to change dialog"; - } else if(ui->cbxAuth->currentIndex()==1) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiSecLeap *connHidWifiSecLeap = new DlgConnHidWifiSecLeap(WepOrWpa); - connHidWifiSecLeap->show(); - } else if(ui->cbxAuth->currentIndex()==2) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiSecPwd *connHidWifiSecPwd = new DlgConnHidWifiSecPwd(WepOrWpa); - connHidWifiSecPwd->show(); - } else if(ui->cbxAuth->currentIndex()==3) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiSecFast *connHidWifiSecFast = new DlgConnHidWifiSecFast(WepOrWpa); - connHidWifiSecFast->show(); - } else if(ui->cbxAuth->currentIndex()==4) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiSecTunnelTLS *connHidWifiSecTuTls = new DlgConnHidWifiSecTunnelTLS(WepOrWpa); - connHidWifiSecTuTls->show(); - } else { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiSecPeap *connHidWifiSecPeap = new DlgConnHidWifiSecPeap(WepOrWpa); - connHidWifiSecPeap->show(); - } -} - -void DlgConnHidWifiSecTls::on_cbxCA_currentIndexChanged(const QString &arg1) -{ - if (ui->cbxCA->currentIndex() == 0){ - ui->leCaPwd->setText(""); - ui->lbCaPwd->setEnabled(false); - ui->leCaPwd->setEnabled(false); - }else{ - ui->leCaPwd->setText(""); - ui->lbCaPwd->setEnabled(true); - ui->leCaPwd->setEnabled(true); - } -} - -void DlgConnHidWifiSecTls::on_cbxUserCertify_currentIndexChanged(const QString &arg1) -{ - if (ui->cbxUserCertify->currentIndex() == 0){ - ui->leUserCertifyPwd->setText(""); - ui->lbUserCertifyPwd->setEnabled(false); - ui->leUserCertifyPwd->setEnabled(false); - - ui->lbUserPriKey->setEnabled(false); - ui->cbxUserPriKey->setEnabled(false); - ui->cbxUserPriKey->setCurrentIndex(0); - - ui->leUserKeyPwd->setText(""); - ui->lbUserKeyPwd->setEnabled(false); - ui->leUserKeyPwd->setEnabled(false); - }else{ - ui->leUserCertifyPwd->setText(""); - ui->lbUserCertifyPwd->setEnabled(true); - ui->leUserCertifyPwd->setEnabled(true); - - ui->lbUserPriKey->setEnabled(true); - ui->cbxUserPriKey->setEnabled(true); - ui->cbxUserPriKey->setCurrentIndex(0); - - ui->leUserKeyPwd->setText(""); - ui->lbUserKeyPwd->setEnabled(false); - ui->leUserKeyPwd->setEnabled(false); - } -} - -void DlgConnHidWifiSecTls::on_cbxUserPriKey_currentIndexChanged(const QString &arg1) -{ - if (ui->cbxUserPriKey->currentIndex() == 0){ - ui->leUserKeyPwd->setText(""); - ui->lbUserKeyPwd->setEnabled(false); - ui->leUserKeyPwd->setEnabled(false); - }else{ - ui->leUserKeyPwd->setText(""); - ui->lbUserKeyPwd->setEnabled(true); - ui->leUserKeyPwd->setEnabled(true); - } -} - -void DlgConnHidWifiSecTls::on_btnCancel_clicked() -{ - this->close(); -} - -void DlgConnHidWifiSecTls::on_btnConnect_clicked() -{ - this->close(); -} - -void DlgConnHidWifiSecTls::on_checkBoxCA_stateChanged(int arg1) -{ - if (arg1 == 0) { - ui->cbxCA->setCurrentIndex(0); - ui->lbCA->setEnabled(true); - ui->cbxCA->setEnabled(true); - } else { - ui->cbxCA->setCurrentIndex(0); - ui->lbCA->setEnabled(false); - ui->cbxCA->setEnabled(false); - } -} - -void DlgConnHidWifiSecTls::on_checkBoxPwd_stateChanged(int arg1) -{ - if (arg1 == 0) { - ui->leCaPwd->setEchoMode(QLineEdit::Password); - } else { - ui->leCaPwd->setEchoMode(QLineEdit::Normal); - } -} - -void DlgConnHidWifiSecTls::on_checkBoxPwdSec_stateChanged(int arg1) -{ - if (arg1 == 0) { - ui->leUserCertifyPwd->setEchoMode(QLineEdit::Password); - ui->leUserKeyPwd->setEchoMode(QLineEdit::Password); - } else { - ui->leUserCertifyPwd->setEchoMode(QLineEdit::Normal); - ui->leUserKeyPwd->setEchoMode(QLineEdit::Normal); - } -} - -void DlgConnHidWifiSecTls::on_leNetName_textEdited(const QString &arg1) -{ - if (ui->leNetName->text() == ""){ - ui->btnConnect->setEnabled(false); - } else if (ui->leIdentity->text() == ""){ - ui->btnConnect->setEnabled(false); - } else if (ui->leDomain->text() == ""){ - ui->btnConnect->setEnabled(false); - } else { - if (ui->cbxCA->currentIndex() == 0){ - if (ui->cbxUserCertify->currentIndex() == 0){ - ui->btnConnect->setEnabled(true); - }else { - if (ui->leUserCertifyPwd->text() == ""){ - ui->btnConnect->setEnabled(false); - } else { - if (ui->cbxUserPriKey->currentIndex() == 0){ - ui->btnConnect->setEnabled(true); - }else if (ui->leUserKeyPwd->text() == ""){ - ui->btnConnect->setEnabled(false); - } else{ - ui->btnConnect->setEnabled(true); - } - } - } - } else { - if (ui->leCaPwd->text() == ""){ - ui->btnConnect->setEnabled(false); - } else { - if (ui->cbxUserCertify->currentIndex() == 0){ - ui->btnConnect->setEnabled(true); - }else { - if (ui->leUserCertifyPwd->text() == ""){ - ui->btnConnect->setEnabled(false); - } else { - if (ui->cbxUserPriKey->currentIndex() == 0){ - ui->btnConnect->setEnabled(true); - }else if (ui->leUserKeyPwd->text() == ""){ - ui->btnConnect->setEnabled(false); - } else{ - ui->btnConnect->setEnabled(true); - } - } - } - } - } - } -} - -void DlgConnHidWifiSecTls::on_leIdentity_textEdited(const QString &arg1) -{ - if (ui->leNetName->text() == ""){ - ui->btnConnect->setEnabled(false); - } else if (ui->leIdentity->text() == ""){ - ui->btnConnect->setEnabled(false); - } else if (ui->leDomain->text() == ""){ - ui->btnConnect->setEnabled(false); - } else { - if (ui->cbxCA->currentIndex() == 0){ - if (ui->cbxUserCertify->currentIndex() == 0){ - ui->btnConnect->setEnabled(true); - }else { - if (ui->leUserCertifyPwd->text() == ""){ - ui->btnConnect->setEnabled(false); - } else { - if (ui->cbxUserPriKey->currentIndex() == 0){ - ui->btnConnect->setEnabled(true); - }else if (ui->leUserKeyPwd->text() == ""){ - ui->btnConnect->setEnabled(false); - } else{ - ui->btnConnect->setEnabled(true); - } - } - } - } else { - if (ui->leCaPwd->text() == ""){ - ui->btnConnect->setEnabled(false); - } else { - if (ui->cbxUserCertify->currentIndex() == 0){ - ui->btnConnect->setEnabled(true); - }else { - if (ui->leUserCertifyPwd->text() == ""){ - ui->btnConnect->setEnabled(false); - } else { - if (ui->cbxUserPriKey->currentIndex() == 0){ - ui->btnConnect->setEnabled(true); - }else if (ui->leUserKeyPwd->text() == ""){ - ui->btnConnect->setEnabled(false); - } else{ - ui->btnConnect->setEnabled(true); - } - } - } - } - } - } -} - -void DlgConnHidWifiSecTls::on_leDomain_textEdited(const QString &arg1) -{ - if (ui->leNetName->text() == ""){ - ui->btnConnect->setEnabled(false); - } else if (ui->leIdentity->text() == ""){ - ui->btnConnect->setEnabled(false); - } else if (ui->leDomain->text() == ""){ - ui->btnConnect->setEnabled(false); - } else { - if (ui->cbxCA->currentIndex() == 0){ - if (ui->cbxUserCertify->currentIndex() == 0){ - ui->btnConnect->setEnabled(true); - }else { - if (ui->leUserCertifyPwd->text() == ""){ - ui->btnConnect->setEnabled(false); - } else { - if (ui->cbxUserPriKey->currentIndex() == 0){ - ui->btnConnect->setEnabled(true); - }else if (ui->leUserKeyPwd->text() == ""){ - ui->btnConnect->setEnabled(false); - } else{ - ui->btnConnect->setEnabled(true); - } - } - } - } else { - if (ui->leCaPwd->text() == ""){ - ui->btnConnect->setEnabled(false); - } else { - if (ui->cbxUserCertify->currentIndex() == 0){ - ui->btnConnect->setEnabled(true); - }else { - if (ui->leUserCertifyPwd->text() == ""){ - ui->btnConnect->setEnabled(false); - } else { - if (ui->cbxUserPriKey->currentIndex() == 0){ - ui->btnConnect->setEnabled(true); - }else if (ui->leUserKeyPwd->text() == ""){ - ui->btnConnect->setEnabled(false); - } else{ - ui->btnConnect->setEnabled(true); - } - } - } - } - } - } -} - -void DlgConnHidWifiSecTls::on_leCaPwd_textEdited(const QString &arg1) -{ - if (ui->leNetName->text() == ""){ - ui->btnConnect->setEnabled(false); - } else if (ui->leIdentity->text() == ""){ - ui->btnConnect->setEnabled(false); - } else if (ui->leDomain->text() == ""){ - ui->btnConnect->setEnabled(false); - } else if(ui->leCaPwd->text() == ""){ - ui->btnConnect->setEnabled(false); - } else { - if (ui->cbxUserCertify->currentIndex() == 0){ - ui->btnConnect->setEnabled(true); - }else { - if (ui->leUserCertifyPwd->text() == ""){ - ui->btnConnect->setEnabled(false); - } else { - if (ui->cbxUserPriKey->currentIndex() == 0){ - ui->btnConnect->setEnabled(true); - }else if (ui->leUserKeyPwd->text() == ""){ - ui->btnConnect->setEnabled(false); - } else{ - ui->btnConnect->setEnabled(true); - } - } - } - } -} - -void DlgConnHidWifiSecTls::on_leUserCertifyPwd_textEdited(const QString &arg1) -{ - if (ui->leNetName->text() == ""){ - ui->btnConnect->setEnabled(false); - } else if (ui->leIdentity->text() == ""){ - ui->btnConnect->setEnabled(false); - } else if (ui->leDomain->text() == ""){ - ui->btnConnect->setEnabled(false); - } else { - if (ui->cbxCA->currentIndex() == 0){ - if (ui->leUserCertifyPwd->text() == ""){ - ui->btnConnect->setEnabled(false); - }else{ - if (ui->cbxUserPriKey->currentIndex() == 0){ - ui->btnConnect->setEnabled(true); - }else if (ui->leUserKeyPwd->text() == ""){ - ui->btnConnect->setEnabled(false); - } else{ - ui->btnConnect->setEnabled(true); - } - } - } else { - if (ui->leCaPwd->text() == ""){ - ui->btnConnect->setEnabled(false); - }else{ - if (ui->leUserCertifyPwd->text() == ""){ - ui->btnConnect->setEnabled(false); - }else{ - if (ui->cbxUserPriKey->currentIndex() == 0){ - ui->btnConnect->setEnabled(true); - }else if (ui->leUserKeyPwd->text() == ""){ - ui->btnConnect->setEnabled(false); - } else{ - ui->btnConnect->setEnabled(true); - } - } - } - } - } -} - -void DlgConnHidWifiSecTls::on_leUserKeyPwd_textEdited(const QString &arg1) -{ - if (ui->leNetName->text() == ""){ - ui->btnConnect->setEnabled(false); - } else if (ui->leIdentity->text() == ""){ - ui->btnConnect->setEnabled(false); - } else if (ui->leDomain->text() == ""){ - ui->btnConnect->setEnabled(false); - } else { - if (ui->cbxCA->currentIndex() == 0){ - if (ui->leUserCertifyPwd->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->leUserKeyPwd->text() == ""){ - ui->btnConnect->setEnabled(false); - } else{ - ui->btnConnect->setEnabled(true); - } - } else { - if (ui->leCaPwd->text() == ""){ - ui->btnConnect->setEnabled(false); - }else{ - if (ui->leUserCertifyPwd->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->leUserKeyPwd->text() == ""){ - ui->btnConnect->setEnabled(false); - } else{ - ui->btnConnect->setEnabled(true); - } - } - } - } -} - -void DlgConnHidWifiSecTls::paintEvent(QPaintEvent *event) -{ - QStyleOption opt; - opt.init(this); - QPainter p(this); - style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); - QWidget::paintEvent(event); -} diff --git a/KylinNM/wireless-security/dlgconnhidwifisectls.h b/KylinNM/wireless-security/dlgconnhidwifisectls.h deleted file mode 100644 index c133807..0000000 --- a/KylinNM/wireless-security/dlgconnhidwifisectls.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see -#include - -namespace Ui { -class DlgConnHidWifiSecTls; -} - -class DlgConnHidWifiSecTls : public QDialog -{ - Q_OBJECT - -public: - explicit DlgConnHidWifiSecTls(int type, QWidget *parent = 0); - ~DlgConnHidWifiSecTls(); - -protected: - void paintEvent(QPaintEvent *event); - -public slots: - void changeDialogSecu(); - void changeDialogAuth(); - -private slots: - void on_btnCancel_clicked(); - - void on_btnConnect_clicked(); - - void on_checkBoxCA_stateChanged(int arg1); - - void on_checkBoxPwd_stateChanged(int arg1); - - void on_checkBoxPwdSec_stateChanged(int arg1); - - void on_leNetName_textEdited(const QString &arg1); - - void on_leIdentity_textEdited(const QString &arg1); - - void on_leDomain_textEdited(const QString &arg1); - - void on_leCaPwd_textEdited(const QString &arg1); - - void on_leUserCertifyPwd_textEdited(const QString &arg1); - - void on_leUserKeyPwd_textEdited(const QString &arg1); - - void on_cbxCA_currentIndexChanged(const QString &arg1); - - void on_cbxUserCertify_currentIndexChanged(const QString &arg1); - - void on_cbxUserPriKey_currentIndexChanged(const QString &arg1); - -private: - Ui::DlgConnHidWifiSecTls *ui; - int WepOrWpa = 0;//0 WEP;1WPA - - void mousePressEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - -// QString labelQss, cbxQss, leQss, btnConnQss, btnCancelQss, lineQss, checkBoxQss, checkBoxCAQss; - - bool isPress; - QPoint winPos; - QPoint dragPos; -}; - -#endif // DLGCONNHIDWIFISECTLS_H diff --git a/KylinNM/wireless-security/dlgconnhidwifisectls.ui b/KylinNM/wireless-security/dlgconnhidwifisectls.ui deleted file mode 100644 index 969ab4f..0000000 --- a/KylinNM/wireless-security/dlgconnhidwifisectls.ui +++ /dev/null @@ -1,617 +0,0 @@ - - - DlgConnHidWifiSecTls - - - - 0 - 0 - 432 - 705 - - - - Connect to Hidden Wi-Fi Network - - - - - 180 - 185 - 200 - 32 - - - - - 10 - - - - - - - - - - 180 - 145 - 200 - 32 - - - - - 10 - - - - - - - 180 - 505 - 200 - 32 - - - - - 10 - - - - QLineEdit::Password - - - - - - 180 - 385 - 200 - 32 - - - - - 10 - - - - QLineEdit::Password - - - - - - 357 - 397 - 18 - 9 - - - - - 10 - - - - - - - - - - 76 - 80 - 90 - 20 - - - - - 10 - - - - - - - - - - 76 - 150 - 90 - 20 - - - - - 10 - - - - - - - - - - 76 - 310 - 90 - 20 - - - - - 10 - - - - - - - - - - 76 - 350 - 90 - 20 - - - - - 10 - - - - - - - - - - 180 - 465 - 200 - 32 - - - - - 10 - - - - - - - - - - 76 - 270 - 90 - 20 - - - - - 10 - - - - - - - - - - 76 - 510 - 90 - 20 - - - - - 10 - - - - - - - - - - 215 - 660 - 90 - 30 - - - - - 10 - - - - - - - - - - 76 - 590 - 90 - 20 - - - - - 10 - - - - - - - - - - 180 - 345 - 200 - 32 - - - - - 10 - - - - - - - - - - 76 - 550 - 90 - 20 - - - - - 10 - - - - - - - - - - 76 - 390 - 90 - 20 - - - - - 10 - - - - - - - - - - 180 - 305 - 200 - 32 - - - - - 10 - - - - - - - 357 - 597 - 18 - 9 - - - - - 10 - - - - - - - - - - 180 - 265 - 200 - 32 - - - - - 10 - - - - - - - 180 - 585 - 200 - 32 - - - - - 10 - - - - QLineEdit::Password - - - - - - 76 - 470 - 90 - 20 - - - - - 10 - - - - - - - - - - 76 - 230 - 90 - 20 - - - - - 10 - - - - - - - - - - 180 - 225 - 200 - 32 - - - - - 10 - - - - - - - - - - 315 - 660 - 90 - 30 - - - - - 10 - - - - - - - - - - 180 - 425 - 200 - 25 - - - - - 10 - - - - - - - - - - 180 - 75 - 200 - 32 - - - - - 10 - - - - - - - - - - 180 - 545 - 200 - 32 - - - - - 10 - - - - - - - - - - 76 - 190 - 90 - 20 - - - - - 10 - - - - - - - - - - 0 - 0 - 432 - 705 - - - - - - - - - - 30 - 30 - 140 - 22 - - - - - - - - - - 10 - 125 - 412 - 1 - - - - Qt::Horizontal - - - - - - 10 - 640 - 412 - 1 - - - - Qt::Horizontal - - - lbBoder - cbxSecurity - leNetName - leUserCertifyPwd - leCaPwd - checkBoxPwd - lbConn - lbNetName - lbDomain - lbCA - cbxUserCertify - lbIdentity - lbUserCertifyPwd - btnCancel - lbUserKeyPwd - cbxCA - lbUserPriKey - lbCaPwd - leDomain - leIdentity - leUserKeyPwd - lbUserCertify - lbAuth - cbxAuth - btnConnect - checkBoxCA - cbxConn - cbxUserPriKey - lbSecurity - lbLeftupTitle - checkBoxPwdSec - lineUp - lineDown - - - - diff --git a/KylinNM/wireless-security/dlgconnhidwifisectunneltls.cpp b/KylinNM/wireless-security/dlgconnhidwifisectunneltls.cpp deleted file mode 100644 index fb02a60..0000000 --- a/KylinNM/wireless-security/dlgconnhidwifisectunneltls.cpp +++ /dev/null @@ -1,457 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see - -DlgConnHidWifiSecTunnelTLS::DlgConnHidWifiSecTunnelTLS(int type, QWidget *parent) : - WepOrWpa(type), - QDialog(parent), - ui(new Ui::DlgConnHidWifiSecTunnelTLS) -{ - ui->setupUi(this); - - this->setWindowFlags(Qt::FramelessWindowHint); - this->setAttribute(Qt::WA_TranslucentBackground); - //需要添加 void paintEvent(QPaintEvent *event) 函数 - - QPainterPath path; - auto rect = this->rect(); - rect.adjust(1, 1, -1, -1); - path.addRoundedRect(rect, 6, 6); - setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon())); - - this->setStyleSheet("QWidget{border-radius:6px;background-color:rgba(19,19,20,0.7);border:1px solid rgba(255, 255, 255, 0.05);}"); - - MyQss objQss; - - ui->lbBoder->setStyleSheet("QLabel{border-radius:6px;background-color:rgba(19,19,20,0.95);border:1px solid rgba(255, 255, 255, 0.05);}"); - ui->lbBoder->hide(); - ui->lbLeftupTitle->setStyleSheet("QLabel{border:0px;font-size:20px;color:rgba(255,255,255,0.97);background-color:transparent;}"); - ui->lbConn->setStyleSheet(objQss.labelQss); - ui->lbNetName->setStyleSheet(objQss.labelQss); - ui->lbSecurity->setStyleSheet(objQss.labelQss); - ui->lbAuth->setStyleSheet(objQss.labelQss); - ui->lbAnonyId->setStyleSheet(objQss.labelQss); - ui->lbDomain->setStyleSheet(objQss.labelQss); - ui->lbCA->setStyleSheet(objQss.labelQss); - ui->lbCaPwd->setStyleSheet(objQss.labelQss); - ui->lbInnerAuth->setStyleSheet(objQss.labelQss); - ui->lbUserName->setStyleSheet(objQss.labelQss); - ui->lbPassword->setStyleSheet(objQss.labelQss); - - ui->cbxConn->setStyleSheet(objQss.cbxQss); - ui->cbxConn->setView(new QListView()); - ui->leNetName->setStyleSheet(objQss.leQss); - ui->cbxSecurity->setStyleSheet(objQss.cbxQss); - ui->cbxSecurity->setView(new QListView()); - ui->cbxAuth->setStyleSheet(objQss.cbxQss); - ui->cbxAuth->setView(new QListView()); - ui->leAnonyId->setStyleSheet(objQss.leQss); - ui->leDomain->setStyleSheet(objQss.leQss); - ui->cbxCA->setStyleSheet(objQss.cbxQss); - ui->cbxCA->setView(new QListView()); - ui->leCaPwd->setStyleSheet(objQss.leQss); - ui->checkBoxPwd->setStyleSheet(objQss.checkBoxQss); - ui->checkBoxCA->setStyleSheet(objQss.checkBoxCAQss); - ui->cbxInnerAuth->setStyleSheet(objQss.cbxQss); - ui->cbxInnerAuth->setView(new QListView()); - ui->leUserName->setStyleSheet(objQss.leQss); - ui->lePassword->setStyleSheet(objQss.leQss); - ui->checkBoxPwdSec->setStyleSheet(objQss.checkBoxQss); - - ui->btnCancel->setStyleSheet(objQss.btnCancelQss); - ui->btnConnect->setStyleSheet(objQss.btnConnQss); - ui->lineUp->setStyleSheet(objQss.lineQss); - ui->lineDown->setStyleSheet(objQss.lineQss); - ui->checkBoxCA->setFocusPolicy(Qt::NoFocus); - - - ui->lbLeftupTitle->setText(tr("Add hidden Wi-Fi")); //加入隐藏Wi-Fi - ui->lbConn->setText(tr("Connection")); //连接设置: - ui->lbNetName->setText(tr("Network name")); //网络名称: - ui->lbSecurity->setText(tr("Wi-Fi security")); //Wi-Fi安全性: - ui->lbAuth->setText(tr("Authentication")); //认证: - ui->lbAnonyId->setText(tr("Anonymous identity")); //匿名身份: - ui->lbDomain->setText(tr("Domain")); //域名: - ui->lbCA->setText(tr("CA certificate")); //CA 证书: - ui->lbCaPwd->setText(tr("CA certificate password")); //CA 证书密码: - ui->checkBoxCA->setText(tr("No CA certificate is required")); //不需要CA证书 - ui->lbInnerAuth->setText(tr("Inner authentication")); //内部认证: - ui->lbUserName->setText(tr("Username")); //用户名: - ui->lbPassword->setText(tr("Password")); //密码: - ui->btnCancel->setText(tr("Cancel")); //取消 - ui->btnConnect->setText(tr("Connect")); //连接 - - ui->cbxConn->addItem(tr("C_reate…")); //新建... - int status = system("nmcli connection show>/tmp/kylin-nm-connshow"); - if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection show' in function 'DlgConnHidWifiSecTunnelTLS' failed");} - QFile file("/tmp/kylin-nm-connshow"); - if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){ - qDebug()<<"Can't open the file!"; - } - QString txt = file.readAll(); - QStringList txtLine = txt.split("\n"); - file.close(); - foreach (QString line, txtLine) { - if(line.indexOf("wifi") != -1){ - QStringList subLine = line.split(" "); - ui->cbxConn->addItem(subLine[0]); - } - } - ui->cbxConn->setCurrentIndex(0); - - ui->cbxSecurity->addItem(tr("None")); //无 - ui->cbxSecurity->addItem(tr("WPA & WPA2 Personal")); //WPA 及 WPA2 个人 - ui->cbxSecurity->addItem(tr("WEP 40/128-bit Key (Hex or ASCII)")); //WEP 40/128 位密钥(十六进制或ASCII) - ui->cbxSecurity->addItem(tr("WEP 128-bit Passphrase")); //WEP 128 位密码句 - ui->cbxSecurity->addItem("LEAP"); - ui->cbxSecurity->addItem(tr("Dynamic WEP (802.1X)")); //动态 WEP (802.1x) - ui->cbxSecurity->addItem(tr("WPA & WPA2 Enterprise")); //WPA 及 WPA2 企业 - if (WepOrWpa == 0) { - ui->cbxSecurity->setCurrentIndex(5); - } else if (WepOrWpa == 1) { - ui->cbxSecurity->setCurrentIndex(6); - } - connect(ui->cbxSecurity,SIGNAL(currentIndexChanged(QString)),this,SLOT(changeDialogSecu())); - - ui->cbxAuth->addItem("TLS"); - ui->cbxAuth->addItem("LEAP"); - ui->cbxAuth->addItem("PWD"); - ui->cbxAuth->addItem("FAST"); - ui->cbxAuth->addItem(tr("Tunneled TLS"));//隧道 TLS - ui->cbxAuth->addItem(tr("Protected EAP (PEAP)")); //受保护的 EAP - ui->cbxAuth->setCurrentIndex(4); - connect(ui->cbxAuth,SIGNAL(currentIndexChanged(QString)),this,SLOT(changeDialogAuth())); - - ui->cbxCA->addItem(tr("None")); //无 - ui->cbxCA->addItem(tr("Choose from file")); //从文件选择... - ui->cbxCA->setCurrentIndex(0); - - ui->cbxInnerAuth->addItem("PAP"); - ui->cbxInnerAuth->addItem("MSCHAP"); - ui->cbxInnerAuth->addItem("MSCHAPv2"); - ui->cbxInnerAuth->addItem("MSCHAPv2(no EAP)"); - ui->cbxInnerAuth->addItem("CHAP"); - ui->cbxInnerAuth->addItem("MDS"); - ui->cbxInnerAuth->addItem("GTC"); - ui->cbxInnerAuth->setCurrentIndex(0); - - ui->btnConnect->setEnabled(false); - - this->setFixedSize(432,665); - -} - -DlgConnHidWifiSecTunnelTLS::~DlgConnHidWifiSecTunnelTLS() -{ - delete ui; -} - -void DlgConnHidWifiSecTunnelTLS::mousePressEvent(QMouseEvent *event){ - if(event->button() == Qt::LeftButton){ - this->isPress = true; - this->winPos = this->pos(); - this->dragPos = event->globalPos(); - event->accept(); - } -} -void DlgConnHidWifiSecTunnelTLS::mouseReleaseEvent(QMouseEvent *event){ - this->isPress = false; -} -void DlgConnHidWifiSecTunnelTLS::mouseMoveEvent(QMouseEvent *event){ - if(this->isPress){ - this->move(this->winPos - (this->dragPos - event->globalPos())); - event->accept(); - } -} - -void DlgConnHidWifiSecTunnelTLS::changeDialogSecu() -{ - if(ui->cbxSecurity->currentIndex()==0){ -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifi *connHidWifi = new DlgConnHidWifi(0, 0, this->parentWidget()); - connHidWifi->show(); - } else if(ui->cbxSecurity->currentIndex()==1) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiWpa *connHidWifiWpa = new DlgConnHidWifiWpa(0, 0, this->parentWidget()); - connHidWifiWpa->show(); - } else if(ui->cbxSecurity->currentIndex()==2) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiWep *connHidWifiWep = new DlgConnHidWifiWep(0, this->parentWidget()); - connHidWifiWep->show(); - } else if(ui->cbxSecurity->currentIndex()==3) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiWep *connHidWifiWep = new DlgConnHidWifiWep(1, this->parentWidget()); - connHidWifiWep->show(); - } else if(ui->cbxSecurity->currentIndex()==4) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiLeap *connHidWifiLeap = new DlgConnHidWifiLeap(this->parentWidget()); - connHidWifiLeap->show(); - } else if(ui->cbxSecurity->currentIndex()==5) { - if (WepOrWpa == 1) { - ui->cbxSecurity->setCurrentIndex(5); - WepOrWpa = 0; - } - } else { - if (WepOrWpa == 0){ - ui->cbxSecurity->setCurrentIndex(6); - WepOrWpa = 1; - } - } -} - -void DlgConnHidWifiSecTunnelTLS::changeDialogAuth() -{ - if(ui->cbxAuth->currentIndex()==0){ -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiSecTls *connHidWifiSecTls = new DlgConnHidWifiSecTls(WepOrWpa, this->parentWidget()); - connHidWifiSecTls->show(); - } else if(ui->cbxAuth->currentIndex()==1) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiSecLeap *connHidWifiSecLeap = new DlgConnHidWifiSecLeap(WepOrWpa, this->parentWidget()); - connHidWifiSecLeap->show(); - } else if(ui->cbxAuth->currentIndex()==2) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiSecPwd *connHidWifiSecPwd = new DlgConnHidWifiSecPwd(WepOrWpa, this->parentWidget()); - connHidWifiSecPwd->show(); - } else if(ui->cbxAuth->currentIndex()==3) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiSecFast *connHidWifiSecFast = new DlgConnHidWifiSecFast(WepOrWpa, this->parentWidget()); - connHidWifiSecFast->show(); - } else if(ui->cbxAuth->currentIndex()==4) { - qDebug()<<"it's not need to change dialog"; - } else { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiSecPeap *connHidWifiSecPeap = new DlgConnHidWifiSecPeap(WepOrWpa, this->parentWidget()); - connHidWifiSecPeap->show(); - } -} - -void DlgConnHidWifiSecTunnelTLS::on_cbxCA_currentIndexChanged(const QString &arg1) -{ - if (ui->cbxCA->currentIndex() == 0){ - ui->leCaPwd->setText(""); - ui->lbCaPwd->setEnabled(false); - ui->leCaPwd->setEnabled(false); - } else { - ui->leCaPwd->setText(""); - ui->lbCaPwd->setEnabled(true); - ui->leCaPwd->setEnabled(true); - } -} - -void DlgConnHidWifiSecTunnelTLS::on_btnCancel_clicked() -{ - this->close(); -} - -void DlgConnHidWifiSecTunnelTLS::on_btnConnect_clicked() -{ - this->close(); -} - -void DlgConnHidWifiSecTunnelTLS::on_checkBoxPwd_stateChanged(int arg1) -{ - if (arg1 == 0) { - ui->leCaPwd->setEchoMode(QLineEdit::Password); - } else { - ui->leCaPwd->setEchoMode(QLineEdit::Normal); - } -} - -void DlgConnHidWifiSecTunnelTLS::on_checkBoxCA_stateChanged(int arg1) -{ - if (arg1 == 0) { - ui->cbxCA->setCurrentIndex(0); - ui->leCaPwd->setText(""); - ui->lbCA->setEnabled(true); - ui->cbxCA->setEnabled(true); - } else { - ui->cbxCA->setCurrentIndex(0); - ui->leCaPwd->setText(""); - ui->lbCA->setEnabled(false); - ui->cbxCA->setEnabled(false); - } -} - -void DlgConnHidWifiSecTunnelTLS::on_checkBoxPwdSec_stateChanged(int arg1) -{ - if (arg1 == 0) { - ui->lePassword->setEchoMode(QLineEdit::Password); - } else { - ui->lePassword->setEchoMode(QLineEdit::Normal); - } -} - -void DlgConnHidWifiSecTunnelTLS::on_leNetName_textEdited(const QString &arg1) -{ - if (ui->leNetName->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->leAnonyId->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->leDomain->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->leUserName->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->lePassword->text() == ""){ - ui->btnConnect->setEnabled(false); - }else{ - if (ui->cbxCA->currentIndex() == 0){ - ui->btnConnect->setEnabled(true); - }else if(ui->leCaPwd->text() == ""){ - ui->btnConnect->setEnabled(false); - }else{ - ui->btnConnect->setEnabled(true); - } - } -} - -void DlgConnHidWifiSecTunnelTLS::on_leAnonyId_textEdited(const QString &arg1) -{ - if (ui->leNetName->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->leAnonyId->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->leDomain->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->leUserName->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->lePassword->text() == ""){ - ui->btnConnect->setEnabled(false); - }else{ - if (ui->cbxCA->currentIndex() == 0){ - ui->btnConnect->setEnabled(true); - }else if(ui->leCaPwd->text() == ""){ - ui->btnConnect->setEnabled(false); - }else{ - ui->btnConnect->setEnabled(true); - } - } -} - -void DlgConnHidWifiSecTunnelTLS::on_leDomain_textEdited(const QString &arg1) -{ - if (ui->leNetName->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->leAnonyId->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->leDomain->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->leUserName->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->lePassword->text() == ""){ - ui->btnConnect->setEnabled(false); - }else{ - if (ui->cbxCA->currentIndex() == 0){ - ui->btnConnect->setEnabled(true); - }else if(ui->leCaPwd->text() == ""){ - ui->btnConnect->setEnabled(false); - }else{ - ui->btnConnect->setEnabled(true); - } - } -} - -void DlgConnHidWifiSecTunnelTLS::on_leCaPwd_textEdited(const QString &arg1) -{ - if (ui->leNetName->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->leAnonyId->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->leDomain->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->leUserName->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->lePassword->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->leCaPwd->text() == ""){ - ui->btnConnect->setEnabled(false); - }else{ - ui->btnConnect->setEnabled(true); - } -} - -void DlgConnHidWifiSecTunnelTLS::on_leUserName_textEdited(const QString &arg1) -{ - if (ui->leNetName->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->leAnonyId->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->leDomain->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->leUserName->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->lePassword->text() == ""){ - ui->btnConnect->setEnabled(false); - }else{ - if (ui->cbxCA->currentIndex() == 0){ - ui->btnConnect->setEnabled(true); - }else if(ui->leCaPwd->text() == ""){ - ui->btnConnect->setEnabled(false); - }else{ - ui->btnConnect->setEnabled(true); - } - } -} - -void DlgConnHidWifiSecTunnelTLS::on_lePwd_textEdited(const QString &arg1) -{ - if (ui->leNetName->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->leAnonyId->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->leDomain->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->leUserName->text() == ""){ - ui->btnConnect->setEnabled(false); - }else if (ui->lePassword->text() == ""){ - ui->btnConnect->setEnabled(false); - }else{ - if (ui->cbxCA->currentIndex() == 0){ - ui->btnConnect->setEnabled(true); - }else if(ui->leCaPwd->text() == ""){ - ui->btnConnect->setEnabled(false); - }else{ - ui->btnConnect->setEnabled(true); - } - } -} - -void DlgConnHidWifiSecTunnelTLS::paintEvent(QPaintEvent *event) -{ - QStyleOption opt; - opt.init(this); - QPainter p(this); - style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); - QWidget::paintEvent(event); -} diff --git a/KylinNM/wireless-security/dlgconnhidwifisectunneltls.h b/KylinNM/wireless-security/dlgconnhidwifisectunneltls.h deleted file mode 100644 index bbd881a..0000000 --- a/KylinNM/wireless-security/dlgconnhidwifisectunneltls.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see -#include - -namespace Ui { -class DlgConnHidWifiSecTunnelTLS; -} - -class DlgConnHidWifiSecTunnelTLS : public QDialog -{ - Q_OBJECT - -public: - explicit DlgConnHidWifiSecTunnelTLS(int type, QWidget *parent = 0); - ~DlgConnHidWifiSecTunnelTLS(); - -protected: - void paintEvent(QPaintEvent *event); - -public slots: - void changeDialogSecu(); - void changeDialogAuth(); - -private slots: - void on_btnCancel_clicked(); - - void on_btnConnect_clicked(); - - void on_cbxCA_currentIndexChanged(const QString &arg1); - - void on_checkBoxPwd_stateChanged(int arg1); - - void on_checkBoxCA_stateChanged(int arg1); - - void on_checkBoxPwdSec_stateChanged(int arg1); - - void on_leNetName_textEdited(const QString &arg1); - - void on_leAnonyId_textEdited(const QString &arg1); - - void on_leDomain_textEdited(const QString &arg1); - - void on_leCaPwd_textEdited(const QString &arg1); - - void on_leUserName_textEdited(const QString &arg1); - - void on_lePwd_textEdited(const QString &arg1); - -private: - Ui::DlgConnHidWifiSecTunnelTLS *ui; - int WepOrWpa = 0;//0 WEP;1WPA - - void mousePressEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - -// QString labelQss, cbxQss, leQss, btnConnQss, btnCancelQss, lineQss, checkBoxQss, checkBoxCAQss; - - bool isPress; - QPoint winPos; - QPoint dragPos; -}; - -#endif // DLGCONNHIDWIFISECTUNNELTLS_H diff --git a/KylinNM/wireless-security/dlgconnhidwifisectunneltls.ui b/KylinNM/wireless-security/dlgconnhidwifisectunneltls.ui deleted file mode 100644 index c625c2f..0000000 --- a/KylinNM/wireless-security/dlgconnhidwifisectunneltls.ui +++ /dev/null @@ -1,579 +0,0 @@ - - - DlgConnHidWifiSecTunnelTLS - - - - 0 - 0 - 432 - 665 - - - - Connect to Hidden Wi-Fi Network - - - - - 180 - 75 - 200 - 32 - - - - - 10 - - - - - - - - - - 180 - 385 - 200 - 32 - - - - - 10 - - - - QLineEdit::Password - - - - - - 180 - 145 - 200 - 32 - - - - - 10 - - - - - - - 315 - 620 - 90 - 30 - - - - - 10 - - - - - - - - - - 180 - 545 - 200 - 32 - - - - - 10 - - - - QLineEdit::Password - - - - - - 215 - 620 - 90 - 30 - - - - - 10 - - - - - - - - - - 76 - 310 - 90 - 20 - - - - - 10 - - - - - - - - - - 357 - 557 - 18 - 9 - - - - - 10 - - - - - - - - - - 76 - 510 - 90 - 20 - - - - - 10 - - - - - - - - - - 76 - 190 - 90 - 20 - - - - - 10 - - - - - - - - - - 180 - 185 - 200 - 32 - - - - - 10 - - - - - - - - - - 180 - 345 - 200 - 32 - - - - - 10 - - - - - - - - - - 180 - 465 - 200 - 32 - - - - - 10 - - - - - - - - - - 180 - 505 - 200 - 32 - - - - - 10 - - - - QLineEdit::Normal - - - - - - 76 - 350 - 90 - 20 - - - - - 10 - - - - - - - - - - 180 - 225 - 200 - 32 - - - - - 10 - - - - - - - - - - 76 - 270 - 90 - 20 - - - - - 10 - - - - - - - - - - 76 - 150 - 90 - 20 - - - - - 10 - - - - - - - - - - 180 - 425 - 200 - 25 - - - - - 10 - - - - - - - - - - 76 - 470 - 90 - 20 - - - - - 10 - - - - - - - - - - 180 - 305 - 200 - 32 - - - - - 10 - - - - - - - 76 - 230 - 90 - 20 - - - - - 10 - - - - - - - - - - 76 - 80 - 90 - 20 - - - - - 10 - - - - - - - - - - 76 - 390 - 90 - 20 - - - - - 10 - - - - - - - - - - 76 - 550 - 90 - 20 - - - - - 10 - - - - - - - - - - 357 - 397 - 18 - 9 - - - - - 10 - - - - - - - - - - 180 - 265 - 200 - 32 - - - - - 10 - - - - - - - 0 - 0 - 432 - 665 - - - - - - - - - - 30 - 30 - 140 - 22 - - - - - - - - - - 10 - 125 - 412 - 1 - - - - Qt::Horizontal - - - - - - 10 - 600 - 412 - 1 - - - - Qt::Horizontal - - - lbBoder - cbxConn - leCaPwd - leNetName - btnConnect - lePassword - btnCancel - lbDomain - checkBoxPwdSec - lbUserName - lbSecurity - cbxSecurity - cbxCA - cbxInnerAuth - leUserName - lbCA - cbxAuth - lbAnonyId - lbNetName - checkBoxCA - lbInnerAuth - leDomain - lbAuth - lbConn - lbCaPwd - lbPassword - checkBoxPwd - leAnonyId - lbLeftupTitle - lineUp - lineDown - - - - diff --git a/KylinNM/wireless-security/dlgconnhidwifiwep.cpp b/KylinNM/wireless-security/dlgconnhidwifiwep.cpp deleted file mode 100644 index 72fa078..0000000 --- a/KylinNM/wireless-security/dlgconnhidwifiwep.cpp +++ /dev/null @@ -1,239 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see - -DlgConnHidWifiWep::DlgConnHidWifiWep(int type, QWidget *parent) : - WepPwdOrCode(type), - QDialog(parent), - ui(new Ui::DlgConnHidWifiWep) -{ - ui->setupUi(this); - - this->setWindowFlags(Qt::FramelessWindowHint); - this->setAttribute(Qt::WA_TranslucentBackground); - //需要添加 void paintEvent(QPaintEvent *event) 函数 - - QPainterPath path; - auto rect = this->rect(); - rect.adjust(1, 1, -1, -1); - path.addRoundedRect(rect, 6, 6); - setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon())); - - this->setStyleSheet("QWidget{border-radius:6px;background-color:rgba(19,19,20,0.7);border:1px solid rgba(255, 255, 255, 0.05);}"); - - MyQss objQss; - - ui->lbBoder->setStyleSheet("QLabel{border-radius:6px;background-color:rgba(19,19,20,0.95);border:1px solid rgba(255, 255, 255, 0.05);}"); - ui->lbBoder->hide(); - ui->lbLeftupTitle->setStyleSheet("QLabel{border:0px;font-size:20px;color:rgba(255,255,255,0.97);background-color:transparent;}"); - ui->lbConn->setStyleSheet(objQss.labelQss); - ui->lbNetName->setStyleSheet(objQss.labelQss); - ui->lbSecurity->setStyleSheet(objQss.labelQss); - ui->lbKey->setStyleSheet(objQss.labelQss); - ui->lbWEPindex->setStyleSheet(objQss.labelQss); - ui->lbAuth->setStyleSheet(objQss.labelQss); - - ui->cbxConn->setStyleSheet(objQss.cbxQss); - ui->cbxConn->setView(new QListView()); - ui->leNetName->setStyleSheet(objQss.leQss); - ui->leKey->setStyleSheet(objQss.leQss); - ui->checkBoxPwd->setStyleSheet(objQss.checkBoxQss); - ui->cbxSecurity->setStyleSheet(objQss.cbxQss); - ui->cbxSecurity->setView(new QListView()); - ui->cbxWEPindex->setStyleSheet(objQss.cbxQss); - ui->cbxWEPindex->setView(new QListView()); - ui->cbxAuth->setStyleSheet(objQss.cbxQss); - ui->cbxAuth->setView(new QListView()); - - ui->btnCancel->setStyleSheet(objQss.btnCancelQss); - ui->btnConnect->setStyleSheet(objQss.btnConnQss); - ui->lineUp->setStyleSheet(objQss.lineQss); - ui->lineDown->setStyleSheet(objQss.lineQss); - - ui->lbLeftupTitle->setText(tr("Add hidden Wi-Fi")); //加入隐藏Wi-Fi - ui->lbConn->setText(tr("Connection")); //连接设置: - ui->lbNetName->setText(tr("Network name")); //网络名称: - ui->lbSecurity->setText(tr("Wi-Fi security")); //Wi-Fi 安全性: - ui->lbKey->setText(tr("Key")); //密钥: - ui->lbWEPindex->setText(tr("WEP index")); //WEP 检索: - ui->lbAuth->setText(tr("Authentication")); //认证: - ui->btnCancel->setText(tr("Cancel")); //取消 - ui->btnConnect->setText(tr("Connect")); //连接 - - ui->cbxConn->addItem(tr("C_reate…")); //新建... - int status = system("nmcli connection show>/tmp/kylin-nm-connshow"); - if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection show' in function 'DlgConnHidWifiWep' failed");} - QFile file("/tmp/kylin-nm-connshow"); - if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){ - qDebug()<<"Can't open the file!"; - } - QString txt = file.readAll(); - QStringList txtLine = txt.split("\n"); - file.close(); - foreach (QString line, txtLine) { - if(line.indexOf("wifi") != -1){ - QStringList subLine = line.split(" "); - ui->cbxConn->addItem(subLine[0]); - } - } - ui->cbxConn->setCurrentIndex(0); - - ui->cbxSecurity->addItem(tr("None")); //无 - ui->cbxSecurity->addItem(tr("WPA & WPA2 Personal")); //WPA 及 WPA2 个人 - ui->cbxSecurity->addItem(tr("WEP 40/128-bit Key (Hex or ASCII)")); //WEP 40/128 位密钥(十六进制或ASCII) - ui->cbxSecurity->addItem(tr("WEP 128-bit Passphrase")); //WEP 128 位密码句 - ui->cbxSecurity->addItem("LEAP"); - ui->cbxSecurity->addItem(tr("Dynamic WEP (802.1X)")); //动态 WEP (802.1x) - ui->cbxSecurity->addItem(tr("WPA & WPA2 Enterprise")); //WPA 及 WPA2 企业 - if (WepPwdOrCode == 0) { - ui->cbxSecurity->setCurrentIndex(2); - } else if (WepPwdOrCode == 1) { - ui->cbxSecurity->setCurrentIndex(3); - } - connect(ui->cbxSecurity,SIGNAL(currentIndexChanged(QString)),this,SLOT(changeDialog())); - - ui->cbxWEPindex->addItem(tr("1(default)")); //1(默认) - ui->cbxWEPindex->addItem("2"); - ui->cbxWEPindex->addItem("3"); - ui->cbxWEPindex->addItem("4"); - ui->cbxWEPindex->setCurrentIndex(0); - - ui->cbxAuth->addItem(tr("Open System")); //开放式系统 - ui->cbxAuth->addItem(tr("Shared Key")); //共享密钥 - ui->cbxAuth->setCurrentIndex(0); - - ui->btnConnect->setEnabled(false); - - this->setFixedSize(432,493); - -} - -DlgConnHidWifiWep::~DlgConnHidWifiWep() -{ - delete ui; -} - -void DlgConnHidWifiWep::mousePressEvent(QMouseEvent *event){ - if(event->button() == Qt::LeftButton){ - this->isPress = true; - this->winPos = this->pos(); - this->dragPos = event->globalPos(); - event->accept(); - } -} -void DlgConnHidWifiWep::mouseReleaseEvent(QMouseEvent *event){ - this->isPress = false; -} -void DlgConnHidWifiWep::mouseMoveEvent(QMouseEvent *event){ - if(this->isPress){ - this->move(this->winPos - (this->dragPos - event->globalPos())); - event->accept(); - } -} - -//切换到其他Wi-Fi安全类型 -void DlgConnHidWifiWep::changeDialog() -{ - if(ui->cbxSecurity->currentIndex()==0){ -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifi *connHidWifi = new DlgConnHidWifi(0, 0, this->parentWidget()); - connHidWifi->show(); - } else if(ui->cbxSecurity->currentIndex()==1) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiWpa *connHidWifiWpa = new DlgConnHidWifiWpa(0, 0, this->parentWidget()); - connHidWifiWpa->show(); - } else if(ui->cbxSecurity->currentIndex()==2) { - if (WepPwdOrCode == 1) { - ui->cbxSecurity->setCurrentIndex(2); - WepPwdOrCode = 0; - } - } else if(ui->cbxSecurity->currentIndex()==3) { - if (WepPwdOrCode == 0) { - ui->cbxSecurity->setCurrentIndex(3); - WepPwdOrCode = 1; - } - } else if(ui->cbxSecurity->currentIndex()==4) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiLeap *connHidWifiLeap = new DlgConnHidWifiLeap(this->parentWidget()); - connHidWifiLeap->show(); - } else if(ui->cbxSecurity->currentIndex()==5) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiSecTls *connHidWifiSecTls = new DlgConnHidWifiSecTls(0, this->parentWidget()); - connHidWifiSecTls->show(); - } else { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiSecTls *connHidWifiSecTls = new DlgConnHidWifiSecTls(1, this->parentWidget()); - connHidWifiSecTls->show(); - } -} - -void DlgConnHidWifiWep::on_btnCancel_clicked() -{ - this->close(); -} - -void DlgConnHidWifiWep::on_btnConnect_clicked() -{ - this->close(); -} - -void DlgConnHidWifiWep::on_checkBoxPwd_stateChanged(int arg1) -{ - if (arg1 == 0) { - ui->leKey->setEchoMode(QLineEdit::Password); - } else { - ui->leKey->setEchoMode(QLineEdit::Normal); - } -} - -void DlgConnHidWifiWep::on_leKey_textEdited(const QString &arg1) -{ - if (ui->leNetName->text() == "" || ui->leKey->text() == ""){ - ui->btnConnect->setEnabled(false); - } else { - ui->btnConnect->setEnabled(true); - } -} - -void DlgConnHidWifiWep::on_leNetName_textEdited(const QString &arg1) -{ - if (ui->leNetName->text() == "" || ui->leKey->text() == ""){ - ui->btnConnect->setEnabled(false); - } else { - ui->btnConnect->setEnabled(true); - } -} - -void DlgConnHidWifiWep::paintEvent(QPaintEvent *event) -{ - QStyleOption opt; - opt.init(this); - QPainter p(this); - style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); - QWidget::paintEvent(event); -} diff --git a/KylinNM/wireless-security/dlgconnhidwifiwep.h b/KylinNM/wireless-security/dlgconnhidwifiwep.h deleted file mode 100644 index bd071ac..0000000 --- a/KylinNM/wireless-security/dlgconnhidwifiwep.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see -#include - -namespace Ui { -class DlgConnHidWifiWep; -} - -class DlgConnHidWifiWep : public QDialog -{ - Q_OBJECT - -public: - explicit DlgConnHidWifiWep(int type, QWidget *parent = 0); - ~DlgConnHidWifiWep(); - -protected: - void paintEvent(QPaintEvent *event); - -public slots: - void changeDialog(); - -private slots: - void on_btnCancel_clicked(); - - void on_btnConnect_clicked(); - - void on_checkBoxPwd_stateChanged(int arg1); - - void on_leKey_textEdited(const QString &arg1); - - void on_leNetName_textEdited(const QString &arg1); - -private: - Ui::DlgConnHidWifiWep *ui; - int WepPwdOrCode = 0; //0 WEP password;1 WEP Code Sentence - - void mousePressEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - -// QString labelQss, cbxQss, leQss, btnConnQss, btnCancelQss, lineQss, checkBoxQss; - - bool isPress; - QPoint winPos; - QPoint dragPos; -}; - -#endif // DLGCONNHIDWIFIWEP_H diff --git a/KylinNM/wireless-security/dlgconnhidwifiwep.ui b/KylinNM/wireless-security/dlgconnhidwifiwep.ui deleted file mode 100644 index baac5c8..0000000 --- a/KylinNM/wireless-security/dlgconnhidwifiwep.ui +++ /dev/null @@ -1,360 +0,0 @@ - - - DlgConnHidWifiWep - - - - 0 - 0 - 432 - 493 - - - - Connect to Hidden Wi-Fi Network - - - - - 76 - 266 - 90 - 20 - - - - - 10 - - - - - - - - - - 76 - 311 - 90 - 20 - - - - - 10 - - - - - - - - - - 76 - 356 - 90 - 20 - - - - - 10 - - - - - - - - - - 175 - 215 - 182 - 32 - - - - - 10 - - - - - - - - - - 315 - 440 - 90 - 30 - - - - - 10 - - - - - - - - - - 175 - 350 - 182 - 32 - - - - - 10 - - - - - - - - - - 76 - 80 - 90 - 20 - - - - - 10 - - - - Qt::LeftToRight - - - - - - - - - 175 - 305 - 182 - 32 - - - - - 10 - - - - - - - - - - 215 - 440 - 90 - 30 - - - - - 10 - - - - - - - - - - 332 - 272 - 18 - 9 - - - - - 10 - - - - - - - - - - 76 - 176 - 90 - 20 - - - - - 10 - - - - - - - - - - 175 - 260 - 182 - 32 - - - - - 10 - - - - QLineEdit::Password - - - - - - 175 - 170 - 182 - 32 - - - - - 10 - - - - - - - 76 - 221 - 90 - 20 - - - - - 10 - - - - - - - - - - 175 - 75 - 182 - 32 - - - - - 10 - - - - - - - - - - 0 - 0 - 432 - 493 - - - - - - - - - - 30 - 30 - 140 - 22 - - - - - - - - - - 10 - 140 - 412 - 1 - - - - Qt::Horizontal - - - - - - 10 - 410 - 412 - 1 - - - - Qt::Horizontal - - - lbBoder - leKey - lbKey - lbWEPindex - lbAuth - cbxSecurity - btnConnect - cbxAuth - lbConn - cbxWEPindex - btnCancel - checkBoxPwd - lbNetName - leNetName - lbSecurity - cbxConn - lbLeftupTitle - lineUp - lineDown - - - - diff --git a/KylinNM/wireless-security/dlgconnhidwifiwpa.cpp b/KylinNM/wireless-security/dlgconnhidwifiwpa.cpp deleted file mode 100644 index c1a9fdc..0000000 --- a/KylinNM/wireless-security/dlgconnhidwifiwpa.cpp +++ /dev/null @@ -1,411 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see -#include - -#include - -DlgConnHidWifiWpa::DlgConnHidWifiWpa(int type, KylinNM *mainWindow, QWidget *parent) : - isUsed(type), - QDialog(parent), - ui(new Ui::DlgConnHidWifiWpa) -{ - ui->setupUi(this); - - this->setWindowFlags(Qt::FramelessWindowHint); - this->setAttribute(Qt::WA_TranslucentBackground); - //需要添加 void paintEvent(QPaintEvent *event) 函数 - - QPainterPath path; - auto rect = this->rect(); - rect.adjust(1, 1, -1, -1); - path.addRoundedRect(rect, 6, 6); - setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon())); - - KylinDBus mkylindbus; - double trans = mkylindbus.getTransparentData(); - QString strTrans; - strTrans = QString::number(trans, 10, 2); - QString sty = "QWidget{border-radius:6px;background-color:rgba(255,255,255,1);border:1px solid rgba(255, 255, 255, 0.05);}"; - this->setStyleSheet(sty); - //this->setStyleSheet("QWidget{border-radius:6px;background-color:rgba(19,19,20,0.7);border:1px solid rgba(255, 255, 255, 0.05);}"); - - MyQss objQss; - - ui->lbBoder->setStyleSheet("QLabel{border-radius:6px;background-color:rgba(19,19,20,0.95);border:1px solid rgba(255, 255, 255, 0.05);}"); - ui->lbBoder->hide(); - ui->lbLeftupTitle->setStyleSheet("QLabel{border:0px;font-size:20px;color:rgba(255,255,255,0.97);background-color:transparent;}"); - ui->lbConn->setStyleSheet(objQss.labelQss); - ui->lbNetName->setStyleSheet(objQss.labelQss); - ui->lbSecurity->setStyleSheet(objQss.labelQss); - ui->lbPassword->setStyleSheet(objQss.labelQss); - - ui->cbxConn->setStyleSheet(objQss.cbxQss); - ui->cbxConn->setView(new QListView()); - ui->leNetName->setStyleSheet(objQss.leQss); - ui->lePassword->setStyleSheet(objQss.leQss); - ui->cbxSecurity->setStyleSheet(objQss.cbxQss); - ui->cbxSecurity->setView(new QListView()); - ui->checkBoxPwd->setStyleSheet(objQss.checkBoxQss); - - ui->btnCancel->setStyleSheet(objQss.btnCancelQss); - ui->btnConnect->setStyleSheet(objQss.btnConnQss); - ui->lineUp->setStyleSheet(objQss.lineQss); - ui->lineDown->setStyleSheet(objQss.lineQss); - ui->btnCancel->setFocusPolicy(Qt::NoFocus); - ui->checkBoxPwd->setFocusPolicy(Qt::NoFocus); - - - ui->lbLeftupTitle->setText(tr("Add Hidden Wi-Fi")); //加入隐藏Wi-Fi - ui->lbConn->setText(tr("Connection")); //连接设置: - ui->lbNetName->setText(tr("Wi-Fi name")); //网络名称: - ui->lbSecurity->setText(tr("Wi-Fi security")); //Wi-Fi 安全性: - ui->lbPassword->setText(tr("Password")); //密码: - ui->btnCancel->setText(tr("Cancel")); //取消 - ui->btnConnect->setText(tr("Connect")); //连接 - - ui->cbxConn->addItem(tr("C_reate…")); //新建... - QString tmpPath = "/tmp/kylin-nm-connshow-" + QDir::home().dirName(); - QString cmd = "nmcli connection show > " + tmpPath; - int status = system(cmd.toUtf8().data()); - if (status != 0) { - syslog(LOG_ERR, "execute 'nmcli connection show' in function 'DlgConnHidWifiWpa' failed"); - } - QFile file(tmpPath); - if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){ - qDebug()<<"Can't open the file!"; - } - QString txt = file.readAll(); - QStringList txtLine = txt.split("\n"); - file.close(); - foreach (QString line, txtLine) { - if (line.indexOf("wifi") != -1 || line.indexOf("802-11-wireless") != -1) { - QStringList subLine = line.split(" "); - ui->cbxConn->addItem(subLine[0]); - } - } - ui->cbxConn->setCurrentIndex(0); - connect(ui->cbxConn,SIGNAL(currentIndexChanged(QString)),this,SLOT(changeWindow())); - - ui->cbxSecurity->addItem(tr("None")); //无 - ui->cbxSecurity->addItem(tr("WPA & WPA2 Personal")); //WPA 及 WPA2 个人 - //ui->cbxSecurity->addItem(tr("WEP 40/128-bit Key (Hex or ASCII)")); //WEP 40/128 位密钥(十六进制或ASCII) - //ui->cbxSecurity->addItem(tr("WEP 128-bit Passphrase")); //WEP 128 位密码句 - //ui->cbxSecurity->addItem("LEAP"); - //ui->cbxSecurity->addItem(tr("Dynamic WEP (802.1X)")); //动态 WEP (802.1x) - //ui->cbxSecurity->addItem(tr("WPA & WPA2 Enterprise")); //WPA 及 WPA2 企业 - ui->cbxSecurity->setCurrentIndex(1); - connect(ui->cbxSecurity,SIGNAL(currentIndexChanged(QString)),this,SLOT(changeDialog())); - - if (isUsed == 0){ - ui->btnConnect->setEnabled(false); - } else { - ui->cbxConn->setCurrentIndex(isUsed); - ui->leNetName->setText(ui->cbxConn->currentText()); - ui->leNetName->setEnabled(false); - ui->lbNetName->setEnabled(false); - ui->lbSecurity->setEnabled(false); - ui->cbxSecurity->setEnabled(false); - ui->lbPassword->setEnabled(false); - ui->lePassword->setText(""); - ui->lePassword->setEnabled(false); - ui->btnConnect->setEnabled(true); - ui->checkBoxPwd->setEnabled(false); - } - - this->setFixedSize(432,397); - - this->mw = mainWindow; - - /**解决锁屏设置 X11BypassWindowManagerHint 属性导致QCombox弹框异常的问题---START---- - ** 手动绑定下拉框视图和下拉框 - **/ - ui->cbxConn->view()->setWindowFlags(Qt::Popup | Qt::X11BypassWindowManagerHint); - ui->cbxConn->view()->setParent(this); - ui->cbxConn->view()->hide(); - ui->cbxConn->installEventFilter(this); - - ui->cbxSecurity->view()->setWindowFlags(Qt::Popup | Qt::X11BypassWindowManagerHint); - ui->cbxSecurity->view()->setParent(this); - ui->cbxSecurity->view()->hide(); - ui->cbxSecurity->installEventFilter(this); - - connect(ui->cbxConn->view(), &QAbstractItemView::pressed, this, [=](QModelIndex index){ - Q_EMIT ui->cbxConn->setCurrentIndex(index.row()); - ui->cbxConn->view()->hide(); - }); - - connect(ui->cbxSecurity->view(), &QAbstractItemView::pressed, this, [=](QModelIndex index){ - ui->cbxSecurity->view()->hide(); - Q_EMIT ui->cbxSecurity->setCurrentIndex(index.row()); - }); - - ui->cbxConn->view()->setGeometry(QRect(ui->cbxConn->geometry().left(), ui->cbxConn->geometry().bottom(), ui->cbxConn->view()->width(), ui->cbxConn->view()->height())); - ui->cbxSecurity->view()->setGeometry(QRect(ui->cbxSecurity->geometry().left(), ui->cbxSecurity->geometry().bottom(), ui->cbxSecurity->view()->width(), ui->cbxSecurity->view()->height())); - /**解决锁屏设置 X11BypassWindowManagerHint 属性导致QCombox弹框异常的问题---END---- - ** 手动绑定下拉框视图和下拉框 - **/ -} - -DlgConnHidWifiWpa::~DlgConnHidWifiWpa() -{ - delete ui; -} - -/**解决锁屏设置 X11BypassWindowManagerHint 属性导致QCombox弹框异常的问题---START---- -** 手动绑定下拉框视图和下拉框 -**/ -bool DlgConnHidWifiWpa::eventFilter(QObject *obj, QEvent *ev) -{ - if(ev->type() == QEvent::MouseButtonPress) - { - if(obj == ui->cbxConn) - { - ui->cbxConn->view()->setVisible(!ui->cbxConn->view()->isVisible()); - if(ui->cbxConn->view()->isVisible()) - ui->cbxConn->view()->setFocus(); - } else if (obj == ui->cbxSecurity) - { - ui->cbxSecurity->view()->setVisible(!ui->cbxSecurity->view()->isVisible()); - if(ui->cbxSecurity->view()->isVisible()) - ui->cbxSecurity->view()->setFocus(); - } - } - return false; -} -/**解决锁屏设置 X11BypassWindowManagerHint 属性导致QCombox弹框异常的问题---END---- -** 手动绑定下拉框视图和下拉框 -**/ - -void DlgConnHidWifiWpa::mousePressEvent(QMouseEvent *event){ - if(event->button() == Qt::LeftButton){ - this->isPress = true; - this->winPos = this->pos(); - this->dragPos = event->globalPos(); - event->accept(); - } -} -void DlgConnHidWifiWpa::mouseReleaseEvent(QMouseEvent *event){ - this->isPress = false; -} -void DlgConnHidWifiWpa::mouseMoveEvent(QMouseEvent *event){ - if(this->isPress){ - this->move(this->winPos - (this->dragPos - event->globalPos())); - event->accept(); - } -} - -//切换到其他Wi-Fi安全类型 -void DlgConnHidWifiWpa::changeDialog() -{ - if(ui->cbxSecurity->currentIndex()==0){ -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifi *connHidWifi = new DlgConnHidWifi(0,mw, this->parentWidget()); - connHidWifi->show(); - connect(connHidWifi, SIGNAL(reSetWifiList() ), mw, SLOT(on_btnWifiList_clicked()) ); - } else if(ui->cbxSecurity->currentIndex()==1) { - qDebug()<<"it's not need to change dialog"; - } else if(ui->cbxSecurity->currentIndex()==2) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiWep *connHidWifiWep = new DlgConnHidWifiWep(0, this->parentWidget()); - connHidWifiWep->show(); - } else if(ui->cbxSecurity->currentIndex()==3) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiWep *connHidWifiWep = new DlgConnHidWifiWep(1,this->parentWidget()); - connHidWifiWep->show(); - } else if(ui->cbxSecurity->currentIndex()==4) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiLeap *connHidWifiLeap = new DlgConnHidWifiLeap(this->parentWidget()); - connHidWifiLeap->show(); - } else if(ui->cbxSecurity->currentIndex()==5) { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiSecTls *connHidWifiSecTls = new DlgConnHidWifiSecTls(0, this->parentWidget()); - connHidWifiSecTls->show(); - } else { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifiSecTls *connHidWifiSecTls = new DlgConnHidWifiSecTls(1, this->parentWidget()); - connHidWifiSecTls->show(); - } -} - -//同一 Wi-Fi安全类型的窗口变换 -void DlgConnHidWifiWpa::changeWindow() -{ - if (ui->cbxConn->currentIndex() == 0){ -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifi *connHidWifi = new DlgConnHidWifi(0, mw, this->parentWidget()); - connHidWifi->show(); - connect(connHidWifi, SIGNAL(reSetWifiList() ), mw, SLOT(on_btnWifiList_clicked()) ); - }else if (ui->cbxConn->currentIndex() >= 1){ - QString tmpPath = "/tmp/kylin-nm-connshow-" + QDir::home().dirName(); - QString name = ui->cbxConn->currentText(); - QString currStr = "nmcli connection show \"" + name.replace("\"","\\\"") + "\" > " + tmpPath; - - int status = system(currStr.toUtf8().data()); - if(status != 0){ - syslog(LOG_ERR, "execute 'nmcli connection show' in function 'changeWindow' failed"); - } - QFile file(tmpPath); - if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){ - qDebug()<<"Can't open the file!"; - } - QString txt = file.readAll(); - file.close(); - if (txt.indexOf("802-11-wireless-security.key-mgmt:") != -1){ - isUsed = ui->cbxConn->currentIndex(); - ui->lbNetName->setEnabled(false); - ui->leNetName->setText(ui->cbxConn->currentText()); - ui->leNetName->setEnabled(false); - ui->lbSecurity->setEnabled(false); - ui->cbxSecurity->setEnabled(false); - ui->lePassword->setText(""); - ui->lbPassword->setEnabled(false); - ui->lePassword->setEnabled(false); - ui->btnConnect->setEnabled(true); - }else { -// QApplication::setQuitOnLastWindowClosed(false); - this->hide(); - DlgConnHidWifi *connHidWifi = new DlgConnHidWifi(ui->cbxConn->currentIndex(), mw); - connHidWifi->show(); - connect(connHidWifi, SIGNAL(reSetWifiList() ), mw, SLOT(on_btnWifiList_clicked()) ); - } - } -} - -void DlgConnHidWifiWpa::on_btnCancel_clicked() -{ - this->close(); -} - -void DlgConnHidWifiWpa::on_btnConnect_clicked() -{ - QThread *t = new QThread(); - connect(t, SIGNAL(finished()), t, SLOT(deleteLater())); - connect(t, SIGNAL(started()), this, SLOT(slotStartLoading())); - connect(this, SIGNAL(stopSignal()), t, SLOT(quit())); - t->start(); - - QString wifiName = ui->leNetName->text(); - QString wifiPassword = ui->lePassword->text(); - BackThread *bt = new BackThread(); - strWifiname = wifiName; - strWifiPassword = wifiPassword; - if (isUsed == 0){ - int x = 0; - do{ - sleep(1); - QString tmpPath = "/tmp/kylin-nm-btoutput-" + QDir::home().dirName(); - QString cmd = "nmcli device wifi connect \"" + wifiName.replace("\"","\\\"") + "\" password \"" + wifiPassword.replace("\"","\\\"") + "\" hidden yes > " + tmpPath; - - int status = system(cmd.toUtf8().data()); - if (status != 0) { - syslog(LOG_ERR, "execute 'nmcli device wifi connect' in function 'on_btnConnect_clicked' failed"); - } - - QFile file(tmpPath); - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { - qDebug()<<"Can't open the file!"<execConnWifi(wifiName); - connect(this, SIGNAL(sendMessage()), this,SLOT(emitSignal() )); - QTimer::singleShot(4*1000, this, SLOT(emitSignal() )); - } - this->close(); -} - -void DlgConnHidWifiWpa::on_checkBoxPwd_stateChanged(int arg1) -{ - if (arg1 == 0) { - ui->lePassword ->setEchoMode(QLineEdit::Password); - } else { - ui->lePassword->setEchoMode(QLineEdit::Normal); - } -} - -void DlgConnHidWifiWpa::on_leNetName_textEdited(const QString &arg1) -{ - if (ui->leNetName->text() == "" || ui->lePassword->text() == ""){ - ui->btnConnect->setEnabled(false); - } else { - ui->btnConnect->setEnabled(true); - } -} - -void DlgConnHidWifiWpa::on_lePassword_textEdited(const QString &arg1) -{ - if (ui->leNetName->text() == "" || ui->lePassword->text() == ""){ - ui->btnConnect->setEnabled(false); - } else { - ui->btnConnect->setEnabled(true); - } -} - -void DlgConnHidWifiWpa::slotStartLoading() -{ - mw->startLoading(); -} - -void DlgConnHidWifiWpa::on_execSecConn() -{ - QString name = strWifiname; - QString pwd = strWifiPassword; - QString str = "nmcli device wifi connect \"" + name.replace("\"","\\\"") + "\" password\"" + pwd.replace("\"","\\\"") + "\""; - int status = system(str.toUtf8().data()); - if (status != 0){ syslog(LOG_ERR, "execute 'nmcli device wifi connect' in function 'on_execSecConn' failed");} - connect(this, SIGNAL(sendMessage()), this,SLOT(emitSignal() )); - QTimer::singleShot(3*1000, this, SLOT(emitSignal() )); -} - -void DlgConnHidWifiWpa::emitSignal() -{ - emit reSetWifiList(); - mw->stopLoading(); - emit this->stopSignal(); -} - -void DlgConnHidWifiWpa::paintEvent(QPaintEvent *event) -{ - QStyleOption opt; - opt.init(this); - QPainter p(this); - style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); - QWidget::paintEvent(event); -} diff --git a/KylinNM/wireless-security/dlgconnhidwifiwpa.h b/KylinNM/wireless-security/dlgconnhidwifiwpa.h deleted file mode 100644 index 3b73126..0000000 --- a/KylinNM/wireless-security/dlgconnhidwifiwpa.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see -#include -#include - -class KylinNM; - -namespace Ui { -class DlgConnHidWifiWpa; -} - -class DlgConnHidWifiWpa : public QDialog -{ - Q_OBJECT - -public: - explicit DlgConnHidWifiWpa(int type, KylinNM *mw = 0, QWidget *parent = 0); - ~DlgConnHidWifiWpa(); - -protected: - void paintEvent(QPaintEvent *event); - - /**解决锁屏设置 X11BypassWindowManagerHint 属性导致QCombox弹框异常的问题---START---- - ** 手动绑定下拉框视图和下拉框 过滤点击事件 - **/ - bool eventFilter(QObject *obj, QEvent *ev) override; - -public slots: - void changeDialog(); - void changeWindow(); - void emitSignal(); - void on_execSecConn(); - void slotStartLoading(); - -private slots: - void on_btnCancel_clicked(); - - void on_btnConnect_clicked(); - - void on_checkBoxPwd_stateChanged(int arg1); - - void on_leNetName_textEdited(const QString &arg1); - - void on_lePassword_textEdited(const QString &arg1); - -signals: - void reSetWifiList(); - void sendMessage(); - void execSecConn(); - void stopSignal(); - -private: - Ui::DlgConnHidWifiWpa *ui; - int isUsed;//=0 current wifi not used before; >=1 used - KylinNM *mw; - QString strWifiname; - QString strWifiPassword; - - void mousePressEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - -// QString labelQss, cbxQss, leQss, btnConnQss, btnCancelQss, lineQss, checkBoxQss; - - bool isPress; - QPoint winPos; - QPoint dragPos; -}; - -#endif // DLGCONNHIDWIFIWPA_H diff --git a/KylinNM/wireless-security/dlgconnhidwifiwpa.ui b/KylinNM/wireless-security/dlgconnhidwifiwpa.ui deleted file mode 100644 index 093ab22..0000000 --- a/KylinNM/wireless-security/dlgconnhidwifiwpa.ui +++ /dev/null @@ -1,284 +0,0 @@ - - - DlgConnHidWifiWpa - - - - 0 - 0 - 432 - 397 - - - - Connect to Hidden Wi-Fi Network - - - - - 76 - 221 - 90 - 20 - - - - - 10 - - - - - - - - - - 76 - 176 - 90 - 20 - - - - - 10 - - - - - - - - - - 215 - 350 - 90 - 30 - - - - - 10 - - - - - - - - - - 175 - 75 - 182 - 32 - - - - - 10 - - - - - - - - - - 332 - 272 - 18 - 9 - - - - - 10 - - - - - - - - - - 76 - 266 - 90 - 20 - - - - - 10 - - - - - - - - - - 175 - 170 - 182 - 32 - - - - - 10 - - - - - - - - - - 175 - 261 - 182 - 32 - - - - - 10 - - - - QLineEdit::Password - - - - - - 315 - 350 - 90 - 30 - - - - - 10 - - - - - - - - - - 76 - 80 - 90 - 20 - - - - - 10 - - - - Qt::LeftToRight - - - - - - - - - 175 - 215 - 182 - 32 - - - - - 10 - - - - - - - 0 - 0 - 432 - 397 - - - - - - - - - - 30 - 30 - 240 - 22 - - - - - - - - - - 10 - 140 - 412 - 1 - - - - Qt::Horizontal - - - - - - 10 - 320 - 412 - 1 - - - - Qt::Horizontal - - - lbBoder - lePassword - lbNetName - lbSecurity - btnCancel - cbxConn - checkBoxPwd - lbPassword - cbxSecurity - btnConnect - lbConn - leNetName - lbLeftupTitle - lineUp - lineDown - - - - diff --git a/KylinNM/wireless-security/kylinheadfile.cpp b/KylinNM/wireless-security/kylinheadfile.cpp deleted file mode 100644 index e8b92dc..0000000 --- a/KylinNM/wireless-security/kylinheadfile.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see -#include -#include -#include -#include -#include - -class MyQss -{ -public: - MyQss(); - - QString labelQss, cbxQss, leQss, btnConnQss, btnCancelQss, lineQss, checkBoxQss, checkBoxCAQss; - -}; - -#endif // KYLINHEADFILE_H diff --git a/config.h.in b/config.h.in deleted file mode 100644 index a66e4e2..0000000 --- a/config.h.in +++ /dev/null @@ -1,9 +0,0 @@ -#cmakedefine USE_INTEL - -// == 下面是测试用的 -#cmakedefine01 TEST_ON -#cmakedefine01 TEST_OF - -#ifndef __${VAR}___@VAR@ - -#endif diff --git a/data/screensaver-startup.sh b/data/screensaver-startup.sh index 822388a..1df3f0a 100755 --- a/data/screensaver-startup.sh +++ b/data/screensaver-startup.sh @@ -1,6 +1,6 @@ #!/bin/bash ukui-screensaver-dialog --lock-startup & >/dev/null 2>&1 -/usr/lib/ukui-screensaver/screensaver-focus-helper & >/dev/null 2>&1 +#/usr/lib/ukui-screensaver/screensaver-focus-helper & >/dev/null 2>&1 #如果锁屏和桌面进程并行启动,会对锁屏启动时间有较大影响,因此先启动锁屏,1s后再往下执行 sleep 1 diff --git a/data/ukui-greeter/95-ukui-greeter.conf b/data/ukui-greeter/95-ukui-greeter.conf new file mode 100644 index 0000000..45a0cda --- /dev/null +++ b/data/ukui-greeter/95-ukui-greeter.conf @@ -0,0 +1,4 @@ +[Seat:*] +greeter-session=ukui-greeter +user-session=ukui +#greeter-setup-script=/usr/lib/ukui-greeter/ukui-greeter-nm-start.sh diff --git a/data/ukui-greeter/lightdm-session-setup.sh b/data/ukui-greeter/lightdm-session-setup.sh new file mode 100755 index 0000000..d1b0402 --- /dev/null +++ b/data/ukui-greeter/lightdm-session-setup.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +if [ "$XDG_SESSION_TYPE" != "wayland" ]; then + bootinfo=$(cat /proc/cmdline | grep "boot=casper") + if [ ! "$bootinfo" = "" ]; then + echo "This is Try or install mode!" + else + username=`whoami` + if [ -x "$(command -v save-param)" ]; then + save-param -u $username + fi + fi +else + echo "Session type is wayland!" +fi diff --git a/data/ukui-greeter/ukui-greeter.desktop b/data/ukui-greeter/ukui-greeter.desktop new file mode 100644 index 0000000..b1d202f --- /dev/null +++ b/data/ukui-greeter/ukui-greeter.desktop @@ -0,0 +1,6 @@ +[Desktop Entry] +Name=UKUI Greeter +Comment=UKUI Greeter +Exec=ukui-greeter +Type=Application +X-Ubuntu-Gettext-Domain=ukui-greeter diff --git a/debian/control b/debian/control index e26075a..2d2bce2 100644 --- a/debian/control +++ b/debian/control @@ -35,7 +35,10 @@ Build-Depends: debhelper-compat (= 12), libavcodec-dev, libavformat-dev, qtmultimedia5-dev, - libkysdk-systime-dev + libkysdk-systime-dev, + liblightdm-qt5-3-dev, + libsystemd-dev, + libssl-dev Standards-Version: 4.5.0 Rules-Requires-Root: no Homepage: https://www.github.com/ukui/ukui-screensaver @@ -50,6 +53,7 @@ Depends: ethtool, libpam-biometric(>=3.20.0.10), ukui-input-gather(>=1.0.0.2), layer-shell-qt, + gstreamer1.0-libav, ${misc:Depends}, ${shlibs:Depends} Replaces: ukui-screensaver-common (<< 2.0.0) diff --git a/debian/copyright b/debian/copyright index 34d2316..98ffa21 100644 --- a/debian/copyright +++ b/debian/copyright @@ -8,32 +8,14 @@ Files: CMakeLists.txt data/* man/* debian/* - screensaver/* - Common/* .gitattributes - KylinNM/* .config.h.in - screensaver-focus-helper/* - set4kScale/* Copyright: 2018, Tianjin KYLIN Information Technology Co., Ltd. 2019, Tianjin KYLIN Information Technology Co., Ltd. 2020, Tianjin KYLIN Information Technology Co., Ltd. 2021, Tianjin KYLIN Information Technology Co., Ltd. 2022, Tianjin KYLIN Information Technology Co., Ltd. -License: GPL-3+ - -Files: src/xeventmonitor.h - src/xeventmonitor.cpp -Copyright: 2011 ~ 2017 Deepin, Inc. - 2011 ~ 2017 Wang Yong - 2018, Tianjin KYLIN Information Technology Co., Ltd. -License: GPL-3+ - -Files: BiometricAuth/* - VirtualKeyboard/* -Copyright: 2018, Tianjin KYLIN Information Technology Co., Ltd. - 2021, Tianjin KYLIN Information Technology Co., Ltd. - 2022, Tianjin KYLIN Information Technology Co., Ltd. + 2023, Tianjin KYLIN Information Technology Co., Ltd. License: GPL-3+ License: GPL-3+ diff --git a/debian/ukui-screensaver.install b/debian/ukui-screensaver.install new file mode 100644 index 0000000..7cebfef --- /dev/null +++ b/debian/ukui-screensaver.install @@ -0,0 +1,3 @@ +data/ukui-greeter/95-ukui-greeter.conf /usr/share/lightdm/lightdm.conf.d/ +data/ukui-greeter/lightdm-session-setup.sh /usr/lib/lightdm/ +data/ukui-greeter/ukui-greeter.desktop /usr/share/xgreeters/ \ No newline at end of file diff --git a/debian/ukui-screensaver.preinst b/debian/ukui-screensaver.preinst new file mode 100644 index 0000000..ebf7535 --- /dev/null +++ b/debian/ukui-screensaver.preinst @@ -0,0 +1,18 @@ +#!/bin/sh + +#set -e + +echo "run ukui-screensaver.preinst" + +path_conf="/usr/share/lightdm/lightdm.conf.d/95-ukui-greeter.conf" +dpkg-divert --package ukui-screensaver --rename --divert "$path_conf"".old" --add $path_conf +path_sh="/usr/lib/lightdm/lightdm-session-setup.sh " +dpkg-divert --package ukui-screensaver --rename --divert "$path_sh"".old" --add $path_sh +path_desktop="/usr/share/xgreeters/ukui-greeter.desktop" +dpkg-divert --package ukui-screensaver --rename --divert "$path_desktop"".old" --add $path_desktop + +#remove_greeter(){ +# dpkg -P ukui-greeter +#} + +#remove_greeter() diff --git a/i18n_ts/CMakeLists.txt b/i18n_ts/CMakeLists.txt index f4b0cef..c29c6a3 100644 --- a/i18n_ts/CMakeLists.txt +++ b/i18n_ts/CMakeLists.txt @@ -2,11 +2,10 @@ find_package(Qt5LinguistTools) file(GLOB ts_files *.ts) qt5_create_translation(qm_files ${ts_files}) + add_custom_target(i18n DEPENDS ${qm_files} SOURCES ${ts_files} ) -# 让主目标依赖翻译文件,这样才会执行i18n -add_dependencies(ukui-screensaver-dialog i18n) install(FILES ${qm_files} DESTINATION /usr/share/ukui-screensaver/i18n_qm/) diff --git a/i18n_ts/bo.ts b/i18n_ts/bo.ts index 16a474d..c9e62fa 100644 --- a/i18n_ts/bo.ts +++ b/i18n_ts/bo.ts @@ -4,8 +4,7 @@ AgreementWindow - - + I know @@ -13,186 +12,41 @@ AuthDialog - + Authentication failure, Please try again - - - - - Please try again in %1 minutes. - - - - - Enter the ukey password - - - - - Insert the ukey into the USB port - - - - - - - - Please try again in %1 seconds. - - - - - - - - Account locked permanently. - - - - - Verify face recognition or enter password to unlock - - - - - Press fingerprint or enter password to unlock - - - - - Verify voiceprint or enter password to unlock - - - - - Verify finger vein or enter password to unlock - - - - - Verify iris or enter password to unlock - - - - - Use the bound wechat scanning code or enter the password to unlock - - - - - + + Password cannot be empty - - Password: + + Password - + Input Password - + Login - + Retry - - - Failed to verify %1, please enter password to unlock - - - - - - Unable to verify %1, please enter password to unlock - - - - - - Failed to verify %1, you still have %2 verification opportunities - - - - - Abnormal network - - - - - BatteryWidget - - - Charging... - - - - - fully charged - - - - - PowerMode - - - - - BatteryMode - - - - - BiometricAuthWidget - - - Current device: - - - - - Identify failed, Please retry. - - - - - BiometricDevicesWidget - - - Please select the biometric device - - - - - Device type: - - - - - Device name: - - - - - OK - - CharsMoreWidget - + &&?! @@ -200,2159 +54,155 @@ CharsWidget - + More - + ABC - + 123 - - ConfForm - - - edit network - - - - - LAN name: - - - - - Method: - - - - - Address: - - - - - Netmask: - - - - - Gateway: - - - - - DNS 1: - - - - - DNS 2: - - - - - Edit Conn - - - - - - Auto(DHCP) - - - - - - Manual - - - - - Cancel - - - - - Save - - - - - Ok - - - - - Can not create new wired network for without wired card - - - - - New network already created - - - - - New network settings already finished - - - - - New settings already effective - - - - - Edit Network - - - - - Add Wired Network - - - - - DeviceType - - - FingerPrint - - - - - FingerVein - - - - - Iris - - - - - Face - - - - - VoicePrint - - - - - Ukey - - - - - QRCode - - - - - DigitalAuthDialog - - - - LoginByUEdu - - - - - ResetPWD? - - - - - - SetNewUEduPWD - - - - - clear - - - - - ConfirmNewUEduPWD - - - - - The two password entries are inconsistent, please reset - - - - - Password entered incorrectly, please try again - - - - - DlgConnHidWifi - - - Connect to Hidden Wi-Fi Network - - - - - Add Hidden Wi-Fi - - - - - Connection - - - - - Wi-Fi name - - - - - Wi-Fi security - - - - - Cancel - - - - - Connect - - - - - C_reate… - - - - - None - - - - - WPA & WPA2 Personal - - - - - DlgConnHidWifiLeap - - - Connect to Hidden Wi-Fi Network - - - - - Add hidden Wi-Fi - - - - - Connection - - - - - Network name - - - - - Wi-Fi security - - - - - Username - - - - - Password - - - - - Cancel - - - - - Connect - - - - - C_reate… - - - - - None - - - - - WPA & WPA2 Personal - - - - - WEP 40/128-bit Key (Hex or ASCII) - - - - - WEP 128-bit Passphrase - - - - - Dynamic WEP (802.1X) - - - - - WPA & WPA2 Enterprise - - - - - DlgConnHidWifiSecFast - - - Connect to Hidden Wi-Fi Network - - - - - Add hidden Wi-Fi - - - - - Connection - - - - - Network name - - - - - Wi-Fi security - - - - - Authentication - - - - - Anonymous identity - - - - - Allow automatic PAC pro_visioning - - - - - PAC file - - - - - Inner authentication - - - - - Username - - - - - Password - - - - - Cancel - - - - - Connect - - - - - C_reate… - - - - - - None - - - - - WPA & WPA2 Personal - - - - - WEP 40/128-bit Key (Hex or ASCII) - - - - - WEP 128-bit Passphrase - - - - - Dynamic WEP (802.1X) - - - - - WPA & WPA2 Enterprise - - - - - Tunneled TLS - - - - - Protected EAP (PEAP) - - - - - Anonymous - - - - - Authenticated - - - - - Both - - - - - DlgConnHidWifiSecLeap - - - Connect to Hidden Wi-Fi Network - - - - - Add hidden Wi-Fi - - - - - Connection - - - - - Network name - - - - - Wi-Fi security - - - - - Authentication - - - - - Username - - - - - Password - - - - - Cancel - - - - - Connect - - - - - C_reate… - - - - - None - - - - - WPA & WPA2 Personal - - - - - WEP 40/128-bit Key (Hex or ASCII) - - - - - WEP 128-bit Passphrase - - - - - Dynamic WEP (802.1X) - - - - - WPA & WPA2 Enterprise - - - - - Tunneled TLS - - - - - Protected EAP (PEAP) - - - - - DlgConnHidWifiSecPeap - - - Connect to Hidden Wi-Fi Network - - - - - Add hidden Wi-Fi - - - - - Connection - - - - - Network name - - - - - Wi-Fi security - - - - - Authentication - - - - - Anonymous identity - - - - - Domain - - - - - CA certificate - - - - - CA certificate password - - - - - No CA certificate is required - - - - - PEAP version - - - - - Inner authentication - - - - - Username - - - - - Password - - - - - Cancel - - - - - Connect - - - - - - None - - - - - WPA & WPA2 Personal - - - - - WEP 40/128-bit Key (Hex or ASCII) - - - - - WEP 128-bit Passphrase - - - - - Dynamic WEP (802.1X) - - - - - WPA & WPA2 Enterprise - - - - - Tunneled TLS - - - - - Protected EAP (PEAP) - - - - - Choose from file - - - - - Automatic - - - - - Version 0 - - - - - Version 1 - - - - - DlgConnHidWifiSecPwd - - - Connect to Hidden Wi-Fi Network - - - - - Add hidden Wi-Fi - - - - - Connection - - - - - Network name - - - - - Wi-Fi security - - - - - Authentication - - - - - Username - - - - - Password - - - - - Cancel - - - - - Connect - - - - - C_reate… - - - - - None - - - - - WPA & WPA2 Personal - - - - - WEP 40/128-bit Key (Hex or ASCII) - - - - - WEP 128-bit Passphrase - - - - - Dynamic WEP (802.1X) - - - - - WPA & WPA2 Enterprise - - - - - Tunneled TLS - - - - - Protected EAP (PEAP) - - - - - DlgConnHidWifiSecTls - - - Connect to Hidden Wi-Fi Network - - - - - Add hidden Wi-Fi - - - - - Connection - - - - - Network name - - - - - Wi-Fi security - - - - - Authentication - - - - - Identity - - - - - Domain - - - - - CA certificate - - - - - CA certificate password - - - - - No CA certificate is required - - - - - User certificate - - - - - User certificate password - - - - - User private key - - - - - User key password - - - - - Cancel - - - - - Connect - - - - - C_reate… - - - - - - - - None - - - - - WPA & WPA2 Personal - - - - - WEP 40/128-bit Key (Hex or ASCII) - - - - - WEP 128-bit Passphrase - - - - - Dynamic WEP (802.1X) - - - - - WPA & WPA2 Enterprise - - - - - Tunneled TLS - - - - - Protected EAP (PEAP) - - - - - - - Choose from file - - - - - DlgConnHidWifiSecTunnelTLS - - - Connect to Hidden Wi-Fi Network - - - - - Add hidden Wi-Fi - - - - - Connection - - - - - Network name - - - - - Wi-Fi security - - - - - Authentication - - - - - Anonymous identity - - - - - Domain - - - - - CA certificate - - - - - CA certificate password - - - - - No CA certificate is required - - - - - Inner authentication - - - - - Username - - - - - Password - - - - - Cancel - - - - - Connect - - - - - C_reate… - - - - - - None - - - - - WPA & WPA2 Personal - - - - - WEP 40/128-bit Key (Hex or ASCII) - - - - - WEP 128-bit Passphrase - - - - - Dynamic WEP (802.1X) - - - - - WPA & WPA2 Enterprise - - - - - Tunneled TLS - - - - - Protected EAP (PEAP) - - - - - Choose from file - - - - - DlgConnHidWifiWep - - - Connect to Hidden Wi-Fi Network - - - - - Add hidden Wi-Fi - - - - - Connection - - - - - Network name - - - - - Wi-Fi security - - - - - Key - - - - - WEP index - - - - - Authentication - - - - - Cancel - - - - - Connect - - - - - C_reate… - - - - - None - - - - - WPA & WPA2 Personal - - - - - WEP 40/128-bit Key (Hex or ASCII) - - - - - WEP 128-bit Passphrase - - - - - Dynamic WEP (802.1X) - - - - - WPA & WPA2 Enterprise - - - - - 1(default) - - - - - Open System - - - - - Shared Key - - - - - DlgConnHidWifiWpa - - - Connect to Hidden Wi-Fi Network - - - - - Add Hidden Wi-Fi - - - - - Connection - - - - - Wi-Fi name - - - - - Wi-Fi security - - - - - Password - - - - - Cancel - - - - - Connect - - - - - C_reate… - - - - - None - - - - - WPA & WPA2 Personal - - - - - DlgHotspotCreate - - - Dialog - - - - - Create Hotspot - - - - - Network name - - - - - Wi-Fi security - - - - - Password - - - - - Cancel - - - - - Ok - - - - - None - - - - - WPA & WPA2 Personal - - - - - EngineDevice - - - yes - - - - - no - - - - - Yes - - - - - No - - - - - %1% available, charged - - - - - Left %1h %2m (%3%) - - - - - %1% available - - - - - Left %1h %2m to full - - - - - charging (%1%) - - - - - %1 waiting to discharge (%2%) - - - - - %1 waiting to charge (%2%) - - - - - AC adapter - - - - - Laptop battery - - - - - UPS - - - - - Monitor - - - - - Mouse - - - - - Keyboard - - - - - PDA - - - - - Cell phone - - - - - Media player - - - - - Tablet - - - - - Computer - - - - - unrecognised - - - - - IconEdit - - - OK - - - - - InputInfos - - - - Get code - - - - - Recapture(60s) - - - - - Recapture(%1s) - - - - - Service exception... - - - - - Invaild parameters... - - - - - Unknown fault:%1 - - - - - KylinNM - - - kylin-nm - - - - - No usable network in the list - - - - - Inactivated LAN - - - - - Other WLAN - - - - - - LAN - - - - - - WLAN - - - - - HotSpot - - - - - FlyMode - - - - - - Advanced - - - - - Show KylinNM - - - - - No wireless card detected - - - - - Activated LAN - - - - - Activated WLAN - - - - - - - - - Not connected - - - - - - - - - - - - - Disconnected - - - - - - NetOn, - - - - - No Other Wired Network Scheme - - - - - No Other Wireless Network Scheme - - - - - Wired net is disconnected - - - - - Conn Ethernet Success - - - - - Conn Ethernet Fail - - - - - Conn Wifi Success - - - - - Confirm your Wi-Fi password or usable of wireless card - - - LettersWidget - + &&?! - + 123 - LockWidget + LightDMHelper - - Form + + failed to start session. - - Date + + Login - - Time + + Guest + + + MyNetworkWidget - - PowerInfo - - - - - Power - - - - - VirtualKeyboard - - - - - SwitchUser - - - - - Multiple users are logged in at the same time.Are you sure you want to reboot this system? - - - - + LAN - + WLAN - - LoginOptionsWidget - - - Login Options - - - - - Password - - - - - Other - - - - - Identify device removed! - - - - - MyLineEdit - - - - - Verification code - - - NumbersWidget - + &&?! - + Return - OneConnForm + PowerListWidget - - Form - - - - - - - - Connect - - - - - Disconnect - - - - - Input Password... - - - - - Automatically join the network - - - - - Connect to Hidden Wi-Fi Network - - - - - None - - - - - WiFi Security: - - - - - Signal: - - - - - MAC: - - - - - Conn Wifi Failed - - - - - OneLancForm - - - Form - - - - - - Connect - - - - - Disconnect - - - - - - No Configuration - - - - - IPv4: - - - - - IPv6: - - - - - BandWidth: - - - - - MAC: - - - - - PhoneAuthWidget - - - - Verification by phoneNum - - - - - 「 Use bound Phone number to verification 」 - - - - - - commit - - - - - 「 Use SMS to verification 」 - - - - - - Network not connected~ - - - - - Verification Code invalid! - - - - - Verification Code incorrect.Please retry! - - - - - Failed time over limit!Retry after 1 hour! - - - - - verifaction failed! - - - - - Network unavailable~ - - - - - PowerManager - - - Log Out - - - - - lock - - - - - - Restart - - - - - Power Off - - - - - Close all apps, turn off your computer, and then turn your computer back on - - - - - Close all apps, and then shut down your computer - - - - - Shut Down - - - - - Turn off your computer, but the app stays open. When the computer is turned on, it can be restored to the state you left - - - - + Hibernate - + + Turn off your computer, but the app stays open. When the computer is turned on, it can be restored to the state you left + + + + + Suspend + + + + + The computer stays on, but consumes less power. The app stays open and can quickly wake up and revert to where you left off - - Suspend + + Reboot + + + + + Power Off + + + + + Close all apps, and then shut down your computer QObject - + The screensaver is active. - + The screensaver is inactive. - - S: - - - - tablet device - - - Screensaver - + Picture does not exist - + View - - - You have new notification - - SleepTime - + You have rested - - SureWindow - - - Form - - - - - TextLabel - - - - - Cancel - - - - - Confirm - - - - - The following program is running to prevent the system from reboot! - - - - - The following program is running to prevent the system from shutting down! - - - - - The following program is running to prevent the system from suspend! - - - - - The following program is running to prevent the system from hibernate! - - - - - SwitchButtonGroup - - - uEduPWD - - - - - Wechat - - - - - TabletLockWidget - - - - - - - - Cancel - - - - - - Back - - - - - Skip - - - - - New password is the same as old - - - - - Reset password error:%1 - - - - - Please scan by correct WeChat - - - - - Utils - - - kylin network applet desktop message - - - - - VerificationWidget - - - Please scan by bound WeChat - - - - - VerticalVerificationWidget - - - Please scan by bound WeChat - - - - - WeChatAuthDialog - - - - Login by wechat - - - - - - 「 Use registered WeChat account to login 」 - - - - - - Verification by wechat - - - - - - 「 Use bound WeChat account to verification 」 - - - - - - Network not connected~ - - - - - Scan code successfully - - - - - Timeout!Try again! - - - - - Widget - - - Widget - - - - - LoadPlugin - - - delay - + how long to show lock @@ -2360,7 +210,7 @@ has-lock - + if show lock @@ -2368,87 +218,97 @@ main - + Screensaver for ukui-screensaver - + show on root window - + show on window. - + window id - + Start command for the ukui ScreenSaver. - - - + + + lock the screen immediately - + query the status of the screen saver - + unlock the screen saver - + show the screensaver - + show blank and delay to lock,param:idle/lid/lowpower - + Dialog for the ukui ScreenSaver. - + activated by session idle signal - - + + lock the screen and show screensaver immediately - + show screensaver immediately - + show blank screensaver immediately and delay time to show lock - + show blank screensaver immediately and if lock + + + Backend for the ukui ScreenSaver. + + + + + lock the screen by startup + + diff --git a/i18n_ts/bo_CN.ts b/i18n_ts/bo_CN.ts index 65a7c75..bb07f7e 100644 --- a/i18n_ts/bo_CN.ts +++ b/i18n_ts/bo_CN.ts @@ -4,173 +4,273 @@ AgreementWindow + I know - + ངས་ཤེས་སོང་། AuthDialog + More Devices + 选择其他设备 + + + Biometric + 使用生物识别认证 + + + Password + 使用密码认证 + + + Retry - ཡང་བསྐྱར་ཚོད་ལེན། + བསྐྱར་དུ་ཞིབ་བཤེར་བྱ་དགོས། - Please enter your password or enroll your fingerprint - གསང་ཨང་མནོན་པའམ་མཛུབ་རིམ་མནོན་རོགས། + UnLock + 解锁 - Too many unsuccessful attempts,please enter password. - མཛུབ་རིས་ར་སྤྲོད་ཕམ་ཉེས་ཚད་ཆེས་ཆེ་ལས་བརྒལ་བ། ཁྱོས་གསང་ཨང་བཀོལ་ནས་ཟྭ་འབྱེད་རོགས། + Slide to unlock + 向上滑动解锁 - Fingerprint authentication failed, you still have %1 verification opportunities - མཛུབ་རིས་ར་སྤྲོད་ཕམ་ཉེས་བྱུང་། ཁྱོད་ལ་ད་དུང་གོ་སྐབས་གཅིག་ཡོད། + You have %1 unread message + 您有%1条未读消息 + + + LoggedIn + 已登录 Password: - གསང་ཨང་། + 密码: - Biometric Authentication - སྐྱེ་དངོས་ངོས་འཛིན་ཀྱི་དཔང་ལེན། - - - Other Devices - སྒྲིག་ཆས་གཞན་དག - - - Password Authentication - གསང་ཨང་ར་སྤྲོད་གྲོས་ཆིངས། - - - Authentication failure, Please try again - དཔང་ལེན་བྱ་མ་ཐུབ། ཡང་བསྐྱར་ཚོད་ལྟ་བྱོས། + Account locked %1 minutes due to %2 fail attempts + 账户锁定%1分钟由于%2次错误尝试 Please try again in %1 minutes. - + ཁྱོད་ཀྱིས་ཡང་བསྐྱར་ཐེངས་གཅིག་ལ་ཚོད་ལྟ་ཞིག་བྱེད་རོགས། Please try again in %1 seconds. - + ཁྱོད་ཀྱིས་དུས་ཚོད་སྐར་ཆ་གཅིག་གི་ནང་དུ་ཡང་བསྐྱར་ཚོད་ལྟ་ཞིག་བྱེད་རོགས། Account locked permanently. - + དུས་གཏན་དུ་ཟྭ་བརྒྱབ་པའི་རྩིས་ཐོ། Verify face recognition or enter password to unlock - + ངོ་གདོང་ངོས་འཛིན་ལ་ཞིབ་བཤེར་བྱེད་པའམ་ཡང་ན་གསང་གྲངས་ནང་ Press fingerprint or enter password to unlock - + མཛུབ་རིས་མནན་པའམ་ཡང་ན་གསང་གྲངས་ནང་འཇུག་བྱས་ནས་ Verify voiceprint or enter password to unlock - + སྒྲ་པར་ཞིབ་བཤེར་བྱེད་པའམ་ཡང་ན་གསང་གྲངས་ནང་འཇུག་བྱས་ནས་ཟྭ་རྒྱག Verify finger vein or enter password to unlock - + མཛུབ་མོའི་ནང་དུ་ཞིབ་བཤེར་བྱེད་པའམ་ཡང་ན་གསང་གྲངས་ནང་འཇུག་བྱས་ Verify iris or enter password to unlock - + iris ཞིབ་བཤེར་བྱེད་པའམ་ཡང་ན་གསང་གྲངས་ནང་འཇུག་བྱས་ནས་ཟྭ་ - Password cannot be empty - - - - Login - - - - Failed to verify %1, you still have %2 verification opportunities - - - - Use the bound wechat scanning code or enter the password to unlock - + + Input Password + ནང་འཇུག་གི་གསང་གྲངས། Failed to verify %1, please enter password to unlock - + %1ལ་ཞིབ་བཤེར་བྱེད་མ་ཐུབ་ན། གསང་གྲངས་ནང་འཇུག་བྱས་ནས་ཟྭ་རྒྱག་རོགས། Unable to verify %1, please enter password to unlock - - - - Input Password - + %1ལ་ཞིབ་བཤེར་བྱེད་ཐབས་བྲལ་བ་དང་། གསང་གྲངས་ནང་འཇུག་བྱས་ནས་ཟྭ་རྒྱག་རོགས། Abnormal network - + རྒྱུན་ལྡན་མིན་པའི་དྲ་ + + + Face recognition waiting time out, please click refresh or enter the password to unlock. + མིའི་གདོང་ལ་དབྱེ་འབྱེད་བྱེད་པར་རེ་སྒུག་བྱེད་དུས་གསང་གྲངས་ཀྱི་སྒོ་ལྕགས་རྒྱག་རོགས། + + + Use the bound wechat scanning code or enter the password to log in + 使用绑定的微信扫码或输入密码登录 + + + + + Password cannot be empty + གསང་གྲངས་སྟོང་པ་ཡིན་མི་སྲིད། + + + Failed to verify %1, please enter password. + 验证%1失败,请输入密码. + + + Unable to verify %1, please enter password. + 无法验证%1,请输入密码. + + + Failed to verify %1, you still have %2 verification opportunities + %1ལ་ཞིབ་བཤེར་བྱེད་མ་ཐུབ་ན། ཁྱེད་ཚོར་ད་དུང་%2ལ་ཞིབ་བཤེར་བྱེད་པའི་གོ་སྐབས་ཡོད། + + + Biometric/code scan authentication failed too many times, please enter the password. + 生物/扫码验证失败达最大次数,请使用密码解锁 + + + Bioauth/code scan authentication failed, you still have %1 verification opportunities + 生物/扫码验证失败,您还有%1次尝试机会 + + + NET Exception + 网络异常 + + + Password Incorrect, Please try again + 密码错误,请重试 + + + Authentication failure,there are still %1 remaining opportunities + 认证失败,还剩%1次尝试机会 + + + Please enter your password or enroll your fingerprint + 请输入密码或者录入指纹 + + + + Authentication failure, Please try again + བདེན་དཔང་ར་སྤྲོད་བྱེད་མ་ཐུབ་ན། ཡང་བསྐྱར་ཚོད་ལྟ་ཞིག + + + Use the bound wechat scanning code or enter the password to unlock + འབྲེལ་མཐུད་ཀྱི་འཕྲིན་ཕྲན་ཞིབ་བཤེར་ཨང་གྲངས་སམ་ཡང་ན་གསང་གྲངས་ནང་འཇུག་བྱས་ནས་ཟྭ་རྒྱག་པ། Enter the ukey password - གསང་བའི་ཨང་གྲངས་ནང་འཇུག་བྱེད་པ། + གསང་བའི་ཨང་གྲངས་ནང་འཇུག་བྱེད་པ། Insert the ukey into the USB port - བདེ་འཇགས་ཀྱི་གསང་བའི་ལྡེ་མིག་དེ་USBཡི་སྣེ་འདྲེན་དུ་འཇུག་རོགས། + བདེ་འཇགས་ཀྱི་གསང་བའི་ལྡེ་མིག་དེ་USBཡི་སྣེ་འདྲེན་དུ་འཇུག་རོགས། + + + + Password + གསང་གྲངས། + + + + Login + ཐོ་འགོད་བྱེད་པ། + + + Biometric Authentication + 生物识别认证 + + + Password Authentication + 密码认证 + + + Other Devices + 其他设备 + + + Too many unsuccessful attempts,please enter password. + 指纹验证失败达最大次数,请使用密码登录 + + + Fingerprint authentication failed, you still have %1 verification opportunities + 指纹验证失败,您还有%1次尝试机会 - BatteryWidget + BioDevices - Charging... - + FingerPrint + 指纹 - fully charged - + FingerVein + 指静脉 - PowerMode - + Iris + 虹膜 - BatteryMode - + Face + 人脸 + + + VoicePrint + 声纹 + + + + BioDevicesWidget + + Please select other biometric devices + 请选择其他生物识别设备 + + + Device Type: + 设备类型: + + + Device Name: + 设备名称: BiometricAuthWidget - Identify failed, Please retry. - ངོས་འཛིན་མ་ཐུབ། ཡང་བསྐྱར་ཚོད་ལྟ་བྱོས། + Current device: + མིག་སྔའི་སྒྲིག་ཆས་ནི། - Current device: - མིག་སྔའི་སྒྲིག་ཆས་རེའུ་མིག: + Identify failed, Please retry. + ཕམ་ཉེས་བྱུང་བར་ངོས་འཛིན་གནང་རོགས། ཁྱེད་ཀྱིས་ཡང་བསྐྱར་ཐེངས་གཅིག་ལ BiometricDevicesWidget - - OK - གཏན་འཁེལ་བྱེད་པ། - Please select the biometric device - ཉིད་ཀྱིས་སྐྱེ་དངོས་སྒྲིག་ཆས་འདེམ་རོགས། + སྐྱེ་དངོས་དབྱེ་འབྱེད་སྒྲིག་ཆས་འདེམས་རོགས། Device type: - སྒྲིག་ཆས་ཀྱི་རིགས། + སྒྲིག་ཆས་ཀྱི་རིགས་དབྱིབས་ནི། Device name: - སྒྲིག་ཆས་ཀྱི་མིང་། + སྒྲིག་ཆས་ཀྱི་མིང་གཤམ་གསལ། + + + OK + འགྲིགས། CharsMoreWidget + &&?! @@ -178,14 +278,22 @@ CharsWidget - More - + + + དེ་བས་ཀྱང་མང་ + + More + དེ་བས་ཀྱང་མང་ + + + ABC + 123 @@ -194,1723 +302,1938 @@ ConfForm edit network - + རྩོམ་སྒྲིག་དྲ་བ། LAN name: - + LANཡི་མིང་ནི། Method: - + བྱེད་ཐབས་ནི། Address: - + སྡོད་གནས་ནི། Netmask: - + དྲ་རྒྱའི་མ་སི་ཁི་ཡིས་བཤད་རྒྱུར། Gateway: - + འགག་སྒོ་ནི། DNS 1: - + DNS 1: DNS 2: - + DNS 2: Edit Conn - + རྩོམ་སྒྲིག་པ། Auto(DHCP) - + རང་འགུལ་(DHCP) Manual - + ལག་དེབ། Cancel - + ཕྱིར་འཐེན། Save - + གྲོན་ཆུང་བྱེད་དགོས། Ok - + འགྲིགས། Can not create new wired network for without wired card - + སྐུད་ཡོད་བྱང་བུ་མེད་ན་སྐུད་ཡོད་དྲ་རྒྱ་གསར་པ་གཏོད་མི་ཐུབ། New network already created - + དྲ་རྒྱ་གསར་པ་གསར་སྐྲུན་བྱས་ཟིན་པ། New network settings already finished - - - - New settings already effective - + དྲ་རྒྱའི་སྒྲིག་བཀོད་གསར་པ་ལེགས་འགྲུབ་བྱུང་ཡོད། Edit Network - + རྩོམ་སྒྲིག་དྲ་བ། Add Wired Network - + སྐུད་ཡོད་བརྙན་འཕྲིན་དྲ་བ་ཁ་སྣོན་ + + + create wired network successfully + 已创建新的有线网络 + + + change configuration of wired network successfully + 新的设置已经生效 + + + New settings already effective + སྒྲིག་གཞི་གསར་པར་ཕན་ནུས་ཐོན་ཡོད། + + + There is a same named LAN exsits. + 已有同名连接存在 DeviceType - - Face - མིའི་གདོང་། - - - Iris - འཇའ་སྐྱི། - - - VoicePrint - སྒྲ་རིས། - FingerPrint - མཛུབ་རིས། + མཛུབ་མོའི་པར་གཞི། FingerVein - མཛུབ་མོའི་སྡོད་རྩ། + མཛུབ་མོ་ཝེ་ལིན། - QRCode - + Iris + དབྱི་ལི་སི། + + + Face + ངོ་གདོང་། + + + VoicePrint + སྒྲ་གདངས་ཀྱི་པར་གཞི། Ukey - + བདེ་འཇགས་གསང་ལྡེ་ + + + QRCode + དོན་ཚན་གཉིས་པ། DigitalAuthDialog LoginByUEdu - + LoginByUEdu + + + now is authing, wait a moment + 认证中,请稍后 + + + Password Incorrect, Please try again + 密码错误,请重试 ResetPWD? - + ཡང་བསྐྱར་བཀོད་སྒྲིག་བྱེད་དགོས་སམ། SetNewUEduPWD - - - - clear - + SetNewUeduPWD ConfirmNewUEduPWD - + གསར་དུ་གཏན་འཁེལ་བྱས་པའི་ནུའུ་ཝུའུ་ཏུའུ་ཕུའུ་ཝེ་ཏི། The two password entries are inconsistent, please reset - + གསང་བའི་འཇུག་སྒོ་གཉིས་གཅིག་མཐུན་མིན་པས་བསྐྱར་དུ་བཀོད་སྒྲིག་གནང་རོགས། Password entered incorrectly, please try again - + གསང་གྲངས་ནང་འཇུག་བྱས་པ་ནོར་འདུག་པས་ཡང་བསྐྱར་ཚོད་ལྟ་ཞིག་གནང་རོགས། + + + clear + གསལ་པོར་བཤད་ན། DlgConnHidWifi - - Connect to Hidden Wi-Fi Network - - Add Hidden Wi-Fi - + སྦས་སྐུང་བྱས་པའི་Wi-Fiབསྣན་པ། Connection - + འབྲེལ་མཐུད་ Wi-Fi name - + Wi-Fiཡི་མིང་། Wi-Fi security - + Wi-Fiབདེ་འཇགས། Cancel - + ཕྱིར་འཐེན། Connect - + སྦྲེལ་མཐུད་བྱེད་པ C_reate… - + C_reate… None - + གཅིག་ཀྱང་མེད། WPA & WPA2 Personal - + WPA & WPA2 མི་སྒེར་ + + + WEP 40/128-bit Key (Hex or ASCII) + WEP 40/128 位密钥(十六进制或ASCII) + + + WEP 128-bit Passphrase + WEP 128 位密码句 + + + Dynamic WEP (802.1X) + 动态 WEP (802.1x) + + + WPA & WPA2 Enterprise + WPA 及 WPA2 企业 + + + Connect to Hidden Wi-Fi Network + སྦས་སྐུང་བྱས་པའི་Wi-Fiདྲ་རྒྱ་སྦྲེལ་མཐུད་བྱེད་པ། DlgConnHidWifiLeap Connect to Hidden Wi-Fi Network - + སྦས་སྐུང་བྱས་པའི་Wi-Fiདྲ་རྒྱ་སྦྲེལ་མཐུད་བྱེད་པ། Add hidden Wi-Fi - + སྦས་སྐུང་བྱས་པའི་Wi-Fiབསྣན་པ། Connection - + འབྲེལ་མཐུད་ Network name - + དྲ་རྒྱའི་མིང་། Wi-Fi security - + Wi-Fiབདེ་འཇགས། Username - + སྤྱོད་མཁན་གྱི་མིང་། Password - + གསང་གྲངས། Cancel - + ཕྱིར་འཐེན། Connect - + སྦྲེལ་མཐུད་བྱེད་པ C_reate… - + C_reate… None - + གཅིག་ཀྱང་མེད། WPA & WPA2 Personal - + WPA & WPA2 མི་སྒེར་ WEP 40/128-bit Key (Hex or ASCII) - + WEP 40/128-bit Key (Hex or ASCII) WEP 128-bit Passphrase - + WEP 128-bit Passprase Dynamic WEP (802.1X) - + འགུལ་རྣམ་གྱི་WEP (802.1X) WPA & WPA2 Enterprise - + WPA & WPA2 ཁེ་ལས། DlgConnHidWifiSecFast Connect to Hidden Wi-Fi Network - + སྦས་སྐུང་བྱས་པའི་Wi-Fiདྲ་རྒྱ་སྦྲེལ་མཐུད་བྱེད་པ། Add hidden Wi-Fi - + སྦས་སྐུང་བྱས་པའི་Wi-Fiབསྣན་པ། Connection - + འབྲེལ་མཐུད་ Network name - + དྲ་རྒྱའི་མིང་། Wi-Fi security - + Wi-Fiབདེ་འཇགས། Authentication - + བདེན་དཔང་ར་སྤྲོད་ Anonymous identity - + མིང་མ་བཀོད་པའི་ཐོབ་ཐང Allow automatic PAC pro_visioning - + རང་འགུལ་གྱིས་PACའགོ་pro_visioning་བྱས་ཆོག། PAC file - + PACཡིག་ཆ། Inner authentication - + ནང་ཁུལ་གྱི་བདེན་དཔང་ར་སྤྲོད། Username - + སྤྱོད་མཁན་གྱི་མིང་། Password - + གསང་གྲངས། Cancel - + ཕྱིར་འཐེན། Connect - + སྦྲེལ་མཐུད་བྱེད་པ C_reate… - + C_reate… None - + གཅིག་ཀྱང་མེད། WPA & WPA2 Personal - + WPA & WPA2 མི་སྒེར་ WEP 40/128-bit Key (Hex or ASCII) - + WEP 40/128-bit Key (Hex or ASCII) WEP 128-bit Passphrase - + WEP 128-bit Passprase Dynamic WEP (802.1X) - + འགུལ་རྣམ་གྱི་WEP (802.1X) WPA & WPA2 Enterprise - + WPA & WPA2 ཁེ་ལས། Tunneled TLS - + ཕུག་ལམ་གྱི་TLS Protected EAP (PEAP) - + སྲུང་སྐྱོབ་ཐོབ་པའི་EAP(PEAP) Anonymous - + མིང་མ་བཀོད་པའི་ Authenticated - + བདེན་དཔང་ར་སྤྲོད་བྱས། Both - + དེ་གཉིས་ཀ DlgConnHidWifiSecLeap Connect to Hidden Wi-Fi Network - + སྦས་སྐུང་བྱས་པའི་Wi-Fiདྲ་རྒྱ་སྦྲེལ་མཐུད་བྱེད་པ། Add hidden Wi-Fi - + སྦས་སྐུང་བྱས་པའི་Wi-Fiབསྣན་པ། Connection - + འབྲེལ་མཐུད་ Network name - + དྲ་རྒྱའི་མིང་། Wi-Fi security - + Wi-Fiབདེ་འཇགས། Authentication - + བདེན་དཔང་ར་སྤྲོད་ Username - + སྤྱོད་མཁན་གྱི་མིང་། Password - + གསང་གྲངས། Cancel - + ཕྱིར་འཐེན། Connect - + སྦྲེལ་མཐུད་བྱེད་པ C_reate… - + C_reate… None - + གཅིག་ཀྱང་མེད། WPA & WPA2 Personal - + WPA & WPA2 མི་སྒེར་ WEP 40/128-bit Key (Hex or ASCII) - + WEP 40/128-bit Key (Hex or ASCII) WEP 128-bit Passphrase - + WEP 128-bit Passprase Dynamic WEP (802.1X) - + འགུལ་རྣམ་གྱི་WEP (802.1X) WPA & WPA2 Enterprise - + WPA & WPA2 ཁེ་ལས། Tunneled TLS - + ཕུག་ལམ་གྱི་TLS Protected EAP (PEAP) - + སྲུང་སྐྱོབ་ཐོབ་པའི་EAP(PEAP) DlgConnHidWifiSecPeap Connect to Hidden Wi-Fi Network - + སྦས་སྐུང་བྱས་པའི་Wi-Fiདྲ་རྒྱ་སྦྲེལ་མཐུད་བྱེད་པ། Add hidden Wi-Fi - + སྦས་སྐུང་བྱས་པའི་Wi-Fiབསྣན་པ། Connection - + འབྲེལ་མཐུད་ Network name - + དྲ་རྒྱའི་མིང་། Wi-Fi security - + Wi-Fiབདེ་འཇགས། Authentication - + བདེན་དཔང་ར་སྤྲོད་ Anonymous identity - + མིང་མ་བཀོད་པའི་ཐོབ་ཐང Domain - + ཁྱབ་ཁོངས། CA certificate - + CA དཔང་ཡིག CA certificate password - + CA དཔང་ཡིག་གི་གསང་གྲངས། No CA certificate is required - + CAལག་ཁྱེར་མི་དགོས། PEAP version - + PEAPཔར་གཞི། Inner authentication - + ནང་ཁུལ་གྱི་བདེན་དཔང་ར་སྤྲོད། Username - + སྤྱོད་མཁན་གྱི་མིང་། Password - + གསང་གྲངས། Cancel - + ཕྱིར་འཐེན། Connect - + སྦྲེལ་མཐུད་བྱེད་པ None - + གཅིག་ཀྱང་མེད། WPA & WPA2 Personal - + WPA & WPA2 མི་སྒེར་ WEP 40/128-bit Key (Hex or ASCII) - + WEP 40/128-bit Key (Hex or ASCII) WEP 128-bit Passphrase - + WEP 128-bit Passprase Dynamic WEP (802.1X) - + འགུལ་རྣམ་གྱི་WEP (802.1X) WPA & WPA2 Enterprise - + WPA & WPA2 ཁེ་ལས། Tunneled TLS - + ཕུག་ལམ་གྱི་TLS Protected EAP (PEAP) - + སྲུང་སྐྱོབ་ཐོབ་པའི་EAP(PEAP) Choose from file - + ཡིག་ཆའི་ནང་ནས་གདམ་གསེས་ Automatic - + རང་འགུལ་གྱིས་རང་ Version 0 - + པར་གཞི་0 Version 1 - + པར་གཞི་དང་པོ། DlgConnHidWifiSecPwd Connect to Hidden Wi-Fi Network - + སྦས་སྐུང་བྱས་པའི་Wi-Fiདྲ་རྒྱ་སྦྲེལ་མཐུད་བྱེད་པ། Add hidden Wi-Fi - + སྦས་སྐུང་བྱས་པའི་Wi-Fiབསྣན་པ། Connection - + འབྲེལ་མཐུད་ Network name - + དྲ་རྒྱའི་མིང་། Wi-Fi security - + Wi-Fiབདེ་འཇགས། Authentication - + བདེན་དཔང་ར་སྤྲོད་ Username - + སྤྱོད་མཁན་གྱི་མིང་། Password - + གསང་གྲངས། Cancel - + ཕྱིར་འཐེན། Connect - + སྦྲེལ་མཐུད་བྱེད་པ C_reate… - + C_reate… None - + གཅིག་ཀྱང་མེད། WPA & WPA2 Personal - + WPA & WPA2 མི་སྒེར་ WEP 40/128-bit Key (Hex or ASCII) - + WEP 40/128-bit Key (Hex or ASCII) WEP 128-bit Passphrase - + WEP 128-bit Passprase Dynamic WEP (802.1X) - + འགུལ་རྣམ་གྱི་WEP (802.1X) WPA & WPA2 Enterprise - + WPA & WPA2 ཁེ་ལས། Tunneled TLS - + ཕུག་ལམ་གྱི་TLS Protected EAP (PEAP) - + སྲུང་སྐྱོབ་ཐོབ་པའི་EAP(PEAP) DlgConnHidWifiSecTls Connect to Hidden Wi-Fi Network - + སྦས་སྐུང་བྱས་པའི་Wi-Fiདྲ་རྒྱ་སྦྲེལ་མཐུད་བྱེད་པ། Add hidden Wi-Fi - + སྦས་སྐུང་བྱས་པའི་Wi-Fiབསྣན་པ། Connection - + འབྲེལ་མཐུད་ Network name - + དྲ་རྒྱའི་མིང་། Wi-Fi security - + Wi-Fiབདེ་འཇགས། Authentication - + བདེན་དཔང་ར་སྤྲོད་ Identity - + ཐོབ་ཐང་། Domain - + ཁྱབ་ཁོངས། CA certificate - + CA དཔང་ཡིག CA certificate password - + CA དཔང་ཡིག་གི་གསང་གྲངས། No CA certificate is required - + CAལག་ཁྱེར་མི་དགོས། User certificate - + སྤྱོད་མཁན་གྱི་ལག་ཁྱེར། User certificate password - + སྤྱོད་མཁན་གྱི་ལག་ཁྱེར་གྱི་གསང་ User private key - + སྤྱོད་མཁན་གྱི་སྒེར་གྱི་ལྡེ་མིག User key password - + སྤྱོད་མཁན་གྱི་ལྡེ་མིག་གི་གསང་ Cancel - + ཕྱིར་འཐེན། Connect - + སྦྲེལ་མཐུད་བྱེད་པ C_reate… - + C_reate… None - + གཅིག་ཀྱང་མེད། WPA & WPA2 Personal - + WPA & WPA2 མི་སྒེར་ WEP 40/128-bit Key (Hex or ASCII) - + WEP 40/128-bit Key (Hex or ASCII) WEP 128-bit Passphrase - + WEP 128-bit Passprase Dynamic WEP (802.1X) - + འགུལ་རྣམ་གྱི་WEP (802.1X) WPA & WPA2 Enterprise - + WPA & WPA2 ཁེ་ལས། Tunneled TLS - + ཕུག་ལམ་གྱི་TLS Protected EAP (PEAP) - + སྲུང་སྐྱོབ་ཐོབ་པའི་EAP(PEAP) Choose from file - + ཡིག་ཆའི་ནང་ནས་གདམ་གསེས་ DlgConnHidWifiSecTunnelTLS Connect to Hidden Wi-Fi Network - + སྦས་སྐུང་བྱས་པའི་Wi-Fiདྲ་རྒྱ་སྦྲེལ་མཐུད་བྱེད་པ། Add hidden Wi-Fi - + སྦས་སྐུང་བྱས་པའི་Wi-Fiབསྣན་པ། Connection - + འབྲེལ་མཐུད་ Network name - + དྲ་རྒྱའི་མིང་། Wi-Fi security - + Wi-Fiབདེ་འཇགས། Authentication - + བདེན་དཔང་ར་སྤྲོད་ Anonymous identity - + མིང་མ་བཀོད་པའི་ཐོབ་ཐང Domain - + ཁྱབ་ཁོངས། CA certificate - + CA དཔང་ཡིག CA certificate password - + CA དཔང་ཡིག་གི་གསང་གྲངས། No CA certificate is required - + CAལག་ཁྱེར་མི་དགོས། Inner authentication - + ནང་ཁུལ་གྱི་བདེན་དཔང་ར་སྤྲོད། Username - + སྤྱོད་མཁན་གྱི་མིང་། Password - + གསང་གྲངས། Cancel - + ཕྱིར་འཐེན། Connect - + སྦྲེལ་མཐུད་བྱེད་པ C_reate… - + C_reate… None - + གཅིག་ཀྱང་མེད། WPA & WPA2 Personal - + WPA & WPA2 མི་སྒེར་ WEP 40/128-bit Key (Hex or ASCII) - + WEP 40/128-bit Key (Hex or ASCII) WEP 128-bit Passphrase - + WEP 128-bit Passprase Dynamic WEP (802.1X) - + འགུལ་རྣམ་གྱི་WEP (802.1X) WPA & WPA2 Enterprise - + WPA & WPA2 ཁེ་ལས། Tunneled TLS - + ཕུག་ལམ་གྱི་TLS Protected EAP (PEAP) - + སྲུང་སྐྱོབ་ཐོབ་པའི་EAP(PEAP) Choose from file - + ཡིག་ཆའི་ནང་ནས་གདམ་གསེས་ DlgConnHidWifiWep Connect to Hidden Wi-Fi Network - + སྦས་སྐུང་བྱས་པའི་Wi-Fiདྲ་རྒྱ་སྦྲེལ་མཐུད་བྱེད་པ། Add hidden Wi-Fi - + སྦས་སྐུང་བྱས་པའི་Wi-Fiབསྣན་པ། Connection - + འབྲེལ་མཐུད་ Network name - + དྲ་རྒྱའི་མིང་། Wi-Fi security - + Wi-Fiབདེ་འཇགས། Key - + ལྡེ་མིག WEP index - + WEPསྟོན་གྲངས། Authentication - + བདེན་དཔང་ར་སྤྲོད་ Cancel - + ཕྱིར་འཐེན། Connect - + སྦྲེལ་མཐུད་བྱེད་པ C_reate… - + C_reate… None - + གཅིག་ཀྱང་མེད། WPA & WPA2 Personal - + WPA & WPA2 མི་སྒེར་ WEP 40/128-bit Key (Hex or ASCII) - + WEP 40/128-bit Key (Hex or ASCII) WEP 128-bit Passphrase - + WEP 128-bit Passprase Dynamic WEP (802.1X) - + འགུལ་རྣམ་གྱི་WEP (802.1X) WPA & WPA2 Enterprise - + WPA & WPA2 ཁེ་ལས། 1(default) - + 1(default) Open System - + སྒོ་འབྱེད་མ་ལག Shared Key - + མཉམ་སྤྱོད་ཀྱི་ལྡེ་མིག DlgConnHidWifiWpa Connect to Hidden Wi-Fi Network - + སྦས་སྐུང་བྱས་པའི་Wi-Fiདྲ་རྒྱ་སྦྲེལ་མཐུད་བྱེད་པ། Add Hidden Wi-Fi - + སྦས་སྐུང་བྱས་པའི་Wi-Fiབསྣན་པ། Connection - + འབྲེལ་མཐུད་ Wi-Fi name - + Wi-Fiཡི་མིང་། Wi-Fi security - + Wi-Fiབདེ་འཇགས། Password - + གསང་གྲངས། Cancel - + ཕྱིར་འཐེན། Connect - + སྦྲེལ་མཐུད་བྱེད་པ C_reate… - + C_reate… None - + གཅིག་ཀྱང་མེད། WPA & WPA2 Personal - + WPA & WPA2 མི་སྒེར་ + + + WEP 40/128-bit Key (Hex or ASCII) + WEP 40/128 位密钥(十六进制或ASCII) + + + WEP 128-bit Passphrase + WEP 128 位密码句 + + + Dynamic WEP (802.1X) + 动态 WEP (802.1x) + + + WPA & WPA2 Enterprise + WPA 及 WPA2 企业 DlgHotspotCreate Dialog - + གླེང་མོལ། Create Hotspot - + ཚ་བ་ཆེ་བའི་ས་ཆ་གསར་སྐྲུན་ Network name - + དྲ་རྒྱའི་མིང་། Wi-Fi security - + Wi-Fiབདེ་འཇགས། Password - + གསང་གྲངས། Cancel - + ཕྱིར་འཐེན། Ok - + འགྲིགས། None - + གཅིག་ཀྱང་མེད། WPA & WPA2 Personal - - - - - EngineDevice - - yes - - - - no - - - - Yes - - - - No - - - - %1% available, charged - - - - Left %1h %2m (%3%) - - - - %1% available - - - - Left %1h %2m to full - - - - charging (%1%) - - - - %1 waiting to discharge (%2%) - - - - %1 waiting to charge (%2%) - - - - AC adapter - - - - Laptop battery - - - - UPS - - - - Monitor - - - - Mouse - - - - Keyboard - - - - PDA - - - - Cell phone - - - - Media player - - - - Tablet - - - - Computer - - - - unrecognised - + WPA & WPA2 མི་སྒེར་ IconEdit OK - གཏན་འཁེལ་བྱེད་པ། + སྤྲོད་དགོས། InputInfos - - Get code - - - - Recapture(60s) - - - - Recapture(%1s) - - Service exception... - + ཞབས་ཞུའི་དམིགས་བསལ་ ... Invaild parameters... - + གོ་མི་ཐུབ་པའི་གྲངས་ཀ་ ... Unknown fault:%1 - + ཤེས་མེད་པའི་ནོར་འཛོལ། %1 + + + Recapture(60s) + ཕྱིར་ལེན་པ།(60s) + + + Recapture(%1s) + ཕྱིར་ལེན་པ།(%1s) + + + Get code + ཚབ་རྟགས་ཐོབ་པ། + + + + KeyboardWidget + + KeyboardWidget + མཐེབ་གཞོང་Widget + + + + KylinDBus + + kylin network applet desktop message + 麒麟网络工具信息提示 KylinNM kylin-nm - - - - No usable network in the list - - - - HotSpot - - - - FlyMode - - - - Advanced - - - - Show KylinNM - - - - No wireless card detected - - - - Not connected - - - - Disconnected - - - - NetOn, - - - - No Other Wired Network Scheme - - - - No Other Wireless Network Scheme - - - - Wired net is disconnected - - - - Conn Ethernet Success - - - - Conn Ethernet Fail - - - - Conn Wifi Success - - - - Confirm your Wi-Fi password or usable of wireless card - - - - Inactivated LAN - + kylin-nm LAN - + ལན་ལན། - WLAN - + Enabel LAN List + 其他有线网络 - Activated LAN - + WiFi + 无线网络 - Activated WLAN - + Enabel WiFi List + 其他无线网络 + + + New WiFi + 加入其他网络 + + + Network + 网络 + + + Advanced + སྔོན་ཐོན་རང་བཞིན། + + + Ethernet + 有线网络 + + + Connect Hide Network + 加入网络 + + + Wifi + 无线网络 + + + Enabled + 已开启 + + + Disabled + 已关闭 + + + HotSpot + ཚ་བ་ཆེ་བ། + + + FlyMode + འཕུར་སྐྱོད་འཕྲུལ་འཁོར། + + + Show MainWindow + 显示网络连接界面 + + + Inactivated LAN + འགུལ་སྐྱོད་མ་བྱས་པའི་LAN + + + Inactivated WLAN + 未激活 Other WLAN - + WLAN གཞན་དག + + + WLAN + སྐུད་མེད་ཅུས་ཁོངས་ཀྱི་དྲ་བ། + + + Show KylinNM + ཅིན་ལིན་ནའེ་མུའུ་ལ་བསྟན་དོན། + + + No wireless card detected + སྐུད་མེད་བྱང་བུ་མ་རྙེད་པ། + + + Activated LAN + འགུལ་སྐྱོད་བྱས་པའི་LAN + + + Activated WLAN + འགུལ་སྐྱོད་བྱས་པའི་WLAN + + + Not connected + འབྲེལ་མཐུད་མི་བྱེད་པ། + + + Disconnected + འབྲེལ་ཐག་ཆད་པ། + + + No Other Wired Network Scheme + སྐུད་ཡོད་བརྙན་འཕྲིན་དྲ་བའི་འཆར་གཞི་གཞན་དག་མེད + + + Edit + 编辑 + + + Done + 完成 + + + No wifi connected. + 未连接任何网络 + + + No Other Wireless Network Scheme + སྐུད་མེད་དྲ་རྒྱའི་འཆར་གཞི་གཞན་དག་མེད། + + + Wired net is disconnected + སྐུད་ཡོད་དྲ་རྒྱ་ཆད་པ། + + + Wi-Fi is disconnected + 断开无线网络 + + + Confirm your Wi-Fi password or usable of wireless card + ཁྱོད་ཀྱི་Wi-Fiཡི་གསང་གྲངས་སམ་ཡང་ན་སྐུད་མེད་བྱང་བུ་བཀོལ་སྤྱོད་བྱེད་ཆོག་པ་ར་སྤྲོད + + + Ethernet Networks + 其他有线网络 + + + New LAN + 新建有线网络 + + + Hide WiFi + 加入网络 + + + No usable network in the list + མིང་ཐོའི་ནང་དུ་སྤྱོད་གོ་ཆོད་པའི་དྲ་རྒྱ་མེད། + + + NetOn, + དྲ་རྒྱ་དང་། + + + Wifi Networks + 其他无线网络 + + + None + + + + keep wired network switch is on before turning on wireless switch + 打开无线网开关前保持有线网开关打开 + + + please insert the wireless network adapter + 请先插入无线网卡 + + + Abnormal connection exist, program will delete it + 正在断开异常连接的网络 + + + update Wi-Fi list now, click again + 正在更新 Wi-Fi列表 请再次点击 + + + update Wi-Fi list now + 正在更新 Wi-Fi列表 + + + Conn Ethernet Success + Conn Ethernetལེགས་འགྲུབ་བྱུང་བ། + + + Conn Ethernet Fail + ཁུང་ནེ་ཨེ་ཐེ་ནའེ་ལ་ཕམ་ཉེས་བྱུང་བ། + + + Conn Wifi Success + ཁུང་ནེ་ཝེ་ཧྥེ་ལེགས་འགྲུབ་བྱུང་བ། LettersWidget + &&?! + 123 + + LightDMHelper + + + failed to start session. + + + + + Login + ཐོ་འགོད་བྱེད་པ། + + + + Guest + 游客 + + LockWidget Date - དུས་ཚོད། - - - Form - ནས་འོང་བ། + དུས་ཚོད། Time - དུས་ཚོད། + དུས་ཚོད། Guest - མགྲོན་པོ། + 游客 SwitchUser - བཀོལ་མི་བརྗེ་བ། - - - Multiple users are logged in at the same time.Are you sure you want to reboot this system? - སྤྱོད་མཁན་མང་པོ་ཞིག་དུས་གཅིག་ཏུ་ཐོ་འགོད་བྱས་པ་རེད། ཁྱོད་ཀྱིས་མ་ལག་འདི་བསྐྱར་དུ་སྒྲིག་རྒྱུ་ཡིན་ནམ - - - LAN - - - - WLAN - - - - PowerInfo - + སྤྱོད་མཁན་བརྗེ་དགོས། Power - གློག་ཁུངས། + གློག་ཁུངས། VirtualKeyboard - རྟོག་བཟོའི་མཐེབ་གཞོང་། + རྟོག་བཟོའི་མཐེབ་གཞོང་། + + + Multiple users are logged in at the same time.Are you sure you want to reboot this system? + སྤྱོད་མཁན་མང་པོ་ཞིག་དུས་གཅིག་ཏུ་ཐོ་འགོད་བྱས་པ་རེད། ཁྱོད་ཀྱིས་མ་ལག་འདི་བསྐྱར་དུ་སྒྲིག་རྒྱུ་ཡིན་ནམ། + + + LAN + སྐུད་ཡོད་དྲ་བ། + + + WLAN + སྐུད་མེད་ཅུས་ཁོངས་ཀྱི་དྲ་བ། LoginOptionsWidget Login Options - - - - Identify device removed! - + ཐོ་འགོད་ཀྱི་བསལ་འདེམས་ཀྱི་དབང་ཆ། Password - + གསང་གྲངས། Other - + གཞན་དག + + + Wechat + 微信 + + + Identify device removed! + དབྱེ་འབྱེད་སྒྲིག་ཆས་མེད་པར་བཟོ་དགོས། MyLineEdit Verification code + ཞིབ་བཤེར་གྱི་ཚབ་རྟགས། + + + + MyNetworkWidget + + + LAN + + + WLAN + སྐུད་མེད་ཅུས་ཁོངས་ཀྱི་དྲ་བ། + NumbersWidget + &&?! + Return - + ཕྱིར་ལོག་པ། OneConnForm Form - ནས་འོང་བ། - - - Connect - - - - Disconnect - - - - Input Password... - + རྣམ་པ། Automatically join the network - + རང་འགུལ་གྱིས་དྲ་རྒྱའི་ནང་དུ་ཞུགས་པ། + + + Input password + 输入密码 + + + Config + 设置 + + + Connect + སྦྲེལ་མཐུད་བྱེད་པ + + + Disconnect + འབྲེལ་ཐག་ཆད་པ། + + + Input Password... + ནང་འཇུག་གི་གསང་གྲངས་ Connect to Hidden Wi-Fi Network - - - - None - - - - WiFi Security: - + སྦས་སྐུང་བྱས་པའི་Wi-Fiདྲ་རྒྱ་སྦྲེལ་མཐུད་བྱེད་པ། Signal: - + བརྡ་རྟགས་ནི། + + + Public + 开放 + + + Safe + 安全 + + + Rate + 速率 + + + None + གཅིག་ཀྱང་མེད། + + + WiFi Security: + WiFiབཀོལ་སྤྱོད་བདེ་འཇགས་ནི། MAC: - + MAC: Conn Wifi Failed - + ཁུང་ནེ་ཝེ་ཧྥེ་ཕམ་སོང་། OneLancForm Form - ནས་འོང་བ། + རྣམ་པ། + + + Config + 设置 Connect - + སྦྲེལ་མཐུད་བྱེད་པ Disconnect - + འབྲེལ་ཐག་ཆད་པ། No Configuration - + བཀོད་སྒྲིག་བྱས་མེད་པ། IPv4: - + IPv4: IPv6: - + IPv6: BandWidth: - + 带宽: MAC: - + MAC: + + + Auto + 自动 PhoneAuthWidget Verification by phoneNum - + ཁ་པར་གྱི་ནུའུ་མུའུ་ཡིས་ཞིབ་བཤེར་བྱས། 「 Use bound Phone number to verification 」 - - - - commit - + 「ས་མཚམས་ཀྱི་ཁ་པར་ཨང་གྲངས་ལ་བརྟེན་ནས་ཞིབ་བཤེར་བྱ་དགོས།」 「 Use SMS to verification 」 - + 「SMSབཀོལ་ནས་ཞིབ་བཤེར་བྱ་དགོས།」 + + + commit + བསྒྲུབ་རྒྱུ་ཁས་ལེན་ Network not connected~ - - - - Verification Code invalid! - - - - Verification Code incorrect.Please retry! - - - - Failed time over limit!Retry after 1 hour! - - - - verifaction failed! - + དྲ་རྒྱ་དང་འབྲེལ་མཐུད་མི་བྱེད་པ Network unavailable~ + དྲ་རྒྱ་སྤྱོད་མི་ཐུབ་པ~ + + + Verification Code invalid! + ཞིབ་བཤེར་ཚད་གཞི་གོ་མི་ཆོད་པ་རེད། + + + Verification Code incorrect.Please retry! + ཞིབ་བཤེར་ཚད་གཞི་ཡང་དག་མིན་པ། ཁྱེད་ཀྱིས་ཡང་བསྐྱར་ཐེངས་གཅིག་ལ་བསྐྱར་དུ་ཞིབ + + + Failed time over limit!Retry after 1 hour! + ཚད་ལས་བརྒལ་ནས་ཕམ་ཁ་བྱུང་བའི་དུས་ཚོད་ ཆུ་ཚོད་1འགོར་རྗེས་ཡང་བསྐྱར་ཞིབ་བཤེར་བྱ་དགོས། + + + verifaction failed! + ངོ་རྒོལ་བྱེད་པའི་བྱ་སྤྱོད་ལ་ཕམ་ཉེས་བྱུང་བ་རེད། + + + + PowerListWidget + + + Hibernate + ཧིན་རྡུ་ཉི་ཞི་ཡ། + + + + Turn off your computer, but the app stays open. When the computer is turned on, it can be restored to the state you left + གློག་ཀླད་ཀྱི་སྒོ་བརྒྱབ་ནས་བཀོལ་སྤྱོད་བྱེད་སྐབས་ཐོག་མཐའ་བར་གསུམ་དུ་རྣམ་པ་རྒྱུན་འཁྱོངས་བྱེད་ཐུབ། གློག་ཀླད་ཀྱི་ཁ་ཕྱེ་དུས་ཁྱོད་དང་ཁ་བྲལ་བའི་རྣམ་པ་སླར་གསོ་བྱེད་ཐུབ། + + + + Suspend + གནས་སྐབས་མཚམས་འཇོག་ + + + + + The computer stays on, but consumes less power. The app stays open and can quickly wake up and revert to where you left off + གློག་ཀླད་ཀྱི་ཁ་ཕྱེ་བའི་རྣམ་པ་རྒྱུན་འཁྱོངས་བྱས་མོད། འོན་ཀྱང་གློག་ཟད་ཚད་ཅུང་ཉུང་། ཉེར་སྤྱོད་ཚོགས་འདུའི་ཐོག་ཁ་ཕྱེ་ནས་མགྱོགས་མྱུར་ངང་གློག་ཀླད་དཀྲོགས་ཏེ་ཁྱོད་དང་ཁ་བྲལ་བའི་རྣམ་པ་སླར་གསོ་བྱེད་ཐུབ། + + + + Reboot + + + Power Off + གློག་ཆད་པ། + + + + Close all apps, and then shut down your computer + བཀོལ་སྤྱོད་ཡོད་ཚད་སྒོ་བརྒྱབ་ནས་གློག་ཀླད་སྒོ་རྒྱག་དགོས། + PowerManager - Sleep - མལ་གསོ། + lock + ཟྭ་རྒྱག་པ། - Log Out - རྩིས་ཐེམ་ནས་བསུབ་པ། + SwitchUser + 切换用户 + + + logout + 注销 + + + reboot + 重启 + + + shutdown + 关机 Lock Screen - བརྙན་ཡོལ་ཟྭ་རྒྱག།(_L) - - - Restart - བསྐྱར་སློང་། + 锁屏 Switch User - སྤྱོད་མཁན་བརྗེ་རེས། + 切换用户 - Suspend - འགེལ་འཇོག + Log Out + ཕྱིར་འཐེན་བྱ་དགོས། + + + Restart + ཡང་བསྐྱར་འགོ་འཛུགས་ Power Off - འཁོར་ཁ་རྒྱག་པ། - - - lock - - - - Shut Down - - - - Hibernate - + གློག་ཆད་པ། Close all apps, turn off your computer, and then turn your computer back on - སྤྱོད་སྒོ་ཡོད་ཚད་སྒོ་བརྒྱབ་ནས་གློག་ཀླད་སྒོ་རྒྱག་པ་དང་། དེ་ནས་ཡང་བསྐྱར་གློག་ཀླད་ཀྱི་ཁ་ཕྱེ་བ་རེད། + སྤྱོད་སྒོ་ཡོད་ཚད་སྒོ་བརྒྱབ་ནས་གློག་ཀླད་སྒོ་རྒྱག་པ་དང་། དེ་ནས་ཡང་བསྐྱར་གློག་ཀླད་ཀྱི་ཁ་ཕྱེ་བ་རེད། Close all apps, and then shut down your computer - བཀོལ་སྤྱོད་ཡོད་ཚད་སྒོ་བརྒྱབ་ནས་གློག་ཀླད་སྒོ་རྒྱག་དགོས། + བཀོལ་སྤྱོད་ཡོད་ཚད་སྒོ་བརྒྱབ་ནས་གློག་ཀླད་སྒོ་རྒྱག་དགོས། + + + Shut Down + ལས་མཚམས་འཇོག Turn off your computer, but the app stays open. When the computer is turned on, it can be restored to the state you left - གློག་ཀླད་ཀྱི་སྒོ་བརྒྱབ་ནས་བཀོལ་སྤྱོད་བྱེད་སྐབས་ཐོག་མཐའ་བར་གསུམ་དུ་རྣམ་པ་རྒྱུན་འཁྱོངས་བྱེད་ཐུབ། གློག་ཀླད་ཀྱི་ཁ་ཕྱེ་དུས་ཁྱོད་དང་ཁ་བྲལ་བའི་རྣམ་པ་སླར་གསོ་བྱེད་ཐུབ། + གློག་ཀླད་ཀྱི་སྒོ་བརྒྱབ་ནས་བཀོལ་སྤྱོད་བྱེད་སྐབས་ཐོག་མཐའ་བར་གསུམ་དུ་རྣམ་པ་རྒྱུན་འཁྱོངས་བྱེད་ཐུབ། གློག་ཀླད་ཀྱི་ཁ་ཕྱེ་དུས་ཁྱོད་དང་ཁ་བྲལ་བའི་རྣམ་པ་སླར་གསོ་བྱེད་ཐུབ། + + + Hibernate + ཧིན་རྡུ་ཉི་ཞི་ཡ། The computer stays on, but consumes less power. The app stays open and can quickly wake up and revert to where you left off - གློག་ཀླད་ཀྱི་ཁ་ཕྱེ་བའི་རྣམ་པ་རྒྱུན་འཁྱོངས་བྱས་མོད། འོན་ཀྱང་གློག་ཟད་ཚད་ཅུང་ཉུང་། ཉེར་སྤྱོད་ཚོགས་འདུའི་ཐོག་ཁ་ཕྱེ་ནས་མགྱོགས་མྱུར་ངང་གློག་ཀླད་དཀྲོགས་ཏེ་ཁྱོད་དང་ཁ་བྲལ་བའི་རྣམ་པ་སླར་གསོ་བྱེད་ཐུབ། + གློག་ཀླད་ཀྱི་ཁ་ཕྱེ་བའི་རྣམ་པ་རྒྱུན་འཁྱོངས་བྱས་མོད། འོན་ཀྱང་གློག་ཟད་ཚད་ཅུང་ཉུང་། ཉེར་སྤྱོད་ཚོགས་འདུའི་ཐོག་ཁ་ཕྱེ་ནས་མགྱོགས་མྱུར་ངང་གློག་ཀླད་དཀྲོགས་ཏེ་ཁྱོད་དང་ཁ་བྲལ་བའི་རྣམ་པ་སླར་གསོ་བྱེད་ཐུབ། + + + Suspend + གནས་སྐབས་མཚམས་འཇོག་ + + + Sleep + 休眠 QObject - The screensaver is inactive. - འཆར་ངོས་སྲུང་སྐྱོབ་བྱ་རིམ་སད་མི་འདུག - - + The screensaver is active. - འཆར་ངོས་སྲུང་སྐྱོབ་བྱ་རིམ་སད་འདུག + བརྙན་ཤེལ་འདི་འགུལ་སྐྱོད་བྱེད་བཞིན་ཡོད། - - - S: - - tablet device - + + The screensaver is inactive. + བརྙན་ཤེལ་འདི་ལ་ནུས་པ་མེད། Screensaver - Automatic switching - རང་འགུལ་བརྗེ་སྤོར། + exit(Esc) + 退出(Esc) + exit + 退出 + + + Picture does not exist - པར་རིས་མི་འདུག + རི་མོ་མི་གནས་པ། Set as desktop wallpaper - ཅོག་ངོས་ཀྱི་གདོང་ཤོག་ཏུ་འཇོག་པ། + 设置为桌面壁纸 - View - + Automatic switching + 自动切换 + + + You have %1 unread message + 您有%1条未读消息 You have new notification - + ཁྱེད་ཚོར་བརྡ་ཐོ་གསར་པ་ཡོད། + + + + View + ལྟ་ཚུལ། SleepTime - You have rested: - ཁྱེད་ཀྱིས་ ལ་ངལ་གསོས་ཟིན། + + You have rested + ཁྱེད་ཚོས་ངལ་གསོ་བྱས་ཟིན་པ་གཤམ་གསལ། - You have rested - + You have rested: + ཁྱེད་ཚོས་ངལ་གསོ་བྱས་ཟིན་པ་གཤམ་གསལ། SureWindow Form - ནས་འོང་བ། + རྣམ་པ། TextLabel - + ཡི་གེ་ལ་པེར་གྱིས་བཤད་རྒྱུར Cancel - + ཕྱིར་འཐེན། Confirm - + གཏན་འཁེལ་བྱ་དགོས། - The following program is running to prevent the system from reboot! - - - - The following program is running to prevent the system from shutting down! - + Multiple users are logged in at the same time.Are you sure you want to reboot this system? + 同时有多个用户登录系统,您确定要退出系统吗? The following program is running to prevent the system from suspend! - + གཤམ་གྱི་གོ་རིམ་ནི་མ་ལག་གནས་སྐབས་མཚམས་འཇོག་པར་བཀག་འགོག་བྱེད་པའི་ཆེད་དུ་ཡིན། The following program is running to prevent the system from hibernate! - + གཤམ་གྱི་གོ་རིམ་ནི་མ་ལག་ལ་བཀག་འགོག་བྱེད་པའི་ཆེད་དུ་ཡིན། + + + The following program is running to prevent the system from shutting down! + གཤམ་གྱི་གོ་རིམ་ནི་མ་ལག་གི་སྒོ་རྒྱག་པར་བཀག་འགོག་བྱེད་པའི་ཆེད་དུ་ཡིན། + + + The following program is running to prevent the system from reboot! + གཤམ་གྱི་གོ་རིམ་ནི་མ་ལག་བསྐྱར་དུ་འབྱུང་བར་སྔོན་འགོག་བྱེད་ཆེད་ཡིན། + + + + SwitchButton + + login by password + 密码登录 + + + login by qr code + 微信登录 SwitchButtonGroup uEduPWD - + uEduPWD Wechat - + འཕྲིན་ཕྲན། TabletLockWidget - Cancel - + You have %1 unread message + 您有%1条未读消息 - Back - - - - Skip - + Slide to unlock + 向上滑动解锁 New password is the same as old - + གསང་གྲངས་གསར་པ་དང་རྙིང་པ་གཅིག་མཚུངས་ཡིན། Reset password error:%1 - + གསང་གྲངས་ཀྱི་ནོར་འཁྲུལ་བསྐྱར་དུ་བཀོད་སྒྲིག་བྱེད་པ།%1 Please scan by correct WeChat - + ཡང་དག་པའི་འཕྲིན་ཕྲན་ཐོག་ནས་ཞིབ་བཤེར་གནང་རོགས། + + + Cancel + ཕྱིར་འཐེན། + + + Back + ཕྱིར་ལོག་པ། + + + Skip + བྲོས་བྱོལ་དུ་སོང་བ། Utils kylin network applet desktop message - + kylinདྲ་རྒྱའི་ཀུ་ཤུའི་ཅོག་ཙེའི་ཆ་འཕྲིན། VerificationWidget Please scan by bound WeChat - + འཕྲིན་ཕྲན་གྱིས་ཞིབ་བཤེར་བྱེད་རོགས། VerticalVerificationWidget Please scan by bound WeChat - + འཕྲིན་ཕྲན་གྱིས་ཞིབ་བཤེར་བྱེད་རོགས། WeChatAuthDialog Login by wechat - - - - 「 Use registered WeChat account to login 」 - + ཝེ་ཆི་ཐེས་ཐོ་འགོད་བྱས་པ། Verification by wechat - + ཝེ་ཆི་ཐེས་ཞིབ་བཤེར་བྱས་པ། + + + 「 Use registered WeChat account to login 」 + 「ཐོ་འགོད་བྱས་ཟིན་པའི་སྐད་འཕྲིན་གྱི་ཐོ་ཁོངས་ལ་བརྟེན་ནས་ཐོ་འགོད་བྱེད་པ།」 「 Use bound WeChat account to verification 」 - + 「ཚོད་འཛིན་རང་བཞིན་གྱི་སྐད་འཕྲིན་ཨང་གྲངས་ལ་བརྟེན་ནས་ཞིབ་བཤེར་བྱ་དགོས།」 Network not connected~ - + དྲ་རྒྱ་དང་འབྲེལ་མཐུད་མི་བྱེད་པ Scan code successfully - + ཞིབ་བཤེར་ཨང་གྲངས་ལེགས་འགྲུབ་བྱུང་བ། Timeout!Try again! - - - - - Widget - - Widget - + དུས་ཚོད་ཕྱིར་འགོར་སོང་། ཡང་བསྐྱར་ཚོད་ལྟ།! - LoadPlugin - + Login failed + 登录失败 delay + how long to show lock @@ -1918,6 +2241,7 @@ has-lock + if show lock @@ -1925,68 +2249,97 @@ main + Start command for the ukui ScreenSaver. - ཡོལ་སྒོའི་ཁ་འབྱེད་བཀའ་བརྡ། + ukui ScreenSaver ལ་བཀོད་འདོམས་བྱེད་འགོ་ཚུགས། + + + lock the screen immediately - མྱུར་དུ་འཆར་ངོས་ཀྱི་ཟྭ་རྒྱག་པ། + འཕྲལ་དུ་བརྙན་ཤེལ་ལ་ཟྭ་རྒྱག་པ། + query the status of the screen saver - འཆར་ངོས་ལ་ཟྭ་བརྒྱབ་པའི་གནས་ཚུལ་ལེན་པ། + བརྙན་ཤེལ་གསོག་འཇོག་བྱེད་མཁན་གྱི་གནས་ཚུལ་ལ་འདྲི་རྩད་བྱས། + unlock the screen saver - འཆར་ངོས་ཀྱི་ཟྭ་ཕྱེ་བ། - - - Screensaver for ukui-screensaver - - - - show on root window - - - - show on window. - - - - window id - + བརྙན་ཤེལ་གསོག་འཇོག་བྱེད་མཁན་ལ་སྒོ་འབྱེད་ + show the screensaver - - - - Dialog for the ukui ScreenSaver. - - - - activated by session idle signal - - - - lock the screen and show screensaver immediately - - - - show screensaver immediately - + བརྙན་ཤེལ་གྱི་བརྙན་ཤེལ་ལ་བལྟ་རུ་འཇུག་དགོས། + show blank and delay to lock,param:idle/lid/lowpower + + Dialog for the ukui ScreenSaver. + དབྱིན་ཇིའི་བརྙན་ཤེལ་གྱི་བརྙན་ཤེལ་ལ་ཁ་པར་རྒྱག་པའི་གླེང་མོལ། + + + + activated by session idle signal + སྐབས་འདིའི་ཁོམ་པའི་བརྡ་རྟགས་ཀྱིས་སྐུལ་སློང་བྱས་པ། + + + + + lock the screen and show screensaver immediately + བརྙན་ཤེལ་ལ་ཟྭ་བརྒྱབ་ནས་འཕྲལ་མར་བརྙན་ཤེལ་གྱི་བརྙན་ཤེལ་སྟོན་པ། + + + + show screensaver immediately + འཕྲལ་མར་བརྙན་ཤེལ་གྱི་བརྙན་ཤེལ་སྟོན་པ། + + + show blank screensaver immediately and delay time to show lock + show blank screensaver immediately and if lock + + + Screensaver for ukui-screensaver + དབྱིན་ཇིའི་བརྙན་ཤེལ་གྱི་བརྙན་ཤེལ་ལ་ལྟ་ཞིབ་བྱེད་མཁན། + + + + show on root window + རྩ་བའི་སྒེའུ་ཁུང་ནས་མངོན་པ། + + + + show on window. + སྒེའུ་ཁུང་ནས་མངོན་པ། + + + + window id + སྒེའུ་ཁུང་གི་ཐོབ་ཐང་ + + + + Backend for the ukui ScreenSaver. + + + + + lock the screen by startup + + diff --git a/i18n_ts/es.ts b/i18n_ts/es.ts index c6eb0fb..2fedd11 100644 --- a/i18n_ts/es.ts +++ b/i18n_ts/es.ts @@ -46,18 +46,6 @@ Authentication failure, Please try again - - Please try again in %1 minutes. - - - - Please try again in %1 seconds. - - - - Account locked permanently. - - Password cannot be empty @@ -67,80 +55,13 @@ - Verify face recognition or enter password to unlock - - - - Press fingerprint or enter password to unlock - - - - Verify voiceprint or enter password to unlock - - - - Verify finger vein or enter password to unlock - - - - Verify iris or enter password to unlock - - - - Failed to verify %1, you still have %2 verification opportunities - - - - Use the bound wechat scanning code or enter the password to unlock - - - - Failed to verify %1, please enter password to unlock - - - - Unable to verify %1, please enter password to unlock + Password Input Password - - Abnormal network - - - - Enter the ukey password - - - - Insert the ukey into the USB port - - - - Password: - - - - - BatteryWidget - - Charging... - - - - fully charged - - - - PowerMode - - - - BatteryMode - - BioAuthWidget @@ -207,36 +128,6 @@ Nombre del dispositivo: - - BiometricAuthWidget - - Current device: - - - - Identify failed, Please retry. - - - - - BiometricDevicesWidget - - Please select the biometric device - - - - Device type: - - - - Device name: - - - - OK - - - CharsMoreWidget @@ -259,1159 +150,83 @@ - - ConfForm - - edit network - - - - LAN name: - - - - Method: - - - - Address: - - - - Netmask: - - - - Gateway: - - - - DNS 1: - - - - DNS 2: - - - - Edit Conn - - - - Auto(DHCP) - - - - Manual - - - - Cancel - - - - Save - - - - Ok - - - - Can not create new wired network for without wired card - - - - New network already created - - - - New network settings already finished - - - - New settings already effective - - - - Edit Network - - - - Add Wired Network - - - DeviceType FingerPrint - Huella dactilar + Huella dactilar FingerVein - FingerVein + FingerVein Iris - Iris + Iris Face - Cara + Cara VoicePrint - Impresión de voz - - - QRCode - - - - Ukey - - - - - DigitalAuthDialog - - LoginByUEdu - - - - ResetPWD? - - - - SetNewUEduPWD - - - - clear - - - - ConfirmNewUEduPWD - - - - The two password entries are inconsistent, please reset - - - - Password entered incorrectly, please try again - - - - - DlgConnHidWifi - - Connect to Hidden Wi-Fi Network - - - - Add Hidden Wi-Fi - - - - Connection - - - - Wi-Fi name - - - - Wi-Fi security - - - - Cancel - - - - Connect - - - - C_reate… - - - - None - - - - WPA & WPA2 Personal - + Impresión de voz DlgConnHidWifiLeap - - Connect to Hidden Wi-Fi Network - - - - Add hidden Wi-Fi - - - - Connection - - - - Network name - - - - Wi-Fi security - - - - Username - - Password - Contraseña - - - Cancel - - - - Connect - - - - C_reate… - - - - None - - - - WPA & WPA2 Personal - - - - WEP 40/128-bit Key (Hex or ASCII) - - - - WEP 128-bit Passphrase - - - - Dynamic WEP (802.1X) - - - - WPA & WPA2 Enterprise - + Contraseña DlgConnHidWifiSecFast - - Connect to Hidden Wi-Fi Network - - - - Add hidden Wi-Fi - - - - Connection - - - - Network name - - - - Wi-Fi security - - - - Authentication - - - - Anonymous identity - - - - Allow automatic PAC pro_visioning - - - - PAC file - - - - Inner authentication - - - - Username - - Password - Contraseña - - - Cancel - - - - Connect - - - - C_reate… - - - - None - - - - WPA & WPA2 Personal - - - - WEP 40/128-bit Key (Hex or ASCII) - - - - WEP 128-bit Passphrase - - - - Dynamic WEP (802.1X) - - - - WPA & WPA2 Enterprise - - - - Tunneled TLS - - - - Protected EAP (PEAP) - - - - Anonymous - - - - Authenticated - - - - Both - + Contraseña DlgConnHidWifiSecLeap - - Connect to Hidden Wi-Fi Network - - - - Add hidden Wi-Fi - - - - Connection - - - - Network name - - - - Wi-Fi security - - - - Authentication - - - - Username - - Password - Contraseña - - - Cancel - - - - Connect - - - - C_reate… - - - - None - - - - WPA & WPA2 Personal - - - - WEP 40/128-bit Key (Hex or ASCII) - - - - WEP 128-bit Passphrase - - - - Dynamic WEP (802.1X) - - - - WPA & WPA2 Enterprise - - - - Tunneled TLS - - - - Protected EAP (PEAP) - + Contraseña DlgConnHidWifiSecPeap - - Connect to Hidden Wi-Fi Network - - - - Add hidden Wi-Fi - - - - Connection - - - - Network name - - - - Wi-Fi security - - - - Authentication - - - - Anonymous identity - - - - Domain - - - - CA certificate - - - - CA certificate password - - - - No CA certificate is required - - - - PEAP version - - - - Inner authentication - - - - Username - - Password - Contraseña - - - Cancel - - - - Connect - - - - None - - - - WPA & WPA2 Personal - - - - WEP 40/128-bit Key (Hex or ASCII) - - - - WEP 128-bit Passphrase - - - - Dynamic WEP (802.1X) - - - - WPA & WPA2 Enterprise - - - - Tunneled TLS - - - - Protected EAP (PEAP) - - - - Choose from file - - - - Automatic - - - - Version 0 - - - - Version 1 - + Contraseña DlgConnHidWifiSecPwd - - Connect to Hidden Wi-Fi Network - - - - Add hidden Wi-Fi - - - - Connection - - - - Network name - - - - Wi-Fi security - - - - Authentication - - - - Username - - Password - Contraseña - - - Cancel - - - - Connect - - - - C_reate… - - - - None - - - - WPA & WPA2 Personal - - - - WEP 40/128-bit Key (Hex or ASCII) - - - - WEP 128-bit Passphrase - - - - Dynamic WEP (802.1X) - - - - WPA & WPA2 Enterprise - - - - Tunneled TLS - - - - Protected EAP (PEAP) - - - - - DlgConnHidWifiSecTls - - Connect to Hidden Wi-Fi Network - - - - Add hidden Wi-Fi - - - - Connection - - - - Network name - - - - Wi-Fi security - - - - Authentication - - - - Identity - - - - Domain - - - - CA certificate - - - - CA certificate password - - - - No CA certificate is required - - - - User certificate - - - - User certificate password - - - - User private key - - - - User key password - - - - Cancel - - - - Connect - - - - C_reate… - - - - None - - - - WPA & WPA2 Personal - - - - WEP 40/128-bit Key (Hex or ASCII) - - - - WEP 128-bit Passphrase - - - - Dynamic WEP (802.1X) - - - - WPA & WPA2 Enterprise - - - - Tunneled TLS - - - - Protected EAP (PEAP) - - - - Choose from file - + Contraseña DlgConnHidWifiSecTunnelTLS - - Connect to Hidden Wi-Fi Network - - - - Add hidden Wi-Fi - - - - Connection - - - - Network name - - - - Wi-Fi security - - - - Authentication - - - - Anonymous identity - - - - Domain - - - - CA certificate - - - - CA certificate password - - - - No CA certificate is required - - - - Inner authentication - - - - Username - - Password - Contraseña - - - Cancel - - - - Connect - - - - C_reate… - - - - None - - - - WPA & WPA2 Personal - - - - WEP 40/128-bit Key (Hex or ASCII) - - - - WEP 128-bit Passphrase - - - - Dynamic WEP (802.1X) - - - - WPA & WPA2 Enterprise - - - - Tunneled TLS - - - - Protected EAP (PEAP) - - - - Choose from file - - - - - DlgConnHidWifiWep - - Connect to Hidden Wi-Fi Network - - - - Add hidden Wi-Fi - - - - Connection - - - - Network name - - - - Wi-Fi security - - - - Key - - - - WEP index - - - - Authentication - - - - Cancel - - - - Connect - - - - C_reate… - - - - None - - - - WPA & WPA2 Personal - - - - WEP 40/128-bit Key (Hex or ASCII) - - - - WEP 128-bit Passphrase - - - - Dynamic WEP (802.1X) - - - - WPA & WPA2 Enterprise - - - - 1(default) - - - - Open System - - - - Shared Key - + Contraseña DlgConnHidWifiWpa - - Connect to Hidden Wi-Fi Network - - - - Add Hidden Wi-Fi - - - - Connection - - - - Wi-Fi name - - - - Wi-Fi security - - Password - Contraseña - - - Cancel - - - - Connect - - - - C_reate… - - - - None - - - - WPA & WPA2 Personal - + Contraseña DlgHotspotCreate - - Dialog - - - - Create Hotspot - - - - Network name - - - - Wi-Fi security - - Password - Contraseña - - - Cancel - - - - Ok - - - - None - - - - WPA & WPA2 Personal - - - - - EngineDevice - - yes - - - - no - - - - Yes - - - - No - - - - %1% available, charged - - - - Left %1h %2m (%3%) - - - - %1% available - - - - Left %1h %2m to full - - - - charging (%1%) - - - - %1 waiting to discharge (%2%) - - - - %1 waiting to charge (%2%) - - - - AC adapter - - - - Laptop battery - - - - UPS - - - - Monitor - - - - Mouse - - - - Keyboard - - - - PDA - - - - Cell phone - - - - Media player - - - - Tablet - - - - Computer - - - - unrecognised - - - - - IconEdit - - OK - - - - - InputInfos - - Get code - - - - Recapture(60s) - - - - Recapture(%1s) - - - - Service exception... - - - - Invaild parameters... - - - - Unknown fault:%1 - + Contraseña @@ -1421,101 +236,6 @@ TecladoWidget - - KylinNM - - kylin-nm - - - - No usable network in the list - - - - HotSpot - - - - FlyMode - - - - Advanced - - - - Show KylinNM - - - - No wireless card detected - - - - Not connected - - - - Disconnected - - - - NetOn, - - - - No Other Wired Network Scheme - - - - No Other Wireless Network Scheme - - - - Wired net is disconnected - - - - Conn Ethernet Success - - - - Conn Ethernet Fail - - - - Conn Wifi Success - - - - Confirm your Wi-Fi password or usable of wireless card - - - - Inactivated LAN - - - - LAN - - - - WLAN - - - - Activated LAN - - - - Activated WLAN - - - - Other WLAN - - - LettersWidget @@ -1527,19 +247,34 @@ + + LightDMHelper + + failed to start session. + + + + Login + + + + Guest + Huésped + + LockWidget Form - Formar + Formar Date - Fecha + Fecha Time - Hora + Hora Guest @@ -1547,12 +282,18 @@ SwitchUser - Cambiar de usuario + Cambiar de usuario + + + LoginOptionsWidget - Multiple users are logged in at the same time.Are you sure you want to reboot this system? - + Password + Contraseña + + + MyNetworkWidget LAN @@ -1561,44 +302,6 @@ WLAN - - PowerInfo - - - - Power - - - - VirtualKeyboard - - - - - LoginOptionsWidget - - Login Options - - - - Password - Contraseña - - - Identify device removed! - - - - Other - - - - - MyLineEdit - - Verification code - - NumbersWidget @@ -1615,124 +318,44 @@ OneConnForm Form - Formar - - - Connect - - - - Disconnect - - - - Input Password... - - - - Automatically join the network - - - - Connect to Hidden Wi-Fi Network - - - - None - - - - WiFi Security: - - - - Signal: - - - - MAC: - - - - Conn Wifi Failed - + Formar OneLancForm Form - Formar - - - Connect - - - - Disconnect - - - - No Configuration - - - - IPv4: - - - - IPv6: - - - - BandWidth: - - - - MAC: - + Formar - PhoneAuthWidget + PowerListWidget - Verification by phoneNum + Hibernate - 「 Use bound Phone number to verification 」 + Turn off your computer, but the app stays open. When the computer is turned on, it can be restored to the state you left - commit + Suspend - 「 Use SMS to verification 」 + The computer stays on, but consumes less power. The app stays open and can quickly wake up and revert to where you left off - Network not connected~ + Reboot - Verification Code invalid! + Power Off - Verification Code incorrect.Please retry! - - - - Failed time over limit!Retry after 1 hour! - - - - verifaction failed! - - - - Network unavailable~ + Close all apps, and then shut down your computer @@ -1742,50 +365,6 @@ SwitchUser Cambiar de usuario - - Log Out - - - - Power Off - - - - Suspend - - - - lock - - - - Shut Down - - - - Hibernate - - - - Restart - - - - Close all apps, turn off your computer, and then turn your computer back on - - - - Close all apps, and then shut down your computer - - - - Turn off your computer, but the app stays open. When the computer is turned on, it can be restored to the state you left - - - - The computer stays on, but consumes less power. The app stays open and can quickly wake up and revert to where you left off - - QObject @@ -1798,14 +377,6 @@ - - S: - - - tablet device - - - Screensaver @@ -1816,10 +387,6 @@ View - - You have new notification - - SleepTime @@ -1832,136 +399,11 @@ SureWindow Form - Formar + Formar TextLabel - TextLabel - - - Cancel - - - - Confirm - - - - The following program is running to prevent the system from reboot! - - - - The following program is running to prevent the system from shutting down! - - - - The following program is running to prevent the system from suspend! - - - - The following program is running to prevent the system from hibernate! - - - - - SwitchButtonGroup - - uEduPWD - - - - Wechat - - - - - TabletLockWidget - - Cancel - - - - Back - - - - Skip - - - - New password is the same as old - - - - Reset password error:%1 - - - - Please scan by correct WeChat - - - - - Utils - - kylin network applet desktop message - - - - - VerificationWidget - - Please scan by bound WeChat - - - - - VerticalVerificationWidget - - Please scan by bound WeChat - - - - - WeChatAuthDialog - - Login by wechat - - - - 「 Use registered WeChat account to login 」 - - - - Verification by wechat - - - - 「 Use bound WeChat account to verification 」 - - - - Network not connected~ - - - - Scan code successfully - - - - Timeout!Try again! - - - - - Widget - - Widget - - - - LoadPlugin - + TextLabel @@ -2044,5 +486,13 @@ show blank screensaver immediately and if lock + + Backend for the ukui ScreenSaver. + + + + lock the screen by startup + + diff --git a/i18n_ts/fr.ts b/i18n_ts/fr.ts index 7479a1f..d14fe7e 100644 --- a/i18n_ts/fr.ts +++ b/i18n_ts/fr.ts @@ -46,18 +46,6 @@ Authentication failure, Please try again - - Please try again in %1 minutes. - - - - Please try again in %1 seconds. - - - - Account locked permanently. - - Password cannot be empty @@ -67,80 +55,13 @@ - Verify face recognition or enter password to unlock - - - - Press fingerprint or enter password to unlock - - - - Verify voiceprint or enter password to unlock - - - - Verify finger vein or enter password to unlock - - - - Verify iris or enter password to unlock - - - - Failed to verify %1, you still have %2 verification opportunities - - - - Use the bound wechat scanning code or enter the password to unlock - - - - Failed to verify %1, please enter password to unlock - - - - Unable to verify %1, please enter password to unlock + Password Input Password - - Abnormal network - - - - Enter the ukey password - - - - Insert the ukey into the USB port - - - - Password: - - - - - BatteryWidget - - Charging... - - - - fully charged - - - - PowerMode - - - - BatteryMode - - BioAuthWidget @@ -207,36 +128,6 @@ Nom de l'appareil: - - BiometricAuthWidget - - Current device: - - - - Identify failed, Please retry. - - - - - BiometricDevicesWidget - - Please select the biometric device - - - - Device type: - - - - Device name: - - - - OK - - - CharsMoreWidget @@ -259,1159 +150,83 @@ - - ConfForm - - edit network - - - - LAN name: - - - - Method: - - - - Address: - - - - Netmask: - - - - Gateway: - - - - DNS 1: - - - - DNS 2: - - - - Edit Conn - - - - Auto(DHCP) - - - - Manual - - - - Cancel - - - - Save - - - - Ok - - - - Can not create new wired network for without wired card - - - - New network already created - - - - New network settings already finished - - - - New settings already effective - - - - Edit Network - - - - Add Wired Network - - - DeviceType FingerPrint - Empreinte digitale + Empreinte digitale FingerVein - FingerVein + FingerVein Iris - Iris + Iris Face - Visage + Visage VoicePrint - VoicePrint - - - QRCode - - - - Ukey - - - - - DigitalAuthDialog - - LoginByUEdu - - - - ResetPWD? - - - - SetNewUEduPWD - - - - clear - - - - ConfirmNewUEduPWD - - - - The two password entries are inconsistent, please reset - - - - Password entered incorrectly, please try again - - - - - DlgConnHidWifi - - Connect to Hidden Wi-Fi Network - - - - Add Hidden Wi-Fi - - - - Connection - - - - Wi-Fi name - - - - Wi-Fi security - - - - Cancel - - - - Connect - - - - C_reate… - - - - None - - - - WPA & WPA2 Personal - + VoicePrint DlgConnHidWifiLeap - - Connect to Hidden Wi-Fi Network - - - - Add hidden Wi-Fi - - - - Connection - - - - Network name - - - - Wi-Fi security - - - - Username - - Password - Mot de passe - - - Cancel - - - - Connect - - - - C_reate… - - - - None - - - - WPA & WPA2 Personal - - - - WEP 40/128-bit Key (Hex or ASCII) - - - - WEP 128-bit Passphrase - - - - Dynamic WEP (802.1X) - - - - WPA & WPA2 Enterprise - + Mot de passe DlgConnHidWifiSecFast - - Connect to Hidden Wi-Fi Network - - - - Add hidden Wi-Fi - - - - Connection - - - - Network name - - - - Wi-Fi security - - - - Authentication - - - - Anonymous identity - - - - Allow automatic PAC pro_visioning - - - - PAC file - - - - Inner authentication - - - - Username - - Password - Mot de passe - - - Cancel - - - - Connect - - - - C_reate… - - - - None - - - - WPA & WPA2 Personal - - - - WEP 40/128-bit Key (Hex or ASCII) - - - - WEP 128-bit Passphrase - - - - Dynamic WEP (802.1X) - - - - WPA & WPA2 Enterprise - - - - Tunneled TLS - - - - Protected EAP (PEAP) - - - - Anonymous - - - - Authenticated - - - - Both - + Mot de passe DlgConnHidWifiSecLeap - - Connect to Hidden Wi-Fi Network - - - - Add hidden Wi-Fi - - - - Connection - - - - Network name - - - - Wi-Fi security - - - - Authentication - - - - Username - - Password - Mot de passe - - - Cancel - - - - Connect - - - - C_reate… - - - - None - - - - WPA & WPA2 Personal - - - - WEP 40/128-bit Key (Hex or ASCII) - - - - WEP 128-bit Passphrase - - - - Dynamic WEP (802.1X) - - - - WPA & WPA2 Enterprise - - - - Tunneled TLS - - - - Protected EAP (PEAP) - + Mot de passe DlgConnHidWifiSecPeap - - Connect to Hidden Wi-Fi Network - - - - Add hidden Wi-Fi - - - - Connection - - - - Network name - - - - Wi-Fi security - - - - Authentication - - - - Anonymous identity - - - - Domain - - - - CA certificate - - - - CA certificate password - - - - No CA certificate is required - - - - PEAP version - - - - Inner authentication - - - - Username - - Password - Mot de passe - - - Cancel - - - - Connect - - - - None - - - - WPA & WPA2 Personal - - - - WEP 40/128-bit Key (Hex or ASCII) - - - - WEP 128-bit Passphrase - - - - Dynamic WEP (802.1X) - - - - WPA & WPA2 Enterprise - - - - Tunneled TLS - - - - Protected EAP (PEAP) - - - - Choose from file - - - - Automatic - - - - Version 0 - - - - Version 1 - + Mot de passe DlgConnHidWifiSecPwd - - Connect to Hidden Wi-Fi Network - - - - Add hidden Wi-Fi - - - - Connection - - - - Network name - - - - Wi-Fi security - - - - Authentication - - - - Username - - Password - Mot de passe - - - Cancel - - - - Connect - - - - C_reate… - - - - None - - - - WPA & WPA2 Personal - - - - WEP 40/128-bit Key (Hex or ASCII) - - - - WEP 128-bit Passphrase - - - - Dynamic WEP (802.1X) - - - - WPA & WPA2 Enterprise - - - - Tunneled TLS - - - - Protected EAP (PEAP) - - - - - DlgConnHidWifiSecTls - - Connect to Hidden Wi-Fi Network - - - - Add hidden Wi-Fi - - - - Connection - - - - Network name - - - - Wi-Fi security - - - - Authentication - - - - Identity - - - - Domain - - - - CA certificate - - - - CA certificate password - - - - No CA certificate is required - - - - User certificate - - - - User certificate password - - - - User private key - - - - User key password - - - - Cancel - - - - Connect - - - - C_reate… - - - - None - - - - WPA & WPA2 Personal - - - - WEP 40/128-bit Key (Hex or ASCII) - - - - WEP 128-bit Passphrase - - - - Dynamic WEP (802.1X) - - - - WPA & WPA2 Enterprise - - - - Tunneled TLS - - - - Protected EAP (PEAP) - - - - Choose from file - + Mot de passe DlgConnHidWifiSecTunnelTLS - - Connect to Hidden Wi-Fi Network - - - - Add hidden Wi-Fi - - - - Connection - - - - Network name - - - - Wi-Fi security - - - - Authentication - - - - Anonymous identity - - - - Domain - - - - CA certificate - - - - CA certificate password - - - - No CA certificate is required - - - - Inner authentication - - - - Username - - Password - Mot de passe - - - Cancel - - - - Connect - - - - C_reate… - - - - None - - - - WPA & WPA2 Personal - - - - WEP 40/128-bit Key (Hex or ASCII) - - - - WEP 128-bit Passphrase - - - - Dynamic WEP (802.1X) - - - - WPA & WPA2 Enterprise - - - - Tunneled TLS - - - - Protected EAP (PEAP) - - - - Choose from file - - - - - DlgConnHidWifiWep - - Connect to Hidden Wi-Fi Network - - - - Add hidden Wi-Fi - - - - Connection - - - - Network name - - - - Wi-Fi security - - - - Key - - - - WEP index - - - - Authentication - - - - Cancel - - - - Connect - - - - C_reate… - - - - None - - - - WPA & WPA2 Personal - - - - WEP 40/128-bit Key (Hex or ASCII) - - - - WEP 128-bit Passphrase - - - - Dynamic WEP (802.1X) - - - - WPA & WPA2 Enterprise - - - - 1(default) - - - - Open System - - - - Shared Key - + Mot de passe DlgConnHidWifiWpa - - Connect to Hidden Wi-Fi Network - - - - Add Hidden Wi-Fi - - - - Connection - - - - Wi-Fi name - - - - Wi-Fi security - - Password - Mot de passe - - - Cancel - - - - Connect - - - - C_reate… - - - - None - - - - WPA & WPA2 Personal - + Mot de passe DlgHotspotCreate - - Dialog - - - - Create Hotspot - - - - Network name - - - - Wi-Fi security - - Password - Mot de passe - - - Cancel - - - - Ok - - - - None - - - - WPA & WPA2 Personal - - - - - EngineDevice - - yes - - - - no - - - - Yes - - - - No - - - - %1% available, charged - - - - Left %1h %2m (%3%) - - - - %1% available - - - - Left %1h %2m to full - - - - charging (%1%) - - - - %1 waiting to discharge (%2%) - - - - %1 waiting to charge (%2%) - - - - AC adapter - - - - Laptop battery - - - - UPS - - - - Monitor - - - - Mouse - - - - Keyboard - - - - PDA - - - - Cell phone - - - - Media player - - - - Tablet - - - - Computer - - - - unrecognised - - - - - IconEdit - - OK - - - - - InputInfos - - Get code - - - - Recapture(60s) - - - - Recapture(%1s) - - - - Service exception... - - - - Invaild parameters... - - - - Unknown fault:%1 - + Mot de passe @@ -1421,101 +236,6 @@ KeyboardWidget - - KylinNM - - kylin-nm - - - - No usable network in the list - - - - HotSpot - - - - FlyMode - - - - Advanced - - - - Show KylinNM - - - - No wireless card detected - - - - Not connected - - - - Disconnected - - - - NetOn, - - - - No Other Wired Network Scheme - - - - No Other Wireless Network Scheme - - - - Wired net is disconnected - - - - Conn Ethernet Success - - - - Conn Ethernet Fail - - - - Conn Wifi Success - - - - Confirm your Wi-Fi password or usable of wireless card - - - - Inactivated LAN - - - - LAN - - - - WLAN - - - - Activated LAN - - - - Activated WLAN - - - - Other WLAN - - - LettersWidget @@ -1527,19 +247,34 @@ + + LightDMHelper + + failed to start session. + + + + Login + + + + Guest + Client + + LockWidget Form - Forme + Forme Date - Rendez-vous amoureux + Rendez-vous amoureux Time - Temps + Temps Guest @@ -1547,12 +282,18 @@ SwitchUser - Changer d'utilisateur + Changer d'utilisateur + + + LoginOptionsWidget - Multiple users are logged in at the same time.Are you sure you want to reboot this system? - + Password + Mot de passe + + + MyNetworkWidget LAN @@ -1561,44 +302,6 @@ WLAN - - PowerInfo - - - - Power - - - - VirtualKeyboard - - - - - LoginOptionsWidget - - Login Options - - - - Password - Mot de passe - - - Identify device removed! - - - - Other - - - - - MyLineEdit - - Verification code - - NumbersWidget @@ -1615,124 +318,44 @@ OneConnForm Form - Forme - - - Connect - - - - Disconnect - - - - Input Password... - - - - Automatically join the network - - - - Connect to Hidden Wi-Fi Network - - - - None - - - - WiFi Security: - - - - Signal: - - - - MAC: - - - - Conn Wifi Failed - + Forme OneLancForm Form - Forme - - - Connect - - - - Disconnect - - - - No Configuration - - - - IPv4: - - - - IPv6: - - - - BandWidth: - - - - MAC: - + Forme - PhoneAuthWidget + PowerListWidget - Verification by phoneNum + Hibernate - 「 Use bound Phone number to verification 」 + Turn off your computer, but the app stays open. When the computer is turned on, it can be restored to the state you left - commit + Suspend - 「 Use SMS to verification 」 + The computer stays on, but consumes less power. The app stays open and can quickly wake up and revert to where you left off - Network not connected~ + Reboot - Verification Code invalid! + Power Off - Verification Code incorrect.Please retry! - - - - Failed time over limit!Retry after 1 hour! - - - - verifaction failed! - - - - Network unavailable~ + Close all apps, and then shut down your computer @@ -1742,50 +365,6 @@ SwitchUser Changer d'utilisateur - - Log Out - - - - Power Off - - - - Suspend - - - - lock - - - - Shut Down - - - - Hibernate - - - - Restart - - - - Close all apps, turn off your computer, and then turn your computer back on - - - - Close all apps, and then shut down your computer - - - - Turn off your computer, but the app stays open. When the computer is turned on, it can be restored to the state you left - - - - The computer stays on, but consumes less power. The app stays open and can quickly wake up and revert to where you left off - - QObject @@ -1798,14 +377,6 @@ - - S: - - - tablet device - - - Screensaver @@ -1816,10 +387,6 @@ View - - You have new notification - - SleepTime @@ -1832,136 +399,11 @@ SureWindow Form - Forme + Forme TextLabel - TextLabel - - - Cancel - - - - Confirm - - - - The following program is running to prevent the system from reboot! - - - - The following program is running to prevent the system from shutting down! - - - - The following program is running to prevent the system from suspend! - - - - The following program is running to prevent the system from hibernate! - - - - - SwitchButtonGroup - - uEduPWD - - - - Wechat - - - - - TabletLockWidget - - Cancel - - - - Back - - - - Skip - - - - New password is the same as old - - - - Reset password error:%1 - - - - Please scan by correct WeChat - - - - - Utils - - kylin network applet desktop message - - - - - VerificationWidget - - Please scan by bound WeChat - - - - - VerticalVerificationWidget - - Please scan by bound WeChat - - - - - WeChatAuthDialog - - Login by wechat - - - - 「 Use registered WeChat account to login 」 - - - - Verification by wechat - - - - 「 Use bound WeChat account to verification 」 - - - - Network not connected~ - - - - Scan code successfully - - - - Timeout!Try again! - - - - - Widget - - Widget - - - - LoadPlugin - + TextLabel @@ -2044,5 +486,13 @@ show blank screensaver immediately and if lock + + Backend for the ukui ScreenSaver. + + + + lock the screen by startup + + diff --git a/i18n_ts/mn.ts b/i18n_ts/mn.ts index c79878b..bcbe087 100644 --- a/i18n_ts/mn.ts +++ b/i18n_ts/mn.ts @@ -4,8 +4,7 @@ AgreementWindow - - + I know ᠪᠢ ᠮᠡᠳᠡᠵᠡᠢ ᠃ @@ -25,7 +24,7 @@ 使用密码认证 - + Retry ᠳᠠᠬᠢᠵᠤ ᠳᠤᠷᠱᠢᠬᠤ @@ -46,91 +45,69 @@ 已登录 - Password: - 密码: + 密码: Account locked %1 minutes due to %2 fail attempts 账户锁定%1分钟由于%2次错误尝试 - - - - Please try again in %1 minutes. - %1 ᠮᠢᠨᠦ᠋ᠲ᠎ᠦᠨ ᠳᠠᠷᠠᠭ᠎ᠠ ᠳᠠᠬᠢᠵᠤ ᠳᠤᠷᠠᠱᠢᠭᠠᠷᠠᠢ + %1 ᠮᠢᠨᠦ᠋ᠲ᠎ᠦᠨ ᠳᠠᠷᠠᠭ᠎ᠠ ᠳᠠᠬᠢᠵᠤ ᠳᠤᠷᠠᠱᠢᠭᠠᠷᠠᠢ - - - - Please try again in %1 seconds. - %1 ᠮᠢᠨᠦ᠋ᠲ᠎ᠦᠨ ᠳᠠᠷᠠᠭ᠎ᠠ ᠳᠠᠬᠢᠵᠤ ᠳᠤᠷᠠᠱᠢᠭᠠᠷᠠᠢ + %1 ᠮᠢᠨᠦ᠋ᠲ᠎ᠦᠨ ᠳᠠᠷᠠᠭ᠎ᠠ ᠳᠠᠬᠢᠵᠤ ᠳᠤᠷᠠᠱᠢᠭᠠᠷᠠᠢ - - - - Account locked permanently. - ᠳᠠᠩᠰᠠ ᠨᠢᠭᠡᠨᠳᠡ ᠦᠨᠢᠳᠡ ᠤᠨᠢᠰᠤᠯᠠᠭᠳᠠᠪᠠ᠃ + ᠳᠠᠩᠰᠠ ᠨᠢᠭᠡᠨᠳᠡ ᠦᠨᠢᠳᠡ ᠤᠨᠢᠰᠤᠯᠠᠭᠳᠠᠪᠠ᠃ - Verify face recognition or enter password to unlock - ᠨᠢᠭᠤᠷ ᠱᠢᠷᠪᠢᠵᠤ ᠪᠠᠳᠤᠯᠭᠠᠵᠢᠭᠤᠯᠬᠤ ᠪᠤᠶᠤ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠤᠷᠤᠭᠤᠯᠵᠤ ᠤᠨᠢᠰᠤ᠎ᠶᠢ ᠳᠠᠢᠯᠤᠭᠠᠷᠠᠢ + ᠨᠢᠭᠤᠷ ᠱᠢᠷᠪᠢᠵᠤ ᠪᠠᠳᠤᠯᠭᠠᠵᠢᠭᠤᠯᠬᠤ ᠪᠤᠶᠤ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠤᠷᠤᠭᠤᠯᠵᠤ ᠤᠨᠢᠰᠤ᠎ᠶᠢ ᠳᠠᠢᠯᠤᠭᠠᠷᠠᠢ - Press fingerprint or enter password to unlock - ᠬᠤᠷᠤᠭᠤᠨ᠎ᠤ ᠤᠷᠤᠮ ᠳᠠᠷᠤᠬᠤ ᠪᠤᠶᠤ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠤᠷᠤᠭᠤᠯᠵᠤ ᠤᠨᠢᠰᠤ᠎ᠶᠢ ᠳᠠᠢᠯᠤᠭᠠᠷᠠᠢ + ᠬᠤᠷᠤᠭᠤᠨ᠎ᠤ ᠤᠷᠤᠮ ᠳᠠᠷᠤᠬᠤ ᠪᠤᠶᠤ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠤᠷᠤᠭᠤᠯᠵᠤ ᠤᠨᠢᠰᠤ᠎ᠶᠢ ᠳᠠᠢᠯᠤᠭᠠᠷᠠᠢ - Verify voiceprint or enter password to unlock - ᠳᠠᠭᠤ᠎ᠪᠠᠷ ᠪᠠᠳᠤᠯᠭᠠᠵᠢᠭᠤᠯᠬᠤ ᠪᠤᠶᠤ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠤᠷᠤᠭᠤᠯᠵᠤ ᠤᠨᠢᠰᠤ᠎ᠶᠢ ᠳᠠᠢᠯᠤᠭᠠᠷᠠᠢ + ᠳᠠᠭᠤ᠎ᠪᠠᠷ ᠪᠠᠳᠤᠯᠭᠠᠵᠢᠭᠤᠯᠬᠤ ᠪᠤᠶᠤ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠤᠷᠤᠭᠤᠯᠵᠤ ᠤᠨᠢᠰᠤ᠎ᠶᠢ ᠳᠠᠢᠯᠤᠭᠠᠷᠠᠢ - Verify finger vein or enter password to unlock - ᠬᠤᠷᠤᠭᠤᠨ᠎ᠤ ᠨᠠᠮᠵᠢᠭᠤᠨ ᠰᠤᠳᠠᠯ᠎ᠢᠶᠠᠷ ᠪᠠᠳᠤᠯᠭᠠᠵᠢᠭᠤᠯᠬᠤ ᠪᠤᠶᠤ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠤᠷᠤᠭᠤᠯᠵᠤ ᠤᠨᠢᠰᠤ᠎ᠶᠢ ᠳᠠᠢᠯᠤᠭᠠᠷᠠᠢ + ᠬᠤᠷᠤᠭᠤᠨ᠎ᠤ ᠨᠠᠮᠵᠢᠭᠤᠨ ᠰᠤᠳᠠᠯ᠎ᠢᠶᠠᠷ ᠪᠠᠳᠤᠯᠭᠠᠵᠢᠭᠤᠯᠬᠤ ᠪᠤᠶᠤ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠤᠷᠤᠭᠤᠯᠵᠤ ᠤᠨᠢᠰᠤ᠎ᠶᠢ ᠳᠠᠢᠯᠤᠭᠠᠷᠠᠢ - Verify iris or enter password to unlock - ᠰᠤᠯᠤᠩᠭ᠎ᠠ ᠪᠦᠷᠬᠦᠪᠴᠢ᠎ᠶᠢ ᠪᠠᠳᠤᠯᠭᠠᠵᠢᠭᠤᠯᠬᠤ ᠪᠤᠶᠤ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠤᠷᠤᠭᠤᠯᠵᠤ ᠤᠨᠢᠰᠤ᠎ᠶᠢ ᠳᠠᠢᠯᠤᠭᠠᠷᠠᠢ + ᠰᠤᠯᠤᠩᠭ᠎ᠠ ᠪᠦᠷᠬᠦᠪᠴᠢ᠎ᠶᠢ ᠪᠠᠳᠤᠯᠭᠠᠵᠢᠭᠤᠯᠬᠤ ᠪᠤᠶᠤ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠤᠷᠤᠭᠤᠯᠵᠤ ᠤᠨᠢᠰᠤ᠎ᠶᠢ ᠳᠠᠢᠯᠤᠭᠠᠷᠠᠢ - + Input Password ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠤᠷᠤᠭᠤᠯᠬᠤ - Failed to verify %1, please enter password to unlock - %1᠎ᠤ ᠪᠠᠳᠤᠯᠭᠠᠵᠢᠭᠤᠯᠤᠯᠳᠠ ᠢᠯᠠᠭᠳᠠᠪᠠ ᠂ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠤᠷᠤᠭᠤᠯᠵᠤ ᠤᠨᠢᠰᠤ᠎ᠶᠢ ᠳᠠᠢᠯᠤᠭᠠᠷᠠᠢ + %1᠎ᠤ ᠪᠠᠳᠤᠯᠭᠠᠵᠢᠭᠤᠯᠤᠯᠳᠠ ᠢᠯᠠᠭᠳᠠᠪᠠ ᠂ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠤᠷᠤᠭᠤᠯᠵᠤ ᠤᠨᠢᠰᠤ᠎ᠶᠢ ᠳᠠᠢᠯᠤᠭᠠᠷᠠᠢ - - Unable to verify %1, please enter password to unlock - %1᠎ᠶᠢ/᠎ᠢ ᠪᠠᠳᠤᠯᠭᠠᠵᠢᠭᠤᠯᠬᠤ ᠠᠷᠭ᠎ᠠ ᠦᠬᠡᠢ ᠂ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠤᠷᠤᠭᠤᠯᠵᠤ ᠤᠨᠢᠰᠤ᠎ᠶᠢ ᠳᠠᠢᠯᠤᠭᠠᠷᠠᠢ + %1᠎ᠶᠢ/᠎ᠢ ᠪᠠᠳᠤᠯᠭᠠᠵᠢᠭᠤᠯᠬᠤ ᠠᠷᠭ᠎ᠠ ᠦᠬᠡᠢ ᠂ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠤᠷᠤᠭᠤᠯᠵᠤ ᠤᠨᠢᠰᠤ᠎ᠶᠢ ᠳᠠᠢᠯᠤᠭᠠᠷᠠᠢ - Abnormal network - ᠰᠦᠯᠵᠢᠶ᠎ᠡ ᠬᠡᠪ᠎ᠦᠨ ᠪᠤᠰᠤ + ᠰᠦᠯᠵᠢᠶ᠎ᠡ ᠬᠡᠪ᠎ᠦᠨ ᠪᠤᠰᠤ Use the bound wechat scanning code or enter the password to log in 使用绑定的微信扫码或输入密码登录 - - + + Password cannot be empty ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠬᠤᠭᠤᠰᠤᠨ ᠪᠠᠢᠵᠤ ᠪᠤᠯᠬᠤ ᠦᠬᠡᠢ @@ -143,10 +120,8 @@ 无法验证%1,请输入密码. - - Failed to verify %1, you still have %2 verification opportunities - %1᠎ᠶᠢᠨ/᠎ᠦᠨ ᠪᠠᠳᠤᠯᠭᠠᠵᠢᠭᠤᠯᠤᠯᠳᠠ ᠢᠯᠠᠭᠳᠠᠪᠠ ᠂ ᠲᠠ ᠪᠠᠰᠠ%2 ᠤᠳᠠᠭᠠᠨ᠎ᠤ ᠳᠤᠷᠱᠢᠬᠤ ᠵᠠᠪᠱᠢᠶᠠᠨ ᠲᠠᠢ + %1᠎ᠶᠢᠨ/᠎ᠦᠨ ᠪᠠᠳᠤᠯᠭᠠᠵᠢᠭᠤᠯᠤᠯᠳᠠ ᠢᠯᠠᠭᠳᠠᠪᠠ ᠂ ᠲᠠ ᠪᠠᠰᠠ%2 ᠤᠳᠠᠭᠠᠨ᠎ᠤ ᠳᠤᠷᠱᠢᠬᠤ ᠵᠠᠪᠱᠢᠶᠠᠨ ᠲᠠᠢ Biometric/code scan authentication failed too many times, please enter the password. @@ -173,31 +148,29 @@ 请输入密码或者录入指纹 - + Authentication failure, Please try again ᠪᠠᠳᠤᠯᠭᠠᠵᠢᠭᠤᠯᠤᠯᠳᠠ ᠢᠯᠠᠭᠳᠠᠪᠠ ᠂ ᠳᠠᠬᠢᠵᠤ ᠳᠤᠷᠱᠢᠭᠠᠷᠠᠢ - Use the bound wechat scanning code or enter the password to unlock - ᠤᠶᠠᠭᠰᠠᠨ ᠸᠢᠴᠠᠲ᠎ᠢᠶᠠᠷ ᠺᠤᠳ᠋ ᠱᠢᠷᠪᠢᠬᠦ᠌ ᠪᠤᠶᠤ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠤᠷᠤᠭᠤᠯᠵᠤ ᠤᠨᠢᠰᠤ᠎ᠶᠢ ᠳᠠᠢᠯᠤᠭᠠᠷᠠᠢ + ᠤᠶᠠᠭᠰᠠᠨ ᠸᠢᠴᠠᠲ᠎ᠢᠶᠠᠷ ᠺᠤᠳ᠋ ᠱᠢᠷᠪᠢᠬᠦ᠌ ᠪᠤᠶᠤ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠤᠷᠤᠭᠤᠯᠵᠤ ᠤᠨᠢᠰᠤ᠎ᠶᠢ ᠳᠠᠢᠯᠤᠭᠠᠷᠠᠢ - Enter the ukey password - ᠠᠮᠤᠷ ᠲᠦᠪᠰᠢᠨ ᠨᠢᠭᠤᠴᠠ ᠨᠣᠮᠧᠷ ᠢ ᠣᠷᠣᠭᠤᠯᠤᠨ᠎ᠠ ᠃ + ᠠᠮᠤᠷ ᠲᠦᠪᠰᠢᠨ ᠨᠢᠭᠤᠴᠠ ᠨᠣᠮᠧᠷ ᠢ ᠣᠷᠣᠭᠤᠯᠤᠨ᠎ᠠ ᠃ - Insert the ukey into the USB port - ᠠᠮᠤᠷ ᠲᠦᠪᠰᠢᠨ ᠦ ᠨᠢᠭᠤᠴᠠ ᠶᠢ USB ᠦᠵᠦᠭᠦᠷ ᠲᠦ ᠬᠠᠳᠬᠤᠵᠤ ᠣᠷᠣᠭᠠᠷᠠᠢ ᠃ + ᠠᠮᠤᠷ ᠲᠦᠪᠰᠢᠨ ᠦ ᠨᠢᠭᠤᠴᠠ ᠶᠢ USB ᠦᠵᠦᠭᠦᠷ ᠲᠦ ᠬᠠᠳᠬᠤᠵᠤ ᠣᠷᠣᠭᠠᠷᠠᠢ ᠃ + Password - ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ + ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ - + Login ᠳᠠᠩᠰᠠᠯᠠᠨ ᠤᠷᠤᠬᠤ @@ -222,29 +195,6 @@ 指纹验证失败,您还有%1次尝试机会 - - BatteryWidget - - - Charging... - - - - - fully charged - - - - - PowerMode - - - - - BatteryMode - - - BioDevices @@ -286,43 +236,37 @@ BiometricAuthWidget - Current device: - ᠤᠳᠤᠬᠠᠨ᠎ᠤ ᠳᠦᠬᠦᠬᠡᠷᠦᠮᠵᠢ + ᠤᠳᠤᠬᠠᠨ᠎ᠤ ᠳᠦᠬᠦᠬᠡᠷᠦᠮᠵᠢ - Identify failed, Please retry. - ᠢᠯᠭᠠᠨ ᠳᠠᠨᠢᠯᠳᠠ ᠢᠯᠠᠭᠳᠠᠪᠠ ᠂ ᠳᠠᠬᠢᠵᠤ ᠳᠤᠷᠱᠢᠭᠠᠷᠠᠢ + ᠢᠯᠭᠠᠨ ᠳᠠᠨᠢᠯᠳᠠ ᠢᠯᠠᠭᠳᠠᠪᠠ ᠂ ᠳᠠᠬᠢᠵᠤ ᠳᠤᠷᠱᠢᠭᠠᠷᠠᠢ BiometricDevicesWidget - Please select the biometric device - ᠠᠮᠢᠳᠤ ᠪᠤᠳᠠᠰ᠎ᠤᠨ ᠳᠦᠬᠦᠬᠡᠷᠦᠮᠵᠢ᠎ᠶᠢ ᠰᠤᠩᠭᠤᠭᠠᠷᠠᠢ + ᠠᠮᠢᠳᠤ ᠪᠤᠳᠠᠰ᠎ᠤᠨ ᠳᠦᠬᠦᠬᠡᠷᠦᠮᠵᠢ᠎ᠶᠢ ᠰᠤᠩᠭᠤᠭᠠᠷᠠᠢ - Device type: - ᠳᠦᠬᠦᠬᠡᠷᠦᠮᠵᠢ᠎ᠶᠢᠨ ᠬᠡᠯᠪᠡᠷᠢ ᠳᠦᠷᠰᠦ ᠄ + ᠳᠦᠬᠦᠬᠡᠷᠦᠮᠵᠢ᠎ᠶᠢᠨ ᠬᠡᠯᠪᠡᠷᠢ ᠳᠦᠷᠰᠦ ᠄ - Device name: - ᠳᠦᠬᠦᠬᠡᠷᠦᠮᠵᠢ᠎ᠶᠢᠨ ᠱᠢᠨᠵᠢ ᠳᠡᠮᠳᠡᠭ ᠄ + ᠳᠦᠬᠦᠬᠡᠷᠦᠮᠵᠢ᠎ᠶᠢᠨ ᠱᠢᠨᠵᠢ ᠳᠡᠮᠳᠡᠭ ᠄ - OK - OK + OK CharsMoreWidget - + &&?! &&?! @@ -330,17 +274,17 @@ CharsWidget - + More - ᠨᠡᠩ ᠣᠯᠠᠨ + ᠨᠡᠩ ᠠᠷᠪᠢᠨ ᠃ - + ABC ABC - + 123 123 @@ -348,101 +292,80 @@ ConfForm - edit network - ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠬᠠᠷᠢᠶᠠᠳᠤ ᠴᠢᠨᠠᠷ + ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠬᠠᠷᠢᠶᠠᠳᠤ ᠴᠢᠨᠠᠷ - LAN name: - ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠨᠡᠷᠡᠢᠳᠦᠯ ᠄ + ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠨᠡᠷᠡᠢᠳᠦᠯ ᠄ - Method: - ᠠᠷᠭ᠎ᠠ ᠄ + ᠠᠷᠭ᠎ᠠ ᠄ - Address: - ᠬᠠᠶᠢᠭ ᠄ + ᠬᠠᠶᠢᠭ ᠄ - Netmask: - ᠬᠤᠪᠢᠶᠠᠷᠢ ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠳᠠᠯᠳᠠᠯᠠᠯ ᠄ + ᠬᠤᠪᠢᠶᠠᠷᠢ ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠳᠠᠯᠳᠠᠯᠠᠯ ᠄ - Gateway: - ᠠᠶᠠᠳᠠᠯ ᠲᠤᠤᠷ ᠰᠦᠯᠵᠢᠶᠡᠨ ᠪᠤᠭᠤᠮᠳᠠ ᠄ + ᠠᠶᠠᠳᠠᠯ ᠲᠤᠤᠷ ᠰᠦᠯᠵᠢᠶᠡᠨ ᠪᠤᠭᠤᠮᠳᠠ ᠄ - DNS 1: - DNS᠎ᠢ ᠰᠤᠩᠭᠤᠬᠤ + DNS᠎ᠢ ᠰᠤᠩᠭᠤᠬᠤ - DNS 2: - ᠪᠡᠯᠡᠳᠭᠡᠯ ᠰᠤᠩᠭᠤᠭᠤᠯᠢDNS ᠄ + ᠪᠡᠯᠡᠳᠭᠡᠯ ᠰᠤᠩᠭᠤᠭᠤᠯᠢDNS ᠄ - Edit Conn - ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠳᠤᠬᠢᠷᠠᠭᠤᠯᠤᠯᠳᠠ + ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠳᠤᠬᠢᠷᠠᠭᠤᠯᠤᠯᠳᠠ - - Auto(DHCP) - ᠠᠦ᠋ᠲ᠋ᠤ᠋(DHCP) + ᠠᠦ᠋ᠲ᠋ᠤ᠋(DHCP) - - Manual - ᠭᠠᠷ᠎ᠢᠶᠠᠷ ᠬᠦᠳᠡᠯᠭᠡᠬᠦ᠌ + ᠭᠠᠷ᠎ᠢᠶᠠᠷ ᠬᠦᠳᠡᠯᠭᠡᠬᠦ᠌ - Cancel - ᠪᠤᠴᠠᠬᠤ + ᠪᠤᠴᠠᠬᠤ - Save - ᠪᠠᠳᠤᠯᠠᠬᠤ + ᠪᠠᠳᠤᠯᠠᠬᠤ - Ok - Ok + Ok - Can not create new wired network for without wired card - ᠤᠳᠠᠰᠤᠳᠤ ᠰᠦᠯᠵᠢᠶᠡᠨ ᠺᠠᠷᠲ ᠳᠤᠳᠠᠭᠤ ᠂ ᠱᠢᠨ᠎ᠡ ᠰᠦᠯᠵᠢᠶ᠎ᠡ ᠪᠠᠢᠭᠤᠯᠬᠤ᠎ᠶᠢᠨ ᠠᠷᠭ᠎ᠠ ᠦᠬᠡᠢ + ᠤᠳᠠᠰᠤᠳᠤ ᠰᠦᠯᠵᠢᠶᠡᠨ ᠺᠠᠷᠲ ᠳᠤᠳᠠᠭᠤ ᠂ ᠱᠢᠨ᠎ᠡ ᠰᠦᠯᠵᠢᠶ᠎ᠡ ᠪᠠᠢᠭᠤᠯᠬᠤ᠎ᠶᠢᠨ ᠠᠷᠭ᠎ᠠ ᠦᠬᠡᠢ - New network already created - ᠱᠢᠨ᠎ᠡ ᠤᠳᠠᠰᠤᠳᠤ ᠰᠦᠯᠵᠢᠶ᠎ᠡ᠎ᠶᠢ ᠨᠢᠭᠡᠨᠳᠡ ᠪᠠᠢᠭᠤᠯᠪᠠ + ᠱᠢᠨ᠎ᠡ ᠤᠳᠠᠰᠤᠳᠤ ᠰᠦᠯᠵᠢᠶ᠎ᠡ᠎ᠶᠢ ᠨᠢᠭᠡᠨᠳᠡ ᠪᠠᠢᠭᠤᠯᠪᠠ - New network settings already finished - ᠱᠢᠨ᠎ᠡ ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠪᠠᠢᠷᠢᠯᠠᠯ᠎ᠢ ᠨᠢᠭᠡᠨᠳᠡ ᠳᠠᠭᠤᠰᠭᠠᠪᠠ + ᠱᠢᠨ᠎ᠡ ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠪᠠᠢᠷᠢᠯᠠᠯ᠎ᠢ ᠨᠢᠭᠡᠨᠳᠡ ᠳᠠᠭᠤᠰᠭᠠᠪᠠ - Edit Network - ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠬᠠᠷᠢᠶᠠᠳᠤ ᠴᠢᠨᠠᠷ + ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠬᠠᠷᠢᠶᠠᠳᠤ ᠴᠢᠨᠠᠷ - Add Wired Network - ᠱᠢᠨ᠎ᠡ᠎ᠪᠡᠷ ᠪᠠᠢᠭᠤᠯᠤᠭᠰᠠᠨ ᠤᠳᠠᠰᠤᠳᠤ ᠰᠦᠯᠵᠢᠶ᠎ᠡ + ᠱᠢᠨ᠎ᠡ᠎ᠪᠡᠷ ᠪᠠᠢᠭᠤᠯᠤᠭᠰᠠᠨ ᠤᠳᠠᠰᠤᠳᠤ ᠰᠦᠯᠵᠢᠶ᠎ᠡ create wired network successfully @@ -453,9 +376,8 @@ 新的设置已经生效 - New settings already effective - ᠱᠢᠨ᠎ᠡ ᠳᠤᠬᠢᠷᠠᠭᠤᠯᠤᠯᠳᠠ ᠨᠢᠭᠡᠨᠳᠡ ᠬᠦᠴᠦᠨ ᠲᠠᠢ ᠪᠤᠯᠪᠠ + ᠱᠢᠨ᠎ᠡ ᠳᠤᠬᠢᠷᠠᠭᠤᠯᠤᠯᠳᠠ ᠨᠢᠭᠡᠨᠳᠡ ᠬᠦᠴᠦᠨ ᠲᠠᠢ ᠪᠤᠯᠪᠠ There is a same named LAN exsits. @@ -465,52 +387,39 @@ DeviceType - FingerPrint - ᠬᠤᠷᠤᠭᠤᠨ᠎ᠤ ᠤᠷᠤᠮ + ᠬᠤᠷᠤᠭᠤᠨ᠎ᠤ ᠤᠷᠤᠮ - FingerVein - ᠬᠤᠷᠤᠭᠤᠨ᠎ᠤ ᠨᠠᠮᠵᠢᠭᠤᠨ ᠰᠤᠳᠠᠯ + ᠬᠤᠷᠤᠭᠤᠨ᠎ᠤ ᠨᠠᠮᠵᠢᠭᠤᠨ ᠰᠤᠳᠠᠯ - Iris - ᠰᠤᠯᠤᠩᠭ᠎ᠠ ᠪᠦᠷᠬᠦᠪᠴᠢ + ᠰᠤᠯᠤᠩᠭ᠎ᠠ ᠪᠦᠷᠬᠦᠪᠴᠢ - Face - ᠴᠢᠷᠠᠢ᠎ᠪᠠᠷ ᠢᠯᠭᠠᠨ ᠳᠠᠨᠢᠬᠤ + ᠴᠢᠷᠠᠢ᠎ᠪᠠᠷ ᠢᠯᠭᠠᠨ ᠳᠠᠨᠢᠬᠤ - VoicePrint - ᠳᠠᠭᠤᠨ᠎ᠤ ᠢᠷᠠᠯᠵᠢ - - - - Ukey - ᠠᠮᠤᠷ ᠲᠦᠪᠰᠢᠨ ᠨᠢᠭᠤᠴᠠ ᠪᠠᠷ ᠬᠥᠯᠬᠢᠳᠡᠬᠦ ᠃ + ᠳᠠᠭᠤᠨ᠎ᠤ ᠢᠷᠠᠯᠵᠢ ukey ᠠᠮᠤᠷ ᠲᠦᠪᠰᠢᠨ ᠨᠢᠭᠤᠴᠠ ᠪᠠᠷ ᠬᠥᠯᠬᠢᠳᠡᠬᠦ ᠃ - QRCode - ᠬᠤᠶᠠᠷ ᠬᠡᠮᠵᠢᠯᠳᠡᠳᠦ ᠺᠤᠳ᠋ + ᠬᠤᠶᠠᠷ ᠬᠡᠮᠵᠢᠯᠳᠡᠳᠦ ᠺᠤᠳ᠋ DigitalAuthDialog - - LoginByUEdu - ᠳᠡᠯᠭᠡᠴᠡᠨ᠎ᠦ ᠤᠨᠢᠰᠤ᠎ᠶᠢ ᠳᠠᠢᠯᠠᠬᠤ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋᠎ᠢ ᠤᠷᠤᠭᠤᠯᠤᠭᠠᠷᠠᠢ + ᠳᠡᠯᠭᠡᠴᠡᠨ᠎ᠦ ᠤᠨᠢᠰᠤ᠎ᠶᠢ ᠳᠠᠢᠯᠠᠬᠤ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋᠎ᠢ ᠤᠷᠤᠭᠤᠯᠤᠭᠠᠷᠠᠢ now is authing, wait a moment @@ -521,83 +430,67 @@ 密码错误,请重试 - ResetPWD? - ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋᠎ᠪᠠᠨ ᠮᠠᠷᠳᠠᠭᠰᠠᠨ ᠤᠤ? + ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋᠎ᠪᠠᠨ ᠮᠠᠷᠳᠠᠭᠰᠠᠨ ᠤᠤ? - - SetNewUEduPWD - ᠳᠡᠯᠭᠡᠴᠡ ᠤᠨᠢᠰᠤᠯᠠᠬᠤ ᠱᠢᠨ᠎ᠡ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠳᠤᠬᠢᠷᠠᠭᠤᠯᠬᠤ + ᠳᠡᠯᠭᠡᠴᠡ ᠤᠨᠢᠰᠤᠯᠠᠬᠤ ᠱᠢᠨ᠎ᠡ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠳᠤᠬᠢᠷᠠᠭᠤᠯᠬᠤ - ConfirmNewUEduPWD - ᠳᠡᠯᠭᠡᠴᠡ ᠤᠨᠢᠰᠤᠯᠠᠬᠤ ᠱᠢᠨ᠎ᠡ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋᠎ᠢ ᠪᠠᠳᠤᠯᠠᠬᠤ + ᠳᠡᠯᠭᠡᠴᠡ ᠤᠨᠢᠰᠤᠯᠠᠬᠤ ᠱᠢᠨ᠎ᠡ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋᠎ᠢ ᠪᠠᠳᠤᠯᠠᠬᠤ - The two password entries are inconsistent, please reset - ᠬᠤᠶᠠᠷ ᠤᠳᠠᠭᠠᠨ᠎ᠤ ᠤᠷᠤᠭᠤᠯᠤᠭᠰᠠᠨ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠠᠳᠠᠯᠢ ᠪᠤᠰᠤ ᠂ ᠳᠠᠬᠢᠵᠤ ᠳᠤᠬᠢᠷᠠᠭᠤᠯᠤᠭᠠᠷᠠᠢ + ᠬᠤᠶᠠᠷ ᠤᠳᠠᠭᠠᠨ᠎ᠤ ᠤᠷᠤᠭᠤᠯᠤᠭᠰᠠᠨ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠠᠳᠠᠯᠢ ᠪᠤᠰᠤ ᠂ ᠳᠠᠬᠢᠵᠤ ᠳᠤᠬᠢᠷᠠᠭᠤᠯᠤᠭᠠᠷᠠᠢ - Password entered incorrectly, please try again - ᠤᠷᠤᠭᠤᠯᠤᠭᠰᠠᠨ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠪᠤᠷᠤᠭᠤᠳᠠᠪᠠ ᠂ ᠳᠠᠬᠢᠵᠤ ᠳᠤᠷᠱᠢᠭᠠᠷᠠᠢ + ᠤᠷᠤᠭᠤᠯᠤᠭᠰᠠᠨ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠪᠤᠷᠤᠭᠤᠳᠠᠪᠠ ᠂ ᠳᠠᠬᠢᠵᠤ ᠳᠤᠷᠱᠢᠭᠠᠷᠠᠢ - clear - ᠬᠤᠭᠤᠰᠤᠯᠠᠬᠤ + ᠬᠤᠭᠤᠰᠤᠯᠠᠬᠤ DlgConnHidWifi - Add Hidden Wi-Fi - ᠤᠳᠠᠰᠤ ᠦᠬᠡᠢ ᠰᠦᠯᠵᠢᠶ᠎ᠡ ᠨᠡᠮᠡᠵᠤ ᠤᠷᠤᠭᠤᠯᠬᠤ + ᠤᠳᠠᠰᠤ ᠦᠬᠡᠢ ᠰᠦᠯᠵᠢᠶ᠎ᠡ ᠨᠡᠮᠡᠵᠤ ᠤᠷᠤᠭᠤᠯᠬᠤ - Connection - ᠵᠠᠯᠭᠠᠰᠤ ᠳᠤᠬᠢᠷᠠᠭᠤᠯᠬᠤ ᠄ + ᠵᠠᠯᠭᠠᠰᠤ ᠳᠤᠬᠢᠷᠠᠭᠤᠯᠬᠤ ᠄ - Wi-Fi name - ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠨᠡᠷᠡᠢᠳᠦᠯ ᠄ + ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠨᠡᠷᠡᠢᠳᠦᠯ ᠄ - Wi-Fi security - Wi-Fi᠎ᠤ ᠠᠶᠤᠯᠬᠦᠢ ᠱᠢᠨᠵᠢ ᠄ + Wi-Fi᠎ᠤ ᠠᠶᠤᠯᠬᠦᠢ ᠱᠢᠨᠵᠢ ᠄ - Cancel - ᠪᠤᠴᠠᠬᠤ + ᠪᠤᠴᠠᠬᠤ - Connect - ᠪᠠᠳᠤᠯᠠᠬᠤ + ᠪᠠᠳᠤᠯᠠᠬᠤ - C_reate… - ᠱᠢᠨ᠎ᠡ᠎ᠪᠡᠷ ᠪᠠᠢᠭᠤᠯᠬᠤ… + ᠱᠢᠨ᠎ᠡ᠎ᠪᠡᠷ ᠪᠠᠢᠭᠤᠯᠬᠤ… - None - ᠦᠬᠡᠢ + ᠦᠬᠡᠢ - WPA & WPA2 Personal - WPA ᠵᠢᠴᠢWPA2 ᠬᠦᠮᠦᠨ + WPA ᠵᠢᠴᠢWPA2 ᠬᠦᠮᠦᠨ WEP 40/128-bit Key (Hex or ASCII) @@ -616,1009 +509,807 @@ WPA 及 WPA2 企业 - Connect to Hidden Wi-Fi Network - ᠨᠢᠭᠤᠴᠠᠯᠢᠭWi-Fi ᠰᠦᠯᠵᠢᠶ᠎ᠡ᠎ᠳᠦ ᠵᠠᠯᠭᠠᠪᠠ + ᠨᠢᠭᠤᠴᠠᠯᠢᠭWi-Fi ᠰᠦᠯᠵᠢᠶ᠎ᠡ᠎ᠳᠦ ᠵᠠᠯᠭᠠᠪᠠ DlgConnHidWifiLeap - Connect to Hidden Wi-Fi Network - ᠨᠢᠭᠤᠴᠠᠯᠢᠭWi-Fi ᠰᠦᠯᠵᠢᠶ᠎ᠡ᠎ᠳᠦ ᠵᠠᠯᠭᠠᠪᠠ + ᠨᠢᠭᠤᠴᠠᠯᠢᠭWi-Fi ᠰᠦᠯᠵᠢᠶ᠎ᠡ᠎ᠳᠦ ᠵᠠᠯᠭᠠᠪᠠ - Add hidden Wi-Fi - ᠤᠳᠠᠰᠤ ᠦᠬᠡᠢ ᠰᠦᠯᠵᠢᠶ᠎ᠡ ᠨᠡᠮᠡᠵᠤ ᠤᠷᠤᠭᠤᠯᠬᠤ + ᠤᠳᠠᠰᠤ ᠦᠬᠡᠢ ᠰᠦᠯᠵᠢᠶ᠎ᠡ ᠨᠡᠮᠡᠵᠤ ᠤᠷᠤᠭᠤᠯᠬᠤ - Connection - ᠵᠠᠯᠭᠠᠰᠤ ᠳᠤᠬᠢᠷᠠᠭᠤᠯᠬᠤ + ᠵᠠᠯᠭᠠᠰᠤ ᠳᠤᠬᠢᠷᠠᠭᠤᠯᠬᠤ - Network name - ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠨᠡᠷᠡᠢᠳᠦᠯ ᠄ + ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠨᠡᠷᠡᠢᠳᠦᠯ ᠄ - Wi-Fi security - Wi-Fi᠎ᠤ ᠠᠶᠤᠯᠬᠦᠢ ᠱᠢᠨᠵᠢ + Wi-Fi᠎ᠤ ᠠᠶᠤᠯᠬᠦᠢ ᠱᠢᠨᠵᠢ - Username - ᠬᠡᠷᠡᠭᠯᠡᠭᠴᠢ᠎ᠶᠢᠨ ᠨᠡᠷ᠎ᠡ ᠄ + ᠬᠡᠷᠡᠭᠯᠡᠭᠴᠢ᠎ᠶᠢᠨ ᠨᠡᠷ᠎ᠡ ᠄ - Password - ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠄ + ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠄ - Cancel - ᠦᠭᠡᠢᠰᠬᠡᠬᠦ + ᠦᠭᠡᠢᠰᠬᠡᠬᠦ - Connect - ᠴᠦᠷᠬᠡᠯᠡᠬᠡ + ᠴᠦᠷᠬᠡᠯᠡᠬᠡ - C_reate… - ᠱᠢᠨ᠎ᠡ᠎ᠪᠡᠷ ᠪᠠᠢᠭᠤᠯᠬᠤ… + ᠱᠢᠨ᠎ᠡ᠎ᠪᠡᠷ ᠪᠠᠢᠭᠤᠯᠬᠤ… - None - ᠥᠬᠡᠢ + ᠥᠬᠡᠢ - WPA & WPA2 Personal - WPA ᠪᠣᠯᠣᠨ WPA2 ᠬᠤᠪᠢ ᠬᠥᠮᠥᠨ ᠃ + WPA ᠪᠣᠯᠣᠨ WPA2 ᠬᠤᠪᠢ ᠬᠥᠮᠥᠨ ᠃ - WEP 40/128-bit Key (Hex or ASCII) - WEP 40/128 ᠨᠢᠭᠤᠴᠠ ᠭᠬᠢᠷ (ᠠᠷᠪᠠᠨ ᠵᠢᠷᠭᠤᠭ᠎ᠠ ᠶᠢ ᠣᠷᠣᠭᠤᠯᠬᠤ ᠦᠢᠯᠡᠳᠦᠯ ᠪᠤᠶᠤ ASCII) + WEP 40/128 ᠨᠢᠭᠤᠴᠠ ᠭᠬᠢᠷ (ᠠᠷᠪᠠᠨ ᠵᠢᠷᠭᠤᠭ᠎ᠠ ᠶᠢ ᠣᠷᠣᠭᠤᠯᠬᠤ ᠦᠢᠯᠡᠳᠦᠯ ᠪᠤᠶᠤ ASCII) - WEP 128-bit Passphrase - WEP 128 ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋᠎ᠤᠨ ᠦᠬᠦᠯᠡᠪᠦᠷᠢ + WEP 128 ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋᠎ᠤᠨ ᠦᠬᠦᠯᠡᠪᠦᠷᠢ - Dynamic WEP (802.1X) - ᠬᠦᠳᠡᠯᠦᠩᠬᠦᠢ ᠪᠠᠢᠳᠠᠯWEP (802.1X) + ᠬᠦᠳᠡᠯᠦᠩᠬᠦᠢ ᠪᠠᠢᠳᠠᠯWEP (802.1X) - WPA & WPA2 Enterprise - WPA ᠵᠢᠴᠢWPA2 ᠠᠵᠤ ᠠᠬᠤᠢᠯᠠᠯ + WPA ᠵᠢᠴᠢWPA2 ᠠᠵᠤ ᠠᠬᠤᠢᠯᠠᠯ DlgConnHidWifiSecFast - Connect to Hidden Wi-Fi Network - ᠨᠢᠭᠤᠴᠠᠯᠢᠭ Wi-Fi ᠰᠦᠯᠵᠢᠶ᠎ᠡ᠎ᠳᠦ ᠵᠠᠯᠭᠠᠪᠠ + ᠨᠢᠭᠤᠴᠠᠯᠢᠭ Wi-Fi ᠰᠦᠯᠵᠢᠶ᠎ᠡ᠎ᠳᠦ ᠵᠠᠯᠭᠠᠪᠠ - Add hidden Wi-Fi - ᠨᠢᠭᠤᠴᠠᠯᠢᠭ Wi-Fi ᠨᠡᠮᠡᠬᠦ + ᠨᠢᠭᠤᠴᠠᠯᠢᠭ Wi-Fi ᠨᠡᠮᠡᠬᠦ - Connection - ᠬᠤᠯᠪᠤᠭᠠᠰᠤ + ᠬᠤᠯᠪᠤᠭᠠᠰᠤ - Network name - ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠨᠡᠷᠡᠢᠳᠦᠯ + ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠨᠡᠷᠡᠢᠳᠦᠯ - Wi-Fi security - Wi-Fi᠎ᠤ ᠠᠶᠤᠯᠬᠦᠢ ᠱᠢᠨᠵᠢ + Wi-Fi᠎ᠤ ᠠᠶᠤᠯᠬᠦᠢ ᠱᠢᠨᠵᠢ - Authentication - ᠭᠡᠷᠡᠴᠢᠯᠡᠬᠦ᠌ ᠄ + ᠭᠡᠷᠡᠴᠢᠯᠡᠬᠦ᠌ ᠄ - Anonymous identity - ᠨᠡᠷ᠎ᠡ ᠪᠤᠷᠤᠭᠤᠯᠤᠭᠰᠠᠨ ᠪᠡᠶ᠎ᠡ᠎ᠶᠢᠨ ᠭᠠᠷᠤᠯ + ᠨᠡᠷ᠎ᠡ ᠪᠤᠷᠤᠭᠤᠯᠤᠭᠰᠠᠨ ᠪᠡᠶ᠎ᠡ᠎ᠶᠢᠨ ᠭᠠᠷᠤᠯ - Allow automatic PAC pro_visioning - ᠠᠦ᠋ᠲ᠋ᠤ᠋PACᠪᠠᠢᠷᠢᠯᠠᠯ + ᠠᠦ᠋ᠲ᠋ᠤ᠋PACᠪᠠᠢᠷᠢᠯᠠᠯ - PAC file - PAC ᠹᠠᠢᠯ ᠄ + PAC ᠹᠠᠢᠯ ᠄ - Inner authentication - ᠳᠤᠳᠤᠭᠠᠳᠤ᠎ᠶᠢᠨ ᠭᠡᠷᠡᠴᠢᠯᠡᠯ + ᠳᠤᠳᠤᠭᠠᠳᠤ᠎ᠶᠢᠨ ᠭᠡᠷᠡᠴᠢᠯᠡᠯ - Username - ᠬᠡᠷᠡᠭᠯᠡᠭᠴᠢ ᠵᠢᠨ ᠨᠡᠷ᠎ᠡ + ᠬᠡᠷᠡᠭᠯᠡᠭᠴᠢ ᠵᠢᠨ ᠨᠡᠷ᠎ᠡ - Password - ᠨᠢᠭᠤᠴᠠ ᠺᠣᠳ᠋᠎ᠢ᠋ ᠵᠠᠰᠠᠬᠤ + ᠨᠢᠭᠤᠴᠠ ᠺᠣᠳ᠋᠎ᠢ᠋ ᠵᠠᠰᠠᠬᠤ - Cancel - ᠪᠣᠯᠢᠬᠤ ᠂ ᠪᠣᠯᠢᠬᠤ + ᠬᠦᠴᠦᠨ ᠦᠭᠡᠶ ᠪᠣᠯᠭᠠᠨ᠎ᠠ᠃ - Connect - ᠰᠢᠷᠪᠢᠬᠦᠷ ᠲᠤ᠌ ᠴᠥᠷᠬᠡᠯᠡᠪᠡ + ᠰᠢᠷᠪᠢᠬᠦᠷ ᠲᠤ᠌ ᠴᠥᠷᠬᠡᠯᠡᠪᠡ - C_reate… - ᠱᠢᠨ᠎ᠡ᠎ᠪᠡᠷ ᠪᠠᠢᠭᠤᠯᠬᠤ… + ᠱᠢᠨ᠎ᠡ᠎ᠪᠡᠷ ᠪᠠᠢᠭᠤᠯᠬᠤ… - - None - ᠥᠬᠡᠢ + ᠥᠬᠡᠢ - WPA & WPA2 Personal - WPA ᠪᠣᠯᠣᠨ WPA2 ᠬᠤᠪᠢ ᠬᠥᠮᠥᠨ ᠃ + WPA ᠪᠣᠯᠣᠨ WPA2 ᠬᠤᠪᠢ ᠬᠥᠮᠥᠨ ᠃ - WEP 40/128-bit Key (Hex or ASCII) - WEP 40/128 ᠨᠢᠭᠤᠴᠠ ᠳᠦᠯᠬᠢᠬᠦᠷ (ᠠᠷᠪᠠᠨ ᠵᠢᠷᠭᠤᠭ᠎ᠠ᠎ᠪᠠᠷ ᠳᠠᠪᠱᠢᠬᠤ ᠳᠦᠷᠢᠮ ᠡᠰᠡᠬᠦᠯ᠎ᠡASCII) + WEP 40/128 ᠨᠢᠭᠤᠴᠠ ᠳᠦᠯᠬᠢᠬᠦᠷ (ᠠᠷᠪᠠᠨ ᠵᠢᠷᠭᠤᠭ᠎ᠠ᠎ᠪᠠᠷ ᠳᠠᠪᠱᠢᠬᠤ ᠳᠦᠷᠢᠮ ᠡᠰᠡᠬᠦᠯ᠎ᠡASCII) - WEP 128-bit Passphrase - WEP 128 ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋᠎ᠤᠨ ᠦᠬᠦᠯᠡᠪᠦᠷᠢ + WEP 128 ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋᠎ᠤᠨ ᠦᠬᠦᠯᠡᠪᠦᠷᠢ - Dynamic WEP (802.1X) - ᠬᠦᠳᠡᠯᠦᠩᠬᠦᠢ ᠪᠠᠢᠳᠠᠯWEP (802.1X) + ᠬᠦᠳᠡᠯᠦᠩᠬᠦᠢ ᠪᠠᠢᠳᠠᠯWEP (802.1X) - WPA & WPA2 Enterprise - WPA ᠵᠢᠴᠢWPA2 ᠠᠵᠤ ᠠᠬᠤᠢᠯᠠᠯ + WPA ᠵᠢᠴᠢWPA2 ᠠᠵᠤ ᠠᠬᠤᠢᠯᠠᠯ - Tunneled TLS - ᠨᠦᠬᠡᠨ ᠵᠠᠮTLS + ᠨᠦᠬᠡᠨ ᠵᠠᠮTLS - Protected EAP (PEAP) - ᠬᠠᠮᠠᠭᠠᠯᠠᠯᠳᠠ᠎ᠳᠤ ᠪᠠᠭᠳᠠᠬᠤEAP (PEAP) + ᠬᠠᠮᠠᠭᠠᠯᠠᠯᠳᠠ᠎ᠳᠤ ᠪᠠᠭᠳᠠᠬᠤEAP (PEAP) - Anonymous - ᠪᠤᠷᠤᠭᠤᠯᠤᠭᠰᠠᠨ ᠨᠡᠷ᠎ᠡ + ᠪᠤᠷᠤᠭᠤᠯᠤᠭᠰᠠᠨ ᠨᠡᠷ᠎ᠡ - Authenticated - ᠨᠢᠭᠡᠨᠳᠡ ᠬᠡᠷᠡᠴᠢᠯᠡᠪᠡ + ᠨᠢᠭᠡᠨᠳᠡ ᠬᠡᠷᠡᠴᠢᠯᠡᠪᠡ - Both - ᠬᠤᠶᠠᠭᠤᠯᠠ᠎ᠶᠢ ᠬᠤᠤᠰᠯᠠᠭᠤᠯᠵᠤ ᠬᠡᠷᠡᠭᠯᠡᠬᠦ᠌ + ᠬᠤᠶᠠᠭᠤᠯᠠ᠎ᠶᠢ ᠬᠤᠤᠰᠯᠠᠭᠤᠯᠵᠤ ᠬᠡᠷᠡᠭᠯᠡᠬᠦ᠌ DlgConnHidWifiSecLeap - Connect to Hidden Wi-Fi Network - ᠨᠢᠭᠤᠴᠠᠯᠢᠭ Wi-Fi ᠰᠦᠯᠵᠢᠶ᠎ᠡ᠎ᠳᠦ ᠵᠠᠯᠭᠠᠪᠠ + ᠨᠢᠭᠤᠴᠠᠯᠢᠭ Wi-Fi ᠰᠦᠯᠵᠢᠶ᠎ᠡ᠎ᠳᠦ ᠵᠠᠯᠭᠠᠪᠠ - Add hidden Wi-Fi - ᠨᠢᠭᠤᠴᠠᠯᠢᠭ Wi-Fi ᠨᠡᠮᠡᠬᠦ + ᠨᠢᠭᠤᠴᠠᠯᠢᠭ Wi-Fi ᠨᠡᠮᠡᠬᠦ - Connection - ᠵᠠᠯᠭᠠᠰᠤ ᠳᠤᠬᠢᠷᠠᠭᠤᠯᠬᠤ ᠄ + ᠵᠠᠯᠭᠠᠰᠤ ᠳᠤᠬᠢᠷᠠᠭᠤᠯᠬᠤ ᠄ - Network name - ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠨᠡᠷᠡᠢᠳᠦᠯ + ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠨᠡᠷᠡᠢᠳᠦᠯ - Wi-Fi security - Wi-Fi᠎ᠤ ᠠᠶᠤᠯᠬᠦᠢ ᠱᠢᠨᠵᠢ + Wi-Fi᠎ᠤ ᠠᠶᠤᠯᠬᠦᠢ ᠱᠢᠨᠵᠢ - Authentication - ᠭᠡᠷᠡᠴᠢᠯᠡᠭᠡ ᠃ + ᠭᠡᠷᠡᠴᠢᠯᠡᠭᠡ ᠃ - Username - ᠬᠡᠷᠡᠭᠯᠡᠭᠴᠢ ᠵᠢᠨ ᠨᠡᠷ᠎ᠡ + ᠬᠡᠷᠡᠭᠯᠡᠭᠴᠢ ᠵᠢᠨ ᠨᠡᠷ᠎ᠡ - Password - ᠨᠢᠭᠤᠴᠠ ᠺᠣᠳ᠋᠎ᠢ᠋ ᠵᠠᠰᠠᠬᠤ + ᠨᠢᠭᠤᠴᠠ ᠺᠣᠳ᠋᠎ᠢ᠋ ᠵᠠᠰᠠᠬᠤ - Cancel - ᠪᠣᠯᠢᠬᠤ ᠂ ᠪᠣᠯᠢᠬᠤ + ᠬᠦᠴᠦᠨ ᠦᠭᠡᠶ ᠪᠣᠯᠭᠠᠨ᠎ᠠ᠃ - Connect - ᠰᠢᠷᠪᠢᠬᠦᠷ ᠲᠤ᠌ ᠴᠥᠷᠬᠡᠯᠡᠪᠡ + ᠰᠢᠷᠪᠢᠬᠦᠷ ᠲᠤ᠌ ᠴᠥᠷᠬᠡᠯᠡᠪᠡ - C_reate… - ᠱᠢᠨ᠎ᠡ᠎ᠪᠡᠷ ᠪᠠᠢᠭᠤᠯᠬᠤ… + ᠱᠢᠨ᠎ᠡ᠎ᠪᠡᠷ ᠪᠠᠢᠭᠤᠯᠬᠤ… - None - ᠥᠬᠡᠢ + ᠥᠬᠡᠢ - WPA & WPA2 Personal - WPA ᠪᠣᠯᠣᠨ WPA2 ᠬᠤᠪᠢ ᠬᠥᠮᠥᠨ ᠃ + WPA ᠪᠣᠯᠣᠨ WPA2 ᠬᠤᠪᠢ ᠬᠥᠮᠥᠨ ᠃ - WEP 40/128-bit Key (Hex or ASCII) - WEP 40/128 ᠨᠢᠭᠤᠴᠠ ᠭᠬᠢᠷ (ᠠᠷᠪᠠᠨ ᠵᠢᠷᠭᠤᠭ᠎ᠠ ᠶᠢ ᠣᠷᠣᠭᠤᠯᠬᠤ ᠦᠢᠯᠡᠳᠦᠯ ᠪᠤᠶᠤ ASCII) + WEP 40/128 ᠨᠢᠭᠤᠴᠠ ᠭᠬᠢᠷ (ᠠᠷᠪᠠᠨ ᠵᠢᠷᠭᠤᠭ᠎ᠠ ᠶᠢ ᠣᠷᠣᠭᠤᠯᠬᠤ ᠦᠢᠯᠡᠳᠦᠯ ᠪᠤᠶᠤ ASCII) - WEP 128-bit Passphrase - WEP 128 ᠨᠢᠭᠤᠴᠠ ᠨᠣᠮᠧᠷᠲᠤ ᠦᠭᠡ ᠃ + WEP 128 ᠨᠢᠭᠤᠴᠠ ᠨᠣᠮᠧᠷᠲᠤ ᠦᠭᠡ ᠃ - Dynamic WEP (802.1X) - ᠬᠦᠳᠡᠯᠦᠩᠬᠦᠢ ᠪᠠᠢᠳᠠᠯ WEP (802.1X) + ᠬᠦᠳᠡᠯᠦᠩᠬᠦᠢ ᠪᠠᠢᠳᠠᠯ WEP (802.1X) - WPA & WPA2 Enterprise - WPA ᠵᠢᠴᠢWPA2 ᠠᠵᠤ ᠠᠬᠤᠢᠯᠠᠯ + WPA ᠵᠢᠴᠢWPA2 ᠠᠵᠤ ᠠᠬᠤᠢᠯᠠᠯ - Tunneled TLS - ᠨᠦᠬᠡᠨ ᠵᠠᠮ TLS + ᠨᠦᠬᠡᠨ ᠵᠠᠮ TLS - Protected EAP (PEAP) - ᠬᠠᠮᠠᠭᠠᠯᠠᠯᠳᠠ᠎ᠳᠤ ᠪᠠᠭᠳᠠᠬᠤEAP (PEAP) + ᠬᠠᠮᠠᠭᠠᠯᠠᠯᠳᠠ᠎ᠳᠤ ᠪᠠᠭᠳᠠᠬᠤEAP (PEAP) DlgConnHidWifiSecPeap - Connect to Hidden Wi-Fi Network - ᠨᠢᠭᠤᠴᠠᠯᠢᠭ Wi-Fi ᠰᠦᠯᠵᠢᠶ᠎ᠡ᠎ᠳᠦ ᠵᠠᠯᠭᠠᠪᠠ + ᠨᠢᠭᠤᠴᠠᠯᠢᠭ Wi-Fi ᠰᠦᠯᠵᠢᠶ᠎ᠡ᠎ᠳᠦ ᠵᠠᠯᠭᠠᠪᠠ - Add hidden Wi-Fi - ᠨᠢᠭᠤᠴᠠᠯᠢᠭ Wi-Fi ᠨᠡᠮᠡᠬᠦ + ᠨᠢᠭᠤᠴᠠᠯᠢᠭ Wi-Fi ᠨᠡᠮᠡᠬᠦ - Connection - ᠬᠤᠯᠪᠤᠭᠠᠰᠤ + ᠬᠤᠯᠪᠤᠭᠠᠰᠤ - Network name - ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠨᠡᠷᠡᠢᠳᠦᠯ + ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠨᠡᠷᠡᠢᠳᠦᠯ - Wi-Fi security - Wi-Fi᠎ᠤ ᠠᠶᠤᠯᠬᠦᠢ ᠱᠢᠨᠵᠢ + Wi-Fi᠎ᠤ ᠠᠶᠤᠯᠬᠦᠢ ᠱᠢᠨᠵᠢ - Authentication - ᠭᠡᠷᠡᠴᠢᠯᠡᠭᠡ ᠃ + ᠭᠡᠷᠡᠴᠢᠯᠡᠭᠡ ᠃ - Anonymous identity - ᠨᠡᠷ᠎ᠡ ᠪᠤᠷᠤᠭᠤᠯᠤᠭᠰᠠᠨ ᠪᠡᠶ᠎ᠡ᠎ᠶᠢᠨ ᠭᠠᠷᠤᠯ + ᠨᠡᠷ᠎ᠡ ᠪᠤᠷᠤᠭᠤᠯᠤᠭᠰᠠᠨ ᠪᠡᠶ᠎ᠡ᠎ᠶᠢᠨ ᠭᠠᠷᠤᠯ - Domain - ᠨᠸᠲ᠎ᠦᠨ ᠬᠠᠶᠢᠭ ᠄ + ᠨᠸᠲ᠎ᠦᠨ ᠬᠠᠶᠢᠭ ᠄ - CA certificate - CAᠦᠨᠡᠮᠯᠡᠯ ᠄ + CAᠦᠨᠡᠮᠯᠡᠯ ᠄ - CA certificate password - CA ᠦᠨᠡᠮᠯᠡᠯ᠎ᠦᠨ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠄ + CA ᠦᠨᠡᠮᠯᠡᠯ᠎ᠦᠨ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠄ - No CA certificate is required - CA ᠦᠨᠡᠮᠯᠡᠯ ᠬᠡᠷᠡᠭᠰᠡᠬᠦ᠌ ᠦᠬᠡᠢ + CA ᠦᠨᠡᠮᠯᠡᠯ ᠬᠡᠷᠡᠭᠰᠡᠬᠦ᠌ ᠦᠬᠡᠢ - PEAP version - PEAP ᠬᠡᠪᠯᠡᠯ + PEAP ᠬᠡᠪᠯᠡᠯ - Inner authentication - ᠳᠤᠳᠤᠭᠠᠳᠤ᠎ᠶᠢᠨ ᠭᠡᠷᠡᠴᠢᠯᠡᠯ ᠄ + ᠳᠤᠳᠤᠭᠠᠳᠤ᠎ᠶᠢᠨ ᠭᠡᠷᠡᠴᠢᠯᠡᠯ ᠄ - Username - ᠬᠡᠷᠡᠭᠯᠡᠭᠴᠢ ᠵᠢᠨ ᠨᠡᠷ᠎ᠡ + ᠬᠡᠷᠡᠭᠯᠡᠭᠴᠢ ᠵᠢᠨ ᠨᠡᠷ᠎ᠡ - Password - ᠨᠢᠭᠤᠴᠠ ᠺᠣᠳ᠋᠎ᠢ᠋ ᠵᠠᠰᠠᠬᠤ + ᠨᠢᠭᠤᠴᠠ ᠺᠣᠳ᠋᠎ᠢ᠋ ᠵᠠᠰᠠᠬᠤ - Cancel - ᠪᠣᠯᠢᠬᠤ ᠂ ᠪᠣᠯᠢᠬᠤ + ᠬᠦᠴᠦᠨ ᠦᠭᠡᠶ ᠪᠣᠯᠭᠠᠨ᠎ᠠ᠃ - Connect - ᠰᠢᠷᠪᠢᠬᠦᠷ ᠲᠤ᠌ ᠴᠥᠷᠬᠡᠯᠡᠪᠡ + ᠰᠢᠷᠪᠢᠬᠦᠷ ᠲᠤ᠌ ᠴᠥᠷᠬᠡᠯᠡᠪᠡ - - None - ᠥᠬᠡᠢ + ᠥᠬᠡᠢ - WPA & WPA2 Personal - WPA ᠪᠣᠯᠣᠨ WPA2 ᠬᠤᠪᠢ ᠬᠥᠮᠥᠨ ᠃ + WPA ᠪᠣᠯᠣᠨ WPA2 ᠬᠤᠪᠢ ᠬᠥᠮᠥᠨ ᠃ - WEP 40/128-bit Key (Hex or ASCII) - WEP 40/128 ᠨᠢᠭᠤᠴᠠ ᠭᠬᠢᠷ (ᠠᠷᠪᠠᠨ ᠵᠢᠷᠭᠤᠭ᠎ᠠ ᠶᠢ ᠣᠷᠣᠭᠤᠯᠬᠤ ᠦᠢᠯᠡᠳᠦᠯ ᠪᠤᠶᠤ ASCII) + WEP 40/128 ᠨᠢᠭᠤᠴᠠ ᠭᠬᠢᠷ (ᠠᠷᠪᠠᠨ ᠵᠢᠷᠭᠤᠭ᠎ᠠ ᠶᠢ ᠣᠷᠣᠭᠤᠯᠬᠤ ᠦᠢᠯᠡᠳᠦᠯ ᠪᠤᠶᠤ ASCII) - WEP 128-bit Passphrase - WEP 128 ᠨᠢᠭᠤᠴᠠ ᠨᠣᠮᠧᠷᠲᠤ ᠦᠭᠡ ᠃ + WEP 128 ᠨᠢᠭᠤᠴᠠ ᠨᠣᠮᠧᠷᠲᠤ ᠦᠭᠡ ᠃ - Dynamic WEP (802.1X) - ᠬᠦᠳᠡᠯᠦᠩᠬᠦᠢ ᠪᠠᠢᠳᠠᠯ WEP (802.1X) + ᠬᠦᠳᠡᠯᠦᠩᠬᠦᠢ ᠪᠠᠢᠳᠠᠯ WEP (802.1X) - WPA & WPA2 Enterprise - WPA ᠵᠢᠴᠢWPA2 ᠠᠵᠤ ᠠᠬᠤᠢᠯᠠᠯ + WPA ᠵᠢᠴᠢWPA2 ᠠᠵᠤ ᠠᠬᠤᠢᠯᠠᠯ - Tunneled TLS - ᠨᠦᠬᠡᠨ ᠵᠠᠮ TLS + ᠨᠦᠬᠡᠨ ᠵᠠᠮ TLS - Protected EAP (PEAP) - ᠬᠠᠮᠠᠭᠠᠯᠠᠭᠳᠠᠭᠰᠠᠨ EAP (PEAP) + ᠬᠠᠮᠠᠭᠠᠯᠠᠭᠳᠠᠭᠰᠠᠨ EAP (PEAP) - Choose from file - ᠹᠠᠢᠯ᠎ᠠᠴᠠ ᠰᠤᠩᠭᠤᠬᠤ + ᠹᠠᠢᠯ᠎ᠠᠴᠠ ᠰᠤᠩᠭᠤᠬᠤ - Automatic - ᠠᠦ᠋ᠲ᠋ᠤ᠋ + ᠠᠦ᠋ᠲ᠋ᠤ᠋ - Version 0 - ᠬᠡᠪᠯᠡᠯ0 + ᠬᠡᠪᠯᠡᠯ0 - Version 1 - ᠬᠡᠪᠯᠡᠯ1 + ᠬᠡᠪᠯᠡᠯ1 DlgConnHidWifiSecPwd - Connect to Hidden Wi-Fi Network - ᠨᠢᠭᠤᠴᠠᠯᠢᠭ Wi-Fi ᠰᠦᠯᠵᠢᠶ᠎ᠡ᠎ᠳᠦ ᠵᠠᠯᠭᠠᠪᠠ + ᠨᠢᠭᠤᠴᠠᠯᠢᠭ Wi-Fi ᠰᠦᠯᠵᠢᠶ᠎ᠡ᠎ᠳᠦ ᠵᠠᠯᠭᠠᠪᠠ - Add hidden Wi-Fi - ᠨᠢᠭᠤᠴᠠᠯᠢᠭ Wi-Fi ᠨᠡᠮᠡᠬᠦ + ᠨᠢᠭᠤᠴᠠᠯᠢᠭ Wi-Fi ᠨᠡᠮᠡᠬᠦ - Connection - ᠵᠠᠯᠭᠠᠰᠤ ᠳᠤᠬᠢᠷᠠᠭᠤᠯᠬᠤ ᠄ + ᠵᠠᠯᠭᠠᠰᠤ ᠳᠤᠬᠢᠷᠠᠭᠤᠯᠬᠤ ᠄ - Network name - ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠨᠡᠷᠡᠢᠳᠦᠯ + ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠨᠡᠷᠡᠢᠳᠦᠯ - Wi-Fi security - Wi-Fi᠎ᠤ ᠠᠶᠤᠯᠬᠦᠢ ᠱᠢᠨᠵᠢ + Wi-Fi᠎ᠤ ᠠᠶᠤᠯᠬᠦᠢ ᠱᠢᠨᠵᠢ - Authentication - ᠭᠡᠷᠡᠴᠢᠯᠡᠭᠡ ᠃ + ᠭᠡᠷᠡᠴᠢᠯᠡᠭᠡ ᠃ - Username - ᠬᠡᠷᠡᠭᠯᠡᠭᠴᠢ ᠵᠢᠨ ᠨᠡᠷ᠎ᠡ + ᠬᠡᠷᠡᠭᠯᠡᠭᠴᠢ ᠵᠢᠨ ᠨᠡᠷ᠎ᠡ - Password - ᠨᠢᠭᠤᠴᠠ ᠺᠣᠳ᠋᠎ᠢ᠋ ᠵᠠᠰᠠᠬᠤ + ᠨᠢᠭᠤᠴᠠ ᠺᠣᠳ᠋᠎ᠢ᠋ ᠵᠠᠰᠠᠬᠤ - Cancel - ᠪᠣᠯᠢᠬᠤ ᠂ ᠪᠣᠯᠢᠬᠤ + ᠬᠦᠴᠦᠨ ᠦᠭᠡᠶ ᠪᠣᠯᠭᠠᠨ᠎ᠠ᠃ - Connect - ᠰᠢᠷᠪᠢᠬᠦᠷ ᠲᠤ᠌ ᠴᠥᠷᠬᠡᠯᠡᠪᠡ + ᠰᠢᠷᠪᠢᠬᠦᠷ ᠲᠤ᠌ ᠴᠥᠷᠬᠡᠯᠡᠪᠡ - C_reate… - ᠱᠢᠨ᠎ᠡ᠎ᠪᠡᠷ ᠪᠠᠢᠭᠤᠯᠬᠤ… + ᠱᠢᠨ᠎ᠡ᠎ᠪᠡᠷ ᠪᠠᠢᠭᠤᠯᠬᠤ… - None - ᠥᠬᠡᠢ + ᠥᠬᠡᠢ - WPA & WPA2 Personal - WPA ᠪᠣᠯᠣᠨ WPA2 ᠬᠤᠪᠢ ᠬᠥᠮᠥᠨ ᠃ + WPA ᠪᠣᠯᠣᠨ WPA2 ᠬᠤᠪᠢ ᠬᠥᠮᠥᠨ ᠃ - WEP 40/128-bit Key (Hex or ASCII) - WEP 40/128 ᠨᠢᠭᠤᠴᠠ ᠭᠬᠢᠷ (ᠠᠷᠪᠠᠨ ᠵᠢᠷᠭᠤᠭ᠎ᠠ ᠶᠢ ᠣᠷᠣᠭᠤᠯᠬᠤ ᠦᠢᠯᠡᠳᠦᠯ ᠪᠤᠶᠤ ASCII) + WEP 40/128 ᠨᠢᠭᠤᠴᠠ ᠭᠬᠢᠷ (ᠠᠷᠪᠠᠨ ᠵᠢᠷᠭᠤᠭ᠎ᠠ ᠶᠢ ᠣᠷᠣᠭᠤᠯᠬᠤ ᠦᠢᠯᠡᠳᠦᠯ ᠪᠤᠶᠤ ASCII) - WEP 128-bit Passphrase - WEP 128 ᠨᠢᠭᠤᠴᠠ ᠨᠣᠮᠧᠷᠲᠤ ᠦᠭᠡ ᠃ + WEP 128 ᠨᠢᠭᠤᠴᠠ ᠨᠣᠮᠧᠷᠲᠤ ᠦᠭᠡ ᠃ - Dynamic WEP (802.1X) - ᠬᠦᠳᠡᠯᠦᠩᠬᠦᠢ ᠪᠠᠢᠳᠠᠯ WEP (802.1X) + ᠬᠦᠳᠡᠯᠦᠩᠬᠦᠢ ᠪᠠᠢᠳᠠᠯ WEP (802.1X) - WPA & WPA2 Enterprise - WPA ᠵᠢᠴᠢWPA2 ᠠᠵᠤ ᠠᠬᠤᠢᠯᠠᠯ + WPA ᠵᠢᠴᠢWPA2 ᠠᠵᠤ ᠠᠬᠤᠢᠯᠠᠯ - Tunneled TLS - ᠨᠦᠬᠡᠨ ᠵᠠᠮ TLS + ᠨᠦᠬᠡᠨ ᠵᠠᠮ TLS - Protected EAP (PEAP) - ᠬᠠᠮᠠᠭᠠᠯᠠᠭᠳᠠᠭᠰᠠᠨ EAP (PEAP) + ᠬᠠᠮᠠᠭᠠᠯᠠᠭᠳᠠᠭᠰᠠᠨ EAP (PEAP) DlgConnHidWifiSecTls - Connect to Hidden Wi-Fi Network - ᠨᠢᠭᠤᠴᠠᠯᠢᠭ Wi-Fi ᠰᠦᠯᠵᠢᠶ᠎ᠡ᠎ᠳᠦ ᠵᠠᠯᠭᠠᠪᠠ + ᠨᠢᠭᠤᠴᠠᠯᠢᠭ Wi-Fi ᠰᠦᠯᠵᠢᠶ᠎ᠡ᠎ᠳᠦ ᠵᠠᠯᠭᠠᠪᠠ - Add hidden Wi-Fi - ᠨᠢᠭᠤᠴᠠᠯᠢᠭ Wi-Fi ᠨᠡᠮᠡᠬᠦ + ᠨᠢᠭᠤᠴᠠᠯᠢᠭ Wi-Fi ᠨᠡᠮᠡᠬᠦ - Connection - ᠬᠤᠯᠪᠤᠭᠠᠰᠤ + ᠬᠤᠯᠪᠤᠭᠠᠰᠤ - Network name - ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠨᠡᠷᠡᠢᠳᠦᠯ + ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠨᠡᠷᠡᠢᠳᠦᠯ - Wi-Fi security - Wi-Fi᠎ᠤ ᠠᠶᠤᠯᠬᠦᠢ ᠱᠢᠨᠵᠢ + Wi-Fi᠎ᠤ ᠠᠶᠤᠯᠬᠦᠢ ᠱᠢᠨᠵᠢ - Authentication - ᠭᠡᠷᠡᠴᠢᠯᠡᠭᠡ ᠃ + ᠭᠡᠷᠡᠴᠢᠯᠡᠭᠡ ᠃ - Identity - ᠪᠡᠶ᠎ᠡ᠎ᠶᠢᠨ ᠭᠠᠷᠤᠯ ᠄ + ᠪᠡᠶ᠎ᠡ᠎ᠶᠢᠨ ᠭᠠᠷᠤᠯ ᠄ - Domain - ᠣᠷᠣᠨ ᠪᠦᠰᠡ + ᠣᠷᠣᠨ ᠪᠦᠰᠡ - CA certificate - CA ᠬᠡᠷᠡᠴᠢᠯᠡᠯ + CA ᠬᠡᠷᠡᠴᠢᠯᠡᠯ - CA certificate password - CA ᠬᠡᠷᠡᠴᠢᠯᠡᠯ ᠤ᠋ᠨ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ + CA ᠬᠡᠷᠡᠴᠢᠯᠡᠯ ᠤ᠋ᠨ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ - No CA certificate is required - CA ᠬᠡᠷᠡᠴᠢᠯᠡᠯ ᠬᠡᠷᠡᠭᠰᠡᠬᠦ᠌ ᠦᠬᠡᠢ + CA ᠬᠡᠷᠡᠴᠢᠯᠡᠯ ᠬᠡᠷᠡᠭᠰᠡᠬᠦ᠌ ᠦᠬᠡᠢ - User certificate - ᠬᠡᠷᠡᠭᠯᠡᠭᠴᠢ ᠵᠢᠨ ᠦᠨᠡᠮᠯᠡᠯ + ᠬᠡᠷᠡᠭᠯᠡᠭᠴᠢ ᠵᠢᠨ ᠦᠨᠡᠮᠯᠡᠯ - User certificate password - ᠬᠡᠷᠡᠭᠯᠡᠭᠴᠢ ᠵᠢᠨ ᠬᠡᠷᠡᠴᠢᠯᠡᠯ ᠤ᠋ᠨ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ + ᠬᠡᠷᠡᠭᠯᠡᠭᠴᠢ ᠵᠢᠨ ᠬᠡᠷᠡᠴᠢᠯᠡᠯ ᠤ᠋ᠨ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ - User private key - ᠬᠡᠷᠡᠭᠯᠡᠭᠴᠢ᠎ᠶᠢᠨ ᠬᠤᠪᠢ᠎ᠶᠢᠨ ᠳᠦᠯᠬᠢᠬᠦᠷ ᠄ + ᠬᠡᠷᠡᠭᠯᠡᠭᠴᠢ᠎ᠶᠢᠨ ᠬᠤᠪᠢ᠎ᠶᠢᠨ ᠳᠦᠯᠬᠢᠬᠦᠷ ᠄ - User key password - ᠬᠡᠷᠡᠭᠯᠡᠭᠴᠢ᠎ᠶᠢᠨ ᠨᠢᠭᠤᠴᠠ ᠳᠦᠯᠬᠢᠬᠦᠷ᠎ᠦᠨ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠄ + ᠬᠡᠷᠡᠭᠯᠡᠭᠴᠢ᠎ᠶᠢᠨ ᠨᠢᠭᠤᠴᠠ ᠳᠦᠯᠬᠢᠬᠦᠷ᠎ᠦᠨ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠄ - Cancel - ᠪᠣᠯᠢᠬᠤ ᠂ ᠪᠣᠯᠢᠬᠤ + ᠬᠦᠴᠦᠨ ᠦᠭᠡᠶ ᠪᠣᠯᠭᠠᠨ᠎ᠠ᠃ - Connect - ᠴᠦᠷᠬᠡᠯᠡᠬᠡ + ᠴᠦᠷᠬᠡᠯᠡᠬᠡ - C_reate… - ᠱᠢᠨ᠎ᠡ᠎ᠪᠡᠷ ᠪᠠᠢᠭᠤᠯᠬᠤ… + ᠱᠢᠨ᠎ᠡ᠎ᠪᠡᠷ ᠪᠠᠢᠭᠤᠯᠬᠤ… - - - - None - ᠥᠬᠡᠢ + ᠥᠬᠡᠢ - WPA & WPA2 Personal - WPA ᠪᠣᠯᠣᠨ WPA2 ᠬᠤᠪᠢ ᠬᠥᠮᠥᠨ ᠃ + WPA ᠪᠣᠯᠣᠨ WPA2 ᠬᠤᠪᠢ ᠬᠥᠮᠥᠨ ᠃ - WEP 40/128-bit Key (Hex or ASCII) - WEP 40/128 ᠨᠢᠭᠤᠴᠠ ᠭᠬᠢᠷ (ᠠᠷᠪᠠᠨ ᠵᠢᠷᠭᠤᠭ᠎ᠠ ᠶᠢ ᠣᠷᠣᠭᠤᠯᠬᠤ ᠦᠢᠯᠡᠳᠦᠯ ᠪᠤᠶᠤ ASCII) + WEP 40/128 ᠨᠢᠭᠤᠴᠠ ᠭᠬᠢᠷ (ᠠᠷᠪᠠᠨ ᠵᠢᠷᠭᠤᠭ᠎ᠠ ᠶᠢ ᠣᠷᠣᠭᠤᠯᠬᠤ ᠦᠢᠯᠡᠳᠦᠯ ᠪᠤᠶᠤ ASCII) - WEP 128-bit Passphrase - WEP 128 ᠨᠢᠭᠤᠴᠠ ᠨᠣᠮᠧᠷᠲᠤ ᠦᠭᠡ ᠃ + WEP 128 ᠨᠢᠭᠤᠴᠠ ᠨᠣᠮᠧᠷᠲᠤ ᠦᠭᠡ ᠃ - Dynamic WEP (802.1X) - ᠬᠦᠳᠡᠯᠦᠩᠬᠦᠢ ᠪᠠᠢᠳᠠᠯ WEP (802.1X) + ᠬᠦᠳᠡᠯᠦᠩᠬᠦᠢ ᠪᠠᠢᠳᠠᠯ WEP (802.1X) - WPA & WPA2 Enterprise - WPA ᠵᠢᠴᠢWPA2 ᠠᠵᠤ ᠠᠬᠤᠢᠯᠠᠯ + WPA ᠵᠢᠴᠢWPA2 ᠠᠵᠤ ᠠᠬᠤᠢᠯᠠᠯ - Tunneled TLS - ᠨᠦᠬᠡᠨ ᠵᠠᠮ TLS + ᠨᠦᠬᠡᠨ ᠵᠠᠮ TLS - Protected EAP (PEAP) - ᠬᠠᠮᠠᠭᠠᠯᠠᠭᠳᠠᠭᠰᠠᠨ EAP (PEAP) + ᠬᠠᠮᠠᠭᠠᠯᠠᠭᠳᠠᠭᠰᠠᠨ EAP (PEAP) - - - Choose from file - ᠹᠠᠢᠯ᠎ᠠᠴᠠ ᠰᠤᠩᠭᠤᠬᠤ + ᠹᠠᠢᠯ᠎ᠠᠴᠠ ᠰᠤᠩᠭᠤᠬᠤ DlgConnHidWifiSecTunnelTLS - Connect to Hidden Wi-Fi Network - ᠨᠢᠭᠤᠴᠠᠯᠢᠭ Wi-Fi ᠰᠦᠯᠵᠢᠶ᠎ᠡ᠎ᠳᠦ ᠵᠠᠯᠭᠠᠪᠠ + ᠨᠢᠭᠤᠴᠠᠯᠢᠭ Wi-Fi ᠰᠦᠯᠵᠢᠶ᠎ᠡ᠎ᠳᠦ ᠵᠠᠯᠭᠠᠪᠠ - Add hidden Wi-Fi - ᠤᠳᠠᠰᠤ ᠦᠬᠡᠢ ᠰᠦᠯᠵᠢᠶ᠎ᠡ ᠨᠡᠮᠡᠵᠤ ᠤᠷᠤᠭᠤᠯᠬᠤ + ᠤᠳᠠᠰᠤ ᠦᠬᠡᠢ ᠰᠦᠯᠵᠢᠶ᠎ᠡ ᠨᠡᠮᠡᠵᠤ ᠤᠷᠤᠭᠤᠯᠬᠤ - Connection - ᠬᠤᠯᠪᠤᠭᠠᠰᠤ + ᠬᠤᠯᠪᠤᠭᠠᠰᠤ - Network name - ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠨᠡᠷᠡᠢᠳᠦᠯ + ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠨᠡᠷᠡᠢᠳᠦᠯ - Wi-Fi security - Wi-Fi᠎ᠤ ᠠᠶᠤᠯᠬᠦᠢ ᠱᠢᠨᠵᠢ + Wi-Fi᠎ᠤ ᠠᠶᠤᠯᠬᠦᠢ ᠱᠢᠨᠵᠢ - Authentication - ᠡᠷᠬᠡ ᠤᠯᠭᠤᠬᠤ + ᠡᠷᠬᠡ ᠤᠯᠭᠤᠬᠤ - Anonymous identity - ᠨᠡᠷ᠎ᠡ ᠪᠤᠷᠤᠭᠤᠯᠤᠭᠰᠠᠨ ᠪᠡᠶ᠎ᠡ᠎ᠶᠢᠨ ᠭᠠᠷᠤᠯ + ᠨᠡᠷ᠎ᠡ ᠪᠤᠷᠤᠭᠤᠯᠤᠭᠰᠠᠨ ᠪᠡᠶ᠎ᠡ᠎ᠶᠢᠨ ᠭᠠᠷᠤᠯ - Domain - ᠣᠷᠣᠨ ᠪᠦᠰᠡ + ᠣᠷᠣᠨ ᠪᠦᠰᠡ - CA certificate - CA ᠬᠡᠷᠡᠴᠢᠯᠡᠯ + CA ᠬᠡᠷᠡᠴᠢᠯᠡᠯ - CA certificate password - CA ᠬᠡᠷᠡᠴᠢᠯᠡᠯ ᠤ᠋ᠨ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ + CA ᠬᠡᠷᠡᠴᠢᠯᠡᠯ ᠤ᠋ᠨ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ - No CA certificate is required - CA ᠬᠡᠷᠡᠴᠢᠯᠡᠯ ᠬᠡᠷᠡᠭᠰᠡᠬᠦ᠌ ᠦᠬᠡᠢ + CA ᠬᠡᠷᠡᠴᠢᠯᠡᠯ ᠬᠡᠷᠡᠭᠰᠡᠬᠦ᠌ ᠦᠬᠡᠢ - Inner authentication - ᠳᠤᠳᠤᠭᠠᠳᠤ᠎ᠶᠢᠨ ᠭᠡᠷᠡᠴᠢᠯᠡᠯ ᠄ + ᠳᠤᠳᠤᠭᠠᠳᠤ᠎ᠶᠢᠨ ᠭᠡᠷᠡᠴᠢᠯᠡᠯ ᠄ - Username - ᠬᠡᠷᠡᠭᠯᠡᠭᠴᠢ ᠵᠢᠨ ᠨᠡᠷ᠎ᠡ + ᠬᠡᠷᠡᠭᠯᠡᠭᠴᠢ ᠵᠢᠨ ᠨᠡᠷ᠎ᠡ - Password - ᠨᠢᠭᠤᠴᠠ ᠺᠣᠳ᠋᠎ᠢ᠋ ᠵᠠᠰᠠᠬᠤ + ᠨᠢᠭᠤᠴᠠ ᠺᠣᠳ᠋᠎ᠢ᠋ ᠵᠠᠰᠠᠬᠤ - Cancel - ᠪᠣᠯᠢᠬᠤ ᠂ ᠪᠣᠯᠢᠬᠤ + ᠬᠦᠴᠦᠨ ᠦᠭᠡᠶ ᠪᠣᠯᠭᠠᠨ᠎ᠠ᠃ - Connect - ᠰᠢᠷᠪᠢᠬᠦᠷ ᠲᠤ᠌ ᠴᠥᠷᠬᠡᠯᠡᠪᠡ + ᠰᠢᠷᠪᠢᠬᠦᠷ ᠲᠤ᠌ ᠴᠥᠷᠬᠡᠯᠡᠪᠡ - C_reate… - ᠱᠢᠨ᠎ᠡ᠎ᠪᠡᠷ ᠪᠠᠢᠭᠤᠯᠬᠤ… + ᠱᠢᠨ᠎ᠡ᠎ᠪᠡᠷ ᠪᠠᠢᠭᠤᠯᠬᠤ… - - None - ᠥᠬᠡᠢ + ᠥᠬᠡᠢ - WPA & WPA2 Personal - WPA ᠪᠣᠯᠣᠨ WPA2 ᠬᠤᠪᠢ ᠬᠥᠮᠥᠨ ᠃ + WPA ᠪᠣᠯᠣᠨ WPA2 ᠬᠤᠪᠢ ᠬᠥᠮᠥᠨ ᠃ - WEP 40/128-bit Key (Hex or ASCII) - WEP 40/128 ᠨᠢᠭᠤᠴᠠ ᠭᠬᠢᠷ (ᠠᠷᠪᠠᠨ ᠵᠢᠷᠭᠤᠭ᠎ᠠ ᠶᠢ ᠣᠷᠣᠭᠤᠯᠬᠤ ᠦᠢᠯᠡᠳᠦᠯ ᠪᠤᠶᠤ ASCII) + WEP 40/128 ᠨᠢᠭᠤᠴᠠ ᠭᠬᠢᠷ (ᠠᠷᠪᠠᠨ ᠵᠢᠷᠭᠤᠭ᠎ᠠ ᠶᠢ ᠣᠷᠣᠭᠤᠯᠬᠤ ᠦᠢᠯᠡᠳᠦᠯ ᠪᠤᠶᠤ ASCII) - WEP 128-bit Passphrase - WEP 128 ᠨᠢᠭᠤᠴᠠ ᠨᠣᠮᠧᠷᠲᠤ ᠦᠭᠡ ᠃ + WEP 128 ᠨᠢᠭᠤᠴᠠ ᠨᠣᠮᠧᠷᠲᠤ ᠦᠭᠡ ᠃ - Dynamic WEP (802.1X) - ᠬᠦᠳᠡᠯᠦᠩᠬᠦᠢ ᠪᠠᠢᠳᠠᠯ WEP (802.1X) + ᠬᠦᠳᠡᠯᠦᠩᠬᠦᠢ ᠪᠠᠢᠳᠠᠯ WEP (802.1X) - WPA & WPA2 Enterprise - WPA ᠵᠢᠴᠢWPA2 ᠠᠵᠤ ᠠᠬᠤᠢᠯᠠᠯ + WPA ᠵᠢᠴᠢWPA2 ᠠᠵᠤ ᠠᠬᠤᠢᠯᠠᠯ - Tunneled TLS - ᠨᠦᠬᠡᠨ ᠵᠠᠮ TLS + ᠨᠦᠬᠡᠨ ᠵᠠᠮ TLS - Protected EAP (PEAP) - ᠬᠠᠮᠠᠭᠠᠯᠠᠭᠳᠠᠭᠰᠠᠨ EAP (PEAP) + ᠬᠠᠮᠠᠭᠠᠯᠠᠭᠳᠠᠭᠰᠠᠨ EAP (PEAP) - Choose from file - ᠹᠠᠢᠯ᠎ᠠᠴᠠ ᠰᠤᠩᠭᠤᠬᠤ + ᠹᠠᠢᠯ᠎ᠠᠴᠠ ᠰᠤᠩᠭᠤᠬᠤ DlgConnHidWifiWep - Connect to Hidden Wi-Fi Network - ᠨᠢᠭᠤᠴᠠᠯᠢᠭ Wi-Fi ᠰᠦᠯᠵᠢᠶ᠎ᠡ᠎ᠳᠦ ᠵᠠᠯᠭᠠᠪᠠ + ᠨᠢᠭᠤᠴᠠᠯᠢᠭ Wi-Fi ᠰᠦᠯᠵᠢᠶ᠎ᠡ᠎ᠳᠦ ᠵᠠᠯᠭᠠᠪᠠ - Add hidden Wi-Fi - ᠨᠢᠭᠤᠴᠠᠯᠢᠭ Wi-Fi ᠨᠡᠮᠡᠬᠦ + ᠨᠢᠭᠤᠴᠠᠯᠢᠭ Wi-Fi ᠨᠡᠮᠡᠬᠦ - Connection - ᠬᠤᠯᠪᠤᠭᠠᠰᠤ + ᠬᠤᠯᠪᠤᠭᠠᠰᠤ - Network name - ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠨᠡᠷᠡᠢᠳᠦᠯ + ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠨᠡᠷᠡᠢᠳᠦᠯ - Wi-Fi security - Wi-Fi᠎ᠤ ᠠᠶᠤᠯᠬᠦᠢ ᠱᠢᠨᠵᠢ + Wi-Fi᠎ᠤ ᠠᠶᠤᠯᠬᠦᠢ ᠱᠢᠨᠵᠢ - Key - ᠨᠢᠭᠤᠴᠠ ᠳᠦᠯᠬᠢᠬᠦᠷ + ᠨᠢᠭᠤᠴᠠ ᠳᠦᠯᠬᠢᠬᠦᠷ - WEP index - WEPᠡᠷᠢᠯᠲᠡ + WEPᠡᠷᠢᠯᠲᠡ - Authentication - ᠭᠡᠷᠡᠴᠢᠯᠡᠭᠡ ᠃ + ᠭᠡᠷᠡᠴᠢᠯᠡᠭᠡ ᠃ - Cancel - ᠪᠣᠯᠢᠬᠤ ᠂ ᠪᠣᠯᠢᠬᠤ + ᠬᠦᠴᠦᠨ ᠦᠭᠡᠶ ᠪᠣᠯᠭᠠᠨ᠎ᠠ᠃ - Connect - ᠰᠢᠷᠪᠢᠬᠦᠷ ᠲᠤ᠌ ᠴᠥᠷᠬᠡᠯᠡᠪᠡ + ᠰᠢᠷᠪᠢᠬᠦᠷ ᠲᠤ᠌ ᠴᠥᠷᠬᠡᠯᠡᠪᠡ - C_reate… - ᠱᠢᠨ᠎ᠡ᠎ᠪᠡᠷ ᠪᠠᠢᠭᠤᠯᠬᠤ… + ᠱᠢᠨ᠎ᠡ᠎ᠪᠡᠷ ᠪᠠᠢᠭᠤᠯᠬᠤ… - None - ᠥᠬᠡᠢ + ᠥᠬᠡᠢ - WPA & WPA2 Personal - WPA ᠪᠣᠯᠣᠨ WPA2 ᠬᠤᠪᠢ ᠬᠥᠮᠥᠨ ᠃ + WPA ᠪᠣᠯᠣᠨ WPA2 ᠬᠤᠪᠢ ᠬᠥᠮᠥᠨ ᠃ - WEP 40/128-bit Key (Hex or ASCII) - WEP 40/128 ᠨᠢᠭᠤᠴᠠ ᠭᠬᠢᠷ (ᠠᠷᠪᠠᠨ ᠵᠢᠷᠭᠤᠭ᠎ᠠ ᠶᠢ ᠣᠷᠣᠭᠤᠯᠬᠤ ᠦᠢᠯᠡᠳᠦᠯ ᠪᠤᠶᠤ ASCII) + WEP 40/128 ᠨᠢᠭᠤᠴᠠ ᠭᠬᠢᠷ (ᠠᠷᠪᠠᠨ ᠵᠢᠷᠭᠤᠭ᠎ᠠ ᠶᠢ ᠣᠷᠣᠭᠤᠯᠬᠤ ᠦᠢᠯᠡᠳᠦᠯ ᠪᠤᠶᠤ ASCII) - WEP 128-bit Passphrase - WEP 128 ᠨᠢᠭᠤᠴᠠ ᠨᠣᠮᠧᠷᠲᠤ ᠦᠭᠡ ᠃ + WEP 128 ᠨᠢᠭᠤᠴᠠ ᠨᠣᠮᠧᠷᠲᠤ ᠦᠭᠡ ᠃ - Dynamic WEP (802.1X) - ᠬᠦᠳᠡᠯᠦᠩᠬᠦᠢ ᠪᠠᠢᠳᠠᠯ WEP (802.1X) + ᠬᠦᠳᠡᠯᠦᠩᠬᠦᠢ ᠪᠠᠢᠳᠠᠯ WEP (802.1X) - WPA & WPA2 Enterprise - WPA ᠵᠢᠴᠢWPA2 ᠠᠵᠤ ᠠᠬᠤᠢᠯᠠᠯ + WPA ᠵᠢᠴᠢWPA2 ᠠᠵᠤ ᠠᠬᠤᠢᠯᠠᠯ - 1(default) - 1( ᠠᠶᠠᠳᠠᠯ) + 1( ᠠᠶᠠᠳᠠᠯ) - Open System - ᠨᠡᠬᠡᠬᠡᠯᠳᠡᠳᠡᠢ ᠱᠢᠰᠲ᠋ᠧᠮ + ᠨᠡᠬᠡᠬᠡᠯᠳᠡᠳᠡᠢ ᠱᠢᠰᠲ᠋ᠧᠮ - Shared Key - ᠬᠠᠮᠳᠤᠪᠠᠷ ᠡᠳ᠋ᠯᠡᠬᠦ᠌ ᠨᠢᠭᠤᠴᠠ ᠳᠦᠯᠬᠢᠬᠦᠷ + ᠬᠠᠮᠳᠤᠪᠠᠷ ᠡᠳ᠋ᠯᠡᠬᠦ᠌ ᠨᠢᠭᠤᠴᠠ ᠳᠦᠯᠬᠢᠬᠦᠷ DlgConnHidWifiWpa - Connect to Hidden Wi-Fi Network - ᠨᠢᠭᠤᠴᠠᠯᠢᠭ Wi-Fi ᠰᠦᠯᠵᠢᠶ᠎ᠡ᠎ᠳᠦ ᠵᠠᠯᠭᠠᠪᠠ + ᠨᠢᠭᠤᠴᠠᠯᠢᠭ Wi-Fi ᠰᠦᠯᠵᠢᠶ᠎ᠡ᠎ᠳᠦ ᠵᠠᠯᠭᠠᠪᠠ - Add Hidden Wi-Fi - ᠤᠳᠠᠰᠤ ᠦᠬᠡᠢ ᠰᠦᠯᠵᠢᠶ᠎ᠡ ᠨᠡᠮᠡᠵᠤ ᠤᠷᠤᠭᠤᠯᠬᠤ + ᠤᠳᠠᠰᠤ ᠦᠬᠡᠢ ᠰᠦᠯᠵᠢᠶ᠎ᠡ ᠨᠡᠮᠡᠵᠤ ᠤᠷᠤᠭᠤᠯᠬᠤ - Connection - ᠬᠤᠯᠪᠤᠭᠠᠰᠤ + ᠬᠤᠯᠪᠤᠭᠠᠰᠤ - Wi-Fi name - ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠨᠡᠷᠡᠢᠳᠦᠯ + ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠨᠡᠷᠡᠢᠳᠦᠯ - Wi-Fi security - Wi-Fi᠎ᠤ ᠠᠶᠤᠯᠬᠦᠢ ᠱᠢᠨᠵᠢ + Wi-Fi᠎ᠤ ᠠᠶᠤᠯᠬᠦᠢ ᠱᠢᠨᠵᠢ - Password - ᠨᠢᠭᠤᠴᠠ ᠺᠣᠳ᠋᠎ᠢ᠋ ᠵᠠᠰᠠᠬᠤ + ᠨᠢᠭᠤᠴᠠ ᠺᠣᠳ᠋᠎ᠢ᠋ ᠵᠠᠰᠠᠬᠤ - Cancel - ᠪᠣᠯᠢᠬᠤ ᠂ ᠪᠣᠯᠢᠬᠤ + ᠬᠦᠴᠦᠨ ᠦᠭᠡᠶ ᠪᠣᠯᠭᠠᠨ᠎ᠠ᠃ - Connect - ᠰᠢᠷᠪᠢᠬᠦᠷ ᠲᠤ᠌ ᠴᠥᠷᠬᠡᠯᠡᠪᠡ + ᠰᠢᠷᠪᠢᠬᠦᠷ ᠲᠤ᠌ ᠴᠥᠷᠬᠡᠯᠡᠪᠡ - C_reate… - ᠱᠢᠨ᠎ᠡ᠎ᠪᠡᠷ ᠪᠠᠢᠭᠤᠯᠬᠤ… + ᠱᠢᠨ᠎ᠡ᠎ᠪᠡᠷ ᠪᠠᠢᠭᠤᠯᠬᠤ… - None - ᠥᠬᠡᠢ + ᠥᠬᠡᠢ - WPA & WPA2 Personal - WPA ᠪᠣᠯᠣᠨ WPA2 ᠬᠤᠪᠢ ᠬᠥᠮᠥᠨ ᠃ + WPA ᠪᠣᠯᠣᠨ WPA2 ᠬᠤᠪᠢ ᠬᠥᠮᠥᠨ ᠃ WEP 40/128-bit Key (Hex or ASCII) @@ -1640,209 +1331,74 @@ DlgHotspotCreate - Dialog - ᠦᠬᠡᠷᠡᠴᠢᠯᠡᠭᠰᠡᠨ ᠴᠠᠭ + ᠦᠬᠡᠷᠡᠴᠢᠯᠡᠭᠰᠡᠨ ᠴᠠᠭ - Create Hotspot - ᠬᠤᠪᠢ᠎ᠶᠢᠨ ᠬᠠᠯᠠᠮᠱᠢᠯ ᠴᠡᠭ ᠪᠠᠢᠭᠤᠯᠬᠤ + ᠬᠤᠪᠢ᠎ᠶᠢᠨ ᠬᠠᠯᠠᠮᠱᠢᠯ ᠴᠡᠭ ᠪᠠᠢᠭᠤᠯᠬᠤ - Network name - ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠨᠡᠷᠡᠢᠳᠦᠯ + ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠨᠡᠷᠡᠢᠳᠦᠯ - Wi-Fi security - Wi-Fi᠎ᠤ ᠠᠶᠤᠯᠬᠦᠢ ᠱᠢᠨᠵᠢ + Wi-Fi᠎ᠤ ᠠᠶᠤᠯᠬᠦᠢ ᠱᠢᠨᠵᠢ - Password - ᠨᠢᠭᠤᠴᠠ ᠺᠣᠳ᠋᠎ᠢ᠋ ᠵᠠᠰᠠᠬᠤ + ᠨᠢᠭᠤᠴᠠ ᠺᠣᠳ᠋᠎ᠢ᠋ ᠵᠠᠰᠠᠬᠤ - Cancel - ᠪᠣᠯᠢᠬᠤ ᠂ ᠪᠣᠯᠢᠬᠤ + ᠬᠦᠴᠦᠨ ᠦᠭᠡᠶ ᠪᠣᠯᠭᠠᠨ᠎ᠠ᠃ - Ok - Ok + Ok - None - ᠥᠬᠡᠢ + ᠥᠬᠡᠢ - WPA & WPA2 Personal - WPA ᠪᠣᠯᠣᠨ WPA2 ᠬᠤᠪᠢ ᠬᠥᠮᠥᠨ ᠃ - - - - EngineDevice - - - yes - - - - - no - - - - - Yes - - - - - No - - - - - %1% available, charged - - - - - Left %1h %2m (%3%) - - - - - %1% available - - - - - Left %1h %2m to full - - - - - charging (%1%) - - - - - %1 waiting to discharge (%2%) - - - - - %1 waiting to charge (%2%) - - - - - AC adapter - - - - - Laptop battery - - - - - UPS - - - - - Monitor - - - - - Mouse - - - - - Keyboard - - - - - PDA - - - - - Cell phone - - - - - Media player - - - - - Tablet - - - - - Computer - - - - - unrecognised - + WPA ᠪᠣᠯᠣᠨ WPA2 ᠬᠤᠪᠢ ᠬᠥᠮᠥᠨ ᠃ IconEdit - OK - ᠪᠠᠰᠠ ᠪᠣᠯᠣᠨ᠎ᠠ ᠃ + ᠪᠠᠰᠠ ᠪᠣᠯᠣᠨ᠎ᠠ ᠃ InputInfos - Service exception... - ᠦᠢᠯᠡᠴᠢᠯᠡᠬᠡ ᠬᠡᠪ᠎ᠦᠨ ᠪᠤᠰᠤ ᠂ ᠳᠠᠬᠢᠵᠤ ᠳᠤᠷᠱᠢᠵᠤ ᠪᠠᠢᠨ᠎ᠠ... + ᠦᠢᠯᠡᠴᠢᠯᠡᠬᠡ ᠬᠡᠪ᠎ᠦᠨ ᠪᠤᠰᠤ ᠂ ᠳᠠᠬᠢᠵᠤ ᠳᠤᠷᠱᠢᠵᠤ ᠪᠠᠢᠨ᠎ᠠ... - Invaild parameters... - ᠫᠠᠷᠠᠮᠸᠲᠷ ᠬᠡᠪ᠎ᠦᠨ ᠪᠤᠰᠤ ᠂ ᠳᠠᠬᠢᠵᠤ ᠳᠤᠷᠱᠢᠵᠤ ᠪᠠᠢᠨ᠎ᠠ... + ᠫᠠᠷᠠᠮᠸᠲᠷ ᠬᠡᠪ᠎ᠦᠨ ᠪᠤᠰᠤ ᠂ ᠳᠠᠬᠢᠵᠤ ᠳᠤᠷᠱᠢᠵᠤ ᠪᠠᠢᠨ᠎ᠠ... - Unknown fault:%1 - ᠦᠯᠦ᠍ ᠮᠡᠳᠡᠬᠦ᠌ ᠠᠯᠳᠠᠭ᠎ᠠ ᠄%1 + ᠦᠯᠦ᠍ ᠮᠡᠳᠡᠬᠦ᠌ ᠠᠯᠳᠠᠭ᠎ᠠ ᠄%1 - Recapture(60s) - ᠳᠠᠬᠢᠨ ᠤᠯᠵᠠᠯᠠᠬᠤ(60s) + ᠳᠠᠬᠢᠨ ᠤᠯᠵᠠᠯᠠᠬᠤ(60s) - Recapture(%1s) - ᠳᠠᠬᠢᠨ ᠤᠯᠵᠠᠯᠠᠬᠤ(%1s) + ᠳᠠᠬᠢᠨ ᠤᠯᠵᠠᠯᠠᠬᠤ(%1s) - - Get code - ᠪᠠᠳᠤᠯᠠᠬᠤ ᠺᠤᠳ᠋ ᠤᠯᠵᠠᠯᠠᠬᠤ + ᠪᠠᠳᠤᠯᠠᠬᠤ ᠺᠤᠳ᠋ ᠤᠯᠵᠠᠯᠠᠬᠤ @@ -1862,15 +1418,12 @@ KylinNM - kylin-nm - ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠪᠠᠭᠠᠵᠢ + ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠪᠠᠭᠠᠵᠢ - - LAN - ᠤᠳᠠᠰᠤᠳᠤ ᠰᠦᠯᠵᠢᠶ᠎ᠡ + ᠤᠳᠠᠰᠤᠳᠤ ᠰᠦᠯᠵᠢᠶ᠎ᠡ Enabel LAN List @@ -1893,10 +1446,8 @@ 网络 - - Advanced - ᠦᠨᠳᠦᠷ ᠳᠡᠰ ᠤ᠋ᠨ ᠳᠤᠬᠢᠷᠠᠭᠤᠯᠭ᠎ᠠ + ᠦᠨᠳᠦᠷ ᠳᠡᠰ ᠤ᠋ᠨ ᠳᠤᠬᠢᠷᠠᠭᠤᠯᠭ᠎ᠠ Ethernet @@ -1919,85 +1470,60 @@ 已关闭 - HotSpot - ᠬᠤᠪᠢ᠎ᠶᠢᠨ ᠬᠠᠯᠠᠮᠱᠢᠯ ᠴᠡᠭ + ᠬᠤᠪᠢ᠎ᠶᠢᠨ ᠬᠠᠯᠠᠮᠱᠢᠯ ᠴᠡᠭ - FlyMode - ᠨᠢᠰᠦᠯᠭᠡ᠎ᠶᠢᠨ ᠬᠡᠯᠪᠡᠷᠢ + ᠨᠢᠰᠦᠯᠭᠡ᠎ᠶᠢᠨ ᠬᠡᠯᠪᠡᠷᠢ Show MainWindow 显示网络连接界面 - Inactivated LAN - ᠢᠳᠡᠪᠬᠢᠵᠢᠬᠦᠯᠦᠭᠰᠡᠨ ᠦᠬᠡᠢ + ᠢᠳᠡᠪᠬᠢᠵᠢᠬᠦᠯᠦᠭᠰᠡᠨ ᠦᠬᠡᠢ Inactivated WLAN 未激活 - Other WLAN - ᠪᠤᠰᠤᠳ + ᠪᠤᠰᠤᠳ - - WLAN - ᠤᠳᠠᠰᠤ ᠦᠬᠡᠢ ᠬᠡᠰᠡᠭ ᠬᠡᠪᠴᠢᠶᠡᠨ᠎ᠦ ᠰᠦᠯᠵᠢᠶ᠎ᠡ + ᠤᠳᠠᠰᠤ ᠦᠬᠡᠢ ᠬᠡᠰᠡᠭ ᠬᠡᠪᠴᠢᠶᠡᠨ᠎ᠦ ᠰᠦᠯᠵᠢᠶ᠎ᠡ - Show KylinNM - KylinNM᠎ᠶᠢ/᠎ᠢ ᠢᠯᠡᠷᠡᠬᠦᠯᠬᠦ᠌ + KylinNM᠎ᠶᠢ/᠎ᠢ ᠢᠯᠡᠷᠡᠬᠦᠯᠬᠦ᠌ - No wireless card detected - ᠤᠳᠠᠰᠤ ᠦᠬᠡᠢ ᠰᠦᠯᠵᠢᠶᠡᠨ ᠺᠠᠷᠲ᠎ᠢ ᠬᠢᠨᠠᠨ ᠬᠡᠮᠵᠢᠵᠤ ᠤᠯᠤᠭᠰᠠᠨ ᠦᠬᠡᠢ + ᠤᠳᠠᠰᠤ ᠦᠬᠡᠢ ᠰᠦᠯᠵᠢᠶᠡᠨ ᠺᠠᠷᠲ᠎ᠢ ᠬᠢᠨᠠᠨ ᠬᠡᠮᠵᠢᠵᠤ ᠤᠯᠤᠭᠰᠠᠨ ᠦᠬᠡᠢ - Activated LAN - ᠨᠢᠭᠡᠨᠳᠡ ᠢᠳᠡᠪᠬᠢᠵᠢᠬᠦᠯᠪᠡ + ᠨᠢᠭᠡᠨᠳᠡ ᠢᠳᠡᠪᠬᠢᠵᠢᠬᠦᠯᠪᠡ - Activated WLAN - ᠨᠢᠭᠡᠨᠳᠡ ᠢᠳᠡᠪᠬᠢᠵᠢᠬᠦᠯᠪᠡ + ᠨᠢᠭᠡᠨᠳᠡ ᠢᠳᠡᠪᠬᠢᠵᠢᠬᠦᠯᠪᠡ - - - - - Not connected - ᠶᠠᠮᠠᠷ ᠴᠤ᠌ ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠳᠦ ᠴᠦᠷᠬᠡᠯᠡᠭᠰᠡᠨ ᠦᠬᠡᠢ + ᠶᠠᠮᠠᠷ ᠴᠤ᠌ ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠳᠦ ᠴᠦᠷᠬᠡᠯᠡᠭᠰᠡᠨ ᠦᠬᠡᠢ - - - - - - - - - Disconnected - ᠴᠦᠷᠬᠡᠯᠡᠭᠰᠡᠨ ᠦᠬᠡᠢ + ᠴᠦᠷᠬᠡᠯᠡᠭᠰᠡᠨ ᠦᠬᠡᠢ - No Other Wired Network Scheme - ᠵᠢᠭᠰᠠᠭᠠᠯᠳᠠ᠎ᠳᠤ ᠪᠤᠰᠤᠳ ᠤᠳᠠᠰᠤᠳᠤ ᠰᠦᠯᠵᠢᠶ᠎ᠡ ᠪᠠᠢᠬᠤ ᠦᠬᠡᠢ + ᠵᠢᠭᠰᠠᠭᠠᠯᠳᠠ᠎ᠳᠤ ᠪᠤᠰᠤᠳ ᠤᠳᠠᠰᠤᠳᠤ ᠰᠦᠯᠵᠢᠶ᠎ᠡ ᠪᠠᠢᠬᠤ ᠦᠬᠡᠢ Edit @@ -2012,23 +1538,20 @@ 未连接任何网络 - No Other Wireless Network Scheme - ᠪᠤᠰᠤᠳ ᠤᠳᠠᠰᠤ ᠦᠬᠡᠢ ᠰᠦᠯᠵᠢᠶ᠎ᠡ᠎ᠶᠢ ᠬᠢᠨᠠᠨ ᠬᠡᠮᠵᠢᠵᠤ ᠤᠯᠤᠭᠰᠠᠨ ᠦᠬᠡᠢ + ᠪᠤᠰᠤᠳ ᠤᠳᠠᠰᠤ ᠦᠬᠡᠢ ᠰᠦᠯᠵᠢᠶ᠎ᠡ᠎ᠶᠢ ᠬᠢᠨᠠᠨ ᠬᠡᠮᠵᠢᠵᠤ ᠤᠯᠤᠭᠰᠠᠨ ᠦᠬᠡᠢ - Wired net is disconnected - ᠤᠳᠠᠰᠤᠳᠤ ᠰᠦᠯᠵᠢᠶ᠎ᠡ᠎ᠶᠢ ᠳᠠᠰᠤᠯᠬᠤ + ᠤᠳᠠᠰᠤᠳᠤ ᠰᠦᠯᠵᠢᠶ᠎ᠡ᠎ᠶᠢ ᠳᠠᠰᠤᠯᠬᠤ Wi-Fi is disconnected 断开无线网络 - Confirm your Wi-Fi password or usable of wireless card - Wi-Fi᠎ᠶᠢᠨ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠪᠤᠶᠤ ᠤᠳᠠᠰᠤ ᠦᠬᠡᠢ ᠳᠦᠬᠦᠬᠡᠷᠦᠮᠵᠢ᠎ᠶᠢ ᠪᠠᠳᠤᠯᠭᠠᠷᠠᠢ + Wi-Fi᠎ᠶᠢᠨ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠪᠤᠶᠤ ᠤᠳᠠᠰᠤ ᠦᠬᠡᠢ ᠳᠦᠬᠦᠬᠡᠷᠦᠮᠵᠢ᠎ᠶᠢ ᠪᠠᠳᠤᠯᠭᠠᠷᠠᠢ Ethernet Networks @@ -2043,15 +1566,12 @@ 加入网络 - No usable network in the list - ᠵᠢᠭᠰᠠᠭᠠᠯᠳᠠ᠎ᠳᠤ ᠤᠳᠤᠬᠠᠨ᠎ᠳᠠᠭᠠᠨ ᠴᠦᠷᠬᠡᠯᠡᠵᠤ ᠪᠤᠯᠬᠤ ᠰᠦᠯᠵᠢᠶ᠎ᠡ ᠪᠠᠢᠬᠤ ᠦᠬᠡᠢ + ᠵᠢᠭᠰᠠᠭᠠᠯᠳᠠ᠎ᠳᠤ ᠤᠳᠤᠬᠠᠨ᠎ᠳᠠᠭᠠᠨ ᠴᠦᠷᠬᠡᠯᠡᠵᠤ ᠪᠤᠯᠬᠤ ᠰᠦᠯᠵᠢᠶ᠎ᠡ ᠪᠠᠢᠬᠤ ᠦᠬᠡᠢ - - NetOn, - ᠨᠢᠭᠡᠨᠳᠡ ᠴᠦᠷᠬᠡᠯᠡᠪᠡ ᠂ + ᠨᠢᠭᠡᠨᠳᠡ ᠴᠦᠷᠬᠡᠯᠡᠪᠡ ᠂ Wifi Networks @@ -2082,137 +1602,148 @@ 正在更新 Wi-Fi列表 - Conn Ethernet Success - ᠤᠳᠠᠰᠤᠳᠤ ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠠᠮᠵᠢᠯᠳᠠᠳᠠᠢ ᠴᠦᠷᠬᠡᠯᠡᠪᠡ + ᠤᠳᠠᠰᠤᠳᠤ ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠠᠮᠵᠢᠯᠳᠠᠳᠠᠢ ᠴᠦᠷᠬᠡᠯᠡᠪᠡ - Conn Ethernet Fail - ᠤᠳᠠᠰᠤᠳᠤ ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠳᠦ ᠴᠦᠷᠬᠡᠯᠡᠵᠤ ᠴᠢᠳᠠᠭᠰᠠᠨ ᠦᠬᠡᠢ + ᠤᠳᠠᠰᠤᠳᠤ ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠳᠦ ᠴᠦᠷᠬᠡᠯᠡᠵᠤ ᠴᠢᠳᠠᠭᠰᠠᠨ ᠦᠬᠡᠢ - Conn Wifi Success - ᠤᠳᠠᠰᠤ ᠦᠬᠡᠢ ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠳᠦ ᠠᠮᠵᠢᠯᠳᠠᠳᠠᠢ ᠴᠦᠷᠬᠡᠯᠡᠪᠡ + ᠤᠳᠠᠰᠤ ᠦᠬᠡᠢ ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠳᠦ ᠠᠮᠵᠢᠯᠳᠠᠳᠠᠢ ᠴᠦᠷᠬᠡᠯᠡᠪᠡ LettersWidget - + &&?! &&?! - + 123 123 + + Ctrl + ᠳᠠᠷᠤᠶ᠎ᠠ ᠃ + + + Alt + ᠣᠷᠣᠯᠠᠭᠤᠯᠬᠤ ᠵᠦᠢᠯ ᠢ ᠣᠷᠣᠯᠠᠭᠤᠯᠬᠤ + + + + LightDMHelper + + + failed to start session. + + + + + Login + ᠳᠠᠩᠰᠠᠯᠠᠨ ᠤᠷᠤᠬᠤ + + + + Guest + 游客 + LockWidget - - Form - - - - Date - ᠡᠳᠦᠷ ᠰᠠᠷ᠎ᠠ + ᠡᠳᠦᠷ ᠰᠠᠷ᠎ᠠ - Time - ᠴᠠᠭ + ᠴᠠᠭ Guest 游客 - - PowerInfo - - - - Power - ᠴᠠᠬᠢᠯᠭᠠᠨ ᠡᠭᠦᠰᠭᠡᠭᠴᠢ᠃ + ᠴᠠᠬᠢᠯᠭᠠᠨ ᠡᠭᠦᠰᠭᠡᠭᠴᠢ᠃ - VirtualKeyboard - ᠬᠡᠶᠢᠰᠬᠡᠷ ᠲᠠᠷᠤᠭᠤᠯ ᠤᠨ ᠫᠠᠨᠰᠠ᠃ + ᠬᠡᠶᠢᠰᠬᠡᠷ ᠲᠠᠷᠤᠭᠤᠯ ᠤᠨ ᠫᠠᠨᠰᠠ᠃ - SwitchUser - ᠬᠡᠷᠡᠭᠯᠡᠭᠴᠢ ᠶᠢ ᠰᠣᠯᠢᠨ᠎ᠠ᠃ + ᠬᠡᠷᠡᠭᠯᠡᠭᠴᠢ ᠶᠢ ᠰᠣᠯᠢᠨ᠎ᠠ᠃ - Multiple users are logged in at the same time.Are you sure you want to reboot this system? - ᠬᠡᠳᠦ ᠬᠡᠳᠦᠨ ᠬᠡᠷᠡᠭᠯᠡᠭᠴᠢ ᠠᠳᠠᠯᠢ ᠴᠠᠭ᠎ᠲᠤ ᠨᠡᠪᠳᠡᠷᠡᠵᠤ ᠪᠠᠢᠬᠤ ᠪᠠᠢᠳᠠᠯ ᠲᠠᠢ ᠂ ᠲᠠ ᠱᠢᠰᠲ᠋ᠧᠮ᠎ᠡᠴᠡ ᠪᠤᠴᠠᠵᠤ ᠭᠠᠷᠬᠤ ᠤᠤ? + ᠬᠡᠳᠦ ᠬᠡᠳᠦᠨ ᠬᠡᠷᠡᠭᠯᠡᠭᠴᠢ ᠠᠳᠠᠯᠢ ᠴᠠᠭ᠎ᠲᠤ ᠨᠡᠪᠳᠡᠷᠡᠵᠤ ᠪᠠᠢᠬᠤ ᠪᠠᠢᠳᠠᠯ ᠲᠠᠢ ᠂ ᠲᠠ ᠱᠢᠰᠲ᠋ᠧᠮ᠎ᠡᠴᠡ ᠪᠤᠴᠠᠵᠤ ᠭᠠᠷᠬᠤ ᠤᠤ? - LAN - ᠤᠳᠠᠰᠤᠳᠤ ᠰᠦᠯᠵᠢᠶ᠎ᠡ + ᠤᠳᠠᠰᠤᠳᠤ ᠰᠦᠯᠵᠢᠶ᠎ᠡ - WLAN - ᠤᠳᠠᠰᠤ ᠦᠬᠡᠢ ᠬᠡᠰᠡᠭ ᠬᠡᠪᠴᠢᠶᠡᠨ᠎ᠦ ᠰᠦᠯᠵᠢᠶ᠎ᠡ + ᠤᠳᠠᠰᠤ ᠦᠬᠡᠢ ᠬᠡᠰᠡᠭ ᠬᠡᠪᠴᠢᠶᠡᠨ᠎ᠦ ᠰᠦᠯᠵᠢᠶ᠎ᠡ LoginOptionsWidget - Login Options - ᠨᠡᠪᠳᠡᠷᠡᠬᠦ᠌ ᠰᠤᠩᠭᠤᠯᠳᠠ + ᠨᠡᠪᠳᠡᠷᠡᠬᠦ᠌ ᠰᠤᠩᠭᠤᠯᠳᠠ - Password - ᠨᠢᠭᠤᠴᠠ ᠺᠣᠳ᠋᠎ᠢ᠋ ᠵᠠᠰᠠᠬᠤ + ᠨᠢᠭᠤᠴᠠ ᠺᠣᠳ᠋᠎ᠢ᠋ ᠵᠠᠰᠠᠬᠤ - Other - ᠪᠤᠰᠤᠳ ᠃ + ᠪᠤᠰᠤᠳ ᠃ Wechat 微信 - Identify device removed! - ᠬᠠᠷᠭᠤᠭᠤᠯᠵᠤ ᠱᠢᠯᠭᠠᠬᠤ ᠳᠦᠬᠦᠬᠡᠷᠦᠮᠵᠢ᠎ᠶᠢ ᠨᠢᠭᠡᠨᠳᠡ ᠱᠢᠯᠵᠢᠬᠦᠯᠦᠨ ᠬᠠᠰᠤᠪᠠ! + ᠬᠠᠷᠭᠤᠭᠤᠯᠵᠤ ᠱᠢᠯᠭᠠᠬᠤ ᠳᠦᠬᠦᠬᠡᠷᠦᠮᠵᠢ᠎ᠶᠢ ᠨᠢᠭᠡᠨᠳᠡ ᠱᠢᠯᠵᠢᠬᠦᠯᠦᠨ ᠬᠠᠰᠤᠪᠠ! MyLineEdit - - - Verification code - ᠤᠬᠤᠷ ᠮᠡᠳᠡᠭᠡᠨ᠎ᠦ ᠪᠠᠳᠤᠯᠠᠬᠤ ᠺᠤᠳ᠋ + ᠤᠬᠤᠷ ᠮᠡᠳᠡᠭᠡᠨ᠎ᠦ ᠪᠠᠳᠤᠯᠠᠬᠤ ᠺᠤᠳ᠋ + + + + MyNetworkWidget + + + LAN + ᠤᠳᠠᠰᠤᠳᠤ ᠰᠦᠯᠵᠢᠶ᠎ᠡ + + + + WLAN + ᠤᠳᠠᠰᠤ ᠦᠬᠡᠢ ᠬᠡᠰᠡᠭ ᠬᠡᠪᠴᠢᠶᠡᠨ᠎ᠦ ᠰᠦᠯᠵᠢᠶ᠎ᠡ NumbersWidget - + &&?! &&?! - + Return ᠪᠤᠴᠠᠵᠤ ᠢᠷᠡᠨ᠎ᠡ ᠃ @@ -2220,14 +1751,12 @@ OneConnForm - Form - ᠬᠦᠰᠦᠨᠦᠭ + ᠬᠦᠰᠦᠨᠦᠭ - Automatically join the network - ᠲᠤᠰ ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠳᠦ ᠠᠦ᠋ᠲ᠋ᠤ᠋᠎ᠪᠠᠷ ᠤᠷᠤᠬᠤ + ᠲᠤᠰ ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠳᠦ ᠠᠦ᠋ᠲ᠋ᠤ᠋᠎ᠪᠠᠷ ᠤᠷᠤᠬᠤ Input password @@ -2238,32 +1767,24 @@ 设置 - - - - Connect - ᠰᠢᠷᠪᠢᠬᠦᠷ ᠲᠤ᠌ ᠴᠥᠷᠬᠡᠯᠡᠪᠡ + ᠰᠢᠷᠪᠢᠬᠦᠷ ᠲᠤ᠌ ᠴᠥᠷᠬᠡᠯᠡᠪᠡ - Disconnect - ᠴᠦᠷᠬᠡᠯᠡᠬᠡ᠎ᠶᠢ ᠳᠠᠰᠤᠯᠬᠤ + ᠴᠦᠷᠬᠡᠯᠡᠬᠡ᠎ᠶᠢ ᠳᠠᠰᠤᠯᠬᠤ - Input Password... - ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠤᠷᠤᠭᠤᠯᠬᠤ... + ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠤᠷᠤᠭᠤᠯᠬᠤ... - Connect to Hidden Wi-Fi Network - ᠨᠢᠭᠤᠴᠠᠯᠢᠭ Wi-Fi ᠰᠦᠯᠵᠢᠶ᠎ᠡ᠎ᠳᠦ ᠵᠠᠯᠭᠠᠪᠠ + ᠨᠢᠭᠤᠴᠠᠯᠢᠭ Wi-Fi ᠰᠦᠯᠵᠢᠶ᠎ᠡ᠎ᠳᠦ ᠵᠠᠯᠭᠠᠪᠠ - Signal: - ᠲᠤᠬᠢᠶᠠᠨ᠎ᠤ ᠡᠷᠴᠢᠮ ᠄ + ᠲᠤᠬᠢᠶᠠᠨ᠎ᠤ ᠡᠷᠴᠢᠮ ᠄ Public @@ -2278,73 +1799,59 @@ 速率 - None - ᠥᠬᠡᠢ + ᠥᠬᠡᠢ - WiFi Security: - Wi-Fi᠎ᠤ ᠠᠶᠤᠯᠬᠦᠢ ᠱᠢᠨᠵᠢ: + Wi-Fi᠎ᠤ ᠠᠶᠤᠯᠬᠦᠢ ᠱᠢᠨᠵᠢ: - MAC: - ᠹᠢᠼᠢᠺ᠎ᠦᠨ ᠬᠠᠶᠢᠭ ᠄ + ᠹᠢᠼᠢᠺ᠎ᠦᠨ ᠬᠠᠶᠢᠭ ᠄ - Conn Wifi Failed - ᠤᠳᠠᠰᠤ ᠦᠬᠡᠢ ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠴᠦᠷᠬᠡᠯᠡᠬᠡ ᠢᠯᠠᠭᠳᠠᠪᠠ + ᠤᠳᠠᠰᠤ ᠦᠬᠡᠢ ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠴᠦᠷᠬᠡᠯᠡᠬᠡ ᠢᠯᠠᠭᠳᠠᠪᠠ OneLancForm - Form - ᠬᠦᠰᠦᠨᠦᠭ + ᠬᠦᠰᠦᠨᠦᠭ Config 设置 - - Connect - ᠰᠢᠷᠪᠢᠬᠦᠷ ᠲᠤ᠌ ᠴᠥᠷᠬᠡᠯᠡᠪᠡ + ᠰᠢᠷᠪᠢᠬᠦᠷ ᠲᠤ᠌ ᠴᠥᠷᠬᠡᠯᠡᠪᠡ - Disconnect - ᠲᠠᠰᠤᠷᠠᠪᠠ ᠃ + ᠲᠠᠰᠤᠷᠠᠪᠠ ᠃ - - No Configuration - ᠪᠠᠢᠷᠢᠯᠠᠭᠤᠯᠤᠭᠰᠠᠨ ᠦᠬᠡᠢ + ᠪᠠᠢᠷᠢᠯᠠᠭᠤᠯᠤᠭᠰᠠᠨ ᠦᠬᠡᠢ - IPv4: - IPv4 ᠬᠠᠶᠢᠭ ᠄ + IPv4 ᠬᠠᠶᠢᠭ ᠄ - IPv6: - IPv6 ᠬᠠᠶᠢᠭ ᠄ + IPv6 ᠬᠠᠶᠢᠭ ᠄ - BandWidth: - ᠪᠦᠰᠡ᠎ᠶᠢᠨ ᠦᠷᠭᠡᠨ ᠄ + ᠪᠦᠰᠡ᠎ᠶᠢᠨ ᠦᠷᠭᠡᠨ ᠄ - MAC: - MAC ᠬᠠᠶᠢᠭ: + MAC ᠬᠠᠶᠢᠭ: Auto @@ -2354,65 +1861,90 @@ PhoneAuthWidget - - Verification by phoneNum - ᠭᠠᠷ ᠤᠳᠠᠰᠤᠨ᠎ᠤ ᠨᠤᠮᠸᠷ᠎ᠢᠶᠠᠷ ᠪᠠᠳᠤᠯᠠᠬᠤ + ᠭᠠᠷ ᠤᠳᠠᠰᠤᠨ᠎ᠤ ᠨᠤᠮᠸᠷ᠎ᠢᠶᠠᠷ ᠪᠠᠳᠤᠯᠠᠬᠤ - 「 Use bound Phone number to verification 」 - 「ᠤᠶᠠᠭᠰᠠᠨ ᠤᠳᠠᠰᠤᠨ᠎ᠤ ᠨᠤᠮᠸᠷ᠎ᠢᠶᠠᠷ ᠪᠠᠳᠤᠯᠭᠠᠵᠢᠭᠤᠯᠤᠭᠠᠷᠠᠢ」 + 「ᠤᠶᠠᠭᠰᠠᠨ ᠤᠳᠠᠰᠤᠨ᠎ᠤ ᠨᠤᠮᠸᠷ᠎ᠢᠶᠠᠷ ᠪᠠᠳᠤᠯᠭᠠᠵᠢᠭᠤᠯᠤᠭᠠᠷᠠᠢ」 - 「 Use SMS to verification 」 - 「ᠲᠤᠰ ᠳᠠᠩᠰᠠᠨ᠎ᠳᠤ ᠤᠶᠠᠭᠰᠠᠨ ᠭᠠᠷ ᠤᠳᠠᠰᠤᠨ᠎ᠤ ᠨᠤᠮᠸᠷ᠎ᠢᠶᠠᠷ ᠪᠠᠳᠤᠯᠭᠠᠵᠢᠭᠤᠯᠤᠭᠠᠷᠠᠢ」 + 「ᠲᠤᠰ ᠳᠠᠩᠰᠠᠨ᠎ᠳᠤ ᠤᠶᠠᠭᠰᠠᠨ ᠭᠠᠷ ᠤᠳᠠᠰᠤᠨ᠎ᠤ ᠨᠤᠮᠸᠷ᠎ᠢᠶᠠᠷ ᠪᠠᠳᠤᠯᠭᠠᠵᠢᠭᠤᠯᠤᠭᠠᠷᠠᠢ」 - - commit - ᠳᠤᠱᠢᠶᠠᠬᠤ + ᠳᠤᠱᠢᠶᠠᠬᠤ - - Network not connected~ - ᠱᠢᠰᠲ᠋ᠧᠮ ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠳᠦ ᠬᠤᠯᠪᠤᠭᠳᠠᠭ᠎ᠠ ᠦᠬᠡᠢ ᠂ ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠴᠦᠷᠬᠡᠯᠡᠬᠡ᠎ᠶᠢ ᠪᠠᠢᠴᠠᠭᠠᠭᠠᠷᠠᠢ~ + ᠱᠢᠰᠲ᠋ᠧᠮ ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠳᠦ ᠬᠤᠯᠪᠤᠭᠳᠠᠭ᠎ᠠ ᠦᠬᠡᠢ ᠂ ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠴᠦᠷᠬᠡᠯᠡᠬᠡ᠎ᠶᠢ ᠪᠠᠢᠴᠠᠭᠠᠭᠠᠷᠠᠢ~ - Network unavailable~ - ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠪᠠᠢᠳᠠᠯ ᠮᠠᠭᠤ ᠪᠠᠢᠨ᠎ᠠ ᠂ ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠴᠦᠷᠬᠡᠯᠡᠬᠡ᠎ᠶᠢ ᠪᠠᠢᠴᠠᠭᠠᠭᠠᠷᠠᠢ~ + ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠪᠠᠢᠳᠠᠯ ᠮᠠᠭᠤ ᠪᠠᠢᠨ᠎ᠠ ᠂ ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠴᠦᠷᠬᠡᠯᠡᠬᠡ᠎ᠶᠢ ᠪᠠᠢᠴᠠᠭᠠᠭᠠᠷᠠᠢ~ - Verification Code invalid! - ᠪᠠᠳᠤᠯᠠᠬᠤ ᠺᠤᠳ᠋ ᠬᠦᠴᠦᠨ ᠦᠬᠡᠢ ᠪᠤᠯᠪᠠ! + ᠪᠠᠳᠤᠯᠠᠬᠤ ᠺᠤᠳ᠋ ᠬᠦᠴᠦᠨ ᠦᠬᠡᠢ ᠪᠤᠯᠪᠠ! - Verification Code incorrect.Please retry! - ᠪᠠᠳᠤᠯᠠᠬᠤ ᠺᠤᠳ᠋ ᠪᠤᠷᠤᠭᠤᠳᠠᠪᠠ! ᠵᠦᠪ ᠪᠠᠳᠤᠯᠠᠬᠤ ᠺᠤᠳ᠋᠎ᠢ ᠳᠠᠭᠯᠠᠭᠠᠷᠠᠢ! + ᠪᠠᠳᠤᠯᠠᠬᠤ ᠺᠤᠳ᠋ ᠪᠤᠷᠤᠭᠤᠳᠠᠪᠠ! ᠵᠦᠪ ᠪᠠᠳᠤᠯᠠᠬᠤ ᠺᠤᠳ᠋᠎ᠢ ᠳᠠᠭᠯᠠᠭᠠᠷᠠᠢ! - Failed time over limit!Retry after 1 hour! - ᠪᠠᠳᠤᠯᠠᠬᠤ ᠺᠤᠳ᠋ ᠪᠤᠷᠤᠭᠤ ᠤᠷᠤᠭᠤᠯᠤᠭᠰᠠᠨ ᠤᠳᠠᠭ᠎ᠠ10᠎ᠶᠢ ᠬᠡᠳᠦᠷᠡᠪᠡ ᠂1 ᠴᠠᠭ᠎ᠤᠨ ᠳᠠᠷᠠᠭ᠎ᠠ ᠳᠠᠬᠢᠵᠤ ᠳᠤᠷᠱᠢᠭᠠᠷᠠᠢ! + ᠪᠠᠳᠤᠯᠠᠬᠤ ᠺᠤᠳ᠋ ᠪᠤᠷᠤᠭᠤ ᠤᠷᠤᠭᠤᠯᠤᠭᠰᠠᠨ ᠤᠳᠠᠭ᠎ᠠ10᠎ᠶᠢ ᠬᠡᠳᠦᠷᠡᠪᠡ ᠂1 ᠴᠠᠭ᠎ᠤᠨ ᠳᠠᠷᠠᠭ᠎ᠠ ᠳᠠᠬᠢᠵᠤ ᠳᠤᠷᠱᠢᠭᠠᠷᠠᠢ! - verifaction failed! - ᠭᠠᠷ ᠤᠳᠠᠰᠤᠨ᠎ᠤ ᠪᠠᠳᠤᠯᠭᠠᠵᠢᠭᠤᠯᠤᠯᠳᠠ ᠢᠯᠠᠭᠳᠠᠪᠠ! + ᠭᠠᠷ ᠤᠳᠠᠰᠤᠨ᠎ᠤ ᠪᠠᠳᠤᠯᠭᠠᠵᠢᠭᠤᠯᠤᠯᠳᠠ ᠢᠯᠠᠭᠳᠠᠪᠠ! + + + + PowerListWidget + + + Hibernate + ᠢᠴᠡᠬᠡᠯᠡᠬᠦ᠌ + + + + Turn off your computer, but the app stays open. When the computer is turned on, it can be restored to the state you left + ᠺᠣᠮᠫᠢᠦ᠋ᠲ᠋ᠧᠷ ᠢ ᠬᠠᠭᠠᠬᠤ ᠪᠣᠯᠪᠠᠴᠤ ᠬᠡᠷᠡᠭᠯᠡᠭᠡᠨ ᠦ ᠬᠤᠷᠠᠯ ᠨᠡᠭᠡᠭᠡᠬᠦ ᠪᠠᠶᠢᠳᠠᠯ ᠢᠶᠠᠨ ᠪᠠᠷᠢᠮᠲᠠᠯᠠᠳᠠᠭ ᠃ ᠺᠣᠮᠫᠢᠦ᠋ᠲ᠋ᠧᠷ ᠢ ᠨᠡᠭᠡᠭᠡᠬᠦ ᠦᠶ᠎ᠡ ᠳᠦ ᠂ ᠴᠢᠨᠦ ᠰᠠᠯᠤᠭᠰᠠᠨ ᠪᠠᠶᠢᠳᠠᠯ ᠢᠶᠠᠨ ᠰᠡᠷᠭᠦᠭᠡᠵᠦ ᠪᠣᠯᠣᠨ᠎ᠠ ᠃ + + + + Suspend + ᠤᠨᠳᠠᠬᠤ + + + + + The computer stays on, but consumes less power. The app stays open and can quickly wake up and revert to where you left off + ᠺᠣᠮᠫᠢᠦ᠋ᠲ᠋ᠧᠷ ᠮᠠᠰᠢᠨ ᠢᠶᠠᠨ ᠨᠡᠭᠡᠭᠡᠬᠦ ᠪᠠᠶᠢᠳᠠᠯ ᠢᠶᠠᠨ ᠪᠠᠷᠢᠮᠲᠠᠯᠠᠳᠠᠭ ᠂ ᠭᠡᠪᠡᠴᠦ ᠴᠠᠬᠢᠯᠭᠠᠨ ᠬᠣᠷᠣᠭᠳᠠᠭᠤᠯᠭ᠎ᠠ ᠨᠡᠯᠢᠶᠡᠳ ᠪᠠᠭ᠎ᠠ ᠃ ᠬᠡᠷᠡᠭᠯᠡᠭᠡᠨ ᠦ ᠬᠤᠷᠠᠯ ᠨᠡᠭᠡᠭᠡᠬᠦ ᠪᠠᠶᠢᠳᠠᠯ ᠢᠶᠠᠨ ᠦᠷᠭᠦᠯᠵᠢᠯᠡᠭᠦᠯᠦᠭᠰᠡᠭᠡᠷ ᠂ ᠺᠣᠮᠫᠢᠦ᠋ᠲ᠋ᠧᠷ ᠢ ᠲᠦᠷᠭᠡᠨ ᠰᠡᠷᠢᠭᠡᠬᠦ ᠶᠢᠨ ᠬᠠᠮᠲᠤ ᠴᠢᠨᠦ ᠰᠠᠯᠤᠭᠰᠠᠨ ᠪᠠᠶᠢᠳᠠᠯ ᠢᠶᠠᠨ ᠰᠡᠷᠭᠦᠭᠡᠵᠦ ᠪᠣᠯᠣᠨ᠎ᠠ ᠃ + + + + Reboot + + + + + Power Off + ᠬᠠᠭᠠᠬᠤ + + + + Close all apps, and then shut down your computer + PowerManager - lock - ᠤᠨᠢᠰᠤᠯᠠᠬᠤ + ᠤᠨᠢᠰᠤᠯᠠᠬᠤ SwitchUser @@ -2439,55 +1971,44 @@ 切换用户 - Log Out - ᠬᠦᠴᠦᠨ ᠦᠬᠡᠢ ᠪᠤᠯᠭᠠᠬᠤ + ᠬᠦᠴᠦᠨ ᠦᠬᠡᠢ ᠪᠤᠯᠭᠠᠬᠤ - - Restart - ᠳᠠᠬᠢᠵᠤ ᠡᠬᠢᠯᠡᠬᠦᠯᠬᠦ᠌ + ᠳᠠᠬᠢᠵᠤ ᠡᠬᠢᠯᠡᠬᠦᠯᠬᠦ᠌ - Power Off - ᠬᠠᠭᠠᠬᠤ + ᠬᠠᠭᠠᠬᠤ - Close all apps, turn off your computer, and then turn your computer back on - ᠪᠤᠢ ᠪᠥᠬᠥᠢ ᠬᠡᠷᠡᠭ᠍ᠯᠡᠭᠡ ᠶᠢ ᠬᠠᠭᠠᠵᠤ ᠂ ᠺᠣᠮᠫᠢᠦ᠋ᠲ᠋ᠧᠷ ᠢ ᠬᠠᠭᠠᠵᠤ ᠂ ᠳᠠᠷᠠᠭ᠎ᠠ ᠨᠢ ᠺᠣᠮᠫᠢᠦ᠋ᠲ᠋ᠧᠷ ᠢ ᠳᠠᠬᠢᠨ ᠨᠡᠭᠡᠭᠡᠨ᠎ᠡ ᠃ + ᠪᠤᠢ ᠪᠥᠬᠥᠢ ᠬᠡᠷᠡᠭ᠍ᠯᠡᠭᠡ ᠶᠢ ᠬᠠᠭᠠᠵᠤ ᠂ ᠺᠣᠮᠫᠢᠦ᠋ᠲ᠋ᠧᠷ ᠢ ᠬᠠᠭᠠᠵᠤ ᠂ ᠳᠠᠷᠠᠭ᠎ᠠ ᠨᠢ ᠺᠣᠮᠫᠢᠦ᠋ᠲ᠋ᠧᠷ ᠢ ᠳᠠᠬᠢᠨ ᠨᠡᠭᠡᠭᠡᠨ᠎ᠡ ᠃ - - Close all apps, and then shut down your computer - ᠪᠤᠢ ᠪᠥᠬᠥᠢ ᠬᠡᠷᠡᠭ᠍ᠯᠡᠭᠡ ᠶᠢ ᠬᠠᠭᠠᠵᠤ ᠂ ᠳᠠᠷᠠᠭ᠎ᠠ ᠨᠢ ᠺᠣᠮᠫᠢᠦ᠋ᠲ᠋ᠧᠷ ᠢ ᠬᠠᠭᠠᠬᠤ + ᠪᠤᠢ ᠪᠥᠬᠥᠢ ᠬᠡᠷᠡᠭ᠍ᠯᠡᠭᠡ ᠶᠢ ᠬᠠᠭᠠᠵᠤ ᠂ ᠳᠠᠷᠠᠭ᠎ᠠ ᠨᠢ ᠺᠣᠮᠫᠢᠦ᠋ᠲ᠋ᠧᠷ ᠢ ᠬᠠᠭᠠᠬᠤ + ᠪᠤᠢ ᠪᠥᠬᠥᠢ ᠬᠡᠷᠡᠭ᠍ᠯᠡᠭᠡ ᠶᠢ ᠬᠠᠭᠠᠵᠤ ᠂ ᠳᠠᠷᠠᠭ᠎ᠠ ᠨᠢ ᠺᠣᠮᠫᠢᠦ᠋ᠲ᠋ᠧᠷ ᠢ ᠬᠠᠭᠠᠬᠤ - Shut Down - ᠬᠠᠭᠠᠬᠤ + ᠬᠠᠭᠠᠬᠤ - Turn off your computer, but the app stays open. When the computer is turned on, it can be restored to the state you left - ᠺᠣᠮᠫᠢᠦ᠋ᠲ᠋ᠧᠷ ᠢ ᠬᠠᠭᠠᠬᠤ ᠪᠣᠯᠪᠠᠴᠤ ᠬᠡᠷᠡᠭᠯᠡᠭᠡᠨ ᠦ ᠬᠤᠷᠠᠯ ᠨᠡᠭᠡᠭᠡᠬᠦ ᠪᠠᠶᠢᠳᠠᠯ ᠢᠶᠠᠨ ᠪᠠᠷᠢᠮᠲᠠᠯᠠᠳᠠᠭ ᠃ ᠺᠣᠮᠫᠢᠦ᠋ᠲ᠋ᠧᠷ ᠢ ᠨᠡᠭᠡᠭᠡᠬᠦ ᠦᠶ᠎ᠡ ᠳᠦ ᠂ ᠴᠢᠨᠦ ᠰᠠᠯᠤᠭᠰᠠᠨ ᠪᠠᠶᠢᠳᠠᠯ ᠢᠶᠠᠨ ᠰᠡᠷᠭᠦᠭᠡᠵᠦ ᠪᠣᠯᠣᠨ᠎ᠠ ᠃ + ᠺᠣᠮᠫᠢᠦ᠋ᠲ᠋ᠧᠷ ᠢ ᠬᠠᠭᠠᠬᠤ ᠪᠣᠯᠪᠠᠴᠤ ᠬᠡᠷᠡᠭᠯᠡᠭᠡᠨ ᠦ ᠬᠤᠷᠠᠯ ᠨᠡᠭᠡᠭᠡᠬᠦ ᠪᠠᠶᠢᠳᠠᠯ ᠢᠶᠠᠨ ᠪᠠᠷᠢᠮᠲᠠᠯᠠᠳᠠᠭ ᠃ ᠺᠣᠮᠫᠢᠦ᠋ᠲ᠋ᠧᠷ ᠢ ᠨᠡᠭᠡᠭᠡᠬᠦ ᠦᠶ᠎ᠡ ᠳᠦ ᠂ ᠴᠢᠨᠦ ᠰᠠᠯᠤᠭᠰᠠᠨ ᠪᠠᠶᠢᠳᠠᠯ ᠢᠶᠠᠨ ᠰᠡᠷᠭᠦᠭᠡᠵᠦ ᠪᠣᠯᠣᠨ᠎ᠠ ᠃ - Hibernate - ᠢᠴᠡᠬᠡᠯᠡᠬᠦ᠌ + ᠢᠴᠡᠬᠡᠯᠡᠬᠦ᠌ - The computer stays on, but consumes less power. The app stays open and can quickly wake up and revert to where you left off - ᠺᠣᠮᠫᠢᠦ᠋ᠲ᠋ᠧᠷ ᠮᠠᠰᠢᠨ ᠢᠶᠠᠨ ᠨᠡᠭᠡᠭᠡᠬᠦ ᠪᠠᠶᠢᠳᠠᠯ ᠢᠶᠠᠨ ᠪᠠᠷᠢᠮᠲᠠᠯᠠᠳᠠᠭ ᠂ ᠭᠡᠪᠡᠴᠦ ᠴᠠᠬᠢᠯᠭᠠᠨ ᠬᠣᠷᠣᠭᠳᠠᠭᠤᠯᠭ᠎ᠠ ᠨᠡᠯᠢᠶᠡᠳ ᠪᠠᠭ᠎ᠠ ᠃ ᠬᠡᠷᠡᠭᠯᠡᠭᠡᠨ ᠦ ᠬᠤᠷᠠᠯ ᠨᠡᠭᠡᠭᠡᠬᠦ ᠪᠠᠶᠢᠳᠠᠯ ᠢᠶᠠᠨ ᠦᠷᠭᠦᠯᠵᠢᠯᠡᠭᠦᠯᠦᠭᠰᠡᠭᠡᠷ ᠂ ᠺᠣᠮᠫᠢᠦ᠋ᠲ᠋ᠧᠷ ᠢ ᠲᠦᠷᠭᠡᠨ ᠰᠡᠷᠢᠭᠡᠬᠦ ᠶᠢᠨ ᠬᠠᠮᠲᠤ ᠴᠢᠨᠦ ᠰᠠᠯᠤᠭᠰᠠᠨ ᠪᠠᠶᠢᠳᠠᠯ ᠢᠶᠠᠨ ᠰᠡᠷᠭᠦᠭᠡᠵᠦ ᠪᠣᠯᠣᠨ᠎ᠠ ᠃ + ᠺᠣᠮᠫᠢᠦ᠋ᠲ᠋ᠧᠷ ᠮᠠᠰᠢᠨ ᠢᠶᠠᠨ ᠨᠡᠭᠡᠭᠡᠬᠦ ᠪᠠᠶᠢᠳᠠᠯ ᠢᠶᠠᠨ ᠪᠠᠷᠢᠮᠲᠠᠯᠠᠳᠠᠭ ᠂ ᠭᠡᠪᠡᠴᠦ ᠴᠠᠬᠢᠯᠭᠠᠨ ᠬᠣᠷᠣᠭᠳᠠᠭᠤᠯᠭ᠎ᠠ ᠨᠡᠯᠢᠶᠡᠳ ᠪᠠᠭ᠎ᠠ ᠃ ᠬᠡᠷᠡᠭᠯᠡᠭᠡᠨ ᠦ ᠬᠤᠷᠠᠯ ᠨᠡᠭᠡᠭᠡᠬᠦ ᠪᠠᠶᠢᠳᠠᠯ ᠢᠶᠠᠨ ᠦᠷᠭᠦᠯᠵᠢᠯᠡᠭᠦᠯᠦᠭᠰᠡᠭᠡᠷ ᠂ ᠺᠣᠮᠫᠢᠦ᠋ᠲ᠋ᠧᠷ ᠢ ᠲᠦᠷᠭᠡᠨ ᠰᠡᠷᠢᠭᠡᠬᠦ ᠶᠢᠨ ᠬᠠᠮᠲᠤ ᠴᠢᠨᠦ ᠰᠠᠯᠤᠭᠰᠠᠨ ᠪᠠᠶᠢᠳᠠᠯ ᠢᠶᠠᠨ ᠰᠡᠷᠭᠦᠭᠡᠵᠦ ᠪᠣᠯᠣᠨ᠎ᠠ ᠃ - Suspend - ᠤᠨᠳᠠᠬᠤ + ᠤᠨᠳᠠᠬᠤ Sleep @@ -2497,25 +2018,16 @@ QObject - + The screensaver is active. ᠳᠡᠯᠭᠡᠴᠡ ᠬᠠᠮᠠᠭᠠᠯᠠᠬᠤ ᠫᠠᠷᠦᠭᠷᠡᠮ᠎ᠢ ᠨᠢᠭᠡᠨᠳᠡ ᠢᠳᠡᠪᠬᠢᠵᠢᠬᠦᠯᠪᠡ - + The screensaver is inactive. ᠳᠡᠯᠭᠡᠴᠡ ᠬᠠᠮᠠᠭᠠᠯᠠᠬᠤ ᠫᠠᠷᠦᠭᠷᠡᠮ᠎ᠢ ᠢᠳᠡᠪᠬᠢᠵᠢᠬᠦᠯᠦᠬᠡ ᠦᠬᠡᠢ ᠃ - - S: - - - - tablet device - - - Screensaver @@ -2527,7 +2039,7 @@ 退出 - + Picture does not exist ᠵᠢᠷᠤᠭ ᠪᠠᠢᠬᠤ ᠦᠬᠡᠢ @@ -2544,12 +2056,11 @@ 您有%1条未读消息 - You have new notification - ᠲᠠ ᠱᠢᠨ᠎ᠡ ᠮᠡᠳᠡᠭᠳᠡᠯ ᠤᠯᠤᠭᠰᠠᠨ + ᠲᠠ ᠱᠢᠨ᠎ᠡ ᠮᠡᠳᠡᠭᠳᠡᠯ ᠤᠯᠤᠭᠰᠠᠨ - + View ᠬᠡᠪ ᠦᠵᠡᠬᠦ᠌ @@ -2561,7 +2072,7 @@ ᠲᠠ ᠨᠢᠭᠡᠨᠳᠡ ᠠᠮᠠᠷᠠᠪᠠ ᠄ - + You have rested ᠲᠠ ᠨᠢᠭᠡᠨᠲᠡ ᠠᠮᠠᠷᠠᠵᠠᠢ᠃ @@ -2569,48 +2080,40 @@ SureWindow - Form - ᠬᠦᠰᠦᠨᠦᠭ + ᠬᠦᠰᠦᠨᠦᠭ - TextLabel - ᠲᠸᠺᠰᠲ᠎ᠦᠨ ᠱᠤᠱᠢᠭ᠎ᠠ + ᠲᠸᠺᠰᠲ᠎ᠦᠨ ᠱᠤᠱᠢᠭ᠎ᠠ - Cancel - ᠦᠬᠡᠢᠰᠭᠡᠬᠦ᠌ + ᠦᠬᠡᠢᠰᠭᠡᠬᠦ᠌ - Confirm - ᠪᠠᠳᠤᠯᠠᠬᠤ + ᠪᠠᠳᠤᠯᠠᠬᠤ Multiple users are logged in at the same time.Are you sure you want to reboot this system? 同时有多个用户登录系统,您确定要退出系统吗? - The following program is running to prevent the system from suspend! - ᠳᠠᠷᠠᠭᠠᠬᠢ ᠫᠠᠷᠦᠭᠷᠡᠮ ᠶᠠᠭ ᠠᠵᠢᠯᠯᠠᠵᠤ ᠪᠠᠢᠨ᠎ᠠ ᠂ ᠱᠢᠰᠲ᠋ᠧᠮ᠎ᠦᠨ ᠤᠨᠳᠠᠬᠤ᠎ᠶᠢ ᠬᠤᠷᠢᠭᠯᠠᠨ᠎ᠠ! + ᠳᠠᠷᠠᠭᠠᠬᠢ ᠫᠠᠷᠦᠭᠷᠡᠮ ᠶᠠᠭ ᠠᠵᠢᠯᠯᠠᠵᠤ ᠪᠠᠢᠨ᠎ᠠ ᠂ ᠱᠢᠰᠲ᠋ᠧᠮ᠎ᠦᠨ ᠤᠨᠳᠠᠬᠤ᠎ᠶᠢ ᠬᠤᠷᠢᠭᠯᠠᠨ᠎ᠠ! - The following program is running to prevent the system from hibernate! - ᠳᠠᠷᠠᠭᠠᠬᠢ ᠫᠠᠷᠦᠭᠷᠡᠮ ᠶᠠᠭ ᠠᠵᠢᠯᠯᠠᠵᠤ ᠪᠠᠢᠨ᠎ᠠ ᠂ ᠱᠢᠰᠲ᠋ᠧᠮ᠎ᠦᠨ ᠢᠴᠡᠬᠡᠯᠡᠬᠦ᠌᠎ᠶᠢ ᠬᠤᠷᠢᠭᠯᠠᠨ᠎ᠠ! + ᠳᠠᠷᠠᠭᠠᠬᠢ ᠫᠠᠷᠦᠭᠷᠡᠮ ᠶᠠᠭ ᠠᠵᠢᠯᠯᠠᠵᠤ ᠪᠠᠢᠨ᠎ᠠ ᠂ ᠱᠢᠰᠲ᠋ᠧᠮ᠎ᠦᠨ ᠢᠴᠡᠬᠡᠯᠡᠬᠦ᠌᠎ᠶᠢ ᠬᠤᠷᠢᠭᠯᠠᠨ᠎ᠠ! - The following program is running to prevent the system from shutting down! - ᠳᠠᠷᠠᠭᠠᠬᠢ ᠫᠠᠷᠦᠭᠷᠡᠮ ᠶᠠᠭ ᠠᠵᠢᠯᠯᠠᠵᠤ ᠪᠠᠢᠨ᠎ᠠ ᠂ ᠱᠢᠰᠲ᠋ᠧᠮ᠎ᠦᠨ ᠬᠠᠭᠠᠬᠤ᠎ᠶᠢ ᠬᠤᠷᠢᠭᠯᠠᠨ᠎ᠠ! + ᠳᠠᠷᠠᠭᠠᠬᠢ ᠫᠠᠷᠦᠭᠷᠡᠮ ᠶᠠᠭ ᠠᠵᠢᠯᠯᠠᠵᠤ ᠪᠠᠢᠨ᠎ᠠ ᠂ ᠱᠢᠰᠲ᠋ᠧᠮ᠎ᠦᠨ ᠬᠠᠭᠠᠬᠤ᠎ᠶᠢ ᠬᠤᠷᠢᠭᠯᠠᠨ᠎ᠠ! - The following program is running to prevent the system from reboot! - ᠳᠠᠷᠠᠭᠠᠬᠢ ᠫᠠᠷᠦᠭᠷᠡᠮ ᠶᠠᠭ ᠠᠵᠢᠯᠯᠠᠵᠤ ᠪᠠᠢᠨ᠎ᠠ ᠂ ᠱᠢᠰᠲ᠋ᠧᠮ᠎ᠦᠨ ᠳᠠᠬᠢᠵᠤ ᠡᠬᠢᠯᠡᠬᠦ᠌᠎ᠶᠢ ᠬᠤᠷᠢᠭᠯᠠᠨ᠎ᠠ! + ᠳᠠᠷᠠᠭᠠᠬᠢ ᠫᠠᠷᠦᠭᠷᠡᠮ ᠶᠠᠭ ᠠᠵᠢᠯᠯᠠᠵᠤ ᠪᠠᠢᠨ᠎ᠠ ᠂ ᠱᠢᠰᠲ᠋ᠧᠮ᠎ᠦᠨ ᠳᠠᠬᠢᠵᠤ ᠡᠬᠢᠯᠡᠬᠦ᠌᠎ᠶᠢ ᠬᠤᠷᠢᠭᠯᠠᠨ᠎ᠠ! @@ -2627,14 +2130,12 @@ SwitchButtonGroup - uEduPWD - ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋᠎ᠢᠶᠠᠷ ᠨᠡᠪᠳᠡᠷᠡᠬᠦ᠌ + ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋᠎ᠢᠶᠠᠷ ᠨᠡᠪᠳᠡᠷᠡᠬᠦ᠌ - Wechat - ᠸᠢᠴᠠᠲ᠎ᠢᠶᠠᠷ ᠨᠡᠪᠳᠡᠷᠡᠬᠦ᠌ + ᠸᠢᠴᠠᠲ᠎ᠢᠶᠠᠷ ᠨᠡᠪᠳᠡᠷᠡᠬᠦ᠌ @@ -2648,130 +2149,90 @@ 向上滑动解锁 - New password is the same as old - ᠱᠢᠨ᠎ᠡ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠪᠤᠯᠤᠨ ᠤᠤᠯ᠎ᠤᠨ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠠᠳᠠᠯᠢ + ᠱᠢᠨ᠎ᠡ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠪᠤᠯᠤᠨ ᠤᠤᠯ᠎ᠤᠨ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠠᠳᠠᠯᠢ - Reset password error:%1 - ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋᠎ᠢ ᠳᠠᠬᠢᠵᠤ ᠳᠤᠬᠢᠷᠠᠭᠤᠯᠤᠭᠰᠠᠨ ᠨᠢ ᠢᠯᠠᠭᠳᠠᠪᠠ ᠄%1 + ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋᠎ᠢ ᠳᠠᠬᠢᠵᠤ ᠳᠤᠬᠢᠷᠠᠭᠤᠯᠤᠭᠰᠠᠨ ᠨᠢ ᠢᠯᠠᠭᠳᠠᠪᠠ ᠄%1 - Please scan by correct WeChat - ᠲᠠ ᠵᠦᠪ ᠸᠢᠴᠠᠲ᠎ᠢᠶᠠᠷ ᠺᠤᠳ᠋᠎ᠢ ᠱᠢᠷᠪᠢᠬᠡᠷᠡᠢ + ᠲᠠ ᠵᠦᠪ ᠸᠢᠴᠠᠲ᠎ᠢᠶᠠᠷ ᠺᠤᠳ᠋᠎ᠢ ᠱᠢᠷᠪᠢᠬᠡᠷᠡᠢ - - - - - - Cancel - ᠪᠣᠯᠢᠬᠤ ᠂ ᠪᠣᠯᠢᠬᠤ + ᠬᠦᠴᠦᠨ ᠦᠭᠡᠶ ᠪᠣᠯᠭᠠᠨ᠎ᠠ᠃ - - Back - ᠪᠤᠴᠠᠬᠤ + ᠪᠤᠴᠠᠬᠤ - Skip - ᠦᠰᠦᠷᠴᠤ᠌ ᠭᠠᠷᠬᠤ + ᠦᠰᠦᠷᠴᠤ᠌ ᠭᠠᠷᠬᠤ Utils - kylin network applet desktop message - ᠴᠢ ᠯᠢᠨ ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠪᠠᠭᠠᠵᠢ ᠰᠤᠷᠠᠭ ᠵᠠᠩᠬᠢ᠎ᠪᠠᠷ ᠰᠠᠨᠠᠭᠤᠯᠬᠤ + ᠴᠢ ᠯᠢᠨ ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠪᠠᠭᠠᠵᠢ ᠰᠤᠷᠠᠭ ᠵᠠᠩᠬᠢ᠎ᠪᠠᠷ ᠰᠠᠨᠠᠭᠤᠯᠬᠤ VerificationWidget - Please scan by bound WeChat - ᠲᠠ ᠨᠢᠭᠡᠨᠳᠡ ᠤᠶᠠᠭᠰᠠᠨ ᠸᠢᠴᠠᠲ᠎ᠢᠶᠠᠷ ᠺᠤᠳ᠋᠎ᠢ ᠱᠢᠷᠪᠢᠬᠡᠷᠡᠢ + ᠲᠠ ᠨᠢᠭᠡᠨᠳᠡ ᠤᠶᠠᠭᠰᠠᠨ ᠸᠢᠴᠠᠲ᠎ᠢᠶᠠᠷ ᠺᠤᠳ᠋᠎ᠢ ᠱᠢᠷᠪᠢᠬᠡᠷᠡᠢ VerticalVerificationWidget - Please scan by bound WeChat - ᠲᠠ ᠨᠢᠭᠡᠨᠳᠡ ᠤᠶᠠᠭᠰᠠᠨ ᠸᠢᠴᠠᠲ᠎ᠢᠶᠠᠷ ᠺᠤᠳ᠋᠎ᠢ ᠱᠢᠷᠪᠢᠬᠡᠷᠡᠢ + ᠲᠠ ᠨᠢᠭᠡᠨᠳᠡ ᠤᠶᠠᠭᠰᠠᠨ ᠸᠢᠴᠠᠲ᠎ᠢᠶᠠᠷ ᠺᠤᠳ᠋᠎ᠢ ᠱᠢᠷᠪᠢᠬᠡᠷᠡᠢ WeChatAuthDialog - - Login by wechat - ᠸᠢᠴᠠᠲ᠎ᠢᠶᠠᠷ ᠨᠡᠪᠳᠡᠷᠡᠬᠦ᠌ + ᠸᠢᠴᠠᠲ᠎ᠢᠶᠠᠷ ᠨᠡᠪᠳᠡᠷᠡᠬᠦ᠌ - - Verification by wechat - ᠸᠢᠴᠠᠲ᠎ᠢᠶᠠᠷ ᠪᠠᠳᠤᠯᠠᠬᠤ + ᠸᠢᠴᠠᠲ᠎ᠢᠶᠠᠷ ᠪᠠᠳᠤᠯᠠᠬᠤ - - 「 Use registered WeChat account to login 」 - 「 ᠨᠢᠭᠡᠨᠳᠡ ᠪᠦᠷᠢᠳᠭᠡᠬᠦᠯᠦᠭᠰᠡᠨ ᠸᠢᠴᠠᠲ᠎ᠤᠨ ᠨᠤᠮᠸᠷ᠎ᠢᠶᠠᠷ ᠨᠡᠪᠳᠡᠷᠡᠬᠦ᠌」 + 「 ᠨᠢᠭᠡᠨᠳᠡ ᠪᠦᠷᠢᠳᠭᠡᠬᠦᠯᠦᠭᠰᠡᠨ ᠸᠢᠴᠠᠲ᠎ᠤᠨ ᠨᠤᠮᠸᠷ᠎ᠢᠶᠠᠷ ᠨᠡᠪᠳᠡᠷᠡᠬᠦ᠌」 - - 「 Use bound WeChat account to verification 」 - 「 ᠲᠤᠰ ᠳᠠᠩᠰᠠᠨ᠎ᠳᠤ ᠤᠶᠠᠭᠰᠠᠨ ᠸᠢᠴᠠᠲ᠎ᠢᠶᠠᠷ ᠪᠠᠳᠤᠯᠠᠬᠤ」 + 「 ᠲᠤᠰ ᠳᠠᠩᠰᠠᠨ᠎ᠳᠤ ᠤᠶᠠᠭᠰᠠᠨ ᠸᠢᠴᠠᠲ᠎ᠢᠶᠠᠷ ᠪᠠᠳᠤᠯᠠᠬᠤ」 - - Network not connected~ - ᠱᠢᠰᠲ᠋ᠧᠮ ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠳᠦ ᠬᠤᠯᠪᠤᠭᠳᠠᠭ᠎ᠠ ᠦᠬᠡᠢ ᠂ ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠴᠦᠷᠬᠡᠯᠡᠬᠡ᠎ᠶᠢ ᠪᠠᠢᠴᠠᠭᠠᠭᠠᠷᠠᠢ~ + ᠱᠢᠰᠲ᠋ᠧᠮ ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠳᠦ ᠬᠤᠯᠪᠤᠭᠳᠠᠭ᠎ᠠ ᠦᠬᠡᠢ ᠂ ᠰᠦᠯᠵᠢᠶᠡᠨ᠎ᠦ ᠴᠦᠷᠬᠡᠯᠡᠬᠡ᠎ᠶᠢ ᠪᠠᠢᠴᠠᠭᠠᠭᠠᠷᠠᠢ~ - Scan code successfully - ᠺᠤᠳ᠋ ᠱᠢᠷᠪᠢᠵᠤ ᠴᠢᠳᠠᠪᠠ + ᠺᠤᠳ᠋ ᠱᠢᠷᠪᠢᠵᠤ ᠴᠢᠳᠠᠪᠠ - Timeout!Try again! - ᠴᠠᠭ ᠬᠡᠳᠦᠷᠡᠪᠡ! ᠺᠤᠳ᠋᠎ᠢ ᠳᠠᠬᠢᠵᠤ ᠱᠢᠷᠪᠢᠬᠡᠷᠡᠢ! + ᠴᠠᠭ ᠬᠡᠳᠦᠷᠡᠪᠡ! ᠺᠤᠳ᠋᠎ᠢ ᠳᠠᠬᠢᠵᠤ ᠱᠢᠷᠪᠢᠬᠡᠷᠡᠢ! Login failed 登录失败 - - Widget - - - Widget - - - - - LoadPlugin - - - delay - + how long to show lock ᠡᠳᠦᠢ ᠤᠷᠲᠤ ᠬᠤᠭᠤᠴᠠᠭ᠎ᠠ᠎ᠪᠠᠷ ᠣᠨᠢᠰᠣ᠎ᠶ᠋ᠢ ᠢᠯᠡᠷᠡᠭᠦᠯᠬᠦ @@ -2779,7 +2240,7 @@ has-lock - + if show lock ᠣᠨᠢᠰᠤᠯᠠᠬᠤ᠎ᠶ᠋ᠢ ᠢᠯᠡᠷᠡᠭᠦᠯᠪᠡᠯ @@ -2787,87 +2248,97 @@ main - + Start command for the ukui ScreenSaver. ᠳᠡᠯᠭᠡᠴᠡ ᠤᠨᠢᠰᠤᠯᠠᠬᠤ᠎ᠶᠢ ᠡᠬᠢᠯᠡᠬᠦᠯᠵᠤ ᠵᠠᠷᠯᠢᠭ᠎ᠲᠤ ᠬᠦᠷᠬᠡᠬᠦ᠌ - - - + + + lock the screen immediately ᠤᠳᠤᠬᠠᠨ ᠳᠡᠯᠬᠡᠴᠡ᠎ᠶᠢ ᠤᠨᠢᠰᠤᠯᠠᠬᠤ - + query the status of the screen saver ᠳᠡᠯᠭᠡᠴᠡ ᠤᠨᠢᠰᠤᠯᠠᠭᠰᠠᠨ ᠪᠠᠢᠳᠠᠯ᠎ᠢ ᠤᠯᠵᠠᠯᠠᠬᠤ - + unlock the screen saver ᠳᠡᠯᠭᠡᠴᠡᠨ᠎ᠦ ᠤᠨᠢᠰᠤ᠎ᠶᠢ ᠳᠠᠢᠯᠠᠬᠤ - + show the screensaver ᠳᠡᠯᠭᠡᠴᠡ ᠬᠠᠮᠠᠭᠠᠯᠠᠬᠤ ᠫᠷᠦᠭᠷᠡᠮ᠎ᠢ ᠢᠯᠡᠷᠡᠬᠦᠯᠬᠦ᠌ - + show blank and delay to lock,param:idle/lid/lowpower ᠬᠣᠭᠣᠰᠣᠨ ᠪᠠᠢᠬᠤ ᠪᠥᠭᠡᠳ ᠣᠨᠢᠰᠤᠯᠠᠬᠤ᠎ᠶ᠋ᠢ ᠬᠣᠢᠰᠢᠯᠠᠭᠤᠯᠬᠤ ᠫᠷᠠᠮᠧᠲ᠋ᠷ᠎ᠢ᠋ ᠢᠯᠡᠷᠡᠭᠦᠯᠬᠦ ᠄ ᠰᠤᠯᠠ / ᠳᠡᠭᠡᠷ᠎ᠡ ᠬᠠᠪᠬᠠᠭᠠᠰᠤ / ᠪᠠᠭ᠎ᠠ ᠴᠢᠳᠠᠮᠵᠢ - + Dialog for the ukui ScreenSaver. ᠳᠡᠯᠭᠡᠴᠡ ᠬᠠᠮᠠᠭᠠᠯᠠᠬᠤ ᠫᠷᠦᠭᠷᠡᠮ᠎ᠦᠨ ᠶᠠᠷᠢᠯᠴᠠᠯᠭ᠎ᠠ᠎ᠶᠢᠨ ᠴᠤᠩᠬᠤ - + activated by session idle signal ᠶᠠᠷᠢᠯᠴᠠᠭ᠎ᠠ ᠰᠤᠯᠠ ᠳᠣᠬᠢᠶ᠎ᠠ᠎ᠪᠠᠷ ᠢᠳᠡᠪᠬᠢᠵᠢᠭᠦᠯᠬᠦ - - + + lock the screen and show screensaver immediately ᠳᠡᠯᠭᠡᠴᠡ᠎ᠶᠢ ᠤᠨᠢᠰᠤᠯᠠᠬᠤ᠎ᠶᠢᠨ ᠵᠡᠷᠬᠡᠴᠡᠬᠡ ᠳᠡᠯᠭᠡᠴᠡ ᠬᠠᠮᠠᠭᠠᠯᠠᠬᠤ ᠫᠷᠦᠭᠷᠡᠮ᠎ᠢ ᠳᠠᠷᠤᠢᠬᠠᠨ ᠢᠯᠡᠷᠡᠬᠦᠯᠬᠦ᠌ - + show screensaver immediately ᠳᠡᠯᠭᠡᠴᠡ ᠬᠠᠮᠠᠭᠠᠯᠠᠬᠤ ᠫᠷᠤᠭ᠌ᠷᠡᠮ᠎ᠢ ᠳᠠᠷᠤᠢᠬᠠᠨ ᠢᠯᠡᠷᠡᠬᠦᠯᠬᠦ᠌ - + show blank screensaver immediately and delay time to show lock ᠬᠣᠭᠣᠰᠣᠨ ᠳᠡᠯᠭᠡᠴᠡ ᠬᠠᠮᠠᠭᠠᠯᠠᠬᠤ ᠫᠷᠤᠭ᠌ᠷᠠᠮ᠎ᠢ᠋ ᠳᠠᠷᠤᠢᠬᠠᠨ ᠢᠯᠡᠷᠡᠭᠦᠯᠵᠦ ᠣᠨᠢᠰᠤᠯᠠᠭᠰᠠᠨ ᠴᠠᠭ᠎ᠢ᠋ ᠬᠣᠢᠰᠢᠯᠠᠭᠤᠯᠬᠤ - + show blank screensaver immediately and if lock ᠳᠠᠷᠤᠢ ᠬᠣᠭᠣᠰᠣᠨ ᠳᠡᠯᠭᠡᠴᠡ᠎ᠶ᠋ᠢ ᠬᠠᠮᠠᠭᠠᠯᠠᠬᠤ ᠫᠷᠤᠭ᠌ᠷᠠᠮ᠎ᠢ᠋ ᠢᠯᠡᠷᠡᠭᠦᠯᠦᠨ᠎ᠡ ᠂ ᠬᠡᠷᠪᠡ ᠣᠨᠢᠰᠤᠯᠠᠪᠠᠯ - + Screensaver for ukui-screensaver ukui—screensaver ᠳᠡᠯᠭᠡᠴᠡ ᠬᠠᠮᠠᠭᠠᠯᠠᠬᠤ ᠫᠷᠤᠭ᠌ᠷᠠᠮ - + show on root window ᠦᠨᠳᠦᠰᠦ ᠴᠣᠩᠬᠣᠨ᠎ᠳ᠋ᠤ᠌ ᠬᠠᠷᠠᠭᠤᠯᠬᠤ - + show on window. ᠴᠣᠩᠬᠣᠨ ᠳᠡᠭᠡᠷ᠎ᠡ ᠢᠯᠡᠷᠡᠭᠦᠯᠬᠦ ᠃ - + window id ᠴᠣᠩᠬᠣᠨ᠎ᠤ᠋ id + + + Backend for the ukui ScreenSaver. + + + + + lock the screen by startup + + diff --git a/i18n_ts/pt.ts b/i18n_ts/pt.ts index 5659448..d2ba1ec 100644 --- a/i18n_ts/pt.ts +++ b/i18n_ts/pt.ts @@ -46,18 +46,6 @@ Authentication failure, Please try again - - Please try again in %1 minutes. - - - - Please try again in %1 seconds. - - - - Account locked permanently. - - Password cannot be empty @@ -67,80 +55,13 @@ - Verify face recognition or enter password to unlock - - - - Press fingerprint or enter password to unlock - - - - Verify voiceprint or enter password to unlock - - - - Verify finger vein or enter password to unlock - - - - Verify iris or enter password to unlock - - - - Failed to verify %1, you still have %2 verification opportunities - - - - Use the bound wechat scanning code or enter the password to unlock - - - - Failed to verify %1, please enter password to unlock - - - - Unable to verify %1, please enter password to unlock + Password Input Password - - Abnormal network - - - - Enter the ukey password - - - - Insert the ukey into the USB port - - - - Password: - - - - - BatteryWidget - - Charging... - - - - fully charged - - - - PowerMode - - - - BatteryMode - - BioAuthWidget @@ -207,36 +128,6 @@ Nome do dispositivo: - - BiometricAuthWidget - - Current device: - - - - Identify failed, Please retry. - - - - - BiometricDevicesWidget - - Please select the biometric device - - - - Device type: - - - - Device name: - - - - OK - - - CharsMoreWidget @@ -259,1159 +150,83 @@ - - ConfForm - - edit network - - - - LAN name: - - - - Method: - - - - Address: - - - - Netmask: - - - - Gateway: - - - - DNS 1: - - - - DNS 2: - - - - Edit Conn - - - - Auto(DHCP) - - - - Manual - - - - Cancel - - - - Save - - - - Ok - - - - Can not create new wired network for without wired card - - - - New network already created - - - - New network settings already finished - - - - New settings already effective - - - - Edit Network - - - - Add Wired Network - - - DeviceType FingerPrint - Impressão digital + Impressão digital FingerVein - FingerVein + FingerVein Iris - Íris + Íris Face - Face + Face VoicePrint - VoicePrint - - - QRCode - - - - Ukey - - - - - DigitalAuthDialog - - LoginByUEdu - - - - ResetPWD? - - - - SetNewUEduPWD - - - - clear - - - - ConfirmNewUEduPWD - - - - The two password entries are inconsistent, please reset - - - - Password entered incorrectly, please try again - - - - - DlgConnHidWifi - - Connect to Hidden Wi-Fi Network - - - - Add Hidden Wi-Fi - - - - Connection - - - - Wi-Fi name - - - - Wi-Fi security - - - - Cancel - - - - Connect - - - - C_reate… - - - - None - - - - WPA & WPA2 Personal - + VoicePrint DlgConnHidWifiLeap - - Connect to Hidden Wi-Fi Network - - - - Add hidden Wi-Fi - - - - Connection - - - - Network name - - - - Wi-Fi security - - - - Username - - Password - Senha - - - Cancel - - - - Connect - - - - C_reate… - - - - None - - - - WPA & WPA2 Personal - - - - WEP 40/128-bit Key (Hex or ASCII) - - - - WEP 128-bit Passphrase - - - - Dynamic WEP (802.1X) - - - - WPA & WPA2 Enterprise - + Senha DlgConnHidWifiSecFast - - Connect to Hidden Wi-Fi Network - - - - Add hidden Wi-Fi - - - - Connection - - - - Network name - - - - Wi-Fi security - - - - Authentication - - - - Anonymous identity - - - - Allow automatic PAC pro_visioning - - - - PAC file - - - - Inner authentication - - - - Username - - Password - Senha - - - Cancel - - - - Connect - - - - C_reate… - - - - None - - - - WPA & WPA2 Personal - - - - WEP 40/128-bit Key (Hex or ASCII) - - - - WEP 128-bit Passphrase - - - - Dynamic WEP (802.1X) - - - - WPA & WPA2 Enterprise - - - - Tunneled TLS - - - - Protected EAP (PEAP) - - - - Anonymous - - - - Authenticated - - - - Both - + Senha DlgConnHidWifiSecLeap - - Connect to Hidden Wi-Fi Network - - - - Add hidden Wi-Fi - - - - Connection - - - - Network name - - - - Wi-Fi security - - - - Authentication - - - - Username - - Password - Senha - - - Cancel - - - - Connect - - - - C_reate… - - - - None - - - - WPA & WPA2 Personal - - - - WEP 40/128-bit Key (Hex or ASCII) - - - - WEP 128-bit Passphrase - - - - Dynamic WEP (802.1X) - - - - WPA & WPA2 Enterprise - - - - Tunneled TLS - - - - Protected EAP (PEAP) - + Senha DlgConnHidWifiSecPeap - - Connect to Hidden Wi-Fi Network - - - - Add hidden Wi-Fi - - - - Connection - - - - Network name - - - - Wi-Fi security - - - - Authentication - - - - Anonymous identity - - - - Domain - - - - CA certificate - - - - CA certificate password - - - - No CA certificate is required - - - - PEAP version - - - - Inner authentication - - - - Username - - Password - Senha - - - Cancel - - - - Connect - - - - None - - - - WPA & WPA2 Personal - - - - WEP 40/128-bit Key (Hex or ASCII) - - - - WEP 128-bit Passphrase - - - - Dynamic WEP (802.1X) - - - - WPA & WPA2 Enterprise - - - - Tunneled TLS - - - - Protected EAP (PEAP) - - - - Choose from file - - - - Automatic - - - - Version 0 - - - - Version 1 - + Senha DlgConnHidWifiSecPwd - - Connect to Hidden Wi-Fi Network - - - - Add hidden Wi-Fi - - - - Connection - - - - Network name - - - - Wi-Fi security - - - - Authentication - - - - Username - - Password - Senha - - - Cancel - - - - Connect - - - - C_reate… - - - - None - - - - WPA & WPA2 Personal - - - - WEP 40/128-bit Key (Hex or ASCII) - - - - WEP 128-bit Passphrase - - - - Dynamic WEP (802.1X) - - - - WPA & WPA2 Enterprise - - - - Tunneled TLS - - - - Protected EAP (PEAP) - - - - - DlgConnHidWifiSecTls - - Connect to Hidden Wi-Fi Network - - - - Add hidden Wi-Fi - - - - Connection - - - - Network name - - - - Wi-Fi security - - - - Authentication - - - - Identity - - - - Domain - - - - CA certificate - - - - CA certificate password - - - - No CA certificate is required - - - - User certificate - - - - User certificate password - - - - User private key - - - - User key password - - - - Cancel - - - - Connect - - - - C_reate… - - - - None - - - - WPA & WPA2 Personal - - - - WEP 40/128-bit Key (Hex or ASCII) - - - - WEP 128-bit Passphrase - - - - Dynamic WEP (802.1X) - - - - WPA & WPA2 Enterprise - - - - Tunneled TLS - - - - Protected EAP (PEAP) - - - - Choose from file - + Senha DlgConnHidWifiSecTunnelTLS - - Connect to Hidden Wi-Fi Network - - - - Add hidden Wi-Fi - - - - Connection - - - - Network name - - - - Wi-Fi security - - - - Authentication - - - - Anonymous identity - - - - Domain - - - - CA certificate - - - - CA certificate password - - - - No CA certificate is required - - - - Inner authentication - - - - Username - - Password - Senha - - - Cancel - - - - Connect - - - - C_reate… - - - - None - - - - WPA & WPA2 Personal - - - - WEP 40/128-bit Key (Hex or ASCII) - - - - WEP 128-bit Passphrase - - - - Dynamic WEP (802.1X) - - - - WPA & WPA2 Enterprise - - - - Tunneled TLS - - - - Protected EAP (PEAP) - - - - Choose from file - - - - - DlgConnHidWifiWep - - Connect to Hidden Wi-Fi Network - - - - Add hidden Wi-Fi - - - - Connection - - - - Network name - - - - Wi-Fi security - - - - Key - - - - WEP index - - - - Authentication - - - - Cancel - - - - Connect - - - - C_reate… - - - - None - - - - WPA & WPA2 Personal - - - - WEP 40/128-bit Key (Hex or ASCII) - - - - WEP 128-bit Passphrase - - - - Dynamic WEP (802.1X) - - - - WPA & WPA2 Enterprise - - - - 1(default) - - - - Open System - - - - Shared Key - + Senha DlgConnHidWifiWpa - - Connect to Hidden Wi-Fi Network - - - - Add Hidden Wi-Fi - - - - Connection - - - - Wi-Fi name - - - - Wi-Fi security - - Password - Senha - - - Cancel - - - - Connect - - - - C_reate… - - - - None - - - - WPA & WPA2 Personal - + Senha DlgHotspotCreate - - Dialog - - - - Create Hotspot - - - - Network name - - - - Wi-Fi security - - Password - Senha - - - Cancel - - - - Ok - - - - None - - - - WPA & WPA2 Personal - - - - - EngineDevice - - yes - - - - no - - - - Yes - - - - No - - - - %1% available, charged - - - - Left %1h %2m (%3%) - - - - %1% available - - - - Left %1h %2m to full - - - - charging (%1%) - - - - %1 waiting to discharge (%2%) - - - - %1 waiting to charge (%2%) - - - - AC adapter - - - - Laptop battery - - - - UPS - - - - Monitor - - - - Mouse - - - - Keyboard - - - - PDA - - - - Cell phone - - - - Media player - - - - Tablet - - - - Computer - - - - unrecognised - - - - - IconEdit - - OK - - - - - InputInfos - - Get code - - - - Recapture(60s) - - - - Recapture(%1s) - - - - Service exception... - - - - Invaild parameters... - - - - Unknown fault:%1 - + Senha @@ -1421,101 +236,6 @@ KeyboardWidget - - KylinNM - - kylin-nm - - - - No usable network in the list - - - - HotSpot - - - - FlyMode - - - - Advanced - - - - Show KylinNM - - - - No wireless card detected - - - - Not connected - - - - Disconnected - - - - NetOn, - - - - No Other Wired Network Scheme - - - - No Other Wireless Network Scheme - - - - Wired net is disconnected - - - - Conn Ethernet Success - - - - Conn Ethernet Fail - - - - Conn Wifi Success - - - - Confirm your Wi-Fi password or usable of wireless card - - - - Inactivated LAN - - - - LAN - - - - WLAN - - - - Activated LAN - - - - Activated WLAN - - - - Other WLAN - - - LettersWidget @@ -1527,19 +247,34 @@ + + LightDMHelper + + failed to start session. + + + + Login + + + + Guest + Convidado + + LockWidget Form - Formato + Formato Date - Encontro + Encontro Time - Tempo + Tempo Guest @@ -1547,12 +282,18 @@ SwitchUser - Mudar de utilizador + Mudar de utilizador + + + LoginOptionsWidget - Multiple users are logged in at the same time.Are you sure you want to reboot this system? - + Password + Senha + + + MyNetworkWidget LAN @@ -1561,44 +302,6 @@ WLAN - - PowerInfo - - - - Power - - - - VirtualKeyboard - - - - - LoginOptionsWidget - - Login Options - - - - Password - Senha - - - Identify device removed! - - - - Other - - - - - MyLineEdit - - Verification code - - NumbersWidget @@ -1615,124 +318,44 @@ OneConnForm Form - Formato - - - Connect - - - - Disconnect - - - - Input Password... - - - - Automatically join the network - - - - Connect to Hidden Wi-Fi Network - - - - None - - - - WiFi Security: - - - - Signal: - - - - MAC: - - - - Conn Wifi Failed - + Formato OneLancForm Form - Formato - - - Connect - - - - Disconnect - - - - No Configuration - - - - IPv4: - - - - IPv6: - - - - BandWidth: - - - - MAC: - + Formato - PhoneAuthWidget + PowerListWidget - Verification by phoneNum + Hibernate - 「 Use bound Phone number to verification 」 + Turn off your computer, but the app stays open. When the computer is turned on, it can be restored to the state you left - commit + Suspend - 「 Use SMS to verification 」 + The computer stays on, but consumes less power. The app stays open and can quickly wake up and revert to where you left off - Network not connected~ + Reboot - Verification Code invalid! + Power Off - Verification Code incorrect.Please retry! - - - - Failed time over limit!Retry after 1 hour! - - - - verifaction failed! - - - - Network unavailable~ + Close all apps, and then shut down your computer @@ -1742,50 +365,6 @@ SwitchUser Mudar de utilizador - - Log Out - - - - Power Off - - - - Suspend - - - - lock - - - - Shut Down - - - - Hibernate - - - - Restart - - - - Close all apps, turn off your computer, and then turn your computer back on - - - - Close all apps, and then shut down your computer - - - - Turn off your computer, but the app stays open. When the computer is turned on, it can be restored to the state you left - - - - The computer stays on, but consumes less power. The app stays open and can quickly wake up and revert to where you left off - - QObject @@ -1798,14 +377,6 @@ - - S: - - - tablet device - - - Screensaver @@ -1816,10 +387,6 @@ View - - You have new notification - - SleepTime @@ -1832,136 +399,11 @@ SureWindow Form - Formato + Formato TextLabel - TextLabel - - - Cancel - - - - Confirm - - - - The following program is running to prevent the system from reboot! - - - - The following program is running to prevent the system from shutting down! - - - - The following program is running to prevent the system from suspend! - - - - The following program is running to prevent the system from hibernate! - - - - - SwitchButtonGroup - - uEduPWD - - - - Wechat - - - - - TabletLockWidget - - Cancel - - - - Back - - - - Skip - - - - New password is the same as old - - - - Reset password error:%1 - - - - Please scan by correct WeChat - - - - - Utils - - kylin network applet desktop message - - - - - VerificationWidget - - Please scan by bound WeChat - - - - - VerticalVerificationWidget - - Please scan by bound WeChat - - - - - WeChatAuthDialog - - Login by wechat - - - - 「 Use registered WeChat account to login 」 - - - - Verification by wechat - - - - 「 Use bound WeChat account to verification 」 - - - - Network not connected~ - - - - Scan code successfully - - - - Timeout!Try again! - - - - - Widget - - Widget - - - - LoadPlugin - + TextLabel @@ -2044,5 +486,13 @@ show blank screensaver immediately and if lock + + Backend for the ukui ScreenSaver. + + + + lock the screen by startup + + diff --git a/i18n_ts/ru.ts b/i18n_ts/ru.ts index cabb146..808e42c 100644 --- a/i18n_ts/ru.ts +++ b/i18n_ts/ru.ts @@ -46,18 +46,6 @@ Authentication failure, Please try again - - Please try again in %1 minutes. - - - - Please try again in %1 seconds. - - - - Account locked permanently. - - Password cannot be empty @@ -67,80 +55,13 @@ - Verify face recognition or enter password to unlock - - - - Press fingerprint or enter password to unlock - - - - Verify voiceprint or enter password to unlock - - - - Verify finger vein or enter password to unlock - - - - Verify iris or enter password to unlock - - - - Failed to verify %1, you still have %2 verification opportunities - - - - Use the bound wechat scanning code or enter the password to unlock - - - - Failed to verify %1, please enter password to unlock - - - - Unable to verify %1, please enter password to unlock + Password Input Password - - Abnormal network - - - - Enter the ukey password - - - - Insert the ukey into the USB port - - - - Password: - - - - - BatteryWidget - - Charging... - - - - fully charged - - - - PowerMode - - - - BatteryMode - - BioAuthWidget @@ -207,36 +128,6 @@ Имя устройства: - - BiometricAuthWidget - - Current device: - - - - Identify failed, Please retry. - - - - - BiometricDevicesWidget - - Please select the biometric device - - - - Device type: - - - - Device name: - - - - OK - - - CharsMoreWidget @@ -259,1159 +150,83 @@ - - ConfForm - - edit network - - - - LAN name: - - - - Method: - - - - Address: - - - - Netmask: - - - - Gateway: - - - - DNS 1: - - - - DNS 2: - - - - Edit Conn - - - - Auto(DHCP) - - - - Manual - - - - Cancel - - - - Save - - - - Ok - - - - Can not create new wired network for without wired card - - - - New network already created - - - - New network settings already finished - - - - New settings already effective - - - - Edit Network - - - - Add Wired Network - - - DeviceType FingerPrint - FingerPrint + FingerPrint FingerVein - FingerVein + FingerVein Iris - Ирис + Ирис Face - Лицо + Лицо VoicePrint - Voiceprint - - - QRCode - - - - Ukey - - - - - DigitalAuthDialog - - LoginByUEdu - - - - ResetPWD? - - - - SetNewUEduPWD - - - - clear - - - - ConfirmNewUEduPWD - - - - The two password entries are inconsistent, please reset - - - - Password entered incorrectly, please try again - - - - - DlgConnHidWifi - - Connect to Hidden Wi-Fi Network - - - - Add Hidden Wi-Fi - - - - Connection - - - - Wi-Fi name - - - - Wi-Fi security - - - - Cancel - - - - Connect - - - - C_reate… - - - - None - - - - WPA & WPA2 Personal - + Voiceprint DlgConnHidWifiLeap - - Connect to Hidden Wi-Fi Network - - - - Add hidden Wi-Fi - - - - Connection - - - - Network name - - - - Wi-Fi security - - - - Username - - Password - пароль - - - Cancel - - - - Connect - - - - C_reate… - - - - None - - - - WPA & WPA2 Personal - - - - WEP 40/128-bit Key (Hex or ASCII) - - - - WEP 128-bit Passphrase - - - - Dynamic WEP (802.1X) - - - - WPA & WPA2 Enterprise - + пароль DlgConnHidWifiSecFast - - Connect to Hidden Wi-Fi Network - - - - Add hidden Wi-Fi - - - - Connection - - - - Network name - - - - Wi-Fi security - - - - Authentication - - - - Anonymous identity - - - - Allow automatic PAC pro_visioning - - - - PAC file - - - - Inner authentication - - - - Username - - Password - пароль - - - Cancel - - - - Connect - - - - C_reate… - - - - None - - - - WPA & WPA2 Personal - - - - WEP 40/128-bit Key (Hex or ASCII) - - - - WEP 128-bit Passphrase - - - - Dynamic WEP (802.1X) - - - - WPA & WPA2 Enterprise - - - - Tunneled TLS - - - - Protected EAP (PEAP) - - - - Anonymous - - - - Authenticated - - - - Both - + пароль DlgConnHidWifiSecLeap - - Connect to Hidden Wi-Fi Network - - - - Add hidden Wi-Fi - - - - Connection - - - - Network name - - - - Wi-Fi security - - - - Authentication - - - - Username - - Password - пароль - - - Cancel - - - - Connect - - - - C_reate… - - - - None - - - - WPA & WPA2 Personal - - - - WEP 40/128-bit Key (Hex or ASCII) - - - - WEP 128-bit Passphrase - - - - Dynamic WEP (802.1X) - - - - WPA & WPA2 Enterprise - - - - Tunneled TLS - - - - Protected EAP (PEAP) - + пароль DlgConnHidWifiSecPeap - - Connect to Hidden Wi-Fi Network - - - - Add hidden Wi-Fi - - - - Connection - - - - Network name - - - - Wi-Fi security - - - - Authentication - - - - Anonymous identity - - - - Domain - - - - CA certificate - - - - CA certificate password - - - - No CA certificate is required - - - - PEAP version - - - - Inner authentication - - - - Username - - Password - пароль - - - Cancel - - - - Connect - - - - None - - - - WPA & WPA2 Personal - - - - WEP 40/128-bit Key (Hex or ASCII) - - - - WEP 128-bit Passphrase - - - - Dynamic WEP (802.1X) - - - - WPA & WPA2 Enterprise - - - - Tunneled TLS - - - - Protected EAP (PEAP) - - - - Choose from file - - - - Automatic - - - - Version 0 - - - - Version 1 - + пароль DlgConnHidWifiSecPwd - - Connect to Hidden Wi-Fi Network - - - - Add hidden Wi-Fi - - - - Connection - - - - Network name - - - - Wi-Fi security - - - - Authentication - - - - Username - - Password - пароль - - - Cancel - - - - Connect - - - - C_reate… - - - - None - - - - WPA & WPA2 Personal - - - - WEP 40/128-bit Key (Hex or ASCII) - - - - WEP 128-bit Passphrase - - - - Dynamic WEP (802.1X) - - - - WPA & WPA2 Enterprise - - - - Tunneled TLS - - - - Protected EAP (PEAP) - - - - - DlgConnHidWifiSecTls - - Connect to Hidden Wi-Fi Network - - - - Add hidden Wi-Fi - - - - Connection - - - - Network name - - - - Wi-Fi security - - - - Authentication - - - - Identity - - - - Domain - - - - CA certificate - - - - CA certificate password - - - - No CA certificate is required - - - - User certificate - - - - User certificate password - - - - User private key - - - - User key password - - - - Cancel - - - - Connect - - - - C_reate… - - - - None - - - - WPA & WPA2 Personal - - - - WEP 40/128-bit Key (Hex or ASCII) - - - - WEP 128-bit Passphrase - - - - Dynamic WEP (802.1X) - - - - WPA & WPA2 Enterprise - - - - Tunneled TLS - - - - Protected EAP (PEAP) - - - - Choose from file - + пароль DlgConnHidWifiSecTunnelTLS - - Connect to Hidden Wi-Fi Network - - - - Add hidden Wi-Fi - - - - Connection - - - - Network name - - - - Wi-Fi security - - - - Authentication - - - - Anonymous identity - - - - Domain - - - - CA certificate - - - - CA certificate password - - - - No CA certificate is required - - - - Inner authentication - - - - Username - - Password - пароль - - - Cancel - - - - Connect - - - - C_reate… - - - - None - - - - WPA & WPA2 Personal - - - - WEP 40/128-bit Key (Hex or ASCII) - - - - WEP 128-bit Passphrase - - - - Dynamic WEP (802.1X) - - - - WPA & WPA2 Enterprise - - - - Tunneled TLS - - - - Protected EAP (PEAP) - - - - Choose from file - - - - - DlgConnHidWifiWep - - Connect to Hidden Wi-Fi Network - - - - Add hidden Wi-Fi - - - - Connection - - - - Network name - - - - Wi-Fi security - - - - Key - - - - WEP index - - - - Authentication - - - - Cancel - - - - Connect - - - - C_reate… - - - - None - - - - WPA & WPA2 Personal - - - - WEP 40/128-bit Key (Hex or ASCII) - - - - WEP 128-bit Passphrase - - - - Dynamic WEP (802.1X) - - - - WPA & WPA2 Enterprise - - - - 1(default) - - - - Open System - - - - Shared Key - + пароль DlgConnHidWifiWpa - - Connect to Hidden Wi-Fi Network - - - - Add Hidden Wi-Fi - - - - Connection - - - - Wi-Fi name - - - - Wi-Fi security - - Password - пароль - - - Cancel - - - - Connect - - - - C_reate… - - - - None - - - - WPA & WPA2 Personal - + пароль DlgHotspotCreate - - Dialog - - - - Create Hotspot - - - - Network name - - - - Wi-Fi security - - Password - пароль - - - Cancel - - - - Ok - - - - None - - - - WPA & WPA2 Personal - - - - - EngineDevice - - yes - - - - no - - - - Yes - - - - No - - - - %1% available, charged - - - - Left %1h %2m (%3%) - - - - %1% available - - - - Left %1h %2m to full - - - - charging (%1%) - - - - %1 waiting to discharge (%2%) - - - - %1 waiting to charge (%2%) - - - - AC adapter - - - - Laptop battery - - - - UPS - - - - Monitor - - - - Mouse - - - - Keyboard - - - - PDA - - - - Cell phone - - - - Media player - - - - Tablet - - - - Computer - - - - unrecognised - - - - - IconEdit - - OK - - - - - InputInfos - - Get code - - - - Recapture(60s) - - - - Recapture(%1s) - - - - Service exception... - - - - Invaild parameters... - - - - Unknown fault:%1 - + пароль @@ -1421,101 +236,6 @@ KeyboardWidget - - KylinNM - - kylin-nm - - - - No usable network in the list - - - - HotSpot - - - - FlyMode - - - - Advanced - - - - Show KylinNM - - - - No wireless card detected - - - - Not connected - - - - Disconnected - - - - NetOn, - - - - No Other Wired Network Scheme - - - - No Other Wireless Network Scheme - - - - Wired net is disconnected - - - - Conn Ethernet Success - - - - Conn Ethernet Fail - - - - Conn Wifi Success - - - - Confirm your Wi-Fi password or usable of wireless card - - - - Inactivated LAN - - - - LAN - - - - WLAN - - - - Activated LAN - - - - Activated WLAN - - - - Other WLAN - - - LettersWidget @@ -1527,19 +247,34 @@ + + LightDMHelper + + failed to start session. + + + + Login + + + + Guest + гость + + LockWidget Form - форма + форма Date - Дата + Дата Time - Время + Время Guest @@ -1547,12 +282,18 @@ SwitchUser - Сменить пользователя + Сменить пользователя + + + LoginOptionsWidget - Multiple users are logged in at the same time.Are you sure you want to reboot this system? - + Password + пароль + + + MyNetworkWidget LAN @@ -1561,44 +302,6 @@ WLAN - - PowerInfo - - - - Power - - - - VirtualKeyboard - - - - - LoginOptionsWidget - - Login Options - - - - Password - пароль - - - Identify device removed! - - - - Other - - - - - MyLineEdit - - Verification code - - NumbersWidget @@ -1615,124 +318,44 @@ OneConnForm Form - форма - - - Connect - - - - Disconnect - - - - Input Password... - - - - Automatically join the network - - - - Connect to Hidden Wi-Fi Network - - - - None - - - - WiFi Security: - - - - Signal: - - - - MAC: - - - - Conn Wifi Failed - + форма OneLancForm Form - форма - - - Connect - - - - Disconnect - - - - No Configuration - - - - IPv4: - - - - IPv6: - - - - BandWidth: - - - - MAC: - + форма - PhoneAuthWidget + PowerListWidget - Verification by phoneNum + Hibernate - 「 Use bound Phone number to verification 」 + Turn off your computer, but the app stays open. When the computer is turned on, it can be restored to the state you left - commit + Suspend - 「 Use SMS to verification 」 + The computer stays on, but consumes less power. The app stays open and can quickly wake up and revert to where you left off - Network not connected~ + Reboot - Verification Code invalid! + Power Off - Verification Code incorrect.Please retry! - - - - Failed time over limit!Retry after 1 hour! - - - - verifaction failed! - - - - Network unavailable~ + Close all apps, and then shut down your computer @@ -1742,50 +365,6 @@ SwitchUser Сменить пользователя - - Log Out - - - - Power Off - - - - Suspend - - - - lock - - - - Shut Down - - - - Hibernate - - - - Restart - - - - Close all apps, turn off your computer, and then turn your computer back on - - - - Close all apps, and then shut down your computer - - - - Turn off your computer, but the app stays open. When the computer is turned on, it can be restored to the state you left - - - - The computer stays on, but consumes less power. The app stays open and can quickly wake up and revert to where you left off - - QObject @@ -1798,14 +377,6 @@ - - S: - - - tablet device - - - Screensaver @@ -1816,10 +387,6 @@ View - - You have new notification - - SleepTime @@ -1832,136 +399,11 @@ SureWindow Form - форма + форма TextLabel - TextLabel - - - Cancel - - - - Confirm - - - - The following program is running to prevent the system from reboot! - - - - The following program is running to prevent the system from shutting down! - - - - The following program is running to prevent the system from suspend! - - - - The following program is running to prevent the system from hibernate! - - - - - SwitchButtonGroup - - uEduPWD - - - - Wechat - - - - - TabletLockWidget - - Cancel - - - - Back - - - - Skip - - - - New password is the same as old - - - - Reset password error:%1 - - - - Please scan by correct WeChat - - - - - Utils - - kylin network applet desktop message - - - - - VerificationWidget - - Please scan by bound WeChat - - - - - VerticalVerificationWidget - - Please scan by bound WeChat - - - - - WeChatAuthDialog - - Login by wechat - - - - 「 Use registered WeChat account to login 」 - - - - Verification by wechat - - - - 「 Use bound WeChat account to verification 」 - - - - Network not connected~ - - - - Scan code successfully - - - - Timeout!Try again! - - - - - Widget - - Widget - - - - LoadPlugin - + TextLabel @@ -2044,5 +486,13 @@ show blank screensaver immediately and if lock + + Backend for the ukui ScreenSaver. + + + + lock the screen by startup + + diff --git a/i18n_ts/tr.ts b/i18n_ts/tr.ts index 138992b..07d7f24 100644 --- a/i18n_ts/tr.ts +++ b/i18n_ts/tr.ts @@ -4,8 +4,7 @@ AgreementWindow - - + I know @@ -25,7 +24,7 @@ Parola - + Retry Yeniden Dene @@ -34,9 +33,8 @@ Kilidi Aç - Password: - Parola + Parola Account locked %1 minutes due to %2 fail attempts @@ -51,112 +49,31 @@ Kimlik doğrulama hatası, hala %1 kalan denemen var - + Authentication failure, Please try again - - - - - Please try again in %1 minutes. - - - - - Enter the ukey password - - - - - Insert the ukey into the USB port - - - - - - - - Please try again in %1 seconds. - - - - - - - - Account locked permanently. - - - - - Verify face recognition or enter password to unlock - - - - - Press fingerprint or enter password to unlock - - - - - Verify voiceprint or enter password to unlock - - - - - Verify finger vein or enter password to unlock - - - - - Verify iris or enter password to unlock - - - - - Use the bound wechat scanning code or enter the password to unlock - - - - - + + Password cannot be empty - + + Password + + + + Input Password - + Login - - - Failed to verify %1, please enter password to unlock - - - - - - Unable to verify %1, please enter password to unlock - - - - - - Failed to verify %1, you still have %2 verification opportunities - - - - - Abnormal network - - Biometric Authentication Biyometrik Kimlik Doğrulama @@ -170,29 +87,6 @@ Diğer Ayıtlar - - BatteryWidget - - - Charging... - - - - - fully charged - - - - - PowerMode - - - - - BatteryMode - - - BioDevices @@ -234,43 +128,37 @@ BiometricAuthWidget - Current device: - Şuanki aygıt: + Şuanki aygıt: - Identify failed, Please retry. - Tanımlama başarısız, Lütfen tekrar deneyin. + Tanımlama başarısız, Lütfen tekrar deneyin. BiometricDevicesWidget - Please select the biometric device - Lütfen biyometrik aygıtı seçin + Lütfen biyometrik aygıtı seçin - Device type: - Aygıt türü: + Aygıt türü: - Device name: - Aygıt adı: + Aygıt adı: - OK - Tamam + Tamam CharsMoreWidget - + &&?! @@ -278,1883 +166,234 @@ CharsWidget - + More - + ABC - + 123 - - ConfForm - - - edit network - - - - - LAN name: - - - - - Method: - - - - - Address: - - - - - Netmask: - - - - - Gateway: - - - - - DNS 1: - - - - - DNS 2: - - - - - Edit Conn - - - - - - Auto(DHCP) - - - - - - Manual - - - - - Cancel - - - - - Save - - - - - Ok - - - - - Can not create new wired network for without wired card - - - - - New network already created - - - - - New network settings already finished - - - - - New settings already effective - - - - - Edit Network - - - - - Add Wired Network - - - DeviceType - FingerPrint - Parmak İzi + Parmak İzi - FingerVein - Parmak Damarı + Parmak Damarı - Iris - Göz + Göz - Face - Yüz + Yüz - VoicePrint - Ses İzi - - - - Ukey - - - - - QRCode - - - - - DigitalAuthDialog - - - - LoginByUEdu - - - - - ResetPWD? - - - - - - SetNewUEduPWD - - - - - clear - - - - - ConfirmNewUEduPWD - - - - - The two password entries are inconsistent, please reset - - - - - Password entered incorrectly, please try again - - - - - DlgConnHidWifi - - - Connect to Hidden Wi-Fi Network - - - - - Add Hidden Wi-Fi - - - - - Connection - - - - - Wi-Fi name - - - - - Wi-Fi security - - - - - Cancel - - - - - Connect - - - - - C_reate… - - - - - None - - - - - WPA & WPA2 Personal - + Ses İzi DlgConnHidWifiLeap - - Connect to Hidden Wi-Fi Network - - - - - Add hidden Wi-Fi - - - - - Connection - - - - - Network name - - - - - Wi-Fi security - - - - - Username - - - - Password - Parola - - - - Cancel - - - - - Connect - - - - - C_reate… - - - - - None - - - - - WPA & WPA2 Personal - - - - - WEP 40/128-bit Key (Hex or ASCII) - - - - - WEP 128-bit Passphrase - - - - - Dynamic WEP (802.1X) - - - - - WPA & WPA2 Enterprise - + Parola DlgConnHidWifiSecFast - - Connect to Hidden Wi-Fi Network - - - - - Add hidden Wi-Fi - - - - - Connection - - - - - Network name - - - - - Wi-Fi security - - - - - Authentication - - - - - Anonymous identity - - - - - Allow automatic PAC pro_visioning - - - - - PAC file - - - - - Inner authentication - - - - - Username - - - - Password - Parola - - - - Cancel - - - - - Connect - - - - - C_reate… - - - - - - None - - - - - WPA & WPA2 Personal - - - - - WEP 40/128-bit Key (Hex or ASCII) - - - - - WEP 128-bit Passphrase - - - - - Dynamic WEP (802.1X) - - - - - WPA & WPA2 Enterprise - - - - - Tunneled TLS - - - - - Protected EAP (PEAP) - - - - - Anonymous - - - - - Authenticated - - - - - Both - + Parola DlgConnHidWifiSecLeap - - Connect to Hidden Wi-Fi Network - - - - - Add hidden Wi-Fi - - - - - Connection - - - - - Network name - - - - - Wi-Fi security - - - - - Authentication - - - - - Username - - - - Password - Parola - - - - Cancel - - - - - Connect - - - - - C_reate… - - - - - None - - - - - WPA & WPA2 Personal - - - - - WEP 40/128-bit Key (Hex or ASCII) - - - - - WEP 128-bit Passphrase - - - - - Dynamic WEP (802.1X) - - - - - WPA & WPA2 Enterprise - - - - - Tunneled TLS - - - - - Protected EAP (PEAP) - + Parola DlgConnHidWifiSecPeap - - Connect to Hidden Wi-Fi Network - - - - - Add hidden Wi-Fi - - - - - Connection - - - - - Network name - - - - - Wi-Fi security - - - - - Authentication - - - - - Anonymous identity - - - - - Domain - - - - - CA certificate - - - - - CA certificate password - - - - - No CA certificate is required - - - - - PEAP version - - - - - Inner authentication - - - - - Username - - - - Password - Parola - - - - Cancel - - - - - Connect - - - - - - None - - - - - WPA & WPA2 Personal - - - - - WEP 40/128-bit Key (Hex or ASCII) - - - - - WEP 128-bit Passphrase - - - - - Dynamic WEP (802.1X) - - - - - WPA & WPA2 Enterprise - - - - - Tunneled TLS - - - - - Protected EAP (PEAP) - - - - - Choose from file - - - - - Automatic - - - - - Version 0 - - - - - Version 1 - + Parola DlgConnHidWifiSecPwd - - Connect to Hidden Wi-Fi Network - - - - - Add hidden Wi-Fi - - - - - Connection - - - - - Network name - - - - - Wi-Fi security - - - - - Authentication - - - - - Username - - - - Password - Parola - - - - Cancel - - - - - Connect - - - - - C_reate… - - - - - None - - - - - WPA & WPA2 Personal - - - - - WEP 40/128-bit Key (Hex or ASCII) - - - - - WEP 128-bit Passphrase - - - - - Dynamic WEP (802.1X) - - - - - WPA & WPA2 Enterprise - - - - - Tunneled TLS - - - - - Protected EAP (PEAP) - - - - - DlgConnHidWifiSecTls - - - Connect to Hidden Wi-Fi Network - - - - - Add hidden Wi-Fi - - - - - Connection - - - - - Network name - - - - - Wi-Fi security - - - - - Authentication - - - - - Identity - - - - - Domain - - - - - CA certificate - - - - - CA certificate password - - - - - No CA certificate is required - - - - - User certificate - - - - - User certificate password - - - - - User private key - - - - - User key password - - - - - Cancel - - - - - Connect - - - - - C_reate… - - - - - - - - None - - - - - WPA & WPA2 Personal - - - - - WEP 40/128-bit Key (Hex or ASCII) - - - - - WEP 128-bit Passphrase - - - - - Dynamic WEP (802.1X) - - - - - WPA & WPA2 Enterprise - - - - - Tunneled TLS - - - - - Protected EAP (PEAP) - - - - - - - Choose from file - + Parola DlgConnHidWifiSecTunnelTLS - - Connect to Hidden Wi-Fi Network - - - - - Add hidden Wi-Fi - - - - - Connection - - - - - Network name - - - - - Wi-Fi security - - - - - Authentication - - - - - Anonymous identity - - - - - Domain - - - - - CA certificate - - - - - CA certificate password - - - - - No CA certificate is required - - - - - Inner authentication - - - - - Username - - - - Password - Parola - - - - Cancel - - - - - Connect - - - - - C_reate… - - - - - - None - - - - - WPA & WPA2 Personal - - - - - WEP 40/128-bit Key (Hex or ASCII) - - - - - WEP 128-bit Passphrase - - - - - Dynamic WEP (802.1X) - - - - - WPA & WPA2 Enterprise - - - - - Tunneled TLS - - - - - Protected EAP (PEAP) - - - - - Choose from file - - - - - DlgConnHidWifiWep - - - Connect to Hidden Wi-Fi Network - - - - - Add hidden Wi-Fi - - - - - Connection - - - - - Network name - - - - - Wi-Fi security - - - - - Key - - - - - WEP index - - - - - Authentication - - - - - Cancel - - - - - Connect - - - - - C_reate… - - - - - None - - - - - WPA & WPA2 Personal - - - - - WEP 40/128-bit Key (Hex or ASCII) - - - - - WEP 128-bit Passphrase - - - - - Dynamic WEP (802.1X) - - - - - WPA & WPA2 Enterprise - - - - - 1(default) - - - - - Open System - - - - - Shared Key - + Parola DlgConnHidWifiWpa - - Connect to Hidden Wi-Fi Network - - - - - Add Hidden Wi-Fi - - - - - Connection - - - - - Wi-Fi name - - - - - Wi-Fi security - - - - Password - Parola - - - - Cancel - - - - - Connect - - - - - C_reate… - - - - - None - - - - - WPA & WPA2 Personal - + Parola DlgHotspotCreate - - Dialog - - - - - Create Hotspot - - - - - Network name - - - - - Wi-Fi security - - - - Password - Parola - - - - Cancel - - - - - Ok - - - - - None - - - - - WPA & WPA2 Personal - - - - - EngineDevice - - - yes - - - - - no - - - - - Yes - - - - - No - - - - - %1% available, charged - - - - - Left %1h %2m (%3%) - - - - - %1% available - - - - - Left %1h %2m to full - - - - - charging (%1%) - - - - - %1 waiting to discharge (%2%) - - - - - %1 waiting to charge (%2%) - - - - - AC adapter - - - - - Laptop battery - - - - - UPS - - - - - Monitor - - - - - Mouse - - - - - Keyboard - - - - - PDA - - - - - Cell phone - - - - - Media player - - - - - Tablet - - - - - Computer - - - - - unrecognised - + Parola IconEdit - OK - Tamam - - - - InputInfos - - - - Get code - - - - - Recapture(60s) - - - - - Recapture(%1s) - - - - - Service exception... - - - - - Invaild parameters... - - - - - Unknown fault:%1 - - - - - KylinNM - - - kylin-nm - - - - - No usable network in the list - - - - - Inactivated LAN - - - - - Other WLAN - - - - - - LAN - - - - - - WLAN - - - - - HotSpot - - - - - FlyMode - - - - - - Advanced - - - - - Show KylinNM - - - - - No wireless card detected - - - - - Activated LAN - - - - - Activated WLAN - - - - - - - - - Not connected - - - - - - - - - - - - - Disconnected - - - - - - NetOn, - - - - - No Other Wired Network Scheme - - - - - No Other Wireless Network Scheme - - - - - Wired net is disconnected - - - - - Conn Ethernet Success - - - - - Conn Ethernet Fail - - - - - Conn Wifi Success - - - - - Confirm your Wi-Fi password or usable of wireless card - + Tamam LettersWidget - + &&?! - + 123 + + LightDMHelper + + + failed to start session. + + + + + Login + + + + + Guest + Misafir + + LockWidget - - Form - - - - Date - Tarih + Tarih - Time - Zaman + Zaman Guest Misafir - - PowerInfo - - - - - Power - - - - - VirtualKeyboard - - - - SwitchUser - Kullanıcı Değiştir - - - - Multiple users are logged in at the same time.Are you sure you want to reboot this system? - - - - - LAN - - - - - WLAN - + Kullanıcı Değiştir LoginOptionsWidget - - Login Options - - - - Password - Parola - - - - Other - - - - - Identify device removed! - + Parola - MyLineEdit + MyNetworkWidget - - - - Verification code + + LAN + + + + + WLAN NumbersWidget - + &&?! - + Return - OneConnForm + PowerListWidget - - Form + + Hibernate - - - - - Connect + + Turn off your computer, but the app stays open. When the computer is turned on, it can be restored to the state you left - - Disconnect + + Suspend - - Input Password... + + + The computer stays on, but consumes less power. The app stays open and can quickly wake up and revert to where you left off - - Automatically join the network + + Reboot - - Connect to Hidden Wi-Fi Network - + + Power Off + Bilgisayarı Kapat - - None - - - - - WiFi Security: - - - - - Signal: - - - - - MAC: - - - - - Conn Wifi Failed - - - - - OneLancForm - - - Form - - - - - - Connect - - - - - Disconnect - - - - - - No Configuration - - - - - IPv4: - - - - - IPv6: - - - - - BandWidth: - - - - - MAC: - - - - - PhoneAuthWidget - - - - Verification by phoneNum - - - - - 「 Use bound Phone number to verification 」 - - - - - - commit - - - - - 「 Use SMS to verification 」 - - - - - - Network not connected~ - - - - - Verification Code invalid! - - - - - Verification Code incorrect.Please retry! - - - - - Failed time over limit!Retry after 1 hour! - - - - - verifaction failed! - - - - - Network unavailable~ + + Close all apps, and then shut down your computer PowerManager - lock - kilit + kilit SwitchUser @@ -2181,79 +420,31 @@ Kullanıcı Değiştir - Log Out - Çıkış + Çıkış - - Restart - Yeniden Başlat + Yeniden Başlat - Power Off - Bilgisayarı Kapat - - - - Close all apps, turn off your computer, and then turn your computer back on - - - - - Close all apps, and then shut down your computer - - - - - Shut Down - - - - - Turn off your computer, but the app stays open. When the computer is turned on, it can be restored to the state you left - - - - - Hibernate - - - - - The computer stays on, but consumes less power. The app stays open and can quickly wake up and revert to where you left off - - - - - Suspend - + Bilgisayarı Kapat QObject - + The screensaver is active. - + The screensaver is inactive. - - S: - - - - tablet device - - - Screensaver @@ -2265,20 +456,15 @@ çıkış - + Picture does not exist - + View - - - You have new notification - - Set as desktop wallpaper Masaüstü arkaplanı olarak ayarla @@ -2291,190 +477,15 @@ SleepTime - + You have rested - - SureWindow - - - Form - - - - - TextLabel - - - - - Cancel - - - - - Confirm - - - - - The following program is running to prevent the system from reboot! - - - - - The following program is running to prevent the system from shutting down! - - - - - The following program is running to prevent the system from suspend! - - - - - The following program is running to prevent the system from hibernate! - - - - - SwitchButtonGroup - - - uEduPWD - - - - - Wechat - - - - - TabletLockWidget - - - - - - - - Cancel - - - - - - Back - - - - - Skip - - - - - New password is the same as old - - - - - Reset password error:%1 - - - - - Please scan by correct WeChat - - - - - Utils - - - kylin network applet desktop message - - - - - VerificationWidget - - - Please scan by bound WeChat - - - - - VerticalVerificationWidget - - - Please scan by bound WeChat - - - - - WeChatAuthDialog - - - - Login by wechat - - - - - - 「 Use registered WeChat account to login 」 - - - - - - Verification by wechat - - - - - - 「 Use bound WeChat account to verification 」 - - - - - - Network not connected~ - - - - - Scan code successfully - - - - - Timeout!Try again! - - - - - Widget - - - Widget - - - - - LoadPlugin - - - delay - + how long to show lock @@ -2482,7 +493,7 @@ has-lock - + if show lock @@ -2490,87 +501,97 @@ main - + Start command for the ukui ScreenSaver. Ukui Ekran Koruyucu için başlatma komutu. - - - + + + lock the screen immediately Ekranı hemen kilitle - + query the status of the screen saver - + unlock the screen saver - + show the screensaver - + show blank and delay to lock,param:idle/lid/lowpower - + Dialog for the ukui ScreenSaver. - + activated by session idle signal - - + + lock the screen and show screensaver immediately - + show screensaver immediately - + show blank screensaver immediately and delay time to show lock - + show blank screensaver immediately and if lock - + Screensaver for ukui-screensaver - + show on root window - + show on window. - + window id + + + Backend for the ukui ScreenSaver. + + + + + lock the screen by startup + + diff --git a/i18n_ts/zh_CN.ts b/i18n_ts/zh_CN.ts index 351d419..a39e069 100644 --- a/i18n_ts/zh_CN.ts +++ b/i18n_ts/zh_CN.ts @@ -4,8 +4,7 @@ AgreementWindow - - + I know 我已知晓 @@ -25,7 +24,7 @@ 使用密码认证 - + Retry 重试 @@ -46,91 +45,73 @@ 已登录 - Password: - 密码: + 密码: Account locked %1 minutes due to %2 fail attempts 账户锁定%1分钟由于%2次错误尝试 - - - - Please try again in %1 minutes. - 请%1分钟后再试 + 请%1分钟后再试 - - - - Please try again in %1 seconds. - 请%1秒后再试 + 请%1秒后再试 - - - - Account locked permanently. - 账号已被永久锁定 + 账号已被永久锁定 - Verify face recognition or enter password to unlock - 验证人脸识别或输入密码解锁 + 验证人脸识别或输入密码解锁 - Press fingerprint or enter password to unlock - 按压指纹或输入密码解锁 + 按压指纹或输入密码解锁 - Verify voiceprint or enter password to unlock - 验证声纹或输入密码解锁 + 验证声纹或输入密码解锁 - Verify finger vein or enter password to unlock - 验证指静脉或输入密码解锁 + 验证指静脉或输入密码解锁 - Verify iris or enter password to unlock - 验证虹膜或输入密码解锁 + 验证虹膜或输入密码解锁 - + Input Password 输入密码 - Failed to verify %1, please enter password to unlock - 验证%1失败,请输入密码解锁 + 验证%1失败,请输入密码解锁 - - Unable to verify %1, please enter password to unlock - 无法验证%1,请输入密码解锁 + 无法验证%1,请输入密码解锁 - Abnormal network - 网络异常 + 网络异常 + + + Face recognition waiting time out, please click refresh or enter the password to unlock. + 人脸识别等待超时,请点击刷新或输入密码解锁 Use the bound wechat scanning code or enter the password to log in 使用绑定的微信扫码或输入密码登录 - - + + Password cannot be empty 密码不能为空 @@ -143,10 +124,8 @@ 无法验证%1,请输入密码. - - Failed to verify %1, you still have %2 verification opportunities - 验证%1失败,您还有%2次尝试机会 + 验证%1失败,您还有%2次尝试机会 Biometric/code scan authentication failed too many times, please enter the password. @@ -173,31 +152,29 @@ 请输入密码或者录入指纹 - + Authentication failure, Please try again 认证失败,请重试 - Use the bound wechat scanning code or enter the password to unlock - 使用绑定的微信扫码或输入密码解锁 + 使用绑定的微信扫码或输入密码解锁 - Enter the ukey password - 输入安全密钥密码 + 输入安全密钥密码 - Insert the ukey into the USB port - 请将安全密钥插入USB端口 + 请将安全密钥插入USB端口 + Password - 密码 + 密码 - + Login 登录 @@ -222,29 +199,6 @@ 指纹验证失败,您还有%1次尝试机会 - - BatteryWidget - - - BatteryMode - 电池模式 - - - - PowerMode - 电源模式 - - - - Charging... - 正在充电... - - - - fully charged - 已充满电 - - BioDevices @@ -286,47 +240,37 @@ BiometricAuthWidget - Current device: - 当前设备: + 当前设备: - Identify failed, Please retry. - 识别失败,请重试 + 识别失败,请重试 BiometricDevicesWidget - Please select the biometric device - 请选择生物设备 + 请选择生物设备 - Device type: - 设备类型: + 设备类型: - Device name: - 设备型号: + 设备型号: - OK - 确定 + 确定 CharsMoreWidget - Return - 返回 - - - + &&?! @@ -334,127 +278,98 @@ CharsWidget - + More 更多 - + ABC - + 123 - - Return - 返回 - - - Number - 数字 - ConfForm - edit network - 网络属性 + 网络属性 - LAN name: - 网络名称: + 网络名称: - Method: - 编辑IP设置: + 编辑IP设置: - Address: - IP地址: + IP地址: - Netmask: - 子网掩码: + 子网掩码: - Gateway: - 默认网关: + 默认网关: - DNS 1: - 首选DNS: + 首选DNS: - DNS 2: - 备选DNS: + 备选DNS: - Edit Conn - 网络设置 + 网络设置 - - Auto(DHCP) - 自动(DHCP) + 自动(DHCP) - - Manual - 手动 + 手动 - Cancel - 返回 + 返回 - Save - 确定 + 确定 - Ok - 确定 + 确定 - Can not create new wired network for without wired card - 缺少有线网卡 无法新建网络 + 缺少有线网卡 无法新建网络 - New network already created - 已创建新的有线网络 + 已创建新的有线网络 - New network settings already finished - 新的网络配置已经完成 + 新的网络配置已经完成 - Edit Network - 网络属性 + 网络属性 - Add Wired Network - 新建有线网络 + 新建有线网络 create wired network successfully @@ -465,9 +380,8 @@ 新的设置已经生效 - New settings already effective - 新的设置已经生效 + 新的设置已经生效 There is a same named LAN exsits. @@ -477,48 +391,39 @@ DeviceType - FingerPrint - 指纹 + 指纹 - FingerVein - 指静脉 + 指静脉 - Iris - 虹膜 + 虹膜 - Face - 人脸识别 + 人脸识别 - VoicePrint - 声纹 + 声纹 - Ukey - + 安全密钥 - QRCode - 二维码 + 二维码 DigitalAuthDialog - - LoginByUEdu - 请输入锁屏密码 + 请输入锁屏密码 now is authing, wait a moment @@ -529,83 +434,67 @@ 密码错误,请重试 - ResetPWD? - 忘记密码? + 忘记密码? - - SetNewUEduPWD - 设置新锁屏密码 + 设置新锁屏密码 - ConfirmNewUEduPWD - 确认新锁屏密码 + 确认新锁屏密码 - The two password entries are inconsistent, please reset - 两次密码输入不一致,请重设 + 两次密码输入不一致,请重设 - Password entered incorrectly, please try again - 密码输入错误,请重试 + 密码输入错误,请重试 - clear - 清空 + 清空 DlgConnHidWifi - Add Hidden Wi-Fi - 加入无线网络 + 加入无线网络 - Connection - 连接设置: + 连接设置: - Wi-Fi name - 网络名称: + 网络名称: - Wi-Fi security - Wi-Fi 安全性: + Wi-Fi 安全性: - Cancel - 返回 + 返回 - Connect - 确定 + 确定 - C_reate… - 新建... + 新建... - None - + - WPA & WPA2 Personal - WPA 及 WPA2 个人 + WPA 及 WPA2 个人 WEP 40/128-bit Key (Hex or ASCII) @@ -624,1009 +513,807 @@ WPA 及 WPA2 企业 - Connect to Hidden Wi-Fi Network - 连接到隐藏 Wi-Fi 网络 + 连接到隐藏 Wi-Fi 网络 DlgConnHidWifiLeap - Connect to Hidden Wi-Fi Network - 连接到隐藏 Wi-Fi 网络 + 连接到隐藏 Wi-Fi 网络 - Add hidden Wi-Fi - 加入无线网络 + 加入无线网络 - Connection - 连接设置: + 连接设置: - Network name - 网络名称: + 网络名称: - Wi-Fi security - Wi-Fi 安全性: + Wi-Fi 安全性: - Username - 用户名: + 用户名: - Password - 密码: + 密码: - Cancel - 返回 + 返回 - Connect - 连接 + 连接 - C_reate… - 新建... + 新建... - None - + - WPA & WPA2 Personal - WPA 及 WPA2 个人 + WPA 及 WPA2 个人 - WEP 40/128-bit Key (Hex or ASCII) - WEP 40/128 位密钥(十六进制或ASCII) + WEP 40/128 位密钥(十六进制或ASCII) - WEP 128-bit Passphrase - WEP 128 位密码句 + WEP 128 位密码句 - Dynamic WEP (802.1X) - 动态 WEP (802.1x) + 动态 WEP (802.1x) - WPA & WPA2 Enterprise - WPA 及 WPA2 企业 + WPA 及 WPA2 企业 DlgConnHidWifiSecFast - Connect to Hidden Wi-Fi Network - 连接到隐藏 Wi-Fi 网络 + 连接到隐藏 Wi-Fi 网络 - Add hidden Wi-Fi - 加入无线网络 + 加入无线网络 - Connection - 连接设置: + 连接设置: - Network name - 网络名称: + 网络名称: - Wi-Fi security - Wi-Fi 安全性: + Wi-Fi 安全性: - Authentication - 认证: + 认证: - Anonymous identity - 匿名身份: + 匿名身份: - Allow automatic PAC pro_visioning - 自动PAC配置: + 自动PAC配置: - PAC file - PAC文件: + PAC文件: - Inner authentication - 内部认证: + 内部认证: - Username - 用户名: + 用户名: - Password - 密码: + 密码: - Cancel - 返回 + 返回 - Connect - 连接 + 连接 - C_reate… - 新建... + 新建... - - None - + - WPA & WPA2 Personal - WPA 及 WPA2 个人 + WPA 及 WPA2 个人 - WEP 40/128-bit Key (Hex or ASCII) - WEP 40/128 位密钥(十六进制或ASCII) + WEP 40/128 位密钥(十六进制或ASCII) - WEP 128-bit Passphrase - WEP 128 位密码句 + WEP 128 位密码句 - Dynamic WEP (802.1X) - 动态 WEP (802.1x) + 动态 WEP (802.1x) - WPA & WPA2 Enterprise - WPA 及 WPA2 企业 + WPA 及 WPA2 企业 - Tunneled TLS - 隧道 TLS + 隧道 TLS - Protected EAP (PEAP) - 受保护的 EAP + 受保护的 EAP - Anonymous - 匿名 + 匿名 - Authenticated - 已认证 + 已认证 - Both - 两者兼用 + 两者兼用 DlgConnHidWifiSecLeap - Connect to Hidden Wi-Fi Network - 连接到隐藏 Wi-Fi 网络 + 连接到隐藏 Wi-Fi 网络 - Add hidden Wi-Fi - 加入无线网络 + 加入无线网络 - Connection - 连接设置: + 连接设置: - Network name - 网络名称: + 网络名称: - Wi-Fi security - Wi-Fi 安全性: + Wi-Fi 安全性: - Authentication - 认证: + 认证: - Username - 用户名: + 用户名: - Password - 密码: + 密码: - Cancel - 返回 + 返回 - Connect - 连接 + 连接 - C_reate… - 新建... + 新建... - None - + - WPA & WPA2 Personal - WPA 及 WPA2 个人 + WPA 及 WPA2 个人 - WEP 40/128-bit Key (Hex or ASCII) - WEP 40/128 位密钥(十六进制或ASCII) + WEP 40/128 位密钥(十六进制或ASCII) - WEP 128-bit Passphrase - WEP 128 位密码句 + WEP 128 位密码句 - Dynamic WEP (802.1X) - 动态 WEP (802.1x) + 动态 WEP (802.1x) - WPA & WPA2 Enterprise - WPA 及 WPA2 企业 + WPA 及 WPA2 企业 - Tunneled TLS - 隧道 TLS + 隧道 TLS - Protected EAP (PEAP) - 受保护的 EAP + 受保护的 EAP DlgConnHidWifiSecPeap - Connect to Hidden Wi-Fi Network - 连接到隐藏 Wi-Fi 网络 + 连接到隐藏 Wi-Fi 网络 - Add hidden Wi-Fi - 加入无线网络 + 加入无线网络 - Connection - 连接设置: + 连接设置: - Network name - 网络名称: + 网络名称: - Wi-Fi security - Wi-Fi 安全性: + Wi-Fi 安全性: - Authentication - 认证: + 认证: - Anonymous identity - 匿名身份: + 匿名身份: - Domain - 域名: + 域名: - CA certificate - CA 证书: + CA 证书: - CA certificate password - CA 证书密码: + CA 证书密码: - No CA certificate is required - 不需要CA证书 + 不需要CA证书 - PEAP version - PEAP版本: + PEAP版本: - Inner authentication - 内部认证: + 内部认证: - Username - 用户名: + 用户名: - Password - 密码: + 密码: - Cancel - 返回 + 返回 - Connect - 连接 + 连接 - - None - + - WPA & WPA2 Personal - WPA 及 WPA2 个人 + WPA 及 WPA2 个人 - WEP 40/128-bit Key (Hex or ASCII) - WEP 40/128 位密钥(十六进制或ASCII) + WEP 40/128 位密钥(十六进制或ASCII) - WEP 128-bit Passphrase - WEP 128 位密码句 + WEP 128 位密码句 - Dynamic WEP (802.1X) - 动态 WEP (802.1x) + 动态 WEP (802.1x) - WPA & WPA2 Enterprise - WPA 及 WPA2 企业 + WPA 及 WPA2 企业 - Tunneled TLS - 隧道 TLS + 隧道 TLS - Protected EAP (PEAP) - 受保护的 EAP + 受保护的 EAP - Choose from file - 从文件选择... + 从文件选择... - Automatic - 自动 + 自动 - Version 0 - 版本 0 + 版本 0 - Version 1 - 版本 1 + 版本 1 DlgConnHidWifiSecPwd - Connect to Hidden Wi-Fi Network - 连接到隐藏 Wi-Fi 网络 + 连接到隐藏 Wi-Fi 网络 - Add hidden Wi-Fi - 加入无线网络 + 加入无线网络 - Connection - 连接设置: + 连接设置: - Network name - 网络名称: + 网络名称: - Wi-Fi security - Wi-Fi 安全性: + Wi-Fi 安全性: - Authentication - 认证: + 认证: - Username - 用户名: + 用户名: - Password - 密码: + 密码: - Cancel - 返回 + 返回 - Connect - 连接 + 连接 - C_reate… - 新建... + 新建... - None - + - WPA & WPA2 Personal - WPA 及 WPA2 个人 + WPA 及 WPA2 个人 - WEP 40/128-bit Key (Hex or ASCII) - WEP 40/128 位密钥(十六进制或ASCII) + WEP 40/128 位密钥(十六进制或ASCII) - WEP 128-bit Passphrase - WEP 128 位密码句 + WEP 128 位密码句 - Dynamic WEP (802.1X) - 动态 WEP (802.1x) + 动态 WEP (802.1x) - WPA & WPA2 Enterprise - WPA 及 WPA2 企业 + WPA 及 WPA2 企业 - Tunneled TLS - 隧道 TLS + 隧道 TLS - Protected EAP (PEAP) - 受保护的 EAP + 受保护的 EAP DlgConnHidWifiSecTls - Connect to Hidden Wi-Fi Network - 连接到隐藏 Wi-Fi 网络 + 连接到隐藏 Wi-Fi 网络 - Add hidden Wi-Fi - 加入无线网络 + 加入无线网络 - Connection - 连接设置: + 连接设置: - Network name - 网络名称: + 网络名称: - Wi-Fi security - Wi-Fi 安全性: + Wi-Fi 安全性: - Authentication - 认证: + 认证: - Identity - 身份: + 身份: - Domain - 域名: + 域名: - CA certificate - CA 证书: + CA 证书: - CA certificate password - CA 证书密码: + CA 证书密码: - No CA certificate is required - 不需要CA证书 + 不需要CA证书 - User certificate - 用户证书: + 用户证书: - User certificate password - 用户证书密码: + 用户证书密码: - User private key - 用户私钥: + 用户私钥: - User key password - 用户密钥密码: + 用户密钥密码: - Cancel - 返回 + 返回 - Connect - 连接 + 连接 - C_reate… - 新建... + 新建... - - - - None - + - WPA & WPA2 Personal - WPA 及 WPA2 个人 + WPA 及 WPA2 个人 - WEP 40/128-bit Key (Hex or ASCII) - WEP 40/128 位密钥(十六进制或ASCII) + WEP 40/128 位密钥(十六进制或ASCII) - WEP 128-bit Passphrase - WEP 128 位密码句 + WEP 128 位密码句 - Dynamic WEP (802.1X) - 动态 WEP (802.1x) + 动态 WEP (802.1x) - WPA & WPA2 Enterprise - WPA 及 WPA2 企业 + WPA 及 WPA2 企业 - Tunneled TLS - 隧道 TLS + 隧道 TLS - Protected EAP (PEAP) - 受保护的 EAP + 受保护的 EAP - - - Choose from file - 从文件选择... + 从文件选择... DlgConnHidWifiSecTunnelTLS - Connect to Hidden Wi-Fi Network - 连接到隐藏 Wi-Fi 网络 + 连接到隐藏 Wi-Fi 网络 - Add hidden Wi-Fi - 加入无线网络 + 加入无线网络 - Connection - 连接设置: + 连接设置: - Network name - 网络名称: + 网络名称: - Wi-Fi security - Wi-Fi 安全性: + Wi-Fi 安全性: - Authentication - 认证: + 认证: - Anonymous identity - 匿名身份: + 匿名身份: - Domain - 域名: + 域名: - CA certificate - CA 证书: + CA 证书: - CA certificate password - CA 证书密码: + CA 证书密码: - No CA certificate is required - 不需要CA证书 + 不需要CA证书 - Inner authentication - 内部认证: + 内部认证: - Username - 用户名: + 用户名: - Password - 密码: + 密码: - Cancel - 返回 + 返回 - Connect - 连接 + 连接 - C_reate… - 新建... + 新建... - - None - + - WPA & WPA2 Personal - WPA 及 WPA2 个人 + WPA 及 WPA2 个人 - WEP 40/128-bit Key (Hex or ASCII) - WEP 40/128 位密钥(十六进制或ASCII) + WEP 40/128 位密钥(十六进制或ASCII) - WEP 128-bit Passphrase - WEP 128 位密码句 + WEP 128 位密码句 - Dynamic WEP (802.1X) - 动态 WEP (802.1x) + 动态 WEP (802.1x) - WPA & WPA2 Enterprise - WPA 及 WPA2 企业 + WPA 及 WPA2 企业 - Tunneled TLS - 隧道 TLS + 隧道 TLS - Protected EAP (PEAP) - 受保护的 EAP + 受保护的 EAP - Choose from file - 从文件选择... + 从文件选择... DlgConnHidWifiWep - Connect to Hidden Wi-Fi Network - 连接到隐藏 Wi-Fi 网络 + 连接到隐藏 Wi-Fi 网络 - Add hidden Wi-Fi - 加入无线网络 + 加入无线网络 - Connection - 连接设置: + 连接设置: - Network name - 网络名称: + 网络名称: - Wi-Fi security - Wi-Fi 安全性: + Wi-Fi 安全性: - Key - 密钥 + 密钥 - WEP index - WEP 检索 + WEP 检索 - Authentication - 认证: + 认证: - Cancel - 返回 + 返回 - Connect - 连接 + 连接 - C_reate… - 新建... + 新建... - None - + - WPA & WPA2 Personal - WPA 及 WPA2 个人 + WPA 及 WPA2 个人 - WEP 40/128-bit Key (Hex or ASCII) - WEP 40/128 位密钥(十六进制或ASCII) + WEP 40/128 位密钥(十六进制或ASCII) - WEP 128-bit Passphrase - WEP 128 位密码句 + WEP 128 位密码句 - Dynamic WEP (802.1X) - 动态 WEP (802.1x) + 动态 WEP (802.1x) - WPA & WPA2 Enterprise - WPA 及 WPA2 企业 + WPA 及 WPA2 企业 - 1(default) - 1(默认) + 1(默认) - Open System - 开放式系统 + 开放式系统 - Shared Key - 共享密钥 + 共享密钥 DlgConnHidWifiWpa - Connect to Hidden Wi-Fi Network - 连接到隐藏 Wi-Fi 网络 + 连接到隐藏 Wi-Fi 网络 - Add Hidden Wi-Fi - 加入无线网络 + 加入无线网络 - Connection - 连接设置: + 连接设置: - Wi-Fi name - 网络名称: + 网络名称: - Wi-Fi security - Wi-Fi 安全性: + Wi-Fi 安全性: - Password - 密码: + 密码: - Cancel - 返回 + 返回 - Connect - 连接 + 连接 - C_reate… - 新建... + 新建... - None - + - WPA & WPA2 Personal - WPA 及 WPA2 个人 + WPA 及 WPA2 个人 WEP 40/128-bit Key (Hex or ASCII) @@ -1648,209 +1335,70 @@ DlgHotspotCreate - - Dialog - - - - Create Hotspot - 创建个人热点 + 创建个人热点 - Network name - 网络名称: + 网络名称: - Wi-Fi security - Wi-Fi 安全性: + Wi-Fi 安全性: - Password - 密码: + 密码: - Cancel - 返回 + 返回 - Ok - 确定 + 确定 - None - + - WPA & WPA2 Personal - WPA 及 WPA2 个人 - - - - EngineDevice - - - yes - - - - - no - - - - - Yes - - - - - No - - - - - %1% available, charged - - - - - Left %1h %2m (%3%) - - - - - %1% available - - - - - Left %1h %2m to full - - - - - charging (%1%) - - - - - %1 waiting to discharge (%2%) - - - - - %1 waiting to charge (%2%) - - - - - AC adapter - - - - - Laptop battery - - - - - UPS - - - - - Monitor - - - - - Mouse - - - - - Keyboard - - - - - PDA - - - - - Cell phone - - - - - Media player - - - - - Tablet - - - - - Computer - - - - - unrecognised - + WPA 及 WPA2 个人 IconEdit - OK - 提交 + 提交 InputInfos - Service exception... - 服务异常,重试中... + 服务异常,重试中... - Invaild parameters... - 参数异常,重试中... + 参数异常,重试中... - Unknown fault:%1 - 未知错误:%1 + 未知错误:%1 - Recapture(60s) - 重新获取(60s) + 重新获取(60s) - Recapture(%1s) - 重新获取(%1s) + 重新获取(%1s) - - Get code - 获取验证码 + 获取验证码 @@ -1863,15 +1411,12 @@ KylinNM - kylin-nm - 网络工具 + 网络工具 - - LAN - 有线网络 + 有线网络 Enabel LAN List @@ -1894,10 +1439,8 @@ 网络 - - Advanced - 设置网络 + 设置网络 Ethernet @@ -1920,85 +1463,56 @@ 已关闭 - HotSpot - 个人热点 + 个人热点 - FlyMode - 飞行模式 + 飞行模式 Show MainWindow 显示网络连接界面 - Inactivated LAN - 未激活 + 未激活 Inactivated WLAN 未激活 - Other WLAN - 其他 + 其他 - - WLAN - 无线局域网 + 无线局域网 - - Show KylinNM - - - - No wireless card detected - 未检测到无线网卡 + 未检测到无线网卡 - Activated LAN - 已激活 + 已激活 - Activated WLAN - 已激活 + 已激活 - - - - - Not connected - 未连接任何网络 + 未连接任何网络 - - - - - - - - - Disconnected - 未连接 + 未连接 - No Other Wired Network Scheme - 列表中无其他有线网络 + 列表中无其他有线网络 Edit @@ -2013,23 +1527,20 @@ 未连接任何网络 - No Other Wireless Network Scheme - 未检测到其他无线网络 + 未检测到其他无线网络 - Wired net is disconnected - 断开有线网络 + 断开有线网络 Wi-Fi is disconnected 断开无线网络 - Confirm your Wi-Fi password or usable of wireless card - 请确认Wi-Fi密码或无线设备 + 请确认Wi-Fi密码或无线设备 Ethernet Networks @@ -2044,15 +1555,12 @@ 加入网络 - No usable network in the list - 列表暂无可连接网络 + 列表暂无可连接网络 - - NetOn, - 已连接, + 已连接, Wifi Networks @@ -2083,149 +1591,140 @@ 正在更新 Wi-Fi列表 - Conn Ethernet Success - 连接有线网络成功 + 连接有线网络成功 - Conn Ethernet Fail - 连接有线网络失败 + 连接有线网络失败 - Conn Wifi Success - 连接无线网络成功 + 连接无线网络成功 LettersWidget - Symbol - 符号 - - - Num - 数字 - - - + &&?! - + 123 + + LightDMHelper + + + failed to start session. + + + + + Login + 登录 + + + + Guest + 游客 + + LockWidget - - Form - - - - Date - 日期 + 日期 - Time - 时间 + 时间 Guest 游客 - - PowerInfo - 电源信息 - - - - Power - 电源 - - - - VirtualKeyboard - 虚拟键盘 - - - SwitchUser - 切换用户 + 切换用户 + + + Power + 电源 + + + VirtualKeyboard + 虚拟键盘 - Multiple users are logged in at the same time.Are you sure you want to reboot this system? - 同时有多个用户登录系统,您确定要退出系统吗? + 同时有多个用户登录系统,您确定要退出系统吗? - LAN - 有线网络 + 有线网络 - WLAN - 无线局域网 + 无线局域网 LoginOptionsWidget - Login Options - 登录选项 + 登录选项 - Password - 密码 + 密码 - Other - + 其他 Wechat 微信 - Identify device removed! - 校验设备已移除! + 校验设备已移除! MyLineEdit - - - Verification code - 短信验证码 + 短信验证码 + + + + MyNetworkWidget + + + LAN + 有线网络 + + + + WLAN + 无线局域网 NumbersWidget - Symbol - 符号 - - - + &&?! - + Return 返回 @@ -2233,14 +1732,12 @@ OneConnForm - Form - -- + -- - Automatically join the network - 自动加入该网络 + 自动加入该网络 Input password @@ -2251,32 +1748,24 @@ 设置 - - - - Connect - 连接 + 连接 - Disconnect - 断开连接 + 断开连接 - Input Password... - 输入密码... + 输入密码... - Connect to Hidden Wi-Fi Network - 连接到隐藏 Wi-Fi 网络 + 连接到隐藏 Wi-Fi 网络 - Signal: - 信号强度: + 信号强度: Public @@ -2291,73 +1780,59 @@ 速率 - None - + - WiFi Security: - WiFi安全性: + WiFi安全性: - MAC: - 物理地址: + 物理地址: - Conn Wifi Failed - 连接无线网络失败 + 连接无线网络失败 OneLancForm - Form - -- + -- Config 设置 - - Connect - 连接 + 连接 - Disconnect - 断开连接 + 断开连接 - - No Configuration - 未配置 + 未配置 - IPv4: - IPv4地址: + IPv4地址: - IPv6: - IPv6地址: + IPv6地址: - BandWidth: - 带宽: + 带宽: - MAC: - 物理地址: + 物理地址: Auto @@ -2367,65 +1842,86 @@ PhoneAuthWidget - - Verification by phoneNum - 手机号验证 + 手机号验证 - - 「 Use bound Phone number to verification 」 + 「 Use SMS to verification 」 + 「 请使用绑定该账户手机号验证 」 + + + commit + 提交 + + + Network not connected~ + 系统未联网,请检查网络连接~ + + + Network unavailable~ + 网络状态差,请检查网络连接~ + + + Verification Code invalid! + 验证码失效 + + + Verification Code incorrect.Please retry! + 验证码错误!请填写正确的验证码! + + + Failed time over limit!Retry after 1 hour! + 验证码错误次数超过10次,1小时后再试 + + + verifaction failed! + 手机验证失败 + + + + PowerListWidget + + + Hibernate + 休眠 + + + + Turn off your computer, but the app stays open. When the computer is turned on, it can be restored to the state you left + 关闭电脑,但是应用会一直保持打开状态。当打开电脑时,可以恢复到你离开的状态。 + + + + Suspend + 睡眠 + + + + + The computer stays on, but consumes less power. The app stays open and can quickly wake up and revert to where you left off + 电脑保持开机状态,但耗电较少。应用会一直保持打开状态,可快速唤醒电脑并恢复到你离开的状态。 + + + + Reboot - - 「 Use SMS to verification 」 - 「 请使用绑定该账户手机号验证 」 + + Power Off + 关机 - - - commit - 提交 - - - - - Network not connected~ - 系统未联网,请检查网络连接~ - - - - Network unavailable~ - 网络状态差,请检查网络连接~ - - - - Verification Code invalid! - 验证码失效 - - - - Verification Code incorrect.Please retry! - 验证码错误!请填写正确的验证码! - - - - Failed time over limit!Retry after 1 hour! - 验证码错误次数超过10次,1小时后再试 - - - - verifaction failed! - 手机验证失败 + + Close all apps, and then shut down your computer + 关闭所有应用,然后关闭电脑。 PowerManager - lock - 锁定 + 锁定 SwitchUser @@ -2452,59 +1948,44 @@ 切换用户 - Log Out - 注销 + 注销 - - Restart - 重启 - - - Reboot 重启 - Power Off - 关机 + 关机 - Close all apps, turn off your computer, and then turn your computer back on - 关闭所有应用,关闭电脑,然后重新打开电脑。 + 关闭所有应用,关闭电脑,然后重新打开电脑。 - Close all apps, and then shut down your computer - 关闭所有应用,然后关闭电脑。 + 关闭所有应用,然后关闭电脑。 - Shut Down - 关机 + 关机 - Turn off your computer, but the app stays open. When the computer is turned on, it can be restored to the state you left - 关闭电脑,但是应用会一直保持打开状态。当打开电脑时,可以恢复到你离开的状态。 + 关闭电脑,但是应用会一直保持打开状态。当打开电脑时,可以恢复到你离开的状态。 - Hibernate - 休眠 + 休眠 - The computer stays on, but consumes less power. The app stays open and can quickly wake up and revert to where you left off - 电脑保持开机状态,但耗电较少。应用会一直保持打开状态,可快速唤醒电脑并恢复到你离开的状态。 + 电脑保持开机状态,但耗电较少。应用会一直保持打开状态,可快速唤醒电脑并恢复到你离开的状态。 - Suspend - 睡眠 + 睡眠 Sleep @@ -2514,25 +1995,16 @@ QObject - + The screensaver is active. 屏幕保护程序已激活 - + The screensaver is inactive. 屏幕保护程序未激活 - - S: - - - - tablet device - - - Screensaver @@ -2544,7 +2016,7 @@ 退出 - + Picture does not exist 图片不存在 @@ -2561,12 +2033,11 @@ 您有%1条未读消息 - You have new notification - 您有新的消息 + 您有新的消息 - + View 预览 @@ -2578,7 +2049,7 @@ 您已休息: - + You have rested 您已休息 @@ -2586,48 +2057,36 @@ SureWindow - Form - -- + -- - - TextLabel - - - - Cancel - 取消 + 取消 - Confirm - 确认 + 确认 Multiple users are logged in at the same time.Are you sure you want to reboot this system? 同时有多个用户登录系统,您确定要退出系统吗? - The following program is running to prevent the system from suspend! - 以下程序正在运行,阻止系统进入睡眠! + 以下程序正在运行,阻止系统进入睡眠! - The following program is running to prevent the system from hibernate! - 以下程序正在运行,阻止系统进入休眠! + 以下程序正在运行,阻止系统进入休眠! - The following program is running to prevent the system from shutting down! - 以下程序正在运行,阻止系统关机! + 以下程序正在运行,阻止系统关机! - The following program is running to prevent the system from reboot! - 以下程序正在运行,阻止系统重启! + 以下程序正在运行,阻止系统重启! @@ -2644,14 +2103,12 @@ SwitchButtonGroup - uEduPWD - 密码登录 + 密码登录 - Wechat - 微信登录 + 微信登录 @@ -2665,130 +2122,90 @@ 向上滑动解锁 - New password is the same as old - 新密码与原密码相同 + 新密码与原密码相同 - Reset password error:%1 - 重置密码失败:%1 + 重置密码失败:%1 - Please scan by correct WeChat - 请使用正确的微信扫码 + 请使用正确的微信扫码 - - - - - - Cancel - 取消 + 取消 - - Back - 返回 + 返回 - Skip - 跳过 + 跳过 Utils - kylin network applet desktop message - 麒麟网络工具信息提示 + 麒麟网络工具信息提示 VerificationWidget - Please scan by bound WeChat - 请使用已绑定的微信扫码 + 请使用已绑定的微信扫码 VerticalVerificationWidget - Please scan by bound WeChat - 请使用已绑定的微信扫码 + 请使用已绑定的微信扫码 WeChatAuthDialog - - Login by wechat - 微信登录 + 微信登录 - - Verification by wechat - 微信验证 + 微信验证 - - 「 Use registered WeChat account to login 」 - 「 使用已注册的微信号登录 」 + 「 使用已注册的微信号登录 」 - - 「 Use bound WeChat account to verification 」 - 「 请使用绑定该账号的微信验证 」 + 「 请使用绑定该账号的微信验证 」 - - Network not connected~ - 系统未联网,请检查网络连接~ + 系统未联网,请检查网络连接~ - Scan code successfully - 扫码成功 + 扫码成功 - Timeout!Try again! - 超时!请重新扫码! + 超时!请重新扫码! Login failed 登录失败 - - Widget - - - Widget - - - - - LoadPlugin - - - delay - + how long to show lock @@ -2796,7 +2213,7 @@ has-lock - + if show lock @@ -2804,87 +2221,97 @@ main - + Start command for the ukui ScreenSaver. 启动锁屏到命令 - - - + + + lock the screen immediately 马上锁定屏幕 - + query the status of the screen saver 获取锁屏状态 - + unlock the screen saver 解锁屏幕 - + show the screensaver - + show blank and delay to lock,param:idle/lid/lowpower - + Dialog for the ukui ScreenSaver. - + activated by session idle signal - - + + lock the screen and show screensaver immediately - + show screensaver immediately - + show blank screensaver immediately and delay time to show lock - + show blank screensaver immediately and if lock - + Screensaver for ukui-screensaver - + show on root window - + show on window. - + window id + + + Backend for the ukui ScreenSaver. + + + + + lock the screen by startup + + diff --git a/i18n_ts/zh_HK.ts b/i18n_ts/zh_HK.ts new file mode 100644 index 0000000..9e6936a --- /dev/null +++ b/i18n_ts/zh_HK.ts @@ -0,0 +1,2337 @@ + + + + + AgreementWindow + + + I know + 我知道 + + + + AuthDialog + + More Devices + 选择其他设备 + + + Biometric + 使用生物识别认证 + + + Password + 使用密码认证 + + + + Retry + 重試 + + + UnLock + 解锁 + + + Slide to unlock + 向上滑动解锁 + + + You have %1 unread message + 您有%1条未读消息 + + + LoggedIn + 已登录 + + + Password: + 密码: + + + Account locked %1 minutes due to %2 fail attempts + 账户锁定%1分钟由于%2次错误尝试 + + + Please try again in %1 minutes. + 請在 %1 分鐘後重試。 + + + Please try again in %1 seconds. + 請在 %1 秒後重試。 + + + Account locked permanently. + 帳戶永久鎖定。 + + + Verify face recognition or enter password to unlock + 驗證人臉識別或輸入密碼解鎖 + + + Press fingerprint or enter password to unlock + 按指紋或輸入密碼解鎖 + + + Verify voiceprint or enter password to unlock + 驗證聲紋或輸入密碼以解鎖 + + + Verify finger vein or enter password to unlock + 驗證指靜脈或輸入密碼解鎖 + + + Verify iris or enter password to unlock + 驗證虹膜或輸入密碼解鎖 + + + + Input Password + 輸入密碼 + + + Failed to verify %1, please enter password to unlock + 驗證 %1 失敗,請輸入密碼進行解鎖 + + + Unable to verify %1, please enter password to unlock + 無法驗證 %1,請輸入密碼進行解鎖 + + + Abnormal network + 網路異常 + + + Use the bound wechat scanning code or enter the password to log in + 使用绑定的微信扫码或输入密码登录 + + + + + Password cannot be empty + 密碼不能為空 + + + Failed to verify %1, please enter password. + 验证%1失败,请输入密码. + + + Unable to verify %1, please enter password. + 无法验证%1,请输入密码. + + + Failed to verify %1, you still have %2 verification opportunities + 驗證 %1 失敗,您仍有 %2 次驗證機會 + + + Biometric/code scan authentication failed too many times, please enter the password. + 生物/扫码验证失败达最大次数,请使用密码解锁 + + + Bioauth/code scan authentication failed, you still have %1 verification opportunities + 生物/扫码验证失败,您还有%1次尝试机会 + + + NET Exception + 网络异常 + + + Password Incorrect, Please try again + 密码错误,请重试 + + + Authentication failure,there are still %1 remaining opportunities + 认证失败,还剩%1次尝试机会 + + + Please enter your password or enroll your fingerprint + 请输入密码或者录入指纹 + + + + Authentication failure, Please try again + 身份驗證失敗,請重試 + + + Use the bound wechat scanning code or enter the password to unlock + 使用綁定的微信掃碼或輸入密碼解鎖 + + + Enter the ukey password + 輸入ukey密碼 + + + Insert the ukey into the USB port + 將 Ukey 插入 USB 埠 + + + + Password + 密碼 + + + + Login + 登錄 + + + Biometric Authentication + 生物识别认证 + + + Password Authentication + 密码认证 + + + Other Devices + 其他设备 + + + Too many unsuccessful attempts,please enter password. + 指纹验证失败达最大次数,请使用密码登录 + + + Fingerprint authentication failed, you still have %1 verification opportunities + 指纹验证失败,您还有%1次尝试机会 + + + + BioDevices + + FingerPrint + 指纹 + + + FingerVein + 指静脉 + + + Iris + 虹膜 + + + Face + 人脸 + + + VoicePrint + 声纹 + + + + BioDevicesWidget + + Please select other biometric devices + 请选择其他生物识别设备 + + + Device Type: + 设备类型: + + + Device Name: + 设备名称: + + + + BiometricAuthWidget + + Current device: + 目前裝置: + + + Identify failed, Please retry. + 識別失敗,請重試。 + + + + BiometricDevicesWidget + + Please select the biometric device + 請選擇生物識別設備 + + + Device type: + 裝置類型: + + + Device name: + 裝置名稱: + + + OK + 還行 + + + + CharsMoreWidget + + + &&?! + &&?! + + + + CharsWidget + + + More + 更多 + + + + ABC + 美國廣播公司 + + + + 123 + 123 + + + + ConfForm + + edit network + 編輯網路 + + + LAN name: + 區域網名稱: + + + Method: + 方法: + + + Address: + 位址: + + + Netmask: + 網路遮罩: + + + Gateway: + 閘道: + + + DNS 1: + 網域名稱系統 1: + + + DNS 2: + 網域名稱系統 2: + + + Edit Conn + 編輯康恩 + + + Auto(DHCP) + 自動(DHCP) + + + Manual + 手動 + + + Cancel + 取消 + + + Save + + + + Ok + 還行 + + + Can not create new wired network for without wired card + 沒有有線卡就無法創建新的有線網路 + + + New network already created + 已創建新網路 + + + New network settings already finished + 新的網路設置已完成 + + + Edit Network + 編輯網路 + + + Add Wired Network + 添加有線網路 + + + create wired network successfully + 已创建新的有线网络 + + + change configuration of wired network successfully + 新的设置已经生效 + + + New settings already effective + 新設置已生效 + + + There is a same named LAN exsits. + 已有同名连接存在 + + + + DeviceType + + FingerPrint + 指紋 + + + FingerVein + 指靜脈 + + + Iris + 虹膜 + + + Face + 人臉 + + + VoicePrint + 聲紋 + + + ukey + 安全秘鑰 + + + QRCode + 微信掃碼 + + + + DigitalAuthDialog + + LoginByUEdu + LoginByUEdu + + + now is authing, wait a moment + 认证中,请稍后 + + + Password Incorrect, Please try again + 密码错误,请重试 + + + ResetPWD? + 重置PWD? + + + SetNewUEduPWD + 設置新UEduPWD + + + ConfirmNewUEduPWD + 確認新UEduPWD + + + The two password entries are inconsistent, please reset + 兩個密碼條目不一致,請重置 + + + Password entered incorrectly, please try again + 密碼輸入錯誤,請重試 + + + clear + 清楚 + + + + DlgConnHidWifi + + Add Hidden Wi-Fi + 添加隱藏的無線網路 + + + Connection + 連接 + + + Wi-Fi name + 無線網路名稱 + + + Wi-Fi security + 無線網路安全 + + + Cancel + 取消 + + + Connect + 連接 + + + C_reate… + C_reate...… + + + None + 沒有 + + + WPA & WPA2 Personal + WPA 和 WPA2 個人 + + + WEP 40/128-bit Key (Hex or ASCII) + WEP 40/128 位密钥(十六进制或ASCII) + + + WEP 128-bit Passphrase + WEP 128 位密码句 + + + Dynamic WEP (802.1X) + 动态 WEP (802.1x) + + + WPA & WPA2 Enterprise + WPA 及 WPA2 企业 + + + Connect to Hidden Wi-Fi Network + 連接到隱藏的Wi-Fi網路 + + + + DlgConnHidWifiLeap + + Connect to Hidden Wi-Fi Network + 連接到隱藏的Wi-Fi網路 + + + Add hidden Wi-Fi + 添加隱藏的無線網路 + + + Connection + 連接 + + + Network name + 網路名稱 + + + Wi-Fi security + 無線網路安全 + + + Username + 使用者名 + + + Password + 密碼 + + + Cancel + 取消 + + + Connect + 連接 + + + C_reate… + C_reate...… + + + None + 沒有 + + + WPA & WPA2 Personal + WPA 和 WPA2 個人 + + + WEP 40/128-bit Key (Hex or ASCII) + WEP 40/128 位金鑰(十六進位或 ASCII) + + + WEP 128-bit Passphrase + WEP 128 位密碼短語 + + + Dynamic WEP (802.1X) + 動態 WEP (802.1X) + + + WPA & WPA2 Enterprise + WPA & WPA2 Enterprise + + + + DlgConnHidWifiSecFast + + Connect to Hidden Wi-Fi Network + 連接到隱藏的Wi-Fi網路 + + + Add hidden Wi-Fi + 添加隱藏的無線網路 + + + Connection + 連接 + + + Network name + 網路名稱 + + + Wi-Fi security + 無線網路安全 + + + Authentication + 認證 + + + Anonymous identity + 匿名身份 + + + Allow automatic PAC pro_visioning + 允許自動 PAC pro_visioning + + + PAC file + PAC 檔 + + + Inner authentication + 內部身份驗證 + + + Username + 使用者名 + + + Password + 密碼 + + + Cancel + 取消 + + + Connect + 連接 + + + C_reate… + C_reate...… + + + None + 沒有 + + + WPA & WPA2 Personal + WPA 和 WPA2 個人 + + + WEP 40/128-bit Key (Hex or ASCII) + WEP 40/128 位金鑰(十六進位或 ASCII) + + + WEP 128-bit Passphrase + WEP 128 位密碼短語 + + + Dynamic WEP (802.1X) + 動態 WEP (802.1X) + + + WPA & WPA2 Enterprise + WPA & WPA2 Enterprise + + + Tunneled TLS + 隧道式紅綠燈系統 + + + Protected EAP (PEAP) + 受保護的 EAP (PEAP) + + + Anonymous + 匿名 + + + Authenticated + 認證 + + + Both + + + + + DlgConnHidWifiSecLeap + + Connect to Hidden Wi-Fi Network + 連接到隱藏的Wi-Fi網路 + + + Add hidden Wi-Fi + 添加隱藏的無線網路 + + + Connection + 連接 + + + Network name + 網路名稱 + + + Wi-Fi security + 無線網路安全 + + + Authentication + 認證 + + + Username + 使用者名 + + + Password + 密碼 + + + Cancel + 取消 + + + Connect + 連接 + + + C_reate… + C_reate...… + + + None + 沒有 + + + WPA & WPA2 Personal + WPA 和 WPA2 個人 + + + WEP 40/128-bit Key (Hex or ASCII) + WEP 40/128 位金鑰(十六進位或 ASCII) + + + WEP 128-bit Passphrase + WEP 128 位密碼短語 + + + Dynamic WEP (802.1X) + 動態 WEP (802.1X) + + + WPA & WPA2 Enterprise + WPA & WPA2 Enterprise + + + Tunneled TLS + 隧道式紅綠燈系統 + + + Protected EAP (PEAP) + 受保護的 EAP (PEAP) + + + + DlgConnHidWifiSecPeap + + Connect to Hidden Wi-Fi Network + 連接到隱藏的Wi-Fi網路 + + + Add hidden Wi-Fi + 添加隱藏的無線網路 + + + Connection + 連接 + + + Network name + 網路名稱 + + + Wi-Fi security + 無線網路安全 + + + Authentication + 認證 + + + Anonymous identity + 匿名身份 + + + Domain + + + + CA certificate + CA 證書 + + + CA certificate password + CA 憑證密碼 + + + No CA certificate is required + 不需要 CA 證書 + + + PEAP version + PEAP 版本 + + + Inner authentication + 內部身份驗證 + + + Username + 使用者名 + + + Password + 密碼 + + + Cancel + 取消 + + + Connect + 連接 + + + None + 沒有 + + + WPA & WPA2 Personal + WPA 和 WPA2 個人 + + + WEP 40/128-bit Key (Hex or ASCII) + WEP 40/128 位金鑰(十六進位或 ASCII) + + + WEP 128-bit Passphrase + WEP 128 位密碼短語 + + + Dynamic WEP (802.1X) + 動態 WEP (802.1X) + + + WPA & WPA2 Enterprise + WPA & WPA2 Enterprise + + + Tunneled TLS + 隧道式紅綠燈系統 + + + Protected EAP (PEAP) + 受保護的 EAP (PEAP) + + + Choose from file + 從檔案中選擇 + + + Automatic + 自動 + + + Version 0 + 版本 0 + + + Version 1 + 版本 1 + + + + DlgConnHidWifiSecPwd + + Connect to Hidden Wi-Fi Network + 連接到隱藏的Wi-Fi網路 + + + Add hidden Wi-Fi + 添加隱藏的無線網路 + + + Connection + 連接 + + + Network name + 網路名稱 + + + Wi-Fi security + 無線網路安全 + + + Authentication + 認證 + + + Username + 使用者名 + + + Password + 密碼 + + + Cancel + 取消 + + + Connect + 連接 + + + C_reate… + C_reate...… + + + None + 沒有 + + + WPA & WPA2 Personal + WPA 和 WPA2 個人 + + + WEP 40/128-bit Key (Hex or ASCII) + WEP 40/128 位金鑰(十六進位或 ASCII) + + + WEP 128-bit Passphrase + WEP 128 位密碼短語 + + + Dynamic WEP (802.1X) + 動態 WEP (802.1X) + + + WPA & WPA2 Enterprise + WPA & WPA2 Enterprise + + + Tunneled TLS + 隧道式紅綠燈系統 + + + Protected EAP (PEAP) + 受保護的 EAP (PEAP) + + + + DlgConnHidWifiSecTls + + Connect to Hidden Wi-Fi Network + 連接到隱藏的Wi-Fi網路 + + + Add hidden Wi-Fi + 添加隱藏的無線網路 + + + Connection + 連接 + + + Network name + 網路名稱 + + + Wi-Fi security + 無線網路安全 + + + Authentication + 認證 + + + Identity + 身份 + + + Domain + + + + CA certificate + CA 證書 + + + CA certificate password + CA 憑證密碼 + + + No CA certificate is required + 不需要 CA 證書 + + + User certificate + 用戶證書 + + + User certificate password + 使用者證書密碼 + + + User private key + 使用者私鑰 + + + User key password + 用戶金鑰密碼 + + + Cancel + 取消 + + + Connect + 連接 + + + C_reate… + C_reate...… + + + None + 沒有 + + + WPA & WPA2 Personal + WPA 和 WPA2 個人 + + + WEP 40/128-bit Key (Hex or ASCII) + WEP 40/128 位金鑰(十六進位或 ASCII) + + + WEP 128-bit Passphrase + WEP 128 位密碼短語 + + + Dynamic WEP (802.1X) + 動態 WEP (802.1X) + + + WPA & WPA2 Enterprise + WPA & WPA2 Enterprise + + + Tunneled TLS + 隧道式紅綠燈系統 + + + Protected EAP (PEAP) + 受保護的 EAP (PEAP) + + + Choose from file + 從檔案中選擇 + + + + DlgConnHidWifiSecTunnelTLS + + Connect to Hidden Wi-Fi Network + 連接到隱藏的Wi-Fi網路 + + + Add hidden Wi-Fi + 添加隱藏的無線網路 + + + Connection + 連接 + + + Network name + 網路名稱 + + + Wi-Fi security + 無線網路安全 + + + Authentication + 認證 + + + Anonymous identity + 匿名身份 + + + Domain + + + + CA certificate + CA 證書 + + + CA certificate password + CA 憑證密碼 + + + No CA certificate is required + 不需要 CA 證書 + + + Inner authentication + 內部身份驗證 + + + Username + 使用者名 + + + Password + 密碼 + + + Cancel + 取消 + + + Connect + 連接 + + + C_reate… + C_reate...… + + + None + 沒有 + + + WPA & WPA2 Personal + WPA 和 WPA2 個人 + + + WEP 40/128-bit Key (Hex or ASCII) + WEP 40/128 位金鑰(十六進位或 ASCII) + + + WEP 128-bit Passphrase + WEP 128 位密碼短語 + + + Dynamic WEP (802.1X) + 動態 WEP (802.1X) + + + WPA & WPA2 Enterprise + WPA & WPA2 Enterprise + + + Tunneled TLS + 隧道式紅綠燈系統 + + + Protected EAP (PEAP) + 受保護的 EAP (PEAP) + + + Choose from file + 從檔案中選擇 + + + + DlgConnHidWifiWep + + Connect to Hidden Wi-Fi Network + 連接到隱藏的Wi-Fi網路 + + + Add hidden Wi-Fi + 添加隱藏的無線網路 + + + Connection + 連接 + + + Network name + 網路名稱 + + + Wi-Fi security + 無線網路安全 + + + Key + 鑰匙 + + + WEP index + WEP指數 + + + Authentication + 認證 + + + Cancel + 取消 + + + Connect + 連接 + + + C_reate… + C_reate...… + + + None + 沒有 + + + WPA & WPA2 Personal + WPA 和 WPA2 個人 + + + WEP 40/128-bit Key (Hex or ASCII) + WEP 40/128 位金鑰(十六進位或 ASCII) + + + WEP 128-bit Passphrase + WEP 128 位密碼短語 + + + Dynamic WEP (802.1X) + 動態 WEP (802.1X) + + + WPA & WPA2 Enterprise + WPA & WPA2 Enterprise + + + 1(default) + 1(預設) + + + Open System + 開放系統 + + + Shared Key + 共用金鑰 + + + + DlgConnHidWifiWpa + + Connect to Hidden Wi-Fi Network + 連接到隱藏的Wi-Fi網路 + + + Add Hidden Wi-Fi + 添加隱藏的無線網路 + + + Connection + 連接 + + + Wi-Fi name + 無線網路名稱 + + + Wi-Fi security + 無線網路安全 + + + Password + 密碼 + + + Cancel + 取消 + + + Connect + 連接 + + + C_reate… + C_reate...… + + + None + 沒有 + + + WPA & WPA2 Personal + WPA 和 WPA2 個人 + + + WEP 40/128-bit Key (Hex or ASCII) + WEP 40/128 位密钥(十六进制或ASCII) + + + WEP 128-bit Passphrase + WEP 128 位密码句 + + + Dynamic WEP (802.1X) + 动态 WEP (802.1x) + + + WPA & WPA2 Enterprise + WPA 及 WPA2 企业 + + + + DlgHotspotCreate + + Dialog + 對話 + + + Create Hotspot + 創建熱點 + + + Network name + 網路名稱 + + + Wi-Fi security + 無線網路安全 + + + Password + 密碼 + + + Cancel + 取消 + + + Ok + 還行 + + + None + 沒有 + + + WPA & WPA2 Personal + WPA 和 WPA2 個人 + + + + IconEdit + + OK + 還行 + + + + InputInfos + + Service exception... + 服務異常... + + + Invaild parameters... + 不合法參數... + + + Unknown fault:%1 + 未知故障:%1 + + + Recapture(60s) + 奪回(60年代) + + + Recapture(%1s) + 重新擷取(%1 秒) + + + Get code + 獲取代碼 + + + + KylinDBus + + kylin network applet desktop message + 麒麟网络工具信息提示 + + + + KylinNM + + kylin-nm + 麒麟-納米 + + + LAN + 局域網 + + + Enabel LAN List + 其他有线网络 + + + WiFi + 无线网络 + + + Enabel WiFi List + 其他无线网络 + + + New WiFi + 加入其他网络 + + + Network + 网络 + + + Advanced + 高深 + + + Ethernet + 有线网络 + + + Connect Hide Network + 加入网络 + + + Wifi + 无线网络 + + + Enabled + 已开启 + + + Disabled + 已关闭 + + + HotSpot + 熱點 + + + FlyMode + 飛行模式 + + + Show MainWindow + 显示网络连接界面 + + + Inactivated LAN + 停用的局域網 + + + Inactivated WLAN + 未激活 + + + Other WLAN + 其他無線局域網 + + + WLAN + 無線局域網 + + + Show KylinNM + 顯示麒麟NM + + + No wireless card detected + 未檢測到無線網卡 + + + Activated LAN + 啟動的局域網 + + + Activated WLAN + 啟動的無線局域網 + + + Not connected + 未連接 + + + Disconnected + 斷開 + + + No Other Wired Network Scheme + 沒有其他有線網路方案 + + + Edit + 编辑 + + + Done + 完成 + + + No wifi connected. + 未连接任何网络 + + + No Other Wireless Network Scheme + 無其他無線網路方案 + + + Wired net is disconnected + 有線網路已斷開連接 + + + Wi-Fi is disconnected + 断开无线网络 + + + Confirm your Wi-Fi password or usable of wireless card + 確認您的Wi-Fi密碼或可用的無線網卡 + + + Ethernet Networks + 其他有线网络 + + + New LAN + 新建有线网络 + + + Hide WiFi + 加入网络 + + + No usable network in the list + 清單中沒有可用的網路 + + + NetOn, + 內頓, + + + Wifi Networks + 其他无线网络 + + + None + + + + keep wired network switch is on before turning on wireless switch + 打开无线网开关前保持有线网开关打开 + + + please insert the wireless network adapter + 请先插入无线网卡 + + + Abnormal connection exist, program will delete it + 正在断开异常连接的网络 + + + update Wi-Fi list now, click again + 正在更新 Wi-Fi列表 请再次点击 + + + update Wi-Fi list now + 正在更新 Wi-Fi列表 + + + Conn Ethernet Success + 連接乙太網成功案例 + + + Conn Ethernet Fail + 連接乙太網故障 + + + Conn Wifi Success + 連接無線成功 + + + + LettersWidget + + + &&?! + &&?! + + + + 123 + 123 + + + Ctrl + + + + Alt + 替代項 + + + + LightDMHelper + + + failed to start session. + + + + + Login + 登錄 + + + + Guest + 游客 + + + + LockWidget + + Date + 日期 + + + Time + 時間 + + + Guest + 游客 + + + SwitchUser + 切換使用者 + + + Power + 電源管理 + + + VirtualKeyboard + 虛擬鍵盤 + + + Multiple users are logged in at the same time.Are you sure you want to reboot this system? + 多個用戶同時登錄。是否確實要重新啟動此系統? + + + LAN + 局域網 + + + WLAN + 無線局域網 + + + + LoginOptionsWidget + + Login Options + 登錄選項 + + + Password + 密碼 + + + Other + 其他 + + + Wechat + 微信 + + + Identify device removed! + 識別已刪除的設備! + + + + MyLineEdit + + Verification code + 驗證碼 + + + + MyNetworkWidget + + + LAN + 局域網 + + + + WLAN + 無線局域網 + + + + NumbersWidget + + + &&?! + &&?! + + + + Return + 返回 + + + + OneConnForm + + Form + 形式 + + + Automatically join the network + 自動加入網路 + + + Input password + 输入密码 + + + Config + 设置 + + + Connect + 連接 + + + Disconnect + 斷開 + + + Input Password... + 輸入密碼... + + + Connect to Hidden Wi-Fi Network + 連接到隱藏的Wi-Fi網路 + + + Signal: + 信號: + + + Public + 开放 + + + Safe + 安全 + + + Rate + 速率 + + + None + 沒有 + + + WiFi Security: + 無線安全: + + + MAC: + MAC: + + + Conn Wifi Failed + 連接無線上網失敗 + + + + OneLancForm + + Form + 形式 + + + Config + 设置 + + + Connect + 連接 + + + Disconnect + 斷開 + + + No Configuration + 無配置 + + + IPv4: + IPv4: + + + IPv6: + IPv6: + + + BandWidth: + 頻寬: + + + MAC: + MAC: + + + Auto + 自动 + + + + PhoneAuthWidget + + Verification by phoneNum + 通過電話驗證數位 + + + 「 Use bound Phone number to verification 」 + 「使用綁定的電話號碼進行驗證」 + + + 「 Use SMS to verification 」 + 「 使用簡訊進行驗證 」 + + + commit + + + + Network not connected~ + 網路未連接~ + + + Network unavailable~ + 網路不可用~ + + + Verification Code invalid! + 驗證碼無效! + + + Verification Code incorrect.Please retry! + 驗證碼不正確。請重試! + + + Failed time over limit!Retry after 1 hour! + 失敗時間超過限制!1 小時後重試! + + + verifaction failed! + 驗證失敗! + + + + PowerListWidget + + + Hibernate + 休眠 + + + + Turn off your computer, but the app stays open. When the computer is turned on, it can be restored to the state you left + 關閉電腦,但應用會保持打開狀態。當計算機打開時,它可以恢復到您離開時的狀態 + + + + Suspend + 睡眠 + + + + + The computer stays on, but consumes less power. The app stays open and can quickly wake up and revert to where you left off + 計算機保持打開狀態,但消耗的電量更少。該應用程式保持打開狀態,可以快速喚醒並恢復到上次中斷的位置 + + + + Reboot + + + + + Power Off + 關機 + + + + Close all apps, and then shut down your computer + 關閉所有應用,然後關閉電腦 + + + + PowerManager + + lock + + + + SwitchUser + 切换用户 + + + logout + 注销 + + + reboot + 重启 + + + shutdown + 关机 + + + Lock Screen + 锁屏 + + + Switch User + 切换用户 + + + Log Out + 註銷 + + + Restart + 重新啟動 + + + Power Off + 關機 + + + Close all apps, turn off your computer, and then turn your computer back on + 關閉所有應用,關閉計算機,然後重新打開計算機 + + + Close all apps, and then shut down your computer + 關閉所有應用,然後關閉電腦 + + + Shut Down + 關閉 + + + Turn off your computer, but the app stays open. When the computer is turned on, it can be restored to the state you left + 關閉電腦,但應用會保持打開狀態。當計算機打開時,它可以恢復到您離開時的狀態 + + + Hibernate + 休眠 + + + The computer stays on, but consumes less power. The app stays open and can quickly wake up and revert to where you left off + 計算機保持打開狀態,但消耗的電量更少。該應用程式保持打開狀態,可以快速喚醒並恢復到上次中斷的位置 + + + Suspend + 睡眠 + + + Sleep + 休眠 + + + + QObject + + + The screensaver is active. + 屏幕保護程式處於活動狀態。 + + + + The screensaver is inactive. + 屏幕保護程式處於非活動狀態。 + + + + Screensaver + + exit(Esc) + 退出(Esc) + + + exit + 退出 + + + + Picture does not exist + 圖片不存在 + + + Set as desktop wallpaper + 设置为桌面壁纸 + + + Automatic switching + 自动切换 + + + You have %1 unread message + 您有%1条未读消息 + + + You have new notification + 您有新通知 + + + + View + 視圖 + + + + SleepTime + + You have rested: + 您已休息: + + + + You have rested + 你已經休息了 + + + + SureWindow + + Form + 形式 + + + TextLabel + 文本標籤 + + + Cancel + 取消 + + + Confirm + 確認 + + + Multiple users are logged in at the same time.Are you sure you want to reboot this system? + 同时有多个用户登录系统,您确定要退出系统吗? + + + The following program is running to prevent the system from suspend! + 以下程式正在運行以防止系統掛起! + + + The following program is running to prevent the system from hibernate! + 以下程式正在運行以防止系統休眠! + + + The following program is running to prevent the system from shutting down! + 以下程式正在運行以防止系統關閉! + + + The following program is running to prevent the system from reboot! + 以下程式正在運行以防止系統重新啟動! + + + + SwitchButton + + login by password + 密码登录 + + + login by qr code + 微信登录 + + + + SwitchButtonGroup + + uEduPWD + uEduPWD + + + Wechat + 微信 + + + + TabletLockWidget + + You have %1 unread message + 您有%1条未读消息 + + + Slide to unlock + 向上滑动解锁 + + + New password is the same as old + 新密碼與舊密碼相同 + + + Reset password error:%1 + 重置密碼錯誤:%1 + + + Please scan by correct WeChat + 請通過正確的微信掃描 + + + Cancel + 取消 + + + Back + 返回 + + + Skip + + + + + Utils + + kylin network applet desktop message + 麒麟網路小程式桌面留言 + + + + VerificationWidget + + Please scan by bound WeChat + 請通過綁定微信掃描 + + + + VerticalVerificationWidget + + Please scan by bound WeChat + 請通過綁定微信掃描 + + + + WeChatAuthDialog + + Login by wechat + 微信登錄 + + + Verification by wechat + 微信驗證 + + + 「 Use registered WeChat account to login 」 + 「 使用已註冊的微信公眾號登入 」 + + + 「 Use bound WeChat account to verification 」 + 「 使用綁定的微信帳號進行驗證 」 + + + Network not connected~ + 網路未連接~ + + + Scan code successfully + 掃碼成功 + + + Timeout!Try again! + 超時!再試一次! + + + Login failed + 登录失败 + + + + delay + + + how long to show lock + 顯示鎖定多長時間 + + + + has-lock + + + if show lock + 如果顯示鎖定 + + + + main + + + Start command for the ukui ScreenSaver. + uui 螢幕保護程式的啟動命令。 + + + + + + lock the screen immediately + 立即鎖定螢幕 + + + + query the status of the screen saver + 查詢屏幕保護程序的狀態 + + + + unlock the screen saver + 解鎖螢幕保護程式 + + + + show the screensaver + 顯示螢幕保護程式 + + + + show blank and delay to lock,param:idle/lid/lowpower + 顯示空白和延遲鎖定,參數:空閒/蓋子/低功耗 + + + + Dialog for the ukui ScreenSaver. + ukui 螢幕保護程序的對話框。 + + + + activated by session idle signal + 由會話空閒信號啟動 + + + + + lock the screen and show screensaver immediately + 鎖定螢幕並立即顯示螢幕保護程式 + + + + show screensaver immediately + 立即顯示螢幕保護程式 + + + + show blank screensaver immediately and delay time to show lock + 立即顯示空白螢幕保護程式並延遲顯示鎖定的時間 + + + + show blank screensaver immediately and if lock + 立即顯示空白螢幕保護程式,如果鎖定 + + + + Screensaver for ukui-screensaver + ukui螢幕保護程式的螢幕保護程式 + + + + show on root window + 在根視窗上顯示 + + + + show on window. + 在視窗上顯示。 + + + + window id + 窗口標識 + + + + Backend for the ukui ScreenSaver. + + + + + lock the screen by startup + + + + diff --git a/screensaver-focus-helper/CMakeLists.txt b/screensaver-focus-helper/CMakeLists.txt deleted file mode 100644 index 2a8374d..0000000 --- a/screensaver-focus-helper/CMakeLists.txt +++ /dev/null @@ -1,27 +0,0 @@ -project(screensaver-capslock-helper) - -pkg_check_modules(X11 REQUIRED x11) -pkg_check_modules(XCB REQUIRED xcb) - -include_directories( - ${X11_INCLUDE_DIRS} - ${XCB_INCLUDE_DIRS} - ) - -set(CMAKE_AUTOMOC ON) - -qt5_wrap_cpp(bin_SRCS - blackwindow.h - ) -set(bin_SRCS - ${bin_SRCS} - main.cpp - blackwindow.cpp - ) - -add_executable(screensaver-focus-helper ${bin_SRCS}) -target_link_libraries(screensaver-focus-helper Qt5::Core Qt5::Widgets Qt5::X11Extras ${X11_LIBRARIES} ${XCB_LIBRARIES}) - -install(TARGETS - screensaver-focus-helper - DESTINATION lib/ukui-screensaver) diff --git a/screensaver-focus-helper/blackwindow.h b/screensaver-focus-helper/blackwindow.h deleted file mode 100644 index 6d1f071..0000000 --- a/screensaver-focus-helper/blackwindow.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2021 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#ifndef BLACKWINDOW_H -#define BLACKWINDOW_H - -#include -#include - -class BlackWindow : public QWidget, public QAbstractNativeEventFilter -{ - Q_OBJECT -public: - explicit BlackWindow(QWidget *parent = nullptr); - - virtual bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) override; - bool eventFilter(QObject *obj, QEvent *event); -signals: - -private Q_SLOTS: - void laterActivate(); - -protected: - void paintEvent(QPaintEvent *event); - bool screensaverIsShow = false; -}; - -#endif // BLACKWINDOW_H diff --git a/screensaver-focus-helper/main.cpp b/screensaver-focus-helper/main.cpp deleted file mode 100644 index 70b9982..0000000 --- a/screensaver-focus-helper/main.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2021 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "blackwindow.h" -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - BlackWindow w; - w.setGeometry(QApplication::desktop()->geometry()); - //w.activateWindow(); - w.show(); - a.exec(); - return 0; -} diff --git a/screensaver/customplugin.cpp b/screensaver/customplugin.cpp deleted file mode 100644 index 7f31d23..0000000 --- a/screensaver/customplugin.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#include "customplugin.h" -#include "screensaver.h" -#include -#include -#include - -#define WORKING_DIRECTORY "/usr/share/ukui-screensaver" - -CustomPlugin::CustomPlugin(QObject *parent):QObject(parent) -{ - -} - -QString CustomPlugin::name() const -{ - return "screensaver-default"; -} - -QWidget* CustomPlugin::createWidget(bool isScreensaver,QWidget* parent) -{ - //加载翻译文件 - QString locale = QLocale::system().name(); - QTranslator translator; - QString qmFile = QString(WORKING_DIRECTORY"/i18n_qm/%1.qm").arg(locale); - translator.load(qmFile); - qApp->installTranslator(&translator); - qDebug() << "load translation file " << qmFile; - return new Screensaver(isScreensaver,parent); -} - -QString CustomPlugin::displayName() const -{ - return "screensaver-default"; -} diff --git a/screensaver/customplugin.h b/screensaver/customplugin.h deleted file mode 100644 index 49f3b07..0000000 --- a/screensaver/customplugin.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2022 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#ifndef CUSTOMPLUGIN_H -#define CUSTOMPLUGIN_H - -#include "screensaverplugin.h" -#include - -class CustomPlugin : public QObject, ScreensaverPlugin -{ - Q_OBJECT - //声明QT识别的唯一标识符 - Q_PLUGIN_METADATA(IID "org.ukui.screensaver.screensaver-default1.0.0") - //声明实现的插件接口 - Q_INTERFACES(ScreensaverPlugin) -public: - CustomPlugin(QObject* parent = 0); - QString name() const override; - QWidget* createWidget(bool isScreensaver,QWidget* parent) override; - QString displayName() const override; -}; - -#endif // CUSTOMPLUGIN_H diff --git a/screensaver/language/screensaver-zh_CN.ini b/screensaver/language/screensaver-zh_CN.ini deleted file mode 100644 index 51b93e7..0000000 --- a/screensaver/language/screensaver-zh_CN.ini +++ /dev/null @@ -1,121 +0,0 @@ -[1] -FL=世上的事,只要肯用心去学, -SL=没有一件是太晚的。 -author=三毛《送你一匹马》 -[2] -OL=如果你是大河,何必在乎别人把你当成小溪。 -author=汪国真 《如果》 -[3] -OL=世界上有不绝的风景,我有不老的心情。 -author=汪国真《我喜欢出发》 -[4] -OL=人生如逆旅,我亦是行人。 -author=苏轼《临江仙·送钱穆父》 -[5] -OL=行乐直须年少,尊前看取衰翁。 -author=欧阳修《朝中措·送刘仲原甫出守维扬》 -[6] -OL=行到水穷处,坐看云起时。 -author=王维《终南别业》 -[7] -OL=仰天大笑出门去,我辈岂是蓬蒿人。 -author=李白《南陵别儿童入京》 -[8] -OL=天生我材必有用,千金散尽还复来。 -author=李白《将进酒》 -[9] -OL=希君生羽翼,一化北溟鱼。 -author=李白《江夏使君叔席上赠史郎中》 -[10] -OL=惟沉默是最高的轻蔑。 -author=鲁迅《且介亭杂文附集》 -[11] -OL=虽偶有轻风细雨,但总归晴天朗照。 -author=史铁生《记忆与印象》 -[12] -OL=不能走远路却有辽阔的心。 -author=史铁生《我与地坛》 -[13] -OL=从卖气球的人那里,每个孩子牵走一个心愿。 -author=北岛《代课》 -[14] -OL=要有最朴素的生活和最遥远的梦想 -author=海子《枫》 -[15] -OL=雾打湿了我的双翼,可风却不容我再迟疑。 -author=舒婷《双桅船》 -[16] -OL=拯救地球好累,虽然有些疲惫但我还是会。 -author=《超人不会飞》 -[17] -OL=宁可一思进,莫在一思停。 -author=电影《一代宗师》 -[18] -OL=让人类永远保持理智,确实是一件奢侈的事。 -author=电影《流浪地球》 -[19] -FL=无论结果如何,人类的勇气和坚毅, -SL=都被镌刻在星空下。 -author=电影《流浪地球》 -[20] -OL=生活就像一盒巧克力,你不知道你的下一块口味是什么。 -author=电影《阿甘正传》 -[21] -FL=也许我们这些聪明人,脑袋里能装的目标太多, -SL=所以忘了执着。 -author=电影《阿甘正传》 -[22] -FL=我并不是每次吃完饭就看电视,有时我边吃边看电视, -SL=生活中有些改变会增加乐趣。 -author=电影《加菲猫》 -[23] -OL=做人如果没梦想,那跟咸鱼有什么分别? -author=电影《少林足球》 -[24] -FL=世界上有一种鸟是关不住的,因为它们的每一片羽毛都沾满了太阳的光辉。 -SL=当它们飞走的时候,你会觉得把它关起来是一种罪恶。 -author=电影《肖申克的救赎》 -[25] -FL=你每天都在做很多看起来毫无意义的决定, -SL=但某天你的某个决定就能改变你一生。 -author=电影《西雅图未眠夜》 -[26] -FL=把人类看做虫子的三体人似乎忘记了一个事实: -SL=虫子从来没有被战胜过。 -author=刘慈欣《三体》 -[27] -FL=在宇宙中,你再快都有比你更快的, -SL=你再慢也有比你更慢的。 -author=刘慈欣《三体》 -[28] -OL=人间风雨各处有,何处不是浪浪山? -author=国漫《小妖怪的夏天》 -[29] -FL=我看到那些岁月如何奔驰, -SL=挨过了冬季,便迎来了春天。 -author=《瓦尔登湖》 -[30] -OL=保持热爱,奔赴山海。 -author=佚名 -[31] -OL=别慌,月亮也正在大海某处迷茫。 -author=佚名 -[32] -OL=当太阳升到最高点的时候,影子就不见了。 -author=佚名 -[33] -OL=大直若屈,大巧若拙,大辩若讷。 -author=《老子》 -[34] -OL=博学之,审问之,慎思之,明辨之,笃行之。 -author=《礼记》 -[35] -OL=你要批评指点四周的风景,你首先要爬上屋顶。 -author=歌德 -[36] -OL=只有流过血的手指,才能弹出世间的绝唱。 -author=泰戈尔 -[37] -OL=他强任他强,清风拂山岗。 -author=佚名 - diff --git a/screensaver/scconfiguration.cpp b/screensaver/scconfiguration.cpp deleted file mode 100644 index e81c73b..0000000 --- a/screensaver/scconfiguration.cpp +++ /dev/null @@ -1,371 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#include "scconfiguration.h" -#include "commonfunc.h" -#include -#include -#include -#include -#include -#include -#include -#include "glibinterface.h" - -#define GSETTINGS_SCHEMA_SCREENSAVER "org.ukui.screensaver" -#define GSETTINGS_SCHEMA_MATE_BACKGROUND "org.mate.background" -#define GSETTINGS_SCHEMA_SCREENSAVER_DEFAULT "org.ukui.screensaver-default" -#define TIME_TYPE_SCHEMA "org.ukui.control-center.panel.plugins" -#define GSETTINGS_SCHEMA_STYLE "org.ukui.style" - -SCConfiguration* SCConfiguration::instance_ = nullptr; - -SCConfiguration::SCConfiguration(QObject *parent) : - QObject(parent), - mgsettings(nullptr), - ukgsettings(nullptr), - udgsettings(nullptr), - timegsettings(nullptr), - stygsettings(nullptr), - vdgsettings(nullptr) -{ - initGsettings(); -} - -SCConfiguration* SCConfiguration::instance(QObject *parent) -{ - if(instance_ == nullptr) - instance_ = new SCConfiguration(parent); - return instance_; -} - -void SCConfiguration::initGsettings() -{ - if(QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA_MATE_BACKGROUND)) - mgsettings = new QGSettings(GSETTINGS_SCHEMA_MATE_BACKGROUND, "", this); - - if(QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA_SCREENSAVER)) - ukgsettings = new QGSettings(GSETTINGS_SCHEMA_SCREENSAVER, "", this); - - if(QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA_SCREENSAVER_DEFAULT)) - udgsettings = new QGSettings(GSETTINGS_SCHEMA_SCREENSAVER_DEFAULT,"",this); - - if(QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA_SCREENSAVER_DEFAULT)) - vdgsettings = new QGSettings(GSETTINGS_SCHEMA_SCREENSAVER_DEFAULT,"",this); - - if(QGSettings::isSchemaInstalled(TIME_TYPE_SCHEMA)) - timegsettings = new QGSettings(TIME_TYPE_SCHEMA,"",this); - - if(QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA_STYLE)) - stygsettings = new QGSettings(GSETTINGS_SCHEMA_STYLE, "", this); - - connect(udgsettings, &QGSettings::changed, - this, &SCConfiguration::onConfigurationChanged); - connect(ukgsettings, &QGSettings::changed, - this, &SCConfiguration::onConfigurationChanged); - connect(vdgsettings, &QGSettings::changed, - this, &SCConfiguration::onConfigurationChanged); - connect(timegsettings, &QGSettings::changed, - this, &SCConfiguration::onConfigurationChanged); - connect(stygsettings, &QGSettings::changed, - this, &SCConfiguration::onConfigurationChanged); -} - -void SCConfiguration::initDefaultSettings() -{ - - -} - -void SCConfiguration::onConfigurationChanged(QString key) -{ - if(key == "cycleTime"){ - int cycleTime = getCycleTime(); - Q_EMIT cycleTimeChanged(cycleTime); - }else if(key == "automaticSwitchingEnabled"){ - bool changed = getAutoSwitch(); - Q_EMIT autoSwitchChanged(changed); - }else if(key == "backgroundPath"){ - QString path = getBackgroundPath(); - Q_EMIT backgroundPathChanged(path); - }else if(key == "mytext"){ - QString text = getMyText(); - Q_EMIT myTextChanged(text); - }else if(key == "showCustomRestTime"){ - bool ret = getCShowRestTime(); - Q_EMIT showCRestTimeChanged(ret); - }else if(key == "showUkuiRestTime"){ - bool ret = getUShowRestTime(); - Q_EMIT showURestTimeChanged(ret); - }else if(key == "textIsCenter"){ - bool ret = getTextIsCenter(); - Q_EMIT textIsCenterChanged(ret); - }else if(key == "showMessageEnabled"){ - bool ret = getMessageShowEnable(); - Q_EMIT messageShowEnableChanged(ret); - }else if(key == "messageNumber"){ - int num = getMessageNumber(); - Q_EMIT messageNumberChanged(num); - }else if(key == "hoursystem"){ - int timeType = timegsettings->get("hoursystem").toInt(); - Q_EMIT timeTypeChanged(timeType); - }else if(key == "type"){ - QString dateType = timegsettings->get("date").toString(); - Q_EMIT dateTypeChanged(dateType); - }else if(key == "menuTransparency"){ - int blur_Num = stygsettings->get("menuTransparency").toInt(); - Q_EMIT blurChanged(blur_Num); - }else if(key == "styleName"){ - QString m_curStyle = stygsettings->get("styleName").toString(); - Q_EMIT styleChanged(m_curStyle); - } else if (key == "systemFontSize") { - double m_curFontSize = stygsettings->get("systemFontSize").toDouble(); - qDebug() << "curFontSize = " << m_curFontSize ; - Q_EMIT fontSizeChanged(m_curFontSize); - } -} - -QString SCConfiguration::getDefaultBackground() -{ - QString backgroundFile = ""; - if(ukgsettings){ - backgroundFile = ukgsettings->get("background").toString(); - } - - if(ispicture(backgroundFile)) { - return backgroundFile; - } else { - char *systemName = kdk_system_get_systemName(); - if (systemName) { - if (QString(systemName) == "openKylin") { - free(systemName); - return "/usr/share/backgrounds/1-openkylin.jpg"; - } - free(systemName); - } - return "/usr/share/backgrounds/1-warty-final-ubuntukylin.jpg"; - } -} - -int SCConfiguration::getTimeType() -{ - int timeType = 24; - if(timegsettings){ - QStringList keys = timegsettings->keys(); - if (keys.contains("hoursystem")) { - timeType = timegsettings->get("hoursystem").toInt(); - } - } - return timeType; -} - -QString SCConfiguration::getDateType() -{ - QString dateType = "cn"; - if(timegsettings){ - QStringList keys = timegsettings->keys(); - if (keys.contains("date")) { - dateType = timegsettings->get("date").toString(); - } - } - return dateType; -} - -int SCConfiguration::getFontSize() -{ - double fontSize = 0; - if(stygsettings){ - QStringList keys = stygsettings->keys(); - if (keys.contains("systemFontSize")) { - fontSize = stygsettings->get("systemFontSize").toDouble(); - } - } - - double defaultFontSize = getDefaultFontSize(); - qDebug()<<"defaultFontSize = "<logicalDotsPerInch() > 0) - m_ptTopx = 72/(QApplication::primaryScreen()->logicalDotsPerInch()); - return m_ptTopx; -} - -bool SCConfiguration::getAutoSwitch() -{ - bool ret = false; - if(udgsettings){ - ret = udgsettings->get("automatic-switching-enabled").toBool(); - } - - return ret; -} - -bool SCConfiguration::getIsCustom() -{ - bool ret = false; - if(ukgsettings){ - ret = (ukgsettings->get("mode").toString() == "default-ukui-custom"); - } - - return ret; -} - -bool SCConfiguration::getMessageShowEnable() -{ - bool ret = false; - if(ukgsettings){ - ret = ukgsettings->get("show-message-enabled").toBool(); - } - - return ret; -} - -int SCConfiguration::getMessageNumber() -{ - bool ret = false; - if(ukgsettings){ - ret = (ukgsettings->get("mode").toString() == "default-ukui-custom"); - } - - return ret; -} - -bool SCConfiguration::getCShowRestTime() -{ - bool ret = true; - if(udgsettings){ - QStringList keys = udgsettings->keys(); - ret = udgsettings->get("show-custom-rest-time").toBool(); - } - return ret; -} - -bool SCConfiguration::getUShowRestTime() -{ - bool ret = true; - if(udgsettings){ - QStringList keys = udgsettings->keys(); - ret = udgsettings->get("show-ukui-rest-time").toBool(); - } - return ret; -} - -int SCConfiguration::getCycleTime() -{ - int cycleTime = 300; - if(udgsettings){ - cycleTime = udgsettings->get("cycle-time").toInt(); - } - return cycleTime; -} - -QString SCConfiguration::getBackgroundPath() -{ - QString backgroundPath = "/usr/share/backgrounds"; - if(udgsettings){ - backgroundPath = udgsettings->get("background-path").toString(); - } - return backgroundPath; -} - -bool SCConfiguration::getTextIsCenter() -{ - bool ret = true; - if(udgsettings){ - ret = udgsettings->get("text-is-center").toBool(); - } - return ret; -} - -QString SCConfiguration::getMyText() -{ - QString myText = ""; - if(udgsettings){ - myText = udgsettings->get("mytext").toString(); - } - return myText; -} - -int SCConfiguration::getBlurNumber() -{ - int blurNum = 50; - if(stygsettings){ - blurNum = stygsettings->get("menu-transparency").toInt(); - qDebug()<<"????nm"<get("style-name").toString(); - } - return curStyle; -} - -QString SCConfiguration::getVideoPath() -{ - QString videoPath; - if(vdgsettings){ - videoPath = vdgsettings->get("video-path").toString(); - } - return videoPath; -} - -QString SCConfiguration::getVideoFormat() -{ - QString videoFormat; - if(vdgsettings){ - videoFormat = vdgsettings->get("video-format").toString(); - } - return videoFormat; -} - -int SCConfiguration::getVideoSize() -{ - int videoSize; - if(vdgsettings){ - videoSize = vdgsettings->get("video-size").toInt(); - } - return videoSize; -} - -int SCConfiguration::getVideoWidth() -{ - int videoWidth; - if(vdgsettings){ - videoWidth = vdgsettings->get("video-width").toInt(); - } - return videoWidth; -} - -int SCConfiguration::getVideoHeight() -{ - int videoHeight; - if(vdgsettings){ - videoHeight = vdgsettings->get("video-height").toInt(); - } - return videoHeight; -} - diff --git a/screensaver/ukui-screensaver-default.pro b/screensaver/ukui-screensaver-default.pro deleted file mode 100644 index 5dd421d..0000000 --- a/screensaver/ukui-screensaver-default.pro +++ /dev/null @@ -1,49 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2020-01-10T17:10:24 -# -#------------------------------------------------- - -QT += core gui x11extras - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -TARGET = ukui-screensaver-default -TEMPLATE = app - -# The following define makes your compiler emit warnings if you use -# any feature of Qt which as been marked as deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if you use deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - -LIBS += -lX11 - -SOURCES += \ - main.cpp \ - screensaver.cpp \ - sleeptime.cpp \ - chinesedate.cpp \ - mbackground.cpp \ - scconfiguration.cpp - -HEADERS += \ - screensaver.h \ - sleeptime.h \ - chinesedate.h \ - mbackground.h \ - scconfiguration.h - -TRANSLATIONS = ../i18n_ts/zh_CN.ts \ - ../i18n_ts/ru.ts \ - ../i18n_ts/fr.ts \ - ../i18n_ts/pt.ts \ - ../i18n_ts/es.ts - -RESOURCES = default.qrc - diff --git a/set4kScale/CMakeLists.txt b/set4kScale/CMakeLists.txt deleted file mode 100644 index 9429dfa..0000000 --- a/set4kScale/CMakeLists.txt +++ /dev/null @@ -1,30 +0,0 @@ -project(set4kScale) - -pkg_check_modules(X11 REQUIRED x11) -pkg_check_modules(XCB REQUIRED xcb) -pkg_check_modules(QGS REQUIRED gsettings-qt) -pkg_check_modules(KDKINFO REQUIRED kysdk-sysinfo) - -include_directories( - ${X11_INCLUDE_DIRS} - ${XCB_INCLUDE_DIRS} - ${QGS_INCLUDE_DIRS} - ${KDKINFO_INCLUDE_DIRS} - ) - -link_directories( - ${KDKINFO_LIBRARY_DIRS}) - -set(CMAKE_AUTOMOC ON) - -set(bin_SRCS - ${bin_SRCS} - main.cpp - ) - -add_executable(set4kScale ${bin_SRCS}) -target_link_libraries(set4kScale Qt5::Core Qt5::Widgets Qt5::X11Extras ${X11_LIBRARIES} ${XCB_LIBRARIES} ${QGS_LIBRARIES} ${KDKINFO_LIBRARIES}) - -install(TARGETS - set4kScale - DESTINATION lib/ukui-screensaver) diff --git a/set4kScale/main.cpp b/set4kScale/main.cpp deleted file mode 100644 index 80b6c1e..0000000 --- a/set4kScale/main.cpp +++ /dev/null @@ -1,240 +0,0 @@ -/* - * Copyright (C) 2022 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -extern "C" { -#include -#include -} - - -#define XSETTINGS_SCHEMA "org.ukui.SettingsDaemon.plugins.xsettings" -#define MOUSE_SCHEMA "org.ukui.peripherals-mouse" -#define SCALING_KEY "scaling-factor" -#define CURSOR_SIZE "cursor-size" -#define CURSOR_THEME "cursor-theme" - - -/* 设置DPI环境变量 */ -void setXresources(double scale) -{ - Display *dpy; - QGSettings *mouse_settings = new QGSettings(MOUSE_SCHEMA); - QString str = QString("Xft.dpi:\t%1\nXcursor.size:\t%2\nXcursor.theme:\t%3\n") - .arg(scale * 96) - .arg(mouse_settings->get(CURSOR_SIZE).toInt() * scale) - .arg(mouse_settings->get(CURSOR_THEME).toString()); - - dpy = XOpenDisplay(NULL); - XChangeProperty(dpy, RootWindow(dpy, 0), XA_RESOURCE_MANAGER, XA_STRING, 8, - PropModeReplace, (unsigned char *) str.toLatin1().data(), str.length()); - XCloseDisplay(dpy); - - qDebug() << "setXresources:" << str; - - delete mouse_settings; -} - -/* 过滤低分辨率高缩放比情况 */ -void screenScaleJudgement(QGSettings *settings) -{ - qreal scaling = qApp->devicePixelRatio(); - double scale; - scale = settings->get(SCALING_KEY).toDouble(); - if (scale > 1.25) { - bool state = false; - bool mScale = false; - - for (QScreen *screen : QGuiApplication::screens()) { - int width = screen->geometry().width() * scaling; - int height = screen->geometry().height() * scaling; - - if (width < 1920 && height < 1080) { - state = true; - } - else if (width == 1920 && height == 1080 && scale > 1.5) { - state = true; - } - /* - else if (width > 2560 && height > 1440) { - mScale = true; - } - */ - } - -// if (state && !mScale) { - if (state) { - settings->set(SCALING_KEY, 1.0); - scale = 1.0; - } - } - setXresources(scale); -} - -/* 判断文件是否存在 */ -bool isFileExist(QString XresourcesFile) -{ - QFileInfo fileInfo(XresourcesFile); - if (fileInfo.isFile()) { - qDebug() << "File exists"; - return true; - } - - qDebug() << "File does not exis"; - - return false; -} - -/* 编写判断标志文件,更改 鼠标/DPI 配置大小*/ -void writeXresourcesFile(QString XresourcesFile, QGSettings *settings, double scaling) -{ - QFile file(XresourcesFile); - QString content = QString("Xft.dpi:%1\nXcursor.size:%2").arg(96.0 * scaling).arg(24.0 * scaling); - QByteArray str = content.toLatin1().data(); - - file.open(QIODevice::ReadWrite | QIODevice::Text); - file.write(str); - file.close(); - - QGSettings *Font = new QGSettings("org.ukui.font-rendering"); - - Font->set("dpi", 96.0); - settings->set(SCALING_KEY, scaling); - - qDebug() << " writeXresourcesFile: content = " << content - << " scalings = " << settings->get(SCALING_KEY).toDouble(); - delete Font; -} - -/* 判断是否为首次登陆 */ -bool isTheFirstLogin(QGSettings *settings) -{ - QString homePath = getenv("HOME"); - QString XresourcesFile = homePath+"/.config/xresources"; - QString Xresources = homePath+"/.Xresources"; - qreal scaling = qApp->devicePixelRatio(); - bool zoom1 = false, zoom2 = false, zoom3 = false; - double mScaling; - bool xres, Xres; - - Xres = isFileExist(Xresources); - xres = isFileExist(XresourcesFile); //判断标志文件是否存在 - - if (xres && !Xres) { - return false; - } else if (xres && Xres) { - QFile::remove(Xresources); - return false; - } else if (Xres && !xres) { - QFile::rename(Xresources, XresourcesFile); - return false; - } - - for (QScreen *screen : QGuiApplication::screens()) { - int width = screen->geometry().width() * scaling; - int height = screen->geometry().height() * scaling; - - if (width <= 1920 && height <= 1080) { - zoom1 = true; - } else if (width > 1920 && height > 1080 && width <= 2560 && height <=1500) { - zoom2 = true; - } else if (width > 2560 && height > 1440) { - zoom3 = true; - } - } - - if (zoom1) { - mScaling = 1.0; - } else if (!zoom1 && zoom2) { - mScaling = 1.5; //考虑新版缩放,设置默认150%暂时停止设置; - } else if (!zoom1 && !zoom2 && zoom3) { - mScaling = 2.0; - } - - writeXresourcesFile(XresourcesFile, settings, mScaling); - - setXresources(mScaling); - - return true; -} - -/* 配置新装系统、新建用户第一次登陆时,4K缩放功能*/ -void setHightResolutionScreenZoom(bool platForm) -{ - QGSettings *settings; - double scale; - int ScreenNum = QApplication::screens().length(); - if (!QGSettings::isSchemaInstalled(XSETTINGS_SCHEMA) || !QGSettings::isSchemaInstalled("org.ukui.font-rendering") || - !QGSettings::isSchemaInstalled(MOUSE_SCHEMA)) { - qDebug() << "Error: ukui-settings-daemon's Schema is not installed, will not setting dpi!"; - delete settings; - return; - } - settings = new QGSettings(XSETTINGS_SCHEMA); - - scale = settings->get(SCALING_KEY).toDouble(); - - if (platForm) { - setXresources(scale); - goto end; - } - - if (isTheFirstLogin(settings)) { - qDebug() << "Set the default zoom value when logging in for the first time."; - goto end; - } - /* 过滤单双屏下小分辨率大缩放值 */ - - - if (ScreenNum > 1) { - setXresources(scale); - goto end; - } - - screenScaleJudgement(settings); - -end: - delete settings; -} - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - QString platForm = kdk_system_get_hostCloudPlatform(); - if (platForm == "none") { - qDebug() << "platForm=" << platForm << ", 系统环境为实体机"; - setHightResolutionScreenZoom(false); - } else { - qDebug() << "platForm=" << platForm << ", 系统环境为云环境"; - setHightResolutionScreenZoom(true); - } - return 0; -} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2a9e00f..34445d1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,200 +1,118 @@ +find_package(Qt5 COMPONENTS Core Widgets DBus X11Extras Xml Network Svg Multimedia MultimediaWidgets) +find_package(PkgConfig REQUIRED) +find_package(OpenCV REQUIRED) +find_package(LayerShellQt) +find_package(KF5Wayland CONFIG) + +if(LayerShellQt_FOUND) + add_definitions(-DHAVE_LAYERSHELLQT=1) +endif() + +pkg_check_modules(GIOUNIX2 REQUIRED gio-unix-2.0) +pkg_check_modules(GLIB2 REQUIRED glib-2.0 gio-2.0) + find_package(X11 REQUIRED) -pkg_check_modules(KYSDKSYSTIME_PKG kysdk-systime) +pkg_check_modules(KYSDKSYSTIME REQUIRED kysdk-systime) pkg_check_modules(XTST REQUIRED xtst) pkg_check_modules(XCB REQUIRED xcb) pkg_check_modules(QGS REQUIRED gsettings-qt) - -pkg_check_modules(GLIB REQUIRED glib-2.0) pkg_check_modules(MMIX REQUIRED libmatemixer) pkg_check_modules(kylin-nm-base REQUIRED kylin-nm-base) -pkg_check_modules(KDKINFO REQUIRED kysdk-sysinfo) pkg_check_modules(IMLIB2 REQUIRED imlib2) +pkg_check_modules(LIGHTDM-QT5-3 REQUIRED liblightdm-qt5-3) +pkg_check_modules(LIBSYSTEMD REQUIRED libsystemd) +# 查找pam动态库全路径并缓存到PAM_LIBRARIES变量 find_library(PAM_LIBRARIES pam) include_directories(${PROJECT_BINARY_DIR}) +include_directories(${PROJECT_SOURCE_DIR}/src) +include_directories(${PROJECT_SOURCE_DIR}/src/common) +include_directories(${PROJECT_SOURCE_DIR}/src/widgets) +include_directories(${PROJECT_SOURCE_DIR}/src/QtSingleApplication) +include_directories(${PROJECT_SOURCE_DIR}/src/dbusifs) include_directories(${PROJECT_SOURCE_DIR}/VirtualKeyboard/src) -include_directories(${PROJECT_SOURCE_DIR}/BiometricAuth) -include_directories(${PROJECT_SOURCE_DIR}/Common) -include_directories(${PROJECT_SOURCE_DIR}/screensaver) -include_directories(${PROJECT_SOURCE_DIR}/KylinNM) -include_directories(${PROJECT_SOURCE_DIR}/KylinNM/src) -include_directories(${PROJECT_SOURCE_DIR}/KylinNM/hot-spot) -include_directories(${PROJECT_SOURCE_DIR}/KylinNM/wireless-security) + +aux_source_directory(${PROJECT_SOURCE_DIR}/src/common COMMON) +aux_source_directory(${PROJECT_SOURCE_DIR}/src/widgets WIDGEGS) +aux_source_directory(${PROJECT_SOURCE_DIR}/src/lock-dialog LOCK_DIALOG) +aux_source_directory(${PROJECT_SOURCE_DIR}/src/lock-backend LOCK_BACKEND) +aux_source_directory(${PROJECT_SOURCE_DIR}/src/lock-command LOCK_COMMAND) +aux_source_directory(${PROJECT_SOURCE_DIR}/src/lock-checkpasswd LOCK_CHECKPASSWD) +aux_source_directory(${PROJECT_SOURCE_DIR}/src/lock-focushelper LOCK_FOCUSHELPER) + +add_definitions(-DRESOURCE_PATH="/usr/share/ukui-screensaver/") + +set(SINGLE_GUI_APPLICATION_SRCS + ${PROJECT_SOURCE_DIR}/src/QtSingleApplication/qtsingleapplication.cpp + ${PROJECT_SOURCE_DIR}/src/QtSingleApplication/qtlocalpeer.cpp + ) +set(SINGLE_CORE_APPLICATION_SRCS + ${PROJECT_SOURCE_DIR}/src/QtSingleApplication/qtsinglecoreapplication.cpp + ${PROJECT_SOURCE_DIR}/src/QtSingleApplication/qtlocalpeer.cpp + ) include_directories( ${X11_INCLUDE_DIRS} ${XTST_INCLUDE_DIRS} ${XCB_INCLUDE_DIRS} ${QGS_INCLUDE_DIRS} - ${GLIB_INCLUDE_DIRS} + ${GIOUNIX2_INCLUDE_DIRS} + ${GLIB2_INCLUDE_DIRS} ${MMIX_INCLUDE_DIRS} ${kylin-nm-base_INCLUDE_DIRS} - ${KF5Wayland_LIBRARIES} - ${KDKINFO_INCLUDE_DIRS} ${IMLIB2_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS} - ) - -link_directories( - ${KDKINFO_LIBRARY_DIRS} + ${LIGHTDM-QT5-3_INCLUDE_DIRS} + ${LIBSYSTEMD_INCLUDE_DIRS} ) set(EXTRA_LIBS ${EXTRA_LIBS} - ${PAM_LIBRARIES} ${X11_LIBRARIES} ${XTST_LIBRARIES} ${XCB_LIBRARIES} ${QGS_LIBRARIES} - ${GLIB_LIBRARIES} + ${GIOUNIX2_LIBRARIES} + ${GLIB2_LIBRARIES} ${MMIX_LIBRARIES} - ${KF5Wayland_LIBRARIES} - ${KDKINFO_LIBRARIES} ${IMLIB2_LIBRARIES} -lrt -lpthread - -lKF5WaylandServer - -lKF5WaylandClient -llibnm-icon-kylin - -lukuiinputgatherclient ) -qt5_wrap_ui(dialog_SRC - lockwidget.ui - surewindow.ui - ) +#qt5_wrap_ui(dialog_SRC +# lockwidget.ui +# surewindow.ui +# ) qt5_add_resources(dialog_SRC - assets.qrc - ../KylinNM/nmqrc.qrc #暂时将麒麟网络的资源文件放到这里,否则显示不出来,暂时不知道原因 - ../screensaver/default.qrc + assets.qrc ) -# 头文件中包含了Xlib.h,需要单独拿出来处理,不知道原因 qt5_wrap_cpp(dialog_SRC - agreementwindow.h - pam-tally.h - fullbackgroundwidget.h - lockwidget.h - authdialog.h - loginoptionswidget.h - screensaverwidget.h - auth.h - auth-pam.h - screensavermode.h - screensaverwndadaptor.h - xeventmonitor.h - monitorwatcher.h - configuration.h - utils.h - users.h - hoverwidget.h - displaymanager.h - iconedit.h - iconbutton.h - imageutil.h - powermanager.h - logind.h - weathermanager.h - tabletlockwidget.h - gestureauthdialog.h - digitalauthdialog.h - switchbuttongroup.h - wechatauthdialog.h - verificationwidget.h - verticalVerificationwidget.h - common.h - eduplatforminterface.h - accountsinterface.h - networkwatcher.h - digitalkeyboard.h - surewindow.h - loginedusers.h - lockchecker.h - servicemanager.h - mytabwidget.h - modebutton.h - iconbutton.h - klabel.h - greeterservice.h - loginplugininterface.h - loginauthinterface.h - pluginsloader.h - PhysicalDeviceSet/brightnessdeviceset.h - PhysicalDeviceSet/flightmodeset.h - PhysicalDeviceSet/sounddeviceset.h - PhysicalDeviceSet/touchscreenset.h - device.h - enginedevice.h - batterywidget.h - libinputswitchevent.h - machinemodel.h + userinfo.h + agreementinfo.h ) set(dialog_SRC ${dialog_SRC} - agreementwindow.cpp - pam-tally.c - ukui-screensaver-dialog.cpp - fullbackgroundwidget.cpp - lockwidget.cpp - authdialog.cpp - loginoptionswidget.cpp - screensaverwidget.cpp - auth-pam.cpp - xeventmonitor.cpp - monitorwatcher.cpp - grab-x11.cpp - configuration.cpp - screensavermode.cpp - screensaverwndadaptor.cpp - powermanager.cpp - utils.cpp - users.cpp - displaymanager.cpp - iconbutton.cpp - iconedit.cpp - imageutil.cpp - logind.cpp - hoverwidget.cpp - weathermanager.cpp - tabletlockwidget.cpp - gestureauthdialog.cpp - digitalauthdialog.cpp - switchbuttongroup.cpp - wechatauthdialog.cpp - verificationwidget.cpp - verticalVerificationwidget.cpp - eduplatforminterface.cpp - accountsinterface.cpp - networkwatcher.cpp - digitalkeyboard.cpp - surewindow.cpp - loginedusers.cpp - lockchecker.cpp - servicemanager.cpp - mytabwidget.cpp - modebutton.cpp - iconbutton.cpp - klabel.cpp - greeterservice.cpp - rootWindowBackground.cpp - pluginsloader.cpp - PhysicalDeviceSet/brightnessdeviceset.cpp - PhysicalDeviceSet/flightmodeset.cpp - PhysicalDeviceSet/sounddeviceset.cpp - PhysicalDeviceSet/touchscreenset.cpp - device.cpp - enginedevice.cpp - batterywidget.cpp - libinputswitchevent.cpp - machinemodel.cpp + ${COMMON} + ${WIDGEGS} + ${SINGLE_GUI_APPLICATION_SRCS} + ${LOCK_DIALOG} + userinfo.cpp + agreementinfo.cpp + dbusifs/uniauthservice.cpp + dbusifs/biometrichelper.cpp + dbusifs/freedesktophelper.cpp + dbusifs/giodbus.cpp ) add_executable(ukui-screensaver-dialog ${dialog_SRC}) add_definitions(-DAPP_API_MAJOR=0 -DAPP_API_MINOR=11 -DAPP_API_FUNC=0) -target_include_directories(ukui-screensaver-dialog PRIVATE ${KYSDKSYSTIME_PKG_INCLUDE_DIRS}) -target_link_directories(ukui-screensaver-dialog PRIVATE ${KYSDKSYSTIME_PKG_LIBRARY_DIRS}) +target_include_directories(ukui-screensaver-dialog PRIVATE ${KYSDKSYSTIME_INCLUDE_DIRS}) +target_link_directories(ukui-screensaver-dialog PRIVATE ${KYSDKSYSTIME_LIBRARY_DIRS}) target_link_libraries(ukui-screensaver-dialog Qt5::Core Qt5::Widgets @@ -203,62 +121,94 @@ target_link_libraries(ukui-screensaver-dialog Qt5::X11Extras Qt5::Network Qt5::Widgets - ${KYSDKSYSTIME_PKG_LIBRARIES} + KF5::WaylandClient + ${KYSDKSYSTIME_LIBRARIES} ${EXTRA_LIBS} - BiometricAuth - VirtualKeyboard - Common - Kylin-nm + VirtualKeyboard ukui-log4qt - Screensaver opencv_imgcodecs opencv_imgproc opencv_core - LayerShellQt::Interface -ldl - ) -link_libraries(libmatemixer.so glib-2.0.so) + -lcrypto + ) + +if(LayerShellQt_FOUND) + target_link_libraries(ukui-screensaver-dialog LayerShellQt::Interface) +endif() qt5_add_dbus_adaptor(backend_SRC - org.ukui.ScreenSaver.xml - interface.h - Interface + lock-backend/org.ukui.ScreenSaver.xml + lock-backend/dbusupperinterface.h + DbusUpperInterface ) qt5_wrap_cpp(backend_SRC - interface.h - sessionwatcher.h - logind.h + userinfo.h + agreementinfo.h ) + set(backend_SRC ${backend_SRC} - ukui-screensaver-backend.cpp - interface.cpp - sessionwatcher.cpp - logind.cpp + ${LOCK_BACKEND} + ${SINGLE_CORE_APPLICATION_SRCS} + dbusifs/login1helper.cpp + dbusifs/usdhelper.cpp + dbusifs/upowerhelper.cpp + dbusifs/enginedevice.cpp + dbusifs/device.cpp + dbusifs/accountservicehelper.cpp + dbusifs/sessionhelper.cpp + dbusifs/uniauthservice.cpp + dbusifs/biometrichelper.cpp + dbusifs/freedesktophelper.cpp + dbusifs/giodbus.cpp + dbusifs/kglobalaccelhelper.cpp + userinfo.cpp + agreementinfo.cpp + common/global_utils.cpp + common/configuration.cpp + common/biodefines.cpp ) add_executable(ukui-screensaver-backend ${backend_SRC}) -target_link_libraries(ukui-screensaver-backend Qt5::Core Qt5::DBus ${QGS_LIBRARIES} ukui-log4qt Common) +target_link_libraries(ukui-screensaver-backend + Qt5::Core + Qt5::DBus + Qt5::Network + ${PAM_LIBRARIES} + ${LIGHTDM-QT5-3_LIBRARIES} + ${QGS_LIBRARIES} + ${LIBSYSTEMD_LIBRARIES} + ${GLIB2_LIBRARIES} + ukui-log4qt + -ldl + -lcrypto + ) set(command_SRC - ukui-screensaver-command.cpp + ${LOCK_COMMAND} ) add_executable(ukui-screensaver-command ${command_SRC}) target_link_libraries(ukui-screensaver-command Qt5::Core Qt5::DBus ukui-log4qt) set(checkpass_SRC - ukui-screensaver-checkpass.cpp + ${LOCK_CHECKPASSWD} ) add_executable(ukui-screensaver-checkpass ${checkpass_SRC}) target_link_libraries(ukui-screensaver-checkpass ${PAM_LIBRARIES}) -set(ukss_SRCS - ukss_interface.cpp +set(focushelper_SRCS + ${focushelper_SRCS} + ${LOCK_FOCUSHELPER} ) -add_definitions(-DUKSSSO_LIBRARY) -add_library(ukss SHARED ${ukss_SRCS}) -target_link_libraries(ukss Qt5::Core Qt5::DBus ${QGS_LIBRARIES}) +add_executable(screensaver-focus-helper ${focushelper_SRCS}) +target_link_libraries(screensaver-focus-helper Qt5::Core Qt5::Widgets Qt5::X11Extras ${X11_LIBRARIES} ${XCB_LIBRARIES}) + +add_subdirectory(VirtualKeyboard) +add_subdirectory(screensaver) + +add_dependencies(ukui-screensaver-dialog VirtualKeyboard ukui-screensaver-default screensaver-default) install(TARGETS ukui-screensaver-dialog @@ -267,11 +217,8 @@ install(TARGETS ukui-screensaver-checkpass DESTINATION bin) -install(TARGETS ukss DESTINATION ${QT_INSTALL_LIBS}) +install(TARGETS + screensaver-focus-helper + DESTINATION lib/ukui-screensaver) -#set(test-act_SRC -# users.cpp -# test-accounts.cpp -# ) -#add_executable(test-accounts ${test-act_SRC}) -#target_link_libraries(test-accounts Qt5::Core Qt5::DBus) +install(DIRECTORY assets/badges DESTINATION /usr/share/ukui-screensaver/images/) diff --git a/src/PhysicalDeviceSet/brightnessdeviceset.cpp b/src/PhysicalDeviceSet/brightnessdeviceset.cpp deleted file mode 100644 index 5e25b9f..0000000 --- a/src/PhysicalDeviceSet/brightnessdeviceset.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (C) 2022 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#include "brightnessdeviceset.h" - -int BrightnessDeviceSet::m_value = -1; -int BrightnessDeviceSet::m_maxBrightnessValue = -1; -bool BrightnessDeviceSet::m_isPowerSupply = false; -int BrightnessDeviceSet::m_curBrightnessValue = -1; - -BrightnessDeviceSet* BrightnessDeviceSet::instance(QObject *parent) -{ - static BrightnessDeviceSet* _instance = nullptr; - QMutex mutex; - mutex.lock(); - if(_instance == nullptr) - _instance = new BrightnessDeviceSet(parent); - mutex.unlock(); - return _instance; -} - -BrightnessDeviceSet::BrightnessDeviceSet(QObject *parent): - QObject(parent) -{ - init(); -} - -void BrightnessDeviceSet::init() -{ - //m_isPowerSupply = true; - m_isPowerSupply = isPowerSupply(); - if(!m_isPowerSupply){ - qWarning() << "info: [BrightnessDeviceSet][init]: current device not support brightness-change!"; - } - m_curBrightnessValue = getCurBrightness(); - m_maxBrightnessValue = getMaxBrightness(); - //m_maxBrightnessValue = 19200; - m_value = m_curBrightnessValue * 1.0 / m_maxBrightnessValue * 100; -} - -int BrightnessDeviceSet::getValue() -{ - return m_value; -} - -void BrightnessDeviceSet::setValue(int value) -{ - if(!m_isPowerSupply) return; - if(value == m_value) return; - if(value > 100) value = 100; - else if(value < 0) value = 0; - m_value = value; - //emit valueChanged(m_value); - // 调整亮度 - int val = value * 1.0 / 100 * m_maxBrightnessValue; - setBrightness(val); -} - -bool BrightnessDeviceSet::isPowerSupply() -{ - QProcess process; - QString command = "/usr/lib/ukui-greeter/greeter-backlight-helper --get-support-brightness"; - - process.start(command); - process.waitForFinished(3000); - QString result = process.readAll(); - - return result == "true"; -} - -int BrightnessDeviceSet::getMaxBrightness() -{ - if(!m_isPowerSupply) return 0; - QProcess process; - QString command = "/usr/lib/ukui-greeter/greeter-backlight-helper --get-max-brightness"; - - process.start(command); - process.waitForFinished(3000); - QString result = process.readAll(); - return result.toInt(); -} - -int BrightnessDeviceSet::getCurBrightness() -{ - if(!m_isPowerSupply) return 0; - QProcess process; - QString command = "/usr/lib/ukui-greeter/greeter-backlight-helper --get-brightness"; - - process.start(command); - process.waitForFinished(3000); - QString result = process.readAll(); - return result.toInt(); -} - -void BrightnessDeviceSet::setBrightness(int val) -{ - if(!m_isPowerSupply) return; - if(val > m_maxBrightnessValue) val = m_maxBrightnessValue; - else if(val < 100) val = 100; - - QString command = "/usr/lib/ukui-greeter/greeter-backlight-helper --set-brightness " + QString::number(val); - - QProcess process; - process.start(command); - process.waitForFinished(3000); - //QString result = process.readAll(); -} diff --git a/src/PhysicalDeviceSet/brightnessdeviceset.h b/src/PhysicalDeviceSet/brightnessdeviceset.h deleted file mode 100644 index c361c9d..0000000 --- a/src/PhysicalDeviceSet/brightnessdeviceset.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#ifndef BRIGHTNESSDEVICESET_H -#define BRIGHTNESSDEVICESET_H - -#include -#include -#include -#include - -class BrightnessDeviceSet : public QObject -{ - Q_OBJECT -public: - static BrightnessDeviceSet* instance(QObject *parent = nullptr); - -public Q_SLOTS: - // val from 0 to 100 change - void setValue(int value); - int getValue(); - -private: - BrightnessDeviceSet(QObject *parent = nullptr); - void init(); - bool isPowerSupply(); - int getMaxBrightness(); - int getCurBrightness(); - // val from 0 to MaxBrightness change - void setBrightness(int val); - -Q_SIGNALS: - // val form to 100 change - //void valueChanged(int val); - -private: - static int m_value; - static int m_maxBrightnessValue; - static int m_curBrightnessValue; - static bool m_isPowerSupply; -}; - -#endif // BRIGHTNESSDEVICESET_H diff --git a/src/PhysicalDeviceSet/flightmodeset.cpp b/src/PhysicalDeviceSet/flightmodeset.cpp deleted file mode 100644 index 33e4616..0000000 --- a/src/PhysicalDeviceSet/flightmodeset.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#include "flightmodeset.h" - -bool FlightModeSet::m_isFlightModeOpen = false; - -FlightModeSet* FlightModeSet::instance(QObject *parent) -{ - static FlightModeSet* _instance = nullptr; - QMutex mutex; - mutex.lock(); - if(_instance == nullptr) - _instance = new FlightModeSet(parent); - mutex.unlock(); - return _instance; -} - -FlightModeSet::FlightModeSet(QObject *parent): - QObject(parent) -{ - -} diff --git a/src/PhysicalDeviceSet/flightmodeset.h b/src/PhysicalDeviceSet/flightmodeset.h deleted file mode 100644 index 3efcd0a..0000000 --- a/src/PhysicalDeviceSet/flightmodeset.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#ifndef FLIGHTMODESET_H -#define FLIGHTMODESET_H -/*! - *@brief 设置飞行模式 - * 本想在登录界面加载时 提供实体键 飞行模式的功能 - * 后来发现有效。但是飞行模式具体设置是谁负责管理的 还未知。 - * 最初实现的策略是通过 nmcli networking off 的方式设置飞行模式。 - */ - - -#include -#include - -class FlightModeSet : public QObject -{ - Q_OBJECT -public: - static FlightModeSet* instance(QObject *parent = nullptr); - -private: - FlightModeSet(QObject *parent = nullptr); - -private: - static bool m_isFlightModeOpen; - -}; - -#endif // FLIGHTMODESET_H diff --git a/src/PhysicalDeviceSet/physical-device-set.pri b/src/PhysicalDeviceSet/physical-device-set.pri deleted file mode 100644 index 365f7bf..0000000 --- a/src/PhysicalDeviceSet/physical-device-set.pri +++ /dev/null @@ -1,11 +0,0 @@ -HEADERS += \ - $$PWD/brightnessdeviceset.h \ - $$PWD/flightmodeset.h \ - $$PWD/sounddeviceset.h \ - $$PWD/touchscreenset.h - -SOURCES += \ - $$PWD/brightnessdeviceset.cpp \ - $$PWD/flightmodeset.cpp \ - $$PWD/sounddeviceset.cpp \ - $$PWD/touchscreenset.cpp diff --git a/src/PhysicalDeviceSet/sounddeviceset.cpp b/src/PhysicalDeviceSet/sounddeviceset.cpp deleted file mode 100644 index 876708f..0000000 --- a/src/PhysicalDeviceSet/sounddeviceset.cpp +++ /dev/null @@ -1,238 +0,0 @@ -/* - * Copyright (C) 2021 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#include "sounddeviceset.h" - -int SoundDeviceSet::m_value = -1; - -SoundDeviceSet* SoundDeviceSet::instance(QObject *parent) -{ - static SoundDeviceSet* _instance = nullptr; - QMutex mutex; - mutex.lock(); - if(!_instance) - _instance = new SoundDeviceSet(parent); - mutex.unlock(); - return _instance; -} - -SoundDeviceSet::SoundDeviceSet(QObject *parent): - QObject(parent) -{ - init(); -} - - -void SoundDeviceSet::init(){ - if (mate_mixer_init () == FALSE){ - qDebug()<<"matemixer init false"; - return ; - } - - context = mate_mixer_context_new (); - if (mate_mixer_context_open (context) == FALSE) { - qDebug()<<"matemixer context open context false."; - return ; - } - - MateMixerState state = mate_mixer_context_get_state (context); - - switch (state) { - case MATE_MIXER_STATE_READY: - connected (context); - break; - case MATE_MIXER_STATE_CONNECTING: - g_print ("Waiting for connection...\n"); - - /* The state will change asynchronously to either MATE_MIXER_STATE_READY - * or MATE_MIXER_STATE_FAILED, wait for the change in a main loop */ - g_signal_connect (G_OBJECT (context), - "notify::state", - G_CALLBACK (on_context_state_notify), - NULL); - break; - default: - qDebug()<<"it's can not reached"; - break; - } -} - -void SoundDeviceSet::emitSignal(bool val){ - emit muteChanged(val); -} - -void SoundDeviceSet::setValue(int val){ - if(!context) - return ; - if(val > 100) val = 100; - else if(val < 0) val = 0; - if(val == m_value) return; - m_value = val; - emit valueChanged(m_value); - - MateMixerStream *m_pOutputStream = mate_mixer_context_get_default_output_stream(context); - if(m_pOutputStream == NULL) - return; - - MateMixerStreamControl *control = mate_mixer_stream_get_default_control(m_pOutputStream); - - bool status = false; - int volume = val*65536/100; - - mate_mixer_stream_control_set_volume(control,guint(volume)); - if (val <= 0) { - status = true; - mate_mixer_stream_control_set_mute(control,status); - mate_mixer_stream_control_set_volume(control,0); - } - else { - mate_mixer_stream_control_set_mute(control,status); - } -} - -void SoundDeviceSet::onStreamControlMuteNotify(MateMixerStreamControl *m_pControl,GParamSpec *pspec,gpointer point){ - - if(!m_pControl) - return ; - - bool state = mate_mixer_stream_control_get_mute (m_pControl); - SoundDeviceSet::instance()->emitSignal(state); -} - -void SoundDeviceSet::onStreamControlVolumeNotify(MateMixerStreamControl *m_pControl,GParamSpec *pspec,gpointer point){ - - MateMixerStreamControlFlags flags; - guint volume = 0; - - if (m_pControl != nullptr) - flags = mate_mixer_stream_control_get_flags(m_pControl); - - if (flags&MATE_MIXER_STREAM_CONTROL_VOLUME_READABLE) { - volume = mate_mixer_stream_control_get_volume(m_pControl); - } - - MateMixerDirection direction; - MateMixerStream *m_pStream = mate_mixer_stream_control_get_stream(m_pControl); - - direction = mate_mixer_stream_get_direction(m_pStream); - //设置输出滑动条的值 - int value = volume*100/65536.0 + 0.5; - if (direction == MATE_MIXER_DIRECTION_OUTPUT) { - SoundDeviceSet::instance()->setValue(value); - } -} - -void SoundDeviceSet::connected (MateMixerContext *context) -{ - - MateMixerStream *m_pOutputStream = mate_mixer_context_get_default_output_stream(context); - if(m_pOutputStream == NULL) - return; - - MateMixerStreamControl *control = mate_mixer_stream_get_default_control(m_pOutputStream); - - g_signal_connect ( G_OBJECT (control), - "notify::volume", - G_CALLBACK (onStreamControlVolumeNotify), - NULL); - - g_signal_connect (control, - "notify::mute", - G_CALLBACK (onStreamControlMuteNotify), - NULL); - - SoundDeviceSet::instance()->setDefaultVal(); -} - -void SoundDeviceSet::setDefaultVal() -{ - if(!context) - return ; - - MateMixerStream *m_pOutputStream = mate_mixer_context_get_default_output_stream(context); - if(m_pOutputStream == NULL) - return; - - MateMixerStreamControl *control = mate_mixer_stream_get_default_control(m_pOutputStream); - -// int volume = mate_mixer_stream_control_get_volume(control); -// int value = volume *100 /65536.0+0.5; - -// setValue(value); -} - -void SoundDeviceSet::on_context_state_notify (MateMixerContext *context,GParamSpec *pspec,gpointer point ) -{ - MateMixerState state; - - state = mate_mixer_context_get_state (context); - - switch (state) { - case MATE_MIXER_STATE_READY: - /* This state can be reached repeatedly if the context is connected - * to a sound server, the connection is dropped and then reestablished */ - connected (context); - break; - case MATE_MIXER_STATE_FAILED: - qDebug()<<"matemixser state failed"; - break; - default: - break; - } -} - -bool SoundDeviceSet::getIsMute(){ - if(!context) - return false; - - MateMixerState state; - state = mate_mixer_context_get_state (context); - if(state != MATE_MIXER_STATE_READY) - return false; - - MateMixerStream *m_pOutputStream = mate_mixer_context_get_default_output_stream(context); - if(m_pOutputStream == NULL) - return false; - - MateMixerStreamControl *control = mate_mixer_stream_get_default_control(m_pOutputStream); - - return mate_mixer_stream_control_get_mute(control); -} - -void SoundDeviceSet::setMute(bool val){ - if(!context) - return; - - MateMixerState state; - state = mate_mixer_context_get_state (context); - if(state != MATE_MIXER_STATE_READY) - return; - - MateMixerStream *m_pOutputStream = mate_mixer_context_get_default_output_stream(context); - if(m_pOutputStream == NULL) - return; - - MateMixerStreamControl *control = mate_mixer_stream_get_default_control(m_pOutputStream); - - mate_mixer_stream_control_set_mute(control,val); -} - -bool SoundDeviceSet::getIsReady(){ - MateMixerState state; - state = mate_mixer_context_get_state (context); - return state == MATE_MIXER_STATE_READY; -} diff --git a/src/PhysicalDeviceSet/sounddeviceset.h b/src/PhysicalDeviceSet/sounddeviceset.h deleted file mode 100644 index 12701bd..0000000 --- a/src/PhysicalDeviceSet/sounddeviceset.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#ifndef SOUNDDEVICESET_H -#define SOUNDDEVICESET_H - -#include -#include -#include -#include -#include -#include - -class SoundDeviceSet : public QObject -{ - Q_OBJECT -public: - static SoundDeviceSet* instance(QObject *parent = nullptr); - void setMute(bool val); - bool getIsMute(); - void setDefaultVal(); - int getValue(){ return m_value; } - -Q_SIGNALS: - void muteChanged(bool mute); - // val from 0 to 100 change - void valueChanged(int val); - -public Q_SLOTS: - // val from 0 to 100 change - void setValue(int val); - -private: - SoundDeviceSet(QObject *parent = nullptr); - -private: - MateMixerContext *context; - - static void onStreamControlMuteNotify(MateMixerStreamControl *m_pControl,GParamSpec *pspec,gpointer point); - static void onStreamControlVolumeNotify(MateMixerStreamControl *m_pControl,GParamSpec *pspec,gpointer point); - static void on_context_state_notify (MateMixerContext *context,GParamSpec *pspec,gpointer point ); - static void connected (MateMixerContext *context); - void init(); - void emitSignal(bool val); - bool getIsReady(); - - static int m_value; // 当前的音量值 - -}; - -#endif // SOUNDDEVICESET_H diff --git a/src/PhysicalDeviceSet/touchscreenset.cpp b/src/PhysicalDeviceSet/touchscreenset.cpp deleted file mode 100644 index 9884078..0000000 --- a/src/PhysicalDeviceSet/touchscreenset.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#include "touchscreenset.h" - -#include - -TouchScreenSet* TouchScreenSet::instance(QObject *parent) -{ - static TouchScreenSet* _instance = nullptr; - QMutex mutex; - mutex.lock(); - if(!_instance) - _instance = new TouchScreenSet(parent); - mutex.unlock(); - return _instance; -} - -TouchScreenSet::TouchScreenSet(QObject *parent): - QObject(parent) -{ - init(); -} - -void TouchScreenSet::init() -{ - -} - -int TouchScreenSet::getTouchScreenID() -{ - -} diff --git a/src/PhysicalDeviceSet/touchscreenset.h b/src/PhysicalDeviceSet/touchscreenset.h deleted file mode 100644 index 096ce9e..0000000 --- a/src/PhysicalDeviceSet/touchscreenset.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#ifndef TOUCHSCREENSET_H -#define TOUCHSCREENSET_H - -#include - -class TouchScreenSet : public QObject -{ - Q_OBJECT -public: - TouchScreenSet *instance(QObject* parent = nullptr); - void init(); - int getTouchScreenID(); - -private: - TouchScreenSet(QObject *parent = nullptr); -}; - -#endif // TOUCHSCREENSET_H diff --git a/src/QtSingleApplication/QtLockedFile b/src/QtSingleApplication/QtLockedFile new file mode 100644 index 0000000..16b48ba --- /dev/null +++ b/src/QtSingleApplication/QtLockedFile @@ -0,0 +1 @@ +#include "qtlockedfile.h" diff --git a/src/QtSingleApplication/QtSingleApplication b/src/QtSingleApplication/QtSingleApplication new file mode 100644 index 0000000..d111bf7 --- /dev/null +++ b/src/QtSingleApplication/QtSingleApplication @@ -0,0 +1 @@ +#include "qtsingleapplication.h" diff --git a/src/QtSingleApplication/qtlocalpeer.cpp b/src/QtSingleApplication/qtlocalpeer.cpp new file mode 100644 index 0000000..f3c4546 --- /dev/null +++ b/src/QtSingleApplication/qtlocalpeer.cpp @@ -0,0 +1,213 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Solutions component. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include "qtlocalpeer.h" +#include +#include +#include + +#if defined(Q_OS_WIN) +#include +#include +typedef BOOL(WINAPI*PProcessIdToSessionId)(DWORD,DWORD*); +static PProcessIdToSessionId pProcessIdToSessionId = 0; +#endif +#if defined(Q_OS_UNIX) +#include +#include +#include +#endif + +namespace QtLP_Private { +#include "qtlockedfile.cpp" +#if defined(Q_OS_WIN) +#include "qtlockedfile_win.cpp" +#else +#include "qtlockedfile_unix.cpp" +#endif +} + +const char* QtLocalPeer::ack = "ack"; + +QtLocalPeer::QtLocalPeer(QObject* parent, const QString &appId) + : QObject(parent), id(appId) +{ + QString prefix = id; + if (id.isEmpty()) { + id = QCoreApplication::applicationFilePath(); +#if defined(Q_OS_WIN) + id = id.toLower(); +#endif + prefix = id.section(QLatin1Char('/'), -1); + } + prefix.remove(QRegExp("[^a-zA-Z]")); + prefix.truncate(6); + + QByteArray idc = id.toUtf8(); + quint16 idNum = qChecksum(idc.constData(), idc.size()); + socketName = QLatin1String("qtsingleapp-") + prefix + + QLatin1Char('-') + QString::number(idNum, 16); + +#if defined(Q_OS_WIN) + if (!pProcessIdToSessionId) { + QLibrary lib("kernel32"); + pProcessIdToSessionId = (PProcessIdToSessionId)lib.resolve("ProcessIdToSessionId"); + } + if (pProcessIdToSessionId) { + DWORD sessionId = 0; + pProcessIdToSessionId(GetCurrentProcessId(), &sessionId); + socketName += QLatin1Char('-') + QString::number(sessionId, 16); + } +#else + socketName += QLatin1Char('-') + QString::number(::getuid(), 16); +#endif + + server = new QLocalServer(this); + QString lockName = QDir(QDir::tempPath()).absolutePath() + + QLatin1Char('/') + socketName + + QLatin1String("-lockfile"); + lockFile.setFileName(lockName); + lockFile.open(QIODevice::ReadWrite); +} + + + +bool QtLocalPeer::isClient() +{ + if (lockFile.isLocked()) + return false; + + if (!lockFile.lock(QtLP_Private::QtLockedFile::WriteLock, false)) + return true; + + bool res = server->listen(socketName); +#if defined(Q_OS_UNIX) && (QT_VERSION >= QT_VERSION_CHECK(4,5,0)) + // ### Workaround + if (!res && server->serverError() == QAbstractSocket::AddressInUseError) { + QFile::remove(QDir::cleanPath(QDir::tempPath())+QLatin1Char('/')+socketName); + res = server->listen(socketName); + } +#endif + if (!res) + qWarning("QtSingleCoreApplication: listen on local socket failed, %s", qPrintable(server->errorString())); + QObject::connect(server, SIGNAL(newConnection()), SLOT(receiveConnection())); + return false; +} + + +bool QtLocalPeer::sendMessage(const QString &message, int timeout) +{ + if (!isClient()) + return false; + + QLocalSocket socket; + bool connOk = false; + for(int i = 0; i < 2; i++) { + // Try twice, in case the other instance is just starting up + socket.connectToServer(socketName); + connOk = socket.waitForConnected(timeout/2); + if (connOk || i) + break; + int ms = 250; +#if defined(Q_OS_WIN) + Sleep(DWORD(ms)); +#else + struct timespec ts = { ms / 1000, (ms % 1000) * 1000 * 1000 }; + nanosleep(&ts, NULL); +#endif + } + if (!connOk) + return false; + + QByteArray uMsg(message.toUtf8()); + QDataStream ds(&socket); + ds.writeBytes(uMsg.constData(), uMsg.size()); + bool res = socket.waitForBytesWritten(timeout); + if (res) { + res &= socket.waitForReadyRead(timeout); // wait for ack + if (res) + res &= (socket.read(qstrlen(ack)) == ack); + } + return res; +} + + +void QtLocalPeer::receiveConnection() +{ + QLocalSocket* socket = server->nextPendingConnection(); + if (!socket) + return; + + while (true) { + if (socket->state() == QLocalSocket::UnconnectedState) { + qWarning("QtLocalPeer: Peer disconnected"); + delete socket; + return; + } + if (socket->bytesAvailable() >= qint64(sizeof(quint32))) + break; + socket->waitForReadyRead(); + } + + QDataStream ds(socket); + QByteArray uMsg; + quint32 remaining; + ds >> remaining; + uMsg.resize(remaining); + int got = 0; + char* uMsgBuf = uMsg.data(); + do { + got = ds.readRawData(uMsgBuf, remaining); + remaining -= got; + uMsgBuf += got; + } while (remaining && got >= 0 && socket->waitForReadyRead(2000)); + if (got < 0) { + qWarning("QtLocalPeer: Message reception failed %s", socket->errorString().toLatin1().constData()); + delete socket; + return; + } + QString message(QString::fromUtf8(uMsg)); + socket->write(ack, qstrlen(ack)); + socket->waitForBytesWritten(1000); + socket->waitForDisconnected(1000); // make sure client reads ack + delete socket; + emit messageReceived(message); //### (might take a long time to return) +} diff --git a/src/QtSingleApplication/qtlocalpeer.h b/src/QtSingleApplication/qtlocalpeer.h new file mode 100644 index 0000000..1b533b1 --- /dev/null +++ b/src/QtSingleApplication/qtlocalpeer.h @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Solutions component. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QTLOCALPEER_H +#define QTLOCALPEER_H + +#include +#include +#include + +#include "qtlockedfile.h" + +class QtLocalPeer : public QObject +{ + Q_OBJECT + +public: + QtLocalPeer(QObject *parent = 0, const QString &appId = QString()); + bool isClient(); + bool sendMessage(const QString &message, int timeout); + QString applicationId() const + { return id; } + +Q_SIGNALS: + void messageReceived(const QString &message); + +protected Q_SLOTS: + void receiveConnection(); + +protected: + QString id; + QString socketName; + QLocalServer* server; + QtLP_Private::QtLockedFile lockFile; + +private: + static const char* ack; +}; + +#endif // QTLOCALPEER_H diff --git a/src/QtSingleApplication/qtlockedfile.cpp b/src/QtSingleApplication/qtlockedfile.cpp new file mode 100644 index 0000000..c142a86 --- /dev/null +++ b/src/QtSingleApplication/qtlockedfile.cpp @@ -0,0 +1,193 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Solutions component. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qtlockedfile.h" + +/*! + \class QtLockedFile + + \brief The QtLockedFile class extends QFile with advisory locking + functions. + + A file may be locked in read or write mode. Multiple instances of + \e QtLockedFile, created in multiple processes running on the same + machine, may have a file locked in read mode. Exactly one instance + may have it locked in write mode. A read and a write lock cannot + exist simultaneously on the same file. + + The file locks are advisory. This means that nothing prevents + another process from manipulating a locked file using QFile or + file system functions offered by the OS. Serialization is only + guaranteed if all processes that access the file use + QLockedFile. Also, while holding a lock on a file, a process + must not open the same file again (through any API), or locks + can be unexpectedly lost. + + The lock provided by an instance of \e QtLockedFile is released + whenever the program terminates. This is true even when the + program crashes and no destructors are called. +*/ + +/*! \enum QtLockedFile::LockMode + + This enum describes the available lock modes. + + \value ReadLock A read lock. + \value WriteLock A write lock. + \value NoLock Neither a read lock nor a write lock. +*/ + +/*! + Constructs an unlocked \e QtLockedFile object. This constructor + behaves in the same way as \e QFile::QFile(). + + \sa QFile::QFile() +*/ +QtLockedFile::QtLockedFile() + : QFile() +{ +#ifdef Q_OS_WIN + wmutex = 0; + rmutex = 0; +#endif + m_lock_mode = NoLock; +} + +/*! + Constructs an unlocked QtLockedFile object with file \a name. This + constructor behaves in the same way as \e QFile::QFile(const + QString&). + + \sa QFile::QFile() +*/ +QtLockedFile::QtLockedFile(const QString &name) + : QFile(name) +{ +#ifdef Q_OS_WIN + wmutex = 0; + rmutex = 0; +#endif + m_lock_mode = NoLock; +} + +/*! + Opens the file in OpenMode \a mode. + + This is identical to QFile::open(), with the one exception that the + Truncate mode flag is disallowed. Truncation would conflict with the + advisory file locking, since the file would be modified before the + write lock is obtained. If truncation is required, use resize(0) + after obtaining the write lock. + + Returns true if successful; otherwise false. + + \sa QFile::open(), QFile::resize() +*/ +bool QtLockedFile::open(OpenMode mode) +{ + if (mode & QIODevice::Truncate) { + qWarning("QtLockedFile::open(): Truncate mode not allowed."); + return false; + } + return QFile::open(mode); +} + +/*! + Returns \e true if this object has a in read or write lock; + otherwise returns \e false. + + \sa lockMode() +*/ +bool QtLockedFile::isLocked() const +{ + return m_lock_mode != NoLock; +} + +/*! + Returns the type of lock currently held by this object, or \e + QtLockedFile::NoLock. + + \sa isLocked() +*/ +QtLockedFile::LockMode QtLockedFile::lockMode() const +{ + return m_lock_mode; +} + +/*! + \fn bool QtLockedFile::lock(LockMode mode, bool block = true) + + Obtains a lock of type \a mode. The file must be opened before it + can be locked. + + If \a block is true, this function will block until the lock is + aquired. If \a block is false, this function returns \e false + immediately if the lock cannot be aquired. + + If this object already has a lock of type \a mode, this function + returns \e true immediately. If this object has a lock of a + different type than \a mode, the lock is first released and then a + new lock is obtained. + + This function returns \e true if, after it executes, the file is + locked by this object, and \e false otherwise. + + \sa unlock(), isLocked(), lockMode() +*/ + +/*! + \fn bool QtLockedFile::unlock() + + Releases a lock. + + If the object has no lock, this function returns immediately. + + This function returns \e true if, after it executes, the file is + not locked by this object, and \e false otherwise. + + \sa lock(), isLocked(), lockMode() +*/ + +/*! + \fn QtLockedFile::~QtLockedFile() + + Destroys the \e QtLockedFile object. If any locks were held, they + are released. +*/ diff --git a/src/QtSingleApplication/qtlockedfile.h b/src/QtSingleApplication/qtlockedfile.h new file mode 100644 index 0000000..84c18e5 --- /dev/null +++ b/src/QtSingleApplication/qtlockedfile.h @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Solutions component. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QTLOCKEDFILE_H +#define QTLOCKEDFILE_H + +#include +#ifdef Q_OS_WIN +#include +#endif + +#if defined(Q_OS_WIN) +# if !defined(QT_QTLOCKEDFILE_EXPORT) && !defined(QT_QTLOCKEDFILE_IMPORT) +# define QT_QTLOCKEDFILE_EXPORT +# elif defined(QT_QTLOCKEDFILE_IMPORT) +# if defined(QT_QTLOCKEDFILE_EXPORT) +# undef QT_QTLOCKEDFILE_EXPORT +# endif +# define QT_QTLOCKEDFILE_EXPORT __declspec(dllimport) +# elif defined(QT_QTLOCKEDFILE_EXPORT) +# undef QT_QTLOCKEDFILE_EXPORT +# define QT_QTLOCKEDFILE_EXPORT __declspec(dllexport) +# endif +#else +# define QT_QTLOCKEDFILE_EXPORT +#endif + +namespace QtLP_Private { + +class QT_QTLOCKEDFILE_EXPORT QtLockedFile : public QFile +{ +public: + enum LockMode { NoLock = 0, ReadLock, WriteLock }; + + QtLockedFile(); + QtLockedFile(const QString &name); + ~QtLockedFile(); + + bool open(OpenMode mode); + + bool lock(LockMode mode, bool block = true); + bool unlock(); + bool isLocked() const; + LockMode lockMode() const; + +private: +#ifdef Q_OS_WIN + Qt::HANDLE wmutex; + Qt::HANDLE rmutex; + QVector rmutexes; + QString mutexname; + + Qt::HANDLE getMutexHandle(int idx, bool doCreate); + bool waitMutex(Qt::HANDLE mutex, bool doBlock); + +#endif + LockMode m_lock_mode; +}; +} +#endif diff --git a/src/QtSingleApplication/qtlockedfile_unix.cpp b/src/QtSingleApplication/qtlockedfile_unix.cpp new file mode 100644 index 0000000..976c1b9 --- /dev/null +++ b/src/QtSingleApplication/qtlockedfile_unix.cpp @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Solutions component. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +#include "qtlockedfile.h" + +bool QtLockedFile::lock(LockMode mode, bool block) +{ + if (!isOpen()) { + qWarning("QtLockedFile::lock(): file is not opened"); + return false; + } + + if (mode == NoLock) + return unlock(); + + if (mode == m_lock_mode) + return true; + + if (m_lock_mode != NoLock) + unlock(); + + struct flock fl; + fl.l_whence = SEEK_SET; + fl.l_start = 0; + fl.l_len = 0; + fl.l_type = (mode == ReadLock) ? F_RDLCK : F_WRLCK; + int cmd = block ? F_SETLKW : F_SETLK; + int ret = fcntl(handle(), cmd, &fl); + + if (ret == -1) { + if (errno != EINTR && errno != EAGAIN) + qWarning("QtLockedFile::lock(): fcntl: %s", strerror(errno)); + return false; + } + + + m_lock_mode = mode; + return true; +} + + +bool QtLockedFile::unlock() +{ + if (!isOpen()) { + qWarning("QtLockedFile::unlock(): file is not opened"); + return false; + } + + if (!isLocked()) + return true; + + struct flock fl; + fl.l_whence = SEEK_SET; + fl.l_start = 0; + fl.l_len = 0; + fl.l_type = F_UNLCK; + int ret = fcntl(handle(), F_SETLKW, &fl); + + if (ret == -1) { + qWarning("QtLockedFile::lock(): fcntl: %s", strerror(errno)); + return false; + } + + m_lock_mode = NoLock; + return true; +} + +QtLockedFile::~QtLockedFile() +{ + if (isOpen()) + unlock(); +} + diff --git a/src/QtSingleApplication/qtlockedfile_win.cpp b/src/QtSingleApplication/qtlockedfile_win.cpp new file mode 100644 index 0000000..5e21262 --- /dev/null +++ b/src/QtSingleApplication/qtlockedfile_win.cpp @@ -0,0 +1,211 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Solutions component. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qtlockedfile.h" +#include +#include + +#define MUTEX_PREFIX "QtLockedFile mutex " +// Maximum number of concurrent read locks. Must not be greater than MAXIMUM_WAIT_OBJECTS +#define MAX_READERS MAXIMUM_WAIT_OBJECTS + +#if QT_VERSION >= 0x050000 +#define QT_WA(unicode, ansi) unicode +#endif + +Qt::HANDLE QtLockedFile::getMutexHandle(int idx, bool doCreate) +{ + if (mutexname.isEmpty()) { + QFileInfo fi(*this); + mutexname = QString::fromLatin1(MUTEX_PREFIX) + + fi.absoluteFilePath().toLower(); + } + QString mname(mutexname); + if (idx >= 0) + mname += QString::number(idx); + + Qt::HANDLE mutex; + if (doCreate) { + QT_WA( { mutex = CreateMutexW(NULL, FALSE, (TCHAR*)mname.utf16()); }, + { mutex = CreateMutexA(NULL, FALSE, mname.toLocal8Bit().constData()); } ); + if (!mutex) { + qErrnoWarning("QtLockedFile::lock(): CreateMutex failed"); + return 0; + } + } + else { + QT_WA( { mutex = OpenMutexW(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, (TCHAR*)mname.utf16()); }, + { mutex = OpenMutexA(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, mname.toLocal8Bit().constData()); } ); + if (!mutex) { + if (GetLastError() != ERROR_FILE_NOT_FOUND) + qErrnoWarning("QtLockedFile::lock(): OpenMutex failed"); + return 0; + } + } + return mutex; +} + +bool QtLockedFile::waitMutex(Qt::HANDLE mutex, bool doBlock) +{ + Q_ASSERT(mutex); + DWORD res = WaitForSingleObject(mutex, doBlock ? INFINITE : 0); + switch (res) { + case WAIT_OBJECT_0: + case WAIT_ABANDONED: + return true; + break; + case WAIT_TIMEOUT: + break; + default: + qErrnoWarning("QtLockedFile::lock(): WaitForSingleObject failed"); + } + return false; +} + + + +bool QtLockedFile::lock(LockMode mode, bool block) +{ + if (!isOpen()) { + qWarning("QtLockedFile::lock(): file is not opened"); + return false; + } + + if (mode == NoLock) + return unlock(); + + if (mode == m_lock_mode) + return true; + + if (m_lock_mode != NoLock) + unlock(); + + if (!wmutex && !(wmutex = getMutexHandle(-1, true))) + return false; + + if (!waitMutex(wmutex, block)) + return false; + + if (mode == ReadLock) { + int idx = 0; + for (; idx < MAX_READERS; idx++) { + rmutex = getMutexHandle(idx, false); + if (!rmutex || waitMutex(rmutex, false)) + break; + CloseHandle(rmutex); + } + bool ok = true; + if (idx >= MAX_READERS) { + qWarning("QtLockedFile::lock(): too many readers"); + rmutex = 0; + ok = false; + } + else if (!rmutex) { + rmutex = getMutexHandle(idx, true); + if (!rmutex || !waitMutex(rmutex, false)) + ok = false; + } + if (!ok && rmutex) { + CloseHandle(rmutex); + rmutex = 0; + } + ReleaseMutex(wmutex); + if (!ok) + return false; + } + else { + Q_ASSERT(rmutexes.isEmpty()); + for (int i = 0; i < MAX_READERS; i++) { + Qt::HANDLE mutex = getMutexHandle(i, false); + if (mutex) + rmutexes.append(mutex); + } + if (rmutexes.size()) { + DWORD res = WaitForMultipleObjects(rmutexes.size(), rmutexes.constData(), + TRUE, block ? INFINITE : 0); + if (res != WAIT_OBJECT_0 && res != WAIT_ABANDONED) { + if (res != WAIT_TIMEOUT) + qErrnoWarning("QtLockedFile::lock(): WaitForMultipleObjects failed"); + m_lock_mode = WriteLock; // trick unlock() to clean up - semiyucky + unlock(); + return false; + } + } + } + + m_lock_mode = mode; + return true; +} + +bool QtLockedFile::unlock() +{ + if (!isOpen()) { + qWarning("QtLockedFile::unlock(): file is not opened"); + return false; + } + + if (!isLocked()) + return true; + + if (m_lock_mode == ReadLock) { + ReleaseMutex(rmutex); + CloseHandle(rmutex); + rmutex = 0; + } + else { + foreach(Qt::HANDLE mutex, rmutexes) { + ReleaseMutex(mutex); + CloseHandle(mutex); + } + rmutexes.clear(); + ReleaseMutex(wmutex); + } + + m_lock_mode = QtLockedFile::NoLock; + return true; +} + +QtLockedFile::~QtLockedFile() +{ + if (isOpen()) + unlock(); + if (wmutex) + CloseHandle(wmutex); +} diff --git a/src/QtSingleApplication/qtsingleapplication.cpp b/src/QtSingleApplication/qtsingleapplication.cpp new file mode 100644 index 0000000..bc2943a --- /dev/null +++ b/src/QtSingleApplication/qtsingleapplication.cpp @@ -0,0 +1,348 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Solutions component. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include "qtsingleapplication.h" +#include "qtlocalpeer.h" +#include + + +/*! + \class QtSingleApplication qtsingleapplication.h + \brief The QtSingleApplication class provides an API to detect and + communicate with running instances of an application. + + This class allows you to create applications where only one + instance should be running at a time. I.e., if the user tries to + launch another instance, the already running instance will be + activated instead. Another usecase is a client-server system, + where the first started instance will assume the role of server, + and the later instances will act as clients of that server. + + By default, the full path of the executable file is used to + determine whether two processes are instances of the same + application. You can also provide an explicit identifier string + that will be compared instead. + + The application should create the QtSingleApplication object early + in the startup phase, and call isRunning() to find out if another + instance of this application is already running. If isRunning() + returns false, it means that no other instance is running, and + this instance has assumed the role as the running instance. In + this case, the application should continue with the initialization + of the application user interface before entering the event loop + with exec(), as normal. + + The messageReceived() signal will be emitted when the running + application receives messages from another instance of the same + application. When a message is received it might be helpful to the + user to raise the application so that it becomes visible. To + facilitate this, QtSingleApplication provides the + setActivationWindow() function and the activateWindow() slot. + + If isRunning() returns true, another instance is already + running. It may be alerted to the fact that another instance has + started by using the sendMessage() function. Also data such as + startup parameters (e.g. the name of the file the user wanted this + new instance to open) can be passed to the running instance with + this function. Then, the application should terminate (or enter + client mode). + + If isRunning() returns true, but sendMessage() fails, that is an + indication that the running instance is frozen. + + Here's an example that shows how to convert an existing + application to use QtSingleApplication. It is very simple and does + not make use of all QtSingleApplication's functionality (see the + examples for that). + + \code + // Original + int main(int argc, char **argv) + { + QApplication app(argc, argv); + + MyMainWidget mmw; + mmw.show(); + return app.exec(); + } + + // Single instance + int main(int argc, char **argv) + { + QtSingleApplication app(argc, argv); + + if (app.isRunning()) + return !app.sendMessage(someDataString); + + MyMainWidget mmw; + app.setActivationWindow(&mmw); + mmw.show(); + return app.exec(); + } + \endcode + + Once this QtSingleApplication instance is destroyed (normally when + the process exits or crashes), when the user next attempts to run the + application this instance will not, of course, be encountered. The + next instance to call isRunning() or sendMessage() will assume the + role as the new running instance. + + For console (non-GUI) applications, QtSingleCoreApplication may be + used instead of this class, to avoid the dependency on the QtGui + library. + + \sa QtSingleCoreApplication +*/ + + +void QtSingleApplication::sysInit(const QString &appId) +{ + actWin = 0; + peer = new QtLocalPeer(this, appId); + connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&))); +} + + +/*! + Creates a QtSingleApplication object. The application identifier + will be QCoreApplication::applicationFilePath(). \a argc, \a + argv, and \a GUIenabled are passed on to the QAppliation constructor. + + If you are creating a console application (i.e. setting \a + GUIenabled to false), you may consider using + QtSingleCoreApplication instead. +*/ + +QtSingleApplication::QtSingleApplication(int &argc, char **argv, bool GUIenabled) + : QApplication(argc, argv, GUIenabled) +{ + sysInit(); +} + + +/*! + Creates a QtSingleApplication object with the application + identifier \a appId. \a argc and \a argv are passed on to the + QAppliation constructor. +*/ + +QtSingleApplication::QtSingleApplication(const QString &appId, int &argc, char **argv) + : QApplication(argc, argv) +{ + sysInit(appId); +} + +#if QT_VERSION < 0x050000 + +/*! + Creates a QtSingleApplication object. The application identifier + will be QCoreApplication::applicationFilePath(). \a argc, \a + argv, and \a type are passed on to the QAppliation constructor. +*/ +QtSingleApplication::QtSingleApplication(int &argc, char **argv, Type type) + : QApplication(argc, argv, type) +{ + sysInit(); +} + + +# if defined(Q_WS_X11) +/*! + Special constructor for X11, ref. the documentation of + QApplication's corresponding constructor. The application identifier + will be QCoreApplication::applicationFilePath(). \a dpy, \a visual, + and \a cmap are passed on to the QApplication constructor. +*/ +QtSingleApplication::QtSingleApplication(Display* dpy, Qt::HANDLE visual, Qt::HANDLE cmap) + : QApplication(dpy, visual, cmap) +{ + sysInit(); +} + +/*! + Special constructor for X11, ref. the documentation of + QApplication's corresponding constructor. The application identifier + will be QCoreApplication::applicationFilePath(). \a dpy, \a argc, \a + argv, \a visual, and \a cmap are passed on to the QApplication + constructor. +*/ +QtSingleApplication::QtSingleApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual, Qt::HANDLE cmap) + : QApplication(dpy, argc, argv, visual, cmap) +{ + sysInit(); +} + +/*! + Special constructor for X11, ref. the documentation of + QApplication's corresponding constructor. The application identifier + will be \a appId. \a dpy, \a argc, \a + argv, \a visual, and \a cmap are passed on to the QApplication + constructor. +*/ +QtSingleApplication::QtSingleApplication(Display* dpy, const QString &appId, int argc, char **argv, Qt::HANDLE visual, Qt::HANDLE cmap) + : QApplication(dpy, argc, argv, visual, cmap) +{ + sysInit(appId); +} +# endif // Q_WS_X11 +#endif // QT_VERSION < 0x050000 + + +/*! + Returns true if another instance of this application is running; + otherwise false. + + This function does not find instances of this application that are + being run by a different user (on Windows: that are running in + another session). + + \sa sendMessage() +*/ + +bool QtSingleApplication::isRunning() +{ + return peer->isClient(); +} + + +/*! + Tries to send the text \a message to the currently running + instance. The QtSingleApplication object in the running instance + will emit the messageReceived() signal when it receives the + message. + + This function returns true if the message has been sent to, and + processed by, the current instance. If there is no instance + currently running, or if the running instance fails to process the + message within \a timeout milliseconds, this function return false. + + \sa isRunning(), messageReceived() +*/ +bool QtSingleApplication::sendMessage(const QString &message, int timeout) +{ + return peer->sendMessage(message, timeout); +} + + +/*! + Returns the application identifier. Two processes with the same + identifier will be regarded as instances of the same application. +*/ +QString QtSingleApplication::id() const +{ + return peer->applicationId(); +} + + +/*! + Sets the activation window of this application to \a aw. The + activation window is the widget that will be activated by + activateWindow(). This is typically the application's main window. + + If \a activateOnMessage is true (the default), the window will be + activated automatically every time a message is received, just prior + to the messageReceived() signal being emitted. + + \sa activateWindow(), messageReceived() +*/ + +void QtSingleApplication::setActivationWindow(QWidget* aw, bool activateOnMessage) +{ + actWin = aw; + if (activateOnMessage) + connect(peer, SIGNAL(messageReceived(const QString&)), this, SLOT(activateWindow())); + else + disconnect(peer, SIGNAL(messageReceived(const QString&)), this, SLOT(activateWindow())); +} + + +/*! + Returns the applications activation window if one has been set by + calling setActivationWindow(), otherwise returns 0. + + \sa setActivationWindow() +*/ +QWidget* QtSingleApplication::activationWindow() const +{ + return actWin; +} + + +/*! + De-minimizes, raises, and activates this application's activation window. + This function does nothing if no activation window has been set. + + This is a convenience function to show the user that this + application instance has been activated when he has tried to start + another instance. + + This function should typically be called in response to the + messageReceived() signal. By default, that will happen + automatically, if an activation window has been set. + + \sa setActivationWindow(), messageReceived(), initialize() +*/ +void QtSingleApplication::activateWindow() +{ + if (actWin) { + actWin->setWindowState(actWin->windowState() & ~Qt::WindowMinimized); + actWin->raise(); + actWin->showNormal(); + actWin->activateWindow(); + } +} + + +/*! + \fn void QtSingleApplication::messageReceived(const QString& message) + + This signal is emitted when the current instance receives a \a + message from another instance of this application. + + \sa sendMessage(), setActivationWindow(), activateWindow() +*/ + + +/*! + \fn void QtSingleApplication::initialize(bool dummy = true) + + \obsolete +*/ diff --git a/src/QtSingleApplication/qtsingleapplication.h b/src/QtSingleApplication/qtsingleapplication.h new file mode 100644 index 0000000..049406f --- /dev/null +++ b/src/QtSingleApplication/qtsingleapplication.h @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Solutions component. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QTSINGLEAPPLICATION_H +#define QTSINGLEAPPLICATION_H + +#include + +class QtLocalPeer; + +#if defined(Q_OS_WIN) +# if !defined(QT_QTSINGLEAPPLICATION_EXPORT) && !defined(QT_QTSINGLEAPPLICATION_IMPORT) +# define QT_QTSINGLEAPPLICATION_EXPORT +# elif defined(QT_QTSINGLEAPPLICATION_IMPORT) +# if defined(QT_QTSINGLEAPPLICATION_EXPORT) +# undef QT_QTSINGLEAPPLICATION_EXPORT +# endif +# define QT_QTSINGLEAPPLICATION_EXPORT __declspec(dllimport) +# elif defined(QT_QTSINGLEAPPLICATION_EXPORT) +# undef QT_QTSINGLEAPPLICATION_EXPORT +# define QT_QTSINGLEAPPLICATION_EXPORT __declspec(dllexport) +# endif +#else +# define QT_QTSINGLEAPPLICATION_EXPORT +#endif + +class QT_QTSINGLEAPPLICATION_EXPORT QtSingleApplication : public QApplication +{ + Q_OBJECT + +public: + QtSingleApplication(int &argc, char **argv, bool GUIenabled = true); + QtSingleApplication(const QString &id, int &argc, char **argv); +#if QT_VERSION < 0x050000 + QtSingleApplication(int &argc, char **argv, Type type); +# if defined(Q_WS_X11) + QtSingleApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0); + QtSingleApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0); + QtSingleApplication(Display* dpy, const QString &appId, int argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0); +# endif // Q_WS_X11 +#endif // QT_VERSION < 0x050000 + + bool isRunning(); + QString id() const; + + void setActivationWindow(QWidget* aw, bool activateOnMessage = true); + QWidget* activationWindow() const; + + // Obsolete: + void initialize(bool dummy = true) + { isRunning(); Q_UNUSED(dummy) } + +public Q_SLOTS: + bool sendMessage(const QString &message, int timeout = 5000); + void activateWindow(); + + +Q_SIGNALS: + void messageReceived(const QString &message); + + +private: + void sysInit(const QString &appId = QString()); + QtLocalPeer *peer; + QWidget *actWin; +}; + +#endif // QTSINGLEAPPLICATION_H diff --git a/src/QtSingleApplication/qtsingleapplication.pri b/src/QtSingleApplication/qtsingleapplication.pri new file mode 100644 index 0000000..1d85285 --- /dev/null +++ b/src/QtSingleApplication/qtsingleapplication.pri @@ -0,0 +1,16 @@ +INCLUDEPATH += $$PWD +DEPENDPATH += $$PWD +QT *= network +greaterThan(QT_MAJOR_VERSION, 4): QT *= widgets + +qtsingleapplication-uselib:!qtsingleapplication-buildlib { + LIBS += -L$$QTSINGLEAPPLICATION_LIBDIR -l$$QTSINGLEAPPLICATION_LIBNAME +} else { + SOURCES += $$PWD/qtsingleapplication.cpp $$PWD/qtlocalpeer.cpp + HEADERS += $$PWD/qtsingleapplication.h $$PWD/qtlocalpeer.h +} + +win32 { + contains(TEMPLATE, lib):contains(CONFIG, shared):DEFINES += QT_QTSINGLEAPPLICATION_EXPORT + else:qtsingleapplication-uselib:DEFINES += QT_QTSINGLEAPPLICATION_IMPORT +} diff --git a/src/QtSingleApplication/qtsinglecoreapplication.cpp b/src/QtSingleApplication/qtsinglecoreapplication.cpp new file mode 100644 index 0000000..5634537 --- /dev/null +++ b/src/QtSingleApplication/qtsinglecoreapplication.cpp @@ -0,0 +1,149 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Solutions component. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include "qtsinglecoreapplication.h" +#include "qtlocalpeer.h" + +/*! + \class QtSingleCoreApplication qtsinglecoreapplication.h + \brief A variant of the QtSingleApplication class for non-GUI applications. + + This class is a variant of QtSingleApplication suited for use in + console (non-GUI) applications. It is an extension of + QCoreApplication (instead of QApplication). It does not require + the QtGui library. + + The API and usage is identical to QtSingleApplication, except that + functions relating to the "activation window" are not present, for + obvious reasons. Please refer to the QtSingleApplication + documentation for explanation of the usage. + + A QtSingleCoreApplication instance can communicate to a + QtSingleApplication instance if they share the same application + id. Hence, this class can be used to create a light-weight + command-line tool that sends commands to a GUI application. + + \sa QtSingleApplication +*/ + +/*! + Creates a QtSingleCoreApplication object. The application identifier + will be QCoreApplication::applicationFilePath(). \a argc and \a + argv are passed on to the QCoreAppliation constructor. +*/ + +QtSingleCoreApplication::QtSingleCoreApplication(int &argc, char **argv) + : QCoreApplication(argc, argv) +{ + peer = new QtLocalPeer(this); + connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&))); +} + + +/*! + Creates a QtSingleCoreApplication object with the application + identifier \a appId. \a argc and \a argv are passed on to the + QCoreAppliation constructor. +*/ +QtSingleCoreApplication::QtSingleCoreApplication(const QString &appId, int &argc, char **argv) + : QCoreApplication(argc, argv) +{ + peer = new QtLocalPeer(this, appId); + connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&))); +} + + +/*! + Returns true if another instance of this application is running; + otherwise false. + + This function does not find instances of this application that are + being run by a different user (on Windows: that are running in + another session). + + \sa sendMessage() +*/ + +bool QtSingleCoreApplication::isRunning() +{ + return peer->isClient(); +} + + +/*! + Tries to send the text \a message to the currently running + instance. The QtSingleCoreApplication object in the running instance + will emit the messageReceived() signal when it receives the + message. + + This function returns true if the message has been sent to, and + processed by, the current instance. If there is no instance + currently running, or if the running instance fails to process the + message within \a timeout milliseconds, this function return false. + + \sa isRunning(), messageReceived() +*/ + +bool QtSingleCoreApplication::sendMessage(const QString &message, int timeout) +{ + return peer->sendMessage(message, timeout); +} + + +/*! + Returns the application identifier. Two processes with the same + identifier will be regarded as instances of the same application. +*/ + +QString QtSingleCoreApplication::id() const +{ + return peer->applicationId(); +} + + +/*! + \fn void QtSingleCoreApplication::messageReceived(const QString& message) + + This signal is emitted when the current instance receives a \a + message from another instance of this application. + + \sa sendMessage() +*/ diff --git a/src/QtSingleApplication/qtsinglecoreapplication.h b/src/QtSingleApplication/qtsinglecoreapplication.h new file mode 100644 index 0000000..b87fffe --- /dev/null +++ b/src/QtSingleApplication/qtsinglecoreapplication.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Solutions component. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QTSINGLECOREAPPLICATION_H +#define QTSINGLECOREAPPLICATION_H + +#include + +class QtLocalPeer; + +class QtSingleCoreApplication : public QCoreApplication +{ + Q_OBJECT + +public: + QtSingleCoreApplication(int &argc, char **argv); + QtSingleCoreApplication(const QString &id, int &argc, char **argv); + + bool isRunning(); + QString id() const; + +public Q_SLOTS: + bool sendMessage(const QString &message, int timeout = 5000); + + +Q_SIGNALS: + void messageReceived(const QString &message); + + +private: + QtLocalPeer* peer; +}; + +#endif // QTSINGLECOREAPPLICATION_H diff --git a/src/QtSingleApplication/qtsinglecoreapplication.pri b/src/QtSingleApplication/qtsinglecoreapplication.pri new file mode 100644 index 0000000..d2d6cc3 --- /dev/null +++ b/src/QtSingleApplication/qtsinglecoreapplication.pri @@ -0,0 +1,10 @@ +INCLUDEPATH += $$PWD +DEPENDPATH += $$PWD +HEADERS += $$PWD/qtsinglecoreapplication.h $$PWD/qtlocalpeer.h +SOURCES += $$PWD/qtsinglecoreapplication.cpp $$PWD/qtlocalpeer.cpp + +QT *= network + +win32:contains(TEMPLATE, lib):contains(CONFIG, shared) { + DEFINES += QT_QTSINGLECOREAPPLICATION_EXPORT=__declspec(dllexport) +} diff --git a/VirtualKeyboard/CMakeLists.txt b/src/VirtualKeyboard/CMakeLists.txt similarity index 89% rename from VirtualKeyboard/CMakeLists.txt rename to src/VirtualKeyboard/CMakeLists.txt index aa1ddf2..a1469e1 100644 --- a/VirtualKeyboard/CMakeLists.txt +++ b/src/VirtualKeyboard/CMakeLists.txt @@ -4,8 +4,6 @@ set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTORCC ON) -include_directories(${PROJECT_SOURCE_DIR}/Common) - qt5_add_resources(VirtualKeyboard_SRC src/keyboard.qrc) @@ -14,7 +12,7 @@ qt5_wrap_cpp(VirtualKeyboard_SRC ) set(VirtualKeyboard_SRC - ${VirtualKeyboard_SRC} + ${VirtualKeyboard_SRC} src/charsmorewidget.cpp src/charswidget.cpp src/dragwidget.cpp @@ -33,4 +31,4 @@ include_directories( ) add_library(VirtualKeyboard STATIC ${VirtualKeyboard_SRC}) -target_link_libraries(VirtualKeyboard Qt5::Core Qt5::Widgets Qt5::X11Extras Common) +target_link_libraries(VirtualKeyboard Qt5::Core Qt5::Widgets Qt5::X11Extras KF5::WaylandClient) diff --git a/VirtualKeyboard/README.md b/src/VirtualKeyboard/README.md similarity index 100% rename from VirtualKeyboard/README.md rename to src/VirtualKeyboard/README.md diff --git a/VirtualKeyboard/VirtualKeyboard.pri b/src/VirtualKeyboard/VirtualKeyboard.pri similarity index 100% rename from VirtualKeyboard/VirtualKeyboard.pri rename to src/VirtualKeyboard/VirtualKeyboard.pri diff --git a/VirtualKeyboard/VirtualKeyboard.pro b/src/VirtualKeyboard/VirtualKeyboard.pro similarity index 100% rename from VirtualKeyboard/VirtualKeyboard.pro rename to src/VirtualKeyboard/VirtualKeyboard.pro diff --git a/VirtualKeyboard/src/charsmorewidget.cpp b/src/VirtualKeyboard/src/charsmorewidget.cpp similarity index 100% rename from VirtualKeyboard/src/charsmorewidget.cpp rename to src/VirtualKeyboard/src/charsmorewidget.cpp diff --git a/VirtualKeyboard/src/charsmorewidget.h b/src/VirtualKeyboard/src/charsmorewidget.h similarity index 100% rename from VirtualKeyboard/src/charsmorewidget.h rename to src/VirtualKeyboard/src/charsmorewidget.h diff --git a/VirtualKeyboard/src/charswidget.cpp b/src/VirtualKeyboard/src/charswidget.cpp similarity index 100% rename from VirtualKeyboard/src/charswidget.cpp rename to src/VirtualKeyboard/src/charswidget.cpp diff --git a/VirtualKeyboard/src/charswidget.h b/src/VirtualKeyboard/src/charswidget.h similarity index 100% rename from VirtualKeyboard/src/charswidget.h rename to src/VirtualKeyboard/src/charswidget.h diff --git a/VirtualKeyboard/src/commondef.h b/src/VirtualKeyboard/src/commondef.h similarity index 100% rename from VirtualKeyboard/src/commondef.h rename to src/VirtualKeyboard/src/commondef.h diff --git a/VirtualKeyboard/src/cursormonitor.cpp b/src/VirtualKeyboard/src/cursormonitor.cpp similarity index 100% rename from VirtualKeyboard/src/cursormonitor.cpp rename to src/VirtualKeyboard/src/cursormonitor.cpp diff --git a/VirtualKeyboard/src/dragwidget.cpp b/src/VirtualKeyboard/src/dragwidget.cpp similarity index 100% rename from VirtualKeyboard/src/dragwidget.cpp rename to src/VirtualKeyboard/src/dragwidget.cpp diff --git a/VirtualKeyboard/src/dragwidget.h b/src/VirtualKeyboard/src/dragwidget.h similarity index 100% rename from VirtualKeyboard/src/dragwidget.h rename to src/VirtualKeyboard/src/dragwidget.h diff --git a/VirtualKeyboard/src/fakekeyboard.h b/src/VirtualKeyboard/src/fakekeyboard.h similarity index 100% rename from VirtualKeyboard/src/fakekeyboard.h rename to src/VirtualKeyboard/src/fakekeyboard.h diff --git a/VirtualKeyboard/src/images/close.svg b/src/VirtualKeyboard/src/images/close.svg similarity index 100% rename from VirtualKeyboard/src/images/close.svg rename to src/VirtualKeyboard/src/images/close.svg diff --git a/VirtualKeyboard/src/images/delet.svg b/src/VirtualKeyboard/src/images/delet.svg similarity index 100% rename from VirtualKeyboard/src/images/delet.svg rename to src/VirtualKeyboard/src/images/delet.svg diff --git a/VirtualKeyboard/src/images/drag.svg b/src/VirtualKeyboard/src/images/drag.svg similarity index 100% rename from VirtualKeyboard/src/images/drag.svg rename to src/VirtualKeyboard/src/images/drag.svg diff --git a/VirtualKeyboard/src/images/enter.svg b/src/VirtualKeyboard/src/images/enter.svg similarity index 100% rename from VirtualKeyboard/src/images/enter.svg rename to src/VirtualKeyboard/src/images/enter.svg diff --git a/VirtualKeyboard/src/images/float-restore.svg b/src/VirtualKeyboard/src/images/float-restore.svg similarity index 100% rename from VirtualKeyboard/src/images/float-restore.svg rename to src/VirtualKeyboard/src/images/float-restore.svg diff --git a/VirtualKeyboard/src/images/float.svg b/src/VirtualKeyboard/src/images/float.svg similarity index 100% rename from VirtualKeyboard/src/images/float.svg rename to src/VirtualKeyboard/src/images/float.svg diff --git a/VirtualKeyboard/src/images/left.svg b/src/VirtualKeyboard/src/images/left.svg similarity index 100% rename from VirtualKeyboard/src/images/left.svg rename to src/VirtualKeyboard/src/images/left.svg diff --git a/VirtualKeyboard/src/images/rectangle.svg b/src/VirtualKeyboard/src/images/rectangle.svg similarity index 100% rename from VirtualKeyboard/src/images/rectangle.svg rename to src/VirtualKeyboard/src/images/rectangle.svg diff --git a/VirtualKeyboard/src/images/right.svg b/src/VirtualKeyboard/src/images/right.svg similarity index 100% rename from VirtualKeyboard/src/images/right.svg rename to src/VirtualKeyboard/src/images/right.svg diff --git a/VirtualKeyboard/src/images/shift.svg b/src/VirtualKeyboard/src/images/shift.svg similarity index 100% rename from VirtualKeyboard/src/images/shift.svg rename to src/VirtualKeyboard/src/images/shift.svg diff --git a/VirtualKeyboard/src/images/shift_lock.svg b/src/VirtualKeyboard/src/images/shift_lock.svg similarity index 100% rename from VirtualKeyboard/src/images/shift_lock.svg rename to src/VirtualKeyboard/src/images/shift_lock.svg diff --git a/VirtualKeyboard/src/images/space.svg b/src/VirtualKeyboard/src/images/space.svg similarity index 100% rename from VirtualKeyboard/src/images/space.svg rename to src/VirtualKeyboard/src/images/space.svg diff --git a/VirtualKeyboard/src/images/unlock.svg b/src/VirtualKeyboard/src/images/unlock.svg similarity index 100% rename from VirtualKeyboard/src/images/unlock.svg rename to src/VirtualKeyboard/src/images/unlock.svg diff --git a/VirtualKeyboard/src/kbbutton.cpp b/src/VirtualKeyboard/src/kbbutton.cpp similarity index 100% rename from VirtualKeyboard/src/kbbutton.cpp rename to src/VirtualKeyboard/src/kbbutton.cpp diff --git a/VirtualKeyboard/src/kbbutton.h b/src/VirtualKeyboard/src/kbbutton.h similarity index 100% rename from VirtualKeyboard/src/kbbutton.h rename to src/VirtualKeyboard/src/kbbutton.h diff --git a/VirtualKeyboard/src/kbtitle.cpp b/src/VirtualKeyboard/src/kbtitle.cpp similarity index 96% rename from VirtualKeyboard/src/kbtitle.cpp rename to src/VirtualKeyboard/src/kbtitle.cpp index f5aa6b7..509ebed 100644 --- a/VirtualKeyboard/src/kbtitle.cpp +++ b/src/VirtualKeyboard/src/kbtitle.cpp @@ -37,8 +37,8 @@ KBTitle::~KBTitle() void KBTitle::initUI() { setFixedHeight(KEYBOARD_TITLE_DEFAULT_HEIGHT); - QString strBtnStyle = "QPushButton{ text-align:center; color: rgba(255, 255, 255, 255); border: none; border-radius: 4px; outline: none;}" - "QPushButton:hover{ background-color: rgba(255,255,255,15%); }" + QString strBtnStyle = "QPushButton{ text-align:center; color: rgb(255, 255, 255, 255); border: none; border-radius: 4px; outline: none;}" + "QPushButton:hover{ background-color: rgb(255,255,255,15%); }" "QPushButton::pressed { background-color: rgba(255,255,255,40%); }" "QPushButton::checked { background-color: rgba(255,255,255,40%); }"; diff --git a/VirtualKeyboard/src/kbtitle.h b/src/VirtualKeyboard/src/kbtitle.h similarity index 100% rename from VirtualKeyboard/src/kbtitle.h rename to src/VirtualKeyboard/src/kbtitle.h diff --git a/VirtualKeyboard/src/keyboard.qrc b/src/VirtualKeyboard/src/keyboard.qrc similarity index 100% rename from VirtualKeyboard/src/keyboard.qrc rename to src/VirtualKeyboard/src/keyboard.qrc diff --git a/VirtualKeyboard/src/letterswidget.cpp b/src/VirtualKeyboard/src/letterswidget.cpp similarity index 99% rename from VirtualKeyboard/src/letterswidget.cpp rename to src/VirtualKeyboard/src/letterswidget.cpp index 8a8c6cc..e5caabb 100644 --- a/VirtualKeyboard/src/letterswidget.cpp +++ b/src/VirtualKeyboard/src/letterswidget.cpp @@ -18,11 +18,13 @@ #include "letterswidget.h" #include "commondef.h" #include "plasma-shell-manager.h" -#include "commonfunc.h" +#include "utils.h" #include #include #include +extern bool checkCapsLockState(); + LettersWidget::LettersWidget(QWidget *parent/* = nullptr*/) : QWidget(parent) { diff --git a/VirtualKeyboard/src/letterswidget.h b/src/VirtualKeyboard/src/letterswidget.h similarity index 100% rename from VirtualKeyboard/src/letterswidget.h rename to src/VirtualKeyboard/src/letterswidget.h diff --git a/VirtualKeyboard/src/main.cpp b/src/VirtualKeyboard/src/main.cpp similarity index 100% rename from VirtualKeyboard/src/main.cpp rename to src/VirtualKeyboard/src/main.cpp diff --git a/VirtualKeyboard/src/numberswidget.cpp b/src/VirtualKeyboard/src/numberswidget.cpp similarity index 100% rename from VirtualKeyboard/src/numberswidget.cpp rename to src/VirtualKeyboard/src/numberswidget.cpp diff --git a/VirtualKeyboard/src/numberswidget.h b/src/VirtualKeyboard/src/numberswidget.h similarity index 100% rename from VirtualKeyboard/src/numberswidget.h rename to src/VirtualKeyboard/src/numberswidget.h diff --git a/VirtualKeyboard/src/qtkeyboard.cpp b/src/VirtualKeyboard/src/qtkeyboard.cpp similarity index 100% rename from VirtualKeyboard/src/qtkeyboard.cpp rename to src/VirtualKeyboard/src/qtkeyboard.cpp diff --git a/VirtualKeyboard/src/qtkeyboard.h b/src/VirtualKeyboard/src/qtkeyboard.h similarity index 100% rename from VirtualKeyboard/src/qtkeyboard.h rename to src/VirtualKeyboard/src/qtkeyboard.h diff --git a/VirtualKeyboard/src/virtualkeyboardwidget.cpp b/src/VirtualKeyboard/src/virtualkeyboardwidget.cpp similarity index 100% rename from VirtualKeyboard/src/virtualkeyboardwidget.cpp rename to src/VirtualKeyboard/src/virtualkeyboardwidget.cpp diff --git a/VirtualKeyboard/src/virtualkeyboardwidget.h b/src/VirtualKeyboard/src/virtualkeyboardwidget.h similarity index 100% rename from VirtualKeyboard/src/virtualkeyboardwidget.h rename to src/VirtualKeyboard/src/virtualkeyboardwidget.h diff --git a/VirtualKeyboard/src/x11keyboard.cpp b/src/VirtualKeyboard/src/x11keyboard.cpp similarity index 100% rename from VirtualKeyboard/src/x11keyboard.cpp rename to src/VirtualKeyboard/src/x11keyboard.cpp diff --git a/VirtualKeyboard/src/x11keyboard.h b/src/VirtualKeyboard/src/x11keyboard.h similarity index 100% rename from VirtualKeyboard/src/x11keyboard.h rename to src/VirtualKeyboard/src/x11keyboard.h diff --git a/src/accountsinterface.cpp b/src/accountsinterface.cpp deleted file mode 100644 index 7bc8cbb..0000000 --- a/src/accountsinterface.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (C) 2019 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#include "accountsinterface.h" - -const QString STR_EDU_SERVICE = "cn.kylinos.SSOBackend"; -const QString STR_EDU_PATH = "/cn/kylinos/SSOBackend"; - -AccountsInterface* AccountsInterface::m_instance = nullptr; - -AccountsInterface::AccountsInterface(const QString &strService,const QString &strPath,\ - const QDBusConnection &connection, QObject *parent)\ - :QDBusAbstractInterface(strService,strPath,getInterfaceName(),connection,parent) -{ - -} - -AccountsInterface* AccountsInterface::getInstance() -{ - static QMutex mutex; - mutex.lock(); - if(m_instance == nullptr) - m_instance = new AccountsInterface(STR_EDU_SERVICE, STR_EDU_PATH, QDBusConnection::systemBus()); - mutex.unlock(); - return m_instance; -} - -DBusMsgCode AccountsInterface::SetAccountPincode(const QString &username, const QString &pincode) -{ - QDBusReply reply = call("SetAccountPincode", username, pincode); - if(!reply.isValid()) - { - qDebug() << "error: [AccountsInterface][SetAccountPincode]: DBus Connect Failed!"; - return DBusMsgCode::Error_NoReply; - } - if(reply.value() != 0) - { - qDebug() << "error: [AccountsInterface][SetAccountPincode]: DBus request failed!"; - //return static_cast(reply.value()); - return DBusMsgCode::Error_NoReply; - } - - return DBusMsgCode::No_Error; -} - -DBusMsgCode AccountsInterface::GetAccountPincode(const QString &username, QString &pincode) -{ - QDBusMessage message = call("GetAccountPincode", username); - if(QDBusMessage::ErrorMessage == message.type()) - { - qDebug() << "error: [AccountsInterface][GetAccountPincode]: DBus Connect Failed!"; - return DBusMsgCode::Error_NoReply; - } - QList argvs = message.arguments(); - if(argvs.size() != 2) - { - qDebug() << "error: [AccountsInterface][GetAccountPincode]: DBus arguments error!"; - return DBusMsgCode::Error_ArgCnt; - } - int state = argvs.at(1).value(); - if(state != 0) - { - qDebug() << "error: [AccountsInterface][GetAccountPincode]: DBus request failed!"; - //return static_cast(state); - return DBusMsgCode::Error_ArgCnt; - } - pincode = argvs.at(0).value(); - qDebug() << "pincode:" << pincode; - - return DBusMsgCode::No_Error; -} - -DBusMsgCode AccountsInterface::CheckUserIsNew(const QString &username, bool &isNewUser) -{ - QDBusReply reply = call("CheckUserIsNew", username); - if(!reply.isValid()) - { - qDebug() << "info: [AccountsInterface][CheckUserIsNew]: DBus connect failed!"; - return DBusMsgCode::Error_NoReply; - } - if(reply.value()) - { - qDebug() << "info: [AccountsInterface][CheckUserIsNew]: DBus request failed!"; - return DBusMsgCode::Error_UnknownReason; - } - - isNewUser = static_cast(reply.value()); - return DBusMsgCode::No_Error; -} - -DBusMsgCode AccountsInterface::GetUserPhone(const QString &username, QString &phonenum) -{ - QDBusMessage message = call("GetAccountBasicInfo", username); - if(QDBusMessage::ErrorMessage == message.type()) - { - qDebug() << "info: [AccountsInterface][GetUserPhone]: DBus Connect Failed!"; - return DBusMsgCode::Error_NoReply; - } - QList argvs = message.arguments(); - if(argvs.size() != 7) - { - qDebug() << "info: [AccountsInterface][GetUserPhone]: DBus arguments =" << argvs.size() << "error!"; - return DBusMsgCode::Error_ArgCnt; - } - int role = argvs.at(0).value(); Q_UNUSED(role); - QString school = argvs.at(1).value(); Q_UNUSED(school); - QString province = argvs.at(2).value(); Q_UNUSED(province); - QString city = argvs.at(3).value(); Q_UNUSED(city); - QString county = argvs.at(4).value(); Q_UNUSED(county); - phonenum = argvs.at(5).value(); - int state = argvs.at(6).value(); Q_UNUSED(state); - return state ? DBusMsgCode::Error_UnknownReason : DBusMsgCode::No_Error; -} diff --git a/src/accountsinterface.h b/src/accountsinterface.h deleted file mode 100644 index 2e1a0d5..0000000 --- a/src/accountsinterface.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#ifndef ACCOUNTSINTERFACE_H -#define ACCOUNTSINTERFACE_H - -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "common.h" - -class AccountsInterface: public QDBusAbstractInterface -{ - Q_OBJECT -public: - static inline const char* getInterfaceName() - {return "cn.kylinos.SSOBackend.accounts";} -public: - static AccountsInterface* getInstance(); - - AccountsInterface(const QString &strService,const QString &strPath,\ - const QDBusConnection &connection, QObject *parent = 0); - - DBusMsgCode SetAccountPincode(const QString &username, const QString &pincode); - - DBusMsgCode GetAccountPincode(const QString &username, QString &pincode); - - // 检查用户是不是新用户 - DBusMsgCode CheckUserIsNew(const QString &username, bool &isNewUser); - // 获得用户的手机号 - DBusMsgCode GetUserPhone(const QString &username, QString &phone); -private: - static AccountsInterface *m_instance; -}; - -#endif // ACCOUNTSINTERFACE_H diff --git a/src/agreementinfo.cpp b/src/agreementinfo.cpp new file mode 100644 index 0000000..09da6ed --- /dev/null +++ b/src/agreementinfo.cpp @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * +**/ +#include "agreementinfo.h" + +AgreementInfo::AgreementInfo(QObject *parent) + : QObject(parent) + , m_showLoginPrompt(false) + , m_hideTitle(false) + , m_promptTitle("") + , m_promptText("") + , m_promptTextFilePath("") +{ +} + +AgreementInfo::AgreementInfo(const AgreementInfo &agreementInfo) + : QObject(agreementInfo.parent()) + , m_showLoginPrompt(agreementInfo.m_showLoginPrompt) + , m_hideTitle(agreementInfo.m_hideTitle) + , m_promptTitle(agreementInfo.m_promptTitle) + , m_promptText(agreementInfo.m_promptText) + , m_promptTextFilePath(agreementInfo.m_promptTextFilePath) +{ + +} + +AgreementInfo::~AgreementInfo() +{ + +} + +bool AgreementInfo::operator==(const AgreementInfo &agreementInfo) const +{ + return ( agreementInfo.showLoginPrompt() == m_showLoginPrompt + && agreementInfo.hideTitle() == m_hideTitle + && agreementInfo.promptTitle() == m_promptTitle + && agreementInfo.promptText() == m_promptText + && agreementInfo.promptTextFilePath() == m_promptTextFilePath); +} + +void AgreementInfo::updateShowLoginPrompt(const bool &showLoginPrompt) +{ + m_showLoginPrompt = showLoginPrompt; +} + +void AgreementInfo::updateHideTitle(const bool &hideTitle) +{ + m_hideTitle = hideTitle; +} + +void AgreementInfo::updatePromptTitle(const QString &promptTitle) +{ + m_promptTitle = promptTitle; +} + +void AgreementInfo::updatePromptText(const QString &promptText) +{ + m_promptText = promptText; +} + +void AgreementInfo::updatePromptTextFilePath(const QString &promptTextFilePath) +{ + m_promptTextFilePath = promptTextFilePath; +} + +QDebug operator <<(QDebug stream, const AgreementInfo &agreementInfo) +{ + stream << "[" + << agreementInfo.showLoginPrompt() + << agreementInfo.hideTitle() + << agreementInfo.promptTitle() + << agreementInfo.promptText() + << agreementInfo.promptTextFilePath() + << "]"; + return stream; +} diff --git a/src/agreementinfo.h b/src/agreementinfo.h new file mode 100644 index 0000000..36c7d96 --- /dev/null +++ b/src/agreementinfo.h @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * +**/ +#ifndef AGREEMENTINFO_H +#define AGREEMENTINFO_H + +#include +#include +#include + +class AgreementInfo : public QObject +{ + Q_OBJECT +public: + explicit AgreementInfo(QObject *parent = nullptr); + explicit AgreementInfo(const AgreementInfo &agreementInfo); + virtual ~AgreementInfo(); + + bool operator==(const AgreementInfo &agreementInfo) const; + +public: + inline bool showLoginPrompt() const { return m_showLoginPrompt; } + inline bool hideTitle() const { return m_hideTitle; } + inline QString promptTitle() const { return m_promptTitle; } + inline QString promptText() const { return m_promptText; } + inline QString promptTextFilePath() const { return m_promptTextFilePath; } + + void updateShowLoginPrompt(const bool &showLoginPrompt); + void updateHideTitle(const bool &hideTitle); + void updatePromptTitle(const QString &promptTitle); + void updatePromptText(const QString &promptText); + void updatePromptTextFilePath(const QString &promptTextFilePath); + +protected: + bool m_showLoginPrompt; //是否显示特别提示界面 + bool m_hideTitle; //是否隐藏标题 + QString m_promptTitle; //特别提示标题 + QString m_promptText; //特别提示文本 + QString m_promptTextFilePath; //特别提示文本路径 +}; + +typedef std::shared_ptr AgreementInfoPtr; + +QDebug operator <<(QDebug stream, const AgreementInfo &agreementInfo); + +#endif // USERINFO_H diff --git a/src/agreementwindow.cpp b/src/agreementwindow.cpp deleted file mode 100644 index 8a63c6e..0000000 --- a/src/agreementwindow.cpp +++ /dev/null @@ -1,140 +0,0 @@ -#include "agreementwindow.h" -#include -#include -#include -#include -#include - -#define CONFIG_FILE "/usr/share/ukui-greeter/ukui-greeter.conf" - -AgreementWindow::AgreementWindow(QWidget *parent) : - QWidget(parent) -{ - init(); -} - -bool AgreementWindow::getShowLoginPrompt() -{ - return showLoginPrompt; -} - -void AgreementWindow::initUI() -{ - centerWidget = new QWidget(this); - centerWidget->setObjectName("centerWidget"); - // centerWidget->setFixedSize(960,744); - centerWidget->setStyleSheet("#centerWidget{background-color: rgba(0,0,0,15%);border-radius: 12px;}"); - - QVBoxLayout *layout = new QVBoxLayout(centerWidget); - - - ensureBtn = new QPushButton(this); - ensureBtn->setText(tr("I know")); - ensureBtn->setObjectName("ensureBtn"); - ensureBtn->setFixedSize(240,48); - ensureBtn->setDefault(true); - ensureBtn->setFocusPolicy(Qt::StrongFocus); - ensureBtn->setStyleSheet("#ensureBtn{background-color:rgba(55, 144, 250, 1);border-radius: 6px;}"); - ensureBtn->setStyleSheet("QPushButton{text-align:center;background-color:#3790FA;border-radius: 6px;color:white} \ - QPushButton::hover{background-color:#3489EE;} \ - QPushButton::pressed {background-color:#2C73C8;}"); - connect(ensureBtn, &QPushButton::clicked, this, &AgreementWindow::switchPage); - - titleLbl = new QLabel(centerWidget); - titleLbl->setText(promptTitle); - titleLbl->setObjectName("titleLbl"); - titleLbl->setStyleSheet("#titleLbl{color: white;font-size: 24px;}"); - - browser = new QTextBrowser(centerWidget); - browser->setObjectName("browser"); - browser->setAttribute(Qt::WA_TranslucentBackground); - browser->setStyleSheet("#browser{background-color:transparent;border-radius: none;color: white;font-size: 16px;}"); - browser->verticalScrollBar()->setProperty("drawScrollBarGroove", false); - browser->setContextMenuPolicy(Qt::NoContextMenu); - browser->verticalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu); - - setFocusProxy(ensureBtn); - - bool res = loadText(); - if(!res || (promptTitle.isEmpty() && !hideTitle)){ - emit switchToGreeter(); - } - - layout->addSpacing(24); - layout->addWidget(titleLbl); - layout->addWidget(browser); - layout->setAlignment(ensureBtn,Qt::AlignCenter); - layout->setAlignment(titleLbl,Qt::AlignCenter); - - if(hideTitle) - titleLbl->hide(); -} - -void AgreementWindow::switchPage() -{ - emit switchToGreeter(); -} - -void AgreementWindow::resizeEvent(QResizeEvent *event) -{ - // qDebug()<<"" - int m_width = 960,m_height = 722 - 88; - if(this->width() < (960+80)) - m_width = (width() - 80)/2; - if(this->height() < (722+80)) - m_height = (height() - 80)/2; - - centerWidget->setGeometry((width()-m_width)/2,(height()-m_height)/2,m_width,m_height); - - ensureBtn->move((width()-ensureBtn->width())/2,centerWidget->geometry().bottom() + 40); - -} - -bool AgreementWindow::loadText() -{ - if(!promptText.isEmpty()){ - browser->setText(promptText); - return true; - } - - if(promptTextFilePath.isEmpty()) - return false; - QFile file(promptTextFilePath); - if(!file.exists()) - return false; - file.open(QFile::ReadOnly); - QString str(file.readAll()); - if(str == "") - return false; - browser->setText(str); - file.close(); - return true; - -} - -void AgreementWindow::init() -{ - QSettings *settings = new QSettings(CONFIG_FILE,QSettings::IniFormat); - settings->setIniCodec(QTextCodec::codecForName("utf-8")); - - if(settings->contains("Greeter/showLoginPrompt")){ - showLoginPrompt = settings->value("Greeter/showLoginPrompt").toBool(); - } - - if(settings->contains("Greeter/hideTitle")){ - hideTitle = settings->value("Greeter/hideTitle").toBool(); - } - - if(settings->contains("Greeter/promptTitle")){ - promptTitle = settings->value("Greeter/promptTitle").toString(); - } - - if(settings->contains("Greeter/promptText")){ - promptText = settings->value("Greeter/promptText").toString(); - } - - if(settings->contains("Greeter/promptTextFilePath")){ - promptTextFilePath = settings->value("Greeter/promptTextFilePath").toString(); - } - -} diff --git a/src/agreementwindow.h b/src/agreementwindow.h deleted file mode 100644 index 4dca358..0000000 --- a/src/agreementwindow.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef AGREEMENTWINDOW_H -#define AGREEMENTWINDOW_H - -#include -#include -#include -#include -#include - -class AgreementWindow : public QWidget -{ - Q_OBJECT -public: - explicit AgreementWindow(QWidget *parent = nullptr); - bool getShowLoginPrompt(); - void initUI(); - -signals: - void switchToGreeter(); - -protected: - void resizeEvent(QResizeEvent *event); - -protected Q_SLOTS: - void switchPage(); - -private: - void init(); - bool loadText(); - - QTextBrowser *browser = nullptr; - QLabel *titleLbl = nullptr; - QPushButton *ensureBtn = nullptr; - - QFile *file = nullptr; - - bool showLoginPrompt = false; - bool hideTitle = true; - - QString promptTitle = ""; - QString promptText = ""; - QString promptTextFilePath = ""; - - QWidget *centerWidget = nullptr; - -}; - -#endif // AGREEMENTWINDOW_H diff --git a/src/assets/badges/budgie_badge.svg b/src/assets/badges/budgie_badge.svg new file mode 100644 index 0000000..bbf3424 --- /dev/null +++ b/src/assets/badges/budgie_badge.svg @@ -0,0 +1 @@ +budgie_badge \ No newline at end of file diff --git a/src/assets/badges/gnome_badge.svg b/src/assets/badges/gnome_badge.svg new file mode 100644 index 0000000..0c9092b --- /dev/null +++ b/src/assets/badges/gnome_badge.svg @@ -0,0 +1 @@ +gnome_badge \ No newline at end of file diff --git a/src/assets/badges/kde_badge.svg b/src/assets/badges/kde_badge.svg new file mode 100644 index 0000000..c099e42 --- /dev/null +++ b/src/assets/badges/kde_badge.svg @@ -0,0 +1 @@ +kde_badge \ No newline at end of file diff --git a/src/assets/badges/lubuntu_badge.svg b/src/assets/badges/lubuntu_badge.svg new file mode 100644 index 0000000..6ff3a92 --- /dev/null +++ b/src/assets/badges/lubuntu_badge.svg @@ -0,0 +1 @@ +lubuntu_badge \ No newline at end of file diff --git a/src/assets/badges/mate_badge.svg b/src/assets/badges/mate_badge.svg new file mode 100644 index 0000000..0d0e80e --- /dev/null +++ b/src/assets/badges/mate_badge.svg @@ -0,0 +1 @@ +mate_badge \ No newline at end of file diff --git a/src/assets/badges/pantheon_badge.svg b/src/assets/badges/pantheon_badge.svg new file mode 100644 index 0000000..7448dc2 --- /dev/null +++ b/src/assets/badges/pantheon_badge.svg @@ -0,0 +1 @@ +pantheon_badge \ No newline at end of file diff --git a/src/assets/badges/plasma_badge.svg b/src/assets/badges/plasma_badge.svg new file mode 100644 index 0000000..72b10cc --- /dev/null +++ b/src/assets/badges/plasma_badge.svg @@ -0,0 +1,17 @@ + + + +画板 1 + + + + + + + + + + diff --git a/src/assets/badges/ubuntu_badge.svg b/src/assets/badges/ubuntu_badge.svg new file mode 100644 index 0000000..21b17af --- /dev/null +++ b/src/assets/badges/ubuntu_badge.svg @@ -0,0 +1 @@ +ubuntu_badge \ No newline at end of file diff --git a/src/assets/badges/ukui_badge.svg b/src/assets/badges/ukui_badge.svg new file mode 100644 index 0000000..f56f080 --- /dev/null +++ b/src/assets/badges/ukui_badge.svg @@ -0,0 +1 @@ +ukui_badge \ No newline at end of file diff --git a/src/assets/badges/ukui_wayland_badge.svg b/src/assets/badges/ukui_wayland_badge.svg new file mode 100644 index 0000000..705e0fe --- /dev/null +++ b/src/assets/badges/ukui_wayland_badge.svg @@ -0,0 +1 @@ +ukui on wayland \ No newline at end of file diff --git a/src/assets/badges/unknown_badge.svg b/src/assets/badges/unknown_badge.svg new file mode 100644 index 0000000..0d6dc09 --- /dev/null +++ b/src/assets/badges/unknown_badge.svg @@ -0,0 +1,9 @@ + + + +画板 1 + + + + diff --git a/src/assets/badges/xfce_badge.svg b/src/assets/badges/xfce_badge.svg new file mode 100644 index 0000000..0f463b2 --- /dev/null +++ b/src/assets/badges/xfce_badge.svg @@ -0,0 +1 @@ +xfce_badge \ No newline at end of file diff --git a/src/assets/badges/xubuntu_badge.svg b/src/assets/badges/xubuntu_badge.svg new file mode 100644 index 0000000..a2032bb --- /dev/null +++ b/src/assets/badges/xubuntu_badge.svg @@ -0,0 +1 @@ +xubuntu_badge \ No newline at end of file diff --git a/src/assets/hibernate.svg b/src/assets/hibernate.svg index 6cfad35..c091d25 100644 --- a/src/assets/hibernate.svg +++ b/src/assets/hibernate.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/auth-pam.cpp b/src/auth-pam.cpp deleted file mode 100644 index aa01e1c..0000000 --- a/src/auth-pam.cpp +++ /dev/null @@ -1,352 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#include "auth-pam.h" - -#include - -#include -#include -#include -#define PAM_SERVICE_NAME "ukui-screensaver-qt" - -//通信管道的文件描述符 -int toParent[2], toChild[2]; -void sigchld_handler(int signo); -static void writeData(int fd, const void *buf, ssize_t count); -static void writeString(int fd, const char *data); -static int readData(int fd, void *buf, size_t count); -static char * readString(int fd); -static int pam_conversation(int msgLength, const struct pam_message **msg, - PAM_RESPONSE **resp, void *appData); -void sigchld_handler(int signo); -AuthPAM::AuthPAM(QObject *parent) - : Auth(parent), - pid(0), - nPrompts(0), - _isAuthenticated(false), - _isAuthenticating(false) -{ -// signal(SIGCHLD, sigchld_handler); -} - -void AuthPAM::authenticate(const QString &userName) -{ - stopAuth(); - - if(pipe(toParent) || pipe(toChild)) - qDebug()<< "create pipe failed: " << strerror(errno); - if((pid = fork()) < 0) - { - qDebug() << "fork error: " << strerror(errno); - } - else if(pid == 0) - { - prctl(PR_SET_PDEATHSIG, SIGHUP); - close(toParent[0]); - close(toChild[1]); - int arg1_int = toParent[1]; - int arg2_int = toChild[0]; - char arg1[128]; - char arg2[128]; - sprintf(arg1,"%d",arg1_int); - sprintf(arg2,"%d",arg2_int); - execlp ("ukui-screensaver-checkpass", - "ukui-screensaver-checkpass", - arg1, arg2,userName.toLocal8Bit().data(), NULL); - _exit (EXIT_FAILURE); - } - else - { - close(toParent[1]); - close(toChild[0]); - _isAuthenticating = true; - notifier = new QSocketNotifier(toParent[0], QSocketNotifier::Read); - connect(notifier, &QSocketNotifier::activated, this, &AuthPAM::onSockRead); - } -} - -void AuthPAM::stopAuth() -{ - if(pid != 0) - { - messageList.clear(); - responseList.clear(); - _isAuthenticating = false; - _isAuthenticated = false; - nPrompts = 0; - ::kill(pid, SIGKILL); - - close(toParent[0]); - close(toChild[1]); - if(notifier){ - notifier->deleteLater(); - notifier = nullptr; - } - pid = 0; - } -} - -void AuthPAM::respond(const QString &response) -{ - nPrompts--; - responseList.push_back(response); - -// for(auto msg : messageList) -// qDebug() << msg.msg; -// qDebug() << responseList; -// qDebug() << nPrompts; - - if(nPrompts == 0) - { - //发送响应到子进程 - int j = 0; - PAM_RESPONSE *resp = (PAM_RESPONSE*)calloc(messageList.size(), sizeof(PAM_RESPONSE)); - //响应的数量和消息的数量一致,如果消息类型不是PROMPT,则响应是空的 - for(int i = 0; i < messageList.size(); i++) - { - struct pam_message message = messageList[i]; - PAM_RESPONSE *r = &resp[i]; - if(message.msg_style == PAM_PROMPT_ECHO_OFF - || message.msg_style == PAM_PROMPT_ECHO_ON) - { - int respLength = responseList[j].length() + 1; - r->resp = (char *)malloc(sizeof(char) * respLength); - memcpy(r->resp, responseList[j].toLocal8Bit().data(), respLength); - j++; - } - } - _respond(resp); - free(resp); - messageList.clear(); - responseList.clear(); - } -} - -bool AuthPAM::isAuthenticated() -{ - return _isAuthenticated; -} - -bool AuthPAM::isAuthenticating() -{ - return _isAuthenticating; -} - - -void AuthPAM::onSockRead() -{ -// qDebug() << "has message"; - int msgLength; - int authComplete = 0; - readData(toParent[0], &authComplete, sizeof(authComplete)); - - if(authComplete) - { - int authRet = -1; - if(readData(toParent[0], (void*)&authRet, sizeof(authRet)) <= 0) - qDebug() << "get authentication result failed: " << strerror(errno); - qDebug() << "result: " << authRet; - _isAuthenticated = (authRet == PAM_SUCCESS); - _isAuthenticating = false; - if(notifier){ - notifier->deleteLater(); - notifier = nullptr; - } - Q_EMIT authenticateComplete(); - - } - else - { - readData(toParent[0], &msgLength, sizeof(msgLength)); -// qDebug() << "message length: " << msgLength; - - for(int i = 0; i < msgLength; i++) - { - //读取message - struct pam_message message; - readData(toParent[0], &message.msg_style, sizeof(message.msg_style)); - message.msg = readString(toParent[0]); - - qDebug() << message.msg; - - messageList.push_back(message); - - switch (message.msg_style) - { - case PAM_PROMPT_ECHO_OFF: - nPrompts++; - Q_EMIT showPrompt(message.msg, Auth::PromptTypeSecret); - break; - case PAM_PROMPT_ECHO_ON: - nPrompts++; - Q_EMIT showPrompt(message.msg, Auth::PromptTypeQuestion); - break; - case PAM_ERROR_MSG: - Q_EMIT showMessage(message.msg, Auth::MessageTypeInfo); - break; - case PAM_TEXT_INFO: - Q_EMIT showMessage(message.msg, Auth::MessageTypeError); - break; - } - } - - if(nPrompts == 0) - { - //不需要响应,发送一个空的 - PAM_RESPONSE *response = (PAM_RESPONSE*)calloc(messageList.size(), sizeof(PAM_RESPONSE)); - _respond(response); - free(response); - messageList.clear(); - } - } -} - -static void -writeData(int fd, const void *buf, ssize_t count) -{ - if(write(fd, buf, count) != count) - qDebug() << "write to parent failed: " << strerror(errno); -} - -static void -writeString(int fd, const char *data) -{ - int length = data ? strlen(data) : -1; - writeData(fd, &length, sizeof(length)); - if(data) - writeData(fd, data, sizeof(char) * length); -} - -static int -readData(int fd, void *buf, size_t count) -{ - ssize_t nRead = read(fd, buf, count); - if(nRead < 0) - qDebug() << "read data failed: " << strerror(errno); - return nRead; -} - -static char * -readString(int fd) -{ - int length; - - if(readData(fd, &length, sizeof(length)) <= 0) - return NULL; - if(length <= 0) - length = 0; - - char *value = (char *)malloc(sizeof(char) * (length + 1)); - readData(fd, value, length); - value[length] = '\0'; - - return value; -} - -void AuthPAM::_authenticate(const char *userName) -{ - qDebug() << "authenticate " << userName; - - pam_handle_t *pamh = NULL; - char *newUser; - int ret; - int authRet; - struct pam_conv conv; - - conv.conv = pam_conversation; - conv.appdata_ptr = NULL; - - ret = pam_start(PAM_SERVICE_NAME, userName, &conv, &pamh); - if(ret != PAM_SUCCESS) - { - qDebug() << "failed to start PAM: " << pam_strerror(NULL, ret); - } - - authRet = pam_authenticate(pamh, 0); - - ret = pam_get_item(pamh, PAM_USER, (const void **)&newUser); - if(ret != PAM_SUCCESS) - { - pam_end(pamh, 0); - qDebug() << "failed to get username"; - } - if(authRet == PAM_SUCCESS) - ret = pam_acct_mgmt(pamh, 0); - - if(ret != PAM_SUCCESS) - { - qDebug() << "failed to acct mgmt " << pam_strerror(NULL, ret); - } - - free(newUser); - fprintf(stderr, "authentication result: %d\n", authRet); - - // 发送认证结果 - int authComplete = 1; - writeData(toParent[1], (const void*)&authComplete, sizeof(authComplete)); - writeData(toParent[1], (const void *)&authRet, sizeof(authRet)); - qDebug() << "--- 认证完成"; - _exit(EXIT_SUCCESS); -} - -void AuthPAM::_respond(const PAM_RESPONSE *response) -{ - for(int i = 0; i < messageList.size(); i++) - { - const PAM_RESPONSE *resp = &response[i]; - writeData(toChild[1], (const void *)&resp->resp_retcode, - sizeof(resp->resp_retcode)); - writeString(toChild[1], resp->resp); - } -} - - -static int -pam_conversation(int msgLength, const struct pam_message **msg, - PAM_RESPONSE **resp, void */*appData*/) -{ - PAM_RESPONSE *response = (PAM_RESPONSE*)calloc(msgLength,sizeof(PAM_RESPONSE)); - - int authComplete = 0; - writeData(toParent[1], (const void*)&authComplete, sizeof(authComplete)); - writeData(toParent[1], (const void*)&msgLength, sizeof(msgLength)); - //发送pam消息 - for(int i = 0; i < msgLength; i++) - { - const struct pam_message *m = msg[i]; - writeData(toParent[1], (const void *)&m->msg_style, sizeof(m->msg_style)); - writeString(toParent[1], m->msg); - } - //读取响应 - for(int i = 0; i < msgLength; i++) - { - PAM_RESPONSE *r = &response[i]; - readData(toChild[0], &r->resp_retcode, sizeof(r->resp_retcode)); - r->resp = readString(toChild[0]); - } - *resp = response; - return PAM_SUCCESS; -} - -void sigchld_handler(int signo) -{ - if(signo == SIGCHLD) - { - ::waitpid(-1, NULL, WNOHANG); - } -} diff --git a/src/auth-pam.h b/src/auth-pam.h deleted file mode 100644 index 3fba36c..0000000 --- a/src/auth-pam.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#ifndef AUTHPAM_H -#define AUTHPAM_H -#include "auth.h" -#include -#include - -#include - -typedef struct pam_message PAM_MESSAGE; -typedef struct pam_response PAM_RESPONSE; - -class AuthPAM : public Auth -{ - Q_OBJECT -public: - AuthPAM(QObject *parent = nullptr); - - void authenticate(const QString &userName); - void stopAuth(); - void respond(const QString &response); - bool isAuthenticated(); - bool isAuthenticating(); - -private: - void _authenticate(const char *userName); - void _respond(const struct pam_response *response); - -private Q_SLOTS: - void onSockRead(); - -private: - QString userName; - pid_t pid; - QSocketNotifier *notifier; - int nPrompts; - QStringList responseList; - QList messageList; - bool _isAuthenticated; //认证结果 - bool _isAuthenticating; -}; - -#endif // AUTHPAM_H diff --git a/src/auth.h b/src/auth.h deleted file mode 100644 index b2f8193..0000000 --- a/src/auth.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#ifndef AUTH_H -#define AUTH_H - -#ifndef QT_NO_KEYWORDS -#define QT_NO_KEYWORDS -#endif - -#include - -class Auth : public QObject -{ - Q_OBJECT - - Q_ENUMS(PromptType MessageType) -public: - explicit Auth(QObject *parent = nullptr) - : QObject(parent) - { - - } - - enum PromptType { - PromptTypeQuestion, - PromptTypeSecret - }; - enum MessageType { - MessageTypeInfo, - MessageTypeError - }; - - -Q_SIGNALS: - void showPrompt(const QString &prompt, Auth::PromptType type); - void showMessage(const QString &message, Auth::MessageType type); - void authenticateComplete(); - -public: - virtual void authenticate(const QString &userName) = 0; - virtual void stopAuth() = 0; - virtual void respond(const QString &response) = 0; - virtual bool isAuthenticating() = 0; - virtual bool isAuthenticated() = 0; -}; - -#endif // AUTH_H diff --git a/src/authdialog.cpp b/src/authdialog.cpp deleted file mode 100644 index 937212c..0000000 --- a/src/authdialog.cpp +++ /dev/null @@ -1,1852 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#include "authdialog.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "users.h" -#include "iconedit.h" -#include "configuration.h" -#include "biometricproxy.h" -#include "pam-tally.h" -#include "commonfunc.h" -#include "loginoptionswidget.h" -#include "servicemanager.h" -#include "uniauthservice.h" -#include "imageutil.h" -#include "klabel.h" -#include "loginauthinterface.h" - -AuthDialog::AuthDialog(const UserItem &user, QWidget *parent) : - QWidget(parent), - user(user), - auth(new AuthPAM(this)), - configuration(Configuration::instance()), - authMode(UNKNOWN), - m_biometricProxy(nullptr), - m_widgetLoginOpts(nullptr), - m_buttonsWidget(nullptr), - m_retryButton(nullptr), - isBioPassed(false), - m_bioTimer(nullptr), - m_timer(nullptr), - isLockingFlg(false), - m_nCurLockMin(0), - w_timer(nullptr), - m_uniauthService(new UniAuthService(this)) -{ - setObjectName("AuthDialog"); - - QFile qssFile(":/qss/assets/authdialog.qss"); - if(qssFile.open(QIODevice::ReadOnly)) { - this->setStyleSheet(qssFile.readAll()); - } - curFontSize = configuration->getFontSize(); - m_ptToPx = configuration->getPtToPx(); - initUI(); - pam_tally_init(); //这里写函数声明 - - connect(auth, &Auth::showMessage, this, &AuthDialog::onShowMessage); - connect(auth, &Auth::showPrompt, this, &AuthDialog::onShowPrompt); - connect(auth, &Auth::authenticateComplete, this, &AuthDialog::onAuthComplete); - ServiceManager *sm = ServiceManager::instance(); - connect(sm, &ServiceManager::serviceStatusChanged, - this, &AuthDialog::onBiometricDbusChanged); - - m_failedTimes.clear(); - - connect(m_messageButton, &QPushButton::clicked, - this, &AuthDialog::onMessageButtonClicked); - -} - -void AuthDialog::startAuth() -{ - prompted = false; - unacknowledged_messages = false; - auth->authenticate(user.name); - - m_passwordEdit->clear(); - m_passwordEdit->readOnly(true); -} - -void AuthDialog::stopAuth() -{ - if(m_widgetLoginOpts) - { - if(m_bioTimer && m_bioTimer->isActive()) - m_bioTimer->stop(); - m_widgetLoginOpts->stopAuth(); - - m_widgetLoginOpts->hide(); - } - - clearMessage(); - // auth->stopAuth(); - // m_passwordEdit->readOnly(true); -// if(m_passwdWidget) -// m_passwdWidget->hide(); -} - -void AuthDialog::initUI() -{ - if (scale < 0.5) { - setFixedWidth(360); - } else { - setFixedWidth(600); - } - - m_userWidget = new QWidget(this); - m_userWidget->setObjectName(QStringLiteral("userWidget")); - - /* 头像 */ - const QString SheetStyle = QString("border-radius: %1px; border:0px solid white;").arg((int)(77*scale)); - m_labelHeadImg = new QLabel(m_userWidget); - m_labelHeadImg->setObjectName(QStringLiteral("faceLabel")); - m_labelHeadImg->setFocusPolicy(Qt::NoFocus); - m_labelHeadImg->setStyleSheet(SheetStyle); - m_labelHeadImg->setAlignment(Qt::AlignCenter); - m_labelHeadImg->hide(); - - QPixmap facePixmap = makeRoundLogo(user.icon, 154*scale, 154*scale, 77*scale); - m_labelHeadImg->setAlignment(Qt::AlignCenter); - m_labelHeadImg->setPixmap(facePixmap); - - // 人脸识别 - m_labelFace = new QLabel(m_userWidget); - m_labelFace->setObjectName("faceLabel"); - m_labelFace->setAlignment(Qt::AlignCenter); - m_labelFace->hide(); - - // 二维码窗口 - m_labelLoginTypeTip = new KLabel(m_userWidget); - m_labelLoginTypeTip->setFontSize(14); - m_labelLoginTypeTip->setObjectName("loginTypeTipLabel"); - m_labelLoginTypeTip->setAlignment(Qt::AlignCenter); - m_labelQRCode = new QLabel(m_userWidget); - m_labelQRCode->setObjectName("qrCodeLabel"); - m_labelQRCode->setAlignment(Qt::AlignCenter); - m_labelQRCode->hide(); - QVBoxLayout *layoutQRCode = new QVBoxLayout(); - layoutQRCode->setAlignment(Qt::AlignCenter); - layoutQRCode->setSpacing(10); - m_labelQRCode->setLayout(layoutQRCode); - m_labelQRCodeTip = new QLabel(); - m_labelQRCodeTip->setFixedSize(22,22); - layoutQRCode->addWidget(m_labelQRCodeTip, 0, Qt::AlignHCenter); - m_labelQRCodeMsg = new KLabel(); - m_labelQRCodeMsg->setFixedHeight(30); - m_labelQRCodeMsg->setFontSize(14); - m_labelQRCodeMsg->setStyleSheet("QLabel{background-color:rgba(255,255,255,0);color:rgb(255,0,0)}"); - layoutQRCode->addWidget(m_labelQRCodeMsg, 0, Qt::AlignHCenter); - - /* 用户名 */ - m_nameLabel = new KLabel(m_userWidget); - m_nameLabel->setObjectName(QStringLiteral("login_nameLabel")); - m_nameLabel->setFocusPolicy(Qt::NoFocus); - m_nameLabel->setAlignment(Qt::AlignCenter); - m_nameLabel->setFontSize(24); - //m_nameLabel->setText(user.realName.isEmpty() ? user.name : user.realName); - QString text = user.realName.isEmpty() ? user.name : user.realName; - m_nameLabel->setElideText(text, 380); - - /* 密码框所在窗口 */ - m_passwdWidget = new QWidget(this); - m_passwdWidget->setObjectName(QStringLiteral("passwordWidget")); - - /* 密码框 */ - m_passwordEdit = new IconEdit(m_passwdWidget); - connect(m_passwordEdit,&IconEdit::clickedPassword, - this,&AuthDialog::onM_passwordEditClicked); - - m_passwdWidget->setInputMethodHints(Qt::ImhNone); - m_passwordEdit->setObjectName(QStringLiteral("passwordEdit")); - QPixmap iconLogin = QIcon::fromTheme("system-lock-screen-symbolic").pixmap(16,16); - iconLogin = ImageUtil::drawSymbolicColoredPixmap(iconLogin, "white"); - m_passwordEdit->setIcon(iconLogin); - //m_passwordEdit->setFocusPolicy(Qt::StrongFocus); - m_passwordEdit->installEventFilter(this); - m_passwordEdit->readOnly(true); - /*免密登录时,会出现闪一下密码框的问题,因此初始化时隐藏,收到pam发来的prompt类型的消息后再显示*/ - m_passwordEdit->hide(); - m_passwordEdit->setType(QLineEdit::Password); - //setFocusProxy(m_passwordEdit); - connect(m_passwordEdit, SIGNAL(clicked(const QString&)), - this, SLOT(onRespond(const QString&))); - - //m_passwdWidget->hide(); - - /* 密码认证信息显示列表 */ - m_messageLabel = new KLabel(m_passwdWidget); - m_messageLabel->setObjectName(QStringLiteral("messageLabel")); - m_messageLabel->setAlignment(Qt::AlignLeft); - m_messageLabel->setFontSize(14); - - /* ukey密码框所在窗口 */ - m_ukeyPasswdWidget = new QWidget(this); - m_ukeyPasswdWidget->setObjectName(QStringLiteral("passwordWidget")); - - /* 密码框 */ - m_ukeyPasswordEdit = new IconEdit(m_ukeyPasswdWidget); - connect(m_ukeyPasswordEdit,&IconEdit::clickedPassword, - this,&AuthDialog::onM_passwordEditClicked); - - m_ukeyPasswdWidget->setInputMethodHints(Qt::ImhNone); - m_ukeyPasswordEdit->setObjectName(QStringLiteral("passwordEdit")); - m_ukeyPasswordEdit->setIcon(QIcon::fromTheme("system-lock-screen-symbolic")); - //m_ukeyPasswordEdit->setFocusPolicy(Qt::StrongFocus); - m_ukeyPasswordEdit->installEventFilter(this); - m_ukeyPasswordEdit->setType(QLineEdit::Password); - m_ukeyPasswordEdit->setPrompt(tr("Enter the ukey password")); - m_ukeyPasswordEdit->setModeBtnVisible(false); - connect(m_ukeyPasswordEdit, SIGNAL(clicked(const QString&)), - this, SLOT(onRespondUkey(const QString&))); - - /* 密码认证信息显示列表 */ - m_ukeyMessageLabel = new KLabel(m_ukeyPasswdWidget); - m_ukeyMessageLabel->setObjectName(QStringLiteral("messageLabel")); - m_ukeyMessageLabel->setAlignment(Qt::AlignLeft); - m_ukeyMessageLabel->setFontSize(14); - m_ukeyMessageLabel->setStyleSheet("QToolTip{border-radius:4px;background-color:#FFFFFF;color:black;font-size:16px}"); - - m_ukeyPasswdWidget->hide(); - - m_loadingWidget = new QWidget(m_ukeyPasswdWidget); - m_loadingText = new KLabel(m_loadingWidget); - m_loadingText->setFontSize(18); - m_loadingText->setText(tr("Insert the ukey into the USB port")); - m_loadingButton = new QPushButton(m_loadingWidget); - m_loadingButton->setAttribute(Qt::WA_TransparentForMouseEvents, true); - m_loadingButton->setFlat(true); - m_loadingButton->installEventFilter(this); - m_loadingButton->setStyleSheet("QPushButton{text-align:center;color: rgb(255, 255, 255, 255);border: none;border-radius: 4px;outline: none;}"); - - m_loadingWidget->adjustSize(); - - QVBoxLayout *loadingLayout= new QVBoxLayout(m_loadingWidget); - loadingLayout->addWidget(m_loadingButton); - loadingLayout->addWidget(m_loadingText); - startLoadingUkey(); - - m_messageButton = new QPushButton(m_passwdWidget); - m_messageButton->setObjectName(QStringLiteral("messageButton")); - QFont font; - font = m_messageButton->font(); - font.setPointSize((14 + curFontSize) *m_ptToPx); - m_messageButton->setFont(font); - m_messageButton->hide(); - - m_customWidget = new QWidget(this); - m_layoutCustom = new QHBoxLayout(); - m_layoutCustom->setSpacing(0); - m_layoutCustom->setContentsMargins(0,0,0,0); - m_customWidget->setLayout(m_layoutCustom); - m_customWidget->hide(); -} - - -void AuthDialog::startLoadingUkey() -{ - //isLoadingUkey = true; - m_loadingWidget->show(); - m_ukeyPasswordEdit->hide(); - m_ukeyMessageLabel->hide(); - if(!m_loadingTimer) - { - m_loadingTimer = new QTimer(this); - m_loadingTimer->setInterval(150); - connect(m_loadingTimer, &QTimer::timeout, this, &AuthDialog::updateLoadingPixmap); - } - - QPixmap icon = QIcon::fromTheme("ukui-loading-0-symbolic").pixmap(27,27); - m_loadingPixmap = ImageUtil::drawSymbolicColoredPixmap(icon, "white"); - m_loadingButton->setIcon(m_loadingPixmap); - m_loadingButton->setIconSize(QSize(27, 27)); - m_loadingTimer->start(); -} - -void AuthDialog::stopLoadingUkey() -{ - isLoadingUkey = false; - m_loadingWidget->hide(); - m_ukeyPasswordEdit->show(); - m_ukeyMessageLabel->show(); - if(m_loadingTimer){ - m_loadingTimer->stop(); - } -} - -void AuthDialog::updateLoadingPixmap() -{ - QMatrix matrix; - matrix.rotate(90.0); - m_loadingPixmap = m_loadingPixmap.transformed(matrix, Qt::FastTransformation); - m_loadingButton->setIcon(QIcon(m_loadingPixmap)); -} - -bool AuthDialog::unlock_countdown() -{ - int failed_count = 0; - int time_left = 0; - int deny = 0; - int fail_time =0; - int unlock_time = 0; - pam_tally_unlock_time_left(user.uid, &failed_count, &time_left, &deny,&fail_time,&unlock_time); - - // qDebug() << "failed_count:" << failed_count << "time_left:" <= 60)//请多少分钟后重试 - { - int nMinuteleft = time_left/60; - if (isLockingFlg == false){ - m_nCurLockMin = unlock_time/60;//获取当前需要锁定的分钟数 - } - - //如果当前设置的不是1min钟锁定,那么1min显示成2min,由2min直接跳到59s || 剩余分钟数小于当前设置的锁定时间,并且大于1min,自增+1 - if ((nMinuteleft == 1 && m_nCurLockMin != 1) || (nMinuteleft > 1 && nMinuteleft < m_nCurLockMin)) - { - nMinuteleft = nMinuteleft + 1; - } - - m_messageLabel->setText(tr("Please try again in %1 minutes.").arg(nMinuteleft)); - m_messageLabel->setToolTip(tr("Please try again in %1 minutes.").arg(nMinuteleft)); - m_passwordEdit->clearText(); - m_passwordEdit->readOnly(true); - m_passwordEdit->setLocked(true); - isLockingFlg = true; - return true; - } - else if(time_left > 0 && time_left < 60)//请多少秒后重试 - { - m_messageLabel->setText(tr("Please try again in %1 seconds.").arg(time_left%60)); - m_messageLabel->setToolTip(tr("Please try again in %1 seconds.").arg(time_left%60)); - m_passwordEdit->clearText(); - m_passwordEdit->readOnly(true); - m_passwordEdit->setLocked(true); - isLockingFlg = true; - return true; - } - else if (failed_count == 0xFFFF)//账号被永久锁定 - { - m_messageLabel->setText(tr("Account locked permanently.")); - m_messageLabel->setToolTip(tr("Account locked permanently.")); - m_passwordEdit->clearText(); - m_passwordEdit->readOnly(true); - m_passwordEdit->setLocked(true); - isLockingFlg = true; - return true; - } - else - { - if(m_passwordEdit){ - m_passwordEdit->readOnly(false); - if (m_passwordEdit->isVisible()) { - m_passwordEdit->setFocus(); - } - } - if (isLockingFlg) - { - onShowMessage("",Auth::MessageTypeError); - isLockingFlg = false; - m_passwordEdit->setLocked(false); - } - if (m_timer) - m_timer->stop(); - } - return false; -} - -void AuthDialog::root_unlock_countdown() -{ - int failed_count = 0; - int time_left = 0; - int deny = 0; - int fail_time =0; - int unlock_time = 0; - pam_tally_root_unlock_time_left(&failed_count, &time_left, &deny,&fail_time,&unlock_time); - if(time_left >= 60)//请多少分钟后重试 - { - int nMinuteleft = time_left/60; - if (isLockingFlg == false){ - m_nCurLockMin = unlock_time/60;//获取当前需要锁定的分钟数 - } - - - //如果当前设置的不是1min钟锁定,那么1min显示成2min,由2min直接跳到59s || 剩余分钟数小于当前设置的锁定时间,并且大于1min,自增+1 - if ((nMinuteleft == 1 && m_nCurLockMin != 1) || (nMinuteleft > 1 && nMinuteleft < m_nCurLockMin)) - { - nMinuteleft = nMinuteleft + 1; - } - - m_messageLabel->setText(tr("Please try again in %1 minutes.").arg(nMinuteleft)); - m_messageLabel->setToolTip(tr("Please try again in %1 minutes.").arg(nMinuteleft)); - m_passwordEdit->clearText(); - m_passwordEdit->readOnly(true); - isLockingFlg = true; - return ; - } - else if(time_left > 0 && time_left < 60)//请多少秒后重试 - { - m_messageLabel->setText(tr("Please try again in %1 seconds.").arg(time_left%60)); - m_messageLabel->setToolTip(tr("Please try again in %1 seconds.").arg(time_left%60)); - m_passwordEdit->clearText(); - m_passwordEdit->readOnly(true); - isLockingFlg = true; - return ; - } - else if (failed_count == 0xFFFF)//账号被永久锁定 - { - m_messageLabel->setText(tr("Account locked permanently.")); - m_messageLabel->setToolTip(tr("Account locked permanently.")); - m_passwordEdit->clearText(); - m_passwordEdit->readOnly(true); - isLockingFlg = true; - return ; - } - else - { - if(m_passwordEdit){ - m_passwordEdit->readOnly(false); - if (m_passwordEdit->isVisible()) { - m_passwordEdit->setFocus(); - } - } - if (isLockingFlg) - { - onShowMessage("",Auth::MessageTypeError); - isLockingFlg = false; - } - if (m_timer) - m_timer->stop(); - } - return ; -} - -void AuthDialog::resizeEvent(QResizeEvent *) -{ - setChildrenGeometry(); -} - -void AuthDialog::setChildrenGeometry() -{ - if(scale < 0.5) - setFixedWidth(500); - // 用户信息显示位置 - m_userWidget->setGeometry(0, 0, - width(), 376*scale); - m_labelLoginTypeTip->setGeometry(0,0,m_userWidget->width(), 30); - m_labelLoginTypeTip->setAlignment(Qt::AlignCenter); - m_labelLoginTypeTip->setText(m_labelLoginTypeTip->text()); - m_labelHeadImg->setStyleSheet(QString("border-radius: %1px; border:0px solid white;").arg((int)(77*scale))); - m_labelHeadImg->setGeometry((width() - 154*scale) / 2 , m_labelLoginTypeTip->geometry().bottom()+24*scale, 154*scale, 154*scale); - QPixmap facePixmap = makeRoundLogo(user.icon, 154*scale, 154*scale, 77*scale); - m_labelHeadImg->setPixmap(facePixmap); - - m_labelQRCode->setStyleSheet(QString("border-radius: %1px; border:0px solid white;background-color: rgba(255,255,255,100%);").arg((int)(6*scale))); - m_labelQRCode->setGeometry((width() - 154*scale) / 2 , m_labelLoginTypeTip->geometry().bottom()+24*scale, 154*scale, 154*scale); - setQRCode(m_imgQRCode); - - m_labelFace->setStyleSheet(QString("border-radius: %1px; border:0px solid white;background-color: rgba(255,255,255,10%);").arg((int)(77*scale))); - m_labelFace->setGeometry((width() - 154*scale) / 2 , m_labelLoginTypeTip->geometry().bottom()+24*scale, 154*scale, 154*scale); - QImage faceImg; - setFaceImg(faceImg); - - m_nameLabel->setGeometry(0, m_labelHeadImg->geometry().bottom() + 16*scale, - width(), 40); - - m_passwdWidget->setGeometry(0, m_nameLabel->geometry().bottom() + 24*scale, width(), 100); - m_passwordEdit->setGeometry((m_passwdWidget->width() - 240)/2, 0, 240, 40); - m_messageLabel->setGeometry((m_passwdWidget->width() - 240)/2, - m_passwordEdit->geometry().bottom() + 4, - width()-(m_passwdWidget->width() - 240)/2, 36); - m_messageLabel->setMinimumHeight(36); - - m_ukeyPasswdWidget->setGeometry(0, m_nameLabel->geometry().bottom() + 24*scale, width(), 100); - m_ukeyPasswordEdit->setGeometry((m_ukeyPasswdWidget->width() - 240)/2, 0, 240, 40); - m_ukeyMessageLabel->setGeometry((m_ukeyPasswdWidget->width() - 240)/2, - m_ukeyPasswordEdit->geometry().bottom() + 4, - width()-(m_ukeyPasswdWidget->width() - 240)/2, 36); - m_loadingWidget->adjustSize(); - m_loadingWidget->setGeometry((m_ukeyPasswdWidget->width() - m_loadingWidget->width())/2, 0, m_loadingWidget->width(), m_loadingWidget->height()); - m_messageLabel->setMinimumHeight(36); - - m_messageButton->setGeometry((m_passwdWidget->width() - 200)/2, 0, 200, 40); -// m_messageButton->setStyleSheet("QPushButton:!checked:!pressed:!hover{background-color: rgba(255,255,255,40)}" -// "QPushButton:!checked:!pressed:hover{background-color: rgba(255,255,255,100)}" -// "QPushButton:pressed{background-color: rgba(255,255,255,40)}"); - - m_customWidget->setGeometry(0, 0, - width(), 376*scale+100); - - setBiometricWidgetGeometry(); -} - -void AuthDialog::switchLoginOptType(unsigned uLoginOptType) -{ - qDebug()<<"switchLoginOptType"<show(); - m_labelHeadImg->show(); - m_labelQRCode->hide(); - m_labelFace->hide(); - m_passwdWidget->show(); - m_customWidget->hide(); - m_ukeyPasswdWidget->hide(); - } - break; - case LOGINOPT_TYPE_FACE: - { - m_userWidget->show(); - m_labelHeadImg->hide(); - m_labelQRCode->hide(); - m_labelFace->show(); - m_passwdWidget->show(); - m_customWidget->hide(); - m_ukeyPasswdWidget->hide(); - } - break; - case LOGINOPT_TYPE_FINGERPRINT: - case LOGINOPT_TYPE_VOICEPRINT: - case LOGINOPT_TYPE_FINGERVEIN: - case LOGINOPT_TYPE_IRIS: - { - m_userWidget->show(); - m_labelHeadImg->show(); - m_labelQRCode->hide(); - m_labelFace->hide(); - m_passwdWidget->show(); - m_customWidget->hide(); - m_ukeyPasswdWidget->hide(); - } - break; - case LOGINOPT_TYPE_QRCODE: - { - m_userWidget->show(); - m_labelHeadImg->hide(); - setQRCodeMsg(""); - m_labelQRCode->show(); - m_labelFace->hide(); - m_passwdWidget->show(); - m_customWidget->hide(); - m_ukeyPasswdWidget->hide(); - } - break; - case LOGINOPT_TYPE_GENERAL_UKEY: - { - m_userWidget->show(); - m_labelHeadImg->show(); - m_labelQRCode->hide(); - m_labelFace->hide(); - m_passwdWidget->hide(); - m_customWidget->hide(); - m_ukeyPasswdWidget->show(); -// setFocusProxy(m_ukeyPasswordEdit); -// m_ukeyPasswordEdit->setFocusPolicy(Qt::StrongFocus); -// m_ukeyPasswordEdit->setFocus(); - } - break; - case LOGINOPT_TYPE_CUSTOM: - { - m_userWidget->hide(); - m_passwdWidget->hide(); - m_labelHeadImg->hide(); - setQRCodeMsg(""); - m_labelQRCode->hide(); - m_labelFace->hide(); - m_ukeyPasswdWidget->hide(); - LoginAuthInterface* plugin = m_widgetLoginOpts->getCustomLoginAuth(); - if (plugin) { - QWidget *authWidget = plugin->getPluginMainWnd(); - if (authWidget) { - if (m_customWidget != authWidget->parent()) { - m_layoutCustom->addWidget(authWidget); - qDebug()<<"CustomWidget Size:"<size(); - QObject *obj = dynamic_cast(plugin); - connect(obj, SIGNAL(requestAuthAccount(QString)), this, SLOT(onCustomRequestAccount(QString))); - connect(obj, SIGNAL(authenticateResult(int, QString)), this, SLOT(onCustomAuthResult(int, QString))); - connect(obj, SIGNAL(onRequest(QString)), this, SLOT(onCustomRequest(QString))); - connect(obj, SIGNAL(getLoginPluginEnv()), this, SLOT(onCustomPlugEnv())); - } - authWidget->show(); - } - } - m_customWidget->show(); - } - break; - default: - return; - } - if (uLoginOptType != m_uCurLoginOptType || (m_deviceInfo && m_deviceInfo->id != m_nLastDeviceId)) { - clearMessage(); - switch(uLoginOptType) { - case LOGINOPT_TYPE_PASSWORD: - { - setLoginTypeTip(""); - } - break; - case LOGINOPT_TYPE_FACE: - { - setLoginTypeTip(tr("Verify face recognition or enter password to unlock")); - } - break; - case LOGINOPT_TYPE_FINGERPRINT: - { - setLoginTypeTip(tr("Press fingerprint or enter password to unlock")); - } - break; - case LOGINOPT_TYPE_VOICEPRINT: - { - setLoginTypeTip(tr("Verify voiceprint or enter password to unlock")); - } - break; - case LOGINOPT_TYPE_FINGERVEIN: - { - setLoginTypeTip(tr("Verify finger vein or enter password to unlock")); - } - break; - case LOGINOPT_TYPE_IRIS: - { - setLoginTypeTip(tr("Verify iris or enter password to unlock")); - } - break; - case LOGINOPT_TYPE_QRCODE: - { - setLoginTypeTip(tr("Use the bound wechat scanning code or enter the password to unlock")); - } - break; - case LOGINOPT_TYPE_GENERAL_UKEY: - { - setLoginTypeTip(""); - } - break; - case LOGINOPT_TYPE_CUSTOM: - { - setLoginTypeTip(""); - } - break; - default: - return; - } - } - if (m_deviceInfo) { - m_nLastDeviceId = m_deviceInfo->id; - } else { - m_nLastDeviceId = -1; - } - - m_uCurLoginOptType = uLoginOptType; -} - - -void AuthDialog::closeEvent(QCloseEvent *event) -{ - qDebug() << "AuthDialog::closeEvent"; - - if(auth && auth->isAuthenticating()) - { - auth->stopAuth(); - } - - //调用kylin的接口,重新初始化 - QDBusInterface interface("com.kylin.network", - "/com/kylin/network", - "com.kylin.network", - QDBusConnection::sessionBus()); - QDBusMessage result = interface.call("keyRingInit"); - - return QWidget::closeEvent(event); -} - - -void AuthDialog::onShowMessage(const QString &message, Auth::MessageType type) -{ - qDebug()<setMinimumHeight(36); - if (message.indexOf("account locked") != -1 || message.indexOf("账户已锁定") != -1 - || message.indexOf("Account locked") != -1 || message.indexOf("永久锁定") != -1) - { - if (unlock_countdown()) { - if(!m_timer){ - m_timer = new QTimer(this); - m_timer->setInterval(500); - connect(m_timer, &QTimer::timeout, this, &AuthDialog::unlock_countdown); - } else { - if(m_timer->isActive()) { - m_timer->stop(); - } - } - m_timer->start(); - } - }else if (message.indexOf("No password received, please input password") != -1){ - m_messageLabel->setText(tr("Password cannot be empty")); - m_messageLabel->setToolTip(tr("Password cannot be empty")); - } - else{ - QString strText = message; - if (!m_preStrMessage.isEmpty() && m_preStrMessageType != type && m_preStrMessageType != -1) - { - strText = m_preStrMessage + "," + strText; - } - QFontMetrics font(m_messageLabel->font()); - QString strDisplay = font.elidedText(message, Qt::ElideRight, m_messageLabel->width()-8); - m_messageLabel->setText(strDisplay); - m_messageLabel->setToolTip(message); - } - unacknowledged_messages = true; - //stopWaiting(); -} - -void AuthDialog::pamBioSuccess() -{ - m_bioTimer->stop(); - if (!m_widgetLoginOpts) { - switchLoginOptType(LOGINOPT_TYPE_PASSWORD); - return ; - } - - if(m_deviceInfo && m_deviceInfo->deviceType == LOGINOPT_TYPE_GENERAL_UKEY){ - //ukey时不调用ukey认证 - }else{ - m_widgetLoginOpts->startAuth(m_deviceInfo, user.uid); - } - - if (m_deviceInfo) { - switchLoginOptType(m_widgetLoginOpts->convertDeviceType(m_deviceInfo->deviceType)); - } else { - switchLoginOptType(LOGINOPT_TYPE_PASSWORD); - } -} - -void AuthDialog::startBioAuth(unsigned uTimeout) -{ - if (m_widgetLoginOpts) - m_widgetLoginOpts->stopAuth(); - - if(m_deviceInfo && m_deviceInfo->deviceType == LOGINOPT_TYPE_GENERAL_UKEY){ - //ukey时不调用ukey认证 - switchLoginOptType(m_widgetLoginOpts->convertDeviceType(m_deviceInfo->deviceType)); - return; - } - - if(!m_bioTimer){ - m_bioTimer = new QTimer(this); - connect(m_bioTimer, SIGNAL(timeout()), this, SLOT(pamBioSuccess())); - } - m_bioTimer->start(uTimeout); - -} - -void AuthDialog::setX11Focus() -{ - if(m_passwordEdit && m_passwordEdit->isVisible()){ - m_passwordEdit->setX11Focus(); - } -} - -void AuthDialog::setFocusin(int target) -{ - if(m_passwordEdit && m_passwordEdit->isVisible()) { - if (m_ukeyPasswordEdit) { - m_ukeyPasswordEdit->setFocusin(2); - } - switch (target) { - case REMOVE: //焦点清除 - if(m_widgetLoginOpts) - m_widgetLoginOpts->tabOptionSelected(2); - m_passwordEdit->setFocusin(2); - if(is_showMessageBtn) { - m_messageButton->clearFocus(); - m_messageButton->setStyleSheet("QPushButton:!checked:!pressed:!hover{background-color: rgba(255,255,255,40)}" - "QPushButton:!checked:!pressed:hover{background-color: rgba(255,255,255,100)}" - "QPushButton:pressed{background-color: rgba(255,255,255,40)}"); - } - m_nameLabel->setFocus(); - break; - case IN_LIGIN: //焦点在登录按钮 - if(m_widgetLoginOpts) - m_widgetLoginOpts->tabOptionSelected(2); - m_passwordEdit->setFocusin(1); - break; - case BIO_RIGHT: //登录选项焦点右移 - if(m_widgetLoginOpts) - m_widgetLoginOpts->tabOptionSelected(0); - m_passwordEdit->setFocusin(2); - m_nameLabel->setFocus(); - break; - case BIO_LEFT: //登录选项焦点左移 - if(m_widgetLoginOpts) - m_widgetLoginOpts->tabOptionSelected(1); - m_passwordEdit->setFocusin(target); - m_nameLabel->setFocus(); - break; - case IN_LINEEDIT: //焦点在密码输入框 - if(m_widgetLoginOpts) - m_widgetLoginOpts->tabOptionSelected(2); - m_passwordEdit->setFocusin(0); - break; - case ON_MESSAGEBTN: //免密登录按钮 - if(m_widgetLoginOpts) - m_widgetLoginOpts->tabOptionSelected(2); - m_passwordEdit->setFocusin(2); - m_messageButton->setFocus(); - m_messageButton->setStyleSheet("QPushButton{background-color: rgba(255,255,255,15%); border-radius: 4px; border: 2px solid #2C73C8;}"); - break; - default: - if(m_passwordEdit) - m_passwordEdit->setFocusin(target); - m_widgetLoginOpts->tabOptionSelected(2); - break; - } - } else { - if (m_passwordEdit) { - m_passwordEdit->setFocusin(2); - } - switch (target) { - case REMOVE: //焦点清除 - if(m_widgetLoginOpts) - m_widgetLoginOpts->tabOptionSelected(2); - m_ukeyPasswordEdit->setFocusin(2); - if(is_showMessageBtn) { - m_messageButton->clearFocus(); - m_messageButton->setStyleSheet("QPushButton:!checked:!pressed:!hover{background-color: rgba(255,255,255,40)}" - "QPushButton:!checked:!pressed:hover{background-color: rgba(255,255,255,100)}" - "QPushButton:pressed{background-color: rgba(255,255,255,40)}"); - } - m_nameLabel->setFocus(); - break; - case IN_LIGIN: //焦点在登录按钮 - if(m_widgetLoginOpts) - m_widgetLoginOpts->tabOptionSelected(2); - m_ukeyPasswordEdit->setFocusin(1); - break; - case BIO_RIGHT: //登录选项焦点右移 - if(m_widgetLoginOpts) - m_widgetLoginOpts->tabOptionSelected(0); - m_ukeyPasswordEdit->setFocusin(2); - m_nameLabel->setFocus(); - break; - case BIO_LEFT: //登录选项焦点左移 - if(m_widgetLoginOpts) - m_widgetLoginOpts->tabOptionSelected(1); - m_ukeyPasswordEdit->setFocusin(target); - m_nameLabel->setFocus(); - break; - case IN_LINEEDIT: //焦点在密码输入框 - if(m_widgetLoginOpts) - m_widgetLoginOpts->tabOptionSelected(2); - m_ukeyPasswordEdit->setFocusin(0); - break; - case ON_MESSAGEBTN: //免密登录按钮 - if(m_widgetLoginOpts) - m_widgetLoginOpts->tabOptionSelected(2); - m_ukeyPasswordEdit->setFocusin(2); - m_messageButton->setFocus(); - m_messageButton->setStyleSheet("QPushButton{background-color: rgba(255,255,255,15%); border-radius: 4px; border: 2px solid #2C73C8;}"); - break; - default: - if(m_ukeyPasswordEdit) - m_ukeyPasswordEdit->setFocusin(target); - m_widgetLoginOpts->tabOptionSelected(2); - break; - } - } -} - -void AuthDialog::setClick() -{ - m_widgetLoginOpts->tabOptionSelected(3); -} - -void AuthDialog::checkPassword() -{ - if (m_passwordEdit && m_passwordEdit->isVisible()) { - m_passwordEdit->clicked_cb(); - } else if (m_ukeyPasswordEdit && m_ukeyPasswordEdit->isVisible()) { - m_ukeyPasswordEdit->clicked_cb(); - } - setFocusin(REMOVE); -} - -void AuthDialog::onShowPrompt(const QString &prompt, Auth::PromptType type) -{ - qDebug() << "-------prompt: " << prompt<readOnly(false); - m_passwordEdit->show(); - } - - if (m_passwordEdit->isVisible()) - m_passwordEdit->setFocus(); - - prompted = true; - unacknowledged_messages = false; - m_preStrMessage = ""; - if (!m_biometricProxy || !m_biometricProxy->isValid() || !m_deviceInfo) { - switchLoginOptType(LOGINOPT_TYPE_PASSWORD); - if (m_widgetLoginOpts) - m_widgetLoginOpts->setSelectedPassword(); - } - - if(text == "Password: " || text == "密码:"){ - text = tr("Password: "); - } else if (text == "Input password" || text == "Input Password" || text == "输入密码") { - text = tr("Input Password"); - } - - m_passwordEdit->clear(); - m_passwordEdit->setPrompt(text); - m_passwordEdit->show(); - if (m_passwordEdit->isVisible()) - m_passwordEdit->setFocus(); - if (unlock_countdown()) { - if(!m_timer){ - m_timer = new QTimer(this); - m_timer->setInterval(500); - connect(m_timer, &QTimer::timeout, this, &AuthDialog::unlock_countdown); - } else { - if(m_timer->isActive()) { - m_timer->stop(); - } - } - m_timer->start(); - } - } -} - -void AuthDialog::onAuthComplete() -{ - stopWaiting(); - qDebug()<<"--------------------"<isAuthenticated(); - if(auth->isAuthenticated()) { - if (m_widgetLoginOpts) { - m_widgetLoginOpts->stopAuth(); - } - - if((prompted && !unacknowledged_messages )||direct_login) { - direct_login = false; - Q_EMIT authenticateCompete(true); - } else { - qDebug()<<"prompted = "<setInterval(500); - connect(m_timer, &QTimer::timeout, this, &AuthDialog::unlock_countdown); - } else { - if(m_timer->isActive()) { - m_timer->stop(); - } - } - m_timer->start(); - } - startAuth(); -// } -// else -// { -// show_authenticated (false); -// } - } -} - -void AuthDialog::show_authenticated(bool successful) -{ - m_passwdWidget->show(); - m_passwordEdit->hide(); - m_passwordEdit->setFocusPolicy(Qt::NoFocus); -// m_messageButton->setFocusPolicy(Qt::StrongFocus); -// setFocusProxy(m_messageButton); - m_messageButton->show(); - is_showMessageBtn = true; - Q_EMIT showMessageBtn(is_showMessageBtn); - m_messageButton->setFocus(); - m_messageButton->setDefault(true); - - if(successful) - { - isretry = false; - m_messageButton->setText(tr("Login")); - QString strMsgTip = m_messageLabel->text(); - switchLoginOptType(LOGINOPT_TYPE_PASSWORD); - if (!strMsgTip.isEmpty()) { - m_messageLabel->setText(strMsgTip); - m_messageLabel->move(m_messageButton->x(), m_messageLabel->y()); - } -// QTimer::singleShot(100, this, [=](){ -// qDebug()<<"Delay to focus msgBtn!!"; -// m_messageButton->show(); -// m_messageButton->setFocus(); -// m_messageButton->setDefault(true); -// }); - } - else - { - isretry = true; - m_messageButton->setText(tr("Retry")); - } - -} - -void AuthDialog::onMessageButtonClicked() -{ - m_messageButton->setDefault(false); - if(!isretry) - { - Q_EMIT authenticateCompete(true); - } - else - { - m_messageButton->hide(); - is_showMessageBtn = false; - authMode = PASSWORD; - - m_messageLabel->setText(""); - startAuth(); - } -} - -void AuthDialog::onRespondUkey(const QString &text) -{ - if (m_widgetLoginOpts){ - m_widgetLoginOpts->SetExtraInfo(text,"pincode"); - m_widgetLoginOpts->startAuth(m_deviceInfo, user.uid); - } -} - -bool AuthDialog::getLineeditStatus() -{ - return is_showMessageBtn; -} - -void AuthDialog::onRespond(const QString &text) -{ - if (!prompted && text != BIOMETRIC_SUCCESS) { - qInfo()<<"Wait for input passwd!"; - return; - } - unacknowledged_messages=false; - clearMessage(); - startWaiting(); - m_passwordEdit->readOnly(true); - auth->respond(text); -} - -void AuthDialog::onM_passwordEditClicked() -{ - Q_EMIT clickPassword(true); -} - -//void AuthDialog::onCapsLockChanged() -//{ -// m_passwordEdit->onCapsStateChanged(); -//} - -void AuthDialog::startWaiting() -{ - if(m_buttonsWidget) - { - m_buttonsWidget->setEnabled(false); - } -} - -void AuthDialog::stopWaiting() -{ - m_passwordEdit->stopWaiting(); - if(m_buttonsWidget) - { - m_buttonsWidget->setEnabled(true); - } -} - -void AuthDialog::clearMessage() -{ - m_messageLabel->clear(); - m_preStrMessage = ""; - m_preStrMessageType = -1; -} - -void AuthDialog::performBiometricAuth() -{ - qDebug()<<"performBiometricAuth"; - if(!m_biometricProxy) - { - m_biometricProxy = new BiometricProxy(this); - if (m_uniauthService && m_uniauthService->isActivatable()) { - isHiddenSwitchButton = m_uniauthService->getHiddenSwitchButton(); - maxFailedTimes = m_uniauthService->getMaxFailedTimes(); - } else { - isHiddenSwitchButton = GetHiddenSwitchButton(); - maxFailedTimes = GetFailedTimes(); - } - } - - //服务没启动,或者打开DBus连接出错 - if(!m_biometricProxy->isValid()) - { - qWarning() << "An error occurs when connect to the biometric DBus"; - skipBiometricAuth(); - if (m_deviceInfo) { - if (!m_widgetLoginOpts || !m_widgetLoginOpts->findDeviceById(m_deviceInfo->id) - || m_widgetLoginOpts->isDeviceDisable(m_deviceInfo->id)) { - m_deviceInfo = DeviceInfoPtr(); - } - } - return; - } - - //初始化生物识别认证UI - initBiometricWidget(); - - //没有可用设备,不启用生物识别认证 - if(m_widgetLoginOpts->getLoginOptCount() < 1) - { - qWarning() << "No available devices"; - skipBiometricAuth(); - if (m_deviceInfo) { - if (!m_widgetLoginOpts || !m_widgetLoginOpts->findDeviceById(m_deviceInfo->id) - || m_widgetLoginOpts->isDeviceDisable(m_deviceInfo->id)) { - m_deviceInfo = DeviceInfoPtr(); - } - } - return; - } - - //获取默认设备 - if (m_widgetLoginOpts) { - m_deviceName = m_widgetLoginOpts->getDefaultDevice(user.name); - if (m_isCustomDefault) { - m_deviceName = m_widgetLoginOpts->getCustomDevName(); - } - } - qDebug() << m_deviceName; - if (m_deviceInfo) { - if (!m_widgetLoginOpts || !m_widgetLoginOpts->findDeviceById(m_deviceInfo->id) - || m_widgetLoginOpts->isDeviceDisable(m_deviceInfo->id)) { - m_deviceInfo = DeviceInfoPtr(); - } - } - - //如果默认设备为空的话,不进行生物认证 - if(m_deviceName.isEmpty() && !m_deviceInfo) - { - skipBiometricAuth(); - return; - } - - //clearMessage(); - - if(!m_deviceInfo) - { - m_deviceInfo = m_widgetLoginOpts->findDeviceByName(m_deviceName); - if(!m_deviceInfo) - { - skipBiometricAuth(); - return; - } - } - - if(m_deviceInfo->deviceType == LOGINOPT_TYPE_GENERAL_UKEY){ - switchLoginOptType(LOGINOPT_TYPE_PASSWORD); - m_widgetLoginOpts->setSelectedPassword(); - skipBiometricAuth(); - return ; - } - - switchLoginOptType(m_widgetLoginOpts->convertDeviceType(m_deviceInfo->deviceType)); - if(!m_widgetLoginOpts->isDeviceDisable(m_deviceInfo->id)) - startBioAuth(); - else { - QImage imgFailed; - setFaceImg(imgFailed, 1); - } - skipBiometricAuth(); -} - -void AuthDialog::skipBiometricAuth() -{ - auth->respond(BIOMETRIC_IGNORE); -} - -void AuthDialog::initBiometricWidget() -{ - if(m_widgetLoginOpts) { - m_widgetLoginOpts->setUser(user.uid); - } else { - m_widgetLoginOpts = new LoginOptionsWidget(m_biometricProxy, user.uid, m_uniauthService, this); - connect(m_widgetLoginOpts, &LoginOptionsWidget::authComplete, - this, &AuthDialog::onBiometricAuthComplete); - connect(m_widgetLoginOpts, &LoginOptionsWidget::optionSelected, - this, &AuthDialog::onDeviceChanged); - connect(m_widgetLoginOpts, &LoginOptionsWidget::updateImage, - this, &AuthDialog::onLoginOptImage); - connect(m_widgetLoginOpts, &LoginOptionsWidget::setLoadingImage, - this, &AuthDialog::onLoadingImage); - connect(m_widgetLoginOpts, &LoginOptionsWidget::notifyOptionsChange, - this, &AuthDialog::onLoginOptsCount); - connect(m_widgetLoginOpts, &LoginOptionsWidget::updateAuthMsg, - this, &AuthDialog::setLoginMsg); - m_widgetLoginOpts->setUser(user.uid); - } - - qDebug()<<"----------DeviceCount:"<getLoginOptCount(); - if (m_widgetLoginOpts->getLoginOptCount() < 1) - m_widgetLoginOpts->hide(); - else - m_widgetLoginOpts->show(); - - if(m_widgetLoginOpts->getHasUkeyOptions() && m_widgetLoginOpts->getLoginOptCount() < 1){ - m_widgetLoginOpts->show(); - m_widgetLoginOpts->setSelectedPassword(); - } - - m_widgetLoginOpts->setEnabled(true); - - setBiometricWidgetGeometry(); -} - -void AuthDialog::setBiometricWidgetGeometry() -{ - //生物识别 - if(m_widgetLoginOpts) - { - m_widgetLoginOpts->setGeometry(0, m_passwdWidget->geometry().bottom(), - width(), 92*scale); - qDebug()<<"LoginOptGeometry:"<geometry()<<","<geometry() - <<","<isHidden(); - } -} - -int AuthDialog::getBioNum() -{ - return m_widgetLoginOpts->getVisibleLoginOptCount(); -} - -void AuthDialog::onDeviceChanged(unsigned uCurLoginOptType, const DeviceInfoPtr &deviceInfo, bool keyNavigation) -{ - if(!keyNavigation) - Q_EMIT loginOptionClicked(); - isLoadingUkey = false; - if(uCurLoginOptType == LOGINOPT_TYPE_PASSWORD){ - switchLoginOptType(uCurLoginOptType); - if(m_widgetLoginOpts){ - m_widgetLoginOpts->stopAuth(); - } - m_deviceInfo = nullptr; - authMode = PASSWORD; - startAuth(); - return; - } - if (uCurLoginOptType != LOGINOPT_TYPE_GENERAL_UKEY && !deviceInfo) - return; - if(deviceInfo) - qDebug() << "device changed: " << *deviceInfo; - if(deviceInfo && m_failedTimes.contains(deviceInfo->id) && - m_failedTimes[deviceInfo->id] >= maxFailedTimes){ - qDebug() << "Failed MAX:"<id; - return ; - } - - if (uCurLoginOptType == LOGINOPT_TYPE_GENERAL_UKEY && !deviceInfo){ - isLoadingUkey = true; - startLoadingUkey(); - }else if(uCurLoginOptType == LOGINOPT_TYPE_GENERAL_UKEY && deviceInfo){ - stopLoadingUkey(); - } - - if (uCurLoginOptType != LOGINOPT_TYPE_GENERAL_UKEY && deviceInfo == m_deviceInfo) { - return ; - } - - if(m_bioTimer && m_bioTimer->isActive()) - m_bioTimer->stop(); - - authMode = BIOMETRIC; - m_deviceInfo = deviceInfo; - switchLoginOptType(uCurLoginOptType); - if(!isBioPassed && deviceInfo) - startBioAuth(); -} - -void AuthDialog::onBiometricAuthComplete(bool result, int nStatus) -{ - if(!result) { - - if(m_deviceInfo && m_deviceInfo->deviceType == LOGINOPT_TYPE_GENERAL_UKEY && m_ukeyPasswdWidget->isVisible()){ - m_ukeyPasswordEdit->stopWaiting(); - m_ukeyPasswordEdit->clearText(); - } - - if (nStatus == 5 && m_deviceInfo) { - if(w_timer && w_timer->isActive()) - w_timer->stop(); - QImage imgFailed; - setFaceImg(imgFailed, 2); - return; - } else if (nStatus >= 2 && nStatus != 5) { - if (m_deviceInfo) { - if (m_failedTimes.contains(m_deviceInfo->id)) { - m_failedTimes[m_deviceInfo->id] = m_failedTimes[m_deviceInfo->id] + 1; - } else { - m_failedTimes[m_deviceInfo->id] = 1; - } - qDebug()<<"Failed count:"<id]<<",Max:"<id; - if (m_deviceInfo->deviceType == DeviceType::Face) { - QImage imgFailed; - setFaceImg(imgFailed, 1); - } - if(m_failedTimes[m_deviceInfo->id] >= maxFailedTimes){ - if (m_deviceInfo->deviceType == REMOTE_QRCODE_TYPE) { - setLoginTypeTip(tr("Failed to verify %1, please enter password to unlock").arg(DeviceType::getDeviceType_tr(m_deviceInfo->deviceType))); - QImage nullImage; - setQRCode(nullImage); - }else if(m_deviceInfo->deviceType == LOGINOPT_TYPE_GENERAL_UKEY){ - setUkeyTypeTip(tr("Unable to verify %1, please enter password to unlock").arg(DeviceType::getDeviceType_tr(m_deviceInfo->deviceType))); - } else { - setLoginTypeTip(tr("Unable to verify %1, please enter password to unlock").arg(DeviceType::getDeviceType_tr(m_deviceInfo->deviceType))); - } - if (m_widgetLoginOpts) - m_widgetLoginOpts->setDeviceDisable(m_deviceInfo->id, true); - - if(m_ukeyPasswdWidget && m_ukeyPasswdWidget->isVisible()){ - m_ukeyPasswordEdit->readOnly(true); - } - return ; - } - - qDebug()<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"; - if(m_deviceInfo->deviceType == LOGINOPT_TYPE_GENERAL_UKEY){ - setUkeyTypeTip(tr("Failed to verify %1, you still have %2 verification opportunities") - .arg(DeviceType::getDeviceType_tr(m_deviceInfo->deviceType)) - .arg(maxFailedTimes-m_failedTimes[m_deviceInfo->id])); - }else { - setLoginTypeTip(tr("Failed to verify %1, you still have %2 verification opportunities") - .arg(DeviceType::getDeviceType_tr(m_deviceInfo->deviceType)) - .arg(maxFailedTimes-m_failedTimes[m_deviceInfo->id])); - } - qDebug()<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"; - } - } - - if(!isBioPassed) { - if (nStatus <= 0) { - qDebug()<<"Biometric dbus error:"<= 2 && nStatus != 5 && m_deviceInfo) { - if (m_deviceInfo->deviceType == DeviceType::Face) { - QImage imgFailed; - setFaceImg(imgFailed, 1); - } - } - } - } else { - direct_login = true; - isBioPassed = true; - onBiometricButtonClicked(); - } -} - -void AuthDialog::onBiometricButtonClicked() -{ - //当前没有设备 - if (!m_deviceInfo) { - qWarning()<<"未选择生物设备--"; - return ; - } - authMode = BIOMETRIC; - startAuth(); -} - -void AuthDialog::onPasswordButtonClicked() -{ - skipBiometricAuth(); -} - -void AuthDialog::onOtherDevicesButtonClicked() -{ - if (m_widgetLoginOpts) - m_widgetLoginOpts->stopAuth(); -} - -void AuthDialog::onRetryButtonClicked() -{ - if (m_widgetLoginOpts) - m_widgetLoginOpts->startAuth(m_deviceInfo, user.uid); - //m_retryButton->setVisible(false); -} - -void AuthDialog::setQRCode(QImage& imgQRCode) -{ - if (imgQRCode.isNull()) { - m_imgQRCode.load(":/image/assets/ukui-qrcode-null.svg"); - } else { - m_imgQRCode = imgQRCode; - m_labelQRCodeTip->hide(); - } - m_imgQRCode = m_imgQRCode.scaled(QSize(150*scale, 150*scale)); - m_labelQRCode->setAlignment(Qt::AlignCenter); - m_labelQRCode->setPixmap(QPixmap::fromImage(m_imgQRCode)); -} - -void AuthDialog::setQRCodeMsg(QString strMsg) -{ - if (strMsg.isEmpty()) { - m_labelQRCodeMsg->hide(); - //m_labelQRCodeTip->hide(); - } else { - //一开始认证时就没有网,直接停止加载状态 - if(w_timer && w_timer->isActive()) - { - w_timer->stop(); - } - m_labelQRCodeMsg->setElideText(strMsg, m_labelQRCode->width() - 20* scale, 14); - m_labelQRCodeMsg->show(); - m_labelQRCodeTip->setPixmap(QIcon::fromTheme("dialog-warning").pixmap(QSize(22,22))); - m_labelQRCodeTip->show(); - } -} - -void AuthDialog::setFaceImg(QImage& imgFace, int nStatus) -{ - QPixmap faceImage; - m_labelFace->setFixedSize(154*scale,154*scale); - //如果头像文件不存在,则使用默认头像 - if(!imgFace.isNull()) { - faceImage = PixmapToRound(QPixmap::fromImage(imgFace),77*scale); - } else { - switch(nStatus){ - case 1: - faceImage = QPixmap(":/image/assets/ukui-loginopt-lose.svg"); - break; - case 2: - faceImage = m_widgetLoginOpts->loadSvg(":/image/assets/ukui-loginopt-smile.svg", "gray", 48); - m_labelFace->setStyleSheet(QString("border-radius: %1px; border:0px solid white;background-color: rgba(255,255,255,10%);").arg((int)(77*scale))); - break; - default: - faceImage = QPixmap(":/image/assets/ukui-loginopt-smile.svg"); - break; - } - } - - m_labelFace->setAlignment(Qt::AlignCenter); - m_labelFace->setPixmap(faceImage); -} - -void AuthDialog::updatePixmap() -{ - QMatrix matrix; - matrix.rotate(90.0); - m_waitingPixmap = m_waitingPixmap.transformed(matrix, Qt::FastTransformation); - if(m_uCurLoginOptType == LOGINOPT_TYPE_QRCODE) - m_labelQRCodeTip->setPixmap(m_waitingPixmap); - else if(m_uCurLoginOptType == LOGINOPT_TYPE_FACE) { - m_labelFace->setPixmap(m_waitingPixmap); - } -} - -void AuthDialog::setUkeyTypeTip(QString text) -{ - QString textTip = text; - if (!textTip.isEmpty()) { -// QFontMetrics font(m_ukeyMessageLabel->font()); -// QString textTip = font.elidedText(textTip, Qt::ElideRight, m_messageLabel->width()-8); - m_ukeyMessageLabel->setText(textTip); - m_ukeyMessageLabel->setToolTip(text); - m_ukeyMessageLabel->show(); - } else { - m_ukeyMessageLabel->hide(); - } -} - -void AuthDialog::setLoginTypeTip(QString strLoginTypeTip) -{ - m_strLoginTypeTip = strLoginTypeTip; - if (!m_strLoginTypeTip.isEmpty()) { - QFontMetrics font(m_labelLoginTypeTip->font()); - QString strDisplay = font.elidedText(m_strLoginTypeTip, Qt::ElideRight, m_messageLabel->width()-8); - m_labelLoginTypeTip->setText(strDisplay); - if (strDisplay != strLoginTypeTip) - m_labelLoginTypeTip->setToolTip(m_strLoginTypeTip); - m_labelLoginTypeTip->show(); - } else { - m_labelLoginTypeTip->hide(); - } -} - -void AuthDialog::setLoginMsg(QString strLoginMsg) -{ - setLoginTypeTip(strLoginMsg); -} - -void AuthDialog::onLoginOptsCount(unsigned uCount, bool is_bioBtn) -{ - qDebug()<<"----------------------onLoginOptsCount Count:"< 0) { - setBiometricWidgetGeometry(); - m_widgetLoginOpts->show(); - } else { - switchLoginOptType(LOGINOPT_TYPE_PASSWORD); - m_widgetLoginOpts->hide(); - } - - if (!m_deviceInfo || !m_widgetLoginOpts->findDeviceById(m_deviceInfo->id) - || m_widgetLoginOpts->isDeviceDisable(m_deviceInfo->id)) { - m_widgetLoginOpts->stopAuth(); - authMode = BIOMETRIC; - //初始化生物识别认证UI - initBiometricWidget(); - - //没有可用设备,不启用生物识别认证 - if(m_widgetLoginOpts->getLoginOptCount() < 1) - { - qWarning() << "No available devices"; - if (m_deviceInfo) { - m_deviceInfo = DeviceInfoPtr(); - } - return; - } - - //获取默认设备 - if (m_widgetLoginOpts) { - qDebug()<<"isLoadingUkey:"<getDefaultDevice(user.name,UniT_General_Ukey); - } else { - m_deviceName = m_widgetLoginOpts->getDefaultDevice(user.name); - } - } - qDebug() << m_deviceName; - if (m_deviceInfo) { - if (!m_widgetLoginOpts || !m_widgetLoginOpts->findDeviceById(m_deviceInfo->id) - || m_widgetLoginOpts->isDeviceDisable(m_deviceInfo->id)) { - m_deviceInfo = DeviceInfoPtr(); - } - } - - //如果默认设备为空的话,不进行生物认证 - if(m_deviceName.isEmpty() && !m_deviceInfo) - { - return; - } - - if(!m_deviceInfo) - { - m_deviceInfo = m_widgetLoginOpts->findDeviceByName(m_deviceName); - if(!m_deviceInfo) - { - return; - } - } - - if (m_deviceInfo->deviceType == LOGINOPT_TYPE_GENERAL_UKEY){ - stopLoadingUkey(); - } - - if(m_deviceInfo){ - m_widgetLoginOpts->setCurrentDevice(m_deviceInfo); - m_widgetLoginOpts->updateUIStatus(); - } - - switchLoginOptType(m_widgetLoginOpts->convertDeviceType(m_deviceInfo->deviceType)); - startBioAuth(); - } - if(is_bioBtn && uCount <= 1) - Q_EMIT loginOptionClicked(); -} - -void AuthDialog::onLoginOptImage(QImage img) -{ -// if (img.isNull()) { -// return ; -// } - if (m_uCurLoginOptType == LOGINOPT_TYPE_FACE) { - setFaceImg(img); - } else if (m_uCurLoginOptType == LOGINOPT_TYPE_QRCODE) { - setQRCode(img); - } - if(w_timer && w_timer->isActive()) - { - w_timer->stop(); - } -} - -void AuthDialog::onLoadingImage() -{ - if(!w_timer) - { - w_timer = new QTimer(this); - w_timer->setInterval(150); - connect(w_timer, &QTimer::timeout, this, &AuthDialog::updatePixmap); - } - m_waitingPixmap = QIcon::fromTheme("ukui-loading-0-symbolic").pixmap(24, 24); - m_labelFace->setAlignment(Qt::AlignCenter); - if (m_uCurLoginOptType == LOGINOPT_TYPE_FACE) { - m_labelFace->setPixmap(m_waitingPixmap); - m_labelFace->show(); - } else if (m_uCurLoginOptType == LOGINOPT_TYPE_QRCODE) { - m_labelQRCodeTip->setPixmap(m_waitingPixmap); - m_labelQRCodeTip->show(); - } - w_timer->start(); -} - -void AuthDialog::onBiometricDbusChanged(bool bActive) -{ - qDebug()<<"BiometricDbus:"<isActivatable()) { - isHiddenSwitchButton = m_uniauthService->getHiddenSwitchButton(); - maxFailedTimes = m_uniauthService->getMaxFailedTimes(); - } else { - isHiddenSwitchButton = GetHiddenSwitchButton(); - maxFailedTimes = GetFailedTimes(); - } - } - - //服务没启动,或者打开DBus连接出错 - if(!m_biometricProxy->isValid()) - { - qWarning() << "An error occurs when connect to the biometric DBus"; - if (m_deviceInfo) { - if (!m_widgetLoginOpts || !m_widgetLoginOpts->findDeviceById(m_deviceInfo->id) - || m_widgetLoginOpts->isDeviceDisable(m_deviceInfo->id)) { - m_deviceInfo = DeviceInfoPtr(); - } - } - return; - } - - //初始化生物识别认证UI - initBiometricWidget(); - - //没有可用设备,不启用生物识别认证 - if(m_widgetLoginOpts->getLoginOptCount() < 1) - { - qWarning() << "No available devices"; - if (m_deviceInfo) { - if (!m_widgetLoginOpts || !m_widgetLoginOpts->findDeviceById(m_deviceInfo->id) - || m_widgetLoginOpts->isDeviceDisable(m_deviceInfo->id)) { - m_deviceInfo = DeviceInfoPtr(); - } - } - return; - } - - //获取默认设备 - if (m_widgetLoginOpts) { - m_deviceName = m_widgetLoginOpts->getDefaultDevice(user.name); - } - qDebug() << m_deviceName; - if (m_deviceInfo) { - if (!m_widgetLoginOpts || !m_widgetLoginOpts->findDeviceById(m_deviceInfo->id) - || m_widgetLoginOpts->isDeviceDisable(m_deviceInfo->id)) { - m_deviceInfo = DeviceInfoPtr(); - } - } - - //如果默认设备为空的话,不再使用生物认证 - if(m_deviceName.isEmpty() && !m_deviceInfo) { - return; - } - - if (!m_deviceInfo) { - m_deviceInfo = m_widgetLoginOpts->findDeviceByName(m_deviceName); - if(!m_deviceInfo) { - return; - } - } - switchLoginOptType(m_widgetLoginOpts->convertDeviceType(m_deviceInfo->deviceType)); - startBioAuth(); - }); - } -} - -QString AuthDialog::getCurAuthUserName() -{ - return user.name; -} - -void AuthDialog::onCustomRequestAccount(QString strName) -{ - qDebug()<<"onCustomRequestAccount:"<= 0 && !user.name.isEmpty() && !user.name.startsWith("*")) { - QJsonObject jsonUser; - jsonUser["Name"] = user.name; - jsonUser["Id"] = (double)user.uid; - jsonUser["HeadImg"] = user.icon; - jsonUser["RealName"] = user.realName.isEmpty() ? user.name : user.realName; - contentObj["CurrentUser"] = jsonUser; - } else { - retObj["Ret"] = -1; - retObj["Message"] = "Current user is invalid!"; - } - } - } - retObj["Content"] = contentObj; - return QString(QJsonDocument(retObj).toJson()); - } - } -} - -int AuthDialog::onCustomPlugEnv() -{ - return LoginPluginInterface::LOGINPLUGINENV_LOCKSCREEN; -} - -void AuthDialog::setCustomAuthDefault(bool isDefault) -{ - m_isCustomDefault = isDefault; -} - -QPixmap AuthDialog::makeRoundLogo(QString logo, int wsize, int hsize, int radius) -{ - QPixmap rectPixmap; - QPixmap iconcop = QPixmap(logo); - qreal dpi = m_labelHeadImg->devicePixelRatioF(); - if (dpi > 1.0) { - wsize = wsize * dpi; - hsize = hsize * dpi; - } - if (iconcop.width() > iconcop.height()) { - QPixmap iconPixmap = iconcop.copy((iconcop.width() - iconcop.height())/2, 0, iconcop.height(), iconcop.height()); - // 根据label高度等比例缩放图片 - rectPixmap = iconPixmap.scaledToHeight(hsize, Qt::SmoothTransformation); - } else { - QPixmap iconPixmap = iconcop.copy(0, (iconcop.height() - iconcop.width())/2, iconcop.width(), iconcop.width()); - // 根据label宽度等比例缩放图片 - rectPixmap = iconPixmap.scaledToWidth(wsize, Qt::SmoothTransformation); - } - - if (rectPixmap.isNull()) { - return QPixmap(); - } - QPixmap pixmapa(rectPixmap); - QPixmap pixmap(radius * 2 * dpi, radius * 2 * dpi); - pixmap.fill(Qt::transparent); - QPainter painter(&pixmap); - painter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); - QPainterPath path; - path.addEllipse(0, 0, radius * 2 * dpi, radius * 2 * dpi); - painter.setClipPath(path); - painter.drawPixmap(0, 0, radius * 2 * dpi, radius * 2 * dpi, pixmapa); - pixmap.setDevicePixelRatio(dpi); - return pixmap; -} diff --git a/src/authdialog.h b/src/authdialog.h deleted file mode 100644 index 3c3d913..0000000 --- a/src/authdialog.h +++ /dev/null @@ -1,260 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#ifndef AUTHDIALOG_H -#define AUTHDIALOG_H - -#ifndef QT_NO_KEYWORDS -#define QT_NO_KEYWORDS -#endif - -#include -#include -#include -#include "auth-pam.h" -#include "types.h" -#include "users.h" -#include "biometricdeviceinfo.h" -#include "pam-tally.h" -#include "uniauthservice.h" -#include "pluginsloader.h" - -namespace Ui { -class AuthDialog; -} - -class QLabel; -class KLabel; -class QPushButton; -class Configuration; -class IconEdit; -class Auth; -class BiometricProxy; -class PamTally; -class LoginOptionsWidget; -class QHBoxLayout; - -enum FOCUS { - REMOVE = 0, - IN_LIGIN, - BIO_RIGHT, - BIO_LEFT, - IN_LINEEDIT, - ON_MESSAGEBTN, -}; - -extern float scale; -class AuthDialog : public QWidget -{ - Q_OBJECT - -public: - explicit AuthDialog(const UserItem &user, QWidget *parent = 0); - void resizeEvent(QResizeEvent *event); - void closeEvent(QCloseEvent *event); - void setUserOfAuth(); - void setX11Focus(); - void setFocusin(int target); - void setClick(); - void checkPassword(); - int getBioNum(); - bool getLineeditStatus(); - QString getCurAuthUserName(); - /** - * @brief setCustomAuthDefault 设置是否默认第三方认证 - * @param isDefault true 是,否则 否 - */ - void setCustomAuthDefault(bool isDefault); - void setChildrenGeometry(); - -private: - void initUI(); - void startWaiting(); - void stopWaiting(); - void clearMessage(); - void performBiometricAuth(); - void skipBiometricAuth(); - void initBiometricWidget(); - - void setBiometricWidgetGeometry(); - void startBioAuth(unsigned uTimeout = 1000); - void show_authenticated (bool successful = true); - void setLoginTypeTip(QString strLoginTypeTip); - void setUkeyTypeTip(QString text); - void updatePixmap(); - void startLoadingUkey(); - void stopLoadingUkey(); - void updateLoadingPixmap(); - QPixmap makeRoundLogo(QString logo, int wsize, int hsize, int radius); - -private Q_SLOTS: - void onShowMessage(const QString &message, Auth::MessageType type); - void onShowPrompt(const QString &prompt, Auth::PromptType type); - void onAuthComplete(); - void onRespond(const QString &text); - void onRespondUkey(const QString &text); -// void onBioAuthStart(); -// void onBioAuthStop(); -// void setBioMovieImage(); -// void updateIcon(); - void onDeviceChanged(unsigned uCurLoginOptType, const DeviceInfoPtr &deviceInfo, bool keyNavigation); - void onBiometricAuthComplete(bool result, int nStatus); - void onBiometricButtonClicked(); - void onPasswordButtonClicked(); - void onOtherDevicesButtonClicked(); - void onRetryButtonClicked(); - void pamBioSuccess(); - void onMessageButtonClicked(); - void switchLoginOptType(unsigned uLoginOptType); - void onLoginOptsCount(unsigned uCount, bool is_bioBtn); - void onLoginOptImage(QImage img); - void setLoginMsg(QString strLoginMsg); - void setQRCode(QImage& imgQRCode); - void setFaceImg(QImage& imgFace, int nStatus = 0); - void onM_passwordEditClicked(); - void setQRCodeMsg(QString strMsg); - void onBiometricDbusChanged(bool bActive); - void onLoadingImage(); - -public Q_SLOTS: -// void switchToBiometric(); -// void switchToPassword(); -// void switchToDevices(); -// void onCapsLockChanged(); - void startAuth(); - void stopAuth(); - /** - * @brief onCustomRequestAccount 第三方请求认证用户槽 - * @param strName 用户名 - */ - void onCustomRequestAccount(QString strName); - /** - * @brief onCustomAuthResult 第三方认证结果 - * @param nResult 结果值,0 成功,其他失败 - * @param strMsg 结果消息 - */ - void onCustomAuthResult(int nResult, QString strMsg); - /** - * @brief onCustomRequest 第三方请求响应槽 - * @param strReqJson 请求json - * @return 请求结果 - */ - QString onCustomRequest(QString strReqJson); - /** - * @brief onCustomPlugEnv 插件所处环境 - * @return 登录或锁屏等 - */ - int onCustomPlugEnv(); - -Q_SIGNALS: - void authenticateCompete(bool result); - void clickPassword(bool clicked); - void loginOptionClicked(); - void showMessageBtn(bool is_show); - /** - * @brief customRequestAccount 第三方请求认证用户信号 - * @param account 用户名 - */ - void customRequestAccount(QString account); -private: - UserItem user; - Auth *auth; - - enum AuthMode { PASSWORD, BIOMETRIC, UNKNOWN }; - - AuthMode authMode; - Configuration *configuration; - - // biometric auth - QString m_deviceName; - DeviceInfoPtr m_deviceInfo = nullptr; - BiometricProxy *m_biometricProxy; - QWidget *m_buttonsWidget; - QPushButton *m_biometricButton; - QPushButton *m_passwordButton; - QPushButton *m_otherDeviceButton; - QPushButton *m_retryButton; - - LoginOptionsWidget *m_widgetLoginOpts = nullptr; - - // UI -// QPushButton *m_backButton; //返回用户列表 - QWidget *m_userWidget; //放置用户信息Label - QLabel *m_labelHeadImg = nullptr; //头像 - KLabel *m_nameLabel; //用户名 -// QLabel *m_isLoginLabel; //提示是否已登录 - - QWidget *m_passwdWidget; //放置密码输入框和信息列表 - IconEdit *m_passwordEdit; //密码输入框 - KLabel *m_messageLabel; //PAM消息显示 - QPushButton *m_messageButton; - bool is_showMessageBtn = false; - - QWidget *m_ukeyPasswdWidget = nullptr; //放置密码输入框和信息列表 - IconEdit *m_ukeyPasswordEdit = nullptr; //密码输入框 - KLabel *m_ukeyMessageLabel = nullptr; //PAM消息显示 - - QWidget *m_loadingWidget = nullptr; - QPushButton *m_loadingButton = nullptr; - KLabel *m_loadingText = nullptr; - QTimer *m_loadingTimer = nullptr; - QPixmap m_loadingPixmap; - - QLabel *m_labelFace = nullptr; - KLabel *m_labelLoginTypeTip = nullptr; // 登录类型提示 - QLabel *m_labelQRCode = nullptr; // 二维码图标 - KLabel *m_labelQRCodeMsg = nullptr; // 二维码状态消息提示 - QLabel *m_labelQRCodeTip = nullptr; - - bool isBioPassed; // 生物认证是否成功 - int maxFailedTimes; - bool isHiddenSwitchButton; - QMap m_failedTimes; - QTimer *m_bioTimer; - bool isLockingFlg; //判断当前是否正在锁定倒计时 - int m_nCurLockMin; //当前锁定的分钟数 - bool prompted = false; - bool unacknowledged_messages = false; - bool direct_login = false; - bool isretry = true; - QString m_preStrMessage = ""; - int m_preStrMessageType = -1; - - void root_unlock_countdown(); - bool unlock_countdown(); - QTimer *m_timer; - - QImage m_imgQRCode; - unsigned m_uCurLoginOptType = LOGINOPT_TYPE_PASSWORD; // 当前登录验证方式 - QString m_strLoginTypeTip = ""; - int m_nLastDeviceId = -1; - - QPixmap m_waitingPixmap; - QTimer *w_timer; - UniAuthService *m_uniauthService = nullptr; - double curFontSize = 0; - double m_ptToPx = 1.0; - bool isLoadingUkey = false; - - QString m_strRealName; - QWidget *m_customWidget; //放置第三方认证界面 - QHBoxLayout *m_layoutCustom; - bool m_isCustomDefault = false; /** 是否默认使用第三方认证 */ - PluginsLoader *m_pluginsLoader = nullptr; /** 插件加载器 */ -}; - -#endif // AUTHDIALOG_H diff --git a/src/common.h b/src/common.h deleted file mode 100644 index 95489cb..0000000 --- a/src/common.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2021 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#ifndef LOCKCOMMON_H -#define LOCKCOMMON_H - -enum SwitchPage{ - SwitchToPin = 0, - SwitchToWechat, - SwitchToCheck, - SwitchToResetPWD, - SwitchToConfigPWD -}; - -// 和后台规定好的 错误码固定值 -enum DBusMsgCode{ - - Error_QR_Get_Timeout = -8, // 二维码获取时间超时 - Error_NetWork = -7, // 网络错误 未能如期获得对应的数据 - Error_VerifyCode_Timeout = -6, // 验证码失效 - Error_RepeatedRequests = -5, // 重复请求二维码服务 - Error_NoReply = -4, // DBus接口连接失败导致的无回复错误 - Error_UnknownReason = -3, // 未知原因 - Error_ArgCnt = -2, // 参数个数错误 - Error_SetPsw_SameAsOriPsw = -1, // 设置新密码时 与原密码相同 - No_Error = 0, // 获取消息无错误 - Error_TelHaveBinded = 9009, // 手机号已绑定 -> 更换手机号后再试 - Error_VerifyCodeDiff = 9000, // 验证码错误 -> 请填写正确的验证码 - Error_AccessTokenInvalid = 9007,// Access Token 失效 -> 登录状态已过期,请重新扫码登录 - Error_ErrTimesOverMax = 9014, // 手机号登录时验证码错误次数超限 - // 账号密码登录时密码错误次数超限 - // 1小时内连续错10次触发 -> 1小时后再试 - Error_UserInfo = 9017, // 用户微信信息不存在 ->老用户,联系管理员处理 - Error_WechatHaveBinded = 9022, // 微信号已被其他账号绑定 -> 更换微信号再试 - Error_DeviceHaveBinded = 9027, // 当前设备已被绑定 -> 请联系管理员或班主任解绑 - Error_HaveBindOtherDevice = 9028, // 用户已绑定其他设备 -> 请联系管理员或班主任解绑 - - //以下错误码保留 - Error_NWUnused = 6, // 网络异常,请检查网络链接哦~ - Error_TencentUnused = 7, // 腾讯服务异常,请稍后再试~ - Error_NWDelay = 28, // 网络延迟大,请更换良好网络~ - Error_ResMalloc = 301, // 资源分配异常,请重启尝试 - Error_DBOpen = 101, // 数据库打开异常,请重试,或重启再试 - Error_DBGetKey = 102, // 获取数据库密钥失败,请重试 - Error_DBRetrieve = 103, // 数据库检索数据失败,请重试 - Error_DBDecryption = 105, // 数据库解密过程失败,请重试 -}; - - - -/*! - * \brief The QRCodeSwepState enum - * WaitingSwep 在DBus、SSOBackend、1.617 版本中未启用 - */ -enum QRCodeSwepState{ - WaitingSwep = 0, //等待用户扫码 - HaveSwep = 2, // 用户扫码、等待用户确认 - CancelSwep = 3, // 用户扫码后、取消确认 - ConfirmSuccess = 4, // 扫码确认成功 - QRCodeInvalid = 5, // 二维码失效 - QRCodeTimeout = 6, //二维码超时 -}; - -#endif // LOCKCOMMON_H diff --git a/src/common/biodefines.cpp b/src/common/biodefines.cpp new file mode 100644 index 0000000..fda64a8 --- /dev/null +++ b/src/common/biodefines.cpp @@ -0,0 +1,130 @@ +/* + * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301, USA. +**/ + +#include "biodefines.h" +#include +#include + +QString getDeviceTypeTr(int deviceType) +{ + switch(deviceType) + { + case BioT_FingerPrint: + return QObject::tr("FingerPrint"); + case BioT_FingerVein: + return QObject::tr("FingerVein"); + case BioT_Iris: + return QObject::tr("Iris"); + case BioT_Face: + return QObject::tr("Face"); + case BioT_VoicePrint: + return QObject::tr("VoicePrint"); + case UniT_General_Ukey: + return QObject::tr("Ukey"); + case UniT_Remote: + return QObject::tr("QRCode"); + default: + return ""; + } +} + +QDebug operator <<(QDebug stream, const DeviceInfo &deviceInfo) +{ + stream << "[" + << deviceInfo.id + << deviceInfo.shortName + << deviceInfo.fullName + << deviceInfo.deviceType + << deviceInfo.driverEnable + << deviceInfo.deviceNum + << "]"; + return stream; +} + +QDBusArgument &operator <<(QDBusArgument &arg, const DeviceInfo &deviceInfo) +{ + arg.beginStructure(); + arg << deviceInfo.id + << deviceInfo.shortName + << deviceInfo.fullName + << deviceInfo.driverEnable + << deviceInfo.deviceNum + << deviceInfo.deviceType + << deviceInfo.storageType + << deviceInfo.eigType + << deviceInfo.verifyType + << deviceInfo.identifyType + << deviceInfo.busType + << deviceInfo.deviceStatus + << deviceInfo.OpsStatus; + arg.endStructure(); + return arg; +} +const QDBusArgument &operator >>(const QDBusArgument &arg, DeviceInfo &deviceInfo) +{ + arg.beginStructure(); + arg >> deviceInfo.id + >> deviceInfo.shortName + >> deviceInfo.fullName + >> deviceInfo.driverEnable + >> deviceInfo.deviceNum + >> deviceInfo.deviceType + >> deviceInfo.storageType + >> deviceInfo.eigType + >> deviceInfo.verifyType + >> deviceInfo.identifyType + >> deviceInfo.busType + >> deviceInfo.deviceStatus + >> deviceInfo.OpsStatus; + arg.endStructure(); + return arg; +} + +QDebug operator <<(QDebug stream, const FeatureInfo &featureInfo) +{ + stream << "[" + << featureInfo.uid + << featureInfo.biotype + << featureInfo.device_shortname + << featureInfo.index + << featureInfo.index_name + << "]"; + return stream; +} + +/* For the type FeatureInfo */ +QDBusArgument &operator<<(QDBusArgument &argument, const FeatureInfo &featureInfo) +{ + argument.beginStructure(); + argument << featureInfo.uid << featureInfo.biotype + << featureInfo.device_shortname << featureInfo.index + << featureInfo.index_name; + argument.endStructure(); + return argument; +} + +const QDBusArgument &operator>>(const QDBusArgument &argument, FeatureInfo &featureInfo) +{ + argument.beginStructure(); + argument >> featureInfo.uid >> featureInfo.biotype + >> featureInfo.device_shortname >> featureInfo.index + >> featureInfo.index_name; + argument.endStructure(); + return argument; +} diff --git a/BiometricAuth/biometricdeviceinfo.h b/src/common/biodefines.h similarity index 72% rename from BiometricAuth/biometricdeviceinfo.h rename to src/common/biodefines.h index e963fd7..3e791b3 100644 --- a/BiometricAuth/biometricdeviceinfo.h +++ b/src/common/biodefines.h @@ -3,7 +3,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) + * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, @@ -12,14 +12,16 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301, USA. **/ -#ifndef BIOMETRICDEVICEINFO_H -#define BIOMETRICDEVICEINFO_H -#include -#include +#ifndef BIODEFINES_H +#define BIODEFINES_H + +#include +#include #define BIOMETRIC_DBUS_SERVICE "org.ukui.Biometric" #define BIOMETRIC_DBUS_PATH "/org/ukui/Biometric" @@ -30,48 +32,6 @@ #define UKUI_BIOMETRIC_SYS_CONFIG_PATH "/etc/biometric-auth/ukui-biometric.conf" #define SHARE_BIOMETRIC_CONFIG_PATH "/var/lib/lightdm-data/%1/ukui-biometric.conf" //greeter、screensaver、polkit share conf -#define BIOMETRIC_PAM_DOUBLE "BIOMETRIC_PAM_DOUBLE" -#define BIOMETRIC_PAM "BIOMETRIC_PAM" -#define BIOMETRIC_PAM_QRCODE "BIOMETRIC_PAM_QRCODE" -#define BIOMETRIC_IGNORE "BIOMETRIC_IGNORE" -#define BIOMETRIC_SUCCESS "BIOMETRIC_SUCCESS" - -#define REMOTE_QRCODE_TYPE (8) - -/** - * @brief 设备类型 - */ -class DeviceType : public QObject -{ - Q_OBJECT -public: - DeviceType(); - enum Type { - FingerPrint, - FingerVein, - Iris, - Face, - VoicePrint, - __MAX_NR_TYPES - }; - Q_ENUM(Type) - /** - * @brief 获取设备类型的字符串表现形式 - * @param deviceType 设备类型 - * @return - */ - static QString getDeviceType(int deviceType); - - /** - * @brief 获取设备类型的国际化字符串 - * @param deviceType 设备类型 - * @return - */ - static QString getDeviceType_tr(int deviceType); - //根据设备优先级获取设备类型 - static int getBioType(int bioType); -}; - /** * @brief StatusChanged D-Bus 信号触发时的状态变化类型 */ @@ -191,12 +151,45 @@ typedef enum { OPS_CLOSE_MAX, }OpsResult; +/** + * @brief UpdateStauts调用返回的结果 + */ +struct StatusReslut +{ + int result; + int enable; + int devNum; + int devStatus; + int opsStatus; + int notifyMessageId; +}; + +/** + * @brief USB设备插拔动作 + */ +enum USBDeviceAction +{ + ACTION_ATTACHED = 1, + ACTION_DETACHED = -1 +}; + +/** + * @brief 特征的信息 + */ +struct FeatureInfo { + int uid; + int biotype; + QString device_shortname; + int index; + QString index_name; +}; + /** * @brief 设备的信息 */ struct DeviceInfo { - int id; + int id = -1; QString shortName; QString fullName; int driverEnable; @@ -211,81 +204,47 @@ struct DeviceInfo int OpsStatus; }; - -struct FeatureInfo { - int uid; - int biotype; - QString device_shortname; - int index; - QString index_name; -}; - -class QDBusArgument; - QDBusArgument &operator <<(QDBusArgument &arg, const DeviceInfo &deviceInfo); const QDBusArgument &operator >>(const QDBusArgument &arg, DeviceInfo &deviceInfo); QDBusArgument &operator<<(QDBusArgument &argument, const FeatureInfo &featureInfo); const QDBusArgument &operator>>(const QDBusArgument &argument, FeatureInfo &featureInfo); -void registerMetaType(); - typedef std::shared_ptr DeviceInfoPtr; typedef QList DeviceList; -typedef QMap DeviceMap; +typedef QMap DeviceMap; typedef std::shared_ptr FeatureInfoPtr; typedef QList FeatureList; typedef QMap FeatureMap; +QDebug operator <<(QDebug stream, const FeatureInfo &featureInfo); QDebug operator <<(QDebug stream, const DeviceInfo &deviceInfo); Q_DECLARE_METATYPE(DeviceInfo) Q_DECLARE_METATYPE(FeatureInfo) -/** - * @brief 获取默认设备 - * @return - */ -QString GetDefaultDevice(const QString &userName); +QString getDeviceTypeTr(int deviceType); -/** - * @brief 获取上次选择的设备 - * @return - */ -int GetLastDevice(const QString &userName); +typedef enum { + BioT_FingerPrint, /** 指纹 **/ + BioT_FingerVein, /** 指静脉 **/ + BioT_Iris, /** 虹膜 **/ + BioT_Face, /** 人脸 **/ + BioT_VoicePrint, /** 声纹 **/ -void SetLastDevice(const QString &userName, int drvid); + UniT_KCM, /** 安全管控 **/ + UniT_General_Ukey, /** 普通的Ukey **/ + UniT_Advanced_Ukey, /** 高阶的Ukey **/ + UniT_Remote, /** 远程账户 **/ + UniT_Custom = 0xFFFF /** 第三方 **/ +}BioType; -/** - * @brief 获取失败后自动重新开始的最大次数 - * @param userName - * @return - */ -int GetMaxFailedAutoRetry(const QString &userName); -/** - * @brief 获取超时后自动重新开始的最大次数 - * @param userName - * @return - */ -int GetMaxTimeoutAutoRetry(const QString &userName); -bool GetHiddenSwitchButton(); -int GetFailedTimes(); -bool GetAuthEnable(); -bool GetQRCodeEnable(); - -enum LOGINOPT_TYPE { - LOGINOPT_TYPE_PASSWORD = 0, // 密码 - LOGINOPT_TYPE_FACE, // 人脸 - LOGINOPT_TYPE_FINGERPRINT, // 指纹 - LOGINOPT_TYPE_IRIS, // 虹膜 - LOGINOPT_TYPE_VOICEPRINT, // 声纹 - LOGINOPT_TYPE_FINGERVEIN, // 指静脉 - LOGINOPT_TYPE_GENERAL_UKEY, // 普通的ukey - LOGINOPT_TYPE_ADVANCED_UKEY, // 高阶的ukey - LOGINOPT_TYPE_QRCODE, // 二维码 - LOGINOPT_TYPE_CUSTOM, // 第三方 - LOGINOPT_TYPE_OTHERS, // 其他 - LOGINOPT_TYPE_COUNT +enum BIOAUTH_STATE{ + BIOAUTH_IDLE = 0, + BIOAUTH_START, + BIOAUTH_TIMEOUT, + BIOAUTH_DEVICEREMOVED, + BIOAUTH_COMPLETE }; -#endif // BIOMETRICDEVICEINFO_H +#endif // BIODEFINES_H diff --git a/src/common/commonfunc.cpp b/src/common/commonfunc.cpp new file mode 100644 index 0000000..0eeab9b --- /dev/null +++ b/src/common/commonfunc.cpp @@ -0,0 +1,167 @@ +#include "commonfunc.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE +extern void qt_blurImage(QPainter *p, QImage &blurImage, qreal radius, bool quality, bool alphaOnly, int transposed = 0); +QT_END_NAMESPACE + +#define BLUR_RADIUS 300 +// 设置一下鼠标的居于主屏中央 +void setCursorCenter() +{ + auto setCursorPos = [ = ] (QPoint p) { + QCursor::setPos(p); + }; + + if (!qApp->primaryScreen()) { + QObject::connect(qApp, &QGuiApplication::primaryScreenChanged, [ = ] { + static bool first = true; + if (first) { + setCursorPos(qApp->primaryScreen()->geometry().center()); + first = false; + } + }); + } else { + setCursorPos(qApp->primaryScreen()->geometry().center()); + } +} + +/*修改图片缩放机制,图片长宽不一致时,先取图片中央的部分*/ +QPixmap scaledPixmap(QPixmap src) +{ + QPixmap rectPixmap; + if (src.width() > src.height()) { + QPixmap iconPixmap = src.copy((src.width() - src.height())/2, 0, src.height(), src.height()); + // 根据label高度等比例缩放图片 + rectPixmap = iconPixmap.scaledToHeight(src.height()); + } else { + QPixmap iconPixmap = src.copy(0, (src.height() - src.width())/2, src.width(), src.width()); + // 根据label宽度等比例缩放图片 + rectPixmap = iconPixmap.scaledToWidth(src.width()); + } + return rectPixmap; +} + +QPixmap PixmapToRound(const QPixmap &src, int radius) +{ + if (src.isNull()) { + return QPixmap(); + } + + QPixmap pixmapa(src); + QPixmap pixmap(radius*2,radius*2); + pixmap.fill(Qt::transparent); + QPainter painter(&pixmap); + painter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); + QPainterPath path; + path.addEllipse(0, 0, radius*2, radius*2); + painter.setClipPath(path); + painter.drawPixmap(0, 0, radius*2, radius*2, pixmapa); + return pixmap; +} + +const QPixmap loadSvg(const QString &path, const QString color, int size) +{ + int origSize = size; + const auto ratio = qApp->devicePixelRatio(); + if ( 2 == ratio) { + size += origSize; + } else if (3 == ratio) { + size += origSize; + } + QPixmap pixmap(size, size); + QSvgRenderer renderer(path); + pixmap.fill(Qt::transparent); + + QPainter painter; + painter.begin(&pixmap); + renderer.render(&painter); + painter.end(); + + pixmap.setDevicePixelRatio(ratio); + return drawSymbolicColoredPixmap(pixmap, color); +} + +QPixmap drawSymbolicColoredPixmap(const QPixmap &source, QString cgColor) +{ + QImage img = source.toImage(); + for (int x = 0; x < img.width(); x++) { + for (int y = 0; y < img.height(); y++) { + auto color = img.pixelColor(x, y); + if (color.alpha() > 0) { + if ( "white" == cgColor) { + color.setRed(255); + color.setGreen(255); + color.setBlue(255); + img.setPixelColor(x, y, color); + } else if( "black" == cgColor) { + color.setRed(0); + color.setGreen(0); + color.setBlue(0); + img.setPixelColor(x, y, color); + } else if ("gray"== cgColor) { + color.setRed(152); + color.setGreen(163); + color.setBlue(164); + img.setPixelColor(x, y, color); + } else if ("blue" == cgColor){ + color.setRed(61); + color.setGreen(107); + color.setBlue(229); + img.setPixelColor(x, y, color); + } else { + return source; + } + } + } + } + return QPixmap::fromImage(img); +} + +QPixmap getLoadingIcon(int size) +{ + QPixmap icon = QIcon::fromTheme("ukui-loading-0-symbolic").pixmap(size, size); + return drawSymbolicColoredPixmap(icon, "white"); +} + +QPixmap scaleBlurPixmap(int width, int height, QString url) +{ + QFile imgFile(url); + if(!imgFile.exists()){ + //qDebug()<< "pixmap file not exist!"; + return QPixmap(); + } + QImageReader imgReader; + imgReader.setFileName(url); + imgReader.setAutoTransform(true); + imgReader.setDecideFormatFromContent(true); + QPixmap pixmap = blurPixmap(QPixmap::fromImageReader(&imgReader)); + return pixmap.scaled(width, height, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation); +} + +QPixmap blurPixmap(QPixmap pixmap) +{ + QPainter painter(&pixmap); + QImage srcImg = pixmap.toImage(); + qt_blurImage(&painter, srcImg, BLUR_RADIUS, false, false); + + //在设置Qt::WA_TranslucentBackground属性后,模糊图片会导致锁屏界面透明 + //因此这里修改image图形的alpha值为255. + for (int y = 0;y < srcImg.height();++y) { + QRgb *row = (QRgb*)srcImg.scanLine(y); + for (int x = 0; x < srcImg.width(); ++x) { + ((unsigned char*)&row[x])[3] = 255; + } + } + painter.end(); + return QPixmap::fromImage(srcImg); +} diff --git a/src/common/commonfunc.h b/src/common/commonfunc.h new file mode 100644 index 0000000..b2e1c59 --- /dev/null +++ b/src/common/commonfunc.h @@ -0,0 +1,23 @@ +#ifndef COMMONFUNC_H +#define COMMONFUNC_H + +#include + +// 设置一下鼠标的居于主屏中央 +void setCursorCenter(); + +QPixmap scaledPixmap(QPixmap src); + +QPixmap PixmapToRound(const QPixmap &src, int radius); + +const QPixmap loadSvg(const QString &path, const QString color, int size); + +QPixmap drawSymbolicColoredPixmap(const QPixmap &source, QString cgColor); + +QPixmap getLoadingIcon(int size); + +QPixmap blurPixmap(QPixmap pixmap); + +QPixmap scaleBlurPixmap(int width, int height, QString url); + +#endif // COMMONFUNC_H diff --git a/src/common/configuration.cpp b/src/common/configuration.cpp new file mode 100644 index 0000000..6576ebd --- /dev/null +++ b/src/common/configuration.cpp @@ -0,0 +1,175 @@ +/* + * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301, USA. +**/ +#include "configuration.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define CONFIG_FILE "/etc/lightdm/ukui-greeter.conf" +#define PROC_CPUINFO "/proc/cpuinfo" + +Configuration::Configuration(QObject *parent) + : QObject(parent) +{ + QString recodfile = QDir::homePath() + "/.cache/ukui-greeter.conf"; + qDebug() << recodfile; + + configSettings = new QSettings(CONFIG_FILE, QSettings::IniFormat, this); + recordSettings = new QSettings(recodfile, QSettings::IniFormat, this); + userSetting = new QSettings(configPath, QSettings::IniFormat, this); +} + +QVariant Configuration::getValue(const QString &key) +{ + configSettings->beginGroup("Greeter"); + QVariant value = configSettings->value(key); + configSettings->endGroup(); + + return value; +} + +void Configuration::getCurrentUser(const QString userName) +{ + configPath = QString("/var/lib/lightdm-data/%1/ukui-greeter.conf").arg(userName); + userSetting = new QSettings(configPath, QSettings::IniFormat, this); +} + +QVariant Configuration::getUserConfig(const QString &key) +{ + userSetting->beginGroup("Greeter"); + QVariant value = userSetting->value(key); + userSetting->endGroup(); + qDebug() << " value = " << value ; + return value; +} + +void Configuration::setValue(const QString &key, const QVariant &value) +{ + configSettings->beginGroup("Greeter"); + configSettings->setValue(key, value); + configSettings->endGroup(); +} + +bool Configuration::hasValue(const QString &key) +{ + configSettings->beginGroup("Greeter"); + bool value = configSettings->contains(key); + configSettings->endGroup(); + + return value; +} + +QString Configuration::getLastLoginUser() +{ + recordSettings->beginGroup("Greeter"); + QString lastLoginUser = recordSettings->value("lastLoginUser").toString(); + recordSettings->endGroup(); + return lastLoginUser; +} + +void Configuration::saveLastLoginUser(const QString &userRealName) +{ + recordSettings->beginGroup("Greeter"); + recordSettings->setValue("lastLoginUser", userRealName); + recordSettings->endGroup(); + recordSettings->sync(); +} + +void Configuration::saveLastLoginUser1(const QString &userRealName) +{ + recordSettings->beginGroup("Greeter"); + recordSettings->setValue("lastLoginUser1", userRealName); + recordSettings->endGroup(); + recordSettings->sync(); +} + +bool Configuration::getLastNumLock() +{ + recordSettings->beginGroup("Greeter"); + if(recordSettings->contains("numlock") == false){ + recordSettings->setValue("numlock", true); + recordSettings->sync(); + recordSettings->endGroup(); + return true; + } + bool lastNumLock = recordSettings->value("numlock").toBool(); + recordSettings->endGroup(); + return lastNumLock; +} + +void Configuration::saveLastNumLock(bool value) +{ + recordSettings->beginGroup("Greeter"); + recordSettings->setValue("numlock", value); + recordSettings->endGroup(); + recordSettings->sync(); +} + +int Configuration::getRootBackgroundOption(QString userName) +{ + static QMap mapPicOptions = {{"scaled",0},{"stretched",1},{"centered",2},{"wallpaper",3},{"zoom",4},{"spanned",5}}; + QString userConfigurePath = QString("/var/lib/lightdm-data/%1/ukui-greeter.conf").arg(userName); + QFile backgroundFile(userConfigurePath); + if(backgroundFile.exists()){ + QSettings settings(userConfigurePath,QSettings::IniFormat); + settings.beginGroup("greeter"); + if(settings.contains("picture-options")){ + QString picOptions = settings.value("picture-options").toString(); + if(!picOptions.isEmpty() && mapPicOptions.contains(picOptions)){ + return mapPicOptions[picOptions]; + } + } + } + return 0; +} + +bool Configuration::getIs990() +{ + if(hasCheck990){ + return is990; + } + + hasCheck990 = true; + QRegExp r1("kirin.*9.0"); + r1.setCaseSensitivity(Qt::CaseInsensitive); + QRegExp r2("pangu.*m900"); + r2.setCaseSensitivity(Qt::CaseInsensitive); + + QFile file(PROC_CPUINFO); + if(!file.exists()){ + is990 = false; + return is990; + } + file.open(QFile::ReadOnly); + QString str(file.readAll()); + is990 = (str.contains(r1) || str.contains(r2)); + file.close(); + + if(is990) + qDebug()<<"is 990"; + + return is990; +} diff --git a/src/common/configuration.h b/src/common/configuration.h new file mode 100644 index 0000000..4c9f991 --- /dev/null +++ b/src/common/configuration.h @@ -0,0 +1,60 @@ +/* configuration.h + * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301, USA. +**/ +#ifndef CONFIGURATION_H +#define CONFIGURATION_H + +#include +#include +#include +#include +#include + +class Configuration : public QObject +{ + Q_OBJECT +public: + explicit Configuration(QObject *parent = nullptr); + +public: + QVariant getValue(const QString &); + QVariant getUserConfig(const QString &key); + void setValue(const QString&, const QVariant &); + bool hasValue(const QString &); + + void getCurrentUser(const QString userName); + QString getLastLoginUser(); + void saveLastLoginUser(const QString &); + void saveLastLoginUser1(const QString &); + bool getLastNumLock(); + void saveLastNumLock(bool value); + int getRootBackgroundOption(QString userName); + bool getIs990(); + +private: + QSettings *configSettings; + QSettings *recordSettings; + QSettings *userSetting; + QString configPath; + QGSettings *stylesettings = nullptr; + bool hasCheck990 = false; + bool is990 = false; + +}; + +#endif // CONFIGURATION_H diff --git a/src/common/definetypes.h b/src/common/definetypes.h new file mode 100644 index 0000000..05c3540 --- /dev/null +++ b/src/common/definetypes.h @@ -0,0 +1,311 @@ +/* + * Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * +**/ +#ifndef DEFINETYPES_H +#define DEFINETYPES_H + +typedef enum _LOCK_CMD_ID_e +{ + LOCK_CMD_ID_GET_USERINFO_LIST = 0, + LOCK_CMD_ID_USERINFO_CHANGED, + LOCK_CMD_ID_SET_USER, + LOCK_CMD_ID_GET_DEFAULT_AUTH_USER, + LOCK_CMD_ID_GET_CURRENT_USER, + LOCK_CMD_ID_CURRENT_USER_CHANGED, + LOCK_CMD_ID_GET_SESSIONS_LIST, + LOCK_CMD_ID_SESSIONS_CHANGED, + LOCK_CMD_ID_SET_SESSION, + LOCK_CMD_ID_GET_CURRENT_SESSION, + LOCK_CMD_ID_CURRENT_SESSION_CHANGED, + LOCK_CMD_ID_START_SESSION, + LOCK_CMD_ID_LOGIN1_REQ_LOCK = 100, + LOCK_CMD_ID_LOGIN1_REQ_UNLOCK, + LOCK_CMD_ID_LOGIN1_PREPAREFORSLEEP, + LOCK_CMD_ID_LOGIN1_SESSION_ACTIVE_CHANGED, + LOCK_CMD_ID_LOGIN1_IS_SESSION_ACTIVE, + LOCK_CMD_ID_LOGIN1_LIDSTATE_CHANGED, + LOCK_CMD_ID_LOGIN1_SET_POWER_MANAGER, + LOCK_CMD_ID_LOGIN1_GET_POWER_MANAGER_CANHIBERNATE, + LOCK_CMD_ID_LOGIN1_GET_POWER_MANAGER_CANPOWEROFF, + LOCK_CMD_ID_LOGIN1_GET_POWER_MANAGER_CANREBOOT, + LOCK_CMD_ID_LOGIN1_GET_POWER_MANAGER_CANSUSPEND, + LOCK_CMD_ID_GSETTINGS_GET_LOCKSCREEN_CONF = 200, + LOCK_CMD_ID_GSETTINGS_SET_LOCKSCREEN_CONF, + LOCK_CMD_ID_GSETTINGS_LOCKSCREEN_CONF_CHANGED, + LOCK_CMD_ID_GSETTINGS_GET_SCREENSAVER_CONF, + LOCK_CMD_ID_GSETTINGS_SET_SCREENSAVER_CONF, + LOCK_CMD_ID_GSETTINGS_SCREENSAVER_CONF_CHANGED, + LOCK_CMD_ID_GSETTINGS_GET_POWERMANAGER_CONF, + LOCK_CMD_ID_GSETTINGS_SET_POWERMANAGER_CONF, + LOCK_CMD_ID_GSETTINGS_POWERMANAGER_CONF_CHANGED, + LOCK_CMD_ID_GSETTINGS_GET_MATEBG_CONF, + LOCK_CMD_ID_GSETTINGS_SET_MATEBG_CONF, + LOCK_CMD_ID_GSETTINGS_MATEBG_CONF_CHANGED, + LOCK_CMD_ID_GSETTINGS_GET_UKCCPLUGINS_CONF, + LOCK_CMD_ID_GSETTINGS_SET_UKCCPLUGINS_CONF, + LOCK_CMD_ID_GSETTINGS_UKCCPLUGINS_CONF_CHANGED, + LOCK_CMD_ID_GSETTINGS_GET_THEMESTYLE_CONF, + LOCK_CMD_ID_GSETTINGS_SET_THEMESTYLE_CONF, + LOCK_CMD_ID_GSETTINGS_THEMESTYLE_CONF_CHANGED, + LOCK_CMD_ID_GSETTINGS_GET_SESSION_CONF, + LOCK_CMD_ID_GSETTINGS_SET_SESSION_CONF, + LOCK_CMD_ID_GSETTINGS_SESSION_CONF_CHANGED, + LOCK_CMD_ID_GSETTINGS_GET_KEYBOARD_CONF, + LOCK_CMD_ID_GSETTINGS_SET_KEYBOARD_CONF, + LOCK_CMD_ID_GSETTINGS_KEYBOARD_CONF_CHANGED, + LOCK_CMD_ID_GSETTINGS_GET_USD_MEDIAKEYS_CONF, + LOCK_CMD_ID_GSETTINGS_SET_USD_MEDIAKEYS_CONF, + LOCK_CMD_ID_GSETTINGS_USD_MEDIAKEYS_CONF_CHANGED, + LOCK_CMD_ID_GET_AGREEMENT = 300, + LOCK_CMD_ID_LOCK_STATE_CHANGED, + LOCK_CMD_ID_LIDSTATE_CHANGED, + LOCK_CMD_ID_PAMAUTH_IS_INAUTHTICATION = 400, + LOCK_CMD_ID_PAMAUTH_IS_AUTHENTICATED, + LOCK_CMD_ID_PAMAUTH_GET_AUTHUSER, + LOCK_CMD_ID_PAMAUTH_AUTHENTICATE, + LOCK_CMD_ID_PAMAUTH_RESPOND, + LOCK_CMD_ID_PAMAUTH_AUTHENTICATE_CANCEL, + LOCK_CMD_ID_PAMAUTH_SHOWMESSAGE, + LOCK_CMD_ID_PAMAUTH_SHOWPROMPT, + LOCK_CMD_ID_PAMAUTH_AUTH_COMPLETED, + LOCK_CMD_ID_USD_MEDIAKEYS = 500, + LOCK_CMD_ID_UPOWER_BATTERY_STATUS, + LOCK_CMD_ID_UPOWER_IS_BATTERY, + LOCK_CMD_ID_UPOWER_BATTERY, + LOCK_CMD_ID_SESSION_GET_SLEEP_LOCKCHECK, + LOCK_CMD_ID_SESSION_GET_SHUTDOWN_LOCKCHECK, + LOCK_CMD_ID_LOCK_SCREEN_GET_THEMES, + LOCK_CMD_ID_KWIN_BLOCK_SHORTCUT, + LOCK_CMD_ID_BIOAUTH_GET_AVAILABLE_DEVICES = 600, + LOCK_CMD_ID_BIOAUTH_GET_DISABLED_DEVICES, + LOCK_CMD_ID_BIOAUTH_GET_STATE, + LOCK_CMD_ID_BIOAUTH_GET_CURDEVICE, + LOCK_CMD_ID_BIOAUTH_FIND_DEVICE_BY_ID, + LOCK_CMD_ID_BIOAUTH_FIND_DEVICE_BY_NAME, + LOCK_CMD_ID_BIOAUTH_STARTAUTH, + LOCK_CMD_ID_BIOAUTH_STOPAUTH, + LOCK_CMD_ID_BIOAUTH_GET_DEFAULT_DEVICE, + LOCK_CMD_ID_BIOAUTH_SERVICE_STATUS_CHANGED, + LOCK_CMD_ID_BIOAUTH_DEVICE_CHANGED, + LOCK_CMD_ID_BIOAUTH_SHOW_MESSAGE, + LOCK_CMD_ID_BIOAUTH_AUTHSTATE_CHANGED, + LOCK_CMD_ID_BIOAUTH_FRAME_DATA, + LOCK_CMD_ID_BIOAUTH_COMPLETE, + LOCK_CMD_ID_COUNT +}LOCK_CMD_ID; + + +#define GSETTINGS_SCHEMA_SCREENSAVER "org.ukui.screensaver" +#define KEY_IDLE_DELAY "idleDelay" +#define KEY_IDLE_LOCK "idleLock" +#define KEY_IDLE_ACTIVATION_ENABLED "idleActivationEnabled" +#define KEY_IDLE_LOCK_ENABLED "idleLockEnabled" +#define KEY_LOCK_TIMEOUT "lockTimeout" +#define KEY_CLOSE_ACTIVATION_ENABLED "closeActivationEnabled" +#define KEY_SLEEP_ACTIVATION_ENABLED "sleepActivationEnabled" +#define KEY_LOCK_ENABLED "lockEnabled" +#define KEY_BACKGROUND "background" +#define KEY_MODE "mode" +#define KEY_THEMES "themes" +#define KEY_IMAGE_TRANSITION_EFFECT "image-transition-effect" +#define KEY_IMAGE_SWITCH_INTERVAL "image-switch-interval" + +#define GSETTINGS_SCHEMA_SCREENSAVER_DEFAULT "org.ukui.screensaver-default" +#define KEY_SHOW_REST_TIME "showRestTime" // old +#define KEY_SHOW_CUSTOM_REST_TIME "showCustomRestTime" +#define KEY_SHOW_UKUI_REST_TIME "showUkuiRestTime" +#define KEY_CYCLE_TIME "cycleTime" +#define KEY_AUTOMATIC_SWITCHING_ENABLE "automaticSwitchingEnabled" +#define KEY_BACKGROUND_PATH "backgroundPath" +#define KEY_MYTEXT "mytext" +#define KEY_TEXT_IS_CENTER "textIsCenter" +#define KEY_SHOW_MESSAGE_ENABLED "showMessageEnabled" +#define KEY_MESSAGE_NUMBER "messageNumber" +#define KEY_VIDEO_FORMAT "videoFormat" +#define KEY_VIDEO_HEIGHT "videoHeight" +#define KEY_VIDEO_WIDTH "videoWidth" +#define KEY_VIDEO_PATH "videoPath" +#define KEY_VIDEO_SIZE "videoSize" + +#define GSETTINGS_SCHEMA_POWER_MANAGER "org.ukui.power-manager" +#define KEY_LOCK_SUSPEND "lockSuspend" +#define KEY_LOCK_HIBERNATE "lockHibernate" +#define KEY_LOCK_BLANKSCREEN "lockBlankScreen" +#define KEY_SLEEP_COMPUTER_AC "sleepComputerAc" +#define KEY_SLEEP_DISPLAY_AC "sleepDisplayAc" +#define KEY_BUTTON_LID_AC "buttonLidAc" + +#define GSETTINGS_SCHEMA_MATE_BG "org.mate.background" +#define KEY_PICTURE_FILENAME "pictureFilename" +#define KEY_PICTURE_OPTIONS "pictureOptions" +#define KEY_PRIMARY_COLOR "primaryColor" + +#define GSETTINGS_SCHEMA_TIME_TYPE "org.ukui.control-center.panel.plugins" +#define KEY_HOUR_SYSTEM "hoursystem" +#define KEY_DATE "date" + +#define GSETTINGS_SCHEMA_STYLE "org.ukui.style" +#define KEY_SYSTEM_FONT_SIZE "systemFontSize" +#define GLIB_KEY_SYSTEM_FONT_SIZE "system-font-size" +#define KEY_THEME_COLOR "themeColor" + +#define GSETTINGS_SCHEMA_SESSION "org.ukui.session" +#define KEY_SESSION_IDLE "idleDelay" + +#define GSETTINGS_SCHEMA_PERIPHERALS_KEYBOARD "org.ukui.peripherals-keyboard" +#define KEY_CAPSLOCK_STATUS "capslockState" + +#define GSETTINGS_SCHEMA_MEDIAKEY_SCHEMA "org.ukui.SettingsDaemon.plugins.media-keys" +#define KEY_AREA_SCREENSHOT "areaScreenshot" +#define KEY_AREA_SCREENSHOT2 "areaScreenshot2" +#define KEY_SCREEN_SHOT "screenShot" +#define KEY_SCREEN_SHOT2 "screenShot2" +#define KEY_WINDOW_SCREENSHOT "windowScreenshot" + +#define WORKING_DIRECTORY "/usr/share/ukui-screensaver" + +#define SUBWND_COUNT_MAX 1024 + +#define SS_DBUS_SERVICE "org.ukui.ScreenSaver" +#define SS_DBUS_PATH "/" +#define SS_DBUS_INTERFACE "org.ukui.ScreenSaver" + +enum SessionStatus +{ + SESSION_AVAILABLE = 0, + SESSION_INVISIBLE = 1, + SESSION_BUSY = 2, + SESSION_IDLE = 3 +}; + +#define SM_DBUS_SERVICE "org.gnome.SessionManager" +#define SM_DBUS_PATH "/org/gnome/SessionManager/Presence" +#define SM_DBUS_INTERFACE "org.gnome.SessionManager.Presence" + +#define DM_DBUS_SERVICE "org.freedesktop.DisplayManager" +#define DM_DBUS_PATH "/org/freedesktop/DisplayManager" +#define DM_DBUS_INTERFACE "org.freedesktop.DisplayManager" +#define DM_SEAT_INTERFACE "org.freedesktop.DisplayManager.Seat" + +#define SSWND_DBUS_SERVICE "org.ukui.ScreenSaverWnd" +#define SSWND_DBUS_PATH "/" +#define SSWND_DBUS_INTERFACE "org.ukui.ScreenSaverWnd" + +#define DEFAULT_BACKGROUND_PATH "/usr/share/backgrounds/1-warty-final-ubuntukylin.jpg" + +#define G_FONT_SIZE (11.0) +#define DEFAULT_FONT_SIZE (10.0) + +#define XSCREENSAVER_DIRNAME "/usr/lib/xscreensaver" + +enum LOGINOPT_TYPE { + LOGINOPT_TYPE_PASSWORD = 0, // 密码 + LOGINOPT_TYPE_FACE, // 人脸 + LOGINOPT_TYPE_FINGERPRINT, // 指纹 + LOGINOPT_TYPE_IRIS, // 虹膜 + LOGINOPT_TYPE_VOICEPRINT, // 声纹 + LOGINOPT_TYPE_FINGERVEIN, // 指静脉 + LOGINOPT_TYPE_GENERAL_UKEY, // 普通的ukey + LOGINOPT_TYPE_ADVANCED_UKEY, // 高阶的ukey + LOGINOPT_TYPE_QRCODE, // 二维码 + LOGINOPT_TYPE_CUSTOM, // 第三方 + LOGINOPT_TYPE_OTHERS, // 其他 + LOGINOPT_TYPE_COUNT +}; + +#define BIOMETRIC_PAM_DOUBLE "BIOMETRIC_PAM_DOUBLE" +#define BIOMETRIC_PAM "BIOMETRIC_PAM" +#define BIOMETRIC_PAM_QRCODE "BIOMETRIC_PAM_QRCODE" +#define BIOMETRIC_IGNORE "BIOMETRIC_IGNORE" +#define BIOMETRIC_SUCCESS "BIOMETRIC_SUCCESS" + +namespace PamAuth { + +enum PromptType { + PromptTypeQuestion, + PromptTypeSecret +}; +enum MessageType { + MessageTypeInfo, + MessageTypeError +}; + +} + +// usd功能枚举(dbus接口参数) +typedef enum { + TOUCHPAD_KEY, + MUTE_KEY, + VOLUME_DOWN_KEY, + VOLUME_UP_KEY, + MIC_MUTE_KEY, + BRIGHT_UP_KEY, + BRIGHT_DOWN_KEY, + POWER_DOWN_KEY, + POWER_OFF_KEY, + EJECT_KEY, + HOME_KEY, + MEDIA_KEY, + CALCULATOR_KEY, + EMAIL_KEY, + SCREENSAVER_KEY, + HELP_KEY, + WWW_KEY, + PLAY_KEY, + PAUSE_KEY, + STOP_KEY, + PREVIOUS_KEY, + NEXT_KEY, + REWIND_KEY, + FORWARD_KEY, + REPEAT_KEY, + CURSOR_PROMPT_KEY, + RANDOM_KEY, + SETTINGS_KEY, + FILE_MANAGER_KEY, + SHUTDOWN_MANAGEMENT_KEY, + TERMINAL_KEY, + SCREENSHOT_KEY, + WINDOW_SCREENSHOT_KEY, + AREA_SCREENSHOT_KEY, + WINDOWSWITCH_KEY, + SYSTEM_MONITOR_KEY, + CONNECTION_EDITOR_KEY, + GLOBAL_SEARCH_KEY, + KDS_KEY, + WLAN_KEY, + WEBCAM_KEY, + HANDLED_KEYS, + UKUI_SIDEBAR, + UKUI_EYECARE_CENTER, + TOUCHPAD_ON_KEY, + TOUCHPAD_OFF_KEY, + RFKILL_KEY, + BLUETOOTH_KEY, + ASRASSISTANT, + PERFORMANCE_KEY, +} ActionType; + +#define UNIAUTH_DBUS_SERVICE "org.ukui.UniauthBackend" +#define UNIAUTH_DBUS_PATH "/org/ukui/UniauthBackend" +#define UNIAUTH_DBUS_INTERFACE "org.ukui.UniauthBackend" + +#define FD_DBUS_SERVICE "org.freedesktop.DBus" +#define FD_DBUS_PATH "/org/freedesktop/DBus" +#define FD_DBUS_INTERFACE "org.freedesktop.DBus" + +#endif // DEFINETYPES_H diff --git a/src/common/global_utils.cpp b/src/common/global_utils.cpp new file mode 100644 index 0000000..14c0076 --- /dev/null +++ b/src/common/global_utils.cpp @@ -0,0 +1,207 @@ +/* + * Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * +**/ +#include "global_utils.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define KYSDK_SYSINFO_DLL "/usr/lib/kysdk/kysdk-system/libkysysinfo.so" +typedef char* (*PFuncGetHostCloudPlatform)(); + +bool isGreeterMode() +{ + static int nIsGreeter = -1; + if (nIsGreeter < 0) { + QString username = getenv("USER"); + if (username == "lightdm") { + nIsGreeter = 1; + } else { + nIsGreeter = 0; + } + } + return (bool)(nIsGreeter); +} + +/** + * @brief 删除给定字符串前后的空格、制表符、换行符,注意该操作会修改原字符串 + * + * @param str 需要进行strip操作的字符串指针 + */ +static void strstripspace(char *str) +{ + if (strlen(str) == 0) + return; + char *startPos = str; + while (*startPos != '\0' && isspace(*startPos)) + startPos++; + if (*startPos == '\0') + { + str[0] = 0; + return; + } + + char *endPos = str + strlen(str) - 1; + while (endPos != str && isspace(*endPos)) + endPos --; + + memmove(str, startPos, endPos - startPos + 1); + *(str + (endPos - startPos) + 1) = 0; +} + +static char* kdk_system_get_hostCloudPlatform() +{ + char *cloudplat = (char *)malloc(sizeof(char) * 65); + if (!cloudplat) + return NULL; +#ifdef __linux__ + cloudplat[0] = 0; + char buf[256] = {0}; + bool res_flag = false; + if (geteuid() == 0) // root 用户,可以用dmidecode + { + FILE *pipeLine = popen("dmidecode -s chassis-manufacturer", "r"); + if (__glibc_likely(pipeLine != NULL)) + { + fgets(buf, 255 * sizeof(char), pipeLine); + strstripspace(buf); + if (strcmp(buf, "Huawei Inc.") == 0) // 华为云 + { + strcpy(cloudplat, "huawei"); + res_flag = true; + } + pclose(pipeLine); + } + if (!res_flag) + { + pipeLine = popen("dmidecode -s chassis-asset-tag", "r"); + if (__glibc_likely(pipeLine != NULL)) + { + fgets(buf, 255 * sizeof(char), pipeLine); + strstripspace(buf); + if (strcmp(buf, "HUAWEICLOUD") == 0) // 华为云 + { + strcpy(cloudplat, "huawei"); + } + pclose(pipeLine); + } + } + } + else // 普通用户,只能读取文件 + { + FILE *fp = fopen("/sys/devices/virtual/dmi/id/chassis_vendor", "rt"); + if (__glibc_likely(fp != NULL)) + { + fgets(buf, 255 * sizeof(char), fp); + strstripspace(buf); + if (strcmp(buf, "Huawei Inc.") == 0) // 华为云 + { + strcpy(cloudplat, "huawei"); + res_flag = true; + } + fclose(fp); + } + if (!res_flag) + { + fp = fopen("chassis_asset_tag", "r"); + if (__glibc_likely(fp != NULL)) + { + fgets(buf, 255 * sizeof(char), fp); + strstripspace(buf); + if (strcmp(buf, "HUAWEICLOUD") == 0) // 华为云 + { + strcpy(cloudplat, "huawei"); + } + fclose(fp); + } + } + } + + if (strlen(cloudplat) == 0) + strcpy(cloudplat, "none"); +#endif + return cloudplat; +} + +QString getHostCloudPlatform() +{ + static QString strPlatform = ""; + if (strPlatform.isEmpty()) { + void *kysdkSysinfoDll = NULL; + char *platForm = NULL; + PFuncGetHostCloudPlatform pFuncGetCloudPlatform = NULL; + kysdkSysinfoDll = dlopen(KYSDK_SYSINFO_DLL, RTLD_LAZY); + if (kysdkSysinfoDll) { + pFuncGetCloudPlatform = (PFuncGetHostCloudPlatform)dlsym(kysdkSysinfoDll, "kdk_system_get_hostCloudPlatform"); + } + if (!pFuncGetCloudPlatform) { + platForm = kdk_system_get_hostCloudPlatform(); + } else { + platForm = pFuncGetCloudPlatform(); + } + if (platForm) { + strPlatform = platForm; + free(platForm); + platForm = NULL; + } + if (kysdkSysinfoDll) { + dlclose(kysdkSysinfoDll); + kysdkSysinfoDll = NULL; + } + } + return strPlatform; +} + +bool isCommunity() +{ + static int sIsCommunity = -1; + if (sIsCommunity == -1) { + QString filename = "/etc/os-release"; + QSettings osSettings(filename, QSettings::IniFormat); + + QString versionID = osSettings.value("VERSION_ID").toString(); + + if (versionID.compare("22.04", Qt::CaseSensitive)) { + sIsCommunity = 0; + } else { + sIsCommunity = 1; + } + } + return (bool)(sIsCommunity); +} + +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"; + } + return ":/images/01-default-commercial.png"; + } +} diff --git a/src/ukss_interface.h b/src/common/global_utils.h similarity index 64% rename from src/ukss_interface.h rename to src/common/global_utils.h index b62effc..15888e9 100644 --- a/src/ukss_interface.h +++ b/src/common/global_utils.h @@ -15,17 +15,27 @@ * along with this program; if not, see . * **/ -#ifndef __UKSS_INTERFACE_H__ -#define __UKSS_INTERFACE_H__ +#ifndef GLOBAL_UTILS_H +#define GLOBAL_UTILS_H #include +#include "definetypes.h" -#if defined(UKSSSO_LIBRARY) -# define UKSSSO_EXPORT Q_DECL_EXPORT -#else -# define UKSSSO_EXPORT Q_DECL_IMPORT -#endif +/** + * @brief isGreeterMode 是否为欢迎界面模式,区分桌面锁屏 + * @return true 是,false 否 + */ +bool isGreeterMode(); -extern "C" UKSSSO_EXPORT int LockByBlank(QString strReason); +/** + * @brief getHostCloudPlatform 获取当前云平台环境 + * @return 云环境标识 + */ +QString getHostCloudPlatform(); -#endif // __UKSS_INTERFACE_H__ + +bool isCommunity(); + +QString getDefaultFace(); + +#endif // GLOBAL_UTILS_H diff --git a/Common/plasma-shell-manager.cpp b/src/common/plasma-shell-manager.cpp similarity index 98% rename from Common/plasma-shell-manager.cpp rename to src/common/plasma-shell-manager.cpp index e8336b4..eeea7e4 100644 --- a/Common/plasma-shell-manager.cpp +++ b/src/common/plasma-shell-manager.cpp @@ -19,7 +19,6 @@ #include "plasma-shell-manager.h" #include -#include #include #include @@ -32,9 +31,6 @@ static PlasmaShellManager* global_instance = nullptr; PlasmaShellManager *PlasmaShellManager::getInstance() { - if(QString(qgetenv("XDG_SESSION_TYPE")) != "wayland" || QX11Info::isPlatformX11()){ - return nullptr; - } if (!global_instance) { global_instance = new PlasmaShellManager; diff --git a/Common/plasma-shell-manager.h b/src/common/plasma-shell-manager.h similarity index 100% rename from Common/plasma-shell-manager.h rename to src/common/plasma-shell-manager.h diff --git a/src/common/rsac.cpp b/src/common/rsac.cpp new file mode 100644 index 0000000..0c6877d --- /dev/null +++ b/src/common/rsac.cpp @@ -0,0 +1,199 @@ +#include "rsac.h" +#include +#include + +RSA* publicKeyToRSA(const QByteArray &pubKey) +{ + BIO *pBio = BIO_new_mem_buf(pubKey.data(), pubKey.size()); // 创建内存 + RSA* rsa = PEM_read_bio_RSA_PUBKEY(pBio, nullptr, nullptr, nullptr); + BIO_free_all(pBio); // 释放内存 + return rsa; +} + +RSA* privateKeyToRSA(const QByteArray &priKey) +{ + BIO *pBio = BIO_new_mem_buf(priKey.data(), priKey.size()); // 创建内存 + RSA* rsa = PEM_read_bio_RSAPrivateKey(pBio, nullptr, nullptr, nullptr); + BIO_free_all(pBio); // 释放内存 + return rsa; +} + +/** + * @brief RSAC::generateKeyPair + * 生成密钥对,并分别保存为文件 + * @param priKeyFile 私钥文件名 + * @param pubKeyFile 公钥文件名 + * @param bits 秘钥长度,一般建议1024及以上 + */ +void RSAC::generateKeyPair(const QString &priKeyFile, const QString &pubKeyFile, int bits) +{ + // 生成公钥 + RSA* rsa = RSA_generate_key(bits, RSA_F4, nullptr, nullptr); + BIO *bp = BIO_new(BIO_s_file()); + BIO_write_filename(bp, (void*)pubKeyFile.toStdString().c_str()); + PEM_write_bio_RSAPublicKey(bp, rsa); + BIO_free_all(bp); + + // 生成私钥 + bp = BIO_new(BIO_s_file()); + BIO_write_filename(bp, (void*)priKeyFile.toStdString().c_str()); + PEM_write_bio_RSAPrivateKey(bp, rsa, nullptr, nullptr, 0, nullptr, nullptr); + CRYPTO_cleanup_all_ex_data(); + BIO_free_all(bp); + RSA_free(rsa); +} + +/** + * @brief RSAC::generateKeyPair + * 生成密钥对数据 + * @param privateKey 私钥数据 + * @param publicKey 公钥数据 + * @param bits 秘钥长度,一般建议1024及以上 + */ +void RSAC::generateKeyPair(QByteArray &privateKey, QByteArray &pubKey, int bits) +{ + // 生成密钥对 + RSA *keyPair = RSA_generate_key(bits, RSA_F4, nullptr, nullptr); + + BIO *pri = BIO_new(BIO_s_mem()); + BIO *pub = BIO_new(BIO_s_mem()); + + PEM_write_bio_RSAPrivateKey(pri, keyPair, nullptr, nullptr, 0, nullptr, nullptr); + PEM_write_bio_RSA_PUBKEY(pub, keyPair); + + // 获取长度 + int pri_len = BIO_pending(pri); + int pub_len = BIO_pending(pub); + + privateKey.resize(pri_len); + pubKey.resize(pub_len); + + BIO_read(pri, privateKey.data(), pri_len); + BIO_read(pub, pubKey.data(), pub_len); + + // 内存释放 + RSA_free(keyPair); + BIO_free_all(pub); + BIO_free_all(pri); +} + +/** + * @brief RSAC::encrypt + * RSA加密函数,使用公钥对输入数据,进行加密 + * @param in 输入数据(明文) + * @param out 输出数据(密文) + * @param pubKey 公钥 + * @return 执行结果 + */ +bool RSAC::encrypt(const QByteArray &in, QByteArray &out, const QByteArray& pubKey) +{ + // 公钥数据转RSA + RSA* rsa = publicKeyToRSA(pubKey); + if (rsa == nullptr) + { + return false; + } + + // 对任意长度数据进行加密,超长时,进行分段加密 + int keySize = RSA_size(rsa); + int dataLen = in.size(); + const unsigned char *from = (const unsigned char *)in.data(); + QByteArray to(keySize, 0); + int readLen = 0; + do + { + int select = (keySize - 11) > dataLen ? dataLen : (keySize - 11); + RSA_public_encrypt(select, (from + readLen), (unsigned char *)to.data(), rsa, RSA_PKCS1_PADDING); + dataLen -= select; + readLen += select; + out.append(to); + }while (dataLen > 0); + RSA_free(rsa); + return true; +} + +/** + * @brief RSAC::private_decrypt + * RSA解密函数,使用私钥对输入数据,进行解密 + * @param in 输入数据(密文) + * @param out 输出数据(解密后的内容) + * @param priKey 私钥 + * @return 执行结果 + */ +bool RSAC::decrypt(const QByteArray &in, QByteArray &out, const QByteArray& priKey) +{ + // 私钥数据转RSA + RSA* rsa = privateKeyToRSA(priKey); + if (rsa == nullptr) + { + return false; + } + + // 对任意长度数据进行解密,超长时,进行分段解密 + int keySize = RSA_size(rsa); + int dataLen = in.size(); + const unsigned char *from = (const unsigned char *)in.data(); + QByteArray to(keySize, 0); + int readLen = 0; + do + { + int size = RSA_private_decrypt(keySize, (from + readLen), (unsigned char *)to.data(), rsa, RSA_PKCS1_PADDING); + dataLen -= keySize; + readLen += keySize; + out.append(to.data(), size); + }while (dataLen > 0); + RSA_free(rsa); + return true; +} + +/** + * @brief RSAC::sign + * 使用私钥对摘要数据进行签名 + * @param digest 摘要数据 + * @param sign 签名后的数据 + * @param priKey 私钥 + * @return 执行结果 + */ +bool RSAC::sign(const QByteArray &digest, QByteArray &sign, const QByteArray& priKey) +{ + // 私钥数据转RSA + RSA* rsa = privateKeyToRSA(priKey); + if (rsa == nullptr) + { + return false; + } + + // 对digest进行签名 + unsigned int siglen = 0; + QByteArray temp(RSA_size(rsa), 0); + RSA_sign(NID_sha1, (const unsigned char*)digest.data(), digest.size(), + (unsigned char*)temp.data(), &siglen, rsa); + sign.clear(); + sign.append(temp.data(), siglen); + RSA_free(rsa); + return true; +} + +/** + * @brief RSAC::verify + * 使用公钥对摘要数据进行验签 + * @param digest 摘要数据 + * @param sign 签名后的数据 + * @param pubKey 公钥 + * @return 执行结果 + */ +bool RSAC::verify(const QByteArray &digest, const QByteArray &sign, const QByteArray& pubKey) +{ + // 公钥数据转RSA + RSA* rsa = publicKeyToRSA(pubKey); + if (rsa == nullptr) + { + return false; + } + + // 对digest、sign进行验签 + int ret = RSA_verify(NID_sha1, (const unsigned char*)digest.data(), digest.size(), + (const unsigned char *)sign.data(), sign.size(), rsa); + RSA_free(rsa); + return (ret == 1); +} diff --git a/src/common/rsac.h b/src/common/rsac.h new file mode 100644 index 0000000..93d4678 --- /dev/null +++ b/src/common/rsac.h @@ -0,0 +1,26 @@ +#ifndef RSAC_H +#define RSAC_H + +#include + +/** + * @brief The RSAC class + * RSA算法相关实现,包括密钥对生成,加密与解密,签名与验签。 + */ +class RSAC +{ +public: + // 生成秘钥对 + void generateKeyPair(const QString& priKeyFile, const QString &pubKeyFile, int bits = 1024); + void generateKeyPair(QByteArray& priKey, QByteArray& pubKey, int bits = 1024); + + // 对数据进行加解密 + bool encrypt(const QByteArray& in, QByteArray& out, const QByteArray& pubKey); + bool decrypt(const QByteArray& in, QByteArray& out, const QByteArray& priKey); + + // 对摘要进行签名和验签 + bool sign(const QByteArray& digest, QByteArray& sign, const QByteArray &priKey); + bool verify(const QByteArray& digest, const QByteArray &sign, const QByteArray &pubKey); +}; + +#endif // RSAC_H diff --git a/src/common/utils.cpp b/src/common/utils.cpp new file mode 100644 index 0000000..695645b --- /dev/null +++ b/src/common/utils.cpp @@ -0,0 +1,152 @@ +/* + * Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * +**/ +#include "utils.h" +#include "definetypes.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DRM_DIR "/sys/class/leds/" + +void checkIslivecd() +{ + char cmd[128] = {0}; + char str[1024]; + FILE *fp = NULL; + + int n = sprintf(cmd, "cat /proc/cmdline"); + Q_UNUSED(n) + + fp = popen(cmd, "r"); + while(fgets(str, sizeof(str)-1, fp)) { + if(strstr(str,"boot=casper")) { + printf("is livecd\n"); + exit(0); + } + } + pclose(fp); + + QString filepath = QDir::homePath() + "/Desktop" + "/kylin-os-installer.desktop"; + QFileInfo file(filepath); + if(!file.exists()) + return; + if(getuid() != 999) + return; + exit(0); +} + +void KillFocusOfKydroid() +{ + if (!isGreeterMode()) { + QString username = getenv("USER"); + int uid = getuid(); + QDBusInterface *interface = new QDBusInterface("cn.kylinos.Kydroid2", + "/cn/kylinos/Kydroid2", + "cn.kylinos.Kydroid2", + QDBusConnection::systemBus()); + if (interface) { + QDBusPendingCall pendingCall = interface->asyncCall(QStringLiteral("SetPropOfContainer"), username, uid, "is_kydroid_on_focus", "0"); + Q_UNUSED(pendingCall); + interface->deleteLater(); + interface = nullptr; + } + } +} + +/** + * @brief 判断大写键状态 + * @return true: 大写锁定 + */ +bool checkCapsLockState() +{ + QDir ledDir(DRM_DIR); + QStringList leds = ledDir.entryList(QDir::Dirs); + QString capsFile; + + for(int i = 0;i. * **/ -#ifndef GLIBINTERFACE_H -#define GLIBINTERFACE_H +#ifndef UTILS_H +#define UTILS_H + +#include "global_utils.h" + +/** + * @brief checkIslivecd 检查是否为试用模式,试用模式直接退出进程 + */ +void checkIslivecd(); + +/** + * @brief KillFocusOfKydroid 通知Kydroid组件取消焦点 + */ +void KillFocusOfKydroid(); + +/** + * @brief 判断大写键状态 + * @return true: 大写锁定 + */ +bool checkCapsLockState(); + +bool ispicture(QString filepath); double getDefaultFontSize(); -#endif // LOCKWIDGET_H - +#endif // UTILS_H diff --git a/src/configuration.cpp b/src/configuration.cpp deleted file mode 100644 index 639b7e7..0000000 --- a/src/configuration.cpp +++ /dev/null @@ -1,290 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#include "configuration.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "glibinterface.h" -#include -#include -#include -#include -#include - -#include "commonfunc.h" -#define GSETTINGS_SCHEMA_SCREENSAVER "org.ukui.screensaver" -#define GSETTINGS_SCHEMA_STYLE "org.ukui.style" -#define KEY_MODE "mode" -#define KEY_THEMES "themes" -#define KEY_FONT_SIZE "systemFontSize" -#define KEY_IDLE_ACTIVATION_ENABLED "idle-activation-enabled" -#define KEY_LOCK_ENABLED "lock-enabled" -#define KEY_IMAGE_TRANSITION_EFFECT "image-transition-effect" -#define KEY_IMAGE_SWITCH_INTERVAL "image-switch-interval" -#define KEY_BACKGROUND "background" -#define XSCREENSAVER_DIRNAME "/usr/lib/xscreensaver" -#define KEY_IDLE_DELAY "idleDelay" -#define KEY_IDLE_LOCK "idleLock" -#define KEY_LOCK_TIMEOUT "lockTimeout" - -Configuration* Configuration::instance_ = nullptr; - -Configuration::Configuration(QObject *parent) : QObject(parent) -{ - /* QGSettings for screensaver */ - gsettings = new QGSettings(GSETTINGS_SCHEMA_SCREENSAVER, "", this); - connect(gsettings, &QGSettings::changed, - this, &Configuration::onConfigurationChanged); - - /* Initiailization */ - mode = gsettings->get(KEY_MODE).toString(); - themes = gsettings->get(KEY_THEMES).toStringList(); - idleDelay = gsettings->get(KEY_IDLE_DELAY).toInt(); - lockEnabled = gsettings->get(KEY_LOCK_ENABLED).toBool(); - idleLock = gsettings->get(KEY_IDLE_LOCK).toInt(); - imageSwitchInterval = gsettings->get(KEY_IMAGE_SWITCH_INTERVAL).toInt(); - imageTSEffect = gsettings->get(KEY_IMAGE_TRANSITION_EFFECT).toInt(); - background = gsettings->get(KEY_BACKGROUND).toString(); - QStringList keysScreenSaver = gsettings->keys(); - if (keysScreenSaver.contains(KEY_LOCK_TIMEOUT)) { - m_nLockTimeout = gsettings->get(KEY_LOCK_TIMEOUT).toInt(); - } - - qDebug() << mode << themes; - qDebug() << imageSwitchInterval << imageTSEffect; - - int FileisExist = 0; - if(!background.isEmpty()) - { - QFileInfo file(background); - if(file.exists()==false) - FileisExist = 0; - else - FileisExist = 1; - } - - //如果org.ukui.screensaver background中的背景图片为空,则设为桌面背景 - if(background.isEmpty()||0==FileisExist) - { - QString currentDesktop = qgetenv("XDG_CURRENT_DESKTOP"); - if(currentDesktop == "UKUI" || currentDesktop == "MATE") - { - bgGsettings = new QGSettings("org.mate.background"); - background = bgGsettings->get("picture-filename").toString(); - } - else if(currentDesktop == "ubuntu:GNOME") - { - bgGsettings = new QGSettings("org.gnome.desktop.background"); - background = bgGsettings->get("picture-uri").toString(); - //去除前缀:file:///usr/share/background/xxx.png - background.remove(0, 7); - } - } - qDebug() << "background: " << background; - - if(themes.count() == 1 && themes[0] == "kyccss-personal-slideshow") - mode ="image"; - - fsGsettings = new QGSettings(GSETTINGS_SCHEMA_STYLE); - - double defaultFontSize = getDefaultFontSize(); - - qDebug()<<"defaultFontSize = "<get(KEY_FONT_SIZE).toDouble() - defaultFontSize; -} - -Configuration* Configuration::instance(QObject *parent) -{ - if(instance_ == nullptr) - instance_ = new Configuration(parent); - return instance_; -} - -/* Update member value when GSettings changed */ -void Configuration::onConfigurationChanged(QString key) -{ - qDebug() << "GSettings value changed, key = " << key; - if (key == KEY_MODE) - mode = gsettings->get(KEY_MODE).toString(); - else if (key == KEY_THEMES) - themes = gsettings->get(KEY_THEMES).toStringList(); - else if (key == KEY_IDLE_DELAY) - idleDelay = gsettings->get(KEY_IDLE_DELAY).toInt(); - else if (key == KEY_IDLE_LOCK) - idleLock = gsettings->get(KEY_IDLE_LOCK).toInt(); - else if(key == KEY_IMAGE_TRANSITION_EFFECT) - imageTSEffect = gsettings->get(KEY_IMAGE_TRANSITION_EFFECT).toInt(); - else if(key == KEY_IMAGE_SWITCH_INTERVAL) - imageSwitchInterval = gsettings->get(KEY_IMAGE_SWITCH_INTERVAL).toInt(); - else if (key == KEY_LOCK_TIMEOUT) - m_nLockTimeout = gsettings->get(KEY_LOCK_TIMEOUT).toInt(); -} - -/* - * Getter - */ - -/* Get the executable path of xscreensaver */ -ScreenSaver *Configuration::getScreensaver() -{ - QStringList modeStr{"blank-only", "random", "single", "image","default-ukui","default-ukui-custom"}; - ScreenSaver *saver = new ScreenSaver; - int index = modeStr.indexOf(mode); - saver->mode = SaverMode(index); - saver->interval = imageSwitchInterval; - saver->effect = TransitionEffect(imageTSEffect); - - switch(index){ - case SAVER_BLANK_ONLY: - break; - case SAVER_RANDOM: - { - if(themes.count()==0){ - saver->path = "/usr/lib/ukui-screensaver/ukui-screensaver-default"; - break; - } - qsrand((unsigned)time(0)); - int index = qrand() % themes.count(); - while(QString::compare(themes[index], "kyccss-personal-slideshow")==0) - { - index = qrand() % themes.count(); - } - saver->path = getXScreensaverPath(themes[index]); - break; - } - case SAVER_SINGLE: - if(themes.count()==0){ - saver->path = "/usr/lib/ukui-screensaver/ukui-screensaver-default"; - break; - } - saver->path = getXScreensaverPath(themes[0]); - break; - case SAVER_IMAGE: - { - QString lang = qgetenv("LANG"); - if (!lang.isEmpty()){ - qDebug()<<"lang = "<path = QDir::homePath() + "/图片"; - break; - } - } - saver->path = QDir::homePath() + "/" + QStandardPaths::displayName(QStandardPaths::PicturesLocation); - break; - } - case SAVER_DEFAULT: - saver->path = "/usr/lib/ukui-screensaver/ukui-screensaver-default"; - break; - case SAVER_DEFAULT_CUSTOM: - saver->path = "/usr/lib/ukui-screensaver/ukui-screensaver-default"; - break; - default: - break; - } - return saver; -} - -QString Configuration::getXScreensaverPath(const QString &theme) -{ - /* screensavers-ukui-binaryring => binaryring */ - QStringList strs = theme.split("-"); - QString str = strs.at(strs.size() - 1); - QString filePath = QString("%1/%2").arg(XSCREENSAVER_DIRNAME, str); - //除了判断gsetting值是否为空,还需要判断屏保文件是否存在,不存在就使用默认屏保。 - if(QFile(filePath).exists()) - return filePath; - else - return "/usr/lib/ukui-screensaver/ukui-screensaver-default"; -} - -QString Configuration::getBackground() -{ - if(ispicture(background)) - return background; - - char *systemName = kdk_system_get_systemName(); - if (systemName) { - if (QString(systemName) == "openKylin") { - free(systemName); - return "/usr/share/backgrounds/1-openkylin.jpg"; - } - free(systemName); - } - return "/usr/share/backgrounds/1-warty-final-ubuntukylin.jpg"; -} - -QString Configuration::getDefaultBackgroundName() -{ - return "/usr/share/backgrounds/1-warty-final-ubuntukylin.jpg"; -} - -bool Configuration::lockWhenXScreensaverActivated() -{ - return lockEnabled; -} - -int Configuration::idlelock() -{ - return idleLock; -} - -int Configuration::idledelay() -{ - return idleDelay; -} - -int Configuration::locktimeout() -{ - return m_nLockTimeout; -} - -double Configuration::getFontSize() -{ - return curFontSize; -} - -double Configuration::getPtToPx() -{ - if (QApplication::primaryScreen()->logicalDotsPerInch() > 0) - m_pxToPt = 72/(QApplication::primaryScreen()->logicalDotsPerInch()); - return m_pxToPt; -} - -QString Configuration::getHostCloudPlatform() -{ - static QString strPlatform = ""; - if (strPlatform.isEmpty()) { - char *platForm = kdk_system_get_hostCloudPlatform(); - if (platForm) { - strPlatform = platForm; - free(platForm); - platForm = NULL; - } - } - return strPlatform; -} diff --git a/src/configuration.h b/src/configuration.h deleted file mode 100644 index d5bb49d..0000000 --- a/src/configuration.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#ifndef CONFIGURATION_H -#define CONFIGURATION_H - -#ifndef QT_NO_KEYWORDS -#define QT_NO_KEYWORDS -#endif - -//#include "gsettings.h" - -#include -#include "screensavermode.h" - -class QGSettings; - -class Configuration : public QObject -{ - Q_OBJECT -private: - explicit Configuration(QObject *parent = nullptr); - -public: - ScreenSaver *getScreensaver(); - static Configuration *instance(QObject *parent = nullptr); - QString getBackground(); - QString getDefaultBackgroundName(); - bool lockWhenXScreensaverActivated(); - int idlelock(); - int idledelay(); - int locktimeout(); - double getFontSize(); - double getPtToPx(); - QString getHostCloudPlatform(); - -public Q_SLOTS: - void onConfigurationChanged(QString key); - -private: - QString getXScreensaverPath(const QString &theme); - -private: - QGSettings *gsettings; - QGSettings *bgGsettings; - QGSettings *fsGsettings; - QString mode; - double curFontSize; - double m_pxToPt = 1.0; - QList themes; - QString background; - bool idleActivationEnabled; - bool lockEnabled; - int idleDelay = -1; - int idleLock = -1; - int imageTSEffect; - int imageSwitchInterval; - static Configuration *instance_; - int m_nLockTimeout = -1; -}; - -#endif // CONFIGURATION_H diff --git a/src/dbusifs/accountservicehelper.cpp b/src/dbusifs/accountservicehelper.cpp new file mode 100644 index 0000000..98319cd --- /dev/null +++ b/src/dbusifs/accountservicehelper.cpp @@ -0,0 +1,106 @@ +/* + * Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * +**/ +#include "accountservicehelper.h" +#include +#include +#include +#include + +const static QString accountsService = QStringLiteral("org.freedesktop.Accounts"); +const static QString accountsPath = QStringLiteral("/org/freedesktop/Accounts"); +const static QString accountsInterface = QStringLiteral("org.freedesktop.Accounts"); +const static QString propertiesInterface = QStringLiteral("org.freedesktop.DBus.Properties"); +const static QString accountsUserInterface = QStringLiteral("org.freedesktop.Accounts.User"); + +AccountServiceHelper::AccountServiceHelper(QObject *parent) + : QObject(parent) +{ + m_accountsInterface = new QDBusInterface(accountsService, + accountsPath, + accountsInterface, + QDBusConnection::systemBus(), + this); +} + +AccountServiceHelper::~AccountServiceHelper() +{ + +} + +QString AccountServiceHelper::getUserLanguageByName(QString strUserName) +{ + QString strLanguage = ""; + if(!m_accountsInterface) + return strLanguage; + QDBusReply userPath = m_accountsInterface->call("FindUserByName", strUserName); + if(!userPath.isValid()) + qWarning() << "Get UserPath error:" << userPath.error(); + else { + QDBusInterface userIface(accountsService, userPath.value().path(), + propertiesInterface, QDBusConnection::systemBus()); + QDBusReply languageReply = userIface.call("Get", accountsUserInterface, "Language"); + if(!languageReply.isValid()) + qWarning() << "Get User's language error" << languageReply.error(); + else { + strLanguage = languageReply.value().variant().toString(); + } + } + return strLanguage; +} + +QString AccountServiceHelper::getUserBackgroundByName(QString strUserName) +{ + QString strBackground = ""; + if(!m_accountsInterface) + return strBackground; + QDBusReply userPath = m_accountsInterface->call("FindUserByName", strUserName); + if(!userPath.isValid()) + qWarning() << "Get UserPath error:" << userPath.error(); + else { + QDBusInterface userIface(accountsService, userPath.value().path(), + propertiesInterface, QDBusConnection::systemBus()); + QDBusReply backgroundReply = userIface.call("Get", accountsUserInterface, "BackgroundFile"); + if(!backgroundReply.isValid()) + qWarning() << "Get User's background error" << backgroundReply.error(); + else { + strBackground = backgroundReply.value().variant().toString(); + } + } + return strBackground; +} + +QString AccountServiceHelper::getUserSessionByName(QString strUserName) +{ + QString strSession = ""; + if(!m_accountsInterface) + return strSession; + QDBusReply userPath = m_accountsInterface->call("FindUserByName", strUserName); + if(!userPath.isValid()) + qWarning() << "Get UserPath error:" << userPath.error(); + else { + QDBusInterface userIface(accountsService, userPath.value().path(), + propertiesInterface, QDBusConnection::systemBus()); + QDBusReply sessionReply = userIface.call("Get", accountsUserInterface, "XSession"); + if(!sessionReply.isValid()) + qWarning() << "Get User's xsession error" << sessionReply.error(); + else { + strSession = sessionReply.value().variant().toString(); + } + } + return strSession; +} diff --git a/src/klabel.h b/src/dbusifs/accountservicehelper.h similarity index 59% rename from src/klabel.h rename to src/dbusifs/accountservicehelper.h index c96b00b..376a05b 100644 --- a/src/klabel.h +++ b/src/dbusifs/accountservicehelper.h @@ -15,26 +15,28 @@ * along with this program; if not, see . * **/ -#ifndef KLABEL_H -#define KLABEL_H +#ifndef ACCOUNTSERVICEHELPER_H +#define ACCOUNTSERVICEHELPER_H -#include +#include +#include -class Configuration; - -class KLabel : public QLabel +class AccountServiceHelper : public QObject { Q_OBJECT public: - KLabel(QWidget *parent = nullptr); - void setFontSize(int fontSize); - void setElideText(const QString text, int width, int size = 16); + explicit AccountServiceHelper(QObject *parent = nullptr); + + virtual ~AccountServiceHelper(); + + QString getUserLanguageByName(QString strUserName); + + QString getUserBackgroundByName(QString strUserName); + + QString getUserSessionByName(QString strUserName); private: - Configuration *configuration; - double curFontSize; - double m_ptToPx = 1.0; - QFont sysFont; + QDBusInterface *m_accountsInterface = nullptr; }; -#endif // KLABEL_H +#endif // ACCOUNTSERVICEHELPER_H diff --git a/BiometricAuth/biometricproxy.cpp b/src/dbusifs/biometrichelper.cpp similarity index 87% rename from BiometricAuth/biometricproxy.cpp rename to src/dbusifs/biometrichelper.cpp index 9f2513e..e89dcc2 100644 --- a/BiometricAuth/biometricproxy.cpp +++ b/src/dbusifs/biometrichelper.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. + * Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -15,36 +15,35 @@ * along with this program; if not, see . * **/ -#include "biometricproxy.h" +#include "biometrichelper.h" #include #include -BiometricProxy::BiometricProxy(QObject *parent) +BiometricHelper::BiometricHelper(QObject *parent) : QDBusAbstractInterface(BIOMETRIC_DBUS_SERVICE, BIOMETRIC_DBUS_PATH, BIOMETRIC_DBUS_INTERFACE, QDBusConnection::systemBus(), parent) { - registerMetaType(); setTimeout(2147483647); } -QDBusPendingCall BiometricProxy::Identify(int drvid, int uid, int indexStart, int indexEnd) +QDBusPendingCall BiometricHelper::Identify(int drvid, int uid, int indexStart, int indexEnd) { QList argList; argList << drvid << uid << indexStart << indexEnd; return asyncCallWithArgumentList(QStringLiteral("Identify"), argList); } -QDBusPendingCall BiometricProxy::UkeyIdentify(int drvid, int type, int uid) +QDBusPendingCall BiometricHelper::UkeyIdentify(int drvid, int type, int uid) { QList argList; argList << drvid << type << uid; return asyncCallWithArgumentList(QStringLiteral("UkeyIdentify"), argList); } -bool BiometricProxy::GetHasUkeyFeature(int uid, int indexStart, int indexEnd) +bool BiometricHelper::GetHasUkeyFeature(int uid, int indexStart, int indexEnd) { QList qlist; FeatureInfo *featureInfo; @@ -61,7 +60,7 @@ bool BiometricProxy::GetHasUkeyFeature(int uid, int indexStart, int indexEnd) for (int i = 0; i < listsize; i++) { featureInfo = new FeatureInfo; qlist[i].variant().value() >> *featureInfo; - if(featureInfo->biotype == LOGINOPT_TYPE_GENERAL_UKEY){ + if(featureInfo->biotype == UniT_General_Ukey){ delete featureInfo; return true; } @@ -72,7 +71,7 @@ bool BiometricProxy::GetHasUkeyFeature(int uid, int indexStart, int indexEnd) } -int BiometricProxy::GetFeatureCount(int uid, int indexStart, int indexEnd) +int BiometricHelper::GetFeatureCount(int uid, int indexStart, int indexEnd) { QDBusMessage result = call(QStringLiteral("GetDevList")); if(result.type() == QDBusMessage::ErrorMessage) @@ -103,7 +102,7 @@ int BiometricProxy::GetFeatureCount(int uid, int indexStart, int indexEnd) return res; } -int BiometricProxy::SetExtraInfo(QString info_type,QString extra_info) +int BiometricHelper::SetExtraInfo(QString info_type,QString extra_info) { QDBusReply reply = call(QStringLiteral("SetExtraInfo"), info_type, extra_info); if(!reply.isValid()) @@ -114,7 +113,7 @@ int BiometricProxy::SetExtraInfo(QString info_type,QString extra_info) return reply.value(); } -int BiometricProxy::StopOps(int drvid, int waiting) +int BiometricHelper::StopOps(int drvid, int waiting) { QDBusReply reply = call(QStringLiteral("StopOps"), drvid, waiting); if(!reply.isValid()) @@ -125,7 +124,7 @@ int BiometricProxy::StopOps(int drvid, int waiting) return reply.value(); } -int BiometricProxy::GetUserDevCount(int uid) +int BiometricHelper::GetUserDevCount(int uid) { QDBusMessage result = call(QStringLiteral("GetDevList")); if(result.type() == QDBusMessage::ErrorMessage) @@ -153,7 +152,7 @@ int BiometricProxy::GetUserDevCount(int uid) return deviceList.count(); } -int BiometricProxy::GetUserDevFeatureCount(int uid,int drvid) +int BiometricHelper::GetUserDevFeatureCount(int uid,int drvid) { StopOps(drvid); QDBusMessage FeatureResult = call(QStringLiteral("GetFeatureList"),drvid,uid,0,-1); @@ -165,7 +164,7 @@ int BiometricProxy::GetUserDevFeatureCount(int uid,int drvid) return FeatureResult.arguments().takeFirst().toInt(); } -DeviceList BiometricProxy::GetDevList() +DeviceList BiometricHelper::GetDevList() { QDBusMessage result = call(QStringLiteral("GetDevList")); if(result.type() == QDBusMessage::ErrorMessage) @@ -191,7 +190,7 @@ DeviceList BiometricProxy::GetDevList() return deviceList; } -FeatureMap BiometricProxy::GetUserFeatures(int uid) +FeatureMap BiometricHelper::GetUserFeatures(int uid) { FeatureMap featureMap; QList qlist; @@ -213,7 +212,7 @@ FeatureMap BiometricProxy::GetUserFeatures(int uid) return featureMap; } -int BiometricProxy::GetDevCount() +int BiometricHelper::GetDevCount() { QDBusMessage result = call(QStringLiteral("GetDevList")); if(result.type() == QDBusMessage::ErrorMessage) @@ -225,7 +224,7 @@ int BiometricProxy::GetDevCount() return count; } -QString BiometricProxy::GetDevMesg(int drvid) +QString BiometricHelper::GetDevMesg(int drvid) { QDBusMessage result = call(QStringLiteral("GetDevMesg"), drvid); if(result.type() == QDBusMessage::ErrorMessage) @@ -236,7 +235,7 @@ QString BiometricProxy::GetDevMesg(int drvid) return result.arguments().at(0).toString(); } -QString BiometricProxy::GetNotifyMesg(int drvid) +QString BiometricHelper::GetNotifyMesg(int drvid) { QDBusMessage result = call(QStringLiteral("GetNotifyMesg"), drvid); if(result.type() == QDBusMessage::ErrorMessage) @@ -247,7 +246,7 @@ QString BiometricProxy::GetNotifyMesg(int drvid) return result.arguments().at(0).toString(); } -QString BiometricProxy::GetOpsMesg(int drvid) +QString BiometricHelper::GetOpsMesg(int drvid) { QDBusMessage result = call(QStringLiteral("GetOpsMesg"), drvid); if(result.type() == QDBusMessage::ErrorMessage) @@ -258,7 +257,7 @@ QString BiometricProxy::GetOpsMesg(int drvid) return result.arguments().at(0).toString(); } -StatusReslut BiometricProxy::UpdateStatus(int drvid) +StatusReslut BiometricHelper::UpdateStatus(int drvid) { StatusReslut status; QDBusMessage result = call(QStringLiteral("UpdateStatus"), drvid); diff --git a/BiometricAuth/biometricproxy.h b/src/dbusifs/biometrichelper.h similarity index 87% rename from BiometricAuth/biometricproxy.h rename to src/dbusifs/biometrichelper.h index 5395ed7..ebd8fb9 100644 --- a/BiometricAuth/biometricproxy.h +++ b/src/dbusifs/biometrichelper.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. + * Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -15,44 +15,19 @@ * along with this program; if not, see . * **/ -#ifndef BIOMETRICPROXY_H -#define BIOMETRICPROXY_H +#ifndef BIOMETRICHELPER_H +#define BIOMETRICHELPER_H #include #include #include -#include "biometricdeviceinfo.h" +#include "biodefines.h" -/** - * @brief UpdateStauts调用返回的结果 - */ -struct StatusReslut -{ - int result; - int enable; - int devNum; - int devStatus; - int opsStatus; - int notifyMessageId; -}; - -/** - * @brief USB设备插拔动作 - */ -enum USBDeviceAction -{ - ACTION_ATTACHED = 1, - ACTION_DETACHED = -1 -}; - -/** - * @brief DBus代理类,负责调用对应的DBus接口 - */ -class BiometricProxy : public QDBusAbstractInterface +class BiometricHelper : public QDBusAbstractInterface { Q_OBJECT public: - explicit BiometricProxy(QObject *parent = nullptr); + explicit BiometricHelper(QObject *parent = nullptr); public Q_SLOTS: /** @@ -163,4 +138,4 @@ Q_SIGNALS: void FrameWritten(int drvid); }; -#endif // BIOMETRICPROXY_H +#endif // BIOMETRICHELPER_H diff --git a/src/device.cpp b/src/dbusifs/device.cpp similarity index 100% rename from src/device.cpp rename to src/dbusifs/device.cpp diff --git a/src/device.h b/src/dbusifs/device.h similarity index 100% rename from src/device.h rename to src/dbusifs/device.h diff --git a/src/enginedevice.cpp b/src/dbusifs/enginedevice.cpp similarity index 100% rename from src/enginedevice.cpp rename to src/dbusifs/enginedevice.cpp diff --git a/src/enginedevice.h b/src/dbusifs/enginedevice.h similarity index 100% rename from src/enginedevice.h rename to src/dbusifs/enginedevice.h diff --git a/src/dbusifs/freedesktophelper.cpp b/src/dbusifs/freedesktophelper.cpp new file mode 100644 index 0000000..44a9cbc --- /dev/null +++ b/src/dbusifs/freedesktophelper.cpp @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * +**/ +#include "freedesktophelper.h" +#include + +FreedesktopHelper::FreedesktopHelper(bool bSession, QObject *parent) + : QDBusAbstractInterface(FD_DBUS_SERVICE, + FD_DBUS_PATH, + FD_DBUS_INTERFACE, + (bSession?QDBusConnection::sessionBus():QDBusConnection::systemBus()), + parent) +{ + connect(this, SIGNAL(NameOwnerChanged(QString, QString, QString)), + this, SLOT(onDBusNameOwnerChanged(QString,QString,QString))); +} + +bool FreedesktopHelper::NameHasOwner(const QString &strService) +{ + QDBusReply ret = call("NameHasOwner", strService); + if(ret.isValid() && ret.value()) { + return true; + } + return false; +} + +bool FreedesktopHelper::isServiceActivable(const QString &strService) +{ + bool isActivable = false; + QDBusReply result = call(QStringLiteral("ListActivatableNames")); + if(!result.isValid()) { + qWarning() << "ListActivatableNames error:" << result.error().message(); + } else { + QStringList listNames = result.value(); + if (listNames.contains(strService)) { + isActivable = true; + } + } + return isActivable; +} + +void FreedesktopHelper::onDBusNameOwnerChanged(const QString &name, + const QString &oldOwner, + const QString &newOwner) +{ + Q_UNUSED(oldOwner); + Q_EMIT serviceStatusChanged(name, !newOwner.isEmpty()); +} diff --git a/src/modebutton.h b/src/dbusifs/freedesktophelper.h similarity index 53% rename from src/modebutton.h rename to src/dbusifs/freedesktophelper.h index dc7944c..4292b1b 100644 --- a/src/modebutton.h +++ b/src/dbusifs/freedesktophelper.h @@ -15,18 +15,28 @@ * along with this program; if not, see . * **/ -#ifndef MODEBUTTON_H -#define MODEBUTTON_H -#include +#ifndef FREEDESKTOPHELPER_H +#define FREEDESKTOPHELPER_H -class ModeButton : public QPushButton +#include +#include +#include +#include "definetypes.h" + +class FreedesktopHelper : public QDBusAbstractInterface { Q_OBJECT public: - ModeButton(QWidget *parent = nullptr); + explicit FreedesktopHelper(bool bSession = true, QObject *parent = nullptr); + +public Q_SLOTS: + bool NameHasOwner(const QString &strService); + bool isServiceActivable(const QString &strService); + void onDBusNameOwnerChanged(const QString &name, const QString &oldOwner, const QString &newOwner); + +Q_SIGNALS: + void serviceStatusChanged(QString strName, bool isActive); -protected: - void paintEvent(QPaintEvent *event); }; -#endif // MODEBUTTON_H +#endif // FREEDESKTOPHELPER_H diff --git a/BiometricAuth/giodbus.cpp b/src/dbusifs/giodbus.cpp similarity index 88% rename from BiometricAuth/giodbus.cpp rename to src/dbusifs/giodbus.cpp index 02a362b..fac0e55 100644 --- a/BiometricAuth/giodbus.cpp +++ b/src/dbusifs/giodbus.cpp @@ -1,9 +1,9 @@ -/* - * Copyright (C) 2021 Tianjin KYLIN Information Technology Co., Ltd. +/* giodbus.cpp + * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) + * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, @@ -12,9 +12,11 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301, USA. **/ + #include "giodbus.h" #include #include @@ -55,13 +57,11 @@ int get_server_gvariant_stdout (int drvid) g_dbus_message_to_gerror (method_reply_message, error); goto out; } - g_print("%s",g_dbus_message_print(method_reply_message,0)); fd_list = g_dbus_message_get_unix_fd_list(method_reply_message); fd = g_unix_fd_list_get(fd_list,0,error); - g_print("get fd : %d\n", fd); dup_fd = dup(fd); - g_print("dup fd : %d\n", dup_fd); + out: g_object_unref (method_call_message); diff --git a/BiometricAuth/giodbus.h b/src/dbusifs/giodbus.h similarity index 67% rename from BiometricAuth/giodbus.h rename to src/dbusifs/giodbus.h index a75f989..5f20256 100644 --- a/BiometricAuth/giodbus.h +++ b/src/dbusifs/giodbus.h @@ -1,9 +1,9 @@ -/* - * Copyright (C) 2021 Tianjin KYLIN Information Technology Co., Ltd. +/* giodbus.h + * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) + * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, @@ -12,9 +12,11 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301, USA. **/ + #ifndef GIODBUS_H #define GIODBUS_H diff --git a/src/dbusifs/kglobalaccelhelper.cpp b/src/dbusifs/kglobalaccelhelper.cpp new file mode 100644 index 0000000..805f92d --- /dev/null +++ b/src/dbusifs/kglobalaccelhelper.cpp @@ -0,0 +1,34 @@ +#include "kglobalaccelhelper.h" +#include +#include +#include +#include +#include + +const static QString kglobalService = QStringLiteral("org.ukui.KWin"); +const static QString kglobalPath = QStringLiteral("/kglobalaccel"); +const static QString kglobalInterface = QStringLiteral("org.kde.KGlobalAccel"); + +KglobalAccelHelper::KglobalAccelHelper(QObject *parent) : QObject(parent) +{ + m_kglobalInterface = new QDBusInterface(kglobalService, + kglobalPath, + kglobalInterface, + QDBusConnection::sessionBus(), + this); +} + +KglobalAccelHelper::~KglobalAccelHelper() +{ + +} + +bool KglobalAccelHelper::blockShortcut(bool val) +{ + QDBusMessage result = m_kglobalInterface->call("blockGlobalShortcuts",val); + if (result.type() == QDBusMessage::ErrorMessage) { + qWarning() << "blockShortcut error:" << result.errorMessage(); + return false; + } + return true; +} diff --git a/src/dbusifs/kglobalaccelhelper.h b/src/dbusifs/kglobalaccelhelper.h new file mode 100644 index 0000000..a7ce081 --- /dev/null +++ b/src/dbusifs/kglobalaccelhelper.h @@ -0,0 +1,22 @@ +#ifndef KGLOBALACCELHELPER_H +#define KGLOBALACCELHELPER_H + +#include +#include +#include + +class KglobalAccelHelper : public QObject +{ + Q_OBJECT +public: + explicit KglobalAccelHelper(QObject *parent = nullptr); + + virtual ~KglobalAccelHelper(); + + bool blockShortcut(bool val); + +private: + QDBusInterface *m_kglobalInterface = nullptr; +}; + +#endif // KGLOBALACCELHELPER_H diff --git a/src/logind.cpp b/src/dbusifs/login1helper.cpp similarity index 51% rename from src/logind.cpp rename to src/dbusifs/login1helper.cpp index e8817ac..3b12944 100644 --- a/src/logind.cpp +++ b/src/dbusifs/login1helper.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. + * Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -15,7 +15,7 @@ * along with this program; if not, see . * **/ -#include "logind.h" +#include "login1helper.h" #include #include #include @@ -28,18 +28,20 @@ const static QString propertiesInterface = QStringLiteral("org.freedesktop.DBus. const static QString login1ManagerInterface = QStringLiteral("org.freedesktop.login1.Manager"); const static QString login1SessionInterface = QStringLiteral("org.freedesktop.login1.Session"); -LogindIntegration::LogindIntegration(QObject *parent) - : QObject(parent) +Login1Helper::Login1Helper(QObject *parent) : QObject(parent) { - QDBusInterface loginInterface(login1Service, - login1Path, - login1ManagerInterface, - QDBusConnection::systemBus()); - QDBusReply sessionPath = loginInterface.call("GetSession", "auto"); + QDBusInterface *loginInterface = new QDBusInterface(login1Service, + login1Path, + login1ManagerInterface, + QDBusConnection::systemBus(), + this); + // 监听manager的睡眠、唤醒信号 + connect(loginInterface, SIGNAL(PrepareForSleep(bool)), this, SLOT(onPrepareForSleep(bool))); + + QDBusReply sessionPath = loginInterface->call("GetSession", "auto"); if(!sessionPath.isValid()){ qWarning()<< "Get session error:" << sessionPath.error(); - } - else{ + } else { QString session = sessionPath.value().path(); QDBusConnection::systemBus().connect(login1Service, session, @@ -74,16 +76,29 @@ LogindIntegration::LogindIntegration(QObject *parent) "PropertiesChanged", this, SLOT(onSessionPropChanged(QString, QVariantMap, QStringList))); + + // 监听程序阻塞关机/睡眠 + QDBusConnection::systemBus().connect( + login1Service, + login1Path, + propertiesInterface, + "PropertiesChanged", + this, + SLOT(onHibitedWatcherMessage(void))); } - return; + + m_isCanHibernate = getCanPowerManager("CanHibernate"); + m_isCanSuspend = getCanPowerManager("CanSuspend"); + m_isCanReboot = getCanPowerManager("CanReboot"); + m_isCanPowerOff = getCanPowerManager("CanPowerOff"); } -LogindIntegration::~LogindIntegration() +Login1Helper::~Login1Helper() { } -void LogindIntegration::onSessionPropChanged(QString strInterface, QVariantMap mapVar, QStringList listValue) +void Login1Helper::onSessionPropChanged(QString strInterface, QVariantMap mapVar, QStringList listValue) { if (login1SessionInterface == strInterface) { qDebug()<<"onSessionPropChanged:"< reply = iface.call("Get", "org.freedesktop.login1.Manager", "BlockInhibited"); + if (reply.isValid()) { + QString lidState = reply.value().toString(); + Q_EMIT lidStateChanged(lidState); + } else { + qDebug() << "Failed to get lid closed event!"; + } +} + +void Login1Helper::setPowerManager(const QString &powerManagerfunc) +{ + QDBusInterface iface(login1Service,login1Path,login1ManagerInterface, QDBusConnection::systemBus()); + iface.call(powerManagerfunc,true); +} + +bool Login1Helper::getCanPowerManager(const QString &powerManagerfunc) +{ + qDebug() << __LINE__ << __FUNCTION__ << "==========="; + bool canFlag = true; + QDBusInterface iface(login1Service,login1Path,login1ManagerInterface, QDBusConnection::systemBus()); + QDBusReply stateReplySuspend = iface.call(powerManagerfunc); + if(stateReplySuspend.isValid() && stateReplySuspend.value() == "yes"){ + canFlag = true; + }else{ + canFlag = false; + } + return canFlag; +} +bool Login1Helper::isCanHibernate() +{ + return m_isCanHibernate; +} +bool Login1Helper::isCanSuspend() +{ + return m_isCanSuspend; +} +bool Login1Helper::isCanReboot() +{ + return m_isCanReboot; +} + +bool Login1Helper::isCanPowerOff() +{ + return m_isCanPowerOff; +} diff --git a/src/dbusifs/login1helper.h b/src/dbusifs/login1helper.h new file mode 100644 index 0000000..536efad --- /dev/null +++ b/src/dbusifs/login1helper.h @@ -0,0 +1,121 @@ +/* + * Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * +**/ +#ifndef LOGIN1HELPER_H +#define LOGIN1HELPER_H + +#include +#include +#include + +/** + * @brief login1访问工具类 + * + */ +class Login1Helper : public QObject +{ + Q_OBJECT +public: + /** + * @brief 构造 + * + * @param parent 父指针 + */ + explicit Login1Helper(QObject *parent = nullptr); + /** + * @brief 析构 + * + */ + virtual ~Login1Helper(); + + /** + * @brief 当前会话是否处于活跃 + * + * @return bool true 是,否则否 + */ + bool isSessionActive(); + + void setPowerManager(const QString &powerManagerfunc); + + bool getCanPowerManager(const QString &powerManagerfunc); + bool isCanHibernate(); + bool isCanSuspend(); + bool isCanReboot(); + bool isCanPowerOff(); + +public Q_SLOTS: + /** + * @brief 会话属性改变 + * + * @param QString 接口名 + * @param QVariantMap 变化的属性表 + * @param QStringList 无效的属性 + */ + void onSessionPropChanged(QString, QVariantMap, QStringList); + /** + * @brief 准备休眠/唤醒 + * + * @param isSleep true 休眠,false 唤醒 + */ + void onPrepareForSleep(bool isSleep); + /** + * @brief 程序阻塞关机/睡眠状态改变 + * + */ + void onHibitedWatcherMessage(void); + +Q_SIGNALS: + /** + * @brief 请求锁定 + * + */ + void requestLock(); + /** + * @brief 请求解锁 + * + */ + void requestUnlock(); + /** + * @brief 会话活跃状态改变 + * + * @param isActive true 活跃,false 不活跃 + */ + void sessionActiveChanged(bool isActive); + /** + * @brief 准备休眠/唤醒 + * + * @param isSleep true 休眠,false 唤醒 + */ + void PrepareForSleep(bool isSleep); + /** + * @brief 程序阻塞关机/睡眠状态改变 + * + * @param lidState 阻塞类型 + */ + void lidStateChanged(QString lidState); + +private: + bool m_isSessionActive = false; /**< 是否处于活跃状态 */ + bool m_isSleeping = false; /**< 是否处于休眠状态 */ + + bool m_isCanHibernate = true; + bool m_isCanSuspend = true; + bool m_isCanReboot = true; + bool m_isCanPowerOff = true; +}; + +#endif // LOGIN1HELPER_H diff --git a/src/dbusifs/sessionhelper.cpp b/src/dbusifs/sessionhelper.cpp new file mode 100644 index 0000000..fa0b91f --- /dev/null +++ b/src/dbusifs/sessionhelper.cpp @@ -0,0 +1,91 @@ +/* + * Copyright (C) Copyright 2021 KylinSoft Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * +**/ +#include "sessionhelper.h" +#include +#include +#include +#include +#include +#include +#include + +const static QString sessionService = QStringLiteral("org.gnome.SessionManager"); +const static QString sessionPath = QStringLiteral("/org/gnome/SessionManager"); +const static QString sessionInterface = QStringLiteral("org.gnome.SessionManager"); + +QDBusArgument &InhibitInfo::operator<<(QDBusArgument &argument, const InhibitInfo::InhibitorInfo &mystruct) +{ + argument.beginStructure(); + argument << mystruct.name << mystruct.icon; + argument.endStructure(); + return argument; +} + +const QDBusArgument &InhibitInfo::operator>>(const QDBusArgument &argument, InhibitInfo::InhibitorInfo &mystruct) +{ + argument.beginStructure(); + argument >> mystruct.name >> mystruct.icon ; + argument.endStructure(); + return argument; +} + +SessionHelper::SessionHelper(QObject *parent) : QObject(parent) +{ + m_sessionInterface = new QDBusInterface(sessionService, + sessionPath, + sessionInterface, + QDBusConnection::sessionBus(), + this); +} + +SessionHelper::~SessionHelper() +{ + +} + +QStringList SessionHelper::getLockCheckStatus(QString type) +{ + qDBusRegisterMetaType(); + + QVector resVec; + + if (m_sessionInterface->isValid()) { + qDebug() << "create interface success"; + } + + QDBusMessage result = m_sessionInterface->call("ListInhibitor", QVariant(type)); + QList outArgs = result.arguments(); + QVariant first = outArgs.at(0); + const QDBusArgument &dbusArgs = first.value(); + + dbusArgs.beginArray(); + while (!dbusArgs.atEnd()) { + InhibitInfo::InhibitorInfo inhibtor; + dbusArgs >> inhibtor; + resVec.push_back(inhibtor); + } + dbusArgs.endArray(); + QStringList lockCheckList; + for (auto iter = resVec.begin(); iter != resVec.end(); ++iter) { + lockCheckList.append(iter->icon); + lockCheckList.append(iter->name); + } + qDebug() << "lockCheckList = " << lockCheckList; + + return lockCheckList; +} diff --git a/src/lockchecker.h b/src/dbusifs/sessionhelper.h similarity index 54% rename from src/lockchecker.h rename to src/dbusifs/sessionhelper.h index 6653850..30d3bf2 100644 --- a/src/lockchecker.h +++ b/src/dbusifs/sessionhelper.h @@ -16,8 +16,8 @@ * **/ -#ifndef LOCKCHECKER_H -#define LOCKCHECKER_H +#ifndef SESSIONHELPER_H +#define SESSIONHELPER_H #include #include @@ -33,43 +33,22 @@ namespace InhibitInfo { const QDBusArgument &operator>>(const QDBusArgument &argument, InhibitInfo::InhibitorInfo &mystruct); } -//struct userInfo { -// int userId; -// QString userName; -// QDBusObjectPath userPath; -//}; - -//QDBusArgument &operator <<(QDBusArgument &arg, const userInfo &usersInfo); -//const QDBusArgument &operator >>(const QDBusArgument &arg, userInfo &usersInfo); - Q_DECLARE_METATYPE(InhibitInfo::InhibitorInfo) -class LockChecker +class QDBusInterface; + +class SessionHelper : public QObject { + Q_OBJECT public: - LockChecker(); - ~LockChecker(); + explicit SessionHelper(QObject *parent = nullptr); -public: - static int checkLock(); + virtual ~SessionHelper(); - static QStringList getLoginedUsers(); - -// static QVector getInhibitors(); - static QVector listInhibitor(QString type); - -// static bool isSleepBlocked(); - -// static bool isShutdownBlocked(); - -// static void getSleepInhibitors(QStringList &sleepInhibitors, QStringList &sleepInhibitorsReason); - -// static void getShutdownInhibitors(QStringList &shutdownInhibitors, QStringList &shutdownInhibitorsReason); - - static int getCachedUsers(); + QStringList getLockCheckStatus(QString type); private: - static QString getName(QFile *a); + QDBusInterface *m_sessionInterface = nullptr; }; -#endif // LOCKCHECKER_H +#endif // SESSIONHELPER_H diff --git a/BiometricAuth/uniauthservice.cpp b/src/dbusifs/uniauthservice.cpp similarity index 86% rename from BiometricAuth/uniauthservice.cpp rename to src/dbusifs/uniauthservice.cpp index 38bb811..b32d347 100644 --- a/BiometricAuth/uniauthservice.cpp +++ b/src/dbusifs/uniauthservice.cpp @@ -18,14 +18,8 @@ #include "uniauthservice.h" #include #include - -#define UNIAUTH_DBUS_SERVICE "org.ukui.UniauthBackend" -#define UNIAUTH_DBUS_PATH "/org/ukui/UniauthBackend" -#define UNIAUTH_DBUS_INTERFACE "org.ukui.UniauthBackend" - -#define FD_DBUS_SERVICE "org.freedesktop.DBus" -#define FD_DBUS_PATH "/org/freedesktop/DBus" -#define FD_DBUS_INTERFACE "org.freedesktop.DBus" +#include "definetypes.h" +#include "freedesktophelper.h" UniAuthService::UniAuthService(QObject *parent) : QDBusAbstractInterface(UNIAUTH_DBUS_SERVICE, @@ -36,21 +30,12 @@ UniAuthService::UniAuthService(QObject *parent) , m_isActivatable(false) { setTimeout(2147483647); - QDBusInterface *dbusService = new QDBusInterface(FD_DBUS_SERVICE, - FD_DBUS_PATH, - FD_DBUS_INTERFACE, - QDBusConnection::systemBus()); - if (dbusService) { - QDBusReply result = dbusService->call(QStringLiteral("ListActivatableNames")); - if(!result.isValid()) { - qWarning() << "ListActivatableNames error:" << result.error().message(); - } else { - QStringList listNames = result.value(); - if (listNames.contains(UNIAUTH_DBUS_INTERFACE)) { - m_isActivatable = true; - } + FreedesktopHelper *systemFdHelper = new FreedesktopHelper(false); + if (systemFdHelper) { + if (systemFdHelper->isServiceActivable(UNIAUTH_DBUS_INTERFACE)) { + m_isActivatable = true; } - delete dbusService; + delete systemFdHelper; } } @@ -250,3 +235,19 @@ bool UniAuthService::isActivatable() { return m_isActivatable; } + +int UniAuthService::getFTimeoutTimes() +{ + QDBusMessage result = call(QStringLiteral("getFTimeoutTimes")); + if(result.type() == QDBusMessage::ErrorMessage) + { + qWarning() << "getFTimeoutTimes error:" << result.errorMessage(); + return 1; + } + QList varResult = result.arguments(); + if (varResult.size() > 0) { + return varResult.takeFirst().toInt(); + } else { + return 1; + } +} diff --git a/BiometricAuth/uniauthservice.h b/src/dbusifs/uniauthservice.h similarity index 97% rename from BiometricAuth/uniauthservice.h rename to src/dbusifs/uniauthservice.h index 9bbe5b4..b4b5b8d 100644 --- a/BiometricAuth/uniauthservice.h +++ b/src/dbusifs/uniauthservice.h @@ -61,6 +61,8 @@ public Q_SLOTS: bool getUseFirstDevice(); // 获取是否隐藏切换按钮 bool getHiddenSwitchButton(); + // 获取人脸超时停用次数 + int getFTimeoutTimes(); public: bool isActivatable(); diff --git a/src/dbusifs/upowerhelper.cpp b/src/dbusifs/upowerhelper.cpp new file mode 100644 index 0000000..ab6bd3b --- /dev/null +++ b/src/dbusifs/upowerhelper.cpp @@ -0,0 +1,117 @@ +#include "upowerhelper.h" +#include "device.h" +#include "enginedevice.h" +#include +#include +#include +#include +#include + +const static QString upowerService = QStringLiteral("org.freedesktop.UPower"); +const static QString upowerPath = QStringLiteral("/org/freedesktop/UPower"); +const static QString upowerInterface = QStringLiteral("org.freedesktop.UPower"); +const static QString propertiesInterface = QStringLiteral("org.freedesktop.DBus.Properties"); +const static QString upowerDisplayPath = QStringLiteral("/org/freedesktop/UPower/devices/DisplayDevice"); +const static QString upowerDeviceInterface = QStringLiteral("org.freedesktop.UPower.Device"); + +UpowerHelper::UpowerHelper(QObject *parent) : QObject(parent) +{ + m_upowerService = new QDBusInterface(upowerService, + upowerPath, + upowerInterface, + QDBusConnection::systemBus(), + this); + + QString batteryPath = ""; + QDBusReply> reply = m_upowerService->call("EnumerateDevices"); + if (m_upowerService->isValid()) { + for (QDBusObjectPath op : reply.value()) { + if (op.path().contains("battery_")) { + batteryPath = op.path(); +// qDebug() << "battery path is :" << batteryPath; + break; + } + } + } else { + qDebug() << "Enumerate devices failed"; + } + + + QDBusConnection::systemBus().connect( + upowerService, batteryPath, propertiesInterface, "PropertiesChanged", this, SLOT(dealMessage(QDBusMessage))); + + m_upowerInterface = new QDBusInterface(upowerService, + upowerPath, + propertiesInterface, + QDBusConnection::systemBus(), + this); + + m_batInterface = new QDBusInterface(upowerService, batteryPath, propertiesInterface, QDBusConnection::systemBus(), this); + + if (m_upowerInterface->isValid()) { + QDBusReply interfaceReply = m_upowerInterface->call("Get", "org.freedesktop.UPower", "LidIsPresent"); + if (interfaceReply.isValid()) { + m_isBattery = interfaceReply.value().toBool(); + } + } + + m_engineDevice = EngineDevice::getInstance(); + //onBatteryChanged(m_engineDevice->engine_get_state()); + + int size; + size = m_engineDevice->devices.size(); + for (int i = 0; i < size; i++) { + DEVICE *dv; + dv = m_engineDevice->devices.at(i); + + if (dv->m_dev.kind == UP_DEVICE_KIND_LINE_POWER) { + continue; + } + + connect(m_engineDevice, &EngineDevice::engine_signal_Battery_State, this, &UpowerHelper::onBatteryChanged); + continue; + } +} + +UpowerHelper::~UpowerHelper() +{ + +} + +QString UpowerHelper::getBatteryIconName() +{ + if (m_upowerService->isValid() && m_upowerInterface->isValid()) { + bool batteryState = false; + QDBusReply reply = m_upowerInterface->call("Get", upowerService, "OnBattery"); + if (reply.isValid()) { + batteryState = reply.value().toBool(); + } + double percentage = -1.0; + QDBusReply percentage_reply = m_batInterface->call("Get", upowerDeviceInterface, "Percentage"); + if (percentage_reply.isValid()) { + percentage = percentage_reply.value().toDouble(); + } + + if (batteryState) { + return QString("battery-level-%1-symbolic").arg((int)percentage / 10 * 10); + } else { + return QString("battery-level-%1-charging-symbolic").arg((int)percentage / 10 * 10); + } + } + return QString(); +} + +QStringList UpowerHelper::getBatteryArgs() +{ + return m_engineDevice->engine_get_state(); +} + +void UpowerHelper::onBatteryChanged(QStringList args) +{ + Q_EMIT batteryChanged(args); +} + +void UpowerHelper::dealMessage(QDBusMessage) +{ + Q_EMIT batteryStatusChanged(getBatteryIconName()); +} diff --git a/src/dbusifs/upowerhelper.h b/src/dbusifs/upowerhelper.h new file mode 100644 index 0000000..f1f0987 --- /dev/null +++ b/src/dbusifs/upowerhelper.h @@ -0,0 +1,49 @@ +#ifndef UPOWERHELPER_H +#define UPOWERHELPER_H + +#include +#include +#include + +class EngineDevice; + +/** + * @brief login1访问工具类 + * + */ +class UpowerHelper : public QObject +{ + Q_OBJECT +public: + explicit UpowerHelper(QObject *parent = nullptr); + + virtual ~UpowerHelper(); + + QStringList getBatteryArgs(); + + QString getBatteryIconName(); + + inline bool getIsBattery() { return m_isBattery; } + +private Q_SLOTS: + + void onBatteryChanged(QStringList args); + + void dealMessage(QDBusMessage); + +Q_SIGNALS: + void batteryStatusChanged(QString iconName); + + void batteryChanged(QStringList args); + +private: + QDBusInterface *m_upowerInterface = nullptr; + QDBusInterface *m_batInterface = nullptr; + QDBusInterface *m_upowerService = nullptr; + + EngineDevice* m_engineDevice; + + bool m_isBattery = false; +}; + +#endif // UPOWERHELPER_H diff --git a/src/dbusifs/usdhelper.cpp b/src/dbusifs/usdhelper.cpp new file mode 100644 index 0000000..859fc96 --- /dev/null +++ b/src/dbusifs/usdhelper.cpp @@ -0,0 +1,35 @@ +#include "usdhelper.h" +#include +#include +#include +#include +#include + +const static QString usdService = QStringLiteral("org.ukui.SettingsDaemon"); +const static QString usdMediaKeysPath = QStringLiteral("/org/ukui/SettingsDaemon/MediaKeys"); +const static QString usdMediaKeysInterface = QStringLiteral("org.ukui.SettingsDaemon.MediaKeys"); + +UsdHelper::UsdHelper(QObject *parent) : QObject(parent) +{ + usdInterface = new QDBusInterface(usdService, + usdMediaKeysPath, + usdMediaKeysInterface, + QDBusConnection::sessionBus(), + this); +} + + +UsdHelper::~UsdHelper() +{ + +} + +bool UsdHelper::usdExternalDoAction(int actionType) +{ + QDBusMessage result = usdInterface->call("externalDoAction", actionType, "screensaver"); + if (result.type() == QDBusMessage::ErrorMessage) { + qWarning() << "setDefaultDevice error:" << result.errorMessage(); + return false; + } + return true; +} diff --git a/src/dbusifs/usdhelper.h b/src/dbusifs/usdhelper.h new file mode 100644 index 0000000..81c5152 --- /dev/null +++ b/src/dbusifs/usdhelper.h @@ -0,0 +1,31 @@ +#ifndef USDHELPER_H +#define USDHELPER_H + +#include +#include +#include + +class UsdHelper : public QObject +{ + Q_OBJECT +public: + /** + * @brief 构造 + * + * @param parent 父指针 + */ + explicit UsdHelper(QObject *parent = nullptr); + /** + * @brief 析构 + * + */ + virtual ~UsdHelper(); + + bool usdExternalDoAction(int actionType); + + +private: + QDBusInterface *usdInterface = nullptr; +}; + +#endif // USDHELPER_H diff --git a/src/digitalauthdialog.cpp b/src/digitalauthdialog.cpp deleted file mode 100644 index 6646352..0000000 --- a/src/digitalauthdialog.cpp +++ /dev/null @@ -1,834 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * - * Authors: ZHAI Kang-ning -**/ -#include "digitalauthdialog.h" -#include -#include -#include -#include -#include -#include - -#include "auth-pam.h" -#include "permissioncheck.h" -#include "eduplatforminterface.h" - -DigitalAuthDialog::DigitalAuthDialog(QWidget *parent) : QWidget(parent), - m_bgColor("#000000"), //整个wigidt背景颜色 - m_outCircleColor("#000000"), - m_tipLineColor("#ff0000"), - m_circleRingColor("#ddffff"), - m_radius(40), - m_margin(5), - m_pressed(false), - m_showText(true), - m_inputPassword(""), - m_circleColor("#ffffff"),//按钮的颜色 - m_statusRadius(8), - m_auth(new AuthPAM(this)), - m_isAuthing(false), - m_buttonWidth(96), - m_buttonHeight(64), - m_buttonRadius(16), - m_buttonStep(16), - m_resetPassword(""), - m_resetOrAuthFailure(new QLabel(this)), - m_digitalKeyBoard(new DigitalKeyBoard(this)) -{ - //获取键盘事件 此操作会使得其他控件无法获取键盘事件,使用releaseKeyboard可释放 -// grabKeyboard(); - m_posInCircle.isIn = false; -// qDebug() <<"-----------init width=" << width() << ",height=" << height(); - m_title = new QLabel(tr("LoginByUEdu"), this); - m_title->setStyleSheet("font-size:30px;color:#ffffff"); - m_title->adjustSize(); - - m_labelReset = new MyLabel(tr("ResetPWD?"), this); - m_labelReset->setStyleSheet("QLabel{font-size:16px;color:rgba(255, 255, 255, 45);}" - "QLabel:hover{color:rgba(255, 255, 255, 100);}"); - m_labelReset->adjustSize(); - - m_authMessage = new QLabel(this); - m_authMessage->setStyleSheet("font-size:14px;color:#ffffff"); - - //设置字体大小 - QFont f; - f.setPixelSize(m_radius * 24/40); - setFont(f); - - //调整适当的大小 - resize(350,600); - m_title->setGeometry((this->width() - m_title->width())/2, 6, m_title->width(), m_title->height()); - m_labelReset->setGeometry((this->width()- m_labelReset->width())/2, this->height() - 120, m_labelReset->width(),m_labelReset->height()); - - - setMouseTracking(true); - connect(m_digitalKeyBoard, &DigitalKeyBoard::numbersButtonPress, this, &DigitalAuthDialog::onNumerPress); - connect(m_auth, &Auth::showMessage, this, &DigitalAuthDialog::onShowMessage); - connect(m_auth, &Auth::showPrompt, this, &DigitalAuthDialog::onShowPrompt); - connect(m_auth, &Auth::authenticateComplete, this, &DigitalAuthDialog::onAuthComplete); - connect(m_labelReset, &MyLabel::onClick, this, [=]{ -// qDebug() << "-------------------onClick"; - m_title->setText(tr("SetNewUEduPWD")); - m_title->adjustSize(); - m_resetOrAuthFailure->clear(); - m_title->setGeometry((this->width() - m_title->width())/2, 5, m_title->width(), m_title->height()); - m_inputPassword.clear(); - m_loginType = LoginType::RESET; - m_labelReset->hide(); -// PermissionCheck *check = new PermissionCheck(this); -// QVBoxLayout *v = new QVBoxLayout(this); -// v->addWidget(check); -// this->hide(); - Q_EMIT requestPasswordReset(); - }); - -// m_timer = new QTimer(this); -// connect(m_timer,&QTimer::timeout,this,[=]{ -// if(m_isAuthing) -// { -// qDebug() << "Auth respond timeout , restart"; -// startAuth(); -// } -// }); - - m_digitalKeyBoard->move(9,143); -} - -DigitalAuthDialog::~DigitalAuthDialog() -{ - -} - -void DigitalAuthDialog::onNumerPress(int btn_id) -{ - qDebug() << btn_id; - //nothing - if(m_authMessage) - cleanMessage(); - if(m_resetOrAuthFailure) - m_resetOrAuthFailure->clear(); - m_pressed = true; - - if(m_isAuthing) - { - qWarning() << "authenticating"; - return; - } - - if(btn_id == 11) - { - //点击了清空按钮 - m_inputPassword.clear(); - } else if (btn_id == 10) - { - if (!m_inputPassword.isEmpty()) - m_inputPassword.remove(m_inputPassword.size() -1, 1); - } else { - int num = btn_id; - m_inputPassword.append(QString::number(num == 11 ? 0 : num)); - if (m_inputPassword.size() >= 6) - { - checkPassword(); - } - } - repaint(); -} - -void DigitalAuthDialog::paintEvent(QPaintEvent *event) -{ - int width = this->width(); - int height = this->height(); - int side = qMin(width, height); -// qDebug() <<"-----------width=" << width << ",height=" << height << ",side=" << side; - - QPainter painter(this); - painter.setRenderHint(QPainter::Antialiasing); - painter.translate(width / 2, height / 2); - painter.scale(side / 200, side / 200); - -// drawBg(&painter); - drawStatusCircle(&painter); -//// drawOutCircle(&painter); -// drawFilledCircle(&painter); -//// drawTipLine(&painter); -// drawInCircle(&painter); -//// drawJoinLine(&painter); -// drawHoverCircle(&painter); -} - -//画背景颜色 -void DigitalAuthDialog::drawBg(QPainter *painter) -{ - painter->save(); - - int width = this->width(); - int height = this->height(); - - painter->setPen(Qt::NoPen); - m_bgColor.setAlpha(0); - painter->setBrush(m_bgColor); - painter->drawRect(-width / 2, -height / 2, width, height); - - painter->restore(); -} - -//绘制按钮的颜色 -void DigitalAuthDialog::drawFilledCircle(QPainter *painter) -{ - painter->save(); - m_circleColor.setAlphaF(0.15); - QPen pen(m_circleColor); - painter->setPen(pen); - painter->setBrush(m_circleColor); - - for (int i = 0; i < 4; i++) - { - for (int j = 0; j < 3; j++) - { - int x = -3 * (m_buttonWidth / 2) + j * m_buttonWidth + (j - 1) * m_buttonStep; - int y = -2 * m_buttonHeight + i * m_buttonHeight + m_buttonStep * i - 3 * (m_buttonStep / 2); - QRect rect(x, y, m_buttonWidth, m_buttonHeight); -// painter->drawEllipse(rect); - painter->drawRoundedRect(rect, m_buttonRadius, m_buttonRadius); - if (m_showText) - { - painter->save(); - painter->setPen(QColor("#ffffff")); - painter->setBrush(QColor("#ffffff")); - - int number = posToNumber(i, j); - if (number == 11) - { - number = 0; - } else if(number == 10) - { - // 数字10的地方是清空按钮 - x = (j - 1) * m_buttonWidth + (j - 1) * m_buttonStep;; - y = -3 * (m_buttonHeight / 2) + i * m_buttonHeight + m_buttonStep * i - 3 * (m_buttonStep / 2); - QString text = tr("clear"); - int textWidth = fontMetrics().width(text); - QFont font = painter->font(); - font.setPixelSize(m_radius * 20/40); - painter->setFont(font); - painter->drawText(x - textWidth / 2 + 3, y + textWidth / 2 - 18, text); - painter->restore(); - continue; - } - else if (number == 12) - { - // 画删除符号(3,2) - x = m_buttonWidth / 2 + m_buttonStep; - y = m_buttonHeight + 3 * (m_buttonStep / 2); - painter->drawPixmap(x + m_buttonWidth/2 - 15,y + m_buttonHeight/2 - 15, QPixmap(":/image/assets/intel/delete.svg")); - painter->restore(); - continue; - } - - QString text = QString::number(number); - x = (j - 1) * m_buttonWidth + (j - 1) * m_buttonStep;; - y = -3 * (m_buttonHeight / 2) + i * m_buttonHeight + m_buttonStep * i - 3 * (m_buttonStep / 2); - int textWidth = fontMetrics().width(text); - int textHeight = fontMetrics().height(); - painter->drawText(x - textWidth / 2, y + textWidth / 2 + 4, text); - painter->restore(); - } - } - } - painter->restore(); -} - -//画外圆 -void DigitalAuthDialog::drawOutCircle(QPainter *painter) -{ - painter->save(); - QPen pen(m_outCircleColor, 2); - painter->setPen(pen); - painter->setBrush(Qt::NoBrush); - - for (int i = 0; i < 4; i++) - { - for (int j = 0; j < 3; j++) - { - int x = -3 * (m_buttonWidth / 2) + j * m_buttonWidth + (j - 1) * m_buttonStep; - int y = -2 * m_buttonHeight + i * m_buttonHeight + m_buttonStep * i - 3 * (m_buttonStep / 2); - QRect rect(x, y, m_buttonWidth, m_buttonHeight); -// painter->drawEllipse(rect); - painter->drawRoundedRect(rect, m_buttonRadius, m_buttonRadius); -// painter->drawEllipse(x, y, m_radius * 2, m_radius * 2); - if (m_showText) - { - int number = posToNumber(i, j); - QString text = QString::number(number); - x = -2 * m_radius + j * 2 * m_radius + (j - 1) * 16; - y = -3 * m_radius + i * 2 * m_radius + 16 * i - 24; - int textWidth = fontMetrics().width(text); - int textHeight = fontMetrics().height(); - painter->drawText(x - textWidth / 2, y + textWidth / 2, text); - } - } - } - - painter->restore(); -} - -void DigitalAuthDialog::drawTipLine(QPainter *painter) -{ - painter->save(); - - int offset = 3; - - if (m_posInCircle.isIn) - { - if (!m_pressed) - { - painter->setPen(m_tipLineColor); - painter->setBrush(Qt::NoBrush); - int x = -3 * (m_buttonWidth / 2) + m_posInCircle.j * m_buttonWidth + (m_posInCircle.j - 1) * m_buttonStep - offset; - int y = -2 * m_buttonHeight + m_posInCircle.i * m_buttonHeight + m_buttonStep * m_posInCircle.i - 3 * (m_buttonStep / 2) - offset; - QRect rect(x, y, m_buttonWidth, m_buttonHeight); - painter->drawRoundedRect(rect, m_buttonRadius, m_buttonRadius); - } - } - - painter->restore(); -} - -//绘制点击时的颜色 -void DigitalAuthDialog::drawInCircle(QPainter *painter) -{ - painter->save(); - - if (m_pressed) - { - if (m_posInCircle.isIn) - { - m_circleColor.setAlphaF(0.05); - painter->setPen(m_circleColor); - painter->setBrush(m_circleColor); - int x = -3 * (m_buttonWidth / 2) + m_posInCircle.j * m_buttonWidth + (m_posInCircle.j - 1) * m_buttonStep; - int y = -2 * m_buttonHeight + m_posInCircle.i * m_buttonHeight + m_buttonStep * m_posInCircle.i - 3 * (m_buttonStep / 2); - int w = m_buttonWidth; - int h = m_buttonHeight; - QRect rect = QRect(x, y, w, h); - painter->drawRoundedRect(rect, m_buttonRadius, m_buttonRadius); - } - } - - painter->restore(); -} - -//绘制悬浮时的颜色 -void DigitalAuthDialog::drawHoverCircle(QPainter *painter) -{ - painter->save(); - if (!m_pressed) - { - if (m_posInCircle.isIn) - { - m_circleColor.setAlphaF(0.35); - painter->setPen(m_circleColor); - painter->setBrush(m_circleColor); - int x = -3 * (m_buttonWidth / 2) + m_posInCircle.j * m_buttonWidth + (m_posInCircle.j - 1) * m_buttonStep; - int y = -2 * m_buttonHeight + m_posInCircle.i * m_buttonHeight + m_buttonStep * m_posInCircle.i - 3 * (m_buttonStep / 2); - int w = m_buttonWidth; - int h = m_buttonHeight; - QRect rect = QRect(x, y, w, h); - painter->drawRoundedRect(rect, m_buttonRadius, m_buttonRadius); - } - - } - - painter->restore(); -} - - -void DigitalAuthDialog::drawJoinLine(QPainter *painter) -{ - painter->save(); - - QPen pen(m_outCircleColor, 3); - painter->setPen(pen); - //绘制连接线段 - for (int i = 0; i < m_vecInputPoints.count() - 1; i++) - { - painter->drawLine(m_vecInputPoints[i], m_vecInputPoints[i + 1]); - } - - int offset1 = 1;//圆环偏移量 - int offset2 = 3;//内圆偏移量 - //绘制连接圆 - for (int i = 0; i < m_vecInputPoints.count(); i++) - { - int x = m_vecInputPoints[i].x() - m_radius + offset1; - int y = m_vecInputPoints[i].y() - m_radius + offset1; - int w = 2 * (m_radius - offset1); - int h = 2 * (m_radius - offset1); - painter->setPen(m_circleRingColor); - painter->setBrush(m_circleRingColor); - painter->drawEllipse(x, y, w, h); - - x = m_vecInputPoints[i].x() - m_radius + offset2; - y = m_vecInputPoints[i].y() - m_radius + offset2; - w = 2 * (m_radius - offset2); - h = 2 * (m_radius - offset2); - painter->setPen(m_outCircleColor); - painter->setBrush(m_outCircleColor); - painter->drawEllipse(x, y, w, h); - } - //绘制跟随线 - if (m_pressed && m_vecInputPoints.count() < 9) - { - int width = this->width(); - int height = this->height(); - int side = qMin(width, height); - int gestureScale = side / 200; - int x = (m_followPoint.x() - width / 2) / gestureScale; - int y = (m_followPoint.y() - height / 2) / gestureScale; - if (m_vecInputPoints.count() > 0) - { - painter->setPen(pen); - painter->drawLine(m_vecInputPoints.last(), QPoint(x, y)); - } - } - - painter->restore(); -} - -void DigitalAuthDialog::mouseMoveEvent(QMouseEvent *event) -{ -// bool temp = false; -// //nothing -// int x = (event->x() - this->width()/2) / (qMin(width(), height())/200); -// int y = (event->y() - this->height()/2) / (qMin(width(), height())/200); - -// for (int i = 0; i < 4; i++) -// { -// for (int j = 0; j < 3; j++) -// { -// int x1 = -3 * (m_buttonWidth / 2) + j * m_buttonWidth + (j - 1) * m_buttonStep; -// int y1 = -2 * m_buttonHeight + i * m_buttonHeight + m_buttonStep * i - 3 * (m_buttonStep / 2); -// if (isInButtonArea(x, y, x1, y1)) -// { -// m_posInCircle.i = i; -// m_posInCircle.j = j; -// m_posInCircle.isIn = true; -// temp = true; -// repaint(); -// } -// } -// } - -// if (!temp) -// { -// m_posInCircle.isIn = false; -// repaint(); -// } - -} - -void DigitalAuthDialog::mousePressEvent(QMouseEvent *event) -{ - //nothing -// if(m_authMessage) -// cleanMessage(); -// if(m_resetOrAuthFailure) -// m_resetOrAuthFailure->clear(); -// m_pressed = true; -// int x = (event->x() - this->width()/2) / (qMin(width(), height())/200); -// int y = (event->y() - this->height()/2) / (qMin(width(), height())/200); - -// for (int i = 0; i < 4; i++) -// { -// for (int j = 0; j < 3; j++) -// { -// int x1 = -3 * (m_buttonWidth / 2) + j * m_buttonWidth + (j - 1) * m_buttonStep; -// int y1 = -2 * m_buttonHeight + i * m_buttonHeight + m_buttonStep * i - 3 * (m_buttonStep / 2); -// if (isInButtonArea(x, y, x1, y1)) -// { -// if(m_isAuthing) -// { -// qWarning() << "authenticating"; -// return; -// } -// m_posInCircle.i = i; -// m_posInCircle.j = j; -// m_posInCircle.isIn = true; -// if(posToNumber(i, j) == 10) -// { -// //点击了清空按钮 -// m_inputPassword.clear(); -// } else if (posToNumber(i, j) == 12) -// { -// if (!m_inputPassword.isEmpty()) -// m_inputPassword.remove(m_inputPassword.size() -1, 1); -// } else { -// int num = posToNumber(i,j); -// m_inputPassword.append(QString::number(num == 11 ? 0 : num)); -// if (m_inputPassword.size() >= 6) -// { -// checkPassword(); -// } -//// qDebug() << "---------------选中了"<< posToNumber(i,j); -// } -// repaint(); -// } -// } -// } -} - -void DigitalAuthDialog::mouseReleaseEvent(QMouseEvent *event) -{ -// //nothing -// m_pressed = false; -// //m_posInCircle.isIn = false; -// repaint(); -} - -////监听键盘输入 -void DigitalAuthDialog::keyPressEvent(QKeyEvent *event) -{ - qDebug() << "keyPressEvent " << event->key(); - if (m_isAuthing) - { - qWarning() << "authenticating"; - return; - } - if(event->key() == Qt::Key_Backspace) - { - if (!m_inputPassword.isEmpty()) - m_inputPassword.remove(m_inputPassword.size() -1, 1); - } else if (event->key() >= Qt::Key_0 && event->key() <= Qt::Key_9 ) - { - if(m_resetOrAuthFailure) - m_resetOrAuthFailure->clear(); - m_inputPassword.append(event->text()); - if (m_inputPassword.size() >= 6) - { - checkPassword(); - m_inputPassword.clear(); - } - } else { - return; - } - repaint(); -} - -////监听键盘输入 -//void DigitalAuthDialog::RecieveKey(int key) -//{ -// qDebug() << "keyPressEvent " << key; -// if (m_isAuthing) -// { -// qWarning() << "authenticating"; -// return; -// } -// if(key == 10) -// { -// if (!m_inputPassword.isEmpty()) -// m_inputPassword.remove(m_inputPassword.size() -1, 1); -// } else if (key >= 0 && key <= 9 ) -// { -// if(m_resetOrAuthFailure) -// m_resetOrAuthFailure->clear(); -// m_inputPassword.append(QString::number(key)); -// if (m_inputPassword.size() >= 6) -// { -// checkPassword(); -// m_inputPassword.clear(); -// } -// } else { -// return; -// } -// repaint(); -//} - -double DigitalAuthDialog::distance(int x1, int y1, int x2, int y2) -{ - //nothing - double x = x1 - x2; - double y = y1 - y2; - return sqrt(x*x + y*y); -} - -int DigitalAuthDialog::posToNumber(int i, int j) -{ - //nothing - return ((3*i) + j +1); -} - -void DigitalAuthDialog::setPassword(const QString password) -{ - //ToDo - Q_EMIT setPinCode(password); -} - -QString DigitalAuthDialog::getPassword() -{ - //nothing -} - -bool DigitalAuthDialog::checkPassword() -{ - if(m_loginType == LoginType::AUTHENTICATE) - { - m_password = m_inputPassword; - qDebug() << "Input finished" << m_password; - m_auth->respond(m_password); - m_isAuthing = true; -// m_timer->start(5000); -// onShowMessage(tr("now is authing, wait a moment"), Auth::MessageTypeInfo); - } else if (m_loginType == LoginType::RESET) - { - m_resetPassword = m_inputPassword; - m_title->setText(tr("ConfirmNewUEduPWD")); - m_title->adjustSize(); - m_title->setGeometry((this->width() - m_title->width())/2, 5, m_title->width(), m_title->height()); - m_inputPassword.clear(); - m_loginType = LoginType::SECONDCONFIRMATION; - Q_EMIT switchToReset(false); - } else if (m_loginType == LoginType::SECONDCONFIRMATION) - { - if (m_resetPassword == m_inputPassword) - { - setPassword(m_resetPassword); - } else { - m_resetOrAuthFailure->setText(tr("The two password entries are inconsistent, please reset")); - m_resetOrAuthFailure->setStyleSheet("font-size:14px;color:rgba(255, 255, 255, 255)"); - m_resetOrAuthFailure->adjustSize(); - m_resetOrAuthFailure->setGeometry((this->width()- m_resetOrAuthFailure->width())/2, 120, - m_resetOrAuthFailure->width(),m_resetOrAuthFailure->height()); - showResetPasswordPage(); - Q_EMIT switchToReset(true); - } - } - return false; -} - -//画密码状态的圆圈 -void DigitalAuthDialog::drawStatusCircle(QPainter *painter) -{ - painter->save(); - - m_circleColor.setAlphaF(0.45); - QPen pen(m_circleColor, 2); - painter->setPen(pen); - painter->setBrush(Qt::NoBrush); - - for(int i = 0; i < 6; i++) - { - int x = -11 * m_statusRadius + i * 4 * m_statusRadius; - int y = -2 * m_buttonHeight - (11 * m_buttonStep) / 2; - if (i < m_inputPassword.size()) { - painter->save(); - painter->setBrush(QColor("#ffffff")); - QRect rect(x, y, 2 * m_statusRadius, 2 * m_statusRadius); - painter->drawEllipse(rect); - painter->restore(); - } else { - painter->drawEllipse(x, y, 2 * m_statusRadius, 2 * m_statusRadius); - } - } - painter->restore(); -} - -void DigitalAuthDialog::onShowMessage(const QString &message, Auth::MessageType type) -{ - m_authMessage->setText(message); - m_authMessage->adjustSize(); - m_authMessage->setGeometry((this->width()-m_authMessage->width())/2, this->height() -20, m_authMessage->width(),m_authMessage->height()); -} - -void DigitalAuthDialog::cleanMessage() -{ - m_authMessage->clear(); -} - -void DigitalAuthDialog::onShowPrompt(const QString &prompt, Auth::PromptType type) -{ - qDebug() << "prompt: " << prompt; -} - -void DigitalAuthDialog::onAuthComplete() -{ - qDebug() << "Auth Complete"; -// m_timer->stop(); - DBusMsgCode errcode = EduPlatformInterface::getInstance()->CheckToken(getenv("USER")); - if(m_auth->isAuthenticated()) - { - /* - DBusMsgCode errcode = EduPlatformInterface::getInstance()->CheckToken(getenv("USER")); - - if(DBusMsgCode::Error_AccessTokenInvalid == errcode){ - m_resetOrAuthFailure->setText(tr("登录状态已过期,请重新扫码登录")); - m_resetOrAuthFailure->setStyleSheet("font-size:14px;color:rgba(255, 255, 255, 255)"); - m_resetOrAuthFailure->adjustSize(); - m_resetOrAuthFailure->setGeometry((this->width()- m_resetOrAuthFailure->width())/2, 120, - m_resetOrAuthFailure->width(),m_resetOrAuthFailure->height()); - - startAuth(); - m_inputPassword.clear(); - m_password.clear(); - m_isAuthing = false; - repaint(); - return; - } - */ - Q_EMIT authenticateCompete(true); - m_isAuthing = false; - } - else - { - qWarning() << "auth failed"; - if(m_loginType == LoginType::AUTHENTICATE) - { - m_resetOrAuthFailure->setText(tr("Password entered incorrectly, please try again")); - m_resetOrAuthFailure->setStyleSheet("font-size:14px;color:rgba(255, 255, 255, 255)"); - m_resetOrAuthFailure->adjustSize(); - m_resetOrAuthFailure->setGeometry((this->width()- m_resetOrAuthFailure->width())/2, 120, - m_resetOrAuthFailure->width(),m_resetOrAuthFailure->height()); - } - //认证失败,重新认证 - startAuth(); - } - m_inputPassword.clear(); - m_password.clear(); - m_isAuthing = false; - repaint(); -} - -void DigitalAuthDialog::startAuth() -{ - m_inputPassword.clear(); - m_password.clear(); - m_auth->authenticate(getenv("USER")); - m_isAuthing = false; - repaint(); -} - -void DigitalAuthDialog::stopAuth() -{ - m_isAuthing = false; -} - -void DigitalAuthDialog::startWaiting() -{ - -} - -void DigitalAuthDialog::stopWaiting() -{ - -} - -void DigitalAuthDialog::closeEvent(QCloseEvent *event) -{ - qDebug() << "DigitalAuthDialog::closeEvent"; - - if(m_auth && m_auth->isAuthenticating()) - { - m_auth->stopAuth(); - } - return QWidget::closeEvent(event); -} - -bool DigitalAuthDialog::isInButtonArea(int x1, int y1, int x2, int y2) -{ - if (x1 >= x2 && x1 <= (x2 + m_buttonWidth) && y1 >= y2 && y1 <= (y2 + m_buttonHeight)) - return true; - return false; -} - -void DigitalAuthDialog::reset() -{ - m_title->setText(tr("LoginByUEdu")); - m_title->adjustSize(); - m_title->setGeometry((this->width() - m_title->width())/2, 5, m_title->width(), m_title->height()); - - m_labelReset->show(); - m_inputPassword.clear(); - m_resetPassword.clear(); - m_loginType = LoginType::AUTHENTICATE; - repaint(); -} - -/** - * @brief DigitalAuthDialog::showResetPasswordPage - * 重新展示重置密码页 - */ -void DigitalAuthDialog::showResetPasswordPage() -{ - m_title->setText(tr("SetNewUEduPWD")); - m_title->adjustSize(); - m_title->setGeometry((this->width() - m_title->width())/2, 5, m_title->width(), m_title->height()); - m_loginType = LoginType::RESET; - m_resetPassword.clear(); - m_inputPassword.clear(); - repaint(); - Q_EMIT switchToReset(true); -} - -int DigitalAuthDialog::getStatus() -{ - return m_loginType; -} - -void DigitalAuthDialog::showErrorMessage(QString message) -{ - m_resetOrAuthFailure->setText(message); - m_resetOrAuthFailure->setStyleSheet("font-size:14px;color:rgba(255, 255, 255, 255)"); - m_resetOrAuthFailure->adjustSize(); - m_resetOrAuthFailure->setGeometry((this->width()- m_resetOrAuthFailure->width())/2, 120, - m_resetOrAuthFailure->width(),m_resetOrAuthFailure->height()); - - QTimer::singleShot(3000,[=](){ - m_resetOrAuthFailure->clear(); - }); -} - -MyLabel::MyLabel(const QString & text,QWidget *parent) : QLabel(parent) -{ - setText(text); -} - -MyLabel::MyLabel(QWidget *parent) : QLabel(parent) -{ - -} - -void MyLabel::mousePressEvent(QMouseEvent *event) -{ - //Qt::LeftButton - //Qt::RightButton - if(event->button()== Qt::LeftButton) - { - this->setStyleSheet("QLabel{font-size:16px;color:rgba(255, 255, 255, 0.45);}"); - } -} - -void MyLabel::mouseReleaseEvent(QMouseEvent *event) -{ - //Qt::LeftButton - //Qt::RightButton - if(event->button()== Qt::LeftButton) - { - this->setStyleSheet("QLabel{font-size:16px;color:rgba(255, 255, 255, 0.35);}" - "QLabel:hover{color:rgba(255, 255, 255, 1);}"); - Q_EMIT onClick(); - } -} diff --git a/src/digitalauthdialog.h b/src/digitalauthdialog.h deleted file mode 100644 index 630f9be..0000000 --- a/src/digitalauthdialog.h +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * - * Authors: ZHAI Kang-ning -**/ -#ifndef DIGITALAUTHDIALOG_H -#define DIGITALAUTHDIALOG_H - -#include -#include -#include -#include -#include -#include -#include "auth.h" -#include "digitalkeyboard.h" -#include - -class Auth; -class MyLabel; - -class DigitalAuthDialog : public QWidget -{ - Q_OBJECT -public: - struct PosInCircle - { - int i; //行 - int j; //列 - bool isIn; //是否在范围内 - }; - - enum LoginType{ - AUTHENTICATE = 0, - RESET, - SECONDCONFIRMATION, - }; - - explicit DigitalAuthDialog(QWidget *parent = nullptr); - ~DigitalAuthDialog(); - - void setPassword(const QString password); - QString getPassword(); - bool checkPassword(); - void reset(); - void showResetPasswordPage(); - int getStatus(); - void showErrorMessage(QString message); -// void RecieveKey(int key); -protected: - void paintEvent(QPaintEvent *event) override; - void mouseMoveEvent(QMouseEvent *event) override; - void mousePressEvent(QMouseEvent *event) override; - void mouseReleaseEvent(QMouseEvent *event) override; - void keyPressEvent(QKeyEvent *event) override; - void closeEvent(QCloseEvent *evert) override; - - void drawBg(QPainter *painter); - void drawOutCircle(QPainter *painter); - void drawFilledCircle(QPainter *painter); - void drawTipLine(QPainter *painter); - void drawInCircle(QPainter *painter); - void drawJoinLine(QPainter *painter); - void drawStatusCircle(QPainter *painter); - void drawHoverCircle(QPainter *painter); -private: - /** - * 圆形按钮,测量距离中心的距离 - * @brief distance - * @param x1 - * @param y1 - * @param x2 圆心x坐标 - * @param y2 圆心y坐标 - * @return - */ - double distance(int x1, int y1, int x2, int y2); - - bool isInButtonArea(int x1, int y1, int x2, int y2); - int posToNumber(int i, int j); - -// void onShowMessage(const QString &message); - void cleanMessage(); - - void startWaiting(); - void stopWaiting(); -Q_SIGNALS: - void correctPassword(bool isCorrect, QString password); - void authenticateCompete(bool result); - void requestPasswordReset(); - void setPinCode(QString pinCode); - void switchToReset(bool isReset); -private Q_SLOTS: - void onShowMessage(const QString &message, Auth::MessageType type); - void onShowPrompt(const QString &prompt, Auth::PromptType type); - void onAuthComplete(); -public Q_SLOTS: - void startAuth(); - void stopAuth(); - void onNumerPress(int btn_id); -private: - QColor m_bgColor; //背景色 - QColor m_outCircleColor; //外圆颜色 - QColor m_tipLineColor; //提示线颜色 - QColor m_circleRingColor; //圆环颜色 - QColor m_circleColor; //实心圆颜色 - int m_margin; //外边距 - int m_radius; //圆相对半径 - int m_buttonRadius; //按钮圆角半径 - int m_buttonWidth; //按钮宽度 - int m_buttonHeight; //按钮高度 - int m_buttonStep; //按钮间距 - PosInCircle m_posInCircle; //判断点是否在圆内 - bool m_pressed; //鼠标按下 - bool m_showText; //是否显示文字 - - QVector m_vecInputPoints; //鼠标移动选点 - QPoint m_followPoint; //鼠标跟随点 - QString m_password; //原密码 - QString m_inputPassword; //鼠标移动选点转换为密码 - - //label - QLabel *m_title; - MyLabel *m_labelReset; - - //密码状态更新布局 - int m_statusRadius; - - //认证中? - bool m_isAuthing; - - //数字键盘 - DigitalKeyBoard *m_digitalKeyBoard; - - /** - * 二次认证相关成员变量 - */ - int m_loginType = LoginType::AUTHENTICATE; - QString m_resetPassword; - QLabel *m_resetOrAuthFailure; - - QLabel *m_authMessage; - - //pam auth - Auth *m_auth; - -// QTimer *m_timer; -}; - -class MyLabel : public QLabel{ - Q_OBJECT -public: - MyLabel(const QString & text, QWidget *parent); - MyLabel(QWidget *parent); - -Q_SIGNALS: - void onClick(); - -protected: - void mouseReleaseEvent(QMouseEvent *event) override; - void mousePressEvent(QMouseEvent *event) override; -}; - -#endif // DIGITALAUTHDIALOG_H diff --git a/src/digitalkeyboard.cpp b/src/digitalkeyboard.cpp deleted file mode 100644 index 4597ad4..0000000 --- a/src/digitalkeyboard.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (C) 2021 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#include "digitalkeyboard.h" - -#include -#include -#include - -DigitalKeyBoard::DigitalKeyBoard(QWidget *parent): - QWidget(parent) -{ - initUI(); - initConnect(); - setQSS(); -} - -void DigitalKeyBoard::initUI() -{ - setFocusPolicy(Qt::NoFocus); - QGridLayout* mainLayout = new QGridLayout(this); - setLayout(mainLayout); - - for(int i = 1;i <= 9;i++) - { - m_pNumerPressBT[i] = new QPushButton(this); - m_pNumerPressBT[i]->setText(QString(QChar(i + '0'))); - m_pNumerPressBT[i]->setProperty("class", "numberPressBT"); - m_pNumerPressBT[i]->setFocusPolicy(Qt::NoFocus); - mainLayout->addWidget(m_pNumerPressBT[i], (i - 1) / 3, (i - 1) % 3); - } - m_pNumerPressBT[0] = new QPushButton(this); - m_pNumerPressBT[0]->setText(QString(QChar('0'))); - m_pNumerPressBT[0]->setFocusPolicy(Qt::NoFocus); - m_pNumerPressBT[0]->setProperty("class", "numberPressBT"); - mainLayout->addWidget(m_pNumerPressBT[0], 3, 1); - - m_pNumerPressBT[10] = new QPushButton(this); - m_pNumerPressBT[10]->setIcon(QPixmap(":/image/assets/intel/icon-backspace.png")); - m_pNumerPressBT[10]->setIconSize(QSize(30, 30)); - m_pNumerPressBT[10]->setFocusPolicy(Qt::NoFocus); - m_pNumerPressBT[10]->setProperty("class", "numberPressBT"); - mainLayout->addWidget(m_pNumerPressBT[10], 3, 2); - - m_pNumerPressBT[11] = new QPushButton(this); - m_pNumerPressBT[11]->setText("清空"); - m_pNumerPressBT[11]->setFocusPolicy(Qt::NoFocus); - m_pNumerPressBT[11]->setProperty("class", "numberPressBT"); - mainLayout->addWidget(m_pNumerPressBT[11], 3, 0); - - mainLayout->setSpacing(16); - mainLayout->setVerticalSpacing(16); -} - -void DigitalKeyBoard::initConnect() -{ - connect(m_pNumerPressBT[0], &QPushButton::clicked, this, [=](){ qDebug() << "DigitalKeyBoard press";emit numbersButtonPress(0); }); - connect(m_pNumerPressBT[1], &QPushButton::clicked, this, [=](){ emit numbersButtonPress(1); }); - connect(m_pNumerPressBT[2], &QPushButton::clicked, this, [=](){ emit numbersButtonPress(2); }); - connect(m_pNumerPressBT[3], &QPushButton::clicked, this, [=](){ emit numbersButtonPress(3); }); - connect(m_pNumerPressBT[4], &QPushButton::clicked, this, [=](){ emit numbersButtonPress(4); }); - connect(m_pNumerPressBT[5], &QPushButton::clicked, this, [=](){ emit numbersButtonPress(5); }); - connect(m_pNumerPressBT[6], &QPushButton::clicked, this, [=](){ emit numbersButtonPress(6); }); - connect(m_pNumerPressBT[7], &QPushButton::clicked, this, [=](){ emit numbersButtonPress(7); }); - connect(m_pNumerPressBT[8], &QPushButton::clicked, this, [=](){ emit numbersButtonPress(8); }); - connect(m_pNumerPressBT[9], &QPushButton::clicked, this, [=](){ emit numbersButtonPress(9); }); - connect(m_pNumerPressBT[10], &QPushButton::clicked, this, [=](){ emit numbersButtonPress(10); }); - connect(m_pNumerPressBT[11], &QPushButton::clicked, this, [=](){ emit numbersButtonPress(11); }); -} - -void DigitalKeyBoard::setQSS() -{ - setStyleSheet(".numberPressBT{" - "font-size:20px;" - "min-width:96px;" - "min-height:64px;" - "max-width:96px;" - "max-height:64px;" - "background:rgba(255, 255, 255, 15);" - "border-radius:16px;" - "}" - ".numberPressBT:hover{" - "background:rgba(255, 255, 255, 35);" - "}" - ".numberPressBT:pressed{" - "background:rgba(255, 255, 255, 5);" - "}"); -} - - -void DigitalKeyBoard::onKeyReleaseEvent(QKeyEvent *event) -{ -// switch(event->key()) -// { -// case Qt::Key_0: -// emit numbersButtonPress(0); -// break; -// case Qt::Key_1: -// emit numbersButtonPress(1); -// break; -// case Qt::Key_2: -// emit numbersButtonPress(2); -// break; -// case Qt::Key_3: -// emit numbersButtonPress(3); -// break; -// case Qt::Key_4: -// emit numbersButtonPress(4); -// break; -// case Qt::Key_5: -// emit numbersButtonPress(5); -// break; -// case Qt::Key_6: -// emit numbersButtonPress(6); -// break; -// case Qt::Key_7: -// emit numbersButtonPress(7); -// break; -// case Qt::Key_8: -// emit numbersButtonPress(8); -// break; -// case Qt::Key_9: -// emit numbersButtonPress(9); -// break; -// case Qt::Key_Backspace: -// emit numbersButtonPress(10); -// break; -// default: -// break; -// } -} - diff --git a/src/displaymanager.cpp b/src/displaymanager.cpp deleted file mode 100644 index 65e9346..0000000 --- a/src/displaymanager.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#include "displaymanager.h" -#include -#include -#include -#include -#include -#include "types.h" - -DisplayManager::DisplayManager(QObject *parent) : - QObject(parent), - _canSwitch(false), - _displayType(""), - process(nullptr) -{ - - if(getenv("XDG_SEAT_PATH")){ - _displayType = "lightdm"; - } - else if(process_is_running ("gdm") || process_is_running("gdm3") || process_is_running("gdm-binary")){ - _displayType = "gdm"; - process = new QProcess(this); - } - - if(_displayType == "lightdm"){ - char *seatPath = getenv("XDG_SEAT_PATH"); - qDebug() << seatPath; - - dmService = new QDBusInterface(DM_DBUS_SERVICE, - seatPath, - DBUS_PROP_INTERFACE, - QDBusConnection::systemBus()); - dmSeatService = new QDBusInterface(DM_DBUS_SERVICE, - seatPath, - DM_SEAT_INTERFACE, - QDBusConnection::systemBus()); - getProperties(); - }else if(_displayType == "gdm"){ - _canSwitch = true; - } -} - -bool DisplayManager::canSwitch() -{ - return _canSwitch; -} - -bool DisplayManager::hasGuestAccount() -{ - return _hasGuestAccount; -} - -QString DisplayManager::getDisplayType() -{ - return _displayType; -} - -void DisplayManager::switchToGreeter() -{ - if(_displayType == "lightdm"){ - QDBusMessage ret = dmSeatService->call("SwitchToGreeter"); - handleDBusError(ret); - } - else if(_displayType == "gdm"){ - QString cmd = "gdmflexiserver"; - if(QFile("/usr/bin/gdmflexiserver").exists()){ - process->waitForFinished(3000); - process->start(cmd); - } - } -} - -void DisplayManager::switchToUser(const QString &userName) -{ - if(_displayType != "lightdm") - return ; - - QDBusMessage ret = dmSeatService->call("SwitchToUser", userName, ""); - - handleDBusError(ret); -} - -void DisplayManager::switchToGuest() -{ - if(_displayType != "lightdm") - return ; - - QDBusMessage ret = dmSeatService->call("SwitchToGuest", ""); - - handleDBusError(ret); -} - -void DisplayManager::getProperties() -{ - QDBusMessage ret = dmService->call("GetAll", DM_SEAT_INTERFACE); - handleDBusError(ret); - const QDBusArgument &arg = ret.arguments().at(0).value(); - qDebug() << arg.currentType(); - - arg.beginMap(); - while(!arg.atEnd()) - { - QString key; - QVariant value; - arg.beginMapEntry(); - arg >> key >> value; - arg.endMapEntry(); - if(key == "CanSwitch") - { - _canSwitch = value.toBool(); - } - else if(key == "HasGuestAccount") - { - _hasGuestAccount = value.toBool(); - } - } - arg.endMap(); -} - -bool DisplayManager::process_is_running(QString name) -{ - int num_processes; - QString command = "pidof " + name + " | wc -l"; - FILE *fp = popen(command.toLatin1().data(), "r"); - - if (fscanf(fp, "%d", &num_processes) != 1) - num_processes = 0; - - pclose(fp); - - if (num_processes > 0) { - return true; - } else { - return false; - } -} - -void DisplayManager::handleDBusError(const QDBusMessage &msg) -{ - if(msg.type() == QDBusMessage::ErrorMessage) - { - qWarning() << msg.errorMessage(); - } -} diff --git a/src/displaymanager.h b/src/displaymanager.h deleted file mode 100644 index 741be7d..0000000 --- a/src/displaymanager.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#ifndef DISPLAYMANAGER_H -#define DISPLAYMANAGER_H - -#include -#include - -class QDBusInterface; -class QDBusMessage; - -class DisplayManager : public QObject -{ - Q_OBJECT -public: - explicit DisplayManager(QObject *parent = nullptr); - void switchToGreeter(); - void switchToUser(const QString &userName); - void switchToGuest(); - bool canSwitch(); - bool hasGuestAccount(); - - QString getDisplayType(); - -private: - void getProperties(); - void handleDBusError(const QDBusMessage &msg); - bool process_is_running(QString name); - -private: - bool _canSwitch; - bool _hasGuestAccount; - QString _displayType; - - QDBusInterface *dmService; - QDBusInterface *dmSeatService; - QProcess *process; -}; - -#endif // DISPLAYMANAGER_H diff --git a/src/eduplatforminterface.cpp b/src/eduplatforminterface.cpp deleted file mode 100644 index 6f3384c..0000000 --- a/src/eduplatforminterface.cpp +++ /dev/null @@ -1,392 +0,0 @@ -/* - * Copyright (C) 2021 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#include "eduplatforminterface.h" - -const QString STR_EDU_SERVICE = "cn.kylinos.SSOBackend"; -const QString STR_EDU_PATH = "/cn/kylinos/SSOBackend"; - -EduPlatformInterface* EduPlatformInterface::m_instance = nullptr; - -EduPlatformInterface::EduPlatformInterface(const QString &strService,const QString &strPath,\ - const QDBusConnection &connection, QObject *parent)\ - :QDBusAbstractInterface(strService,strPath,getInterfaceName(),connection,parent) -{ - initConnect(); -} - -EduPlatformInterface* EduPlatformInterface::getInstance() -{ - static QMutex mutex; - mutex.lock(); - if(m_instance == nullptr || !m_instance->isValid()) - m_instance = new EduPlatformInterface(STR_EDU_SERVICE, STR_EDU_PATH, QDBusConnection::systemBus()); - mutex.unlock(); - return m_instance; -} - -void EduPlatformInterface::initConnect() -{ - -} - -DBusMsgCode EduPlatformInterface::GetLoginQR(QPixmap &qrcode) -{ - QDBusMessage message = call("GetLoginQR"); - if(QDBusMessage::ErrorMessage == message.type()) - { - qDebug() << "info: [EduPlatformInterface][GetLoginQR]: DBus Connect Failed!"; - return DBusMsgCode::Error_NoReply; - } - QList argvs = message.arguments(); - if(argvs.size() != 2) - { - qDebug() << "info: [EduPlatformInterface][GetLoginQR]: DBus arguments error!"; - return DBusMsgCode::Error_ArgCnt; - } - int state = argvs.at(1).value(); - if(state != 0) - { - qDebug() << "info: [EduPlatformInterface][GetLoginQR]: DBus request failed!"; - //return static_cast(state); - return DBusMsgCode::Error_ArgCnt; - } - const QString url = argvs.at(0).value(); - - DBusMsgCode download_errcode = getQRCodeFromURL(url, qrcode); - if(download_errcode != DBusMsgCode::No_Error) return download_errcode; - qrcode = beautifyQRCode(qrcode); - return DBusMsgCode::No_Error; -} - -DBusMsgCode EduPlatformInterface::GetLoginQRUrl(QString &url) -{ - QDBusMessage message = call("GetLoginQR"); - if(QDBusMessage::ErrorMessage == message.type()) - { - qDebug() << "info: [EduPlatformInterface][GetLoginQR]: DBus Connect Failed!"; - return DBusMsgCode::Error_NoReply; - } - QList argvs = message.arguments(); - if(argvs.size() != 2) - { - qDebug() << "info: [EduPlatformInterface][GetLoginQR]: DBus arguments error!"; - return DBusMsgCode::Error_ArgCnt; - } - int state = argvs.at(1).value(); - if(state != 0) - { - qDebug() << "info: [EduPlatformInterface][GetLoginQR]: DBus request failed!"; - //return static_cast(state); - return DBusMsgCode::Error_ArgCnt; - } - url = argvs.at(0).value(); - return DBusMsgCode::No_Error; -} - -DBusMsgCode EduPlatformInterface::BindPhoneNum(const QString &username, const QString &phonenum, const QString &vcode) -{ - QDBusReply reply = call("BindPhoneNum", username, phonenum, vcode); - if(!reply.isValid()) - { - qDebug() << "info: [EduPlatformInterface][BindPhoneNum]: DBus Connect Failed!"; - return DBusMsgCode::Error_NoReply; - } - if(reply.value() != 0) - { - qDebug() << "info: [EduPlatformInterface][BindPhoneNum]: DBus request failed!"; - //return static_cast(reply.value()); - return DBusMsgCode::Error_NoReply; - } - - return DBusMsgCode::No_Error; -} - -DBusMsgCode EduPlatformInterface::GetVerifyCode(const QString &phonenum) -{ - QDBusReply reply = call("GetVerifyCode", phonenum); - if(!reply.isValid()) - { - qDebug() << "info: [EduPlatformInterface][GetVerifyCode]: DBus Connect Failed!"; - return DBusMsgCode::Error_NoReply; - } - // - if(reply.value() != 0) // 默认0为成功 - { - qDebug() << "info: [EduPlatformInterface][GetVerifyCode]: DBus request failed!"; - //return static_cast(reply.value()); - return DBusMsgCode::Error_NoReply; - } - - return DBusMsgCode::No_Error; -} - -DBusMsgCode EduPlatformInterface::SetPinCode(const QString &username, const QString &pincode) -{ - QDBusReply reply = call("SetPinCode", username, pincode); - if(!reply.isValid()) - { - qDebug() << "info: [][]: DBus connect failed!"; - return DBusMsgCode::Error_NoReply; - } - if(!reply.value()) - { - return DBusMsgCode::No_Error; - } - return DBusMsgCode::Error_NoReply; -} - -DBusMsgCode EduPlatformInterface::CheckToken(const QString &username) -{ - QDBusReply reply = call("CheckToken", username); - if(!reply.isValid()) - { - qDebug() << "info: [EduPlatformInterface][RefreshToken]: DBus connect failed!"; - return DBusMsgCode::Error_NoReply; - } -// if(reply.value()) -// { -// qDebug() << "info: [EduPlatformInterface][RefreshToken]: DBus return-result failed!"; -// } - switch (reply.value()) { - case 0: return DBusMsgCode::No_Error; - default: return static_cast(reply.value()); - } -} - -DBusMsgCode EduPlatformInterface::CheckPhoneNumBind(const QString &username, bool &isBind) -{ - QDBusReply reply = call("CheckPhoneNumBind", username); - if(!reply.isValid()) - { - qDebug() << "info: [EduPlatformInterface][CheckPhoneNumBind]: DBus connect failed!"; - return DBusMsgCode::Error_NoReply; - } - // TODO 需要改接口 接口有问题 - if(reply.value() == 0) - { - isBind = false; - return DBusMsgCode::No_Error; - } - if(reply.value() == 1) - { - isBind = true; - return DBusMsgCode::No_Error; - } - isBind = true; - return DBusMsgCode::Error_NoReply; -} - -DBusMsgCode EduPlatformInterface::CheckPincodeSet(const QString &username, bool &isBind) -{ - QDBusReply reply = call("CheckPincodeSet", username); - if(!reply.isValid()) - { - qDebug() << "info: [EduPlatformInterface][CheckPincodeSet]: DBus connect failed!"; - return DBusMsgCode::Error_NoReply; - } - - if(reply.value() == 0) - { - isBind = true; - return DBusMsgCode::No_Error; - } - if(reply.value() == 1) - { - isBind = false; - return DBusMsgCode::No_Error; - } - - return DBusMsgCode::Error_NoReply; -} - -DBusMsgCode EduPlatformInterface::CheckUserByPhone(const QString &username, const QString &phonenum, const QString &vcode) -{ - QDBusReply reply = call("CheckUserByPhone", username, phonenum, vcode); - if(!reply.isValid()) - { - qDebug() << "info: [EduPlatformInterface][CheckUserByPhone]: DBus connect failed!"; - return DBusMsgCode::Error_NoReply; - } - return static_cast(reply.value()); -} - -DBusMsgCode EduPlatformInterface::CheckUserByQR(QPixmap &qrcode) -{ - QDBusMessage message = call("CheckUserByQR"); - if(QDBusMessage::ErrorMessage == message.type()) - { - qDebug() << "info: [EduPlatformInterface][CheckUserByQR]: DBus Connect Failed!"; - return DBusMsgCode::Error_NoReply; - } - QList argvs = message.arguments(); - if(argvs.size() != 2) - { - qDebug() << "info: [EduPlatformInterface][CheckUserByQR]: DBus arguments error!"; - return DBusMsgCode::Error_ArgCnt; - } - int state = argvs.at(1).value(); - if(state != 0) - { - qDebug() << "info: [EduPlatformInterface][CheckUserByQR]: DBus request failed!"; - //return static_cast(state); - return static_cast(state); - } - const QString url = argvs.at(0).value(); - - DBusMsgCode download_errcode = getQRCodeFromURL(url, qrcode); - if(download_errcode != DBusMsgCode::No_Error) return download_errcode; - qrcode = beautifyQRCode(qrcode); - return DBusMsgCode::No_Error; -} - -DBusMsgCode EduPlatformInterface::CheckUserByQR(QString &url) -{ - QDBusMessage message = call("CheckUserByQR"); - if(QDBusMessage::ErrorMessage == message.type()) - { - qDebug() << "info: [EduPlatformInterface][CheckUserByQR]: DBus Connect Failed!"; - return DBusMsgCode::Error_NoReply; - } - QList argvs = message.arguments(); - if(argvs.size() != 2) - { - qDebug() << "info: [EduPlatformInterface][CheckUserByQR]: DBus arguments error!"; - return DBusMsgCode::Error_ArgCnt; - } - int state = argvs.at(1).value(); - if(state != 0) - { - qDebug() << "info: [EduPlatformInterface][CheckUserByQR]: DBus request failed!"; - //return static_cast(state); - return static_cast(state); - } - url = argvs.at(0).value(); - return DBusMsgCode::No_Error; -} - -DBusMsgCode EduPlatformInterface::getQRCodeFromURL(const QString &url, QPixmap &qrcode) -{ - // 从网络上下载二维码 并加载到qrcode - QNetworkRequest request; - QNetworkAccessManager networkManager; - request.setUrl(url); - QNetworkReply *reply = networkManager.get(request); - - // 超时 \ 同步处理 - QEventLoop loop; - QTimer timer; - connect(reply, &QNetworkReply::finished, &loop, &QEventLoop::quit); - connect(&timer, &QTimer::timeout, &timer, &QTimer::stop); - connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit); - timer.start(3000); - loop.exec(); - - if(!timer.isActive()) - { - reply->abort(); - qDebug() << "info: [EduPlatformInterface][GetLoginQR]: Get QRCode timeout!"; - return DBusMsgCode::Error_QR_Get_Timeout; - } - timer.stop(); - - // 生成二维码 - if(reply->error() != QNetworkReply::NoError) - { - qDebug() << "info: [EduPlatformInterface][GetLoginQR]: Network error!" << reply->errorString(); - return DBusMsgCode::Error_NetWork; - } - QByteArray bytes = reply->readAll(); - qrcode.loadFromData(bytes); - return DBusMsgCode::No_Error; -} - -// 美化图片 -QPixmap EduPlatformInterface::beautifyQRCode(QPixmap &pixImg) -{ - // 去除白边 - QImage img = pixImg.toImage(); - int rect_x, rect_y, rect_width, rect_height; - for(int i = 0;i < img.size().width();i++) - { - bool isEnd = false; - for(int j = 0;j < img.size().height();j++) - { - if(img.pixel(i, j) != qRgb(255, 255, 255)) - { - rect_x = i - 1; - rect_y = j - 1; - rect_width = img.size().width() - 2 * rect_x; - rect_height = img.size().height() - 2 * rect_y; - isEnd = true; - break; - } - } - if(isEnd) break; - } - QPixmap dealImg = QPixmap::fromImage(img.copy(rect_x, rect_y, rect_width, rect_height)).scaledToWidth(150); - img = dealImg.toImage(); - - // 添加微信log -// QPixmap piximg_wechat(WECHAT_LOG_PATH); -// QImage img_wechat = piximg_wechat.scaledToWidth(150).toImage(); -// for(int i = 0;i < img.size().width();++i) -// { -// for(int j = 0;j < img.size().height(); ++j) -// { -// if(img.pixel(i, j) > qRgb(125, 125, 125)) -// { -// int r = qRed(img_wechat.pixel(i, j)); -// int g = qGreen(img_wechat.pixel(i, j)); -// int b = qBlue(img_wechat.pixel(i, j)); -// int alpha = qAlpha(img_wechat.pixel(i, j)); -// if(alpha == 0) r = 255, b = 255, g = 255; -// else r = 0x25, g = 0xAC, b = 0x36; -// img.setPixelColor(i, j, QColor(r, g, b, alpha)); -// //img.setPixel(i, j, qRgb(0, 255, 0)); -// } -// } -// } - dealImg = QPixmap::fromImage(img); - return dealImg; -} - -//void EduPlatformInterface::onScanState(QString username, QString password, int state) -//{ -// switch(state) -// { -// case 4: // 扫码并确认完成 -// qDebug() << "=================扫码并确认完成" << username << password; -// emit qrcodeScanState(QRCodeSwepState::ConfirmSuccess, username, password); -// break; -// case 2: // 用户扫码 -// qDebug() << "=================用户扫码" << username << password; -// emit qrcodeScanState(QRCodeSwepState::HaveSwep, "", ""); -// break; -// case 3: // 用户取消扫码 -// qDebug() << "=================用户取消扫码" << username << password; -// emit qrcodeScanState(QRCodeSwepState::CancelSwep, "", ""); -// break; -// case 5: // 二维码超时 -// qDebug() << "=================二维码超时" << username << password; -// emit qrcodeScanState(QRCodeSwepState::QRCodeInvalid, "", ""); -// break; -// default: -// break; -// } -//} - diff --git a/src/eduplatforminterface.h b/src/eduplatforminterface.h deleted file mode 100644 index 0a93506..0000000 --- a/src/eduplatforminterface.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#ifndef EDUPLATFORMINTERFACE_H -#define EDUPLATFORMINTERFACE_H -#include -#include -#include -#include "common.h" -#include - -#include -#include -#include -#include -#include - -class EduPlatformInterface: public QDBusAbstractInterface -{ - Q_OBJECT -public: - static inline const char* getInterfaceName() - {return "cn.kylinos.SSOBackend.eduplatform";} -public: - EduPlatformInterface(const QString &strService,const QString &strPath,\ - const QDBusConnection &connection, QObject *parent = 0); - - static EduPlatformInterface* getInstance(); - - // 得到登录二维码地址 - DBusMsgCode GetLoginQRUrl(QString &url); - // 绑定手机号 - DBusMsgCode BindPhoneNum(const QString &username, const QString &phonenum, const QString &vcode); - // 得到登录二维码 - DBusMsgCode GetLoginQR(QPixmap &qrcode); - // 得到验证码 - DBusMsgCode GetVerifyCode(const QString &phonenum); - // 设置Pin码 - DBusMsgCode SetPinCode(const QString &username, const QString &pincode); - // 检查手机号绑定 - DBusMsgCode CheckPhoneNumBind(const QString &username, bool &isBind); - // 检查Pin码设置 - DBusMsgCode CheckPincodeSet(const QString &username, bool &isBind); - // 验证手机号正确性 - DBusMsgCode CheckUserByPhone(const QString &username, const QString &phonenum, const QString &vcode); - // 通过二维码检查用户身份 - DBusMsgCode CheckUserByQR(QPixmap &qrcode); - // 通过二维码检查用户身份:获取二维码地址 - DBusMsgCode CheckUserByQR(QString &url); - - // 通过url获取二维码图片数据 - DBusMsgCode getQRCodeFromURL(const QString &url, QPixmap &qrcode); - - // 获取用户登录状态 - DBusMsgCode CheckToken(const QString &username); -private: - void initConnect(); - QPixmap beautifyQRCode(QPixmap &); - - static EduPlatformInterface *m_instance; - -Q_SIGNALS: - void QRStatusChange(QString,QString,int); - -private: - -}; - -#endif // EDUPLATFORMINTERFACE_H diff --git a/src/fullbackgroundwidget.cpp b/src/fullbackgroundwidget.cpp deleted file mode 100644 index 0d7ae0b..0000000 --- a/src/fullbackgroundwidget.cpp +++ /dev/null @@ -1,1483 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#include "fullbackgroundwidget.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "plasma-shell-manager.h" -#include -#include "lockwidget.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include "xeventmonitor.h" -#include "monitorwatcher.h" -#include "configuration.h" -#include "screensavermode.h" -#include "screensaverwidget.h" -#include "grab-x11.h" -#include "tabletlockwidget.h" -#include "sessionwatcher.h" -// 实现键盘f1 - f2 的功能键 -#include "PhysicalDeviceSet/sounddeviceset.h" -#include "PhysicalDeviceSet/brightnessdeviceset.h" - -#include "config.h" - -enum { - SWITCH_TO_LINUX = 0, - SWITCH_TO_ANDROID = 1, - BACK_TO_DESKTOP = 2, - TEST_CONNECTION = 3, -}; - -QT_BEGIN_NAMESPACE -extern void qt_blurImage(QPainter *p, QImage &blurImage, qreal radius, bool quality, bool alphaOnly, int transposed = 0); -QT_END_NAMESPACE - -#define BLUR_RADIUS 300 - -#define SUBWND_COUNT_MAX 1024 - -QPixmap scaledPixmap(int width, int height, QString url) -{ - QFile imgFile(url); - if(!imgFile.exists()){ - qDebug()<< "not find the pixmap file"; - return QPixmap(); - } - QImage image(url); - QPixmap pixmap = QPixmap::fromImage(image); - if(pixmap.isNull()) { - qDebug() << "pixmap is null"; - QProcess exec; - QString program("file " + url); - exec.start(program); - exec.waitForFinished(1000); - QString output = exec.readAllStandardOutput(); - qDebug() << output; - if(output.contains("SVG")){ - qDebug() << "image format is SVG"; - QSvgRenderer render(url); - QImage image(width, height, QImage::Format_ARGB32); - image.fill(Qt::transparent); - QPainter painter(&image); - render.render(&painter, image.rect()); - pixmap.convertFromImage(image); - } else if(output.contains("TIFF")) { - qDebug() << "image format is TIFF"; - - } - } - - return pixmap.scaled(width, height, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation); -} - -int connect_to_switch(const char* path) -{ - int ret; - int connect_fd; - struct sockaddr_un srv_addr; - - connect_fd = socket(PF_UNIX,SOCK_STREAM,0); - if(connect_fd < 0) { - - return -1; - } - - srv_addr.sun_family=AF_UNIX; - strcpy(srv_addr.sun_path, path); - - ret = connect(connect_fd, (struct sockaddr*)&srv_addr, sizeof(srv_addr)); - if(ret < 0) { - perror("cannot connect to the server"); - close(connect_fd); - return -1; - } - - return connect_fd; -} - -int switch_to_linux(const char* container) -{ - int connect_fd; - int32_t switch_to = BACK_TO_DESKTOP; - - char path[1024] = {0}; - sprintf(path, "/var/lib/kydroid/%s/sockets/%s", container, "desktop-switch"); - printf("path = %s\n",path); - connect_fd = connect_to_switch(path); - - if(connect_fd < 0) - return -1; - - write(connect_fd, &switch_to, sizeof(switch_to)); - close(connect_fd); - return 0; -} - -void x11_get_screen_size(int *width,int *height) -{ - Display* display; - - display = XOpenDisplay(NULL); - if (display == NULL) { - fprintf(stderr, "Cannot connect to X server %s/n", "simey:0"); - exit (-1); - } - int screen_num; - - screen_num = DefaultScreen(display); - - *width = DisplayWidth(display, screen_num); - *height = DisplayHeight(display, screen_num); - XCloseDisplay(display); - -} - -QPixmap blurPixmap(QPixmap pixmap) -{ - QPainter painter(&pixmap); - QImage srcImg = pixmap.toImage(); - qt_blurImage(&painter, srcImg, BLUR_RADIUS, false, false); - - //在设置Qt::WA_TranslucentBackground属性后,模糊图片会导致锁屏界面透明 - //因此这里修改image图形的alpha值为255. - for (int y = 0;y < srcImg.height();++y) { - QRgb *row = (QRgb*)srcImg.scanLine(y); - for (int x = 0; x < srcImg.width(); ++x) { - ((unsigned char*)&row[x])[3] = 255; - } - } - - painter.end(); - return QPixmap::fromImage(srcImg); -} - -FullBackgroundWidget::FullBackgroundWidget(QWidget *parent) - : QWidget(parent), - lockWidget(nullptr), - //xEventMonitor(new XEventMonitor(this)), - //monitorWatcher(new MonitorWatcher(this)), - configuration(Configuration::instance()), - isLocked(false), - isPassed(false), - lockState(false), - screenStatus(UNDEFINED), - isBlank(false), - m_delay(false) -{ - qDebug() << "init - screenStatus: " << screenStatus; - m_listWndIds.clear(); - setMouseTracking(true); -// connect(monitorWatcher, &MonitorWatcher::monitorCountChanged, -// this, &FullBackgroundWidget::onScreenCountChanged); - QDesktopWidget *desktop = QApplication::desktop(); - - connect(desktop, &QDesktopWidget::resized, - this, &FullBackgroundWidget::onDesktopResized); -// connect(desktop, &QDesktopWidget::workAreaResized, -// this, &FullBackgroundWidget::onDesktopResized); - connect(desktop, &QDesktopWidget::primaryScreenChanged, - this, &FullBackgroundWidget::onDesktopResized); - connect(desktop, &QDesktopWidget::screenCountChanged, - this, &FullBackgroundWidget::onDesktopResized); - -// connect(QApplication::primaryScreen(),&QScreen::geometryChanged, this, &FullBackgroundWidget::onDesktopResized); -// connect(QApplication::screens().at(0), &QScreen::virtualGeometryChanged, this,&FullBackgroundWidget::onDesktopResized); - - QDBusInterface *iface = new QDBusInterface("org.freedesktop.login1", - "/org/freedesktop/login1", - "org.freedesktop.login1.Manager", - QDBusConnection::systemBus(), - this); - connect(iface, SIGNAL(PrepareForSleep(bool)), this, SLOT(onPrepareForSleep(bool))); - - QString strHostCloundPlatform = Configuration::instance()->getHostCloudPlatform(); - if (strHostCloundPlatform != "ctyun") { // 天翼云不允许锁屏/屏保 - QDBusInterface *interfaceScreensaver = new QDBusInterface( - SS_DBUS_SERVICE, - SS_DBUS_PATH, - SS_DBUS_INTERFACE, - QDBusConnection::sessionBus()); - - connect(interfaceScreensaver, SIGNAL(SecondRunParam(QString)), - this, SLOT(onSecondRunParam(QString))); - } - -#ifdef USE_INTEL - QDBusConnection::systemBus().connect("org.freedesktop.UPower", "/org/freedesktop/UPower", "org.freedesktop.DBus.Properties", "PropertiesChanged", - this, SLOT(propertiesChangedSlot(QString, QMap, QStringList))); -#endif - - init(); - qApp->installNativeEventFilter(this); - installEventFilter(this); - QTimer::singleShot(500,this,SLOT(switchToLinux())); -} - -#ifdef USE_INTEL -void FullBackgroundWidget::propertiesChangedSlot(QString property, QMap propertyMap, QStringList propertyList) -{ - Q_UNUSED(property); - Q_UNUSED(propertyList); - if (propertyMap.keys().contains("LidIsClosed")) { - qDebug() <<"LidIsClosed" << propertyMap.value("LidIsClosed").toBool(); -// if(!(propertyMap.value("LidIsClosed").toBool())) -// { -// m_isSuspend = true; -// } - } -} -#endif - -void FullBackgroundWidget::switchToLinux() -{ - struct passwd *pwd; - pwd = getpwuid(getuid()); - char *username = pwd->pw_name; - int uid = pwd->pw_uid; - char container[100]= {0}; - - sprintf(container,"kydroid2-%d-%s",uid,username); - - switch_to_linux(container); - -} - -void FullBackgroundWidget::laterActivate() -{ - if (QX11Info::isPlatformX11()) { - /*在不调用XSetInputFocus接口的情况下,在窗口失去焦点后,activateWindow概率性无法 - * 激活窗口,导致锁屏输入不了密码。 - * 复现方法:锁屏,然后切换到tty,启动终端,文管等窗口抢占锁屏窗口焦点,数次以后必现*/ - XSetInputFocus(QX11Info::display(),this->winId(),RevertToParent,CurrentTime); - } - activateWindow(); - raise(); - raiseOtherWnd(); - setFocus(); - if(lockWidget && lockWidget->isVisible()) { - lockWidget->setFocus(); - lockWidget->onActiveLineedit();//将焦点设置到密码框 - } - update(); -} - -void FullBackgroundWidget::laterOtherActivate() -{ - activateWindow(); - raiseOtherWnd(); - //setFocus(); - if(lockWidget && lockWidget->isVisible()) { - lockWidget->setFocus(); - lockWidget->onActiveLineedit();//将焦点设置到密码框 - } -} - -void FullBackgroundWidget::setLockState() -{ - if(lockState == true) - return ; - - lockState = true; - QString displayNum = QString(qgetenv("DISPLAY")).replace(":", "").replace(".", "_"); - QString sessionDbus = QString("%1%2").arg(QString(SS_DBUS_SERVICE)).arg(displayNum); - QDBusInterface *interface = new QDBusInterface(sessionDbus, - SS_DBUS_PATH, - SS_DBUS_INTERFACE); - if (!interface->isValid()) { - delete interface; - interface = new QDBusInterface(SS_DBUS_SERVICE, - SS_DBUS_PATH, - SS_DBUS_INTERFACE); - } - QDBusMessage msg = interface->call("SetLockState"); - if(msg.type() == QDBusMessage::ErrorMessage) - qDebug() << msg.errorMessage(); - HideMultiview(); -} - -bool FullBackgroundWidget::eventFilter(QObject *obj, QEvent *event) -{ - if (!QX11Info::isPlatformX11()) { - if(event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseMove || event->type() == 7){ - if(screenStatus & SCREEN_SAVER && !isBlank){ - clearScreensavers(); - } - } - } - if(event->type() == QEvent::WindowDeactivate){ - QTimer::singleShot(50,this,SLOT(laterActivate())); - }else if(event->type() == QEvent::WindowActivate){ -// if(QString(qgetenv("XDG_SESSION_TYPE")) == "wayland" && !QX11Info::isPlatformX11()) { -// PlasmaShellManager::getInstance()->setAppWindowKeepAbove(true); -// } - - QTimer::singleShot(500,this,SLOT(setLockState())); - QTimer::singleShot(200,this,SLOT(killWindow())); - } - return false; -} - -void FullBackgroundWidget::killWindow() -{ - if(isStartup && !process){ - process = new QProcess(this); - process->start("killall screensaver-focus-helper"); - } -} - -void FullBackgroundWidget::setIsStartup(bool val) -{ - isStartup = val; - if (lockWidget) { - lockWidget->setStartupMode(isStartup); - } - Q_EMIT StartupModeChanged(isStartup); -} - -bool FullBackgroundWidget::IsStartupMode() -{ - return isStartup; -} - -void FullBackgroundWidget::paintEvent(QPaintEvent *event) -{ - if(future.isRunning()){ - qDebug()<<"------------------------------------------------------------等待加载背景完成1"; - future.waitForFinished(); - qDebug()<<"------------------------------------------------------------加载背景完成1"; - }else{ - if(!future.isFinished() && future.isStarted()){ - qDebug()<<"------------------------------------------------------------等待加载背景完成2"; - future.waitForFinished(); - qDebug()<<"------------------------------------------------------------加载背景完成2"; - } - } - - for(auto screen : QGuiApplication::screens()) - { - QPainter painter(this); - if(background.isNull()){ - QColor cor = "#035290"; - painter.setBrush(cor); - painter.drawRect(screen->geometry()); - } else { - painter.drawPixmap(screen->geometry(), background); - QPainterPath path; - painter.setOpacity(0.25); - painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; - painter.setClipping(true); - painter.setPen(Qt::transparent); - path.addRect(this->rect()); - path.setFillRule(Qt::WindingFill); - painter.setBrush(QColor("#000000")); - painter.setPen(Qt::transparent); - painter.drawPath(path); - } - } - return QWidget::paintEvent(event); -} - -void FullBackgroundWidget::closeEvent(QCloseEvent *event) -{ - qDebug() << "FullBackgroundWidget::closeEvent"; - // 处理认证完成后收到屏幕变化信号,调用lockWidget指针崩溃问题 - QDesktopWidget *desktop = QApplication::desktop(); - disconnect(desktop, &QDesktopWidget::resized, - this, &FullBackgroundWidget::onDesktopResized); - disconnect(desktop, &QDesktopWidget::workAreaResized, - this, &FullBackgroundWidget::onDesktopResized); - disconnect(desktop, &QDesktopWidget::primaryScreenChanged, - this, &FullBackgroundWidget::onDesktopResized); - disconnect(desktop, &QDesktopWidget::screenCountChanged, - this, &FullBackgroundWidget::onDesktopResized); - if (isStartup){ - killWindow(); - setIsStartup(false); - } - if(future.isRunning()){ - future.cancel(); - future.waitForFinished(); - } -#ifdef USE_INTEL - //蓝牙连接后 唤醒信号会有延迟 以防退出时未收到信号导致kwin compositor未resume - QDBusInterface *interface = new QDBusInterface("org.ukui.KWin", - "/Compositor", - "org.ukui.kwin.Compositing", - QDBusConnection::sessionBus(), - this); - - if (!interface->isValid()){ - syslog(LOG_DEBUG, "interface error"); - return; - } - QDBusMessage msg = interface->call("resume"); - syslog(LOG_DEBUG, "after close resume kwin "); -#endif - - for(auto obj: children()) - { - QWidget *widget = dynamic_cast(obj); - if(widget) - widget->close(); - } - if(QX11Info::isPlatformX11()){ - closeGrab(); - } - - return QWidget::closeEvent(event); -} - -void FullBackgroundWidget::showEvent(QShowEvent *event) -{ - // XSetWindowAttributes top_attrs; - // top_attrs.override_redirect = False; - // XChangeWindowAttributes(QX11Info::display(), this->winId(), CWOverrideRedirect, &top_attrs); - // XRaiseWindow(QX11Info::display(), this->winId()); - // raise(); - - return QWidget::showEvent(event); -} - - -bool FullBackgroundWidget::nativeEventFilter(const QByteArray &eventType, void *message, long *result) -{ - if (qstrcmp(eventType, "xcb_generic_event_t") != 0) { - return false; - } - xcb_generic_event_t *event = reinterpret_cast(message); - const uint8_t responseType = event->response_type & ~0x80; - if (responseType == XCB_CONFIGURE_NOTIFY) { - xcb_configure_notify_event_t *xc = reinterpret_cast(event); - if(xc->window == winId()) { - laterOtherActivate(); - return false; - } - XClassHint ch; - ch.res_name = NULL; - ch.res_class = NULL; - XGetClassHint (QX11Info::display(), xc->window, &ch); - if(QString(ch.res_name) == "ukui-screensaver-dialog") { - if (ch.res_name) - XFree(ch.res_name); - if (ch.res_class) - XFree(ch.res_class); - laterOtherActivate(); - return false; - } else if (isOtherWnd(xc->window)) { - if (ch.res_name) - XFree(ch.res_name); - if (ch.res_class) - XFree(ch.res_class); - return false; - } - if (ch.res_name) - XFree(ch.res_name); - if (ch.res_class) - XFree(ch.res_class); - laterActivate(); - } else if(responseType == XCB_MAP_NOTIFY){ - xcb_map_notify_event_t *xm = reinterpret_cast(event); - if(xm->window == winId()) { - laterOtherActivate(); - return false; - } - XClassHint ch; - ch.res_name = NULL; - ch.res_class = NULL; - XGetClassHint (QX11Info::display(), xm->window, &ch); - if(QString(ch.res_name) == "ukui-screensaver-dialog") { - if (ch.res_name) - XFree(ch.res_name); - if (ch.res_class) - XFree(ch.res_class); - laterOtherActivate(); - return false; - } else if (isOtherWnd(xm->window)) { - if (ch.res_name) - XFree(ch.res_name); - if (ch.res_class) - XFree(ch.res_class); - return false; - } - if (ch.res_name) - XFree(ch.res_name); - if (ch.res_class) - XFree(ch.res_class); - laterActivate(); - } else if (responseType == XCB_DESTROY_NOTIFY) { - xcb_destroy_notify_event_t *xd = reinterpret_cast(event); - if(isOtherWnd(xd->window)) { - UnRegisteSubWnd(xd->window); - return false; - } - } else if (responseType == XCB_UNMAP_NOTIFY) { - xcb_unmap_notify_event_t *xum = reinterpret_cast(event); - if(isOtherWnd(xum->window)) { - UnRegisteSubWnd(xum->window); - return false; - } - } else if (responseType == XCB_KEY_PRESS) { -// xcb_key_press_event_t *xc = reinterpret_cast(event); -// qDebug()<<"---------------------XCB_KEY_PRESS:"<detail; - //onGlobalKeyPress(xc->detail); - } else if (responseType == XCB_KEY_RELEASE) { - xcb_key_release_event_t *xc = reinterpret_cast(event); - onGlobalKeyRelease(xc->detail); - } else if(responseType == XCB_GE_GENERIC){ - xcb_ge_generic_event_t *xc = reinterpret_cast(event); - if(xc->event_type == XCB_BUTTON_PRESS){ //此处获取的是窗口内的点击事件,光标坐标不需要使用,就直接使用QCursor接口获取了 - onGlobalButtonPressed(QCursor::pos().x(), QCursor::pos().y()); - }else if(xc->event_type == XCB_MOTION_NOTIFY){ //此处获取的是窗口内的点击事件,光标坐标不需要使用,就直接使用QCursor接口获取了 - onGlobalButtonDrag(QCursor::pos().x(),QCursor::pos().y()); - } - }else if (responseType == XCB_BUTTON_PRESS) { //此处获取的是窗口外的鼠标点击 - xcb_button_press_event_t *xc = reinterpret_cast(event); - int x = xc->root_x; - int y = xc->root_y; - onGlobalButtonPressed(x, y); - qDebug()<<"---------------------XCB_BUTTON_PRESS:"<(event); - int x = xc->root_x; - int y = xc->root_y; - onGlobalButtonDrag(x, y); - qDebug()<<"---------------------XCB_MOTION_NOTIFY:"<getScreensaver(); - if(saver->path == "/usr/lib/ukui-screensaver/ukui-screensaver-default") - return ; - clearScreensavers(); - } -#else - /*注释掉抓取鼠标后,使用触摸时会出现第一次触摸收不到事件,因此在这里也添加一下*/ - if(screenStatus & SCREEN_SAVER && !isBlank) - { - clearScreensavers(); - } -#endif -} - -void FullBackgroundWidget::init() -{ -/*捕获键盘,如果捕获失败,则可能是由于弹出菜单项已经捕获,那么模拟一次esc按键来退出菜单,如果仍捕获失败,则放弃锁屏,避免密码无法输入*/ - if(QX11Info::isPlatformX11()){ - if(establishGrab()) - qDebug()<<"establishGrab : true"; - else { - qDebug()<<"establishGrab : false"; - /*检测当前是否存在弹出菜单,只有存在弹出菜单时,才模拟按键esc*/ - if(checkHasPopupMenu()){ - XTestFakeKeyEvent(QX11Info::display(), XKeysymToKeycode(QX11Info::display(),XK_Escape), True, 1); - XTestFakeKeyEvent(QX11Info::display(), XKeysymToKeycode(QX11Info::display(),XK_Escape), False, 1); - XFlush(QX11Info::display()); - sleep(1); - } - HideMultiview(); - if(!establishGrab()) - { - exit(1); - } - } - - XWindowAttributes rootAttr; - XGetWindowAttributes(QX11Info::display(), QX11Info::appRootWindow(), &rootAttr); - XSelectInput( QX11Info::display(), QX11Info::appRootWindow(), - SubstructureNotifyMask|rootAttr.your_event_mask ); - - } - - qDebug()<<"----------------------------------------------------------------开始异步调用"; - future = QtConcurrent::run([=](){ - QImageReader reader; - reader.setFileName(configuration->getBackground()); - reader.setAutoTransform(true); - reader.setDecideFormatFromContent(true); - //reader.setScaledSize(QApplication::primaryScreen()->size()); - background = QPixmap::fromImageReader(&reader); - - if(!background.isNull()){ - background = blurPixmap(background); - } - }); - - if(QX11Info::isPlatformX11()){ - setWindowFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint - | Qt::X11BypassWindowManagerHint); - }else{ - setWindowFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint); - } - - /*x100下会出现黑色小方块问题,设置此属性时正常*/ - setAttribute(Qt::WA_TranslucentBackground); - - // 监听session信号 -// smInterface = new QDBusInterface(SM_DBUS_SERVICE, -// SM_DBUS_PATH, -// SM_DBUS_INTERFACE, -// QDBusConnection::sessionBus()); -// connect(smInterface, SIGNAL(StatusChanged(uint)), -// this, SLOT(onSessionStatusChanged(uint))); - -// int totalWidth = 0; -// int totalHeight = 0; -// for(auto screen : QGuiApplication::screens()) -// { -// totalWidth += screen->geometry().width(); -// totalHeight += screen->geometry().height(); -// } -// setGeometry(0, 0, totalWidth, totalHeight); - QDesktopWidget *desktop = QApplication::desktop(); - setGeometry(desktop->geometry()); - -#ifdef USE_INTEL - SoundDeviceSet::instance(); -#endif -} - -void FullBackgroundWidget::onCursorMoved(const QPoint &pos) -{ - if(!lockWidget) - { - return; - } - bool chkInOneScreen = false; - for(auto screen : QGuiApplication::screens()) - { - if(screen == qApp->primaryScreen()){ - qInfo()<<"LockWidget:"<geometry()<geometry(); - lockWidget->hide(); - lockWidget->setGeometry(screen->geometry()); - lockWidget->show(); - chkInOneScreen = true; - break; - } - } - if (!chkInOneScreen) { - for(auto screen : QGuiApplication::screens()) { - if(!screen){ - /*避免切换时闪烁*/ - qInfo()<<"LockWidget:"<geometry()<geometry()<<","<hide(); - lockWidget->setGeometry(screen->geometry()); - lockWidget->show(); - chkInOneScreen = true; - break; - } - } - } -} - -void FullBackgroundWidget::lock() -{ - showLockWidget(); - if(lockWidget){ - lockWidget->show(); - lockWidget->startAuth(); - } -#ifndef USE_INTEL - inhibit(); -#endif -} - -void FullBackgroundWidget::showLock() -{ - screenStatus = (ScreenStatus)(screenStatus | SCREEN_LOCK); - //qDebug() << "showLockWidget - screenStatus: " << screenStatus; -} - -void FullBackgroundWidget::showLockWidget() -{ -#ifdef USE_INTEL - screenStatus = /*(ScreenStatus)(screenStatus | SCREEN_LOCK)*/SCREEN_LOCK; -#else - screenStatus = (ScreenStatus)(screenStatus | SCREEN_LOCK); -#endif - qDebug() << "showLockWidget - screenStatus: " << screenStatus; - - if(!lockWidget) - { -#ifdef USE_INTEL - lockWidget = new TabletLockWidget(this); - connect(lockWidget, &TabletLockWidget::closed, - this, &FullBackgroundWidget::close); - connect(lockWidget, &TabletLockWidget::screenSaver, - this, [=] { - showScreensaver(); - }); - connect(lockWidget, &TabletLockWidget::blackSaver, - this, [=] { - onShowBlackBackGround(); - }); -#else - lockWidget = new LockWidget(this); - lockWidget->setStartupMode(isStartup); - connect(lockWidget, &LockWidget::closed, - this, &FullBackgroundWidget::close); - connect(lockWidget, &LockWidget::keyGlobalRelease, - this, &FullBackgroundWidget::onGlobalKeyRelease); -#endif - } - onCursorMoved(QCursor::pos()); - lockWidget->setFocus(); - if(QX11Info::isPlatformX11() ){ - XSetInputFocus(QX11Info::display(),this->winId(),RevertToParent,CurrentTime); - } - activateWindow(); - repaint(); -} - -void FullBackgroundWidget::onSecondRunParam(QString strParam) -{ - qDebug()<<"onSecondRunParam:"<getScreensaver(); - /*锁屏设置的Qt::WA_TranslucentBackground属性会导致第三方屏保变得透明,因此在使用第三方屏保时 - * 取消该属性,清除屏保时再设置回来*/ - if(saver->path != "/usr/lib/ukui-screensaver/ukui-screensaver-default") - { - setAttribute(Qt::WA_TranslucentBackground,false); - } - - ScreenSaverWidget *saverWidget = new ScreenSaverWidget(saver, this); - qDebug() << " new ScreenSaverWidget"; - widgetXScreensaverList.push_back(saverWidget); - //深色模式有一像素的白边,所以主屏幕向左,向右移一个像素点;这种操作后,外显上方仍旧会有一个像素的白边,暂时不对外显做偏移处理 - if(screen == qApp->primaryScreen()) { - saverWidget->setGeometry(screen->geometry().x()-1, screen->geometry().y()-1, - screen->geometry().width()+1, screen->geometry().height()+1); - } else { - saverWidget->setGeometry(screen->geometry()); - } - - } - setCursor(Qt::BlankCursor); - - //显示屏保时,停止认证(主要针对生物识别) - if(lockWidget) - { - lockWidget->stopAuth(); - lockWidget->hide(); - } - if (!isPreview && !(screenStatus & SCREEN_LOCK)) { - // 延迟启动锁屏 - delayLockScreen(); - } -} - -void FullBackgroundWidget::clearScreensavers() -{ - stopDelayLockScreen(); -#ifdef USE_INTEL - screenStatus = /*(ScreenStatus)(screenStatus & ~SCREEN_SAVER)*/SCREEN_LOCK; -#else - screenStatus = (ScreenStatus)(screenStatus & ~SCREEN_SAVER); -#endif - for(auto widget : widgetXScreensaverList) - { - widget->close(); - } - widgetXScreensaverList.clear(); - setAttribute(Qt::WA_TranslucentBackground,true); - qDebug() << "clearScreensavers - screenStatus: " << screenStatus; - - unsetCursor(); - if(screenStatus == UNDEFINED) - { - close(); - } - else - { - lock(); - } -} - -int FullBackgroundWidget::onSessionStatusChanged(uint status) -{ - qDebug() << "session status changed: " << status; - if(status != SESSION_IDLE) - { - //当前session没有处于空闲状态 - return -1; - } - qDebug() << "onSessionStatusChanged - screenStatus: " << screenStatus; - - if(configuration->idledelay() == -1) - { - return -1; - } -#ifdef USE_INTEL - if(screenStatus == SCREEN_LOCK_AND_SAVER) -#else - if(screenStatus & SCREEN_SAVER) -#endif - { - return -1; - } -#ifdef USE_INTEL - else if(screenStatus == SCREEN_LOCK) -#else - else if(screenStatus & SCREEN_LOCK) -#endif - { - showScreensaver(); - } - else if(screenStatus == UNDEFINED) - { -#ifdef USE_INTEL - //显示锁屏和屏保 - showLockWidget(); - showScreensaver(); -#else - //显示屏保 - showScreensaver(); -#endif - } - return 0; -} - -void FullBackgroundWidget::onSessionActiveChanged(bool isActive) -{ - if (lockWidget) { - lockWidget->onSessionActiveChanged(isActive); - } -} - -void FullBackgroundWidget::delayLockScreen() -{ - if (!m_timerLock) { - m_timerLock = new QTimer(this); - connect(m_timerLock, &QTimer::timeout, this, &FullBackgroundWidget::onLockScreenTimeout); - } - qDebug()<<"LockTimeout:"<locktimeout(); - if (configuration->locktimeout() != -1) { - stopDelayLockScreen(); - m_timerLock->start(configuration->locktimeout()*1000); - } -} - -void FullBackgroundWidget::stopDelayLockScreen() -{ - if (m_timerLock && m_timerLock->isActive()) { - m_timerLock->stop(); - } -} - -void FullBackgroundWidget::onLockScreenTimeout() -{ - qDebug()<<"onLockScreenTimeout:"<lockWhenXScreensaverActivated(); - if (configuration->lockWhenXScreensaverActivated()) { - showLock(); - } - m_timerLock->stop(); -} - -void FullBackgroundWidget::onBlankScreensaver(int nDelay/* = 0*/, bool hasLock/* = true*/) -{ - if (hasLock) { - showLockWidget(); - screenStatus = (ScreenStatus)(screenStatus | SCREEN_SAVER | SCREEN_LOCK); - } else { - screenStatus = (ScreenStatus)(screenStatus | SCREEN_SAVER); - } - qDebug() << "showScreensaver - screenStatus: " << screenStatus << nDelay; - - for(auto screen : QGuiApplication::screens()) - { - ScreenSaver *saver = configuration->getScreensaver(); - saver->mode = SaverMode(SAVER_BLANK_ONLY); - ScreenSaverWidget *saverWidget = new ScreenSaverWidget(saver, this); - widgetXScreensaverList.push_back(saverWidget); - saverWidget->setGeometry(screen->geometry()); - } - setCursor(Qt::BlankCursor); - isBlank = true; - - if (0 == nDelay) { - /*在进行压力测试时,可能会出现锁屏界面启动极慢,导致在睡眠之前调用了锁屏,但 - * 锁屏没来得及绑定睡眠唤醒信号,导致唤醒后,锁屏界面没有收到信号从而一直显示黑屏的问题。 - * 因此这里在进入黑色屏保时,通过后台接口,获取一次当前是否应该显示黑色屏保状态*/ - QString displayNum = QString(qgetenv("DISPLAY")).replace(":", "").replace(".", "_"); - QString sessionDbus = QString("%1%2").arg(QString(SS_DBUS_SERVICE)).arg(displayNum); - QDBusInterface *interface = new QDBusInterface(sessionDbus, - SS_DBUS_PATH, - SS_DBUS_INTERFACE); - if (!interface->isValid()) { - delete interface; - interface = new QDBusInterface(SS_DBUS_SERVICE, - SS_DBUS_PATH, - SS_DBUS_INTERFACE); - } - - QDBusReply stateReply = interface->call("GetBlankState"); - if(!stateReply.isValid()){ - return ; - } - - if(!stateReply){ - isBlank = false; - clearScreensavers(); - } - } else { - QTimer::singleShot(nDelay, this, [=](){ - if (isBlank) { - isBlank = false; - clearScreensavers(); - } - }); - } -} - -void FullBackgroundWidget::onScreensaver() -{ - showLockWidget(); - showScreensaver(); -} - -void FullBackgroundWidget::onGlobalKeyPress(const quint8 &key) -{ -#ifdef USE_INTEL - qDebug() << "onGlobalKeyPress " << key << "screenStatus " << screenStatus; - - if(m_delay) - { - qDebug() << "it is delay time ,ignore"; - return; - } - - if(!key.isEmpty() && (screenStatus == SCREEN_LOCK_AND_SAVER)) - { - clearScreensavers(); - }/*else{ - lockWidget->startAuth(); - inhibit(); - }*/ -// if(screenStatus == SCREEN_LOCK) -// { -// checkNumLock(); -// int keyValue = numberMatch(key);; -// if (keyValue >= 0 && keyValue <= 10 ) -// { -// lockWidget->RecieveKey(keyValue); -// } -// } -#else - -#endif -} - -void FullBackgroundWidget::onGlobalKeyRelease(int key) -{ -// if(key == "Caps_Lock") -// { -// lockWidget->capsLockChanged(); -// } -#ifdef USE_INTEL - - // 声音、亮度等调整 - // 取消声音快捷键设置,由settings-deamon控制 有一个bug,音量为零时再按静音键,静音指示灯会熄灭,可解决,但是不用锁屏做了 -// if(key == "XF86AudioRaiseVolume") -// { -// SoundDeviceSet::instance()->setValue(SoundDeviceSet::instance()->getValue() + 5); -// } -// else if(key == "XF86AudioLowerVolume") -// { -// SoundDeviceSet::instance()->setValue(SoundDeviceSet::instance()->getValue() - 5); -// } -// else if(key == "XF86AudioMute") -// { -// SoundDeviceSet::instance()->setMute(!(SoundDeviceSet::instance()->getIsMute())); -// } -// else - - if (key == "XF86MonBrightnessUp") // 亮度调整 - { - //qDebug() << "up"; - BrightnessDeviceSet* pBrightness = BrightnessDeviceSet::instance(); - pBrightness->setValue(pBrightness->getValue() + 5); - } - else if (key == "XF86MonBrightnessDown") - { - //qDebug() << "down"; - BrightnessDeviceSet* pBrightness = BrightnessDeviceSet::instance(); - pBrightness->setValue(pBrightness->getValue() - 5); - } - else if (key == "XF86RFKill") // 飞行模式 - { - // 键盘上的飞行模式实体键 生效,不需要在登录界面进行设置 - } - else if (key == "") // num_lock - { - // 键盘上的num_lock生效、不需要登录界面进行管理 - } -#else - if (QX11Info::isPlatformX11()) { - if (key == 65) { // "Space" - if (lockWidget && lockWidget->isVisible()) {/*keyReleaseEvent有时候监听不到Space的按键事件 原因未知 - 把Space按键放到nativeEventFilter里面*/ - lockWidget->key_enter_release(Qt::Key_Space); - } - } - if (key == 9 && screenStatus == SCREEN_LOCK) { // "escape" - bool canShow = true; - if (lockWidget && !lockWidget->exitSubWidget()) - canShow = false; - if (configuration && configuration->idledelay() == -1) - canShow = false; - if (!m_isAlreadyShowSaver) - canShow = false; - if (canShow) - showScreensaver(); - } else if (screenStatus & SCREEN_SAVER && !isBlank) { - clearScreensavers(); - } - } else { - if (key == Qt::Key_Escape && screenStatus == SCREEN_LOCK) { // "escape" - bool canShow = true; - if (lockWidget && !lockWidget->exitSubWidget()) - canShow = false; - if (configuration && configuration->idledelay() == -1) - canShow = false; - if (!m_isAlreadyShowSaver) - canShow = false; - if (canShow) - showScreensaver(); - } else if (screenStatus & SCREEN_SAVER && !isBlank) { - clearScreensavers(); - } - } -#endif -} - -void FullBackgroundWidget::onGlobalButtonDrag(int xPos, int yPos) -{ -#ifdef USE_INTEL - if(screenStatus == SCREEN_LOCK_AND_SAVER) - { - ScreenSaver *saver = configuration->getScreensaver(); - if(saver->path == "/usr/lib/ukui-screensaver/ukui-screensaver-default") - return ; - clearScreensavers(); - } -#else - if(screenStatus & SCREEN_SAVER && !isBlank) - { - ScreenSaver *saver = configuration->getScreensaver(); - if(isPassed || saver->path != "/usr/lib/ukui-screensaver/ukui-screensaver-default"){ - clearScreensavers(); - } - isPassed = true; - } -#endif -} - -void FullBackgroundWidget::onGlobalButtonPressed(int xPos, int yPos) -{ -#ifndef USE_INTEL - if(screenStatus & SCREEN_SAVER && !isBlank) - { - clearScreensavers(); - } -#endif -} - -void FullBackgroundWidget::closeScreensaver() -{ - if(screenStatus & SCREEN_SAVER){ - clearScreensavers(); - } - - if(screenStatus & SCREEN_LOCK){ - if(lockWidget){ - lockWidget->stopAuth(); - lockWidget->close(); - } - } - - close(); -} - -void FullBackgroundWidget::onScreenCountChanged(int) -{ -#ifdef USE_INTEL - QDesktopWidget *desktop = QApplication::desktop(); - setGeometry(desktop->geometry()); - //repaint(); - update(); - clearScreensavers(); -#else - QDesktopWidget *desktop = QApplication::desktop(); - setGeometry(desktop->geometry()); - //repaint(); - if(screenStatus & SCREEN_SAVER) - { - clearScreensavers(); - } - update(); -#endif -} - - -void FullBackgroundWidget::onDesktopResized() -{ -#ifdef USE_INTEL - qDebug() << "[FullBackgroundWidget] [onDesktopResized]"; - QDesktopWidget *desktop = QApplication::desktop(); - if(NULL == desktop) - { - qWarning() << " get desktop size failed"; - return; - } - setGeometry(desktop->geometry()); - if(lockWidget) - onCursorMoved(cursor().pos()); -// clearScreensavers(); - //repaint(); - update(); - if(screenStatus == SCREEN_LOCK_AND_SAVER) - { - clearScreensavers(); - showScreensaver(); - } -#else - QDesktopWidget *desktop = QApplication::desktop(); - setGeometry(desktop->geometry()); - if(lockWidget) - onCursorMoved(QCursor::pos()); - if(screenStatus & SCREEN_SAVER) - { - clearScreensavers(); - } - //repaint(); - update(); -#endif - -// if(QString(qgetenv("XDG_SESSION_TYPE")) == "wayland" && !QX11Info::isPlatformX11() ) { -// PlasmaShellManager::getInstance()->setPos(this->windowHandle(),QPoint(0,0)); -// } -} - -void FullBackgroundWidget::laterInhibit(bool val) -{ - if(val){ - inhibit(); - }else{ - uninhibit(); - } -} - -void FullBackgroundWidget::laterStartAuth() -{ - if (lockWidget) - lockWidget->startAuth(); - inhibit(); -} - -void FullBackgroundWidget::onPrepareForSleep(bool sleep) -{ - ///系统休眠时,会关闭总线,导致设备不可用,发生错误 - ///在系统休眠之前停止认证,在系统唤醒后重新开始认证 - qDebug()<<"onPrepareForSleep:"<stopAuth(); - uninhibit(); - } - else - { - if(screenStatus & SCREEN_SAVER) - { - isBlank = false; - clearScreensavers(); - }else{ - repaint(); - if(lockWidget) - lockWidget->startAuth(); - inhibit(); - } - } -} - -void FullBackgroundWidget::inhibit() -{ - if (m_inhibitFileDescriptor.isValid()) { - return; - } - - QDBusMessage message = QDBusMessage::createMethodCall("org.freedesktop.login1", - "/org/freedesktop/login1", - "org.freedesktop.login1.Manager", - QStringLiteral("Inhibit")); - message.setArguments(QVariantList({QStringLiteral("sleep"), - "Screen Locker", - "Ensuring that the screen gets locked before going to sleep", - QStringLiteral("delay")})); - QDBusPendingReply reply = QDBusConnection::systemBus().call(message); - if (!reply.isValid()) { - return; - } - reply.value().swap(m_inhibitFileDescriptor); -} - -void FullBackgroundWidget::uninhibit() -{ - if (!m_inhibitFileDescriptor.isValid()) { - return; - } - m_inhibitFileDescriptor = QDBusUnixFileDescriptor(); -} - -/** - * @brief FullBackgroundWidget::getPaddingPixmap - * @param pixmap 需要填充的图像 - * @param width 容器宽度 - * @param height 容器高度 - * @return - */ -QPixmap FullBackgroundWidget::getPaddingPixmap(QPixmap pixmap, int width, int height) -{ - if (pixmap.isNull() || pixmap.width() == 0 || pixmap.height() == 0) - { - return QPixmap(); - } - - bool useHeight; - float scaled = 0.0; - QPixmap scaledPixmap; - QPixmap paddingPixmap; - qint64 rw = qint64(height) * qint64(pixmap.width()) / qint64(pixmap.height()); - - useHeight = (rw >= width); - if (useHeight) { - scaled = float(height) / float(pixmap.height()); - scaledPixmap = pixmap.scaled(pixmap.width() * scaled, height); - paddingPixmap = scaledPixmap.copy((pixmap.width() * scaled - width) / 2 , 0, width, height); - } else { - scaled = float(width) / float(pixmap.width()); - scaledPixmap = pixmap.scaled(width, pixmap.height() * scaled); - paddingPixmap = scaledPixmap.copy(0 , (pixmap.height() * scaled - height) / 2,width, height); - } - - return paddingPixmap; -} - -int FullBackgroundWidget::RegisteSubWnd(quint64 uWndId) -{ - if (!m_listWndIds.contains(uWndId) && m_listWndIds.size() < SUBWND_COUNT_MAX) { - m_listWndIds.append(uWndId); - qDebug()<<"RegisterSubWnd:"< FullBackgroundWidget::GetSubWndIds() -{ - return m_listWndIds; -} - -void FullBackgroundWidget::raiseOtherWnd() -{ - //qDebug()<<"raiseOtherWnd----:"<getScreensaver(); - saver->mode = SaverMode(SAVER_BLANK_ONLY); - ScreenSaverWidget *saverWidget = new ScreenSaverWidget(saver, this); - widgetBlackList.push_back(saverWidget); - saverWidget->setGeometry(screen->geometry()); - - //深色模式有一像素的白边,所以主屏幕向左,向右移一个像素点;这种操作后,外显上方仍旧会有一个像素的白边,暂时不对外显做偏移处理 - if(screen == qApp->primaryScreen()) { - saverWidget->setGeometry(screen->geometry().x()-1, screen->geometry().y()-1, - screen->geometry().width()+1, screen->geometry().height()+1); - } else { - saverWidget->setGeometry(screen->geometry()); - } - - - } - setCursor(Qt::BlankCursor); -} -#endif - -bool FullBackgroundWidget::initMultiviewDbus() -{ - if (m_dbusIfMultiview) { - return true; - } - m_dbusIfMultiview = new QDBusInterface("org.ukui.KWin", - "/MultitaskView", - "org.ukui.KWin.MultitaskView", - QDBusConnection::sessionBus(), - this); - - if (!m_dbusIfMultiview || !m_dbusIfMultiview->isValid()){ - qWarning()<<"org.ukui.KWin.MultitaskView interface error!"; - return false; - } - return true; -} - -bool FullBackgroundWidget::isMultiviewHidden() -{ - if (initMultiviewDbus()) { - QDBusReply reply = m_dbusIfMultiview->call("isHidden"); - if(!reply.isValid()) { - qWarning() << "isHidden error:" << reply.error(); - return true; - } - return reply.value(); - } - return true; -} - -void FullBackgroundWidget::HideMultiview() -{ - if (initMultiviewDbus()) { - QDBusMessage result = m_dbusIfMultiview->call("hide"); - if(result.type() == QDBusMessage::ErrorMessage) { - qWarning() << "HideMultiview error:" << result.errorMessage(); - } - } -} - -void FullBackgroundWidget::ShowMultiview() -{ - if (initMultiviewDbus()) { - QDBusMessage result = m_dbusIfMultiview->call("show"); - if(result.type() == QDBusMessage::ErrorMessage) { - qWarning() << "HideMultiview error:" << result.errorMessage(); - } - } -} diff --git a/src/fullbackgroundwidget.h b/src/fullbackgroundwidget.h deleted file mode 100644 index e960415..0000000 --- a/src/fullbackgroundwidget.h +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#ifndef FULLBACKGROUNDWIDGET_H -#define FULLBACKGROUNDWIDGET_H - -#ifndef QT_NO_KEYWORDS -#define QT_NO_KEYWORDS -#endif -#include -#include -#include -#include "types.h" -#include -#include -#include -#include "logind.h" -#include "config.h" - -void x11_get_screen_size(int *width,int *height); - -class LockWidget; -class XEventMonitor; -class MonitorWatcher; -class Configuration; -class QDBusInterface; -class TabletLockWidget; -class QProcess; -class FullBackgroundWidget : public QWidget , public QAbstractNativeEventFilter -{ - Q_OBJECT -public: - explicit FullBackgroundWidget(QWidget *parent = nullptr); - void paintEvent(QPaintEvent *event); - void closeEvent(QCloseEvent *event); - void showEvent(QShowEvent *event); - virtual bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) override; - void mouseMoveEvent(QMouseEvent *e); - void mousePressEvent(QMouseEvent *e); - void onScreensaver(); - void onBlankScreensaver(int nDelay = 0, bool hasLock = true); - void closeScreensaver(); - void setIsStartup(bool val); - - int RegisteSubWnd(quint64 uWndId); - int UnRegisteSubWnd(quint64 uWndId); - QList GetSubWndIds(); - bool IsStartupMode(); - -public Q_SLOTS: - void onCursorMoved(const QPoint &pos); - void lock(); - void showLockWidget(); - void showLock(); - void showScreensaver(bool isPreview = false); - void onSecondRunParam(QString strParam); - int onSessionStatusChanged(uint status); - void inhibit(); - void uninhibit(); -#ifdef USE_INTEL - void propertiesChangedSlot(QString, QMap, QStringList); - void onShowBlackBackGround(); -#endif - void onSessionActiveChanged(bool isActive); - -Q_SIGNALS: - void StartupModeChanged(bool isStartup); - -private: - void init(); - void clearScreensavers(); - bool eventFilter(QObject *obj, QEvent *event); - - QPixmap getPaddingPixmap(QPixmap pixmap, int width, int height); -// void checkNumLock(); -// int numberMatch(const QString &key); - void raiseOtherWnd(); - bool isOtherWnd(int wndId); - void delayLockScreen(); - void stopDelayLockScreen(); - bool initMultiviewDbus(); - bool isMultiviewHidden(); - void HideMultiview(); - void ShowMultiview(); - -private Q_SLOTS: - void onScreenCountChanged(int); - void onDesktopResized(); - void onGlobalKeyPress(const quint8 &key); - void onGlobalKeyRelease(int key); - void onGlobalButtonDrag(int xPos, int yPos); - void onGlobalButtonPressed(int xPos, int yPos); - void onPrepareForSleep(bool sleep); - void switchToLinux(); - void laterActivate(); - void laterOtherActivate(); - void setLockState(); - void killWindow(); - void laterInhibit(bool val); - void laterStartAuth(); - void onLockScreenTimeout(); - -private: - QDBusInterface *smInterface; -#ifdef USE_INTEL - TabletLockWidget *lockWidget; -#else - LockWidget *lockWidget; -#endif - XEventMonitor *xEventMonitor; - MonitorWatcher *monitorWatcher; - Configuration *configuration; - QList widgetXScreensaverList; - QList widgetBlackList; - QList xscreensaverPidList; - bool isLocked; - bool lockState; - ScreenStatus screenStatus; - QPixmap background; - QDBusUnixFileDescriptor m_inhibitFileDescriptor; - bool isPassed; - bool m_delay; - int isBlank; - QProcess *process = nullptr; - bool lockEnabled; - bool isStartup = false; - QFuture future; - - // 上层窗口管理 - QList m_listWndIds; - QTimer *m_timerLock = nullptr; - bool m_isAlreadyShowSaver = false; - - // 多任务视图接口 - QDBusInterface *m_dbusIfMultiview = nullptr; -}; - -#endif // FULLBACKGROUNDWIDGET_H diff --git a/src/generalauthwidget.cpp b/src/generalauthwidget.cpp deleted file mode 100644 index eaa2efa..0000000 --- a/src/generalauthwidget.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#include "generalauthwidget.h" - -GeneralAuthWidget::GeneralAuthWidget(QWidget *parent) : QWidget(parent) -{ - -} diff --git a/src/generalauthwidget.h b/src/generalauthwidget.h deleted file mode 100644 index 47f2c57..0000000 --- a/src/generalauthwidget.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#ifndef GENERALAUTHWIDGET_H -#define GENERALAUTHWIDGET_H - -#include - -class GeneralAuthWidget : public QWidget -{ - Q_OBJECT -public: - explicit GeneralAuthWidget(QWidget *parent = nullptr); - -signals: - -public slots: -}; - -#endif // GENERALAUTHWIDGET_H \ No newline at end of file diff --git a/src/gestureauthdialog.cpp b/src/gestureauthdialog.cpp deleted file mode 100644 index ca657dc..0000000 --- a/src/gestureauthdialog.cpp +++ /dev/null @@ -1,402 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * - * Authors: ZHAI Kang-ning -**/ -#include "gestureauthdialog.h" - -#include -#include -#include -#include -#include -#include - -int gestureScale = 1; - -/** - * @author zhaikangning - * @date 2020/09/15 - * 手势密码页 - * 功能未完善 未对接pam - * 未来进化 所有登录均继承认证父类 该父类含有密码校验等基本功能 - */ - -GestureAuthDialog::GestureAuthDialog(QWidget *parent) : QWidget(parent), - m_bgColor("#000000"), - m_outCircleColor("#fff333"), - m_tipLineColor("#ff0000"), - m_circleRingColor("#ddffff"), - m_radius(20), - m_margin(5), - m_pressed(false), - m_showText(true), - m_inputPassword(""), - m_is_set_password(false), - m_is_check_password(false) -{ - m_posInCircle.isIn = false; - qDebug() <<"-----------init width=" << width() << ",height=" << height(); - - m_set_password = new QPushButton(this); - m_set_password->setGeometry(0,0,m_set_password->width(),m_set_password->height()); - m_set_password->setText("设置密码"); - connect(m_set_password, &QPushButton::clicked,this, [=] { - m_chech_result->setText("请输入密码"); - m_is_set_password = true; - }); - - - m_unlock = new QPushButton(this); - m_unlock->setText("解锁"); - m_unlock->setGeometry(0,m_set_password->height() + 2,m_unlock->width(),m_unlock->height()); - connect(m_unlock,&QPushButton::clicked, this, [=] { - m_chech_result->setText("密码校验"); - m_is_check_password = true; - }); - - m_chech_result = new QLabel("校验结果", this); - m_chech_result->setStyleSheet("color:#ffeeff;"); - m_chech_result->setGeometry(0,m_set_password->height() + m_unlock->height() +2, m_chech_result->width(), m_chech_result->height()); - - resize(640,480); -} - -GestureAuthDialog::~GestureAuthDialog() -{ - -} - -void GestureAuthDialog::paintEvent(QPaintEvent *event) -{ - int width = this->width(); - int height = this->height(); - int side = qMin(width, height); - qDebug() <<"-----------width=" << width << ",height=" << height << ",side=" << side; - - QPainter painter(this); - painter.setRenderHint(QPainter::Antialiasing); - painter.translate(width / 2, height / 2); - painter.scale(side / 200, side / 200); - gestureScale = side/200; - - drawBg(&painter); - drawOutCircle(&painter); - drawTipLine(&painter); - drawInCircle(&painter); - drawJoinLine(&painter); -} -void GestureAuthDialog::drawBg(QPainter *painter) -{ - painter->save(); - - int width = this->width(); - int height = this->height(); - - painter->setPen(Qt::NoPen); - m_bgColor.setAlpha(100); - painter->setBrush(m_bgColor); - painter->drawRect(-width / 2, -height / 2, width, height); - - painter->restore(); -} - -void GestureAuthDialog::drawOutCircle(QPainter *painter) -{ - painter->save(); - QPen pen(m_outCircleColor, 2); - painter->setPen(pen); - painter->setBrush(Qt::NoBrush); - - for (int i = 0; i < 3; i++) - { - for (int j = 0; j < 3; j++) - { - int x = -5 * m_radius + j * 4 * m_radius; - int y = -5 * m_radius + i * 4 * m_radius; - painter->drawEllipse(x, y, m_radius * 2, m_radius * 2); -//qDebug() << "-------------x,y=" << x << ","<< y; - if (m_showText) - { - int number = posToNumber(i, j); - QString text = QString::number(number); - x = -4 * m_radius + j * 4 * m_radius; - y = -4 * m_radius + i * 4 * m_radius; - int textWidth = fontMetrics().width(text); - int textHeight = fontMetrics().height(); - painter->drawText(x - textWidth / 2, y + textWidth / 2, text); - } - } - } - - painter->restore(); -} - -void GestureAuthDialog::drawTipLine(QPainter *painter) -{ - painter->save(); - - int offset = 3; - - if (m_posInCircle.isIn) - { - if (!m_pressed) - { - painter->setPen(m_tipLineColor); - painter->setBrush(Qt::NoBrush); - - int x = -m_radius * 5 + m_posInCircle.j * 4 * m_radius - offset; - int y = -m_radius * 5 + m_posInCircle.i * 4 * m_radius - offset; - int w = (m_radius + offset) * 2; - int h = (m_radius + offset) * 2; - QRect rect(x, y, w, h); - painter->drawEllipse(rect); - } - } - - painter->restore(); -} - -void GestureAuthDialog::drawInCircle(QPainter *painter) -{ - painter->save(); - - if (m_pressed) - { - int offset1 = 1;//圆环偏移量 - int offset2 = 3;//内圆偏移量 - - if (m_posInCircle.isIn) - { - //绘制圆环 - painter->setPen(m_circleRingColor); - painter->setBrush(m_circleRingColor); - int x = -m_radius * 5 + m_posInCircle.j * 4 * m_radius + offset1; - int y = -m_radius * 5 + m_posInCircle.i * 4 * m_radius + offset1; - int w = (m_radius - offset1) * 2; - int h = (m_radius - offset1) * 2; - QRect rect(x, y, w, h); - painter->drawEllipse(rect); - - painter->setPen(m_outCircleColor); - painter->setBrush(m_outCircleColor); - x = -m_radius * 5 + m_posInCircle.j * 4 * m_radius + offset2; - y = -m_radius * 5 + m_posInCircle.i * 4 * m_radius + offset2; - w = (m_radius - offset2) * 2; - h = (m_radius - offset2) * 2; - rect = QRect(x, y, w, h); - painter->drawEllipse(rect); - - x = -m_radius * 4 + m_posInCircle.j * 4 * m_radius; - y = -m_radius * 4 + m_posInCircle.i * 4 * m_radius; - - if (!m_vecInputPoints.contains(QPoint(x, y))) - { - m_vecInputPoints.push_back(QPoint(x, y)); - int number = posToNumber(m_posInCircle.i, m_posInCircle.j); - m_inputPassword += QString::number(number); - } - } - } - - painter->restore(); -} - -void GestureAuthDialog::drawJoinLine(QPainter *painter) -{ - painter->save(); - - QPen pen(m_outCircleColor, 3); - painter->setPen(pen); - //绘制连接线段 - for (int i = 0; i < m_vecInputPoints.count() - 1; i++) - { - painter->drawLine(m_vecInputPoints[i], m_vecInputPoints[i + 1]); - } - - int offset1 = 1;//圆环偏移量 - int offset2 = 3;//内圆偏移量 - //绘制连接圆 - for (int i = 0; i < m_vecInputPoints.count(); i++) - { - int x = m_vecInputPoints[i].x() - m_radius + offset1; - int y = m_vecInputPoints[i].y() - m_radius + offset1; - int w = 2 * (m_radius - offset1); - int h = 2 * (m_radius - offset1); - painter->setPen(m_circleRingColor); - painter->setBrush(m_circleRingColor); - painter->drawEllipse(x, y, w, h); - - x = m_vecInputPoints[i].x() - m_radius + offset2; - y = m_vecInputPoints[i].y() - m_radius + offset2; - w = 2 * (m_radius - offset2); - h = 2 * (m_radius - offset2); - painter->setPen(m_outCircleColor); - painter->setBrush(m_outCircleColor); - painter->drawEllipse(x, y, w, h); - } - //绘制跟随线 - if (m_pressed && m_vecInputPoints.count() < 9) - { - int width = this->width(); - int height = this->height(); - int side = qMin(width, height); - int gestureScale = side / 200; - int x = (m_followPoint.x() - width / 2) / gestureScale; - int y = (m_followPoint.y() - height / 2) / gestureScale; - if (m_vecInputPoints.count() > 0) - { - painter->setPen(pen); - painter->drawLine(m_vecInputPoints.last(), QPoint(x, y)); - } - } - - painter->restore(); -} - -void GestureAuthDialog::mouseMoveEvent(QMouseEvent *event) -{ - //nothing - qDebug() << "--------mouseMoveEvent(" << event->x() << "," << event->y() << ")"; - // qDebug() << "-------------gestureScale=" << gestureScale; - int x = (event->x() - this->width()/2) / gestureScale; - int y = (event->y() - this->height()/2) / gestureScale; - // qDebug() << "--------mousePressEvent转化后 x,y(" << x << "," << y << ")"; - int jMax = 0; - if (x >=0) - jMax = 1; - - for (int i = 0; i < 3; i++) - { - for (int j = jMax; j < 3; j++) - { - - int x1 = -4 * m_radius + j * 4 * m_radius; - int y1 = -4 * m_radius + i * 4 * m_radius; - // qDebug() << "--------每个圆心的位置 x1,y1(" << x1 << "," << y1 << ")"; - if (distance(x , y, x1, y1) <= m_radius) - { - QString numStr = QString::number(posToNumber(i,j), 10); - if (m_inputPassword.contains(numStr)) - { - qWarning() << "已选过该区域"; - return; - } - m_inputPassword.append(numStr); - - m_posInCircle.i = i; - m_posInCircle.j = j; -// m_posInCircle.isIn = true; - qDebug() << "---------------选中了"<< posToNumber(i,j); - - - m_vecInputPoints.append(QPoint(x1, y1)); //鼠标移动选点 - m_followPoint = QPoint(x, y); - repaint(); - } - } - } -} - -void GestureAuthDialog::mousePressEvent(QMouseEvent *event) -{ - //nothing - qDebug() << "--------mousePressEvent(" << event->x() << "," << event->y() << ")"; -// qDebug() << "-------------gestureScale=" << gestureScale; - int x = (event->x() - this->width()/2) / gestureScale; - int y = (event->y() - this->height()/2) / gestureScale; -// qDebug() << "--------mousePressEvent转化后 x,y(" << x << "," << y << ")"; - - for (int i = 0; i < 3; i++) - { - for (int j = 0; j < 3; j++) - { - int x1 = -4 * m_radius + j * 4 * m_radius; - int y1 = -4 * m_radius + i * 4 * m_radius; -// qDebug() << "--------每个圆心的位置 x1,y1(" << x1 << "," << y1 << ")"; - if (distance(x , y, x1, y1) <= m_radius) - { - m_posInCircle.i = i; - m_posInCircle.j = j; - m_posInCircle.isIn = true; - - m_vecInputPoints.append(QPoint(x1, y1)); //鼠标移动选点 - m_followPoint = QPoint(x1, y1); - qDebug() << "---------------选中了"<< posToNumber(i,j); - repaint(); - } - } - } -} - -void GestureAuthDialog::mouseReleaseEvent(QMouseEvent *event) -{ - //nothing - qDebug() << "--------mouseReleaseEvent(" << event->x() << "," << event->y() << ")"; - m_posInCircle.isIn = false; - if (m_is_set_password && !m_inputPassword.isEmpty()) - { - m_password = m_inputPassword; - m_chech_result->setText("密码设置成功"); - qDebug() << "---------密码:" << m_password; - m_is_set_password = false; - } - - if (m_is_check_password) { - if (m_inputPassword == m_password) - { - m_chech_result->setText("密码正确"); - qDebug() << "---------密码:" << m_password << " 输入的是:" << m_inputPassword; - emit authenticateCompete(true); -// m_is_check_password = false; - } else { - m_chech_result->setText("密码错误"); - qDebug() << "---------密码:" << m_password << " 输入的是:" << m_inputPassword; - } - } - m_vecInputPoints.clear(); - m_inputPassword.clear(); - repaint(); -} - -double GestureAuthDialog::distance(int x1, int y1, int x2, int y2) -{ - //nothing - double x = x1 - x2; - double y = y1 - y2; - return sqrt(x*x + y*y); -} - -int GestureAuthDialog::posToNumber(int i, int j) -{ - //nothing - return ((3*i) + j +1); -} - -void GestureAuthDialog::setPassword(const QString password) -{ - //nothing -} - -QString GestureAuthDialog::getPassword() -{ - //nothing -} - -bool GestureAuthDialog::checkPassword() -{ - //nothing -} diff --git a/src/gestureauthdialog.h b/src/gestureauthdialog.h deleted file mode 100644 index ad32bc7..0000000 --- a/src/gestureauthdialog.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * - * Authors: ZHAI Kang-ning -**/ -#ifndef GESTUREAUTHDIALOG_H -#define GESTUREAUTHDIALOG_H - -#include -#include -#include -#include -#include -#include - -class GestureAuthDialog : public QWidget -{ - Q_OBJECT -public: - struct PosInCircle - { - int i; //行 - int j; //列 - bool isIn; //是否在范围内 - }; - explicit GestureAuthDialog(QWidget *parent = nullptr); - ~GestureAuthDialog(); - - void setPassword(const QString password); - QString getPassword(); - bool checkPassword(); -protected: - void paintEvent(QPaintEvent *event); - void mouseMoveEvent(QMouseEvent *event); - void mousePressEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void drawBg(QPainter *painter); - void drawOutCircle(QPainter *painter); - void drawTipLine(QPainter *painter); - void drawInCircle(QPainter *painter); - void drawJoinLine(QPainter *painter); -private: - double distance(int x1, int y1, int x2, int y2); - int posToNumber(int i, int j); -Q_SIGNALS: - void correctPassword(bool isCorrect, QString password); - void authenticateCompete(bool result); -public Q_SLOTS: -private: - QColor m_bgColor; //背景色 - QColor m_outCircleColor; //外圆颜色 - QColor m_tipLineColor; //提示线颜色 - QColor m_circleRingColor; //圆环颜色 - int m_margin; //外边距 - int m_radius; //圆相对半径 - PosInCircle m_posInCircle; //判断点是否在圆内 - bool m_pressed; //鼠标按下 - bool m_showText; //是否显示文字 - - QVector m_vecInputPoints; //鼠标移动选点 - QPoint m_followPoint; //鼠标跟随点 - QString m_password; //原密码 - QString m_inputPassword; //鼠标移动选点转换为密码 - - QPushButton *m_set_password; - bool m_is_set_password; - QPushButton *m_unlock; - bool m_is_check_password; - QLabel *m_chech_result; -}; - -#endif // GESTUREAUTHDIALOG_H diff --git a/src/greeterservice.cpp b/src/greeterservice.cpp deleted file mode 100644 index d869659..0000000 --- a/src/greeterservice.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#include "greeterservice.h" -#include - -#include - -#define GREETERDAEMON_DBUS_SERVICE "org.ukui.GreeterDaemon" -#define GREETERDAEMON_DBUS_PATH "/org/ukui/GreeterDaemon" -#define GREETERDAEMON_DBUS_INTERFACE "org.ukui.GreeterDaemon" - -#define FD_DBUS_SERVICE "org.freedesktop.DBus" -#define FD_DBUS_PATH "/org/freedesktop/DBus" -#define FD_DBUS_INTERFACE "org.freedesktop.DBus" - -/* For the type WillLoginUserInfo */ -QDBusArgument &operator<<(QDBusArgument &argument, const WillLoginUserInfo &willLoginUserInfo) -{ - argument.beginStructure(); - argument << willLoginUserInfo.strUserName << willLoginUserInfo.isOneKeyLogin; - argument.endStructure(); - return argument; -} - -const QDBusArgument &operator>>(const QDBusArgument &argument, WillLoginUserInfo &willLoginUserInfo) -{ - argument.beginStructure(); - argument >> willLoginUserInfo.strUserName >> willLoginUserInfo.isOneKeyLogin; - argument.endStructure(); - return argument; -} - -QDebug operator <<(QDebug stream, const WillLoginUserInfo &willLoginUserInfo) -{ - stream << "WillLogUser [" - << willLoginUserInfo.strUserName - << willLoginUserInfo.isOneKeyLogin - << "]"; - return stream; -} - -GreeterService* GreeterService::m_instance = nullptr; -GreeterService::GreeterService(QObject *parent) - : QDBusAbstractInterface(GREETERDAEMON_DBUS_SERVICE, - GREETERDAEMON_DBUS_PATH, - GREETERDAEMON_DBUS_INTERFACE, - QDBusConnection::systemBus(), - parent) -{ - qRegisterMetaType("WillLoginUserInfo"); - qDBusRegisterMetaType(); - - setTimeout(2147483647); - - QDBusInterface *dbusService = new QDBusInterface(FD_DBUS_SERVICE, - FD_DBUS_PATH, - FD_DBUS_INTERFACE, - QDBusConnection::systemBus()); - if (dbusService) { - QDBusReply result = dbusService->call(QStringLiteral("ListActivatableNames")); - if(!result.isValid()) { - qWarning() << "ListActivatableNames error:" << result.error().message(); - } else { - QStringList listNames = result.value(); - if (listNames.contains(GREETERDAEMON_DBUS_SERVICE)) { - m_isActivatable = true; - } - } - delete dbusService; - } -} - -GreeterService* GreeterService::instance(QObject *parent) -{ - if (!m_instance) { - m_instance = new GreeterService(parent); - } - return m_instance; -} - -void GreeterService::SwitchToUser(QString strUserName) -{ - QDBusReply reply = call(QStringLiteral("SwitchToUser"), strUserName); - if(!reply.isValid()) - { - qWarning() << "SwitchToUser error:" << reply.error(); - return ; - } - return ; -} - -void GreeterService::SwitchToGreeterUser(QString strUserName) -{ - QDBusReply reply = call(QStringLiteral("SwitchToGreeterUser"), strUserName); - if(!reply.isValid()) - { - qWarning() << "SwitchToGreeterUser error:" << reply.error(); - return ; - } - return ; -} - -WillLoginUserInfo GreeterService::getWillSwitchUser() -{ - WillLoginUserInfo willLoginUserInfo; - QDBusMessage result = call(QStringLiteral("getWillSwitchUser")); - if(result.type() == QDBusMessage::ErrorMessage) { - qWarning() << "getWillSwitchUser error:" << result.errorMessage(); - return willLoginUserInfo; - } - if (result.arguments().size() > 0) { - QDBusArgument argInfo = result.arguments().at(0).value(); - argInfo >> willLoginUserInfo; - } - qDebug()<<"getUserInfo:"<. - * -**/ -#ifndef GREETERSERVICE_H -#define GREETERSERVICE_H - -#include -#include - -/** - * @brief 用户信息 - */ -struct WillLoginUserInfo -{ - QString strUserName = ""; - bool isOneKeyLogin = false; -}; - -QDBusArgument &operator <<(QDBusArgument &arg, const WillLoginUserInfo &willLoginUserInfo); -const QDBusArgument &operator >>(const QDBusArgument &arg, WillLoginUserInfo &willLoginUserInfo); -QDebug operator <<(QDebug stream, const WillLoginUserInfo &willLoginUserInfo); - -Q_DECLARE_METATYPE(WillLoginUserInfo) - -/** - * @brief 登录服务客户端类 - * - */ -class GreeterService : public QDBusAbstractInterface -{ - Q_OBJECT -private: - /** - * @brief 构造函数 - * - * @param parent 父指针 - */ - explicit GreeterService(QObject *parent = nullptr); - -public: - /** - * @brief 单实例 - * - * @param parent 父指针 - * @return GreeterService 单实例对象指针 - */ - static GreeterService *instance(QObject *parent = nullptr); - /** - * @brief 用户名是否有效 - * - * @param strUserName 用户名 - * @return bool true 有效,否则 无效 - */ - bool isUserNameValid(QString strUserName); - /** - * @brief 服务是否可启动 - * @return true 可启动,否则 不可启动 - */ - bool isServiceActivatable() { return m_isActivatable; } - -public Q_SLOTS: - /** - * @brief 一键切换并登录用户 - * - * @param strUserName 用户名 - */ - void SwitchToUser(QString strUserName); - /** - * @brief 切换到登录用户 - * - * @param strUserName 用户名 - */ - void SwitchToGreeterUser(QString strUserName); - /** - * @brief 将要登录的用户信息 - * - * @return WillLoginUserInfo 用户信息 - */ - WillLoginUserInfo getWillSwitchUser(); - -Q_SIGNALS: - /** - * @brief 将要登录的用户名改变 - * - * @param strUserName 新用户名(需对空串异常处理) - * @param isOneKeyLogin 是否需要一键登录 - */ - void userChanged(WillLoginUserInfo willLoginUser); - -private: - static GreeterService *m_instance; /** 登录服务单实例指针 */ - bool m_isActivatable = false; /** 服务是否可启动 */ -}; - -#endif // GREETERSERVICE_H diff --git a/src/hoverwidget.cpp b/src/hoverwidget.cpp deleted file mode 100644 index 3c3b55e..0000000 --- a/src/hoverwidget.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2019 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#include "hoverwidget.h" - -#include -#include - -#include -#define THEME_QT_SCHEMA "org.ukui.style" -#define MODE_QT_KEY "style-name" - -HoverWidget::HoverWidget(QString mname, QWidget *parent) : - QWidget(parent), - _name(mname) -{ - setAttribute(Qt::WA_DeleteOnClose); -} - -HoverWidget::~HoverWidget() -{ -} - -void HoverWidget::enterEvent(QEvent *event){ - emit enterWidget(_name); - - QWidget::enterEvent(event); -} - -void HoverWidget::leaveEvent(QEvent *event){ - emit leaveWidget(_name); - - QWidget::leaveEvent(event); -} - -//子类化一个QWidget,为了能够使用样式表,则需要提供paintEvent事件。 -//这是因为QWidget的paintEvent()是空的,而样式表要通过paint被绘制到窗口中。 -void HoverWidget::paintEvent(QPaintEvent *event){ - Q_UNUSED(event) - QStyleOption opt; - opt.init(this); - QPainter p(this); - style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); -} diff --git a/src/hoverwidget.h b/src/hoverwidget.h deleted file mode 100644 index 1fcf667..0000000 --- a/src/hoverwidget.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2019 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#ifndef HOVERWIDGET_H -#define HOVERWIDGET_H - -#include -#include -#include -#include -#include - -class HoverWidget : public QWidget -{ - Q_OBJECT - -public: - explicit HoverWidget(QString mname, QWidget *parent = 0); - ~HoverWidget(); - -public: - QString _name; - -protected: - virtual void enterEvent(QEvent * event); - virtual void leaveEvent(QEvent * event); - virtual void paintEvent(QPaintEvent * event); -Q_SIGNALS: - void enterWidget(QString name); - void leaveWidget(QString name); -}; - -#endif // HOVERWIDGET_H - diff --git a/src/iconbutton.cpp b/src/iconbutton.cpp deleted file mode 100644 index fd0fba3..0000000 --- a/src/iconbutton.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#include "iconbutton.h" -#include -#include -#include -#include -#include - -static inline qreal mixQreal(qreal a, qreal b, qreal bias) -{ - return a + (b - a) * bias; -} - -IconButton::IconButton(QWidget *parent) - :QPushButton(parent) -{ - -} - -IconButton::~IconButton() -{ - -} - -QColor IconButton::mixColor(const QColor &c1, const QColor &c2, qreal bias) -{ - if (bias <= 0.0) { - return c1; - } - if (bias >= 1.0) { - return c2; - } - if (qIsNaN(bias)) { - return c1; - } - - qreal r = mixQreal(c1.redF(), c2.redF(), bias); - qreal g = mixQreal(c1.greenF(), c2.greenF(), bias); - qreal b = mixQreal(c1.blueF(), c2.blueF(), bias); - qreal a = mixQreal(c1.alphaF(), c2.alphaF(), bias); - - return QColor::fromRgbF(r, g, b, a); -} - -void IconButton::paintEvent(QPaintEvent *event){ - Q_UNUSED(event) - QStyleOptionButton option; - initStyleOption(&option); - - QPainter p(this); - - p.setRenderHint(QPainter::HighQualityAntialiasing); - p.setRenderHint(QPainter::Antialiasing); - p.setRenderHint(QPainter::TextAntialiasing); - p.setRenderHint(QPainter::SmoothPixmapTransform); - - QColor backgroundColor; - QColor mix = option.palette.brightText().color(); - QColor highlight = option.palette.highlight().color(); - - - if(option.state.testFlag(QStyle::State_MouseOver)) /*鼠标在按钮上(hover状态)*/ - { - if(option.state.testFlag(QStyle::State_Sunken)) { /*按钮被选中(clicked)*/ - backgroundColor = mixColor(highlight,mix,0.2); - } else { - backgroundColor = mixColor(highlight,mix,0.1); - } - } else { - backgroundColor = mixColor(highlight,mix,0.05); - } - - /*绘制背景色和rect*/ - p.save(); - p.setPen(Qt::NoPen); - QPoint point; - QRect ir = option.rect; - if(option.state.testFlag(QStyle::State_HasFocus)) { - p.setBrush(QColor("#3D6BE5")); - p.drawRoundedRect(option.rect, 12, 12); - p.setBrush(backgroundColor); - p.drawRoundedRect(option.rect.adjusted(2, 2, -2, -2), 12, 12); - } else { - p.setBrush(backgroundColor); - p.drawRoundedRect(option.rect, 12, 12); - } - - QPixmap pixmap = option.icon.pixmap(option.iconSize, QIcon::Active, QIcon::On); - - point = QPoint(ir.x() + ir.width() / 2 - (pixmap.width() + 1) / 2, - ir.y() + ir.height() / 2 - (pixmap.height() + 2)/ 2); - - // qDebug() << "point = " << point; - p.drawPixmap(this->style()->visualPos(option.direction, option.rect, point), pixmap); - p.restore(); -} diff --git a/src/iconbutton.h b/src/iconbutton.h deleted file mode 100644 index fc14c51..0000000 --- a/src/iconbutton.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#ifndef ICONBUTTON_H -#define ICONBUTTON_H - -#include -#include -#include - -class IconButton:public QPushButton -{ - Q_OBJECT -public: - IconButton(QWidget* parent = nullptr); - - ~IconButton(); -protected: - void paintEvent(QPaintEvent * event); - -private: - static QColor mixColor(const QColor &c1, const QColor &c2, qreal bias = 0.5); - -private: -}; - -#endif // ICONBUTTON_H diff --git a/src/iconedit.cpp b/src/iconedit.cpp deleted file mode 100644 index 85cff2e..0000000 --- a/src/iconedit.cpp +++ /dev/null @@ -1,401 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#include "iconedit.h" -#include "imageutil.h" -#include "configuration.h" -#include "commonfunc.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define DRM_DIR "/sys/class/leds/" - -#define GSETTINGS_SCHEMA_PERIPHERALS_KEYBOARD "org.ukui.peripherals-keyboard" -#define CAPSLOCK_STATUS "capslock_state" -/** - * @brief 判断大写键状态 - * @return true: 大写锁定 - */ -//bool checkCapsLockState() -//{ -// QDir ledDir(DRM_DIR); -// QStringList leds = ledDir.entryList(QDir::Dirs); -// QString capsFile; - -// for(int i = 0;igetFontSize(); - m_ptToPx = configuration->getPtToPx(); - m_edit = new QLineEdit(this); - m_edit->setObjectName(QStringLiteral("passwdEdit")); - m_edit->setAttribute(Qt::WA_InputMethodEnabled, false); //禁用输入法 - m_edit->setContextMenuPolicy(Qt::NoContextMenu); //禁用右键菜单 - m_edit->installEventFilter(this); - QFont sysFont; - sysFont.setPointSize((16 + curFontSize) *m_ptToPx); - m_edit->setFont(sysFont); - - m_capsIcon = new QSvgWidget(this); - m_capsIcon->setObjectName(QStringLiteral("capsIconLabel")); - - if (QString(qgetenv("XDG_SESSION_TYPE")) == "wayland"){ - capsState = checkCapsLockState(); - }else{ - settings = new QGSettings(GSETTINGS_SCHEMA_PERIPHERALS_KEYBOARD, "", this); - connect(settings, &QGSettings::changed, - this, &IconEdit::onCapsChanged); - capsState = settings->get("capslock-state").toBool(); - } - - m_capsIcon->setVisible(capsState); - m_capsIcon->load(QString(":/image/assets/capslock.svg")); - - m_iconButton = new IconButton(this); - m_iconButton->setFixedSize(24, 24); - m_iconButton->setIconSize(QSize(24, 24)); - m_iconButton->setObjectName(QStringLiteral("loginButton")); - //m_iconButton->setCursor(QCursor(Qt::PointingHandCursor)); - m_iconButton->installEventFilter(this); - m_iconButton->setFocusPolicy(Qt::FocusPolicy::NoFocus); - m_iconButton->setToolTip(tr("OK")); - - m_modeButton = new ModeButton(this); - m_modeButton->setObjectName(QStringLiteral("echoModeButton")); - m_modeButton->setIcon(QIcon::fromTheme("ukui-eye-display-symbolic")); - m_modeButton->setFocusPolicy(Qt::FocusPolicy::NoFocus); - //m_modeButton->setCursor(Qt::PointingHandCursor); - m_modeButton->installEventFilter(this); - m_modeButton->setFixedSize(24, 14); - m_modeButton->setIconSize(QSize(16, 16)); - m_modeButton->setFlat(true); - connect(m_modeButton, &QPushButton::clicked, this, [=](){ - if (m_edit->echoMode() == QLineEdit::Password) { - setType(QLineEdit::Normal); - } else { - setType(QLineEdit::Password); - } - }); - - QHBoxLayout *layout = new QHBoxLayout(this); - layout->setContentsMargins(1, 1, 8, 1); - layout->setSpacing(2); - layout->addStretch(); - layout->addWidget(m_capsIcon); - layout->addWidget(m_modeButton); - layout->addWidget(m_iconButton); - - connect(m_edit, &QLineEdit::returnPressed, this, &IconEdit::clicked_cb); - connect(m_iconButton, &QPushButton::clicked, this, &IconEdit::clicked_cb); - - setFocusProxy(m_edit); - //setCapsState(checkCapsState()); -} - -bool IconEdit::eventFilter(QObject *obj, QEvent *event) -{ - if(obj == m_edit){ - if(event->type() == 6){ //禁止复制粘贴功能。 - QKeyEvent *keyEvent = static_cast(event); - if(keyEvent->matches(QKeySequence::Copy) || keyEvent->matches(QKeySequence::Cut) || keyEvent->matches(QKeySequence::Paste)){ - event->ignore(); - return true; - }else if((keyEvent->modifiers() & Qt::MetaModifier) || (keyEvent->modifiers() & Qt::AltModifier)){//当meta或者alt键被按下时,忽略按键事件 - event->ignore(); - return true; - } - } - if(event->type() == 2) - { - setFocusin(0); - Q_EMIT clickedPassword(true); - } - if(event->type() == 23) - { - if(QX11Info::isPlatformX11()){ - //XSetInputFocus(QX11Info::display(),this->winId(),RevertToParent,CurrentTime); - } - update(); - }else if(event->type() == QEvent::MouseButtonPress){ - if(QX11Info::isPlatformX11()){ - //XSetInputFocus(QX11Info::display(),this->winId(),RevertToParent,CurrentTime); - } - update(); - } else if(event->type() == QEvent::MouseButtonRelease) { //禁用鼠标中键 - QMouseEvent *mouseevent = static_cast(event); - if(mouseevent->button() == Qt::MidButton){ - event->ignore(); - return true; - } - } - } - if(obj == m_iconButton){ - if(m_timer && m_timer->isActive()) - { - return false; - } - if(event->type() == 2) - { - setFocusin(0); - Q_EMIT clickedPassword(true); - } - } - if(obj == m_modeButton){ - if(event->type() == 2) - { - setFocusin(0); - Q_EMIT clickedPassword(true); - } - } - return false; -} - -void IconEdit::setType(QLineEdit::EchoMode type) -{ - m_edit->setEchoMode(type); - if (type == 0) { - m_modeButton->setIcon(QIcon::fromTheme("ukui-eye-display-symbolic")); - } else { - m_modeButton->setIcon(QIcon::fromTheme("ukui-eye-hidden-symbolic")); - } -} - -void IconEdit::setModeBtnVisible(bool visible) -{ - m_modeButton->setVisible(visible); -} - -void IconEdit::resizeEvent(QResizeEvent *) -{ - // 设置输入框中文件输入区,不让输入的文字在被隐藏在按钮下 - int w = m_iconButton->width() + m_modeButton->width(); - m_edit->setTextMargins(1, 1, capsState ? w + m_capsIcon->width() + 10 : w + 6, 1); - m_edit->setFixedSize(size()); -} - - -void IconEdit::setX11Focus() -{ - if(QX11Info::isPlatformX11()){ - //XSetInputFocus(QX11Info::display(),this->winId(),RevertToParent,CurrentTime); - } - update(); -} - -void IconEdit::setFocusin(int target) -{ - switch (target) { - case 0: - m_edit->setFocus(); - m_iconButton->setStyleSheet("border-radius:12px; border:2px solid #3D6BE5;"); - break; - case 1: - m_edit->clearFocus(); - m_iconButton->setFocus(); - m_iconButton->setStyleSheet("border-radius:12px; border:2px solid #000000;"); - break; - default: - m_iconButton->setStyleSheet("border-radius:12px; border:2px solid #3D6BE5;"); - m_edit->clearFocus(); - break; - } -} - -void IconEdit::clicked_cb() -{ - startWaiting(); - emit clicked(m_edit->text()); -} - -void IconEdit::onCapsChanged() -{ - if(settings){ - capsState = settings->get("capslock-state").toBool(); - }else{ - capsState = checkCapsLockState(); - } - m_capsIcon->setVisible(capsState); - int w = m_iconButton->width() + m_modeButton->width(); - m_edit->setTextMargins(1, 1, capsState ? w + m_capsIcon->width() + 10 : w + 6, 1); -} - -void IconEdit::onCapsStateChanged() -{ - capsState = checkCapsLockState(); - m_capsIcon->setVisible(capsState); - int w = m_iconButton->width() + m_modeButton->width(); - m_edit->setTextMargins(1, 1, capsState ? w + m_capsIcon->width() + 10 : w + 6, 1); -} - -void IconEdit::setIcon(const QString &text) -{ - m_iconButton->setIcon(QIcon()); - m_iconButton->setText(text); - m_iconText = text; - m_icon = QIcon(); -} - -void IconEdit::setIcon(const QIcon &icon) -{ - //这里将QIcon转QPixmap传入(24,24)时,实际得到的pixmap大小为(24,24)乘上缩放比例,导致计算pixmap位置错误,因此需要重新设置一次大小 - //更好的解决方案应该是重写IconButton的setIcon函数?直接处理图片大小与icon大小一致? - QPixmap pixmap = icon.pixmap(24, 24).scaled(24,24, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); - m_icon = ImageUtil::drawSymbolicColoredPixmap(pixmap, "white"); - m_iconButton->setIcon(m_icon); - m_iconButton->setIconSize(QSize(12,12)); - m_iconButton->setText(""); - m_iconText = ""; -} - -void IconEdit::clear() -{ - m_edit->setText(""); - setPrompt(""); -} - -void IconEdit::clearText() -{ - m_edit->setText(""); -} - -void IconEdit::setPrompt(const QString &prompt) -{ - m_edit->setPlaceholderText(prompt); - QPalette palette = m_edit->palette(); - palette.setColor(QPalette::Normal, QPalette::PlaceholderText, Qt::gray); - m_edit->setPalette(palette); -} - -const QString IconEdit::text() -{ - return m_edit->text(); -} - -void IconEdit::readOnly(bool enabled) -{ - m_edit->setEnabled(!enabled); - m_edit->setReadOnly(enabled); -} - -void IconEdit::setLocked(bool lock) -{ - m_iconButton->blockSignals(lock); -} - -void IconEdit::startWaiting() -{ - m_edit->setReadOnly(true); - //m_iconButton->setEnabled(false); - - if(!m_timer) - { - m_timer = new QTimer(this); - m_timer->setInterval(150); - connect(m_timer, &QTimer::timeout, this, &IconEdit::updatePixmap); - } - - //m_waitingPixmap.load(":/image/assets/ukui-loginopt-face.svg"); - -// m_iconButton->setProperty("useIconHighlightEffect", true); -// m_iconButton->setProperty("iconHighlightEffectMode", 1); -// m_waitingPixmap = ImageUtil::loadSvg(":/image/assets/ukui-loginopt-face.svg", "white", 24); -// m_iconButton->setIcon(QIcon(m_waitingPixmap)); - - //这里将QIcon转QPixmap传入(24,24)时,实际得到的pixmap大小为(24,24)乘上缩放比例,导致计算pixmap位置错误,因此需要重新设置一次大小 - //更好的解决方案应该是重写IconButton的setIcon函数?直接处理图片大小与icon大小一致? - QPixmap icon = QIcon::fromTheme("ukui-loading-0-symbolic").pixmap(16,16).scaled(16,16, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); - m_waitingPixmap = ImageUtil::drawSymbolicColoredPixmap(icon, "white"); - m_iconButton->setIcon(m_waitingPixmap); - m_iconButton->setIconSize(QSize(16, 16)); - m_timer->start(); -} - - -void IconEdit::stopWaiting() -{ - if(m_timer && m_timer->isActive()) - { - m_timer->stop(); - } - m_iconButton->setAttribute(Qt::WA_TransparentForMouseEvents, false); - m_edit->setReadOnly(false); - //m_iconButton->setEnabled(true); - if(!m_icon.isNull()) { - m_iconButton->setIcon(m_icon); - m_iconButton->setIconSize(QSize(12,12)); - } - else - m_iconButton->setText(m_iconText); -} - -void IconEdit::updatePixmap() -{ - m_iconButton->setEnabled(true); - m_iconButton->setAttribute(Qt::WA_TransparentForMouseEvents, true); - QMatrix matrix; - matrix.rotate(90.0); - m_waitingPixmap = m_waitingPixmap.transformed(matrix, Qt::FastTransformation); - m_iconButton->setIcon(QIcon(m_waitingPixmap)); - m_iconButton->setIconSize(QSize(16, 16)); -} -/* -void IconEdit::setCapsState(bool capsState) -{ - m_capsIcon->setVisible(capsState); - int w = m_iconButton->width() + m_modeButton->width(); - m_edit->setTextMargins(1, 1, capsState ? w + m_capsIcon->width() : w, 1); -} -*/ diff --git a/src/image.qrc b/src/image.qrc deleted file mode 100644 index ca67c5d..0000000 --- a/src/image.qrc +++ /dev/null @@ -1,7 +0,0 @@ - - - image/hide-password.png - image/show-password.png - image/warn.png - - diff --git a/src/imageutil.cpp b/src/imageutil.cpp deleted file mode 100644 index 11fe92f..0000000 --- a/src/imageutil.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2019 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ - -#include "imageutil.h" - -#include -#include -const QPixmap ImageUtil::loadSvg(const QString &path, const QString color, int size) -{ - int origSize = size; - const auto ratio = qApp->devicePixelRatio(); - if ( 2 == ratio) { - size += origSize; - } else if (3 == ratio) { - size += origSize; - } - QPixmap pixmap(size, size); - QSvgRenderer renderer(path); - pixmap.fill(Qt::transparent); - - QPainter painter; - painter.begin(&pixmap); - renderer.render(&painter); - painter.end(); - - pixmap.setDevicePixelRatio(ratio); - return drawSymbolicColoredPixmap(pixmap, color); -} - -QPixmap ImageUtil::drawSymbolicColoredPixmap(const QPixmap &source, QString cgColor) -{ - QImage img = source.toImage(); - for (int x = 0; x < img.width(); x++) { - for (int y = 0; y < img.height(); y++) { - auto color = img.pixelColor(x, y); - if (color.alpha() > 0) { - if ( "white" == cgColor) { - color.setRed(255); - color.setGreen(255); - color.setBlue(255); - img.setPixelColor(x, y, color); - } else if( "black" == cgColor) { - color.setRed(0); - color.setGreen(0); - color.setBlue(0); - img.setPixelColor(x, y, color); - } else if ("gray"== cgColor) { - color.setRed(152); - color.setGreen(163); - color.setBlue(164); - img.setPixelColor(x, y, color); - } else if ("blue" == cgColor){ - color.setRed(61); - color.setGreen(107); - color.setBlue(229); - img.setPixelColor(x, y, color); - } else { - return source; - } - } - } - } - return QPixmap::fromImage(img); -} diff --git a/src/imageutil.h b/src/imageutil.h deleted file mode 100644 index ae40c46..0000000 --- a/src/imageutil.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2019 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ - -#ifndef IMAGEUTIL_H -#define IMAGEUTIL_H - -#include -#include -#include - -class ImageUtil -{ -public: - static const QPixmap loadSvg(const QString &path, const QString color, int size = 16); - static QPixmap drawSymbolicColoredPixmap(const QPixmap &source, QString cgColor); -}; - -#endif // IMAGEUTIL_H diff --git a/src/interface.cpp b/src/interface.cpp deleted file mode 100644 index c99c5e0..0000000 --- a/src/interface.cpp +++ /dev/null @@ -1,574 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#include "interface.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "types.h" - -Interface::Interface(QObject *parent) - : QObject(parent), - m_timerCount(0), - m_timer(nullptr) -{ - lockState = false; - slpState = false; - m_logind = new LogindIntegration(this); - connect(m_logind, &LogindIntegration::requestLock, this, - [this]() { - this->onShowScreensaver(); - } - ); - - connect(m_logind, &LogindIntegration::requestUnlock, this, - [this]() { -// process.terminate(); -// 因为fullbackgroundwidget.cpp会监听这个信号,因此这个信号没必要监听了 -// process.kill(); - } - ); - - connect(&process, static_cast(&QProcess::finished), - [=](int exitCode, QProcess::ExitStatus exitStatus){ - qInfo()<<"ukui-screensaver-dialog is exited,exitCode is "< stateReply = iface.call("NameHasOwner",SSWND_DBUS_SERVICE); - if(!stateReply.isValid()){ - return false; - } - qDebug()<<"stateReply = "< 0 ? "exist dialog running" : ""); - - return num > 0; -} - -void Interface::onNameLost(const QString &serviceName) -{ - if(serviceName == "cn.kylinos.ScreenSaver") - exit(0); -} - -bool Interface::checkScreenDialogRunning() -{ - int fd = -1; - struct flock lock; - - const QString PID_DIR = QString("/var/run/user/%1").arg(QString::number(getuid())); - QString env = qgetenv("DISPLAY"); - const QString PID_FILE = PID_DIR + QString("/ukui-screensaver%1.pid").arg(env); - - QFileInfo fileInfo(PID_FILE); - if(!fileInfo.exists()) { - return false; - } - if((fd = open(PID_FILE.toLocal8Bit().data(), - O_RDWR, 0666)) == -1){ - return false; - } - - memset(&lock, 0, sizeof(struct flock)); - lock.l_type = F_WRLCK; - lock.l_whence = SEEK_SET; - - if(fcntl(fd, F_GETLK, &lock) < 0) { - close(fd); - return false; - } else { - if (lock.l_type == F_UNLCK) { - close(fd); - return false; - } else { - close(fd); - return true; - } - } -} - -void Interface::onPrepareForSleep(bool sleep) -{ - qDebug()<<"onPrepareForSleep:"<onShowBlankScreensaver(); - - if(!m_timer){ - m_timer = new QTimer(this); - connect(m_timer, &QTimer::timeout, this, [&]{ - m_timerCount+=1; - - if(GetLockState() || m_timerCount>20){ - m_timer->stop(); - m_timerCount = 0; - uninhibit(); - } - }); - } - m_timer->start(200); - } - else - { - m_nStatus &= ~SESSION_STATUS_SLEEPED; - blankState = false; - inhibit(); - } -} - -void Interface::onSessionIdleExit() -{ - qDebug()<<"onSessionIdleExit--------"; - m_nStatus &= ~SESSION_STATUS_SCREENSAVER; - m_nStatus &= ~SESSION_STATUS_SCREENCLOSE; - stopDelayLockScreen(); -} - -void Interface::onScreenClosed(bool state) -{ - qDebug()<<"onScreenClosed:"<isLidCloseWithBlank()) { - m_nStatus &= ~SESSION_STATUS_SCREENCLOSE; - } - stopDelayLockScreen(); - } -} - -void Interface::ShowScreensaver() -{ - if(process.state() != QProcess::NotRunning) - return ; - - qDebug() << "lock and show screensaver"; - lockState = false; - QString cmd = QString("/usr/bin/ukui-screensaver-dialog --screensaver"); - qDebug() << cmd; - - process.start(cmd); - emitLockState(true); -} - -void Interface::inhibit() -{ - if (m_inhibitFileDescriptor.isValid()) { - return; - } - - QDBusMessage message = QDBusMessage::createMethodCall("org.freedesktop.login1", - "/org/freedesktop/login1", - "org.freedesktop.login1.Manager", - QStringLiteral("Inhibit")); - message.setArguments(QVariantList({QStringLiteral("sleep"), - "Screen Locker Backend", - "Ensuring that the screen gets locked before going to sleep", - QStringLiteral("delay")})); - QDBusPendingReply reply = QDBusConnection::systemBus().call(message); - if (!reply.isValid()) { - return; - } - reply.value().swap(m_inhibitFileDescriptor); -} - -void Interface::uninhibit() -{ - if (!m_inhibitFileDescriptor.isValid()) { - return; - } - - m_inhibitFileDescriptor = QDBusUnixFileDescriptor(); -} - -bool Interface::checkStatus(int nStatus) -{ - if (!m_sessionWatcher) { - return false; - } - switch (nStatus) { - case SESSION_STATUS_SLEEPED: - { - m_nStatus |= nStatus; - if (!m_sessionWatcher->isSleepActivationEnable()) { - return false; - } - } - break; - case SESSION_STATUS_SCREENCLOSE: - { - m_nStatus |= nStatus; - if ((m_nStatus&SESSION_STATUS_SLEEPED) || !m_sessionWatcher->isCloseActivationEnable()) { - return false; - } - if (((m_sessionWatcher->closeActivationDelay() == m_sessionWatcher->sleepActivationDelay()) - && m_sessionWatcher->sleepActivationDelay() != -1) && !m_sessionWatcher->isSleepActivationEnable()) { - qDebug()<<"Sleep same with Close and Sleep disable!"; - return false; - } - } - break; - case SESSION_STATUS_SCREENSAVER: - { - m_nStatus |= nStatus; - if ((m_nStatus&SESSION_STATUS_SLEEPED) || (m_nStatus&SESSION_STATUS_SCREENCLOSE)) { - return false; - } - if (((m_sessionWatcher->idledelay()*60 == m_sessionWatcher->sleepActivationDelay()) - && m_sessionWatcher->sleepActivationDelay() != -1) && !m_sessionWatcher->isSleepActivationEnable()) { - qDebug()<<"Sleep same with idle and Sleep disable!"; - return false; - } - if (((m_sessionWatcher->idledelay()*60 == m_sessionWatcher->closeActivationDelay()) - && m_sessionWatcher->closeActivationDelay() != -1)/* && !m_sessionWatcher->isCloseActivationEnable()*/) { - qDebug()<<"Close same with idle do nothing!"; - return false; - } - } - break; - default: - return false; - } - return true; -} - -bool Interface::LockByBlank(int nType) // 0:idle delay close;1:lid close;2:lowpower close -{ - qDebug()<<"LockByBlank:"<closeActivationDelay(); - int nIdleDelay = m_sessionWatcher->idledelay(); - bool isCloseActive = m_sessionWatcher->isCloseActivationEnable(); - qDebug()<<"DelayState:"<isLockEnable()) { // 仅启动屏保 - isNeedLock = false; - } - } else { - return false; - } - } else { - qDebug()<<"Don't need blank lock:"<locktimeout() != -1 && isNeedLock) { - delayLockScreen(); - return false; - } else { - QString cmd = QString("/usr/bin/ukui-screensaver-dialog --blank --delay %1 --has-lock %2").arg(2000).arg(isNeedLock?1:0); - qDebug() << cmd; - process.start(cmd); - emitLockState(true); - } - return true; - } -} - -void Interface::delayLockScreen() -{ - if (!m_timerLock) { - m_timerLock = new QTimer(this); - connect(m_timerLock, &QTimer::timeout, this, &Interface::onLockScreenTimeout); - } - qDebug()<<"LockTimeout:"<locktimeout(); - if (m_sessionWatcher->locktimeout() != -1) { - stopDelayLockScreen(); - m_timerLock->start(m_sessionWatcher->locktimeout()*1000); - } -} - -void Interface::stopDelayLockScreen() -{ - if (m_timerLock && m_timerLock->isActive()) { - m_timerLock->stop(); - } -} - -void Interface::onLockScreenTimeout() -{ - Lock(); - m_timerLock->stop(); -} diff --git a/src/interface.h b/src/interface.h deleted file mode 100644 index 8b228ae..0000000 --- a/src/interface.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#ifndef INTERFACE_H -#define INTERFACE_H - -#include -#include -#include -#include -#include -#include "types.h" -#include "logind.h" -#include "sessionwatcher.h" - -class QGSettings; -class Interface : public QObject, protected QDBusContext -{ - Q_OBJECT - - Q_CLASSINFO("D-Bus Interface", SS_DBUS_SERVICE) - -public: - enum { - SESSION_STATUS_SCREENSAVER = 1, // 屏保 - SESSION_STATUS_SCREENCLOSE = 2, // 关屏 - SESSION_STATUS_SLEEPED = 4, // 休眠/睡眠 - }; - explicit Interface(QObject *parent = nullptr); - LogindIntegration *m_logind; - -public Q_SLOTS: - /** - * Lock the screen - */ - void Lock(); - void UnLock(); - void ShowScreensaver(); - bool GetLockState(); - bool GetSlpState(); - void SetLockState(); - void onSessionIdleReceived(); - void onShowScreensaver(); - void onShowBlankScreensaver(); - void onNameLost(const QString&); - void onPrepareForSleep(bool sleep); - bool checkScreenDialogRunning(); - void onSessionIdleExit(); - void onScreenClosed(bool state); - void onLidStateChaned(bool isClosed); - bool GetBlankState(); - bool LockByBlank(int nType); - -private: - bool checkExistChild(); - void inhibit(); - void uninhibit(); - void emitLockState(bool); - bool checkStatus(int nStatus); - /** - * @brief delayLockScreen 延迟锁屏 - */ - void delayLockScreen(); - /** - * @brief stopDelayLockScreen 停止延迟锁屏 - */ - void stopDelayLockScreen(); - /** - * @brief onLockScreenTimeout 延迟锁屏处理过程 - */ - void onLockScreenTimeout(); - -private: - bool lockState; - bool slpState; - int m_timerCount; - SessionWatcher *m_sessionWatcher = nullptr; - QTimer *m_timer; - QDBusUnixFileDescriptor m_inhibitFileDescriptor; - int m_nStatus = 0; // 当前状态 - bool blankState = false; - bool m_isNewBlankInterface = false; - QTimer *m_timerLock = nullptr; -private: - QProcess process; -}; - -#endif // INTERFACE_H diff --git a/src/klabel.cpp b/src/klabel.cpp deleted file mode 100644 index ad19dd3..0000000 --- a/src/klabel.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#include "klabel.h" -#include "configuration.h" -#include "commonfunc.h" -#include -#include -#include - -KLabel::KLabel(QWidget *parent) - : QLabel(parent), - configuration(Configuration::instance()) -{ - curFontSize = configuration->getFontSize(); - m_ptToPx = configuration->getPtToPx(); - this->setStyleSheet("QLabel{color: white;}" - "QToolTip{border-radius:4px; background-color:#FFFFFF; color:black;}"); -} - -void KLabel::setFontSize(int fontSize) -{ - sysFont.setPointSize((fontSize +curFontSize) *m_ptToPx); - this->setFont(sysFont); - QToolTip::setFont(sysFont); -} - -void KLabel::setElideText(const QString text, int width, int size) -{ - sysFont.setPointSize((size + curFontSize) *m_ptToPx); - QString str = ElideText(sysFont,width,text); - if(text != str) - this->setToolTip(text); - if(text == str) - this->setToolTip(""); - this->setText(str); -} diff --git a/src/libinputswitchevent.cpp b/src/libinputswitchevent.cpp deleted file mode 100644 index de3886f..0000000 --- a/src/libinputswitchevent.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2022 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ - -#include "libinputswitchevent.h" - -typedef std::function sendEvent; -LibinputSwitchEvent::LibinputSwitchEvent(QObject *parent) - : QObject(parent) - , m_machineModel(MachineModel::getMachineModelInstance()) -{ - m_machineType = m_machineModel->getTheMachineType(); - sendEvent se = std::bind(&LibinputSwitchEvent::dealEvent, this, std::placeholders::_1); - m_inputGatherClient = new UKUIInputGatherClient; - m_inputGatherClient->setEventCallBack(se); - m_inputGatherClient->startToReceiveEvent(); -} - -LibinputSwitchEvent::~LibinputSwitchEvent() -{ - delete m_inputGatherClient; -} - -bool LibinputSwitchEvent::geInitDevicesStatus() -{ - //其他处理 - if (m_machineType == QStringLiteral("SLATE")) { - return true; - }else if (m_machineType == "LAPTOP" ) {//永久附加键盘笔记本 - //return true; - }else if (m_machineType == "ALLINONE") {//台式 - return false; - }else { - //0 非平板 - //1 平板 - //-1 不支持 - int status = m_inputGatherClient->libinputTabletSwitchState(); - qInfo() << __FILE__ << __LINE__<< "当前设备的状态:" << status; - if(status == 1) - return true; - else - return false; - } -} - -void LibinputSwitchEvent::dealEvent(Event* e) -{ - switch (e->type) { - case LIBINPUT_EVENT_SWITCH_TOGGLE: - qInfo() << __FILE__ << __LINE__ << "=LIBINPUT_EVENT_SWITCH_TOGGLE="; - if(e->event.switchEventDate.switchType == LIBINPUT_SWITCH_TABLET_MODE) { - qInfo() << __FILE__ << __LINE__ << "switch type" << e->event.switchEventDate.switchType; - qInfo() << __FILE__ << __LINE__ << "switch status" << e->event.switchEventDate.switchState; - if(e->event.switchEventDate.switchState == 1) { - Q_EMIT tabletModeStatusChanged(1); - }else { - Q_EMIT tabletModeStatusChanged(0); - } - } - break; - default: - break; - } -} diff --git a/src/libinputswitchevent.h b/src/libinputswitchevent.h deleted file mode 100644 index 95ecbe3..0000000 --- a/src/libinputswitchevent.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2022 KylinSoft Co., Ltd. - * - * This program is free software: you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation, either version 3 of the License, or (at your option) any later - * version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see . - */ - -#ifndef LIBINPUTSWITCHEVENT_H -#define LIBINPUTSWITCHEVENT_H - -#include -#include -#include -#include -#include "machinemodel.h" -//头文件以及顺序不可改,不可删 -class LibinputSwitchEvent : public QObject -{ - Q_OBJECT -public: - explicit LibinputSwitchEvent(QObject *parent = nullptr); - - ~LibinputSwitchEvent(); - UKUIInputGatherClient * m_inputGatherClient = nullptr; - bool geInitDevicesStatus(); -signals: - void tabletModeStatusChanged(int tabletmode); -private: - void dealEvent(Event* e); - -private: - QString m_machineType; - std::shared_ptr m_machineModel = nullptr; -}; - -#endif // LIBINPUTSWITCHEVENT_H diff --git a/src/lock-backend/CSingleton.h b/src/lock-backend/CSingleton.h new file mode 100644 index 0000000..99c42d8 --- /dev/null +++ b/src/lock-backend/CSingleton.h @@ -0,0 +1,46 @@ +#ifndef CSINGLETON_H +#define CSINGLETON_H + + +template +class SingleTon +{ +public: + // 创建单例实例 + template + static T* instance(Args&&... args) + { + if (m_pInstance == nullptr) + { + m_pInstance = new T(std::forward(args)...); + } + + return m_pInstance; + } + + // 获取单例 + static T* getInstance() + { + return m_pInstance; + } + + // 删除单例 + static void destroyInstance() + { + delete m_pInstance; + m_pInstance = nullptr; + } + +private: + SingleTon(); + virtual ~SingleTon(); + +private: + static T* m_pInstance; +}; + +template +T* SingleTon::m_pInstance = nullptr; + + +#endif diff --git a/src/lock-backend/authpamthread.cpp b/src/lock-backend/authpamthread.cpp new file mode 100644 index 0000000..5d4a3ce --- /dev/null +++ b/src/lock-backend/authpamthread.cpp @@ -0,0 +1,223 @@ +/* + * Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * +**/ +#include "authpamthread.h" + +#include +#include +#include +#include +#include +#include +#include + +#define PAM_SERVICE_NAME "ukui-screensaver-qt" + +static void writeData(int fd, const void *buf, ssize_t count); +static void writeString(int fd, const char *data); +static int readData(int fd, void *buf, size_t count); +static char * readString(int fd); +static int pam_conversation(int msgLength, const struct pam_message **msg, + struct pam_response **resp, void *appData); + +AuthPamThread::AuthPamThread(QObject* parent) + : QThread(parent) +{ +} + +AuthPamThread::~AuthPamThread() +{ + +} + +void AuthPamThread::writeData(int fd, const void *buf, ssize_t count) +{ + if (!m_isAuthenticating) { + return; + } + if(write(fd, buf, count) != count) + qDebug() << "write to parent failed: " << strerror(errno); +} + +void AuthPamThread::writeString(int fd, const char *data) +{ + int length = data ? strlen(data) : -1; + writeData(fd, &length, sizeof(length)); + if(data) + writeData(fd, data, sizeof(char) * length); +} + +int AuthPamThread::readData(int fd, void *buf, size_t count) +{ + ssize_t nRead = 0; + while(true) { + nRead = read(fd, buf, count); + if (!m_isAuthenticating) { + break; + } + if (nRead < 0) { + if (errno == EAGAIN) { + usleep(100*1000); + continue; + } else { + qDebug() << "read data failed: " << strerror(errno) << errno; + } + } + break; + } + return nRead; +} + +char* AuthPamThread::readString(int fd) +{ + int length; + + if(readData(fd, &length, sizeof(length)) <= 0) + return NULL; + if(length <= 0) + length = 0; + + char *value = (char *)malloc(sizeof(char) * (length + 1)); + readData(fd, value, length); + + value[length] = '\0'; + + return value; +} + +static int +pam_conversation(int msgLength, const struct pam_message **msg, + struct pam_response **resp, void *appData) +{ + struct pam_response *response = (struct pam_response*)calloc(msgLength,sizeof(struct pam_response)); + AuthPamThread* pData = (AuthPamThread*)appData; + if (!pData || pData->m_fdRead < 0 || pData->m_fdWrite < 0) { + return PAM_CONV_ERR; + } + + int authComplete = 0; + pData->writeData(pData->m_fdWrite, (const void*)&authComplete, sizeof(authComplete)); + pData->writeData(pData->m_fdWrite, (const void*)&msgLength, sizeof(msgLength)); + //发送pam消息 + for(int i = 0; i < msgLength; i++) + { + const struct pam_message *m = msg[i]; + pData->writeData(pData->m_fdWrite, (const void *)&m->msg_style, sizeof(m->msg_style)); + pData->writeString(pData->m_fdWrite, m->msg); + } + //读取响应 + for(int i = 0; i < msgLength; i++) + { + struct pam_response *r = &response[i]; + if (pData->readData(pData->m_fdRead, &r->resp_retcode, sizeof(r->resp_retcode)) < 0) { + break; + } + r->resp = pData->readString(pData->m_fdRead); + } + *resp = response; + return PAM_SUCCESS; +} + +void AuthPamThread::_authenticate(const char *userName) +{ + qDebug() << "authenticate " << userName; + + pam_handle_t *pamh = NULL; + char *newUser = NULL; + int ret; + int authRet; + struct pam_conv conv; + + conv.conv = pam_conversation; + conv.appdata_ptr = this; + + ret = pam_start(PAM_SERVICE_NAME, userName, &conv, &pamh); + if(ret != PAM_SUCCESS) { + qDebug() << "failed to start PAM: " << pam_strerror(NULL, ret); + } + + authRet = pam_authenticate(pamh, 0); + + ret = pam_get_item(pamh, PAM_USER, (const void **)&newUser); + if(ret != PAM_SUCCESS) { + pam_end(pamh, 0); + qDebug() << "failed to get username"; + } + + if(authRet == PAM_SUCCESS) { + /*检测账户有效性,即使密码认证通过,如果账户锁定或无效,也无法解锁*/ + int ret = pam_acct_mgmt(pamh, 0); + + /*如果密码过期,pam_acct_mgmt会返回请求修改口令,由于锁屏不支持修改 + * 密码,会导致无法解锁,因此这里要判断返回值是否为修改口令*/ + if(ret != PAM_NEW_AUTHTOK_REQD) + authRet = ret; + } + + if(authRet != PAM_SUCCESS) { + qDebug() << "failed to acct mgmt " << pam_strerror(NULL, authRet); + } + + if (newUser) { + free(newUser); + newUser = NULL; + } + fprintf(stderr, "authentication result: %d\n", authRet); + + // 发送认证结果 + int authComplete = 1; + writeData(m_fdWrite, (const void*)&authComplete, sizeof(authComplete)); + writeData(m_fdWrite, (const void *)&authRet, sizeof(authRet)); + qDebug() << "--- 认证完成"; +} + +void AuthPamThread::startAuthPam(int fdRead, int fdWrite, QString strUserName) +{ + if (!isRunning()) { + qDebug()<<"startAuthPam ----"; + m_isAuthenticating = true; + int nFlags = fcntl(fdRead, F_GETFL); + nFlags = nFlags | O_NONBLOCK; + fcntl(fdRead, F_SETFL, nFlags); + m_fdRead = fdRead; + m_fdWrite = fdWrite; + m_strUserName = strUserName; + start(); + } else { + qDebug()<<"AuthPamThread is running!!"; + } +} + +void AuthPamThread::run() +{ + if (m_fdRead >=0 && m_fdWrite >= 0 && !m_strUserName.isEmpty()) { + _authenticate(m_strUserName.toLocal8Bit().data()); + } else { + qDebug()<<"AuthPamThread param error:"<. * **/ -#ifndef MACHINEMODEL_H -#define MACHINNEMODEL_H +#ifndef AUTHPAMTHREAD_H +#define AUTHPAMTHREAD_H -#include -#include -#include +#include -class MachineModel : public QObject +class AuthPamThread : public QThread { Q_OBJECT public: - QString getTheMachineType(); - static std::shared_ptr getMachineModelInstance(); + AuthPamThread(QObject* parent = nullptr); + virtual ~AuthPamThread(); + void startAuthPam(int fdRead, int fdWrite, QString strUserName); + void stopAuthPam(); + + void writeData(int fd, const void *buf, ssize_t count); + void writeString(int fd, const char *data); + int readData(int fd, void *buf, size_t count); + char *readString(int fd); + +protected: + void run(); private: - MachineModel(QObject *parent = nullptr); - MachineModel(const MachineModel &); - const MachineModel &operator =(const MachineModel &) = delete; + void _authenticate(const char *userName); + +public: + int m_fdRead = -1; + int m_fdWrite = -1; + QString m_strUserName = ""; private: - void initMachineType(); - const QString getSysVendor() const; - const QString getProductName() const; - const QString getProductFamily() const; - QString m_machineType; - static std::shared_ptr m_machineModel; - static std::mutex m_mutex; - -signals: - + bool m_isAuthenticating = false; }; -#endif // MACHINEMODEL_H +#endif // AUTHPAMTHREAD_H diff --git a/src/lock-backend/bioauthenticate.cpp b/src/lock-backend/bioauthenticate.cpp new file mode 100644 index 0000000..4387536 --- /dev/null +++ b/src/lock-backend/bioauthenticate.cpp @@ -0,0 +1,556 @@ +/* + * Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * +**/ +#include "bioauthenticate.h" +#include "freedesktophelper.h" +#include "biometrichelper.h" +#include "uniauthservice.h" +#include +#include +#include "giodbus.h" + +BioAuthenticate::BioAuthenticate(QObject *parent) + : QObject(parent) + , m_systemFdHelper(new FreedesktopHelper(false, this)) + , m_uniauthService(new UniAuthService(this)) + , m_bioTimer(nullptr) +{ + m_bioauthState = BIOAUTH_IDLE; + m_deviceInfo.id = -1; + m_maxFailedTimes = m_uniauthService->getMaxFailedTimes(); + m_listPriority.clear(); + m_listPriority.push_back(BioT_Face); + m_listPriority.push_back(BioT_FingerPrint); + m_listPriority.push_back(BioT_Iris); + m_listPriority.push_back(BioT_VoicePrint); + m_listPriority.push_back(BioT_FingerVein); + m_listPriority.push_back(UniT_Remote); + m_listPriority.push_back(UniT_General_Ukey); + initBioService(); + initConncetions(); +} + +void BioAuthenticate::initConncetions() +{ + connect(m_systemFdHelper, &FreedesktopHelper::serviceStatusChanged, this, &BioAuthenticate::onServiceStatusChanged); +} + +void BioAuthenticate::initBioService() +{ + if (!m_biometricHelper) { + if (m_systemFdHelper->NameHasOwner(BIOMETRIC_DBUS_SERVICE)) { + m_biometricHelper = new BiometricHelper(this); + connect(m_biometricHelper, &BiometricHelper::USBDeviceHotPlug, this, &BioAuthenticate::onBioDeviceChanged); + connect(m_biometricHelper, &BiometricHelper::StatusChanged, this, &BioAuthenticate::onStatusChanged); + connect(m_biometricHelper, &BiometricHelper::FrameWritten, this, &BioAuthenticate::onFrameWritten); + } + } +} + +DeviceMap BioAuthenticate::getAvailableDevices(int nUid) +{ + DeviceMap mapBioInfo; + checkAvailableBioInfo(nUid); + if (m_mapDevices.contains(nUid)) { + mapBioInfo = m_mapDevices[nUid]; + } + return mapBioInfo; +} + +QList BioAuthenticate::getDisabledDevices(int nUid) +{ + QList listDisabled; + if (m_mapDisableDev.contains(nUid)) { + QMap::iterator devDisable = m_mapDisableDev[nUid].begin(); + for (; devDisable != m_mapDisableDev[nUid].end(); devDisable++) { + if (devDisable.value()) { + listDisabled.append(devDisable.key()); + } + } + } + return listDisabled; +} + +DeviceInfoPtr BioAuthenticate::findDeviceById(int nUid, int nDevId) +{ + DeviceInfoPtr devInfo; + if (m_mapDevices.contains(nUid)) { + DeviceMap::iterator itDevInfo = m_mapDevices[nUid].begin(); + for (; itDevInfo != m_mapDevices[nUid].end(); itDevInfo ++) { + if (itDevInfo.value()->id == nDevId) { + devInfo = itDevInfo.value(); + break; + } + } + } + return devInfo; +} + +DeviceInfoPtr BioAuthenticate::findDeviceByName(int nUid, QString strDevName) +{ + DeviceInfoPtr devInfo; + if (m_mapDevices.contains(nUid)) { + DeviceMap::iterator itDevInfo = m_mapDevices[nUid].begin(); + for (; itDevInfo != m_mapDevices[nUid].end(); itDevInfo ++) { + if (itDevInfo.value()->shortName == strDevName) { + devInfo = itDevInfo.value(); + break; + } + } + } + return devInfo; +} + +void BioAuthenticate::onServiceStatusChanged(const QString &strService, bool bActive) +{ + if (strService == BIOMETRIC_DBUS_SERVICE) { + if (bActive) { + initBioService(); + } else { + clearBioData(); + } + Q_EMIT bioServiceStatusChanged(bActive); + } +} + +bool BioAuthenticate::getBioAuthEnable(QString strUserName, int nType) +{ + bool isEnable = false; + isEnable = m_uniauthService->getBioAuthStatus(strUserName, ENABLETYPE_BIO); + if (isEnable) { + isEnable = m_uniauthService->getBioAuthStatus(strUserName, nType); + } + return isEnable; +} + +void BioAuthenticate::clearBioData() +{ + QMap::iterator itDeviceMap = m_mapDevices.begin(); + for (; itDeviceMap != m_mapDevices.end(); itDeviceMap++) { + itDeviceMap.value().clear(); + } + m_mapDevices.clear(); +} + +void BioAuthenticate::checkAvailableBioInfo(int nUid) +{ + if (!m_biometricHelper) + return ; + if (m_mapDevices.contains(nUid)) { + m_mapDevices[nUid].clear(); + } + struct passwd *pwdInfo = getpwuid(nUid); + if (pwdInfo) { + int nAuthType = (pwdInfo->pw_name == getenv("USER")) ? ENABLETYPE_SAVER : ENABLETYPE_GREETER; + bool isAuthEnable = getBioAuthEnable(pwdInfo->pw_name, nAuthType); + bool isQRCodeEnable = m_uniauthService->getQRCodeEnable(); + DeviceList deviceList = m_biometricHelper->GetDevList(); + QStringList listDefDevices = m_uniauthService->getAllDefaultDevice(pwdInfo->pw_name); + qDebug()<<"BeginGetFeature------!"; + FeatureMap mapFeatures = m_biometricHelper->GetUserFeatures(nUid); + qDebug() << nUid <<",count:"<deviceType <= BioT_VoicePrint) + continue; + if (!isQRCodeEnable && pDeviceInfo->deviceType == UniT_Remote) + continue; + int nFeatureCount = 0; + if (mapFeatures.contains(pDeviceInfo->shortName) && listDefDevices.contains(pDeviceInfo->shortName)) { + nFeatureCount = mapFeatures[pDeviceInfo->shortName].size(); + qDebug() << *pDeviceInfo <<",count:"< 0) { + if (m_mapDevices.contains(nUid)) { + if (!m_mapDevices[nUid].contains(pDeviceInfo->deviceType)) + m_mapDevices[nUid][pDeviceInfo->deviceType] = pDeviceInfo; + } else { + DeviceMap mapBioInfo; + mapBioInfo[pDeviceInfo->deviceType] = pDeviceInfo; + m_mapDevices[nUid] = mapBioInfo; + } + } + } + } + FeatureMap::iterator itFeature = mapFeatures.begin(); + for (; itFeature != mapFeatures.end(); itFeature ++) { + for (auto feature : itFeature.value()) { + if (feature->biotype == UniT_General_Ukey) { + DeviceInfoPtr pDeviceInfo = std::make_shared(); + pDeviceInfo->id = -1; + pDeviceInfo->shortName = "GeneralUKey"; + pDeviceInfo->deviceType = feature->biotype; + if (m_mapDevices.contains(nUid)) { + if (!m_mapDevices[nUid].contains(pDeviceInfo->deviceType)) + m_mapDevices[nUid][pDeviceInfo->deviceType] = pDeviceInfo; + } else { + DeviceMap mapBioInfo; + mapBioInfo[pDeviceInfo->deviceType] = pDeviceInfo; + m_mapDevices[nUid] = mapBioInfo; + } + break; + } + } + } + } +} + +void BioAuthenticate::onBioDeviceChanged(int drvid, int action, int devNum) +{ + Q_UNUSED(devNum); + switch(action) + { + case ACTION_ATTACHED: + { + //插入设备后,需要更新设备列表 + clearBioData(); + QMap::iterator itUserDev = m_mapDevices.begin(); + for (; itUserDev != m_mapDevices.end(); itUserDev++) { + if (itUserDev.key() < 0) + continue; + checkAvailableBioInfo(itUserDev.key()); + } + break; + } + case ACTION_DETACHED: + { + if (m_deviceInfo.id != -1 && m_deviceInfo.id == drvid) { + m_bioauthState = BIOAUTH_DEVICEREMOVED; + Q_EMIT bioAuthStateChanged(BIOAUTH_DEVICEREMOVED); + } + clearBioData(); + QMap::iterator itUserDev = m_mapDevices.begin(); + for (; itUserDev != m_mapDevices.end(); itUserDev++) { + if (itUserDev.key() < 0) + continue; + checkAvailableBioInfo(itUserDev.key()); + } + break; + } + } + Q_EMIT bioDeviceChanged(); +} + +void BioAuthenticate::onStatusChanged(int drvid, int status) +{ + if(m_bioauthState != BIOAUTH_START || m_deviceInfo.id == -1) + { + return; + } + + if(drvid != m_deviceInfo.id) { + return; + } + +// // 显示来自服务的提示信息 +// if(status == STATUS_NOTIFY) { +// QString notifyMsg = m_biometricHelper->GetNotifyMesg(drvid); +// Q_EMIT bioAuthShowMessage(notifyMsg); +// } +} + +void BioAuthenticate::onFrameWritten(int drvid) +{ + if (m_deviceInfo.id == -1 || m_deviceInfo.id != drvid || m_bioauthState != BIOAUTH_START) { + return ; + } + if(m_fdFrame == -1){ + m_fdFrame = get_server_gvariant_stdout(drvid); + } + + if(m_fdFrame <= 0) + return ; + + lseek(m_fdFrame, 0, SEEK_SET); + char base64_bufferData[1024*1024] = {0}; + int rc = read(m_fdFrame, base64_bufferData, 1024*1024); + QByteArray byteData(base64_bufferData); + QString strData = byteData.toBase64(); + Q_EMIT bioAuthFrameData(strData); +} + +/** + * @brief 进行生物识别认证 + * @param deviceInfo 使用的设备 + * @param uid 待认证的用户id + */ +void BioAuthenticate::startAuth(int uid, int nDevId) +{ + if(!m_biometricHelper) { + qWarning() << "BiometricProxy doesn't exist."; + return; + } + if (nDevId < 0) { + qWarning() << "Biometric Auth device invalid."; + return ; + } + qDebug()<<"deviceInfo:"<< nDevId; + DeviceInfoPtr ptrDeviceInfo = findDeviceById(uid, nDevId); + if (!ptrDeviceInfo || ptrDeviceInfo->id < -1) { + qDebug() << "Could not find device info!"; + return ; + } + if (m_failedTimes.contains(uid) && m_failedTimes[uid].contains(ptrDeviceInfo->id) + && m_failedTimes[uid][ptrDeviceInfo->id] >= m_maxFailedTimes) { + qDebug() << "Failed MAX:"<id; + Q_EMIT bioAuthCompleted(uid, false, -1, m_maxFailedTimes, m_failedTimes[uid][ptrDeviceInfo->id]); + return ; + } + if(m_bioauthState != BIOAUTH_IDLE) { + qDebug() << "Identification is currently under way, stop it"; + stopAuth(); + } else { + if(m_bioTimer && m_bioTimer->isActive()) + m_bioTimer->stop(); + } + m_deviceInfo = *ptrDeviceInfo; + m_nUid = uid; + m_isStopped = false; + m_fTimeoutTimes = 0; + m_bioauthState = BIOAUTH_START; + _startAuth(); + Q_EMIT bioAuthStateChanged(m_bioauthState); +} + +void BioAuthenticate::_startAuth() +{ + if (m_nUid < 0 || m_deviceInfo.id < 0) { + return ; + } + if(m_deviceInfo.deviceType == UniT_General_Ukey) { + qDebug()<< QString("Identify:[drvid: %1, uid: %2]").arg(m_deviceInfo.id).arg(m_nUid); + m_fdFrame = -1; + m_biometricHelper->StopOps(m_deviceInfo.id); + QDBusPendingCall call = m_biometricHelper->UkeyIdentify(m_deviceInfo.id, 2,m_nUid); + QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this); + connect(watcher, &QDBusPendingCallWatcher::finished, + this, &BioAuthenticate::onIdentifyComplete); + } else if ((m_deviceInfo.deviceType >= BioT_FingerPrint && m_deviceInfo.deviceType <= BioT_VoicePrint) || m_deviceInfo.deviceType == UniT_Remote) { + qDebug() << QString("Identify:[drvid: %1, uid: %2]").arg(m_deviceInfo.id).arg(m_nUid); + m_fdFrame = -1; + m_biometricHelper->StopOps(m_deviceInfo.id); + QDBusPendingCall call = m_biometricHelper->Identify(m_deviceInfo.id, m_nUid); + QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this); + connect(watcher, &QDBusPendingCallWatcher::finished, + this, &BioAuthenticate::onIdentifyComplete); + } +} + +void BioAuthenticate::SetExtraInfo(QString extra_info, QString info_type) +{ + if(!m_biometricHelper) + { + qWarning() << "m_biometricHelper doesn't exist."; + return; + } + m_biometricHelper->SetExtraInfo(info_type,extra_info); +} + +void BioAuthenticate::onIdentifyComplete(QDBusPendingCallWatcher *watcher) +{ + if(!m_biometricHelper || m_isStopped) + return ; + + QDBusPendingReply reply = *watcher; + if(reply.isError()) { + qWarning() << "Identify error: " << reply.error().message(); + onBioAuthComplete(false, -1); + return; + } + int result = reply.argumentAt(0).toInt(); + int authUid = reply.argumentAt(1).toInt(); + qDebug() << result << authUid << m_nUid; + + // 特征识别成功,而且用户id匹配 + if(result == DBUS_RESULT_SUCCESS && authUid == m_nUid) { + qDebug() << "Identify success"; + onBioAuthComplete(true, 0); + } else if(result == DBUS_RESULT_NOTMATCH) { // 特征识别不匹配 + qDebug() << "Identify failed"; + onBioAuthComplete(false, 2); + } else if(result == DBUS_RESULT_ERROR) { //识别发生错误 + StatusReslut ret = m_biometricHelper->UpdateStatus(m_deviceInfo.id); + qDebug()<<"StatusReslut:"<= OPS_GET_FLIST_SUCCESS && ret.opsStatus <= OPS_GET_FLIST_MAX) { + onBioAuthComplete(false, -3); // 主动停止,直接重试 + } else { + onBioAuthComplete(false, 2); + } + } else { + onBioAuthComplete(false, 2); + } + } else { + onBioAuthComplete(false, 2); + } +} + +/** + * @brief 终止生物识别认证 + */ +void BioAuthenticate::stopAuth() +{ + if (!m_biometricHelper) { + return ; + } + m_isStopped = true; + if(m_bioTimer && m_bioTimer->isActive()) + m_bioTimer->stop(); + if(m_bioauthState == BIOAUTH_IDLE || m_deviceInfo.id < 0) { + return; + } + m_biometricHelper->StopOps(m_deviceInfo.id); + m_bioauthState = BIOAUTH_IDLE; + Q_EMIT bioAuthStateChanged(m_bioauthState); +} + +void BioAuthenticate::onBioAuthComplete(bool isSuccess, int nError) +{ + m_bioauthState = BIOAUTH_COMPLETE; + Q_EMIT bioAuthStateChanged(m_bioauthState); + if(!isSuccess) { + if (nError == 5 && m_deviceInfo.id > -1) { + Q_EMIT bioAuthCompleted(m_nUid, false, nError, m_maxFailedTimes, 0); + return; + } else if (nError >= 2 && nError != 5) + if (m_deviceInfo.id > -1) { + if (m_failedTimes.contains(m_nUid) ) { + if (m_failedTimes[m_nUid].contains(m_deviceInfo.id)) { + m_failedTimes[m_nUid][m_deviceInfo.id] = m_failedTimes[m_nUid][m_deviceInfo.id] + 1; + } else { + m_failedTimes[m_nUid][m_deviceInfo.id] = 1; + } + } else { + m_failedTimes[m_nUid][m_deviceInfo.id] = 1; + } + qDebug()<<"Failed count:"<= m_maxFailedTimes){ + m_mapDisableDev[m_nUid][m_deviceInfo.id] = true; + Q_EMIT bioAuthCompleted(m_nUid, false, nError, m_maxFailedTimes, m_failedTimes[m_nUid][m_deviceInfo.id]); + return ; + } + Q_EMIT bioAuthCompleted(m_nUid, false, nError, m_maxFailedTimes, m_failedTimes[m_nUid][m_deviceInfo.id]); + } + if (nError <= 0) { + qDebug()<<"Biometric dbus error:"<getFTimeoutTimes()) { + m_fTimeoutTimes = 0; + nError = 6; + } else { + startBioAuth(); + } + } else { + startBioAuth(); + } + Q_EMIT bioAuthCompleted(m_nUid, false, nError, m_maxFailedTimes, m_failedTimes[m_nUid][m_deviceInfo.id]); + } else { + Q_EMIT bioAuthCompleted(m_nUid, true, 0, m_maxFailedTimes, 0); + } + m_bioauthState = BIOAUTH_IDLE; + Q_EMIT bioAuthStateChanged(m_bioauthState); +} + +void BioAuthenticate::onPamAuthComplete() +{ + QMap>::iterator itFaildTimes = m_failedTimes.begin(); + for (; itFaildTimes != m_failedTimes.end(); itFaildTimes ++) { + itFaildTimes.value().clear(); + } + QMap>::iterator itDisableDev = m_mapDisableDev.begin(); + for (; itDisableDev != m_mapDisableDev.end(); itDisableDev ++) { + itDisableDev.value().clear(); + } +} + +void BioAuthenticate::onBioAuthTimer() +{ + m_bioTimer->stop(); + if (m_deviceInfo.id < 0) { + return ; + } + + if(m_deviceInfo.id > -1 && m_deviceInfo.deviceType == LOGINOPT_TYPE_GENERAL_UKEY){ + //ukey时不调用ukey认证 + }else{ + _startAuth(); + } +} + +void BioAuthenticate::startBioAuth(unsigned uTimeout) +{ + stopAuth(); + + if(m_deviceInfo.id > -1 && m_deviceInfo.deviceType == UniT_General_Ukey){ + //ukey时不调用ukey认证 + m_bioauthState = BIOAUTH_START; + Q_EMIT bioAuthStateChanged(m_bioauthState); + return; + } + + if(!m_bioTimer){ + m_bioTimer = new QTimer(this); + connect(m_bioTimer, SIGNAL(timeout()), this, SLOT(onBioAuthTimer())); + } + m_bioTimer->start(uTimeout); +} + +QString BioAuthenticate::getDefaultDevice(int nUid, QString strUserName,int bioType) +{ + QString defaultDeviceName = ""; + if (m_uniauthService && m_uniauthService->isActivatable()) { + QString strDeviceName = m_uniauthService->getDefaultDevice(strUserName, bioType); + if(!strDeviceName.isEmpty()) { + DeviceInfoPtr pDeviceInfo = findDeviceByName(nUid, strDeviceName); + if (pDeviceInfo) { + defaultDeviceName = strDeviceName; + } + } + } + return QString(defaultDeviceName); +} + +QString BioAuthenticate::getDefaultDevice(int nUid, QString strUserName) +{ + QString defaultDeviceName = ""; + if (m_uniauthService && m_uniauthService->isActivatable()) { + for (auto bioType : m_listPriority) { + QString strDeviceName = m_uniauthService->getDefaultDevice(strUserName, bioType); + if(!strDeviceName.isEmpty()) { + DeviceInfoPtr pDeviceInfo = findDeviceByName(nUid, strDeviceName); + if (pDeviceInfo) { + defaultDeviceName = strDeviceName; + break; + } + } + } + } + return QString(defaultDeviceName); +} diff --git a/src/lock-backend/bioauthenticate.h b/src/lock-backend/bioauthenticate.h new file mode 100644 index 0000000..57add60 --- /dev/null +++ b/src/lock-backend/bioauthenticate.h @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * +**/ +#ifndef BIOAUTHENTICATE_H +#define BIOAUTHENTICATE_H + +#include +#include +#include +#include "biodefines.h" + +class BiometricHelper; +class FreedesktopHelper; +class UniAuthService; +class BioAuthenticate : public QObject +{ + Q_OBJECT +public: + explicit BioAuthenticate(QObject *parent = nullptr); + + DeviceMap getAvailableDevices(int nUid); + QList getDisabledDevices(int nUid); + inline BIOAUTH_STATE getBioAuthState() { return m_bioauthState; } + inline DeviceInfo getCurBioInfo() { return m_deviceInfo; } + DeviceInfoPtr findDeviceById(int nUid, int nDevId); + DeviceInfoPtr findDeviceByName(int nUid, QString strDevName); + void startAuth(int uid, int nDevId); + void stopAuth(); + QString getDefaultDevice(int nUid, QString strUserName); + QString getDefaultDevice(int nUid, QString strUserName,int bioType); + +public Q_SLOTS: + void onServiceStatusChanged(const QString &strService, bool bActive); + void onBioDeviceChanged(int drvid, int action, int devNum); + void onStatusChanged(int drvid, int status); + void onFrameWritten(int drvid); + void onIdentifyComplete(QDBusPendingCallWatcher *watcher); + void onBioAuthComplete(bool isSuccess, int nError); + void onPamAuthComplete(); + void onBioAuthTimer(); + +Q_SIGNALS: + void bioServiceStatusChanged(bool bValid); + void bioDeviceChanged(); + void bioAuthShowMessage(QString strMsg); + void bioAuthStateChanged(int nState); + void bioAuthFrameData(QString strData); + void bioAuthCompleted(int nUid, bool isSuccess, int nError, int nMaxFailedTime, int nFailedTime); + +private: + void initBioService(); + void initConncetions(); + + bool getBioAuthEnable(QString strUserName, int nType); + void checkAvailableBioInfo(int nUid); + void clearBioData(); + void SetExtraInfo(QString extra_info,QString info_type); + void startBioAuth(unsigned uTimeout = 1000); + void _startAuth(); + +private: + BiometricHelper *m_biometricHelper = nullptr; + FreedesktopHelper *m_systemFdHelper = nullptr; + QMap m_mapDevices; // 用户可用的设备 + UniAuthService *m_uniauthService = nullptr; + DeviceInfo m_deviceInfo; + BIOAUTH_STATE m_bioauthState; + int m_fdFrame = -1; + int m_nUid = -1; + bool m_isStopped = false; // 是否被强制终止 + int m_maxFailedTimes; + QMap> m_mapDisableDev; + QMap> m_failedTimes; + QTimer *m_bioTimer; + int m_fTimeoutTimes = 0; + QList m_listPriority; +}; + +#endif // BIOAUTHENTICATE_H diff --git a/src/lock-backend/dbusupperinterface.cpp b/src/lock-backend/dbusupperinterface.cpp new file mode 100644 index 0000000..06f5b4d --- /dev/null +++ b/src/lock-backend/dbusupperinterface.cpp @@ -0,0 +1,2128 @@ +/* + * Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * +**/ +#include "dbusupperinterface.h" +#include "lightdmhelper.h" +#include "login1helper.h" +#include "definetypes.h" +#include "configuration.h" +#include "gsettingshelper.h" +#include "usdhelper.h" +#include +#include +#include +#include +#include +#include +#include +#include "qtlocalpeer.h" +#include "switchuserutils.h" +#include "pamauthenticate.h" +#include "upowerhelper.h" +#include "accountservicehelper.h" +#include "sessionhelper.h" +#include "sessionwatcher.h" +#include "freedesktophelper.h" +#include "bioauthenticate.h" +#include "kglobalaccelhelper.h" + +#define CONFIG_FILE "/usr/share/ukui-greeter/ukui-greeter.conf" + +DbusUpperInterface::DbusUpperInterface(QObject *parent) + : QObject(parent) +{ + initData(); + initConnections(); +} + +void DbusUpperInterface::initData() +{ + m_bLockState = false; + m_bSlpState = false; + m_lightDmHelper = new LightDMHelper(this); + m_login1Helper = new Login1Helper(this); + m_config = new Configuration(this); + m_gsettingsHelper = new GSettingsHelper(this); + m_bioAuth = new BioAuthenticate(this); + m_pamAuth = new PamAuthenticate(m_lightDmHelper, this); + m_usdHelper= new UsdHelper(this); + m_upowerHelper = new UpowerHelper(this); + m_accountsHelper = new AccountServiceHelper(this); + m_sessionHelper = new SessionHelper(this); + m_sessionWatcher = new SessionWatcher(m_gsettingsHelper, this); + m_kglobalHelper = new KglobalAccelHelper(this); +} + +void DbusUpperInterface::initConnections() +{ + if (m_lightDmHelper) { + connect(m_lightDmHelper, &LightDMHelper::usersInfoChanged, this, &DbusUpperInterface::onUsersInfoChanged); + connect(m_lightDmHelper, &LightDMHelper::currentSessionChanged, this, &DbusUpperInterface::onCurrentSessionChanged); + } + if (m_login1Helper) { + connect(m_login1Helper, &Login1Helper::requestLock, this, &DbusUpperInterface::onLogin1ReqLock); + connect(m_login1Helper, &Login1Helper::requestUnlock, this, &DbusUpperInterface::onLogin1ReqUnLock); + connect(m_login1Helper, &Login1Helper::PrepareForSleep, this, &DbusUpperInterface::onLogin1PrepareForSleep); + connect(m_login1Helper, &Login1Helper::sessionActiveChanged, this, &DbusUpperInterface::onLogin1SessionActiveChanged); + connect(m_login1Helper, &Login1Helper::lidStateChanged, this, &DbusUpperInterface::onLidStateChanged); + } + if (m_gsettingsHelper) { + connect(m_gsettingsHelper, &GSettingsHelper::lockScreenConfigChanged, this, &DbusUpperInterface::onLockScreenConfigChanged); + connect(m_gsettingsHelper, &GSettingsHelper::screenSaverConfigChanged, this, &DbusUpperInterface::onScreenSaverConfigChanged); + connect(m_gsettingsHelper, &GSettingsHelper::powerManagerConfigChanged, this, &DbusUpperInterface::onPowerManagerConfigChanged); + connect(m_gsettingsHelper, &GSettingsHelper::mateBgConfigChanged, this, &DbusUpperInterface::onMateBgConfigChanged); + connect(m_gsettingsHelper, &GSettingsHelper::ukccPluginsConfigChanged, this, &DbusUpperInterface::onUkccPluginsConfigChanged); + connect(m_gsettingsHelper, &GSettingsHelper::themeStyleConfigChanged, this, &DbusUpperInterface::onThemeStyleConfigChanged); + connect(m_gsettingsHelper, &GSettingsHelper::sessionConfigChanged, this, &DbusUpperInterface::onSessionConfigChanged); + connect(m_gsettingsHelper, &GSettingsHelper::keyboardConfigChanged, this, &DbusUpperInterface::onKeyboardConfigChanged); + connect(m_gsettingsHelper, &GSettingsHelper::usdMediaKeysConfigChanged, this, &DbusUpperInterface::onUsdMediaKeysConfigChanged); + } + if (m_bioAuth) { + connect(m_bioAuth, &BioAuthenticate::bioAuthShowMessage, this, &DbusUpperInterface::onBioAuthShowMessage); + connect(m_bioAuth, &BioAuthenticate::bioServiceStatusChanged, this, &DbusUpperInterface::onBioServiceStatusChanged); + connect(m_bioAuth, &BioAuthenticate::bioDeviceChanged, this, &DbusUpperInterface::onBioDeviceChanged); + connect(m_bioAuth, &BioAuthenticate::bioAuthStateChanged, this, &DbusUpperInterface::onBioAuthStateChanged); + connect(m_bioAuth, &BioAuthenticate::bioAuthFrameData, this, &DbusUpperInterface::onBioAuthFrameData); + connect(m_bioAuth, &BioAuthenticate::bioAuthCompleted, this, &DbusUpperInterface::onBioAuthCompleted); + if (m_pamAuth) { + connect(m_pamAuth, &PamAuthenticate::authenticationComplete, m_bioAuth, &BioAuthenticate::onPamAuthComplete); + } + } + if (m_pamAuth) { + connect(m_pamAuth, &PamAuthenticate::showMessage, this, &DbusUpperInterface::onPamShowMessage); + connect(m_pamAuth, &PamAuthenticate::showPrompt, this, &DbusUpperInterface::onPamShowPrompt); + connect(m_pamAuth, &PamAuthenticate::authenticationComplete, this, &DbusUpperInterface::onPamAuthCompleted); + } + if (m_upowerHelper) { + connect(m_upowerHelper, &UpowerHelper::batteryStatusChanged, this, &DbusUpperInterface::onBatteryStatusChanged); + connect(m_upowerHelper, &UpowerHelper::batteryChanged, this, &DbusUpperInterface::onBatteryChanged); + } + if (m_sessionWatcher) { + connect(m_sessionWatcher, &SessionWatcher::sessionIdle, this, &DbusUpperInterface::onSessionIdleReceived); + connect(m_sessionWatcher, &SessionWatcher::sessionIdle, + this, [=](){ + QDBusMessage message; + message = QDBusMessage::createSignal(SS_DBUS_PATH, + SS_DBUS_INTERFACE, + "SecondRunParam"); + message<<"SessionIdle"; + QDBusConnection::sessionBus().send(message); + }); + connect(m_sessionWatcher, &SessionWatcher::sessionIdleExit, this, &DbusUpperInterface::onSessionIdleExit); + } + connect(&m_procLockDialog, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(onLockDialogProcExit(int,QProcess::ExitStatus))); +} + +void DbusUpperInterface::onNameLost(const QString &serviceName) +{ + if(serviceName == "cn.kylinos.ScreenSaver") + exit(0); +} + +bool DbusUpperInterface::GetSlpState() +{ + return ((m_procLockDialog.state() != QProcess::NotRunning) && m_bSlpState); +} + +void DbusUpperInterface::LockStartupMode() +{ + + if(m_procLockDialog.state() != QProcess::NotRunning) { + QDBusMessage message; + message = QDBusMessage::createSignal(SS_DBUS_PATH, + SS_DBUS_INTERFACE, + "SecondRunParam"); + message<<"StartupLock"; + QDBusConnection::sessionBus().send(message); + return ; + } + + qDebug() << "LockStartupMode requested"; + m_bLockState = false; + QString cmd = QString("/usr/bin/ukui-screensaver-dialog --lock-startup"); + qDebug() << cmd; + + m_procLockDialog.start(cmd); + emitLockState(true); +} + +bool DbusUpperInterface::GetBlankState() +{ + return m_bBlankState; +} + +bool DbusUpperInterface::GetLockState() +{ + if(m_procLockDialog.state() == QProcess::NotRunning){ + return false; + }else{ + return lockState; + } + return false; +} + +void DbusUpperInterface::Lock() +{ + if(m_procLockDialog.state() != QProcess::NotRunning) { + QDBusMessage message; + message = QDBusMessage::createSignal(SS_DBUS_PATH, + SS_DBUS_INTERFACE, + "SecondRunParam"); + message<<"CmdLock"; + QDBusConnection::sessionBus().send(message); + return ; + } + qDebug() << "Lock requested"; + m_bLockState = false; + QString cmd = QString("/usr/bin/ukui-screensaver-dialog --lock"); + qDebug() << cmd; + + m_procLockDialog.start(cmd); + emitLockState(true); +} + +void DbusUpperInterface::UnLock() +{ + if(m_procLockDialog.state() != QProcess::NotRunning) + m_procLockDialog.kill(); +} + + +bool DbusUpperInterface::LockByBlank(int nType) +{ + qDebug()<<"LockByBlank:"<GetPowerManagerConf(KEY_SLEEP_DISPLAY_AC).toInt(); + int nIdleDelay = m_gsettingsHelper->GetScreenSaverConf(KEY_IDLE_DELAY).toInt(); + bool isCloseActive = m_gsettingsHelper->GetScreenSaverConf(KEY_CLOSE_ACTIVATION_ENABLED).toBool(); + qDebug()<<"DelayState:"<GetScreenSaverConf(KEY_LOCK_ENABLED).toBool()) { // 仅启动屏保 + isNeedLock = false; + } + } else { + return false; + } + } else { + qDebug()<<"Don't need blank lock:"<GetScreenSaverConf(KEY_LOCK_TIMEOUT).toInt() != -1 && isNeedLock) { + // 空闲关屏且关屏时间与睡眠时间一致时直接锁定 + if (nType == 0 && ((m_gsettingsHelper->GetPowerManagerConf(KEY_SLEEP_DISPLAY_AC).toInt() == m_gsettingsHelper->GetPowerManagerConf(KEY_SLEEP_COMPUTER_AC).toInt()) + && m_gsettingsHelper->GetPowerManagerConf(KEY_SLEEP_COMPUTER_AC).toInt() != -1)) { + qDebug()<<"close delay same with sleep delay then lock!"; + QString cmd = QString("/usr/bin/ukui-screensaver-dialog --blank --delay %1 --has-lock %2").arg(1000).arg(isNeedLock?1:0); + qDebug() << cmd; + m_procLockDialog.start(cmd); + emitLockState(true); + return true; + } else { + delayLockScreen(); + return false; + } + } else { + QString cmd = QString("/usr/bin/ukui-screensaver-dialog --blank --delay %1 --has-lock %2").arg(2000).arg(isNeedLock?1:0); + qDebug() << cmd; + m_procLockDialog.start(cmd); + emitLockState(true); + } + return true; + } + + return true; +} + +void DbusUpperInterface::SetLockState() +{ + m_bLockState = true; +} + +void DbusUpperInterface::onShowBlankScreensaver() +{ + if(m_procLockDialog.state() != QProcess::NotRunning) { + QDBusMessage message; + message = QDBusMessage::createSignal(SS_DBUS_PATH, + SS_DBUS_INTERFACE, + "SecondRunParam"); + message<<"SleepLock"; + QDBusConnection::sessionBus().send(message); + return ; + } + + qDebug() << "lock and show screensaver"; + m_bLockState = false; + m_bSlpState = false; + QString cmd = QString("/usr/bin/ukui-screensaver-dialog --blank"); + qDebug() << cmd; + + m_procLockDialog.start(cmd); + emitLockState(true); +} + +void DbusUpperInterface::ShowScreensaver() +{ + + if(m_procLockDialog.state() != QProcess::NotRunning){ + QDBusMessage message; + message = QDBusMessage::createSignal(SS_DBUS_PATH, + SS_DBUS_INTERFACE, + "SecondRunParam"); + message<<"ScreensaverLock"; + QDBusConnection::sessionBus().send(message); + return ; + return ; + } + + m_bSlpState = true; + qDebug() << "lock and show screensaver"; + m_bLockState = false; + QString cmd = QString("/usr/bin/ukui-screensaver-dialog --lock-screensaver"); + qDebug() << cmd; + + m_procLockDialog.start(cmd); + emitLockState(true); +} + +bool DbusUpperInterface::checkScreenDialogRunning() +{ + bool isRunning = false; + QString id = QString("ukui-screensaver-dialog"+QLatin1String(getenv("DISPLAY"))); + QtLocalPeer *lPeer = new QtLocalPeer(this, id); + isRunning = lPeer->isClient(); + delete lPeer; + return isRunning; +} + +void DbusUpperInterface::emitLockState(bool val) +{ + qDebug()<<"emitLockState state = "<blockShortcut(val); + + QDBusMessage message; + if(val){ + message = QDBusMessage::createSignal(SS_DBUS_PATH, + SS_DBUS_INTERFACE, + "lock"); + }else{ + message = QDBusMessage::createSignal(SS_DBUS_PATH, + SS_DBUS_INTERFACE, + "unlock"); + } + QDBusConnection::sessionBus().send(message); +} + +QString DbusUpperInterface::GetInformation(QString strJson) +{ + QJsonParseError jsonParseError; + QJsonObject retObj; + retObj["Ret"] = 0; + retObj["Message"] = "Success"; + qDebug()<<"Json:"<isSessionActive(); + break; + case LOCK_CMD_ID_GET_AGREEMENT: + retObj["CmdId"] = cmdId; + retObj["Content"] = GenerateAgreementInfo(); + case LOCK_CMD_ID_GSETTINGS_GET_LOCKSCREEN_CONF: + retObj["CmdId"] = cmdId; + GetLockScreenConf(rootObj, retObj); + break; + case LOCK_CMD_ID_GSETTINGS_GET_SCREENSAVER_CONF: + retObj["CmdId"] = cmdId; + GetScreenSaverConf(rootObj, retObj); + break; + case LOCK_CMD_ID_GSETTINGS_GET_POWERMANAGER_CONF: + retObj["CmdId"] = cmdId; + GetPowerManagerConf(rootObj, retObj); + break; + case LOCK_CMD_ID_GSETTINGS_GET_MATEBG_CONF: + retObj["CmdId"] = cmdId; + GetMateBgConf(rootObj, retObj); + break; + case LOCK_CMD_ID_GSETTINGS_GET_UKCCPLUGINS_CONF: + retObj["CmdId"] = cmdId; + GetUkccPluginsConf(rootObj, retObj); + break; + case LOCK_CMD_ID_GSETTINGS_GET_THEMESTYLE_CONF: + retObj["CmdId"] = cmdId; + GetThemeStyleConf(rootObj, retObj); + break; + case LOCK_CMD_ID_GSETTINGS_GET_SESSION_CONF: + retObj["CmdId"] = cmdId; + GetSessionConf(rootObj, retObj); + break; + case LOCK_CMD_ID_GSETTINGS_GET_KEYBOARD_CONF: + retObj["CmdId"] = cmdId; + GetKeyboardConf(rootObj, retObj); + break; + case LOCK_CMD_ID_PAMAUTH_IS_AUTHENTICATED: + retObj["CmdId"] = cmdId; + IsPamAuthenticated(rootObj, retObj); + break; + case LOCK_CMD_ID_PAMAUTH_IS_INAUTHTICATION: + retObj["CmdId"] = cmdId; + IsPamInAuthentication(rootObj, retObj); + break; + case LOCK_CMD_ID_PAMAUTH_GET_AUTHUSER: + retObj["CmdId"] = cmdId; + PamAuthenticationUser(rootObj, retObj); + case LOCK_CMD_ID_GSETTINGS_GET_USD_MEDIAKEYS_CONF: + retObj["CmdId"] = cmdId; + getUsdMediaKeys(rootObj, retObj); + break; + case LOCK_CMD_ID_LOGIN1_GET_POWER_MANAGER_CANHIBERNATE: + retObj["CmdId"] = cmdId; + retObj["Content"] = m_login1Helper->isCanHibernate(); + break; + case LOCK_CMD_ID_LOGIN1_GET_POWER_MANAGER_CANPOWEROFF: + retObj["CmdId"] = cmdId; + retObj["Content"] = m_login1Helper->isCanPowerOff(); + break; + case LOCK_CMD_ID_LOGIN1_GET_POWER_MANAGER_CANREBOOT: + retObj["CmdId"] = cmdId; + retObj["Content"] = m_login1Helper->isCanReboot(); + break; + case LOCK_CMD_ID_LOGIN1_GET_POWER_MANAGER_CANSUSPEND: + retObj["CmdId"] = cmdId; + retObj["Content"] = m_login1Helper->isCanSuspend(); + break; + case LOCK_CMD_ID_UPOWER_BATTERY_STATUS: + retObj["CmdId"] = cmdId; + retObj["Content"] = getBatteryIconName(); + break; + case LOCK_CMD_ID_UPOWER_IS_BATTERY: + retObj["CmdId"] = cmdId; + retObj["Content"] = getIsBattery(); + break; + case LOCK_CMD_ID_UPOWER_BATTERY: + retObj["CmdId"] = cmdId; + retObj["Content"] = GenerateBatteryArgsList(); + break; + case LOCK_CMD_ID_SESSION_GET_SLEEP_LOCKCHECK: + retObj["CmdId"] = cmdId; + retObj["Content"] = getSleepLockCheck(); + break; + case LOCK_CMD_ID_SESSION_GET_SHUTDOWN_LOCKCHECK: + retObj["CmdId"] = cmdId; + retObj["Content"] = getShutdownLockcheck(); + break; + case LOCK_CMD_ID_LOCK_SCREEN_GET_THEMES: + retObj["CmdId"] = cmdId; + retObj["Content"] = getSaverTheme();; + break; + case LOCK_CMD_ID_BIOAUTH_GET_AVAILABLE_DEVICES: + retObj["CmdId"] = cmdId; + BioGetAvailableDevices(rootObj, retObj); + break; + case LOCK_CMD_ID_BIOAUTH_GET_DISABLED_DEVICES: + retObj["CmdId"] = cmdId; + BioGetDisabledDevices(rootObj, retObj); + break; + case LOCK_CMD_ID_BIOAUTH_GET_STATE: + retObj["CmdId"] = cmdId; + BioGetBioAuthState(rootObj, retObj); + break; + case LOCK_CMD_ID_BIOAUTH_GET_CURDEVICE: + retObj["CmdId"] = cmdId; + BioGetCurBioInfo(rootObj, retObj); + break; + case LOCK_CMD_ID_BIOAUTH_FIND_DEVICE_BY_ID: + retObj["CmdId"] = cmdId; + BioFindDeviceById(rootObj, retObj); + break; + case LOCK_CMD_ID_BIOAUTH_FIND_DEVICE_BY_NAME: + retObj["CmdId"] = cmdId; + BioFindDeviceByName(rootObj, retObj); + break; + case LOCK_CMD_ID_BIOAUTH_GET_DEFAULT_DEVICE: + retObj["CmdId"] = cmdId; + BioGetDefaultDevice(rootObj, retObj); + break; + default: + qInfo()<<"不支持的CmdId"; + retObj["Ret"] = -2; + retObj["Message"] = "Unsupported CmdId!!"; + break; + } + } + } + return QString(QJsonDocument(retObj).toJson()); +} + +int DbusUpperInterface::SetInformation(QString strJson) +{ + QJsonParseError jsonParseError; + int nRet = 0; + const QJsonDocument jsonDoc = QJsonDocument::fromJson(strJson.toUtf8(), &jsonParseError); + if (jsonParseError.error != QJsonParseError::NoError) { + qWarning()<<"Parse info json failed!!"; + nRet = -1; + } else { + QJsonObject rootObj = jsonDoc.object(); + if (rootObj.isEmpty()) { + qWarning()<<"Info Json is null!!"; + nRet = -1; + } else { + int cmdId = rootObj.value("CmdId").toInt(); + qInfo() << "CmdId: " << cmdId; + switch (cmdId) { + case LOCK_CMD_ID_SET_USER: + nRet = SetCurrentUser(rootObj); + break; + case LOCK_CMD_ID_SET_SESSION: + nRet = SetCurrentSession(rootObj); + break; + case LOCK_CMD_ID_START_SESSION: + nRet = StartSession(rootObj); + break; + case LOCK_CMD_ID_GSETTINGS_SET_LOCKSCREEN_CONF: + nRet = SetLockScreenConf(rootObj); + break; + case LOCK_CMD_ID_GSETTINGS_SET_SCREENSAVER_CONF: + nRet = SetScreenSaverConf(rootObj); + break; + case LOCK_CMD_ID_GSETTINGS_SET_POWERMANAGER_CONF: + nRet = SetPowerManagerConf(rootObj); + break; + case LOCK_CMD_ID_GSETTINGS_SET_MATEBG_CONF: + nRet = SetMateBgConf(rootObj); + break; + case LOCK_CMD_ID_GSETTINGS_SET_UKCCPLUGINS_CONF: + nRet = SetUkccPluginsConf(rootObj); + break; + case LOCK_CMD_ID_GSETTINGS_SET_THEMESTYLE_CONF: + nRet = SetThemeStyleConf(rootObj); + break; + case LOCK_CMD_ID_GSETTINGS_SET_SESSION_CONF: + nRet = SetSessionConf(rootObj); + break; + case LOCK_CMD_ID_PAMAUTH_AUTHENTICATE: + nRet = PamAuthenticateUser(rootObj); + break; + case LOCK_CMD_ID_PAMAUTH_RESPOND: + nRet = PamRespond(rootObj); + break; + case LOCK_CMD_ID_PAMAUTH_AUTHENTICATE_CANCEL: + nRet = PamAuthenticateCancel(rootObj); + break; + case LOCK_CMD_ID_USD_MEDIAKEYS: + nRet = usdExternalDoAction(rootObj); + break; + case LOCK_CMD_ID_LOGIN1_SET_POWER_MANAGER: + nRet = SetPowerManager(rootObj); + break; + case LOCK_CMD_ID_LOCK_STATE_CHANGED: + nRet = lockStateChanged(rootObj); + break; + case LOCK_CMD_ID_BIOAUTH_STARTAUTH: + nRet = BioStartAuth(rootObj); + break; + case LOCK_CMD_ID_BIOAUTH_STOPAUTH: + nRet = BioStopAuth(rootObj); + break; + case LOCK_CMD_ID_KWIN_BLOCK_SHORTCUT: + nRet = blockShortcut(rootObj); + default: + qInfo()<<"不支持的CmdId"; + nRet = -2; + break; + } + } + } + return nRet; +} + +QJsonObject DbusUpperInterface::GenerateAgreementInfo() +{ + QSettings settings(CONFIG_FILE,QSettings::IniFormat); + settings.setIniCodec(QTextCodec::codecForName("utf-8")); + + QJsonObject objAgreementInfo; + + if(settings.contains("Greeter/showLoginPrompt")){ + objAgreementInfo["showLoginPrompt"] = settings.value("Greeter/showLoginPrompt").toBool(); + } + + if(settings.contains("Greeter/hideTitle")){ + objAgreementInfo["hideTitle"] = settings.value("Greeter/hideTitle").toBool(); + } + + if(settings.contains("Greeter/promptTitle")){ + QString promptTitle = settings.value("Greeter/promptTitle").toString(); + objAgreementInfo["promptTitle"] = promptTitle; + } + + if(settings.contains("Greeter/promptText")){ + QString promptText = settings.value("Greeter/promptText").toString(); + objAgreementInfo["promptText"] = promptText; + } + + if(settings.contains("Greeter/promptTextFilePath")){ + QString promptTextFilePath = settings.value("Greeter/promptTextFilePath").toString(); + objAgreementInfo["promptTextFilePath"] = promptTextFilePath; + } + + return objAgreementInfo; +} + +QJsonArray DbusUpperInterface::GenerateUserInfoList() +{ + QJsonArray jsonArray; + if (m_lightDmHelper) { + QList usersInfo = m_lightDmHelper->getUsersInfo(); + for (auto userInfo : usersInfo) { + QJsonObject objUserInfo; + objUserInfo["uid"] = (double)userInfo->uid(); + objUserInfo["name"] = userInfo->name(); + objUserInfo["fullName"] = userInfo->fullName(); + objUserInfo["loggedIn"] = userInfo->isLoggedIn(); + objUserInfo["backGround"] = userInfo->backGround(); + objUserInfo["lang"] = userInfo->lang(); + objUserInfo["headImg"] = userInfo->headImage(); + jsonArray.append(objUserInfo); + } + } + return jsonArray; +} + +QJsonArray DbusUpperInterface::GenerateBatteryArgsList() +{ + QJsonArray jsonArray; + if (m_upowerHelper) { + QStringList batteryArgs = m_upowerHelper->getBatteryArgs(); + for (auto battery : batteryArgs) { + QJsonObject objBatteryInfo; + objBatteryInfo["key"] = battery; + jsonArray.append(objBatteryInfo); + } + } + return jsonArray; +} + +QJsonArray DbusUpperInterface::getSleepLockCheck() +{ + QJsonArray jsonArray; + if (m_sessionHelper) { + QStringList lockCheckList = m_sessionHelper->getLockCheckStatus("sleep"); + for (auto lockcheck : lockCheckList) { + QJsonObject objBatteryInfo; + objBatteryInfo["key"] = lockcheck; + jsonArray.append(objBatteryInfo); + } + } + return jsonArray; +} + +QJsonArray DbusUpperInterface::getShutdownLockcheck() +{ + QJsonArray jsonArray; + if (m_sessionHelper) { + QStringList lockCheckList = m_sessionHelper->getLockCheckStatus("shutdown"); + for (auto lockcheck : lockCheckList) { + QJsonObject objBatteryInfo; + objBatteryInfo["key"] = lockcheck; + jsonArray.append(objBatteryInfo); + } + } + return jsonArray; +} + +QJsonArray DbusUpperInterface::getSaverTheme() +{ + QJsonArray jsonArray; + if (m_sessionHelper) { + QStringList themeList = m_gsettingsHelper->GetLockScreenConf(KEY_THEMES).toStringList(); + for (auto list : themeList) { + QJsonObject objBatteryInfo; + objBatteryInfo["key"] = list; + jsonArray.append(objBatteryInfo); + } + } + return jsonArray; +} + +QString DbusUpperInterface::getBatteryIconName() +{ + QString iconName; + if (m_upowerHelper) { + iconName = m_upowerHelper->getBatteryIconName(); + } + return iconName; +} + +bool DbusUpperInterface::getIsBattery() +{ + bool isBattery = false; + if (m_upowerHelper) { + isBattery = m_upowerHelper->getIsBattery(); + } + return isBattery; +} + +QString DbusUpperInterface::GetDefaultAuthUser() +{ + QString strUserName = ""; + if (!isGreeterMode()) { + strUserName = getenv("USER"); + } else { + //获取lightdm传过来的被选中的用户 + QString selectedUser = m_lightDmHelper->selectUserHint(); + if(!selectedUser.isEmpty()) { + qDebug() << "SelectUserHint: " << selectedUser; + if (m_lightDmHelper->findUserByName(selectedUser)) { + strUserName = selectedUser; + } else { + qDebug()<<"SlelectUerHint invalid:"<selectGuestHint()) { + qDebug() << "SelectGuest"; + strUserName = "*guest"; + } else if(m_lightDmHelper->getUsersInfo().count() == 1) { //如果只有一个用户,默认选中 + strUserName = m_lightDmHelper->getUsersInfo()[0]->name(); + } else { + QString lastLoginUser = m_config->getLastLoginUser(); + if (m_lightDmHelper->findUserByName(lastLoginUser)) { + strUserName = lastLoginUser; + } else { + if (m_lightDmHelper->getUsersInfo().count() > 0) { + strUserName = m_lightDmHelper->getUsersInfo()[0]->name(); + } else { + qWarning()<<"Have no user to select!!"; + } + } + } + } + return strUserName; +} + +int DbusUpperInterface::StartSession(const QJsonObject &objInfo) +{ + Q_UNUSED(objInfo); + m_lightDmHelper->startSession(); + return 0; +} + +QString DbusUpperInterface::GetCurrentSession() +{ + return m_lightDmHelper->session(); +} + +int DbusUpperInterface::SetCurrentSession(const QJsonObject &objInfo) +{ + int nRet = -1; + QString strSessionName = objInfo.value("Content").toString(); + if (!strSessionName.isEmpty()) { + if (m_lightDmHelper->setSession(strSessionName)) { + nRet = 0; + } + } + return nRet; +} + +void DbusUpperInterface::onCurrentSessionChanged(QString strSession) +{ + QJsonObject retObj; + retObj["CmdId"] = LOCK_CMD_ID_CURRENT_SESSION_CHANGED; + retObj["Content"] = strSession; + SendUpdateInfoSig(QString(QJsonDocument(retObj).toJson())); +} + +QJsonArray DbusUpperInterface::GenerateSessionInfoList() +{ + QJsonArray jsonArray; + if (m_lightDmHelper) { + QList sessionsInfo = m_lightDmHelper->getSessionsInfo(); + for (auto session : sessionsInfo) { + QJsonObject objSessionInfo; + objSessionInfo["key"] = session; + jsonArray.append(objSessionInfo); + } + } + return jsonArray; +} + +QString DbusUpperInterface::GetCurrentUser() +{ + return m_lightDmHelper->getCurrentUser(); +} + +int DbusUpperInterface::SetCurrentUser(const QJsonObject &objInfo) +{ + int nRet = -1; + QString strUserName = objInfo.value("Content").toString(); + if (!strUserName.isEmpty()) { + if (m_lightDmHelper->setCurrentUser(strUserName)) { + nRet = 0; + if (m_accountsHelper) { + QString strSession = m_accountsHelper->getUserSessionByName(strUserName); + if (!strSession.isEmpty()) { + m_lightDmHelper->setSession(strSession); + } + } + { + QString strSwitchSeatPath = ""; + QString strDesUserName = strUserName; + QString strCurUserName = SwitchUserUtils::GetCurUserName(); + if (strCurUserName.isEmpty()) { + qDebug()<<"GetCurUserName failed!"; + nRet = 1; + } else { + UserDisplayIfInfo curUdii = SwitchUserUtils::GetUserUDII(strCurUserName); + UserDisplayIfInfo desUdii = {""}; + if (!strDesUserName.isEmpty()) { + desUdii = SwitchUserUtils::GetUserUDII(strDesUserName); + if (desUdii.strUserName.isEmpty()) { + desUdii.strUserName = strDesUserName; + } + } + + if (!curUdii.strSeatPath.isEmpty()) { + strSwitchSeatPath = curUdii.strSeatPath; + } + if (!desUdii.strSeatPath.isEmpty()) { + strSwitchSeatPath = desUdii.strSeatPath; + } + + if (strSwitchSeatPath.isEmpty()) { + qWarning()<<"switch user: switch seat path invalid!"; + nRet = 1; + } else { + nRet = SwitchUserUtils::SwitchToUserSession(strSwitchSeatPath, desUdii); + qDebug()<<"Switch user result:"<= 0) { + QJsonObject retObj; + retObj["CmdId"] = LOCK_CMD_ID_CURRENT_USER_CHANGED; + retObj["Content"] = GetCurrentUser(); + SendUpdateInfoSig(QString(QJsonDocument(retObj).toJson())); + } + return nRet; +} + +void DbusUpperInterface::onUsersInfoChanged() +{ + QJsonObject retObj; + retObj["CmdId"] = LOCK_CMD_ID_USERINFO_CHANGED; + retObj["Content"] = GenerateUserInfoList(); + SendUpdateInfoSig(QString(QJsonDocument(retObj).toJson())); +} + +bool DbusUpperInterface::SendUpdateInfoSig(QString strJson) +{ + QDBusMessage message; + message = QDBusMessage::createSignal(SS_DBUS_PATH, + SS_DBUS_INTERFACE, + "UpdateInformation"); + message<onShowBlankScreensaver(); + + if(!m_timer){ + m_timer = new QTimer(this); + connect(m_timer, &QTimer::timeout, this, [&]{ + m_timerCount+=1; + + if(GetLockState() || m_timerCount>20){ + m_timer->stop(); + m_timerCount = 0; + uninhibit(); + } + }); + } + m_timer->start(200); + } + else + { + m_nStatus &= ~SESSION_STATUS_SLEEPED; + m_bBlankState = false; + inhibit(); + } + QJsonObject retObj; + retObj["CmdId"] = LOCK_CMD_ID_LOGIN1_PREPAREFORSLEEP; + retObj["IsSleep"] = isSleep; + SendUpdateInfoSig(QString(QJsonDocument(retObj).toJson())); +} + +void DbusUpperInterface::onLogin1SessionActiveChanged(bool isActive) +{ + QJsonObject retObj; + retObj["CmdId"] = LOCK_CMD_ID_LOGIN1_SESSION_ACTIVE_CHANGED; + retObj["IsActive"] = isActive; + SendUpdateInfoSig(QString(QJsonDocument(retObj).toJson())); +} + +void DbusUpperInterface::onLidStateChanged(QString lidState) +{ + QJsonObject retObj; + retObj["CmdId"] = LOCK_CMD_ID_LOGIN1_LIDSTATE_CHANGED; + retObj["Lidstate"] = lidState; + SendUpdateInfoSig(QString(QJsonDocument(retObj).toJson())); +} + +void DbusUpperInterface::onBatteryStatusChanged(QString iconName) +{ + QJsonObject retObj; + retObj["CmdId"] = LOCK_CMD_ID_UPOWER_BATTERY_STATUS; + retObj["IconName"] = iconName; + SendUpdateInfoSig(QString(QJsonDocument(retObj).toJson())); +} + +void DbusUpperInterface::onSessionIdleReceived() +{ + if (!checkStatus(SESSION_STATUS_SCREENSAVER)) { + qDebug()<<"m_nStatus:"<GetScreenSaverConf(KEY_LOCK_TIMEOUT).toInt(); + if (m_gsettingsHelper->GetScreenSaverConf(KEY_LOCK_TIMEOUT).toInt() != -1) { + stopDelayLockScreen(); + m_timerLock->start(m_gsettingsHelper->GetScreenSaverConf(KEY_LOCK_TIMEOUT).toInt()*1000); + } +} + +void DbusUpperInterface::stopDelayLockScreen() +{ + if (m_timerLock && m_timerLock->isActive()) { + m_timerLock->stop(); + } +} + +void DbusUpperInterface::onLockScreenTimeout() +{ + Lock(); + m_timerLock->stop(); +} + +void DbusUpperInterface::onBatteryChanged(QStringList batteryArgs) +{ + QJsonObject retObj; + retObj["CmdId"] = LOCK_CMD_ID_UPOWER_BATTERY; + QJsonArray jsonArray; + for (auto args : batteryArgs) { + QJsonObject objBatteryInfo; + objBatteryInfo["key"] = args; + jsonArray.append(objBatteryInfo); + } + retObj["Content"] = jsonArray; + SendUpdateInfoSig(QString(QJsonDocument(retObj).toJson())); +} + +void DbusUpperInterface::onLockScreenConfigChanged(QString strKey, QVariant value) +{ + QJsonObject retObj; + retObj["CmdId"] = LOCK_CMD_ID_GSETTINGS_LOCKSCREEN_CONF_CHANGED; + switch (value.type()) { + case QVariant::Bool: + retObj[strKey] = value.toBool(); + break; + case QVariant::Int: + retObj[strKey] = value.toInt(); + break; + case QVariant::String: + retObj[strKey] = value.toString(); + break; + case QVariant::UInt: + retObj[strKey] = value.toDouble(); + break; + case QVariant::Double: + retObj[strKey] = value.toDouble(); + break; + default: + return; + } + + SendUpdateInfoSig(QString(QJsonDocument(retObj).toJson())); +} + +void DbusUpperInterface::onScreenSaverConfigChanged(QString strKey, QVariant value) +{ + QJsonObject retObj; + retObj["CmdId"] = LOCK_CMD_ID_GSETTINGS_SCREENSAVER_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::onPowerManagerConfigChanged(QString strKey, QVariant value) +{ + QJsonObject retObj; + retObj["CmdId"] = LOCK_CMD_ID_GSETTINGS_POWERMANAGER_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::onMateBgConfigChanged(QString strKey, QVariant value) +{ + QJsonObject retObj; + retObj["CmdId"] = LOCK_CMD_ID_GSETTINGS_MATEBG_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::onUkccPluginsConfigChanged(QString strKey, QVariant value) +{ + QJsonObject retObj; + retObj["CmdId"] = LOCK_CMD_ID_GSETTINGS_UKCCPLUGINS_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::onThemeStyleConfigChanged(QString strKey, QVariant value) +{ + QJsonObject retObj; + retObj["CmdId"] = LOCK_CMD_ID_GSETTINGS_THEMESTYLE_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::onSessionConfigChanged(QString strKey, QVariant value) +{ + QJsonObject retObj; + retObj["CmdId"] = LOCK_CMD_ID_GSETTINGS_SESSION_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::onKeyboardConfigChanged(QString strKey, QVariant value) +{ + QJsonObject retObj; + retObj["CmdId"] = LOCK_CMD_ID_GSETTINGS_KEYBOARD_CONF_CHANGED; + 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::onUsdMediaKeysConfigChanged(QString strKey, QVariant value) +{ + QJsonObject retObj; + retObj["CmdId"] = LOCK_CMD_ID_GSETTINGS_USD_MEDIAKEYS_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(); + if (!strKey.isEmpty()) { + QVariant value = m_gsettingsHelper->GetScreenSaverConf(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::SetScreenSaverConf(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->SetScreenSaverConf(strKey, value)) { + nRet = 0; + } + } + } + return nRet; +} + +void DbusUpperInterface::GetLockScreenConf(QJsonObject &reqObj, QJsonObject &retObj) +{ + QString strKey = reqObj.value("Key").toString(); + if (!strKey.isEmpty()) { + QVariant value = m_gsettingsHelper->GetLockScreenConf(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::SetLockScreenConf(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->SetLockScreenConf(strKey, value)) { + nRet = 0; + } + } + } + return nRet; +} + +void DbusUpperInterface::GetPowerManagerConf(QJsonObject &reqObj, QJsonObject &retObj) +{ + QString strKey = reqObj.value("Key").toString(); + if (!strKey.isEmpty()) { + QVariant value = m_gsettingsHelper->GetPowerManagerConf(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::SetPowerManagerConf(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->SetPowerManagerConf(strKey, value)) { + nRet = 0; + } + } + } + return nRet; +} + +void DbusUpperInterface::GetMateBgConf(QJsonObject &reqObj, QJsonObject &retObj) +{ + QString strKey = reqObj.value("Key").toString(); + if (!strKey.isEmpty()) { + QVariant value = m_gsettingsHelper->GetMateBgConf(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::SetMateBgConf(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->SetMateBgConf(strKey, value)) { + nRet = 0; + } + } + } + return nRet; +} + +void DbusUpperInterface::GetUkccPluginsConf(QJsonObject &reqObj, QJsonObject &retObj) +{ + QString strKey = reqObj.value("Key").toString(); + if (!strKey.isEmpty()) { + QVariant value = m_gsettingsHelper->GetUkccPluginsConf(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::SetUkccPluginsConf(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->SetUkccPluginsConf(strKey, value)) { + nRet = 0; + } + } + } + return nRet; +} + +void DbusUpperInterface::GetThemeStyleConf(QJsonObject &reqObj, QJsonObject &retObj) +{ + QString strKey = reqObj.value("Key").toString(); + if (!strKey.isEmpty()) { + QVariant value = m_gsettingsHelper->GetThemeStyleConf(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::SetThemeStyleConf(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->SetThemeStyleConf(strKey, value)) { + nRet = 0; + } + } + } + return nRet; +} + +void DbusUpperInterface::GetSessionConf(QJsonObject &reqObj, QJsonObject &retObj) +{ + QString strKey = reqObj.value("Key").toString(); + if (!strKey.isEmpty()) { + QVariant value = m_gsettingsHelper->GetSessionConf(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::SetSessionConf(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->SetSessionConf(strKey, value)) { + nRet = 0; + } + } + } + return nRet; +} + +void DbusUpperInterface::GetKeyboardConf(QJsonObject &reqObj, QJsonObject &retObj) +{ + QString strKey = reqObj.value("Key").toString(); + if (!strKey.isEmpty()) { + QVariant value = m_gsettingsHelper->GetKeyboardConf(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::SetKeyboardConf(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->SetKeyboardConf(strKey, value)) { + nRet = 0; + } + } + } + return nRet; +} + +void DbusUpperInterface::onLockDialogProcExit(int exitCode, QProcess::ExitStatus exitStatus) +{ + qInfo()<<"ukui-screensaver-dialog is exited,exitCode is "<GetLockScreenConf(KEY_SLEEP_ACTIVATION_ENABLED).toBool()) { + return false; + } + } + break; + case SESSION_STATUS_SCREENCLOSE: + { + m_nStatus |= nStatus; + if ((m_nStatus&SESSION_STATUS_SLEEPED) || !m_gsettingsHelper->GetLockScreenConf(KEY_CLOSE_ACTIVATION_ENABLED).toBool()) { + return false; + } + if (((m_gsettingsHelper->GetPowerManagerConf(KEY_SLEEP_COMPUTER_AC).toInt() == m_gsettingsHelper->GetPowerManagerConf(KEY_SLEEP_DISPLAY_AC).toInt()) + && m_gsettingsHelper->GetPowerManagerConf(KEY_SLEEP_COMPUTER_AC).toInt() != -1) && !m_gsettingsHelper->GetLockScreenConf(KEY_SLEEP_ACTIVATION_ENABLED).toBool()) { + qDebug()<<"Sleep same with Close and Sleep disable!"; + return false; + } + } + break; + case SESSION_STATUS_SCREENSAVER: + { + m_nStatus |= nStatus; + if ((m_nStatus&SESSION_STATUS_SLEEPED) || (m_nStatus&SESSION_STATUS_SCREENCLOSE)) { + return false; + } + if (((m_gsettingsHelper->GetLockScreenConf(KEY_IDLE_DELAY).toInt()*60 == m_gsettingsHelper->GetPowerManagerConf(KEY_SLEEP_COMPUTER_AC).toInt()) + && m_gsettingsHelper->GetPowerManagerConf(KEY_SLEEP_COMPUTER_AC).toInt() != -1) && !m_gsettingsHelper->GetLockScreenConf(KEY_SLEEP_ACTIVATION_ENABLED).toBool()) { + qDebug()<<"Sleep same with idle and Sleep disable!"; + return false; + } + if (((m_gsettingsHelper->GetLockScreenConf(KEY_IDLE_DELAY).toInt()*60 == m_gsettingsHelper->GetPowerManagerConf(KEY_SLEEP_DISPLAY_AC).toInt()) + && m_gsettingsHelper->GetPowerManagerConf(KEY_SLEEP_DISPLAY_AC).toInt() != -1)/* && !m_gsettingsHelper->GetLockScreenConf(KEY_CLOSE_ACTIVATION_ENABLED).toBool()*/) { + qDebug()<<"Close same with idle do nothing!"; + return false; + } + } + break; + default: + return false; + } + return true; +} + +void DbusUpperInterface::inhibit() +{ + if (m_inhibitFileDescriptor.isValid()) { + return; + } + + QDBusMessage message = QDBusMessage::createMethodCall("org.freedesktop.login1", + "/org/freedesktop/login1", + "org.freedesktop.login1.Manager", + QStringLiteral("Inhibit")); + message.setArguments(QVariantList({QStringLiteral("sleep"), + "Screen Locker Backend", + "Ensuring that the screen gets locked before going to sleep", + QStringLiteral("delay")})); + QDBusPendingReply reply = QDBusConnection::systemBus().call(message); + if (!reply.isValid()) { + return; + } + reply.value().swap(m_inhibitFileDescriptor); +} + +void DbusUpperInterface::uninhibit() +{ + if (!m_inhibitFileDescriptor.isValid()) { + return; + } + + m_inhibitFileDescriptor = QDBusUnixFileDescriptor(); +} + +void DbusUpperInterface::IsPamInAuthentication(QJsonObject &reqObj, QJsonObject &retObj) +{ + Q_UNUSED(reqObj); + if (m_pamAuth) { + retObj["Content"] = m_pamAuth->inAuthentication(); + } else { + retObj["Content"] = false; + } +} + +void DbusUpperInterface::IsPamAuthenticated(QJsonObject &reqObj, QJsonObject &retObj) +{ + Q_UNUSED(reqObj); + if (m_pamAuth) { + retObj["Content"] = m_pamAuth->isAuthenticated(); + } else { + retObj["Content"] = false; + } +} + +void DbusUpperInterface::PamAuthenticationUser(QJsonObject &reqObj, QJsonObject &retObj) +{ + Q_UNUSED(reqObj); + if (m_pamAuth) { + retObj["Content"] = m_pamAuth->authenticationUser(); + } else { + retObj["Content"] = ""; + } +} + +int DbusUpperInterface::PamAuthenticateUser(const QJsonObject &objInfo) +{ + int nRet = -1; + QVariant varUserName = objInfo.value("UserName"); + if (varUserName.isValid() && m_pamAuth) { + m_pamAuth->authenticate(varUserName.toString()); + nRet = 0; + } + return nRet; +} + +int DbusUpperInterface::PamAuthenticateCancel(const QJsonObject &objInfo) +{ + Q_UNUSED(objInfo); + int nRet = -1; + if (m_pamAuth) { + m_pamAuth->cancelAuthentication(); + nRet = 0; + } + return 0; +} + +int DbusUpperInterface::PamRespond(const QJsonObject &objInfo) +{ + int nRet = -1; + QVariant varRespond = objInfo.value("Content"); + if (varRespond.isValid() && m_pamAuth) { + m_pamAuth->respond(varRespond.toString()); + nRet = 0; + } + return nRet; +} + +void DbusUpperInterface::onPamShowMessage(QString strMsg, int type) +{ + QJsonObject retObj; + retObj["CmdId"] = LOCK_CMD_ID_PAMAUTH_SHOWMESSAGE; + retObj["Message"] = strMsg; + retObj["MsgType"] = type; + SendUpdateInfoSig(QString(QJsonDocument(retObj).toJson())); +} + +void DbusUpperInterface::onPamShowPrompt(QString strPrompt, int type) +{ + QJsonObject retObj; + retObj["CmdId"] = LOCK_CMD_ID_PAMAUTH_SHOWPROMPT; + retObj["Prompt"] = strPrompt; + retObj["PromptType"] = type; + SendUpdateInfoSig(QString(QJsonDocument(retObj).toJson())); +} + +void DbusUpperInterface::onPamAuthCompleted() +{ + QJsonObject retObj; + retObj["CmdId"] = LOCK_CMD_ID_PAMAUTH_AUTH_COMPLETED; + SendUpdateInfoSig(QString(QJsonDocument(retObj).toJson())); +} + +void DbusUpperInterface::onBioAuthShowMessage(QString strMsg) +{ + QJsonObject retObj; + retObj["CmdId"] = LOCK_CMD_ID_BIOAUTH_SHOW_MESSAGE; + retObj["Message"] = strMsg; + SendUpdateInfoSig(QString(QJsonDocument(retObj).toJson())); +} + +void DbusUpperInterface::onBioAuthStateChanged(int nState) +{ + QJsonObject retObj; + retObj["CmdId"] = LOCK_CMD_ID_BIOAUTH_AUTHSTATE_CHANGED; + retObj["State"] = nState; + SendUpdateInfoSig(QString(QJsonDocument(retObj).toJson())); +} + +void DbusUpperInterface::onBioServiceStatusChanged(bool bValid) +{ + QJsonObject retObj; + retObj["CmdId"] = LOCK_CMD_ID_BIOAUTH_SERVICE_STATUS_CHANGED; + retObj["IsValid"] = bValid; + SendUpdateInfoSig(QString(QJsonDocument(retObj).toJson())); +} + +void DbusUpperInterface::onBioDeviceChanged() +{ + QJsonObject retObj; + retObj["CmdId"] = LOCK_CMD_ID_BIOAUTH_DEVICE_CHANGED; + SendUpdateInfoSig(QString(QJsonDocument(retObj).toJson())); +} + +void DbusUpperInterface::onBioAuthFrameData(QString strData) +{ + QJsonObject retObj; + retObj["CmdId"] = LOCK_CMD_ID_BIOAUTH_FRAME_DATA; + retObj["Data"] = strData; + SendUpdateInfoSig(QString(QJsonDocument(retObj).toJson())); +} + +void DbusUpperInterface::onBioAuthCompleted(int nUid, bool isSuccess, int nError, int nMaxFailedTime, int nFailedTime) +{ + QJsonObject retObj; + retObj["CmdId"] = LOCK_CMD_ID_BIOAUTH_COMPLETE; + retObj["UId"] = nUid; + retObj["IsSuccess"] = isSuccess; + retObj["ErrorNo"] = nError; + retObj["MaxFailedTime"] = nMaxFailedTime; + retObj["FailedTime"] = nFailedTime; + SendUpdateInfoSig(QString(QJsonDocument(retObj).toJson())); +} + +void DbusUpperInterface::BioGetAvailableDevices(QJsonObject &reqObj, QJsonObject &retObj) +{ + QVariant varUserId = reqObj.value("UserId"); + if (varUserId.isValid() && m_bioAuth) { + DeviceMap bioDevInfos = m_bioAuth->getAvailableDevices(varUserId.toInt()); + QJsonArray objArray; + DeviceMap::iterator itValidDev = bioDevInfos.begin(); + for (; itValidDev != bioDevInfos.end(); itValidDev++) { + QJsonObject objDevInfo; + objDevInfo["id"] = itValidDev.value()->id; + objDevInfo["ShortName"] = itValidDev.value()->shortName; + objDevInfo["FullName"] = itValidDev.value()->fullName; + objDevInfo["DriverEnable"] = itValidDev.value()->driverEnable; + objDevInfo["DeviceNum"] = itValidDev.value()->deviceNum; + objDevInfo["DeviceType"] = itValidDev.value()->deviceType; + objDevInfo["StorageType"] = itValidDev.value()->storageType; + objDevInfo["EigType"] = itValidDev.value()->eigType; + objDevInfo["VerifyType"] = itValidDev.value()->verifyType; + objDevInfo["IdentifyType"] = itValidDev.value()->identifyType; + objDevInfo["BusType"] = itValidDev.value()->busType; + objDevInfo["DeviceStatus"] = itValidDev.value()->deviceStatus; + objDevInfo["OpsStatus"] = itValidDev.value()->OpsStatus; + objArray.append(objDevInfo); + } + retObj["Content"] = objArray; + } else { + retObj["Content"] = QJsonArray(); + } +} + +void DbusUpperInterface::BioGetDisabledDevices(QJsonObject &reqObj, QJsonObject &retObj) +{ + QVariant varUserId = reqObj.value("UserId"); + if (varUserId.isValid() && m_bioAuth) { + QList disabledInfos = m_bioAuth->getDisabledDevices(varUserId.toInt()); + QJsonArray objArray; + for (auto devType : disabledInfos) { + objArray.append(devType); + } + retObj["Content"] = objArray; + } else { + retObj["Content"] = QJsonArray(); + } +} + +void DbusUpperInterface::BioGetBioAuthState(QJsonObject &reqObj, QJsonObject &retObj) +{ + Q_UNUSED(reqObj); + if (m_bioAuth) { + retObj["Content"] = m_bioAuth->getBioAuthState(); + } else { + retObj["Content"] = BIOAUTH_IDLE; + } +} + +void DbusUpperInterface::BioGetCurBioInfo(QJsonObject &reqObj, QJsonObject &retObj) +{ + Q_UNUSED(reqObj); + if (m_bioAuth) { + DeviceInfo bioDevInfo = m_bioAuth->getCurBioInfo(); + QJsonObject objDevInfo; + objDevInfo["id"] = bioDevInfo.id; + objDevInfo["ShortName"] = bioDevInfo.shortName; + objDevInfo["FullName"] = bioDevInfo.fullName; + objDevInfo["DriverEnable"] = bioDevInfo.driverEnable; + objDevInfo["DeviceNum"] = bioDevInfo.deviceNum; + objDevInfo["DeviceType"] = bioDevInfo.deviceType; + objDevInfo["StorageType"] = bioDevInfo.storageType; + objDevInfo["EigType"] = bioDevInfo.eigType; + objDevInfo["VerifyType"] = bioDevInfo.verifyType; + objDevInfo["IdentifyType"] = bioDevInfo.identifyType; + objDevInfo["BusType"] = bioDevInfo.busType; + objDevInfo["DeviceStatus"] = bioDevInfo.deviceStatus; + objDevInfo["OpsStatus"] = bioDevInfo.OpsStatus; + retObj["Content"] = objDevInfo; + } else { + retObj["Content"] = QJsonObject(); + } +} + +void DbusUpperInterface::BioGetDefaultDevice(QJsonObject &reqObj, QJsonObject &retObj) +{ + qDebug()<<"BioGetDefaultDevice:"<getDefaultDevice(varUserId.toInt(), varUserName.toString(), varDevType.toInt()); + } else { + retObj["Content"] = m_bioAuth->getDefaultDevice(varUserId.toInt(), varUserName.toString()); + } + } else { + retObj["Content"] = ""; + } +} + +void DbusUpperInterface::BioFindDeviceById(QJsonObject &reqObj, QJsonObject &retObj) +{ + QVariant varUserId = reqObj.value("UserId"); + QVariant varDevId = reqObj.value("DevId"); + if (varUserId.isValid() && varDevId.isValid() && m_bioAuth) { + DeviceInfoPtr ptrDevInfo = m_bioAuth->findDeviceById(varUserId.toInt(), varDevId.toInt()); + QJsonObject objDevInfo; + if (ptrDevInfo) { + objDevInfo["id"] = ptrDevInfo->id; + objDevInfo["ShortName"] = ptrDevInfo->shortName; + objDevInfo["FullName"] = ptrDevInfo->fullName; + objDevInfo["DriverEnable"] = ptrDevInfo->driverEnable; + objDevInfo["DeviceNum"] = ptrDevInfo->deviceNum; + objDevInfo["DeviceType"] = ptrDevInfo->deviceType; + objDevInfo["StorageType"] = ptrDevInfo->storageType; + objDevInfo["EigType"] = ptrDevInfo->eigType; + objDevInfo["VerifyType"] = ptrDevInfo->verifyType; + objDevInfo["IdentifyType"] = ptrDevInfo->identifyType; + objDevInfo["BusType"] = ptrDevInfo->busType; + objDevInfo["DeviceStatus"] = ptrDevInfo->deviceStatus; + objDevInfo["OpsStatus"] = ptrDevInfo->OpsStatus; + } + retObj["Content"] = objDevInfo; + } else { + retObj["Content"] = QJsonObject(); + } +} + +void DbusUpperInterface::BioFindDeviceByName(QJsonObject &reqObj, QJsonObject &retObj) +{ + QVariant varUserId = reqObj.value("UserId"); + QVariant varDevName = reqObj.value("DevName"); + if (varUserId.isValid() && varDevName.isValid() && m_bioAuth) { + DeviceInfoPtr ptrDevInfo = m_bioAuth->findDeviceByName(varUserId.toInt(), varDevName.toString()); + QJsonObject objDevInfo; + if (ptrDevInfo) { + objDevInfo["id"] = ptrDevInfo->id; + objDevInfo["ShortName"] = ptrDevInfo->shortName; + objDevInfo["FullName"] = ptrDevInfo->fullName; + objDevInfo["DriverEnable"] = ptrDevInfo->driverEnable; + objDevInfo["DeviceNum"] = ptrDevInfo->deviceNum; + objDevInfo["DeviceType"] = ptrDevInfo->deviceType; + objDevInfo["StorageType"] = ptrDevInfo->storageType; + objDevInfo["EigType"] = ptrDevInfo->eigType; + objDevInfo["VerifyType"] = ptrDevInfo->verifyType; + objDevInfo["IdentifyType"] = ptrDevInfo->identifyType; + objDevInfo["BusType"] = ptrDevInfo->busType; + objDevInfo["DeviceStatus"] = ptrDevInfo->deviceStatus; + objDevInfo["OpsStatus"] = ptrDevInfo->OpsStatus; + } + retObj["Content"] = objDevInfo; + } else { + retObj["Content"] = QJsonObject(); + } +} + +int DbusUpperInterface::BioStartAuth(const QJsonObject &objInfo) +{ + int nRet = -1; + QVariant varUserId = objInfo.value("UserId"); + QVariant varDevId = objInfo.value("DevId"); + if (varUserId.isValid() && varDevId.isValid() && m_bioAuth) { + m_bioAuth->startAuth(varUserId.toInt(), varDevId.toInt()); + nRet = 0; + } + return nRet; +} + +int DbusUpperInterface::BioStopAuth(const QJsonObject &objInfo) +{ + Q_UNUSED(objInfo); + int nRet = -1; + if (m_bioAuth) { + m_bioAuth->stopAuth(); + nRet = 0; + } + return nRet; +} + +void DbusUpperInterface::getUsdMediaKeys(QJsonObject &reqObj, QJsonObject &retObj) +{ + QString strKey = reqObj.value("Key").toString(); + if (!strKey.isEmpty()) { + QVariant value = m_gsettingsHelper->GetUsdMediaKeys(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!!"; +} + +bool DbusUpperInterface::usdExternalDoAction(const QJsonObject &objInfo) +{ + int nRet = -1; + int actionType = objInfo.value("Content").toInt(); + if (m_usdHelper->usdExternalDoAction(actionType)) { + nRet = 0; + } + return nRet; +} + +bool DbusUpperInterface::blockShortcut(const QJsonObject &objInfo) +{ + int nRet = -1; + bool isBlock = objInfo.value("Content").toBool(); + if (m_kglobalHelper->blockShortcut(isBlock)) { + nRet = 0; + } + return nRet; +} + +bool DbusUpperInterface::lockStateChanged(const QJsonObject &objInfo) +{ + int nRet = -1; + lockState = objInfo.value("Content").toBool(); + return lockState; +} + +int DbusUpperInterface::SetPowerManager(const QJsonObject &objInfo) +{ + int nRet = -1; + QString strFuncName = objInfo.value("Content").toString(); + if (!strFuncName.isEmpty()) { + qWarning() << __LINE__ << __FUNCTION__ << strFuncName; + if (m_login1Helper) + m_login1Helper->setPowerManager(strFuncName); + nRet = 0; + } + + return nRet; +} diff --git a/src/lock-backend/dbusupperinterface.h b/src/lock-backend/dbusupperinterface.h new file mode 100644 index 0000000..5ce303e --- /dev/null +++ b/src/lock-backend/dbusupperinterface.h @@ -0,0 +1,386 @@ +/* + * Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * +**/ +#ifndef DBUSUPPERINTERFACE_H +#define DBUSUPPERINTERFACE_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include "utils.h" + +class LightDMHelper; +class Login1Helper; +class GSettingsHelper; +class Configuration; +class QJsonObject; +class PamAuthenticate; +class UsdHelper; +class UpowerHelper; +class AccountServiceHelper; +class SessionHelper; +class SessionWatcher; +class BioAuthenticate; +class KglobalAccelHelper; +/** + * @brief dbus服务接口实现类 + * + */ +class DbusUpperInterface : public QObject, protected QDBusContext +{ + Q_OBJECT + Q_CLASSINFO("D-Bus Interface", SS_DBUS_SERVICE) +public: + enum { + SESSION_STATUS_SCREENSAVER = 1, // 屏保 + SESSION_STATUS_SCREENCLOSE = 2, // 关屏 + SESSION_STATUS_SLEEPED = 4, // 休眠/睡眠 + }; + /** + * @brief 构造 + * + * @param parent 父指针 + */ + explicit DbusUpperInterface(QObject *parent = nullptr); + +public: + bool checkScreenDialogRunning(); + void emitLockState(bool val); + void LockStartupMode(); + /** + * @brief 获取黑色屏保状态(沿用) + * + * @return bool true 是,false 否 + */ + bool GetBlankState(); + /** + * @brief 获取锁屏状态 + * + * @return bool true 锁定,false 未锁定 + */ + bool GetLockState(); + /** + * @brief 锁屏 + * + */ + void Lock(); + /** + * @brief 解锁 + * + */ + void UnLock(); + /** + * @brief 以黑色屏保方式锁屏 + * + * @param int 锁定方式 0 延时关屏、1 合盖、2 低电量 + * @return bool 是否执行 true 已执行,false 未执行 + */ + bool LockByBlank(int); + /** + * @brief 设置锁定状态 + * + */ + void SetLockState(); + /** + * @brief 显示屏保 + * + */ + void ShowScreensaver(); + /** + * @brief 获取信息 + * + * @param strJson 需要获取的信息json + * @return QString 获取到的信息json + */ + QString GetInformation(QString strJson); + /** + * @brief 设置信息 + * + * @param strJson 需要设置的信息json + * @return int 设置结果,0 成功,否则 失败 + */ + int SetInformation(QString strJson); + +public Q_SLOTS: + /** + * @brief 服务退出 + * + * @param serviceName 服务名称 + */ + void onNameLost(const QString &serviceName); + /** + * @brief 用户信息改变 + * + */ + void onUsersInfoChanged(); + /** + * @brief 请求锁定 + * + */ + void onLogin1ReqLock(); + /** + * @brief 请求解锁 + * + */ + void onLogin1ReqUnLock(); + /** + * @brief 系统准备休眠/唤醒 + * + * @param isSleep true 休眠,否则唤醒 + */ + void onLogin1PrepareForSleep(bool isSleep); + /** + * @brief 用户会话活跃状态改变 + * + * @param isActive true 活跃,否则不活跃 + */ + void onLogin1SessionActiveChanged(bool isActive); + /** + * @brief 程序阻塞关机/睡眠状态改变 + * + * @param lidState 阻塞类型 + */ + void onLidStateChanged(QString lidState); + + void onBatteryStatusChanged(QString iconName); + + void onBatteryChanged(QStringList batteryArgs); + + void onLockScreenConfigChanged(QString strKey, QVariant value); + void onScreenSaverConfigChanged(QString strKey, QVariant value); + void onPowerManagerConfigChanged(QString strKey, QVariant value); + void onMateBgConfigChanged(QString strKey, QVariant value); + void onUkccPluginsConfigChanged(QString strKey, QVariant value); + void onThemeStyleConfigChanged(QString strKey, QVariant value); + void onSessionConfigChanged(QString strKey, QVariant value); + void onKeyboardConfigChanged(QString strKey, QVariant value); + + void onCurrentSessionChanged(QString strSession); + void onPamShowMessage(QString strMsg, int type); + void onPamShowPrompt(QString strPrompt, int type); + void onPamAuthCompleted(); + + void onUsdMediaKeysConfigChanged(QString strKey, QVariant value); + + // 空闲锁屏 + void onSessionIdleReceived(); + void onSessionIdleExit(); + void stopDelayLockScreen(); + + void onBioAuthShowMessage(QString strMsg); + void onBioAuthStateChanged(int nState); + void onBioServiceStatusChanged(bool bValid); + void onBioDeviceChanged(); + void onBioAuthFrameData(QString strData); + void onBioAuthCompleted(int nUid, bool isSuccess, int nError, int nMaxFailedTime, int nFailedTime); + +private Q_SLOTS: + void onLockDialogProcExit(int exitCode, QProcess::ExitStatus exitStatus); + +Q_SIGNALS: + /** + * @brief 信息更新 + * + * @param info 信息内容json + */ + void UpdateInformation(const QString &info); + +private: + /** + * @brief 生成用户信息json数组 + * + * @return QJsonArray 信息数组 + */ + QJsonArray GenerateUserInfoList(); + + QString GetDefaultAuthUser(); + + QString GetCurrentUser(); + + int SetCurrentUser(const QJsonObject &objInfo); + + QJsonArray GenerateSessionInfoList(); + + QString GetCurrentSession(); + + int SetCurrentSession(const QJsonObject &objInfo); + + int StartSession(const QJsonObject &objInfo); + + /** + * @brief 生成开机特别提示json字段 + * + * @return QJsonObject 信息数组 + */ + QJsonObject GenerateAgreementInfo(); + + void GetScreenSaverConf(QJsonObject &reqObj, QJsonObject &retObj); + + int SetScreenSaverConf(const QJsonObject &objInfo); + + void GetLockScreenConf(QJsonObject &reqObj, QJsonObject &retObj); + + int SetLockScreenConf(const QJsonObject &objInfo); + + void GetPowerManagerConf(QJsonObject &reqObj, QJsonObject &retObj); + + int SetPowerManagerConf(const QJsonObject &objInfo); + + void GetMateBgConf(QJsonObject &reqObj, QJsonObject &retObj); + + int SetMateBgConf(const QJsonObject &objInfo); + + void GetUkccPluginsConf(QJsonObject &reqObj, QJsonObject &retObj); + + int SetUkccPluginsConf(const QJsonObject &objInfo); + + void GetThemeStyleConf(QJsonObject &reqObj, QJsonObject &retObj); + + int SetThemeStyleConf(const QJsonObject &objInfo); + + void GetSessionConf(QJsonObject &reqObj, QJsonObject &retObj); + + int SetSessionConf(const QJsonObject &objInfo); + + void GetKeyboardConf(QJsonObject &reqObj, QJsonObject &retObj); + + int SetKeyboardConf(const QJsonObject &objInfo); + + void inhibit(); + + void uninhibit(); + + bool checkStatus(int nStatus); + + bool GetSlpState(); + + void onShowBlankScreensaver(); + + void IsPamInAuthentication(QJsonObject &reqObj, QJsonObject &retObj); + + void IsPamAuthenticated(QJsonObject &reqObj, QJsonObject &retObj); + + void PamAuthenticationUser(QJsonObject &reqObj, QJsonObject &retObj); + + int PamAuthenticateUser(const QJsonObject &objInfo); + + int PamAuthenticateCancel(const QJsonObject &objInfo); + + int PamRespond(const QJsonObject &objInfo); + + void getUsdMediaKeys(QJsonObject &reqObj, QJsonObject &retObj); + + bool usdExternalDoAction(const QJsonObject &objInfo); + + bool blockShortcut(const QJsonObject &objInfo); + + int SetPowerManager(const QJsonObject &objInfo); + + bool lockStateChanged(const QJsonObject &objInfo); + + void GetCanPowerManager(QJsonObject &reqObj, QJsonObject &retObj); + + QJsonArray GenerateBatteryArgsList(); + + QString getBatteryIconName(); + + bool getIsBattery(); + + QJsonArray getSleepLockCheck(); + + QJsonArray getShutdownLockcheck(); + + QJsonArray getSaverTheme(); + + /** + * @brief delayLockScreen 延迟锁屏 + */ + void delayLockScreen(); + + /** + * @brief onLockScreenTimeout 延迟锁屏处理过程 + */ + void onLockScreenTimeout(); + + void BioGetAvailableDevices(QJsonObject &reqObj, QJsonObject &retObj); + + void BioGetDisabledDevices(QJsonObject &reqObj, QJsonObject &retObj); + + void BioGetBioAuthState(QJsonObject &reqObj, QJsonObject &retObj); + + void BioGetCurBioInfo(QJsonObject &reqObj, QJsonObject &retObj); + + void BioGetDefaultDevice(QJsonObject &reqObj, QJsonObject &retObj); + + void BioFindDeviceById(QJsonObject &reqObj, QJsonObject &retObj); + + void BioFindDeviceByName(QJsonObject &reqObj, QJsonObject &retObj); + + int BioStartAuth(const QJsonObject &objInfo); + + int BioStopAuth(const QJsonObject &objInfo); + + +private: + /** + * @brief 初始化数据 + * + */ + void initData(); + /** + * @brief 初始化连接 + * + */ + void initConnections(); + /** + * @brief SendUpdateInfoSig 发送更新信息信号 + * @param strJson 信息内容json + * @return true 发送成功,否则失败 + */ + bool SendUpdateInfoSig(QString strJson); + +private: + LightDMHelper* m_lightDmHelper = nullptr; /**< lightdm工具实例 */ + Login1Helper* m_login1Helper = nullptr; /**< login1工具实例 */ + Configuration *m_config = nullptr; + GSettingsHelper *m_gsettingsHelper = nullptr; + QProcess m_procLockDialog; + bool m_bLockState; + bool m_bBlankState = false; + bool m_bSlpState; + int m_nStatus = 0; // 当前状态 + QTimer *m_timer = nullptr; // check lockdialog is show + int m_timerCount = 0; + QTimer *m_timerLock = nullptr; + QDBusUnixFileDescriptor m_inhibitFileDescriptor; + PamAuthenticate *m_pamAuth = nullptr; + UsdHelper *m_usdHelper = nullptr; + UpowerHelper *m_upowerHelper = nullptr; + AccountServiceHelper *m_accountsHelper = nullptr; + bool lockState = false; + SessionHelper *m_sessionHelper = nullptr; + SessionWatcher *m_sessionWatcher = nullptr; + BioAuthenticate *m_bioAuth = nullptr; + KglobalAccelHelper *m_kglobalHelper = nullptr; +}; + +#endif // DBUSUPPERINTERFACE_H diff --git a/src/lock-backend/gsettingshelper.cpp b/src/lock-backend/gsettingshelper.cpp new file mode 100644 index 0000000..0dc164a --- /dev/null +++ b/src/lock-backend/gsettingshelper.cpp @@ -0,0 +1,712 @@ +/* + * Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * +**/ +#include "gsettingshelper.h" +#include +#include "definetypes.h" + +GSettingsHelper::GSettingsHelper(QObject *parent) + : QObject(parent) +{ +} + +GSettingsHelper::~GSettingsHelper() +{ + +} + +bool GSettingsHelper::initLockScreen() +{ + if (!m_gsLockScreen) { + if(QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA_SCREENSAVER)) { + m_gsLockScreen = new QGSettings(GSETTINGS_SCHEMA_SCREENSAVER, "", this); + connect(m_gsLockScreen, &QGSettings::changed, + this, &GSettingsHelper::onLockScreenConfigChanged); + QStringList keys = m_gsLockScreen->keys(); + if (keys.contains(KEY_IDLE_DELAY)) { + m_nIdleDelay = m_gsLockScreen->get(KEY_IDLE_DELAY).toInt(); + } + if (keys.contains(KEY_IDLE_LOCK)) { + m_nIdleLock = m_gsLockScreen->get(KEY_IDLE_LOCK).toInt(); + } + if (keys.contains(KEY_IDLE_ACTIVATION_ENABLED)) { + m_bIdleActivationEnable = m_gsLockScreen->get(KEY_IDLE_ACTIVATION_ENABLED).toBool(); + } + if (keys.contains(KEY_IDLE_LOCK_ENABLED)) { + m_bIdleLockEnable = m_gsLockScreen->get(KEY_IDLE_LOCK_ENABLED).toBool(); + } + if (keys.contains(KEY_LOCK_TIMEOUT)) { + m_nLockTimeout = m_gsLockScreen->get(KEY_LOCK_TIMEOUT).toInt(); + } + if (keys.contains(KEY_CLOSE_ACTIVATION_ENABLED)) { + m_bCloseActivationEnable = m_gsLockScreen->get(KEY_CLOSE_ACTIVATION_ENABLED).toBool(); + } + if (keys.contains(KEY_SLEEP_ACTIVATION_ENABLED)) { + m_bSleepActivationEnable = m_gsLockScreen->get(KEY_SLEEP_ACTIVATION_ENABLED).toBool(); + } + if (keys.contains(KEY_LOCK_ENABLED)) { + m_bLockEnable = m_gsLockScreen->get(KEY_LOCK_ENABLED).toBool(); + } + if (keys.contains(KEY_BACKGROUND)) { + m_strBackground = m_gsLockScreen->get(KEY_BACKGROUND).toString(); + } + if (keys.contains(KEY_MODE)) { + m_saverMode = m_gsLockScreen->get(KEY_MODE).toString(); + } + if (keys.contains(KEY_THEMES)) { + m_saverTheme = m_gsLockScreen->get(KEY_THEMES).toStringList(); + } + if (keys.contains(KEY_IMAGE_TRANSITION_EFFECT)) { + m_imageTSEffect = m_gsLockScreen->get(KEY_IMAGE_TRANSITION_EFFECT).toInt(); + } + if (keys.contains(KEY_IMAGE_SWITCH_INTERVAL)) { + m_imageSwitchInterval = m_gsLockScreen->get(KEY_IMAGE_SWITCH_INTERVAL).toInt(); + } + } + } + return (bool)(m_gsLockScreen); +} + +bool GSettingsHelper::initScreenSaver() +{ + if (!m_gsScreenSaver) { + if(QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA_SCREENSAVER_DEFAULT)) { + m_gsScreenSaver = new QGSettings(GSETTINGS_SCHEMA_SCREENSAVER_DEFAULT, "", this); + connect(m_gsScreenSaver, &QGSettings::changed, + this, &GSettingsHelper::onScreenSaverConfigChanged); + QStringList keys = m_gsScreenSaver->keys(); + if (keys.contains(KEY_SHOW_REST_TIME)) { + m_bShowRestTime = m_gsScreenSaver->get(KEY_SHOW_REST_TIME).toBool(); + } + if (keys.contains(KEY_SHOW_CUSTOM_REST_TIME)) { + m_bShowCustomRestTime = m_gsScreenSaver->get(KEY_SHOW_CUSTOM_REST_TIME).toBool(); + } + if (keys.contains(KEY_SHOW_UKUI_REST_TIME)) { + m_bShowUkuiRestTime = m_gsScreenSaver->get(KEY_SHOW_UKUI_REST_TIME).toBool(); + } + if (keys.contains(KEY_CYCLE_TIME)) { + m_nCycleTime = m_gsScreenSaver->get(KEY_CYCLE_TIME).toInt(); + } + if (keys.contains(KEY_AUTOMATIC_SWITCHING_ENABLE)) { + m_bAutomaticSwitchingEnable = m_gsScreenSaver->get(KEY_AUTOMATIC_SWITCHING_ENABLE).toBool(); + } + if (keys.contains(KEY_BACKGROUND_PATH)) { + m_strBackgroundPath = m_gsScreenSaver->get(KEY_BACKGROUND_PATH).toString(); + } + if (keys.contains(KEY_MYTEXT)) { + m_strMyText = m_gsScreenSaver->get(KEY_MYTEXT).toString(); + } + if (keys.contains(KEY_TEXT_IS_CENTER)) { + m_bTextIsCenter = m_gsScreenSaver->get(KEY_TEXT_IS_CENTER).toBool(); + } + if (keys.contains(KEY_SHOW_MESSAGE_ENABLED)) { + m_bShowMessageEnable = m_gsScreenSaver->get(KEY_SHOW_MESSAGE_ENABLED).toBool(); + } + if (keys.contains(KEY_MESSAGE_NUMBER)) { + m_nMessageNum = m_gsScreenSaver->get(KEY_MESSAGE_NUMBER).toInt(); + } + if (keys.contains(KEY_VIDEO_FORMAT)) { + m_strVideoFormat = m_gsScreenSaver->get(KEY_VIDEO_FORMAT).toString(); + } + if (keys.contains(KEY_VIDEO_PATH)) { + m_strVideoPath = m_gsScreenSaver->get(KEY_VIDEO_PATH).toString(); + } + if (keys.contains(KEY_VIDEO_SIZE)) { + m_nVideoSize = m_gsScreenSaver->get(KEY_VIDEO_SIZE).toInt(); + } + if (keys.contains(KEY_VIDEO_WIDTH)) { + m_nVideoWidth = m_gsScreenSaver->get(KEY_VIDEO_WIDTH).toInt(); + } + if (keys.contains(KEY_VIDEO_HEIGHT)) { + m_nVideoHeight = m_gsScreenSaver->get(KEY_VIDEO_HEIGHT).toInt(); + } + } + } + return (bool)(m_gsScreenSaver); +} + +bool GSettingsHelper::initPowerManager() +{ + if (!m_gsPowerManager) { + if(QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA_POWER_MANAGER)) { + m_gsPowerManager = new QGSettings(GSETTINGS_SCHEMA_POWER_MANAGER, "", this); + connect(m_gsPowerManager, &QGSettings::changed, + this, &GSettingsHelper::onPowerManagerConfigChanged); + QStringList keys = m_gsPowerManager->keys(); + if (keys.contains(KEY_LOCK_SUSPEND)) { + m_bLockSuspend = m_gsPowerManager->get(KEY_LOCK_SUSPEND).toBool(); + } + if (keys.contains(KEY_LOCK_HIBERNATE)) { + m_bLockHibernate = m_gsPowerManager->get(KEY_LOCK_HIBERNATE).toBool(); + } + if (keys.contains(KEY_LOCK_BLANKSCREEN)) { + m_bLockBlankScreen = m_gsPowerManager->get(KEY_LOCK_BLANKSCREEN).toBool(); + } + if (keys.contains(KEY_SLEEP_COMPUTER_AC)) { + m_nSleepComputeAc = m_gsPowerManager->get(KEY_SLEEP_COMPUTER_AC).toInt(); + } + if (keys.contains(KEY_SLEEP_DISPLAY_AC)) { + m_nSleepDisplayAc = m_gsPowerManager->get(KEY_SLEEP_DISPLAY_AC).toInt(); + } + if (keys.contains(KEY_BUTTON_LID_AC)) { + m_strButtonLidAc = m_gsPowerManager->get(KEY_BUTTON_LID_AC).toString(); + } + } + } + return (bool)(m_gsPowerManager); +} + +bool GSettingsHelper::initMateBg() +{ + if (!m_gsMateBg) { + if(QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA_MATE_BG)) { + m_gsMateBg = new QGSettings(GSETTINGS_SCHEMA_MATE_BG, "", this); + connect(m_gsMateBg, &QGSettings::changed, + this, &GSettingsHelper::onMateBgConfigChanged); + QStringList keys = m_gsMateBg->keys(); + if (keys.contains(KEY_PICTURE_FILENAME)) { + m_strPicFileName = m_gsMateBg->get(KEY_PICTURE_FILENAME).toBool(); + } + if (keys.contains(KEY_PICTURE_OPTIONS)) { + m_strPicOptions = m_gsMateBg->get(KEY_PICTURE_OPTIONS).toBool(); + } + if (keys.contains(KEY_PRIMARY_COLOR)) { + m_strPrimaryColor = m_gsMateBg->get(KEY_PRIMARY_COLOR).toBool(); + } + } + } + return (bool)(m_gsMateBg); +} + +bool GSettingsHelper::initUkccPlugins() +{ + if (!m_gsUkccPlugins) { + if(QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA_TIME_TYPE)) { + m_gsUkccPlugins = new QGSettings(GSETTINGS_SCHEMA_TIME_TYPE, "", this); + connect(m_gsUkccPlugins, &QGSettings::changed, + this, &GSettingsHelper::onUkccPluginsConfigChanged); + QStringList keys = m_gsUkccPlugins->keys(); + if (keys.contains(KEY_HOUR_SYSTEM)) { + m_nHourSystem = m_gsUkccPlugins->get(KEY_HOUR_SYSTEM).toInt(); + } + if (keys.contains(KEY_DATE)) { + m_strDateType = m_gsUkccPlugins->get(KEY_DATE).toString(); + } + } + } + return (bool)(m_gsUkccPlugins); +} + +bool GSettingsHelper::initThemeStyle() +{ + if (!m_gsThemeStyle) { + if(QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA_STYLE)) { + m_gsThemeStyle = new QGSettings(GSETTINGS_SCHEMA_STYLE, "", this); + connect(m_gsThemeStyle, &QGSettings::changed, + this, &GSettingsHelper::onThemeStyleConfigChanged); + QStringList keys = m_gsThemeStyle->keys(); + if (keys.contains(KEY_SYSTEM_FONT_SIZE)) { + m_lfFontSize = m_gsThemeStyle->get(KEY_SYSTEM_FONT_SIZE).toDouble(); + } + if (keys.contains(KEY_THEME_COLOR)) { + m_strThemeColor = m_gsThemeStyle->get(KEY_THEME_COLOR).toString(); + } + } + } + return (bool)(m_gsThemeStyle); +} + +bool GSettingsHelper::initSession() +{ + if (!m_gsSession) { + if(QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA_SESSION)) { + m_gsSession = new QGSettings(GSETTINGS_SCHEMA_SESSION, "", this); + connect(m_gsSession, &QGSettings::changed, + this, &GSettingsHelper::onSessionConfigChanged); + QStringList keys = m_gsSession->keys(); + if (keys.contains(KEY_SESSION_IDLE)) { + m_nSessionIdle = m_gsSession->get(KEY_SESSION_IDLE).toInt(); + } + } + } + return (bool)(m_gsSession); +} + +bool GSettingsHelper::initKeyboard() +{ + if (!m_gsKeyboard) { + if(QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA_PERIPHERALS_KEYBOARD)) { + m_gsKeyboard = new QGSettings(GSETTINGS_SCHEMA_PERIPHERALS_KEYBOARD, "", this); + connect(m_gsKeyboard, &QGSettings::changed, + this, &GSettingsHelper::onKeyboardConfigChanged); + QStringList keys = m_gsKeyboard->keys(); + if (keys.contains(KEY_CAPSLOCK_STATUS)) { + m_capsState = m_gsKeyboard->get(KEY_CAPSLOCK_STATUS).toBool(); + } + } + } + return (bool)(m_gsKeyboard); +} + +bool GSettingsHelper::initUsdMediaKeys() +{ + if (!m_gsUsdMediaKeys) { + if(QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA_MEDIAKEY_SCHEMA)) { + m_gsUsdMediaKeys = new QGSettings(GSETTINGS_SCHEMA_MEDIAKEY_SCHEMA, "", this); + connect(m_gsUsdMediaKeys, &QGSettings::changed, + this, &GSettingsHelper::onUsdMediaKeysConfigChanged); + QStringList keys = m_gsUsdMediaKeys->keys(); + if (keys.contains(KEY_AREA_SCREENSHOT)) { + m_areaScreenShot = m_gsUsdMediaKeys->get(KEY_AREA_SCREENSHOT).toString(); + } + if (keys.contains(KEY_AREA_SCREENSHOT2)) { + m_areaScreenShot2 = m_gsUsdMediaKeys->get(KEY_AREA_SCREENSHOT2).toString(); + } else if (keys.contains(KEY_SCREEN_SHOT)) { + m_screenShot = m_gsUsdMediaKeys->get(KEY_SCREEN_SHOT).toString(); + } else if (keys.contains(KEY_SCREEN_SHOT2)) { + m_screenShot2 = m_gsUsdMediaKeys->get(KEY_SCREEN_SHOT2).toString(); + } else if (keys.contains(KEY_WINDOW_SCREENSHOT)) { + m_windowScreenshot = m_gsUsdMediaKeys->get(KEY_WINDOW_SCREENSHOT).toString(); + } + } + } + return (bool)(m_gsUsdMediaKeys); +} + +void GSettingsHelper::onLockScreenConfigChanged(QString strKey) +{ + QVariant varValue; + if (strKey == KEY_IDLE_DELAY) { + varValue = m_nIdleDelay = m_gsLockScreen->get(KEY_IDLE_DELAY).toInt(); + } else if (strKey == KEY_IDLE_LOCK) { + varValue = m_nIdleLock = m_gsLockScreen->get(KEY_IDLE_LOCK).toInt(); + } else if (strKey == KEY_IDLE_ACTIVATION_ENABLED) { + varValue = m_bIdleActivationEnable = m_gsLockScreen->get(KEY_IDLE_ACTIVATION_ENABLED).toBool(); + } else if (strKey == KEY_IDLE_LOCK_ENABLED) { + varValue = m_bIdleLockEnable = m_gsLockScreen->get(KEY_IDLE_LOCK_ENABLED).toBool(); + } else if (strKey == KEY_LOCK_TIMEOUT) { + varValue = m_nLockTimeout = m_gsLockScreen->get(KEY_LOCK_TIMEOUT).toInt(); + } else if (strKey == KEY_CLOSE_ACTIVATION_ENABLED) { + varValue = m_bCloseActivationEnable = m_gsLockScreen->get(KEY_CLOSE_ACTIVATION_ENABLED).toBool(); + } else if (strKey == KEY_SLEEP_ACTIVATION_ENABLED) { + varValue = m_bSleepActivationEnable = m_gsLockScreen->get(KEY_SLEEP_ACTIVATION_ENABLED).toBool(); + } else if (strKey == KEY_LOCK_ENABLED) { + varValue = m_bLockEnable = m_gsLockScreen->get(KEY_LOCK_ENABLED).toBool(); + } else if (strKey == KEY_BACKGROUND) { + varValue = m_strBackground = m_gsLockScreen->get(KEY_BACKGROUND).toBool(); + } else if (strKey == KEY_MODE) { + varValue = m_saverMode = m_gsLockScreen->get(KEY_MODE).toString(); + } else if (strKey == KEY_THEMES) { + varValue = m_saverTheme = m_gsLockScreen->get(KEY_THEMES).toStringList(); + } else if (strKey == KEY_IMAGE_TRANSITION_EFFECT) { + varValue = m_imageTSEffect = m_gsLockScreen->get(KEY_IMAGE_TRANSITION_EFFECT).toInt(); + } else if (strKey == KEY_IMAGE_SWITCH_INTERVAL) { + varValue = m_imageSwitchInterval = m_gsLockScreen->get(KEY_IMAGE_SWITCH_INTERVAL).toInt(); + } + Q_EMIT lockScreenConfigChanged(strKey, varValue); +} + +void GSettingsHelper::onScreenSaverConfigChanged(QString strKey) +{ + QVariant varValue; + if (strKey == KEY_SHOW_REST_TIME) { + varValue = m_bShowRestTime = m_gsScreenSaver->get(KEY_SHOW_REST_TIME).toBool(); + } else if (strKey == KEY_SHOW_CUSTOM_REST_TIME) { + varValue = m_bShowCustomRestTime = m_gsScreenSaver->get(KEY_SHOW_CUSTOM_REST_TIME).toBool(); + } else if (strKey == KEY_SHOW_UKUI_REST_TIME) { + varValue = m_bShowUkuiRestTime = m_gsScreenSaver->get(KEY_SHOW_UKUI_REST_TIME).toBool(); + } else if (strKey == KEY_CYCLE_TIME) { + varValue = m_nCycleTime = m_gsScreenSaver->get(KEY_CYCLE_TIME).toInt(); + } else if (strKey == KEY_AUTOMATIC_SWITCHING_ENABLE) { + varValue = m_bAutomaticSwitchingEnable = m_gsScreenSaver->get(KEY_AUTOMATIC_SWITCHING_ENABLE).toBool(); + } else if (strKey == KEY_BACKGROUND_PATH) { + varValue = m_strBackgroundPath = m_gsScreenSaver->get(KEY_BACKGROUND_PATH).toString(); + } else if (strKey == KEY_MYTEXT) { + varValue = m_strMyText = m_gsScreenSaver->get(KEY_MYTEXT).toString(); + } else if (strKey == KEY_TEXT_IS_CENTER) { + varValue = m_bTextIsCenter = m_gsScreenSaver->get(KEY_TEXT_IS_CENTER).toBool(); + } else if (strKey == KEY_SHOW_MESSAGE_ENABLED) { + varValue = m_bShowMessageEnable = m_gsScreenSaver->get(KEY_SHOW_MESSAGE_ENABLED).toBool(); + } else if (strKey == KEY_MESSAGE_NUMBER) { + varValue = m_nMessageNum = m_gsScreenSaver->get(KEY_MESSAGE_NUMBER).toInt(); + } else if (strKey == KEY_VIDEO_FORMAT) { + varValue = m_strVideoFormat = m_gsScreenSaver->get(KEY_VIDEO_FORMAT).toString(); + } else if (strKey == KEY_VIDEO_PATH) { + varValue = m_strVideoPath = m_gsScreenSaver->get(KEY_VIDEO_PATH).toString(); + } else if (strKey == KEY_VIDEO_SIZE) { + varValue = m_nVideoSize = m_gsScreenSaver->get(KEY_VIDEO_SIZE).toInt(); + } else if (strKey == KEY_VIDEO_WIDTH) { + varValue = m_nVideoWidth = m_gsScreenSaver->get(KEY_VIDEO_WIDTH).toInt(); + } else if (strKey == KEY_VIDEO_HEIGHT) { + varValue = m_nVideoHeight = m_gsScreenSaver->get(KEY_VIDEO_HEIGHT).toInt(); + } + Q_EMIT screenSaverConfigChanged(strKey, varValue); +} + +void GSettingsHelper::onPowerManagerConfigChanged(QString strKey) +{ + QVariant varValue; + if (strKey == KEY_LOCK_SUSPEND) { + varValue = m_bLockSuspend = m_gsPowerManager->get(KEY_LOCK_SUSPEND).toInt(); + } else if (strKey == KEY_LOCK_HIBERNATE) { + varValue = m_bLockHibernate = m_gsPowerManager->get(KEY_LOCK_HIBERNATE).toInt(); + } else if (strKey == KEY_LOCK_BLANKSCREEN) { + varValue = m_bLockBlankScreen = m_gsPowerManager->get(KEY_LOCK_BLANKSCREEN).toBool(); + } else if (strKey == KEY_SLEEP_COMPUTER_AC) { + varValue = m_nSleepComputeAc = m_gsPowerManager->get(KEY_SLEEP_COMPUTER_AC).toBool(); + } else if (strKey == KEY_SLEEP_DISPLAY_AC) { + varValue = m_nSleepDisplayAc = m_gsPowerManager->get(KEY_SLEEP_DISPLAY_AC).toInt(); + } else if (strKey == KEY_BUTTON_LID_AC) { + varValue = m_strButtonLidAc = m_gsPowerManager->get(KEY_BUTTON_LID_AC).toBool(); + } + Q_EMIT powerManagerConfigChanged(strKey, varValue); +} + +void GSettingsHelper::onMateBgConfigChanged(QString strKey) +{ + QVariant varValue; + if (strKey == KEY_PICTURE_FILENAME) { + varValue = m_strPicFileName = m_gsPowerManager->get(KEY_PICTURE_FILENAME).toInt(); + } else if (strKey == KEY_PICTURE_OPTIONS) { + varValue = m_strPicOptions = m_gsPowerManager->get(KEY_PICTURE_OPTIONS).toInt(); + } else if (strKey == KEY_PRIMARY_COLOR) { + varValue = m_strPrimaryColor = m_gsPowerManager->get(KEY_PRIMARY_COLOR).toBool(); + } + Q_EMIT mateBgConfigChanged(strKey, varValue); +} + +void GSettingsHelper::onUkccPluginsConfigChanged(QString strKey) +{ + QVariant varValue; + if (strKey == KEY_HOUR_SYSTEM) { + varValue = m_nHourSystem = m_gsUkccPlugins->get(KEY_HOUR_SYSTEM).toInt(); + } else if (strKey == KEY_DATE) { + varValue = m_strDateType = m_gsUkccPlugins->get(KEY_DATE).toString(); + } + Q_EMIT ukccPluginsConfigChanged(strKey, varValue); +} + +void GSettingsHelper::onThemeStyleConfigChanged(QString strKey) +{ + QVariant varValue; + if (strKey == KEY_SYSTEM_FONT_SIZE) { + varValue = m_lfFontSize = m_gsThemeStyle->get(KEY_SYSTEM_FONT_SIZE).toDouble(); + } else if (strKey == KEY_THEME_COLOR) { + varValue = m_strThemeColor = m_gsThemeStyle->get(KEY_THEME_COLOR).toString(); + } + Q_EMIT themeStyleConfigChanged(strKey, varValue); +} + +void GSettingsHelper::onSessionConfigChanged(QString strKey) +{ + QVariant varValue; + if (strKey == KEY_SESSION_IDLE) { + varValue = m_nSessionIdle = m_gsSession->get(KEY_SESSION_IDLE).toInt(); + } + Q_EMIT sessionConfigChanged(strKey, varValue); +} + +void GSettingsHelper::onKeyboardConfigChanged(QString strKey) +{ + QVariant varValue; + if (strKey == KEY_CAPSLOCK_STATUS) { + varValue = m_capsState = m_gsKeyboard->get(KEY_CAPSLOCK_STATUS).toBool(); + } + Q_EMIT keyboardConfigChanged(strKey, varValue); +} + +void GSettingsHelper::onUsdMediaKeysConfigChanged(QString strKey) +{ + QVariant varValue; + if (strKey == KEY_AREA_SCREENSHOT) { + varValue = m_areaScreenShot = m_gsUsdMediaKeys->get(KEY_AREA_SCREENSHOT).toString(); + } else if (strKey == KEY_AREA_SCREENSHOT2) { + varValue = m_areaScreenShot2 = m_gsUsdMediaKeys->get(KEY_AREA_SCREENSHOT2).toString(); + } else if (strKey == KEY_SCREEN_SHOT) { + varValue = m_screenShot = m_gsUsdMediaKeys->get(KEY_SCREEN_SHOT).toString(); + } else if (strKey == KEY_SCREEN_SHOT2) { + varValue = m_screenShot2 = m_gsUsdMediaKeys->get(KEY_SCREEN_SHOT2).toString(); + } else if (strKey == KEY_WINDOW_SCREENSHOT) { + varValue = m_windowScreenshot = m_gsUsdMediaKeys->get(KEY_WINDOW_SCREENSHOT).toString(); + } + Q_EMIT usdMediaKeysConfigChanged(strKey, varValue); +} + +QVariant GSettingsHelper::GetScreenSaverConf(QString strKey) +{ + QVariant varValue; + if (initScreenSaver()) { + if (strKey == KEY_SHOW_REST_TIME) { + varValue = m_bShowRestTime; + } else if (strKey == KEY_SHOW_CUSTOM_REST_TIME) { + varValue = m_bShowCustomRestTime; + } else if (strKey == KEY_SHOW_UKUI_REST_TIME) { + varValue = m_bShowUkuiRestTime; + } else if (strKey == KEY_CYCLE_TIME) { + varValue = m_nCycleTime; + } else if (strKey == KEY_AUTOMATIC_SWITCHING_ENABLE) { + varValue = m_bAutomaticSwitchingEnable; + } else if (strKey == KEY_BACKGROUND_PATH) { + varValue = m_strBackgroundPath; + } else if (strKey == KEY_MYTEXT) { + varValue = m_strMyText; + } else if (strKey == KEY_TEXT_IS_CENTER) { + varValue = m_bTextIsCenter; + } else if (strKey == KEY_SHOW_MESSAGE_ENABLED) { + varValue = m_bShowMessageEnable; + } else if (strKey == KEY_MESSAGE_NUMBER) { + varValue = m_nMessageNum; + } else if (strKey == KEY_VIDEO_FORMAT) { + varValue = m_strVideoFormat; + } else if (strKey == KEY_VIDEO_PATH) { + varValue = m_strVideoPath; + } else if (strKey == KEY_VIDEO_SIZE) { + varValue = m_nVideoSize; + } else if (strKey == KEY_VIDEO_WIDTH) { + varValue = m_nVideoWidth; + } else if (strKey == KEY_VIDEO_HEIGHT) { + varValue = m_nVideoHeight; + } + } + return varValue; +} + +bool GSettingsHelper::SetScreenSaverConf(QString strKey, QVariant value) +{ + if (initScreenSaver()) { + if (value.isValid()) { + m_gsScreenSaver->set(strKey, value); + return true; + } + } + return false; +} + +QVariant GSettingsHelper::GetLockScreenConf(QString strKey) +{ + QVariant varValue; + if (initLockScreen()) { + if (strKey == KEY_IDLE_DELAY) { + varValue = m_nIdleDelay; + } else if (strKey == KEY_IDLE_LOCK) { + varValue = m_nIdleLock; + } else if (strKey == KEY_IDLE_ACTIVATION_ENABLED) { + varValue = m_bIdleActivationEnable; + } else if (strKey == KEY_IDLE_LOCK_ENABLED) { + varValue = m_bIdleLockEnable; + } else if (strKey == KEY_LOCK_TIMEOUT) { + varValue = m_nLockTimeout; + } else if (strKey == KEY_CLOSE_ACTIVATION_ENABLED) { + varValue = m_bCloseActivationEnable; + } else if (strKey == KEY_SLEEP_ACTIVATION_ENABLED) { + varValue = m_bSleepActivationEnable; + } else if (strKey == KEY_LOCK_ENABLED) { + varValue = m_bLockEnable; + } else if (strKey == KEY_BACKGROUND) { + varValue = m_strBackground; + } else if (strKey == KEY_MODE) { + varValue = m_saverMode; + } else if (strKey == KEY_THEMES) { + varValue = m_saverTheme; + } else if (strKey == KEY_IMAGE_TRANSITION_EFFECT) { + varValue = m_imageTSEffect; + } else if (strKey == KEY_IMAGE_SWITCH_INTERVAL) { + varValue = m_imageSwitchInterval; + } + } + return varValue; +} + +bool GSettingsHelper::SetLockScreenConf(QString strKey, QVariant value) +{ + if (initLockScreen()) { + if (value.isValid()) { + m_gsLockScreen->set(strKey, value); + return true; + } + } + return false; +} + +QVariant GSettingsHelper::GetPowerManagerConf(QString strKey) +{ + QVariant varValue; + if (initPowerManager()) { + if (strKey == KEY_LOCK_SUSPEND) { + varValue = m_bLockSuspend; + } else if (strKey == KEY_LOCK_HIBERNATE) { + varValue = m_bLockHibernate; + } else if (strKey == KEY_LOCK_BLANKSCREEN) { + varValue = m_bLockBlankScreen; + } else if (strKey == KEY_SLEEP_COMPUTER_AC) { + varValue = m_nSleepComputeAc; + } else if (strKey == KEY_SLEEP_DISPLAY_AC) { + varValue = m_nSleepDisplayAc; + } else if (strKey == KEY_BUTTON_LID_AC) { + varValue = m_strButtonLidAc; + } + } + return varValue; +} + +bool GSettingsHelper::SetPowerManagerConf(QString strKey, QVariant value) +{ + if (initPowerManager()) { + if (value.isValid()) { + m_gsPowerManager->set(strKey, value); + return true; + } + } + return false; +} + +QVariant GSettingsHelper::GetMateBgConf(QString strKey) +{ + QVariant varValue; + if (initMateBg()) { + if (strKey == KEY_PICTURE_FILENAME) { + varValue = m_strPicFileName; + } else if (strKey == KEY_PICTURE_OPTIONS) { + varValue = m_strPicOptions; + } else if (strKey == KEY_PRIMARY_COLOR) { + varValue = m_strPrimaryColor; + } + } + return varValue; +} + +bool GSettingsHelper::SetMateBgConf(QString strKey, QVariant value) +{ + if (initMateBg()) { + if (value.isValid()) { + m_gsMateBg->set(strKey, value); + return true; + } + } + return false; +} + +QVariant GSettingsHelper::GetUkccPluginsConf(QString strKey) +{ + QVariant varValue; + if (initUkccPlugins()) { + if (strKey == KEY_HOUR_SYSTEM) { + varValue = m_nHourSystem; + } else if (strKey == KEY_DATE) { + varValue = m_strDateType; + } + } + return varValue; +} + +bool GSettingsHelper::SetUkccPluginsConf(QString strKey, QVariant value) +{ + if (initUkccPlugins()) { + if (value.isValid()) { + m_gsUkccPlugins->set(strKey, value); + return true; + } + } + return false; +} + +QVariant GSettingsHelper::GetThemeStyleConf(QString strKey) +{ + QVariant varValue; + if (initThemeStyle()) { + if (strKey == KEY_SYSTEM_FONT_SIZE) { + varValue = m_lfFontSize; + } else if (strKey == KEY_THEME_COLOR) { + varValue = m_strThemeColor; + } + } + return varValue; +} + +bool GSettingsHelper::SetThemeStyleConf(QString strKey, QVariant value) +{ + if (initThemeStyle()) { + if (value.isValid()) { + m_gsThemeStyle->set(strKey, value); + return true; + } + } + return false; +} + +QVariant GSettingsHelper::GetSessionConf(QString strKey) +{ + QVariant varValue; + if (initSession()) { + if (strKey == KEY_SESSION_IDLE) { + varValue = m_nSessionIdle; + } + } + return varValue; +} + +bool GSettingsHelper::SetSessionConf(QString strKey, QVariant value) +{ + if (initSession()) { + if (value.isValid()) { + m_gsSession->set(strKey, value); + return true; + } + } + return false; +} + +QVariant GSettingsHelper::GetKeyboardConf(QString strKey) +{ + QVariant varValue; + if (initKeyboard()) { + if (strKey == KEY_CAPSLOCK_STATUS) { + varValue = m_capsState; + } + } + return varValue; +} + +bool GSettingsHelper::SetKeyboardConf(QString strKey, QVariant value) +{ + if (initKeyboard()) { + if (value.isValid()) { + m_gsKeyboard->set(strKey, value); + return true; + } + } + return false; +} + +QVariant GSettingsHelper::GetUsdMediaKeys(QString strKey) +{ + QVariant varValue; + if (initUsdMediaKeys()) { + if (strKey == KEY_AREA_SCREENSHOT) { + varValue = m_areaScreenShot; + } else if (strKey == KEY_AREA_SCREENSHOT2) { + varValue = m_areaScreenShot2; + } else if (strKey == KEY_SCREEN_SHOT) { + varValue = m_screenShot; + } else if (strKey == KEY_SCREEN_SHOT2) { + varValue = m_screenShot2; + } else if (strKey == KEY_WINDOW_SCREENSHOT) { + varValue = m_windowScreenshot; + } + } + return varValue; +} diff --git a/src/lock-backend/gsettingshelper.h b/src/lock-backend/gsettingshelper.h new file mode 100644 index 0000000..4f81789 --- /dev/null +++ b/src/lock-backend/gsettingshelper.h @@ -0,0 +1,153 @@ +/* + * Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * +**/ +#ifndef GSETTINGSHELPER_H +#define GSETTINGSHELPER_H + +#include +#include + +class GSettingsHelper : public QObject +{ + Q_OBJECT +public: + explicit GSettingsHelper(QObject *parent = nullptr); + virtual ~GSettingsHelper(); + +public: + QVariant GetLockScreenConf(QString strKey); + bool SetLockScreenConf(QString strKey, QVariant value); + QVariant GetScreenSaverConf(QString strKey); + bool SetScreenSaverConf(QString strKey, QVariant value); + QVariant GetPowerManagerConf(QString strKey); + bool SetPowerManagerConf(QString strKey, QVariant value); + QVariant GetMateBgConf(QString strKey); + bool SetMateBgConf(QString strKey, QVariant value); + QVariant GetUkccPluginsConf(QString strKey); + bool SetUkccPluginsConf(QString strKey, QVariant value); + QVariant GetThemeStyleConf(QString strKey); + bool SetThemeStyleConf(QString strKey, QVariant value); + QVariant GetSessionConf(QString strKey); + bool SetSessionConf(QString strKey, QVariant value); + QVariant GetKeyboardConf(QString strKey); + bool SetKeyboardConf(QString strKey, QVariant value); + QVariant GetUsdMediaKeys(QString strKey); + +public Q_SLOTS: + void onLockScreenConfigChanged(QString strKey); + void onScreenSaverConfigChanged(QString strKey); + void onPowerManagerConfigChanged(QString strKey); + void onMateBgConfigChanged(QString strKey); + void onUkccPluginsConfigChanged(QString strKey); + void onThemeStyleConfigChanged(QString strKey); + void onSessionConfigChanged(QString strKey); + void onKeyboardConfigChanged(QString strKey); + void onUsdMediaKeysConfigChanged(QString strKey); + +Q_SIGNALS: + void lockScreenConfigChanged(QString strKey, QVariant value); + void screenSaverConfigChanged(QString strKey, QVariant value); + void powerManagerConfigChanged(QString strKey, QVariant value); + void mateBgConfigChanged(QString strKey, QVariant value); + void ukccPluginsConfigChanged(QString strKey, QVariant value); + void themeStyleConfigChanged(QString strKey, QVariant value); + void sessionConfigChanged(QString strKey, QVariant value); + void keyboardConfigChanged(QString strKey, QVariant value); + void usdMediaKeysConfigChanged(QString strKey, QVariant value); + +private: + bool initLockScreen(); + bool initScreenSaver(); + bool initPowerManager(); + bool initMateBg(); + bool initUkccPlugins(); + bool initThemeStyle(); + bool initSession(); + bool initKeyboard(); + bool initUsdMediaKeys(); + +private: + QGSettings *m_gsLockScreen = nullptr; + QGSettings *m_gsScreenSaver = nullptr; + QGSettings *m_gsPowerManager = nullptr; + QGSettings *m_gsMateBg = nullptr; + QGSettings *m_gsUkccPlugins = nullptr; + QGSettings *m_gsThemeStyle = nullptr; + QGSettings *m_gsSession = nullptr; + QGSettings *m_gsKeyboard = nullptr; + QGSettings *m_gsUsdMediaKeys = nullptr; + + bool m_bShowRestTime = false; + bool m_bShowCustomRestTime = false; + bool m_bShowUkuiRestTime = false; + int m_nCycleTime = 1; + bool m_bAutomaticSwitchingEnable = false; + QString m_strBackgroundPath; + QString m_strMyText; + bool m_bTextIsCenter = true; + bool m_bShowMessageEnable = false; + int m_nMessageNum = 0; + QString m_strVideoFormat; + QString m_strVideoPath; + int m_nVideoSize = 0; + int m_nVideoWidth = 0; + int m_nVideoHeight = 0; + + int m_nIdleDelay = -1; + int m_nIdleLock = -1; + bool m_bIdleActivationEnable = false; + bool m_bIdleLockEnable = false; + int m_nLockTimeout = -1; + bool m_bCloseActivationEnable = false; + bool m_bSleepActivationEnable = false; + bool m_bLockEnable = false; + QString m_strBackground; + + bool m_bLockSuspend = false; + bool m_bLockHibernate = false; + bool m_bLockBlankScreen = false; + int m_nSleepComputeAc = -1; + int m_nSleepDisplayAc = -1; + QString m_strButtonLidAc; + + QString m_strPicFileName; + QString m_strPicOptions; + QString m_strPrimaryColor; + + int m_nHourSystem = 0; + QString m_strDateType; + + double m_lfFontSize = 0.0; + QString m_strThemeColor; + + int m_nSessionIdle = -1; + + bool m_capsState = false; + + QString m_areaScreenShot; + QString m_areaScreenShot2; + QString m_screenShot; + QString m_screenShot2; + QString m_windowScreenshot; + + QString m_saverMode; + QStringList m_saverTheme; + int m_imageTSEffect; + int m_imageSwitchInterval; +}; + +#endif // GSETTINGSHELPER_H diff --git a/src/lock-backend/lightdmhelper.cpp b/src/lock-backend/lightdmhelper.cpp new file mode 100644 index 0000000..1affdd6 --- /dev/null +++ b/src/lock-backend/lightdmhelper.cpp @@ -0,0 +1,256 @@ +/* + * Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * +**/ +#include "lightdmhelper.h" +#include +#include +#include +#include "securityuser.h" +#include +#include "proxymodel.h" + +LightDMHelper::LightDMHelper(QObject *parent) + : QLightDM::Greeter(parent) + , m_sessionsModel(nullptr) + , m_secUser(SecurityUser::instance()) + , m_strCurUserName("") +{ + //连接到lightdm + if(!connectToDaemonSync()){ + qDebug() << "connect to Daemon failed"; + exit(1); + } + initData(); +} + +void LightDMHelper::initData() +{ + // 获取会话信息 + m_sessionsModel = new QLightDM::SessionsModel(QLightDM::SessionsModel::LocalSessions, this); + updateSessionsInfo(); + setSession(defaultSessionHint()); + // 获取用户信息 + m_isShowManualLogin = showManualLoginHint(); + if(!hideUsersHint()){ + m_modelUsers = new UsersModel(this); + m_modelUsers->setSourceModel(new QLightDM::UsersModel(this)); + connect(m_modelUsers, &UsersModel::userInfoChanged, this, &LightDMHelper::onUsersChanged); + if(hasValidUsers() == 0) { + m_isShowManualLogin = true; + } + } + else { + qDebug() << "hide users, show manual"; + m_isShowManualLogin = true; + } + updateUsersInfo(); +} + +bool LightDMHelper::setSession(const QString &session) +{ + bool bRet = false; + if (!m_listSessions.contains(session)) + return bRet; + if (!session.isEmpty() && session != m_strSession) { + m_strSession = session; + bRet = true; + } else if (!session.isEmpty() && session == m_strSession) { + bRet = true; + } + if (bRet) + Q_EMIT currentSessionChanged(m_strSession); + return bRet; +} + +QString LightDMHelper::session() +{ + return m_strSession; +} + +QList LightDMHelper::getSessionsInfo() +{ + return m_listSessions; +} + +void LightDMHelper::startSession() +{ + if(isAuthenticated()) + Q_EMIT authenticationSucess(authenticationUser()); + + + if(!startSessionSync(m_strSession)) { + Q_EMIT startSessionFailed(); + Q_EMIT showMessage(tr("failed to start session."), QLightDM::Greeter::MessageTypeError); + } +} + +QString LightDMHelper::getCurrentUser() +{ + return m_strCurUserName; +} + +bool LightDMHelper::setCurrentUser(QString strUserName) +{ + bool bRet = false; + if (!strUserName.isEmpty() && strUserName != m_strCurUserName) { + if (findUserByName(strUserName)) { + m_strCurUserName = strUserName; + bRet = true; + } else if (struct passwd * pwinfo = getpwnam(strUserName.toLatin1().data())) { + m_strCurUserName = strUserName; + bRet = true; + } + } else if (!strUserName.isEmpty() && strUserName == m_strCurUserName) { + bRet = true; + } + if (bRet) { + Q_EMIT currentUserChanged(m_strCurUserName); + } + return bRet; +} + +UserInfoPtr LightDMHelper::findUserByUid(uid_t id) +{ + for (auto userInfoPtr : m_listUsers) { + if (userInfoPtr->uid() == id) { + return userInfoPtr; + } + } + return nullptr; +} + +UserInfoPtr LightDMHelper::findUserByName(QString strName) +{ + for (auto userInfoPtr : m_listUsers) { + if (userInfoPtr->name() == strName) { + return userInfoPtr; + } + } + return nullptr; +} + +bool LightDMHelper::hasSameUser(const UserInfoPtr userInfoPtr) +{ + for (auto user : m_listUsers) { + if (user->uid() == userInfoPtr->uid() + && user->name() == userInfoPtr->name()) { + return true; + } + } + return false; +} + +bool LightDMHelper::hasValidUsers() +{ + if (!m_modelUsers) + return false; + int count = 0; + for(int i = 0; i < m_modelUsers->rowCount(QModelIndex()); i++){ + QString name = m_modelUsers->index(i).data(QLightDM::UsersModel::NameRole).toString(); + if(m_secUser->isSecrityUser(name)) + count++; + } + return (bool)(count>0); +} + +bool LightDMHelper::isSameUser(UserInfoPtr userA, UserInfoPtr userB) +{ + return userA->uid() == userB->uid() && + userA->fullName() == userB->fullName() && + userA->name() == userB->name() && + userA->lang() == userB->lang() && + userA->isLoggedIn() == userB->isLoggedIn() && + userA->headImage() == userB->headImage() && + userA->backGround() == userB->backGround(); +} + +void LightDMHelper::onUsersChanged() +{ + if (!m_modelUsers) + return ; + updateUsersInfo(); + Q_EMIT usersInfoChanged(); +} + +void LightDMHelper::updateUsersInfo() +{ + m_listUsers.clear(); + if (m_modelUsers) { + for(int i = 0; i < m_modelUsers->rowCount(QModelIndex()); i++){ + QString name = m_modelUsers->index(i).data(QLightDM::UsersModel::NameRole).toString(); + if(m_secUser->isSecrityUser(name)) { + std::shared_ptr userInfoPtr = std::make_shared(); + userInfoPtr->updateName(name); + QString strRealName = m_modelUsers->index(i).data(QLightDM::UsersModel::RealNameRole).toString(); + if (strRealName.isEmpty()) { + strRealName = name; + } + userInfoPtr->updateFullName(strRealName); + QString strBackGround = m_modelUsers->index(i).data(QLightDM::UsersModel::BackgroundPathRole).toString(); + if (!strBackGround.isEmpty() && QFileInfo(strBackGround).exists()){ + userInfoPtr->updateBackground(strBackGround); + } + QString strImgHead = m_modelUsers->index(i).data(QLightDM::UsersModel::ImagePathRole).toString(); + if (!strImgHead.isEmpty() && QFileInfo(strImgHead).exists()){ + userInfoPtr->updateHeadImage(strImgHead); + } + uid_t uid = m_modelUsers->index(i).data(QLightDM::UsersModel::UidRole).toUInt(); + userInfoPtr->updateUid(uid); + + bool isLoggedIn = m_modelUsers->index(i).data(QLightDM::UsersModel::LoggedInRole).toBool(); + userInfoPtr->updateLoggedIn(isLoggedIn); + + if (!hasSameUser(userInfoPtr)) { + m_listUsers.append(userInfoPtr); + } + } + } + } + if (m_isShowManualLogin) { + std::shared_ptr userInfoPtr = std::make_shared(); + userInfoPtr->updateFullName(tr("Login")); + userInfoPtr->updateName("*login"); + if (!hasSameUser(userInfoPtr)) { + m_listUsers.append(userInfoPtr); + } + } + if (hasGuestAccountHint()) { + std::shared_ptr userInfoPtr = std::make_shared(); + userInfoPtr->updateFullName(tr("Guest")); + userInfoPtr->updateName("*guest"); + if (!hasSameUser(userInfoPtr)) { + m_listUsers.append(userInfoPtr); + } + } +} + +void LightDMHelper::updateSessionsInfo() +{ + if (m_sessionsModel) { + for(int i = 0; i < m_sessionsModel->rowCount(QModelIndex()); i++){ + QString name = m_sessionsModel->index(i).data(QLightDM::SessionsModel::KeyRole).toString(); + if (!name.isEmpty()) { + m_listSessions.append(name); + } + } + } +} + +QList LightDMHelper::getUsersInfo() +{ + return m_listUsers; +} diff --git a/src/lock-backend/lightdmhelper.h b/src/lock-backend/lightdmhelper.h new file mode 100644 index 0000000..a2d3863 --- /dev/null +++ b/src/lock-backend/lightdmhelper.h @@ -0,0 +1,166 @@ +/* + * Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * +**/ +#ifndef LIGHTDMHELPER_H +#define LIGHTDMHELPER_H + +#include +#include +#include +#include +#include +#include +#include "userinfo.h" + +class SecurityUser; +class UsersModel; +/** + * @brief lightdm工具类 + * + */ +class LightDMHelper : public QLightDM::Greeter +{ + Q_OBJECT +public: + /** + * @brief 构造 + * + * @param parent 父指针 + */ + explicit LightDMHelper(QObject *parent = nullptr); + +public: + /** + * @brief 设置会话 + * + * @param session 会话名称 + * @return bool true 设置成功,其他失败 + */ + bool setSession(const QString &session); + /** + * @brief 会话 + * + * @return QString 会话名称 + */ + QString session(); + /** + * @brief 根据用户id查找用户信息 + * + * @param id 用户id + * @return UserInfoPtr 用户信息指针 + */ + UserInfoPtr findUserByUid(uid_t id); + /** + * @brief 根据用户名查找用户信息 + * + * @param strName 用户名 + * @return UserInfoPtr 用户信息指针 + */ + UserInfoPtr findUserByName(QString strName); + /** + * @brief 是否存在相同用户信息 + * + * @param userInfoPtr 用户信息 + * @return bool true 有,false 无 + */ + bool hasSameUser(const UserInfoPtr userInfoPtr); + /** + * @brief 获取用户信息列表 + * + * @return QList 信息列表 + */ + QList getUsersInfo(); + + QString getCurrentUser(); + + bool setCurrentUser(QString strUserName); + + QList getSessionsInfo(); + +public Q_SLOTS: + /** + * @brief 启动会话 + * + */ + void startSession(); + /** + * @brief 用户更新 + */ + void onUsersChanged(); + +Q_SIGNALS: + /** + * @brief 认证成功 + * + * @param userName 用户名 + */ + void authenticationSucess(QString userName); + /** + * @brief 启动会话失败 + * + */ + void startSessionFailed(); + /** + * @brief 用户信息更新 + * + */ + void usersInfoChanged(); + + void currentUserChanged(QString strUserName); + + void currentSessionChanged(QString strSession); + +private: + /** + * @brief 初始化数据 + * + */ + void initData(); + /** + * @brief 是否有有效用户 + * + * @return bool true 有,false 无 + */ + bool hasValidUsers(); + /** + * @brief 是否为同一个用户信息 + * + * @param UserInfoPtr 用户A + * @param UserInfoPtr 用户B + * @return bool true 相同,false 不同 + */ + bool isSameUser(UserInfoPtr, UserInfoPtr); + /** + * @brief 更新用户信息 + * + */ + void updateUsersInfo(); + + void updateSessionsInfo(); + +private: + bool m_isShowManualLogin; /**< 是否显示手动登录 */ + QString m_strSession; /**< 当前会话 */ + QString m_strCurUserName; /**< 当前选择用户 */ + QList m_listUsers; /**< 用户信息列表 */ + SecurityUser *m_secUser = nullptr; /**< 安全用户信息指针 */ + QLightDM::SessionsModel *m_sessionsModel; /**< lightdm 会话数据指针 */ + QList m_listSessions; /**< 会话列表 */ + UsersModel *m_modelUsers = nullptr; /**< lightdm 用户数据指针 */ +}; + +#endif // LIGHTDMHELPER_H diff --git a/src/ukui-screensaver-backend.cpp b/src/lock-backend/main.cpp similarity index 67% rename from src/ukui-screensaver-backend.cpp rename to src/lock-backend/main.cpp index 87ca85d..9ca968e 100644 --- a/src/ukui-screensaver-backend.cpp +++ b/src/lock-backend/main.cpp @@ -19,31 +19,43 @@ #include #include #include - -#include "interface.h" -#include "screensaveradaptor.h" -#include "types.h" +#include #include #include #include #include #include - -void sig_chld(int /*signo*/) -{ - pid_t pid; - while( (pid = waitpid(-1, NULL, WNOHANG)) > 0) - qDebug() << "child" << pid << "terminated"; - return; -} +#include "qtsinglecoreapplication.h" +#include "utils.h" +#include "dbusupperinterface.h" +#include "screensaveradaptor.h" +#include "personalizeddata.h" int main(int argc, char *argv[]) { initUkuiLog4qt("ukui-screensaver-backend"); // 重启或关机时不被session关掉 qunsetenv("SESSION_MANAGER"); - QCoreApplication a(argc, argv); + QString singleId = QString("ukui-screensaver-backend"+QLatin1String(getenv("DISPLAY"))); + QtSingleCoreApplication a(singleId, argc, argv); + if (a.isRunning()) { + qDebug() << "There is an instance running"; + return 0; + } + //命令行参数解析 + QCommandLineParser parser; + parser.setApplicationDescription(QCoreApplication::translate("main", "Backend for the ukui ScreenSaver.")); + parser.addHelpOption(); + parser.addVersionOption(); + parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions); + + QCommandLineOption lockStartupOption(QStringLiteral("lock-startup"), + QCoreApplication::translate("main", "lock the screen by startup")); + parser.addOptions({lockStartupOption}); + parser.process(a.arguments()); + + KYLINUSERDATAMNG::instance(); // 检查该程序是否已经有实例在运行 QDBusInterface *checkInterface = @@ -55,11 +67,11 @@ int main(int argc, char *argv[]) "cn.kylinos.ScreenSaver"); if(ret.value()) { qDebug() << "There is an instance running"; - exit(EXIT_FAILURE); + return EXIT_FAILURE; } // 注册DBus - Interface *interface = new Interface(); + DbusUpperInterface *interface = new DbusUpperInterface(); ScreenSaverAdaptor adaptor(interface); QDBusConnection service = QDBusConnection::sessionBus(); @@ -69,19 +81,25 @@ int main(int argc, char *argv[]) sessionDbus = QString("%1%2").arg(QString(SS_DBUS_SERVICE)).arg(displayNum); if(!service.registerService(sessionDbus)) { qDebug() << service.lastError().message(); - exit(EXIT_FAILURE); + return EXIT_FAILURE; } } if(!service.registerObject(SS_DBUS_PATH, SS_DBUS_SERVICE, &adaptor, QDBusConnection::ExportAllSlots | QDBusConnection::ExportAllSignals)) { qDebug() << service.lastError().message(); - exit(EXIT_FAILURE); + return EXIT_FAILURE; } qDebug() << service.baseService(); QObject::connect(checkInterface, SIGNAL(NameLost(QString)), interface, SLOT(onNameLost(QString))); + if (parser.isSet(lockStartupOption)) { + QTimer::singleShot(0, interface, [=](){ + interface->LockStartupMode(); + }); + } + return a.exec(); } diff --git a/src/org.ukui.ScreenSaver.xml b/src/lock-backend/org.ukui.ScreenSaver.xml similarity index 73% rename from src/org.ukui.ScreenSaver.xml rename to src/lock-backend/org.ukui.ScreenSaver.xml index e0d3a42..ae260a2 100644 --- a/src/org.ukui.ScreenSaver.xml +++ b/src/lock-backend/org.ukui.ScreenSaver.xml @@ -12,6 +12,9 @@ + + + @@ -30,5 +33,13 @@ + + + + + + + + diff --git a/src/lock-backend/pamauthenticate.cpp b/src/lock-backend/pamauthenticate.cpp new file mode 100644 index 0000000..1fd3db2 --- /dev/null +++ b/src/lock-backend/pamauthenticate.cpp @@ -0,0 +1,286 @@ +/* + * Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * +**/ +#include "pamauthenticate.h" +#include "global_utils.h" +#include "authpamthread.h" +#include +#include +#include +#include +#include + +PamAuthenticate::PamAuthenticate(LightDMHelper *helper, QObject *parent) + : QObject(parent) + , m_lightdmHelper(helper) +{ + m_fdToParent[0] = -1; + m_fdToParent[1] = -1; + m_fdToChild[0] = -1; + m_fdToChild[1] = -1; + + connect(m_lightdmHelper, SIGNAL(showMessage(QString, QLightDM::Greeter::MessageType)), + this, + SLOT(onLDMShowMessage(QString,QLightDM::Greeter::MessageType))); + connect(m_lightdmHelper, SIGNAL(showPrompt(QString, QLightDM::Greeter::PromptType)), + this, + SLOT(onLDMShowPrompt(QString,QLightDM::Greeter::PromptType))); + connect(m_lightdmHelper, SIGNAL(authenticationComplete()), this, SIGNAL(authenticationComplete())); +} + +bool PamAuthenticate::inAuthentication() const +{ + if (m_isOtherUser) + return m_lightdmHelper->inAuthentication(); + else { + return m_isInAuthentication; + } +} + +bool PamAuthenticate::isAuthenticated() const +{ + if (m_isOtherUser) + return m_lightdmHelper->isAuthenticated(); + else { + return m_isAuthenticated; + } +} + +QString PamAuthenticate::authenticationUser() const +{ + if (m_isOtherUser) + return m_lightdmHelper->authenticationUser(); + else { + return m_strUserName; + } +} + +void PamAuthenticate::authenticate(const QString &username) +{ + m_isOtherUser = (getenv("USER") != username); + if (username == "*guest") { + m_lightdmHelper->authenticateAsGuest(); + } else if (m_isOtherUser) + m_lightdmHelper->authenticate(username); + else { + cancelAuthentication(); + m_strUserName = username; + if(pipe(m_fdToParent) || pipe(m_fdToChild)) + qDebug()<< "create pipe failed: " << strerror(errno); + m_threadAuthPam = new AuthPamThread(); + m_threadAuthPam->startAuthPam(m_fdToChild[0], m_fdToParent[1], username); + m_isInAuthentication = true; + m_socketNotifier = new QSocketNotifier(m_fdToParent[0], QSocketNotifier::Read); + connect(m_socketNotifier, &QSocketNotifier::activated, this, &PamAuthenticate::onSockRead); + } +} + +void PamAuthenticate::respond(const QString &response) +{ + if (m_isOtherUser) + m_lightdmHelper->respond(response); + else { + m_nPrompts--; + m_responseList.push_back(response); + + if(m_nPrompts == 0) { + //发送响应到子进程 + int j = 0; + PAM_RESPONSE *resp = (PAM_RESPONSE*)calloc(m_messageList.size(), sizeof(PAM_RESPONSE)); + //响应的数量和消息的数量一致,如果消息类型不是PROMPT,则响应是空的 + for(int i = 0; i < m_messageList.size(); i++) { + struct pam_message message = m_messageList[i]; + PAM_RESPONSE *r = &resp[i]; + if(message.msg_style == PAM_PROMPT_ECHO_OFF + || message.msg_style == PAM_PROMPT_ECHO_ON) + { + int respLength = m_responseList[j].length() + 1; + r->resp = (char *)malloc(sizeof(char) * respLength); + memcpy(r->resp, m_responseList[j].toLocal8Bit().data(), respLength); + j++; + } + } + _respond(resp); + free(resp); + m_messageList.clear(); + m_responseList.clear(); + } + } +} + +void PamAuthenticate::cancelAuthentication() +{ + if (m_isOtherUser) + m_lightdmHelper->cancelAuthentication(); + else { + if (m_threadAuthPam) { + m_messageList.clear(); + m_responseList.clear(); + m_isAuthenticated = false; + m_isInAuthentication = false; + m_nPrompts = 0; + if(m_socketNotifier){ + disconnect(m_socketNotifier, &QSocketNotifier::activated, this, &PamAuthenticate::onSockRead); + delete m_socketNotifier; + m_socketNotifier = nullptr; + } + if (m_fdToParent[1] >= 0) { + close(m_fdToParent[1]); + m_fdToParent[1] = -1; + } + if (m_fdToChild[1] >= 0) { + close(m_fdToChild[1]); + m_fdToChild[1] = -1; + } + m_threadAuthPam->stopAuthPam(); + delete m_threadAuthPam; + m_threadAuthPam = nullptr; + if (m_fdToParent[0] >= 0) { + close(m_fdToParent[0]); + m_fdToParent[0] = -1; + } + if (m_fdToChild[0] >= 0) { + close(m_fdToChild[0]); + m_fdToChild[0] = -1; + } + } + } +} + +static void +writeData(int fd, const void *buf, ssize_t count) +{ + if(write(fd, buf, count) != count) + qDebug() << "write to parent failed: " << strerror(errno); +} + +static void +writeString(int fd, const char *data) +{ + int length = data ? strlen(data) : -1; + writeData(fd, &length, sizeof(length)); + if(data) + writeData(fd, data, sizeof(char) * length); +} + +static int +readData(int fd, void *buf, size_t count) +{ + ssize_t nRead = read(fd, buf, count); + if(nRead < 0) + qDebug() << "read data failed: " << strerror(errno); + return nRead; +} + +static char * +readString(int fd) +{ + int length; + + if(readData(fd, &length, sizeof(length)) <= 0) + return NULL; + if(length <= 0) + length = 0; + + char *value = (char *)malloc(sizeof(char) * (length + 1)); + readData(fd, value, length); + value[length] = '\0'; + + return value; +} + +void PamAuthenticate::onSockRead() +{ +// qDebug() << "has message"; + int msgLength; + int authComplete = 0; + readData(m_fdToParent[0], &authComplete, sizeof(authComplete)); + + if(authComplete) { + int authRet = -1; + if(readData(m_fdToParent[0], (void*)&authRet, sizeof(authRet)) <= 0) + qDebug() << "get authentication result failed: " << strerror(errno); + qDebug() << "result: " << authRet; + m_isAuthenticated = (authRet == PAM_SUCCESS); + m_isInAuthentication = false; + if(m_socketNotifier){ + m_socketNotifier->deleteLater(); + m_socketNotifier = nullptr; + } + Q_EMIT authenticationComplete(); + } else { + readData(m_fdToParent[0], &msgLength, sizeof(msgLength)); +// qDebug() << "message length: " << msgLength; + + for(int i = 0; i < msgLength; i++) { + //读取message + struct pam_message message; + readData(m_fdToParent[0], &message.msg_style, sizeof(message.msg_style)); + message.msg = readString(m_fdToParent[0]); + + qDebug() << message.msg; + + m_messageList.push_back(message); + + switch (message.msg_style) + { + case PAM_PROMPT_ECHO_OFF: + m_nPrompts++; + Q_EMIT showPrompt(message.msg, PamAuth::PromptTypeSecret); + break; + case PAM_PROMPT_ECHO_ON: + m_nPrompts++; + Q_EMIT showPrompt(message.msg, PamAuth::PromptTypeQuestion); + break; + case PAM_ERROR_MSG: + Q_EMIT showMessage(message.msg, PamAuth::MessageTypeError); + break; + case PAM_TEXT_INFO: + Q_EMIT showMessage(message.msg, PamAuth::MessageTypeInfo); + break; + } + } + + if(m_nPrompts == 0) { + //不需要响应,发送一个空的 + PAM_RESPONSE *response = (PAM_RESPONSE*)calloc(m_messageList.size(), sizeof(PAM_RESPONSE)); + _respond(response); + free(response); + m_messageList.clear(); + } + } +} + +void PamAuthenticate::_respond(const PAM_RESPONSE *response) +{ + for(int i = 0; i < m_messageList.size(); i++) { + const PAM_RESPONSE *resp = &response[i]; + writeData(m_fdToChild[1], (const void *)&resp->resp_retcode, + sizeof(resp->resp_retcode)); + writeString(m_fdToChild[1], resp->resp); + } +} + +void PamAuthenticate::onLDMShowMessage(QString strMsg, QLightDM::Greeter::MessageType type) +{ + Q_EMIT showMessage(strMsg, type); +} + +void PamAuthenticate::onLDMShowPrompt(QString strPrompt, QLightDM::Greeter::PromptType type) +{ + Q_EMIT showPrompt(strPrompt, type); +} diff --git a/src/lock-backend/pamauthenticate.h b/src/lock-backend/pamauthenticate.h new file mode 100644 index 0000000..44f458f --- /dev/null +++ b/src/lock-backend/pamauthenticate.h @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * +**/ +#ifndef PAMAUTHENTICATE_H +#define PAMAUTHENTICATE_H + +#include +#include +#include +#include "lightdmhelper.h" + +typedef struct pam_message PAM_MESSAGE; +typedef struct pam_response PAM_RESPONSE; + +class AuthPamThread; +class QSocketNotifier; +class PamAuthenticate : public QObject +{ + Q_OBJECT +public: + explicit PamAuthenticate(LightDMHelper *helper, QObject *parent = nullptr); + +public: + bool inAuthentication() const; + bool isAuthenticated() const; + QString authenticationUser() const; + +public Q_SLOTS: + void authenticate(const QString &username=QString()); + void respond(const QString &response); + void cancelAuthentication(); + +Q_SIGNALS: + void showMessage(QString text, int type); + void showPrompt(QString text, int type); + void authenticationComplete(); + +private Q_SLOTS: + void onSockRead(); + void onLDMShowMessage(QString strMsg, QLightDM::Greeter::MessageType type); + void onLDMShowPrompt(QString strPrompt, QLightDM::Greeter::PromptType type); + +private: + void _respond(const struct pam_response *response); + +private: + LightDMHelper *m_lightdmHelper = nullptr; + bool m_isInAuthentication = false; + bool m_isAuthenticated = false; + bool m_isOtherUser = false; + AuthPamThread *m_threadAuthPam = nullptr; + QSocketNotifier *m_socketNotifier = nullptr; + int m_nPrompts = 0; + QStringList m_responseList; + QList m_messageList; + int m_fdToParent[2]; + int m_fdToChild[2]; + QString m_strUserName; +}; + +#endif // PAMAUTHENTICATE_H diff --git a/src/lock-backend/personalizeddata.cpp b/src/lock-backend/personalizeddata.cpp new file mode 100644 index 0000000..4259d92 --- /dev/null +++ b/src/lock-backend/personalizeddata.cpp @@ -0,0 +1,256 @@ +#include "personalizeddata.h" + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +enum enum_operation +{ + enum_operation_update = 0, + enum_operation_add, + enum_operation_del, +}; + +static const char * static_dbus_service_name = "org.ukui.UniauthBackend"; +static const char * static_dbus_path = "/org/ukui/UniauthBackend"; +static const char * static_dbus_interface = "org.ukui.UniauthBackend"; + +PersonalizedData::PersonalizedData(QString user) +{ + KyInfo() << user; + m_user = user; +} + +PersonalizedData::~PersonalizedData() +{ + KyInfo() << m_user; +} + +void PersonalizedData::getJsonData(QJsonObject & json) +{ + json.insert("user", m_user); + { + QJsonObject json_1; + json_1["dateType"] = m_dateType; + json_1["fontSize"] = m_fontSize; + json_1["timeType"] = m_timeType; + json_1["backgroundPath"] = m_backgroundPath; + json_1["color"] = m_color; + json["greeter"] = json_1; + } + + /* + { + QJsonObject json_1; + json_1["cursor-size"] = m_cursor_size; + json_1["cursor-theme"] = m_cursor_theme; + json_1["scaling-factor"] = m_scaling_factor; + json["usd"] = json_1; + } + */ + //KyInfo() << json; +} + +void PersonalizedData::setJson(const QJsonObject &json) +{ + if(json.contains("user") && json.value("user").toString() != m_user) + { + KyWarning()<< m_user; + return; + } + if(json.contains("greeter") && json.value("greeter").isObject()) + { + QJsonObject json_1 = json.value("greeter").toObject(); + if(json_1.contains("dateType")) + m_dateType = json_1["dateType"].toString(); + + if(json_1.contains("fontSize")) + m_fontSize = json_1["fontSize"].toInt(); + + if(json_1.contains("timeType")) + m_timeType = json_1["timeType"].toInt(); + + if(json_1.contains("backgroundPath")) + m_backgroundPath = json_1["backgroundPath"].toString(); + + if(json_1.contains("color")) + m_color = json_1["color"].toString(); + } +} + + + +/////////////////////////PersonalizedDataMng////////////////////////////////////// + +PersonalizedDataMng::PersonalizedDataMng(void) +{ + //后续移动到公共接口 + this->__getUserInfomation(); + + + //后续移动到公共监控dbus接口 + if (QDBusConnection::systemBus().connect(static_dbus_service_name, static_dbus_path, + static_dbus_interface, "updateUserInformation", this, + SLOT(updateUserInformation(QString)))) + { + KyDebug() << "updateUserInformation signal connected successfully to slot"; + } + else + { + KyDebug() << "updateUserInformation signal connection was not successful"; + } +} + +PersonalizedDataMng::~PersonalizedDataMng() +{ + +} + +QString PersonalizedDataMng::GetConfInformation(QString name) +{ + QJsonObject json; + if(m_userPersonalizedData.contains(name)) + { + QJsonObject json1; + m_userPersonalizedData[name]->getJsonData(json1); + json[name] = json1; + } + else if(name.isEmpty()) + { + for(auto & it : m_userPersonalizedData.toStdMap()) + { + QJsonObject json1; + it.second->getJsonData(json1); + json[it.first] = json1; + } + } + + QJsonDocument document; + document.setObject(json); + QString strJson(document.toJson(QJsonDocument::Compact)); + KyInfo() << strJson; + return strJson; +} + +void PersonalizedDataMng::updateUserInformation(QString jsonstring) +{ + KyDebug() << jsonstring; + QJsonParseError jsonParseError; + const QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonstring.toUtf8(), &jsonParseError); + + if (jsonParseError.error != QJsonParseError::NoError) + { + KyInfo()<<"getAgreementInfo Parse json failed!!"; + } + else + { + QJsonObject objJson = jsonDoc.object(); + if (objJson.isEmpty()) + { + KyInfo()<<"getAgreementInfo Json is null!!"; + } + else + { + if(objJson.contains("user") && objJson["user"].isString() && objJson.contains("operation")) + { + QString key = objJson["user"].toString(); + int opt = objJson["operation"].toInt(); + if(enum_operation_update == opt || enum_operation_add == opt) + { + if(m_userPersonalizedData.contains(key)) + { + m_userPersonalizedData[key]->setJson(objJson); + } + else + { + m_userPersonalizedData[key] = KylinUserDatePtr(new PersonalizedData(key)); + m_userPersonalizedData[key]->setJson(objJson); + } + } + else if(enum_operation_del) + { + m_userPersonalizedData.remove(key); + } + } + } + } +} + +void PersonalizedDataMng::__getUserInfomation() +{ + QDBusInterface iface(static_dbus_service_name, + static_dbus_path, + static_dbus_interface, + QDBusConnection::systemBus()); + QString param1 = ""; + QDBusPendingCall pcall = iface.asyncCall("GetUserInformation", param1); + QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pcall, this); + this->wait_for_finish(watcher); + + QDBusPendingReply reply = pcall; + if (reply.isError()) + { + KyWarning() << "getAgreementInfo error: " << reply.error().message(); + } + else + { + KyInfo() << reply.value(); + QString strResponse = reply.value(); + QJsonParseError jsonParseError; + const QJsonDocument jsonDoc = QJsonDocument::fromJson(strResponse.toUtf8(), &jsonParseError); + + if (jsonParseError.error != QJsonParseError::NoError) + { + KyInfo()<<"getAgreementInfo Parse json failed!!"; + } + else + { + QJsonObject objRes = jsonDoc.object(); + if (objRes.isEmpty()) + { + KyInfo()<<"getAgreementInfo Json is null!!"; + } + else + { + for(auto & key :objRes.keys()) + { + QJsonValue value = objRes.value(key); + if(value.isObject()) + { + KyInfo() << key; + if(m_userPersonalizedData.contains(key)) + { + m_userPersonalizedData[key]->setJson(value.toObject()); + } + else + { + m_userPersonalizedData[key] = KylinUserDatePtr(new PersonalizedData(key)); + m_userPersonalizedData[key]->setJson(value.toObject()); + } + } + } + } + } + } +} + +void PersonalizedDataMng::wait_for_finish(QDBusPendingCallWatcher *call) +{ + QEventLoop eventloop; + connect(call, &QDBusPendingCallWatcher::finished, this, [&](QDBusPendingCallWatcher *) + { + eventloop.exit(); + }); + eventloop.exec(); +} + + + diff --git a/src/lock-backend/personalizeddata.h b/src/lock-backend/personalizeddata.h new file mode 100644 index 0000000..1c2d5c8 --- /dev/null +++ b/src/lock-backend/personalizeddata.h @@ -0,0 +1,121 @@ +#ifndef PERSONALIZEDDATA_H +#define PERSONALIZEDDATA_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "ukui-log4qt.h" +#include "CSingleton.h" + +class QDBusPendingCallWatcher; + +class PersonalizedData : public QObject +{ + Q_OBJECT +public: + explicit PersonalizedData(QString user); + virtual ~PersonalizedData(); + + ////////////////////ukui-greeter-conf////////////////////////////// + QString dateType(void){ return m_dateType; } + void dateType(QString val){ m_dateType = val; } + + int fontSize(void){ return m_fontSize; } + void fontSize(int val){ m_fontSize = val; } + + int timeType(void){ return m_timeType; } + void timeType(int val){ m_timeType = val; } + + QString backgroundPath(void){ return m_backgroundPath; } + void backgroundPath(QString val){ m_backgroundPath = val; } + + QString color(void){ return m_color; } + void color(QString val){ m_color = val; } + + /////////////////////usd-ukui-settings-daemon//////////////////////////////// + int cursor_size(void){ return m_cursor_size; } + void cursor_size(int val){ m_cursor_size = val; } + + QString cursor_theme(void){ return m_cursor_theme; } + void cursor_theme(QString val){ m_cursor_theme = val; } + + int scaling_factor(void){ return m_scaling_factor; } + void scaling_factor(int val){ m_scaling_factor = val; } + + + void getJsonData(QJsonObject & json); + void setJson(const QJsonObject & json); + +signals: + void conf_changed(QString user); + +protected: + //ukui-greeter-conf + QString m_dateType = "cn"; + int m_fontSize = 5; + int m_timeType = 24; + QString m_backgroundPath; + QString m_color; + + //usd-ukui-settings-daemon + int m_cursor_size = 48; + QString m_cursor_theme; + int m_scaling_factor = 1; + + //用户名 + QString m_user; +}; + + + +typedef QSharedPointer KylinUserDatePtr; + +///////////////////////////////////////////////// +/// \brief The PersonalizedDataMng class +/// + +class PersonalizedDataMng : public QObject +{ + Q_OBJECT +protected: + explicit PersonalizedDataMng(void); + virtual ~PersonalizedDataMng(); + + +public: + QString GetConfInformation(QString); + + +protected slots: + void updateUserInformation(QString jsonstring); + +protected: + void __getUserInfomation(void); + + void wait_for_finish(QDBusPendingCallWatcher *call); +protected: + QMap m_userPersonalizedData; + + friend class SingleTon; +}; + +typedef SingleTon KYLINUSERDATAMNG; + +#endif // PERSONALIZEDDATA_H diff --git a/src/lock-backend/proxymodel.cpp b/src/lock-backend/proxymodel.cpp new file mode 100644 index 0000000..1ae7adf --- /dev/null +++ b/src/lock-backend/proxymodel.cpp @@ -0,0 +1,92 @@ +/* proxymodel.cpp + * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301, USA. +**/ +#include "proxymodel.h" +#include +UsersModel::UsersModel(QObject *parent) + : QAbstractListModel(parent) + , m_model(nullptr) +{ +} + +QVariant UsersModel::data(const QModelIndex &index, int role) const +{ + return m_model->index(index.row(), 0).data(role); +} + +int UsersModel::rowCount(const QModelIndex &parent) const +{ + Q_UNUSED(parent); + return sourceRowCount(); +} + +QHash UsersModel::roleNames() const +{ + return m_model == nullptr ? QHash() : m_model->roleNames(); +} + +void UsersModel::setSourceModel(QAbstractListModel *sourceModel) +{ + if(m_model) + { + disconnect(m_model, SIGNAL(rowsInserted(const QModelIndex&, int, int)), + this, SLOT(onSourceRowsInserted(const QModelIndex&, int, int))); + disconnect(m_model, SIGNAL(rowsRemoved(const QModelIndex&, int, int)), + this, SLOT(onSourceRowsRemoved(const QModelIndex&, int, int))); + disconnect(m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), + this, SLOT(onSourceDataChanged(const QModelIndex&, const QModelIndex&))); + + } + m_model = sourceModel; + beginResetModel(); + endResetModel(); + + connect(m_model, SIGNAL(rowsInserted(const QModelIndex&, int, int)), + this, SLOT(onSourceRowsInserted(const QModelIndex&, int, int))); + connect(m_model, SIGNAL(rowsRemoved(const QModelIndex&, int, int)), + this, SLOT(onSourceRowsRemoved(const QModelIndex&, int, int))); + connect(m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), + this, SLOT(onSourceDataChanged(const QModelIndex&, const QModelIndex&))); +} + +int UsersModel::sourceRowCount() const +{ + return m_model == nullptr ? 0 : m_model->rowCount(); +} + +void UsersModel::onSourceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) +{ + dataChanged(createIndex(topLeft.row(), 0), createIndex(bottomRight.row(), 0)); + Q_EMIT userInfoChanged(); +} + +void UsersModel::onSourceRowsInserted(const QModelIndex &parent, int start, int end) +{ + Q_UNUSED(parent); + beginInsertRows(parent, start, end); + endInsertRows(); + Q_EMIT userInfoChanged(); +} + +void UsersModel::onSourceRowsRemoved(const QModelIndex &parent, int start, int end) +{ + Q_UNUSED(parent); + beginRemoveRows(parent, start, end); + endRemoveRows(); + Q_EMIT userInfoChanged(); +} diff --git a/src/lock-backend/proxymodel.h b/src/lock-backend/proxymodel.h new file mode 100644 index 0000000..07ed3a5 --- /dev/null +++ b/src/lock-backend/proxymodel.h @@ -0,0 +1,50 @@ +/* proxymodel.h + * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301, USA. +**/ + +#ifndef PROXYMODEL_H +#define PROXYMODEL_H + +#include + +class UsersModel : public QAbstractListModel +{ + Q_OBJECT +public: + UsersModel(QObject *parent = 0); + QVariant data(const QModelIndex &index, int role) const; + int rowCount(const QModelIndex &parent = QModelIndex()) const; + QHash roleNames() const; + + void setSourceModel(QAbstractListModel *sourceModel); + +public Q_SLOTS: + void onSourceDataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight ); + void onSourceRowsInserted ( const QModelIndex & parent, int start, int end ); + void onSourceRowsRemoved ( const QModelIndex & parent, int start, int end ); + +Q_SIGNALS: + void userInfoChanged(); + +private: + QAbstractListModel *m_model; + + int sourceRowCount() const; +}; + +#endif // PROXYMODEL_H diff --git a/src/lock-backend/securityuser.cpp b/src/lock-backend/securityuser.cpp new file mode 100644 index 0000000..d556cf2 --- /dev/null +++ b/src/lock-backend/securityuser.cpp @@ -0,0 +1,151 @@ +/* securityuser.cpp + * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301, USA. +**/ +#include +#include +#include +#include +#include +#include +#include + +#include "securityuser.h" + +#define GREETER_SECURITY_CONFIG_PATH "/etc/ukui-greeter/ukui-greeter-security-config.json" + +SecurityUser* SecurityUser::instance_ = nullptr; + +SecurityUser::SecurityUser() + :mode(NORMAL) +{ + loadJsonFile(); +} + +SecurityUser* SecurityUser::instance() +{ + if(instance_ == nullptr) + instance_ = new SecurityUser(); + return instance_; +} + +void SecurityUser::loadJsonFile() +{ + QFile file(GREETER_SECURITY_CONFIG_PATH); + + if(file.exists() == false){ + qDebug()<<"file is not exists"; + return; + } + + qDebug()<<"/etc/ukui-greeter/ukui-greeter-security-config.json is find!"; + + file.open(QIODevice::ReadOnly); + QString value = file.readAll(); + file.close(); + + QJsonParseError parseJsonErr; + QJsonDocument document = QJsonDocument::fromJson(value.toUtf8(),&parseJsonErr); + if(!(parseJsonErr.error == QJsonParseError::NoError)){ + qWarning()<<"parser json file failed"; + qWarning()< +#include + +enum SECURITYTYPE +{ + NORMAL, + WHITELIST, + BLACKLIST +}; + +class SecurityUser +{ +public: + SecurityUser(); + int getMode(); + QStringList getBlackList(); + QStringList getWhiteList(); + bool isSecrityUser(QString username); + static SecurityUser *instance(); + +private: + int mode; + QStringList blacklist; + QStringList whitelist; + + void loadJsonFile(); + + static SecurityUser *instance_; +}; + +#endif // SECURITYUSER_H diff --git a/src/lock-backend/sessionwatcher.cpp b/src/lock-backend/sessionwatcher.cpp new file mode 100644 index 0000000..321a328 --- /dev/null +++ b/src/lock-backend/sessionwatcher.cpp @@ -0,0 +1,109 @@ +/* + * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * +**/ +#include "sessionwatcher.h" +#include +#include +#include +#include +#include "definetypes.h" +#include "utils.h" + +#define GSETTINGS_SCHEMA_SCREENSAVER "org.ukui.screensaver" + +SessionWatcher::SessionWatcher(GSettingsHelper *helper ,QObject *parent) + : QObject(parent) + , m_gsettingsHelper(helper) +{ + sessionPath = qgetenv("XDG_SESSION_PATH"); + + // defaultFontSize = getDefaultFontSize(); + defaultFontSize = 10; + + QDBusInterface *interface = new QDBusInterface( + SM_DBUS_SERVICE, + SM_DBUS_PATH, + SM_DBUS_INTERFACE, + QDBusConnection::sessionBus(), this); + + connect(interface, SIGNAL(StatusChanged(unsigned int)), + this, SLOT(onStatusChanged(unsigned int))); + + idleDelay = m_gsettingsHelper->GetSessionConf(KEY_SESSION_IDLE).toInt(); + + QDBusInterface *displayManagerInterface = new QDBusInterface( + DM_DBUS_SERVICE, + DM_DBUS_PATH, + DM_DBUS_INTERFACE, + QDBusConnection::systemBus(), this); + connect(displayManagerInterface, SIGNAL(SessionRemoved(QDBusObjectPath)), + this, SLOT(onSessionRemoved(QDBusObjectPath))); +} + +void SessionWatcher::onStatusChanged(unsigned int status) +{ + if(status == SESSION_IDLE) { + qDebug()<< idleDelay; + if(idleDelay != -1){ + if(!m_timer){ + m_timer = new QTimer(this); + connect(m_timer, &QTimer::timeout, this, [&]{ + Q_EMIT sessionIdle(); + m_timer->stop(); + }); + } + int time = (idleDelay - 1)*60000; + if(time<0) + time = 0; + + m_timer->start(time); + } + + if(idleLock != -1){ + if(!m_timer2){ + m_timer2 = new QTimer(this); + connect(m_timer2, &QTimer::timeout, this, [&]{ + Q_EMIT sessionLockIdle(); + m_timer2->stop(); + }); + } + int lockTime = (idleLock - 1)*60000; + if(lockTime<0) + lockTime = 0; + + m_timer2->start(lockTime); + } + + + }else if(status == SESSION_AVAILABLE){ + if(m_timer && m_timer->isActive()){ + m_timer->stop(); + } + if(m_timer2 && m_timer2->isActive()){ + m_timer2->stop(); + } + Q_EMIT sessionIdleExit(); + } +} + +void SessionWatcher::onSessionRemoved(const QDBusObjectPath &objectPath) +{ + //如果session注销了,则结束进程 + if(objectPath.path() == sessionPath) + exit(0); +} + diff --git a/src/sessionwatcher.h b/src/lock-backend/sessionwatcher.h similarity index 64% rename from src/sessionwatcher.h rename to src/lock-backend/sessionwatcher.h index 2c4a56d..a4e5bfc 100644 --- a/src/sessionwatcher.h +++ b/src/lock-backend/sessionwatcher.h @@ -24,43 +24,35 @@ #include #include #include +#include +#include "gsettingshelper.h" class SessionWatcher : public QObject { Q_OBJECT public: - explicit SessionWatcher(QObject *parent = nullptr); - void setValue(const QString &key, const QVariant &value); - bool isSleepActivationEnable(); - bool isCloseActivationEnable(); - bool isLockEnable(); - int sleepActivationDelay(); - int closeActivationDelay(); - int idledelay(); - bool isLidCloseWithBlank(); // 合盖关屏 - int locktimeout(); + enum { + SESSION_STATUS_SCREENSAVER = 1, // 屏保 + SESSION_STATUS_SCREENCLOSE = 2, // 关屏 + SESSION_STATUS_SLEEPED = 4, // 休眠/睡眠 + }; + explicit SessionWatcher(GSettingsHelper *m_gsettingsHelper,QObject *parent = nullptr); Q_SIGNALS: void sessionIdle(); void sessionLockIdle(); void sessionIdleExit(); - void lidStateChanged(bool isClosed); private Q_SLOTS: void onStatusChanged(unsigned int status); void onSessionRemoved(const QDBusObjectPath &objectPath); - void onConfigurationTimeTpChanged(QString key); - void onSSConfigChanged(QString strKey); - void onLidWatcherMessage(void); + +public Q_SLOTS: + +private: private: QString sessionPath; - QGSettings *timegsettings = nullptr; - QSettings *configSettings = nullptr; - QGSettings *m_ssSettings = nullptr; - QGSettings *m_pmSettings = nullptr; - QGSettings *m_sdSettings = nullptr; - QGSettings *stylesettings = nullptr; int idleDelay = -1; int idleLock = -1; int m_nLockTimeout = -1; @@ -68,6 +60,10 @@ private: QTimer *m_timer2 = nullptr; bool m_lidState = false; double defaultFontSize; + bool lockState; + int m_nStatus = 0; // 当前状态 + QTimer *m_timerLock = nullptr; + GSettingsHelper *m_gsettingsHelper = nullptr; }; #endif // SESSIONWATCHER_H diff --git a/src/lock-backend/switchuserutils.cpp b/src/lock-backend/switchuserutils.cpp new file mode 100644 index 0000000..f5aebf1 --- /dev/null +++ b/src/lock-backend/switchuserutils.cpp @@ -0,0 +1,317 @@ +/* + * Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * +**/ +#include "switchuserutils.h" + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +SwitchUserUtils::SwitchUserUtils() +{ + +} + +QString SwitchUserUtils::GetCurUserName() +{ + QString strUserName = ""; + struct passwd *pw = NULL; + pw = getpwuid(getuid()); + if (pw != NULL) { + strUserName = QString(pw->pw_name); + } else { + qWarning()<<"SwitchUserUtils:get user name failed"; + } + + return strUserName; +} + +int SwitchUserUtils::GetUidByName(QString strUserName) +{ + if (strUserName.isEmpty()) { + return (unsigned int)-1; + } + + struct passwd *pwbufp = getpwnam(strUserName.toLatin1().data()); + + return pwbufp ? pwbufp->pw_uid : (unsigned int)-1; +} + +UserDisplayIfInfo SwitchUserUtils::GetUserUDII(QString strUserName) +{ + UserDisplayIfInfo userDisplayIfInfo; + // 获取所有的session路径 + QList listObjPath; + QDBusInterface iface("org.freedesktop.DisplayManager", + "/org/freedesktop/DisplayManager", + "org.freedesktop.DBus.Properties", + QDBusConnection::systemBus()); + QDBusMessage result = iface.call("Get", + "org.freedesktop.DisplayManager", + "Sessions"); + if(result.type() == QDBusMessage::ErrorMessage) { + qWarning() << "Get Sessions:" << result.errorMessage(); + return userDisplayIfInfo; + } + QList variantList = result.arguments(); + if (variantList.size() <= 0) { + qDebug()<<"Get Sessions List is null!"; + return userDisplayIfInfo; + } + QDBusVariant dbusVar = variantList[0].value(); + const QDBusArgument &dbusArg = dbusVar.variant().value(); + if (dbusArg.currentType() == QDBusArgument::ArrayType) { + QDBusObjectPath objPath; + dbusArg.beginArray(); + while (!dbusArg.atEnd()) { + dbusArg >> objPath; + listObjPath.append(objPath); + } + dbusArg.endArray(); + } + + // 获取各session的用户名,过滤指定用户的信息 + for (auto objPath : listObjPath) { + QDBusInterface iface("org.freedesktop.DisplayManager", + objPath.path(), + "org.freedesktop.DBus.Properties", + QDBusConnection::systemBus()); + QDBusMessage result = iface.call("Get", + "org.freedesktop.DisplayManager.Session", + "UserName"); + if(result.type() == QDBusMessage::ErrorMessage) { + qWarning() << "Get Session username :" << result.errorMessage(); + continue; + } + QList variantList = result.arguments(); + if (variantList.size() <= 0) { + qDebug()<<"Get Session user info is null!"; + continue; + } + QDBusVariant dbusUNameVar = variantList[0].value(); + QString userName = dbusUNameVar.variant().value(); + if (strUserName == userName) { + result = iface.call("Get", + "org.freedesktop.DisplayManager.Session", + "Seat"); + if(result.type() == QDBusMessage::ErrorMessage) { + qWarning() << "Get Session seat :" << result.errorMessage(); + continue; + } + QList variantList = result.arguments(); + if (variantList.size() <= 0) { + qDebug()<<"Get Session seatis null!"; + continue; + } + QDBusVariant dbusSeatVar = variantList[0].value(); + QDBusObjectPath strSeat = dbusSeatVar.variant().value(); + if (!strSeat.path().isEmpty()) { + userDisplayIfInfo.strSeatPath = strSeat.path(); + userDisplayIfInfo.strUserName = strUserName; + userDisplayIfInfo.strSessionPath = objPath.path(); + } + } else { + continue ; + } + } + return userDisplayIfInfo; +} + +int SwitchUserUtils::SwitchToUserSession(QString seatPath, UserDisplayIfInfo &toUDII) +{ + // 检查Seat路径是否合规 + if (QDBusObjectPath(seatPath).path().isEmpty()) { + qWarning()<<"SwitchToUserSession failed, invalid seatpath:"< variantList = result.arguments(); + if (variantList.size() <= 0) { + qDebug()<<"Get Session type info is null!"; + return 2; + } + QDBusVariant dbusTypeVar = variantList[0].value(); + QString sessionType = dbusTypeVar.variant().value(); + if (strSessionDisplay.isEmpty() && sessionType != "wayland") { + continue; + } + } else { + if (strSessionDisplay.isEmpty()) { + /** + * 最后一个会话id时,如果该用户的Display不为空,则也认为最后一个会话有效 + **/ + if ((n+1) < listSessions.size() || strUserDisplay.isEmpty()) { + continue; + } + strSessionDisplay = strUserDisplay; + } + } + QString strUserSeatID = ""; + char *seat = NULL; + sd_session_get_seat(listSessions.at(n).toLatin1().data(), &seat); + if (seat) { + strUserSeatID = QString("%1").arg(seat); + free(seat); + seat = NULL; + } + qDebug()<<"SrcSeat:"<isServiceActivatable()) { +// GreeterService::instance()->SwitchToGreeterUser(toUDII.strUserName); +// QDBusMessage result = ifaceDM.call("SwitchToGreeter"); +// if(result.type() == QDBusMessage::ErrorMessage) { +// qWarning() << "SwitchUser SwitchToGreeter failed:" << result.errorMessage(); +// return -2; +// } +// return 2; +// } else { +// QDBusMessage result = ifaceDM.call("SwitchToUser", toUDII.strUserName, toUDII.strSessionPath); +// if(result.type() == QDBusMessage::ErrorMessage) { +// qWarning() << "SwitchUser SwitchToUser failed:" << result.errorMessage(); +// return -2; +// } +// return 1; +// } + } else { +// QDBusMessage result = ifaceDM.call("SwitchToGreeter"); +// if(result.type() == QDBusMessage::ErrorMessage) { +// qWarning() << "SwitchUser SwitchToGreeter failed:" << result.errorMessage(); +// return -2; +// } +// return 2; + } + return 0; +} + +bool SwitchUserUtils::SwitchToUserLock() +{ + QString strLockCommand = QStandardPaths::findExecutable("ukui-screensaver-command"); + if (!strLockCommand.isEmpty()) { + QProcess::execute(strLockCommand, QStringList() << "-S"); + return true; + } + return false; +} diff --git a/src/lock-backend/switchuserutils.h b/src/lock-backend/switchuserutils.h new file mode 100644 index 0000000..e426824 --- /dev/null +++ b/src/lock-backend/switchuserutils.h @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * +**/ +#ifndef SWITCHUSERUTILS_H +#define SWITCHUSERUTILS_H + +#include + +/** + * @brief + * 用户显示接口信息结构体 + */ +typedef struct UserDisplayIfInfo_s { + QString strSessionPath; /**< 用户显示会话路径 */ + QString strSeatPath; /**< 用户Seat路径 */ + QString strUserName; /**< 用户名 */ +}UserDisplayIfInfo; + +/** + * @brief + * 切换用户单元 + */ +class SwitchUserUtils +{ +public: + /** + * @brief + * 构造函数 + */ + SwitchUserUtils(); + + /** + * @brief + * 静态接口:获取当前进程执行所在用户名 + * @return QString 用户名 + */ + static QString GetCurUserName(); + /** + * @brief + * 静态接口:通过用户名获取用户id + * @param strUserName + * @return int + */ + static int GetUidByName(QString strUserName); + /** + * @brief + * 静态接口:获取用户显示接口信息 + * @param strUserName 用户名 + * @return UserDisplayIfInfo 显示接口信息 + */ + static UserDisplayIfInfo GetUserUDII(QString strUserName); + /** + * @brief + * 静态接口:切换用户会话 + * @param seatPath 用户会话所在的lightdm seat路径 + * @param toUDII 即将切换的用户lightdm显示信息 + * @return int 0:激活其他会话;1:切换到登录指定用户;2:切换到登录并选择用户;<0:切换异常 + */ + static int SwitchToUserSession(QString seatPath, UserDisplayIfInfo &toUDII); + + /** + * @brief + * 静态接口:切换到用户的锁屏切换用户界面 + * @return bool true: 切换成功;false:失败 + */ + static bool SwitchToUserLock(); + +}; + +#endif // SWITCHUSERUTILS_H diff --git a/src/ukui-screensaver-checkpass.cpp b/src/lock-checkpasswd/main.cpp similarity index 84% rename from src/ukui-screensaver-checkpass.cpp rename to src/lock-checkpasswd/main.cpp index 165259d..6f48647 100644 --- a/src/ukui-screensaver-checkpass.cpp +++ b/src/lock-checkpasswd/main.cpp @@ -1,20 +1,3 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ #include #include #include diff --git a/src/ukui-screensaver-command.cpp b/src/lock-command/main.cpp similarity index 99% rename from src/ukui-screensaver-command.cpp rename to src/lock-command/main.cpp index c18808c..4927143 100644 --- a/src/ukui-screensaver-command.cpp +++ b/src/lock-command/main.cpp @@ -22,7 +22,7 @@ #include #include #include -#include "types.h" +#include "utils.h" #include #include diff --git a/src/lock-dialog/backenddbushelper.cpp b/src/lock-dialog/backenddbushelper.cpp new file mode 100644 index 0000000..62fee90 --- /dev/null +++ b/src/lock-dialog/backenddbushelper.cpp @@ -0,0 +1,2337 @@ +/* + * Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * +**/ +#include "backenddbushelper.h" +#include "definetypes.h" +#include +#include +#include +#include +#include +#include + + +BackendDbusHelper::BackendDbusHelper(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) + : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) +{ + initConnections(); +} + +BackendDbusHelper::~BackendDbusHelper() +{ +} + +void BackendDbusHelper::initConnections() +{ + connect(this, &BackendDbusHelper::UpdateInformation, this, &BackendDbusHelper::onUpdateInformation); +} + +AgreementInfoPtr BackendDbusHelper::getAgreementInfo() +{ + AgreementInfoPtr agreementInfo = NULL; + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_GET_AGREEMENT; + QDBusPendingReply reply = GetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "getAgreementInfo 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()<<"getAgreementInfo Parse json failed!!"; + } else { + QJsonObject objRes = jsonDoc.object(); + if (objRes.isEmpty()) { + qInfo()<<"getAgreementInfo Json is null!!"; + } else { + if (objRes.contains("CmdId") && objRes.contains("Ret") && objRes.contains("Content")) { + int nCmdId = objRes.value("CmdId").toInt(-1); + int nRet = objRes.value("Ret").toInt(-1); + QJsonObject object = objRes.value("Content").toObject(); + if (nCmdId != LOCK_CMD_ID_GET_AGREEMENT || nRet != 0 || object.isEmpty()) { + qInfo()<<"getAgreementInfo Failed!!"; + } else { + agreementInfo = ParseAgreementInfo(objRes); + } + } else { + qInfo()<<"getAgreementInfo Json is invalid!!"; + } + } + } + } + + if(!agreementInfo){ + agreementInfo = std::make_shared(); + } + + return agreementInfo; +} + +QList BackendDbusHelper::getUsersInfo() +{ + QList listUser; + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_GET_USERINFO_LIST; + QDBusPendingReply reply = GetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "getUsersInfo 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()<<"getUsersInfo Parse json failed!!"; + } else { + QJsonObject objRes = jsonDoc.object(); + if (objRes.isEmpty()) { + qInfo()<<"getUsersInfo Json is null!!"; + } else { + if (objRes.contains("CmdId") && objRes.contains("Ret") && objRes.contains("Content")) { + int nCmdId = objRes.value("CmdId").toInt(-1); + int nRet = objRes.value("Ret").toInt(-1); + QJsonArray jsonArray = objRes.value("Content").toArray(); + if (nCmdId != LOCK_CMD_ID_GET_USERINFO_LIST || nRet != 0 || jsonArray.isEmpty()) { + qInfo()<<"getUsersInfo Failed!!"; + } else { + listUser = ParseUsersInfo(objRes); + } + } else { + qInfo()<<"getUsersInfo Json is invalid!!"; + } + } + } + } + return listUser; +} + +QList BackendDbusHelper::getSessionsInfo() +{ + QList listSession; + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_GET_SESSIONS_LIST; + QDBusPendingReply reply = GetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "getSessionsInfo 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()<<"getSessionsInfo Parse json failed!!"; + } else { + QJsonObject objRes = jsonDoc.object(); + if (objRes.isEmpty()) { + qInfo()<<"getSessionsInfo Json is null!!"; + } else { + if (objRes.contains("CmdId") && objRes.contains("Ret") && objRes.contains("Content")) { + int nCmdId = objRes.value("CmdId").toInt(-1); + int nRet = objRes.value("Ret").toInt(-1); + QJsonArray jsonArray = objRes.value("Content").toArray(); + if (nCmdId != LOCK_CMD_ID_GET_SESSIONS_LIST || nRet != 0 || jsonArray.isEmpty()) { + qInfo()<<"getSessionsInfo Failed!!"; + } else { + listSession = ParseSessionsInfo(objRes); + } + } else { + qInfo()<<"getSessionsInfo Json is invalid!!"; + } + } + } + } + return listSession; +} + +QStringList BackendDbusHelper::getBatteryArgs() +{ + QStringList listArgs; + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_UPOWER_BATTERY; + QDBusPendingReply reply = GetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "getBatteryArgs 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()<<"getBatteryArgs Parse json failed!!"; + } else { + QJsonObject objRes = jsonDoc.object(); + if (objRes.isEmpty()) { + qInfo()<<"getBatteryArgs Json is null!!"; + } else { + if (objRes.contains("CmdId") && objRes.contains("Ret") && objRes.contains("Content")) { + int nCmdId = objRes.value("CmdId").toInt(-1); + int nRet = objRes.value("Ret").toInt(-1); + QJsonArray jsonArray = objRes.value("Content").toArray(); + if (nCmdId != LOCK_CMD_ID_UPOWER_BATTERY || nRet != 0 || jsonArray.isEmpty()) { + qInfo()<<"getBatteryArgs Failed!!"; + } else { + listArgs = ParseBatteryArgs(objRes); + } + } else { + qInfo()<<"getBatteryArgs Json is invalid!!"; + } + } + } + } + return listArgs; +} + +QStringList BackendDbusHelper::getSleepLockcheck() +{ + QStringList listArgs; + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_SESSION_GET_SLEEP_LOCKCHECK; + QDBusPendingReply reply = GetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "getSleepLockcheck 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()<<"getSleepLockcheck Parse json failed!!"; + } else { + QJsonObject objRes = jsonDoc.object(); + if (objRes.isEmpty()) { + qInfo()<<"getSleepLockcheck Json is null!!"; + } else { + if (objRes.contains("CmdId") && objRes.contains("Ret") && objRes.contains("Content")) { + int nCmdId = objRes.value("CmdId").toInt(-1); + int nRet = objRes.value("Ret").toInt(-1); + QJsonArray jsonArray = objRes.value("Content").toArray(); + if (nCmdId != LOCK_CMD_ID_SESSION_GET_SLEEP_LOCKCHECK || nRet != 0 || jsonArray.isEmpty()) { + qInfo()<<"getSleepLockcheck Failed!!"; + } else { + listArgs = ParseSleepLockcheck(objRes); + } + } else { + qInfo()<<"getSleepLockcheck Json is invalid!!"; + } + } + } + } + return listArgs; +} + +QString BackendDbusHelper::getBatteryIconName() +{ + QString batteryIconName = ""; + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_UPOWER_BATTERY_STATUS; + QDBusPendingReply reply = GetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "getBatteryIconName 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()<<"getBatteryIconName Parse json failed!!"; + } else { + QJsonObject objRes = jsonDoc.object(); + if (objRes.isEmpty()) { + qInfo()<<"getBatteryIconName 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_UPOWER_BATTERY_STATUS || nRet != 0) { + qInfo()<<"getBatteryIconName Failed!!"; + } else { + batteryIconName = objRes.value("Content").toString(); + } + } else { + qInfo()<<"getBatteryIconName Json is invalid!!"; + } + } + } + } + return batteryIconName; +} + +bool BackendDbusHelper::getIsBattery() +{ + bool isBattery = false; + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_UPOWER_IS_BATTERY; + QDBusPendingReply reply = GetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "getIsBattery 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()<<"getIsBattery Parse json failed!!"; + } else { + QJsonObject objRes = jsonDoc.object(); + if (objRes.isEmpty()) { + qInfo()<<"getIsBattery 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_UPOWER_IS_BATTERY || nRet != 0) { + qInfo()<<"getIsBattery Failed!!"; + } else { + isBattery = objRes.value("Content").toBool(); + } + } else { + qInfo()<<"getIsBattery Json is invalid!!"; + } + } + } + } + return isBattery; +} + +bool BackendDbusHelper::setCurrentSession(QString strSession) +{ + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_SET_SESSION; + jsonCmd["Content"] = strSession; + QDBusPendingReply reply = SetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "setCurrentSession error: " << reply.error().message(); + return false; + } + return true; +} + +bool BackendDbusHelper::lockStateChanged(bool isVisible) +{ + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_LOCK_STATE_CHANGED; + jsonCmd["Content"] = isVisible; + QDBusPendingReply reply = SetInformation(QString(QJsonDocument(jsonCmd).toJson())); + if (reply.isError()) { + qWarning() << "lockStateChanged error: " << reply.error().message(); + return false; + } + return true; +} + +void BackendDbusHelper::startSession() +{ + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_START_SESSION; + QDBusPendingReply reply = SetInformation(QString(QJsonDocument(jsonCmd).toJson())); + if (reply.isError()) { + qWarning() << "startSession error: " << reply.error().message(); + } +} + +void BackendDbusHelper::pamAuthenticate(QString strUserName) +{ + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_PAMAUTH_AUTHENTICATE; + jsonCmd["UserName"] = strUserName; + QDBusPendingReply reply = SetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "pamAuthenticate error: " << reply.error().message(); + } +} + +void BackendDbusHelper::bioStartAuth(int uid, int nDevId) +{ + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_BIOAUTH_STARTAUTH; + jsonCmd["UserId"] = uid; + jsonCmd["DevId"] = nDevId; + QDBusPendingReply reply = SetInformation(QString(QJsonDocument(jsonCmd).toJson())); + if (reply.isError()) { + qWarning() << "bioStartAuth error: " << reply.error().message(); + } +} + +void BackendDbusHelper::bioStopAuth() +{ + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_BIOAUTH_STOPAUTH; + QDBusPendingReply reply = SetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "bioStopAuth error: " << reply.error().message(); + } +} + +void BackendDbusHelper::pamRespond(QString strRespond) +{ + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_PAMAUTH_RESPOND; + jsonCmd["Content"] = strRespond; + QDBusPendingReply reply = SetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "pamAuthenticate error: " << reply.error().message(); + } +} + +void BackendDbusHelper::pamAuthenticateCancel() +{ + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_PAMAUTH_AUTHENTICATE_CANCEL; + QDBusPendingReply reply = SetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "pamAuthenticate error: " << reply.error().message(); + } +} + +bool BackendDbusHelper::pamIsInAuthentication() +{ + bool isInAuthentication = false; + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_PAMAUTH_IS_INAUTHTICATION; + QDBusPendingReply reply = GetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "pamIsInAuthentication 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()<<"pamIsInAuthentication Parse json failed!!"; + } else { + QJsonObject objRes = jsonDoc.object(); + if (objRes.isEmpty()) { + qInfo()<<"pamIsInAuthentication 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_PAMAUTH_IS_INAUTHTICATION || nRet != 0) { + qInfo()<<"pamIsInAuthentication Failed!!"; + } else { + isInAuthentication = objRes.value("Content").toBool(); + } + } else { + qInfo()<<"pamIsInAuthentication Json is invalid!!"; + } + } + } + } + return isInAuthentication; +} + +bool BackendDbusHelper::pamIsAuthenticated() +{ + bool isAuthenticated = false; + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_PAMAUTH_IS_AUTHENTICATED; + QDBusPendingReply reply = GetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "pamIsAuthenticated 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()<<"pamIsAuthenticated Parse json failed!!"; + } else { + QJsonObject objRes = jsonDoc.object(); + if (objRes.isEmpty()) { + qInfo()<<"pamIsAuthenticated 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_PAMAUTH_IS_AUTHENTICATED || nRet != 0) { + qInfo()<<"pamIsAuthenticated Failed!!"; + } else { + isAuthenticated = objRes.value("Content").toBool(); + } + } else { + qInfo()<<"pamIsAuthenticated Json is invalid!!"; + } + } + } + } + return isAuthenticated; +} + +QString BackendDbusHelper::pamAuthenticateUser() +{ + QString strUser; + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_PAMAUTH_IS_INAUTHTICATION; + QDBusPendingReply reply = GetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "pamAuthenticateUser 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()<<"pamAuthenticateUser Parse json failed!!"; + } else { + QJsonObject objRes = jsonDoc.object(); + if (objRes.isEmpty()) { + qInfo()<<"pamAuthenticateUser 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_PAMAUTH_IS_INAUTHTICATION || nRet != 0) { + qInfo()<<"pamAuthenticateUser Failed!!"; + } else { + strUser = objRes.value("Content").toString(); + } + } else { + qInfo()<<"pamAuthenticateUser Json is invalid!!"; + } + } + } + } + return strUser; +} + +void BackendDbusHelper::ParsePamShowMessage(const QJsonObject &objRes) +{ + QString strMsg = objRes.value("Message").toString(); + int nType = objRes.value("MsgType").toInt(); + Q_EMIT pamShowMessage(strMsg, nType); +} + +void BackendDbusHelper::ParsePamShowPrompt(const QJsonObject &objRes) +{ + QString strPrompt = objRes.value("Prompt").toString(); + int nType = objRes.value("PromptType").toInt(); + Q_EMIT pamShowPrompt(strPrompt, nType); +} + +void BackendDbusHelper::ParsePamAuthCompleted(const QJsonObject &objRes) +{ + Q_UNUSED(objRes); + Q_EMIT pamAuthCompleted(); +} + +void BackendDbusHelper::ParseBioServiceStatus(const QJsonObject &objRes) +{ + Q_EMIT bioServiceStatusChanged(objRes.value("IsValid").toBool()); +} + +void BackendDbusHelper::ParseBioDeviceChanged(const QJsonObject &objRes) +{ + Q_UNUSED(objRes); + Q_EMIT bioDeviceChanged(); +} + +void BackendDbusHelper::ParseBioAuthShowMessage(const QJsonObject &objRes) +{ + Q_EMIT bioAuthShowMessage(objRes.value("Message").toString()); +} + +void BackendDbusHelper::ParseBioAuthStateChanged(const QJsonObject &objRes) +{ + Q_EMIT bioAuthStateChanged(objRes.value("State").toInt()); +} + +void BackendDbusHelper::ParseBioAuthFrameData(const QJsonObject &objRes) +{ + Q_EMIT bioAuthFrameData(objRes.value("Data").toString()); +} + +void BackendDbusHelper::ParseBioAuthCompleted(const QJsonObject &objRes) +{ + int nUid = objRes.value("UId").toInt(); + bool isSuccess = objRes.value("IsSuccess").toBool(); + int nError = objRes.value("ErrorNo").toInt(); + int nMaxFailedTime = objRes.value("MaxFailedTime").toInt(); + int nFailedTime = objRes.value("FailedTime").toInt(); + Q_EMIT bioAuthCompleted(nUid, isSuccess, nError, nMaxFailedTime, nFailedTime); +} + +QList BackendDbusHelper::bioGetAvailableDevices(int nUid) +{ + QList listDevInfo; + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_BIOAUTH_GET_AVAILABLE_DEVICES; + jsonCmd["UserId"] = nUid; + QDBusPendingReply reply = GetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "bioGetAvailableDevices 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()<<"bioGetAvailableDevices Parse json failed!!"; + } else { + QJsonObject objRes = jsonDoc.object(); + if (objRes.isEmpty()) { + qInfo()<<"bioGetAvailableDevices 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_BIOAUTH_GET_AVAILABLE_DEVICES || nRet != 0) { + qInfo()<<"bioGetAvailableDevices Failed!!"; + } else { + QJsonArray arrayDevInfo = objRes.value("Content").toArray(); + for (auto devInfoObj : arrayDevInfo) { + if (devInfoObj.isObject()) { + DeviceInfo devInfo; + devInfo.id = devInfoObj.toObject().value("id").toInt(); + devInfo.shortName = devInfoObj.toObject().value("ShortName").toString(); + devInfo.fullName = devInfoObj.toObject().value("FullName").toString(); + devInfo.driverEnable = devInfoObj.toObject().value("DriverEnable").toInt(); + devInfo.deviceNum = devInfoObj.toObject().value("DeviceNum").toInt(); + devInfo.deviceType = devInfoObj.toObject().value("DeviceType").toInt(); + devInfo.storageType = devInfoObj.toObject().value("StorageType").toInt(); + devInfo.eigType = devInfoObj.toObject().value("EigType").toInt(); + devInfo.verifyType = devInfoObj.toObject().value("VerifyType").toInt(); + devInfo.identifyType = devInfoObj.toObject().value("IdentifyType").toInt(); + devInfo.busType = devInfoObj.toObject().value("BusType").toInt(); + devInfo.deviceStatus = devInfoObj.toObject().value("DeviceStatus").toInt(); + devInfo.OpsStatus = devInfoObj.toObject().value("OpsStatus").toInt(); + listDevInfo.append(devInfo); + } + } + } + } else { + qInfo()<<"bioGetAvailableDevices Json is invalid!!"; + } + } + } + } + return listDevInfo; +} + +QList BackendDbusHelper::bioGetDisabledDevices(int nUid) +{ + QList listDevDisabled; + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_BIOAUTH_GET_DISABLED_DEVICES; + jsonCmd["UserId"] = nUid; + QDBusPendingReply reply = GetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "bioGetDisabledDevices 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()<<"bioGetDisabledDevices Parse json failed!!"; + } else { + QJsonObject objRes = jsonDoc.object(); + if (objRes.isEmpty()) { + qInfo()<<"bioGetDisabledDevices 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_BIOAUTH_GET_DISABLED_DEVICES || nRet != 0) { + qInfo()<<"bioGetDisabledDevices Failed!!"; + } else { + QJsonArray arrayDevInfo = objRes.value("Content").toArray(); + for (auto devInfoObj : arrayDevInfo) { + if (devInfoObj.isDouble()) { + listDevDisabled.append(devInfoObj.toInt()); + } + } + } + } else { + qInfo()<<"bioGetDisabledDevices Json is invalid!!"; + } + } + } + } + return listDevDisabled; +} + +int BackendDbusHelper::bioGetBioAuthState() +{ + int nAuthState = 0; + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_BIOAUTH_GET_STATE; + QDBusPendingReply reply = GetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "bioGetBioAuthState 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()<<"bioGetBioAuthState Parse json failed!!"; + } else { + QJsonObject objRes = jsonDoc.object(); + if (objRes.isEmpty()) { + qInfo()<<"bioGetBioAuthState 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_BIOAUTH_GET_STATE || nRet != 0) { + qInfo()<<"bioGetBioAuthState Failed!!"; + } else { + nAuthState = objRes.value("Content").toInt(); + } + } else { + qInfo()<<"bioGetBioAuthState Json is invalid!!"; + } + } + } + } + return nAuthState; +} + +DeviceInfo BackendDbusHelper::bioGetCurBioInfo() +{ + DeviceInfo curDevInfo; + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_BIOAUTH_GET_CURDEVICE; + QDBusPendingReply reply = GetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "bioGetCurBioInfo 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()<<"bioGetCurBioInfo Parse json failed!!"; + } else { + QJsonObject objRes = jsonDoc.object(); + if (objRes.isEmpty()) { + qInfo()<<"bioGetCurBioInfo 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_BIOAUTH_GET_CURDEVICE || nRet != 0) { + qInfo()<<"bioGetCurBioInfo Failed!!"; + } else { + QJsonObject objDevInfo = objRes.value("Content").toObject(); + if (!objDevInfo.isEmpty()) { + curDevInfo.id = objDevInfo.value("id").toInt(); + curDevInfo.shortName = objDevInfo.value("ShortName").toString(); + curDevInfo.fullName = objDevInfo.value("FullName").toString(); + curDevInfo.driverEnable = objDevInfo.value("DriverEnable").toInt(); + curDevInfo.deviceNum = objDevInfo.value("DeviceNum").toInt(); + curDevInfo.deviceType = objDevInfo.value("DeviceType").toInt(); + curDevInfo.storageType = objDevInfo.value("StorageType").toInt(); + curDevInfo.eigType = objDevInfo.value("EigType").toInt(); + curDevInfo.verifyType = objDevInfo.value("VerifyType").toInt(); + curDevInfo.identifyType = objDevInfo.value("IdentifyType").toInt(); + curDevInfo.busType = objDevInfo.value("BusType").toInt(); + curDevInfo.deviceStatus = objDevInfo.value("DeviceStatus").toInt(); + curDevInfo.OpsStatus = objDevInfo.value("OpsStatus").toInt(); + } + } + } else { + qInfo()<<"bioGetCurBioInfo Json is invalid!!"; + } + } + } + } + return curDevInfo; +} + +DeviceInfo BackendDbusHelper::bioFindDeviceById(int nUid, int nDevId) +{ + DeviceInfo curDevInfo; + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_BIOAUTH_FIND_DEVICE_BY_ID; + jsonCmd["UserId"] = nUid; + jsonCmd["DevId"] = nDevId; + QDBusPendingReply reply = GetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "bioFindDeviceById 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()<<"bioFindDeviceById Parse json failed!!"; + } else { + QJsonObject objRes = jsonDoc.object(); + if (objRes.isEmpty()) { + qInfo()<<"bioFindDeviceById 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_BIOAUTH_FIND_DEVICE_BY_ID || nRet != 0) { + qInfo()<<"bioFindDeviceById Failed!!"; + } else { + QJsonObject objDevInfo = objRes.value("Content").toObject(); + if (!objDevInfo.isEmpty()) { + curDevInfo.id = objDevInfo.value("id").toInt(); + curDevInfo.shortName = objDevInfo.value("ShortName").toString(); + curDevInfo.fullName = objDevInfo.value("FullName").toString(); + curDevInfo.driverEnable = objDevInfo.value("DriverEnable").toInt(); + curDevInfo.deviceNum = objDevInfo.value("DeviceNum").toInt(); + curDevInfo.deviceType = objDevInfo.value("DeviceType").toInt(); + curDevInfo.storageType = objDevInfo.value("StorageType").toInt(); + curDevInfo.eigType = objDevInfo.value("EigType").toInt(); + curDevInfo.verifyType = objDevInfo.value("VerifyType").toInt(); + curDevInfo.identifyType = objDevInfo.value("IdentifyType").toInt(); + curDevInfo.busType = objDevInfo.value("BusType").toInt(); + curDevInfo.deviceStatus = objDevInfo.value("DeviceStatus").toInt(); + curDevInfo.OpsStatus = objDevInfo.value("OpsStatus").toInt(); + } + } + } else { + qInfo()<<"bioFindDeviceById Json is invalid!!"; + } + } + } + } + return curDevInfo; +} + +DeviceInfo BackendDbusHelper::bioFindDeviceByName(int nUid, QString strDevName) +{ + DeviceInfo curDevInfo; + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_BIOAUTH_FIND_DEVICE_BY_NAME; + jsonCmd["UserId"] = nUid; + jsonCmd["DevName"] = strDevName; + QDBusPendingReply reply = GetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "bioFindDeviceByName 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()<<"bioFindDeviceByName Parse json failed!!"; + } else { + QJsonObject objRes = jsonDoc.object(); + if (objRes.isEmpty()) { + qInfo()<<"bioFindDeviceByName 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_BIOAUTH_FIND_DEVICE_BY_NAME || nRet != 0) { + qInfo()<<"bioFindDeviceByName Failed!!"; + } else { + QJsonObject objDevInfo = objRes.value("Content").toObject(); + if (!objDevInfo.isEmpty()) { + curDevInfo.id = objDevInfo.value("id").toInt(); + curDevInfo.shortName = objDevInfo.value("ShortName").toString(); + curDevInfo.fullName = objDevInfo.value("FullName").toString(); + curDevInfo.driverEnable = objDevInfo.value("DriverEnable").toInt(); + curDevInfo.deviceNum = objDevInfo.value("DeviceNum").toInt(); + curDevInfo.deviceType = objDevInfo.value("DeviceType").toInt(); + curDevInfo.storageType = objDevInfo.value("StorageType").toInt(); + curDevInfo.eigType = objDevInfo.value("EigType").toInt(); + curDevInfo.verifyType = objDevInfo.value("VerifyType").toInt(); + curDevInfo.identifyType = objDevInfo.value("IdentifyType").toInt(); + curDevInfo.busType = objDevInfo.value("BusType").toInt(); + curDevInfo.deviceStatus = objDevInfo.value("DeviceStatus").toInt(); + curDevInfo.OpsStatus = objDevInfo.value("OpsStatus").toInt(); + } + } + } else { + qInfo()<<"bioFindDeviceByName Json is invalid!!"; + } + } + } + } + return curDevInfo; +} + +QString BackendDbusHelper::bioGetDefaultDevice(int nUid, QString strUserName,int bioType /* = -1 */) +{ + QString strDevName; + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_BIOAUTH_GET_DEFAULT_DEVICE; + jsonCmd["UserId"] = nUid; + jsonCmd["UserName"] = strUserName; + if (bioType != -1) + jsonCmd["DevType"] = bioType; + QDBusPendingReply reply = GetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "bioGetDefaultDevice 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()<<"bioGetDefaultDevice Parse json failed!!"; + } else { + QJsonObject objRes = jsonDoc.object(); + if (objRes.isEmpty()) { + qInfo()<<"bioGetDefaultDevice 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_BIOAUTH_GET_DEFAULT_DEVICE || nRet != 0) { + qInfo()<<"bioGetDefaultDevice Failed!!"; + } else { + strDevName = objRes.value("Content").toString(); + } + } else { + qInfo()<<"bioGetDefaultDevice Json is invalid!!"; + } + } + } + } + return strDevName; +} + +QString BackendDbusHelper::getCurrentSession() +{ + QString strCurSession = ""; + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_GET_CURRENT_SESSION; + QDBusPendingReply reply = GetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "getCurrentSession 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()<<"getCurrentSession Parse json failed!!"; + } else { + QJsonObject objRes = jsonDoc.object(); + if (objRes.isEmpty()) { + qInfo()<<"getCurrentSession 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_GET_CURRENT_SESSION || nRet != 0) { + qInfo()<<"getCurrentSession Failed!!"; + } else { + strCurSession = objRes.value("Content").toString(); + } + } else { + qInfo()<<"getCurrentSession Json is invalid!!"; + } + } + } + } + return strCurSession; +} + +void BackendDbusHelper::onUpdateInformation(const QString &strJson) +{ + QJsonParseError jsonParseError; + const QJsonDocument jsonDoc = QJsonDocument::fromJson(strJson.toUtf8(), &jsonParseError); + if (jsonParseError.error != QJsonParseError::NoError) { + qInfo()<<"onUpdateInformation Parse json failed!!"; + } else { + QJsonObject objRes = jsonDoc.object(); + if (objRes.isEmpty()) { + qInfo()<<"onUpdateInformation Json is null!!"; + } else { + if (objRes.contains("CmdId")) { + int nCmdId = objRes.value("CmdId").toInt(-1); + switch (nCmdId) { + case LOCK_CMD_ID_USERINFO_CHANGED: + { + ParseUsersInfo(objRes); + } + break; + case LOCK_CMD_ID_CURRENT_USER_CHANGED: + { + ParseCurrentUser(objRes); + } + break; + case LOCK_CMD_ID_CURRENT_SESSION_CHANGED: + { + ParseCurrentSession(objRes); + } + break; + case LOCK_CMD_ID_LOGIN1_REQ_LOCK: + { + ParseLogin1ReqLock(objRes); + } + break; + case LOCK_CMD_ID_LOGIN1_REQ_UNLOCK: + { + ParseLogin1ReqUnLock(objRes); + } + break; + case LOCK_CMD_ID_LOGIN1_PREPAREFORSLEEP: + { + ParseLogin1PrepareForSleep(objRes); + } + break; + case LOCK_CMD_ID_LOGIN1_SESSION_ACTIVE_CHANGED: + { + ParseLogin1SessionActiveChanged(objRes); + } + break; + case LOCK_CMD_ID_GSETTINGS_GET_LOCKSCREEN_CONF: + { + ParseLockScreenConf(objRes); + } + break; + case LOCK_CMD_ID_GSETTINGS_SCREENSAVER_CONF_CHANGED: + { + ParseScreenSaverConf(objRes); + } + break; + case LOCK_CMD_ID_LOGIN1_LIDSTATE_CHANGED: + { + ParseLidstateChanged(objRes); + } + break; + case LOCK_CMD_ID_GSETTINGS_KEYBOARD_CONF_CHANGED: + { + ParseCapslockConf(objRes); + } + break; + case LOCK_CMD_ID_PAMAUTH_SHOWMESSAGE: + { + ParsePamShowMessage(objRes); + } + break; + case LOCK_CMD_ID_PAMAUTH_SHOWPROMPT: + { + ParsePamShowPrompt(objRes); + } + break; + case LOCK_CMD_ID_PAMAUTH_AUTH_COMPLETED: + { + ParsePamAuthCompleted(objRes); + } + break; + case LOCK_CMD_ID_GSETTINGS_USD_MEDIAKEYS_CONF_CHANGED: + { + ParseUsdMediaKeysConf(objRes); + } + break; + case LOCK_CMD_ID_UPOWER_BATTERY_STATUS: + { + ParseBatteryStatusChanged(objRes); + } + break; + case LOCK_CMD_ID_UPOWER_BATTERY: + { + ParseBatteryChanged(objRes); + } + break; + case LOCK_CMD_ID_BIOAUTH_SERVICE_STATUS_CHANGED: + { + ParseBioServiceStatus(objRes); + } + break; + case LOCK_CMD_ID_BIOAUTH_DEVICE_CHANGED: + { + ParseBioDeviceChanged(objRes); + } + break; + case LOCK_CMD_ID_BIOAUTH_SHOW_MESSAGE: + { + ParseBioAuthShowMessage(objRes); + } + break; + case LOCK_CMD_ID_BIOAUTH_AUTHSTATE_CHANGED: + { + ParseBioAuthStateChanged(objRes); + } + break; + case LOCK_CMD_ID_BIOAUTH_FRAME_DATA: + { + ParseBioAuthFrameData(objRes); + } + break; + case LOCK_CMD_ID_BIOAUTH_COMPLETE: + { + ParseBioAuthCompleted(objRes); + } + break; + default: + break; + } + } else { + qInfo()<<"getUsersInfo Json is invalid!!"; + } + } + } +} + +AgreementInfoPtr BackendDbusHelper::ParseAgreementInfo(const QJsonObject &objRes) +{ + AgreementInfoPtr agreementInfo; + QJsonObject jsonObject = objRes.value("Content").toObject(); + + if(jsonObject.isEmpty()){ + qInfo()<<"updateAgreementInfo failed!!"; + return agreementInfo; + } else { + agreementInfo = std::make_shared(); + agreementInfo->updateShowLoginPrompt(jsonObject.value("showLoginPrompt").toBool()); + agreementInfo->updateHideTitle(jsonObject.value("hideTitle").toBool()); + agreementInfo->updatePromptTitle(jsonObject.value("promptTitle").toString()); + agreementInfo->updatePromptText(jsonObject.value("promptText").toString()); + agreementInfo->updatePromptTextFilePath(jsonObject.value("promptTextFilePath").toString()); + + qDebug()<<"------------------------------------------------------------"; + qDebug()< BackendDbusHelper::ParseUsersInfo(const QJsonObject &objRes) +{ + QList listUser; + QJsonArray jsonArray = objRes.value("Content").toArray(); + if (jsonArray.isEmpty()) { + qInfo()<<"updateUsersInfo Failed!!"; + return listUser; + } else { + for (auto jsonValue : jsonArray) { + QJsonObject objUser = jsonValue.toObject(); + UserInfoPtr userPtr = std::make_shared(); + userPtr->updateUid((uid_t)objUser.value("uid").toDouble(-1)); + userPtr->updateName(objUser.value("name").toString()); + userPtr->updateFullName(objUser.value("fullName").toString()); + userPtr->updateHeadImage(objUser.value("headImg").toString()); + userPtr->updateLoggedIn(objUser.value("loggedIn").toBool(false)); + userPtr->updateBackground(objUser.value("backGround").toString()); + userPtr->updateLang(objUser.value("lang").toString()); + listUser.append(userPtr); + } + Q_EMIT usersInfoChanged(listUser); + } + return listUser; +} + +QList BackendDbusHelper::ParseSessionsInfo(const QJsonObject &objRes) +{ + QList listSessions; + QJsonArray jsonArray = objRes.value("Content").toArray(); + if (jsonArray.isEmpty()) { + qInfo()<<"ParseSessionsInfo Failed!!"; + return listSessions; + } else { + for (auto jsonValue : jsonArray) { + QJsonObject objUser = jsonValue.toObject(); + QString strSession = objUser.value("key").toString(); + listSessions.append(strSession); + } + } + return listSessions; +} + +QList BackendDbusHelper::ParseSaverThemes(const QJsonObject &objRes) +{ + QList listThemes; + QJsonArray jsonArray = objRes.value("Content").toArray(); + if (jsonArray.isEmpty()) { + qInfo()<<"ParseSessionsInfo Failed!!"; + return listThemes; + } else { + for (auto jsonValue : jsonArray) { + QJsonObject objUser = jsonValue.toObject(); + QString strSession = objUser.value("key").toString(); + qDebug() << "savertheme = " << strSession; + listThemes.append(strSession); + } + } + return listThemes; +} + +QStringList BackendDbusHelper::ParseBatteryArgs(const QJsonObject &objRes) +{ + QStringList listBattery; + QJsonArray jsonArray = objRes.value("Content").toArray(); + if (jsonArray.isEmpty()) { + qInfo()<<"ParseBatteryArgs Failed!!"; + return listBattery; + } else { + for (auto jsonValue : jsonArray) { + QJsonObject objUser = jsonValue.toObject(); + QString strBattery = objUser.value("key").toString(); + listBattery.append(strBattery); + } + } + return listBattery; +} + +QStringList BackendDbusHelper::ParseSleepLockcheck(const QJsonObject &objRes) +{ + QStringList sleepLockcheck; + QJsonArray jsonArray = objRes.value("Content").toArray(); + if (jsonArray.isEmpty()) { + qInfo()<<"ParseSleepLockcheck Failed!!"; + return sleepLockcheck; + } else { + for (auto jsonValue : jsonArray) { + QJsonObject objUser = jsonValue.toObject(); + QString strLockcheck = objUser.value("key").toString(); + sleepLockcheck.append(strLockcheck); + } + } + return sleepLockcheck; +} + +QStringList BackendDbusHelper::ParseShutdownLockcheck(const QJsonObject &objRes) +{ + QStringList shutdownLockcheck; + QJsonArray jsonArray = objRes.value("Content").toArray(); + if (jsonArray.isEmpty()) { + qInfo()<<"ParseShutdownLockcheck Failed!!"; + return shutdownLockcheck; + } else { + for (auto jsonValue : jsonArray) { + QJsonObject objUser = jsonValue.toObject(); + QString strLockcheck = objUser.value("key").toString(); + shutdownLockcheck.append(strLockcheck); + } + } + return shutdownLockcheck; +} + +bool BackendDbusHelper::ParseLogin1ReqLock(const QJsonObject &objRes) +{ + Q_UNUSED(objRes); + Q_EMIT requestLock(); + return true; +} + +bool BackendDbusHelper::ParseLogin1ReqUnLock(const QJsonObject &objRes) +{ + Q_UNUSED(objRes); + Q_EMIT requestUnlock(); + return true; +} + +bool BackendDbusHelper::ParseLogin1PrepareForSleep(const QJsonObject &objRes) +{ + bool isSleep = objRes.value("IsSleep").toBool(false); + Q_EMIT PrepareForSleep(isSleep); + return true; +} + +bool BackendDbusHelper::ParseLogin1SessionActiveChanged(const QJsonObject &objRes) +{ + bool isActive = objRes.value("IsActive").toBool(true); + Q_EMIT sessionActiveChanged(isActive); + return true; +} + +bool BackendDbusHelper::ParseLidstateChanged(const QJsonObject &objRes) +{ + QString lidstate = objRes.value("Lidstate").toString(); + Q_EMIT lidstateChanged(lidstate); + return true; +} + +bool BackendDbusHelper::ParseBatteryStatusChanged(const QJsonObject &objRes) +{ + QString iconName = objRes.value("IconName").toString(); + Q_EMIT batteryStatusChanged(iconName); + return true; +} + +bool BackendDbusHelper::ParseBatteryChanged(const QJsonObject &objRes) +{ + QStringList listBattery; + listBattery = ParseBatteryArgs(objRes); + Q_EMIT batteryChanged(listBattery); + return true; +} + +bool BackendDbusHelper::isSessionActive() +{ + bool isActive = true; + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_LOGIN1_IS_SESSION_ACTIVE; + QDBusPendingReply reply = GetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "isSessionActive 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()<<"isSessionActive Parse json failed!!"; + } else { + QJsonObject objRes = jsonDoc.object(); + if (objRes.isEmpty()) { + qInfo()<<"isSessionActive 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_LOGIN1_IS_SESSION_ACTIVE || nRet != 0) { + qInfo()<<"isSessionActive Failed!!"; + } else { + isActive = objRes.value("IsActive").toBool(true); + } + } else { + qInfo()<<"isSessionActive Json is invalid!!"; + } + } + } + } + return isActive; +} + +bool BackendDbusHelper::setCurrentUser(QString strUserName) +{ + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_SET_USER; + jsonCmd["Content"] = strUserName; + QDBusPendingReply reply = SetInformation(QString(QJsonDocument(jsonCmd).toJson())); + if (reply.isError()) { + qWarning() << "setCurrentUser error: " << reply.error().message(); + return false; + } + return true; +} + +bool BackendDbusHelper::usdExternalDoAction(int actionType) +{ + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_USD_MEDIAKEYS; + jsonCmd["Content"] = actionType; + QDBusPendingReply reply = SetInformation(QString(QJsonDocument(jsonCmd).toJson())); + if (reply.isError()) { + qWarning() << "setCurrentUser error: " << reply.error().message(); + return false; + } + return true; +} + +QString BackendDbusHelper::getDefaultAuthUser() +{ + QString strDefUser = ""; + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_GET_DEFAULT_AUTH_USER; + QDBusPendingReply reply = GetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "getDefaultAuthUser 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()<<"getDefaultAuthUser Parse json failed!!"; + } else { + QJsonObject objRes = jsonDoc.object(); + if (objRes.isEmpty()) { + qInfo()<<"getDefaultAuthUser 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_GET_DEFAULT_AUTH_USER || nRet != 0) { + qInfo()<<"getDefaultAuthUser Failed!!"; + } else { + strDefUser = objRes.value("Content").toString(); + } + } else { + qInfo()<<"getDefaultAuthUser Json is invalid!!"; + } + } + } + } + return strDefUser; +} + +QString BackendDbusHelper::getCurrentUser() +{ + QString strCurUser = ""; + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_GET_CURRENT_USER; + QDBusPendingReply reply = GetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "getCurrentUser 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()<<"getCurrentUser Parse json failed!!"; + } else { + QJsonObject objRes = jsonDoc.object(); + if (objRes.isEmpty()) { + qInfo()<<"getCurrentUser 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_GET_CURRENT_USER || nRet != 0) { + qInfo()<<"getCurrentUser Failed!!"; + } else { + strCurUser = objRes.value("Content").toString(); + } + } else { + qInfo()<<"getCurrentUser Json is invalid!!"; + } + } + } + } + return strCurUser; +} + +bool BackendDbusHelper::ParseCurrentUser(const QJsonObject &objRes) +{ + QString strCurUser = objRes.value("Content").toString(); + Q_EMIT currentUserChanged(strCurUser); + return true; +} + +bool BackendDbusHelper::ParseCurrentSession(const QJsonObject &objRes) +{ + QString strSession = objRes.value("Content").toString(); + Q_EMIT currentSessionChanged(strSession); + return true; +} + +QVariant BackendDbusHelper::getScreenSaverConf(QString strKey) +{ + QVariant varValue; + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_GSETTINGS_GET_SCREENSAVER_CONF; + jsonCmd["Key"] = strKey; + QDBusPendingReply reply = GetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "getScreenSaverConf 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()<<"getScreenSaverConf Parse json failed!!"; + } else { + QJsonObject objRes = jsonDoc.object(); + if (objRes.isEmpty()) { + qInfo()<<"getScreenSaverConf 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_SCREENSAVER_CONF || nRet != 0) { + qInfo()<<"getScreenSaverConf Failed!!"; + } else { + varValue = objRes.value(strKey); + } + } else { + qInfo()<<"getScreenSaverConf Json is invalid!!"; + } + } + } + } + return varValue; +} + +bool BackendDbusHelper::setScreenSaverConf(QString strKey, QVariant value) +{ + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_GSETTINGS_SET_SCREENSAVER_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 reply = SetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "setScreenSaverConf error: " << reply.error().message(); + return false; + } + return true; +} + +bool BackendDbusHelper::ParseScreenSaverConf(const QJsonObject &objRes) +{ + QString strKey = objRes.value("Key").toString(); + Q_EMIT screenSaverConfChanged(strKey, objRes.value("Value").toVariant()); + return true; +} + +bool BackendDbusHelper::ParseLockScreenConf(const QJsonObject &objRes) +{ + QString strKey = objRes.value("Key").toString(); + Q_EMIT lockScreenConfChanged(strKey, objRes.value("Value").toVariant()); + return true; +} + +bool BackendDbusHelper::ParsePowerManagerConf(const QJsonObject &objRes) +{ + QString strKey = objRes.value("Key").toString(); + Q_EMIT powerManagerConfChanged(strKey, objRes.value("Value").toVariant()); + return true; +} + +bool BackendDbusHelper::ParseMateBgConf(const QJsonObject &objRes) +{ + QString strKey = objRes.value("Key").toString(); + Q_EMIT mateBgConfChanged(strKey, objRes.value("Value").toVariant()); + return true; +} + +bool BackendDbusHelper::ParseUkccPluginsConf(const QJsonObject &objRes) +{ + QString strKey = objRes.value("Key").toString(); + Q_EMIT ukccPluginsConfChanged(strKey, objRes.value("Value").toVariant()); + return true; +} + +bool BackendDbusHelper::ParseThemeStyleConf(const QJsonObject &objRes) +{ + QString strKey = objRes.value("Key").toString(); + Q_EMIT themeStyleConfChanged(strKey, objRes.value("Value").toVariant()); + return true; +} + +bool BackendDbusHelper::ParseSessionConf(const QJsonObject &objRes) +{ + QString strKey = objRes.value("Key").toString(); + Q_EMIT sessionConfChanged(strKey, objRes.value("Value").toVariant()); + return true; +} + +bool BackendDbusHelper::ParseCapslockConf(const QJsonObject &objRes) +{ + bool state = objRes.value("Value").toBool(); + Q_EMIT capslockConfChanged(state); + return true; +} + +bool BackendDbusHelper::ParseUsdMediaKeysConf(const QJsonObject &objRes) +{ + QString strKey = objRes.value("Key").toString(); + Q_EMIT usdMediaKeysConfChanged(strKey, objRes.value("Value").toString()); + return true; +} + +QVariant BackendDbusHelper::getLockScreenConf(QString strKey) +{ + QVariant varValue; + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_GSETTINGS_GET_LOCKSCREEN_CONF; + jsonCmd["Key"] = strKey; + QDBusPendingReply reply = GetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "getLockScreenConf 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()<<"getLockScreenConf Parse json failed!!"; + } else { + QJsonObject objRes = jsonDoc.object(); + if (objRes.isEmpty()) { + qInfo()<<"getLockScreenConf 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_LOCKSCREEN_CONF || nRet != 0) { + qInfo()<<"getLockScreenConf Failed!!"; + } else { + varValue = objRes.value(strKey); + } + } else { + qInfo()<<"getLockScreenConf Json is invalid!!"; + } + } + } + } + return varValue; +} + +QStringList BackendDbusHelper::getShutdownLockcheck() +{ + QStringList listArgs; + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_SESSION_GET_SHUTDOWN_LOCKCHECK; + QDBusPendingReply reply = GetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "getShutdownLockcheck 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()<<"getShutdownLockcheck Parse json failed!!"; + } else { + QJsonObject objRes = jsonDoc.object(); + if (objRes.isEmpty()) { + qInfo()<<"getShutdownLockcheck Json is null!!"; + } else { + if (objRes.contains("CmdId") && objRes.contains("Ret") && objRes.contains("Content")) { + int nCmdId = objRes.value("CmdId").toInt(-1); + int nRet = objRes.value("Ret").toInt(-1); + QJsonArray jsonArray = objRes.value("Content").toArray(); + if (nCmdId != LOCK_CMD_ID_SESSION_GET_SHUTDOWN_LOCKCHECK || nRet != 0 || jsonArray.isEmpty()) { + qInfo()<<"getShutdownLockcheck Failed!!"; + } else { + listArgs = ParseShutdownLockcheck(objRes); + } + } else { + qInfo()<<"getShutdownLockcheck Json is invalid!!"; + } + } + } + } + return listArgs; +} + +QList BackendDbusHelper::getSaverThemes() +{ + QList listThemes; + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_LOCK_SCREEN_GET_THEMES; + QDBusPendingReply reply = GetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "getSaverThemes 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()<<"getSaverThemes Parse json failed!!"; + } else { + QJsonObject objRes = jsonDoc.object(); + if (objRes.isEmpty()) { + qInfo()<<"getSaverThemes 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); + QJsonArray jsonArray = objRes.value("Content").toArray(); + if (nCmdId != LOCK_CMD_ID_LOCK_SCREEN_GET_THEMES || nRet != 0 || jsonArray.isEmpty()) { + qInfo()<<"getSaverThemes Failed!!"; + } else { + listThemes = ParseSaverThemes(objRes); + } + } else { + qInfo()<<"getSaverThemes Json is invalid!!"; + } + } + } + } + return listThemes; +} + +bool BackendDbusHelper::setLockScreenConf(QString strKey, QVariant value) +{ + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_GSETTINGS_SET_LOCKSCREEN_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 reply = SetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "setLockScreenConf error: " << reply.error().message(); + return false; + } + return true; +} + +QVariant BackendDbusHelper::getPowerManagerConf(QString strKey) +{ + QVariant varValue; + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_GSETTINGS_GET_POWERMANAGER_CONF; + jsonCmd["Key"] = strKey; + QDBusPendingReply reply = GetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "getPowerManagerConf 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()<<"getPowerManagerConf Parse json failed!!"; + } else { + QJsonObject objRes = jsonDoc.object(); + if (objRes.isEmpty()) { + qInfo()<<"getPowerManagerConf 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_POWERMANAGER_CONF || nRet != 0) { + qInfo()<<"getPowerManagerConf Failed!!"; + } else { + varValue = objRes.value(strKey); + } + } else { + qInfo()<<"getPowerManagerConf Json is invalid!!"; + } + } + } + } + return varValue; +} + +bool BackendDbusHelper::setPowerManagerConf(QString strKey, QVariant value) +{ + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_GSETTINGS_SET_POWERMANAGER_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 reply = SetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "setPowerManagerConf error: " << reply.error().message(); + return false; + } + return true; +} + +QVariant BackendDbusHelper::getMateBgConf(QString strKey) +{ + QVariant varValue; + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_GSETTINGS_GET_MATEBG_CONF; + jsonCmd["Key"] = strKey; + QDBusPendingReply reply = GetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "getMateBgConf 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()<<"getMateBgConf Parse json failed!!"; + } else { + QJsonObject objRes = jsonDoc.object(); + if (objRes.isEmpty()) { + qInfo()<<"getMateBgConf 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_MATEBG_CONF || nRet != 0) { + qInfo()<<"getMateBgConf Failed!!"; + } else { + varValue = objRes.value(strKey); + } + } else { + qInfo()<<"getMateBgConf Json is invalid!!"; + } + } + } + } + return varValue; +} + +bool BackendDbusHelper::setMateBgConf(QString strKey, QVariant value) +{ + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_GSETTINGS_SET_MATEBG_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 reply = SetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "setMateBgConf error: " << reply.error().message(); + return false; + } + return true; +} + +QVariant BackendDbusHelper::getUkccPluginsConf(QString strKey) +{ + QVariant varValue; + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_GSETTINGS_GET_UKCCPLUGINS_CONF; + jsonCmd["Key"] = strKey; + QDBusPendingReply reply = GetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "getUkccPluginsConf 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()<<"getUkccPluginsConf Parse json failed!!"; + } else { + QJsonObject objRes = jsonDoc.object(); + if (objRes.isEmpty()) { + qInfo()<<"getUkccPluginsConf 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_UKCCPLUGINS_CONF || nRet != 0) { + qInfo()<<"getUkccPluginsConf Failed!!"; + } else { + varValue = objRes.value(strKey); + } + } else { + qInfo()<<"getUkccPluginsConf Json is invalid!!"; + } + } + } + } + return varValue; +} + +bool BackendDbusHelper::setUkccPluginsConf(QString strKey, QVariant value) +{ + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_GSETTINGS_SET_UKCCPLUGINS_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 reply = SetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "setUkccPluginsConf error: " << reply.error().message(); + return false; + } + return true; +} + +QVariant BackendDbusHelper::getThemeStyleConf(QString strKey) +{ + QVariant varValue; + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_GSETTINGS_GET_THEMESTYLE_CONF; + jsonCmd["Key"] = strKey; + QDBusPendingReply reply = GetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "getThemeStyleConf 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()<<"getThemeStyleConf Parse json failed!!"; + } else { + QJsonObject objRes = jsonDoc.object(); + if (objRes.isEmpty()) { + qInfo()<<"getThemeStyleConf 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_THEMESTYLE_CONF || nRet != 0) { + qInfo()<<"getThemeStyleConf Failed!!"; + } else { + varValue = objRes.value(strKey); + } + } else { + qInfo()<<"getThemeStyleConf Json is invalid!!"; + } + } + } + } + return varValue; +} + +bool BackendDbusHelper::setThemeStyleConf(QString strKey, QVariant value) +{ + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_GSETTINGS_SET_THEMESTYLE_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 reply = SetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "setThemeStyleConf error: " << reply.error().message(); + return false; + } + return true; +} + +QVariant BackendDbusHelper::getSessionConf(QString strKey) +{ + QVariant varValue; + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_GSETTINGS_GET_SESSION_CONF; + jsonCmd["Key"] = strKey; + QDBusPendingReply reply = GetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "getSessionConf 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()<<"getSessionConf Parse json failed!!"; + } else { + QJsonObject objRes = jsonDoc.object(); + if (objRes.isEmpty()) { + qInfo()<<"getSessionConf 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_SESSION_CONF || nRet != 0) { + qInfo()<<"getSessionConf Failed!!"; + } else { + varValue = objRes.value(strKey); + } + } else { + qInfo()<<"getSessionConf Json is invalid!!"; + } + } + } + } + return varValue; +} + +bool BackendDbusHelper::setSessionConf(QString strKey, QVariant value) +{ + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_GSETTINGS_SET_SESSION_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 reply = SetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "setSessionConf error: " << reply.error().message(); + return false; + } + return true; +} + +QVariant BackendDbusHelper::getKeyboardConf(QString strKey) +{ + QVariant varValue; + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_GSETTINGS_GET_KEYBOARD_CONF; + jsonCmd["Key"] = strKey; + QJsonObject objRes ; + QDBusPendingReply reply = GetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "getKeyboardConf 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()<<"getKeyboardConf Parse json failed!!"; + } else { + objRes = jsonDoc.object(); + if (objRes.isEmpty()) { + qInfo()<<"getKeyboardConf 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_KEYBOARD_CONF || nRet != 0) { + qInfo()<<"getKeyboardConf Failed!!"; + } else { + varValue = objRes.value(strKey); + } + } else { + qInfo()<<"getKeyboardConf Json is invalid!!"; + } + } + } + } + return varValue; +} + +bool BackendDbusHelper::setKeyboardConf(QString strKey, QVariant value) +{ + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_GSETTINGS_SET_KEYBOARD_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 reply = SetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "setKeyboardConf error: " << reply.error().message(); + return false; + } + return true; +} + +QVariant BackendDbusHelper::getUsdMediaKeys(QString strKey) +{ + QVariant varValue; + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_GSETTINGS_GET_USD_MEDIAKEYS_CONF; + jsonCmd["Key"] = strKey; + QJsonObject objRes ; + QDBusPendingReply reply = GetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "getUsdMediaKeys 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()<<"getUsdMediaKeys Parse json failed!!"; + } else { + objRes = jsonDoc.object(); + if (objRes.isEmpty()) { + qInfo()<<"getUsdMediaKeys 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_MEDIAKEYS_CONF || nRet != 0) { + qInfo()<<"getUsdMediaKeys Failed!!"; + } else { + varValue = objRes.value(strKey); + } + } else { + qInfo()<<"getUsdMediaKeys Json is invalid!!"; + } + } + } + } + return varValue; +} + +bool BackendDbusHelper::setPowerManager(QString strFuncName) +{ + qWarning()<< __LINE__ << __FUNCTION__ << "===================="; + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_LOGIN1_SET_POWER_MANAGER; + jsonCmd["Content"] = strFuncName; + QDBusPendingReply reply = SetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning()<< __LINE__ << __FUNCTION__ << reply.error().message(); + return false; + } + return true; +} + +bool BackendDbusHelper::getPowerManagerCanSuspend() +{ + bool canFlag = true; + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_LOGIN1_GET_POWER_MANAGER_CANSUSPEND; + QDBusPendingReply reply = GetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "getPowerManagerCanSuspend 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()<<"getPowerManagerCanSuspend Parse json failed!!"; + } else { + QJsonObject objRes = jsonDoc.object(); + if (objRes.isEmpty()) { + qInfo()<<"getPowerManagerCanSuspend 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_LOGIN1_GET_POWER_MANAGER_CANSUSPEND || nRet != 0) { + qInfo()<<"getPowerManagerCanSuspend Failed!!"; + } else { + canFlag = objRes.value("Content").toBool(); + } + } else { + qInfo()<<"getPowerManagerCanSuspend Json is invalid!!"; + } + } + } + } + return canFlag; +} + +bool BackendDbusHelper::getPowerManagerCanReboot() +{ + bool canFlag = true; + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_LOGIN1_GET_POWER_MANAGER_CANREBOOT; + QDBusPendingReply reply = GetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "getPowerManagerCanReboot 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()<<"getPowerManagerCanReboot Parse json failed!!"; + } else { + QJsonObject objRes = jsonDoc.object(); + if (objRes.isEmpty()) { + qInfo()<<"getPowerManagerCanReboot 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_LOGIN1_GET_POWER_MANAGER_CANREBOOT || nRet != 0) { + qInfo()<<"getPowerManagerCanReboot Failed!!"; + } else { + canFlag = objRes.value("Content").toBool(); + } + } else { + qInfo()<<"getPowerManagerCanReboot Json is invalid!!"; + } + } + } + } + return canFlag; +} + +bool BackendDbusHelper::getPowerManagerCanPowerOff() +{ + bool canFlag = true; + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_LOGIN1_GET_POWER_MANAGER_CANPOWEROFF; + QDBusPendingReply reply = GetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "getPowerManagerCanPowerOff 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()<<"getPowerManagerCanPowerOff Parse json failed!!"; + } else { + QJsonObject objRes = jsonDoc.object(); + if (objRes.isEmpty()) { + qInfo()<<"getPowerManagerCanPowerOff 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_LOGIN1_GET_POWER_MANAGER_CANPOWEROFF || nRet != 0) { + qInfo()<<"getPowerManagerCanPowerOff Failed!!"; + } else { + canFlag = objRes.value("Content").toBool(); + } + } else { + qInfo()<<"getPowerManagerCanPowerOff Json is invalid!!"; + } + } + } + } + return canFlag; +} + +bool BackendDbusHelper::getPowerManagerCanHibernate() +{ + bool canFlag = true; + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_LOGIN1_GET_POWER_MANAGER_CANHIBERNATE; + QDBusPendingReply reply = GetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "getPowerManagerCanHibernate 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()<<"getPowerManagerCanHibernate Parse json failed!!"; + } else { + QJsonObject objRes = jsonDoc.object(); + if (objRes.isEmpty()) { + qInfo()<<"getPowerManagerCanHibernate 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_LOGIN1_GET_POWER_MANAGER_CANHIBERNATE || nRet != 0) { + qInfo()<<"getPowerManagerCanHibernate Failed!!"; + } else { + canFlag = objRes.value("Content").toBool(); + } + } else { + qInfo()<<"getPowerManagerCanHibernate Json is invalid!!"; + } + } + } + } + return canFlag; +} diff --git a/src/lock-dialog/backenddbushelper.h b/src/lock-dialog/backenddbushelper.h new file mode 100644 index 0000000..5e5c287 --- /dev/null +++ b/src/lock-dialog/backenddbushelper.h @@ -0,0 +1,422 @@ +/* + * Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * +**/ +#ifndef BACKENDDBUSHELPER_H +#define BACKENDDBUSHELPER_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include "userinfo.h" +#include "agreementinfo.h" +#include "biodefines.h" + +/** + * @brief 后端服务访问工具类 + * + */ +class BackendDbusHelper : public QDBusAbstractInterface +{ + Q_OBJECT +public: + /** + * @brief 接口名称 + * + * @return const char + */ + static inline const char *staticInterfaceName() + { return "org.ukui.ScreenSaver"; } + +public: + /** + * @brief 构造 + * + * @param service dbus服务名称 + * @param path dbus路径 + * @param connection dbus连接 + * @param parent 父指针 + */ + BackendDbusHelper(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = nullptr); + + /** + * @brief 析构 + * + */ + ~BackendDbusHelper(); + +public: + /** + * @brief 获取用户信息列表 + * + * @return QList + */ + QList getUsersInfo(); + + bool isSessionActive(); + + QString getDefaultAuthUser(); + + QString getCurrentUser(); + + QList getSessionsInfo(); + QString getCurrentSession(); + + AgreementInfoPtr getAgreementInfo(); + QVariant getLockScreenConf(QString strKey); + bool setLockScreenConf(QString strKey, QVariant value); + QVariant getScreenSaverConf(QString strKey); + bool setScreenSaverConf(QString strKey, QVariant value); + QVariant getPowerManagerConf(QString strKey); + bool setPowerManagerConf(QString strKey, QVariant value); + QVariant getMateBgConf(QString strKey); + bool setMateBgConf(QString strKey, QVariant value); + QVariant getUkccPluginsConf(QString strKey); + bool setUkccPluginsConf(QString strKey, QVariant value); + QVariant getThemeStyleConf(QString strKey); + bool setThemeStyleConf(QString strKey, QVariant value); + QVariant getSessionConf(QString strKey); + bool setSessionConf(QString strKey, QVariant value); + QVariant getKeyboardConf(QString strKey); + bool setKeyboardConf(QString strKey, QVariant value); + + QVariant getUsdMediaKeys(QString strKey); + + QList getSaverThemes(); + + /** + * @brief 调用usd dbus接口实现相关快捷键功能 + * + *@param actionType:快捷键类型 + * + * @return 是否调用成功 + */ + bool usdExternalDoAction(int actionType); + bool getPowerManagerCanHibernate(); + bool getPowerManagerCanPowerOff(); + bool getPowerManagerCanReboot(); + bool getPowerManagerCanSuspend(); + + QStringList getBatteryArgs(); + + QString getBatteryIconName(); + + bool getIsBattery(); + + QStringList getSleepLockcheck(); + + QStringList getShutdownLockcheck(); + +public Q_SLOTS: + /** + * @brief dbus服务信息更新处理 + * + * @param strJson 信息json + */ + void onUpdateInformation(const QString &strJson); + + bool setCurrentUser(QString strUserName); + bool setCurrentSession(QString strSession); + bool lockStateChanged(bool isVisible); + void startSession(); + + void pamAuthenticate(QString strUserName); + void pamRespond(QString strRespond); + void pamAuthenticateCancel(); + bool pamIsInAuthentication(); + bool pamIsAuthenticated(); + QString pamAuthenticateUser(); + bool setPowerManager(QString strFuncName); + + void bioStartAuth(int uid, int nDevId); + void bioStopAuth(); + QList bioGetAvailableDevices(int nUid); + QList bioGetDisabledDevices(int nUid); + int bioGetBioAuthState(); + DeviceInfo bioGetCurBioInfo(); + DeviceInfo bioFindDeviceById(int nUid, int nDevId); + DeviceInfo bioFindDeviceByName(int nUid, QString strDevName); + QString bioGetDefaultDevice(int nUid, QString strUserName,int bioType = -1); +public Q_SLOTS: // METHODS + /** + * @brief 获取黑色屏保状态 + * + * @return QDBusPendingReply 是否为黑色屏保状态 + */ + inline QDBusPendingReply GetBlankState() + { + QList argumentList; + return asyncCallWithArgumentList(QStringLiteral("GetBlankState"), argumentList); + } + + /** + * @brief 获取信息 + * + * @param in0 信息参数json + * @return QDBusPendingReply 信息json + */ + inline QDBusPendingReply GetInformation(const QString &in0) + { + QList argumentList; + argumentList << QVariant::fromValue(in0); + return asyncCallWithArgumentList(QStringLiteral("GetInformation"), argumentList); + } + + /** + * @brief 获取锁定状态 + * + * @return QDBusPendingReply 锁定状态 + */ + inline QDBusPendingReply GetLockState() + { + QList argumentList; + return asyncCallWithArgumentList(QStringLiteral("GetLockState"), argumentList); + } + + /** + * @brief 锁定 + * + * @return QDBusPendingReply<> + */ + inline QDBusPendingReply<> Lock() + { + QList argumentList; + return asyncCallWithArgumentList(QStringLiteral("Lock"), argumentList); + } + + /** + * @brief 以黑色屏保方式锁定 + * + * @param in0 触发锁定的类型 + * @return QDBusPendingReply 是否锁定成功 + */ + inline QDBusPendingReply LockByBlank(int in0) + { + QList argumentList; + argumentList << QVariant::fromValue(in0); + return asyncCallWithArgumentList(QStringLiteral("LockByBlank"), argumentList); + } + + /** + * @brief 设置信息 + * + * @param in0 信息参数json + * @return QDBusPendingReply 设置结果 0 成功,其他失败 + */ + inline QDBusPendingReply SetInformation(const QString &in0) + { + QList argumentList; + argumentList << QVariant::fromValue(in0); + return asyncCallWithArgumentList(QStringLiteral("SetInformation"), argumentList); + } + + /** + * @brief 设置锁定状态 + * + * @return QDBusPendingReply<> + */ + inline QDBusPendingReply<> SetLockState() + { + QList argumentList; + return asyncCallWithArgumentList(QStringLiteral("SetLockState"), argumentList); + } + + /** + * @brief 显示屏保 + * + * @return QDBusPendingReply<> + */ + inline QDBusPendingReply<> ShowScreensaver() + { + QList argumentList; + return asyncCallWithArgumentList(QStringLiteral("ShowScreensaver"), argumentList); + } + + /** + * @brief 解锁 + * + * @return QDBusPendingReply<> + */ + inline QDBusPendingReply<> UnLock() + { + QList argumentList; + return asyncCallWithArgumentList(QStringLiteral("UnLock"), argumentList); + } + +Q_SIGNALS: // SIGNALS + /** + * @brief 第二次启动参数通知 + * + * @param param 启动参数 + */ + void SecondRunParam(const QString ¶m); + /** + * @brief 会话空闲进入屏保 + * + */ + void SessionIdle(); + /** + * @brief 会话空闲进入锁屏 + * + */ + void SessionLockIdle(); + /** + * @brief 后端服务信息更新 + * + * @param info 信息json + */ + void UpdateInformation(const QString &info); + /** + * @brief 进入锁定 + * + */ + void lock(); + /** + * @brief 退出锁定 + * + */ + void unlock(); + + /** + * @brief 用户信息更新 + * + * @param list 用户信息列表 + */ + void usersInfoChanged(QList list); + + /** + * @brief 请求锁定 + * + */ + void requestLock(); + /** + * @brief 请求解锁 + * + */ + void requestUnlock(); + /** + * @brief 会话活跃状态改变 + * + * @param isActive true 活跃,false 不活跃 + */ + void sessionActiveChanged(bool isActive); + /** + * @brief 准备休眠/唤醒 + * + * @param isSleep true 休眠,false 唤醒 + */ + void PrepareForSleep(bool isSleep); + + void currentUserChanged(QString strUserName); + + void currentSessionChanged(QString strSession); + + void lidstateChanged(QString lidstate); + + void batteryStatusChanged(QString iconName); + + void batteryChanged(QStringList batteryArgs); + + void screenSaverConfChanged(QString strKey, QVariant value); + void lockScreenConfChanged(QString strKey, QVariant value); + void powerManagerConfChanged(QString strKey, QVariant value); + void mateBgConfChanged(QString strKey, QVariant value); + void ukccPluginsConfChanged(QString strKey, QVariant value); + void themeStyleConfChanged(QString strKey, QVariant value); + void sessionConfChanged(QString strKey, QVariant value); + void capslockConfChanged(bool state); + + void pamShowMessage(QString text, int type); + void pamShowPrompt(QString text, int type); + void pamAuthCompleted(); + + void usdMediaKeysConfChanged(QString strKey, QString value); + + void bioServiceStatusChanged(bool bValid); + void bioDeviceChanged(); + void bioAuthShowMessage(QString strMsg); + void bioAuthStateChanged(int nState); + void bioAuthFrameData(QString strData); + void bioAuthCompleted(int nUid, bool isSuccess, int nError, int nMaxFailedTime, int nFailedTime); + +private: + /** + * @brief 连接信号槽 + * + */ + void initConnections(); + + QList ParseUsersInfo(const QJsonObject &objRes); + + QList ParseSessionsInfo(const QJsonObject &objRes); + + QList ParseSaverThemes(const QJsonObject &objRes); + + QStringList ParseBatteryArgs(const QJsonObject &objRes); + + QStringList ParseSleepLockcheck(const QJsonObject &objRes); + + QStringList ParseShutdownLockcheck(const QJsonObject &objRes); + + AgreementInfoPtr ParseAgreementInfo(const QJsonObject &objRes); + + bool ParseLogin1ReqLock(const QJsonObject &objRes); + + bool ParseLogin1ReqUnLock(const QJsonObject &objRes); + + bool ParseLogin1PrepareForSleep(const QJsonObject &objRes); + + bool ParseLogin1SessionActiveChanged(const QJsonObject &objRes); + + bool ParseCurrentUser(const QJsonObject &objRes); + + bool ParseCurrentSession(const QJsonObject &objRes); + + bool ParseLidstateChanged(const QJsonObject &objRes); + + bool ParseBatteryStatusChanged(const QJsonObject &objRes); + + bool ParseBatteryChanged(const QJsonObject &objRes); + + bool ParseScreenSaverConf(const QJsonObject &objRes); + bool ParseLockScreenConf(const QJsonObject &objRes); + bool ParsePowerManagerConf(const QJsonObject &objRes); + bool ParseMateBgConf(const QJsonObject &objRes); + bool ParseUkccPluginsConf(const QJsonObject &objRes); + bool ParseThemeStyleConf(const QJsonObject &objRes); + bool ParseSessionConf(const QJsonObject &objRes); + bool ParseCapslockConf(const QJsonObject &objRes); + + void ParsePamShowMessage(const QJsonObject &objRes); + void ParsePamShowPrompt(const QJsonObject &objRes); + void ParsePamAuthCompleted(const QJsonObject &objRes); + + bool ParseUsdMediaKeysConf(const QJsonObject &objRes); + + void ParseBioServiceStatus(const QJsonObject &objRes); + void ParseBioDeviceChanged(const QJsonObject &objRes); + void ParseBioAuthShowMessage(const QJsonObject &objRes); + void ParseBioAuthStateChanged(const QJsonObject &objRes); + void ParseBioAuthFrameData(const QJsonObject &objRes); + void ParseBioAuthCompleted(const QJsonObject &objRes); +}; + +#endif // BACKENDDBUSHELPER_H diff --git a/src/lock-dialog/lockdialogmodel.cpp b/src/lock-dialog/lockdialogmodel.cpp new file mode 100644 index 0000000..f3dc51e --- /dev/null +++ b/src/lock-dialog/lockdialogmodel.cpp @@ -0,0 +1,445 @@ +/* + * Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * +**/ +#include "lockdialogmodel.h" +#include +#include +#include +#include +#include +#include +#include "utils.h" +#include "definetypes.h" + +LockDialogModel::LockDialogModel(QObject *parent) + : QObject(parent) + , m_isUseWayland(QGuiApplication::platformName().startsWith("wayland", Qt::CaseInsensitive)) +{ +} + +bool LockDialogModel::parseCmdArguments(QStringList args, CommandLineArgs &cmdArgs) +{ + //命令行参数解析 + QCommandLineParser parser; + parser.setApplicationDescription(QGuiApplication::translate("main", "Dialog for the ukui ScreenSaver.")); + parser.addHelpOption(); + parser.addVersionOption(); + parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions); + + QCommandLineOption lockOption(QStringLiteral("lock"), + QGuiApplication::translate("main", "lock the screen immediately")); + QCommandLineOption lstOption(QStringLiteral("lock-startup"), + QGuiApplication::translate("main", "lock the screen immediately")); + QCommandLineOption sessionIdleOption(QStringLiteral("session-idle"), + QGuiApplication::translate("main", "activated by session idle signal")); + QCommandLineOption lscreensaverOption(QStringLiteral("lock-screensaver"), + QGuiApplication::translate("main", "lock the screen and show screensaver immediately")); + QCommandLineOption screensaverOption(QStringLiteral("screensaver"), + QGuiApplication::translate("main", "show screensaver immediately")); + QCommandLineOption blankOption(QStringLiteral("blank"), + QGuiApplication::translate("main", "lock the screen and show screensaver immediately")); + QCommandLineOption delayOption(QStringLiteral("delay"), + QGuiApplication::translate("main", "show blank screensaver immediately and delay time to show lock"), + QGuiApplication::translate("delay", "how long to show lock"), "0"); + QCommandLineOption hasLockOption(QStringLiteral("has-lock"), + QGuiApplication::translate("main", "show blank screensaver immediately and if lock"), + QGuiApplication::translate("has-lock", "if show lock"), "1"); + parser.addOptions({lockOption, lstOption,sessionIdleOption , screensaverOption,blankOption,lscreensaverOption,delayOption,hasLockOption}); + parser.process(args); + + QString strHostCloundPlatform = getHostCloudPlatform(); + qDebug()<<"HostCloundPlatform:"<name() == strName) { + return user; + } + } + return nullptr; +} + +UserInfoPtr LockDialogModel::findUserById(const uid_t &id) +{ + for (auto user : m_listUsersInfo) { + if (user->uid() == id) { + return user; + } + } + return nullptr; +} + +void LockDialogModel::updateSessionsInfo(QStringList list) +{ + m_listSessions = list; +} + +void LockDialogModel::updateUsersInfo(QList list) +{ + m_listUsersInfo = list; + Q_EMIT usersInfoChanged(); +} + +void LockDialogModel::updateAgreementInfo(AgreementInfoPtr agreementInfo) +{ + m_agreementInfo = agreementInfo; + Q_EMIT agreementInfoChanged(); +} + +void LockDialogModel::onUsersInfoChanged(QList list) +{ + m_listUsersInfo = list; + Q_EMIT usersInfoChanged(); +} + +void LockDialogModel::onCurUserChanged(const QString &strUserName) +{ + updateCurUserName(strUserName); + Q_EMIT currentUserChanged(strUserName); +} + +void LockDialogModel::onCurSessionChanged(const QString &strSession) +{ + updateCurSession(strSession); + Q_EMIT currentSessionChanged(strSession); +} + +QString LockDialogModel::getAgreementWindowText() +{ + if(!m_agreementInfo->promptText().isEmpty()){ + return m_agreementInfo->promptText(); + } + + if(m_agreementInfo->promptTextFilePath().isEmpty()) + return ""; + + QFile file(m_agreementInfo->promptTextFilePath()); + if(!file.exists()) + return ""; + file.open(QFile::ReadOnly); + QString str(file.readAll()); + if(str == "") + return ""; + file.close(); + return str; +} + +ScreenSaver *LockDialogModel::getScreensaver() +{ + QStringList modeStr{"blank-only", "random", "single", "image","default-ukui","default-ukui-custom"}; + ScreenSaver *saver = new ScreenSaver; + int index = modeStr.indexOf(m_saverMode); + saver->mode = SaverMode(index); + saver->interval = m_imageSwitchInterval; + saver->effect = TransitionEffect(m_imageTSEffect); + + switch(index){ + case SAVER_BLANK_ONLY: + break; + case SAVER_RANDOM: + { + if(m_saverTheme.count()==0){ + saver->path = "/usr/lib/ukui-screensaver/ukui-screensaver-default"; + break; + } + qsrand((unsigned)time(0)); + int index = qrand() % m_saverTheme.count(); + while(QString::compare(m_saverTheme[index], "kyccss-personal-slideshow")==0) + { + index = qrand() % m_saverTheme.count(); + } + saver->path = getXScreensaverPath(m_saverTheme[index]); + break; + } + case SAVER_SINGLE: + if(m_saverTheme.count()==0){ + saver->path = "/usr/lib/ukui-screensaver/ukui-screensaver-default"; + break; + } + saver->path = getXScreensaverPath(m_saverTheme[0]); + break; + case SAVER_IMAGE: + { + QString lang = qgetenv("LANG"); + if (!lang.isEmpty()){ + qDebug()<<"lang = "<path = QDir::homePath() + "/图片"; + break; + } + } + saver->path = QDir::homePath() + "/" + QStandardPaths::displayName(QStandardPaths::PicturesLocation); + break; + } + case SAVER_DEFAULT: + saver->path = "/usr/lib/ukui-screensaver/ukui-screensaver-default"; + break; + case SAVER_DEFAULT_CUSTOM: + saver->path = "/usr/lib/ukui-screensaver/ukui-screensaver-default"; + break; + default: + break; + } + return saver; +} + +QString LockDialogModel::getXScreensaverPath(const QString &theme) +{ + /* screensavers-ukui-binaryring => binaryring */ + QStringList strs = theme.split("-"); + QString str = strs.at(strs.size() - 1); + QString filePath = QString("%1/%2").arg(XSCREENSAVER_DIRNAME, str); + //除了判断gsetting值是否为空,还需要判断屏保文件是否存在,不存在就使用默认屏保。 + if(QFile(filePath).exists()) + return filePath; + else + return "/usr/lib/ukui-screensaver/ukui-screensaver-default"; +} + +void LockDialogModel::onLidstateChanged(const QString &lidstate) +{ + Q_EMIT lidstateChanged(lidstate); +} + +void LockDialogModel::onBatteryStatusChanged(const QString &iconName) +{ + Q_EMIT batteryStatusChanged(iconName); +} + +void LockDialogModel::onBatteryChanged(const QStringList &batteryArgs) +{ + Q_EMIT batteryChanged(batteryArgs); +} + +void LockDialogModel::onLockScreenConfChanged(const QString &key, QVariant value) +{ + if (key == KEY_MODE) { + m_saverMode = value.toString(); + } else if (key ==KEY_THEMES) { + m_saverTheme = value.toStringList(); + } else if (key ==KEY_IMAGE_TRANSITION_EFFECT) { + m_imageTSEffect = value.toInt(); + } else if (key ==KEY_IMAGE_SWITCH_INTERVAL) { + m_imageSwitchInterval = value.toInt(); + } +} + +void LockDialogModel::onCapslockStateChanged(const bool capslockState) +{ + Q_EMIT capslockStateChanged(capslockState); +} + +void LockDialogModel::onUsdMediaKeysChanged(const QString &key, const QString &value) +{ + Q_EMIT usdMediaKeysChanged(key, value); +} + +void LockDialogModel::updateCapslockState(bool capslockState) +{ + m_capslockState = capslockState; +} + +void LockDialogModel::onSecondRunParam(const QString &str) +{ + Q_EMIT SecondRunParam(str); +} + +void LockDialogModel::updateUsdMediaKeys(QString keys, QString value) +{ + if (keys == KEY_AREA_SCREENSHOT) { + m_areaScreenShot = value; + } else if (keys == KEY_AREA_SCREENSHOT2) { + m_areaScreenShot2 = value; + } else if (keys == KEY_SCREEN_SHOT) { + m_screenShot = value; + } else if (keys == KEY_SCREEN_SHOT2) { + m_screenShot2 = value; + } else if (keys == KEY_WINDOW_SCREENSHOT) { + m_windowScreenshot = value; + } + +} + +void LockDialogModel::updateScreensaverMode(QString value) +{ + m_saverMode = value; +} + +void LockDialogModel::updateScreensaverTheme(QStringList value) +{ + m_saverTheme = value; +} + +void LockDialogModel::updateScreensaverImageTSEffect(int value) +{ + m_imageTSEffect = value; +} + +void LockDialogModel::updateScreensaverImageSwitchInterval(int value) +{ + m_imageSwitchInterval = value; +} + +void LockDialogModel::updateCanHibernate(bool canflag) +{ + qWarning()<<__LINE__ << __FUNCTION__ << canflag; + + m_CanHibernate = canflag; + +} +void LockDialogModel::updateCanReboot(bool canflag) +{ + qWarning()<<__LINE__ << __FUNCTION__ << canflag; + + m_CanReboot = canflag; + +} +void LockDialogModel::updateCanPowerOff(bool canflag) +{ + qWarning()<<__LINE__ << __FUNCTION__ << canflag; + m_CanPowerOff = canflag; + +} +void LockDialogModel::updateCanSuspend(bool canflag) +{ + qWarning()<<__LINE__ << __FUNCTION__ << canflag; + m_CanSuspend = canflag; + +} + +void LockDialogModel::updateBatteryArgs(QStringList batteryArgs) +{ + m_batteryArgs = batteryArgs; +} + +void LockDialogModel::updateBatteryIconName(QString iconName) +{ + m_batteryIconName = iconName; +} + +void LockDialogModel::updateIsBattery(bool isBattery) +{ + m_isBattery = isBattery; +} + +void LockDialogModel::updateSleepLockcheck(QStringList sleepLockcheck) +{ + m_sleepLockcheck = sleepLockcheck; +} + +void LockDialogModel::updateShutdownLockcheck(QStringList shutdownLockcheck) +{ + m_shutdownLockcheck = shutdownLockcheck; +} + +void LockDialogModel::updateLoggedInUsersCount() +{ + m_loggedinUsersCount = 0; + if (!m_listUsersInfo.isEmpty()) { + for (auto user : m_listUsersInfo) { + if (user->isLoggedIn()) { + m_loggedinUsersCount++; + } + } + } +} diff --git a/src/lock-dialog/lockdialogmodel.h b/src/lock-dialog/lockdialogmodel.h new file mode 100644 index 0000000..28923aa --- /dev/null +++ b/src/lock-dialog/lockdialogmodel.h @@ -0,0 +1,379 @@ +/* + * Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * +**/ +#ifndef LOCKDIALOGMODEL_H +#define LOCKDIALOGMODEL_H + +#include +#include "userinfo.h" +#include "agreementinfo.h" +#include "screensaver.h" +#include "biodefines.h" + +/** + * @brief 锁屏模型类(管理所有功能逻辑和状态) + * + */ +class LockDialogModel : public QObject +{ + Q_OBJECT +public: + /** + * @brief + * + */ + struct CommandLineArgs { + bool isSessionIdle = false; /**< 是否会话空闲 */ + bool isLock = false; /**< 是否直接锁定 */ + bool isLockStartup = false; /**< 是否开机启动锁定 */ + bool isScreenSaver = false; /**< 是否屏保 */ + bool isLockScreensaver = false; /**< 是否锁定与屏保 */ + bool isBlank = false; /**< 是否黑色屏保锁定 */ + bool isBlankHasLock = false; /**< 是否黑色屏保需要锁定 */ + int nBlankDelay = 0; /**< 黑色屏保延迟锁定时间 */ + }; + /** + * @brief 构造 + * + * @param parent 父指针 + */ + explicit LockDialogModel(QObject *parent = nullptr); + +public: + /** + * @brief 解析命令行参数 + * + * @param args 命令行参数列表 + * @param cmdArgs 解析后结果 + * @return bool 是否解析完成 + */ + bool parseCmdArguments(QStringList args, CommandLineArgs &cmdArgs); + /** + * @brief 更新会话状态 + * + * @param isActive 是否激活 true 是,否则不是 + */ + void updateSessionState(bool isActive); + /** + * @brief 会话是否激活 + * + * @return bool true 是,否则不是 + */ + bool sessionActive(); + /** + * @brief 是否是wayland模式 + * + * @return bool true 是,否则不是 + */ + inline bool isUseWayland() { return m_isUseWayland; } + /** + * @brief 更新用户信息列表 + * + * @param list 用户信息列表 + */ + void updateUsersInfo(QList list); + + void updateCapslockState(bool capslockState); + + void updateUsdMediaKeys(QString keys, QString value); + + void updateBatteryArgs(QStringList batteryArgs); + + void updateBatteryIconName(QString iconName); + + void updateIsBattery(bool isBattery); + + void updateSleepLockcheck(QStringList sleepLockcheck); + + void updateShutdownLockcheck(QStringList shutdownLockcheck); + + void updateLoggedInUsersCount(); + /** + * @brief 获取用户信息列表 + * + * @return QList 用户信息列表 + */ + inline QList usersInfo() { return m_listUsersInfo; } + + void updateSessionsInfo(QStringList list); + + void updateScreensaverMode(QString value); + + void updateScreensaverTheme(QStringList value); + + void updateScreensaverImageTSEffect(int value); + + void updateScreensaverImageSwitchInterval(int value); + + inline QStringList sessionsInfo() { return m_listSessions; } + + inline void updateCurSession(const QString &strSession) { m_strCurSession = strSession; } + + inline QString currentSession() { return m_strCurSession; } + + UserInfoPtr findUserByName(const QString &strName); + + UserInfoPtr findUserById(const uid_t &id); + + inline QString defaultUserName() { return m_strDefUserName; } + + inline void updateDefUserName(const QString &strUserName) { m_strDefUserName = strUserName; } + + inline QString currentUserName() { return m_strCurUserName; } + + inline void updateCurUserName(const QString &strUserName) { m_strCurUserName = strUserName; } + + void updateAgreementInfo(AgreementInfoPtr agreementInfo); + + inline AgreementInfoPtr agreementInfo() { return m_agreementInfo;} + + inline bool getAgreementWindowShowLoginPrompt() { return m_agreementInfo->showLoginPrompt(); } + inline bool getAgreementWindowHideTitle() { return m_agreementInfo->hideTitle(); } + inline QString getAgreementWindowPromptTitle() { return m_agreementInfo->promptTitle(); } + QString getAgreementWindowText(); + + inline bool getCapslockState() { return m_capslockState; } + + inline QString getUsdAreaScreenShotKey() { return m_areaScreenShot; } + inline QString getUsdAreaScreenShot2Key() { return m_areaScreenShot2; } + inline QString getUsdScreenShotKey() { return m_screenShot; } + inline QString getUsdScreenShot2Key() { return m_screenShot2; } + inline QString getUsdwindowScreenshotKey() { return m_windowScreenshot; } + +// inline QString getSaverMode() { return m_saverMode; } +// inline QString getSaverTheme() { return m_saverTheme; } + ScreenSaver *getScreensaver(); + + inline bool getCanHibernate() { return m_CanHibernate; } + inline bool getCanSuspend() { return m_CanSuspend; } + inline bool getCanReboot() { return m_CanReboot; } + inline bool getCanPowerOff() { return m_CanPowerOff; } + + void updateCanHibernate(bool); + void updateCanReboot(bool); + void updateCanPowerOff(bool); + void updateCanSuspend(bool); + + inline QStringList getBatteryArgs() { return m_batteryArgs; } + + inline QString getBatteryIconName() { return m_batteryIconName; } + + inline bool getIsBattery() { return m_isBattery; } + + inline QStringList getSleepLockcheck() { return m_sleepLockcheck; } + + inline QStringList getShutdownLockcheck() { return m_shutdownLockcheck; } + + inline int getLoggedInUsersCount() { return m_loggedinUsersCount; } + +public Q_SLOTS: + /** + * @brief 会话激活状态改变 + * + * @param isActive 是否激活 true 是,否则不是 + */ + void onSessionActiveChanged(bool isActive); + /** + * @brief 进程启动时再次运行传入参数 + * + * @param strMsg 新参数 + */ + void onRunningMessage(const QString &strMsg); + /** + * @brief 用户信息更新 + * + * @param list 用户信息列表 + */ + void onUsersInfoChanged(QList list); + + void onCurUserChanged(const QString &strUserName); + + void onCurSessionChanged(const QString &strSession); + + void onLidstateChanged(const QString &lidstate); + + void onBatteryStatusChanged(const QString &iconName); + + void onBatteryChanged(const QStringList &batteryArgs); + + void onCapslockStateChanged(const bool capslockState); + + void onUsdMediaKeysChanged(const QString &key, const QString &value); + + void onSecondRunParam(const QString &str); + + void onLockScreenConfChanged(const QString &key, QVariant value); + +Q_SIGNALS: + /** + * @brief 请求解锁会话 + * + */ + void requestUnlockSession(); + /** + * @brief 请求锁定会话 + * + */ + void requestLockSession(); + /** + * @brief 准备休眠/唤醒 + * + * @param isSleep 休眠还是唤醒 true 休眠,否则唤醒 + */ + void prepareForSleep(bool isSleep); + /** + * @brief 会话激活改变 + * + * @param isActive true 激活,否则未激活 + */ + void sessionActiveChanged(bool isActive); + /** + * @brief 用户信息改变 + * + */ + void usersInfoChanged(); + + /** + * @brief 显示黑色屏保 + * + * @param nDelay 锁定延迟时间 + * @param isHasLock 是否锁定 true 锁定,否则不 + */ + void showBlankScreensaver(int nDelay, bool isHasLock); + /** + * @brief 显示锁定 + * + * @param isStartup 是否为开机启动 true 是,否则不是 + */ + void showLock(bool isStartup); + /** + * @brief 显示会话空闲状态 + * + */ + void showSessionIdle(); + /** + * @brief 显示锁定和屏保 + * + */ + void showLockScreensaver(); + /** + * @brief 显示屏保 + * + */ + void showScreensaver(); + /** + * @brief 显示电源管理 + * + */ + void showPowerManager(); + + void currentUserChanged(const QString &strUserName); + + void currentSessionChanged(const QString &strSession); + + void agreementInfoChanged(); + + void lockStateChanged(bool isVisible); + + void lidstateChanged(const QString &lidstate); + + void batteryStatusChanged(const QString &iconName); + + void batteryChanged(const QStringList &batteryArgs); + + void capslockStateChanged(const bool capslockState); + + void screenSaverConfChanged(const QString &key, const QString &value); + + /// + void setCurrentUser(QString strUserName); + void setCurrentSession(QString strSession); + void startSession(); + void pamAuthenticate(QString strUserName); + void pamRespond(QString strRespond); + void pamAuthenticateCancel(); + bool pamIsInAuthentication(); + bool pamIsAuthenticated(); + QString pamAuthenticateUser(); + bool GetBlankState(); + void pamShowMessage(QString text, int type); + void pamShowPrompt(QString text, int type); + void pamAuthCompleted(); + + void bioStartAuth(int uid, int nDevId); + void bioStopAuth(); + QList bioGetAvailableDevices(int nUid); + QList bioGetDisabledDevices(int nUid); + int bioGetBioAuthState(); + DeviceInfo bioGetCurBioInfo(); + DeviceInfo bioFindDeviceById(int nUid, int nDevId); + DeviceInfo bioFindDeviceByName(int nUid, QString strDevName); + QString bioGetDefaultDevice(int nUid, QString strUserName,int bioType = -1); + + void bioServiceStatusChanged(bool bValid); + void bioDeviceChanged(); + void bioAuthShowMessage(QString strMsg); + void bioAuthStateChanged(int nState); + void bioAuthFrameData(QString strData); + void bioAuthCompleted(int nUid, bool isSuccess, int nError, int nMaxFailedTime, int nFailedTime); + + void usdMediaKeysChanged(const QString &key, const QString &value); + void usdExternalDoAction(int actionType); + + void setPowerManager(QString strFuncName); + + void SecondRunParam(const QString &str); + +private: + QString getXScreensaverPath(const QString &theme); +private: + bool m_isSessionActive; /**< 会话是否激活 */ + bool m_isUseWayland = false; /**< 是否为wayland环境 */ + QList m_listUsersInfo; /**< 用户信息列表 */ + QString m_strDefUserName; + QString m_strCurUserName; + AgreementInfoPtr m_agreementInfo = nullptr; + bool m_capslockState; + QStringList m_listSessions; /**< 会话列表*/ + QString m_strCurSession; + + QString m_areaScreenShot; + QString m_areaScreenShot2; + QString m_screenShot; + QString m_screenShot2; + QString m_windowScreenshot; + + QString m_saverMode; + QList m_saverTheme; + int m_imageTSEffect; + int m_imageSwitchInterval; + + bool m_CanHibernate; + bool m_CanReboot; + bool m_CanPowerOff; + bool m_CanSuspend; + + QStringList m_batteryArgs; + QString m_batteryIconName; + bool m_isBattery = false; + + QStringList m_sleepLockcheck; + QStringList m_shutdownLockcheck; + int m_loggedinUsersCount = 0; +}; + +#endif // LOCKDIALOGMODEL_H diff --git a/src/lock-dialog/lockdialogperformer.cpp b/src/lock-dialog/lockdialogperformer.cpp new file mode 100644 index 0000000..ecc8420 --- /dev/null +++ b/src/lock-dialog/lockdialogperformer.cpp @@ -0,0 +1,129 @@ +/* + * Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * +**/ +#include "lockdialogperformer.h" +#include "lockdialogmodel.h" +#include "backenddbushelper.h" +#include "utils.h" + +LockDialogPerformer::LockDialogPerformer(LockDialogModel *model, QObject *parent) + : QObject(parent) + , m_modelLockDialog(model) +{ + QString displayNum = QString(qgetenv("DISPLAY")).replace(":", "").replace(".", "_"); + QString sessionDbus = QString("%1%2").arg(QString(SS_DBUS_SERVICE)).arg(displayNum); + m_bdHelper = new BackendDbusHelper(sessionDbus, SS_DBUS_PATH, QDBusConnection::sessionBus(), this); + if (!m_bdHelper->isValid()) { + delete m_bdHelper; + m_bdHelper = new BackendDbusHelper(SS_DBUS_SERVICE, SS_DBUS_PATH, QDBusConnection::sessionBus(), this); + } + initConnections(); + initData(); +} + +void LockDialogPerformer::initConnections() +{ + connect(m_bdHelper, &BackendDbusHelper::requestLock, m_modelLockDialog, &LockDialogModel::requestLockSession); + connect(m_bdHelper, &BackendDbusHelper::requestUnlock, m_modelLockDialog, &LockDialogModel::requestUnlockSession); + connect(m_bdHelper, &BackendDbusHelper::PrepareForSleep, m_modelLockDialog, &LockDialogModel::prepareForSleep); + connect(m_bdHelper, &BackendDbusHelper::sessionActiveChanged, m_modelLockDialog, &LockDialogModel::onSessionActiveChanged); + + connect(m_bdHelper, &BackendDbusHelper::usersInfoChanged, m_modelLockDialog, &LockDialogModel::onUsersInfoChanged); + connect(m_bdHelper, &BackendDbusHelper::currentUserChanged, m_modelLockDialog, &LockDialogModel::onCurUserChanged); + connect(m_bdHelper, &BackendDbusHelper::currentSessionChanged, m_modelLockDialog, &LockDialogModel::onCurSessionChanged); + + connect(m_bdHelper, &BackendDbusHelper::lidstateChanged, m_modelLockDialog, &LockDialogModel::onLidstateChanged); + connect(m_bdHelper, &BackendDbusHelper::capslockConfChanged, m_modelLockDialog, &LockDialogModel::onCapslockStateChanged); + + connect(m_bdHelper, &BackendDbusHelper::batteryStatusChanged, m_modelLockDialog, &LockDialogModel::onBatteryStatusChanged); + connect(m_bdHelper, &BackendDbusHelper::batteryChanged, m_modelLockDialog, &LockDialogModel::batteryChanged); + connect(m_bdHelper, &BackendDbusHelper::SecondRunParam, m_modelLockDialog, &LockDialogModel::onSecondRunParam); + connect(m_bdHelper, &BackendDbusHelper::lockScreenConfChanged, m_modelLockDialog, &LockDialogModel::onLockScreenConfChanged); + + // pam signals + connect(m_bdHelper, SIGNAL(pamShowMessage(QString, int)), m_modelLockDialog, SIGNAL(pamShowMessage(QString, int))); + connect(m_bdHelper, SIGNAL(pamShowPrompt(QString, int)), m_modelLockDialog, SIGNAL(pamShowPrompt(QString, int))); + connect(m_bdHelper, SIGNAL(pamAuthCompleted()), m_modelLockDialog, SIGNAL(pamAuthCompleted())); + + // bio signals + connect(m_bdHelper, SIGNAL(bioServiceStatusChanged(bool)), m_modelLockDialog, SIGNAL(bioServiceStatusChanged(bool))); + connect(m_bdHelper, SIGNAL(bioDeviceChanged()), m_modelLockDialog, SIGNAL(bioDeviceChanged())); + connect(m_bdHelper, SIGNAL(bioAuthShowMessage(QString)), m_modelLockDialog, SIGNAL(bioAuthShowMessage(QString))); + connect(m_bdHelper, SIGNAL(bioAuthStateChanged(int)), m_modelLockDialog, SIGNAL(bioAuthStateChanged(int))); + connect(m_bdHelper, SIGNAL(bioAuthFrameData(QString)), m_modelLockDialog, SIGNAL(bioAuthFrameData(QString))); + connect(m_bdHelper, SIGNAL(bioAuthCompleted(int, bool, int, int, int)), m_modelLockDialog, SIGNAL(bioAuthCompleted(int, bool, int, int, int))); + + connect(m_bdHelper, &BackendDbusHelper::usdMediaKeysConfChanged, m_modelLockDialog, &LockDialogModel::onUsdMediaKeysChanged); + ///通过信号直接调用槽 + connect(m_modelLockDialog, &LockDialogModel::setCurrentUser, m_bdHelper, &BackendDbusHelper::setCurrentUser); + connect(m_modelLockDialog, &LockDialogModel::setCurrentSession, m_bdHelper, &BackendDbusHelper::setCurrentSession); + connect(m_modelLockDialog, &LockDialogModel::startSession, m_bdHelper, &BackendDbusHelper::startSession); + connect(m_modelLockDialog, &LockDialogModel::pamAuthenticate, m_bdHelper, &BackendDbusHelper::pamAuthenticate); + connect(m_modelLockDialog, &LockDialogModel::pamRespond, m_bdHelper, &BackendDbusHelper::pamRespond); + connect(m_modelLockDialog, &LockDialogModel::pamAuthenticateCancel, m_bdHelper, &BackendDbusHelper::pamAuthenticateCancel); + connect(m_modelLockDialog, &LockDialogModel::pamIsInAuthentication, m_bdHelper, &BackendDbusHelper::pamIsInAuthentication); + connect(m_modelLockDialog, &LockDialogModel::pamIsAuthenticated, m_bdHelper, &BackendDbusHelper::pamIsAuthenticated); + connect(m_modelLockDialog, &LockDialogModel::pamAuthenticateUser, m_bdHelper, &BackendDbusHelper::pamAuthenticateUser); + connect(m_modelLockDialog, &LockDialogModel::GetBlankState, m_bdHelper, &BackendDbusHelper::GetBlankState); + + connect(m_modelLockDialog, &LockDialogModel::bioStartAuth, m_bdHelper, &BackendDbusHelper::bioStartAuth); + connect(m_modelLockDialog, &LockDialogModel::bioStopAuth, m_bdHelper, &BackendDbusHelper::bioStopAuth); + connect(m_modelLockDialog, &LockDialogModel::bioGetAvailableDevices, m_bdHelper, &BackendDbusHelper::bioGetAvailableDevices); + connect(m_modelLockDialog, &LockDialogModel::bioGetDisabledDevices, m_bdHelper, &BackendDbusHelper::bioGetDisabledDevices); + connect(m_modelLockDialog, &LockDialogModel::bioGetBioAuthState, m_bdHelper, &BackendDbusHelper::bioGetBioAuthState); + connect(m_modelLockDialog, &LockDialogModel::bioGetCurBioInfo, m_bdHelper, &BackendDbusHelper::bioGetCurBioInfo); + connect(m_modelLockDialog, &LockDialogModel::bioFindDeviceById, m_bdHelper, &BackendDbusHelper::bioFindDeviceById); + connect(m_modelLockDialog, &LockDialogModel::bioFindDeviceByName, m_bdHelper, &BackendDbusHelper::bioFindDeviceByName); + connect(m_modelLockDialog, &LockDialogModel::bioGetDefaultDevice, m_bdHelper, &BackendDbusHelper::bioGetDefaultDevice); + + + connect(m_modelLockDialog, &LockDialogModel::usdExternalDoAction, m_bdHelper, &BackendDbusHelper::usdExternalDoAction); + connect(m_modelLockDialog, &LockDialogModel::setPowerManager, m_bdHelper, &BackendDbusHelper::setPowerManager); + connect(m_modelLockDialog, &LockDialogModel::lockStateChanged, m_bdHelper, &BackendDbusHelper::lockStateChanged); +} + +void LockDialogPerformer::initData() +{ + m_modelLockDialog->updateUsersInfo(m_bdHelper->getUsersInfo()); + m_modelLockDialog->updateSessionsInfo(m_bdHelper->getSessionsInfo()); + m_modelLockDialog->updateSessionState(m_bdHelper->isSessionActive()); + m_modelLockDialog->updateDefUserName(m_bdHelper->getDefaultAuthUser()); + m_modelLockDialog->updateCurUserName(m_bdHelper->getCurrentUser()); + m_modelLockDialog->updateCurSession(m_bdHelper->getCurrentSession()); + m_modelLockDialog->updateAgreementInfo(m_bdHelper->getAgreementInfo()); + m_modelLockDialog->updateCapslockState(m_bdHelper->getKeyboardConf(KEY_CAPSLOCK_STATUS).toBool()); + m_modelLockDialog->updateUsdMediaKeys(KEY_AREA_SCREENSHOT, m_bdHelper->getUsdMediaKeys(KEY_AREA_SCREENSHOT).toString()); + m_modelLockDialog->updateUsdMediaKeys(KEY_AREA_SCREENSHOT2, m_bdHelper->getUsdMediaKeys(KEY_AREA_SCREENSHOT2).toString()); + m_modelLockDialog->updateUsdMediaKeys(KEY_SCREEN_SHOT, m_bdHelper->getUsdMediaKeys(KEY_SCREEN_SHOT).toString()); + 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()); + m_modelLockDialog->updateScreensaverMode(m_bdHelper->getLockScreenConf(KEY_MODE).toString()); + m_modelLockDialog->updateScreensaverTheme(m_bdHelper->getSaverThemes()); + m_modelLockDialog->updateScreensaverImageTSEffect(m_bdHelper->getLockScreenConf(KEY_IMAGE_TRANSITION_EFFECT).toInt()); + m_modelLockDialog->updateScreensaverImageSwitchInterval(m_bdHelper->getLockScreenConf(KEY_IMAGE_SWITCH_INTERVAL).toInt()); + m_modelLockDialog->updateCanHibernate(m_bdHelper->getPowerManagerCanHibernate()); + m_modelLockDialog->updateCanReboot(m_bdHelper->getPowerManagerCanReboot()); + m_modelLockDialog->updateCanPowerOff(m_bdHelper->getPowerManagerCanPowerOff()); + m_modelLockDialog->updateCanSuspend(m_bdHelper->getPowerManagerCanSuspend()); + m_modelLockDialog->updateBatteryArgs(m_bdHelper->getBatteryArgs()); + m_modelLockDialog->updateBatteryIconName(m_bdHelper->getBatteryIconName()); + m_modelLockDialog->updateIsBattery(m_bdHelper->getIsBattery()); + m_modelLockDialog->updateSleepLockcheck(m_bdHelper->getSleepLockcheck()); + m_modelLockDialog->updateShutdownLockcheck(m_bdHelper->getShutdownLockcheck()); + m_modelLockDialog->updateLoggedInUsersCount(); +} + diff --git a/src/lock-dialog/lockdialogperformer.h b/src/lock-dialog/lockdialogperformer.h new file mode 100644 index 0000000..711bf94 --- /dev/null +++ b/src/lock-dialog/lockdialogperformer.h @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * +**/ +#ifndef LOCKDIALOGWORKER_H +#define LOCKDIALOGWORKER_H + +#include + +class LockDialogModel; +class BackendDbusHelper; + +/** + * @brief 执行者类(承接程序内外的接口类) + * + */ +class LockDialogPerformer : public QObject +{ + Q_OBJECT +public: + /** + * @brief 构造 + * + * @param model 模型 + * @param parent 父指针 + */ + explicit LockDialogPerformer(LockDialogModel *model, QObject *parent = nullptr); + +private: + /** + * @brief 初始化连接信号槽 + * + */ + void initConnections(); + /** + * @brief 初始化数据 + * + */ + void initData(); + +private: + LockDialogModel *m_modelLockDialog = nullptr; /**< 锁屏数据模型 */ + BackendDbusHelper *m_bdHelper = nullptr; /**< 后端服务客户端类 */ +}; + +#endif // LOCKDIALOGWORKER_H diff --git a/src/lock-dialog/main.cpp b/src/lock-dialog/main.cpp new file mode 100644 index 0000000..0cd23e4 --- /dev/null +++ b/src/lock-dialog/main.cpp @@ -0,0 +1,204 @@ +/* + * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * +**/ +#include +#include +#include +#include +#include +#include + +#ifdef HAVE_LAYERSHELLQT +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "utils.h" +#include "commonfunc.h" +#include "lockdialogmodel.h" +#include "lockdialogperformer.h" +#include "fullbackgroundwidget.h" +#include "screensaverwndadaptor.h" +#include "pluginsloader.h" + +FullBackgroundWidget *window = nullptr; + +int main(int argc, char *argv[]) +{ + if(argc < 2) + return 0; + syslog(LOG_INFO, "[ukui-screensaver-dialog] startup!!"); + initUkuiLog4qt("ukui-screensaver-dialog"); + // 重启或关机时不被session关掉 + qunsetenv("SESSION_MANAGER"); + if (!isGreeterMode()) { + // 试用模式不起锁屏 + checkIslivecd(); + } + +#ifdef HAVE_LAYERSHELLQT + LayerShellQt::Shell::useLayerShell(); +#endif + + qputenv("QT_QPA_PLATFORMTHEME",QByteArray("ukui")); + +#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); +#endif +#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) + QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); +#endif + // 屏蔽输入法 + qunsetenv("QT_IM_MODULE"); + + QString id = QString("ukui-screensaver-dialog"+QLatin1String(getenv("DISPLAY"))); + QtSingleApplication app(id, argc, argv); + if (app.isRunning()) { + QString strArguments = QApplication::arguments().join(","); + app.sendMessage(strArguments); + qInfo()<<"ukui screensaver dialog is running!"; + return EXIT_SUCCESS; + } + setCursorCenter(); + // 加载插件实例 + PluginsLoader *pluginsLoader = &PluginsLoader::instance(); + pluginsLoader->start(QThread::HighestPriority); + pluginsLoader->wait(); + + QApplication::setSetuidAllowed(true); + + LockDialogModel *lockDialogModel = new LockDialogModel(); + LockDialogPerformer *performer = new LockDialogPerformer(lockDialogModel); + + QObject::connect(lockDialogModel, &LockDialogModel::requestUnlockSession, [=]() { + if (window) { + window->onCloseScreensaver(); + } else { + exit(0); + } + }); + if (!lockDialogModel->sessionActive()) { + QEventLoop *loopTemp = new QEventLoop(&app); + QObject::connect(lockDialogModel, &LockDialogModel::sessionActiveChanged, [loopTemp](bool isActive) { + qDebug()<<"sessionActiveChanged:"<isRunning()) { + loopTemp->quit(); + } + }); + QObject::connect(lockDialogModel, &LockDialogModel::requestLockSession, [loopTemp]() { + qDebug()<<"session requestLock!"; + if (loopTemp->isRunning()) { + loopTemp->quit(); + } + }); + loopTemp->exec(); + } + + LockDialogModel::CommandLineArgs cmdArgs; + if (!lockDialogModel->parseCmdArguments(app.arguments(), cmdArgs)) { + return 0; + } + QObject::connect(&app, SIGNAL(messageReceived(const QString&)), lockDialogModel, SLOT(onRunningMessage(const QString&))); + + qInfo()<<"Start "<showBlankScreensaver(cmdArgs.nBlankDelay, cmdArgs.isBlankHasLock); + } + +#ifndef USE_INTEL + syslog(LOG_INFO, "[ukui-screensaver-dialog] window show!!"); + window->show(); + window->activateWindow(); + syslog(LOG_INFO, "[ukui-screensaver-dialog] window show done!!"); +#endif + if(cmdArgs.isLock) { + Q_EMIT lockDialogModel->showLock(false); + } + + if(cmdArgs.isLockStartup) { + Q_EMIT lockDialogModel->showLock(true); + } + + if(cmdArgs.isSessionIdle) { + Q_EMIT lockDialogModel->showSessionIdle(); + } + + if(cmdArgs.isLockScreensaver) { + Q_EMIT lockDialogModel->showLockScreensaver(); + } + + if(cmdArgs.isScreenSaver) { + Q_EMIT lockDialogModel->showScreensaver(); + } + +#ifdef HAVE_LAYERSHELLQT + if(lockDialogModel->isUseWayland()){ + if (auto layerShellWindow = LayerShellQt::Window::get(window->windowHandle())) { + layerShellWindow->setExclusiveZone(-1); + layerShellWindow->setLayer(LayerShellQt::Window::LayerOverlay); + layerShellWindow->setKeyboardInteractivity(LayerShellQt::Window::KeyboardInteractivityExclusive); + } + } +#endif + + KillFocusOfKydroid(); + + return app.exec(); +} diff --git a/src/pam-tally.c b/src/lock-dialog/pam-tally.c similarity index 91% rename from src/pam-tally.c rename to src/lock-dialog/pam-tally.c index ff0642c..5927b29 100644 --- a/src/pam-tally.c +++ b/src/lock-dialog/pam-tally.c @@ -18,7 +18,6 @@ #include "pam-tally.h" -#include #include #include #include @@ -357,37 +356,37 @@ pam_modutil_read(int fd, char *buffer, int count) void get_tally(uid_t uid, int *tfile, struct tallylog *tally) { - char filename[50]={0}; + char filename[50]={0}; sprintf(filename,"/tmp/.tallylog.d/.%d",uid); - fprintf(stderr,"new_filename = :%s \n",filename); - void *void_tally = tally; + fprintf(stderr,"filename = :%s \n",filename); + void *void_tally = tally; if ((*tfile = open(filename, O_RDONLY)) == -1){ fprintf(stderr, "lseek tallylog failed,Re-open the new file, uid = %d \n",uid); sprintf(filename,"/tmp/.tallylog"); - fprintf(stderr,"old_filename = :%s \n",filename); + fprintf(stderr,"filename = :%s \n",filename); if ((*tfile = open(filename, O_RDONLY)) == -1){ - fprintf(stderr, "open tallylog failed \n"); + fprintf(stderr, "open tallylog failed:%s \n", strerror(errno)); return ; } } - if (lseek(*tfile, (off_t)uid*(off_t)sizeof(*tally), SEEK_SET) == (off_t)-1) { - fprintf(stderr, "lseek tallylog failed \n"); - close(*tfile); - return ; - } + if (lseek(*tfile, (off_t)uid*(off_t)sizeof(*tally), SEEK_SET) == (off_t)-1) { + fprintf(stderr, "lseek tallylog failed \n"); + sprintf(filename,"/tmp/.tallylog"); + close(*tfile); + return ; + } if (pam_modutil_read(*tfile, void_tally, sizeof(*tally)) != sizeof(*tally)) { fprintf(stderr, "read tallylog failed \n"); memset(tally, 0, sizeof(*tally)); } - close(*tfile); tally->fail_line[sizeof(tally->fail_line)-1] = '\0'; } -int pam_tally_unlock_time_left(int uid, int *fail_cnt,int *left_time, int *deny, int *fail_time, int *unlock_time1) +int pam_tally_unlock_time_left(uid_t userID, int *fail_cnt,int *left_time, int *deny, int *fail_time, int *unlock_time1) { pam_tally *tally_ptr; @@ -396,17 +395,20 @@ int pam_tally_unlock_time_left(int uid, int *fail_cnt,int *left_time, int *deny, int unlock_time = tally_ptr->unlock_time; *deny = tally_ptr->deny; + if(unlock_time == 0) return 0; - int tfile = -1; + int tfile = -1; + + + struct tallylog tally; tally.reserved = 0; tally.fail_cnt = 0; tally.fail_time = 0; - get_tally(uid,&tfile,&tally); - + get_tally(userID,&tfile,&tally); if(tally.fail_cnt<*deny) return 0; @@ -423,8 +425,9 @@ int pam_tally_unlock_time_left(int uid, int *fail_cnt,int *left_time, int *deny, } + int unlock_time_left = unlock_time - ((long)time(NULL) - tally.fail_time); - + // fprintf(stderr, "unlock_time:%d, (long)time(NULL):%d, tally.fail_time:%d\n",unlock_time,(long)time(NULL),tally.fail_time); *fail_time = tally.fail_time; *unlock_time1 = unlock_time; @@ -434,7 +437,7 @@ int pam_tally_unlock_time_left(int uid, int *fail_cnt,int *left_time, int *deny, return *left_time; } -int pam_tally_root_unlock_time_left(int *fail_cnt,int *left_time, int *deny1, int *fail_time, int *unlock_time1) +int pam_tally_root_unlock_time_left(uid_t userID, int *fail_cnt,int *left_time, int *deny1, int *fail_time, int *unlock_time1) { pam_tally *tally_ptr; @@ -447,13 +450,12 @@ int pam_tally_root_unlock_time_left(int *fail_cnt,int *left_time, int *deny1, in return 0; int tfile = -1; - uid_t uid = getuid(); struct tallylog tally; tally.reserved = 0; tally.fail_cnt = 0; tally.fail_time = 0; - get_tally(uid,&tfile,&tally); + get_tally(userID,&tfile,&tally); if(tally.fail_cnt +#include #ifdef __cplusplus extern "C" { @@ -43,8 +44,8 @@ int pam_tally_failed_count(); int pam_tally_unlock_time(); int pam_tally_is_enbled(); int pam_tally_is_canUnlock(); -int pam_tally_unlock_time_left(int uid, int *fail_cnt, int *left_time, int *deny, int *fail_time, int *unlock_time); -int pam_tally_root_unlock_time_left(int *fail_cnt, int *left_time, int *deny, int *fail_time, int *unlock_time); +int pam_tally_unlock_time_left(uid_t userID, int *fail_cnt, int *left_time, int *deny, int *fail_time, int *unlock_time); +int pam_tally_root_unlock_time_left(uid_t userID, int *fail_cnt, int *left_time, int *deny, int *fail_time, int *unlock_time1); #ifdef __cplusplus } diff --git a/src/screensaverwndadaptor.cpp b/src/lock-dialog/screensaverwndadaptor.cpp similarity index 62% rename from src/screensaverwndadaptor.cpp rename to src/lock-dialog/screensaverwndadaptor.cpp index 8d4b9a5..34761ed 100644 --- a/src/screensaverwndadaptor.cpp +++ b/src/lock-dialog/screensaverwndadaptor.cpp @@ -1,20 +1,3 @@ -/* - * Copyright (C) 2022 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ #include "screensaverwndadaptor.h" #include diff --git a/src/screensaverwndadaptor.h b/src/lock-dialog/screensaverwndadaptor.h similarity index 74% rename from src/screensaverwndadaptor.h rename to src/lock-dialog/screensaverwndadaptor.h index 77c3dde..0641c0c 100644 --- a/src/screensaverwndadaptor.h +++ b/src/lock-dialog/screensaverwndadaptor.h @@ -1,20 +1,3 @@ -/* - * Copyright (C) 2022 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ #ifndef SCREENSAVERWNDADAPTOR_H #define SCREENSAVERWNDADAPTOR_H diff --git a/screensaver-focus-helper/blackwindow.cpp b/src/lock-focushelper/blackwindow.cpp similarity index 80% rename from screensaver-focus-helper/blackwindow.cpp rename to src/lock-focushelper/blackwindow.cpp index 0830595..52f270e 100644 --- a/screensaver-focus-helper/blackwindow.cpp +++ b/src/lock-focushelper/blackwindow.cpp @@ -1,20 +1,3 @@ -/* - * Copyright (C) 2021 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ #include "blackwindow.h" #include #include diff --git a/src/lock-focushelper/blackwindow.h b/src/lock-focushelper/blackwindow.h new file mode 100644 index 0000000..9f30d24 --- /dev/null +++ b/src/lock-focushelper/blackwindow.h @@ -0,0 +1,25 @@ +#ifndef BLACKWINDOW_H +#define BLACKWINDOW_H + +#include +#include + +class BlackWindow : public QWidget, public QAbstractNativeEventFilter +{ + Q_OBJECT +public: + explicit BlackWindow(QWidget *parent = nullptr); + + virtual bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) override; + bool eventFilter(QObject *obj, QEvent *event); +signals: + +private Q_SLOTS: + void laterActivate(); + +protected: + void paintEvent(QPaintEvent *event); + bool screensaverIsShow = false; +}; + +#endif // BLACKWINDOW_H diff --git a/src/lock-focushelper/main.cpp b/src/lock-focushelper/main.cpp new file mode 100644 index 0000000..35a93f6 --- /dev/null +++ b/src/lock-focushelper/main.cpp @@ -0,0 +1,20 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "blackwindow.h" +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + BlackWindow w; + w.setGeometry(QApplication::desktop()->geometry()); + //w.activateWindow(); + w.show(); + a.exec(); + return 0; +} diff --git a/src/lockchecker.cpp b/src/lockchecker.cpp deleted file mode 100644 index c0533cf..0000000 --- a/src/lockchecker.cpp +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Copyright (C) 2021 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ - -#include "lockchecker.h" -#include "loginedusers.h" -#include -#include -#include -#include -#include -#include -#include - -#define SYSTEMD_SERVICE "org.freedesktop.login1" -#define SYSTEMD_PATH "/org/freedesktop/login1" -#define SYSTEMD_INTERFACE "org.freedesktop.login1.Manager" - -QDBusArgument &InhibitInfo::operator<<(QDBusArgument &argument, const InhibitInfo::InhibitorInfo &mystruct) -{ - argument.beginStructure(); - argument << mystruct.name << mystruct.icon; - argument.endStructure(); - return argument; -} - -const QDBusArgument &InhibitInfo::operator>>(const QDBusArgument &argument, InhibitInfo::InhibitorInfo &mystruct) -{ - argument.beginStructure(); - argument >> mystruct.name >> mystruct.icon ; - argument.endStructure(); - return argument; -} - -LockChecker::LockChecker() -{ -} - -LockChecker::~LockChecker() -{ -} - -int LockChecker::checkLock() -{ - bool lockfile = false; - bool lockuser = false; - - QFile file_backup("/tmp/lock/kylin-backup.lock"); - QFile file_update("/tmp/lock/kylin-update.lock"); - if (file_backup.exists()) { - int fd_backup = open(QString("/tmp/lock/kylin-backup.lock").toUtf8().data(), O_RDONLY); - int b = flock(fd_backup, LOCK_EX|LOCK_NB); - qDebug() << "b" << b; - if (b < 0) { - lockfile = true; - QString file_user = getName(&file_backup); - if (file_user == qgetenv("USER")) { - lockuser = true; - } - } - file_backup.close(); - if (flock(fd_backup, LOCK_UN) == 0) { - qDebug() << "unlock sucess."; - } else { - qDebug() << "unlock fail."; - } - } - if (file_update.exists()) { - int fd_update = open(QString("/tmp/lock/kylin-update.lock").toUtf8().data(), O_RDONLY); - int c = flock(fd_update, LOCK_EX|LOCK_NB); - qDebug() << "c" << c; - if (c < 0) { - lockfile = true; - QString file_user = getName(&file_update); - if (file_user == qgetenv("USER")) { - lockuser = true; - } - } - file_backup.close(); - if (flock(fd_update, LOCK_UN) == 0) { - qDebug() << "unlock sucess."; - } else { - qDebug() << "unlock fail."; - } - } - if (lockfile) { - if(lockuser) - return 2; - return 1; - } - return 0; -} - -QStringList LockChecker::getLoginedUsers() -{ - QStringList loginedUser; - qRegisterMetaType("LoginedUsers"); - qDBusRegisterMetaType(); - QDBusInterface loginInterface(SYSTEMD_SERVICE, - SYSTEMD_PATH, - SYSTEMD_INTERFACE, - QDBusConnection::systemBus()); - - if (loginInterface.isValid()) { - qDebug() << "create interface success"; - } - - QDBusMessage result = loginInterface.call("ListUsers"); - QList outArgs = result.arguments(); - QVariant first = outArgs.at(0); - const QDBusArgument &dbusArgs = first.value(); - - QVector loginedUsers; - - dbusArgs.beginArray(); - while (!dbusArgs.atEnd()) { - LoginedUsers user; - dbusArgs >> user; - loginedUsers.push_back(user); - } - dbusArgs.endArray(); - - for (LoginedUsers user : loginedUsers) { - - QDBusInterface userPertyInterface("org.freedesktop.login1", - user.objpath.path(), - "org.freedesktop.DBus.Properties", - QDBusConnection::systemBus()); - - QDBusReply reply = userPertyInterface.call("Get", "org.freedesktop.login1.User", "State"); - if (reply.isValid()) { - QString status = reply.value().toString(); - if ("closing" != status) { - loginedUser.append(user.userName); - } - } - } - return loginedUser; -} - -QVector LockChecker::listInhibitor(QString type) -{ - qDBusRegisterMetaType(); - - QVector resVec; - - QDBusInterface loginInterface("org.gnome.SessionManager", "/org/gnome/SessionManager", - "org.gnome.SessionManager", QDBusConnection::sessionBus()); - - if (loginInterface.isValid()) { - qDebug() << "create interface success"; - } - - QDBusMessage result = loginInterface.call("ListInhibitor", QVariant(type)); - QList outArgs = result.arguments(); - QVariant first = outArgs.at(0); - const QDBusArgument &dbusArgs = first.value(); - - dbusArgs.beginArray(); - while (!dbusArgs.atEnd()) { - InhibitInfo::InhibitorInfo inhibtor; - dbusArgs >> inhibtor; - resVec.push_back(inhibtor); - } - - dbusArgs.endArray(); - - return resVec; -} - -QString LockChecker::getName(QFile *a) -{ - QString user = getenv("USER"); - if (a->exists()) { - a->open(QIODevice::ReadOnly|QIODevice::Text); - QTextStream fileStream(a); - int k = 0; - while (!fileStream.atEnd()) { - QString line = fileStream.readLine(); - if (k == 0) { - QString a = line; - qDebug() << "uid="< outArgs = ret.arguments(); - QVariant first = outArgs.at(0); - const QDBusArgument &dbusArgs = first.value(); - QDBusObjectPath path; - dbusArgs.beginArray(); - int userNum = 0; - while (!dbusArgs.atEnd()) { - dbusArgs >> path; - userNum++; - } - dbusArgs.endArray(); - qDebug() << userNum; - - return userNum; -} diff --git a/src/lockwidget.cpp b/src/lockwidget.cpp deleted file mode 100644 index cb6723d..0000000 --- a/src/lockwidget.cpp +++ /dev/null @@ -1,2241 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ - -#include "lockwidget.h" - -#include "powermanager.h" -#include "ui_lockwidget.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "authdialog.h" -#include "loginauthinterface.h" -#include "virtualkeyboardwidget.h" -#include "configuration.h" -#include "users.h" -#include "displaymanager.h" -#include "config.h" -#include "commonfunc.h" -#include "hoverwidget.h" -#include "kylinnm.h" -#include "mytabwidget.h" -#include "klabel.h" -#include "rootWindowBackground.h" -#include "configuration.h" -#include "greeterservice.h" - -#include -#include -#include - -#define GSETTINGS_SCHEMA_MATE_BG "org.mate.background" -#define KEY_PICTURE_FILENAME "pictureFilename" -#define KEY_PICTURE_OPTIONS "pictureOptions" -#define KEY_PRIMARY_COLOR "primaryColor" -#define TIME_TYPE_SCHEMA "org.ukui.control-center.panel.plugins" -#define CONFIG_FILE "/etc/lightdm/ukui-greeter.conf" -#define ON_TAB_SHEET_WIDGET "#widgetNetworkManager{background-color: rgba(255,255,255,15%); border-radius: 4px; border: 2px solid #2C73C8;}" -#define ON_NORMAL_SHEET_WIDGET "#widgetNetworkManager{text-align:center;color: rgba(255, 255, 255, 255);border: none;border-radius: 4px;outline: none;}" -#define ON_TAB_SHEET "QPushButton{background-color: rgba(255,255,255,15%); border-radius: 4px; border: 2px solid #2C73C8;}" -#define ON_NORMAL_SHEET "QPushButton{text-align:center;color: rgba(255, 255, 255, 255);border: none;border-radius: 4px;outline: none;} \ - QPushButton::hover{background-color: rgba(255,255,255,15%);} \ - QPushButton::pressed {background-color: rgba(255,255,255,40%);}\ - QPushButton::checked {background-color: rgba(255, 255, 255, 40%);}" -float scale; -LockWidget::LockWidget(QWidget *parent) - : QWidget(parent), - ui(new Ui::LockWidget), - usersMenu(nullptr), - scrollArea(nullptr), - configuration(Configuration::instance()), - users(new Users(this)), - displayManager(new DisplayManager(this)), - timeType(24), - m_kylinNM(nullptr) -{ - scale = 1.0; - ui->setupUi(this); - // m_kylinNM->installEventFilter(this); - - if(users->getUsers().count() < 2){ - ui->btnSwitchUser->hide(); - } - UserItem user = users->getUserByName(getenv("USER")); - authDialog = new AuthDialog(user, this); - authDialog->installEventFilter(this); - connect(authDialog, &AuthDialog::authenticateCompete, - this, &LockWidget::onAuthenticateCompete); - connect(authDialog,&AuthDialog::clickPassword, - this,&LockWidget::onClickPassword); - connect(authDialog,&AuthDialog::loginOptionClicked, - this,&LockWidget::resetNavigation); - connect(authDialog,&AuthDialog::showMessageBtn, - this,&LockWidget::onShowMessageBtn); -// connect(this, &LockWidget::capsLockChanged, -// authDialog, &AuthDialog::onCapsLockChanged); - - curFontSize = configuration->getFontSize(); - this->installEventFilter(this); - initUI(); - - if(users->getUsers().count() < 2){ - is_switchBtn = false; - ui->btnSwitchUser->hide(); - } - - if(horAT != KEYBOARDBTN) { - if(is_batteryBtn) - horAT = BATTERYBTN; - else if(!is_batteryBtn && is_switchBtn) - horAT = SWITCHBTN; - else - horAT = NETWORKBTN; - } -} - -LockWidget::~LockWidget() -{ - delete ui; -} - -void LockWidget::closeEvent(QCloseEvent *event) -{ - qDebug() << "LockWidget::closeEvent"; - authDialog->close(); - - return QWidget::closeEvent(event); -} - -bool LockWidget::eventFilter(QObject *obj, QEvent *event) -{ - if(event->type() == 2){ - if(obj == mkylinNM) - return true; - - if(vKeyboard && obj == vKeyboard) - return true; - - if (vKeyboard && obj != vKeyboard && obj != ui->btnKeyboard && obj != btnNetworkManager && obj != ui->btnPowerManager && vKeyboard->isVisible()) { - hideBottomPlugins(); - } - - if(obj == ui->btnPowerManager || obj == ui->btnSwitchUser || obj == btnNetworkManager || obj == ui->btnBatteryStatus || obj == ui->btnKeyboard) { - authDialog->setFocusin(REMOVE); - return false; - } - - if(tabAt != LINEEDIT) { - authDialog->setFocusin(REMOVE); - if(tabAt == BOTTMBTN) { - tabAt = LINEEDIT; - setBottomBtnSheet(); - tabAt = BOTTMBTN; - } - } - - if(mBatteryWidget && mBatteryWidget->isVisible()) { - setCheckedSheet(BATTERYBTN, false); - at_plugins = false; - } - - if(scrollArea && scrollArea->isVisible()) { - setCheckedSheet(SWITCHBTN,false); - at_plugins = false; - } - - if(vKeyboard && vKeyboard->isVisible()) { - vKeyboard->hide(); - at_plugins = false; - } - - if(m_kylinNM && m_kylinNM->isVisible()) { - setCheckedSheet(NETWORKBTN, false); - at_plugins = false; - } - - if(powermanager && powermanager->isVisible()){ - showPowerManager(); - } - } - - if (obj == scrollContents ){ - if (event->type() == 76 ) { - usersMenu->show(); - //qDebug()<<"````````````````````````````````````````````"<type(); - } - } - return false; -} - -void LockWidget::setStartupMode(bool mode) -{ - m_isStartupMode = mode; - if (powermanager) { - powermanager->setStartupMode(m_isStartupMode); - } - if (m_isStartupMode) { - m_futureLoadDeskBg = QtConcurrent::run([=](){ - setRootWindow(); - }); - - m_agreementWindow = new AgreementWindow(this); - - connect(m_agreementWindow, &AgreementWindow::switchToGreeter, this, - [this]() { - switchWnd(0); - update(); - }); - - if(m_agreementWindow->getShowLoginPrompt()){ - switchWnd(1); - m_agreementWindow->initUI(); - }else{ - m_agreementWindow->hide(); - } - } -} - -void LockWidget::switchWnd(int index) -{ - if(authDialog) - authDialog->hide(); - if(m_agreementWindow) - m_agreementWindow->hide(); - ui->widgetTime->show(); - - repaint(); - - switch (index) { - case 0: - if(m_agreementWindow){ - m_agreementWindow->clearFocus(); - } - if(authDialog){ - authDialog->show(); - authDialog->setFocus(); - } - setBottomBtnVisible(true); - break; - case 1: - if(m_agreementWindow) - m_agreementWindow->show(); - ui->widgetTime->hide(); - - setBottomBtnVisible(false); - authDialog->clearFocus(); - m_agreementWindow->setFocusPolicy(Qt::StrongFocus); - setFocusProxy(m_agreementWindow); - m_agreementWindow->setFocus(); - default: - break; - } -} - -void LockWidget::setBottomBtnVisible(bool visible) -{ - if(visible){ - ui->btnSwitchUser->setVisible(btnVisMap.value(ui->btnSwitchUser)); - ui->btnPowerManager->setVisible(btnVisMap.value(ui->btnPowerManager)); - ui->btnKeyboard->setVisible(btnVisMap.value(ui->btnKeyboard)); - btnNetworkManager->setVisible(btnVisMap.value(btnNetworkManager)); - ui->btnBatteryStatus->setVisible(btnVisMap.value(btnNetworkManager)); - }else{ - btnVisMap.insert(ui->btnSwitchUser,!ui->btnSwitchUser->isHidden()); - ui->btnSwitchUser->setVisible(visible); - btnVisMap.insert(ui->btnPowerManager,!ui->btnPowerManager->isHidden()); - ui->btnPowerManager->setVisible(visible); - btnVisMap.insert(ui->btnKeyboard,!ui->btnKeyboard->isHidden()); - ui->btnKeyboard->setVisible(visible); - btnVisMap.insert(btnNetworkManager,!btnNetworkManager->isHidden()); - btnNetworkManager->setVisible(visible); - btnVisMap.insert(ui->btnBatteryStatus,!ui->btnBatteryStatus->isHidden()); - ui->btnBatteryStatus->setVisible(visible); - } -} - -void LockWidget::key_enter_release(int key) -{ - if (tabAt == BOTTMBTN) { - switch (horAT) { - case BATTERYBTN: - showBattery(); - ui->btnBatteryStatus->setStyleSheet(ON_NORMAL_SHEET); - break; - case SWITCHBTN: - if(scrollArea && scrollArea->isVisible()) { - SwitchToUser(list.at(nowAt)->objectName()); - } else { - ui->btnSwitchUser->setStyleSheet(ON_NORMAL_SHEET); - showUserMenu(); - } - break; - case NETWORKBTN: - if(!m_kylinNM || !(m_kylinNM && m_kylinNM->isVisible())) - showNetManager(true); - widgetNetworkManager->setStyleSheet(ON_NORMAL_SHEET_WIDGET); - authDialog->setFocusin(REMOVE); - break; - case KEYBOARDBTN: - if(!vKeyboard || !(vKeyboard && vKeyboard->isVisible())) - showVirtualKeyboard(); - ui->btnSwitchUser->setStyleSheet(ON_NORMAL_SHEET); - break; - case POWERBTN: - showPowerManager(true); - break; - default: - break; - } - } else if (tabAt == BIOBTN) { - authDialog->setClick(); - } else if (tabAt == ENTERBTN) { - authDialog->checkPassword(); - tabAt = LINEEDIT; - } else if (tabAt == POWERMANAGER) { - powermanager->keyBdRelease(key); - } -} - -void LockWidget::key_tab_release(int key) -{ - if(key == Qt::Key_Tab) { - if (at_plugins) { - authDialog->setFocusin(REMOVE); - return; - } - switch (tabAt) { - case LINEEDIT: - authDialog->setFocusin(IN_LIGIN); - tabAt = ENTERBTN; - break; - case MESSAGEBTN : - tabAt = BOTTMBTN; - authDialog->setFocusin(REMOVE); - if(is_batteryBtn) { - horAT = BATTERYBTN; - setBottomBtnSheet(); - } else if(users->getUsers().count() > 1){ - horAT = SWITCHBTN; - setBottomBtnSheet(); - } else { - horAT =NETWORKBTN; - setBottomBtnSheet(); - } - break; - case ENTERBTN: - if(authDialog->getBioNum() >1) { - authDialog->setFocusin(BIO_RIGHT); - tabAt = BIOBTN; - } else { - tabAt = BOTTMBTN; - authDialog->setFocusin(REMOVE); - if(is_batteryBtn){ - horAT = BATTERYBTN; - } else if(users->getUsers().count() > 1){ - horAT = SWITCHBTN; - } else { - horAT =NETWORKBTN; - } - setBottomBtnSheet(); - } - break; - case BIOBTN: - tabAt = BOTTMBTN; - authDialog->setFocusin(REMOVE); - if(is_batteryBtn) { - horAT = BATTERYBTN; - setBottomBtnSheet(); - } else if(users->getUsers().count() > 1){ - horAT = SWITCHBTN; - setBottomBtnSheet(); - } else { - horAT =NETWORKBTN; - setBottomBtnSheet(); - } - break; - case BOTTMBTN: - if(!at_power) { - if(!authDialog->getLineeditStatus()) { - authDialog->setFocusin(IN_LINEEDIT); - tabAt = LINEEDIT; - } else { - authDialog->setFocusin(ON_MESSAGEBTN); - tabAt = MESSAGEBTN; - } - setBottomBtnSheet(); - } else if (at_power) { - powermanager->keyBdRelease(Qt::Key_Right); - tabAt = POWERMANAGER; - setBottomBtnSheet(); - } - break; - case POWERMANAGER: - powermanager->clearStatus(); - tabAt = BOTTMBTN; - if(is_batteryBtn) { - horAT = BATTERYBTN; - setBottomBtnSheet(); - } else if(users->getUsers().count() > 1){ - horAT = SWITCHBTN; - setBottomBtnSheet(); - } else { - horAT =NETWORKBTN; - setBottomBtnSheet(); - } - break; - case EMPTY: - authDialog->setFocusin(IN_LINEEDIT); - tabAt = LINEEDIT; - setBottomBtnSheet(); - } - } -} - -void LockWidget::key_shiftTab_release() -{ - if (at_plugins) { - authDialog->setFocusin(REMOVE); - return; - } - switch (tabAt) { - case LINEEDIT: - tabAt = BOTTMBTN; - authDialog->setFocusin(REMOVE); - if(is_batteryBtn) - horAT = BATTERYBTN; - else if(users->getUsers().count() > 1){ - horAT = SWITCHBTN; - } else { - horAT =NETWORKBTN; - } - setBottomBtnSheet(); - break; - case MESSAGEBTN : - tabAt = BOTTMBTN; - authDialog->setFocusin(REMOVE); - if(is_batteryBtn) { - horAT = BATTERYBTN; - setBottomBtnSheet(); - } else if(users->getUsers().count() > 1){ - horAT = SWITCHBTN; - setBottomBtnSheet(); - } else { - horAT =NETWORKBTN; - setBottomBtnSheet(); - } - break; - case ENTERBTN: - authDialog->setFocusin(IN_LINEEDIT); - tabAt = LINEEDIT; - setBottomBtnSheet(); - break; - case BIOBTN: - authDialog->setFocusin(IN_LIGIN); - tabAt = ENTERBTN; - break; - case BOTTMBTN: - if(!at_power) { - if(!authDialog->getLineeditStatus()) { - if(authDialog->getBioNum() >1) { - authDialog->setFocusin(BIO_RIGHT); - tabAt = BIOBTN; - } else { - authDialog->setFocusin(IN_LIGIN); - tabAt = ENTERBTN; - } - } else { - authDialog->setFocusin(ON_MESSAGEBTN); - tabAt = MESSAGEBTN; - } - setBottomBtnSheet(); - } else { - powermanager->keyBdRelease(Qt::Key_Right); - tabAt = POWERMANAGER; - } - setBottomBtnSheet(); - break; - case POWERMANAGER: - powermanager->clearStatus(); - tabAt = BOTTMBTN; - if(is_batteryBtn) { - horAT = BATTERYBTN; - setBottomBtnSheet(); - } else if(users->getUsers().count() > 1){ - horAT = SWITCHBTN; - setBottomBtnSheet(); - } else { - horAT =NETWORKBTN; - setBottomBtnSheet(); - } - break; - case EMPTY: - authDialog->setFocusin(IN_LINEEDIT); - tabAt = LINEEDIT; - setBottomBtnSheet(); - } -} - -void LockWidget::key_LR_release(int key) -{ - if(key == Qt::Key_Right) { - if(tabAt == BOTTMBTN) { - if (at_plugins) - return; - switch (horAT) { - case BATTERYBTN: - if(is_switchBtn) - horAT = SWITCHBTN; - else - horAT = NETWORKBTN; - break; - case SWITCHBTN: - horAT = NETWORKBTN; - break; - case NETWORKBTN: - if (ui->btnKeyboard->isHidden()) { - horAT = POWERBTN; - } else { - horAT = KEYBOARDBTN; - } - break; - case KEYBOARDBTN: - horAT = POWERBTN; - break; - case POWERBTN: - if(is_batteryBtn) - horAT = BATTERYBTN; - else if(is_switchBtn) - horAT = SWITCHBTN; - else - horAT = NETWORKBTN; - break; - default: - break; - } - setBottomBtnSheet(); - } else if (tabAt == BIOBTN) { - authDialog->setFocusin(BIO_RIGHT); - } else if (tabAt == POWERMANAGER) { - powermanager->keyBdRelease(Qt::Key_Right); - } - } else if (key == Qt::Key_Left) { - if(tabAt == BOTTMBTN) { - if (at_plugins) - return; - switch (horAT) { - case BATTERYBTN: - horAT = POWERBTN; - break; - case SWITCHBTN: - if(is_batteryBtn) - horAT = BATTERYBTN; - else - horAT = POWERBTN; - break; - case NETWORKBTN: - if(is_switchBtn) - horAT = SWITCHBTN; - else if(is_batteryBtn) - horAT = BATTERYBTN; - else - horAT = POWERBTN;; - break; - case KEYBOARDBTN: - horAT = NETWORKBTN; - break; - case POWERBTN: - if (ui->btnKeyboard->isHidden()) { - horAT = NETWORKBTN; - } else { - horAT = KEYBOARDBTN; - } - break; - default: - break; - } - setBottomBtnSheet(); - } else if (tabAt == BIOBTN) { - authDialog->setFocusin(BIO_LEFT); - } else if (tabAt == POWERMANAGER) { - powermanager->keyBdRelease(Qt::Key_Left); - } - } -} - -void LockWidget::setBottomBtnSheet() -{ - if (tabAt == BOTTMBTN) { - switch (horAT) { - case BATTERYBTN: - ui->btnBatteryStatus->setStyleSheet(ON_TAB_SHEET); - ui->btnSwitchUser->setStyleSheet(ON_NORMAL_SHEET); - widgetNetworkManager->setStyleSheet(ON_NORMAL_SHEET_WIDGET); - ui->btnKeyboard->setStyleSheet(ON_NORMAL_SHEET); - ui->btnPowerManager->setStyleSheet(ON_NORMAL_SHEET); - break; - case SWITCHBTN: - ui->btnSwitchUser->setStyleSheet(ON_TAB_SHEET); - widgetNetworkManager->setStyleSheet(ON_NORMAL_SHEET_WIDGET); - ui->btnKeyboard->setStyleSheet(ON_NORMAL_SHEET); - ui->btnPowerManager->setStyleSheet(ON_NORMAL_SHEET); - ui->btnBatteryStatus->setStyleSheet(ON_NORMAL_SHEET); - break; - case NETWORKBTN: - widgetNetworkManager->setStyleSheet(ON_TAB_SHEET_WIDGET); - ui->btnKeyboard->setStyleSheet(ON_NORMAL_SHEET); - ui->btnPowerManager->setStyleSheet(ON_NORMAL_SHEET); - ui->btnSwitchUser->setStyleSheet(ON_NORMAL_SHEET); - ui->btnBatteryStatus->setStyleSheet(ON_NORMAL_SHEET); - break; - case KEYBOARDBTN: - ui->btnKeyboard->setStyleSheet(ON_TAB_SHEET); - ui->btnPowerManager->setStyleSheet(ON_NORMAL_SHEET); - ui->btnSwitchUser->setStyleSheet(ON_NORMAL_SHEET); - widgetNetworkManager->setStyleSheet(ON_NORMAL_SHEET_WIDGET); - ui->btnBatteryStatus->setStyleSheet(ON_NORMAL_SHEET); - break; - case POWERBTN: - ui->btnPowerManager->setStyleSheet(ON_TAB_SHEET); - ui->btnSwitchUser->setStyleSheet(ON_NORMAL_SHEET); - widgetNetworkManager->setStyleSheet(ON_NORMAL_SHEET_WIDGET); - ui->btnKeyboard->setStyleSheet(ON_NORMAL_SHEET); - ui->btnBatteryStatus->setStyleSheet(ON_NORMAL_SHEET); - break; - default: - ui->btnSwitchUser->setStyleSheet(ON_NORMAL_SHEET); - widgetNetworkManager->setStyleSheet(ON_NORMAL_SHEET_WIDGET); - ui->btnKeyboard->setStyleSheet(ON_NORMAL_SHEET); - ui->btnPowerManager->setStyleSheet(ON_NORMAL_SHEET); - ui->btnBatteryStatus->setStyleSheet(ON_NORMAL_SHEET); - break; - } - } else { - ui->btnSwitchUser->setStyleSheet(ON_NORMAL_SHEET); - widgetNetworkManager->setStyleSheet(ON_NORMAL_SHEET_WIDGET); - ui->btnKeyboard->setStyleSheet(ON_NORMAL_SHEET); - ui->btnPowerManager->setStyleSheet(ON_NORMAL_SHEET); - ui->btnBatteryStatus->setStyleSheet(ON_NORMAL_SHEET); - } -} - -void LockWidget::key_OB_release(int key) -{ - QString focus = "focus"; - QString normal = "normal"; - if(key == Qt::Key_Up){ // "Up" - for(int i = 0; i < list.count(); i++){ - if(nowAt == i){ - if(i == 0) - return ; - list.at(i)->setStyleSheet("HoverWidget{background-color:transparent;}" - "HoverWidget:hover:!pressed{background-color:rgb(255,255,255,15%);border-radius: 6px;}"); - list.at(i-1)->setStyleSheet("HoverWidget{background-color:rgb(255,255,255,40%);border-radius: 6px;}" - "HoverWidget:hover:!pressed{background-color:rgb(255,255,255,15%);border-radius: 6px;}"); - nowAt = i-1; - - /*else if(i == 0){ - list.last()->setStyleSheet("HoverWidget{background-color:rgb(255,255,255,40%);border-radius: 6px;}" - "HoverWidget:hover:!pressed{background-color:rgb(255,255,255,15%);border-radius: 6px;}"); - nowAt = list.count() -1; - }*/ - } - } - } else if(key == Qt::Key_Down) { // "Down" - for(int i = list.count(); i >= 0; i--){ - if(nowAt == i){ - if(i == list.count() - 1) - return ; - list.at(i)->setStyleSheet("HoverWidget{background-color:transparent;}" - "HoverWidget:hover:!pressed{background-color:rgb(255,255,255,15%);border-radius: 6px;}"); - list.at(i+1)->setStyleSheet("HoverWidget{background-color:rgb(255,255,255,40%);border-radius: 6px;}" - "HoverWidget:hover:!pressed{background-color:rgb(255,255,255,15%);border-radius: 6px;}"); - nowAt = i+1; - /*else if(i == list.count() - 1){ - list.first()->setStyleSheet("HoverWidget{background-color:rgb(255,255,255,40%);border-radius: 6px;}" - "HoverWidget:hover:!pressed{background-color:rgb(255,255,255,15%);border-radius: 6px;}"); - nowAt = 0; - }*/ - } - } - } -} - -void LockWidget::resetNavigation() -{ - tabAt = LINEEDIT; - setBottomBtnSheet(); - authDialog->setFocusin(IN_LINEEDIT); -} - -QString LockWidget::getLongFormatDate(int type) -{ - kdk_logn_dateinfo *dateInfo = kdk_system_login_lock_dateinfo(getenv("USER")); - if (type == DATE) { - QString date = dateInfo->date; - QString week = dateInfo->week; - if (dateInfo) { - kdk_free_logn_dateinfo(dateInfo); - } - return date + " " + week; - } else if (type == TIME) { - QString time = dateInfo->time; - if (dateInfo) { - kdk_free_logn_dateinfo(dateInfo); - } - return time; - } -} - -void LockWidget::startAuth() -{ - if(authDialog) - { - authDialog->startAuth(); -// if (isTableMode && !(vKeyboard && vKeyboard->isVisible())) { -// showVirtualKeyboard(); -// } - } -} - -void LockWidget::stopAuth() -{ - if(authDialog) - { - authDialog->stopAuth(); - } -} - -void LockWidget::setX11Focus() -{ - if(authDialog){ - //authDialog->setX11Focus(); - } -} - -void LockWidget::initUI() -{ - setFocusProxy(authDialog); - // 检查并获取第三方认证插件配置信息 - if (PluginsLoader::instance().findModulesByType(LoginPluginInterface::MODULETYPE_AUTH).size() > 0) { - LoginAuthInterface *plugin = dynamic_cast(PluginsLoader::instance() \ - .findModulesByType(LoginPluginInterface::MODULETYPE_AUTH) \ - .values().first()); - QJsonObject rootObj; - rootObj["MsgType"] = "GetInformations"; - rootObj["Key"] = "Configures"; - QString strMsg = plugin->onMessage(QJsonDocument(rootObj).toJson()); - onGetCustomPluginMsg(strMsg); - } - if (authDialog) - authDialog->setCustomAuthDefault(m_isCustomDefault); - - if(QGSettings::isSchemaInstalled(TIME_TYPE_SCHEMA)){ - QGSettings *time_type = new QGSettings(TIME_TYPE_SCHEMA); - QStringList keys = time_type->keys(); - if (keys.contains("hoursystem")) { - timeType = time_type->get("hoursystem").toInt(); - } - if (keys.contains("date")) { - dateType = time_type->get("date").toString(); - } - } - - //显示系统时间 - timer = new QTimer(this); - connect(timer, &QTimer::timeout, this, [&]{ - ui->lblTime->setText(getLongFormatDate(TIME)); - ui->lblDate->setText(getLongFormatDate(DATE)); - }); - - ui->lblTime->setText(getLongFormatDate(TIME)); - - ui->lblTime->setFontSize(36); - ui->lblTime->setAlignment(Qt::AlignCenter); - ui->lblTime->adjustSize(); - timer->start(1000); - - if(dateType == "cn") - ui->lblDate->setText(getLongFormatDate(DATE)); - else - ui->lblDate->setText(getLongFormatDate(DATE)); - - ui->lblDate->setFontSize(18); - ui->lblDate->setAlignment(Qt::AlignCenter); - ui->lblDate->adjustSize(); - ui->widgetTime->adjustSize(); - - //电池电量显示icon - batInterface = new QDBusInterface( - "org.freedesktop.UPower", "/org/freedesktop/UPower", "org.freedesktop.DBus.Properties", QDBusConnection::systemBus(), this); - - QString batteryPath = ""; - dface = new QDBusInterface(UPOWER_SERVICE, UPOWER_PATH, UPOWER_INTERFACE, QDBusConnection::systemBus(), this); - QDBusReply> reply = dface->call("EnumerateDevices"); - if (dface->isValid()) { - for (QDBusObjectPath op : reply.value()) { - if (op.path().contains("battery_")) { - batteryPath = op.path(); - qDebug() << "battery path is :" << batteryPath; - break; - } - } - } else { - qDebug() << "Enumerate devices failed"; - } - - iface = new QDBusInterface(UPOWER_SERVICE, batteryPath, FREEDESKTOP_UPOWER, QDBusConnection::systemBus()); - if (dface->isValid()) { - QDBusReply reply = batInterface->call("Get", "org.freedesktop.UPower", "LidIsPresent"); - if (reply.isValid()) { - if (true == reply.value().toBool()) { - setBatteryIcon(getBatteryIconName()); - QDBusConnection::systemBus().connect( - UPOWER_SERVICE, batteryPath, FREEDESKTOP_UPOWER, "PropertiesChanged", this, SLOT(dealMessage(QDBusMessage))); - ui->btnBatteryStatus->setFixedSize(48,48); - ui->btnBatteryStatus->setIconSize(QSize(24,24)); - ui->btnBatteryStatus->setFocusPolicy(Qt::NoFocus); - ui->btnBatteryStatus->installEventFilter(this); - ui->btnBatteryStatus->setCheckable(true); - ui->btnBatteryStatus->setToolTip(tr("PowerInfo")); - ui->btnBatteryStatus->raise(); - mBatteryWidget = new BatteryWidget(QPoint(ui->btnBatteryStatus->x(), ui->btnBatteryStatus->y()), this); - mBatteryWidget->hide(); - connect(ui->btnBatteryStatus,&QPushButton::clicked - ,this,&LockWidget::showBattery); - } else { - ui->btnBatteryStatus->hide(); - is_batteryBtn = false; - } - } else { - ui->btnBatteryStatus->hide(); - is_batteryBtn = false; - } - } else { - ui->btnBatteryStatus->hide(); - is_batteryBtn = false; - } - - //电源管理 - ui->btnPowerManager->setIcon(QIcon(":/image/assets/shutdown.svg")); - ui->btnPowerManager->setFixedSize(48,48); - ui->btnPowerManager->setIconSize(QSize(24,24)); - ui->btnPowerManager->setToolTip(tr("Power")); - ui->btnPowerManager->setFocusPolicy(Qt::NoFocus); - ui->btnPowerManager->installEventFilter(this); - - connect(ui->btnPowerManager,&QPushButton::clicked - ,this,&LockWidget::showPowerManager); - - widgetNetworkManager = new QWidget(this); - widgetNetworkManager->setObjectName("widgetNetworkManager"); - widgetNetworkManager->setFixedSize(48,48); - btnNetworkManager = new KyNetworkIcon(widgetNetworkManager); - btnNetworkManager->setCheckable(true); - btnNetworkManager->setFixedSize(48,48); - btnNetworkManager->setIconSize(QSize(24,24)); - btnNetworkManager->setFocusPolicy(Qt::NoFocus); - btnNetworkManager->installEventFilter(this); - btnNetworkManager->setCursor(Qt::ArrowCursor); - - connect(btnNetworkManager,&QPushButton::clicked - ,this, [&,this](){ - this->showNetManager(); - this->setCursor(Qt::ArrowCursor); - }); - - ui->btnKeyboard->setIcon(QIcon(":/image/assets/keyboard.svg")); - ui->btnKeyboard->setFixedSize(48, 48); - ui->btnKeyboard->setIconSize(QSize(24, 24)); - ui->btnKeyboard->setToolTip(tr("VirtualKeyboard")); - ui->btnKeyboard->setFocusPolicy(Qt::NoFocus); - ui->btnKeyboard->installEventFilter(this); - - connect(ui->btnKeyboard, &QPushButton::clicked, - this, &LockWidget::showVirtualKeyboard); - - //用户切换 - if(displayManager->canSwitch()) - { - //initUserMenu(); - ui->btnSwitchUser->setIcon(QIcon(":/image/assets/switchuser.svg")); - ui->btnSwitchUser->setIconSize(QSize(24, 24)); - ui->btnSwitchUser->setToolTip(tr("SwitchUser")); - ui->btnSwitchUser->setFixedSize(48, 48); - ui->btnSwitchUser->setFocusPolicy(Qt::NoFocus); - ui->btnSwitchUser->setCheckable(true); - ui->btnSwitchUser->raise(); - - connect(ui->btnSwitchUser, &QPushButton::clicked, - this, &LockWidget::showUserMenu); - } - //监听物理键盘插拔 - libswitch = new LibinputSwitchEvent; - isTableMode = libswitch->geInitDevicesStatus(); -// if(isTableMode && !(vKeyboard && vKeyboard->isVisible())) { -// showVirtualKeyboard(); -// } - connect(libswitch , &LibinputSwitchEvent::tabletModeStatusChanged, this, [ = ](int tablet_mode) { - isTableMode = tablet_mode; - qInfo()<<"TableMode:"<isVisible())) { -// QTimer::singleShot(1000, this, [=]{ -// if (this->isTableMode) { -// showVirtualKeyboard(); -// QTimer::singleShot(500, this, [&, this](){ -// authDialog->setFocusin(IN_LINEEDIT); -// }); -// } -// }); - } else if (!isTableMode && (tabAt == BOTTMBTN && horAT == KEYBOARDBTN) && (vKeyboard && vKeyboard->isVisible())) { - QTimer::singleShot(100, this, [=]{ - if (!this->isTableMode) { - hideBottomPlugins(); - } - }); - } - }); -} - -void LockWidget::netInPutStatus() -{ - if(isTableMode && !(vKeyboard && vKeyboard->isVisible())) - showVirtualKeyboard(); -} - -void LockWidget::showVirtualKeyboard() -{ - tabAt = LINEEDIT; - setBottomBtnSheet(); - tabAt = BOTTMBTN; - horAT = KEYBOARDBTN; - if(!vKeyboard){ - vKeyboard = new VirtualKeyboardWidget(this); - vKeyboard->installEventFilter(this); - vKeyboard->hide(); - - connect(vKeyboard, &VirtualKeyboardWidget::aboutToClose, - this, &LockWidget::hideBottomPlugins); - connect(vKeyboard, &VirtualKeyboardWidget::aboutToFloat, - this, &LockWidget::netResetLocation); - } - - vKeyboard->setVisible(vKeyboard->isHidden()); - - if(!vKeyboard->isHidden()){ - vKeyboard->raise(); - //authDialog->setFocusin(IN_LINEEDIT); - at_plugins = true; - if(m_kylinNM && m_kylinNM->isVisible() && !vKeyboard->getFloatStatus()) { - m_kylinNM->move(this->width() - m_kylinNM->width() - 20, - this->height() - m_kylinNM->height() - vKeyboard->height()); - m_kylinNM->raise(); - } else - authDialog->setFocusin(IN_LINEEDIT); - if(scrollArea && scrollArea->isVisible()) - setCheckedSheet(SWITCHBTN, false); - if(mBatteryWidget && mBatteryWidget->isVisible()) - setCheckedSheet(BATTERYBTN, false); - } - vKeyboard->raise(); - //setVirkeyboardPos(); -} - -void LockWidget::netResetLocation() -{ - if (m_kylinNM && m_kylinNM->isVisible()) { - if (vKeyboard->getFloatStatus()) { - m_kylinNM->move(this->width() - m_kylinNM->width() - 20, - this->height() - m_kylinNM->height() - 72 - 8) ; - } else { - m_kylinNM->move(this->width() - m_kylinNM->width() - 20, - this->height() - m_kylinNM->height() - vKeyboard->height()); - } - m_kylinNM->raise(); - } - if (vKeyboard && vKeyboard->isVisible()) { - vKeyboard->raise(); - } -} - -void LockWidget::showUserMenu() -{ - if(!usersMenu){ - initUserMenu(); - } - tabAt = LINEEDIT; - setBottomBtnSheet(); - tabAt = BOTTMBTN; - horAT = SWITCHBTN; - - if(scrollArea && scrollArea->isVisible()){ - setCheckedSheet(SWITCHBTN,false); - at_plugins = false; - authDialog->setFocusin(REMOVE); - } else { - setCheckedSheet(SWITCHBTN, true); - at_plugins = true; - authDialog->setFocusin(REMOVE); - if(m_kylinNM && m_kylinNM->isVisible()) - setCheckedSheet(NETWORKBTN, false); - if(mBatteryWidget && mBatteryWidget->isVisible()) - setCheckedSheet(BATTERYBTN, false); - scrollArea->setFocus(); - } -} - -void LockWidget::showPowerManager(bool keynavigation) -{ - if(!powermanager){ - powermanager = new PowerManager(getLoginedNum(), this); - powermanager->setStartupMode(m_isStartupMode); - sureWidget = new SureWindow(this); - powermanager->hide(); - connect(powermanager,SIGNAL(lock()) - ,this,SLOT(showPowerManager())); - connect(powermanager,SIGNAL(switchToUser()) - ,this,SLOT(switchToGreeter())); - connect(powermanager, SIGNAL(showInhibitWarning(QVector&,int)), - this,SLOT(showWarning(QVector&,int))); - connect(powermanager, SIGNAL(mulUsersLogined(int)), - this,SLOT(switchToSureDialog(int))); - connect(powermanager, SIGNAL(clickedSuspend()) - , this, SLOT(resetNavigation())); - sureWidget->adjustSize(); - sureWidget->move((width()-sureWidget->geometry().width())/2, (height()-sureWidget->geometry().height())/2); - sureWidget->hide(); - connect(sureWidget, SIGNAL(cantelButtonclicked()), - this, SLOT(hideSureDialog())); - connect(sureWidget, SIGNAL(confirmButtonclicked()), - this, SLOT(confirmClicked())); - } - - if(m_kylinNM && m_kylinNM->isVisible()) - setCheckedSheet(NETWORKBTN, false); - if(scrollArea && scrollArea->isVisible()) - setCheckedSheet(SWITCHBTN,false); - if(mBatteryWidget && mBatteryWidget->isVisible()) - setCheckedSheet(BATTERYBTN, false); - if(sureWidget && sureWidget->isVisible()) - sureWidget->hide(); - if (!at_power && (vKeyboard && vKeyboard->isVisible())) { - m_isShowKeyboard = true; - hideBottomPlugins(); - } else if (!at_power && (vKeyboard && !vKeyboard->isVisible())) { - m_isShowKeyboard = false; - } - if(powermanager->isVisible()){ - authDialog->show(); - powermanager->hide(); - if(!authDialog->getLineeditStatus()) { - tabAt = LINEEDIT; - authDialog->setFocusin(IN_LINEEDIT); -// if (m_isShowKeyboard && isTableMode && !(vKeyboard && vKeyboard->isVisible())) { -// showVirtualKeyboard(); -// } - } else { - tabAt = MESSAGEBTN; - authDialog->setFocusin(ON_MESSAGEBTN); - } - //setBottomBtnSheet(); - powermanager->clearStatus(); - at_power = false; - } - else{ - authDialog->hide(); - powermanager->show(); - if(keynavigation){ - powermanager->keyBdRelease(Qt::Key_Right); - tabAt = POWERMANAGER; - setBottomBtnSheet(); - } else { - tabAt = LINEEDIT; - setBottomBtnSheet(); - tabAt = BOTTMBTN; - horAT = POWERBTN; - } - at_power = true; -#ifndef USE_INTEL - powermanager->showNormalSize(); -#endif - powermanager->setGeometry((width()-powermanager->width())/2, - (height()-powermanager->height())/2, - powermanager->width(),powermanager->height()); - } -} - -void LockWidget::setCheckedSheet(int type, bool show) -{ - switch (type) { - case BATTERYBTN: - if(show) { - mBatteryWidget->show(); - ui->btnBatteryStatus->setChecked(true); - } else { - mBatteryWidget->hide(); - ui->btnBatteryStatus->setChecked(false); - } - break; - case SWITCHBTN: - if(show) { - scrollArea->show(); - ui->btnSwitchUser->setChecked(true); - } else { - scrollArea->hide(); - ui->btnSwitchUser->setChecked(false); - } - break; - case NETWORKBTN: - if(show) { - m_kylinNM->show(); - btnNetworkManager->setChecked(true); - } else { - m_kylinNM->hide(); - btnNetworkManager->setChecked(false); - } - break; - default: - break; - } -} - -void LockWidget::showWarning(QVector &wlist, int type) -{ - powermanagerType = type; - if(m_kylinNM && m_kylinNM->isVisible()) - setCheckedSheet(NETWORKBTN, false); - if(scrollArea && scrollArea->isVisible()) - setCheckedSheet(SWITCHBTN, false); - - authDialog->hide(); - powermanager->hide(); - sureWidget->show(); - sureWidget->setFocus(); - ui->widgetTime->hide(); - ui->btnPowerManager->hide(); - //btnNetworkManager->hide(); - widgetNetworkManager->hide(); - ui->btnSwitchUser->hide(); - ui->btnKeyboard->hide(); - ui->btnBatteryStatus->hide(); - - sureWidget->setWarning(wlist, type); -} - -void LockWidget::switchToSureDialog(int type) -{ - powermanagerType = type; - if(m_kylinNM && m_kylinNM->isVisible()) - setCheckedSheet(NETWORKBTN, false); - if(scrollArea && scrollArea->isVisible()) - setCheckedSheet(SWITCHBTN, false); - - authDialog->hide(); - powermanager->hide(); - sureWidget->show(); - sureWidget->setFocus(); - ui->widgetTime->hide(); - ui->btnPowerManager->hide(); - widgetNetworkManager->hide(); - //btnNetworkManager->hide(); - ui->btnSwitchUser->hide(); - ui->btnKeyboard->hide(); - ui->btnBatteryStatus->hide(); - - sureWidget->setTips(tr("Multiple users are logged in at the same time.Are you sure you want to reboot this system?")); -} - -void LockWidget::hideSureDialog() -{ - sureWidget->hide(); - powermanager->show(); - ui->widgetTime->show(); - ui->btnPowerManager->show(); - widgetNetworkManager->show(); - //btnNetworkManager->show(); - ui->btnSwitchUser->show(); - ui->btnKeyboard->show(); - ui->btnBatteryStatus->show(); -} - -void LockWidget::confirmClicked() -{ - if(m_kylinNM && m_kylinNM->isVisible()) - setCheckedSheet(NETWORKBTN, false); - if(scrollArea && scrollArea->isVisible()) - setCheckedSheet(SWITCHBTN, false); - if(mBatteryWidget && mBatteryWidget->isVisible()) - setCheckedSheet(BATTERYBTN, false); - sureWidget->hide(); - powermanager->hide(); - authDialog->show(); - ui->widgetTime->show(); - ui->btnPowerManager->show(); - widgetNetworkManager->show(); - //btnNetworkManager->show(); - ui->btnSwitchUser->show(); - ui->btnKeyboard->show(); - ui->btnBatteryStatus->show(); - powermanager->doEvent(powermanagerType); -} - -void LockWidget::showNetManager(bool keynavigation) -{ - if(!keynavigation) { - tabAt = LINEEDIT; - setBottomBtnSheet(); - tabAt = BOTTMBTN; - horAT = NETWORKBTN; - } - if(!m_kylinNM){ - /*这里放在点击按钮后加载,一个原因是启动优化,另一个原因是如果放在构造函数中加载,则必须 - * 先让网络窗口显示出来一次,否则会在锁屏程序退出时,锁屏窗口在closeEvent中崩溃,原因未知 - * 同时,可以尽量降低在未操作网络时,网络程序对锁屏窗口的影响*/ - loadNetPlugin(); - m_kylinNM->hide(); - } - - if(m_kylinNM->isVisible()) - { - setCheckedSheet(NETWORKBTN, false); - } else { - setCheckedSheet(NETWORKBTN, true); - if(scrollArea && scrollArea->isVisible()) - setCheckedSheet(SWITCHBTN, false); - if(mBatteryWidget && mBatteryWidget->isVisible()) - setCheckedSheet(BATTERYBTN, false); - m_kylinNM->setGeometry(this->width() - m_kylinNM->width() - 20, - this->height() - m_kylinNM->height() - 72 - 8, - m_kylinNM->width(), - m_kylinNM->height()); - m_kylinNM->raise(); - if (vKeyboard && vKeyboard->isVisible()) { - vKeyboard->raise(); - } - m_kylinNM->setFocus(); - /*在150%缩放下,点击网络弹窗左上角有线连接部分,authDialog会收到点击事件导致网络弹窗隐藏, - * 这里只调用m_kylinNM->raise()仍会有问题,需要再调用一次authDialog->lower()才行,原因未知*/ - if(authDialog && authDialog->isVisible()){ - authDialog->lower(); - authDialog->clearFocus(); - } - - if(mBatteryWidget && mBatteryWidget->isVisible()) { - mBatteryWidget->lower(); - mBatteryWidget->clearFocus(); - } - at_plugins = true; - - //m_kylinNM->updateWifiList(); - } -} - -void LockWidget::onClickPassword() -{ - tabAt = LINEEDIT; - if(is_switchBtn) - horAT = SWITCHBTN; - else - horAT = NETWORKBTN; - setBottomBtnSheet(); - authDialog->setFocusin(IN_LINEEDIT); - - if(m_kylinNM && m_kylinNM->isVisible()) { - setCheckedSheet(NETWORKBTN, false); - at_plugins = false; - } - - if(scrollArea && scrollArea->isVisible()) { - setCheckedSheet(SWITCHBTN, false); - at_plugins = false; - } - if(isTableMode) { - if(!(vKeyboard && vKeyboard->isVisible())) - showVirtualKeyboard(); - } -// if(vKeyboard && vKeyboard->isVisible()) { -// vKeyboard->hide(); -// at_plugins = false; -// } -} - -void LockWidget::onShowMessageBtn(bool is_show) -{ - if(is_show) { - tabAt = MESSAGEBTN; - authDialog->setFocusin(ON_MESSAGEBTN); - } -} - -void LockWidget::showBattery() -{ - if(mBatteryWidget->isVisible()) { - setCheckedSheet(BATTERYBTN, false); - at_plugins = false; - } else { - setCheckedSheet(BATTERYBTN, true); - at_plugins = true; - } - - tabAt = LINEEDIT; - setBottomBtnSheet(); - tabAt = BOTTMBTN; - horAT = BATTERYBTN; - if(scrollArea && scrollArea->isVisible()){ - setCheckedSheet(SWITCHBTN, false); - } else if (m_kylinNM && m_kylinNM->isVisible()){ - setCheckedSheet(NETWORKBTN, false); - } -} - -void LockWidget::hideBottomPlugins() -{ - if(scrollArea && scrollArea->isVisible()) - setCheckedSheet(SWITCHBTN, false); - - if(vKeyboard && vKeyboard->isVisible()) { - vKeyboard->hide(); - at_plugins = false; - } - if(m_kylinNM && m_kylinNM->isVisible()) { - m_kylinNM->move(this->width() - m_kylinNM->width() - 20, - this->height() - m_kylinNM->height() - 72 - 8); - tabAt = BOTTMBTN; - horAT = NETWORKBTN; - setCheckedSheet(NETWORKBTN, true); - at_plugins = true; - authDialog->setFocusin(REMOVE); - return ; - } - //tabAt = EMPTY; - if(!authDialog->getLineeditStatus()) - tabAt = LINEEDIT; - setBottomBtnSheet(); -} - -void LockWidget::setBatteryIcon(QString str) -{ - QPixmap pixmap = QIcon::fromTheme(str).pixmap(QSize(24, 24)); - QImage img = pixmap.toImage(); - for (int x = 0; x < img.width(); x++) { - for (int y = 0; y < img.height(); y++) { - QColor color = img.pixelColor(x, y); - color.setRed(255); - color.setGreen(255); - color.setBlue(255); - img.setPixelColor(x, y, color); - } - } - ui->btnBatteryStatus->setIcon(QPixmap::fromImage(img)); -} - -void LockWidget::dealMessage(QDBusMessage) -{ - setBatteryIcon(getBatteryIconName()); -} - -int LockWidget::getNetStatus() -{ - int ret = -1; - QString actLanName = "--"; - QString actWifiName = "--"; - - qInfo()<<"getNetStatus start"; - activecon *act = NULL; - int count = 0; - kylin_network_get_activecon_info(&act, &count); - qInfo()<<"getNetStatus end"; - if(!act) - return -1; - - int index = 0; - while (act && index < count) { - if (QString(act[index].type) == "ethernet" || QString(act[index].type) == "802-3-ethernet") { - actLanName = QString(act[index].con_name); - } - if (QString(act[index].type) == "wifi" || QString(act[index].type) == "802-11-wireless") { - actWifiName = QString(act[index].con_name); - } - index ++; - } - if (act) { - free(act); - } - - // 设置图标 - if (actLanName != "--") { - ret = 0; - } else if (actWifiName != "--") { - ret = 1; - } else { - ret = -1; - } - qDebug() << "[KylinNM] [getConnectStatus] getConnectStatus = " << ret; - //KylinDBus::checkConnectivity(); - return ret; -} - -void LockWidget::loadNetPlugin() -{ - m_kylinNM = new QWidget(this); - m_kylinNM->setFixedSize(420,480); - m_kylinNM->setObjectName("m_kylinNM"); - m_kylinNM->setStyleSheet("#m_kylinNM{background-color: white; border-radius:12px;}"); - - mkylinNM = new MyTabWidget(m_kylinNM); - mkylinNM->setFixedSize(420,480); - mkylinNM->tabBar()->setFixedHeight(40); - mkylinNM->installEventFilter(this); - - QPluginLoader netloader("/usr/lib/kylin-nm/libnetconnect.so");//有线 - QPluginLoader wlanloader("/usr/lib/kylin-nm/libwlanconnect.so");//无线 - - if (netloader.load()) { - QObject * plugin = netloader.instance(); - - if (plugin) { - Interface * pluginInstance = qobject_cast(plugin); - // 插件是否启用 - if (!pluginInstance) { - return; - } - - pluginInstance->setPluginType(SIMPLE); - QWidget *widget = pluginInstance->pluginUi(); - mkylinNM->addTab(widget,""); - - } else { - qDebug() << "Load Failed: " << netloader.errorString() << "\n"; - return; - } - } else { - qDebug() << "Load Failed: " << netloader.errorString() << "\n"; - return; - } - - if (wlanloader.load()) { - QObject * plugin = wlanloader.instance(); - - if (plugin) { - Interface * pluginInstance = qobject_cast(plugin); - // 插件是否启用 - if (!pluginInstance) { - return; - } - - pluginInstance->setPluginType(SIMPLE); - /*这里需要先调用setParentWidget,否则会出现网络连接弹窗无法弹出来的问题*/ - pluginInstance->setParentWidget(this); - QWidget *widget = pluginInstance->pluginUi(); - mkylinNM->addTab(widget,""); - - // 平板模式输入状态下自动调出虚拟键盘 - connect(pluginInstance, SIGNAL(needShowVirtualKeyboard()), this, SLOT(netInPutStatus())); - } else { - qDebug() << "Load Failed: " << wlanloader.errorString() << "\n"; - return; - } - } else { - qDebug() << "Load Failed: " << wlanloader.errorString() << "\n"; - return; - } - - - QHBoxLayout *m_tabBarLayout = new QHBoxLayout(mkylinNM); - m_tabBarLayout->setContentsMargins(0,0,0,0); - QLabel *m_lanLabel = new QLabel(tr("LAN")); - m_lanLabel->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter); - QLabel *m_wlanLabel = new QLabel(tr("WLAN")); - m_wlanLabel->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter); - m_tabBarLayout->addWidget(m_lanLabel); - m_tabBarLayout->addWidget(m_wlanLabel); - mkylinNM->tabBar()->setLayout(m_tabBarLayout); - mkylinNM->tabBar()->setFixedWidth(420); - QPalette pal = qApp->palette(); - pal.setBrush(QPalette::Background, Qt::white); -// m_kylinNM->setPalette(pal); - mkylinNM->widget(0)->setPalette(pal); - mkylinNM->widget(1)->setPalette(pal); - - m_kylinNM->setGeometry(this->width() - mkylinNM->width() - 20, - this->height() - mkylinNM->height() - 72 - 8, - mkylinNM->width(), - mkylinNM->height()); - -} - -void LockWidget::switchToGreeter() -{ - if(authDialog) - { - authDialog->stopAuth(); - } - displayManager->switchToGreeter();; -} - -void LockWidget::setVirkeyboardPos() -{ - if(vKeyboard) - { -// vKeyboard->setGeometry(0, -// height() - height()/3, -// width(), height()/3); - vKeyboard->adjustGeometry(); - } -} - -void LockWidget::SwitchToUser(QString strUserName) -{ - bool isSwitchSelf = false; - if(authDialog) { - if (strUserName == authDialog->getCurAuthUserName()) { - isSwitchSelf = true; - } else { - authDialog->stopAuth(); - } - } - if (!isSwitchSelf) { - this->hide(); - if (!m_timerChkActive) { - m_timerChkActive = new QTimer(this); - m_timerChkActive->setInterval(10*1000); - connect(m_timerChkActive, &QTimer::timeout, this, [&,this](){ - if (this->isHidden()) { - this->show(); - } - m_timerChkActive->stop(); - }); - } else { - if (m_timerChkActive->isActive()) { - m_timerChkActive->stop(); - } - } - m_timerChkActive->start(); - } - QTimer::singleShot(10,this, [&,this, isSwitchSelf, strUserName](){ - if(strUserName == "*Guest") - { - this->displayManager->switchToGuest(); - } - else if(strUserName == "*SwitchUser") - { - this->displayManager->switchToGreeter(); - } - else - { - if (!isSwitchSelf) { - if (GreeterService::instance()->isServiceActivatable()) { - GreeterService::instance()->SwitchToGreeterUser(strUserName); - displayManager->switchToGreeter(); - } else { - displayManager->switchToUser(strUserName); - } - } - } - }); -} - -void LockWidget::onSessionActiveChanged(bool isActive) -{ - if (isActive) { - if (m_timerChkActive && m_timerChkActive->isActive()) { - m_timerChkActive->stop(); - } - if (this->isHidden()) { - this->show(); - } - } else { - if (m_timerChkActive && m_timerChkActive->isActive()) { - m_timerChkActive->stop(); - } - } -} - -void LockWidget::initUserMenu() -{ - scrollArea = new QScrollArea(this); - scrollArea->installEventFilter(this); -// scrollArea->setAttribute(Qt::WA_TranslucentBackground); //设置背景透明 -// scrollArea->viewport()->setAttribute(Qt::WA_TranslucentBackground); //设置背景透明 - scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); //屏蔽水平滚动条 - scrollArea->setStyleSheet("QScrollArea {background-color: rgba(255,255,255,15%);border-radius:8px;}"); - scrollArea->viewport()->setStyleSheet("background-color:transparent;"); - scrollArea->verticalScrollBar()->setProperty("drawScrollBarGroove", false); - scrollArea->verticalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu); - scrollContents = new QWidget(scrollArea); - scrollContents->installEventFilter(this); - scrollArea->setWidget(scrollContents); - scrollArea->hide(); - - if(!usersMenu) - { - usersMenu = new QMenu(scrollContents); - usersMenu->setObjectName("usersMenu"); - usersMenu->setToolTipsVisible(true); - usersMenu->setStyleSheet("QMenu{background-color: rgb(255,255,255,15%);color: white;border-radius: 8px;width:250px;padding: 5px 5px 5px 5px;} \ - QMenu::icon{padding: 2px 5px 2px 5px;}\ - QMenu::item{width:225px;border-radius: 4px;height:36px;padding: 2px 10px 2px 10px;} \ - QMenu::item:selected {border-radius: 4px;background-color:rgb(255,255,255,40%);} \ - QMenu::item:pressed {border-radius: 4px;background-color: rgb(255,255,255,40%);}"); - -// usersMenu->setStyleSheet("QMenu{background-color:transparent;color:white;padding:5px 5px 5px 8px}"); - //QToolTip{border-radius:4px;background-color:rgb(255,255,255,40%);color:white;} - //如果没有设置x11属性,则由于弹出菜单受窗口管理器管理,而主窗口不受,在点击菜单又点回主窗口会闪屏。 - usersMenu->setWindowFlags(Qt::X11BypassWindowManagerHint); - //usersMenu->hide(); - connect(usersMenu, &QMenu::triggered, - this, &LockWidget::onUserMenuTrigged); - } - - if(displayManager->getDisplayType() == "gdm"){ -// QAction *action = new QAction(QIcon(users->getDefaultIcon()), -// tr("SwitchUser"), this); - QWidgetAction *action = new QWidgetAction(usersMenu); - HoverWidget *widget = new HoverWidget(""); - widget->setStyleSheet("HoverWidget:hover{background-color:rgb(255,255,255,15%);border-radius: 6px;}"); - widget->setObjectName("*SwitchUser"); - list.append(widget); - widget->setFixedSize(240, 40); - QLabel *iconlabel =new QLabel(widget); - QPixmap p(users->getDefaultIcon()); - p = scaledPixmap(p); - p = p.scaled(32*scale,32*scale, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); - p = PixmapToRound(p, 16*scale); - iconlabel->setPixmap(p); - iconlabel->setGeometry(8,4,32,32); - KLabel *textlabel =new KLabel(widget); - textlabel->setFontSize(16); - textlabel->setGeometry(48,4,190,30); - action->setToolTip("SwitchUser"); - action->setData("*SwitchUser"); - usersMenu->addAction(action); - list.append(widget); - } - - else if(displayManager->getDisplayType() == "lightdm"){ - connect(users, &Users::userAdded, this, &LockWidget::onUserAdded); - connect(users, &Users::userDeleted, this, &LockWidget::onUserDeleted); - - for(auto user : users->getUsers()) - { - onUserAdded(user); - } - - if(displayManager->hasGuestAccount()) - { -// QAction *action = new QAction(QIcon(users->getDefaultIcon()), -// tr("Guest"), this); - QWidgetAction *action = new QWidgetAction(usersMenu); - HoverWidget *widget = new HoverWidget(""); - widget->setStyleSheet("HoverWidget:hover{background-color:rgb(255,255,255,15%);border-radius: 6px;}"); - widget->setObjectName("*Guest"); - list.append(widget); - widget->setFixedSize(240, 40); - QLabel *iconlabel =new QLabel(widget); - QPixmap p(users->getDefaultIcon()); - p = scaledPixmap(p); - p = p.scaled(32*scale,32*scale, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); - p = PixmapToRound(p, 16*scale); - iconlabel->setPixmap(p); - iconlabel->setGeometry(8,4,32,32); - KLabel *textlabel =new KLabel(widget); - textlabel->setFontSize(16); - textlabel->setGeometry(48,4,190,30); - action->setData("*Guest"); - action->setToolTip("Guest"); - usersMenu->addAction(action); - list.append(widget); - } - } - UserItem currentUser = users->getUserByName(getenv("USER")); - for(int i = 0;i < list.count(); i++){ - if(list.at(i)->objectName() == currentUser.name){ - list.at(i)->setStyleSheet("HoverWidget{background-color:rgb(255,255,255,40%);border-radius: 6px;}" - "HoverWidget:hover:!pressed{background-color:rgb(255,255,255,40%);border-radius: 6px;}"); - nowAt = i; - } else { - list.at(i)->setStyleSheet("HoverWidget{background-color:transparent;}" - "HoverWidget:hover:!pressed{background-color:rgb(255,255,255,15%);border-radius: 6px;}"); - } - } - scrollContents->setFixedSize(usersMenu->width(), usersMenu->height()); - //设置弹出菜单,设置弹出菜单的坐标为切换用户按钮的上方,中间保持一定间隔。 - if(scrollArea){ - if(scrollContents->height() < height()/2){ - scrollArea->setFixedSize(usersMenu->width(), scrollContents->height()+1); - - scrollArea->clearMask(); - }else{ - scrollArea->setFixedSize(usersMenu->width() + 16, height()/2); - - /*当scrollArea区域小于scrollContent大小时,使用样式表绘制的圆角外部透明部分,会显示出scrollContent的内容 - * 导致圆角外部有阴影,因此使用另一种方式再次绘制圆角,该方式绘制出来的圆角存在一定锯齿,所以只在会有阴影 - * 的情况下执行。*/ - QBitmap bitMap(scrollArea->width(),scrollArea->height()); // 定义一个窗口大小的位图 - bitMap.fill(); // 填充整个位图 - QPainter painter(&bitMap); // 定义绘图设备 - painter.setBrush(Qt::black); // 必须定义为黑色 - painter.setPen(Qt::NoPen); // 只能为黑色或者不设置画笔 - painter.setRenderHint(QPainter::Antialiasing);// 反走样 - painter.drawRoundedRect(bitMap.rect(),8,8); // 绘制圆角矩形 - scrollArea->setMask(bitMap); - } - scrollArea->move(ui->btnSwitchUser->geometry().x()- scrollArea->width()/2 + 24, \ - height() - 72 - scrollArea->height() - 8); - } - -} - -void LockWidget::keyReleaseEvent(QKeyEvent *e) -{ - if (!QX11Info::isPlatformX11()) - Q_EMIT keyGlobalRelease(e->key()); - -/* if (e->key() == 9) { // "Escape" - - } else */if(e->key() == Qt::Key_K){ - if(e->modifiers() & Qt::ControlModifier) - showVirtualKeyboard(); - } else if (e->key() == Qt::Key_Tab) { - key_tab_release(e->key()); - } else if(e->key() == Qt::Key_Backtab){ - if(e->modifiers() & Qt::ShiftModifier) - key_shiftTab_release(); - } else if (e->key() == Qt::Key_Up || e->key() == Qt::Key_Down) { // "Up" "Down" - if(scrollArea && scrollArea->isVisible()) - key_OB_release(e->key()); - } else if (e->key() == Qt::Key_Left || e->key() == Qt::Key_Right ) { // "Left" "Right" - key_LR_release(e->key()); - } else if (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) { // "Return" "KP_Enter" - key_enter_release(e->key()); - } -} - -/* lockscreen follows cursor */ -void LockWidget::resizeEvent(QResizeEvent *event) -{ - QSize size = event->size(); - //重新计算缩放比例 - scale = QString::number(size.width() / 1920.0, 'f', 1).toFloat(); - - //系统时间 - ui->widgetTime->move((width()-ui->widgetTime->geometry().width())/2, 59*scale); - - if(sureWidget){ - sureWidget->adjustSize(); - sureWidget->move((width()-sureWidget->geometry().width())/2, (height()-sureWidget->geometry().height())/2); - } - - //认证窗口 - //设置认证窗口左右居中 - if(scale >= 1.3) - authDialog->setGeometry((width()-authDialog->geometry().width())/2,height()/(4-0.7*scale), \ - authDialog->width(), (height()*3/4)); - else if(scale <= 0.9) - authDialog->setGeometry((width()-authDialog->geometry().width())/2,height()/(4-0.9*scale), \ - authDialog->width(), (height()*3/4)); - else - authDialog->setGeometry((width()-authDialog->geometry().width())/2,height()/(4-0.65*scale), \ - authDialog->width(), (height()*3/4)); - - if(m_agreementWindow){ - m_agreementWindow->setGeometry(this->geometry()); - } - - if(scale > 1) - scale = 1; - - //右下角按钮,x,y的初始值代表距离右下角的距离。 - int x=24,y=72; - x = x + ui->btnPowerManager->width(); - ui->btnPowerManager->move(width() - x,height() - y); - - if(ui->btnKeyboard){ - x = x+ui->btnKeyboard->width()+16; - ui->btnKeyboard->move(width() - x, height() - y); - } - - x = x + widgetNetworkManager->width()+16; - widgetNetworkManager->move(width() - x, height() - y); - - if(ui->btnSwitchUser && (!ui->btnSwitchUser->isHidden()||m_isShowUserSwitch) ) { - x = x + ui->btnSwitchUser->width()+16; - ui->btnSwitchUser->move(width() - x, height() - y); - } - - x = x + ui->btnBatteryStatus->width()+16; - ui->btnBatteryStatus->move(width() - x, height() - y); - setVirkeyboardPos(); - - if (mBatteryWidget) { - mBatteryWidget->setFixedSize(314, 112); - mBatteryWidget->setPoint(QPoint(width() - 334, ui->btnBatteryStatus->y() - 16)); - } - - - if(scrollContents && usersMenu) - scrollContents->setFixedSize(usersMenu->width(), usersMenu->height()); - //设置弹出菜单,设置弹出菜单的坐标为切换用户按钮的上方,中间保持一定间隔。 - if(scrollArea){ - if(scrollContents->height() < height()/2){ - scrollArea->setFixedSize(usersMenu->width(),scrollContents->height()+1); - - scrollArea->clearMask(); - }else{ - scrollArea->setFixedSize(usersMenu->width() + 16, height()/2); - - QBitmap bitMap(scrollArea->width(),scrollArea->height()); // 定义一个窗口大小的位图 - bitMap.fill(); // 填充整个位图 - QPainter painter(&bitMap); // 定义绘图设备 - painter.setBrush(Qt::black); // 必须定义为黑色 - painter.setPen(Qt::NoPen); // 只能为黑色或者不设置画笔 - painter.setRenderHint(QPainter::Antialiasing);// 反走样 - painter.drawRoundedRect(bitMap.rect(),8,8); // 绘制圆角矩形 - scrollArea->setMask(bitMap); - } - scrollArea->move(ui->btnSwitchUser->geometry().x()- scrollArea->width()/2 + 24, \ - height() - y - scrollArea->height() - 8); - } - - if(m_kylinNM){ - m_kylinNM->setGeometry(this->width() - m_kylinNM->width() - 20, - this->height() - m_kylinNM->height() - y - 8, - m_kylinNM->width(), - m_kylinNM->height()); - } - - if(powermanager){ -#ifndef USE_INTEL - if(width() < 1280) - powermanager->showSmallSize(); - else - powermanager->showNormalSize(); -#endif - powermanager->setGeometry((width()- powermanager->width())/2, - (height()-powermanager->height())/2, - powermanager->width(),powermanager->height()); - - } - if(QX11Info::isPlatformX11()){ - // XSetInputFocus(QX11Info::display(),this->winId(),RevertToParent,CurrentTime); - } -} - - -void LockWidget::onUserAdded(const UserItem &user) -{ -// QAction *action = new QAction(QIcon(user.icon), user.realName, this); -// action->setCheckable(true); - - QWidgetAction *action = new QWidgetAction(usersMenu); - HoverWidget *widget = new HoverWidget(""); - widget->setStyleSheet("HoverWidget:hover{background-color:rgb(255,255,255,15%);border-radius: 6px;}"); - widget->setObjectName(user.name); - list.append(widget); - widget->setFixedSize(240, 40); - QLabel *iconlabel =new QLabel(widget); - QPixmap p(user.icon); - p = scaledPixmap(p); - p = p.scaled(32*scale,32*scale, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); - p = PixmapToRound(p, 16*scale); - iconlabel->setPixmap(p); - //iconlabel->setStyleSheet("background-color:transparent;"); - iconlabel->setGeometry(8,4,32,32); - KLabel *textlabel =new KLabel(widget); - textlabel->setFontSize(16); - textlabel->setGeometry(48,4,190,30); - if(getLoadStatus(user.name)){ - QLabel *statusIcon = new QLabel(widget); - QPixmap status(":/image/assets/selected.svg"); - status = scaledPixmap(status); - status = status.scaled(14*scale,14*scale, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); - p = PixmapToRound(status, 7*scale); - statusIcon->setPixmap(status); - statusIcon->setGeometry(32, 5, 14, 14); - } - action->setDefaultWidget(widget); - - textlabel->setElideText(user.realName, textlabel->width()); - action->setData(user.name); - usersMenu->addAction(action); - usersMenu->adjustSize(); -} - -void LockWidget::onUserDeleted(const UserItem &user) -{ - for(auto action : usersMenu->actions()) - { - if(action->data() == user.name) - usersMenu->removeAction(action); - } -} - -bool LockWidget::getLoadStatus(const QString &name) -{ - QDBusInterface interface(LG_DBUS_SERVICE, - LG_DBUS_PATH, - LG_DBUS_INTERFACE, - QDBusConnection::systemBus()); - QDBusMessage result = interface.call("ListUsers"); - QList outArgs = result.arguments(); - QVariant first = outArgs.at(0); - QDBusArgument dbvFirst = first.value(); - QVariant vFirst = dbvFirst.asVariant(); - const QDBusArgument &dbusArgs = vFirst.value(); - - QVector loginedUsers; - - dbusArgs.beginArray(); - while (!dbusArgs.atEnd()) { - userInfo user; - dbusArgs >> user; - loginedUsers.push_back(user); - } - for (userInfo user : loginedUsers) { - QDBusInterface userPertyInterface("org.freedesktop.login1", - user.userPath.path(), - "org.freedesktop.DBus.Properties", - QDBusConnection::systemBus()); - QDBusReply reply = userPertyInterface.call("Get", "org.freedesktop.login1.User", "State"); - if (reply.isValid()) { - QString status = reply.value().toString(); - if ("closing" != status) { - m_loginedUser.append(user.userName); - } - } - } - int count = 0; - for(int i = 0 ;i 0) - return true; - else - return false; -} - -void LockWidget::onUserMenuTrigged(QAction *action) -{ - qDebug() << action->data().toString() << "selected"; - - QString userName = action->data().toString(); - for (int i =0; i < list.count(); i++) - { - if(list.at(i)->objectName() == userName){ - list.at(i)->setStyleSheet("HoverWidget{background-color:rgb(255,255,255,40%);border-radius: 6px;}" - "HoverWidget:hover:!pressed{background-color:rgb(255,255,255,40%);border-radius: 6px;}"); - } else { - list.at(i)->setStyleSheet("HoverWidget{background-color:transparent;}" - "HoverWidget:hover:!pressed{background-color:rgb(255,255,255,15%);border-radius: 6px;}"); - } - } - SwitchToUser(userName); -} - -bool LockWidget::exitSubWidget() -{ - bool allExited = true; - if(mBatteryWidget && mBatteryWidget->isVisible()) { - setCheckedSheet(BATTERYBTN, false); - at_plugins = false; - if(tabAt == BOTTMBTN && horAT == BATTERYBTN) - ui->btnBatteryStatus->setStyleSheet(ON_TAB_SHEET); - } else if(scrollArea && scrollArea->isVisible()){ - setCheckedSheet(SWITCHBTN, false); - at_plugins = false; - if(tabAt == BOTTMBTN && horAT == SWITCHBTN) - ui->btnSwitchUser->setStyleSheet(ON_TAB_SHEET); - allExited = false; - } else if(m_kylinNM && m_kylinNM->isVisible()){ - setCheckedSheet(NETWORKBTN, false); - at_plugins = false; - if(tabAt == BOTTMBTN && horAT == NETWORKBTN) - widgetNetworkManager->setStyleSheet(ON_TAB_SHEET_WIDGET); - allExited = false; - } else if(vKeyboard && vKeyboard->isVisible()) { - vKeyboard->hide(); - at_plugins = false; - if(tabAt == BOTTMBTN && horAT == KEYBOARDBTN) - ui->btnKeyboard->setStyleSheet(ON_TAB_SHEET); - allExited = false; - } else if(powermanager && powermanager->isVisible()){ - authDialog->show(); - powermanager->hide(); - if(!authDialog->getLineeditStatus()) { - tabAt = LINEEDIT; - authDialog->setFocusin(IN_LINEEDIT); - if(isTableMode && !(vKeyboard && vKeyboard->isVisible())) { - showVirtualKeyboard(); - } - } else { - tabAt = MESSAGEBTN; - authDialog->setFocusin(ON_MESSAGEBTN); - } - setBottomBtnSheet(); - powermanager->clearStatus(); - at_power = false; - allExited = false; - return allExited; - } - if(tabAt != LINEEDIT && tabAt != MESSAGEBTN && tabAt != ENTERBTN && tabAt != BIOBTN) - authDialog->setFocusin(REMOVE); - return allExited; -} - -void LockWidget::onActiveLineedit() -{ - if(tabAt == LINEEDIT || (tabAt == BOTTMBTN && horAT == KEYBOARDBTN)) { /* - 重启时session拉其他组件时会多次设置焦点 - 这个时候如果是平板模式,因为已经弹出了虚拟键盘 tabAt就会是BOTTOM - */ - if(authDialog && authDialog->isVisible()) { - if(!authDialog->getLineeditStatus()) { - authDialog->setFocusin(IN_LINEEDIT); -// if(isTableMode && !(vKeyboard && vKeyboard->isVisible())) -// showVirtualKeyboard(); - } else { - tabAt = MESSAGEBTN; - authDialog->setFocusin(ON_MESSAGEBTN); - } - } - } -} - -QString LockWidget::getBatteryIconName() -{ - if (iface->isValid() && dface->isValid()) { - bool batteryState = false; - QDBusReply reply = batInterface->call("Get", UPOWER_SERVICE, "OnBattery"); - if (reply.isValid()) { - batteryState = reply.value().toBool(); - } - double percentage = -1.0; - QDBusReply percentage_reply = iface->call("Get", UPOWER_DIVICES_SERVICE, "Percentage"); - if (percentage_reply.isValid()) { - percentage = percentage_reply.value().toDouble(); - } - - if (true == batteryState) { - return QString("battery-level-%1-symbolic").arg((int)percentage / 10 * 10); - } else { - return QString("battery-level-%1-charging-symbolic").arg((int)percentage / 10 * 10); - } - } - return QString(); -} - -int LockWidget::getLoginedNum() -{ - if(loginedNum != 0) - return loginedNum; - for(auto user : users->getUsers()) - { - if(getLoadStatus(user.name)){ - loginedNum++; - } - } - return loginedNum; -} - -QDBusArgument &operator <<(QDBusArgument &arg, const userInfo &usersInfo) -{ - arg.beginStructure(); - arg << usersInfo.userId - << usersInfo.userName - << usersInfo.userPath; - arg.endStructure(); - return arg; -} -const QDBusArgument &operator >>(const QDBusArgument &arg, userInfo &usersInfo) -{ - arg.beginStructure(); - arg >> usersInfo.userId - >> usersInfo.userName - >> usersInfo.userPath; - arg.endStructure(); - return arg; -} - -bool LockWidget::IsDesktopStarted() -{ - QDBusInterface *iface = new QDBusInterface(DESKTOP_DBUS_SERVICE, - DESKTOP_DBUS_PATH, - DESKTOP_DBUS_INTERFACE, - QDBusConnection::sessionBus(), - this); - if (iface) { - if (iface->isValid()) { - delete iface; - return true; - } - delete iface; - } - return false; -} - -void LockWidget::setRootWindow() -{ - QStringList keysMateBg; - QString strUserBgFile = ""; - QString strUserBgColor = ""; - QString strUserBgOptions = ""; - if(QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA_MATE_BG)){ - QGSettings *mateBgSettings = new QGSettings(GSETTINGS_SCHEMA_MATE_BG, "", this); - keysMateBg = mateBgSettings->keys(); - if (keysMateBg.contains(KEY_PICTURE_FILENAME)) { - strUserBgFile = mateBgSettings->get(KEY_PICTURE_FILENAME).toString(); - } - if (keysMateBg.contains(KEY_PRIMARY_COLOR)) { - strUserBgColor = mateBgSettings->get(KEY_PRIMARY_COLOR).toString(); - } - if (keysMateBg.contains(KEY_PICTURE_OPTIONS)) { - strUserBgOptions = mateBgSettings->get(KEY_PICTURE_OPTIONS).toString(); - } - qDebug()<<"User bg info:"<getDefaultBackgroundName(); - } - if(nDrawBgType == 0) { - qDebug()<<"DrawBgFile:"<getCurAuthUserName()) { - isSwitchSelf = true; - } else { - authDialog->stopAuth(); - } - } - if(account == "*Guest") { - displayManager->switchToGuest(); - } else if(account == "*SwitchUser") { - displayManager->switchToGreeter(); - } else { - if (!isSwitchSelf) { - if (GreeterService::instance()->isValid()) { - GreeterService::instance()->SwitchToGreeterUser(account); - displayManager->switchToGreeter(); - } else { - displayManager->switchToUser(account); - } - } - } -} - -void LockWidget::onGetCustomPluginMsg(QString strMsg) -{ - QJsonParseError jsonParseError; - const QJsonDocument jsonDoc = QJsonDocument::fromJson(strMsg.toUtf8(), &jsonParseError); - if (jsonParseError.error != QJsonParseError::NoError) { - qWarning()<<"Parse message json failed!!"; - return ; - } else { - QJsonObject rootObj = jsonDoc.object(); - if (rootObj.isEmpty()) { - qWarning()<<"Message Json is null!!"; - return ; - } else { - QJsonObject contentObj = rootObj.value("Content").toObject(); - if (!contentObj.isEmpty()) { - QJsonObject configObj = contentObj.value("Configures").toObject(); - if (!configObj.isEmpty()) { - m_isCustomDefault = configObj.value("DefaultAuth").toBool(false); - m_isShowNetwork = configObj.value("ShowNetwork").toBool(true); - m_isShowUserSwitch = configObj.value("ShowUserSwitch").toBool(true); - } - } - } - } -} - diff --git a/src/lockwidget.h b/src/lockwidget.h deleted file mode 100644 index 91613c4..0000000 --- a/src/lockwidget.h +++ /dev/null @@ -1,243 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#ifndef LOCKWIDGET_H -#define LOCKWIDGET_H - -#ifndef QT_NO_KEYWORDS -#define QT_NO_KEYWORDS -#endif - -#include -#include -#include -#include -#include -#include -#include -#include "kylin-nm/kylin-nm-interface.h" -#include "surewindow.h" -#include "lockchecker.h" -#include "xeventmonitor.h" -#include "batterywidget.h" -#include "libinputswitchevent.h" -#include "agreementwindow.h" -#include - -namespace Ui { -class LockWidget; -} - - -struct userInfo { - int userId; - QString userName; - QDBusObjectPath userPath; -}; - -enum dateinfo { - DATE, - TIME, -}; - -QDBusArgument &operator <<(QDBusArgument &arg, const userInfo &usersInfo); -const QDBusArgument &operator >>(const QDBusArgument &arg, userInfo &usersInfo); - -class VirtualKeyboardWidget; -class PowerManager; -class AuthDialog; -class Configuration; -class Users; -class UserItem; -class DisplayManager; -class QMenu; -class QScrollArea; -class KylinNM; - -enum TABAT { - EMPTY = -1, - LINEEDIT = 0, - ENTERBTN, - BIOBTN, - BOTTMBTN, - POWERMANAGER, - MESSAGEBTN, -}; - -enum HORIZONBTN { - BATTERYBTN = 0, - SWITCHBTN, - NETWORKBTN, - KEYBOARDBTN, - POWERBTN, -}; - -class LockWidget : public QWidget -{ - Q_OBJECT - -public: - explicit LockWidget(QWidget *parent = 0); - ~LockWidget(); - void closeEvent(QCloseEvent *event); - void startAuth(); - void stopAuth(); - void setX11Focus(); - bool exitSubWidget(); - void setStartupMode(bool mode); - void onActiveLineedit(); - QString getBatteryIconName(); - void key_enter_release(int key); - void onSessionActiveChanged(bool isActive); - -Q_SIGNALS: - void closed(); - void keyGlobalRelease(int key); -// void capsLockChanged(); - -private: - void switchWnd(int); - void initUI(); - void initUserMenu(); - void setVirkeyboardPos(); - bool getLoadStatus(const QString &name); - int getNetStatus(); - void key_OB_release(int key); - void key_tab_release(int key); - void key_shiftTab_release(); - void key_LR_release(int key); - int getLoginedNum(); - void loadNetPlugin(); - void setBottomBtnSheet(); - void setCheckedSheet(int type, bool show); - void netResetLocation(); - void setBottomBtnVisible(bool visible); - QString getLongFormatDate(int type); - - /** - * @brief IsDesktopStarted 桌面是否已启动 - * @return - */ - bool IsDesktopStarted(); - - /** - * @brief setRootWindow 设置X背景 - */ - void setRootWindow(); - - void SwitchToUser(QString strUserName); - -private Q_SLOTS: - void onUserAdded(const UserItem &user); - void onUserDeleted(const UserItem &user); - void onUserMenuTrigged(QAction *action); - void showVirtualKeyboard(); - void netInPutStatus(); - void showPowerManager(bool keynavigation = false); - void showUserMenu(); - void showNetManager(bool keynavigation = false); - void showBattery(); - void switchToGreeter(); - void switchToSureDialog(int type); - void showWarning(QVector &list, int type); - void hideSureDialog(); - void confirmClicked(); - void onClickPassword(); - void hideBottomPlugins(); - void resetNavigation(); - void setBatteryIcon(QString str); - void dealMessage(QDBusMessage); - void onShowMessageBtn(bool is_show); - /** - * @brief onAuthenticateCompete 认证完成 - */ - void onAuthenticateCompete(); - - /** - * @brief onCustomRequestAccount 请求切换认证用户 - * @param account 用户名 - */ - void onCustomRequestAccount(QString account); - /** - * @brief onGetCustomPluginMsg 获取插件消息槽 - * @param strMsg 消息json - */ - void onGetCustomPluginMsg(QString strMsg); - -protected: - bool eventFilter(QObject *obj, QEvent *event); - void resizeEvent(QResizeEvent *event); - void keyReleaseEvent(QKeyEvent *e); - -private: - Ui::LockWidget *ui; - AuthDialog *authDialog = nullptr; - Configuration *configuration; - VirtualKeyboardWidget *vKeyboard = nullptr; - PowerManager *powermanager = nullptr; - SureWindow *sureWidget = nullptr; - QTimer *timer; - QMenu *usersMenu = nullptr; - QList list; - Users *users; - DisplayManager *displayManager; - int timeType; - QString dateType; - QScrollArea *scrollArea; - QWidget *scrollContents; - - QWidget *m_kylinNM = nullptr; - BatteryWidget *mBatteryWidget = nullptr; - QTabWidget *mkylinNM = nullptr; - QWidget *m_NetManagerWidget = nullptr; - QStringList m_loginedUser; - bool isNetFinished = false; - int powermanagerType; - int nowAt = -1; - int loginedNum = 0; - QWidget *widgetNetworkManager = nullptr; - QPushButton *btnNetworkManager = nullptr; - bool m_isStartupMode = false; - bool is_switchBtn = true; - bool is_batteryBtn = true; - bool is_keynavigation =false; - int tabAt = LINEEDIT; - int horAT = BATTERYBTN; - bool at_power = false; - bool at_plugins = false; - - QDBusInterface *batInterface = nullptr; - QDBusInterface *iface = nullptr; - QDBusInterface *dface = nullptr; - AgreementWindow *m_agreementWindow = nullptr; - - // 监听键盘插拔 - LibinputSwitchEvent *libswitch = nullptr; - bool isTableMode = false; - bool m_isShowKeyboard = false; // 打开电源管理界面前虚拟键盘是否已打开 - - double curFontSize = 0; - QFuture m_futureLoadDeskBg; - - QTimer *m_timerChkActive = nullptr; - QMap btnVisMap; - bool m_isCustomDefault = false; /** 是否默认使用第三方认证 */ - bool m_isShowNetwork = true; /** 是否显示网络插件 */ - bool m_isShowUserSwitch = true; /** 是否显示用户切换 */ -}; - -#endif // LOCKWIDGET_H diff --git a/src/lockwidget.ui b/src/lockwidget.ui deleted file mode 100644 index 90d92f4..0000000 --- a/src/lockwidget.ui +++ /dev/null @@ -1,191 +0,0 @@ - - - LockWidget - - - - 0 - 0 - 748 - 433 - - - - Form - - - - - 550 - 10 - 80 - 26 - - - - ArrowCursor - - - Qt::NoFocus - - - QPushButton{ - text-align:center; - color: rgb(255, 255, 255, 255); - border: none; - border-radius: 4px; - outline: none; -} -QPushButton::hover{ - background-color: rgb(255,255,255,15%); -} -QPushButton::pressed { - background-color: rgba(255,255,255,40%); -} - - - - - - - - - - - 10 - 280 - 54 - 70 - - - - - - - Time - - - - - - - Date - - - - - - - - - 460 - 10 - 80 - 26 - - - - ArrowCursor - - - Qt::NoFocus - - - QPushButton{ - text-align:center; - color: rgb(255, 255, 255, 255); - border: none; - border-radius: 4px; - outline: none; -} -QPushButton::hover{ - background-color: rgb(255,255,255,15%); -} -QPushButton::pressed { - background-color: rgba(255,255,255,40%); -} - - - - - - - - - - - 650 - 10 - 80 - 26 - - - - ArrowCursor - - - QPushButton{ - text-align:center; - color: rgb(255, 255, 255, 255); - border: none; - border-radius: 4px; - outline: none; -} -QPushButton::hover{ - background-color: rgb(255,255,255,15%); -} -QPushButton::pressed { - background-color: rgba(255,255,255,40%); -} - - - - - - - - - - - 330 - 10 - 97 - 32 - - - - ArrowCursor - - - QPushButton::menu-indicator{ - image:none; -} -QPushButton{ - text-align:center; - color: rgb(255, 255, 255, 255); - border: none; - border-radius: 4px; - outline: none; -} -QPushButton::hover{ - background-color: rgb(255,255,255,15%); -} -QPushButton::pressed { - background-color: rgba(255,255,255,40%); -} - - - - - - - - - KLabel - QLabel -
klabel.h
-
-
- - -
diff --git a/src/logind.h b/src/logind.h deleted file mode 100644 index 155c1ef..0000000 --- a/src/logind.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#ifndef LOGIND_H -#define LOGIND_H - -#include -#include -#include - -class QDBusServiceWatcher; - -class LogindIntegration : public QObject -{ - Q_OBJECT -public: - explicit LogindIntegration(QObject *parent = nullptr); - virtual ~LogindIntegration(); - - bool isSessionActive(); - -public Q_SLOTS: - void onSessionPropChanged(QString, QVariantMap, QStringList); - -Q_SIGNALS: - void requestLock(); - void requestUnlock(); - void sessionActiveChanged(bool isActive); - -private: - bool m_isSessionActive = false; -}; - -#endif diff --git a/src/loginedusers.cpp b/src/loginedusers.cpp deleted file mode 100644 index bd4d247..0000000 --- a/src/loginedusers.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2019 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ - -#include "loginedusers.h" - -QDBusArgument &operator<<(QDBusArgument &argument, const LoginedUsers &mystruct) -{ - argument.beginStructure(); - argument << mystruct.uid << mystruct.userName << mystruct.objpath;//< mystruct.usergroup; - argument.endStructure(); - return argument; -} - -const QDBusArgument &operator>>(const QDBusArgument &argument, LoginedUsers &mystruct) -{ - argument.beginStructure(); - argument >> mystruct.uid >> mystruct.userName >> mystruct.objpath;// >> mystruct.usergroup; - argument.endStructure(); - return argument; -} diff --git a/src/loginedusers.h b/src/loginedusers.h deleted file mode 100644 index de1b175..0000000 --- a/src/loginedusers.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2019 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ - -#ifndef LOGINEDUSER_H -#define LOGINEDUSER_H - -#include - -struct LoginedUsers -{ - int uid; - QString userName; - QDBusObjectPath objpath; -}; - -QDBusArgument &operator<<(QDBusArgument &argument, const LoginedUsers &mystruct); - -const QDBusArgument &operator>>(const QDBusArgument &argument, LoginedUsers &mystruct); - - - -Q_DECLARE_METATYPE(LoginedUsers) - -#endif // LOGINEDUSER_H diff --git a/src/machinemodel.cpp b/src/machinemodel.cpp deleted file mode 100644 index 957da65..0000000 --- a/src/machinemodel.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#include "machinemodel.h" -#include -#include -#include - -std::shared_ptr MachineModel::m_machineModel = nullptr; -std::mutex MachineModel::m_mutex; - -MachineModel::MachineModel(QObject *parent) : QObject(parent) -{ - initMachineType(); -} - -QString MachineModel::getTheMachineType() -{ - return m_machineType; -} - -std::shared_ptr MachineModel::getMachineModelInstance() -{ - if(m_machineModel == nullptr) - { - std::unique_lock lock(m_mutex); - if(m_machineModel == nullptr) - { - m_machineModel = std::shared_ptr(new MachineModel); - } - } - return m_machineModel; -} - -void MachineModel::initMachineType() -{ - QSettings setting(":/assets/data/conf.ini", QSettings::IniFormat); - setting.beginGroup("MachineType");//节点开始 - - QString type = getSysVendor() + getProductFamily(); - qInfo() << __FILE__ << __LINE__ << type; - if (setting.contains(type)) { - m_machineType = setting.value(type).toString(); - } else { - m_machineType = QString(); - } - qInfo() << __FILE__ << __LINE__ << m_machineType; - setting.endGroup();//节点结束 - -} - -const QString MachineModel::getSysVendor() const -{ - QProcess process; - QStringList options; - options << "-c"; - options << "cat /sys/class/dmi/id/sys_vendor"; - process.start("/bin/bash", options); - process.waitForFinished(); - QString result = process.readAllStandardOutput(); - - QStringList list = result.split("\n"); - result = list.at(0); - qInfo() << __FILE__ << __LINE__ << "获取设备厂商为:" << result; - return result; -} - -const QString MachineModel::getProductName() const -{ - QProcess process; - QStringList options; - options << "-c"; - options << "cat /sys/class/dmi/id/product_name"; - process.start("/bin/bash", options); - process.waitForFinished(); - QString result = process.readAllStandardOutput(); - - QStringList list = result.split("\n"); - result = list.at(0); - qInfo() << __FILE__ << __LINE__ << "获取产品名为:" << result; - return result; -} - -const QString MachineModel::getProductFamily() const -{ - QProcess process; - QStringList options; - options << "-c"; - options << "cat /sys/class/dmi/id/product_family"; - process.start("/bin/bash", options); - process.waitForFinished(); - QString result = process.readAllStandardOutput(); - - QStringList list = result.split("\n"); - result = list.at(0); - qInfo() << __FILE__ << __LINE__ << "获取设备Family为:" << result; - return result; -} diff --git a/src/modebutton.cpp b/src/modebutton.cpp deleted file mode 100644 index 3b8bb26..0000000 --- a/src/modebutton.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#include "modebutton.h" -#include -#include - -ModeButton::ModeButton(QWidget *parent) - : QPushButton(parent) -{ - -} - -void ModeButton::paintEvent(QPaintEvent *event) -{ - QStylePainter p(this); - QStyleOptionButton option; - initStyleOption(&option); - option.state = QStyle::State_Enabled; - p.drawControl(QStyle::CE_PushButton, option); -} - diff --git a/src/monitorwatcher.cpp b/src/monitorwatcher.cpp deleted file mode 100644 index 60009ec..0000000 --- a/src/monitorwatcher.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#include "monitorwatcher.h" -#include -#include -#include -#include - -#define DRM_DIR "/sys/class/drm/" - -MonitorWatcher::MonitorWatcher(QObject *parent) - : QThread(parent), - virtualSize(0, 0), - monitorCount(0), - firstDetect(true) -{ - -} - -MonitorWatcher::~MonitorWatcher() -{ - requestInterruption(); - terminate(); - wait(); -} - -void MonitorWatcher::run() -{ - QDir drmDir(DRM_DIR); - QStringList drms = drmDir.entryList(QDir::Dirs); - for(auto iter = drms.begin(); iter != drms.end(); ) { - if((*iter).indexOf("card") == 0 || iter->length() > 5) - iter++; - else - iter = drms.erase(iter); - } - - FILE * fp = popen("xrandr", "r"); - Q_UNUSED(fp) - - /* 每隔3秒遍历一次显卡接口的连接状态 */ - while(!isInterruptionRequested()) { - int width = 0; - int height = 0; - QMap tmpStatus; - for(const QString & drm : drms) { - QFile drmStatusFile(DRM_DIR + drm + "/status"); - if(drmStatusFile.open(QIODevice::ReadOnly | QIODevice::Text)) { - QTextStream in(&drmStatusFile); - QString status = in.readLine(); - tmpStatus[drm] = status; - - if(status == "connected") { - QSize maxMode = getMonitorMaxSize(drm); - width += maxMode.width(); - height = height > maxMode.height() ? height : maxMode.height(); - } - } - } - if(drmStatus != tmpStatus) { - drmStatus = tmpStatus; - int count = 0; - for(auto &pair : tmpStatus) - if(pair == "connected") - count++; - qDebug() << "monitor count changed ---" << count; - if(monitorCount != count) { - monitorCount = count; - if(!firstDetect) { - firstDetect = false; - Q_EMIT monitorCountChanged(count); - } - } - FILE *fp = popen("xrandr", "r"); - Q_UNUSED(fp) - } - - virtualSize = QSize(width, height); - sleep(3); - } -} - -/** - * 获取显示器的最大分辨率 - */ -QSize MonitorWatcher::getMonitorMaxSize(const QString &drm) -{ - int width = 0, height = 0; - QFile drmModeFile(DRM_DIR + drm + "/modes"); - if(drmModeFile.open(QIODevice::ReadOnly | QIODevice::Text)) { - QTextStream in2(&drmModeFile); - QString maxMode = in2.readLine(); - int xpos = maxMode.indexOf('x', 0); - width = maxMode.left(xpos).toInt(); - int ipos = maxMode.indexOf('i', 0); - if(ipos != -1) - height = maxMode.mid(xpos+1, ipos-xpos-1).toInt(); - else - height = maxMode.mid(xpos+1).toInt(); - } - return QSize(width, height); -} - -QSize MonitorWatcher::getVirtualSize() -{ - return virtualSize; -} - -int MonitorWatcher::getMonitorCount() -{ - return monitorCount; -} diff --git a/src/monitorwatcher.h b/src/monitorwatcher.h deleted file mode 100644 index 0f10599..0000000 --- a/src/monitorwatcher.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#ifndef MONITORWATCHER_H -#define MONITORWATCHER_H - -#include -#include -#include - -/*! - * \brief The MonitorWatcher class - * 监控显示器的插拔 - */ -class MonitorWatcher : public QThread -{ - Q_OBJECT - -public: - MonitorWatcher(QObject *parent=nullptr); - ~MonitorWatcher(); - QSize getVirtualSize(); - int getMonitorCount(); - -Q_SIGNALS: - void monitorCountChanged(int newCount); - void virtualSizeChanged(const QSize &newVirtualSize); - -protected: - void run(); - -private: - QSize getMonitorMaxSize(const QString &drm); - - QMap drmStatus; - QSize virtualSize; - int monitorCount; - bool firstDetect; -}; - -#endif // MONITORWATCHER_H diff --git a/src/mytabwidget.cpp b/src/mytabwidget.cpp deleted file mode 100644 index dcc2e20..0000000 --- a/src/mytabwidget.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2021 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#include "mytabwidget.h" -#include -#include -#include - -MyTabWidget::MyTabWidget(QWidget *parent) : QTabWidget(parent) -{ - //隐藏标题栏 - // setWindowFlags(Qt::FramelessWindowHint);//无边框 置顶 - - //设置窗口背景透明 -// setAttribute(Qt::WA_TranslucentBackground,false); - - //设置样式 - -// QWidget *w = new QWidget(this); -// QWidget *k = new QWidget(this); -// this->addTab(w,"111"); -// this->addTab(k,"222"); - - -} - -void MyTabWidget::paintEvent(QPaintEvent *p1) -{ - //绘制样式 - QStyleOption opt; - opt.initFrom(this); - QPainter p(this); - style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);//绘制样式 - - QBitmap bmp(this->size()); - bmp.fill(); - QPainter painter(&bmp); - painter.setPen(Qt::NoPen); - painter.setBrush(Qt::black); - painter.setRenderHint(QPainter::Antialiasing); - painter.drawRoundedRect(bmp.rect(), 12, 12); - setMask(bmp); -} diff --git a/src/mytabwidget.h b/src/mytabwidget.h deleted file mode 100644 index 732d44d..0000000 --- a/src/mytabwidget.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2021 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#ifndef MYTABWIDGET_H -#define MYTABWIDGET_H - -#include -#include - -class MyTabWidget : public QTabWidget -{ - Q_OBJECT -public: - explicit MyTabWidget(QWidget *parent = nullptr); - void paintEvent(QPaintEvent *event); - -signals: - -}; - -#endif // WIDGET_H diff --git a/src/pam-tally.cpp b/src/pam-tally.cpp deleted file mode 100644 index ba82fec..0000000 --- a/src/pam-tally.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301, USA. -**/ -#include "pam-tally.h" -#include -#include -#include -#include -#include -#define PAM_CONFIG_FILE "/etc/pam.d/common-auth" - -PamTally* PamTally::instance_ = nullptr; - -PamTally::PamTally(QObject *parent) - : QObject(parent) -{ - parsePamConfig(); -} - -PamTally* PamTally::instance(QObject *parent) -{ - if(instance_ == nullptr) - instance_ = new PamTally(parent); - return instance_; -} - -int PamTally::parsePamConfig() -{ - deny = 0; - unlock_time = 0; - root_unlock_time = 0; - - QFile file(PAM_CONFIG_FILE); - if(!file.open(QIODevice::ReadOnly|QIODevice::Text)){ - qDebug()<<"open /etc/pam.d/common-auth failed"; - return -1; - } - - QStringList list; - list.clear(); - - while(!file.atEnd()){ - QString line = (QString)file.readLine(); - line = line.trimmed(); - - if(line.startsWith("#") || !line.contains("unix",Qt::CaseSensitive)) - continue; - - list << line; - } - file.close(); - - if(list.size() > 0) - { - QString line = list.at(0); - QStringList strs = line.split(" "); - foreach (QString str, strs) { - if(str.contains("deny",Qt::CaseSensitive)) - { - deny = str.split("=").at(1).toUInt(); - } - if(str.contains("unlock_time",Qt::CaseSensitive)) - { - unlock_time = str.split("=").at(1).toULongLong(); - } - if(str.contains("root_unlock_time",Qt::CaseSensitive)) - { - root_unlock_time = str.split("=").at(1).toULongLong(); - } - } - } - qDebug()<<"deny = "< - #include - #include -} - -#define TO_AUTHCHILD_RD_SHIFT 16 -#define TO_PARENT_WR_SHIFT 0 -#define PIPE_FD_MASK ((1 << TO_AUTHCHILD_RD_SHIFT) - 1) - -void authenticate(int toParent[2], int toAuthChild[2]) -{ - pam_handle_t *pamh = NULL; - char *username; - int retval; - int auth_status; - struct pam_conv conv; - unsigned long fd = 0; - fd = fd | toAuthChild[0] << TO_AUTHCHILD_RD_SHIFT - | toParent[1] << TO_PARENT_WR_SHIFT; - /* authentication child process */ - username=getenv("USER"); - conv.conv = pam_conversation; - conv.appdata_ptr = (void *)fd; - retval = pam_start("ukui-screensaver-qt", username, &conv, &pamh); - if(retval == PAM_SUCCESS) - qDebug("PAM started successfully."); - else - qDebug("PAM started unsuccessfully."); - qDebug("Invoke pam authentication."); - auth_status = pam_authenticate(pamh, 0); - qDebug("Complete pam authentication."); - if(pam_end(pamh, retval) != PAM_SUCCESS){ - qDebug("Failed to terminate PAM."); - _exit(1); - } - qDebug("PAM ended successfully."); - kill(getppid(), SIGUSR1); - char buffer[16]; - sprintf(buffer, "%d", auth_status); - PIPE_OPS_SAFE( - write(toParent[1], buffer, strlen(buffer) + 1) - ); - qDebug("Auth status has been written to pipe."); - ::close(toParent[1]); - ::close(toAuthChild[0]); - qDebug("Authenticate child process now exits."); - _exit(0); -} - -#define MAX_PASSWORD_LENGTH 1024 -int pam_conversation(int num_msg, const struct pam_message **msg, - struct pam_response **resp, void *appdata_ptr) -{ - unsigned long fd; - int read_from_parent; - int write_to_parent; - int count; - char *password; - struct pam_response *tmp_save; - - qDebug("Into pam_conversation"); - - fd = (unsigned long)appdata_ptr; - read_from_parent = (fd >> TO_AUTHCHILD_RD_SHIFT) & PIPE_FD_MASK; - write_to_parent = (fd >> TO_PARENT_WR_SHIFT) & PIPE_FD_MASK; - count = num_msg; - password = (char *)malloc(MAX_PASSWORD_LENGTH); - *resp = (struct pam_response *)malloc(num_msg * - sizeof(struct pam_response)); - tmp_save = (struct pam_response *)(*resp); - memset(*resp, 0, num_msg * sizeof(struct pam_response)); - qDebug("Resolve PAM messages."); - while(count-- >= 1){ - struct pam_message_object pam_msg_obj; - pam_msg_obj.msg_style = (*msg)->msg_style; - strncpy(pam_msg_obj.msg, (*msg)->msg, MAX_MSG_LENGTH); - PIPE_OPS_SAFE( - write(write_to_parent, &pam_msg_obj, sizeof(pam_msg_obj)); - ); - qDebug("PAM message has been written to pipe."); - kill(getppid(), SIGUSR1); - - if ((*msg)->msg_style == PAM_PROMPT_ECHO_OFF - || (*msg)->msg_style == PAM_PROMPT_ECHO_ON){ - int n; - PIPE_OPS_SAFE( - n = read(read_from_parent, password, MAX_PASSWORD_LENGTH); - ); - qDebug("%d bytes response received from pipe.", n); - (*resp)->resp = password; - (*resp)->resp_retcode = 0; - } else { - ; - } - if(count != 0){ - msg++; - (*resp)++; - } - } - - (*resp) = tmp_save; - - qDebug("Out pam_conversation."); - return PAM_SUCCESS; -} - diff --git a/src/pam.h b/src/pam.h deleted file mode 100644 index 317098d..0000000 --- a/src/pam.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#ifndef PAM_H -#define PAM_H - -#include -#include -#include - -void authenticate(int toParent[2], int toAuthChild[2]); - -int pam_conversation(int num_msg, const struct pam_message **msg, - struct pam_response **resp, void *appdata_ptr); - -#define MAX_MSG_LENGTH 1024 -struct pam_message_object { - int msg_style; - char msg[MAX_MSG_LENGTH + 1]; -} __attribute__((packed)); - -#define PIPE_OPS_SAFE(statement) do { \ - int return_value = statement; \ - if (return_value == -1)\ - qWarning("PIPE write/read error: %s", strerror(errno)); \ -} while (0) - -#endif // PAM_H diff --git a/src/permissioncheck.cpp b/src/permissioncheck.cpp deleted file mode 100644 index 82ee79b..0000000 --- a/src/permissioncheck.cpp +++ /dev/null @@ -1,401 +0,0 @@ -#include "permissioncheck.h" -#include -#include -#include -#include -#include "common.h" - -#include "wechatauthdialog.h" - -VerificationWidget::VerificationWidget(QWidget *parent) : QWidget(parent) -{ - qDebug() << "PermissionCheck"; - resize(1000,355); - QHBoxLayout *mainLayout = new QHBoxLayout(this); - setLayout(mainLayout); - - WeChatAuthDialog *m_weChatWidget; - PhoneAuthWidget *m_phoneAuthWidget; - - m_weChatWidget = new WeChatAuthDialog(1,this); - mainLayout->addWidget(m_weChatWidget, 1, Qt::AlignLeft); - - mainLayout->addSpacing(400); - - m_phoneAuthWidget = new PhoneAuthWidget(this); - mainLayout->addWidget(m_phoneAuthWidget, 1, Qt::AlignRight); - - connect(m_phoneAuthWidget, &PhoneAuthWidget::pageMessage, this, [=](SwitchPage s, QList list){ - Q_EMIT pageMessage(s, list); - }); -} - -void VerificationWidget::paintEvent(QPaintEvent *) -{ - int x1 = width() / 2; - int y1 = height() / 4; - int x2 = x1; - int y2 = height() / 3 * 2 + y1; - QLinearGradient linearGra(QPoint(x1, y1), QPoint(x2, y2)); - linearGra.setColorAt(0, QColor(238, 238, 238, 0)); - linearGra.setColorAt(0.5, QColor(255, 255, 255, 138)); - linearGra.setColorAt(1, QColor(216, 216, 216, 0)); - - QPainter painter(this); - QBrush brush(linearGra); - painter.setPen(Qt::transparent); - painter.setBrush(brush); - painter.drawRoundedRect(QRect(x1, y1, 4, height() / 3 * 2), 16, 16); -} - -InputInfos::InputInfos(QWidget *parent): - QWidget(parent) -{ - initUI(); - initConnect(); - setQSS(); -} - -void InputInfos::initUI() -{ - setFixedWidth(316); - QGridLayout *mainLayout = new QGridLayout(this); - setLayout(mainLayout); - mainLayout->setColumnStretch(1, 0); - mainLayout->setColumnStretch(2, 1); - mainLayout->setColumnStretch(3, 0); - - m_pPhoneIconLB = new QLabel(this); - m_pPhoneIconLB->setPixmap(QPixmap(":/images/icon-phone.png")); - mainLayout->addWidget(m_pPhoneIconLB, 0, 1, 1, 1, Qt::AlignLeft); - - m_pPhoneLE = new QLineEdit(this); - m_pPhoneLE->setPlaceholderText("手机号"); - m_pPhoneLE->setProperty("class", "InputLine"); - m_pPhoneLE->setValidator(0); - mainLayout->addWidget(m_pPhoneLE, 0, 2, 1, 2, Qt::AlignLeft); - - m_pVerCodeIconLB = new QLabel(this); - m_pVerCodeIconLB->setPixmap(QPixmap(":/images/icon-sms.png")); - mainLayout->addWidget(m_pVerCodeIconLB, 1, 1, 1, 1, Qt::AlignLeft); - - m_pVerCodeLE = new QLineEdit(this); - m_pVerCodeLE->setPlaceholderText("短信验证码"); - m_pVerCodeLE->setProperty("class", "InputLine"); - m_pVerCodeLE->setValidator(0); - mainLayout->addWidget(m_pVerCodeLE, 1, 2, 1, 1, Qt::AlignLeft); - - m_pGetVerCodeBT = new QPushButton(this); - m_pGetVerCodeBT->setText("获取验证码"); - m_pGetVerCodeBT->setEnabled(false); - m_pGetVerCodeBT->setFocusPolicy(Qt::NoFocus); - m_pGetVerCodeBT->setProperty("class", "GetCodeBT"); - m_pGetVerCodeBT->setCursor(QCursor(Qt::PointingHandCursor)); - mainLayout->addWidget(m_pGetVerCodeBT, 1, 3, 1, 1, Qt::AlignLeft); - - m_pNextGetVerCodeQTimer = new QTimer(this); - - m_curInputState = InputState::InputWaiting; -} - -void InputInfos::initConnect() -{ - connect(m_pPhoneLE, &QLineEdit::textChanged, this, &InputInfos::onPhoneTextChanged); - - connect(m_pVerCodeLE, &QLineEdit::textChanged, this, &InputInfos::onVerCodeTextChanged); - - connect(m_pNextGetVerCodeQTimer, &QTimer::timeout, this, &InputInfos::onNextGetVerCodeTimer); - - connect(m_pGetVerCodeBT, &QPushButton::clicked, this, &InputInfos::onGetVerCode); -} - -void InputInfos::setQSS() -{ - QString style_sheet = ".InputLine{" - "padding:10px 2px 10px 2px;" - "}" - ".GetCodeBT{" - "background:rgba(0,0,0,0);" - "color:rgba(38,38,38,115);" - "font-size:16px;" - "}"; - setStyleSheet(style_sheet); - adjustSize(); -} - -void InputInfos::paintEvent(QPaintEvent *) -{ - QPainter painter(this); - painter.setRenderHint(QPainter::Antialiasing); - painter.setPen(Qt::white); - painter.setBrush(Qt::white); - painter.drawRoundedRect(rect(), 16, 16); - painter.setPen(QColor(226, 226, 226)); - painter.drawLine(QLineF(0, m_pPhoneIconLB->y() + m_pPhoneIconLB->height() + 1, - width(), m_pPhoneIconLB->y() + m_pPhoneIconLB->height() + 1)); -} - -void InputInfos::onPhoneTextChanged(const QString &text) -{ - if(text.length() == 11){ - m_pGetVerCodeBT->setEnabled(true); - m_pGetVerCodeBT->setFocusPolicy(Qt::NoFocus); - m_pGetVerCodeBT->setStyleSheet("color:#2FB3E8;"); - - if(m_pVerCodeLE->text().length() == 6){ - Q_EMIT InputStateChanged(InputState::InputFinish); - m_curInputState = InputState::InputFinish; - } - } - else - { - m_pGetVerCodeBT->setEnabled(false); - m_pGetVerCodeBT->setStyleSheet("color:rgba(38, 38, 38, 115);"); - if(InputState::InputFinish == m_curInputState) - { - m_curInputState = InputState::InputWaiting; - Q_EMIT InputStateChanged(InputState::InputWaiting); - } - } -} - -void InputInfos::onVerCodeTextChanged(const QString &text) -{ - if(text.length() == 6 && m_pPhoneLE->text().length() == 11) - { - Q_EMIT InputStateChanged(InputState::InputFinish); - m_curInputState = InputState::InputFinish; - } - else if(m_curInputState == InputState::InputFinish) - { - Q_EMIT InputStateChanged(InputState::InputWaiting); - m_curInputState = InputState::InputWaiting; - } -} - -void InputInfos::clearInfos() -{ - m_pPhoneLE->clear(); - m_pVerCodeLE->clear(); - if(m_curInputState == InputState::InputFinish) - { - m_curInputState = InputState::InputWaiting; - Q_EMIT InputStateChanged(m_curInputState); - } -} - -QString InputInfos::getVerificationCode() -{ - return m_pVerCodeLE->text(); -} - -QString InputInfos::getPhoneNumer() -{ - return m_pPhoneLE->text(); -} - -void InputInfos::onGetVerCode() -{ - m_pGetVerCodeBT->setEnabled(false); - m_pGetVerCodeBT->setStyleSheet("color:rgba(38, 38, 38, 115);"); - m_nextGetVerCodeTime = 60; - m_pGetVerCodeBT->setText("重新获取(60s)"); - m_pNextGetVerCodeQTimer->start(1000); -} - - -void InputInfos::onNextGetVerCodeTimer() -{ - --m_nextGetVerCodeTime; - m_pGetVerCodeBT->setText("重新获取(" + QString::number(m_nextGetVerCodeTime) + "s)"); - if(m_nextGetVerCodeTime == 0) - { - m_pNextGetVerCodeQTimer->stop(); - m_pGetVerCodeBT->setEnabled(true); - m_pGetVerCodeBT->setFocusPolicy(Qt::NoFocus); - m_pGetVerCodeBT->setText("获取验证码"); - m_pGetVerCodeBT->setStyleSheet("color:#2FB3E8;"); - return; - } - -} - -PhoneAuthWidget::PhoneAuthWidget(QWidget *parent) -{ - initUI(); - initConnect(); - setQSS(); -} - -void PhoneAuthWidget::initUI() -{ - QVBoxLayout *phoLayout = new QVBoxLayout(this); - phoLayout->setMargin(0); - - m_pPhoTitleLB = new QLabel(this); - m_pPhoTitleLB->setText(tr("Verification by phoneNum")); - m_pPhoTitleLB->setProperty("class", "titleLB"); - phoLayout->addWidget(m_pPhoTitleLB, 0, Qt::AlignHCenter); - - m_pPhoPromptMsgLB = new QLabel(this); - m_pPhoPromptMsgLB->setText(tr("「 Use bound Phone number to verification 」")); - m_pPhoPromptMsgLB->setProperty("class", "PromptText"); - phoLayout->addWidget(m_pPhoPromptMsgLB, 0, Qt::AlignHCenter); - - m_pPhoErrorMsgLB = new QLabel(this); - m_pPhoErrorMsgCloneLB = new QLabel(this); - m_pPhoErrorMsgLB->setProperty("class", "ErrorMsg"); - m_pPhoErrorMsgCloneLB->setProperty("class", "ErrorMsg"); - hidePhoneErrorMsg(); - phoLayout->addWidget(m_pPhoErrorMsgLB, 0, Qt::AlignHCenter); - phoLayout->addWidget(m_pPhoErrorMsgCloneLB, 0, Qt::AlignHCenter); - - - m_pPhoInputInfos = new InputInfos(this); - phoLayout->addWidget(m_pPhoInputInfos, 0, Qt::AlignHCenter); - - m_pPhoSubmitBT = new QPushButton(this); - m_pPhoSubmitBT->setFocusPolicy(Qt::NoFocus); - m_pPhoSubmitBT->setText(tr("commit")); - m_pPhoSubmitBT->setProperty("class", "BindBT"); - m_pPhoSubmitBT->setCursor(QCursor(Qt::PointingHandCursor)); - m_pPhoSubmitBT->setEnabled(false); - phoLayout->addSpacing(8); - phoLayout->addWidget(m_pPhoSubmitBT, 0, Qt::AlignHCenter); - phoLayout->addStretch(1); -} - -void PhoneAuthWidget::initConnect() -{ - connect(m_pPhoInputInfos, &InputInfos::InputStateChanged, this, &PhoneAuthWidget::onInputStateChanged); - - connect(m_pPhoSubmitBT, &QPushButton::clicked, this, &PhoneAuthWidget::onSubmitBTClick); - - connect(m_pPhoInputInfos, &InputInfos::getVerCode, this, &PhoneAuthWidget::onGetVerCode); -} - -QSize PhoneAuthWidget::sizeHint() const{ - return QWidget::sizeHint(); -} - -void PhoneAuthWidget::hidePhoneErrorMsg() -{ - m_pPhoErrorMsgCloneLB->setFixedHeight(m_pPhoErrorMsgLB->height()); - m_pPhoErrorMsgCloneLB->show(); - m_pPhoErrorMsgLB->hide(); -} - -void PhoneAuthWidget::showPhoneErrorMsg() -{ - m_pPhoErrorMsgLB->show(); - m_pPhoErrorMsgCloneLB->hide(); -} - -void PhoneAuthWidget::onInputStateChanged(InputInfos::InputState input_state) -{ - if(input_state == InputInfos::InputState::InputFinish) - { - m_pPhoSubmitBT->setEnabled(true); - m_pPhoSubmitBT->setFocusPolicy(Qt::NoFocus); - m_pPhoSubmitBT->setStyleSheet("background:#2FB3E8;"); - } - else - { - m_pPhoSubmitBT->setEnabled(false); - m_pPhoSubmitBT->setStyleSheet("background:rgba(255,255,255,115);"); - } -} - - -void PhoneAuthWidget::onSubmitBTClick() -{ - QString tel = m_pPhoInputInfos->getPhoneNumer(); - QString verCode = m_pPhoInputInfos->getVerificationCode(); - if (true) - { - //验证成功 - qDebug() << "-----------onSubmitBTClick"; - Q_EMIT pageMessage(SwitchPage::SwitchToResetPWD, QList()); - } -// DBusMsgCode msgCode = SSOP->m_pRetrievePwdInterface->CheckVerificationCode(tel, verCode); -// switch (msgCode) { -// case DBusMsgCode::No_Error: -// emit pageMessage(PageMessage::JumpToNewPswSet, QList()); -// break; -// // TODO 更新提交后的错误状态 -// default: -// break; -// } -} - -void PhoneAuthWidget::onGetVerCode() -{ -// DBusMsgCode msgCode = SSOP->m_pRetrievePwdInterface->GetVerificationCode(Cfg->getUsername(), m_pPhoInputInfos->getPhoneNumer()); -// switch (msgCode) { -// case DBusMsgCode::No_Error: -// // 验证码获取无错误 -// break; -// // TODO 更新错误状态 -// default: -// break; -// } -} - -void PhoneAuthWidget::onQRCodeStateChanged(QString username, QString password, int nState) -{ - QRCodeSwepState state = static_cast(nState); - switch (state) { - case QRCodeSwepState::WaitingSwep: - qDebug() << "info: [QRCodePhoneAuthWidget][onQRCodeStateChanged]: waiting user swep qrcode!"; - break; - case QRCodeSwepState::HaveSwep: - qDebug() << "info: [QRCodePhoneAuthWidget][onQRCodeStateChanged]: user has swep code!"; - break; - case QRCodeSwepState::CancelSwep: - qDebug() << "info: [QRCodePhoneAuthWidget][onQRCodeStateChanged]: user cancel swep code!"; - break; - case QRCodeSwepState::ConfirmSuccess: - { - qDebug() << "info: [QRCodePhoneAuthWidget][onQRCodeStateChanged]: user = [" << username << "] confirm success!"; -// if(username != Cfg->getUsername()) -// { -// resetQRCService(); -// // TODO 更新错误信息 -// } -// else -// emit pageMessage(PageMessage::JumpToNewPswSet, QList()); -// break; - } - case QRCodeSwepState::QRCodeInvalid: - { - qDebug() << "info: [QRCodePhoneAuthWidget][onQRCodeStateChanged]: qrcode invalid!"; -// resetQRCService(); - break; - } - default: - break; - } -} - -void PhoneAuthWidget::setQSS() -{ - QString style_sheet =".PromptText{" - "font-size:24px;" - "color: rgba(255,255,255,192);" - "}" - ".BindBT{" - "background:rgba(255,255,255,115);" - "width:316px;" - "height:64px;" - "border-radius:16px;" - "}" - ".ErrorMsg{" - "color:#FD625E;" - "font-size:14px;" - "}" - ".titleLB{" - "color:#FFFFFF;" - "font-size:32px;" - "}"; - setStyleSheet(style_sheet); -} diff --git a/src/permissioncheck.h b/src/permissioncheck.h deleted file mode 100644 index 3af7e9c..0000000 --- a/src/permissioncheck.h +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (C) 2021 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#ifndef PERMISSIONCHECK_H -#define PERMISSIONCHECK_H - -#include -#include -#include -#include -#include "wechatauthdialog.h" -#include "common.h" - -class InputInfos; -class PhoneAuthWidget; - -class InputInfos : public QWidget -{ - Q_OBJECT -public: - enum InputState{ - InputWaiting - , InputFinish - }; - InputInfos(QWidget *parent = nullptr); - QString getPhoneNumer(); - QString getVerificationCode(); - void clearInfos(); - -Q_SIGNALS: - void getVerCode(); - void InputStateChanged(InputState input_state); - -protected: - void paintEvent(QPaintEvent *); - -private Q_SLOTS: - void onPhoneTextChanged(const QString &text); - void onVerCodeTextChanged(const QString &text); - void onGetVerCode(); - void onNextGetVerCodeTimer(); - -private: - void initUI(); - void initConnect(); - void setQSS(); - -private: - QLabel *m_pPhoneIconLB; - QLineEdit *m_pPhoneLE; - QLabel *m_pVerCodeIconLB; - QLineEdit *m_pVerCodeLE; - QPushButton *m_pGetVerCodeBT; - QTimer *m_pNextGetVerCodeQTimer; - int m_nextGetVerCodeTime; - - InputState m_curInputState; -}; - -class VerificationWidget : public QWidget -{ - Q_OBJECT -public: - explicit VerificationWidget(QWidget *parent = nullptr); - -Q_SIGNALS: - void pageMessage(SwitchPage id, QList argvs); -private: - QLabel *m_titleLB; - QLabel *m_phonePromptMsgLB; - WeChatAuthDialog *m_weChatWidget; -//public: - PhoneAuthWidget *m_phoneAuthWidget; - -protected: - void paintEvent(QPaintEvent *); -}; - -class PhoneAuthWidget : public QWidget -{ - Q_OBJECT -public: - PhoneAuthWidget(QWidget* parent = nullptr); - QSize sizeHint() const; - -private: - void initUI(); - void initConnect(); - void setQSS(); - - void showPhoneErrorMsg(); - void hidePhoneErrorMsg(); -Q_SIGNALS: - void pageMessage(SwitchPage id, QList argvs); -private Q_SLOTS: - void onInputStateChanged(InputInfos::InputState input_state); - void onSubmitBTClick(); - void onGetVerCode(); - void onQRCodeStateChanged(QString username, QString password, int nState); - -private: - // 手机号验证 - QLabel *m_pPhoTitleLB; - QLabel *m_pPhoPromptMsgLB; - QLabel *m_pPhoErrorMsgLB; - QLabel *m_pPhoErrorMsgCloneLB; // 控制格式 - QPushButton *m_pPhoSubmitBT; - InputInfos *m_pPhoInputInfos; - -}; -#endif // PERMISSIONCHECK_H diff --git a/src/powermanager.cpp b/src/powermanager.cpp deleted file mode 100644 index 9ae9bfa..0000000 --- a/src/powermanager.cpp +++ /dev/null @@ -1,794 +0,0 @@ - /* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * - **/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "powermanager.h" -#include "lockchecker.h" -#include "klabel.h" - -const static QString login1Service = QStringLiteral("org.freedesktop.login1"); -const static QString login1Path = QStringLiteral("/org/freedesktop/login1"); -const static QString login1ManagerInterface = QStringLiteral("org.freedesktop.login1.Manager"); - -#define NORMAL "normal" -#define FOCUS "focus" - -#ifdef USE_INTEL -PowerManager::PowerManager(QWidget *parent) - : QWidget(parent), - lasttime(QTime::currentTime()) -{ - resize((ITEM_WIDTH*4 + ITEM_SPACING*3), ITEM_HEIGHT); - initUI(); - setQSS(); -} -#else -PowerManager::PowerManager(int num, QWidget *parent) - : QListWidget(parent), - lasttime(QTime::currentTime()) -{ - // resize(ITEM_WIDTH*7, ITEM_HEIGHT); - QFile qssFile(":/qss/assets/authdialog.qss"); - if(qssFile.open(QIODevice::ReadOnly)) { - this->setStyleSheet(qssFile.readAll()); - } - setObjectName("PowerManager"); - setFlow(QListWidget::LeftToRight); - setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - setSelectionMode(QListWidget::NoSelection); - - - //QObject::connect(this,SIGNAL(itemClicked(QListWidgetItem*)),this,SLOT(powerClicked(QListWidgetItem*))); - - sessionInterface = new QDBusInterface("org.gnome.SessionManager", - "/org/gnome/SessionManager", - "org.gnome.SessionManager", - QDBusConnection::sessionBus(), - this); - - loginInterface = new QDBusInterface(login1Service, - login1Path, - login1ManagerInterface, - QDBusConnection::systemBus(), - this); - - QDBusReply stateReply = loginInterface->call("CanSuspend"); - if(stateReply.isValid() && stateReply.value() == "yes"){ - canSuspend = true; - }else{ - canSuspend = false; - } - - QDBusReply stateReply1 = loginInterface->call("CanHibernate"); - if(stateReply1.isValid() && stateReply1.value() == "yes"){ - canHibernate = true; - }else{ - canHibernate = false; - } - - initUI(); - //resize((ITEM_WIDTH+ITEM_SPACING*2)*this->count()-ITEM_SPACING*2, ITEM_HEIGHT+ITEM_SPACING*2); - resize((ITEM_WIDTH)*this->count(), ITEM_HEIGHT); - //setCurrentRow(0); - loginedNum = num; -} - -bool PowerManager::eventFilter(QObject *obj, QEvent *event) -{ - /*这里之前使用点击事件,再某些机器上会出现点击睡眠后,先睡眠,再自动唤醒的问题, - * 原因不明,改为鼠标释放事件时无此问题*/ - if(event->type() != QEvent::MouseButtonRelease){ - return QWidget::eventFilter(obj, event); - } - - QString name = obj->objectName(); - - if(name == "switchFace") - switchWidgetClicked(); - else if(name == "logoutFace") - logoutWidgetCliced(); - else if(name == "rebootFace") - rebootWidgetClicked(); - else if(name == "shutdownFace") - shutdownWidgetClicked(); - else if(name == "suspendFace") - suspendWidgetClicked(); - else if(name == "hibernateFace") - hibernateWidgetClicked(); - - return QWidget::eventFilter(obj, event); -} - -void PowerManager::onGlobalKeyPress(const quint8 &key) -{ -} - -void PowerManager::onGlobalkeyRelease(const quint8 &key) -{ -// if (key == 9) { // "Escape" - -// } else if (key == 113 || key == 114 || key == 36 || key == 104) { // "Left" "Right" "Return" "KP_Enter" -// keyBdRelease(key); -// } -} - -void PowerManager::keyBdRelease(int key) -{ - if(key == Qt::Key_Right){ // "Right" - if(nowAt == -1){ - nowAt = 0; - setButtonStyle(FOCUS); - } else if(nowAt == 0){ - setButtonStyle(NORMAL); - nowAt = 1; - setButtonStyle(FOCUS); - } else if(nowAt == 1){ - setButtonStyle(NORMAL); - nowAt = 2; - setButtonStyle(FOCUS); - } else if(nowAt == 2){ - setButtonStyle(NORMAL); - nowAt = 3; - setButtonStyle(FOCUS); - } else if(nowAt == 3){ - setButtonStyle(NORMAL); - nowAt = 0; - setButtonStyle(FOCUS); - } - } else if(key == Qt::Key_Left) { // "Left" - if(nowAt == -1){ - nowAt = 3; - setButtonStyle(FOCUS); - } else if(nowAt == 3){ - setButtonStyle(NORMAL); - nowAt = 2; - setButtonStyle(FOCUS); - } else if(nowAt == 2){ - setButtonStyle(NORMAL); - nowAt = 1; - setButtonStyle(FOCUS); - } else if(nowAt == 1){ - setButtonStyle(NORMAL); - nowAt = 0; - setButtonStyle(FOCUS); - } else if(nowAt == 0){ - setButtonStyle(NORMAL); - nowAt = 3; - setButtonStyle(FOCUS); - } - } else if(key == Qt::Key_Return || key == Qt::Key_Enter || key == Qt::Key_Space){ // "Return" "KP_Enter" "Space" - if(nowAt == 0 && this->isVisible()) - hibernateWidgetClicked(); - else if(nowAt == 1 && this->isVisible()) - suspendWidgetClicked(); - else if(nowAt == 2 && this->isVisible()) - rebootWidgetClicked(); - else if(nowAt == 3 && this->isVisible()) - shutdownWidgetClicked(); - } -} - -void PowerManager::clearStatus() -{ - for(nowAt = 0; nowAt < listLabel.count(); nowAt++) { - setButtonStyle(NORMAL); - } - nowAt = -1; -} - -void::PowerManager::setButtonStyle(QString Style) -{ - if(Style == "normal") - listLabel.at(nowAt)->setStyleSheet("background-color: rgba(255, 255, 255, 15%);\ - QPushButton:hover{background-color:rgba(255,255,255,40%)};QPushButton:pressed:!hover{background-color:rgba(255,255,255,30%)}"); - else if(Style == "focus") - listLabel.at(nowAt)->setStyleSheet("background-color: rgba(255, 255, 255, 20%);border: 1px solid #296CD9; border-radius: 64px;"); -} - -void PowerManager::powerClicked(QListWidgetItem *item) -{ - int interval = lasttime.msecsTo(QTime::currentTime()); - if(interval < 200 && interval > -200) - return ; - lasttime = QTime::currentTime(); - - QString name = itemWidget(item)->objectName(); -// if(name == lockWidget->objectName()) -// lockWidgetClicked(); - if(switchWidget && name == switchWidget->objectName()) - switchWidgetClicked(); - else if(name == logoutWidget->objectName()) - logoutWidgetCliced(); - else if(name == rebootWidget->objectName()) - rebootWidgetClicked(); - else if(name == shutdownWidget->objectName()) - shutdownWidgetClicked(); - else if(suspendWidget && name == suspendWidget->objectName()) - suspendWidgetClicked(); - else if(hibernateWidget && name == hibernateWidget->objectName()) - hibernateWidgetClicked(); -} -#endif - -void PowerManager::lockWidgetClicked() -{ - emit lock(); -} - -void PowerManager::switchWidgetClicked() -{ - emit switchToUser(); -} - -#ifdef USE_INTEL -void PowerManager::shutdownWidgetClicked() -{ - QDBusInterface *interface = new QDBusInterface("org.gnome.SessionManager", - "/org/gnome/SessionManager", - "org.gnome.SessionManager", - QDBusConnection::sessionBus(), - this); - - QDBusMessage msg = interface->call("powerOff"); - qDebug() << "[PowerManager] [shutdownWidgetClicked]" << msg.errorMessage(); -} - -void PowerManager::rebootWidgetClicked() -{ - QDBusInterface *interface = new QDBusInterface("org.gnome.SessionManager", - "/org/gnome/SessionManager", - "org.gnome.SessionManager", - QDBusConnection::sessionBus(), - this); - - QDBusMessage msg = interface->call("reboot"); - qDebug() << "[PowerManager] [rebootWidgetClicked]" << msg.errorMessage(); -} - -void PowerManager::logoutWidgetCliced() -{ - QDBusInterface *interface = new QDBusInterface("org.gnome.SessionManager", - "/org/gnome/SessionManager", - "org.gnome.SessionManager", - QDBusConnection::sessionBus(), - this); - - QDBusMessage msg = interface->call("logout"); - qDebug() << "[PowerManager] [logoutWidgetCliced]" << msg.errorMessage(); -} - -void PowerManager::initUI() -{ - this->setContentsMargins(0,0,0,0); - QHBoxLayout *main_layout = new QHBoxLayout(this); - main_layout->setContentsMargins(0,0,0,0); - main_layout->setSpacing(0); - - lockWidget = new QWidget(this); - lockWidget->setContentsMargins(0,0,0,0); - lockWidget->setFixedSize(ITEM_WIDTH,ITEM_HEIGHT); - QPushButton *lockPB = new QPushButton(lockWidget); - QLabel *lockLabel = new QLabel(lockWidget); - lockPB->setProperty("class", "PowerManagerPB"); - lockPB->setIcon(QIcon(QPixmap(":/image/assets/intel/lock.png").scaled(40,40))); - lockLabel->setAlignment(Qt::AlignBottom | Qt::AlignHCenter); - lockLabel->setText(tr("lock")); - QVBoxLayout *locklayout = new QVBoxLayout(lockWidget); - locklayout->setContentsMargins(0,0,0,0); - locklayout->addWidget(lockPB); - locklayout->addWidget(lockLabel); - connect(lockPB, &QPushButton::clicked, this, [=]{ - qDebug() << "PowerManager lock clicked"; - Q_EMIT lock(); - }); - - logoutWidget = new QWidget(this); - logoutWidget->setContentsMargins(0,0,0,0); - logoutWidget->setFixedSize(ITEM_WIDTH,ITEM_HEIGHT); - QPushButton *logoutPB = new QPushButton(logoutWidget); - QLabel *logoutLabel = new QLabel(this); - logoutPB->setProperty("class", "PowerManagerPB"); - logoutPB->setIcon(QIcon(QPixmap(":/image/assets/intel/logout.png").scaled(40,40))); - logoutLabel->setText(tr("Log Out")); - logoutLabel->setAlignment(Qt::AlignBottom | Qt::AlignHCenter); - QVBoxLayout *logoutlayout = new QVBoxLayout(logoutWidget); - logoutlayout->setContentsMargins(0,0,0,0); - logoutlayout->addWidget(logoutPB); - logoutlayout->addWidget(logoutLabel); - connect(logoutPB, &QPushButton::clicked, this, [=]{ - qDebug() << "PowerManager logout clicked"; - logoutWidgetCliced();; - }); - - rebootWidget = new QWidget(this); - rebootWidget->setFixedSize(ITEM_WIDTH,ITEM_HEIGHT); - rebootWidget->setContentsMargins(0,0,0,0); - QPushButton *rebootPB = new QPushButton(rebootWidget); - QLabel *rebootLabel = new QLabel(this); - rebootPB->setProperty("class", "PowerManagerPB"); - rebootPB->setIcon(QIcon(QPixmap(":/image/assets/intel/reboot.png").scaled(40,40))); - rebootLabel->setText(tr("Restart")); - rebootLabel->setAlignment(Qt::AlignBottom | Qt::AlignHCenter); - - QVBoxLayout *rebootlayout = new QVBoxLayout(rebootWidget); - rebootlayout->setContentsMargins(0,0,0,0); - rebootlayout->addWidget(rebootPB); - rebootlayout->addWidget(rebootLabel); - connect(rebootPB, &QPushButton::clicked, this, [=]{ - qDebug() << "PowerManager reboot clicked"; - //rebootWidgetClicked(); - reboot(); - }); - - shutdownWidget = new QWidget(this); - shutdownWidget->setFixedSize(ITEM_WIDTH,ITEM_HEIGHT); - shutdownWidget->setObjectName("shutdownWidget"); - QPushButton *shutdownPB = new QPushButton(shutdownWidget); - QLabel *shutdownLabel = new QLabel(shutdownWidget); - shutdownPB->setProperty("class", "PowerManagerPB"); - shutdownPB->setIcon(QIcon(QPixmap(":/image/assets/intel/shutdown.png").scaled(40,40))); - shutdownLabel->setText(tr("Power Off")); - shutdownLabel->setAlignment(Qt::AlignBottom | Qt::AlignHCenter); - QVBoxLayout *shutdownlayout = new QVBoxLayout(shutdownWidget); - shutdownlayout->setContentsMargins(0,0,0,0); - shutdownlayout->addWidget(shutdownPB); - shutdownlayout->addWidget(shutdownLabel); - connect(shutdownPB, &QPushButton::clicked, this, [=]{ - qDebug() << "PowerManager shutdown clicked"; - //shutdownWidgetClicked(); - powerOff(); - }); - - main_layout->addWidget(lockWidget); - main_layout->addSpacing(ITEM_SPACING); - main_layout->addWidget(logoutWidget); - main_layout->addSpacing(ITEM_SPACING); - main_layout->addWidget(rebootWidget); - main_layout->addSpacing(ITEM_SPACING); - main_layout->addWidget(shutdownWidget); - adjustSize(); -} - -//息屏,休眠状态Hibernate/挂起Suspend -bool PowerManager::hibernate() -{ - const QString service = "org.freedesktop.login1"; - const QString path = "/org/freedesktop/login1"; - const QString interface = "org.freedesktop.login1.Manager"; - QString command = QLatin1String("Suspend"); - - QDBusInterface dbus(service, path, interface, QDBusConnection::systemBus()); - if (!dbus.isValid()) { - qWarning() << "dbusCall: QDBusInterface is invalid" << service<< path - << interface << "Suspend"; - return false; - } - QDBusMessage msg = dbus.call(command, QVariant(true)); - - if (!msg.errorName().isEmpty()) { - qWarning() << "Debus error: " << msg; - } - - if (msg.arguments().isEmpty() || msg.arguments().constFirst().isNull()) - return true; - - QString response = msg.arguments().constFirst().toString(); - qDebug() << "systemd:" << QLatin1String("Suspend") << "=" << response; - return response == QLatin1String("yes") || response == QLatin1String("challenge"); -} - -bool PowerManager::reboot() -{ - const QString service = "org.freedesktop.login1"; - const QString path = "/org/freedesktop/login1"; - const QString interface = "org.freedesktop.login1.Manager"; - QString command = QLatin1String("Reboot"); - - QDBusInterface dbus(service, path, interface, QDBusConnection::systemBus()); - if (!dbus.isValid()) { - qWarning() << "dbusCall: QDBusInterface is invalid" << service<< path - << interface << "Reboot"; - return false; - } - QDBusMessage msg = dbus.call(command, QVariant(true)); - - if (!msg.errorName().isEmpty()) { - qWarning() << "Debus error: " << msg; - } - - if (msg.arguments().isEmpty() || msg.arguments().constFirst().isNull()) - return true; - - QString response = msg.arguments().constFirst().toString(); - qDebug() << "systemd:" << QLatin1String("Reboot") << "=" << response; - return response == QLatin1String("yes") || response == QLatin1String("challenge"); -} - -bool PowerManager::powerOff() -{ - const QString service = "org.freedesktop.login1"; - const QString path = "/org/freedesktop/login1"; - const QString interface = "org.freedesktop.login1.Manager"; - QString command = QLatin1String("PowerOff"); - - QDBusInterface dbus(service, path, interface, QDBusConnection::systemBus()); - if (!dbus.isValid()) { - qWarning() << "dbusCall: QDBusInterface is invalid" << service<< path - << interface << "PowerOff"; - return false; - } - QDBusMessage msg = dbus.call(command, QVariant(true)); - - if (!msg.errorName().isEmpty()) { - qWarning() << "Debus error: " << msg; - } - - if (msg.arguments().isEmpty() || msg.arguments().constFirst().isNull()) - return true; - - QString response = msg.arguments().constFirst().toString(); - qDebug() << "systemd:" << QLatin1String("PowerOff") << "=" << response; - return response == QLatin1String("yes") || response == QLatin1String("challenge"); -} - -void PowerManager::setQSS() -{ - //设置电源管理按键样式 - QString style_sheet = ".PowerManagerPB{" - "background:rgba(255,255,255,38);" - "min-width: 128px;" - "max-width: 128px;" - "min-height: 128px;" - "max-height: 128px;" - "border-radius: 64px;" - "icon-size: 40px;" - "font-family: NotoSansCJKsc-Regular, NotoSansCJKsc;" - "}" - ".PowerManagerPB:hover{" - "background:rgba(255,255,255,89);" - "}" - ".PowerManagerPB:pressed{" - "background:rgba(255,255,255,12);" - "}"; - setStyleSheet(style_sheet); -} -#else - -void PowerManager::doEvent(int type) -{ - switch (type) { - case SLEEP: - loginInterface->call("Suspend",true); - emit lock(); - break; - case HIBERNATE: - loginInterface->call("Hibernate",true); - emit lock(); - break; - case REBOOT: - if (is_hibernate && loginedNum > 1) { - Q_EMIT mulUsersLogined(REBOOT); - is_hibernate = false; - } else - loginInterface->call("Reboot", true); - break; - case SHUTDOWN: - if (is_hibernate && loginedNum > 1) { - Q_EMIT mulUsersLogined(SHUTDOWN); - is_hibernate = false; - } else - loginInterface->call("PowerOff", true); - break; - default: - break; - } -} - -void PowerManager::setStartupMode(bool mode) -{ - m_isStartupMode = mode; -} - -void PowerManager::suspendWidgetClicked() -{ - QVector res = LockChecker::listInhibitor("sleep"); - if (!res.isEmpty()) { - Q_EMIT showInhibitWarning(res, SLEEP); - return; - } - emit lock(); - Q_EMIT clickedSuspend(); - loginInterface->call("Suspend",true); -} - -void PowerManager::hibernateWidgetClicked() -{ - QVector res = LockChecker::listInhibitor("sleep"); - if (!res.isEmpty()) { - Q_EMIT showInhibitWarning(res, HIBERNATE); - return; - } - emit lock(); - loginInterface->call("Hibernate",true); -} - -void PowerManager::shutdownWidgetClicked() -{ - QVector res = LockChecker::listInhibitor("shutdown"); - if (!res.isEmpty()) { - Q_EMIT showInhibitWarning(res, SHUTDOWN); - is_hibernate = true; - return; - } else if(loginedNum > 1){ - Q_EMIT mulUsersLogined(SHUTDOWN); - is_hibernate = false; - return; - } - if (m_isStartupMode) { - loginInterface->call("PowerOff", true); - } else { - sessionInterface->call("powerOff"); - } -} - -void PowerManager::rebootWidgetClicked() -{ - QVector res = LockChecker::listInhibitor("shutdown"); - if (!res.isEmpty()) { - Q_EMIT showInhibitWarning(res, REBOOT); - is_hibernate = true; - return; - } else if(loginedNum > 1){ - Q_EMIT mulUsersLogined(REBOOT); - is_hibernate = false; - return; - } - if (m_isStartupMode) { - loginInterface->call("Reboot", true); - } else { - sessionInterface->call("reboot"); - } -} - -void PowerManager::logoutWidgetCliced() -{ - sessionInterface->call("logout"); -} - -void PowerManager::showSmallSize() -{ - for(int i = 0;iitem(i); - item->setSizeHint(QSize(ITEM_WIDTH*0.8,ITEM_HEIGHT)); - itemWidget(item)->setFixedSize(ITEM_WIDTH*0.8,ITEM_HEIGHT); - } - resize(ITEM_WIDTH*this->count()*0.8,ITEM_HEIGHT); -} - -void PowerManager::showNormalSize() -{ - for(int i = 0;iitem(i); - item->setSizeHint(QSize(ITEM_WIDTH,ITEM_HEIGHT)); - itemWidget(item)->setFixedSize(ITEM_WIDTH,ITEM_HEIGHT); - } - // resize(ITEM_WIDTH*this->count(),ITEM_HEIGHT); - // resize((ITEM_WIDTH+ITEM_SPACING)*this->count(), ITEM_HEIGHT+ITEM_SPACING); -// resize((ITEM_WIDTH+ITEM_SPACING*2)*this->count()-ITEM_SPACING*2, ITEM_HEIGHT+ITEM_SPACING*2); - resize((ITEM_WIDTH)*this->count(), ITEM_HEIGHT); -} - -void PowerManager::initUI() -{ -// setSpacing(30); - -// actService = new QDBusInterface("org.freedesktop.Accounts", -// "/org/freedesktop/Accounts", -// "org.freedesktop.Accounts", -// QDBusConnection::systemBus()); - -// QDBusMessage ret = actService->call("ListCachedUsers"); -// QList outArgs = ret.arguments(); -// QVariant first = outArgs.at(0); -// const QDBusArgument &dbusArgs = first.value(); -// dbusArgs.beginArray(); -// QDBusObjectPath path; -// int userCount =0; -// while (!dbusArgs.atEnd()) -// { -// userCount++; -// dbusArgs >> path; -// } -// dbusArgs.endArray(); -// switchWidget=nullptr; -// if(userCount>1){ -// switchWidget = new QWidget(this); -// switchWidget->setObjectName("switchWidget"); -// QLabel *switchFace = new QLabel(switchWidget); -// QLabel *switchLabel = new QLabel(switchWidget); -// switchFace->setAlignment(Qt::AlignCenter); -// switchFace->setObjectName("switchFace"); -// switchFace->installEventFilter(this); -// switchLabel->setAlignment(Qt::AlignCenter); -// switchFace->setPixmap(QPixmap(":/image/assets/switchGreeter.png").scaled(58,58)); -// switchLabel->setText(tr("Switch User")); -// switchWidget->setFixedSize(ITEM_WIDTH,ITEM_HEIGHT); -// QVBoxLayout *switchlayout = new QVBoxLayout(switchWidget); -// switchlayout->addWidget(switchFace); -// switchlayout->addWidget(switchLabel); -// // switchWidget->installEventFilter(this); -// } -// logoutWidget = new QWidget(this); -// logoutWidget->setObjectName("logoutWidget"); -// QLabel *logoutFace = new QLabel(this); -// QLabel *logoutLabel = new QLabel(this); -// logoutFace->setAlignment(Qt::AlignCenter); -// logoutFace->setObjectName("logoutFace"); -// logoutFace->installEventFilter(this); -// logoutLabel->setAlignment(Qt::AlignCenter); -// logoutFace->setPixmap(QPixmap(":/image/assets/logout.png").scaled(48,48)); -// logoutLabel->setText(tr("Log Out")); -// logoutWidget->setFixedSize(ITEM_WIDTH,ITEM_HEIGHT); -// QVBoxLayout *logoutlayout = new QVBoxLayout(logoutWidget); -// logoutlayout->addWidget(logoutFace); -// logoutlayout->addWidget(logoutLabel); - //logoutWidget->installEventFilter(this); - - rebootWidget = new QWidget(this); - rebootWidget->setObjectName("rebootWidget"); - QWidget *rbLabelWidget = new QWidget(this); - rbLabelWidget->setFixedSize(130, 130); - rebootFace = new QPushButton(rbLabelWidget); - rebootFace->setObjectName("rebootFace"); - KLabel *rebootLabel = new KLabel(this); - //rebootFace->setAlignment(Qt::AlignCenter); - rebootFace->installEventFilter(this); - rebootLabel->setAlignment(Qt::AlignCenter); - rebootFace->setIcon(QIcon(":/image/assets/reboot.svg")); - rebootFace->setIconSize(QSize(48, 48)); - rebootFace->setToolTip(tr("Close all apps, turn off your computer, and then turn your computer back on")); - rebootLabel->setFontSize(16); - rebootLabel->setElideText(tr("Restart"), 130); - //rebootLabel->setText(tr("Restart")); - rebootWidget->setFixedSize(ITEM_WIDTH,ITEM_HEIGHT); - QVBoxLayout *rebootlayout = new QVBoxLayout(rebootWidget); - rebootlayout->setAlignment(Qt::AlignHCenter); - rebootlayout->addWidget(rbLabelWidget); - rebootlayout->addWidget(rebootLabel); - //rebootWidget->installEventFilter(this); - - shutdownWidget = new QWidget(this); - shutdownWidget->setObjectName("shutdownWidget"); - QWidget *shLabelWidget = new QWidget(this); - shLabelWidget->setFixedSize(130, 130); - shutdownFace = new QPushButton(shLabelWidget); - shutdownFace->setObjectName("shutdownFace"); - KLabel *shutdownLabel = new KLabel(this); - shutdownLabel->setAlignment(Qt::AlignCenter); - //shutdownFace->setAlignment(Qt::AlignCenter); - shutdownFace->installEventFilter(this); - shutdownFace->setIcon(QIcon(":/image/assets/shutdown.svg")); - shutdownFace->setIconSize(QSize(48, 48)); - shutdownFace->setToolTip(tr("Close all apps, and then shut down your computer")); - //sysFont.setPointSize(20); - shutdownLabel->setFontSize(16); - shutdownLabel->setElideText(tr("Shut Down"), 130); - //shutdownLabel->setText(tr("Shut Down")); - shutdownWidget->setFixedSize(ITEM_WIDTH, ITEM_HEIGHT); - QVBoxLayout *shutdownlayout = new QVBoxLayout(shutdownWidget); - shutdownlayout->setAlignment(Qt::AlignHCenter); - shutdownlayout->addWidget(shLabelWidget); - shutdownlayout->addWidget(shutdownLabel); - //shutdownWidget->installEventFilter(this); - -// if(userCount>1){ -// QListWidgetItem *item1 = new QListWidgetItem(); -// item1->setSizeHint(QSize(ITEM_WIDTH, ITEM_HEIGHT)); -// insertItem(this->count(), item1); -// setItemWidget(item1, switchWidget); -// } - hibernateWidget = nullptr; - if(canHibernate){ - hibernateWidget = new QWidget(this); - hibernateWidget->setObjectName("hibernateWidget"); - QWidget *hbLabelWidget = new QWidget(this); - hbLabelWidget->setFixedSize(130, 130); - hibernateFace = new QPushButton(hbLabelWidget); - hibernateFace->setObjectName("hibernateFace"); - KLabel *hibernateLabel = new KLabel(this); - hibernateLabel->setAlignment(Qt::AlignCenter); - //hibernateFace->setAlignment(Qt::AlignCenter); - hibernateFace->installEventFilter(this); - hibernateFace->setIcon(QIcon(":/image/assets/hibernate.svg")); - hibernateFace->setIconSize(QSize(48, 48)); - hibernateFace->setToolTip(tr("Turn off your computer, but the app stays open. When the computer is turned on, it can be restored to the state you left")); - hibernateLabel->setFontSize(16); - hibernateLabel->setElideText(tr("Hibernate"), 130); - hibernateWidget->setFixedSize(ITEM_WIDTH,ITEM_HEIGHT); - QVBoxLayout *hibernatelayout = new QVBoxLayout(hibernateWidget); - hibernatelayout->setAlignment(Qt::AlignHCenter); - hibernatelayout->addWidget(hbLabelWidget); - hibernatelayout->addWidget(hibernateLabel); - //hibernateWidget->installEventFilter(this); - - QListWidgetItem *item5 = new QListWidgetItem(); - item5->setSizeHint(QSize(ITEM_WIDTH, ITEM_HEIGHT)); - insertItem(this->count(), item5); - setItemWidget(item5, hibernateWidget); - listLabel.append(hibernateFace); - } - - suspendWidget = nullptr; - if(canSuspend){ - suspendWidget = new QWidget(this); - suspendWidget->setObjectName("suspendWidget"); - QWidget *spLabelWidget = new QWidget(this); - spLabelWidget->setFixedSize(130, 130); - suspendFace = new QPushButton(spLabelWidget); - suspendFace->setObjectName("suspendFace"); - KLabel *suspendLabel = new KLabel(this); - suspendLabel->setAlignment(Qt::AlignCenter); - //suspendFace->setAlignment(Qt::AlignCenter); - suspendFace->installEventFilter(this); - suspendFace->setIcon(QIcon(":/image/assets/suspend.svg")); - suspendFace->setIconSize(QSize(48, 48)); - suspendFace->setToolTip(tr("The computer stays on, but consumes less power. The app stays open and can quickly wake up and revert to where you left off")); - suspendWidget->setFixedSize(ITEM_WIDTH,ITEM_HEIGHT); - suspendLabel->setFontSize(16); - suspendLabel->setElideText(tr("Suspend"), 130); - QVBoxLayout *suspendlayout = new QVBoxLayout(suspendWidget); - suspendlayout->setAlignment(Qt::AlignHCenter); - suspendlayout->addWidget(spLabelWidget); - suspendlayout->addWidget(suspendLabel); - //suspendWidget->installEventFilter(this); - - QListWidgetItem *item4 = new QListWidgetItem(); - item4->setSizeHint(QSize(ITEM_WIDTH, ITEM_HEIGHT)); - insertItem(this->count(), item4); - setItemWidget(item4, suspendWidget); - listLabel.append(suspendFace); - } - -// QListWidgetItem *item1 = new QListWidgetItem(); -// item1->setSizeHint(QSize(ITEM_WIDTH, ITEM_HEIGHT)); -// insertItem(this->count(), item1); -// setItemWidget(item1, logoutWidget); - - QListWidgetItem *item2 = new QListWidgetItem(); - item2->setSizeHint(QSize(ITEM_WIDTH, ITEM_HEIGHT)); - insertItem(this->count(), item2); - setItemWidget(item2, rebootWidget); - listLabel.append(rebootFace); - - QListWidgetItem *item3 = new QListWidgetItem(); - item3->setSizeHint(QSize(ITEM_WIDTH, ITEM_HEIGHT)); - insertItem(this->count(), item3); - setItemWidget(item3, shutdownWidget); - listLabel.append(shutdownFace); -} -#endif diff --git a/src/powermanager.h b/src/powermanager.h deleted file mode 100644 index 6b398f0..0000000 --- a/src/powermanager.h +++ /dev/null @@ -1,138 +0,0 @@ - /* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * - **/ - -#ifndef POWERMANAGER_H -#define POWERMANAGER_H -#include -#include -#include -#include -#include "config.h" -#include "lockchecker.h" -#ifdef USE_INTEL -#define ITEM_WIDTH 128 -#define ITEM_HEIGHT (ITEM_WIDTH + 40) -#define ITEM_SPACING 72 - -class QWidget; -class PowerManager:public QWidget -#else -#define ITEM_WIDTH 204 -#define ITEM_HEIGHT 200 -#define ITEM_SPACING 30 - -enum stateType { - REBOOT, - SHUTDOWN, - SLEEP, - HIBERNATE, - NOTHING -}; - -class QLabel; -class QPushButton; -class QListWidget; -class QListWidgetItem; -class QDBusInterface; -class PowerManager:public QListWidget -#endif -{ - Q_OBJECT - -public: - PowerManager(int num = 0, QWidget *parent = 0); -#ifdef USE_INTEL - bool hibernate(); -#else - void showNormalSize(); - void showSmallSize(); - void keyBdRelease(int key); - void clearStatus(); - void doEvent(int type); - void setStartupMode(bool mode); - -public Q_SLOTS: - void onGlobalKeyPress(const quint8 &key); - void onGlobalkeyRelease(const quint8 &key); -#endif -private: - void initUI(); - -#ifdef USE_INTEL - void setQSS(); - QWidget *list; -#else - QList listLabel; - int nowAt = -1; - QListWidget *list; - QWidget *suspendWidget; - QWidget *hibernateWidget; - QDBusInterface *sessionInterface; - QDBusInterface *loginInterface; - QDBusInterface *actService; - int login_Num; - bool is_hibernate = false; - - bool canSuspend; - bool canHibernate; - int m_count; -#endif - QWidget *lockWidget; - QWidget *switchWidget; - QWidget *logoutWidget; - QWidget *rebootWidget; - QWidget *shutdownWidget; - QTime lasttime; - QPushButton *rebootFace; - QPushButton *shutdownFace; - QPushButton *hibernateFace; - QPushButton *suspendFace; - int loginedNum = 0; - bool m_isStartupMode = false; - -private: - void lockWidgetClicked(); - void switchWidgetClicked(); - void logoutWidgetCliced(); - void rebootWidgetClicked(); - QStringList getLoginedUsers(); - void shutdownWidgetClicked(); - //void keyBdRelease(quint8 key); - void setButtonStyle(QString Style); -#ifdef USE_INTEL - bool reboot(); - bool powerOff(); -#else - void suspendWidgetClicked(); - void hibernateWidgetClicked(); -#endif -private Q_SLOTS: -#ifndef USE_INTEL - void powerClicked(QListWidgetItem *item); - bool eventFilter(QObject *obj, QEvent *event); - -#endif -Q_SIGNALS: - void switchToUser(); - void lock(); - void mulUsersLogined(int type); - void showInhibitWarning(QVector &list, int type); - void clickedSuspend(); -}; - -#endif // POWERMANAGER_H diff --git a/src/rootWindowBackground.cpp b/src/rootWindowBackground.cpp deleted file mode 100644 index eb3d534..0000000 --- a/src/rootWindowBackground.cpp +++ /dev/null @@ -1,410 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "rootWindowBackground.h" - -static const XID INVAL_ID = ~0UL; -Pixmap pix = INVAL_ID; -Display *dpy = NULL; -Window root = 0; -Screen *scn = NULL; - -struct RootWindowBGInfo { - bool isValid = false; - int nType; - int nColor; - QString strFileName; - int nOption; - QList listScreen; -}; - -static RootWindowBGInfo g_lastRootWndInfo; - -static QRect getSourceRect(const QRect &destination, const QRect &source) -{ - qreal screenScale = qreal(destination.width()) / qreal(destination.height()); - qreal width = source.width(); - qreal height = source.height(); - - if ((width / height) == screenScale) { - return source; - } - - bool isShortX = (width <= height); - if (isShortX) { - screenScale = qreal(destination.height()) / qreal(destination.width()); - } - - qreal shortEdge = isShortX ? width : height; - qreal longEdge = isShortX ? height : width; - - while (shortEdge > 1) { - qint32 temp = qFloor(shortEdge * screenScale); - if (temp <= longEdge) { - longEdge = temp; - break; - } - - qint32 spacing = qRound(shortEdge / 20); - if (spacing <= 0) { - spacing = 1; - } - shortEdge -= spacing; - } - - QSize sourceSize = source.size(); - if (shortEdge > 1 && longEdge > 1) { - sourceSize.setWidth(isShortX ? shortEdge : longEdge); - sourceSize.setHeight(isShortX ? longEdge : shortEdge); - } - - qint32 offsetX = 0; - qint32 offsetY = 0; - if (source.width() > sourceSize.width()) { - offsetX = (source.width() - sourceSize.width()) / 2; - } - - if (source.height() > sourceSize.height()) { - offsetY = (source.height() - sourceSize.height()) / 2; - } - - QPoint offsetPoint = source.topLeft(); - offsetPoint += QPoint(offsetX, offsetY); - - return QRect(offsetPoint, sourceSize); -} - -static QRect getDestRect(const QRect &destination, const QRect &source) -{ - qreal screenScale = qreal(destination.width()) / qreal(destination.height()); - qreal pixmapScale = qreal(source.width() / source.height()); - qreal width = source.width(); - qreal height = source.height(); - - if (pixmapScale == screenScale) { - return destination; - } - - qreal scaleWidth = destination.width() / width; - qreal scaleHeight = destination.height() / height; - qreal realPixmapWidth = 0; - qreal realPixmapHeight = 0; - - if(pixmapScale < screenScale){ - //图片比例小于屏幕比例时,按照图片和屏幕高度比进行缩放 - realPixmapWidth = width * scaleHeight; - realPixmapHeight = destination.height(); - }else{ - //图片比例大于屏幕比例时,按照图片与屏幕宽度比进行缩放 - realPixmapWidth = destination.width(); - realPixmapHeight = height * scaleWidth; - } - - QSize sourceSize = destination.size(); - qint32 offsetX = 0; - qint32 offsetY = 0; - if (destination.width() == realPixmapWidth) { - offsetY = (destination.height() - realPixmapHeight) / 2; - sourceSize.setHeight(realPixmapHeight); - } else if (destination.height() == realPixmapHeight) { - offsetX = (destination.width() - realPixmapWidth) / 2; - sourceSize.setWidth(realPixmapWidth); - } - - qDebug() << "=========getDestRect sourceSize:" << sourceSize; - QPoint offsetPoint = destination.topLeft(); - offsetPoint += QPoint(offsetX, offsetY); - - return QRect(offsetPoint, sourceSize); -} - -static QRect getSourceRect(const QRect &source, const QRect &screenGeometry, const QRect &screenVirtualGeometry) -{ - qreal pixWidth = source.width(); - qreal pixHeight = source.height(); - - QSize sourceSize = source.size(); - sourceSize.setWidth(screenGeometry.width() / screenVirtualGeometry.width() * pixWidth); - sourceSize.setHeight(screenGeometry.height() / screenVirtualGeometry.height() * pixHeight); - - qint32 offsetX = 0; - qint32 offsetY = 0; - if (screenGeometry.x() > 0) { - offsetX = (screenGeometry.x() / screenVirtualGeometry.width() * pixWidth); - } - - if (screenGeometry.y() > 0) { - offsetY = (screenGeometry.y() / screenVirtualGeometry.height() * pixHeight); - } - - QPoint offsetPoint = source.topLeft(); - offsetPoint += QPoint(offsetX, offsetY); - - return QRect(offsetPoint, sourceSize); -} - -void setRootWindowBackground(bool type,unsigned int color,char *filename, int nOption) -{ - Imlib_Image img; - - if (!dpy){ - dpy = XOpenDisplay(NULL); - if(!dpy) - return; - } - - int width = 0,height = 0; - - width = QApplication::desktop()->geometry().width()*qApp->devicePixelRatio(); - height = QApplication::desktop()->geometry().height()*qApp->devicePixelRatio(); - - if(!scn) - scn = DefaultScreenOfDisplay(dpy); - if(!root) - root = DefaultRootWindow(dpy); - - if (pix != INVAL_ID) { - XFreePixmap(dpy, pix); - pix = INVAL_ID; - } - pix = XCreatePixmap(dpy, root, width, height, - DefaultDepthOfScreen(scn)); - - imlib_context_set_display(dpy); - imlib_context_set_visual(DefaultVisualOfScreen(scn)); - imlib_context_set_colormap(DefaultColormapOfScreen(scn)); - imlib_context_set_drawable(pix); - - if(type == 0){ - img = imlib_load_image(filename); - if (!img) { - fprintf(stderr, "%s:Unable to load image\n", filename); - return ; - } - imlib_context_set_image(img); - - }else if(type == 1){ - img = imlib_create_image(width, height); - imlib_context_set_image(img); - int blue = color & 0xFF; - int green = color >> 8 & 0xFF; - int red = color >> 16 & 0xFF; - - qDebug()<<"red = "<= rect.width()) { - break; - } - } - drawedHeight += newSrcRect.height(); - if (drawedHeight >= rect.height()) { - break; - } - } - } - break; - case WNDBG_OPTION_ZOOM: // 适应 - { - rect = getDestRect(rect, newSrcRect); - qDebug()<<"Zoom:"<screens()){ - if (screen->name() == sscreen->name()) { - QRect srcRect = getSourceRect(newSrcRect, sscreen->geometry(), screen->virtualGeometry()); - imlib_render_image_part_on_drawable_at_size(srcRect.x(), srcRect.y(), - srcRect.width(), srcRect.height(), - rect.x(), rect.y(), - rect.width(),rect.height()); - break; - } - } - } - break; - default: - { - imlib_render_image_part_on_drawable_at_size(newSrcRect.x(), newSrcRect.y(), - newSrcRect.width(), newSrcRect.height(), - rect.x(), rect.y(), - rect.width(),rect.height()); - } - break; - } - } - - imlib_free_image(); -} - -void updateRootWindowBackground() -{ - // 对比新的屏幕尺寸是否有变化 - if (g_lastRootWndInfo.isValid) { - bool isSame = true; - QList listScreen; - for(QScreen *screen : QApplication::screens()){ - //在每个屏幕上绘制背景 - QRect rect = screen->geometry(); - rect.setX(rect.x()*screen->devicePixelRatio()); - rect.setY(rect.y()*screen->devicePixelRatio()); - rect.setWidth(rect.width()*screen->devicePixelRatio()); - rect.setHeight(rect.height()*screen->devicePixelRatio()); - listScreen.append(rect); - } - qDebug()<<"ScreenRects:"< g_lastRootWndInfo.listScreen.size()) { - isSame = false; - } else { - for (int n = 0; n < listScreen.size(); n++) { - if (n < g_lastRootWndInfo.listScreen.size()) { - if (g_lastRootWndInfo.listScreen[n] != listScreen[n]) { - isSame = false; - break; - } - } - } - } - if (!isSame) { - setRootWindowBackground(g_lastRootWndInfo.nType, g_lastRootWndInfo.nColor, - g_lastRootWndInfo.strFileName.toLatin1().data(), g_lastRootWndInfo.nOption); - } - } -} - -void drawBackground(bool isDraw) -{ - if (!dpy) { - return ; - } - if (isDraw) { - if (pix != INVAL_ID) - XSetWindowBackgroundPixmap(dpy, root, pix); - XClearWindow(dpy, root); - } - - while (XPending(dpy)) { - XEvent ev; - XNextEvent(dpy, &ev); - } - if (pix != INVAL_ID) { - XFreePixmap(dpy, pix); - pix = INVAL_ID; - } - XCloseDisplay(dpy); - dpy = NULL; -} - - diff --git a/src/rootWindowBackground.h b/src/rootWindowBackground.h deleted file mode 100644 index 5cd0860..0000000 --- a/src/rootWindowBackground.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ - -typedef enum WNDBG_OPTION_e{ - WNDBG_OPTION_SCALED, // 填充 - WNDBG_OPTION_STRETCHED, // 拉伸 - WNDBG_OPTION_CENTERED, // 居中 - WNDBG_OPTION_WALLPAPER, // 平铺 - WNDBG_OPTION_ZOOM, // 适应 - WNDBG_OPTION_SPANNED // 跨区 -}WNDBG_OPTION; - -void setRootWindowBackground(bool type,unsigned int color,char *filename, int nOption = 0); -void updateRootWindowBackground(); -void drawBackground(bool isDraw); diff --git a/screensaver/CMakeLists.txt b/src/screensaver/CMakeLists.txt similarity index 60% rename from screensaver/CMakeLists.txt rename to src/screensaver/CMakeLists.txt index 99f2b0d..a400ddd 100644 --- a/screensaver/CMakeLists.txt +++ b/src/screensaver/CMakeLists.txt @@ -1,8 +1,6 @@ -pkg_check_modules(KYSDKSYSTIME_PKG kysdk-systime) pkg_check_modules(X11 REQUIRED x11) pkg_check_modules(XTST REQUIRED xtst) pkg_check_modules(QGS REQUIRED gsettings-qt) -pkg_check_modules(KDKINFO REQUIRED kysdk-sysinfo) include_directories(${PROJECT_BINARY_DIR}) include_directories(${PROJECT_SOURCE_DIR}/Common) @@ -11,20 +9,14 @@ include_directories( ${X11_INCLUDE_DIRS} ${XTST_INCLUDE_DIRS} ${QGS_INCLUDE_DIRS} - ${KDKINFO_INCLUDE_DIRS} ) -link_directories( - ${KDKINFO_LIBRARY_DIRS} - ) - set(EXTRA_LIBS ${EXTRA_LIBS} ${X11_LIBRARIES} ${XTST_LIBRARIES} ${QGS_LIBRARIES} - ${KDKINFO_LIBRARIES} - Common + -ldl ) qt5_add_resources(screensaver_SRC default.qrc @@ -37,9 +29,15 @@ qt5_wrap_cpp(screensaver_SRC cyclelabel.h scconfiguration.h sleeptime.h + checkbutton.h + weathermanager.h + networkwatcher.h videoplayer.h - ../src/weathermanager.h - ../src/networkwatcher.h + ../common/global_utils.h + ../common/utils.h + ../lock-dialog/backenddbushelper.h + ../userinfo.h + ../agreementinfo.h ) set(screensaver_SRC ${screensaver_SRC} @@ -50,15 +48,18 @@ set(screensaver_SRC cyclelabel.cpp scconfiguration.cpp sleeptime.cpp + checkbutton.cpp + weathermanager.cpp + networkwatcher.cpp videoplayer.cpp - ../src/weathermanager.cpp - ../src/networkwatcher.cpp + ../common/global_utils.cpp + ../common/utils.cpp + ../lock-dialog/backenddbushelper.cpp + ../userinfo.cpp + ../agreementinfo.cpp ) add_executable(ukui-screensaver-default ${screensaver_SRC}) -target_include_directories(ukui-screensaver-default PRIVATE ${KYSDKSYSTIME_PKG_INCLUDE_DIRS}) -target_link_directories(ukui-screensaver-default PRIVATE ${KYSDKSYSTIME_PKG_LIBRARY_DIRS}) -target_link_libraries(ukui-screensaver-default Qt5::Core Qt5::Widgets Qt5::X11Extras Qt5::Xml Qt5::Network ${KYSDKSYSTIME_PKG_LIBRARIES} Qt5::Multimedia Qt5::MultimediaWidgets avformat avcodec ukui-log4qt ${EXTRA_LIBS}) - +target_link_libraries(ukui-screensaver-default Qt5::Core Qt5::Widgets Qt5::DBus Qt5::X11Extras Qt5::Xml Qt5::Network Qt5::Multimedia Qt5::MultimediaWidgets avformat avcodec ${EXTRA_LIBS}) qt5_add_resources(screensaver_Plugin_SRC default.qrc @@ -71,11 +72,14 @@ qt5_wrap_cpp(screensaver_Plugin_SRC cyclelabel.h scconfiguration.h sleeptime.h - videoplayer.h - ../src/weathermanager.h - ../src/networkwatcher.h + checkbutton.h + weathermanager.h customplugin.h + networkwatcher.h + videoplayer.h screensaverplugin.h + ../common/global_utils.h + ../common/utils.h ) set(screensaver_Plugin_SRC ${screensaver_Plugin_SRC} @@ -85,16 +89,17 @@ set(screensaver_Plugin_SRC cyclelabel.cpp scconfiguration.cpp sleeptime.cpp + checkbutton.cpp + weathermanager.cpp + networkwatcher.cpp videoplayer.cpp - ../src/weathermanager.cpp - ../src/networkwatcher.cpp customplugin.cpp + ../common/global_utils.cpp + ../common/utils.cpp ) add_library(screensaver-default SHARED ${screensaver_Plugin_SRC}) -target_include_directories(screensaver-default PRIVATE ${KYSDKSYSTIME_PKG_INCLUDE_DIRS}) -target_link_directories(screensaver-default PRIVATE ${KYSDKSYSTIME_PKG_LIBRARY_DIRS}) -target_link_libraries(screensaver-default Qt5::Core Qt5::Widgets Qt5::X11Extras Qt5::Xml Qt5::Network ${KYSDKSYSTIME_PKG_LIBRARIES} Qt5::Multimedia Qt5::MultimediaWidgets avformat avcodec ${EXTRA_LIBS}) +target_link_libraries(screensaver-default Qt5::Core Qt5::Widgets Qt5::DBus Qt5::X11Extras Qt5::Xml Qt5::Network Qt5::Multimedia Qt5::MultimediaWidgets avformat avcodec ${EXTRA_LIBS}) qt5_add_resources(Screensaver_SRC default.qrc @@ -107,9 +112,8 @@ qt5_wrap_cpp(Screensaver_SRC cyclelabel.h scconfiguration.h sleeptime.h + weathermanager.h videoplayer.h - ../src/weathermanager.h - ../src/networkwatcher.h ) set(Screensaver_SRC ${screensaver_Plugin_SRC} @@ -119,15 +123,12 @@ set(Screensaver_SRC cyclelabel.cpp scconfiguration.cpp sleeptime.cpp + weathermanager.cpp videoplayer.cpp - ../src/weathermanager.cpp - ../src/networkwatcher.cpp ) add_library(Screensaver STATIC ${Screensaver_SRC}) -target_include_directories(Screensaver PRIVATE ${KYSDKSYSTIME_PKG_INCLUDE_DIRS}) -target_link_directories(Screensaver PRIVATE ${KYSDKSYSTIME_PKG_LIBRARY_DIRS}) -target_link_libraries(Screensaver Qt5::Core Qt5::Widgets Qt5::X11Extras Qt5::Xml Qt5::Network ${KYSDKSYSTIME_PKG_LIBRARIES} Qt5::Multimedia Qt5::MultimediaWidgets avformat avcodec ${EXTRA_LIBS}) +target_link_libraries(Screensaver Qt5::Core Qt5::Widgets Qt5::DBus Qt5::X11Extras Qt5::Xml Qt5::Network Qt5::Multimedia Qt5::MultimediaWidgets avformat avcodec ${EXTRA_LIBS}) install(TARGETS ukui-screensaver-default diff --git a/screensaver/assets/default-intel.qss b/src/screensaver/assets/default-intel.qss similarity index 100% rename from screensaver/assets/default-intel.qss rename to src/screensaver/assets/default-intel.qss diff --git a/screensaver/assets/default.qss b/src/screensaver/assets/default.qss similarity index 100% rename from screensaver/assets/default.qss rename to src/screensaver/assets/default.qss diff --git a/screensaver/assets/download.svg b/src/screensaver/assets/download.svg similarity index 100% rename from screensaver/assets/download.svg rename to src/screensaver/assets/download.svg diff --git a/screensaver/assets/logo-kylin.svg b/src/screensaver/assets/logo-kylin.svg similarity index 100% rename from screensaver/assets/logo-kylin.svg rename to src/screensaver/assets/logo-kylin.svg diff --git a/screensaver/assets/logo.svg b/src/screensaver/assets/logo.svg similarity index 100% rename from screensaver/assets/logo.svg rename to src/screensaver/assets/logo.svg diff --git a/screensaver/assets/message.png b/src/screensaver/assets/message.png similarity index 100% rename from screensaver/assets/message.png rename to src/screensaver/assets/message.png diff --git a/screensaver/assets/next.svg b/src/screensaver/assets/next.svg similarity index 100% rename from screensaver/assets/next.svg rename to src/screensaver/assets/next.svg diff --git a/screensaver/assets/prev.svg b/src/screensaver/assets/prev.svg similarity index 100% rename from screensaver/assets/prev.svg rename to src/screensaver/assets/prev.svg diff --git a/screensaver/assets/setBackground.svg b/src/screensaver/assets/setBackground.svg similarity index 100% rename from screensaver/assets/setBackground.svg rename to src/screensaver/assets/setBackground.svg diff --git a/screensaver/assets/settings.svg b/src/screensaver/assets/settings.svg similarity index 100% rename from screensaver/assets/settings.svg rename to src/screensaver/assets/settings.svg diff --git a/screensaver/assets/wallpaper.svg b/src/screensaver/assets/wallpaper.svg similarity index 100% rename from screensaver/assets/wallpaper.svg rename to src/screensaver/assets/wallpaper.svg diff --git a/screensaver/assets/weather-icon/.DS_Store b/src/screensaver/assets/weather-icon/.DS_Store similarity index 100% rename from screensaver/assets/weather-icon/.DS_Store rename to src/screensaver/assets/weather-icon/.DS_Store diff --git a/screensaver/assets/weather-icon/._.DS_Store b/src/screensaver/assets/weather-icon/._.DS_Store similarity index 100% rename from screensaver/assets/weather-icon/._.DS_Store rename to src/screensaver/assets/weather-icon/._.DS_Store diff --git a/screensaver/assets/weather-icon/._511-中度霾-Moderate haze.svg b/src/screensaver/assets/weather-icon/._511-中度霾-Moderate haze.svg similarity index 100% rename from screensaver/assets/weather-icon/._511-中度霾-Moderate haze.svg rename to src/screensaver/assets/weather-icon/._511-中度霾-Moderate haze.svg diff --git a/screensaver/assets/weather-icon/100.svg b/src/screensaver/assets/weather-icon/100.svg similarity index 100% rename from screensaver/assets/weather-icon/100.svg rename to src/screensaver/assets/weather-icon/100.svg diff --git a/screensaver/assets/weather-icon/101.svg b/src/screensaver/assets/weather-icon/101.svg similarity index 100% rename from screensaver/assets/weather-icon/101.svg rename to src/screensaver/assets/weather-icon/101.svg diff --git a/screensaver/assets/weather-icon/102.svg b/src/screensaver/assets/weather-icon/102.svg similarity index 100% rename from screensaver/assets/weather-icon/102.svg rename to src/screensaver/assets/weather-icon/102.svg diff --git a/screensaver/assets/weather-icon/103.svg b/src/screensaver/assets/weather-icon/103.svg similarity index 100% rename from screensaver/assets/weather-icon/103.svg rename to src/screensaver/assets/weather-icon/103.svg diff --git a/screensaver/assets/weather-icon/104.svg b/src/screensaver/assets/weather-icon/104.svg similarity index 100% rename from screensaver/assets/weather-icon/104.svg rename to src/screensaver/assets/weather-icon/104.svg diff --git a/screensaver/assets/weather-icon/200.svg b/src/screensaver/assets/weather-icon/200.svg similarity index 100% rename from screensaver/assets/weather-icon/200.svg rename to src/screensaver/assets/weather-icon/200.svg diff --git a/screensaver/assets/weather-icon/201.svg b/src/screensaver/assets/weather-icon/201.svg similarity index 100% rename from screensaver/assets/weather-icon/201.svg rename to src/screensaver/assets/weather-icon/201.svg diff --git a/screensaver/assets/weather-icon/202.svg b/src/screensaver/assets/weather-icon/202.svg similarity index 100% rename from screensaver/assets/weather-icon/202.svg rename to src/screensaver/assets/weather-icon/202.svg diff --git a/screensaver/assets/weather-icon/203.svg b/src/screensaver/assets/weather-icon/203.svg similarity index 100% rename from screensaver/assets/weather-icon/203.svg rename to src/screensaver/assets/weather-icon/203.svg diff --git a/screensaver/assets/weather-icon/204.svg b/src/screensaver/assets/weather-icon/204.svg similarity index 100% rename from screensaver/assets/weather-icon/204.svg rename to src/screensaver/assets/weather-icon/204.svg diff --git a/screensaver/assets/weather-icon/205.svg b/src/screensaver/assets/weather-icon/205.svg similarity index 100% rename from screensaver/assets/weather-icon/205.svg rename to src/screensaver/assets/weather-icon/205.svg diff --git a/screensaver/assets/weather-icon/206.svg b/src/screensaver/assets/weather-icon/206.svg similarity index 100% rename from screensaver/assets/weather-icon/206.svg rename to src/screensaver/assets/weather-icon/206.svg diff --git a/screensaver/assets/weather-icon/207.svg b/src/screensaver/assets/weather-icon/207.svg similarity index 100% rename from screensaver/assets/weather-icon/207.svg rename to src/screensaver/assets/weather-icon/207.svg diff --git a/screensaver/assets/weather-icon/208.svg b/src/screensaver/assets/weather-icon/208.svg similarity index 100% rename from screensaver/assets/weather-icon/208.svg rename to src/screensaver/assets/weather-icon/208.svg diff --git a/screensaver/assets/weather-icon/209.svg b/src/screensaver/assets/weather-icon/209.svg similarity index 100% rename from screensaver/assets/weather-icon/209.svg rename to src/screensaver/assets/weather-icon/209.svg diff --git a/screensaver/assets/weather-icon/210.svg b/src/screensaver/assets/weather-icon/210.svg similarity index 100% rename from screensaver/assets/weather-icon/210.svg rename to src/screensaver/assets/weather-icon/210.svg diff --git a/screensaver/assets/weather-icon/211.svg b/src/screensaver/assets/weather-icon/211.svg similarity index 100% rename from screensaver/assets/weather-icon/211.svg rename to src/screensaver/assets/weather-icon/211.svg diff --git a/screensaver/assets/weather-icon/212.svg b/src/screensaver/assets/weather-icon/212.svg similarity index 100% rename from screensaver/assets/weather-icon/212.svg rename to src/screensaver/assets/weather-icon/212.svg diff --git a/screensaver/assets/weather-icon/213.svg b/src/screensaver/assets/weather-icon/213.svg similarity index 100% rename from screensaver/assets/weather-icon/213.svg rename to src/screensaver/assets/weather-icon/213.svg diff --git a/screensaver/assets/weather-icon/300.svg b/src/screensaver/assets/weather-icon/300.svg similarity index 100% rename from screensaver/assets/weather-icon/300.svg rename to src/screensaver/assets/weather-icon/300.svg diff --git a/screensaver/assets/weather-icon/301.svg b/src/screensaver/assets/weather-icon/301.svg similarity index 100% rename from screensaver/assets/weather-icon/301.svg rename to src/screensaver/assets/weather-icon/301.svg diff --git a/screensaver/assets/weather-icon/302.svg b/src/screensaver/assets/weather-icon/302.svg similarity index 100% rename from screensaver/assets/weather-icon/302.svg rename to src/screensaver/assets/weather-icon/302.svg diff --git a/screensaver/assets/weather-icon/303.svg b/src/screensaver/assets/weather-icon/303.svg similarity index 100% rename from screensaver/assets/weather-icon/303.svg rename to src/screensaver/assets/weather-icon/303.svg diff --git a/screensaver/assets/weather-icon/304.svg b/src/screensaver/assets/weather-icon/304.svg similarity index 100% rename from screensaver/assets/weather-icon/304.svg rename to src/screensaver/assets/weather-icon/304.svg diff --git a/screensaver/assets/weather-icon/305.svg b/src/screensaver/assets/weather-icon/305.svg similarity index 100% rename from screensaver/assets/weather-icon/305.svg rename to src/screensaver/assets/weather-icon/305.svg diff --git a/screensaver/assets/weather-icon/306.svg b/src/screensaver/assets/weather-icon/306.svg similarity index 100% rename from screensaver/assets/weather-icon/306.svg rename to src/screensaver/assets/weather-icon/306.svg diff --git a/screensaver/assets/weather-icon/307.svg b/src/screensaver/assets/weather-icon/307.svg similarity index 100% rename from screensaver/assets/weather-icon/307.svg rename to src/screensaver/assets/weather-icon/307.svg diff --git a/screensaver/assets/weather-icon/308.svg b/src/screensaver/assets/weather-icon/308.svg similarity index 100% rename from screensaver/assets/weather-icon/308.svg rename to src/screensaver/assets/weather-icon/308.svg diff --git a/screensaver/assets/weather-icon/309.svg b/src/screensaver/assets/weather-icon/309.svg similarity index 100% rename from screensaver/assets/weather-icon/309.svg rename to src/screensaver/assets/weather-icon/309.svg diff --git a/screensaver/assets/weather-icon/310.svg b/src/screensaver/assets/weather-icon/310.svg similarity index 100% rename from screensaver/assets/weather-icon/310.svg rename to src/screensaver/assets/weather-icon/310.svg diff --git a/screensaver/assets/weather-icon/311.svg b/src/screensaver/assets/weather-icon/311.svg similarity index 100% rename from screensaver/assets/weather-icon/311.svg rename to src/screensaver/assets/weather-icon/311.svg diff --git a/screensaver/assets/weather-icon/312.svg b/src/screensaver/assets/weather-icon/312.svg similarity index 100% rename from screensaver/assets/weather-icon/312.svg rename to src/screensaver/assets/weather-icon/312.svg diff --git a/screensaver/assets/weather-icon/313.svg b/src/screensaver/assets/weather-icon/313.svg similarity index 100% rename from screensaver/assets/weather-icon/313.svg rename to src/screensaver/assets/weather-icon/313.svg diff --git a/screensaver/assets/weather-icon/314.svg b/src/screensaver/assets/weather-icon/314.svg similarity index 100% rename from screensaver/assets/weather-icon/314.svg rename to src/screensaver/assets/weather-icon/314.svg diff --git a/screensaver/assets/weather-icon/315.svg b/src/screensaver/assets/weather-icon/315.svg similarity index 100% rename from screensaver/assets/weather-icon/315.svg rename to src/screensaver/assets/weather-icon/315.svg diff --git a/screensaver/assets/weather-icon/316.svg b/src/screensaver/assets/weather-icon/316.svg similarity index 100% rename from screensaver/assets/weather-icon/316.svg rename to src/screensaver/assets/weather-icon/316.svg diff --git a/screensaver/assets/weather-icon/317.svg b/src/screensaver/assets/weather-icon/317.svg similarity index 100% rename from screensaver/assets/weather-icon/317.svg rename to src/screensaver/assets/weather-icon/317.svg diff --git a/screensaver/assets/weather-icon/318.svg b/src/screensaver/assets/weather-icon/318.svg similarity index 100% rename from screensaver/assets/weather-icon/318.svg rename to src/screensaver/assets/weather-icon/318.svg diff --git a/screensaver/assets/weather-icon/399.svg b/src/screensaver/assets/weather-icon/399.svg similarity index 100% rename from screensaver/assets/weather-icon/399.svg rename to src/screensaver/assets/weather-icon/399.svg diff --git a/screensaver/assets/weather-icon/400.svg b/src/screensaver/assets/weather-icon/400.svg similarity index 100% rename from screensaver/assets/weather-icon/400.svg rename to src/screensaver/assets/weather-icon/400.svg diff --git a/screensaver/assets/weather-icon/401.svg b/src/screensaver/assets/weather-icon/401.svg similarity index 100% rename from screensaver/assets/weather-icon/401.svg rename to src/screensaver/assets/weather-icon/401.svg diff --git a/screensaver/assets/weather-icon/402.svg b/src/screensaver/assets/weather-icon/402.svg similarity index 100% rename from screensaver/assets/weather-icon/402.svg rename to src/screensaver/assets/weather-icon/402.svg diff --git a/screensaver/assets/weather-icon/403.svg b/src/screensaver/assets/weather-icon/403.svg similarity index 100% rename from screensaver/assets/weather-icon/403.svg rename to src/screensaver/assets/weather-icon/403.svg diff --git a/screensaver/assets/weather-icon/404.svg b/src/screensaver/assets/weather-icon/404.svg similarity index 100% rename from screensaver/assets/weather-icon/404.svg rename to src/screensaver/assets/weather-icon/404.svg diff --git a/screensaver/assets/weather-icon/405.svg b/src/screensaver/assets/weather-icon/405.svg similarity index 100% rename from screensaver/assets/weather-icon/405.svg rename to src/screensaver/assets/weather-icon/405.svg diff --git a/screensaver/assets/weather-icon/406.svg b/src/screensaver/assets/weather-icon/406.svg similarity index 100% rename from screensaver/assets/weather-icon/406.svg rename to src/screensaver/assets/weather-icon/406.svg diff --git a/screensaver/assets/weather-icon/407.svg b/src/screensaver/assets/weather-icon/407.svg similarity index 100% rename from screensaver/assets/weather-icon/407.svg rename to src/screensaver/assets/weather-icon/407.svg diff --git a/screensaver/assets/weather-icon/408.svg b/src/screensaver/assets/weather-icon/408.svg similarity index 100% rename from screensaver/assets/weather-icon/408.svg rename to src/screensaver/assets/weather-icon/408.svg diff --git a/screensaver/assets/weather-icon/409.svg b/src/screensaver/assets/weather-icon/409.svg similarity index 100% rename from screensaver/assets/weather-icon/409.svg rename to src/screensaver/assets/weather-icon/409.svg diff --git a/screensaver/assets/weather-icon/410.svg b/src/screensaver/assets/weather-icon/410.svg similarity index 100% rename from screensaver/assets/weather-icon/410.svg rename to src/screensaver/assets/weather-icon/410.svg diff --git a/screensaver/assets/weather-icon/499.svg b/src/screensaver/assets/weather-icon/499.svg similarity index 100% rename from screensaver/assets/weather-icon/499.svg rename to src/screensaver/assets/weather-icon/499.svg diff --git a/screensaver/assets/weather-icon/500.svg b/src/screensaver/assets/weather-icon/500.svg similarity index 100% rename from screensaver/assets/weather-icon/500.svg rename to src/screensaver/assets/weather-icon/500.svg diff --git a/screensaver/assets/weather-icon/501.svg b/src/screensaver/assets/weather-icon/501.svg similarity index 100% rename from screensaver/assets/weather-icon/501.svg rename to src/screensaver/assets/weather-icon/501.svg diff --git a/screensaver/assets/weather-icon/502.svg b/src/screensaver/assets/weather-icon/502.svg similarity index 100% rename from screensaver/assets/weather-icon/502.svg rename to src/screensaver/assets/weather-icon/502.svg diff --git a/screensaver/assets/weather-icon/503.svg b/src/screensaver/assets/weather-icon/503.svg similarity index 100% rename from screensaver/assets/weather-icon/503.svg rename to src/screensaver/assets/weather-icon/503.svg diff --git a/screensaver/assets/weather-icon/504.svg b/src/screensaver/assets/weather-icon/504.svg similarity index 100% rename from screensaver/assets/weather-icon/504.svg rename to src/screensaver/assets/weather-icon/504.svg diff --git a/screensaver/assets/weather-icon/507.svg b/src/screensaver/assets/weather-icon/507.svg similarity index 100% rename from screensaver/assets/weather-icon/507.svg rename to src/screensaver/assets/weather-icon/507.svg diff --git a/screensaver/assets/weather-icon/508.svg b/src/screensaver/assets/weather-icon/508.svg similarity index 100% rename from screensaver/assets/weather-icon/508.svg rename to src/screensaver/assets/weather-icon/508.svg diff --git a/screensaver/assets/weather-icon/509.svg b/src/screensaver/assets/weather-icon/509.svg similarity index 100% rename from screensaver/assets/weather-icon/509.svg rename to src/screensaver/assets/weather-icon/509.svg diff --git a/screensaver/assets/weather-icon/510.svg b/src/screensaver/assets/weather-icon/510.svg similarity index 100% rename from screensaver/assets/weather-icon/510.svg rename to src/screensaver/assets/weather-icon/510.svg diff --git a/screensaver/assets/weather-icon/511.svg b/src/screensaver/assets/weather-icon/511.svg similarity index 100% rename from screensaver/assets/weather-icon/511.svg rename to src/screensaver/assets/weather-icon/511.svg diff --git a/screensaver/assets/weather-icon/512.svg b/src/screensaver/assets/weather-icon/512.svg similarity index 100% rename from screensaver/assets/weather-icon/512.svg rename to src/screensaver/assets/weather-icon/512.svg diff --git a/screensaver/assets/weather-icon/513.svg b/src/screensaver/assets/weather-icon/513.svg similarity index 100% rename from screensaver/assets/weather-icon/513.svg rename to src/screensaver/assets/weather-icon/513.svg diff --git a/screensaver/assets/weather-icon/514.svg b/src/screensaver/assets/weather-icon/514.svg similarity index 100% rename from screensaver/assets/weather-icon/514.svg rename to src/screensaver/assets/weather-icon/514.svg diff --git a/screensaver/assets/weather-icon/515.svg b/src/screensaver/assets/weather-icon/515.svg similarity index 100% rename from screensaver/assets/weather-icon/515.svg rename to src/screensaver/assets/weather-icon/515.svg diff --git a/screensaver/assets/weather-icon/900.svg b/src/screensaver/assets/weather-icon/900.svg similarity index 100% rename from screensaver/assets/weather-icon/900.svg rename to src/screensaver/assets/weather-icon/900.svg diff --git a/screensaver/assets/weather-icon/901.svg b/src/screensaver/assets/weather-icon/901.svg similarity index 100% rename from screensaver/assets/weather-icon/901.svg rename to src/screensaver/assets/weather-icon/901.svg diff --git a/screensaver/assets/weather-icon/999.svg b/src/screensaver/assets/weather-icon/999.svg similarity index 100% rename from screensaver/assets/weather-icon/999.svg rename to src/screensaver/assets/weather-icon/999.svg diff --git a/Common/checkbutton.cpp b/src/screensaver/checkbutton.cpp similarity index 92% rename from Common/checkbutton.cpp rename to src/screensaver/checkbutton.cpp index 9962a15..14ae327 100644 --- a/Common/checkbutton.cpp +++ b/src/screensaver/checkbutton.cpp @@ -1,10 +1,11 @@ -/* +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * * Copyright (C) 2019 Tianjin KYLIN Information Technology Co., Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -12,9 +13,10 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, see . + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * -**/ + */ #include "checkbutton.h" diff --git a/Common/checkbutton.h b/src/screensaver/checkbutton.h similarity index 81% rename from Common/checkbutton.h rename to src/screensaver/checkbutton.h index 59f3463..d6167c9 100644 --- a/Common/checkbutton.h +++ b/src/screensaver/checkbutton.h @@ -1,10 +1,11 @@ -/* +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * * Copyright (C) 2019 Tianjin KYLIN Information Technology Co., Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -12,9 +13,10 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, see . + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * -**/ + */ #ifndef CHECKBUTTON_H #define CHECKBUTTON_H diff --git a/screensaver/chinesedate.cpp b/src/screensaver/chinesedate.cpp similarity index 100% rename from screensaver/chinesedate.cpp rename to src/screensaver/chinesedate.cpp diff --git a/screensaver/chinesedate.h b/src/screensaver/chinesedate.h similarity index 100% rename from screensaver/chinesedate.h rename to src/screensaver/chinesedate.h diff --git a/src/screensaver/customplugin.cpp b/src/screensaver/customplugin.cpp new file mode 100644 index 0000000..afacc06 --- /dev/null +++ b/src/screensaver/customplugin.cpp @@ -0,0 +1,22 @@ +#include "customplugin.h" +#include "screensaver.h" + +CustomPlugin::CustomPlugin(QObject *parent):QObject(parent) +{ + +} + +QString CustomPlugin::name() const +{ + return "screensaver-default"; +} + +QWidget* CustomPlugin::createWidget(bool isScreensaver,QWidget* parent) +{ + return new Screensaver(isScreensaver,parent); +} + +QString CustomPlugin::displayName() const +{ + return "screensaver-default"; +} diff --git a/src/screensaver/customplugin.h b/src/screensaver/customplugin.h new file mode 100644 index 0000000..2d041f7 --- /dev/null +++ b/src/screensaver/customplugin.h @@ -0,0 +1,21 @@ +#ifndef CUSTOMPLUGIN_H +#define CUSTOMPLUGIN_H + +#include "screensaverplugin.h" +#include + +class CustomPlugin : public QObject, ScreensaverPlugin +{ + Q_OBJECT + //声明QT识别的唯一标识符 + Q_PLUGIN_METADATA(IID "org.ukui.screensaver.screensaver-default1.0.0") + //声明实现的插件接口 + Q_INTERFACES(ScreensaverPlugin) +public: + CustomPlugin(QObject* parent = 0); + QString name() const override; + QWidget* createWidget(bool isScreensaver,QWidget* parent) override; + QString displayName() const override; +}; + +#endif // CUSTOMPLUGIN_H diff --git a/screensaver/cyclelabel.cpp b/src/screensaver/cyclelabel.cpp similarity index 87% rename from screensaver/cyclelabel.cpp rename to src/screensaver/cyclelabel.cpp index f6c847a..a97f42f 100644 --- a/screensaver/cyclelabel.cpp +++ b/src/screensaver/cyclelabel.cpp @@ -1,10 +1,11 @@ -/* +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * * Copyright (C) 2019 Tianjin KYLIN Information Technology Co., Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -12,9 +13,10 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, see . + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * -**/ + */ #include "cyclelabel.h" diff --git a/screensaver/cyclelabel.h b/src/screensaver/cyclelabel.h similarity index 79% rename from screensaver/cyclelabel.h rename to src/screensaver/cyclelabel.h index b8b2af6..9967836 100644 --- a/screensaver/cyclelabel.h +++ b/src/screensaver/cyclelabel.h @@ -1,10 +1,11 @@ -/* +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * * Copyright (C) 2019 Tianjin KYLIN Information Technology Co., Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -12,9 +13,10 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, see . + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * -**/ + */ #ifndef CYCLELABEL_H #define CYCLELABEL_H diff --git a/screensaver/default.qrc b/src/screensaver/default.qrc similarity index 100% rename from screensaver/default.qrc rename to src/screensaver/default.qrc diff --git a/screensaver/language/screensaver-bo_CN.ini b/src/screensaver/language/screensaver-bo_CN.ini similarity index 100% rename from screensaver/language/screensaver-bo_CN.ini rename to src/screensaver/language/screensaver-bo_CN.ini diff --git a/screensaver/language/screensaver-en_US.ini b/src/screensaver/language/screensaver-en_US.ini similarity index 100% rename from screensaver/language/screensaver-en_US.ini rename to src/screensaver/language/screensaver-en_US.ini diff --git a/screensaver/language/screensaver-jd.ini b/src/screensaver/language/screensaver-jd.ini similarity index 100% rename from screensaver/language/screensaver-jd.ini rename to src/screensaver/language/screensaver-jd.ini diff --git a/src/screensaver/language/screensaver-zh_CN.ini b/src/screensaver/language/screensaver-zh_CN.ini new file mode 100644 index 0000000..a201d77 --- /dev/null +++ b/src/screensaver/language/screensaver-zh_CN.ini @@ -0,0 +1,95 @@ +[1] +OL=天生我材必有用,千金散尽还复来。 +author=李白《将进酒》 +[2] +OL=莫愁前路无知己,天下谁人不识君。 +author=高适《别董大二首》 +[3] +OL=莫听穿林打叶声,何妨吟啸且徐行。 +author=苏轼《定风波》 +[4] +OL=巧言令色,鲜矣仁! +author=《论语》 +[5] +FL=与君初相识,犹如故人归。 +SL=天涯明月新,朝暮最相思。 +author=杜牧《会友》 +[6] +OL=见贤思齐焉,见不贤而内自省也。 +author=《论语》 +[7] +OL=为政以德,譬如北辰,居其所而众星共之。 +author=《论语》 +[8] +OL=知彼知己,百战不殆。 +author=《孙子兵法》 +[9] +OL=人患不知其过,既知之,不能改,是无勇也。 +author=韩愈《五箴》 +[10] +OL=万物并育而不相害,道并行而不相悖 +author=《礼记·中庸》 +[11] +OL=自信人生二百年,会当水击三千里 +author=毛泽东《七古·残句》 +[12] +OL=青春虚度无所成,白首衔悲亦何及。 +author=权德舆《放歌行》 +[13] +OL=知者行之始。行者知之成。 +author=王阳明《传习录·卷上·门人陆澄录》 +[14] +OL=此心不动,随机而动。 +author=王阳明 +[15] +OL=你未看此花时,此花与汝心同归于寂。 +author=《传习录·卷下·门人黄省曾录》 +[16] +OL=省察是有事时存养,存养是无事时省察。 +author=王阳明《传习录》 +[17] +OL=路漫漫其修远兮,吾将上下而求索。 +author=《离骚》 +[18] +OL=悲莫悲兮生别离,乐莫乐兮新相知。 +author=《九歌·少司命》 +[19] +OL=风飒飒兮木萧萧,思公子兮徒离忧。 +author=《九歌·山鬼》 +[20] +OL=善守者,藏于九地之下,善攻者,动于九天之上。 +author=《孙子兵法》 +[21] +OL=善战者,致人而不致于人。 +author=《孙子兵法·虚实第六》 +[22] +OL=乱生于治,怯生于勇,弱生于强。 +author=《孙子兵法·兵势第五》 +[23] +OL=不战而屈人之兵,善之善者也。 +author=《孙子兵法·谋攻第三》 +[24] +OL=天行健,君子以自强不息。 +author=《周易.乾卦》 +[25] +OL=积善之家,必有余庆;积不善之家,必有余殃。 +author=《周易.坤卦》 +[26] +OL=穷则变,变则通,通则久。 +author=《周易.系辞下》 +[27] +OL=天若有情天亦老,人间正道是沧桑 +author=毛泽东《七律·人民解放军占领南京》 +[28] +OL=仰天大笑出门去,我辈岂是蓬蒿人。 +author=李白《南陵别儿童入京》 +[29] +OL=秋风生渭水,落叶满长安。 +author=贾岛《忆江上吴处士》 +[30] +OL=飞流直下三千尺,疑是银河落九天。 +author=李白《望庐山瀑布》 +[31] +OL=长风破浪会有时,直挂云帆济沧海。 +author=李白《行路难·其一》 + diff --git a/screensaver/main.cpp b/src/screensaver/main.cpp similarity index 97% rename from screensaver/main.cpp rename to src/screensaver/main.cpp index f50c2a7..69f91da 100644 --- a/screensaver/main.cpp +++ b/src/screensaver/main.cpp @@ -31,9 +31,6 @@ #include #include #include -#include - -#include "config.h" #define WORKING_DIRECTORY "/usr/share/ukui-screensaver" bool bControlFlg = false;//是否控制面板窗口 @@ -46,7 +43,6 @@ int main(int argc, char *argv[]) #endif QApplication a(argc, argv); prctl(PR_SET_PDEATHSIG, SIGHUP); - initUkuiLog4qt("ukui-screensaver-default"); //加载翻译文件 QString locale = QLocale::system().name(); QTranslator translator; @@ -82,7 +78,7 @@ int main(int argc, char *argv[]) scale = screen->devicePixelRatio(); if(onWindow){ - windowId = parser.value("window-id"); + windowId = parser.value("window-id"); WId wid = windowId.toULong(); /*获取窗口属性失败时程序退出,这是为了避免应用调用屏保的一瞬间崩溃,导致 diff --git a/screensaver/mbackground.cpp b/src/screensaver/mbackground.cpp similarity index 99% rename from screensaver/mbackground.cpp rename to src/screensaver/mbackground.cpp index a1e6553..e78e158 100644 --- a/screensaver/mbackground.cpp +++ b/src/screensaver/mbackground.cpp @@ -27,8 +27,6 @@ #include #include "mbackground.h" -#include "commonfunc.h" - MBackground::MBackground(): currentIndex(0) { diff --git a/screensaver/mbackground.h b/src/screensaver/mbackground.h similarity index 100% rename from screensaver/mbackground.h rename to src/screensaver/mbackground.h diff --git a/src/networkwatcher.cpp b/src/screensaver/networkwatcher.cpp similarity index 79% rename from src/networkwatcher.cpp rename to src/screensaver/networkwatcher.cpp index 3c57a49..313eabb 100644 --- a/src/networkwatcher.cpp +++ b/src/screensaver/networkwatcher.cpp @@ -1,20 +1,3 @@ -/* - * Copyright (C) 2021 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ #include #include #include diff --git a/src/networkwatcher.h b/src/screensaver/networkwatcher.h similarity index 53% rename from src/networkwatcher.h rename to src/screensaver/networkwatcher.h index a388266..71d3d28 100644 --- a/src/networkwatcher.h +++ b/src/screensaver/networkwatcher.h @@ -1,20 +1,3 @@ -/* - * Copyright (C) 2021 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ #ifndef NETWORKWATCHER_H #define NETWORKWATCHER_H #include diff --git a/src/screensaver/scconfiguration.cpp b/src/screensaver/scconfiguration.cpp new file mode 100644 index 0000000..83abf7d --- /dev/null +++ b/src/screensaver/scconfiguration.cpp @@ -0,0 +1,268 @@ +/* + * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * +**/ +#include "scconfiguration.h" +#include "utils.h" +#include +#include +#include +#include +#include +#include +#include "lock-dialog/backenddbushelper.h" +#include "definetypes.h" + +SCConfiguration* SCConfiguration::instance_ = nullptr; + +SCConfiguration::SCConfiguration(QObject *parent) : + QObject(parent) +{ + QString displayNum = QString(qgetenv("DISPLAY")).replace(":", "").replace(".", "_"); + QString sessionDbus = QString("%1%2").arg(QString(SS_DBUS_SERVICE)).arg(displayNum); + m_helperBackendDbus = new BackendDbusHelper(sessionDbus, SS_DBUS_PATH, QDBusConnection::sessionBus(), this); + if (!m_helperBackendDbus->isValid()) { + delete m_helperBackendDbus; + m_helperBackendDbus = new BackendDbusHelper(SS_DBUS_SERVICE, SS_DBUS_PATH, QDBusConnection::sessionBus(), this); + } + connect(m_helperBackendDbus, &BackendDbusHelper::screenSaverConfChanged, + this, &SCConfiguration::onConfigurationChanged); + connect(m_helperBackendDbus, &BackendDbusHelper::ukccPluginsConfChanged, + this, &SCConfiguration::onConfigurationChanged); + connect(m_helperBackendDbus, &BackendDbusHelper::themeStyleConfChanged, + this, &SCConfiguration::onConfigurationChanged); + connect(m_helperBackendDbus, &BackendDbusHelper::lockScreenConfChanged, + this, &SCConfiguration::onConfigurationChanged); +} + +SCConfiguration* SCConfiguration::instance(QObject *parent) +{ + if(instance_ == nullptr) + instance_ = new SCConfiguration(parent); + return instance_; +} + +void SCConfiguration::onConfigurationChanged(QString key, QVariant value) +{ + if(key == "cycleTime"){ + int cycleTime = value.toInt(); + Q_EMIT cycleTimeChanged(cycleTime); + }else if(key == "automaticSwitchingEnabled"){ + bool changed = value.toBool(); + Q_EMIT autoSwitchChanged(changed); + }else if(key == "backgroundPath"){ + QString path = value.toString(); + Q_EMIT backgroundPathChanged(path); + }else if(key == "mytext"){ + QString text = value.toString(); + Q_EMIT myTextChanged(text); + }else if(key == "showCustomRestTime"){ + bool ret = value.toInt(); + Q_EMIT showCRestTimeChanged(ret); + }else if(key == "showUkuiRestTime"){ + bool ret = value.toInt(); + Q_EMIT showURestTimeChanged(ret); + }else if(key == "textIsCenter"){ + bool ret = value.toBool(); + Q_EMIT textIsCenterChanged(ret); + }else if(key == "showMessageEnabled"){ + bool ret = value.toBool(); + Q_EMIT messageShowEnableChanged(ret); + }else if(key == "messageNumber"){ + int num = value.toInt(); + Q_EMIT messageNumberChanged(num); + }else if(key == "hoursystem"){ + int timeType = value.toInt(); + Q_EMIT timeTypeChanged(timeType); + }else if(key == "type"){ + QString dateType = value.toString(); + Q_EMIT dateTypeChanged(dateType); + }else if(key == "menuTransparency"){ + int blur_Num = value.toInt(); + Q_EMIT blurChanged(blur_Num); + }else if(key == "styleName"){ + QString m_curStyle = value.toString(); + Q_EMIT styleChanged(m_curStyle); + } else if (key == "systemFontSize") { + double m_curFontSize = value.toDouble(); + qDebug() << "curFontSize = " << m_curFontSize ; + Q_EMIT fontSizeChanged(m_curFontSize); + } +} + +QString SCConfiguration::getDefaultBackground() +{ + QString backgroundFile = m_helperBackendDbus->getLockScreenConf(KEY_BACKGROUND).toString(); + if(ispicture(backgroundFile)) + return backgroundFile; + else + return DEFAULT_BACKGROUND_PATH; +} + +int SCConfiguration::getTimeType() +{ + int timeType = 24; + timeType = m_helperBackendDbus->getUkccPluginsConf(KEY_HOUR_SYSTEM).toInt(); + return timeType; +} + +QString SCConfiguration::getDateType() +{ + QString dateType = "cn"; + dateType = m_helperBackendDbus->getUkccPluginsConf(KEY_DATE).toString(); + return dateType; +} + +int SCConfiguration::getFontSize() +{ + double fontSize = 0; + fontSize = m_helperBackendDbus->getThemeStyleConf(KEY_SYSTEM_FONT_SIZE).toDouble(); + double defaultFontSize = getDefaultFontSize(); + qDebug()<<"defaultFontSize = "<logicalDotsPerInch() > 0) + m_ptTopx = 72/(QApplication::primaryScreen()->logicalDotsPerInch()); + return m_ptTopx; +} + +bool SCConfiguration::getAutoSwitch() +{ + bool ret = false; + ret = m_helperBackendDbus->getScreenSaverConf(KEY_AUTOMATIC_SWITCHING_ENABLE).toBool(); + return ret; +} + +bool SCConfiguration::getIsCustom() +{ + bool ret = false; + ret = (m_helperBackendDbus->getLockScreenConf("mode").toString() == "default-ukui-custom"); + + return ret; +} + +bool SCConfiguration::getMessageShowEnable() +{ + bool ret = false; + ret = m_helperBackendDbus->getScreenSaverConf(KEY_SHOW_MESSAGE_ENABLED).toBool(); + + return ret; +} + +int SCConfiguration::getMessageNumber() +{ + bool ret = false; + ret = (m_helperBackendDbus->getLockScreenConf("mode").toString() == "default-ukui-custom"); + + return ret; +} + +bool SCConfiguration::getCShowRestTime() +{ + bool ret = true; + ret = m_helperBackendDbus->getScreenSaverConf(KEY_SHOW_CUSTOM_REST_TIME).toBool(); + return ret; +} + +bool SCConfiguration::getUShowRestTime() +{ + bool ret = true; + ret = m_helperBackendDbus->getScreenSaverConf(KEY_SHOW_UKUI_REST_TIME).toBool(); + return ret; +} + +int SCConfiguration::getCycleTime() +{ + int cycleTime = 300; + cycleTime = m_helperBackendDbus->getScreenSaverConf(KEY_CYCLE_TIME).toInt(); + return cycleTime; +} + +QString SCConfiguration::getBackgroundPath() +{ + QString backgroundPath = "/usr/share/backgrounds"; + backgroundPath = m_helperBackendDbus->getScreenSaverConf(KEY_BACKGROUND_PATH).toString(); + return backgroundPath; +} + +bool SCConfiguration::getTextIsCenter() +{ + bool ret = true; + ret = m_helperBackendDbus->getScreenSaverConf(KEY_TEXT_IS_CENTER).toBool(); + return ret; +} + +QString SCConfiguration::getMyText() +{ + QString myText = ""; + myText = m_helperBackendDbus->getScreenSaverConf("mytext").toString(); + return myText; +} + +int SCConfiguration::getBlurNumber() +{ + int blurNum = 50; + blurNum = m_helperBackendDbus->getUkccPluginsConf("menuTransparency").toInt(); + qDebug()<<"????nm"<getThemeStyleConf("styleName").toString(); + return curStyle; +} + +QString SCConfiguration::getVideoPath() +{ + QString videoPath; + videoPath = m_helperBackendDbus->getScreenSaverConf(KEY_VIDEO_PATH).toString(); + return videoPath; +} + +QString SCConfiguration::getVideoFormat() +{ + QString videoFormat; + videoFormat = m_helperBackendDbus->getScreenSaverConf(KEY_VIDEO_FORMAT).toString(); + return videoFormat; +} + +int SCConfiguration::getVideoSize() +{ + int videoSize; + videoSize = m_helperBackendDbus->getScreenSaverConf(KEY_VIDEO_SIZE).toInt(); + return videoSize; +} + +int SCConfiguration::getVideoWidth() +{ + int videoWidth; + videoWidth = m_helperBackendDbus->getScreenSaverConf(KEY_VIDEO_WIDTH).toInt(); + return videoWidth; +} + +int SCConfiguration::getVideoHeight() +{ + int videoHeight; + videoHeight = m_helperBackendDbus->getScreenSaverConf(KEY_VIDEO_HEIGHT).toInt(); + return videoHeight; +} diff --git a/screensaver/scconfiguration.h b/src/screensaver/scconfiguration.h similarity index 90% rename from screensaver/scconfiguration.h rename to src/screensaver/scconfiguration.h index 390b74d..6f685c2 100644 --- a/screensaver/scconfiguration.h +++ b/src/screensaver/scconfiguration.h @@ -24,9 +24,11 @@ #include -#include +#include +#include class QGSettings; +class BackendDbusHelper; class SCConfiguration : public QObject { @@ -60,7 +62,7 @@ public: public: public Q_SLOTS: - void onConfigurationChanged(QString key); + void onConfigurationChanged(QString key, QVariant value); Q_SIGNALS: void cycleTimeChanged(int cycleTime); @@ -79,15 +81,7 @@ Q_SIGNALS: int fontSizeChanged(int fontSize); private: - void initGsettings(); - void initDefaultSettings(); -private: - QGSettings *mgsettings; - QGSettings *ukgsettings; - QGSettings *udgsettings; - QGSettings *timegsettings; - QGSettings *stygsettings; - QGSettings *vdgsettings; + BackendDbusHelper *m_helperBackendDbus = nullptr; static SCConfiguration *instance_; }; diff --git a/screensaver/screensaver.cpp b/src/screensaver/screensaver.cpp similarity index 71% rename from screensaver/screensaver.cpp rename to src/screensaver/screensaver.cpp index 34f8f20..2682023 100644 --- a/screensaver/screensaver.cpp +++ b/src/screensaver/screensaver.cpp @@ -48,36 +48,23 @@ #include #include #include -#include #include -#include "../src/weathermanager.h" -#include "commonfunc.h" #include "screensaver.h" +#include "weathermanager.h" #include #include #include #include - -#include "commonfunc.h" -#include "config.h" +#include "utils.h" extern "C" { #include "libavformat/avformat.h" #include "libavcodec/avcodec.h" } -#define TIME_TYPE_SCHEMA "org.ukui.control-center.panel.plugins" -#define THEME_TYPE_SCHENA "org.ukui.style" - -#define GSETTINGS_SCHEMA_SCREENSAVER "org.ukui.screensaver" -#define KEY_MESSAGE_NUMBER "message-number" -#define KEY_MESSAGE_SHOW_ENABLED "show-message-enabled" -#define KEY_HOURSYSTEM "hoursystem" -#define KEY_DATE_FORMAT "date" #define WORKING_DIRECTORY "/usr/share/ukui-screensaver" QTime Screensaver::m_currentTime = QTime::currentTime(); -extern bool bControlFlg; Screensaver::Screensaver(bool isscreensaver,QWidget *parent): isScreensaver(isscreensaver), @@ -103,32 +90,24 @@ Screensaver::Screensaver(bool isscreensaver,QWidget *parent): hasChanged(false), process(nullptr), screenLabel(nullptr), - respondClick(false) + respondClick(false), + m_weatherManager(new WeatherManager(this)) { + //加载翻译文件 + QString locale = QLocale::system().name(); + QTranslator translator; + QString qmFile = QString(WORKING_DIRECTORY"/i18n_qm/%1.qm").arg(locale); + translator.load(qmFile); + qApp->installTranslator(&translator); + qDebug() << "load translation file " << qmFile; + installEventFilter(this); // setWindowFlags(Qt::X11BypassWindowManagerHint); setUpdateCenterWidget(); setMouseTracking(true); qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); - isCustom = configuration->getIsCustom(); - if(isCustom){ - cycleTime = configuration->getCycleTime(); - isAutoSwitch = configuration->getAutoSwitch(); - backgroundPath = configuration->getBackgroundPath(); - isCShowRestTime = configuration->getCShowRestTime(); - textIsCenter = configuration->getTextIsCenter(); - myText = configuration->getMyText(); - }else - isUShowRestTime = configuration->getUShowRestTime(); - curFontSize = configuration->getFontSize(); - m_ptToPx = configuration->getPtToPx(); - - videoPath = configuration->getVideoPath(); - videoFormat = configuration->getVideoFormat(); - videoSize = configuration->getVideoSize(); - videoWidth = configuration->getVideoWidth(); - videoHeight = configuration->getVideoHeight(); + getConfiguration(); initUI(); m_background = new MBackground(); @@ -147,19 +126,13 @@ Screensaver::Screensaver(bool isscreensaver,QWidget *parent): connectSingles(); #endif - QGSettings *themeSettings; - if(QGSettings::isSchemaInstalled(TIME_TYPE_SCHEMA)) - themeSettings = new QGSettings(TIME_TYPE_SCHEMA,"",this); - - connect(themeSettings, &QGSettings::changed, - this, &Screensaver::themeChanged); screenLabel = new QLabel(this); screenLabel->setObjectName("screenLabel"); screenLabel->setText(tr("Picture does not exist")); screenLabel->adjustSize(); screenLabel->hide(); - m_strPreViewTrans = tr("View"); + } Screensaver::~Screensaver() @@ -167,32 +140,26 @@ Screensaver::~Screensaver() } -void Screensaver::themeChanged() +void Screensaver::getConfiguration() { - if(myTextLabel){ - QColor highLightColor = palette().color(QPalette::Base); - QString stringColor = QString("rgba(%1,%2,%3,82%)") - .arg(highLightColor.red()) - .arg(highLightColor.green()) - .arg(highLightColor.blue()); - QColor textColor = palette().color(QPalette::Text); - QString textString = QString("rgb(%1,%2,%3)") - .arg(textColor.red()) - .arg(textColor.green()) - .arg(textColor.blue()); - QColor borderColor = palette().color(QPalette::BrightText); - QString borderString = QString("rgba(%1,%2,%3,85%)") - .arg(borderColor.red()) - .arg(borderColor.green()) - .arg(borderColor.blue()); + isCustom = configuration->getIsCustom(); + if(isCustom){ + cycleTime = configuration->getCycleTime(); + isAutoSwitch = configuration->getAutoSwitch(); + backgroundPath = configuration->getBackgroundPath(); + isCShowRestTime = configuration->getCShowRestTime(); + textIsCenter = configuration->getTextIsCenter(); + myText = configuration->getMyText(); + }else + isUShowRestTime = configuration->getUShowRestTime(); + curFontSize = configuration->getFontSize(); + m_ptToPx = configuration->getPtToPx(); - if(width() < 600 || height()<400) - myTextLabel->setStyleSheet(QString("font-size:5px;border-radius: 2px;background: %1;color: %2;padding: 4px 8px 4px 8px;border-width: 1px;border-style: solid;border-color:%3;") \ - .arg(stringColor).arg(textString).arg(borderString)); - else - myTextLabel->setStyleSheet(QString("font-size:24px;border-radius: 6px;background: %1;color: %2;padding: 24px 24px 24px 24px;border-width: 1px;border-style: solid;border-color:%3;") \ - .arg(stringColor).arg(textString).arg(borderString)); - } + m_videoPath = configuration->getVideoPath(); + m_videoFormat = configuration->getVideoFormat(); + m_videoSize = configuration->getVideoSize(); + m_videoWidth = configuration->getVideoWidth(); + m_videoHeight = configuration->getVideoHeight(); } void Screensaver::connectSingles() @@ -211,10 +178,6 @@ void Screensaver::connectSingles() this, &Screensaver::showURestTimeChanged); connect(configuration, &SCConfiguration::textIsCenterChanged, this, &Screensaver::textIsCenterChanged); - connect(configuration, &SCConfiguration::messageNumberChanged, - this, &Screensaver::onMessageNumberChanged); - connect(configuration, &SCConfiguration::messageShowEnableChanged, - this, &Screensaver::onMessageShowEnabledChanged); connect(configuration, &SCConfiguration::timeTypeChanged, this, &Screensaver::onTimeFormatChanged); connect(configuration, &SCConfiguration::dateTypeChanged, @@ -267,18 +230,6 @@ void Screensaver::onFontSizeChanged(int fontSize) curFontSize = fontSize; } -void Screensaver::onMessageNumberChanged(int num) -{ - int number = configuration->getMessageNumber(); - (configuration->getMessageShowEnable() && number > 0) ? showNotice() : hideNotice(); -} - -void Screensaver::onMessageShowEnabledChanged(bool enabled) -{ - int number = configuration->getMessageNumber(); - (configuration->getMessageShowEnable() && number > 0) ? showNotice() : hideNotice(); -} - void Screensaver::autoSwitchChanged(bool isSwitch) { if(!isCustom || m_isDynamicSaver) @@ -489,6 +440,43 @@ void Screensaver::isMovie() } +void Screensaver::getVideoExistence() +{ + qDebug() << "videoPath = " << m_videoPath << "videoSize = " << m_videoSize << "videoFormat = " << m_videoFormat; + + QFileInfo fileInfo(m_videoPath); + //视频文件是否存在 + if (fileInfo.isFile()) { + //视频文件大小限制 + if (fileInfo.size() <= m_videoSize * 1024 * 1024) { + getVideoFormat(m_videoPath); + QStringList formatList = m_videoFormat.split(','); + //视频格式限制 + bool m_rightFormat = false; + for (int formatAt = 0; formatAt < formatList.count(); formatAt++) { + if (cur_video_format.contains(formatList.at(formatAt))) { + m_rightFormat = true; + break; + } + } + if (m_rightFormat) { + //分辨率限制 + if (cur_video_Width <= m_videoWidth && cur_video_Height <= m_videoHeight) { + m_isDynamicSaver = true; + } else { + qInfo() << "High video resolution!!! resolution = " << cur_video_Width << "x" << cur_video_Height; + } + } else { + qInfo() << "The video format is not supported!!! format = " << cur_video_format << "video_Codetype = " << m_videoFormat; + } + } else { + qInfo() << "Video file too large!!!" ; + } + } else { + qInfo() << "The video file does not exist!!!"; + } +} + QPixmap Screensaver::getPaddingPixmap() { if (background.width() == 0 || background.height() == 0) @@ -524,13 +512,13 @@ void Screensaver::addClickedEvent(){ void Screensaver::resizeEvent(QResizeEvent */*event*/) { if (m_isDynamicSaver) { - playerView->setFixedSize(this->size()); - playerItem->setSize(this->size()); + m_playerView->setFixedSize(this->size()); + m_playerItem->setSize(this->size()); return; } float scale = 1.0; scale = (float)width()/1920; - if((width() < 600 || height()<400) && !isScreensaver){//当显示在控制面板上时,字体缩小三倍。 + if(width() < 600 || height()<400){//当显示在控制面板上时,字体缩小三倍。 if(flag == 0) { QList labelList = this->findChildren(); @@ -566,15 +554,8 @@ void Screensaver::resizeEvent(QResizeEvent */*event*/) flag = 1; #ifndef USE_INTEL if(myTextWidget){ - if(curStyle == "ukui-dark" || curStyle == "ukui-black"){ - myTextLabel->setStyleSheet(QString("QLabel{font-size:5px;border-radius: 2px;padding: 4px 8px 4px 8px;border-width: 1px;\ - background: rgba(0, 0, 0, %1); color:#FFFFFF; border-radius:16px}").arg(blur_Num * 0.01)); - cycleLabel->setStyleSheet(QString("QLabel{background: rgba(0, 0, 0, %1); color:#FFFFFF; border-radius:8px}").arg(blur_Num * 0.01)); - } else{ - myTextLabel->setStyleSheet(QString("QLabel{font-size:5px;border-radius: 2px;padding: 4px 8px 4px 8px;border-width: 1px;\ - background: rgba(255, 255, 255, %1);}").arg(blur_Num * 0.01)); - cycleLabel->setStyleSheet(QString("QLabel{background: rgba(255, 255, 255, %1); border-radius:8px}").arg(blur_Num * 0.01)); - } + onBlurNumChanged(blur_Num); + onStyleChanged(curStyle); cycleLabel->setFixedSize(5, 5); } if(screenLabel) @@ -792,94 +773,6 @@ void Screensaver::stopSwitchImages() switchTimer->stop(); } -void Screensaver::onBackgroundChanged() -{ - opacity = 1.0; - fadeTimer = new QTimer(this); - connect(fadeTimer, &QTimer::timeout, this, [&]{ - opacity -= 0.1; - if(opacity <= 0) - fadeTimer->stop(); - else - repaint(); - - }); - fadeTimer->start(50); -} -void Screensaver::updateCenterWidget(int index) -{ - if(!centerWidget ) - return ; - - QStringList qlist = qsettings->childGroups(); - if(qlist.count()<1) - return; - - if(index<=1){ - index = qrand() % qlist.count() + 1; - } - qsettings->beginGroup(QString::number(index)); - if(qsettings->contains("OL")){ - if(qsettings->value("OL").typeName() == "QString") - centerlabel1->setText(qsettings->value("OL").toString()); - else - centerlabel1->setText(qsettings->value("OL").toStringList().join(' ')); - centerlabel2->hide(); -#ifndef USE_INTEL - authorlabel->setText(qsettings->value("author").toString()); -#endif - } - else if(qsettings->contains("FL")) - { - if(qsettings->value("FL").typeName() == "QString") - centerlabel2->setText(qsettings->value("FL").toString()); - else - centerlabel2->setText(qsettings->value("FL").toStringList().join(' ')); - if(qsettings->value("SL").typeName() == "QString") - centerlabel2->setText(qsettings->value("SL").toString()); - else - centerlabel2->setText(qsettings->value("SL").toStringList().join(' ')); - centerlabel2->show(); -#ifndef USE_INTEL - authorlabel->setText(qsettings->value("author").toString()); -#endif - } - -#ifdef USE_INTEL - if(qsettings->contains("author") && !qsettings->value("author").toString().isEmpty()) - { - authorlabel->setText(qsettings->value("author").toString()); - authorlabel->show(); - } - else - { - authorlabel->setText(""); - authorlabel->hide(); - } -#endif - - centerWidget->adjustSize(); - -#ifdef USE_INTEL - centerWidget->setGeometry((width()-centerWidget->width())/2,(height() * 85) / 100 - (centerWidget->height())/2, - centerWidget->width(),centerWidget->height()); - - if((height()-centerWidget->height())/2 < timeLayout->y() + timeLayout->height()) - centerWidget->setGeometry((width()-centerWidget->width())/2,timeLayout->y() + timeLayout->height(), - centerWidget->width(),centerWidget->height()); - -#else - centerWidget->setGeometry((width()-centerWidget->width())/2,(height()-centerWidget->height())/2, - centerWidget->width(),centerWidget->height()); - - if((height()-centerWidget->height())/2 < timeLayout->y() + timeLayout->height()) - centerWidget->setGeometry((width()-centerWidget->width())/2,timeLayout->y() + timeLayout->height(), - centerWidget->width(),centerWidget->height()); -#endif - qsettings->endGroup(); - -} - void Screensaver::initUI() { QFile qssFile; @@ -904,70 +797,38 @@ void Screensaver::initUI() connect(m_weatherManager, &WeatherManager::onWeatherUpdate, this, &Screensaver::getWeatherFinish); #else - qDebug() << "videoPath = " << videoPath << "videoSize = " << videoSize << "videoFormat = " << videoFormat; - - QFileInfo fileInfo(videoPath); - //视频文件是否存在 - if (fileInfo.isFile()) { - //视频文件大小限制 - if (fileInfo.size() <= videoSize * 1024 * 1024) { - getVideoFormat(videoPath); - QStringList formatList = videoFormat.split(','); - //视频格式限制 - bool m_rightFormat = false; - for (int formatAt = 0; formatAt < formatList.count(); formatAt++) { - if (cur_video_format.contains(formatList.at(formatAt))) { - m_rightFormat = true; - break; - } - } - if (m_rightFormat) { - //分辨率限制 - if (cur_video_Width <= videoWidth && cur_video_Height <= videoHeight) { - m_isDynamicSaver = true; - } else { - qInfo() << "High video resolution!!! resolution = " << cur_video_Width << "x" << cur_video_Height; - } - } else { - qInfo() << "The video format is not supported!!! format = " << cur_video_format << "video_Codetype = " << video_Codetype; - } - } else { - qInfo() << "Video file too large!!!" ; - } - } else { - qInfo() << "The video file does not exist!!!"; - } + getVideoExistence(); if (m_isDynamicSaver) { - m_pVideoPlayer = new VideoPlayer(); - playerScene = new QGraphicsScene(this); - playerView = new QGraphicsView(this); - playerView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - playerView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - playerView->setStyleSheet("border: none; border-radius: 0px;"); - playerItem = new QGraphicsVideoItem; - playerScene->addItem(playerItem); - m_pVideoPlayer->setMediaFile(videoPath); - playerView->setScene(playerScene); - m_pVideoPlayer->setOutput(playerItem, video_Duration); - playerView->show(); - } else { - if (isCustom) - setSleeptime(isCShowRestTime); - else - setSleeptime(isUShowRestTime); - setDatelayout(); - setCenterWidget(); - setRandomText(); - if(centerWidget) { - if (textIsCenter || myText == "") { - myTextWidget->hide(); - centerWidget->show(); - }else{ - centerWidget->hide(); - myTextWidget->show(); + m_pVideoPlayer = new VideoPlayer(); + m_playerScene = new QGraphicsScene(this); + m_playerView = new QGraphicsView(this); + m_playerView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + m_playerView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + m_playerView->setStyleSheet("border: none; border-radius: 0px;"); + m_playerItem = new QGraphicsVideoItem; + m_playerScene->addItem(m_playerItem); + m_pVideoPlayer->setMediaFile(m_videoPath); + m_playerView->setScene(m_playerScene); + m_pVideoPlayer->setOutput(m_playerItem, video_Duration); + m_playerView->show(); + } else { + if (isCustom) + setSleeptime(isCShowRestTime); + else + setSleeptime(isUShowRestTime); + setDatelayout(); + setCenterWidget(); + setRandomText(); + if(centerWidget) { + if (textIsCenter || myText == "") { + myTextWidget->hide(); + centerWidget->show(); + }else{ + centerWidget->hide(); + myTextWidget->show(); + } } } - } #endif } @@ -1048,12 +909,12 @@ void Screensaver::setDatelayout() this->dateOfLocaltime = new QLabel(this); sysFont= qApp->font(); - sysFont.setPointSize((36 + curFontSize) *m_ptToPx); + sysFont.setPointSize((58 + curFontSize) *m_ptToPx); this->dateOfLocaltime->setFont(sysFont); if(timeType == 12) - this->dateOfLocaltime->setText(getLongFormatDate(TIME)); + this->dateOfLocaltime->setText(QDateTime::currentDateTime().toString("A hh:mm")); else - this->dateOfLocaltime->setText(getLongFormatDate(TIME)); + this->dateOfLocaltime->setText(QDateTime::currentDateTime().toString("hh:mm")); this->dateOfLocaltime->setObjectName("dateOfLocaltime"); this->dateOfLocaltime->setAlignment(Qt::AlignCenter); @@ -1061,13 +922,12 @@ void Screensaver::setDatelayout() vtimeLayout->addWidget(dateOfLocaltime); this->dateOfDay = new QLabel(this); - sysFont.setPointSize((18 + curFontSize) *m_ptToPx); + sysFont.setPointSize((16 + curFontSize) *m_ptToPx); this->dateOfDay->setFont(sysFont); -// if(dateType == "cn") -// this->dateOfDay->setText(QDate::currentDate().toString("yyyy/MM/dd ddd").replace("周","星期")); -// else -// this->dateOfDay->setText(QDate::currentDate().toString("yyyy-MM-dd ddd").replace("周","星期")); - this->dateOfDay->setText(getLongFormatDate(DATE)); + if(dateType == "cn") + this->dateOfDay->setText(QDate::currentDate().toString("yyyy/MM/dd ddd").replace("周","星期")); + else + this->dateOfDay->setText(QDate::currentDate().toString("yyyy-MM-dd ddd").replace("周","星期")); this->dateOfDay->setObjectName("dateOfDay"); this->dateOfDay->setAlignment(Qt::AlignCenter); this->dateOfDay->adjustSize(); @@ -1176,15 +1036,14 @@ void Screensaver::updateTime() QDateTime curDateTime = QDateTime::currentDateTime(); if (m_lastDateTime.isNull() || qAbs(curDateTime.secsTo(m_lastDateTime)) >=1) { if(timeType == 12) - this->dateOfLocaltime->setText(getLongFormatDate(TIME)); + this->dateOfLocaltime->setText(curDateTime.toString("A hh:mm")); else - this->dateOfLocaltime->setText(getLongFormatDate(TIME)); + this->dateOfLocaltime->setText(curDateTime.toString("hh:mm")); -// if(dateType == "cn") -// this->dateOfDay->setText(curDateTime.date().toString("yyyy/MM/dd ddd").replace("周","星期")); -// else -// this->dateOfDay->setText(curDateTime.date().toString("yyyy-MM-dd ddd").replace("周","星期")); - this->dateOfDay->setText(getLongFormatDate(DATE)); + if(dateType == "cn") + this->dateOfDay->setText(curDateTime.date().toString("yyyy/MM/dd ddd").replace("周","星期")); + else + this->dateOfDay->setText(curDateTime.date().toString("yyyy-MM-dd ddd").replace("周","星期")); m_lastDateTime = curDateTime; } @@ -1198,22 +1057,6 @@ void Screensaver::updateTime() #endif } -void Screensaver::setUpdateBackground() -{ - -} - -void Screensaver::updateBackground() -{ - QString path = m_background->getRand(); - if(!path.isEmpty() && ispicture(path)){ - background = loadFromFile(path); - hasChanged=true; - isMovie(); - } - // updateCenterWidget(-1); -} - void Screensaver::setRandomText() { if(!myTextWidget){ @@ -1225,36 +1068,10 @@ void Screensaver::setRandomText() layout->setSpacing(8); myTextLabel = new QLabel(myTextWidget); myTextLabel->setObjectName("myText"); -// myTextLabel->setBackgroundRole(QPalette::Base); -// myTextLabel->setAutoFillBackground(true); -// myTextLabel->setMaximumWidth(800); -// QColor highLightColor = palette().color(QPalette::Base); -// QString stringColor = QString("rgba(%1,%2,%3,82%)") -// .arg(highLightColor.red()) -// .arg(highLightColor.green()) -// .arg(highLightColor.blue()); -// QColor textColor = palette().color(QPalette::Text); -// QString textString = QString("rgb(%1,%2,%3)") -// .arg(textColor.red()) -// .arg(textColor.green()) -// .arg(textColor.blue()); -// QColor borderColor = palette().color(QPalette::BrightText); -// QString borderString = QString("rgba(%1,%2,%3,85%)") -// .arg(borderColor.red()) -// .arg(borderColor.green()) -// .arg(borderColor.blue()); -// myTextLabel->setStyleSheet(QString("font-size:18px;border-radius: 6px;background: %1;color: %2;padding: 24px 48px 24px 48px;border-width: 1px;border-style: solid;border-color:%3;") \ -// .arg(stringColor).arg(textString).arg(borderString)); blur_Num = configuration->getBlurNumber(); curStyle = configuration->getcurStyle(); - qDebug()<<"curStyle= "<setStyleSheet(QString("QLabel{background: rgba(0, 0, 0, %1); color:#FFFFFF; border-radius:16px}").arg(blur_Num * 0.01)); - cycleLabel->setStyleSheet(QString("QLabel{background: rgba(0, 0, 0, %1); color:#FFFFFF; border-radius:8px}").arg(blur_Num * 0.01)); - } else{ - myTextLabel->setStyleSheet(QString("QLabel{background: rgba(255, 255, 255, %1); border-radius:16px}").arg(blur_Num * 0.01)); - cycleLabel->setStyleSheet(QString("QLabel{background: rgba(255, 255, 255, %1); border-radius:8px}").arg(blur_Num * 0.01)); - } + onBlurNumChanged(blur_Num); + onStyleChanged(curStyle); layout->addWidget(myTextLabel); } sysFont.setPointSize((18 + curFontSize) *m_ptToPx); @@ -1281,7 +1098,7 @@ void Screensaver::setPreviewText(bool bVisible) myPreviewLabel->setAlignment(Qt::AlignCenter); } - myPreviewLabel->setText(m_strPreViewTrans); + myPreviewLabel->setText(tr("View")); myPreviewLabel->adjustSize(); myPreviewLabel->setVisible(bVisible); @@ -1308,14 +1125,13 @@ void Screensaver::setCenterWidget() index = 1; qsettings->beginGroup(QString::number(index)); - if(isCustom){ + if (isCustom) { centerlabel1 = new QLabel(myText); centerlabel2 = new QLabel(""); centerlabel2->hide(); authorlabel = new QLabel(""); - } - else if(qsettings->contains("OL")){ - if(qsettings->value("OL").typeName() == "QString") + } else if (qsettings->contains("OL")) { + if (qsettings->value("OL").typeName() == "QString") centerlabel1 = new QLabel(qsettings->value("OL").toString()); else centerlabel1 = new QLabel(qsettings->value("OL").toStringList().join(' ')); @@ -1324,14 +1140,12 @@ void Screensaver::setCenterWidget() #ifndef USE_INTEL authorlabel = new QLabel(qsettings->value("author").toString()); #endif - } - else if(qsettings->contains("FL")) - { - if(qsettings->value("FL").typeName() == "QString") + } else if (qsettings->contains("FL")) { + if (qsettings->value("FL").typeName() == "QString") centerlabel1 = new QLabel(qsettings->value("FL").toString()); else centerlabel1 = new QLabel(qsettings->value("FL").toStringList().join(' ')); - if(qsettings->value("SL").typeName() == "QString") + if (qsettings->value("SL").typeName() == "QString") centerlabel2 = new QLabel(qsettings->value("SL").toString()); else centerlabel2 = new QLabel(qsettings->value("SL").toStringList().join(' ')); @@ -1439,38 +1253,6 @@ void Screensaver::getWeatherFinish(QString city, QString cond, QString tmp) m_weatherLaout->geometry().width(), m_weatherLaout->geometry().height()); } -void Screensaver::setNoticeLaout() -{ - m_widgetNotice = new QWidget(this); - QHBoxLayout *hNoticeLayout = new QHBoxLayout(m_widgetNotice); - hNoticeLayout->setContentsMargins(0, 0, 0, 0); - m_labelNoticeIcon = new QLabel(this); - m_labelNoticeMessage = new QLabel(this); - m_labelNoticeMessage->setStyleSheet("font-size:16px;color:#ffffff"); - - m_labelNoticeIcon->setPixmap(QPixmap(":/assets/message.png")); - - m_labelNoticeMessage->setText(tr("You have new notification")); - - int num = configuration->getMessageNumber(); - (configuration->getMessageShowEnable() && num > 0)? showNotice() : hideNotice(); - - hNoticeLayout->addWidget(m_labelNoticeIcon); - hNoticeLayout->addWidget(m_labelNoticeMessage); - m_widgetNotice->adjustSize(); -} - -//显示新消息通知 -void Screensaver::showNotice() -{ - m_widgetNotice->show(); -} - -void Screensaver::hideNotice() -{ - m_widgetNotice->hide(); -} - QPixmap Screensaver::loadFromFile(QString strPath) { QImageReader reader; @@ -1516,78 +1298,10 @@ void Screensaver::getVideoFormat(QString fileName) //获取视频的分辨率 cur_video_Width = (avctx->width >= avctx->height ? avctx->width : avctx->height); cur_video_Height = (avctx->width >= avctx->height ? avctx->height : avctx->width); - + qDebug() << "video_Codetype = " << video_Codetype; avcodec_free_context(&avctx); //关闭上下文 avformat_close_input(&fmt_ctx); return ; } - -QString Screensaver::getLongFormatDate(int type) -{ - kdk_logn_dateinfo *dateInfo = kdk_system_login_lock_dateinfo(getenv("USER")); - if (type == DATE) { - QString date = dateInfo->date; - QString week = dateInfo->week; - if (dateInfo) { - kdk_free_logn_dateinfo(dateInfo); - } - return date + " " + week; - } else if (type == TIME) { - QString time = dateInfo->time; - if (dateInfo) { - kdk_free_logn_dateinfo(dateInfo); - } - return time; - } -} - -/* -void Screensaver::setDesktopBackground() -{ - vboxFrame->hide(); - QString mBackground; - - if(!hasChanged){ - mBackground=defaultBackground; - }else{ - if(m_background->getCurrent().isEmpty()) - return; - mBackground=m_background->getCurrent(); - } - - settings->set("picture-filename",QVariant(mBackground)); - - QDBusInterface * interface = new QDBusInterface("org.freedesktop.Accounts", - "/org/freedesktop/Accounts", - "org.freedesktop.Accounts", - QDBusConnection::systemBus()); - - if (!interface->isValid()){ - return; - } - - QDBusReply reply = interface->call("FindUserByName", getenv("USER")); - QString userPath; - if (reply.isValid()){ - userPath = reply.value().path(); - } - else { - return; - } - - QDBusInterface * useriFace = new QDBusInterface("org.freedesktop.Accounts", - userPath, - "org.freedesktop.Accounts.User", - QDBusConnection::systemBus()); - - if (!useriFace->isValid()){ - return; - } - - QDBusMessage msg = useriFace->call("SetBackgroundFile", mBackground); - if (!msg.errorMessage().isEmpty()) - qDebug() << "update user background file error: " << msg.errorMessage(); - -}*/ diff --git a/screensaver/screensaver.h b/src/screensaver/screensaver.h similarity index 89% rename from screensaver/screensaver.h rename to src/screensaver/screensaver.h index 74acd2b..c31535e 100644 --- a/screensaver/screensaver.h +++ b/src/screensaver/screensaver.h @@ -30,7 +30,6 @@ #include #include #include -#include #include "sleeptime.h" #include "chinesedate.h" @@ -42,11 +41,6 @@ class WeatherManager; -enum dateinfo { - DATE, - TIME, -}; - class Screensaver : public QWidget { Q_OBJECT @@ -60,18 +54,16 @@ private: void initUI(); void setDatelayout(); void setWeatherLayout(); - void setNoticeLaout(); void setSleeptime(bool Isshow); void setCenterWidget(); void updateDate(); - void setUpdateBackground(); void setUpdateCenterWidget(); void startSwitchImages(); void stopSwitchImages(); - void onBackgroundChanged(); void setRandomText(); void setPreviewText(bool bVisible);//设置预览样式 void setRandomPos(); + void getConfiguration(); void connectSingles(); void updateBackgroundPath(); void enterEvent(QEvent*); @@ -80,6 +72,12 @@ private: QPixmap loadFromFile(QString strPath); void getVideoFormat(QString fileName);//获取视频格式(视频格式、编码格式、分辨率) QString getLongFormatDate(int type); + /** + * @brief 获取动态屏保视频是否存在 + * @param + * @return + */ + void getVideoExistence(); QTimer *switchTimer; QTimer *fadeTimer; @@ -97,8 +95,6 @@ private: QLabel *cycleLabel; SCConfiguration *configuration; - void showNotice(); - void hideNotice(); QWidget *myTextWidget; QLabel *dateOfLocaltime; @@ -149,7 +145,7 @@ private: double m_ptToPx = 1.0; QFont sysFont; - WeatherManager *m_weatherManager=nullptr; + WeatherManager *m_weatherManager; QWidget *m_weatherLaout; QLabel *m_weatherIcon; QLabel *m_weatherArea; @@ -169,24 +165,24 @@ private: int currentCount = 0; QDateTime m_lastDateTime; bool isScreensaver = false; - QString m_strPreViewTrans; //动态屏保 bool m_isDynamicSaver = false; VideoPlayer *m_pVideoPlayer; - QGraphicsScene *playerScene; - QGraphicsView *playerView; - QGraphicsVideoItem *playerItem; + QGraphicsScene *m_playerScene; + QGraphicsView *m_playerView; + QGraphicsVideoItem *m_playerItem; int video_Duration = 0; QString cur_video_format; QString video_Codetype; int cur_video_Width; int cur_video_Height; - QString videoPath; - QString videoFormat; - int videoSize; - int videoWidth; - int videoHeight; + QString m_videoPath; + QString m_videoFormat; + int m_videoSize; + int m_videoWidth; + int m_videoHeight; + protected: void paintEvent(QPaintEvent *event); void resizeEvent(QResizeEvent *event); @@ -194,8 +190,6 @@ protected: private Q_SLOTS: void updateTime(); - void updateBackground(); - void updateCenterWidget(int index); void autoSwitchChanged(bool iswitch); void backgroundPathChanged(QString path); void cycleTimeChanged(int cTime); @@ -203,10 +197,7 @@ private Q_SLOTS: void showCRestTimeChanged(bool isShow); void showURestTimeChanged(bool isShow); void textIsCenterChanged(bool isCenter); - void themeChanged(); void getWeatherFinish(QString city, QString cond, QString tmp); - void onMessageNumberChanged(int num); - void onMessageShowEnabledChanged(bool enabled); void onTimeFormatChanged(int type); void onDateFormatChanged(QString type); void onBlurNumChanged(int num); diff --git a/screensaver/screensaverplugin.h b/src/screensaver/screensaverplugin.h similarity index 53% rename from screensaver/screensaverplugin.h rename to src/screensaver/screensaverplugin.h index 4fcd9ff..041bf38 100644 --- a/screensaver/screensaverplugin.h +++ b/src/screensaver/screensaverplugin.h @@ -1,21 +1,4 @@ -/* - * Copyright (C) 2022 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#ifndef SCREENSAVER_PLUGIN_H +#ifndef SCREENSAVER_PLUGIN_H #define SCREENSAVER_PLUGIN_H #include diff --git a/screensaver/sleeptime.cpp b/src/screensaver/sleeptime.cpp similarity index 100% rename from screensaver/sleeptime.cpp rename to src/screensaver/sleeptime.cpp diff --git a/screensaver/sleeptime.h b/src/screensaver/sleeptime.h similarity index 100% rename from screensaver/sleeptime.h rename to src/screensaver/sleeptime.h diff --git a/screensaver/videoplayer.cpp b/src/screensaver/videoplayer.cpp similarity index 67% rename from screensaver/videoplayer.cpp rename to src/screensaver/videoplayer.cpp index 33a1c8e..c292d33 100644 --- a/screensaver/videoplayer.cpp +++ b/src/screensaver/videoplayer.cpp @@ -2,29 +2,27 @@ #include #include - - VideoPlayer::VideoPlayer(QWidget *parent) : QWidget(parent) { - player = new QMediaPlayer(this); - connect(player, &QMediaPlayer::positionChanged, + m_player = new QMediaPlayer(this); + connect(m_player, &QMediaPlayer::positionChanged, this, &VideoPlayer::updatePosition); - connect(player, &QMediaPlayer::mediaStatusChanged, + connect(m_player, &QMediaPlayer::mediaStatusChanged, this, &VideoPlayer::mediaStatusChanged); - connect(player, static_cast + connect(m_player, static_cast (&QMediaPlayer::error), this, &VideoPlayer::showError); } VideoPlayer::~VideoPlayer() { - if(player != nullptr) + if(m_player != nullptr) { - player->stop(); - player->deleteLater(); - player = nullptr; + m_player->stop(); + m_player->deleteLater(); + m_player = nullptr; } } @@ -32,35 +30,35 @@ VideoPlayer::~VideoPlayer() void VideoPlayer::setOutput(QGraphicsVideoItem *videoWidget, int duration) { video_Duration = duration; - player->setVideoOutput(videoWidget); - player->setMuted(true); //视频静音 - player->setPosition(1); //避免首次打开视频是黑屏 - player->play(); + m_player->setVideoOutput(videoWidget); + m_player->setMuted(true); //视频静音 + m_player->setPosition(1); //避免首次打开视频是黑屏 + m_player->play(); } void VideoPlayer::setMediaFile(QString filePath) { m_filePath = filePath; - player->setMedia(QMediaContent(QUrl::fromLocalFile(filePath))); + m_player->setMedia(QMediaContent(QUrl::fromLocalFile(filePath))); } void VideoPlayer::updatePosition(qint64 position) { //因为用wps制作的视频用qmediaplayer去获取视频时长有问题,会在视频最后一帧停留很长时间,所以用ffmpeg获取视频时长,手动循环播放视频 - qDebug() << "position =" << position << "player->duration() = " << player->duration() << "duration = " << video_Duration; - if (video_Duration || player->duration()) { - if (position && position > (video_Duration > 0 ? video_Duration : player->duration())) { - player->setMedia(QMediaContent(QUrl::fromLocalFile(m_filePath))); - player->setPosition(1); - player->play(); - } else if (position == 0 && player->duration()) { //有些wps做的视频播放到最后一帧会自己跳到0 - player->setMedia(QMediaContent(QUrl::fromLocalFile(m_filePath))); - player->setPosition(1); - player->play(); + qDebug() << "position =" << position << "player->duration() = " << m_player->duration() << "duration = " << video_Duration; + if (video_Duration || m_player->duration()) { + if (position && position > (video_Duration > 0 ? video_Duration : m_player->duration())) { + m_player->setMedia(QMediaContent(QUrl::fromLocalFile(m_filePath))); + m_player->setPosition(1); + m_player->play(); + } else if (position == 0 && m_player->duration()) { //有些wps做的视频播放到最后一帧会自己跳到0 + m_player->setMedia(QMediaContent(QUrl::fromLocalFile(m_filePath))); + m_player->setPosition(1); + m_player->play(); } else if (position && position == video_Duration) {//视频当前播放帧数 = 视频总时长 - player->setMedia(QMediaContent(QUrl::fromLocalFile(m_filePath))); - player->setPosition(1); - player->play(); + m_player->setMedia(QMediaContent(QUrl::fromLocalFile(m_filePath))); + m_player->setPosition(1); + m_player->play(); } } } @@ -88,8 +86,6 @@ void VideoPlayer::mediaStatusChanged(QMediaPlayer::MediaStatus status) break; case QMediaPlayer::EndOfMedia: qDebug() << "EndOfMedia!!!" ; -// player->setPosition(0); -// player->play(); break; case QMediaPlayer::LoadedMedia: qDebug() << "LoadedMedia!!!" ; diff --git a/screensaver/videoplayer.h b/src/screensaver/videoplayer.h similarity index 91% rename from screensaver/videoplayer.h rename to src/screensaver/videoplayer.h index acf07b1..a4958b1 100644 --- a/screensaver/videoplayer.h +++ b/src/screensaver/videoplayer.h @@ -16,18 +16,16 @@ public: void setOutput(QGraphicsVideoItem *videoWidget, int duration); void setMediaFile(QString filePath); -private: - QMediaPlayer *player; - int video_Duration = 0; - QString m_filePath; - private slots: void updatePosition(qint64 position); void mediaStatusChanged(QMediaPlayer::MediaStatus status); void showError(QMediaPlayer::Error error); + private: - int playerFlag = 0; + QMediaPlayer *m_player; + int video_Duration = 0; + QString m_filePath; }; #endif // VIDEOPLAYER_H diff --git a/screensaver/weathermanager.cpp b/src/screensaver/weathermanager.cpp similarity index 100% rename from screensaver/weathermanager.cpp rename to src/screensaver/weathermanager.cpp diff --git a/src/weathermanager.h b/src/screensaver/weathermanager.h similarity index 98% rename from src/weathermanager.h rename to src/screensaver/weathermanager.h index 3f29c40..2cc6332 100644 --- a/src/weathermanager.h +++ b/src/screensaver/weathermanager.h @@ -24,7 +24,7 @@ #include #include -#include "../src/networkwatcher.h" +#include "networkwatcher.h" class QNetworkAccessManager; class QNetworkReply; diff --git a/src/servicemanager.cpp b/src/servicemanager.cpp deleted file mode 100644 index 427678e..0000000 --- a/src/servicemanager.cpp +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ - -#include "servicemanager.h" -#include -#include - -#define SERVICE "biometric-authentication.service" -#define DBUS_SERVICE "org.ukui.Biometric" -#define DBUS_PATH "/org/ukui/Biometric" -#define DBUS_INTERFACE "org.ukui.Biometric" - -#define FD_DBUS_SERVICE "org.freedesktop.DBus" -#define FD_DBUS_PATH "/org/freedesktop/DBus" -#define FD_DBUS_INTERFACE "org.freedesktop.DBus" - -ServiceManager *ServiceManager::instance_ = nullptr; - -ServiceManager::ServiceManager(QObject *parent) - : QObject(parent), - dbusService(nullptr), - bioService(nullptr) -{ - init(); -} - -void ServiceManager::init() -{ - if(!dbusService) - { - dbusService = new QDBusInterface(FD_DBUS_SERVICE, - FD_DBUS_PATH, - FD_DBUS_INTERFACE, - QDBusConnection::systemBus()); - connect(dbusService, SIGNAL(NameOwnerChanged(QString, QString, QString)), - this, SLOT(onDBusNameOwnerChanged(QString,QString,QString))); - } -} - -ServiceManager *ServiceManager::instance() -{ - if(!instance_) - { - instance_ = new ServiceManager; - } - return instance_; -} - -bool ServiceManager::connectToService() -{ - if(!bioService) - { - bioService = new QDBusInterface(DBUS_SERVICE, - DBUS_PATH, - DBUS_INTERFACE, - QDBusConnection::systemBus()); - } - return bioService->isValid(); -} - -void ServiceManager::onDBusNameOwnerChanged(const QString &name, - const QString &oldOwner, - const QString &newOwner) -{ - if(name == DBUS_SERVICE) - { - qDebug() << "service status changed:" - << (newOwner.isEmpty() ? "inactivate" : "activate"); - Q_EMIT serviceStatusChanged(!newOwner.isEmpty()); - } -} - -/*! - * \brief checkServiceExist - * 检查生物识别后台服务是否已启动 - */ -bool ServiceManager::serviceExists() -{ - QDBusReply reply = dbusService->call("NameHasOwner", DBUS_SERVICE); - if(!reply.isValid()) - { - qDebug() << "check service exists error:" << reply.error(); - return false; - } - return reply.value(); -} - -/*! - * \brief ServiceManager::apiCompatible - * 检查API版本和服务的版本是否兼容 - */ -bool ServiceManager::apiCompatible() -{ - if(!connectToService()) - return false; - - QDBusReply reply = bioService->call("CheckAppApiVersion", - APP_API_MAJOR, - APP_API_MINOR, - APP_API_FUNC); - if(!reply.isValid()) - { - qDebug() << "check api compatibility error: " << reply.error(); - return false; - } - return (reply.value() == 0); -} diff --git a/src/servicemanager.h b/src/servicemanager.h deleted file mode 100644 index 548cf1d..0000000 --- a/src/servicemanager.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ - -#ifndef SERVICEMANAGER_H -#define SERVICEMANAGER_H - -#include -#include - -class ServiceManager : public QObject -{ - Q_OBJECT -public: - static ServiceManager *instance(); - bool serviceExists(); - bool apiCompatible(); - -private: - explicit ServiceManager(QObject *parent = nullptr); - void init(); - bool connectToService(); - -Q_SIGNALS: - void serviceStatusChanged(bool activate); - -public Q_SLOTS: - void onDBusNameOwnerChanged(const QString &name, - const QString &oldOwner, - const QString &newOwner); - -private: - static ServiceManager *instance_; - QDBusInterface *dbusService; - QDBusInterface *bioService; - bool serviceStatus; -}; - -#endif // SERVICEMANAGER_H diff --git a/src/sessionwatcher.cpp b/src/sessionwatcher.cpp deleted file mode 100644 index 7d3511d..0000000 --- a/src/sessionwatcher.cpp +++ /dev/null @@ -1,363 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#include "sessionwatcher.h" -#include -#include -#include -#include -#include "types.h" -#include "glibinterface.h" - -#define GSETTINGS_SCHEMA_SCREENSAVER "org.ukui.screensaver" -#define KEY_IDLE_DELAY "idleDelay" -#define KEY_IDLE_LOCK "idleLock" -#define KEY_IDLE_ACTIVATION_ENABLED "idleActivationEnabled" -#define KEY_IDLE_LOCK_ENABLED "idleLockEnabled" -#define TIME_TYPE_SCHEMA "org.ukui.control-center.panel.plugins" -#define KEY_LOCK_TIMEOUT "lockTimeout" -#define STYLE_TYPE_SCHEMA "org.ukui.style" - -#define GSETTINGS_SCHEMA_SCREENSAVER_DEFAULT "org.ukui.screensaver-default" -#define KEY_SHOW_REST_TIME "showRestTime" // old -#define KEY_SHOW_CUSTOM_REST_TIME "showCustomRestTime" -#define KEY_SHOW_UKUI_REST_TIME "showUkuiRestTime" - -#define POWER_TYPE_SCHENA "org.ukui.power-manager" -#define FREEDESKTOP_UPOWER "org.freedesktop.DBus.Properties" -#define UPOWER_PATH "/org/freedesktop/UPower" -#define UPOWER_SERVICE "org.freedesktop.UPower" -#define UPOWER_DISPLAY_PATH "/org/freedesktop/UPower/devices/DisplayDevice" -#define G_FONT_SIZE (11.0) - -SessionWatcher::SessionWatcher(QObject *parent) : QObject(parent) -{ - sessionPath = qgetenv("XDG_SESSION_PATH"); - - defaultFontSize = getDefaultFontSize(); - - QDBusInterface *interface = new QDBusInterface( - SM_DBUS_SERVICE, - SM_DBUS_PATH, - SM_DBUS_INTERFACE, - QDBusConnection::sessionBus(), this); - - connect(interface, SIGNAL(StatusChanged(unsigned int)), - this, SLOT(onStatusChanged(unsigned int))); - - QDBusInterface *displayManagerInterface = new QDBusInterface( - DM_DBUS_SERVICE, - DM_DBUS_PATH, - DM_DBUS_INTERFACE, - QDBusConnection::systemBus(), this); - connect(displayManagerInterface, SIGNAL(SessionRemoved(QDBusObjectPath)), - this, SLOT(onSessionRemoved(QDBusObjectPath))); - - QStringList keysScreenSaver; - if(QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA_SCREENSAVER)){ - m_ssSettings = new QGSettings(GSETTINGS_SCHEMA_SCREENSAVER, "", this); - connect(m_ssSettings, &QGSettings::changed, - this, &SessionWatcher::onSSConfigChanged); - keysScreenSaver = m_ssSettings->keys(); - // 重置屏保从不字段 - if (keysScreenSaver.contains(KEY_IDLE_ACTIVATION_ENABLED)) { - bool isEnable = m_ssSettings->get("idle-activation-enabled").toBool(); - if (!isEnable) { - m_ssSettings->set("idle-activation-enabled", true); - if (keysScreenSaver.contains(KEY_IDLE_DELAY)) { - m_ssSettings->set("idle-delay", -1); - } - } - } - // 重置锁屏时间(不处理超时锁屏220620) - if (keysScreenSaver.contains(KEY_IDLE_LOCK)) { - m_ssSettings->set("idle-lock", -1); - } - idleDelay = m_ssSettings->get("idle-delay").toInt(); - idleLock = m_ssSettings->get("idle-lock").toInt(); - - if (keysScreenSaver.contains(KEY_LOCK_TIMEOUT)) { - m_nLockTimeout = m_ssSettings->get("lock-timeout").toInt(); - } - } - - if(QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA_SCREENSAVER_DEFAULT)){ - m_sdSettings = new QGSettings(GSETTINGS_SCHEMA_SCREENSAVER_DEFAULT, "", this); - // 重置屏保休息时间字段 - QStringList keysScreenSaverDefault = m_sdSettings->keys(); - if (keysScreenSaverDefault.contains(KEY_SHOW_REST_TIME)) { - bool isShow = m_sdSettings->get("show-rest-time").toBool(); - if (!isShow) { - m_sdSettings->set("show-rest-time", true); - if (keysScreenSaverDefault.contains(KEY_SHOW_CUSTOM_REST_TIME)) { - m_sdSettings->set("show-custom-rest-time", isShow); - } - if (keysScreenSaverDefault.contains(KEY_SHOW_UKUI_REST_TIME)) { - m_sdSettings->set("show-ukui-rest-time", isShow); - } - } - } - } - - // for PowerManager - // 同步旧的电源管理唤醒是否需密码配置 - FILE *fp = NULL; - fp = popen("xset s 0 0", "r"); - fclose(fp); - - if(QGSettings::isSchemaInstalled(POWER_TYPE_SCHENA)){ - m_pmSettings = new QGSettings(POWER_TYPE_SCHENA,"", this); - QStringList keys = m_pmSettings->keys(); - if (keys.contains("lockSuspend")) { - bool ret = m_pmSettings->get("lockSuspend").toBool(); - if(ret){ - m_pmSettings->set("lock-suspend",false); - } - } - if (keys.contains("lockHibernate")) { - bool ret = m_pmSettings->get("lockHibernate").toBool(); - if(ret){ - m_pmSettings->set("lock-hibernate",false); - } - } - if (keys.contains("lockBlankScreen") && keysScreenSaver.contains("closeActivationEnabled")) { - bool oldValue = m_pmSettings->get("lockBlankScreen").toBool(); - if(!oldValue && m_ssSettings){ - m_ssSettings->set("close-activation-enabled", oldValue); - m_pmSettings->set("lock-blank-screen", true); - } - } - } - - QString userName = getenv("USER"); - QString configPath; - configPath = QString("/var/lib/lightdm-data/%1/ukui-greeter.conf").arg(userName); - QFile fileConf(configPath); - if (!fileConf.exists()) { - QFile file(configPath); - file.setPermissions(QFile::WriteUser | QFile::ReadUser | QFile::WriteOther | QFile::ReadOther); - } - configSettings = new QSettings(configPath, QSettings::IniFormat, this); - if (QGSettings::isSchemaInstalled(TIME_TYPE_SCHEMA)) { - timegsettings = new QGSettings(TIME_TYPE_SCHEMA,"",this); - int timeType = timegsettings->get("hoursystem").toInt(); - setValue("timeType",timeType); - QString dateType = timegsettings->get("date").toString(); - setValue("dateType",dateType); - connect(timegsettings, &QGSettings::changed, - this, &SessionWatcher::onConfigurationTimeTpChanged); - } - - if (QGSettings::isSchemaInstalled(STYLE_TYPE_SCHEMA)) { - stylesettings = new QGSettings(STYLE_TYPE_SCHEMA,"",this); - double fontSize = stylesettings->get("systemFontSize").toDouble(); - setValue("fontSize",fontSize - defaultFontSize); - QString themeColor = stylesettings->get("themeColor").toString(); - setValue("themeColor", themeColor); - connect(stylesettings, &QGSettings::changed, - this, &SessionWatcher::onConfigurationTimeTpChanged); - } - - // 监听合盖信号 - QDBusConnection::systemBus().connect( - UPOWER_SERVICE, UPOWER_PATH, FREEDESKTOP_UPOWER, "PropertiesChanged", this, SLOT(onLidWatcherMessage(void))); -} - -void SessionWatcher::onSSConfigChanged(QString strKey) -{ - if(strKey == KEY_IDLE_DELAY){ - idleDelay = m_ssSettings->get("idle-delay").toInt(); - } else if (strKey == KEY_IDLE_LOCK){ - idleLock = m_ssSettings->get("idle-lock").toInt(); - } else if (strKey == KEY_LOCK_TIMEOUT) { - m_nLockTimeout = m_ssSettings->get("lock-timeout").toInt(); - } -} - -void SessionWatcher::onConfigurationTimeTpChanged(QString key) -{ - if (key == "hoursystem") { - int timeType = timegsettings->get("hoursystem").toInt(); - setValue("timeType",timeType); - } else if (key == "date") { - QString dateType = timegsettings->get("date").toString(); - setValue("dateType",dateType); - } else if (key == "systemFontSize") { - double fontSize = stylesettings->get("systemFontSize").toDouble() - defaultFontSize; - setValue("fontSize", fontSize); - } else if (key == "themeColor") { - QString themeColor = stylesettings->get("themeColor").toString(); - setValue("themeColor", themeColor); - } -} - -void SessionWatcher::setValue(const QString &key, const QVariant &value) -{ - if (!configSettings) - return; - configSettings->beginGroup("Greeter"); - configSettings->setValue(key, value); - configSettings->endGroup(); -} - -void SessionWatcher::onStatusChanged(unsigned int status) -{ - if(status == SESSION_IDLE) { - if(idleDelay != -1){ - if(!m_timer){ - m_timer = new QTimer(this); - connect(m_timer, &QTimer::timeout, this, [&]{ - Q_EMIT sessionIdle(); - m_timer->stop(); - }); - } - int time = (idleDelay - 1)*60000; - if(time<0) - time = 0; - - m_timer->start(time); - } - - if(idleLock != -1){ - if(!m_timer2){ - m_timer2 = new QTimer(this); - connect(m_timer2, &QTimer::timeout, this, [&]{ - Q_EMIT sessionLockIdle(); - m_timer2->stop(); - }); - } - int lockTime = (idleLock - 1)*60000; - if(lockTime<0) - lockTime = 0; - - m_timer2->start(lockTime); - } - - - }else if(status == SESSION_AVAILABLE){ - if(m_timer && m_timer->isActive()){ - m_timer->stop(); - } - if(m_timer2 && m_timer2->isActive()){ - m_timer2->stop(); - } - Q_EMIT sessionIdleExit(); - } -} - -void SessionWatcher::onSessionRemoved(const QDBusObjectPath &objectPath) -{ - //如果session注销了,则结束进程 - if(objectPath.path() == sessionPath) - exit(0); -} - -bool SessionWatcher::isSleepActivationEnable() -{ - if (!m_ssSettings) - return false; - QStringList settingsKeys = m_ssSettings->keys(); - if (settingsKeys.contains("sleepActivationEnabled")) { - return m_ssSettings->get("sleep-activation-enabled").toBool(); - } else { - return false; - } -} - -bool SessionWatcher::isCloseActivationEnable() -{ - if (!m_ssSettings) - return false; - QStringList settingsKeys = m_ssSettings->keys(); - if (settingsKeys.contains("closeActivationEnabled")) { - return m_ssSettings->get("close-activation-enabled").toBool(); - } else { - return false; - } -} - -bool SessionWatcher::isLockEnable() -{ - if (!m_ssSettings) - return false; - QStringList settingsKeys = m_ssSettings->keys(); - if (settingsKeys.contains("lockEnabled")) { - return m_ssSettings->get("lock-enabled").toBool(); - } else { - return false; - } -} - -int SessionWatcher::sleepActivationDelay() -{ - if (!m_pmSettings) - return -1; - QStringList settingsKeys = m_pmSettings->keys(); - if (settingsKeys.contains("sleepComputerAc")) { - return m_pmSettings->get("sleep-computer-ac").toInt(); - } else { - return -1; - } -} - -int SessionWatcher::closeActivationDelay() -{ - if (!m_pmSettings) - return -1; - QStringList settingsKeys = m_pmSettings->keys(); - if (settingsKeys.contains("sleepDisplayAc")) { - return m_pmSettings->get("sleep-display-ac").toInt(); - } else { - return -1; - } -} - -int SessionWatcher::idledelay() -{ - return idleDelay; -} - -int SessionWatcher::locktimeout() -{ - return m_nLockTimeout; -} - -bool SessionWatcher::isLidCloseWithBlank() -{ - if (!m_pmSettings) - return false; - QStringList settingsKeys = m_pmSettings->keys(); - if (settingsKeys.contains("buttonLidAc")) { - QString strAction = m_pmSettings->get("button-lid-ac").toString(); - return (strAction == "blank"); - } else { - return false; - } -} - -void SessionWatcher::onLidWatcherMessage(void) -{ - QDBusInterface iface(UPOWER_SERVICE, UPOWER_PATH, FREEDESKTOP_UPOWER, QDBusConnection::systemBus()); - QDBusReply reply = iface.call("Get", "org.freedesktop.UPower", "LidIsClosed"); - if (reply.isValid()) { - m_lidState = reply.value().toBool(); - Q_EMIT lidStateChanged(m_lidState); - qDebug() << "lid state:" << m_lidState; - } else { - qDebug() << "Failed to get lid closed event!"; - } -} diff --git a/src/surewindow.cpp b/src/surewindow.cpp deleted file mode 100644 index a5eaa24..0000000 --- a/src/surewindow.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (C) 2022 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#include "surewindow.h" -#include "ui_surewindow.h" -#include "configuration.h" -#include -#include - -SureWindow::SureWindow(QWidget *parent) : - QWidget(parent), - ui(new Ui::SureWindow), - configuration(Configuration::instance()) -{ - ui->setupUi(this); - curFontSize = configuration->getFontSize(); - m_ptToPx = configuration->getPtToPx(); - ui->tipLabel->setFontSize(14 + curFontSize); - ui->tipLabel->setFixedWidth(this->width() - 20); - //ui->tipLabel->setWordWrap(true); - connect(ui->cancelBtn, &QPushButton::clicked, this, [&]() { emit cantelButtonclicked(); }); - connect(ui->confirmBtn, &QPushButton::clicked, this, [&]() { emit confirmButtonclicked(); }); -} - -SureWindow::~SureWindow() -{ - delete ui; -} - -void SureWindow::setTips(const QString tips) -{ - ui->tipLabel->setFixedWidth(this->width()); - ui->cancelBtn->setStyleSheet("QPushButton{background: rgba(255, 255, 255, 0.2);border-radius: 8px;color: white;}" - "QPushButton:hover{background: rgba(255, 255, 255, 0.4);border-radius: 8px;}" - "QPushButton:pressed {background: rgba(255, 255, 255, 0.3);border-radius: 8px;}"); - ui->confirmBtn->setStyleSheet("QPushButton{background: rgba(255, 255, 255, 0.2);border-radius: 8px;color: white;}" - "QPushButton:hover{background: rgba(255, 255, 255, 0.4);border-radius: 8px;}" - "QPushButton:pressed {background: rgba(255, 255, 255, 0.3);border-radius: 8px;}"); - sysFont.setPointSize((16 + curFontSize) *m_ptToPx); - ui->confirmBtn->setFont(sysFont); - ui->cancelBtn->setFont(sysFont); - ui->confirmBtn->show(); - ui->tipLabel->show(); - ui->listView->hide(); - ui->tipLabel->setElideText(tips, this->width()); -} - -void SureWindow::setWarning(QVector &list, int type) -{ - ui->tipLabel->setFixedWidth(this->width()); - switch (type) { - case 0: - ui->tipLabel->setElideText(tr("The following program is running to prevent the system from reboot!"), this->width() - 20); - break; - case 1: - ui->tipLabel->setElideText(tr("The following program is running to prevent the system from shutting down!"), this->width() - 20); - break; - case 2: - ui->tipLabel->setElideText(tr("The following program is running to prevent the system from suspend!"), this->width() - 20); - break; - case 3: - ui->tipLabel->setElideText(tr("The following program is running to prevent the system from hibernate!"), this->width() - 20); - break; - default: - break; - } - ui->listView->show(); - - QStandardItemModel *model = new QStandardItemModel(this); - for (auto iter = list.begin(); iter != list.end(); ++iter) { - QIcon icon; - QString appName = iter->name; - QString iconName = iter->icon; - - if (!iconName.isEmpty() && QIcon::hasThemeIcon(iconName)) { - icon = QIcon::fromTheme(iconName); - } else if (QIcon::hasThemeIcon("application-x-desktop")) { - icon = QIcon::fromTheme("application-x-desktop"); - } - model->appendRow(new QStandardItem(icon, appName)); - } - - ui->listView->verticalScrollMode(); - ui->listView->setStyleSheet("color:white; background-color: rgba(255,255,255,30%); border-radius: 12px;"); - sysFont.setPointSize((10 + curFontSize) *m_ptToPx); - ui->listView->setFont(sysFont); - ui->listView->setEditTriggers(QAbstractItemView::NoEditTriggers); - ui->listView->setIconSize(QSize(32,32)); - ui->listView->setModel(model); - ui->listView->setFixedSize(520, 320); - ui->cancelBtn->setFixedSize(120, 48); - - ui->confirmBtn->hide(); - ui->cancelBtn->setStyleSheet("QPushButton{background: rgba(255, 255, 255, 0.2);border-radius: 8px;color: white;}" - "QPushButton:hover{background: rgba(255, 255, 255, 0.4);border-radius: 8px;}" - "QPushButton:pressed {background: rgba(255, 255, 255, 0.3);border-radius: 8px;}"); - sysFont.setPointSize((16 + curFontSize) *m_ptToPx); - ui->cancelBtn->setFont(sysFont); -} diff --git a/src/surewindow.h b/src/surewindow.h deleted file mode 100644 index 7d49b31..0000000 --- a/src/surewindow.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2022 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#ifndef SUREWINDOW_H -#define SUREWINDOW_H - -#include "lockchecker.h" -#include - -namespace Ui { -class SureWindow; -} - -class Configuration; - -class SureWindow : public QWidget -{ - Q_OBJECT - -public: - explicit SureWindow(QWidget *parent = nullptr); - ~SureWindow(); - void setTips(const QString tips); - void setWarning(QVector &list, int type); - -private: - Ui::SureWindow *ui; - void on_cancelBtn_Clicked(); - -Q_SIGNALS: - void cantelButtonclicked(); - void confirmButtonclicked(); - -private: - Configuration *configuration; - double curFontSize = 0; - double m_ptToPx = 1.0; - QFont sysFont; -}; - -#endif // SUREWINDOW_H diff --git a/src/surewindow.ui b/src/surewindow.ui deleted file mode 100644 index 10f3567..0000000 --- a/src/surewindow.ui +++ /dev/null @@ -1,222 +0,0 @@ - - - SureWindow - - - - 0 - 0 - 632 - 674 - - - - Form - - - - 24 - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - Noto Sans CJK SC - - - - TextLabel - - - Qt::AlignCenter - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - 0 - - - 19 - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 520 - 320 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - 24 - - - 5 - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 96 - 36 - - - - - 120 - 48 - - - - Cancel - - - - - - - - 120 - 48 - - - - - 120 - 48 - - - - Confirm - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - KLabel - QLabel -
klabel.h
-
-
- - -
diff --git a/src/switchbuttongroup.cpp b/src/switchbuttongroup.cpp deleted file mode 100644 index dcb085d..0000000 --- a/src/switchbuttongroup.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * - * Authors: ZHAI Kang-ning -**/ -#include "switchbuttongroup.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -SwitchButtonGroup::SwitchButtonGroup(QWidget *parent) : QWidget(parent), - m_checkedId(0) -{ - this->resize(264, 48); - m_bg_switch = new QButtonGroup(this); - m_pb_password = new QPushButton(tr("uEduPWD"), this); - m_pb_qrCode = new QPushButton(tr("Wechat"), this); - m_pb_password->setIcon(QIcon(":/image/assets/intel/pin.png")); - m_pb_qrCode->setIcon(QIcon(":/image/assets/intel/wechat.png")); - - m_pb_password->setCheckable(true); - m_pb_qrCode->setCheckable(true); - - m_pb_password->setStyleSheet("font-size:16px;color:#ffffff"); - m_pb_qrCode->setStyleSheet("font-size:16px;color:#ffffff"); - - m_bg_switch->addButton(m_pb_password, 0); - m_bg_switch->addButton(m_pb_qrCode, 1); - - QObject::connect(m_pb_password, &QPushButton::clicked, this, &SwitchButtonGroup::parseButtonStatus); - QObject::connect(m_pb_qrCode, &QPushButton::clicked, this, &SwitchButtonGroup::parseButtonStatus); - - initUI(); -} - -void SwitchButtonGroup::initUI() -{ - QHBoxLayout *hbLayout = new QHBoxLayout(this); - hbLayout->setContentsMargins(0, 0, 0, 0); - hbLayout->addSpacerItem(new QSpacerItem(40,20,QSizePolicy::Expanding, QSizePolicy::Maximum)); - hbLayout->addWidget(m_pb_password); - hbLayout->addSpacerItem(new QSpacerItem(64,20,QSizePolicy::Expanding, QSizePolicy::Maximum)); - - QLine *s = new QLine(this->width()/2, 0, this->width(), this->height()/2); -// hbLayout->addChildWidget(s); - - hbLayout->addWidget(m_pb_qrCode); - hbLayout->addSpacerItem(new QSpacerItem(40,20,QSizePolicy::Expanding, QSizePolicy::Maximum)); -} - -void SwitchButtonGroup::parseButtonStatus() -{ -// qDebug() << "---------------------------parseButtonStatus check id=" << m_bg_switch->checkedId(); - if (m_checkedId == m_bg_switch->checkedId()) - return; - m_checkedId = m_bg_switch->checkedId(); -// switch (m_checkedId) { -// case 0: -// m_pb_password->setStyleSheet("font-size:16px;color:#2fb4e8"); -// m_pb_qrCode->setStyleSheet("font-size:16px;color:#ffffff"); -// break; -// case 1: -// m_pb_qrCode->setStyleSheet("font-size:16px;color:#2fb4e8"); -// m_pb_password->setStyleSheet("font-size:16px;color:#ffffff"); -// break; -// default: -// break; -// } - repaint(); - emit onSwitch(m_checkedId); -} - -void SwitchButtonGroup::paintEvent(QPaintEvent *event) -{ -// Q_UNUSED(event); -// QPainter painter(this); //QWidget为绘图设备,创建一个画刷对象,主要用到设置颜色和填充模式,brush,setBrush -// int width=this->width(); //获取QWidget 窗口的宽度 -// int height=this->height();//获取QWidget 窗口的高度 - -// painter.setPen(QColor("#ffffff")); -// painter.drawLine(this->width()/2, 0, this->width()/2, this->height()/2); - -// QPainterPath drawtriangle; //单独画三角形 - -// QPushButton *checkedButton; -// if (m_checkedId == 0) -// { -// checkedButton = m_pb_password; -// } else { -// checkedButton = m_pb_qrCode; -// } - -// drawtriangle.moveTo(checkedButton->x() + checkedButton->geometry().width()/2 -6, height);//左下角,第一点坐标为(0,height); -// drawtriangle.lineTo(checkedButton->x() + checkedButton->geometry().width()/2, height -12);//第二点坐标为(width/4,height/2) -// drawtriangle.lineTo(checkedButton->x() + checkedButton->geometry().width()/2 + 6, height);//第三点坐标为(width/2,height) -// painter.setPen(Qt::NoPen); -// painter.setBrush(QColor("#2fb4e8")); //填充绿色 -// painter.drawPath(drawtriangle); //绘制出图形 - - //设计稿变化重新做界面 - QPainter painter(this); - QColor color("#ffffff"); - color.setAlphaF(0.15); - painter.setRenderHint(QPainter::Antialiasing); - QPen pen(color); - painter.setPen(pen); - painter.setBrush(color); - - if(m_checkedId == 0) { - QRect rect1(4, 0, 120, 48); - painter.drawRoundedRect(rect1, 24, 24); - } else { - QRect rect2(140, 0, 120, 48); - painter.drawRoundedRect(rect2, 24, 24); - } -} diff --git a/src/switchbuttongroup.h b/src/switchbuttongroup.h deleted file mode 100644 index 1a2ace7..0000000 --- a/src/switchbuttongroup.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * - * Authors: ZHAI Kang-ning -**/ -#ifndef SWITCHBUTTONGROUP_H -#define SWITCHBUTTONGROUP_H - -#include -#include -#include - -class SwitchButtonGroup : public QWidget -{ - Q_OBJECT -public: - explicit SwitchButtonGroup(QWidget *parent = nullptr); - -Q_SIGNALS: - void onSwitch(int id); - -private Q_SLOTS: - void parseButtonStatus(); - -private: - void initUI(); - - int m_checkedId;//上一次选中的按钮id - QButtonGroup *m_bg_switch; - QPushButton *m_pb_password; - QPushButton *m_pb_qrCode; - -protected: - void paintEvent(QPaintEvent *event) override; -}; - -#endif // SWITCHBUTTONGROUP_H diff --git a/src/tabletlockwidget.cpp b/src/tabletlockwidget.cpp deleted file mode 100644 index 9a18136..0000000 --- a/src/tabletlockwidget.cpp +++ /dev/null @@ -1,657 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * - * Authors: ZHAI Kang-ning -**/ -#include -#include -#include -#include -//#include -//#include -//#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "tabletlockwidget.h" -#include "authdialog.h" -#include "virtualkeyboardwidget.h" -#include "users.h" -#include "displaymanager.h" -#include "weathermanager.h" -#include "powermanager.h" -#include "digitalauthdialog.h" -#include "switchbuttongroup.h" -#include "wechatauthdialog.h" -#include "verificationwidget.h" -#include "verticalVerificationwidget.h" -#include "common.h" -#include "eduplatforminterface.h" -#include "accountsinterface.h" -#include "kylinnm.h" - -#include - -float tablescale; -TabletLockWidget::TabletLockWidget(QWidget *parent) : - QWidget(parent), - displayManager(new DisplayManager(this)), - m_switchButtonGroup(new SwitchButtonGroup(this)), - m_digitalAuthDialog(new DigitalAuthDialog(this)), - m_weChatAuthDialog(new WeChatAuthDialog(this)), - m_pb_powerManager(new QPushButton(this)), - m_pb_networkManager(new QPushButton(this)), - m_vKeyboardPB(new QPushButton(this)), - m_vKeyboard(new VirtualKeyboardWidget(this)), - m_cancelOrBack(new QPushButton(this)), - m_pb_skip(new QPushButton(this)), - m_verificationWidget(new VerificationWidget(this)), - m_verticalVerificationWidget(new VerticalVerificationWidget(this)), - m_authType(0), - m_eduPlatformInterface(nullptr), - m_kylinNM(new KylinNM(this)) -{ - tablescale = 1.0; - m_kylinNM->installEventFilter(this); - m_digitalAuthDialog->installEventFilter(this); - m_switchButtonGroup->installEventFilter(this); - m_vKeyboard->installEventFilter(this); - this->installEventFilter(this); - - powermanager = new PowerManager(0, this); - powermanager->setStartupMode(m_isStartupMode); - powermanager->hide(); - - initUI(); - initConnect(); - onSwitchPage(); -} - -TabletLockWidget::~TabletLockWidget() -{ -} - -void TabletLockWidget::closeEvent(QCloseEvent *event) -{ - qDebug() << "TabletLockWidget::closeEvent"; - m_digitalAuthDialog->close(); - m_weChatAuthDialog->close(); - m_switchButtonGroup->close(); - m_verificationWidget->close(); - m_verticalVerificationWidget->close(); - m_kylinNM->close(); - return QWidget::closeEvent(event); -} - - -bool TabletLockWidget::eventFilter(QObject *obj, QEvent *event) -{ - if (obj == m_vKeyboard || obj == m_kylinNM) - return true; - - if (event->type() == QEvent::MouseButtonPress && m_kylinNM->isVisible()) - { - m_kylinNM->hide(); - if(powermanager->isHidden()) //非电源会话界面则刷新,否则只网络弹窗 - onSwitchPage(); - } - - return QWidget::eventFilter(obj, event); -} - -void TabletLockWidget::setStartupMode(bool mode) -{ - m_isStartupMode = mode; - if (powermanager) { - powermanager->setStartupMode(m_isStartupMode); - } -} - -void TabletLockWidget::startAuth() -{ - m_digitalAuthDialog->startAuth(); -} - -void TabletLockWidget::stopAuth() -{ - -} - -void TabletLockWidget::initUI() -{ - //电源管理 - m_pb_powerManager->setIcon(QIcon(":/image/assets/intel/powerManager.png")); - m_pb_powerManager->setFixedSize(48,48); - m_pb_powerManager->setIconSize(QSize(24,24)); - m_pb_powerManager->setFocusPolicy(Qt::NoFocus); - m_pb_powerManager->setStyleSheet("QPushButton:Hover{border-radius:24px;background-color:rgba(255, 255, 255, 0.15);}" - "QPushButton:Pressed{border-radius:24px;background-color:rgba(255, 255, 255, 0.05);}"); - m_pb_powerManager->installEventFilter(this); - - connect(m_pb_powerManager,&QPushButton::clicked - ,this,&TabletLockWidget::showPowerManager); - - //网络设置 - updateNetIcon(m_kylinNM->getConnectStatus()); - m_pb_networkManager->setFixedSize(48,48); - m_pb_networkManager->setIconSize(QSize(24,24)); - m_pb_networkManager->setFocusPolicy(Qt::NoFocus); - m_pb_networkManager->setStyleSheet("QPushButton:Hover{border-radius:24px;background-color:rgba(255, 255, 255, 0.15);}" - "QPushButton:Pressed{border-radius:24px;background-color:rgba(255, 255, 255, 0.05);}"); - m_pb_networkManager->installEventFilter(this); - - connect(m_pb_networkManager,&QPushButton::clicked - ,this,&TabletLockWidget::showNetManager); - - //虚拟键盘 - m_vKeyboard->hide(); - - connect(m_vKeyboard, &VirtualKeyboardWidget::aboutToClose, - m_vKeyboard, &VirtualKeyboardWidget::hide); - - m_vKeyboardPB->setIcon(QIcon(":/image/assets/intel/keyboard.png")); - m_vKeyboardPB->setFixedSize(48,48); - m_vKeyboardPB->setIconSize(QSize(24,24)); - m_vKeyboardPB->setFocusPolicy(Qt::NoFocus); - m_vKeyboardPB->installEventFilter(this); - m_vKeyboardPB->setStyleSheet("QPushButton:Hover{border-radius:24px;background-color:rgba(255, 255, 255, 0.15);}" - "QPushButton:Pressed{border-radius:24px;background-color:rgba(255, 255, 255, 0.05);}"); - - connect(m_vKeyboardPB,&QPushButton::clicked - ,this,&TabletLockWidget::showVirtualKeyboard); - - //取消或返回 - m_cancelOrBack->resize(88, 48); - m_cancelOrBack->setIcon(QIcon(":/image/assets/intel/cancel.png")); - m_cancelOrBack->setStyleSheet("QPushButton{font-size:16px;color:#ffffff;}" - "QPushButton:Hover{border-radius:24px;background-color:rgba(255, 255, 255, 0.15);}" - "QPushButton:Pressed{border-radius:24px;background-color:rgba(255, 255, 255, 0.05);}"); - m_cancelOrBack->setText(tr("Cancel")); - m_cancelOrBack->setIconSize(QSize(24,24)); - m_cancelOrBack->setFocusPolicy(Qt::NoFocus); - m_cancelOrBack->installEventFilter(this); - connect(m_digitalAuthDialog, &DigitalAuthDialog::requestPasswordReset, this, [=]{ - m_cancelOrBack->setIcon(QIcon(":/image/assets/intel/back.png")); - m_cancelOrBack->setText(tr("Back")); - m_pageType = pageType::check; - m_pb_skip->hide(); - onSwitchPage(); - }); - connect(m_cancelOrBack, &QPushButton::clicked, this, [=]{ - if(powermanager->isVisible()) - { - powermanager->hide(); - onSwitchPage(); - // m_digitalAuthDialog->reset(); - if(m_pageType != pageType::check) - { - m_cancelOrBack->setIcon(QIcon(":/image/assets/intel/cancel.png")); - m_cancelOrBack->setText(tr("Cancel")); - } - return; - } - - if(m_pageType == pageType::pinLogin && - m_digitalAuthDialog->getStatus() == DigitalAuthDialog::LoginType::SECONDCONFIRMATION) - { - // 二次确认页返回,则显示重置密码页 - m_digitalAuthDialog->showResetPasswordPage(); - return; - } - - if(m_pageType == pageType::check) { - m_pageType = pageType::pinLogin; - m_digitalAuthDialog->reset(); - - onSwitchPage(); - m_cancelOrBack->setIcon(QIcon(":/image/assets/intel/cancel.png")); - m_cancelOrBack->setText(tr("Cancel")); - return; - } - - if(m_digitalAuthDialog->getStatus() == 0) - { - //Todo 1、锁屏 -》息屏 - m_digitalAuthDialog->reset(); - Q_EMIT blackSaver(); -#ifdef USE_INTEL - powermanager->hibernate(); -#endif - } else { - m_digitalAuthDialog->reset(); - m_cancelOrBack->setIcon(QIcon(":/image/assets/intel/cancel.png")); - m_cancelOrBack->setText(tr("Cancel")); - } - }); - - // 重置密码时跳过按钮 - m_pb_skip->setText(tr("Skip")); - m_pb_skip->resize(88, 48); - m_pb_skip->setStyleSheet("QPushButton{font-size:16px;color:#ffffff;}" - "QPushButton:Hover{border-radius:24px;background-color:rgba(255, 255, 255, 0.15);}" - "QPushButton:Pressed{border-radius:24px;background-color:rgba(255, 255, 255, 0.05);}"); - m_pb_skip->hide(); - - //网络模块 - m_kylinNM->hide(); -} - -/** - * @brief TabletLockWidget::initConnect - * 建立信号与槽的绑定 - */ -void TabletLockWidget::initConnect() -{ - connect(m_digitalAuthDialog, &DigitalAuthDialog::authenticateCompete, - this, &TabletLockWidget::closed); - connect(m_digitalAuthDialog, &DigitalAuthDialog::setPinCode, this, [=](QString pinCode){ - //Todo - QString currentPinCode; - AccountsInterface::getInstance()->GetAccountPincode(getenv("USER"), currentPinCode); - qDebug() << "currentPinCode:" << currentPinCode << "--old pinCode:" << pinCode; - if(!currentPinCode.isEmpty() && currentPinCode == pinCode) - { - //与原密码相同 - m_digitalAuthDialog->showErrorMessage(tr("New password is the same as old")); - m_digitalAuthDialog->showResetPasswordPage(); - return; - } - - DBusMsgCode code = AccountsInterface::getInstance()->SetAccountPincode(getenv("USER"), pinCode); - if (code == DBusMsgCode::No_Error) { - qDebug() << "set pincode success"; - Q_EMIT closed(); - } else { - qWarning() << "设置失败" << code; - m_digitalAuthDialog->showErrorMessage(tr("Reset password error:%1").arg(code)); - } - }); - connect(m_weChatAuthDialog, &WeChatAuthDialog::authenticateCompete, this, &TabletLockWidget::closed); - connect(m_weChatAuthDialog, &WeChatAuthDialog::qRStatusChange, this, [=] (QString loginname, QString loginpwd, int curstatus){ - //QString loginname, QString loginpwd, int curstatus - if(getenv("USER") == loginname && m_pageType == pageType::wecharLogin) - { - Q_EMIT closed(); - } else { - qWarning() << "[error] Username does not match wechat<" << loginname << ">" << " local<" << getenv("USER")<<">"; - if (!loginname.isEmpty()){ - m_weChatAuthDialog->showErrorMessage(tr("Please scan by correct WeChat")); - m_weChatAuthDialog->onReset(); - } - } - }); - connect(m_switchButtonGroup, &SwitchButtonGroup::onSwitch, this, &TabletLockWidget::switchLoginType); - connect(m_verificationWidget, &VerificationWidget::pageMessage, this, [=](SwitchPage type, QList args) - { - m_pageType = pageType::pinLogin; - onSwitchPage(); - m_pb_skip->show(); - }); - connect(m_verticalVerificationWidget, &VerticalVerificationWidget::pageMessage, this, [=](SwitchPage type, QList args) - { - m_pageType = pageType::pinLogin; - onSwitchPage(); - m_pb_skip->show(); - }); - - connect(powermanager,SIGNAL(lock()) - ,this,SLOT(showPowerManager())); - - if(QGSettings::isSchemaInstalled("org.ukui.SettingsDaemon.plugins.tablet-mode")) - { - QGSettings *tm = new QGSettings("org.ukui.SettingsDaemon.plugins.tablet-mode", "", this); - //判断是否是平板模式 - if(tm->get("tablet-mode").toBool()){ - connect(m_kylinNM, &KylinNM::onLineEditClicked, this, [=](){ - //点击了输入密码的框框,需要弹出软键盘 - showVirtualKeyboard(true); - m_kylinNM->move(m_kylinNM->x(), height() - m_vKeyboard->height() - m_kylinNM->height() - 20); - }); - } - - //监听平板模式变化 - connect(tm, &QGSettings::changed, this, [=](QString key){ - if(key == "tablet-mode" || key == "tabletMode") { - disconnect(m_kylinNM, &KylinNM::onLineEditClicked, this, nullptr); - if(tm->get("tablet-mode").toBool()){ - connect(m_kylinNM, &KylinNM::onLineEditClicked, this, [=](){ - //点击了输入密码的框框,需要弹出软键盘 - showVirtualKeyboard(true); - m_kylinNM->move(m_kylinNM->x(), height() - m_vKeyboard->height() - m_kylinNM->height()); - }); - } - } - }); - } - - connect(m_kylinNM, &KylinNM::onConnectChanged, this,[=](){ - updateNetIcon(m_kylinNM->getConnectStatus()); - }); - - connect(m_vKeyboard, &VirtualKeyboardWidget::aboutToClose, m_vKeyboard, [=](){ - if(m_vKeyboard->isHidden() && m_kylinNM->isVisible()) { - m_kylinNM->setGeometry(this->width() - m_kylinNM->width() - 20, - this->height() - m_kylinNM->height() - 100, - m_kylinNM->width(), - m_kylinNM->height()); - } - }); - - connect(m_pb_skip, &QPushButton::clicked, this, &TabletLockWidget::closed); - connect(m_digitalAuthDialog, &DigitalAuthDialog::switchToReset, this, [=](bool isReset){ - if(isReset){ - m_pb_skip->show(); - } else { - m_pb_skip->hide(); - } - }); -} - -void TabletLockWidget::switchLoginType(int position) -{ - if(position == 0) - { - //锁屏密码登录 - m_pageType = pageType::pinLogin; - } else if (position == 1) - { - m_pageType = pageType::wecharLogin; - //微信登录 - m_digitalAuthDialog->reset(); - m_cancelOrBack->setIcon(QIcon(":/image/assets/intel/cancel.png")); - m_cancelOrBack->setText(tr("Cancel")); - } - - onSwitchPage(); -} - -void TabletLockWidget::showPowerManager() -{ - if (powermanager->isVisible()) - { - powermanager->hide(); - onSwitchPage(); - if(m_pageType != pageType::check) - { - m_cancelOrBack->setIcon(QIcon(":/image/assets/intel/cancel.png")); - m_cancelOrBack->setText(tr("Cancel")); - } - Q_EMIT screenSaver(); - } else { - m_digitalAuthDialog->hide(); - m_weChatAuthDialog->hide(); - m_switchButtonGroup->hide(); - m_verificationWidget->hide(); - m_verticalVerificationWidget->hide(); - m_cancelOrBack->setIcon(QIcon(":/image/assets/intel/back.png")); - m_cancelOrBack->setText(tr("Back")); - m_pb_networkManager->hide(); - m_pb_powerManager->hide(); - m_vKeyboardPB->hide(); - m_vKeyboard->hide(); - powermanager->show(); - powermanager->setGeometry((width()-ITEM_WIDTH*4 - ITEM_SPACING*3)/2, - (height()-ITEM_HEIGHT)/2, - (ITEM_WIDTH*4 + ITEM_SPACING*3),ITEM_HEIGHT); - } -} - -void TabletLockWidget::showNetManager() -{ - if(m_kylinNM->isVisible()) - { - m_kylinNM->hide(); - } else { - m_digitalAuthDialog->releaseKeyboard(); - m_kylinNM->show(); - m_kylinNM->setGeometry(this->width() - m_kylinNM->width() - 20, - this->height() - m_kylinNM->height() - 100, - m_kylinNM->width(), - m_kylinNM->height()); - m_kylinNM->updateWifiList(); - } -} - -/* lockscreen follows cursor */ -void TabletLockWidget::resizeEvent(QResizeEvent *event) -{ - QSize size = event->size(); - //重新计算缩放比例 - tablescale = QString::number(size.width() / 1920.0, 'f', 1).toFloat(); - - if(tablescale > 1) - tablescale = 1; - - m_cancelOrBack->setGeometry(32, 40, m_cancelOrBack->width(), m_cancelOrBack->height()); - m_pb_skip->setGeometry(this->width() - m_pb_skip->width() - 32, 40, m_pb_skip->width(), m_pb_skip->height()); - - m_digitalAuthDialog->setGeometry((this->width()-m_digitalAuthDialog->width())/2, (this->height()-m_digitalAuthDialog->height())/2 + 40, - m_digitalAuthDialog->width(), m_digitalAuthDialog->height()); - m_weChatAuthDialog->setGeometry((this->width()-m_weChatAuthDialog->width())/2, (this->height()-m_digitalAuthDialog->height())/2 + 40, - m_weChatAuthDialog->width(), m_weChatAuthDialog->height()); - - m_switchButtonGroup->setGeometry((this->width()-m_switchButtonGroup->width())/2, this->height()-80, - m_switchButtonGroup->width(), m_switchButtonGroup->height()); - - if(isOrientation()) - m_verticalVerificationWidget->setGeometry((this->width()-m_verticalVerificationWidget->width())/2, (this->height()-m_verticalVerificationWidget->height())/2, - m_verticalVerificationWidget->width(), m_verticalVerificationWidget->height()); - else - m_verificationWidget->setGeometry((this->width()-m_verificationWidget->width())/2, (this->height()-m_verificationWidget->height())/2 - 65, - m_verificationWidget->width(), m_verificationWidget->height()); - if(m_verificationWidget->isVisible() || m_verticalVerificationWidget->isVisible()) - showVerificationPage(); - // XSetInputFocus(QX11Info::display(),this->winId(),RevertToParent,CurrentTime); - //右下角按钮,x,y的初始值代表距离右下角的距离。 - int x=19,y=76; - x = x + m_pb_powerManager->width(); - m_pb_powerManager->setGeometry(this->width() - x,this->height() - y, m_pb_powerManager->width(), m_pb_powerManager->height()); - m_pb_networkManager->setGeometry(this->width() - x - 64 * tablescale, this->height() - y, - m_pb_networkManager->width(),m_pb_networkManager->height()); - m_vKeyboardPB->setGeometry(this->width() - x - 128 * tablescale, this->height() - y, - m_vKeyboardPB->width(), m_vKeyboardPB->height()); - m_kylinNM->setGeometry(this->width() - m_kylinNM->width() - 20, - this->height() - m_kylinNM->height() - 100, - m_kylinNM->width(), - m_kylinNM->height()); - //更新软键盘位置 - setVirkeyboardPos(); - if(powermanager && powermanager->isVisible()) - { - powermanager->setGeometry((width()-ITEM_WIDTH*4 - ITEM_SPACING*3)/2, - (height()-ITEM_HEIGHT)/2, - (ITEM_WIDTH*4 + ITEM_SPACING*3),ITEM_HEIGHT); - } -} - -//重写重绘事件,比如动态更新文本位置等 -void TabletLockWidget::paintEvent(QPaintEvent *event) -{ -} - -void TabletLockWidget::onSwitchPage() -{ - bool isOnlyWeChatLogin = false; - EduPlatformInterface::getInstance()->CheckPincodeSet(getenv("USER"), isOnlyWeChatLogin); - if(isOnlyWeChatLogin && m_pageType == pageType::pinLogin) - { - m_pageType = pageType::wecharLogin; - } - - if(!m_pb_networkManager->isVisible()) - m_pb_networkManager->show(); - - if(!m_pb_powerManager->isVisible()) - m_pb_powerManager->show(); - - switch (m_pageType) { - case pageType::pinLogin: - m_digitalAuthDialog->show(); - m_digitalAuthDialog->grabKeyboard(); - m_switchButtonGroup->show(); - m_weChatAuthDialog->hide(); - m_verificationWidget->hide(); - m_verticalVerificationWidget->hide(); - m_vKeyboardPB->hide(); - m_vKeyboard->hide(); - break; - case pageType::wecharLogin: - m_digitalAuthDialog->hide(); - m_digitalAuthDialog->releaseKeyboard(); - m_weChatAuthDialog->show(); - if(isOnlyWeChatLogin) - { - m_switchButtonGroup->hide(); - } else { - m_switchButtonGroup->show(); - } - m_verificationWidget->hide(); - m_verticalVerificationWidget->hide(); - m_vKeyboardPB->hide(); - m_vKeyboard->hide(); - break; - case pageType::check: - m_digitalAuthDialog->hide(); - m_digitalAuthDialog->releaseKeyboard(); - m_weChatAuthDialog->hide(); - m_switchButtonGroup->hide(); - showVerificationPage(); - m_vKeyboardPB->show(); - break; - default: - break; - } -} - -QWidget* TabletLockWidget::getCurrentWidget() -{ - switch (m_pageType) { - case pageType::pinLogin: - return m_digitalAuthDialog; - case pageType::wecharLogin: - return m_weChatAuthDialog; - case pageType::check: - return m_verificationWidget; - default: - return m_digitalAuthDialog; - } -} - -void TabletLockWidget::showVirtualKeyboard(bool isShow) -{ - m_vKeyboard->setVisible(isShow || m_vKeyboard->isHidden()); - setVirkeyboardPos(); -} - -void TabletLockWidget::setVirkeyboardPos() -{ - if(m_vKeyboard) - { - m_vKeyboard->setGeometry(0 + 20, - height() - height()/3 + 10, - width() - 40 , height()/3 - 20); - m_vKeyboard->raise(); - m_vKeyboard->repaint(); - } -} - -bool TabletLockWidget::isOrientation() -{ - QRect wRect = QApplication::primaryScreen()->geometry(); - if(wRect.height() > wRect.width()) - return true; - return false; -} - -void TabletLockWidget::showVerificationPage() -{ - if(isOrientation()) - { - m_verificationWidget->hide(); - m_verticalVerificationWidget->show(); - } - else - { - m_verificationWidget->show(); - m_verticalVerificationWidget->hide(); - } -} - -//void TabletLockWidget::RecieveKey(int key) -//{ -// if(m_pageType == pageType::pinLogin ||m_pageType == pageType::check) -// m_digitalAuthDialog->RecieveKey(key); -//} - -void TabletLockWidget::updateNetIcon(int status) -{ - switch(status) { - case 0: - //有线 - m_pb_networkManager->setIcon(QIcon(":/image/assets/intel/icon-wired.png")); - break; - case 1: - //无线 - m_pb_networkManager->setIcon(QIcon(":/image/assets/intel/icon-wifi.png")); - break; - case 2: - //有线+无线 - m_pb_networkManager->setIcon(QIcon(":/image/assets/intel/icon-wired.png")); - break; - default: - //无连接 - m_pb_networkManager->setIcon(QIcon(":/image/assets/intel/icon-no-signal.png")); - } -} - -/** - * @Destoryed - * @brief TabletLockWidget::getEduPlatformInterface - * @return - */ -EduPlatformInterface* TabletLockWidget::getEduPlatformInterface() -{ - if(m_eduPlatformInterface == nullptr) - { - m_eduPlatformInterface = new EduPlatformInterface("cn.kylinos.SSOBackend", - "/cn/kylinos/SSOBackend", - QDBusConnection::systemBus(), - this); - } - - return m_eduPlatformInterface; -} - -void TabletLockWidget::onGlobalKeyPress(const quint8 &key) -{ - if (powermanager && powermanager->isVisible()) { - powermanager->onGlobalKeyPress(key); - } -} - -void TabletLockWidget::onGlobalkeyRelease(const quint8 &key) -{ - if (powermanager && powermanager->isVisible()) { - powermanager->onGlobalkeyRelease(key); - } -} diff --git a/src/tabletlockwidget.h b/src/tabletlockwidget.h deleted file mode 100644 index 8acf3b7..0000000 --- a/src/tabletlockwidget.h +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * - * Authors: ZHAI Kang-ning -**/ -#ifndef TABLETLOCKWIDGET_H -#define TABLETLOCKWIDGET_H - -#ifndef QT_NO_KEYWORDS -#define QT_NO_KEYWORDS -#endif - -#include -#include -#include -#include -#include -#include - -class VirtualKeyboardWidget; -class PowerManager; -class AuthDialog; -class Users; -class UserItem; -class DisplayManager; -class QMenu; -class DigitalAuthDialog; -class SwitchButtonGroup; -class WeChatAuthDialog; -class VerificationWidget; -class VerticalVerificationWidget; -class EduPlatformInterface; -class KylinNM; - -class TabletLockWidget : public QWidget -{ - Q_OBJECT -public: - explicit TabletLockWidget(QWidget *parent = nullptr); - ~TabletLockWidget(); - - enum pageType{ - pinLogin = 0, - wecharLogin, - check - }; - - void closeEvent(QCloseEvent *event); - void startAuth(); - void stopAuth(); - bool exitSubWidget() { - return true; - }; -// void RecieveKey(int key); - void setStartupMode(bool mode); - -public Q_SLOTS: - void onGlobalKeyPress(const quint8 &key); - void onGlobalkeyRelease(const quint8 &key); - -Q_SIGNALS: - void closed(); - void capsLockChanged(); - void screenSaver(); - void blackSaver(); - -private: - void initUI(); - void initConnect(); - - void onSwitchPage(); - QWidget* getCurrentWidget(); - EduPlatformInterface* getEduPlatformInterface(); - void updateNetIcon(int status); - - void paintEvent(QPaintEvent *event) override; - - bool isOrientation(); - void showVerificationPage(); - -private Q_SLOTS: - void showPowerManager(); - void showNetManager(); - void showVirtualKeyboard(bool isShow = false); - void setVirkeyboardPos(); - void switchLoginType(int position); - -protected: - bool eventFilter(QObject *obj, QEvent *event); - void resizeEvent(QResizeEvent *event); - -private: - AuthDialog *authDialog; - VirtualKeyboardWidget *m_vKeyboard; - PowerManager *powermanager; - QTimer *timer; - QMenu *usersMenu; - Users *users; - DisplayManager *displayManager; - DigitalAuthDialog *m_digitalAuthDialog; - WeChatAuthDialog *m_weChatAuthDialog; - SwitchButtonGroup *m_switchButtonGroup; - QPushButton *m_pb_powerManager; - QPushButton *m_pb_networkManager; - QPushButton *m_cancelOrBack; - QPushButton *m_pb_skip; - QPushButton *m_vKeyboardPB; - VerificationWidget *m_verificationWidget; - VerticalVerificationWidget *m_verticalVerificationWidget; - EduPlatformInterface *m_eduPlatformInterface; - - KylinNM *m_kylinNM; - QWidget *m_NetManagerWidget; - - int m_authType; - int m_pageType = 0; - bool m_isStartupMode = false; -}; - -#endif // TABLETLOCKWIDGET_H diff --git a/src/test-accounts.cpp b/src/test-accounts.cpp deleted file mode 100644 index 4da700b..0000000 --- a/src/test-accounts.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#include -#include "users.h" -#include - -int main(int argc, char *argv[]) -{ - QCoreApplication app(argc, argv); - - Users users; - - qDebug() << users.getUserByName("kylin"); - - return 0; -} diff --git a/src/types.h b/src/types.h deleted file mode 100644 index 7153a28..0000000 --- a/src/types.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#ifndef TYPES_H -#define TYPES_H - -/* https://www.narf.ssji.net/~shtrom/wiki/projets/gnomescreensavernosession */ -enum SessionStatus -{ - SESSION_AVAILABLE = 0, - SESSION_INVISIBLE = 1, - SESSION_BUSY = 2, - SESSION_IDLE = 3 -}; - -enum ScreenStatus -{ - UNDEFINED = 0x00, - SCREEN_SAVER = 0x01, - SCREEN_LOCK = 0x02, - SCREEN_LOCK_AND_SAVER = 0x03, - SCREEN_BLACK = 0x04, -}; - -#define SM_DBUS_SERVICE "org.gnome.SessionManager" -#define SM_DBUS_PATH "/org/gnome/SessionManager/Presence" -#define SM_DBUS_INTERFACE "org.gnome.SessionManager.Presence" - -#define DM_DBUS_SERVICE "org.freedesktop.DisplayManager" -#define DM_DBUS_PATH "/org/freedesktop/DisplayManager" -#define DM_DBUS_INTERFACE "org.freedesktop.DisplayManager" -#define DM_SEAT_INTERFACE "org.freedesktop.DisplayManager.Seat" - -#define ACT_DBUS_SERVICE "org.freedesktop.Accounts" -#define ACT_DBUS_PATH "/org/freedesktop/Accounts" -#define ACT_DBUS_INTERFACE "org.freedesktop.Accounts" -#define ACT_USER_INTERFACE "org.freedesktop.Accounts.User" - -#define DBUS_PROP_INTERFACE "org.freedesktop.DBus.Properties" - -#define SS_DBUS_SERVICE "org.ukui.ScreenSaver" -#define SS_DBUS_PATH "/" -#define SS_DBUS_INTERFACE "org.ukui.ScreenSaver" - -#define SSWND_DBUS_SERVICE "org.ukui.ScreenSaverWnd" -#define SSWND_DBUS_PATH "/" -#define SSWND_DBUS_INTERFACE "org.ukui.ScreenSaverWnd" - -#define DESKTOP_DBUS_SERVICE "org.ukui.peony" -#define DESKTOP_DBUS_PATH "/org/ukui/peony" -#define DESKTOP_DBUS_INTERFACE "org.ukui.peony" - -#define BIO_ERROR -1 -#define BIO_FAILED 0 -#define BIO_SUCCESS 1 -#define BIO_IGNORE 2 - -#define BIOMETRIC_PAM "BIOMETRIC_PAM" -#define BIOMETRIC_IGNORE "BIOMETRIC_IGNORE" -#define BIOMETRIC_SUCCESS "BIOMETRIC_SUCCESS" -#define BIOMETRIC_FAILED "BIOMETRIC_FAILED" - -#define LG_DBUS_SERVICE "org.freedesktop.login1" -#define LG_DBUS_PATH "/org/freedesktop/login1" -#define LG_DBUS_INTERFACE "org.freedesktop.login1.Manager" - - - -#endif // TYPES_H diff --git a/src/ukss_interface.cpp b/src/ukss_interface.cpp deleted file mode 100644 index 11ea9bd..0000000 --- a/src/ukss_interface.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ - -#include "ukss_interface.h" -#include -#include - -int LockByBlank(QString strReason) -{ - QProcess procCmd; - QString strCmd = QString("ukui-screensaver-command -b %1").arg(strReason); - qDebug()<<"LockByBlank,CMD:"<. - * -**/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "plasma-shell-manager.h" -#include -#include -#include -#include -#include -#include "screensaverwndadaptor.h" -#include -#include -#include "fullbackgroundwidget.h" -#include "configuration.h" -#include "pluginsloader.h" -#define CACHE_DIR "/.cache/ukui-screensaver/" -#define DOUBLE 2 -#define MAX_FILE_SIZE 1024 * 1024 -#define LOG_FILE0 "screensaver_0.log" -#define LOG_FILE1 "screensaver_1.log" -#include - -#define GSETTINGS_SCHEMA_SCREENSAVER "org.ukui.screensaver" -#define KEY_LOCK_ENABLED "lock-enabled" - -FullBackgroundWidget *window = NULL; -static void -messageOutput(QtMsgType type, const QMessageLogContext &context,const QString &msg); - -void checkIslivecd() -{ - char cmd[128] = {0}; - char str[1024]; - FILE *fp; - - int n = sprintf(cmd, "cat /proc/cmdline"); - Q_UNUSED(n) - - fp = popen(cmd, "r"); - while(fgets(str, sizeof(str)-1, fp)) { - if(strstr(str,"boot=casper")) - { - printf("is livecd\n"); - exit(0); - } - } - pclose(fp); - - QString filepath = QDir::homePath() + "/Desktop" + "/kylin-os-installer.desktop"; - QFileInfo file(filepath); - if(!file.exists()) - return; - if(getuid() != 999) - return; - exit(0); -} - -void checkIsRunning() -{ - int fd, len; - char buf[32]; - struct flock lock; - - const QString PID_DIR = QString("/var/run/user/%1").arg(QString::number(getuid())); - QString env = qgetenv("DISPLAY"); - const QString PID_FILE = PID_DIR + QString("/ukui-screensaver%1.pid").arg(env); - - qDebug() << PID_DIR; - QDir dir(PID_DIR); - if(!dir.exists()) { - if(!dir.mkdir(PID_DIR.toLocal8Bit().data())) { - perror("create pid directory failed"); - exit(1); - } - } - if( (fd = open(PID_FILE.toLocal8Bit().data(), - O_RDWR | O_CREAT, 0666)) == -1){ - perror("open pid file failed"); - exit(1); - } - - memset(&lock, 0, sizeof(struct flock)); - lock.l_type = F_WRLCK; - lock.l_whence = SEEK_SET; - - if(fcntl(fd, F_SETLK, &lock) < 0) { -// perror("fcntl F_SETLK failed"); - printf("There is already an instance running\n"); - exit(1); - } - - len = snprintf(buf, sizeof(buf), "%d", getpid()); - ftruncate(fd, 0); - if(write(fd, buf, len) != len) { - perror("write pid to lock file failed"); - exit(1); - } -} - -void handler(int signum) -{ - window->closeScreensaver(); -} - -#define WORKING_DIRECTORY "/usr/share/ukui-screensaver" -int main(int argc, char *argv[]) -{ - LayerShellQt::Shell::useLayerShell(); - - if(argc < 2) - return 0; - - initUkuiLog4qt("ukui-screensaver-dialog"); - // 重启或关机时不被session关掉 - qunsetenv("SESSION_MANAGER"); - checkIsRunning(); - checkIslivecd(); - - qputenv("QT_QPA_PLATFORMTHEME",QByteArray("ukui")); - -#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)) - QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); - QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); -#endif -#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) - QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); -#endif - - qunsetenv("QT_IM_MODULE"); - //signal(SIGTERM,handler); - QApplication a(argc, argv); - QApplication::setSetuidAllowed(true); - - LogindIntegration *m_logind = new LogindIntegration(&a); - QObject::connect(m_logind, &LogindIntegration::requestUnlock, [=]() { - if (window) { - window->closeScreensaver(); - } else { - exit(0); - } - }); - if (!m_logind->isSessionActive()) { - QEventLoop *loopTemp = new QEventLoop(&a); - QObject::connect(m_logind, &LogindIntegration::sessionActiveChanged, [loopTemp](bool isActive) { - qDebug()<<"sessionActiveChanged:"<isRunning()) { - loopTemp->quit(); - } - }); - QObject::connect(m_logind, &LogindIntegration::requestLock, [loopTemp]() { - qDebug()<<"session requestLock!"; - if (loopTemp->isRunning()) { - loopTemp->quit(); - } - }); - loopTemp->exec(); - } - - //命令行参数解析 - QCommandLineParser parser; - parser.setApplicationDescription(QGuiApplication::translate("main", "Dialog for the ukui ScreenSaver.")); - parser.addHelpOption(); - parser.addVersionOption(); - parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions); // 举例说明:将 "-adb" 当成一个选项来看,而不是看成 "-a -b -c" - - QCommandLineOption lockOption(QStringLiteral("lock"), - QGuiApplication::translate("main", "lock the screen immediately")); - QCommandLineOption lstOption(QStringLiteral("lock-startup"), - QGuiApplication::translate("main", "lock the screen immediately")); - QCommandLineOption sessionIdleOption(QStringLiteral("session-idle"), - QGuiApplication::translate("main", "activated by session idle signal")); - QCommandLineOption lscreensaverOption(QStringLiteral("lock-screensaver"), - QGuiApplication::translate("main", "lock the screen and show screensaver immediately")); - QCommandLineOption screensaverOption(QStringLiteral("screensaver"), - QGuiApplication::translate("main", "show screensaver immediately")); - QCommandLineOption blankOption(QStringLiteral("blank"), - QGuiApplication::translate("main", "lock the screen and show screensaver immediately")); - QCommandLineOption delayOption(QStringLiteral("delay"), - QGuiApplication::translate("main", "show blank screensaver immediately and delay time to show lock"), - QGuiApplication::translate("delay", "how long to show lock"), "0"); - QCommandLineOption hasLockOption(QStringLiteral("has-lock"), - QGuiApplication::translate("main", "show blank screensaver immediately and if lock"), - QGuiApplication::translate("has-lock", "if show lock"), "1"); - parser.addOptions({lockOption, lstOption,sessionIdleOption , screensaverOption,blankOption,lscreensaverOption,delayOption,hasLockOption}); - parser.process(a); - - QString strHostCloundPlatform = Configuration::instance()->getHostCloudPlatform(); - qDebug()<<"HostCloundPlatform:"<start(QThread::HighestPriority); - pluginsLoader->wait(); - - if(parser.isSet(blankOption)) - { - int nDelay = 0; - bool isHasLock = true; - if (parser.isSet(delayOption)){ - int nDelayValue = parser.value(delayOption).toInt(); - if (nDelayValue > 0) { - nDelay = nDelayValue; - } - } - if (parser.isSet(hasLockOption)){ - int nHasLockValue = parser.value(hasLockOption).toInt(); - if (nHasLockValue == 0) { - isHasLock = false; - } - } - qDebug()<<"-------------:"<onBlankScreensaver(nDelay, isHasLock); - } - -#ifndef USE_INTEL - syslog(LOG_INFO, "[ukui-screensaver-dialog] window show!!"); - window->show(); - window->activateWindow(); - syslog(LOG_INFO, "[ukui-screensaver-dialog] window show done!!"); -#endif - if(parser.isSet(lockOption)) - { - window->lock(); - } - - if(parser.isSet(lstOption)) - { - window->setIsStartup(true); - window->lock(); - } - - if(parser.isSet(sessionIdleOption)) - { - if(window->onSessionStatusChanged(SESSION_IDLE) == -1) { - window->close(); - return 0; - } - } - - if(parser.isSet(lscreensaverOption)) - { - window->onScreensaver(); - } -/* - if(parser.isSet(blankOption)) - { - window->onBlankScreensaver(); - } -*/ - if(parser.isSet(screensaverOption)) - { - window->showScreensaver(true); - } - -#ifdef USE_INTEL - window->show(); - window->activateWindow(); -#endif - - - bool isWayland = false; - if(QString(qgetenv("XDG_SESSION_TYPE")) == "wayland" && !QX11Info::isPlatformX11()) { - isWayland = true; - } -// if (isWayland){ -// PlasmaShellManager::getInstance(); -// PlasmaShellManager::getInstance()->setAppWindowKeepAbove(true); -// } - if (isWayland) { - if (auto layerShellWindow = LayerShellQt::Window::get(window->windowHandle())) { - layerShellWindow->setExclusiveZone(-1); - layerShellWindow->setLayer(LayerShellQt::Window::LayerOverlay); - layerShellWindow->setKeyboardInteractivity(LayerShellQt::Window::KeyboardInteractivityExclusive); - } - } - QString username = getenv("USER"); - int uid = getuid(); - QDBusInterface *interface = new QDBusInterface("cn.kylinos.Kydroid2", - "/cn/kylinos/Kydroid2", - "cn.kylinos.Kydroid2", - QDBusConnection::systemBus(), - window); - - QDBusMessage msg = interface->call(QStringLiteral("SetPropOfContainer"),username, uid, "is_kydroid_on_focus", "0"); - return a.exec(); -} - -static void messageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg) -{ - Q_UNUSED(context) - QDateTime dateTime = QDateTime::currentDateTime(); - QByteArray time = QString("[%1] ").arg(dateTime.toString("MM-dd hh:mm:ss.zzz")).toLocal8Bit(); - QByteArray localMsg = msg.toLocal8Bit(); - - QString name[DOUBLE] = {LOG_FILE0, LOG_FILE1}; - FILE *log_file = nullptr; - QString logFilePath; - int fileSize; - static int i = 0; - QDir dir; - - if (dir.mkpath(QDir::homePath() + CACHE_DIR)) { - logFilePath = QDir::homePath() + CACHE_DIR + "/" + name[i]; - log_file = fopen(logFilePath.toLocal8Bit().constData(), "a+"); - } - - QString filePath(context.file); - int separator = filePath.lastIndexOf('/'); - QString fileName = filePath.right(filePath.length() - separator - 1); - const char *file = fileName.toLocal8Bit().data(); - - switch(type) { - case QtDebugMsg: - fprintf(log_file? log_file:stderr, "%s Debug: %s:%u: %s\n", time.constData(), file, context.line, localMsg.constData()); - break; - case QtInfoMsg: - fprintf(log_file? log_file:stderr, "%s Info: %s:%u: %s\n", time.constData(), file, context.line, localMsg.constData()); - break; - case QtWarningMsg: - fprintf(log_file? log_file:stderr, "%s Warnning: %s:%u: %s\n", time.constData(), file, context.line, localMsg.constData()); - break; - case QtCriticalMsg: - fprintf(log_file? log_file:stderr, "%s Critical: %s:%u: %s\n", time.constData(), file, context.line, localMsg.constData()); - break; - case QtFatalMsg: - fprintf(log_file? log_file:stderr, "%s Fatal: %s:%u: %s\n", time.constData(), file, context.line, localMsg.constData()); - abort(); - } - fflush(stderr); - - if (log_file) { - fileSize = ftell(log_file); - if (fileSize >= MAX_FILE_SIZE) { - i = (i + 1) % DOUBLE; - logFilePath = QDir::homePath() + logFilePath + "/" + name[i]; - if (QFile::exists(logFilePath)) { - QFile temp(logFilePath); - temp.remove(); - } - } - fclose(log_file); - } -} diff --git a/src/ukui-screensaver.pro b/src/ukui-screensaver.pro deleted file mode 100644 index aab53d3..0000000 --- a/src/ukui-screensaver.pro +++ /dev/null @@ -1,81 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2018-04-09T11:40:40 -# -#------------------------------------------------- -QT += core gui dbus x11extras - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -include(BioAuth/bioauth.pri) -include(VirtualKeyboard/VirtualKeyboard.pri) - -TARGET = ukui-screensaver-dialog -TEMPLATE = app - -# The following define makes your compiler emit warnings if you use -# any feature of Qt which has been marked as deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS \ - QT_MESSAGELOGCONTEXT - -LIBS += -lpam -lpam_misc -lX11 -lXext -lXtst - -CONFIG += link_pkgconfig -PKGCONFIG += gio-2.0 x11 xcb xtst - -# You can also make your code fail to compile if you use deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - -INCLUDEPATH += \ - VirtualKeyboard/src/ - BioAuth/include/ - -SOURCES += \ - ukui-screensaver-dialog.cpp \ - mainwindow.cpp \ - unixsignallistener.cpp \ - auth-pam.cpp \ - authdialog.cpp \ - gsettings.cpp \ - auxiliary.cpp \ - configuration.cpp \ - screensaverwidget.cpp \ - screensavermode.cpp \ - event_monitor.cpp \ - monitorwatcher.cpp - -HEADERS += \ - mainwindow.h \ - unixsignallistener.h \ - auth-pam.h \ - auth.h \ - authdialog.h \ - gsettings.h \ - auxiliary.h \ - configuration.h \ - screensaverwidget.h \ - screensavermode.h \ - event_monitor.h \ - monitorwatcher.h - -FORMS += \ - mainwindow.ui \ - authdialog.ui - -RESOURCES += \ - assets.qrc - -TRANSLATIONS = ../i18n_ts/zh_CN.ts \ - ../i18n_ts/ru.ts \ - ../i18n_ts/fr.ts \ - ../i18n_ts/pt.ts \ - ../i18n_ts/es.ts \ - ../i18n_ts/bo_CN.ts - -target.path = /usr/bin/ - -INSTALLS += target diff --git a/src/unixsignallistener.cpp b/src/unixsignallistener.cpp deleted file mode 100644 index 6cb1583..0000000 --- a/src/unixsignallistener.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#include "unixsignallistener.h" -#include -#include -#include -#include -#include - -int UnixSignalListener::sigusr1Fd[2]; - -UnixSignalListener::UnixSignalListener(QObject *parent) : QObject(parent) -{ - if (::socketpair(AF_UNIX, SOCK_STREAM, 0, sigusr1Fd)) - qFatal("Couldn't create SIGUSR1 socketpair"); - snUsr1 = new QSocketNotifier(sigusr1Fd[1], QSocketNotifier::Read, this); - connect(snUsr1, &QSocketNotifier::activated, this, &UnixSignalListener::handleSigUsr1); -} - -void UnixSignalListener::usr1SignalAction(int sig, siginfo_t *siginfo, void *ucontext) -{ - (void)sig; - (void)ucontext; - char buffer[16]; - sprintf(buffer, "%d", siginfo->si_pid); - int ignore = ::write(sigusr1Fd[0], buffer, strlen(buffer) + 1); - (void)ignore; -} - -void UnixSignalListener::chldSignalAction(int /*sig*/, siginfo_t */*siginfo*/, void */*ucontext*/) -{ - ::waitpid(-1, NULL, 0); -} - -void UnixSignalListener::handleSigUsr1() -{ - snUsr1->setEnabled(false); - char buffer[16]; - int pid; - int ignore = ::read(sigusr1Fd[1], buffer, sizeof(buffer)); - sscanf(buffer, "%d", &pid); - (void)ignore; - - /* Do Qt stuff */ - Q_EMIT transition(pid); - - snUsr1->setEnabled(true); -} diff --git a/src/unixsignallistener.h b/src/unixsignallistener.h deleted file mode 100644 index 2a1da96..0000000 --- a/src/unixsignallistener.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#ifndef UNIXSIGNALLISTENER_H -#define UNIXSIGNALLISTENER_H - -#ifndef QT_NO_KEYWORDS -#define QT_NO_KEYWORDS -#endif - -#include -#include -#include - -class UnixSignalListener : public QObject -{ - Q_OBJECT -public: - explicit UnixSignalListener(QObject *parent = nullptr); - -public: - /* Unix signal handlers. */ - static void usr1SignalAction(int sig, siginfo_t *siginfo, void *ucontext); - static void chldSignalAction(int sig, siginfo_t *siginfo, void *ucontext); - -Q_SIGNALS: - /* pid is the sending process id */ - void transition(int pid); /* Finite State Machine Driven Signal */ - -public Q_SLOTS: - /* Qt signal handlers. */ - void handleSigUsr1(); - -private: - static int sigusr1Fd[2]; - QSocketNotifier *snUsr1; -}; - -#endif // UNIXSIGNALLISTENER_H diff --git a/src/userinfo.cpp b/src/userinfo.cpp new file mode 100644 index 0000000..be2e55f --- /dev/null +++ b/src/userinfo.cpp @@ -0,0 +1,114 @@ +/* + * Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * +**/ +#include "userinfo.h" +#include "global_utils.h" + +UserInfo::UserInfo() + : m_isLoggedIn(false) + , m_uId(-1) + , m_strBackground(DEFAULT_BACKGROUND_PATH) + , m_strLang(qgetenv("LANG")) + , m_strName("") +{ + m_strHeadImage = getDefaultFace(); +} + +UserInfo::UserInfo(const UserInfo &userInfo) + : m_isLoggedIn(userInfo.m_isLoggedIn) + , m_uId(userInfo.m_uId) + , m_strHeadImage(userInfo.m_strHeadImage) + , m_strFullName(userInfo.m_strFullName) + , m_strBackground(userInfo.m_strBackground) + , m_strLang(userInfo.m_strLang) + , m_strName(userInfo.m_strName) +{ + +} + +UserInfo::~UserInfo() +{ + +} + +bool UserInfo::operator==(const UserInfo &userInfo) const +{ + return userInfo.uid() == m_uId && userInfo.name() == m_strName; +} + +UserInfo& UserInfo::operator=(const UserInfo &userInfo) +{ + if (this == &userInfo) return *this; + + updateLoggedIn(userInfo.isLoggedIn()); + updateUid(userInfo.uid()); + updateHeadImage(userInfo.headImage()); + updateFullName(userInfo.fullName()); + updateBackground(userInfo.backGround()); + updateLang(userInfo.lang()); + updateName(userInfo.name()); + return *this; +} + +void UserInfo::updateLoggedIn(const bool &isLoggedIn) +{ + m_isLoggedIn = isLoggedIn; +} + +void UserInfo::updateUid(const uid_t &id) +{ + m_uId = id; +} + +void UserInfo::updateHeadImage(const QString &path) +{ + m_strHeadImage = path; +} + +void UserInfo::updateFullName(const QString &fullName) +{ + m_strFullName = fullName; +} + +void UserInfo::updateBackground(const QString &backGround) +{ + m_strBackground = backGround; +} + +void UserInfo::updateLang(const QString &lang) +{ + m_strLang = lang; +} + +void UserInfo::updateName(const QString &name) +{ + m_strName = name; +} + +QDebug operator <<(QDebug stream, const UserInfo &userInfo) +{ + stream << "[" + << userInfo.uid() + << userInfo.name() + << userInfo.fullName() + << userInfo.headImage() + << userInfo.backGround() + << userInfo.isLoggedIn() + << userInfo.lang() + << "]"; + return stream; +} diff --git a/src/userinfo.h b/src/userinfo.h new file mode 100644 index 0000000..593858b --- /dev/null +++ b/src/userinfo.h @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * +**/ +#ifndef USERINFO_H +#define USERINFO_H + +#include +#include +#include + +class UserInfo +{ +public: + UserInfo(); + UserInfo(const UserInfo &userInfo); + virtual ~UserInfo(); + + bool operator==(const UserInfo &userInfo) const; + UserInfo& operator=(const UserInfo &userInfo); + +public: + inline bool isLoggedIn() const { return m_isLoggedIn; } + inline uid_t uid() const { return m_uId; } + inline QString headImage() const { return m_strHeadImage; } + inline QString fullName() const { return m_strFullName; } + inline QString backGround() const { return m_strBackground; } + inline QString lang() const { return m_strLang; } + inline QString name() const { return m_strName; } + + void updateLoggedIn(const bool &isLoggedIn); + void updateUid(const uid_t &id); + void updateHeadImage(const QString &path); + void updateFullName(const QString &fullName); + void updateBackground(const QString &backGround); + void updateLang(const QString &lang); + void updateName(const QString &name); + +protected: + bool m_isLoggedIn; // 是否已登录 + uid_t m_uId; // 用户 uid + QString m_strHeadImage; // 用户头像 + QString m_strFullName; // 用户全名 + QString m_strBackground; // 用户界面背景 + QString m_strLang; // 用户语言 + QString m_strName; // 用户名 +}; + +typedef std::shared_ptr UserInfoPtr; + +QDebug operator <<(QDebug stream, const UserInfo &userInfo); + +#endif // USERINFO_H diff --git a/src/users.cpp b/src/users.cpp deleted file mode 100644 index 1e4a305..0000000 --- a/src/users.cpp +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#include "users.h" - -#include -#include -#include -#include -#include -#include - -#include "types.h" -#include -#include - -QDebug operator<<(QDebug stream, const UserItem &user) -{ - stream << user.name << user.realName << user.uid - << user.icon << user.path; - return stream; -} - -Users::Users(QObject *parent) : QObject(parent) -{ - if (Utils::isCommunity()) { - defaultIcon = ":/image/assets/01-default-community.png"; - } else { - //优先读取控制面板的默认头像文件,保持登录锁屏默认头像和控制面板一致 - QFile faceFile("/usr/share/ukui/faces/default.png"); - if(faceFile.exists()){ - defaultIcon = "/usr/share/ukui/faces/default.png"; - }else{ - defaultIcon = ":/image/assets/01-default-commercial.png"; - } - } - - loadUsers(); -} - -QList Users::getUsers() -{ - return users; -} - -UserItem Users::getUserByName(const QString &name) -{ - for(int i = 0 ; i < users.size() ; i++) { - if(users.at(i).name == name) - { - return users.at(i); - } - } - UserItem user; - if(name == "root") - { - user.icon = "/root/.face"; - if(!QFile(user.icon).exists()) - { - user.icon = defaultIcon; - } - } - else - { - user.icon = qgetenv("HOME")+"/.face"; - if(!QFile(user.icon).exists()) - { - user.icon = defaultIcon; - } - } - user.name = name; - user.path = ""; - user.realName = name; - user.uid = getuid(); - return user; -} - -QString Users::getDefaultIcon() -{ - return defaultIcon; -} - -bool compareBarData(const UserItem &user1, const UserItem &user2) -{ - if (user1.realName < user2.realName) - { - return true; - } - return false; -} - -//https://stackoverflow.com/questions/20206376/ -//how-do-i-extract-the-returned-data-from-qdbusmessage-in-a-qt-dbus-call -void Users::loadUsers() -{ - qDebug() << "loadUsers"; - actService = new QDBusInterface(ACT_DBUS_SERVICE, - ACT_DBUS_PATH, - ACT_DBUS_INTERFACE, - QDBusConnection::systemBus()); - - connect(actService, SIGNAL(UserAdded(const QDBusObjectPath&)), - this, SLOT(onUserAdded(const QDBusObjectPath&))); - connect(actService, SIGNAL(UserDeleted(const QDBusObjectPath&)), - this, SLOT(onUserDeleted(const QDBusObjectPath&))); - QDBusMessage ret = actService->call("ListCachedUsers"); - QList outArgs = ret.arguments(); //(QVariant(QDBusArgument,)) - QVariant first = outArgs.at(0); //QVariant(QDBusArgument,) - const QDBusArgument &dbusArgs = first.value(); - QDBusObjectPath path; - dbusArgs.beginArray(); - while (!dbusArgs.atEnd()) - { - dbusArgs >> path; - getUser(path.path()); - } - dbusArgs.endArray(); - qSort(users.begin(), users.end(), compareBarData); -} - -UserItem Users::getUser(const QString &path) -{ - QDBusInterface iface(ACT_DBUS_SERVICE, - path, - DBUS_PROP_INTERFACE, - QDBusConnection::systemBus()); - QDBusMessage ret = iface.call("GetAll", ACT_USER_INTERFACE); - QList outArgs = ret.arguments(); - QVariant first = outArgs.at(0); - const QDBusArgument &dbusArgs = first.value(); - UserItem user; - user.path = path; - dbusArgs.beginMap(); - while(!dbusArgs.atEnd()) - { - QString key; - QVariant value; - dbusArgs.beginMapEntry(); - dbusArgs >> key >> value; - if(key == "UserName") - { - user.name = value.toString(); - } - else if(key == "RealName") - { - user.realName = value.toString(); - } - else if(key == "IconFile") - { - user.icon = value.toString(); - if(!QFile(user.icon).exists()) - { - user.icon = defaultIcon; - } - } - else if(key == "Uid") - { - user.uid = value.toUInt(); - } - dbusArgs.endMapEntry(); - } - dbusArgs.endMap(); - if(user.realName.isEmpty()) - { - user.realName = user.name; - } - users.push_back(user); - return user; -} - -void Users::onUserAdded(const QDBusObjectPath& path) -{ - int index = findUserByPath(path.path()); - if(index >=0 &&index= 0 && index. - * -**/ -#ifndef USERS_H -#define USERS_H - -#include - - -struct UserItem -{ - QString name; - QString realName; - QString icon; - quint64 uid; - QString path; //accounts service path - friend QDebug operator<<(QDebug stream, const UserItem &user); -}; - -class QDBusInterface; -class QDBusObjectPath; -class Users : public QObject -{ - Q_OBJECT -public: - explicit Users(QObject *parent = nullptr); - QList getUsers(); - UserItem getUserByName(const QString &name); - QString getDefaultIcon(); - -private: - void loadUsers(); - UserItem getUser(const QString &path); - int findUserByPath(const QString &path); - -private Q_SLOTS: - void onUserAdded(const QDBusObjectPath& path); - void onUserDeleted(const QDBusObjectPath& path); - -Q_SIGNALS: - void userAdded(const UserItem &user); - void userDeleted(const UserItem &user); - -private: - QDBusInterface *actService; - QList users; - QString defaultIcon; -}; - -#endif // USERS_H diff --git a/src/utils.cpp b/src/utils.cpp deleted file mode 100644 index dc5e9bc..0000000 --- a/src/utils.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#include "utils.h" -#include - - -namespace Utils { - -bool isCommunity() -{ - QString filename = "/etc/os-release"; - QSettings osSettings(filename, QSettings::IniFormat); - - QString versionID = osSettings.value("VERSION_ID").toString(); - - if (versionID.compare("22.04", Qt::CaseSensitive)) { - return false; - } - return true; -} - -} diff --git a/src/utils.h b/src/utils.h deleted file mode 100644 index b00b483..0000000 --- a/src/utils.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2022 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#ifndef UTILS_H -#define UTILS_H - -namespace Utils { - -// 是否为2204社区版本 -bool isCommunity(); - -} - -#endif // UTILS_H diff --git a/src/verificationwidget.cpp b/src/verificationwidget.cpp deleted file mode 100644 index 9acb3e4..0000000 --- a/src/verificationwidget.cpp +++ /dev/null @@ -1,691 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#include "verificationwidget.h" -#include -#include -#include -#include -#include -#include -#include -#include - -#include "common.h" - -#include "wechatauthdialog.h" -#include "eduplatforminterface.h" -#include "accountsinterface.h" - -/** - * 忘记密码后,校验页面:分为二维码校验和手机号校验 - */ - -bool isDigitalString(QString s);//判断字符串是否全为数字 - -VerificationWidget::VerificationWidget(QWidget *parent) : QWidget(parent) -{ - qDebug() << "PermissionCheck"; - resize(1000,400); - QHBoxLayout *mainLayout = new QHBoxLayout(this); - setLayout(mainLayout); - - m_weChatWidget = new WeChatAuthDialog(1,this); - mainLayout->addWidget(m_weChatWidget, 1, Qt::AlignLeft); - m_weChatWidget->setFixedWidth(400); - - mainLayout->addSpacerItem(new QSpacerItem(0,200,QSizePolicy::Fixed,QSizePolicy::Expanding)); - - m_phoneAuthWidget = new PhoneAuthWidget(this); - mainLayout->addWidget(m_phoneAuthWidget, 1, Qt::AlignRight); - m_phoneAuthWidget->setFixedWidth(400); - - connect(m_phoneAuthWidget, &PhoneAuthWidget::pageMessage, this, [=](SwitchPage s, QList list){ - Q_EMIT pageMessage(s, list); - }); - - connect(m_weChatWidget, &WeChatAuthDialog::qRStatusChange, this, [=] (QString loginname, QString loginpwd, int curstatus){ - //QString loginname, QString loginpwd, int curstatus - if (loginname.isEmpty()) - { - // Todo?正在登陆???? - qDebug() << "wechar name is null"; - } else if(getenv("USER") == loginname) - { - Q_EMIT pageMessage(SwitchPage::SwitchToResetPWD, QList());; - } else { - qWarning() << "[error] Username does not match wechat<" << loginname << ">" << " local<" << getenv("USER")<<">"; - m_weChatWidget->showErrorMessage(tr("Please scan by bound WeChat")); - m_weChatWidget->onReset(); - } - }); -} - -VerificationWidget::~VerificationWidget() -{ - m_phoneAuthWidget->close(); - m_weChatWidget->close(); -} - -void VerificationWidget::paintEvent(QPaintEvent *) -{ - int x1 = width() / 2; - int y1 = height() / 4; - int x2 = x1; - int y2 = height() / 3 * 2 + y1; - QLinearGradient linearGra(QPoint(x1, y1), QPoint(x2, y2)); - linearGra.setColorAt(0, QColor(238, 238, 238, 0)); - linearGra.setColorAt(0.5, QColor(255, 255, 255, 138)); - linearGra.setColorAt(1, QColor(216, 216, 216, 0)); - - QPainter painter(this); - QBrush brush(linearGra); - painter.setPen(Qt::transparent); - painter.setBrush(brush); - painter.drawRoundedRect(QRect(x1, y1, 4, height() / 3 * 2), 16, 16); -} - -void VerificationWidget::reloadQR() -{ - m_weChatWidget->reloadQR(); -} - -InputInfos::InputInfos(QWidget *parent): - QWidget(parent) -{ - initUI(); - initConnect(); - setQSS(); -} - -void InputInfos::initUI() -{ - setFixedSize(316, 129); - QGridLayout *mainLayout = new QGridLayout(this); - setLayout(mainLayout); - mainLayout->setColumnStretch(1, 0); - mainLayout->setColumnStretch(2, 1); - mainLayout->setColumnStretch(3, 0); - - m_pPhoneIconLB = new QLabel(this); - m_pPhoneIconLB->setPixmap(QPixmap(":/image/assets/intel/phone.png")); - mainLayout->addWidget(m_pPhoneIconLB, 0, 1, 1, 1, Qt::AlignLeft); - - m_pPhoneLE = new QLineEdit(this); - m_pPhoneLE->setReadOnly(true); - //限制以下特殊符号在lineEdit中的输入 - /*需求变更,不需要用户输入手机号,直接获取已绑定的手机号显示给用户 - QRegExp phoneNumrx = QRegExp("^1([358][0-9]|4[579]|66|7[0135678]|9[89])[0-9]{8}$"); - QRegExpValidator *phoneNumValidator = new QRegExpValidator(phoneNumrx); - m_pPhoneLE->setValidator(phoneNumValidator); - */ - m_pPhoneLE->setText("正在获取手机号..."); - GetPhoneNumThread *workerThread = new GetPhoneNumThread(this); - connect(workerThread, &GetPhoneNumThread::resultReady, this, &InputInfos::onGetPhoneNum); - connect(workerThread, &GetPhoneNumThread::finished, workerThread, &QObject::deleteLater); - workerThread->start(); - - m_pPhoneLE->setPlaceholderText("手机号"); - m_pPhoneLE->setProperty("class", "InputLine"); - mainLayout->addWidget(m_pPhoneLE, 0, 2, 1, 2, Qt::AlignLeft); - - m_pVerCodeIconLB = new QLabel(this); - m_pVerCodeIconLB->setPixmap(QPixmap(":/image/assets/sms.png")); - mainLayout->addWidget(m_pVerCodeIconLB, 1, 1, 1, 1, Qt::AlignLeft); - - //限制以下特殊符号在lineEdit中的输入 - QRegExp verCoderx = QRegExp("^[0-9]{6}$"); - QRegExpValidator *verCodeValidator = new QRegExpValidator(verCoderx); - m_pVerCodeLE = new MyLineEdit(this); - m_pVerCodeLE->setValidator(verCodeValidator); - mainLayout->addWidget(m_pVerCodeLE, 1, 2, 1, 1, Qt::AlignLeft); - - m_pGetVerCodeBT = new QPushButton(this); - m_pGetVerCodeBT->setText(tr("Get code")); - m_pGetVerCodeBT->setEnabled(false); - m_pGetVerCodeBT->setFocusPolicy(Qt::NoFocus); - m_pGetVerCodeBT->setProperty("class", "GetCodeBT"); - m_pGetVerCodeBT->setCursor(QCursor(Qt::PointingHandCursor)); - mainLayout->addWidget(m_pGetVerCodeBT, 1, 3, 1, 1, Qt::AlignLeft); - - m_pNextGetVerCodeQTimer = new QTimer(this); - - m_curInputState = InputState::InputWaiting; - - m_networkWatcher = new NetWorkWatcher(this); -} - -void InputInfos::initConnect() -{ - connect(m_pPhoneLE, &QLineEdit::textChanged, this, &InputInfos::onPhoneTextChanged); - - connect(m_pVerCodeLE, &QLineEdit::textChanged, this, &InputInfos::onVerCodeTextChanged); - - connect(m_pNextGetVerCodeQTimer, &QTimer::timeout, this, &InputInfos::onNextGetVerCodeTimer); - - connect(m_pGetVerCodeBT, &QPushButton::clicked, this, &InputInfos::onGetVerCode); - - connect(m_networkWatcher, &NetWorkWatcher::NetworkStateChanged, this, &InputInfos::onNetworkStateChanged); -} - -void InputInfos::setQSS() -{ - QString style_sheet = ".InputLine{" - "padding:10px 2px 10px 2px;" - "background-color:rgb(255,255,255,0);" - "color:black;" - "}" - ".GetCodeBT{" - "background:rgba(0,0,0,0);" - "color:rgba(38,38,38,115);" - "font-size:16px;" - "}"; - setStyleSheet(style_sheet); - //adjustSize(); -} - -void InputInfos::paintEvent(QPaintEvent *) -{ - QPainter painter(this); - painter.setRenderHint(QPainter::Antialiasing); - painter.setPen(Qt::white); - painter.setBrush(Qt::white); - painter.drawRoundedRect(rect(), 16, 16); - painter.setPen(QColor(226, 226, 226)); - painter.drawLine(QLineF(0, m_pPhoneIconLB->y() + m_pPhoneIconLB->height() + 1, - width(), m_pPhoneIconLB->y() + m_pPhoneIconLB->height() + 1)); -} - -void InputInfos::onPhoneTextChanged(const QString &text) -{ - if(text.length() == 11 && isDigitalString(text)){ - m_pGetVerCodeBT->setEnabled(true); - m_pGetVerCodeBT->setFocusPolicy(Qt::NoFocus); - m_pGetVerCodeBT->setStyleSheet("color:#2FB3E8;"); - - if(m_pVerCodeLE->text().length() == 6){ - Q_EMIT InputStateChanged(InputState::InputFinish); - m_curInputState = InputState::InputFinish; - } - } - else - { - m_pGetVerCodeBT->setEnabled(false); - m_pGetVerCodeBT->setStyleSheet("color:rgba(38, 38, 38, 115);"); - if(InputState::InputFinish == m_curInputState) - { - m_curInputState = InputState::InputWaiting; - Q_EMIT InputStateChanged(InputState::InputWaiting); - } - } -} - -void InputInfos::onNetworkStateChanged(uint state) -{ - if(NM_STATE_CONNECTED_LIMIT == state) - { - m_nextGetVerCodeTime = 0; - emit notGlobal(); - } - else if(NM_STATE_CONNECTED_GLOBAL != state) - { - m_nextGetVerCodeTime = 0; - emit offlineState(); - } - else - emit online(); -} - -void InputInfos::onVerCodeTextChanged(const QString &text) -{ - if(text.length() == 6 && m_pPhoneLE->text().length() == 11 && isDigitalString(m_pPhoneLE->text())) - { - Q_EMIT InputStateChanged(InputState::InputFinish); - m_curInputState = InputState::InputFinish; - } - else if(m_curInputState == InputState::InputFinish && text.length() > 0 && text.length() < 6) - { - Q_EMIT InputStateChanged(InputState::InputWaiting); - m_curInputState = InputState::InputWaiting; - } -} - -void InputInfos::clearInfos() -{ - m_pPhoneLE->clear(); - m_pVerCodeLE->clear(); - if(m_curInputState == InputState::InputFinish) - { - m_curInputState = InputState::InputWaiting; - Q_EMIT InputStateChanged(m_curInputState); - } -} - -QString InputInfos::getVerificationCode() -{ - return m_pVerCodeLE->text(); -} - -QString InputInfos::getPhoneNumer() -{ - return m_phoneNum; -} - -/** - * @brief InputInfos::onGetVerCode - * 获取手机验证码 - */ -void InputInfos::onGetVerCode() -{ - if(!m_networkWatcher->isConnect()) - { - emit offlineState(); - return; - } - - m_networkWatcher->checkOnline(); - - m_pGetVerCodeBT->setEnabled(false); - m_pGetVerCodeBT->setStyleSheet("color:rgba(38, 38, 38, 115);"); - m_nextGetVerCodeTime = 60; - m_pGetVerCodeBT->setText(tr("Recapture(60s)")); - m_pNextGetVerCodeQTimer->start(1000); - - QDBusReply reply = EduPlatformInterface::getInstance()->call("GetVerifyCode", getPhoneNumer()); - if(!reply.isValid()) - { - qDebug() << "info: [InputInfos][onGetVerCode]: DBus Connect Failed!"; - return; - } - // - if(reply.value() != 0) // 默认0为成功 - { - qDebug() << "info: [InputInfos][onGetVerCode]: DBus request failed!"; - return; - } -} - - -void InputInfos::onNextGetVerCodeTimer() -{ - if(m_nextGetVerCodeTime > 0) - --m_nextGetVerCodeTime; - if(m_nextGetVerCodeTime == 20 || m_nextGetVerCodeTime == 40) - m_networkWatcher->checkOnline(); - m_pGetVerCodeBT->setText(tr("Recapture(%1s)").arg(QString::number(m_nextGetVerCodeTime))); - if(m_nextGetVerCodeTime == 0) - { - m_pNextGetVerCodeQTimer->stop(); - m_pGetVerCodeBT->setEnabled(true); - m_pGetVerCodeBT->setFocusPolicy(Qt::NoFocus); - m_pGetVerCodeBT->setText(tr("Get code")); - m_pGetVerCodeBT->setStyleSheet("color:#2FB3E8;"); - return; - } - -} - -void InputInfos::onGetPhoneNum(int errorCode, const QString phoneNum) -{ - switch (errorCode) { - case DBusMsgCode::No_Error: - if(phoneNum != nullptr && phoneNum.size() == 11) - { - m_phoneNum = phoneNum; - m_pPhoneLE->setText(QString(phoneNum).replace(3,4,"****")); - } else { - qWarning() << "error: [InputInfos] onGetPhoneNum 获取到的手机号格式错误:" << phoneNum; - } - break; - case DBusMsgCode::Error_NoReply: - m_pPhoneLE->setText(tr("Service exception...")); - break; - case DBusMsgCode::Error_ArgCnt: - m_pPhoneLE->setText(tr("Invaild parameters...")); - break; - default: - m_pPhoneLE->setText(tr("Unknown fault:%1").arg(errorCode)); - break; - } - - if(DBusMsgCode::No_Error == errorCode && phoneNum != nullptr && phoneNum.size() == 11 && isDigitalString(phoneNum)) - { - - } else { - - qWarning() << "error: [InputInfos] onGetPhoneNum errorcode" << errorCode; - } -} - -void InputInfos::onClearInfo() -{ - m_pVerCodeLE->clear(); -} - -PhoneAuthWidget::PhoneAuthWidget(QWidget *parent) -{ - initUI(); - initConnect(); - setQSS(); -} - -void PhoneAuthWidget::initUI() -{ - QVBoxLayout *phoLayout = new QVBoxLayout(this); - phoLayout->setMargin(0); - - m_pPhoTitleLB = new QLabel(this); - m_pPhoTitleLB->setText(tr("Verification by phoneNum")); - m_pPhoTitleLB->setProperty("class", "titleLB"); - phoLayout->addWidget(m_pPhoTitleLB, 0, Qt::AlignHCenter); - - phoLayout->addSpacing(16); - m_pPhoPromptMsgLB = new QLabel(this); - m_pPhoPromptMsgLB->setText(tr("「 Use SMS to verification 」")); - m_pPhoPromptMsgLB->setProperty("class", "PromptText"); - phoLayout->addWidget(m_pPhoPromptMsgLB, 0, Qt::AlignHCenter); - - m_pPhoErrorMsgLB = new QLabel(this); - m_pPhoErrorMsgCloneLB = new QLabel(this); - m_pPhoErrorMsgLB->setProperty("class", "ErrorMsg"); - m_pPhoErrorMsgCloneLB->setProperty("class", "ErrorMsg"); - hidePhoneErrorMsg(); - phoLayout->addWidget(m_pPhoErrorMsgLB, 0, Qt::AlignHCenter); - phoLayout->addWidget(m_pPhoErrorMsgCloneLB, 0, Qt::AlignHCenter); - - - m_pPhoInputInfos = new InputInfos(this); - phoLayout->addWidget(m_pPhoInputInfos, 0, Qt::AlignHCenter); - - m_pPhoSubmitBT = new QPushButton(this); - m_pPhoSubmitBT->setFocusPolicy(Qt::NoFocus); - m_pPhoSubmitBT->setText(tr("commit")); - m_pPhoSubmitBT->setProperty("class", "BindBT"); - m_pPhoSubmitBT->setCursor(QCursor(Qt::PointingHandCursor)); - m_pPhoSubmitBT->setEnabled(false); - phoLayout->addSpacing(8); - phoLayout->addWidget(m_pPhoSubmitBT, 0, Qt::AlignHCenter); - phoLayout->addStretch(1); - - m_pPhoPromptMsgLB->setWordWrap(true); - - m_hideTimer = new QTimer(this); -} - -void PhoneAuthWidget::initConnect() -{ - connect(m_pPhoInputInfos, &InputInfos::InputStateChanged, this, &PhoneAuthWidget::onInputStateChanged); - - connect(m_pPhoSubmitBT, &QPushButton::clicked, this, &PhoneAuthWidget::onSubmitBTClick); - - connect(m_pPhoInputInfos, &InputInfos::getVerCode, this, &PhoneAuthWidget::onGetVerCode); - - connect(m_pPhoInputInfos, &InputInfos::offlineState, this, &PhoneAuthWidget::onOfflineState); - - connect(m_pPhoInputInfos, &InputInfos::notGlobal, this, &PhoneAuthWidget::onNotGlobal); - - connect(m_pPhoInputInfos, &InputInfos::online, this, &PhoneAuthWidget::hidePhoneErrorMsg); - - connect(m_hideTimer, &QTimer::timeout, this, &PhoneAuthWidget::hidePhoneErrorMsg); - - connect(this, &PhoneAuthWidget::clearInfo, m_pPhoInputInfos, &InputInfos::onClearInfo); -} - -QSize PhoneAuthWidget::sizeHint() const{ - return QWidget::sizeHint(); -} - -void PhoneAuthWidget::hidePhoneErrorMsg() -{ - m_pPhoErrorMsgCloneLB->setFixedHeight(m_pPhoErrorMsgLB->height()); - m_pPhoErrorMsgCloneLB->show(); - m_pPhoErrorMsgLB->hide(); -} - -void PhoneAuthWidget::showPhoneErrorMsg() -{ - if(m_hideTimer->isActive()) - m_hideTimer->stop(); - - m_pPhoErrorMsgLB->show(); - m_pPhoErrorMsgCloneLB->hide(); - - //QTimer::singleShot(5*1000, this,&PhoneAuthWidget::hidePhoneErrorMsg); - m_hideTimer->setSingleShot(true); - m_hideTimer->start(5*1000); -} - -void PhoneAuthWidget::onInputStateChanged(InputInfos::InputState input_state) -{ - if(m_pPhoErrorMsgLB->isVisible()) - hidePhoneErrorMsg(); - if(input_state == InputInfos::InputState::InputFinish) - { - m_pPhoSubmitBT->setEnabled(true); - m_pPhoSubmitBT->setFocusPolicy(Qt::NoFocus); - m_pPhoSubmitBT->setStyleSheet("background:#2FB3E8;"); - } - else - { - m_pPhoSubmitBT->setEnabled(false); - m_pPhoSubmitBT->setStyleSheet("background:rgba(255,255,255,115);"); - } -} - -void PhoneAuthWidget::onSubmitBTClick() -{ - QString tel = m_pPhoInputInfos->getPhoneNumer(); - QString verCode = m_pPhoInputInfos->getVerificationCode(); - - DBusMsgCode code = EduPlatformInterface::getInstance()->CheckUserByPhone(getenv("USER"), tel, verCode); - - switch (code) { - case DBusMsgCode::No_Error: - Q_EMIT pageMessage(SwitchPage::SwitchToResetPWD, QList()); - break; - case DBusMsgCode::Error_NetWork: - m_pPhoErrorMsgLB->setText(tr("Network not connected~")); - break; - case DBusMsgCode::Error_VerifyCode_Timeout: - m_pPhoErrorMsgLB->setText(tr("Verification Code invalid!")); - break; - case DBusMsgCode::Error_VerifyCodeDiff: - m_pPhoErrorMsgLB->setText(tr("Verification Code incorrect.Please retry!")); - break; - case Error_ErrTimesOverMax: - m_pPhoErrorMsgLB->setText(tr("Failed time over limit!Retry after 1 hour!")); - break; - default: - qWarning() << "[ERROR] verification error code is" << code; - m_pPhoErrorMsgLB->setText(tr("verifaction failed!")); - break; - } - if( code != DBusMsgCode::No_Error) - { - showPhoneErrorMsg(); - emit clearInfo(); - m_pPhoSubmitBT->setEnabled(false); - m_pPhoSubmitBT->setStyleSheet("background:rgba(255,255,255,115);"); - } -} - -void PhoneAuthWidget::onGetVerCode() -{ -// DBusMsgCode msgCode = SSOP->m_pRetrievePwdInterface->GetVerificationCode(Cfg->getUsername(), m_pPhoInputInfos->getPhoneNumer()); -// switch (msgCode) { -// case DBusMsgCode::No_Error: -// // 验证码获取无错误 -// break; -// // TODO 更新错误状态 -// default: -// break; -// } -} - -void PhoneAuthWidget::onOfflineState() -{ - m_pPhoErrorMsgLB->setText(tr("Network not connected~")); - showPhoneErrorMsg(); -} - -void PhoneAuthWidget::onNotGlobal() -{ - m_pPhoErrorMsgLB->setText(tr("Network unavailable~")); - showPhoneErrorMsg(); -} - -void PhoneAuthWidget::onQRCodeStateChanged(QString username, QString password, int nState) -{ - QRCodeSwepState state = static_cast(nState); - switch (state) { - case QRCodeSwepState::WaitingSwep: - qDebug() << "info: [QRCodePhoneAuthWidget][onQRCodeStateChanged]: waiting user swep qrcode!"; - break; - case QRCodeSwepState::HaveSwep: - qDebug() << "info: [QRCodePhoneAuthWidget][onQRCodeStateChanged]: user has swep code!"; - break; - case QRCodeSwepState::CancelSwep: - qDebug() << "info: [QRCodePhoneAuthWidget][onQRCodeStateChanged]: user cancel swep code!"; - break; - case QRCodeSwepState::ConfirmSuccess: - { - qDebug() << "info: [QRCodePhoneAuthWidget][onQRCodeStateChanged]: user = [" << username << "] confirm success!"; -// if(username != Cfg->getUsername()) -// { -// resetQRCService(); -// // TODO 更新错误信息 -// } -// else -// emit pageMessage(PageMessage::JumpToNewPswSet, QList()); -// break; - } - case QRCodeSwepState::QRCodeInvalid: - { - qDebug() << "info: [QRCodePhoneAuthWidget][onQRCodeStateChanged]: qrcode invalid!"; -// resetQRCService(); - break; - } - default: - break; - } -} - -void PhoneAuthWidget::setQSS() -{ - QString style_sheet =".PromptText{" - "font-size:24px;" - "color: rgba(255,255,255,192);" - "}" - ".BindBT{" - "background:rgba(255,255,255,115);" - "width:316px;" - "height:64px;" - "border-radius:16px;" - "}" - ".ErrorMsg{" - "color:#FD625E;" - "font-size:14px;" - "}" - ".titleLB{" - "color:#FFFFFF;" - "font-size:32px;" - "}"; - setStyleSheet(style_sheet); -} - -MyLineEdit::MyLineEdit(QWidget *parent) -{ - this->setStyleSheet("padding:10px 2px 10px 2px;" - "background-color:rgb(255,255,255,0);" - "color:grey;" - "font-size:16px"); - setText(tr("Verification code")); -} - -void MyLineEdit::focusInEvent(QFocusEvent *e) -{ - QLineEdit::focusInEvent(e); - if(text() == tr("Verification code")) - this->clear(); - this->setStyleSheet("padding:10px 2px 10px 2px;" - "background-color:rgb(255,255,255,0);" - "color:black;" - "font-size:16px"); -} - -void MyLineEdit::focusOutEvent(QFocusEvent *e) -{ - QLineEdit::focusOutEvent(e); - if(text().isEmpty()) - { - this->setStyleSheet("padding:10px 2px 10px 2px;" - "background-color:rgb(255,255,255,0);" - "color:grey;" - "font-size:16px"); - setText(tr("Verification code")); - } - -} - - - -GetPhoneNumThread::GetPhoneNumThread(QObject *parent) : QThread(parent) -{ - //获取手机号的dbus理论上也是耗时操作,故放到线程里面去请求 -} - -void GetPhoneNumThread::run() -{ - QString phoneNum = ""; - DBusMsgCode ret = DBusMsgCode::Error_UnknownReason; - /**极其不良的重试策略,如果没有服务或者网络问题,会导致不停地重试,应该做优化 - * 1、需要后台服务支持,如果不存在dbus服务,应该直接报错,当前绑定失败不意味着服务不存在,判断逻辑需要研究 - * 2、监听网络变化,网络状态变化时,断网时及时提醒用户网络未连接;联网时,如未获取到已绑定的手机号,需要重新获取; - * 网络异常时,固定次数的重试,都失败后提示用户网络请求异常,并提供可手动刷新的策略 - * */ - while (DBusMsgCode::No_Error != ret) - { - ret = AccountsInterface::getInstance()->GetUserPhone(getenv("USER"), phoneNum); - Q_EMIT resultReady(ret, phoneNum); - sleep(5); - } -} - - -bool isDigitalString(QString s) -{ - for(int i = 0; i< s.length(); i++) - { - if(s.at(i) > '9' || s.at(i) < '0') - { - qDebug() << "phoneNum error at" << i+1 << "position"; - return false; - } - if(i == 2) - i += 4; - } - - for(int i = 3; i< 7; i++) - { - if(s.at(i) != '*') - { - qDebug() << "phoneNum error at" << i+1 << "position unencrypted"; - return false; - } - } - return true; -} diff --git a/src/verificationwidget.h b/src/verificationwidget.h deleted file mode 100644 index 973017e..0000000 --- a/src/verificationwidget.h +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#ifndef VERIFICATIONWIDGET_H -#define VERIFICATIONWIDGET_H - -#include -#include -#include -#include -#include -#include "wechatauthdialog.h" -#include "common.h" -#include "networkwatcher.h" - -class InputInfos; -class PhoneAuthWidget; -class MyLineEdit; - -class InputInfos : public QWidget -{ - Q_OBJECT -public: - enum InputState{ - InputWaiting - , InputFinish - }; - InputInfos(QWidget *parent = nullptr); - QString getPhoneNumer(); - QString getVerificationCode(); - void clearInfos(); - -Q_SIGNALS: - void getVerCode(); - void InputStateChanged(InputState input_state); - void offlineState(); - void notGlobal(); - void online(); - -protected: - void paintEvent(QPaintEvent *); - -private Q_SLOTS: - void onPhoneTextChanged(const QString &text); - void onVerCodeTextChanged(const QString &text); - void onGetVerCode(); - void onNextGetVerCodeTimer(); - void onGetPhoneNum(int errorCode, const QString phoneNum); - void onNetworkStateChanged(uint state); - -public Q_SLOTS: - void onClearInfo(); - -private: - void initUI(); - void initConnect(); - void setQSS(); - -private: - QLabel *m_pPhoneIconLB; - QLineEdit *m_pPhoneLE; - QLabel *m_pVerCodeIconLB; - MyLineEdit *m_pVerCodeLE; - QPushButton *m_pGetVerCodeBT; - QTimer *m_pNextGetVerCodeQTimer; - int m_nextGetVerCodeTime; - QString m_phoneNum = nullptr; - - InputState m_curInputState; - NetWorkWatcher *m_networkWatcher; -}; - -class VerificationWidget : public QWidget -{ - Q_OBJECT -public: - explicit VerificationWidget(QWidget *parent = nullptr); - ~VerificationWidget(); - - void reloadQR(); - -Q_SIGNALS: - void pageMessage(SwitchPage id, QList argvs); -private: - QLabel *m_titleLB; - QLabel *m_phonePromptMsgLB; - WeChatAuthDialog *m_weChatWidget; -//public: - PhoneAuthWidget *m_phoneAuthWidget; - -protected: - void paintEvent(QPaintEvent *); -}; - -class PhoneAuthWidget : public QWidget -{ - Q_OBJECT -public: - PhoneAuthWidget(QWidget* parent = nullptr); - QSize sizeHint() const; - -private: - void initUI(); - void initConnect(); - void setQSS(); - - void showPhoneErrorMsg(); - void hidePhoneErrorMsg(); -Q_SIGNALS: - void pageMessage(SwitchPage id, QList argvs); - void clearInfo(); -private Q_SLOTS: - void onInputStateChanged(InputInfos::InputState input_state); - void onSubmitBTClick(); - void onGetVerCode(); - void onQRCodeStateChanged(QString username, QString password, int nState); - void onOfflineState(); - void onNotGlobal(); - - -private: - // 手机号验证 - QLabel *m_pPhoTitleLB; - QLabel *m_pPhoPromptMsgLB; - QLabel *m_pPhoErrorMsgLB; - QLabel *m_pPhoErrorMsgCloneLB; // 控制格式 - QPushButton *m_pPhoSubmitBT; - InputInfos *m_pPhoInputInfos; - QTimer *m_hideTimer; -}; - -class MyLineEdit : public QLineEdit -{ - Q_OBJECT -public: - explicit MyLineEdit(QWidget *parent = nullptr); - -/*public Q_SLOTS: - void onTextChanged(const QString &text);*/ - -protected: - void focusInEvent(QFocusEvent *) override; - void focusOutEvent(QFocusEvent *) override; -}; - -class GetPhoneNumThread : public QThread -{ - Q_OBJECT -public: - GetPhoneNumThread(QObject *parent); - -protected: - void run() override; - -Q_SIGNALS: - void resultReady(int errorCode, const QString phoneNum); -}; -#endif // VERIFICATIONWIDGET_H diff --git a/src/verticalVerificationwidget.cpp b/src/verticalVerificationwidget.cpp deleted file mode 100644 index e848a45..0000000 --- a/src/verticalVerificationwidget.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#include "verticalVerificationwidget.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "common.h" - -#include "wechatauthdialog.h" -#include "eduplatforminterface.h" -#include "accountsinterface.h" - -/** - * 忘记密码后,校验页面:分为二维码校验和手机号校验 - */ - -VerticalVerificationWidget::VerticalVerificationWidget(QWidget *parent) : QWidget(parent) -{ - qDebug() << "PermissionCheck"; - resize(600,1000); - QVBoxLayout *mainLayout = new QVBoxLayout(this); - setLayout(mainLayout); - - m_weChatWidget = new WeChatAuthDialog(1,this); - mainLayout->addWidget(m_weChatWidget, 1, Qt::AlignCenter); - - mainLayout->addSpacerItem(new QSpacerItem(0, 250, QSizePolicy::Fixed, QSizePolicy::Expanding)); - - m_phoneAuthWidget = new PhoneAuthWidget(this); - mainLayout->addWidget(m_phoneAuthWidget, 1, Qt::AlignCenter); - - connect(m_phoneAuthWidget, &PhoneAuthWidget::pageMessage, this, [=](SwitchPage s, QList list){ - Q_EMIT pageMessage(s, list); - }); - - connect(m_weChatWidget, &WeChatAuthDialog::qRStatusChange, this, [=] (QString loginname, QString loginpwd, int curstatus){ - //QString loginname, QString loginpwd, int curstatus - if (loginname.isEmpty()) - { - // Todo?正在登陆???? - qDebug() << "wechar name is null"; - } else if(getenv("USER") == loginname) - { - Q_EMIT pageMessage(SwitchPage::SwitchToResetPWD, QList());; - } else { - qWarning() << "[error] Username does not match wechat<" << loginname << ">" << " local<" << getenv("USER")<<">"; - m_weChatWidget->showErrorMessage(tr("Please scan by bound WeChat")); - m_weChatWidget->onReset(); - } - }); -} - -VerticalVerificationWidget::~VerticalVerificationWidget() -{ - m_phoneAuthWidget->close(); - m_weChatWidget->close(); -} - -void VerticalVerificationWidget::paintEvent(QPaintEvent *) -{ - int x1 = width() / 3; - int y1 = height() / 2; - int x2 = width() / 3 * 2 ; - int y2 = y1; - QLinearGradient linearGra(QPoint(x1, y1), QPoint(x2, y2)); - linearGra.setColorAt(0, QColor(238, 238, 238, 0)); - linearGra.setColorAt(0.5, QColor(255, 255, 255, 138)); - linearGra.setColorAt(1, QColor(216, 216, 216, 0)); - - QPainter painter(this); - QBrush brush(linearGra); - painter.setPen(Qt::transparent); - painter.setBrush(brush); - painter.drawRoundedRect(QRect(x1, y1, width() / 3 * 2, 4), 16, 16); -} - -void VerticalVerificationWidget::reloadQR() -{ - m_weChatWidget->reloadQR(); -} - - diff --git a/src/verticalVerificationwidget.h b/src/verticalVerificationwidget.h deleted file mode 100644 index 26a94d4..0000000 --- a/src/verticalVerificationwidget.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ -#ifndef VERTICALVERIFICATIONWIDGET_H -#define VERTICALVERIFICATIONWIDGET_H - -#include -#include -#include -#include -#include - -#include "common.h" - -class VerticalVerificationWidget : public QWidget -{ - Q_OBJECT -public: - explicit VerticalVerificationWidget(QWidget *parent = nullptr); - ~VerticalVerificationWidget(); - - void reloadQR(); - -Q_SIGNALS: - void pageMessage(SwitchPage id, QList argvs); -private: - QLabel *m_titleLB; - QLabel *m_phonePromptMsgLB; - WeChatAuthDialog *m_weChatWidget; -//public: - PhoneAuthWidget *m_phoneAuthWidget; - -protected: - void paintEvent(QPaintEvent *); -}; - -#endif // VERTICALVERIFICATIONWIDGET_H diff --git a/src/weathermanager.cpp b/src/weathermanager.cpp deleted file mode 100644 index 506b34c..0000000 --- a/src/weathermanager.cpp +++ /dev/null @@ -1,375 +0,0 @@ -/* - * Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * - * Authors: ZHAI Kang-ning -**/ -#include "weathermanager.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -const QString weatherServerAddr = "http://service.ubuntukylin.com:8001/weather/api/3.0/heweather_data_s6/"; -const QString defaultCityId = "101030100"; //"101030100" 默认天津 -const int weatherReqInterval = 1000 * 60 * 20; //定时更新天气,和麒麟天气保持一致 - -const QByteArray schemaWeather = "org.china-weather-data.settings"; - -static const QMap weatherMap { - {"晴", "100"},{"多云", "101"},{"少云", "102"},{"晴间多云", "103"},{"阴", "104"}, - {"有风", "200"},{"平静", "201"},{"微风", "202"},{"和风", "203"},{"清风", "204"},{"强风劲风", "205"},{"疾风", "206"},{"大风", "207"},{"烈风", "208"},{"风暴", "209"}, - {"狂暴风", "210"},{"飓风", "211"},{"龙卷风", "212"},{"热带风暴", "213"}, - {"阵雨", "300"},{"强阵雨", "301"},{"雷阵雨", "302"},{"强雷阵雨", "303"},{"雷阵雨伴有冰雹", "304"},{"小雨", "305"},{"中雨", "306"},{"大雨", "307"},{"极端降雨", "308"},{"毛毛雨细雨", "309"}, - {"暴雨", "310"},{"大暴雨", "311"},{"特大暴雨", "312"},{"冻雨", "313"},{"小到中雨", "314"},{"中到大雨", "315"},{"大到暴雨", "316"},{"暴雨到大暴雨", "317"},{"大暴雨到特大暴雨", "318"}, - {"雨", "399"}, - {"小雪", "400"},{"中雪", "401"},{"大雪", "402"},{"暴雪", "403"},{"雨夹雪", "404"},{"雨雪天气", "405"},{"阵雨夹雪", "406"},{"阵雪", "407"},{"小到中雪", "408"},{"中到大雪", "409"}, - {"大到暴雪", "410"},{"雪", "499"}, - {"薄雾", "500"},{"雾", "501"},{"霾", "502"},{"扬沙", "503"},{"浮尘", "504"},{"沙尘暴", "507"},{"强沙尘暴", "508"},{"大雾", "509"}, - {"强浓雾", "510"},{"中度霾", "511"},{"重度霾", "512"},{"严重霾", "513"},{"大雾", "514"},{"特强浓雾", "515"}, - {"热", "900"},{"冷", "901"}, - {"未知", "999"} -}; - -WeatherManager::WeatherManager(QObject *parent) : QObject(parent) -{ - //初始化m_net_manager请求天气 - m_net_manager = new QNetworkAccessManager(this); - QObject::connect(m_net_manager, SIGNAL(finished(QNetworkReply*)), - this, SLOT(replyFinished(QNetworkReply*))); - - m_timer = new QTimer(this); - m_timer->setInterval(weatherReqInterval); - - m_local_weather_info = new LocalWeatherInfo(this); - - connect(m_timer, &QTimer::timeout, this, &WeatherManager::weatherRequest); - - m_networkWatcher = new NetWorkWatcher(this); - connect(m_networkWatcher, &NetWorkWatcher::NetworkStateChanged, this, &WeatherManager::onNetworkStateChanged); - - m_networkWatcher->checkOnline(); -} - -void WeatherManager::onNetworkStateChanged(uint state) -{ - qDebug() << state; - if (NM_STATE_CONNECTED_GLOBAL != state) - emit onWeatherUpdate("天气不可用", NULL, NULL); - else - getWeather(); -} - -void WeatherManager::getWeather() -{ - weatherRequest(); - if (m_timer != NULL) - { - m_timer->start(); - } - return; -} - -void WeatherManager::weatherRequest() -{ - if (updateLocation()) - return; - QNetworkRequest request(QUrl(weatherServerAddr + m_city_id + "/")); - m_net_manager->get(request); -} - -bool WeatherManager::updateLocation() -{ - //更新城市信息 未实现 麒麟天气提供gsettings,完成后对接 - if (QGSettings::isSchemaInstalled(schemaWeather)) { - m_settings = new QGSettings(schemaWeather,"",this); //org/ukui/indicator-china-weather path - if(getLogcalWeather()) - { - emit onWeatherUpdate(m_local_weather_info->getCityName(), - m_local_weather_info->getCondText(), - m_local_weather_info->getTemperature()); - - - m_networkWatcher->checkOnline(); - return true; - } - m_city_id = getLogcalCityId(); - } - - if (m_city_id.isEmpty()) - m_city_id = defaultCityId; - - return false; -} - -bool WeatherManager::getLogcalWeather() -{ - if (m_settings != nullptr) - { - //"1920-08-27 10:17:42,101310204,澄迈,小雨,95%,25℃,北风,1级," 时间,城市编码,城市名称,天气,湿度,温度,风向,风力 - QString weather = m_settings->get("weather").toString(); - QStringList weatherInfoList = weather.split(","); - if (weatherInfoList.size() < 9) - return false; - m_local_weather_info->setTime(weatherInfoList.at(0)); - if(!m_local_weather_info->isTimeValid()) - return false; - - m_local_weather_info->setCityId(weatherInfoList.at(1)); - m_local_weather_info->setCityName(weatherInfoList.at(2)); - m_local_weather_info->setCondText(weatherInfoList.at(3)); - m_local_weather_info->setAirHumidity(weatherInfoList.at(4)); - m_local_weather_info->setTemperature(weatherInfoList.at(5)); - m_local_weather_info->setWindDirection(weatherInfoList.at(6)); - m_local_weather_info->setWindForce(weatherInfoList.at(7)); - return true; - } - - return false; -} - -QString WeatherManager::getLogcalCityId() -{ - if (m_settings != nullptr) { - QString citys = m_settings->get("citylist").toString();//"101010100," - if (citys.isEmpty()) - return ""; - - QStringList cityList = citys.split(","); - if (cityList.size() >= 1) - { - QString s = cityList.at(0); - qDebug() << "local city id = " << s; - return s; - } - } - return ""; -} - -void WeatherManager::replyFinished(QNetworkReply *reply) -{ - if(reply != nullptr && reply->error() != QNetworkReply::NoError) - { - qWarning() << "[WeatherManager][replyFinished] get weather error:(" - << reply->error() << ")" << reply->errorString(); - if (m_networkTryNum < 15) - { - m_networkTryNum++; - QTimer::singleShot(1000, this, [=]{ - weatherRequest(); - }); - } else { - m_networkTryNum = 0; - } - emit onWeatherUpdate("天气不可用", "", ""); - return; - } - - //注:天气信息只解析了锁屏需要展示的部分 - QByteArray BA; - QJsonDocument JD; - QJsonParseError JPE; - - BA = reply->readAll(); - // QTextCodec *codec = QTextCodec::codecForName("UTF-8"); - // QString all = codec->toUnicode(BA); - // qDebug() << "reply is:" << all; - - JD = QJsonDocument::fromJson(BA, &JPE); - if (JPE.error == QJsonParseError::NoError) - { - if (JD.isObject()) - { - QJsonObject kylinWeatherObj = JD.object().value("KylinWeather").toObject(); - - QString nowWeather = kylinWeatherObj.value("weather").toObject().value("now").toString(); - m_city_name = kylinWeatherObj.value("weather").toObject().value("location").toString(); - QStringList nowList = nowWeather.split(","); - for(QString now : nowList) - { - if(now.contains("cond_txt")) { - m_cond_txt = now.mid(9); - } - - if (now.contains("tmp")){ - m_temperature = now.mid(4) + "°C"; - } - } - emit onWeatherUpdate(m_city_name, m_cond_txt, m_temperature); - } - } else { - qWarning() << "get weather info error : " << JPE.errorString(); - emit onWeatherUpdate("天气不可用", "", ""); - } - - reply->deleteLater(); -} - -QPixmap WeatherManager::getWeatherIcon() -{ - return getWeatherIcon(m_cond_txt); -} - -QPixmap WeatherManager::getWeatherIcon(QString cond) -{ - if (cond.isEmpty()) - { - qWarning() << "cond info is unknown"; - return QPixmap(":/weather/assets/weather-icon/999.svg").scaled(32,32); - } - - //根据m_cond_txt - QString numStr = weatherMap.value(cond); - if (!numStr.isEmpty()) { - qDebug() << "----------------numStr=" + numStr; - return QPixmap(":/weather/assets/weather-icon/" + numStr +".svg").scaled(32,32); - } - - qWarning() << "天气为|" << cond << "|"; - return QPixmap(":/weather/assets/weather-icon/999.svg").scaled(32,32); -} - -QString WeatherManager::getCityName() -{ - return ""; -} - -QString WeatherManager::getCond() -{ - return ""; -} - -QString WeatherManager::getTemperature() -{ - return ""; -} - -LocalWeatherInfo::LocalWeatherInfo(QObject *parent) -{ -} - -bool LocalWeatherInfo::isTimeValid() -{ - if (m_update_time != nullptr && !m_update_time.isEmpty()) - { - QString strBuffer; - QDateTime time = QDateTime::fromString(m_update_time, "yyyy-MM-dd hh:mm:ss"); - QDateTime currentTime = QDateTime::currentDateTime(); - - if (!time.isValid()) - return false; - - uint timeInterval = currentTime.toTime_t() - time.toTime_t(); - - if((timeInterval <= 21 * 60) - && (timeInterval > 0)) - { - //麒麟天气更新时间为20分钟,加入1分钟容错机制 - return true; - } - } - return false; -} - -void LocalWeatherInfo::setTime(QString time) -{ - m_update_time = time; -} - -QString LocalWeatherInfo::getTime() -{ - return m_update_time; -} - -void LocalWeatherInfo::setCityId(QString cityId) -{ - m_city_id = cityId; -} - -QString LocalWeatherInfo::getCityId() -{ - return m_city_id; -} - -void LocalWeatherInfo::setCityName(QString cityName) -{ - m_city_name = cityName; -} - -QString LocalWeatherInfo::getCityName() -{ - return m_city_name; -} - -void LocalWeatherInfo::setCondText(QString condText) -{ - m_cond_text = condText; -} - -QString LocalWeatherInfo::getCondText() -{ - return m_cond_text; -} - -void LocalWeatherInfo::setAirHumidity(QString airHumidity) -{ - m_air_humidity = airHumidity; -} - -QString LocalWeatherInfo::getAirHumidity() -{ - return m_air_humidity; -} - -void LocalWeatherInfo::setTemperature(QString temperature) -{ - m_temperature = temperature; -} - -QString LocalWeatherInfo::getTemperature() -{ - return m_temperature; -} - -void LocalWeatherInfo::setWindDirection(QString windDirection) -{ - m_wind_direction = windDirection; -} - -QString LocalWeatherInfo::getWindDirection() -{ - return m_wind_direction; -} - -void LocalWeatherInfo::setWindForce(QString windForce) -{ - m_wind_force = windForce; -} - -QString LocalWeatherInfo::getWindForce() -{ - return m_wind_force; -} diff --git a/src/wechatauthdialog.cpp b/src/wechatauthdialog.cpp deleted file mode 100644 index 8deb3ed..0000000 --- a/src/wechatauthdialog.cpp +++ /dev/null @@ -1,364 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * - * Authors: ZHAI Kang-ning -**/ -#include "wechatauthdialog.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "eduplatforminterface.h" - -WeChatAuthDialog::WeChatAuthDialog(QWidget *parent) : QWidget(parent), - m_networkManager(new QNetworkAccessManager(this)), - m_loginQR(new QRLabel(this)), - m_title(new QLabel(this)), - m_guide(new QLabel(this)), - m_errorMsg(new QLabel(this)), - m_networkWatcher(new NetWorkWatcher(this)), - m_timer(new QTimer(this)) -{ - initUI(); -} - -WeChatAuthDialog::WeChatAuthDialog(int type, QWidget *parent) : QWidget(parent), - m_networkManager(new QNetworkAccessManager(this)), - m_loginQR(new QRLabel(this)), - m_title(new QLabel(this)), - m_guide(new QLabel(this)), - m_errorMsg(new QLabel(this)), - m_networkWatcher(new NetWorkWatcher(this)), - m_timer(new QTimer(this)) -{ - m_authType = type; - initUI(); -} - -void WeChatAuthDialog::initUI() -{ - /** - * ************标题*************** - * **********提示信息************** - * **********二维码**************** - * **********错误信息*************** - */ - - this->setContentsMargins(0, 0, 0, 0); - QVBoxLayout *vbLayout = new QVBoxLayout(this); - vbLayout->setContentsMargins(0, 0, 0, 0); - - if (m_authType == authType::login) - { - m_title->setText(tr("Login by wechat")); - m_guide->setText(tr("「 Use registered WeChat account to login 」")); - } else if (m_authType == authType::check) - { - m_title->setText(tr("Verification by wechat")); - m_guide->setText(tr("「 Use bound WeChat account to verification 」")); - } - - m_errorMsg->setText(""); - m_title->setStyleSheet("font-size:32px;color:#ffffff"); - m_guide->setStyleSheet("font-size:24px;color: rgba(255,255,255,192);"); - m_errorMsg->setStyleSheet("font-size:14px;color:#FD625E;"); - m_guide->setWordWrap(true); - m_title->adjustSize(); - m_guide->adjustSize(); - - QPixmap pixmap(":/image/assets/intel/icon-wechat-noqrcode.png"); - m_loginQR->setPixmap(pixmap.scaled(188, 188, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); - m_loginQR->setStyleSheet("QLabel{border-radius: 16px;background:rgb(255,255,255);color:white}"); - //m_loginQR->resize(208,208); - - vbLayout->addWidget(m_title, 0, Qt::AlignCenter); - vbLayout->addSpacerItem(new QSpacerItem(0,16,QSizePolicy::Fixed,QSizePolicy::Preferred)); - vbLayout->addWidget(m_guide, 0, Qt::AlignCenter); - vbLayout->addSpacerItem(new QSpacerItem(0,30,QSizePolicy::Fixed,QSizePolicy::Preferred)); - vbLayout->addWidget(m_loginQR, 0, Qt::AlignCenter); - vbLayout->addWidget(m_errorMsg, 0 ,Qt::AlignCenter); - vbLayout->addStretch(1); - this->adjustSize(); - - - -// //监听网络状态变化 -// QDBusConnection::systemBus().connect(QString("org.freedesktop.NetworkManager"), -// QString("/org/freedesktop/NetworkManager"), -// QString("org.freedesktop.NetworkManager"), -// QString("StateChanged"), this, SLOT(onNetworkStateChanged(uint))); - - connect(m_networkWatcher, &NetWorkWatcher::NetworkStateChanged, this, &WeChatAuthDialog::onNetworkStateChanged); - - connect(m_timer, &QTimer::timeout, this, [=]{ - m_errorMsg->clear(); - }); - -} - -void WeChatAuthDialog::onNetworkStateChanged(uint state) -{ - if(isHidden()) - return; - - if(NM_STATE_CONNECTED_GLOBAL == state) - showErrorMessage(" ", true); - else - showErrorMessage(tr("Network not connected~"), true); - -} - -void WeChatAuthDialog::onReset() -{ - if (m_authType == authType::login) - { - m_title->setText(tr("Login by wechat")); - m_guide->setText(tr("「 Use registered WeChat account to login 」")); - } else if (m_authType == authType::check) - { - m_title->setText(tr("Verification by wechat")); - m_guide->setText(tr("「 Use bound WeChat account to verification 」")); - } - m_guide->show(); - - QPixmap pixmap(":/image/assets/intel/icon-wechat-noqrcode.png"); - m_loginQR->setPixmap(pixmap.scaled(188, 188, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); - m_loginQR->setStyleSheet("QLabel{border-radius: 16px;background:rgb(255,255,255);color:white}"); - //m_loginQR->resize(208,208); - reloadQR(); -} - -void WeChatAuthDialog::initConnect() -{ - QObject::connect(m_networkManager, &QNetworkAccessManager::finished, - this, &WeChatAuthDialog::replyFinished); -} - -void WeChatAuthDialog::getLoginQR() -{ - if(!m_requestQRThread) - { - qDebug() << "[WeChatAuthDialog] getLoginQR create new requestQRThread"; - m_requestQRThread = new RequestQRThread(this); - connect(m_requestQRThread, &RequestQRThread::resultReady, this, &WeChatAuthDialog::onQRUrlReady); - } - - if(!m_isThreadWorking){ - qDebug() << "[WeChatAuthDialog] getLoginQR requestQRThread is not running"; - m_requestQRThread->start(); - m_isThreadWorking = true; - } else { - qDebug() << "[WeChatAuthDialog] getLoginQR requestQRThread is running"; - } -} - -void WeChatAuthDialog::replyFinished(QNetworkReply *reply) -{ - if(!reply->isFinished()) - { - //超时 - reply->abort(); - qWarning() << "error: [WeChatAuthDialog][replyFinished]: network timeout"; - showErrorMessage(tr("Network not connected~")); - reloadQR(); - return; - } - - if (reply->error() == QNetworkReply::NoError) - { - QByteArray bytes = reply->readAll(); - - QSize size(188, 188); - QBitmap mask(size); - QPainter painter(&mask); - painter.setRenderHint(QPainter::Antialiasing); - painter.setRenderHint(QPainter::SmoothPixmapTransform); - painter.fillRect(0, 0, size.width(), size.height(), Qt::white); - painter.setBrush(QColor(0, 0, 0)); - painter.drawRoundedRect(0, 0, size.width(), size.height(), 16, 16); - - QPixmap pixmap; - pixmap.loadFromData(bytes); - QPixmap pixmap_ = pixmap.scaled(188, 188, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); - - pixmap_.setMask(mask); - m_loginQR->setPixmap(pixmap_); - //m_loginQR->resize(208,208); - } - else - { - qWarning() << "网络错误" << reply->error(); - reloadQR(); - // 错误处理-显示错误信息,或显示上一次缓存的图片或叉图。 - } -} - -void WeChatAuthDialog::qRStatusChangeSolt(QString loginname, QString loginpwd, int curstatus) -{ - qDebug() << "---loginname:" << loginname << "---loginpwd:" << loginpwd << "---curstatus:" << curstatus; - QRCodeSwepState state = static_cast(curstatus); - switch (state) { - case QRCodeSwepState::WaitingSwep: - qDebug() << "info: [WeChatAuthDialog][qRStatusChangeSolt]: waiting user swep qrcode!"; - break; - case QRCodeSwepState::HaveSwep: - qDebug() << "info: [WeChatAuthDialog][qRStatusChangeSolt]: user has swep code!"; - m_title->setText(tr("Scan code successfully")); - m_guide->setText(" "); - m_errorMsg->setText(""); - break; - case QRCodeSwepState::CancelSwep: - qDebug() << "info: [WeChatAuthDialog][qRStatusChangeSolt]: user cancel swep code!"; - onReset(); - m_errorMsg->setText(""); - break; - case QRCodeSwepState::ConfirmSuccess: - { - //Todo 判断是否是该用户 - qDebug() << "info: [WeChatAuthDialog][qRStatusChangeSolt]: user = [" << loginname << "] confirm success!"; - Q_EMIT qRStatusChange(loginname, loginpwd, curstatus); - } - case QRCodeSwepState::QRCodeInvalid: - { - qDebug() << "info: [WeChatAuthDialog][onQRCodeStateChanged]: qrcode invalid!"; - onReset(); - break; - }case QRCodeSwepState::QRCodeTimeout: - { - qDebug() << "info: [UserSecondQRCodeLogin][onQRCodeState]: qrcode timeout!"; - onReset(); - // 更新错误信息 - showErrorMessage(tr("Timeout!Try again!")); - break; - } - default: - break; - } -} - - -void WeChatAuthDialog::reloadQR() -{ - if(this->parentWidget()->isHidden() || isHidden()) - return; - qDebug() << "info: [WeChatAuthDialog] [reloadQR] reloadQR"; - getLoginQR(); -} - -void WeChatAuthDialog::showErrorMessage(QString message, bool isLong) -{ - if (m_timer->isActive()) - m_timer->stop(); - onReset(); - m_errorMsg->setText(message); - m_errorMsg->adjustSize(); - m_errorMsg->setGeometry((this->width() - m_errorMsg->width())/2, - this->height() - m_errorMsg->height(), - m_errorMsg->width(), - m_errorMsg->height()); -// if(isLong) -// return; -// QTimer *timer = new QTimer(this); -// connect(timer, &QTimer::timeout, this, [=]{ -// m_errorMsg->setText(" "); -// }); -// timer->start(3000); - m_timer->setSingleShot(true); - m_timer->start(10000); -} - -void WeChatAuthDialog::onQRUrlReady(int errorCode, const QString url) -{ - m_isThreadWorking = false; - if (DBusMsgCode(errorCode) == DBusMsgCode::No_Error) - { - // 从网络上下载二维码 并加载到qrcode - QNetworkRequest request; - request.setUrl(url); - QNetworkReply *reply = m_networkManager->get(request); - QTimer::singleShot(2*1000, this, [=](){ - replyFinished(reply); - }); - } else if(DBusMsgCode(errorCode) == DBusMsgCode::Error_NetWork) - { - qWarning() << "[error] [WeChatAuthDialog] DBus(cn.kylinos.SSOBackend.eduplatform) get url network error"; - QTimer::singleShot(2 * 1000, this, [=]{ - if(this->isVisible() && !m_requestQRThread->isRunning()) - reloadQR(); - }); - } - else { - qWarning() << "[error] connect form DBus(cn.kylinos.SSOBackend.eduplatform)"; - QTimer::singleShot(2 * 1000, this, [=](){ reloadQR(); }); - } -} - -void WeChatAuthDialog::closeEvent(QCloseEvent *event) -{ - if(m_requestQRThread) { - qDebug() << "[WeChatAuthDialog] requestQRThread delete"; - m_requestQRThread->quit(); - m_requestQRThread->wait(); - m_requestQRThread->deleteLater(); - } -} - -void WeChatAuthDialog::showEvent(QShowEvent *event) -{ - m_networkWatcher->checkOnline(); - - onReset(); - connect(EduPlatformInterface::getInstance(),&EduPlatformInterface::QRStatusChange, - this, &WeChatAuthDialog::qRStatusChangeSolt); -} - -void WeChatAuthDialog::hideEvent(QHideEvent *event) -{ - disconnect(EduPlatformInterface::getInstance(),&EduPlatformInterface::QRStatusChange, - this, &WeChatAuthDialog::qRStatusChangeSolt); -} - -QRLabel::QRLabel(QWidget *parent) : QLabel(parent) -{ -} - -void QRLabel::mousePressEvent(QMouseEvent *event) -{ - if(event->button()== Qt::LeftButton) - { - Q_EMIT clicked(); - } -} - -RequestQRThread::RequestQRThread(QObject *parent) : QThread(parent) -{ - // -} - -void RequestQRThread::run() -{ - QString url; - DBusMsgCode ret = EduPlatformInterface::getInstance()->CheckUserByQR(url); - Q_EMIT resultReady(ret, url.toLocal8Bit()); -} diff --git a/src/wechatauthdialog.h b/src/wechatauthdialog.h deleted file mode 100644 index 57b183a..0000000 --- a/src/wechatauthdialog.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * - * Authors: ZHAI Kang-ning -**/ -#ifndef WECHATAUTHDIALOG_H -#define WECHATAUTHDIALOG_H - -#include -#include -#include -#include -#include - -#include -#include "networkwatcher.h" - -class QRLabel; -class RequestQRThread; - -/** - * @brief The WeChatAuthDialog class - * 微信登录、校验界面 - * 一、标题状态改变: - * 成功 事例: 1、微信登录->扫描成功->正在登录··· - * 微信不相符: 2、微信登录->登录失败 - */ -class WeChatAuthDialog : public QWidget -{ - Q_OBJECT -public: - explicit WeChatAuthDialog(QWidget *parent = nullptr); - explicit WeChatAuthDialog(int type, QWidget *parent = nullptr); - enum authType{ - login = 0, - check, - }; - - void reloadQR(); - void showErrorMessage(QString message, bool isLong = false); -// void updateStatus(int status); - void onReset(); - -protected: - void closeEvent(QCloseEvent *event) override; - void hideEvent(QHideEvent *event) override; - void showEvent(QShowEvent *event) override; - -Q_SIGNALS: - void authenticateCompete(bool result); - void qRStatusChange(QString loginname, QString loginpwd, int curstatus); - -private: - void initUI(); - void initConnect(); - - int m_authType = 0; - QNetworkAccessManager *m_networkManager; - QRLabel *m_loginQR; - QLabel *m_title; //标题 - QLabel *m_guide; //提示 - QLabel *m_errorMsg; //错误信息 - RequestQRThread *m_requestQRThread = nullptr; - bool m_isThreadWorking = false; - NetWorkWatcher *m_networkWatcher; - QTimer *m_timer; - - void getLoginQR(); - -private Q_SLOTS: - void replyFinished(QNetworkReply *); - void qRStatusChangeSolt(QString loginname, QString loginpwd, int curstatus); - void onQRUrlReady(int errorCode, const QString url); - void onNetworkStateChanged(uint state); -}; - -class QRLabel : public QLabel -{ - Q_OBJECT -public: - explicit QRLabel(QWidget *parent = nullptr); - -Q_SIGNALS: - void clicked(); - -protected: - void mousePressEvent(QMouseEvent *event) override; -}; - -class RequestQRThread : public QThread -{ - Q_OBJECT -public: - RequestQRThread(QObject *parent); - -protected: - void run() override; - -Q_SIGNALS: - void resultReady(int errorCode, const QString url); -}; - -#endif // WECHATAUTHDIALOG_H diff --git a/agreementwindow.cpp b/src/widgets/agreementwindow.cpp similarity index 52% rename from agreementwindow.cpp rename to src/widgets/agreementwindow.cpp index 8a63c6e..9e279c2 100644 --- a/agreementwindow.cpp +++ b/src/widgets/agreementwindow.cpp @@ -7,15 +7,17 @@ #define CONFIG_FILE "/usr/share/ukui-greeter/ukui-greeter.conf" -AgreementWindow::AgreementWindow(QWidget *parent) : - QWidget(parent) +#define CENTER_WIDTH 960 +#define CENTER_HEIGHT 722 +#define ENSURE_BUTTON_HEIGHT 48 +#define BORDER_WIDTH 40 +AgreementWindow::AgreementWindow(bool hideTitle,QString title,QString text,QWidget *parent) + : m_hideTitle(hideTitle) + , m_title(title) + , m_text(text) + ,QWidget(parent) { - init(); -} - -bool AgreementWindow::getShowLoginPrompt() -{ - return showLoginPrompt; + initUI(); } void AgreementWindow::initUI() @@ -41,7 +43,7 @@ void AgreementWindow::initUI() connect(ensureBtn, &QPushButton::clicked, this, &AgreementWindow::switchPage); titleLbl = new QLabel(centerWidget); - titleLbl->setText(promptTitle); + titleLbl->setText(m_title); titleLbl->setObjectName("titleLbl"); titleLbl->setStyleSheet("#titleLbl{color: white;font-size: 24px;}"); @@ -55,10 +57,7 @@ void AgreementWindow::initUI() setFocusProxy(ensureBtn); - bool res = loadText(); - if(!res || (promptTitle.isEmpty() && !hideTitle)){ - emit switchToGreeter(); - } + browser->setText(m_text); layout->addSpacing(24); layout->addWidget(titleLbl); @@ -66,7 +65,7 @@ void AgreementWindow::initUI() layout->setAlignment(ensureBtn,Qt::AlignCenter); layout->setAlignment(titleLbl,Qt::AlignCenter); - if(hideTitle) + if(m_hideTitle) titleLbl->hide(); } @@ -77,64 +76,16 @@ void AgreementWindow::switchPage() void AgreementWindow::resizeEvent(QResizeEvent *event) { - // qDebug()<<"" - int m_width = 960,m_height = 722 - 88; - if(this->width() < (960+80)) - m_width = (width() - 80)/2; - if(this->height() < (722+80)) - m_height = (height() - 80)/2; + int m_width = CENTER_WIDTH,m_height = CENTER_HEIGHT-ENSURE_BUTTON_HEIGHT-BORDER_WIDTH; + if(this->width() < (CENTER_WIDTH + 2*BORDER_WIDTH)) + m_width = (width() - BORDER_WIDTH)/2; + if(this->height() < (CENTER_HEIGHT+2*BORDER_WIDTH)) + m_height = (height() - BORDER_WIDTH)/2; - centerWidget->setGeometry((width()-m_width)/2,(height()-m_height)/2,m_width,m_height); + if (centerWidget) { + centerWidget->setGeometry((width()-m_width)/2,(height()-m_height)/2,m_width,m_height); - ensureBtn->move((width()-ensureBtn->width())/2,centerWidget->geometry().bottom() + 40); - -} - -bool AgreementWindow::loadText() -{ - if(!promptText.isEmpty()){ - browser->setText(promptText); - return true; + if (ensureBtn) + ensureBtn->move((width()-ensureBtn->width())/2,centerWidget->geometry().bottom() + 40); } - - if(promptTextFilePath.isEmpty()) - return false; - QFile file(promptTextFilePath); - if(!file.exists()) - return false; - file.open(QFile::ReadOnly); - QString str(file.readAll()); - if(str == "") - return false; - browser->setText(str); - file.close(); - return true; - -} - -void AgreementWindow::init() -{ - QSettings *settings = new QSettings(CONFIG_FILE,QSettings::IniFormat); - settings->setIniCodec(QTextCodec::codecForName("utf-8")); - - if(settings->contains("Greeter/showLoginPrompt")){ - showLoginPrompt = settings->value("Greeter/showLoginPrompt").toBool(); - } - - if(settings->contains("Greeter/hideTitle")){ - hideTitle = settings->value("Greeter/hideTitle").toBool(); - } - - if(settings->contains("Greeter/promptTitle")){ - promptTitle = settings->value("Greeter/promptTitle").toString(); - } - - if(settings->contains("Greeter/promptText")){ - promptText = settings->value("Greeter/promptText").toString(); - } - - if(settings->contains("Greeter/promptTextFilePath")){ - promptTextFilePath = settings->value("Greeter/promptTextFilePath").toString(); - } - } diff --git a/agreementwindow.h b/src/widgets/agreementwindow.h similarity index 67% rename from agreementwindow.h rename to src/widgets/agreementwindow.h index 4dca358..f77d3c5 100644 --- a/agreementwindow.h +++ b/src/widgets/agreementwindow.h @@ -11,7 +11,7 @@ class AgreementWindow : public QWidget { Q_OBJECT public: - explicit AgreementWindow(QWidget *parent = nullptr); + explicit AgreementWindow(bool hideTitle,QString title,QString text,QWidget *parent = nullptr); bool getShowLoginPrompt(); void initUI(); @@ -21,25 +21,19 @@ signals: protected: void resizeEvent(QResizeEvent *event); -protected Q_SLOTS: +protected slots: void switchPage(); - private: void init(); - bool loadText(); QTextBrowser *browser = nullptr; QLabel *titleLbl = nullptr; QPushButton *ensureBtn = nullptr; - QFile *file = nullptr; - bool showLoginPrompt = false; - bool hideTitle = true; - - QString promptTitle = ""; - QString promptText = ""; - QString promptTextFilePath = ""; + bool m_hideTitle; + QString m_title; + QString m_text; QWidget *centerWidget = nullptr; diff --git a/src/widgets/authdialog.cpp b/src/widgets/authdialog.cpp new file mode 100644 index 0000000..a7f814f --- /dev/null +++ b/src/widgets/authdialog.cpp @@ -0,0 +1,1947 @@ +#include "authdialog.h" +#include "iconedit.h" +#include "klabel.h" +#include "../lock-dialog/lockdialogmodel.h" +#include "statusbutton.h" +#include "commonfunc.h" +#include "biobuttonlistwidget.h" +#include "definetypes.h" +#include +#include +#include +#include +#include +#include +#include "definetypes.h" +#include +#include +#include +#include "../lock-dialog/pam-tally.h" + +AuthDialog::AuthDialog(LockDialogModel *model, UserInfo userInfo, QWidget *parent) + : QWidget(parent) + , m_modelLockDialog(model) + , m_isLockingFlg(false) + , m_isInputPasswd(false) + , m_curUserInfo(userInfo) + , m_uniauthService(new UniAuthService(this)) +{ + initUI(); +} + +void AuthDialog::initUI() +{ + QVBoxLayout *mainLayout = new QVBoxLayout(this); + mainLayout->setAlignment(Qt::AlignCenter); + mainLayout->setSpacing(16); + mainLayout->setContentsMargins(0, 0, 0, 0); + + // 生物认证提示 + m_tipWidget = new QWidget(this); + + // 头像 + m_headerWidget = new QWidget(this); + + // 用户名 + m_nameWidget = new QWidget(this); + + // 密码输入框 + m_editWidget = new QWidget(this); + + //错误信息提示 + m_messageWidget = new QWidget(this); + + // ukey + m_ukeyPasswdWidget = new QWidget(this); + + // login option + m_widgetLoginOpts = new QWidget(this); + + mainLayout->addStretch(); + mainLayout->addWidget(m_tipWidget); + mainLayout->addWidget(m_headerWidget); + mainLayout->addWidget(m_nameWidget); + mainLayout->addWidget(m_editWidget); + mainLayout->addWidget(m_ukeyPasswdWidget); + mainLayout->addWidget(m_widgetLoginOpts); + mainLayout->addStretch(); + + initTipWidget(); + initHeaderWidget(); + initNameWidget(); + initEditWidget(); + initUkeyPasswordWidget(); + initLoginoptionWidget(); + + initConnections(); + updateUI(); +} + +void AuthDialog::initConnections() +{ + connect(m_modelLockDialog, &LockDialogModel::pamShowMessage, this, &AuthDialog::onPamShowMessage); + connect(m_modelLockDialog, &LockDialogModel::pamShowPrompt, this, &AuthDialog::onPamShowPrompt); + connect(m_modelLockDialog, &LockDialogModel::pamAuthCompleted, this, &AuthDialog::onPamAuthCompleted); + + connect(m_passwordEdit, SIGNAL(clicked(const QString&)), + this, SLOT(onRespond(const QString&))); + + connect(m_messageButton, &QPushButton::clicked, + this, &AuthDialog::onMessageButtonClicked); +} + +bool AuthDialog::eventFilter(QObject *obj, QEvent *event) +{ + if (event->type() == QEvent::KeyRelease) { + MyListWidget *listWidget = qobject_cast(obj); + if (listWidget) { + if (listWidget && listWidget->hasFocus()) { //Tab键切入时,设置焦点状态 + listWidget->setCurrentRow(listWidget->currentRow(), QItemSelectionModel::SelectionFlag::SelectCurrent); + listWidget->currentItemChanged(listWidget->currentItem(), nullptr); + } else { //Tab键切出时,清空焦点状态 + listWidget->setCurrentRow(listWidget->currentRow(), QItemSelectionModel::SelectionFlag::Clear); + } + } + } + + return QWidget::eventFilter(obj, event); +} + +void AuthDialog::resizeEvent(QResizeEvent *event) +{ + updateAuthSize(); +} + +void AuthDialog::updateAuthSize() +{ + this->layout()->setSpacing(16*scale); + if (m_tipWidget) + m_tipWidget->setFixedSize(this->width(), 40*scale); + if (m_tipWidget) + m_headerWidget->setFixedSize(this->width(), 154*scale); + if (m_tipWidget) + m_nameWidget->setFixedSize(this->width(), 40*scale); + if (m_tipWidget) + m_editWidget->setFixedSize(this->width(), 80*scale); + if (m_tipWidget) + m_messageWidget->setFixedSize(this->width(), 40*scale); + if (m_tipWidget) + m_ukeyPasswdWidget->setFixedSize(this->width(), 80*scale); + if (m_tipWidget) + m_widgetLoginOpts->setFixedSize(this->width(), 104*scale); + if (m_tipWidget) + m_labelLoginTypeTip->setFixedSize(m_tipWidget->size()); + if (m_tipWidget) + m_labelHeadImg->setFixedSize(154*scale, 154*scale); + if (m_tipWidget) + m_labelFace->setFixedSize(154*scale, 154*scale); + if (m_tipWidget) + m_labelQRCode->setFixedSize(154*scale, 154*scale); + if (m_tipWidget) + m_labelQRCodeTip->setFixedSize(22*scale, 22*scale); + if (m_tipWidget) + m_labelQRCodeMsg->setFixedHeight(30*scale); + if (m_tipWidget) + m_nameLabel->setFixedSize(this->width(), 40*scale); + if (m_tipWidget) + m_passwordEdit->setFixedSize(240*scale, 40*scale); + if (m_tipWidget) + m_messageLabel->setFixedSize(this->width(), 40*scale); + if (m_tipWidget) + m_messageButton->setFixedSize(200*scale, 40*scale); + if (m_tipWidget) + m_ukeyPasswordEdit->setFixedSize(240*scale, 40*scale); + if (m_tipWidget) + m_ukeyMessageLabel->setFixedSize(this->width(), 40*scale); + if (bottomListWidget) { + bottomListWidget->setFixedSize(QSize(48*bottomListWidget->count() + bottomListWidget->spacing()*2*bottomListWidget->count(), 64)); + bottomListWidget->updateUI(); + } + if (m_tipWidget && bottomListWidget) + m_optionTip->setFixedSize(bottomListWidget->width(), 32*scale); + updateUI(); + +} + +void AuthDialog::initTipWidget() +{ + QVBoxLayout *tipLayout = new QVBoxLayout(m_tipWidget); + tipLayout->setAlignment(Qt::AlignCenter); + m_labelLoginTypeTip = new KLabel(m_tipWidget); + m_labelLoginTypeTip->setText("测试测试测试测试222222222222222222222222222222222222222222222222222222222222"); + m_labelLoginTypeTip->setAlignment(Qt::AlignCenter); + m_labelLoginTypeTip->setFixedSize(m_tipWidget->size()); +} + +void AuthDialog::initHeaderWidget() +{ + // 用户头像 + QVBoxLayout *headerLayout = new QVBoxLayout(m_headerWidget); + headerLayout->setAlignment(Qt::AlignCenter); + headerLayout->setContentsMargins(0, 0, 0, 0); + m_labelHeadImg = new QLabel(m_headerWidget); + headerLayout->addWidget(m_labelHeadImg); + + // 人脸识别头像框 + m_labelFace = new QLabel(m_headerWidget); + m_labelFace->setStyleSheet(QString("border-radius: %1px; border:0px solid white;background-color: rgba(255,255,255,10%);").arg((int)(77))); + headerLayout->addWidget(m_labelFace); + m_labelFace->hide(); + + // 人脸识别重试 + m_fRetryButton = new QPushButton(m_headerWidget); + m_fRetryButton->setFocusPolicy(Qt::NoFocus); +// connect(m_fRetryButton,&QPushButton::clicked, +// this,&AuthDialog::onFRetryButtonClicked); + m_fRetryButton->hide(); + headerLayout->addWidget(m_fRetryButton); + + // 微信认证窗口 + m_labelQRCode = new QLabel(m_headerWidget); + m_labelQRCode->setAlignment(Qt::AlignCenter); + m_labelQRCode->setStyleSheet(QString("border-radius: %1px; border:0px solid white;background-color: rgba(255,255,255,100%);").arg((int)(6))); + m_labelQRCode->hide(); + QVBoxLayout *layoutQRCode = new QVBoxLayout(); + layoutQRCode->setAlignment(Qt::AlignCenter); + layoutQRCode->setSpacing(10); + m_labelQRCode->setLayout(layoutQRCode); + m_labelQRCodeTip = new QLabel(); + layoutQRCode->addWidget(m_labelQRCodeTip, 0, Qt::AlignHCenter); + m_labelQRCodeTip->setPixmap(QIcon::fromTheme("dialog-warning").pixmap(QSize(22,22))); + m_labelQRCodeTip->show(); + m_labelQRCodeMsg = new KLabel(); + m_labelQRCodeMsg->setFontSize(14); + m_labelQRCodeMsg->setStyleSheet("QLabel{background-color:rgba(255,255,255,0);color:rgb(255,0,0)}"); + m_labelQRCodeMsg->hide(); + layoutQRCode->addWidget(m_labelQRCodeMsg, 0, Qt::AlignHCenter); + headerLayout->addWidget(m_labelQRCode); + +} + +void AuthDialog::initNameWidget() +{ + QVBoxLayout *nameLayout = new QVBoxLayout(m_nameWidget); + nameLayout->setAlignment(Qt::AlignHCenter); + nameLayout->setContentsMargins(0, 0, 0, 0); + m_nameLabel = new KLabel(m_nameWidget); + m_nameLabel->setAlignment(Qt::AlignCenter); + m_nameLabel->setFontSize(22); +} + +void AuthDialog::initEditWidget() +{ + QVBoxLayout *editWidgetLayout = new QVBoxLayout(m_editWidget); + editWidgetLayout->setContentsMargins(0, 0, 0, 0); + editWidgetLayout->setAlignment(Qt::AlignHCenter); + QVBoxLayout *editLayout = new QVBoxLayout(); + editLayout->setContentsMargins(0, 0, 0, 0); + + editLayout->setAlignment(Qt::AlignHCenter); + m_passwordEdit = new IconEdit(m_modelLockDialog); + //m_passwordEdit->setPrompt("password"); + editLayout->addWidget(m_passwordEdit); + editWidgetLayout->addLayout(editLayout); + + m_messageButton = new QPushButton(m_editWidget); + m_messageButton->setObjectName(QStringLiteral("messageButton")); + QHBoxLayout *msgBtnLayout = new QHBoxLayout(); + msgBtnLayout->setContentsMargins(0, 0, 0, 0); + m_messageButton->setStyleSheet("QPushButton{text-align:center;background-color: rgba(255,255,255,15%);border: none;border-radius: 4px;outline: none;} \ + QPushButton::hover{background-color: rgba(255,255,255,40%);} \ + QPushButton::pressed {background-color: rgba(255,255,255,30%);}"); + m_messageButton->hide(); + msgBtnLayout->addWidget(m_messageButton); + editWidgetLayout->addLayout(msgBtnLayout); + + m_messageLabel = new KLabel(m_editWidget); + m_messageLabel->setAlignment(Qt::AlignHCenter); + editWidgetLayout->addWidget(m_messageLabel); +} + +void AuthDialog::initUkeyPasswordWidget() +{ + QVBoxLayout *ukeyWidgetLayout = new QVBoxLayout(m_ukeyPasswdWidget); + ukeyWidgetLayout->setContentsMargins(0, 0, 0, 0); + ukeyWidgetLayout->setAlignment(Qt::AlignHCenter); + QVBoxLayout *editLayout = new QVBoxLayout(); + editLayout->setContentsMargins(0, 0, 0, 0); + editLayout->setAlignment(Qt::AlignHCenter); + m_ukeyPasswordEdit = new IconEdit(m_modelLockDialog); + m_ukeyPasswordEdit->setPrompt(tr("")); + editLayout->addWidget(m_ukeyPasswordEdit); + ukeyWidgetLayout->addLayout(editLayout); + m_ukeyMessageLabel = new KLabel(m_ukeyPasswdWidget); + m_ukeyMessageLabel->setText(""); + m_ukeyMessageLabel->setAlignment(Qt::AlignHCenter); + ukeyWidgetLayout->addWidget(m_ukeyMessageLabel); + m_ukeyPasswdWidget->hide(); +} + +void AuthDialog::initLoginoptionWidget() +{ +// QVBoxLayout *loginoptionLayout = new QVBoxLayout(m_widgetLoginOpts); +// loginoptionLayout->setContentsMargins(0, 0, 0, 0); +// loginoptionLayout->setSpacing(0); +// loginoptionLayout->setContentsMargins(0, 0, 0, 0); +// loginoptionLayout->setAlignment(Qt::AlignHCenter); + +// QHBoxLayout *tipsLayout = new QHBoxLayout(); +// tipsLayout->setContentsMargins(0,0,0,0); +// m_optionTip = new KLabel(); +// m_optionTip->setText("Login Option"); +// m_optionTip->setAlignment(Qt::AlignHCenter); +// tipsLayout->addWidget(m_optionTip); +// loginoptionLayout->addLayout(tipsLayout); + +// QHBoxLayout *btnsLayout = new QHBoxLayout(); +// bottomListWidget = new BioButtonListWidget(m_widgetLoginOpts); +// bottomListWidget->installEventFilter(this); +// btnsLayout->addWidget(bottomListWidget); +// loginoptionLayout->addLayout(btnsLayout); + + m_customWidget = new QWidget(this); + m_layoutCustom = new QHBoxLayout(); + m_layoutCustom->setSpacing(0); + m_layoutCustom->setContentsMargins(0,0,0,0); + m_customWidget->setLayout(m_layoutCustom); + m_customWidget->hide(); + m_customWidget->setFixedSize(width(), 376+100); +} + +void AuthDialog::updateUI() +{ + QPixmap p(m_curUserInfo.headImage()); + QPixmap userIcon = scaledPixmap(p); + userIcon = userIcon.scaled(154*scale, 154*scale, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + userIcon = PixmapToRound(userIcon, 77*scale); + m_labelHeadImg->setPixmap(userIcon); + + m_nameLabel->setText(m_curUserInfo.fullName()); +} + +void AuthDialog::startLoadingUkey() +{ + //isLoadingUkey = true; + m_ukeyLoadingWidget->show(); + m_ukeyPasswordEdit->hide(); + m_ukeyMessageLabel->hide(); + if(!m_loadingTimer) + { + m_loadingTimer = new QTimer(this); + m_loadingTimer->setInterval(150); + connect(m_loadingTimer, &QTimer::timeout, this, &AuthDialog::updateLoadingPixmap); + } + + QPixmap icon = QIcon::fromTheme("ukui-loading-0-symbolic").pixmap(27,27); + m_ukeyLoadingPixmap = drawSymbolicColoredPixmap(icon, "white"); + m_loadingButton->setIcon(m_ukeyLoadingPixmap); + m_loadingButton->setIconSize(QSize(27, 27)); + m_loadingTimer->start(); +} + +void AuthDialog::stopLoadingUkey() +{ + isLoadingUkey = false; + if (m_ukeyLoadingWidget) + m_ukeyLoadingWidget->hide(); + m_ukeyPasswordEdit->show(); + m_ukeyMessageLabel->show(); + if(m_loadingTimer){ + m_loadingTimer->stop(); + } +} + +void AuthDialog::updateLoadingPixmap() +{ + QMatrix matrix; + matrix.rotate(90.0); + m_ukeyLoadingPixmap = m_ukeyLoadingPixmap.transformed(matrix, Qt::FastTransformation); + m_loadingButton->setIcon(QIcon(m_ukeyLoadingPixmap)); +} + +void AuthDialog::switchLoginOptType(unsigned uLoginOptType, bool faceBtnClicked) +{ + switch(uLoginOptType) { + case LOGINOPT_TYPE_PASSWORD: + { + m_editWidget->show(); + m_labelHeadImg->show(); + m_labelQRCode->hide(); + m_labelFace->hide(); + m_fRetryButton->hide(); + m_nameWidget->show(); + m_ukeyPasswdWidget->hide(); + m_ukeyPasswordEdit->clearFocus(); + m_customWidget->hide(); + setFocusProxy(m_passwordEdit); + } + break; + case LOGINOPT_TYPE_FACE: + { + m_editWidget->show(); + m_labelHeadImg->hide(); + m_labelQRCode->hide(); + m_labelFace->show(); + m_fRetryButton->hide(); + m_nameWidget->show(); + m_ukeyPasswdWidget->hide(); + m_ukeyPasswordEdit->clearFocus(); + m_customWidget->hide(); + setFocusProxy(m_passwordEdit); + if (faceBtnClicked) { + m_fTimeoutTimes = 0; + } + } + break; + case LOGINOPT_TYPE_FINGERPRINT: + case LOGINOPT_TYPE_VOICEPRINT: + case LOGINOPT_TYPE_FINGERVEIN: + case LOGINOPT_TYPE_IRIS: + { + m_editWidget->show(); + m_labelHeadImg->show(); + m_nameWidget->show(); + m_labelQRCode->hide(); + m_labelFace->hide(); + m_fRetryButton->hide(); + m_ukeyPasswdWidget->hide(); + m_ukeyPasswordEdit->clearFocus(); + m_customWidget->hide(); + setFocusProxy(m_passwordEdit); + } + break; + case LOGINOPT_TYPE_QRCODE: + { + m_editWidget->show(); + m_labelHeadImg->hide(); + setQRCodeMsg(""); + m_labelQRCode->show(); + m_labelFace->hide(); + m_nameWidget->show(); + m_fRetryButton->hide(); + m_ukeyPasswdWidget->hide(); + m_ukeyPasswordEdit->clearFocus(); + m_customWidget->hide(); + setFocusProxy(m_passwordEdit); + } + break; + case LOGINOPT_TYPE_GENERAL_UKEY: + { + m_editWidget->show(); + m_labelHeadImg->show(); + m_nameWidget->show(); + m_labelQRCode->hide(); + m_labelFace->hide(); + m_fRetryButton->hide(); + m_customWidget->hide(); + m_ukeyPasswdWidget->show(); + setFocusProxy(m_ukeyPasswordEdit); + m_ukeyPasswordEdit->setFocusPolicy(Qt::StrongFocus); + if(m_ukeyPasswordEdit->isVisible()) + m_ukeyPasswordEdit->setFocus(); + } + break; + case LOGINOPT_TYPE_CUSTOM: + { + m_editWidget->hide(); + m_labelHeadImg->hide(); + setQRCodeMsg(""); + m_labelQRCode->hide(); + m_nameWidget->hide(); + m_labelFace->hide(); + m_fRetryButton->hide(); + m_ukeyPasswdWidget->hide(); + m_ukeyPasswordEdit->clearFocus(); + LoginAuthInterface* plugin = m_loginOpts->getCustomLoginAuth(); + if (plugin) { + QWidget *authWidget = plugin->getPluginMainWnd(); + if (authWidget) { + if (m_customWidget != authWidget->parent()) { + m_layoutCustom->addWidget(authWidget); + qDebug()<<"CustomWidget Size:"<size(); + QObject *obj = dynamic_cast(plugin); + connect(obj, SIGNAL(requestAuthAccount(QString)), this, SLOT(onCustomRequestAccount(QString))); + connect(obj, SIGNAL(authenticateResult(int, QString)), this, SLOT(onCustomAuthResult(int, QString))); + connect(obj, SIGNAL(onRequest(QString)), this, SLOT(onCustomRequest(QString))); + connect(obj, SIGNAL(getLoginPluginEnv()), this, SLOT(onCustomPlugEnv())); + } + setFocusProxy(authWidget); + authWidget->setFocus(); + authWidget->show(); + } + } + m_customWidget->show(); + } + break; + default: + return; + } + + if (uLoginOptType != m_uCurLoginOptType || (m_deviceInfo && m_deviceInfo->id != m_nLastDeviceId) || m_curUserInfo.name() != m_lastUserName) { + clearMessage(); + switch(uLoginOptType) { + case LOGINOPT_TYPE_PASSWORD: + { + setLoginTypeTip(""); + } + break; + case LOGINOPT_TYPE_FACE: + { + setLoginTypeTip(tr("Verify face recognition or enter password to unlock")); + } + break; + case LOGINOPT_TYPE_FINGERPRINT: + { + setLoginTypeTip(tr("Press fingerprint or enter password to unlock")); + } + break; + case LOGINOPT_TYPE_VOICEPRINT: + { + setLoginTypeTip(tr("Verify voiceprint or enter password to unlock")); + } + break; + case LOGINOPT_TYPE_FINGERVEIN: + { + setLoginTypeTip(tr("Verify finger vein or enter password to unlock")); + } + break; + case LOGINOPT_TYPE_IRIS: + { + setLoginTypeTip(tr("Verify iris or enter password to unlock")); + } + break; + case LOGINOPT_TYPE_QRCODE: + { + setLoginTypeTip(tr("Use the bound wechat scanning code or enter the password to unlock")); + } + break; + case LOGINOPT_TYPE_GENERAL_UKEY: + { + setLoginTypeTip(""); + } + break; + case LOGINOPT_TYPE_CUSTOM: + { + setLoginTypeTip(""); + } + break; + default: + return; + } + } else if (uLoginOptType == m_uCurLoginOptType && uLoginOptType == LOGINOPT_TYPE_FACE && !faceBtnClicked) { + clearMessage(); + setLoginTypeTip(tr("Verify face recognition or enter password to unlock")); + } + if (m_deviceInfo) { + m_nLastDeviceId = m_deviceInfo->id; + } else { + m_nLastDeviceId = -1; + } + + m_lastUserName = m_curUserInfo.name(); + m_uCurLoginOptType = uLoginOptType; +} + +/** + * @brief LoginWindow::setFace + * @param faceFile 用户头像文件 + * + * 设置用户头像 + */ +void AuthDialog::setFace(const QString& facePath) +{ + QFile faceFile(facePath); + QPixmap faceImage; + m_labelHeadImg->setFixedSize(154,154); + //如果头像文件不存在,则使用默认头像 + if(faceFile.exists()){ + faceImage.load(facePath); + } + else{ + faceImage.load(m_strDefaultFace); + } + //faceImage = cutPixmap(faceImage); + faceImage = faceImage.scaled(154,154, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + faceImage = PixmapToRound(faceImage,77); + m_labelHeadImg->setAlignment(Qt::AlignCenter); + m_labelHeadImg->setPixmap(faceImage); + + m_face = facePath; +} + +void AuthDialog::setQRCode(QImage& imgQRCode) +{ + if (imgQRCode.isNull()) { + m_imgQRCode.load(":/image/assets/ukui-qrcode-null.svg"); + } else { + m_imgQRCode = imgQRCode; + m_labelQRCodeTip->hide(); + } + m_imgQRCode = m_imgQRCode.scaled(QSize(150, 150)); + m_labelQRCode->setAlignment(Qt::AlignCenter); + m_labelQRCode->setPixmap(QPixmap::fromImage(m_imgQRCode)); +} + +void AuthDialog::setQRCodeMsg(QString strMsg) +{ + if (strMsg.isEmpty()) { + m_labelQRCodeMsg->hide(); + //m_labelQRCodeTip->hide(); + } else { + //一开始认证时就没有网,直接停止加载状态 + if(w_timer && w_timer->isActive()) + { + w_timer->stop(); + } + m_labelQRCodeMsg->setTipText(strMsg); + m_labelQRCodeMsg->show(); + m_labelQRCodeTip->setPixmap(QIcon::fromTheme("dialog-warning").pixmap(QSize(22,22))); + m_labelQRCodeTip->show(); + } +} + +void AuthDialog::setFaceImg(QImage& imgFace, int nStatus) +{ + QPixmap faceImage; + m_labelFace->setFixedSize(154,154); + //如果头像文件不存在,则使用默认头像 + if(!imgFace.isNull()) { + faceImage = PixmapToRound(QPixmap::fromImage(imgFace),77); + } else { + switch(nStatus){ + case 1: + faceImage = QPixmap(":/image/assets/ukui-loginopt-lose.svg"); + break; + case 2: + faceImage = m_loginOpts->loadSvg(":/image/assets/ukui-loginopt-smile.svg", "gray", 48); + m_labelFace->setStyleSheet(QString("border-radius: %1px; border:0px solid white;background-color: rgba(255,255,255,20%);").arg((int)(77))); + break; + default: + faceImage = QPixmap(":/image/assets/ukui-loginopt-smile.svg"); + break; + } + } + + m_labelFace->setAlignment(Qt::AlignCenter); + m_labelFace->setPixmap(faceImage); +} + +void AuthDialog::updatePixmap() +{ + QMatrix matrix; + matrix.rotate(90.0); + m_waitingPixmap = m_waitingPixmap.transformed(matrix, Qt::FastTransformation); + if(m_uCurLoginOptType == LOGINOPT_TYPE_QRCODE) + m_labelQRCodeTip->setPixmap(m_waitingPixmap); + else if(m_uCurLoginOptType == LOGINOPT_TYPE_FACE) { + m_labelFace->setPixmap(m_waitingPixmap); + } +} + +void AuthDialog::onRespondUkey(const QString &text) +{ + if (m_loginOpts && m_deviceInfo){ + m_loginOpts->SetExtraInfo(text,"pincode"); + m_loginOpts->startAuth(m_deviceInfo, m_curUserInfo.uid()); + } +} + +void AuthDialog::onPamShowMessage(QString strMsg, int nType) +{ + qDebug()<<"onPamShowMessage:"<< strMsg; + //设置label最小高度 + m_messageLabel->setMinimumHeight(36); + if (strMsg.indexOf("account locked") != -1 || strMsg.indexOf("账户已锁定") != -1 + || strMsg.indexOf("Account locked") != -1 || strMsg.indexOf("永久锁定") != -1) + { + if (unlockUserTimer()) { + if(!m_timerUserUnlock){ + m_timerUserUnlock = new QTimer(this); + m_timerUserUnlock->setInterval(500); + connect(m_timerUserUnlock, &QTimer::timeout, this, &AuthDialog::unlockUserTimer); + } else { + if(m_timerUserUnlock->isActive()) { + m_timerUserUnlock->stop(); + } + } + m_timerUserUnlock->start(); + } + return; + } else if (strMsg.indexOf("No password received, please input password") != -1){ + m_messageLabel->setText(tr("Password cannot be empty")); + m_messageLabel->setToolTip(tr("Password cannot be empty")); + } + else{ + QString strText = strMsg; + if (!m_preStrMessage.isEmpty() && m_preStrMessageType != nType && m_preStrMessageType != -1) + { + strText = m_preStrMessage + "," + strText; + } + QFontMetrics font(m_messageLabel->font()); + QString strDisplay = font.elidedText(strMsg, Qt::ElideRight, m_messageLabel->width()-8); + m_messageLabel->setText(strDisplay); + m_messageLabel->setToolTip(strMsg); + } + m_bHasUnacknowledgedMsg = true; +} + +void AuthDialog::startFirstLogin() +{ + bioService = new QDBusInterface("org.ukui.Biometric", + "/org/ukui/Biometric", + "org.ukui.Biometric", + QDBusConnection::systemBus(),this); + + if(!bioService->isValid()) + return ; + + QDBusMessage result = bioService->call(QStringLiteral("GetDevList")); + if(result.type() == QDBusMessage::ErrorMessage) + { + qWarning() << "GetDevList error:" << result.errorMessage(); + return ; + } + auto dbusArg = result.arguments().at(1).value(); + QList variantList; + dbusArg >> variantList; + + if(variantList.count() == 0) + return ; + + + DeviceInfoPtr pDeviceInfo = std::make_shared(); + auto arg = variantList.at(0).value(); + arg >> *pDeviceInfo; + + qDebug()<<"pDeviceInfo->id = "<id; + + if(pDeviceInfo->id <= 0) + return ; + + QList argList; + argList << pDeviceInfo->id << -1 << 0 << -1; + + drvid = pDeviceInfo->id; + QDBusPendingCall call = bioService->asyncCallWithArgumentList(QStringLiteral("Identify"), argList); + + QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this); + connect(watcher, &QDBusPendingCallWatcher::finished, + this, &AuthDialog::onFirstLoginIdentifyComplete); + + isFirstAuth = true; + + QTimer::singleShot(3000, [&]{ + if(isFirstAuth){ + bioService->call(QStringLiteral("StopOps"), drvid, 3000); + } + }); + +} + +void AuthDialog::onFirstLoginIdentifyComplete(QDBusPendingCallWatcher *watcher) +{ + isFirstAuth = false; + QDBusPendingReply reply = *watcher; + + if(reply.isError()) + { + qWarning() << "Identify error: " << reply.error().message(); + return; + } + int result = reply.argumentAt(0).toInt(); + int authUid = reply.argumentAt(1).toInt(); + qDebug() << result << authUid <<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"; + + if(result == 0 && authUid > 0){ + struct passwd *pwd; + pwd = getpwuid(authUid); + if(pwd && pwd->pw_name){ + if(m_uniauthService && m_uniauthService->isActivatable()){ + bool isEnable = m_uniauthService->getBioAuthStatus(pwd->pw_name, ENABLETYPE_BIO); + if(isEnable == false) + return; + } + setDirLogin(); + isBioSuccess = true; + authMode = BIOMETRIC; + startAuth(); + } + } +} + +void AuthDialog::onPamShowPrompt(QString strPrompt, int nType) +{ + qDebug()<< "prompt: "<< strPrompt << authMode; +// if(isPowerup && m_configuration->getIs990()){ +// waitBiometricServiceStatus(); +// startFirstLogin(); +// } + if(strPrompt == BIOMETRIC_PAM || strPrompt == BIOMETRIC_PAM_DOUBLE || strPrompt == BIOMETRIC_PAM_QRCODE) { + if(m_bDirectLogin){ + onRespond(BIOMETRIC_SUCCESS); + return ; + } + if(authMode == PASSWORD) { + skipBiometricAuth(); + } else { + skipBiometricAuth(); +// if(isPowerup && m_configuration->getIs990()) { +// QTimer::singleShot(1500, [&]{ +// performBiometricAuth(); +// }); +// isPowerup = false; +// } else { + performBiometricAuth(); +// } + } + } else { + m_isNameLogin = false; + qDebug()<<"m_isNameLogin = false"; + m_passwordEdit->stopWaiting(); + if(!strPrompt.isEmpty()) { + m_passwordEdit->readOnly(false); + m_passwordEdit->show(); + } + + m_passwordEdit->setFocus(); + this->setFocusProxy(m_passwordEdit); + if (nType != PamAuth::PromptTypeSecret) { + m_isAutoSwitch = true; + m_passwordEdit->setType(QLineEdit::Normal); + } else if(m_isAutoSwitch) { + m_passwordEdit->setType(QLineEdit::Password); + m_isAutoSwitch = false; + } + + m_bRecvPrompt = true; + m_bHasUnacknowledgedMsg = false; + m_preStrMessage = ""; + if (!m_biometricProxy || !m_biometricProxy->isValid() || !m_deviceInfo) { + switchLoginOptType(LOGINOPT_TYPE_PASSWORD); + if (m_loginOpts) + m_loginOpts->setSelectedPassword(); + } + if(strPrompt == "Password: " || strPrompt == "密码:"){ + strPrompt = tr("Password "); + m_isPassWdInput = true; + } else if (strPrompt == "Input password" || strPrompt == "Input Password" || strPrompt == "输入密码") { + strPrompt = tr("Input Password"); + m_isPassWdInput = true; + } + + if(strPrompt == "login:") { + strPrompt = tr("Username"); + /// TODO + //m_name = "*login"; + m_isNameLogin = true; + m_isPassWdInput = false; + switchLoginOptType(LOGINOPT_TYPE_PASSWORD); + qDebug()<<"m_isNameLogin = true"; + } + + m_passwordEdit->clear(); + m_passwordEdit->setPrompt(strPrompt); + m_passwordEdit->show(); + + if (unlockUserTimer()) { + if(!m_timerUserUnlock){ + m_timerUserUnlock = new QTimer(this); + m_timerUserUnlock->setInterval(500); + connect(m_timerUserUnlock, &QTimer::timeout, this, &AuthDialog::unlockUserTimer); + } else { + if(m_timerUserUnlock->isActive()) { + m_timerUserUnlock->stop(); + } + } + m_timerUserUnlock->start(); + } + } +} + +void AuthDialog::onPamAuthCompleted() +{ + if (m_curUserInfo.name().isEmpty()) + return ; + m_passwordEdit->stopWaiting(); + bool isAuthenticated = (Q_EMIT m_modelLockDialog->pamIsAuthenticated()); + qDebug()<<"onPamAuthCompleted:"<readOnly(false); + m_passwordEdit->clear(); + clearMessage(); + + Q_EMIT authSucceed(m_curUserInfo.name()); + } else { + qDebug()<<"m_bRecvPrompt = "<setInterval(500); + connect(m_timerUserUnlock, &QTimer::timeout, this, &AuthDialog::unlockUserTimer); + } else { + if(m_timerUserUnlock->isActive()) { + m_timerUserUnlock->stop(); + } + } + m_timerUserUnlock->start(); + } + startAuth(); + } else { + showAuthenticated(false); + } + } +} + +void AuthDialog::onRespond(const QString &strRes) +{ + if (!m_bRecvPrompt && strRes != BIOMETRIC_SUCCESS) { + qInfo()<<"Wait for input passwd!"; + return; + } + if (m_curUserInfo.name().isEmpty()) { + qInfo()<<"No user be selected!!"; + return ; + } + m_bHasUnacknowledgedMsg = false; + clearMessage(); + + qDebug()<<"onRespond:"<pamAuthenticate(m_curUserInfo.name()); + } else if(m_curUserInfo.name() == "*login") { //用户输入用户名 + m_isManual = true; + m_isNameLogin = true; + + Q_EMIT m_modelLockDialog->pamRespond(strRes); + + m_strManualLoginName = strRes; + if (!m_isInputPasswd){ + Q_EMIT userChangedByManual(strRes); + m_isInputPasswd = true; + } + } else { //当密码长度超过1000多时,lightm会出异常,这里暂时先截断 + if(strRes.length()>1000) + Q_EMIT m_modelLockDialog->pamRespond(strRes.mid(0,1000)); + else + Q_EMIT m_modelLockDialog->pamRespond(strRes); + m_passwordEdit->readOnly(true); + } +} + +void AuthDialog::startAuth() +{ + if (!m_curUserInfo.name().isEmpty()) { + m_bRecvPrompt = false; + m_bHasUnacknowledgedMsg = false; + //用户认证 + if(m_curUserInfo.name() == "*guest") { //游客登录 + qDebug() << "guest login"; + m_passwordEdit->show(); + m_passwordEdit->setPrompt(tr("login")); + } else if(m_curUserInfo.name() == "*login") { //手动输入用户名 + Q_EMIT m_modelLockDialog->pamAuthenticate(""); + } else { + qDebug() << "login: " << m_curUserInfo.name(); + Q_EMIT m_modelLockDialog->pamAuthenticate(m_curUserInfo.name()); + m_passwordEdit->clear(); + m_passwordEdit->readOnly(true); + } + } +} + +void AuthDialog::stopAuth() +{ + clearMessage(); +} + +void AuthDialog::onCurUserChanged(UserInfo userInfo) +{ + if(m_loginOpts){ + m_loginOpts->stopAuth(); + if(m_bioTimer && m_bioTimer->isActive()) + m_bioTimer->stop(); + } + m_curUserInfo = userInfo; + m_isInputPasswd = false; + updateUI(); + startAuth(); + if (m_passwordEdit) { + m_passwordEdit->clear(); + m_passwordEdit->setType(QLineEdit::Password); + } + if (m_messageButton) + m_messageButton->hide(); + clearMessage(); + m_bDirectLogin = false; + m_isLockingFlg = false; + authMode = UNKNOWN; + m_deviceInfo = DeviceInfoPtr(); + m_deviceName = ""; + isBioSuccess = false; + if(m_loginOpts){ + m_loginOpts->hide(); + } +} + +void AuthDialog::showAuthenticated(bool successful/* = true*/) +{ + m_editWidget->show(); + m_passwordEdit->hide(); + m_messageButton->show(); + m_messageButton->setDefault(true); + + if(successful) { + m_bNeedRetry = false; + m_messageButton->setText(tr("Login")); + QString strMsgTip = m_messageLabel->text(); + switchLoginOptType(LOGINOPT_TYPE_PASSWORD); + if (!strMsgTip.isEmpty()) { + m_messageLabel->setText(strMsgTip); + m_messageLabel->move(m_messageButton->x(), m_messageLabel->y()); + } + } else { + m_bNeedRetry = true; + m_messageButton->setText(tr("Retry")); + } +} + +void AuthDialog::onMessageButtonClicked() +{ + m_messageButton->setDefault(false); + if(!m_bNeedRetry) { + //认证完成后清空密码框 + m_passwordEdit->readOnly(false); + m_passwordEdit->clear(); + clearMessage(); + + Q_EMIT authSucceed(m_curUserInfo.name()); + } else { + m_messageButton->hide(); + m_messageLabel->setText(""); + authMode = PASSWORD; + startAuth(); + } +} + +void AuthDialog::clearMessage() +{ + m_messageLabel->clear(); + m_preStrMessage = ""; + m_preStrMessageType = -1; +} + +bool AuthDialog::unlockUserTimer() +{ + if (m_curUserInfo.name().isEmpty()) + return false; + int failed_count = 0; + int time_left = 0; + int deny = 0; + int fail_time =0; + int unlock_time = 0; + QString curUserName = m_curUserInfo.name(); + + if (NULL == curUserName.toLatin1().data()) { + qDebug() << "get user info failed." ; + return false; + } + + struct passwd* user = NULL; + user = getpwnam(curUserName.toLatin1().data()); + if(user) + pam_tally_unlock_time_left(user->pw_uid, &failed_count, &time_left, &deny,&fail_time,&unlock_time); + else + return false; + + // qDebug() << "user->pw_uid = " << user->pw_uid << "failed_count:" << failed_count << "time_left:" <= 60) { //请多少分钟后重试 + int nMinuteleft = time_left/60; + if (m_isLockingFlg == false) { + m_nCurLockMin = unlock_time/60;//获取当前需要锁定的分钟数 + } + + //如果当前设置的不是1min钟锁定,那么1min显示成2min,由2min直接跳到59s || 剩余分钟数小于当前设置的锁定时间,并且大于1min,自增+1 + if ((nMinuteleft == 1 && m_nCurLockMin != 1) || (nMinuteleft > 1 && nMinuteleft < m_nCurLockMin)) { + nMinuteleft = nMinuteleft + 1; + } + m_messageLabel->setTipText(tr("Please try again in %1 minutes.").arg(nMinuteleft)); + m_passwordEdit->clearText(); + m_passwordEdit->readOnly(true); + m_passwordEdit->setLocked(true); + m_isLockingFlg = true; + return true; + } else if(time_left > 0 && time_left < 60) { //请多少秒后重试 + m_messageLabel->setTipText(tr("Please try again in %1 seconds.").arg(time_left%60)); + m_passwordEdit->clearText(); + m_passwordEdit->readOnly(true); + m_passwordEdit->setLocked(true); + m_isLockingFlg = true; + return true; + } else if (failed_count == 0xFFFF) {//账号被永久锁定 + m_messageLabel->setTipText(tr("Account locked permanently.")); + m_passwordEdit->clearText(); + m_passwordEdit->readOnly(true); + m_passwordEdit->setLocked(true); + m_isLockingFlg = true; + return true; + } else { + if(m_passwordEdit){ + m_passwordEdit->readOnly(false); + m_passwordEdit->setLocked(false); + m_passwordEdit->setFocus(); + this->setFocusProxy(m_passwordEdit); + } + // qDebug() << "清理 1 clearMessage"; + if (m_isLockingFlg) { + onPamShowMessage("", PamAuth::MessageTypeError); + //onPamShowMessage(tr("Authentication failure, Please try again"), PamAuth::MessageTypeInfo); + m_isLockingFlg = false; + } + if (m_timerUserUnlock) + m_timerUserUnlock->stop(); + } + return false; +} + +void AuthDialog::restartBioAuth() +{ + startBioAuth(); +} + +void AuthDialog::onPrepareForSleep(bool sleep) +{ + ///系统休眠时,会关闭总线,导致设备不可用,发生错误 + ///在系统休眠之前停止认证,在系统唤醒后重新开始认证 + if(sleep) + { + if(m_loginOpts){ + manualStopBio = true; + m_loginOpts->stopAuth(); + if(m_bioTimer && m_bioTimer->isActive()) + m_bioTimer->stop(); + } + } + else + { + manualStopBio = false; + restartBioAuth(); + } +} + +void AuthDialog::setDirLogin() +{ + m_bDirectLogin = true; +} + +void AuthDialog::pamBioSuccess() +{ + m_bioTimer->stop(); + if (!m_loginOpts) { + switchLoginOptType(LOGINOPT_TYPE_PASSWORD); + return ; + } + + if(m_deviceInfo && m_deviceInfo->deviceType == LOGINOPT_TYPE_GENERAL_UKEY){ + //ukey时不调用ukey认证 + }else{ + m_loginOpts->startAuth(m_deviceInfo, m_curUserInfo.uid()); + } + + if (m_deviceInfo) { + switchLoginOptType(m_loginOpts->convertDeviceType(m_deviceInfo->deviceType)); + } else { + switchLoginOptType(LOGINOPT_TYPE_PASSWORD); + } +} + +void AuthDialog::startBioAuth(unsigned uTimeout) +{ + if(m_loginOpts) + m_loginOpts->stopAuth(); + + if(m_deviceInfo && m_deviceInfo->deviceType == LOGINOPT_TYPE_GENERAL_UKEY){ + //ukey时不调用ukey认证 + switchLoginOptType(m_loginOpts->convertDeviceType(m_deviceInfo->deviceType)); + return; + } + + if(!m_bioTimer){ + m_bioTimer = new QTimer(this); + connect(m_bioTimer, SIGNAL(timeout()), this, SLOT(pamBioSuccess())); + } + m_bioTimer->start(uTimeout); +} + +void AuthDialog::waitBiometricServiceStatus() +{ + qDebug()<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~` get biometric status"; + QDBusInterface iface("org.freedesktop.systemd1", "/org/freedesktop/systemd1", + "org.freedesktop.systemd1.Manager",QDBusConnection::systemBus()); + + QDBusReply bioPath = iface.call("GetUnit","biometric-authentication.service"); + if(!bioPath.isValid()){ + return ; + } + + QDBusInterface bioface("org.freedesktop.systemd1", bioPath.value().path(), + "org.freedesktop.DBus.Properties", QDBusConnection::systemBus()); + QDBusReply sessionReply = bioface.call("Get", "org.freedesktop.systemd1.Unit", "UnitFileState"); + if(!sessionReply.isValid()) + qWarning() << sessionReply.error(); + else { + QString res = sessionReply.value().variant().toString(); + if(res == "disable") + return; + } + + qDebug()<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ get activeState"; + int times = 0; + while(times<20){ + QDBusReply sessionReply = bioface.call("Get", "org.freedesktop.systemd1.Unit", "ActiveState"); + if(!sessionReply.isValid()){ + qWarning() << sessionReply.error(); + return ; + } + else { + QString res = sessionReply.value().variant().toString(); + if(res == "activating"){ + times ++; + usleep(100000); + }else{ + break; + } + } + } + qDebug()<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ times = "<getMaxFailedTimes(); + } + + //服务没启动,或者打开DBus连接出错 + if(!m_biometricProxy->isValid()) + { + qWarning() << "An error occurs when connect to the biometric DBus"; + //skipBiometricAuth(); + if (m_deviceInfo) { + if (!m_loginOpts || !m_loginOpts->findDeviceById(m_deviceInfo->id) + || m_loginOpts->isDeviceDisable(m_deviceInfo->id)) { + m_deviceInfo = DeviceInfoPtr(); + } + } + switchLoginOptType(LOGINOPT_TYPE_PASSWORD); + return; + } + + //初始化生物识别认证UI + initBiometricWidget(); + + //没有可用设备,不启用生物识别认证 + if(m_loginOpts->getLoginOptCount() < 1) { + qWarning() << "No available devices"; + //skipBiometricAuth(); + if (m_deviceInfo) { + if (!m_loginOpts || !m_loginOpts->findDeviceById(m_deviceInfo->id) + || m_loginOpts->isDeviceDisable(m_deviceInfo->id)) { + m_deviceInfo = DeviceInfoPtr(); + } + } + return; + } + + //获取默认设备 + if (m_loginOpts) { + if(m_curUserInfo.name() == "*login") + m_deviceName = m_loginOpts->getDefaultDevice(m_strManualLoginName); + else + m_deviceName = m_loginOpts->getDefaultDevice(m_curUserInfo.name()); + + if (m_isCustomDefault) { // 认证插件配置默认插件认证 + if (m_loginOpts) { + m_deviceName = m_loginOpts->getCustomDevName(); + } + } + } + qDebug() << m_deviceName; + if (m_deviceInfo) { + if (!m_loginOpts || !m_loginOpts->findDeviceById(m_deviceInfo->id) + || m_loginOpts->isDeviceDisable(m_deviceInfo->id)) { + m_deviceInfo = DeviceInfoPtr(); + } + } + //如果默认设备为空的话,第一次不启动生物识别认证 + if(m_deviceName.isEmpty() && !m_deviceInfo) + { + qDebug() << "No default device"; + //skipBiometricAuth(); + return; + } + //第一次,获取默认设备的设备信息,之后使用的则是从设备选择窗口传出的设备信息 + if(!m_deviceInfo) + { + m_deviceInfo = m_loginOpts->findDeviceByName(m_deviceName); + if(!m_deviceInfo) + { + qDebug() << "Device Not found: " << m_deviceName; + //skipBiometricAuth(); + return; + } + } + + //已经错误超过3次 + if(m_failMap.contains(m_curUserInfo.uid()) && m_failMap[m_curUserInfo.uid()][m_deviceInfo->id] >= maxFailedTimes) + { + if (m_deviceInfo->deviceType == UniT_Remote) { + setLoginTypeTip(tr("Failed to verify %1, please enter password to unlock").arg(getDeviceType_tr(m_deviceInfo->deviceType))); + } else { + setLoginTypeTip(tr("Unable to verify %1, please enter password to unlock").arg(getDeviceType_tr(m_deviceInfo->deviceType))); + if (m_deviceInfo->deviceType == BioT_Face) { + QImage imgFailed; + setFaceImg(imgFailed, 1); + } + } + m_loginOpts->setDeviceDisable(m_deviceInfo->id, true); + //skipBiometricAuth(); + return; + } + + if(m_deviceInfo->deviceType == LOGINOPT_TYPE_GENERAL_UKEY){ + switchLoginOptType(LOGINOPT_TYPE_PASSWORD); + m_loginOpts->setSelectedPassword(); + //skipBiometricAuth(); + return ; + } + + switchLoginOptType(m_loginOpts->convertDeviceType(m_deviceInfo->deviceType)); + // 自行校验生物设备,pam greeter校验密码 + startBioAuth(); + //skipBiometricAuth(); +} + +void AuthDialog::skipBiometricAuth() +{ + Q_EMIT m_modelLockDialog->pamRespond(BIOMETRIC_IGNORE); +} + +void AuthDialog::initBiometricWidget() +{ + if(m_loginOpts) { + m_loginOpts->setUser(m_curUserInfo.uid()); + } else { + QHBoxLayout *optsLayout = new QHBoxLayout(m_widgetLoginOpts); + optsLayout->setContentsMargins(0,0,0,0); + m_loginOpts = new LoginOptionsWidget(m_biometricProxy, m_curUserInfo.uid(), m_uniauthService, m_widgetLoginOpts); + optsLayout->addWidget(m_loginOpts); + connect(m_loginOpts, &LoginOptionsWidget::authComplete, + this, &AuthDialog::onBiometricAuthComplete); + connect(m_loginOpts, &LoginOptionsWidget::optionSelected, + this, &AuthDialog::onDeviceChanged); + connect(m_loginOpts, &LoginOptionsWidget::updateImage, + this, &AuthDialog::onLoginOptImage); + connect(m_loginOpts, &LoginOptionsWidget::setLoadingImage, + this, &AuthDialog::onLoadingImage); + connect(m_loginOpts, &LoginOptionsWidget::notifyOptionsChange, + this, &AuthDialog::onLoginOptsCount); + connect(m_loginOpts, &LoginOptionsWidget::updateAuthMsg, + this, &AuthDialog::setLoginMsg); + m_loginOpts->setUser(m_curUserInfo.uid()); + } + + qDebug()<<"OptsCount:"<getLoginOptCount(); + if (m_loginOpts->getLoginOptCount() < 1){ + switchLoginOptType(LOGINOPT_TYPE_PASSWORD); + m_loginOpts->hide(); + }else{ + m_loginOpts->show(); + } + + if(m_loginOpts->getHasUkeyOptions() && m_loginOpts->getLoginOptCount() < 1){ + m_loginOpts->show(); + m_loginOpts->setSelectedPassword(); + } + + m_loginOpts->setEnabled(true); + + setBiometricWidgetGeometry(); +} + +void AuthDialog::setBiometricWidgetGeometry() +{ + //生物识别 + if(m_loginOpts) { + m_widgetLoginOpts->setFixedSize(width(), 98); + qDebug()<<"LoginOptGeometry:"<geometry() + <<","<isHidden(); + } +} + +void AuthDialog::onLoginOptsCount(unsigned uCount) +{ + qDebug()<<"----------------------onLoginOptsCount Count:"< 0) { + setBiometricWidgetGeometry(); + m_loginOpts->show(); + qDebug()<<"LoginOptsShow!!"; + } else { + switchLoginOptType(LOGINOPT_TYPE_PASSWORD); + m_loginOpts->hide(); + } + if (!m_deviceInfo || !m_loginOpts->findDeviceById(m_deviceInfo->id) + || m_loginOpts->isDeviceDisable(m_deviceInfo->id)) { + m_loginOpts->stopAuth(); + authMode = BIOMETRIC; + //初始化生物识别认证UI + initBiometricWidget(); + + //没有可用设备,不启用生物识别认证 + if(m_loginOpts->getLoginOptCount() < 1) { + qWarning() << "No available devices"; + if (m_deviceInfo) { + m_deviceInfo = DeviceInfoPtr(); + } + return; + } + + //获取默认设备 + if(m_curUserInfo.name() == "*login"){ + if(isLoadingUkey){ + m_deviceName = m_loginOpts->getDefaultDevice(m_strManualLoginName,UniT_General_Ukey); + }else{ + m_deviceName = m_loginOpts->getDefaultDevice(m_strManualLoginName); + } + } else{ + if(isLoadingUkey){ + m_deviceName = m_loginOpts->getDefaultDevice(m_curUserInfo.name(),UniT_General_Ukey); + }else{ + m_deviceName = m_loginOpts->getDefaultDevice(m_curUserInfo.name()); + } + } + + qDebug() << m_deviceName; + if (m_deviceInfo) { + if (!m_loginOpts || !m_loginOpts->findDeviceById(m_deviceInfo->id) + || m_loginOpts->isDeviceDisable(m_deviceInfo->id)) { + m_deviceInfo = DeviceInfoPtr(); + } + } + //如果默认设备为空的话,第一次不启动生物识别认证 + if(m_deviceName.isEmpty() && !m_deviceInfo) { + qDebug() << "No default device"; + return; + } + //第一次,获取默认设备的设备信息,之后使用的则是从设备选择窗口传出的设备信息 + if(!m_deviceInfo) { + m_deviceInfo = m_loginOpts->findDeviceByName(m_deviceName); + if(!m_deviceInfo) { + qDebug() << "Device Not found: " << m_deviceName; + return; + } + } + + //已经错误超过3次 + if(m_failMap.contains(m_curUserInfo.uid()) && m_failMap[m_curUserInfo.uid()][m_deviceInfo->id] >= maxFailedTimes) + { + if (m_deviceInfo->deviceType == UniT_Remote) { + setLoginTypeTip(tr("Failed to verify %1, please enter password to unlock").arg(getDeviceType_tr(m_deviceInfo->deviceType))); + } else { + setLoginTypeTip(tr("Unable to verify %1, please enter password to unlock").arg(getDeviceType_tr(m_deviceInfo->deviceType))); + if (m_deviceInfo->deviceType == BioT_Face) { + QImage imgFailed; + setFaceImg(imgFailed, 1); + } + } + m_loginOpts->setDeviceDisable(m_deviceInfo->id, true); + return; + } + + if (m_deviceInfo->deviceType == LOGINOPT_TYPE_GENERAL_UKEY){ + stopLoadingUkey(); + } + + if(m_deviceInfo){ + m_loginOpts->setCurrentDevice(m_deviceInfo); + m_loginOpts->updateUIStatus(); + } + + switchLoginOptType(m_loginOpts->convertDeviceType(m_deviceInfo->deviceType)); + // 自行校验生物设备,pam greeter校验密码 + startBioAuth(); + } +} + +void AuthDialog::onLoginOptImage(QImage img) +{ + if (m_uCurLoginOptType == LOGINOPT_TYPE_FACE) { + setFaceImg(img); + } else if (m_uCurLoginOptType == LOGINOPT_TYPE_QRCODE) { + setQRCode(img); + } + if(w_timer && w_timer->isActive()) + { + w_timer->stop(); + } +} + +void AuthDialog::onLoadingImage() +{ + if(!w_timer) + { + w_timer = new QTimer(this); + w_timer->setInterval(150); + connect(w_timer, &QTimer::timeout, this, &AuthDialog::updatePixmap); + } + m_waitingPixmap = QIcon::fromTheme("ukui-loading-0-symbolic").pixmap(24, 24); + m_labelFace->setAlignment(Qt::AlignCenter); + if (m_uCurLoginOptType == LOGINOPT_TYPE_FACE) { + m_labelFace->setPixmap(m_waitingPixmap); + m_labelQRCodeTip->show(); + } else if (m_uCurLoginOptType == LOGINOPT_TYPE_QRCODE) { + m_labelQRCodeTip->setPixmap(m_waitingPixmap); + m_labelQRCodeTip->show(); + } + w_timer->start(); +} + +void AuthDialog::onDeviceChanged(unsigned uCurLoginOptType, const DeviceInfoPtr &deviceInfo) +{ + isLoadingUkey = false; + if(uCurLoginOptType == LOGINOPT_TYPE_PASSWORD){ + switchLoginOptType(uCurLoginOptType); + if(m_loginOpts){ + m_loginOpts->stopAuth(); + } + m_deviceInfo = nullptr; + authMode = PASSWORD; + startAuth(); + return; + } + if (uCurLoginOptType != LOGINOPT_TYPE_GENERAL_UKEY && !deviceInfo) + return; + + if(deviceInfo) + qDebug() << "device changed: " << *deviceInfo; + if(deviceInfo && m_failMap[m_curUserInfo.uid()][deviceInfo->id] >= maxFailedTimes){ + qDebug() << "Failed MAX!!"; + return ; + } + + if (uCurLoginOptType == LOGINOPT_TYPE_GENERAL_UKEY && !deviceInfo){ + isLoadingUkey = true; + startLoadingUkey(); + }else if(uCurLoginOptType == LOGINOPT_TYPE_GENERAL_UKEY && deviceInfo){ + stopLoadingUkey(); + } + + if (uCurLoginOptType != LOGINOPT_TYPE_GENERAL_UKEY && deviceInfo == m_deviceInfo) { + return ; + } + + if(m_bioTimer && m_bioTimer->isActive()) + m_bioTimer->stop(); + + authMode = BIOMETRIC; + m_deviceInfo = deviceInfo; + switchLoginOptType(uCurLoginOptType); + if(!isBioSuccess && deviceInfo) + startBioAuth(); +} + +void AuthDialog::onBiometricAuthComplete(bool result, int nStatus) +{ + if(!result) { + if(m_deviceInfo && m_deviceInfo->deviceType == UniT_General_Ukey && m_ukeyPasswdWidget->isVisible()){ + m_ukeyPasswordEdit->stopWaiting(); + m_ukeyPasswordEdit->clearText(); + } + + if(manualStopBio){ + manualStopBio = false; + return; + } + + if (nStatus == 5 && m_deviceInfo) { + if(w_timer && w_timer->isActive()) + w_timer->stop(); + QImage imgFailed; + setFaceImg(imgFailed, 2); + return; + } else if (nStatus >= 2 && nStatus != 5){ + if (m_deviceInfo) { + if(m_failMap.contains(m_curUserInfo.uid()) && m_failMap[m_curUserInfo.uid()].contains(m_deviceInfo->id)){ + m_failMap[m_curUserInfo.uid()][m_deviceInfo->id] = m_failMap[m_curUserInfo.uid()][m_deviceInfo->id] + 1; + }else{ + m_failMap[m_curUserInfo.uid()][m_deviceInfo->id] = 1; + } + qDebug()<<"Failed count:"<id]<<",Max:"<deviceType == BioT_Face) { + QImage imgFailed; + setFaceImg(imgFailed, 1); + m_fTimeoutTimes = 0; + } + if(m_failMap[m_curUserInfo.uid()][m_deviceInfo->id] >= maxFailedTimes){ + if (m_deviceInfo->deviceType == UniT_Remote) { + setLoginTypeTip(tr("Failed to verify %1, please enter password to unlock").arg(getDeviceType_tr(m_deviceInfo->deviceType))); + QImage nullImage; + setQRCode(nullImage); + }else if(m_deviceInfo->deviceType == LOGINOPT_TYPE_GENERAL_UKEY){ + setUkeyTypeTip(tr("Unable to verify %1, please enter password to unlock").arg(getDeviceType_tr(m_deviceInfo->deviceType))); + }else { + setLoginTypeTip(tr("Unable to verify %1, please enter password to unlock").arg(getDeviceType_tr(m_deviceInfo->deviceType))); + } + if(m_loginOpts) + m_loginOpts->setDeviceDisable(m_deviceInfo->id, true); + + if(m_ukeyPasswdWidget && m_ukeyPasswdWidget->isVisible()){ + m_ukeyPasswordEdit->readOnly(true); + } + + return ; + } + + if(m_deviceInfo->deviceType == LOGINOPT_TYPE_GENERAL_UKEY){ + setUkeyTypeTip(tr("Failed to verify %1, you still have %2 verification opportunities") + .arg(getDeviceType_tr(m_deviceInfo->deviceType)) + .arg(maxFailedTimes-m_failMap[m_curUserInfo.uid()][m_deviceInfo->id])); + }else { + setLoginTypeTip(tr("Failed to verify %1, you still have %2 verification opportunities") + .arg(getDeviceType_tr(m_deviceInfo->deviceType)) + .arg(maxFailedTimes-m_failMap[m_curUserInfo.uid()][m_deviceInfo->id])); + } + } + } + if(!isBioSuccess) { + if (nStatus <= 0) { + qDebug()<<"Biometric dbus error:"<getFTimeoutTimes()) { + m_fRetryButton->show(); + m_labelFace->hide(); + setLoginTypeTip(tr("Face recognition waiting time out, please click refresh or enter the password to unlock.")); + m_fTimeoutTimes = 0; + } else { + startBioAuth(); + } + } else { + startBioAuth(); + } + if (nStatus >= 2 && m_deviceInfo) { + if (m_deviceInfo->deviceType == BioT_Face) { + QImage imgFailed; + setFaceImg(imgFailed, 1); + } + } + } + } else { + //onShowMessage("验证成功!", QLightDM::Greeter::MessageTypeInfo); + setDirLogin(); + isBioSuccess = true; + onBiometricButtonClicked(); + } +} + +void AuthDialog::onBiometricButtonClicked() +{ + //当前没有设备 + if (!m_deviceInfo) { + qWarning()<<"未选择生物设备--"; + return ; + } + authMode = BIOMETRIC; + startAuth(); +} + +void AuthDialog::setUkeyTypeTip(QString text) +{ + QString textTip = text; + if (!textTip.isEmpty()) { +// QFontMetrics font(m_ukeyMessageLabel->font()); +// QString textTip = font.elidedText(textTip, Qt::ElideRight, m_messageLabel->width()-8); + m_ukeyMessageLabel->setTipText(textTip); + m_ukeyMessageLabel->setToolTip(text); + m_ukeyMessageLabel->show(); + } else { + m_ukeyMessageLabel->hide(); + } +} + +void AuthDialog::setLoginTypeTip(QString strLoginTypeTip) +{ + m_strLoginTypeTip = strLoginTypeTip; + if (!m_strLoginTypeTip.isEmpty()) { +// QFontMetrics font(m_labelLoginTypeTip->font()); +// QString strDisplay = font.elidedText(m_strLoginTypeTip, Qt::ElideRight, m_messageLabel->width()-8); + m_labelLoginTypeTip->setTipText(m_strLoginTypeTip); + m_labelLoginTypeTip->show(); + } else { + m_labelLoginTypeTip->hide(); + } +} + +void AuthDialog::setLoginMsg(QString strLoginMsg) +{ + setLoginTypeTip(strLoginMsg); +} + +void AuthDialog::onBiometricDbusChanged(bool bActive) +{ + qDebug()<<"BiometricDbus:"<getMaxFailedTimes(); + } + + //服务没启动,或者打开DBus连接出错 + if(!m_biometricProxy->isValid()) { + qWarning() << "An error occurs when connect to the biometric DBus"; + if (m_deviceInfo) { + if (!m_loginOpts || !m_loginOpts->findDeviceById(m_deviceInfo->id) + || m_loginOpts->isDeviceDisable(m_deviceInfo->id)) { + m_deviceInfo = DeviceInfoPtr(); + } + } + switchLoginOptType(LOGINOPT_TYPE_PASSWORD); + return; + } + + //初始化生物识别认证UI + initBiometricWidget(); + + //没有可用设备,不启用生物识别认证 + if(m_loginOpts->getLoginOptCount() < 1) { + qWarning() << "No available devices"; + if (m_deviceInfo) { + if (!m_loginOpts || !m_loginOpts->findDeviceById(m_deviceInfo->id) + || m_loginOpts->isDeviceDisable(m_deviceInfo->id)) { + m_deviceInfo = DeviceInfoPtr(); + } + } + return; + } + + //获取默认设备 + if (m_loginOpts) { + if(m_curUserInfo.name() == "*login") + m_deviceName = m_loginOpts->getDefaultDevice(m_strManualLoginName); + else + m_deviceName = m_loginOpts->getDefaultDevice(m_curUserInfo.name()); + } + qDebug() << m_deviceName; + if (m_deviceInfo) { + if (!m_loginOpts || !m_loginOpts->findDeviceById(m_deviceInfo->id) + || m_loginOpts->isDeviceDisable(m_deviceInfo->id)) { + m_deviceInfo = DeviceInfoPtr(); + } + } + //如果默认设备为空的话,第一次不启动生物识别认证 + if(m_deviceName.isEmpty() && !m_deviceInfo) { + qDebug() << "No default device"; + return; + } + //第一次,获取默认设备的设备信息,之后使用的则是从设备选择窗口传出的设备信息 + if(!m_deviceInfo) { + m_deviceInfo = m_loginOpts->findDeviceByName(m_deviceName); + if(!m_deviceInfo) { + qDebug() << "Device Not found: " << m_deviceName; + return; + } + } + + //已经错误超过3次 + if(m_failMap.contains(m_curUserInfo.uid()) && m_failMap[m_curUserInfo.uid()][m_deviceInfo->id] >= maxFailedTimes) { + if (m_deviceInfo->deviceType == UniT_Remote) { + setLoginTypeTip(tr("Failed to verify %1, please enter password to unlock").arg(getDeviceType_tr(m_deviceInfo->deviceType))); + } else { + setLoginTypeTip(tr("Unable to verify %1, please enter password to unlock").arg(getDeviceType_tr(m_deviceInfo->deviceType))); + if (m_deviceInfo->deviceType == BioT_Face) { + QImage imgFailed; + setFaceImg(imgFailed, 1); + } + } + m_loginOpts->setDeviceDisable(m_deviceInfo->id, true); + return; + } + + if(m_deviceInfo->deviceType == LOGINOPT_TYPE_GENERAL_UKEY){ + switchLoginOptType(LOGINOPT_TYPE_PASSWORD); + m_loginOpts->setSelectedPassword(); + return ; + } + + switchLoginOptType(m_loginOpts->convertDeviceType(m_deviceInfo->deviceType)); + // 自行校验生物设备,pam greeter校验密码 + startBioAuth(); + }); + } +} + +void AuthDialog::onFRetryButtonClicked() +{ + m_fRetryButton->hide(); + switchLoginOptType(LOGINOPT_TYPE_FACE); + startBioAuth(); +} + +void AuthDialog::setWillLoginUser(QString strUserName, bool isOneKeyLogin) +{ + m_strServiceUser = strUserName; + m_isOneKeyLogin = isOneKeyLogin; +} + +void AuthDialog::onCustomRequestAccount(QString strName) +{ + qDebug()<<"onCustomRequestAccount:"<= 0 && !m_curUserInfo.name().isEmpty() && !m_curUserInfo.name().startsWith("*")) { + QJsonObject user; + user["Name"] = m_curUserInfo.name(); + user["Id"] = (double)(m_curUserInfo.uid()); + QFile faceFile(m_face); + if (!faceFile.exists()) { + user["HeadImg"] = m_strDefaultFace; + } else { + user["HeadImg"] = m_face; + } + user["RealName"] = m_curUserInfo.fullName(); + contentObj["CurrentUser"] = user; + } else { + retObj["Ret"] = -1; + retObj["Message"] = "Current user is invalid!"; + } + } + } + retObj["Content"] = contentObj; + return QString(QJsonDocument(retObj).toJson()); + } + } +} + +int AuthDialog::onCustomPlugEnv() +{ + return LoginPluginInterface::LOGINPLUGINENV_LOGIN; +} + +void AuthDialog::setCustomAuthDefault(bool isDefault) +{ + m_isCustomDefault = isDefault; +} + +QString AuthDialog::getDeviceType_tr(int deviceType) +{ + switch(deviceType) + { + case BioT_FingerPrint: + return tr("FingerPrint"); + case BioT_FingerVein: + return tr("FingerVein"); + case BioT_Iris: + return tr("Iris"); + case BioT_Face: + return tr("Face"); + case BioT_VoicePrint: + return tr("VoicePrint"); + case UniT_General_Ukey: + return tr("Ukey"); + case UniT_Remote: + return tr("QRCode"); + default: + return ""; + } +} diff --git a/src/widgets/authdialog.h b/src/widgets/authdialog.h new file mode 100644 index 0000000..c56edbe --- /dev/null +++ b/src/widgets/authdialog.h @@ -0,0 +1,251 @@ +#ifndef AUTHDIALOG_H +#define AUTHDIALOG_H + +#include "mylistwidget.h" +#include +#include "userinfo.h" +#include "../dbusifs/biometrichelper.h" +#include "definetypes.h" +#include "biodefines.h" +#include "loginoptionswidget.h" +#include "pluginsloader.h" + +class QLabel; +class KLabel; +class QPushButton; +class IconEdit; +class LockDialogModel; +class BioButtonListWidget; +class StatuButton; +class QTimer; + +extern float scale; +class AuthDialog : public QWidget +{ + Q_OBJECT + +public: + explicit AuthDialog(LockDialogModel *model, UserInfo userInfo, QWidget *parent = nullptr); + + void initUI(); + void switchLoginOptType(unsigned uLoginOptType,bool faceBtnClicked = false); + +public: + void startAuth(); + void stopAuth(); + void onCurUserChanged(UserInfo userInfo); + + void updateUI(); + void updateAuthSize(); + void setLoginTypeTip(QString strLoginTypeTip); + void setUkeyTypeTip(QString text); + void setDirLogin(); + void startLoadingUkey(); + void stopLoadingUkey(); + void updateLoadingPixmap(); + void setWillLoginUser(QString strUserName, bool isOneKeyLogin); + /** + * @brief setCustomAuthDefault 设置是否默认第三方认证 + * @param isDefault true 是,否则 否 + */ + void setCustomAuthDefault(bool isDefault); + +private Q_SLOTS: + void onPamShowMessage(QString strMsg, int nType); + void onPamShowPrompt(QString strPrompt, int nType); + void onPamAuthCompleted(); + void onRespond(const QString &strRes); + void onMessageButtonClicked(); + + void onLoginOptsCount(unsigned uCount); + void onLoginOptImage(QImage img); + void setLoginMsg(QString strLoginMsg); + void onFirstLoginIdentifyComplete(QDBusPendingCallWatcher *watcher); + + /** + * @brief onCustomRequestAccount 第三方请求认证用户槽 + * @param strName 用户名 + */ + void onCustomRequestAccount(QString strName); + /** + * @brief onCustomAuthResult 第三方认证结果 + * @param nResult 结果值,0 成功,其他失败 + * @param strMsg 结果消息 + */ + void onCustomAuthResult(int nResult, QString strMsg); + /** + * @brief onCustomRequest 第三方请求响应槽 + * @param strReqJson 请求json + * @return 请求结果 + */ + QString onCustomRequest(QString strReqJson); + /** + * @brief onCustomPlugEnv 插件所处环境 + * @return 登录或锁屏等 + */ + int onCustomPlugEnv(); + +private Q_SLOTS: + void onBiometricButtonClicked(); + void onDeviceChanged(unsigned uCurLoginOptType, const DeviceInfoPtr &deviceInfo); + void onBiometricAuthComplete(bool result, int nStatus); + void onPrepareForSleep(bool sleep); + void setQRCode(QImage& imgQRCode); + void setFaceImg(QImage& imgFace, int nStatus = 0); + void setQRCodeMsg(QString strMsg); + void onLoadingImage(); + void onBiometricDbusChanged(bool bActive); + void onFRetryButtonClicked(); + void pamBioSuccess(); + void onRespondUkey(const QString &text); + +Q_SIGNALS: + void authSucceed(QString strUserName); + /** + * @brief 手动输入用户名 + * @param userName 用户名 + */ + void userChangedByManual(const QString &userName); + /** + * @brief customRequestAccount 第三方请求认证用户信号 + * @param account 用户名 + */ + void customRequestAccount(QString account); + +protected: + bool eventFilter(QObject *obj, QEvent *event); + void resizeEvent(QResizeEvent *event); + +private: + void initTipWidget(); + void initHeaderWidget(); + void initNameWidget(); + void initEditWidget(); + void initMessagerWidget(); + void initUkeyPasswordWidget(); + void initLoginoptionWidget(); + + void showAuthenticated(bool successful = true); + void initConnections(); + void clearMessage(); + bool unlockUserTimer(); + + void initBiometricWidget(); + void setBiometricWidgetGeometry(); + void performBiometricAuth(); + void skipBiometricAuth(); + + void startBioAuth(unsigned uTimeout = 1000); + void restartBioAuth(); + void waitBiometricServiceStatus(); + QString getDeviceType_tr(int deviceType); + void setFace(const QString& facePath); + + void updatePixmap(); + + //一键开机认证函数 + void startFirstLogin(); + +private: + LockDialogModel *m_modelLockDialog = nullptr; + + QWidget *m_tipWidget = nullptr; + QWidget *m_headerWidget = nullptr; + QWidget *m_nameWidget = nullptr; + QLabel *m_labelHeadImg = nullptr; //头像 + KLabel *m_nameLabel = nullptr; //用户名 + + QWidget *m_editWidget = nullptr; + QWidget *m_messageWidget = nullptr; + IconEdit *m_passwordEdit = nullptr; //密码输入框 + KLabel *m_messageLabel = nullptr; //PAM消息显示 + QPushButton *m_messageButton = nullptr; //免密登录按钮 + + QWidget *m_ukeyPasswdWidget = nullptr; //放置密码输入框和信息列表 + IconEdit *m_ukeyPasswordEdit = nullptr; //ukey密码输入框 + KLabel *m_ukeyMessageLabel = nullptr; //PAM消息显示 + + QWidget *m_ukeyLoadingWidget = nullptr; //ukey loading窗口 + QPushButton *m_loadingButton = nullptr; + KLabel *m_ukeyLoadingText = nullptr; + QTimer *m_loadingTimer = nullptr; + QPixmap m_ukeyLoadingPixmap; + + QLabel *m_labelFace = nullptr; + KLabel *m_labelLoginTypeTip = nullptr; // 登录类型提示 + QLabel *m_labelQRCode = nullptr; // 二维码图标 + KLabel *m_labelQRCodeMsg = nullptr; // 二维码状态消息提示 + QLabel *m_labelQRCodeTip = nullptr; + QPushButton *m_fRetryButton = nullptr; //人脸识别重试按钮 + + QWidget *m_widgetLoginOpts = nullptr; // 登录选项 + KLabel *m_optionTip = nullptr; + + BioButtonListWidget *bottomListWidget = nullptr; + + UserInfo m_curUserInfo; + bool m_bRecvPrompt = false; + bool m_bHasUnacknowledgedMsg = false; + bool m_bDirectLogin = false; + bool m_bNeedRetry = false; + QString m_preStrMessage = ""; + int m_preStrMessageType = -1; + bool m_isNameLogin = false; + bool m_isAutoSwitch = false; + bool m_isPassWdInput = false; + //手动输入用户标记,设置该标记的原因是判断是不是手动输入用户, + //如果输入了无法登录的用户,就会一直输出密码错误信息 + bool m_isManual = false; + QString m_strManualLoginName; + bool m_isInputPasswd; + + enum AuthMode { PASSWORD, BIOMETRIC, UNKNOWN }; + + AuthMode authMode = UNKNOWN; + // 生物识别认证 + QString m_deviceName; + DeviceInfoPtr m_deviceInfo = nullptr; + BiometricHelper *m_biometricProxy = nullptr; + LoginOptionsWidget *m_loginOpts = nullptr; + + QWidget *m_customWidget; /** 第三方认证界面窗口 */ + QHBoxLayout *m_layoutCustom; /** 第三方认证界面主布局 */ + + bool isBioSuccess = false; // 生物认证是否成功 + bool manualStopBio = false; + + bool m_isCustomDefault = false; /** 是否默认使用第三方认证 */ + QMap> m_failMap; + int maxFailedTimes; + QString m_face; + QTimer *m_bioTimer = nullptr; + QImage m_imgQRCode; + unsigned m_uCurLoginOptType = LOGINOPT_TYPE_PASSWORD; // 当前登录验证方式 + QString m_strLoginTypeTip = ""; + int m_nLastDeviceId = -1; + QString m_strDefaultFace; + int m_fTimeoutTimes = 0; + + QPixmap m_waitingPixmap; + QTimer *w_timer = nullptr; + UniAuthService *m_uniauthService = nullptr; + bool isLoadingUkey = false; + bool isPowerup = false; + QDBusInterface * bioService=nullptr; + int drvid = -1; + bool isFirstAuth = false; + QString m_lastUserName = ""; + + // 将登录认证的用户名 + QString m_strServiceUser = ""; + // 是否为一键登录 + bool m_isOneKeyLogin = false; + + PluginsLoader *m_pluginsLoader = nullptr; /** 插件加载器 */ + + + bool m_isLockingFlg; //判断当前是否正在锁定倒计时 + int m_nCurLockMin; //当前锁定的分钟数 + QTimer *m_timerUserUnlock = nullptr; +}; +#endif // AUTHDIALOG_H diff --git a/src/batterywidget.cpp b/src/widgets/batterywidget.cpp similarity index 54% rename from src/batterywidget.cpp rename to src/widgets/batterywidget.cpp index d0a1c72..65db55f 100644 --- a/src/batterywidget.cpp +++ b/src/widgets/batterywidget.cpp @@ -22,9 +22,9 @@ #include #include -BatteryWidget::BatteryWidget(QPoint point, QWidget *parent) : +BatteryWidget::BatteryWidget(LockDialogModel *model, QWidget *parent) : QWidget(parent), - mPoint(point) + m_modelLockDialog(model) { // setWindowOpacity(0); setAttribute(Qt::WA_TranslucentBackground); @@ -74,46 +74,15 @@ void BatteryWidget::initUi() void BatteryWidget::setupComponent() { - QString batteryPath = ""; - dface = new QDBusInterface(UPOWER_SERVICE, UPOWER_PATH, UPOWER_INTERFACE, QDBusConnection::systemBus(), this); - QDBusReply> reply = dface->call("EnumerateDevices"); - if (dface->isValid()) { - for (QDBusObjectPath op : reply.value()) { - if (op.path().contains("battery_")) { - batteryPath = op.path(); - qDebug() << "battery path is :" << batteryPath; - break; - } - } - } else { - qDebug() << "Enumerate devices failed"; - } - batInterface = new QDBusInterface(UPOWER_SERVICE, batteryPath, FREEDESKTOP_UPOWER, QDBusConnection::systemBus(), this); + mIconBtn->setIconSize(QSize(48, 32)); + mIconBtn->setFocusPolicy(Qt::NoFocus); + mIconBtn->setIcon(QIcon::fromTheme(m_modelLockDialog->getBatteryIconName())); - QDBusConnection::systemBus().connect( - UPOWER_SERVICE, batteryPath, FREEDESKTOP_UPOWER, "PropertiesChanged", this, SLOT(dealMessage(QDBusMessage))); - iface = new QDBusInterface(UPOWER_SERVICE, UPOWER_PATH, FREEDESKTOP_UPOWER, QDBusConnection::systemBus()); - if (dface->isValid()) { - mIconBtn->setIconSize(QSize(48, 32)); - mIconBtn->setFocusPolicy(Qt::NoFocus); - mIconBtn->setIcon(QIcon::fromTheme(getBatteryIconName())); - } - ed = EngineDevice::getInstance(); - onBatteryChanged(ed->engine_get_state()); + onBatteryChanged(m_modelLockDialog->getBatteryArgs()); - int size; - size = ed->devices.size(); - for (int i = 0; i < size; i++) { - DEVICE *dv; - dv = ed->devices.at(i); + connect(m_modelLockDialog, &LockDialogModel::batteryStatusChanged, this, &BatteryWidget::onBatteryStatusChanged); - if (dv->m_dev.kind == UP_DEVICE_KIND_LINE_POWER) { - continue; - } - - connect(ed, &EngineDevice::engine_signal_Battery_State, this, &BatteryWidget::onBatteryChanged); - continue; - } + connect(m_modelLockDialog, &LockDialogModel::batteryChanged, this, &BatteryWidget::onBatteryChanged); } void BatteryWidget::setPoint(QPoint point) @@ -121,37 +90,6 @@ void BatteryWidget::setPoint(QPoint point) mPoint = point; } -QString BatteryWidget::getBatteryIconName() -{ - if (dface->isValid() && iface->isValid()) { - bool batteryState = false; - QDBusReply reply = iface->call("Get", UPOWER_SERVICE, "OnBattery"); - if (reply.isValid()) { - batteryState = reply.value().toBool(); - } - double percentage = -1.0; - QDBusReply percentage_reply = batInterface->call("Get", UPOWER_DIVICES_SERVICE, "Percentage"); - if (percentage_reply.isValid()) { - percentage = percentage_reply.value().toDouble(); - } - - if (batteryState) { - return QString("battery-level-%1-symbolic").arg((int)percentage / 10 * 10); - } else { - return QString("battery-level-%1-charging-symbolic").arg((int)percentage / 10 * 10); - } - } - return QString(); -} - -void BatteryWidget::showEvent(QShowEvent *event) -{ - QPoint pos = QPoint(mPoint.x(), - mPoint.y() - 112); - this->move(pos); - QWidget::showEvent(event); -} - void BatteryWidget::paintEvent(QPaintEvent *event) { QStyleOption opt; @@ -167,11 +105,6 @@ void BatteryWidget::paintEvent(QPaintEvent *event) style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); } -void BatteryWidget::setBatteryIcon(QString icon) -{ - mIconBtn->setIcon(QIcon::fromTheme(icon)); -} - void BatteryWidget::onBatteryChanged(QStringList args) { int battery = args.at(0).toInt(); @@ -192,7 +125,7 @@ void BatteryWidget::onBatteryChanged(QStringList args) mValueLabel->setText(QString("%1%").arg(battery)); } -void BatteryWidget::dealMessage(QDBusMessage) +void BatteryWidget::onBatteryStatusChanged(QString iconName) { - mIconBtn->setIcon(QIcon::fromTheme(getBatteryIconName())); + mIconBtn->setIcon(QIcon::fromTheme(iconName)); } diff --git a/src/batterywidget.h b/src/widgets/batterywidget.h similarity index 61% rename from src/batterywidget.h rename to src/widgets/batterywidget.h index acf9ac5..e1ba432 100644 --- a/src/batterywidget.h +++ b/src/widgets/batterywidget.h @@ -24,47 +24,32 @@ #include #include #include -#include "enginedevice.h" - -#define FREEDESKTOP_UPOWER "org.freedesktop.DBus.Properties" -#define UPOWER_INTERFACE "org.freedesktop.UPower" -#define UPOWER_PATH "/org/freedesktop/UPower" -#define UPOWER_SERVICE "org.freedesktop.UPower" -#define UPOWER_DISPLAY_PATH "/org/freedesktop/UPower/devices/DisplayDevice" -#define UPOWER_DIVICES_SERVICE "org.freedesktop.UPower.Device" +#include "lock-dialog/lockdialogmodel.h" class BatteryWidget : public QWidget { Q_OBJECT public: - BatteryWidget(QPoint point, QWidget *parent = nullptr); + BatteryWidget(LockDialogModel *model, QWidget *parent = nullptr); void initUi(); void setupComponent(); void setPoint(QPoint point); - QString getBatteryIconName(); protected: - void showEvent(QShowEvent *event); void paintEvent(QPaintEvent *event); private: + LockDialogModel *m_modelLockDialog = nullptr; QLabel *mModeLabel; QPushButton *mIconBtn; QLabel *mValueLabel; QLabel *mStatusLabel; QPoint mPoint; - QDBusInterface *batInterface; - QDBusInterface *iface; - QDBusInterface *dface; - - EngineDevice* ed; - private Q_SLOTS: - void setBatteryIcon(QString icon); void onBatteryChanged(QStringList args); - void dealMessage(QDBusMessage); + void onBatteryStatusChanged(QString iconName); }; diff --git a/src/widgets/biobuttonlistwidget.cpp b/src/widgets/biobuttonlistwidget.cpp new file mode 100644 index 0000000..4eac689 --- /dev/null +++ b/src/widgets/biobuttonlistwidget.cpp @@ -0,0 +1,137 @@ +#include "biobuttonlistwidget.h" +#include "statusbutton.h" +#include "commonfunc.h" +#include "definetypes.h" +#include "loginauthinterface.h" +#include "pluginsloader.h" + +BioButtonListWidget::BioButtonListWidget(QWidget *parent) + : MyListWidget(parent) +{ +// installEventFilter(this); + initUI(); + initConnections(); +} + +void BioButtonListWidget::initUI() +{ + this->setFlow(QListWidget::LeftToRight); + this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + QString buttonListStyle = "QListWidget{ background:rgba(255, 255, 255, 0%); border: 0px;}" + "QListWidget::item{border-radius: 4px; background:rgba(255, 255, 255, 0%);}"; + this->setStyleSheet(buttonListStyle); + this->setSpacing(8); + + +} + +void BioButtonListWidget::initConnections() +{ + // 响应点击事件 + connect(this, &BioButtonListWidget::itemClicked, this, &BioButtonListWidget::onListItemClicked); + connect(this, &BioButtonListWidget::currentItemChanged, this, &BioButtonListWidget::onListItemChanged); +} + +void BioButtonListWidget::addOptionButton(unsigned uLoginOptType, int nDrvId, QString strDrvName) +{ + m_listDriveId.append(nDrvId); + + StatusButton *buttonWidget = new StatusButton(this, BOTBUTTON); + QListWidgetItem *buttonItem = new QListWidgetItem(); + buttonItem->setSizeHint(QSize(48, 48)); + this->insertItem(this->count(), buttonItem); + this->setItemWidget(buttonItem, buttonWidget); + buttonWidget->installEventFilter(this); + this->addItem(buttonItem); + + QPixmap iconPixmap; + switch (uLoginOptType) { + case LOGINOPT_TYPE_PASSWORD: + iconPixmap = loadSvg(":/image/assets/ukui-loginopt-password.svg", "white", 16); + break; + case LOGINOPT_TYPE_GENERAL_UKEY: + iconPixmap = loadSvg(":/image/assets/ukui-loginopt-ukey.svg", "white", 16); + break; + case LOGINOPT_TYPE_FACE: + iconPixmap = loadSvg(":/image/assets/ukui-loginopt-face.svg", "white", 16); + break; + case LOGINOPT_TYPE_FINGERPRINT: + iconPixmap = loadSvg(":/image/assets/ukui-loginopt-finger.svg", "white", 16); + break; + case LOGINOPT_TYPE_IRIS: + iconPixmap = loadSvg(":/image/assets/ukui-loginopt-iris.svg", "white", 16); + break; + case LOGINOPT_TYPE_VOICEPRINT: + iconPixmap = loadSvg(":/image/assets/ukui-loginopt-voice.svg", "white", 16); + break; + case LOGINOPT_TYPE_FINGERVEIN: + iconPixmap = loadSvg(":/image/assets/ukui-loginopt-fingervein.svg", "white", 16); + break; + case LOGINOPT_TYPE_QRCODE: + iconPixmap = loadSvg(":/image/assets/ukui-loginopt-qrcode.svg", "white", 16); + break; + case LOGINOPT_TYPE_CUSTOM: + LoginAuthInterface *plugin = dynamic_cast(PluginsLoader::instance().findModulesByType(LoginPluginInterface::MODULETYPE_AUTH).values().first()); + QString strIcon = plugin->icon(); + if (strIcon.startsWith("/")) { + if (strIcon.endsWith(".svg")) { + iconPixmap = loadSvg(strIcon, "white", 16); + } else { + iconPixmap.load(strIcon); + iconPixmap.scaled(40, 40); + } + } else { + iconPixmap = QIcon::fromTheme(strIcon).pixmap(48,48).scaled(40, 40); + } + if (iconPixmap.isNull()) { + iconPixmap = loadSvg(":/images/ukui-loginopt-custom.svg", "white", 16); + } + break; + } + buttonWidget->setIcon(iconPixmap); + buttonWidget->setToolTip(strDrvName); + connect(buttonWidget, SIGNAL(buttonClicked(int)), this, SLOT(onOptionSelected(int))); +} + +void BioButtonListWidget::onOptionSelected(int nIndex) +{ + if (nIndex < 0) + return; + + +} + +void BioButtonListWidget::updateUI() +{ + this->setSpacing(8*scale); + QList statusButton = this->findChildren(); + for (auto button : statusButton) { + button->setFixedSize(48*scale, 48*scale); + } +} + +void BioButtonListWidget::onListItemClicked(QListWidgetItem *item) +{ + QWidget *widget = itemWidget(item); + StatusButton *currentItem = qobject_cast(widget); + if (currentItem) { + currentItem->setClickedStatus(CLICKED); + currentItem->buttonClicked(currentItem->getDrivedId()); + } +} + +void BioButtonListWidget::onListItemChanged(QListWidgetItem *current, QListWidgetItem *previous) +{ + QWidget *currentWidget = itemWidget(current); + StatusButton *currentItem = static_cast(currentWidget); + if (currentItem) + currentItem->setClickedStatus(SELECT); + if (previous) { + QWidget *previousWidget = itemWidget(previous); + StatusButton *previousItem = static_cast(previousWidget); + if (previousItem) + previousItem->setClickedStatus(NORMAL); + } +} + diff --git a/src/widgets/biobuttonlistwidget.h b/src/widgets/biobuttonlistwidget.h new file mode 100644 index 0000000..5699088 --- /dev/null +++ b/src/widgets/biobuttonlistwidget.h @@ -0,0 +1,39 @@ +#ifndef BIOBUTTONLISTWIDGET_H +#define BIOBUTTONLISTWIDGET_H + +#include +#include "mylistwidget.h" + +class QListWidgetItem; + +extern float scale; +class BioButtonListWidget : public MyListWidget +{ + Q_OBJECT +public: + explicit BioButtonListWidget(QWidget *parent = nullptr); + + void updateWidgetSize(); + + void addOptionButton(unsigned uLoginOptType, int nDrvId, QString strDrvName); + + void onOptionSelected(int nIndex); + + void updateUI(); + +public Q_SLOTS: + void onListItemClicked(QListWidgetItem *item); + void onListItemChanged(QListWidgetItem *current, QListWidgetItem *previous); + +Q_SIGNALS: + void userSelected(QString strUserName); + +private: + void initUI(); + void initConnections(); + +private: + QList m_listDriveId; +}; + +#endif // BIOBUTTONLISTWIDGET_H diff --git a/src/widgets/blockwidget.cpp b/src/widgets/blockwidget.cpp new file mode 100644 index 0000000..c0ff01a --- /dev/null +++ b/src/widgets/blockwidget.cpp @@ -0,0 +1,126 @@ +#include "blockwidget.h" +#include "klabel.h" +#include "statusbutton.h" +#include +#include +#include +#include +#include +#include +BlockWidget::BlockWidget(QWidget* parent) : QWidget(parent) +{ + initUi(); + setFocusPolicy(Qt::NoFocus); +} + +BlockWidget::~BlockWidget() +{ + +} + +void BlockWidget::initUi() +{ + QVBoxLayout *mainLayout = new QVBoxLayout(this); + this->setLayout(mainLayout); + + m_tipLabel = new KLabel(this); + m_tipLabel->setAlignment(Qt::AlignCenter); + QHBoxLayout *listLayout = new QHBoxLayout(); + listLayout->setAlignment(Qt::AlignCenter); + m_listView = new QListView(this); + listLayout->addWidget(m_listView); + + + QHBoxLayout *buttonLayout = new QHBoxLayout(); + m_cancelButton = new QPushButton(this); + m_cancelButton->setText(tr("Cancel")); + m_cancelButton->setFocusPolicy(Qt::NoFocus); + buttonLayout->addWidget(m_cancelButton); + m_confirmButton = new QPushButton(this); + m_confirmButton->setText(tr("Confrim")); + m_confirmButton->setFocusPolicy(Qt::NoFocus); + buttonLayout->addWidget(m_confirmButton); + buttonLayout->setAlignment(Qt::AlignCenter); + + mainLayout->setSpacing(46); + mainLayout->addStretch(); + mainLayout->addWidget(m_tipLabel); + mainLayout->addLayout(listLayout); + mainLayout->addLayout(buttonLayout); + mainLayout->addStretch(); + + connect(m_cancelButton, &QPushButton::clicked, this, [&]() { emit cancelButtonclicked(); }); + connect(m_confirmButton, &QPushButton::clicked, this, [&]() { emit confirmButtonclicked(); }); +} + +void BlockWidget::setTips(const QString tips) +{ + m_cancelButton->setFixedSize(96, 36); + m_confirmButton->setFixedSize(96, 36); + m_tipLabel->setFixedWidth(this->width()); + m_cancelButton->setStyleSheet("QPushButton{background: rgba(255, 255, 255, 0.2);border-radius: 8px;color: white;}" + "QPushButton:hover{background: rgba(255, 255, 255, 0.4);border-radius: 8px;}" + "QPushButton:pressed {background: rgba(255, 255, 255, 0.3);border-radius: 8px;}"); + m_confirmButton->setStyleSheet("QPushButton{background: rgba(255, 255, 255, 0.2);border-radius: 8px;color: white;}" + "QPushButton:hover{background: rgba(255, 255, 255, 0.4);border-radius: 8px;}" + "QPushButton:pressed {background: rgba(255, 255, 255, 0.3);border-radius: 8px;}"); + // sysFont.setPointSize((16 + curFontSize) *m_ptToPx); + // m_confirmButton->setFont(sysFont); + // m_cancelButton->setFont(sysFont); + m_confirmButton->show(); + m_tipLabel->show(); + m_listView->hide(); + m_tipLabel->setText(tips); +} + +void BlockWidget::setWarning(QStringList list, int type) +{ + m_tipLabel->setFixedWidth(this->width()); + switch (type) { + case 0: + m_tipLabel->setText(tr("The following program is running to prevent the system from reboot!")); + break; + case 1: + m_tipLabel->setText(tr("The following program is running to prevent the system from shutting down!")); + break; + case 2: + m_tipLabel->setText(tr("The following program is running to prevent the system from suspend!")); + break; + case 3: + m_tipLabel->setText(tr("The following program is running to prevent the system from hibernate!")); + break; + default: + break; + } + m_listView->show(); + + QStandardItemModel *model = new QStandardItemModel(this); + QIcon icon; + QString iconName = list.at(0); + QString appName = list.at(1); + + if (!iconName.isEmpty() && QIcon::hasThemeIcon(iconName)) { + icon = QIcon::fromTheme(iconName); + } else if (QIcon::hasThemeIcon("application-x-desktop")) { + icon = QIcon::fromTheme("application-x-desktop"); + } + model->appendRow(new QStandardItem(icon, appName)); + + m_listView->verticalScrollMode(); + m_listView->setStyleSheet("color:white; background-color: rgba(255,255,255,30%); border-radius: 12px;"); +// sysFont.setPointSize((10 + curFontSize) *m_ptToPx); +// m_listView->setFont(sysFont); + m_listView->setEditTriggers(QAbstractItemView::NoEditTriggers); + m_listView->setIconSize(QSize(32,32)); + m_listView->setModel(model); + m_listView->setFixedSize(520, 320); + m_cancelButton->setFixedSize(120, 48); + + m_confirmButton->hide(); + m_cancelButton->setStyleSheet("QPushButton{background: rgba(255, 255, 255, 0.2);border-radius: 8px;color: white;}" + "QPushButton:hover{background: rgba(255, 255, 255, 0.4);border-radius: 8px;}" + "QPushButton:pressed {background: rgba(255, 255, 255, 0.3);border-radius: 8px;}"); +// sysFont.setPointSize((16 + curFontSize) *m_ptToPx); +// m_cancelButton->setFont(sysFont); +} + diff --git a/src/widgets/blockwidget.h b/src/widgets/blockwidget.h new file mode 100644 index 0000000..0612540 --- /dev/null +++ b/src/widgets/blockwidget.h @@ -0,0 +1,37 @@ +#ifndef BLOCKWIDGET_H +#define BLOCKWIDGET_H + +#include +#include + +class KLabel; +class QPushButton; +class QListView; + +class BlockWidget : public QWidget +{ + Q_OBJECT + +public: + explicit BlockWidget(QWidget *parent = nullptr); + ~BlockWidget(); + void setTips(const QString tips); + void setWarning(QStringList list, int type); +private: + void initUi(); + +Q_SIGNALS: + void cancelButtonclicked(); + void confirmButtonclicked(); +private: + KLabel *m_tipLabel = nullptr; + QListView *m_listView = nullptr; + QPushButton *m_cancelButton = nullptr; + QPushButton *m_confirmButton = nullptr; + + int m_blockType = 0; + bool m_multiUsers = false; + double curFontSize; +}; + +#endif // BLOCKWIDGET_H diff --git a/src/widgets/fullbackgroundwidget.cpp b/src/widgets/fullbackgroundwidget.cpp new file mode 100644 index 0000000..9ad3dcd --- /dev/null +++ b/src/widgets/fullbackgroundwidget.cpp @@ -0,0 +1,833 @@ +/* + * Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * +**/ +#include "fullbackgroundwidget.h" +#include "../lock-dialog/lockdialogmodel.h" +#include "utils.h" +#include "lockwidget.h" +#include "agreementwindow.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "grab-x11.h" +#include +#include +#include +#include +#include +#include +#include +#include "commonfunc.h" +#include "screensaver.h" +#include "screensaverwidget.h" + +FullBackgroundWidget::FullBackgroundWidget(LockDialogModel *model, QWidget *parent) + : QWidget(parent) + , m_modelLockDialog(model) +{ + initCurrentBackground(); + initUI(); + initConnections(); +} + +FullBackgroundWidget::~FullBackgroundWidget() +{ + if (m_backgrondGradationTimer) + { + if (m_backgrondGradationTimer->isActive()) + m_backgrondGradationTimer->stop(); + m_backgrondGradationTimer->disconnect(); + m_backgrondGradationTimer->deleteLater(); + } + + +} +void FullBackgroundWidget::initUI() +{ + if(QX11Info::isPlatformX11()){ + /*捕获键盘,如果捕获失败,则可能是由于弹出菜单项已经捕获,那么模拟一次esc按键来退出菜单,如果仍捕获失败,则放弃锁屏,避免密码无法输入*/ + if(establishGrab()) + qDebug()<<"establishGrab : true"; + else { + qDebug()<<"establishGrab : false"; + /*检测当前是否存在弹出菜单,只有存在弹出菜单时,才模拟按键esc*/ + if(checkHasPopupMenu()){ + XTestFakeKeyEvent(QX11Info::display(), XKeysymToKeycode(QX11Info::display(),XK_Escape), True, 1); + XTestFakeKeyEvent(QX11Info::display(), XKeysymToKeycode(QX11Info::display(),XK_Escape), False, 1); + XFlush(QX11Info::display()); + sleep(1); + } + if(!establishGrab()) + { + exit(1); + } + } + } + + setMouseTracking(true); + QDesktopWidget *desktop = QApplication::desktop(); + setGeometry(desktop->geometry()); + + if (!m_lockWidget) { + m_lockWidget = new LockWidget(m_modelLockDialog, this); + connect(m_lockWidget, &LockWidget::authSucceed, this, &FullBackgroundWidget::onAuthSucceed); + m_lockWidget->setGeometry(this->geometry()); + m_lockWidget->show(); + } + + /* + * 还差判断秒级登录或处于登录界面时才显示,等整体开发完后再调试。 + */ + + if(m_modelLockDialog->getAgreementWindowShowLoginPrompt()){ + bool hideTitle = m_modelLockDialog->getAgreementWindowHideTitle(); + QString title = m_modelLockDialog->getAgreementWindowPromptTitle(); + QString text = m_modelLockDialog->getAgreementWindowText(); + + //文本内容不为空 且 如果配置了标题,则标题不为空 + if(!text.isEmpty() && (hideTitle || (!hideTitle && !text.isEmpty()))){ + m_agreementWindow = new AgreementWindow(hideTitle,title,text,this); + m_lockWidget->hide(); + m_agreementWindow->setGeometry(this->geometry()); + m_agreementWindow->show(); + connect(m_agreementWindow, &AgreementWindow::switchToGreeter, this, + [this]() { + m_agreementWindow->hide(); + m_lockWidget->show(); + update(); + }); + } + } + + setWindowFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint + | Qt::X11BypassWindowManagerHint); + + qApp->installNativeEventFilter(this); + installEventFilter(this); +} + +bool FullBackgroundWidget::eventFilter(QObject *obj, QEvent *event) +{ + static bool isFirstActive = true; + if(event->type() == QEvent::WindowDeactivate){ + QTimer::singleShot(50,this,SLOT(laterActivate())); + } else if(event->type() == QEvent::WindowActivate){ + if (isFirstActive) { + isFirstActive = false; + syslog(LOG_INFO, "[ukui-screensaver-dialog] window active event!!"); + } + QTimer::singleShot(500,this,SLOT(setLockState())); + //QTimer::singleShot(200,this,SLOT(killWindow())); + } + return QWidget::eventFilter(obj, event); +} + +void FullBackgroundWidget::initConnections() +{ + // 监听全屏窗口变化 + QDesktopWidget *desktop = QApplication::desktop(); + connect(desktop, &QDesktopWidget::resized, + this, &FullBackgroundWidget::onDesktopResized); + connect(desktop, &QDesktopWidget::workAreaResized, + this, &FullBackgroundWidget::onDesktopResized); + connect(desktop, &QDesktopWidget::primaryScreenChanged, + this, &FullBackgroundWidget::onDesktopResized); + connect(desktop, &QDesktopWidget::screenCountChanged, + this, &FullBackgroundWidget::onDesktopResized); + // 监听休眠、睡眠、唤醒 + connect(m_modelLockDialog, SIGNAL(prepareForSleep(bool)), this, SLOT(onPrepareForSleep(bool))); + connect(m_modelLockDialog, &LockDialogModel::currentUserChanged, this, &FullBackgroundWidget::onCurUserChanged); + connect(m_modelLockDialog, &LockDialogModel::showLock, this, &FullBackgroundWidget::onShowLock); + connect(m_modelLockDialog, &LockDialogModel::showBlankScreensaver, this, &FullBackgroundWidget::onShowBlankScreensaver); + connect(m_modelLockDialog, &LockDialogModel::showLockScreensaver, this, &FullBackgroundWidget::onShowLockScreensaver); + connect(m_modelLockDialog, &LockDialogModel::showScreensaver, this, &FullBackgroundWidget::onShowScreensaver); + connect(m_modelLockDialog, &LockDialogModel::showSessionIdle, this, &FullBackgroundWidget::onShowSessionIdle); + connect(m_modelLockDialog, &LockDialogModel::SecondRunParam, this, &FullBackgroundWidget::onSecondRunParam); + +} + +void FullBackgroundWidget::setLockState() +{ + if(m_bIsLockState == true) + return ; + + m_bIsLockState = true; + QString displayNum = QString(qgetenv("DISPLAY")).replace(":", "").replace(".", "_"); + QString sessionDbus = QString("%1%2").arg(QString(SS_DBUS_SERVICE)).arg(displayNum); + QDBusInterface *interface = new QDBusInterface(sessionDbus, + SS_DBUS_PATH, + SS_DBUS_INTERFACE); + if (!interface->isValid()) { + delete interface; + interface = new QDBusInterface(SS_DBUS_SERVICE, + SS_DBUS_PATH, + SS_DBUS_INTERFACE); + } + QDBusMessage msg = interface->call("SetLockState"); + if(msg.type() == QDBusMessage::ErrorMessage) + qDebug() << msg.errorMessage(); + interface->deleteLater(); +} + +void FullBackgroundWidget::onSecondRunParam(const QString &str) +{ + qDebug()<<"onSecondRunParam"<lockStateChanged(true); + + if (isHasLock) { + screenStatus = (ScreenStatus)(screenStatus | SCREEN_SAVER | SCREEN_LOCK); + } else { + screenStatus = (ScreenStatus)(screenStatus | SCREEN_SAVER); + } + + for(auto screen : QGuiApplication::screens()) + { + ScreenSaver *saver = m_modelLockDialog->getScreensaver(); + saver->mode = SaverMode(SAVER_BLANK_ONLY); + ScreenSaverWidget *saverWidget = new ScreenSaverWidget(saver, this); + widgetXScreensaverList.push_back(saverWidget); + saverWidget->setGeometry(screen->geometry()); + } + + setCursor(Qt::BlankCursor); + isBlank = true; + + if (0 == nDelay) { + /*在进行压力测试时,可能会出现锁屏界面启动极慢,导致在睡眠之前调用了锁屏,但 + * 锁屏没来得及绑定睡眠唤醒信号,导致唤醒后,锁屏界面没有收到信号从而一直显示黑屏的问题。 + * 因此这里在进入黑色屏保时,通过后台接口,获取一次当前是否应该显示黑色屏保状态*/ + bool ret = Q_EMIT m_modelLockDialog->GetBlankState(); + if(!ret){ + isBlank = false; + onClearScreensaver(); + } + }else{ + QTimer::singleShot(nDelay, this, [=](){ + if (isBlank) { + isBlank = false; + onClearScreensaver(); + } + }); + } +} + +void FullBackgroundWidget::onShowLock(bool isStartup) +{ + screenStatus = (ScreenStatus)(screenStatus | SCREEN_LOCK); + m_isStartupMode = isStartup; + show(); + Q_EMIT m_modelLockDialog->setCurrentUser(m_modelLockDialog->defaultUserName()); + Q_EMIT m_modelLockDialog->lockStateChanged(true); +} + +void FullBackgroundWidget::onShowSessionIdle() +{ + show(); + Q_EMIT m_modelLockDialog->lockStateChanged(true); +} + +void FullBackgroundWidget::onShowLockScreensaver() +{ + show(); + Q_EMIT m_modelLockDialog->lockStateChanged(true); +} + +void FullBackgroundWidget::onShowScreensaver() +{ + screenStatus = (ScreenStatus)(screenStatus | SCREEN_SAVER); + + for(auto screen : QGuiApplication::screens()) + { + ScreenSaver *saver = m_modelLockDialog->getScreensaver(); + /*锁屏设置的Qt::WA_TranslucentBackground属性会导致第三方屏保变得透明,因此在使用第三方屏保时 + * 取消该属性,清除屏保时再设置回来*/ + if(saver->path != "/usr/lib/ukui-screensaver/ukui-screensaver-default") + { + // setAttribute(Qt::WA_TranslucentBackground,false); + } + + ScreenSaverWidget *saverWidget = new ScreenSaverWidget(saver, this); + qDebug() << " new ScreenSaverWidget"; + widgetXScreensaverList.push_back(saverWidget); + //深色模式有一像素的白边,所以主屏幕向左,向右移一个像素点;这种操作后,外显上方仍旧会有一个像素的白边,暂时不对外显做偏移处理 + if(screen == qApp->primaryScreen()) { + saverWidget->setGeometry(screen->geometry().x()-1, screen->geometry().y()-1, + screen->geometry().width()+1, screen->geometry().height()+1); + } else { + saverWidget->setGeometry(screen->geometry()); + } + } + show(); + Q_EMIT m_modelLockDialog->lockStateChanged(true); +} + +void FullBackgroundWidget::onClearScreensaver() +{ + screenStatus = (ScreenStatus)(screenStatus & ~SCREEN_SAVER); + + for(auto widget : widgetXScreensaverList) + { + widget->close(); + } + widgetXScreensaverList.clear(); + + unsetCursor(); +} + +void FullBackgroundWidget::onShowPowerManager() +{ + show(); + Q_EMIT m_modelLockDialog->lockStateChanged(true); +} + +void FullBackgroundWidget::onCloseScreensaver() +{ + show(); + Q_EMIT m_modelLockDialog->lockStateChanged(true); +} + +void FullBackgroundWidget::onDesktopResized() +{ + qDebug() << "[FullBackgroundWidget] [onDesktopResized]"; + QDesktopWidget *desktop = QApplication::desktop(); + setGeometry(desktop->geometry()); + if(m_lockWidget) + this->onCursorMoved(QCursor::pos()); + update(); +} + +void FullBackgroundWidget::onPrepareForSleep(bool sleep) +{ + ///系统休眠时,会关闭总线,导致设备不可用,发生错误 + ///在系统休眠之前停止认证,在系统唤醒后重新开始认证 + qDebug()<<"onPrepareForSleep:"<stopAuth(); + //uninhibit(); + } + else + { + if(screenStatus & SCREEN_SAVER) + { + //isBlank = false; + //onClearScreensaver(); + }else{ + //repaint(); + //if(m_lockWidget) + // m_lockWidget->startAuth(); + //inhibit(); + } + } + +} + +void FullBackgroundWidget::mousePressEvent(QMouseEvent *e) +{ + //close(); +} + +QString FullBackgroundWidget::getFocusWindowName() +{ + Window focus = 0; + int rev = 0; + + XGetInputFocus (QX11Info::display(), &focus, &rev); + return getWindowNameFromWid(focus); +} + +QString FullBackgroundWidget::getWindowNameFromWid(WId window) +{ + XClassHint ch; + ch.res_name = NULL; + ch.res_class = NULL; + XGetClassHint (QX11Info::display(),window, &ch); + + QString nameStr = QString(ch.res_name); + + if (ch.res_name) + XFree(ch.res_name); + if (ch.res_class) + XFree(ch.res_class); + + return nameStr; +} + +int FullBackgroundWidget::RegisteSubWnd(quint64 uWndId) +{ + if (!m_listWndIds.contains(uWndId) && m_listWndIds.size() < SUBWND_COUNT_MAX) { + m_listWndIds.append(uWndId); + qDebug()<<"RegisterSubWnd:"< FullBackgroundWidget::GetSubWndIds() +{ + return m_listWndIds; +} + +void FullBackgroundWidget::onCursorMoved(const QPoint &pos) +{ + if(!m_lockWidget) + { + return; + } + bool chkInOneScreen = false; + for(auto screen : QGuiApplication::screens()) + { + if(screen == qApp->primaryScreen()){ + qInfo()<<"LockWidget:"<geometry()<geometry(); + m_lockWidget->hide(); + m_lockWidget->setGeometry(screen->geometry()); + m_lockWidget->show(); + chkInOneScreen = true; + break; + } + } + if (!chkInOneScreen) { + for(auto screen : QGuiApplication::screens()) { + if(!screen){ + /*避免切换时闪烁*/ + qInfo()<<"LockWidget:"<geometry()<geometry()<<","<hide(); + m_lockWidget->setGeometry(screen->geometry()); + m_lockWidget->show(); + chkInOneScreen = true; + break; + } + } + } +} + +void FullBackgroundWidget::fakeFocusIn(WId window) +{ + // We have keyboard grab, so this application will + // get keyboard events even without having focus. + // Fake FocusIn to make Qt realize it has the active + // window, so that it will correctly show cursor in the dialog. + XEvent ev; + memset(&ev, 0, sizeof(ev)); + ev.xfocus.display = QX11Info::display(); + ev.xfocus.type = FocusIn; + ev.xfocus.window = window; + ev.xfocus.mode = NotifyNormal; + ev.xfocus.detail = NotifyAncestor; + XSendEvent( QX11Info::display(), window, False, NoEventMask, &ev ); + XFlush(QX11Info::display()); +} + +void FullBackgroundWidget::laterActivate() +{ + if(!QX11Info::isPlatformX11()) + return ; + XSetInputFocus(QX11Info::display(),this->winId(),RevertToParent,CurrentTime); + activateWindow(); +} + +void FullBackgroundWidget::showEvent(QShowEvent *event) +{ + if(QX11Info::isPlatformX11()) + tryGrabKeyboard(); +} + +void FullBackgroundWidget::tryGrabKeyboard() +{ + if (window()->windowHandle() && window()->windowHandle()->setKeyboardGrabEnabled(true)) { + m_tryGrabTimes = 0; + return; + } + + m_tryGrabTimes++; + + if (m_tryGrabTimes == 15) { + qWarning()<<"setKeyboardGrabEnable failed! focus Window is"<(message); + const uint8_t responseType = event->response_type & ~0x80; + + + if (responseType == XCB_FOCUS_OUT) { + //丢焦点时,检测抢焦点的窗口是否为锁屏的子窗口,比如QMenu,QCombobox等, + //如果不是子窗口,则重新给锁屏设置一次焦点 + QString focusWindow = getFocusWindowName(); + if(focusWindow == "ukui-screensaver-dialog"){ + return false; + }else{ + qDebug()<<"focus out. focus window is"<(event); + if(xc->event_type == XCB_BUTTON_PRESS){ + if(this->windowHandle()){ + bool grabed = this->windowHandle()->setKeyboardGrabEnabled(true); + if(!grabed){ + qDebug()<<"setKeyboardGrabEnable failed! focus Window is"<event_type == XCB_BUTTON_RELEASE){ + } + }else if(responseType == XCB_BUTTON_PRESS){ + + }else if(responseType == XCB_BUTTON_RELEASE){ + + } else if (responseType == XCB_KEY_PRESS) { + xcb_key_press_event_t *xc = reinterpret_cast(event); + //qDebug()<<"---------------------XCB_KEY_PRESS:"<detail; + onGlobalKeyPress(xc->detail); + } else if (responseType == XCB_KEY_RELEASE) { + xcb_key_release_event_t *xc = reinterpret_cast(event); + qDebug()<<"---------------------XCB_KEY_RELEASE:"<detail; + onGlobalKeyRelease(xc->detail); + } + return false; +} + +void FullBackgroundWidget::onCurUserChanged(const QString &strUserName) +{ + +} + +void FullBackgroundWidget::onAuthSucceed(QString strUserName) +{ + if (getenv("USER") == strUserName) { + this->hide(); + if (m_modelLockDialog) { + Q_EMIT m_modelLockDialog->lockStateChanged(false); + } + } else { + if (m_modelLockDialog) { + Q_EMIT m_modelLockDialog->startSession(); + } + } +} + +void FullBackgroundWidget::onGlobalKeyPress(const quint8 &key) +{ + +} + +void FullBackgroundWidget::onGlobalKeyRelease(const quint8 &key) +{ +// if (m_lockWidget && m_lockWidget->isVisible()) { +// m_lockWidget->onGlobalkeyRelease(key); +// } + if(key == 9 && screenStatus == SCREEN_LOCK) { // "escape" + bool canShow = true; + if (m_lockWidget && !m_lockWidget->exitSubWidget()) + canShow = false; + if (canShow) + onShowScreensaver(); + } else if(screenStatus & SCREEN_SAVER/* && !isBlank*/) { + qDebug() << "clearclear" ; + onClearScreensaver(); + } +} + +////////////////////////////////// +void FullBackgroundWidget::initCurrentBackground() +{ + loadingAllUserBackground(); + m_backgrondGradationTimer = new QTimer(this); + connect(m_backgrondGradationTimer, &QTimer::timeout, this, &FullBackgroundWidget::onTransition); + + connect(m_modelLockDialog, &LockDialogModel::setCurrentUser, this, &FullBackgroundWidget::onCurrentUserBackground); + connect(m_modelLockDialog, &LockDialogModel::currentUserChanged, this, &FullBackgroundWidget::onUpdateUserBackground); + +// update(); +} + +QString FullBackgroundWidget::getCurrentUserId() +{ + +} + +QStringList FullBackgroundWidget::getUserIdList() +{ + +} + +QString FullBackgroundWidget::getUserBackgroundPath(const QString &strUserName) +{ + for (UserInfoPtr userInfo : m_modelLockDialog->usersInfo()) + { + if (strUserName == userInfo->name()) + return userInfo->backGround(); + } +} + + +void FullBackgroundWidget::loadingAllUserBackground() +{ + qWarning() << __LINE__ << __FUNCTION__ ; + QString default_background_path = "/usr/share/backgrounds/1-warty-final-ubuntukylin.jpg"; + QFile file(default_background_path); + if (!file.exists()) + { + default_background_path = "/usr/share/backgrounds/1-openkylin.jpg"; + } + m_defaultPixmap = new QPixmap(scaleBlurPixmap(width(), height(), default_background_path)); + + FullBackgroundWidget::m_loadingAllBackgroundFuture = QtConcurrent::run([=](){ +// int index = 0; + for (UserInfoPtr userInfo : m_modelLockDialog->usersInfo()) + { + QPixmap *pixmap ; + if (userInfo->backGround().isEmpty()) + pixmap = m_defaultPixmap; + else + pixmap = new QPixmap(scaleBlurPixmap(width(), height(), userInfo->backGround())); + + //test +// if (index == 0) +// pixmap = new QPixmap(scaleBlurPixmap(width(), height(), "/usr/share/backgrounds/background-one.jpg")); +// if (index == 1) +// pixmap = new QPixmap(scaleBlurPixmap(width(), height(), "/usr/share/backgrounds/background-two.jpg")); +// if (index == 2) +// pixmap = new QPixmap(scaleBlurPixmap(width(), height(), "/usr/share/backgrounds/background-three.jpg")); +// if (index == 3) +// pixmap = new QPixmap(scaleBlurPixmap(width(), height(), "/usr/share/backgrounds/ryan-stone-skykomish-river.jpg")); +// index++; + m_allBackgroundsMap[userInfo->name()] = pixmap; + } + }); +} + +void FullBackgroundWidget::paintEvent(QPaintEvent *event) +{ + QPainter painter(this); + QDesktopWidget *desktop = QApplication::desktop(); + + if (m_gradualChanging && m_allBackgroundsMap.contains(m_currentUserName) && m_allBackgroundsMap.contains(m_oldUserName) ) + { + drawBackground(m_allBackgroundsMap[m_currentUserName],m_allBackgroundsMap[m_oldUserName],desktop->geometry(),m_backgroundAlpha); + } + else + { + stopTransition(); + //qWarning() << __LINE__<< __FUNCTION__ << "===============" << m_allBackgroundsMap.contains(m_currentUserName); + + if (m_allBackgroundsMap.contains(m_currentUserName)) + { + + painter.drawPixmap(desktop->geometry(), *m_allBackgroundsMap[m_currentUserName]); + } + else + painter.drawPixmap(desktop->geometry(), *m_defaultPixmap); + + } + return QWidget::paintEvent(event); +} + +bool FullBackgroundWidget::isOpenGradation() +{ + bool isOpenGradation = false; + return true;//test 一直触发渐变效果 + if (m_currentUserName.isEmpty() || m_oldUserName.isEmpty()) + return isOpenGradation; + if (m_currentUserName == m_oldUserName) + return isOpenGradation; + + if (m_allBackgroundsMap.contains(m_currentUserName) && m_allBackgroundsMap.contains(m_oldUserName)) + { + QString m_currentUserBackgroundPath = getUserBackgroundPath(m_currentUserName); + QString m_oldUserBackgroundPath = getUserBackgroundPath(m_oldUserName); + if (m_currentUserBackgroundPath != m_oldUserBackgroundPath) + { + isOpenGradation = true; + } + } + + return isOpenGradation; +} + +void FullBackgroundWidget::onUpdateUserBackground(const QString &strUserName) +{ + qWarning() << __LINE__ <<__FUNCTION__ << "==========" << strUserName ; + if (m_currentUserName == strUserName) + return; + m_oldUserName = m_currentUserName; + m_currentUserName = strUserName; + //是否需要开启渐变效果 + m_gradualChanging = isOpenGradation(); + qWarning() << __LINE__ <<__FUNCTION__ << "==========" << m_gradualChanging ; + + if (m_gradualChanging) + startTransition(); + repaint(); +} + +void FullBackgroundWidget::onTransition() +{ + qWarning() << __LINE__ << __FUNCTION__ ; + m_backgroundAlpha += 0.05; + + if(m_backgroundAlpha >= 1.0) + stopTransition(); + repaint(); +} + +void FullBackgroundWidget::startTransition() +{ + if(!m_backgrondGradationTimer){ + m_backgrondGradationTimer = new QTimer(this); + connect(m_backgrondGradationTimer, &QTimer::timeout, this, &FullBackgroundWidget::onTransition); + } + stopTransition(); + + m_backgroundAlpha = 0.0; + m_gradualChanging = true; + + m_backgrondGradationTimer->start(10); +} +void FullBackgroundWidget::stopTransition() +{ + if(m_backgrondGradationTimer && m_backgrondGradationTimer->isActive()) + m_backgrondGradationTimer->stop(); + m_backgroundAlpha = 1.0; + m_gradualChanging = false; +} + +void FullBackgroundWidget::drawBackground(QPixmap * backgroundBack, QPixmap * backgroundFront, + const QRect &rect, float alpha) +{ + if((backgroundBack == nullptr) || (backgroundFront == nullptr)) + { + stopTransition(); + repaint(); + return; + } + + QPainter painter(this); + painter.drawPixmap(rect, *backgroundFront); + painter.setOpacity(alpha); + painter.drawPixmap(rect, *backgroundBack); + QPainterPath path; + QPainter painter1(this); + painter1.setOpacity(0.25); + painter1.setRenderHint(QPainter::Antialiasing); // 反锯齿; + painter1.setClipping(true); + painter1.setPen(Qt::transparent); + path.addRect(this->rect()); + path.setFillRule(Qt::WindingFill); + painter1.setBrush(QColor("#000000")); + painter1.setPen(Qt::transparent); + painter1.drawPath(path); +} + +void FullBackgroundWidget::onRemoveUserBackground(const QString &strUserName) +{ + if (m_allBackgroundsMap.contains(strUserName)) + m_allBackgroundsMap.remove(strUserName); +} + +void FullBackgroundWidget::onAddUserBackground(const QString &strUserName) +{ + FullBackgroundWidget::m_loadingOneBackgroundFuture = QtConcurrent::run([=](){ + for (UserInfoPtr userInfo : m_modelLockDialog->usersInfo()) + { + if (strUserName == userInfo->name()) + { + QPixmap *pixmap ; + if (userInfo->backGround().isEmpty()) + pixmap = m_defaultPixmap; + else + pixmap = new QPixmap(scaleBlurPixmap(width(), height(), userInfo->backGround())); + m_allBackgroundsMap[userInfo->name()] = pixmap; + break; + } + } + }); + m_loadingOneBackgroundFuture.waitForFinished(); +} + +void FullBackgroundWidget::onUserBackgroundChanged(const QString &strUserName) +{ + +} + +void FullBackgroundWidget::onCurrentUserBackground(const QString &strUserName) +{ + qWarning() << __LINE__ << __FUNCTION__ << "===============" << strUserName; + //m_currentUserName = strUserName; + if (!m_allBackgroundsMap.contains(strUserName)) + { + onAddUserBackground(strUserName); + } + repaint(); +} diff --git a/src/widgets/fullbackgroundwidget.h b/src/widgets/fullbackgroundwidget.h new file mode 100644 index 0000000..eec46b1 --- /dev/null +++ b/src/widgets/fullbackgroundwidget.h @@ -0,0 +1,140 @@ +/* + * Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * +**/ +#ifndef FULLBACKGROUNDWIDGET_H +#define FULLBACKGROUNDWIDGET_H + +#include +#include +#include +#include +#include +#include + +enum ScreenStatus +{ + UNDEFINED = 0x00, + SCREEN_SAVER = 0x01, + SCREEN_LOCK = 0x02, + SCREEN_LOCK_AND_SAVER = 0x03, + SCREEN_BLACK = 0x04, +}; + +class LockDialogModel; +class LockWidget; +class AgreementWindow; + +class FullBackgroundWidget : public QWidget , public QAbstractNativeEventFilter +{ + Q_OBJECT +public: + explicit FullBackgroundWidget(LockDialogModel *model, QWidget *parent = nullptr); + ~FullBackgroundWidget(); + virtual bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) override; + + QMap m_allBackgroundsMap; + QPixmap * m_defaultPixmap ; + + QString m_currentUserName ; + QString m_oldUserName ; + + QFuture m_loadingAllBackgroundFuture; + QFuture m_loadingOneBackgroundFuture; + +public: + int RegisteSubWnd(quint64 uWndId); + int UnRegisteSubWnd(quint64 uWndId); + QList GetSubWndIds(); + inline bool IsStartupMode() { return m_isStartupMode; } + +public Q_SLOTS: + void onCursorMoved(const QPoint &pos); + void onShowBlankScreensaver(int nDelay = 0, bool isHasLock = true); + void onShowLock(bool isStartup); + void onShowSessionIdle(); + void onShowLockScreensaver(); + void onShowScreensaver(); + void onShowPowerManager(); + void onCloseScreensaver(); + void onDesktopResized(); + void onPrepareForSleep(bool sleep); + void laterActivate(); + void setLockState(); + void onClearScreensaver(); + + void onCurUserChanged(const QString &strUserName); + void onUpdateUserBackground(const QString &strUserName); + void onTransition(); + void onAuthSucceed(QString strUserName); + + void onRemoveUserBackground(const QString &); + void onAddUserBackground(const QString &); + void onUserBackgroundChanged(const QString &); + void onCurrentUserBackground(const QString &); + void onSecondRunParam(const QString &); +Q_SIGNALS: + +protected: + void mousePressEvent(QMouseEvent *e); + void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *event); +private: + void initUI(); + void initConnections(); + bool eventFilter(QObject *obj, QEvent *event); + void fakeFocusIn(WId window); + QString getWindowNameFromWid(WId window); + QString getFocusWindowName(); + void tryGrabKeyboard(); + + void initCurrentBackground(); + void loadingAllUserBackground(); + QString getUserBackgroundPath(const QString &); + QString getCurrentUserId(); + QStringList getUserIdList(); + + bool isOpenGradation(); + void startTransition(); + void stopTransition(); + + void drawBackground(QPixmap * backgroundBack, QPixmap * backgroundFront, + const QRect &rect, float alpha); +private Q_SLOTS: + void onGlobalKeyPress(const quint8 &key); + void onGlobalKeyRelease(const quint8 &key); +private: + LockDialogModel *m_modelLockDialog = nullptr; + bool m_isStartupMode = false; + // 上层窗口管理 + QList m_listWndIds; + // 锁屏 + LockWidget *m_lockWidget = nullptr; + AgreementWindow *m_agreementWindow = nullptr; + + int m_tryGrabTimes = 0; + bool m_bIsLockState = false; + QList widgetXScreensaverList; + + QTimer *m_backgrondGradationTimer; + bool m_gradualChanging = false; + float m_backgroundAlpha = 0.0; + + ScreenStatus screenStatus = UNDEFINED; + int isBlank; +}; + +#endif // FULLBACKGROUNDWIDGET_H diff --git a/src/grab-x11.cpp b/src/widgets/grab-x11.cpp similarity index 100% rename from src/grab-x11.cpp rename to src/widgets/grab-x11.cpp diff --git a/src/grab-x11.h b/src/widgets/grab-x11.h similarity index 100% rename from src/grab-x11.h rename to src/widgets/grab-x11.h diff --git a/src/widgets/iconbutton.cpp b/src/widgets/iconbutton.cpp new file mode 100644 index 0000000..7f568bf --- /dev/null +++ b/src/widgets/iconbutton.cpp @@ -0,0 +1,84 @@ +#include "iconbutton.h" +#include +#include +#include +#include +#include +#include +#include + +static inline qreal mixQreal(qreal a, qreal b, qreal bias) +{ + return a + (b - a) * bias; +} + +IconButton::IconButton(QWidget *parent) + :QPushButton(parent) +{ + +} + +IconButton::~IconButton() +{ + +} + +void IconButton::paintEvent(QPaintEvent *event){ + Q_UNUSED(event) + QStyleOptionButton option; + initStyleOption(&option); + QStylePainter painter(this); + if (iconType == ENTERICON) { + painter.setRenderHint(QPainter::Antialiasing, true); + if (option.state & QStyle::State_HasFocus) { + + painter.save(); + QColor color = option.palette.color(QPalette::Highlight); + painter.setPen(Qt::NoPen); + painter.setBrush(color); + painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 12, 12); + painter.restore(); + + painter.save(); + QStyleOption opt; + + + QColor borderColor = option.palette.color(QPalette::Text); + painter.setPen(QPen(borderColor, 2)); + // painter.setPen(Qt::NoPen); + painter.setBrush(Qt::NoBrush); + painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 12, 12); + painter.restore(); + + + } + + int buttonWidget = this->width(); + int buttonHeight = this->height(); + QRect buttonRect(0, 0, buttonWidget, buttonHeight); + + QPixmap pixmap = option.icon.pixmap(option.iconSize, QIcon::Selected, QIcon::On); + int pixmapWidth = static_cast(pixmap.width()); + int pixmapHeight = static_cast(pixmap.height()); + QRect pixmapRect(0, 0, pixmapWidth, pixmapHeight); + + int deltaX = 0; + int deltaY = 0; + if (pixmapRect.width() < buttonRect.width()) + deltaX = buttonRect.width() - pixmapRect.width(); + else + deltaX = pixmapRect.width() - buttonRect.width(); + if (pixmapRect.height() < buttonRect.height()) + deltaY = buttonRect.height() - pixmapRect.height(); + else + deltaY = pixmapRect.height() - buttonRect.height(); + + painter.save(); + painter.translate(deltaX / 2, deltaY / 2); + painter.drawPixmap(pixmapRect, pixmap); + painter.restore(); + } else if (iconType == MODEICON) { + option.state = QStyle::State_Enabled; + painter.drawControl(QStyle::CE_PushButton, option); + } +} diff --git a/src/widgets/iconbutton.h b/src/widgets/iconbutton.h new file mode 100644 index 0000000..ed07290 --- /dev/null +++ b/src/widgets/iconbutton.h @@ -0,0 +1,26 @@ +#ifndef ICONBUTTON_H +#define ICONBUTTON_H + +#include +#include + +enum ICONTYOE { + MODEICON, + ENTERICON +}; + +class IconButton:public QPushButton +{ + Q_OBJECT +public: + IconButton(QWidget* parent = nullptr); + + ~IconButton(); +protected: + void paintEvent(QPaintEvent * event); + +private: + int iconType = MODEICON; +}; + +#endif // ICONBUTTON_H diff --git a/src/widgets/iconedit.cpp b/src/widgets/iconedit.cpp new file mode 100644 index 0000000..66a7297 --- /dev/null +++ b/src/widgets/iconedit.cpp @@ -0,0 +1,260 @@ +/* iconedit.cpp + * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301, USA. +**/ +#include "iconedit.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "commonfunc.h" +#include "utils.h" + +IconEdit::IconEdit(LockDialogModel *model, QWidget *parent) + : QWidget(parent) + , m_modelLockDialog(model) +{ + this->setFixedSize(240, 40); + m_edit = new QLineEdit(this); + + m_capsIcon = new QLabel(this); + m_capsIcon->setPixmap(QIcon::fromTheme("ukui-capslock-symbolic").pixmap(QSize(16,16))); + if (QString(qgetenv("XDG_SESSION_TYPE")) == "wayland"){ + m_capsState = checkCapsLockState(); + } else { + m_capsState = m_modelLockDialog->getCapslockState(); + } + connect(m_modelLockDialog, &LockDialogModel::capslockStateChanged, this, &IconEdit::onCapsChanged); + m_capsIcon->setVisible(m_capsState); + + m_modeButton = new IconButton(this); + m_modeButton->setIcon(QIcon::fromTheme("ukui-eye-display-symbolic")); + m_modeButton->setFlat(true); + m_modeButton->setFixedSize(24, 14); + m_modeButton->setIconSize(QSize(16, 16)); + m_modeButton->setFocusPolicy(Qt::NoFocus); + connect(m_modeButton, &QPushButton::clicked, this, [=](){ + if (m_edit->echoMode() == QLineEdit::Password) { + setType(QLineEdit::Normal); + } else { + setType(QLineEdit::Password); + } + }); + + m_iconButton = new QPushButton(this); + m_iconButton->installEventFilter(this); + m_iconButton->setFixedSize(24, 24); + m_iconButton->setIconSize(QSize(24, 24)); + m_iconButton->setProperty("isRoundButton", true); + m_iconButton->setProperty("isImportant", true); + setIcon(QIcon::fromTheme("go-next-symbolic")); + + + QHBoxLayout *layout = new QHBoxLayout(this); + layout->setContentsMargins(1, 1, 8, 1); + layout->setSpacing(2); + layout->addStretch(); + layout->addWidget(m_capsIcon); + layout->addWidget(m_modeButton); + layout->addWidget(m_iconButton); + + connect(m_edit, &QLineEdit::returnPressed, this, &IconEdit::clicked_cb); + connect(m_iconButton, &QPushButton::clicked, this, &IconEdit::clicked_cb); + + m_edit->setAttribute(Qt::WA_InputMethodEnabled, false); //禁用输入法 + m_edit->setContextMenuPolicy(Qt::NoContextMenu); //禁用右键菜单 + m_edit->installEventFilter(this); + m_iconButton->setFocusPolicy(Qt::TabFocus); + m_iconButton->installEventFilter(this); + this->setFocusProxy(m_edit); +} + +void IconEdit::resizeEvent(QResizeEvent *) +{ + // 设置输入框中文件输入区,不让输入的文字在被隐藏在按钮下 + int w = m_iconButton->width() + m_modeButton->width(); + m_edit->setTextMargins(1, 1, m_capsState ? w + m_capsIcon->width() + 10 : w + 6, 1); + m_edit->setFixedSize(size()); +} + +bool IconEdit::eventFilter(QObject *obj, QEvent *event) +{ + if(obj == m_edit){ + if(event->type() == 6){ //禁止复制粘贴功能。 + QKeyEvent *keyEvent = static_cast(event); + if(keyEvent->matches(QKeySequence::Copy) || keyEvent->matches(QKeySequence::Cut) || keyEvent->matches(QKeySequence::Paste)){ + event->ignore(); + return true; + }else if((keyEvent->modifiers() & Qt::MetaModifier) || (keyEvent->modifiers() & Qt::AltModifier)){//当meta或者alt键被按下时,忽略按键事件 + event->ignore(); + return true; + } + } + if (event->type() == 2) { + + } + if(event->type() == 23) + { + update(); + }else if(event->type() == QEvent::MouseButtonPress){ + update(); + } else if(event->type() == QEvent::MouseButtonRelease) { //禁用鼠标中键 + QMouseEvent *mouseevent = static_cast(event); + if(mouseevent->button() == Qt::MidButton){ + event->ignore(); + return true; + } + } + } + if(obj == m_modeButton){ + if(event->type() == 2) + { + + } + } + return false; +} + +void IconEdit::setIcon(const QIcon &icon) +{ + m_iconButton->setIcon(icon); + m_iconButton->setText(""); + m_iconButton->setIconSize(QSize(24, 24)); + m_icon = icon; + m_iconText = ""; +} + +void IconEdit::clear() +{ + m_edit->setText(""); + setPrompt(""); +} + +void IconEdit::clearText() +{ + m_edit->setText(""); +} + +void IconEdit::setPrompt(const QString &prompt) +{ + m_edit->setPlaceholderText(prompt); + QPalette palette = m_edit->palette(); + palette.setColor(QPalette::Normal, QPalette::PlaceholderText, Qt::gray); + m_edit->setPalette(palette); +} + +const QString IconEdit::text() +{ + return m_edit->text(); +} + +void IconEdit::setType(QLineEdit::EchoMode type) +{ + m_edit->setEchoMode(type); + if (type == 0) { + m_modeButton->setIcon(QIcon::fromTheme("ukui-eye-display-symbolic")); + } else { + m_modeButton->setIcon(QIcon::fromTheme("ukui-eye-hidden-symbolic")); + } +} + +void IconEdit::readOnly(bool enabled) +{ + m_edit->setEnabled(!enabled); + m_edit->setReadOnly(enabled); +} + +void IconEdit::setLocked(bool lock) +{ + m_iconButton->blockSignals(lock); +} + +void IconEdit::setModeBtnVisible(bool visible) +{ + m_modeButton->setVisible(visible); +} + +void IconEdit::startWaiting() +{ + m_edit->setReadOnly(true); + //m_iconButton->setEnabled(false); + + if(!m_timer) + { + m_timer = new QTimer(this); + m_timer->setInterval(150); + connect(m_timer, &QTimer::timeout, this, &IconEdit::updatePixmap); + } + + //这里将QIcon转QPixmap传入(24,24)时,实际得到的pixmap大小为(24,24)乘上缩放比例,导致计算pixmap位置错误,因此需要重新设置一次大小 + //更好的解决方案应该是重写IconButton的setIcon函数?直接处理图片大小与icon大小一致? + QPixmap icon = QIcon::fromTheme("ukui-loading-0-symbolic").pixmap(16,16).scaled(16,16, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + m_waitingPixmap = getLoadingIcon(16); + m_iconButton->setIcon(m_waitingPixmap); + m_iconButton->setIconSize(QSize(16, 16)); + m_timer->start(); +} + +void IconEdit::stopWaiting() +{ + if (m_timer && m_timer->isActive()) { + m_timer->stop(); + } + m_iconButton->setAttribute(Qt::WA_TransparentForMouseEvents, false); + m_edit->setReadOnly(false); + if (!m_icon.isNull()) { + m_iconButton->setIcon(m_icon); + m_iconButton->setIconSize(QSize(24, 24)); + } else { + m_iconButton->setText(m_iconText); + } +} + +void IconEdit::updatePixmap() +{ + m_iconButton->setEnabled(true); + m_iconButton->setAttribute(Qt::WA_TransparentForMouseEvents, true); + QMatrix matrix; + matrix.rotate(90.0); + m_waitingPixmap = m_waitingPixmap.transformed(matrix, Qt::FastTransformation); + m_iconButton->setIcon(QIcon(m_waitingPixmap)); + m_iconButton->setIconSize(QSize(16, 16)); +} + +void IconEdit::clicked_cb() +{ + startWaiting(); + emit clicked(m_edit->text()); +} + +void IconEdit::onCapsChanged(bool state) +{ + if (QString(qgetenv("XDG_SESSION_TYPE")) == "wayland"){ + m_capsState = checkCapsLockState(); + } else { + m_capsState = state; + } + m_capsIcon->setVisible(m_capsState); + int w = m_iconButton->width() + m_modeButton->width(); + m_edit->setTextMargins(1, 1, m_capsState ? w + m_capsIcon->width() + 10 : w + 6, 1); +} diff --git a/src/iconedit.h b/src/widgets/iconedit.h similarity index 68% rename from src/iconedit.h rename to src/widgets/iconedit.h index f78386e..7afc3f1 100644 --- a/src/iconedit.h +++ b/src/widgets/iconedit.h @@ -1,9 +1,9 @@ -/* +/* iconedit.h * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) + * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, @@ -12,46 +12,42 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301, USA. **/ #ifndef ICONEDIT_H #define ICONEDIT_H +#include "iconbutton.h" +#include "statusbutton.h" +#include "lock-dialog/lockdialogmodel.h" #include -#include #include #include -#include #include +#include #include -#include "modebutton.h" -#include "iconbutton.h" class Configuration; - class IconEdit : public QWidget { Q_OBJECT public: - IconEdit(QWidget *parent = 0); + IconEdit(LockDialogModel *model,QWidget *parent = 0); - void setIcon(const QString &text); void setIcon(const QIcon &icon); void clear(); void clearText(); void setPrompt(const QString &); const QString text(); void setType(QLineEdit::EchoMode type = QLineEdit::Password); - void startWaiting(); - void stopWaiting(); - void setX11Focus(); - void setFocusin(int target); void readOnly(bool enabled); void setLocked(bool lock); void setModeBtnVisible(bool visible); - //void setEnabled(bool enabled); + void startWaiting(); + void stopWaiting(); protected: void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE; @@ -59,6 +55,7 @@ protected: private: void updatePixmap(); + void resetFocus(); Q_SIGNALS: void clicked(const QString &); @@ -66,23 +63,20 @@ Q_SIGNALS: void clickedPassword(bool clicked); public Q_SLOTS: void clicked_cb(); - void onCapsChanged(); - void onCapsStateChanged(); + void onCapsChanged(bool state); private: - QLineEdit *m_edit; - QSvgWidget *m_capsIcon; - IconButton *m_iconButton; - ModeButton *m_modeButton; - QTimer *m_timer; - QPixmap m_waitingPixmap; + LockDialogModel *m_modelLockDialog = nullptr; + QLineEdit *m_edit = nullptr; + QPushButton *m_iconButton = nullptr; + QLabel *m_capsIcon = nullptr; + IconButton *m_modeButton = nullptr; + QString m_iconText; //文字作为图标 QIcon m_icon; - QGSettings *settings; - bool capsState = false; - Configuration *configuration; - double curFontSize = 0; - double m_ptToPx = 1.0; + QTimer *m_timer = nullptr; + QPixmap m_waitingPixmap; + bool m_capsState = false; }; #endif // ICONEDIT_H diff --git a/src/widgets/klabel.cpp b/src/widgets/klabel.cpp new file mode 100644 index 0000000..808d76f --- /dev/null +++ b/src/widgets/klabel.cpp @@ -0,0 +1,120 @@ +#include "klabel.h" +#include +#include +#include +#include +#include + +QWidget * KLabel::m_parentWidget; +KLabel::KLabel(QWidget *parent) + : QLabel(parent) +{ + setWindowFlags(Qt::FramelessWindowHint); + //m_strText = ""; + sysFont = qApp->font(); + m_ptToPx = 1; + //获取当前屏幕尺寸 + QDesktopWidget* desktopWidget = QApplication::desktop(); + QRect clientRect = desktopWidget->availableGeometry(); + desktopWidth = clientRect.width(); + desktopHeight = clientRect.height(); + this->installEventFilter(this); + QPalette pe; + pe.setColor(QPalette::WindowText,Qt::white); + this->setPalette(pe); +} + +void KLabel::setFontSize(int fontSize) +{ + sysFont.setPointSize(fontSize * m_ptToPx); + this->setFont(sysFont); +} + +void KLabel::setTipText(const QString &strText) +{ + m_strText = strText; + QLabel::setText(strText); +} + +void KLabel::setText(const QString &strText) +{ + setTipText(strText); +} + +void KLabel::clear() +{ + m_strText.clear(); + QLabel::clear(); +} + +QString KLabel::text() const +{ + if (m_strText.isEmpty()) + return QLabel::text(); + else + return m_strText; +} + +QString KLabel::getElidedText(QFont font,int width,QString strInfo) +{ + QFontMetrics fontMetrics(font); + //如果当前字体下,字符串长度大于指定宽度 + if(fontMetrics.width(strInfo) > width) + { + strInfo= QFontMetrics(font).elidedText(strInfo, Qt::ElideRight, width); + } + return strInfo; +} + +bool KLabel::eventFilter(QObject *obj, QEvent *event) +{ +// if(event->type() == 110){ +// if(QLabel::text() != m_strText) { +// if(QLabel::text().isEmpty()) +// return false; +// if(is_Show)//如果KTooltip已经show出来,直接返回 +// return false; +// kTooltip = new MyTooltip(m_parentWidget); +// kTooltip->popup(kTooltip, m_strText, 16); +// kTooltip->setStyleSheet(QString("background-color:#FFFFFF; color:black; border-radius: 4px;")); +// int cursorX, cursorY; +// if (kTooltip->width() > QCursor::pos().x()) { +// cursorX = 10; +// } else if (QCursor::pos().x() + kTooltip->width() > desktopWidth) { +// cursorX = QCursor::pos().x() - kTooltip->width() - 5; +// } else { +// cursorX = QCursor::pos().x() + 5; +// } +// if (QCursor::pos().y() + kTooltip->height() > desktopHeight - 20) { +// cursorY = QCursor::pos().y() - kTooltip->height() - 20; +// } else { +// cursorY = QCursor::pos().y() + 20; +// } +// kTooltip->move(cursorX, cursorY); +// kTooltip->show(); +// kTooltip->raise(); +// is_Show = true; +// } +// } else if (event->type() == 11){ +// if(!is_Show){//如果本来没有收到tooltip事件,直接返回 +// return false; +// } +// kTooltip->tipClose(kTooltip); +// is_Show = false; +// kTooltip = nullptr; +// } + return false; +} + +void KLabel::paintEvent(QPaintEvent *event) +{ + if (m_strText.isEmpty() && !QLabel::text().isEmpty()) + m_strText = QLabel::text(); + QString strEText = getElidedText(font(), width() ,m_strText); + if (strEText == m_strText) { + QLabel::setText(m_strText); + } else if (strEText != m_strText ) { + QLabel::setText(strEText); + } + QLabel::paintEvent(event); +} diff --git a/src/widgets/klabel.h b/src/widgets/klabel.h new file mode 100644 index 0000000..3563d88 --- /dev/null +++ b/src/widgets/klabel.h @@ -0,0 +1,40 @@ +#ifndef KLABEL_H +#define KLABEL_H + +#include +#include +//#include "mytooltip.h" + +class KLabel : public QLabel +{ + Q_OBJECT +public: + KLabel(QWidget *parent = nullptr); + void setFontSize(int fontSize); + QString getElidedText(QFont font,int width,QString strInfo); + static QWidget *m_parentWidget; + void setTipText(const QString &); + void clear(); + QString text() const; + +public Q_SLOTS: + void setText(const QString &); + +protected: + bool eventFilter(QObject *obj, QEvent *event); + void paintEvent(QPaintEvent *event); + +private: + QFont sysFont; + double m_ptToPx = 1.0; + + //tooltip +// MyTooltip *kTooltip = nullptr; + bool is_Show = false; + int desktopWidth; + int desktopHeight; + + QString m_strText; +}; + +#endif // KLABEL_H diff --git a/src/widgets/lockwidget.cpp b/src/widgets/lockwidget.cpp new file mode 100644 index 0000000..3e0a1b5 --- /dev/null +++ b/src/widgets/lockwidget.cpp @@ -0,0 +1,928 @@ +#include "lockwidget.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "poweritemwidget.h" +#include "useritemwidget.h" +#include "mylistwidget.h" +#include "userlistwidget.h" +#include "sessionlistwidget.h" +#include "statusbutton.h" +#include "../lock-dialog/lockdialogmodel.h" +#include "iconedit.h" +#include "commonfunc.h" +#include "authdialog.h" +#include "powerlistwidget.h" +#include "timewidget.h" +#include "networkbutton.h" +#include "definetypes.h" +#include "mynetworkwidget.h" +#include "batterywidget.h" +#include "VirtualKeyboard/src/virtualkeyboardwidget.h" +#include "blockwidget.h" +#include "pluginsloader.h" + +#define BLUR_RADIUS 300 +#define RIGHT_MARGIN 24 +#define BOTTOM_MARGIN 24 + +#define PREFIX QString(RESOURCE_PATH) +#define IMAGE_DIR PREFIX+"/images/" +float scale; +LockWidget::LockWidget(LockDialogModel *model, QWidget *parent) + : QWidget(parent) + , m_modelLockDialog(model) +{ + scale = 1.0; + UserInfoPtr ptrUser = m_modelLockDialog->findUserByName(m_modelLockDialog->defaultUserName()); + if (ptrUser) { + m_curUserInfo = *ptrUser; + } + initUI(); + initConnections(); + initUsdMediaKeys(); + installEventFilter(this); +} + +bool LockWidget::eventFilter(QObject *obj, QEvent *event) +{ + if (event->type() == QEvent::KeyRelease) { + MyListWidget *listWidget = qobject_cast(obj); + if (listWidget) { + if (listWidget && listWidget->hasFocus()) { //Tab键切入时,设置焦点状态 + listWidget->setCurrentRow(listWidget->currentRow(), QItemSelectionModel::SelectionFlag::SelectCurrent); + listWidget->currentItemChanged(listWidget->currentItem(), nullptr); + } else { //Tab键切出时,清空焦点状态 + listWidget->setCurrentRow(listWidget->currentRow(), QItemSelectionModel::SelectionFlag::Clear); + } + } + } else if (event->type() == QEvent::MouseButtonPress) { + /// TODO + if(m_userListWidget && m_userListWidget->isVisible()){ + if (obj != m_userListWidget) { + onShowUserListWidget(); + } + } + if(m_powerListWidget && m_powerListWidget->isVisible()){ + if (obj != m_powerListWidget) { + onShowPowerListWidget(); + } + } + + //这段代码没看懂,但是如果注释掉的话,点击网络窗口,网络窗口会隐藏 + if(m_networkWidget && m_networkWidget == obj){ + return true; + } + + if(m_networkWidget && m_networkWidget->isVisible()){ + if (m_networkWidget != obj){ + onShowNetworkWidget(); + } + } + + if(m_virtualKeyboardWidget && m_virtualKeyboardWidget->isVisible()){ + if (m_virtualKeyboardWidget != obj){ + onShowVirtualKeyboard(); + } + } + + if(m_sessionListWidget && m_sessionListWidget->isVisible()){ + if (m_sessionListWidget != obj){ + onShowSessionListWidget(); + } + } + + if(batteryWidget && batteryWidget->isVisible()){ + if (batteryWidget != obj){ + onShowBatteryWidget(); + } + } + } + + return false; +} + +bool LockWidget::exitSubWidget() +{ + bool allExited = true; + if(m_userListWidget && m_userListWidget->isVisible()){ + m_userListWidget->hide(); + m_userButton->setClickedStatus(NORMAL); + allExited = false; + } + if(m_powerListWidget && m_powerListWidget->isVisible()){ + authDialog->setFocus(); + authDialog->show(); + authDialog->lower(); + m_powerListWidget->hide(); + m_powerManagerButton->setClickedStatus(NORMAL); + allExited = false; + } + if(m_networkWidget && m_networkWidget->isVisible()){ + m_networkWidget->hide(); + m_networkButton->setClickedStatus(NORMAL); +// sendNetPluginVisible(false); + allExited = false; + } + if (m_virtualKeyboardWidget && m_virtualKeyboardWidget->isVisible()) { + m_virtualKeyboardWidget->hide(); + m_virKbButton->setClickedStatus(NORMAL); + allExited = false; + } + if (batteryWidget && batteryWidget->isVisible()) { + batteryWidget->hide(); + m_batteryonButton->setClickedStatus(NORMAL); + allExited = false; + } + if (m_sessionListWidget && m_sessionListWidget->isVisible()) { + m_sessionListWidget->hide(); + m_sessionButton->setClickedStatus(NORMAL); + allExited = false; + } + authDialog->setFocus(); + + return allExited; +} + +void LockWidget::paintEvent(QPaintEvent *event) +{ + QPainter painter(this); + painter.drawPixmap(this->geometry(), background); + QPainterPath path; + painter.setOpacity(0.25); + painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; + painter.setClipping(true); + painter.setPen(Qt::transparent); + path.addRect(this->rect()); + path.setFillRule(Qt::WindingFill); + painter.setBrush(QColor("#000000")); + painter.setPen(Qt::transparent); + painter.drawPath(path); + return QWidget::paintEvent(event); +} + +void LockWidget::resizeEvent(QResizeEvent *event) +{ + QSize size = event->size(); + //重新计算缩放比例 + scale = QString::number(size.width() / 1920.0, 'f', 1).toFloat(); + + authDialog->setGeometry((width()-this->geometry().width())/2, 148*scale, \ + this->width(), (height() - 150*scale - (24 + 48 + 16)*scale)); + authDialog->updateAuthSize(); + + m_timeWidget->updateUI(); + m_timeWidget->move((width() - m_timeWidget->width())/2, 48*scale); + m_userListWidget->setMaximumHeight(height()/2); + m_userListWidget->updateWidgetSize(); + qDebug()<<"m_userListWidget:"<geometry(); + + m_powerListWidget->move((width() - m_powerListWidget->width())/2, (height() - m_powerListWidget->height())/2 - BOTTOM_MARGIN*scale); + + updateBottomButton(); + if (m_curUserInfo.isLoggedIn() && m_sessionButton) { + buttonListWidget->setFixedSize(QSize(48*(buttonListWidget->count() - 1) + buttonListWidget->spacing()*2*(buttonListWidget->count() - 1), 64)); + } else { + buttonListWidget->setFixedSize(QSize(48*buttonListWidget->count() + buttonListWidget->spacing()*2*buttonListWidget->count(), 64)); + } + buttonListWidget->move(width() - buttonListWidget->width() - RIGHT_MARGIN*scale, height() - buttonListWidget->height() - BOTTOM_MARGIN*scale); + + if (m_sessionListWidget) { + m_sessionListWidget->setMaximumHeight(height()/2); + m_sessionListWidget->updateWidgetSize(); + qDebug()<<"m_sessionListWidget:"<geometry(); + m_sessionListWidget->move(buttonListWidget->x() - m_virKbButton->width()/2 + buttonListWidget->spacing()*scale, + height()- BOTTOM_MARGIN*scale - buttonListWidget->height() - buttonListWidget->spacing()*scale - m_sessionListWidget->height()); + } + + if(m_networkWidget){ + m_networkWidget->setGeometry(this->width() - m_networkWidget->width() - RIGHT_MARGIN*scale, + this->height() - m_networkWidget->height() - BOTTOM_MARGIN*scale - buttonListWidget->spacing()*scale*2 - buttonListWidget->height(), + m_networkWidget->width(), + m_networkWidget->height()); + } + if (batteryWidget) { + if (m_sessionButton->isHidden()) { + batteryWidget->setGeometry(buttonListWidget->x(), + height()- BOTTOM_MARGIN*scale - buttonListWidget->height() - buttonListWidget->spacing()*scale - batteryWidget->height(), 314*scale, 112*scale); + } else { + batteryWidget->setGeometry(buttonListWidget->x() + m_virKbButton->width() + 2*buttonListWidget->spacing(), + height() - BOTTOM_MARGIN*scale - buttonListWidget->height() - buttonListWidget->spacing()*scale - batteryWidget->height(), 314*scale, 112*scale); + } + } + + m_userListWidget->move(width() - (m_userListWidget->width()/2 + RIGHT_MARGIN*scale + (m_virKbButton->width() + buttonListWidget->spacing()*scale*2)*4), + height()- BOTTOM_MARGIN*scale - buttonListWidget->height() - buttonListWidget->spacing()*scale - m_userListWidget->height()); + onSetVirkeyboardPos(); +} + +void LockWidget::keyReleaseEvent(QKeyEvent *e) +{ + if (e->key() == Qt::Key_K) { + if(e->modifiers() & Qt::ControlModifier) + onShowVirtualKeyboard(); + } + + // 监听按键事件实现快捷键功能 + switch (e->key()) { + case Qt::Key_VolumeMute: + Q_EMIT m_modelLockDialog->usdExternalDoAction(MIC_MUTE_KEY); + break; + case Qt::Key_VolumeDown: + Q_EMIT m_modelLockDialog->usdExternalDoAction(VOLUME_DOWN_KEY); + break; + case Qt::Key_VolumeUp: + Q_EMIT m_modelLockDialog->usdExternalDoAction(VOLUME_UP_KEY); + break; + case Qt::Key_MonBrightnessUp: + Q_EMIT m_modelLockDialog->usdExternalDoAction(BRIGHT_UP_KEY); + break; + case Qt::Key_MonBrightnessDown: + Q_EMIT m_modelLockDialog->usdExternalDoAction(BRIGHT_DOWN_KEY); + break; + case Qt::Key_TouchpadOn: + Q_EMIT m_modelLockDialog->usdExternalDoAction(TOUCHPAD_ON_KEY); + break; + case Qt::Key_TouchpadOff: + Q_EMIT m_modelLockDialog->usdExternalDoAction(TOUCHPAD_OFF_KEY); + break; + default: + break; + } + + // 实现锁屏截图功能 + QKeySequence keySequence = QKeySequence(e->modifiers() + e->key()); + if (keySequence == listFromString(m_areaScreenShot)) { + Q_EMIT m_modelLockDialog->usdExternalDoAction(AREA_SCREENSHOT_KEY); + } else if (keySequence == listFromString(m_areaScreenShot2)) { + Q_EMIT m_modelLockDialog->usdExternalDoAction(AREA_SCREENSHOT_KEY); + } else if (keySequence == listFromString(m_screenShot)) { + Q_EMIT m_modelLockDialog->usdExternalDoAction(SCREENSHOT_KEY); + } else if (keySequence == listFromString(m_screenShot2)) { + Q_EMIT m_modelLockDialog->usdExternalDoAction(SCREENSHOT_KEY); + } else if (keySequence == listFromString(m_windowScreenshot)) { + Q_EMIT m_modelLockDialog->usdExternalDoAction(WINDOW_SCREENSHOT_KEY); + } +} + +void LockWidget::initUI() +{ + // 检查并获取第三方认证插件配置信息 + if (PluginsLoader::instance().findModulesByType(LoginPluginInterface::MODULETYPE_AUTH).size() > 0) { + LoginAuthInterface *plugin = dynamic_cast(PluginsLoader::instance() \ + .findModulesByType(LoginPluginInterface::MODULETYPE_AUTH) \ + .values().first()); + QJsonObject rootObj; + rootObj["MsgType"] = "GetInformations"; + rootObj["Key"] = "Configures"; + QString strMsg = plugin->onMessage(QJsonDocument(rootObj).toJson()); + onGetCustomPluginMsg(strMsg); + } + + authDialog = new AuthDialog(m_modelLockDialog, m_curUserInfo, this); + authDialog->installEventFilter(this); + initTimeWidget(); + initUserWidget(); + if (m_modelLockDialog->sessionsInfo().count() > 1) { + initSessionWidget(); + } + initPowerWidget(); + initButtonWidget(); + initBlockWidget(); +// authDialog->setFocus(); + // Q_EMIT m_modelLockDialog->setCurrentUser(m_modelLockDialog->defaultUserName()); +} + +void LockWidget::initConnections() +{ + connect(m_modelLockDialog, &LockDialogModel::currentUserChanged, this, &LockWidget::onCurUserChanged); + connect(m_modelLockDialog, &LockDialogModel::currentSessionChanged, this, &LockWidget::onSessionChanged); + if (authDialog) { + connect(authDialog, SIGNAL(authSucceed(QString)), this, SIGNAL(authSucceed(QString))); + connect(authDialog, &AuthDialog::userChangedByManual, + this, &LockWidget::onUserChangedByManual); + connect(authDialog, &AuthDialog::customRequestAccount, + this, &LockWidget::onCustomRequestAccount); + } +} +void LockWidget::initTimeWidget() +{ + m_timeWidget = new TimeWidget(this); + m_timeWidget->move((width() - m_timeWidget->width())/2, 0); + +} +void LockWidget::initUserWidget() +{ + m_userListWidget = new UserListWidget(m_modelLockDialog, this); + m_userListWidget->installEventFilter(this); + m_userListWidget->setMaximumHeight(height()/2); + m_userListWidget->updateWidgetSize(); + m_userListWidget->hide(); + connect(m_userListWidget, &UserListWidget::userSelected, m_modelLockDialog, &LockDialogModel::setCurrentUser); + m_userListWidget->clearFocus(); +} + +void LockWidget::initSessionWidget() +{ + m_sessionListWidget = new SessionListWidget(m_modelLockDialog, this); + m_sessionListWidget->installEventFilter(this); + m_sessionListWidget->setMaximumHeight(height()/2); + m_sessionListWidget->updateWidgetSize(); + m_sessionListWidget->hide(); + connect(m_sessionListWidget, &SessionListWidget::sessionSelected, m_modelLockDialog, &LockDialogModel::setCurrentSession); + m_sessionListWidget->clearFocus(); +} + +void LockWidget::initPowerWidget() +{ + m_powerListWidget = new PowerListWidget(m_modelLockDialog,this); + m_powerListWidget->setMaximumHeight(height()/2); + m_powerListWidget->move((width() - m_powerListWidget->width())/2, (height()-m_powerListWidget->height())/2-80); + m_powerListWidget->hide(); + connect(m_powerListWidget, &MyListWidget::currentItemChanged, this, &LockWidget::onPowerItemChanged); + connect(m_powerListWidget, &PowerListWidget::showInhibitWarning, this, &LockWidget::onShowInhibitWarning); + connect(m_powerListWidget, &PowerListWidget::mulUsersLogined, this, &LockWidget::onMulUsersLogined); + m_powerListWidget->clearFocus(); +} + +void LockWidget::initButtonWidget() +{ + buttonListWidget = new MyListWidget(this); + buttonListWidget->installEventFilter(this); + buttonListWidget->setFlow(QListWidget::LeftToRight); + buttonListWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + buttonListWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + QString buttonListStyle = "QListWidget{ background:rgba(255, 255, 255, 0%); border: 0px;}" + "QListWidget::item{border-radius: 4px; background:rgba(255, 255, 255, 0%);}"; + buttonListWidget->setStyleSheet(buttonListStyle); + buttonListWidget->setSpacing(8); + + if (m_modelLockDialog->sessionsInfo().count() > 1) { + m_sessionButton = new StatusButton(this, BOTBUTTON); + QListWidgetItem *buttonItem = new QListWidgetItem(); + buttonItem->setSizeHint(QSize(48, 48)); + buttonListWidget->insertItem(buttonListWidget->count(), buttonItem); + buttonListWidget->setItemWidget(buttonItem, m_sessionButton); + buttonListWidget->addItem(buttonItem); + m_sessionButton->setObjectName("BtnSession"); + if (m_curUserInfo.isLoggedIn()) { + buttonListWidget->setItemHidden(buttonItem, true); + } else { + buttonListWidget->setItemHidden(buttonItem, false); + } + QString strCurSession = m_modelLockDialog->currentSession(); + QString sessionPrefix = strCurSession.left(strCurSession.indexOf('-')); + if(strCurSession == "ukui-wayland") + sessionPrefix = "ukui_wayland"; + strCurSession = IMAGE_DIR + QString("badges/%1_badge.svg") + .arg(sessionPrefix.toLower()); + QFile iconFile(strCurSession); + if(!iconFile.exists()){ + strCurSession = IMAGE_DIR + QString("badges/unknown_badge.svg"); + } + QPixmap ssIcon(strCurSession); + ssIcon = scaledPixmap(ssIcon); + ssIcon = ssIcon.scaled(32, 32, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + ssIcon = PixmapToRound(ssIcon, 16); + m_sessionButton->setIcon(ssIcon); + connect(m_sessionButton, &StatusButton::clicked, this, [this]() { + onShowSessionListWidget(); + }); + } + + if (m_modelLockDialog->getIsBattery()) { + m_batteryonButton = new StatusButton(this, BOTBUTTON); + QListWidgetItem *buttonItem = new QListWidgetItem(); + buttonItem->setSizeHint(QSize(48, 48)); + buttonListWidget->insertItem(buttonListWidget->count(), buttonItem); + buttonListWidget->setItemWidget(buttonItem, m_batteryonButton); + QPixmap batteryIcon = drawSymbolicColoredPixmap(QIcon::fromTheme(m_modelLockDialog->getBatteryIconName()).pixmap(QSize(24, 24)), "white"); + m_batteryonButton->setIcon(batteryIcon); + connect(m_modelLockDialog, &LockDialogModel::batteryStatusChanged, this, [=](const QString &iconName) { + QPixmap batteryIcon = drawSymbolicColoredPixmap(QIcon::fromTheme(iconName).pixmap(QSize(24, 24)), "white"); + m_batteryonButton->setIcon(batteryIcon); + }); + buttonListWidget->addItem(buttonItem); + connect(m_batteryonButton, &StatusButton::clicked, this, [this]() { + onShowBatteryWidget(); + }); + } + + if (m_userListWidget->count() > 1 || m_modelLockDialog->findUserByName("*login")) { + m_userButton = new StatusButton(this, BOTBUTTON); + QListWidgetItem *buttonItem = new QListWidgetItem(); + buttonItem->setSizeHint(QSize(48, 48)); + buttonListWidget->insertItem(buttonListWidget->count(), buttonItem); + buttonListWidget->setItemWidget(buttonItem, m_userButton); + m_userButton->setIcon(QIcon(":/image/assets/switchuser.svg")); + buttonListWidget->addItem(buttonItem); + connect(m_userButton, &StatusButton::clicked, this, [this]() { + onShowUserListWidget(); + }); + } + + m_networkButton = new NetWorkButton(this); + QListWidgetItem *buttonItem = new QListWidgetItem(); + buttonItem->setSizeHint(QSize(48, 48)); + buttonListWidget->insertItem(buttonListWidget->count(), buttonItem); + buttonListWidget->setItemWidget(buttonItem, m_networkButton); + buttonListWidget->addItem(buttonItem); + connect(m_networkButton, &NetWorkButton::clicked, this, [this]() { + onShowNetworkWidget(); + }); + + /* + connect(buttonWidget, &KyNetworkIcon::updateIconHidden + ,this, [buttonWidget,this](bool status){ + if (status) { + buttonWidget->hide(); + } else { + buttonWidget->show(); + } + }); + if (buttonWidget->checkIconIsHidden()) { + buttonWidget->hide(); + } + */ + + m_virKbButton = new StatusButton(this, BOTBUTTON); + QListWidgetItem *kyeboardItem = new QListWidgetItem(); + kyeboardItem->setSizeHint(QSize(48, 48)); + buttonListWidget->insertItem(buttonListWidget->count(), kyeboardItem); + buttonListWidget->setItemWidget(kyeboardItem, m_virKbButton); + m_virKbButton->setIcon(QIcon(":/image/assets/keyboard.svg")); + buttonListWidget->addItem(kyeboardItem); + connect(m_virKbButton, &StatusButton::clicked, this, [this]() { + onShowVirtualKeyboard(); + }); + + if (m_powerListWidget->count() > 1 ) { + m_powerManagerButton = new StatusButton(this, BOTBUTTON); + QListWidgetItem *buttonItem = new QListWidgetItem(); + buttonItem->setSizeHint(QSize(48, 48)); + buttonListWidget->insertItem(buttonListWidget->count(), buttonItem); + buttonListWidget->setItemWidget(buttonItem, m_powerManagerButton); + m_powerManagerButton->setIcon(QIcon(":/image/assets/shutdown.svg")); + buttonListWidget->addItem(buttonItem); + connect(m_powerManagerButton, &StatusButton::clicked, this, [this]() { + onShowPowerListWidget(); + }); + } + + if (m_curUserInfo.isLoggedIn() && m_sessionButton) { + buttonListWidget->setFixedSize(QSize(48*(buttonListWidget->count() - 1) + buttonListWidget->spacing()*2*(buttonListWidget->count() - 1), 64)); + } else { + buttonListWidget->setFixedSize(QSize(48*buttonListWidget->count() + buttonListWidget->spacing()*2*buttonListWidget->count(), 64)); + } + buttonListWidget->move(width()- RIGHT_MARGIN -buttonListWidget->width(), height() - BOTTOM_MARGIN - buttonListWidget->spacing()); + connect(buttonListWidget, &MyListWidget::currentItemChanged, this, &LockWidget::onButtonItemChanged); + connect(buttonListWidget, &MyListWidget::itemClicked, this, &LockWidget::onButtonItemClicked); + buttonListWidget->clearFocus(); +} + +void LockWidget::initBlockWidget() +{ + m_blockWidget = new BlockWidget(this); + m_blockWidget->setGeometry(this->geometry()); + m_blockWidget->hide(); + connect(m_blockWidget, SIGNAL(cancelButtonclicked()), + this, SLOT(onCancelBtnClicked())); + connect(m_blockWidget, SIGNAL(confirmButtonclicked()), + this, SLOT(onConfirmBtnClicked())); +} + +void LockWidget::initUsdMediaKeys() +{ + m_areaScreenShot = m_modelLockDialog->getUsdAreaScreenShotKey(); + m_areaScreenShot2 = m_modelLockDialog->getUsdAreaScreenShot2Key(); + m_screenShot = m_modelLockDialog->getUsdScreenShotKey(); + m_screenShot2 = m_modelLockDialog->getUsdScreenShot2Key(); + m_windowScreenshot = m_modelLockDialog->getUsdwindowScreenshotKey(); + connect(m_modelLockDialog, &LockDialogModel::usdMediaKeysChanged, this, &LockWidget::onUsdMediaKeysChanged); +} + +const QKeySequence LockWidget::listFromString(QString keys) +{ + keys.replace("<", ""); + keys.replace(">", "+"); + keys.replace("Win", "Meta", Qt::CaseInsensitive); + keys.replace("Start", "Meta", Qt::CaseInsensitive); + keys.replace("PrtSc", "Print", Qt::CaseInsensitive); + return QKeySequence(keys); +} + +void LockWidget::updateBottomButton() +{ + QList statusButton = this->findChildren(); + for (auto button : statusButton) { + if (button->getButtonTyoe() == POWERBUTTON) { + button->setFixedSize(130*scale, 130*scale); + } else { + button->setFixedSize(48*scale, 48*scale); + } + } + QList networkButton = this->findChildren(); + for (auto button : networkButton) { + button->setFixedSize(48*scale, 48*scale); + } +} + +void LockWidget::onPowerItemChanged(QListWidgetItem *current, QListWidgetItem *previous) +{ + QWidget *currentWidget = m_powerListWidget->itemWidget(current); + PowerItemWidget *currentItem = dynamic_cast(currentWidget); + if (currentItem) { + currentItem->setSelected(SELECT); + } + if (previous) { + QWidget *previousWidget = m_powerListWidget->itemWidget(previous); + PowerItemWidget *previousItem = dynamic_cast(previousWidget); + if (previousItem) { + previousItem->setSelected(NORMAL); + } + } +} + +void LockWidget::onButtonItemChanged(QListWidgetItem *current, QListWidgetItem *previous) +{ + QWidget *currentWidget = buttonListWidget->itemWidget(current); + StatusButton *currentItem = dynamic_cast(currentWidget); + NetWorkButton *netItem = dynamic_cast(currentWidget); + if (currentItem) + currentItem->setClickedStatus(SELECT); + if (netItem) { + netItem->setClickedStatus(SELECT); + } + if (previous) { + QWidget *previousWidget = buttonListWidget->itemWidget(previous); + StatusButton *previousItem = dynamic_cast(previousWidget); + NetWorkButton *previousNetItem = dynamic_cast(previousWidget); + if (previousItem) + previousItem->setClickedStatus(NORMAL); + if (previousNetItem) { + previousNetItem->setClickedStatus(NORMAL); + } + } +} + +void LockWidget::onButtonItemClicked(QListWidgetItem *item) +{ + QWidget *widget = buttonListWidget->itemWidget(item); + StatusButton *currentItem = dynamic_cast(widget); + if (currentItem) { + currentItem->setClickedStatus(CLICKED); + currentItem->clicked(); + } + if (currentItem == m_powerManagerButton) { + for (int i = 0; i < buttonListWidget->count(); i++) { + if (!buttonListWidget->isRowHidden(i)) { + buttonListWidget->setCurrentRow(i, QItemSelectionModel::SelectionFlag::Clear); + buttonListWidget->currentItemChanged(buttonListWidget->item(i), buttonListWidget->item(i)); + break; + } + } + } + NetWorkButton *netItem = dynamic_cast(widget); + if (netItem) { + netItem->setClickedStatus(CLICKED); + netItem->clicked(); + } +} + +void LockWidget::onPowerItemClicked(QListWidgetItem *item) +{ + QWidget *widget = m_powerListWidget->itemWidget(item); + PowerItemWidget *currentItem = dynamic_cast(widget); + if (currentItem) { + currentItem->setSelected(CLICKED); + currentItem->clicked(); + } +} + +void LockWidget::onCurUserChanged(const QString &strUserName) +{ + UserInfoPtr ptrUser = m_modelLockDialog->findUserByName(strUserName); + if (ptrUser && authDialog) { + m_curUserInfo = *ptrUser; + authDialog->onCurUserChanged(m_curUserInfo); + } +} + +void LockWidget::onUserChangedByManual(const QString &userName) +{ + if (m_modelLockDialog && m_modelLockDialog->findUserByName(userName)) { + Q_EMIT m_modelLockDialog->setCurrentUser(userName); + } else { + + } +} + +void LockWidget::onSessionChanged(const QString &strSession) +{ + if (buttonListWidget) { + for (int n = 0; n < buttonListWidget->count(); n++) { + QListWidgetItem *item = buttonListWidget->item(n); + QWidget *widget = buttonListWidget->itemWidget(item); + if (widget->objectName() == "BtnSession") { + StatusButton *sButton = qobject_cast(widget); + if (sButton) { + QString strCurSession = strSession; + QString sessionPrefix = strCurSession.left(strCurSession.indexOf('-')); + if(strCurSession == "ukui-wayland") + sessionPrefix = "ukui_wayland"; + strCurSession = IMAGE_DIR + QString("badges/%1_badge.svg") + .arg(sessionPrefix.toLower()); + QFile iconFile(strCurSession); + if(!iconFile.exists()){ + strCurSession = IMAGE_DIR + QString("badges/unknown_badge.svg"); + } + QPixmap ssIcon(strCurSession); + ssIcon = scaledPixmap(ssIcon); + ssIcon = ssIcon.scaled(32, 32, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + ssIcon = PixmapToRound(ssIcon, 16); + sButton->setIcon(ssIcon); + } + } + } + } +} + +void LockWidget::onUsdMediaKeysChanged(const QString &keys, const QString &value) +{ + if (keys == KEY_AREA_SCREENSHOT) { + m_areaScreenShot = value; + } else if (keys == KEY_AREA_SCREENSHOT2) { + m_areaScreenShot2 = value; + } else if (keys == KEY_SCREEN_SHOT) { + m_screenShot = value; + } else if (keys == KEY_SCREEN_SHOT2) { + m_screenShot2 = value; + } else if (keys == KEY_WINDOW_SCREENSHOT) { + m_windowScreenshot = value; + } +} + +void LockWidget::onShowSessionListWidget() +{ + if (m_sessionListWidget && m_sessionListWidget->isHidden()) { + m_sessionListWidget->show(); + m_sessionListWidget->setFocus(); + m_sessionButton->setClickedStatus(CLICKED); + if (m_networkWidget && m_networkWidget->isVisible()) + m_networkWidget->hide(); + if (batteryWidget && batteryWidget->isVisible()) + batteryWidget->hide(); + if (m_userListWidget && m_userListWidget->isVisible()) + m_userListWidget->hide(); + } else { + m_sessionListWidget->hide(); + m_sessionButton->setClickedStatus(NORMAL); + } +} + +void LockWidget::onShowBatteryWidget() +{ + if (!batteryWidget) { + batteryWidget = new BatteryWidget(m_modelLockDialog, this); + batteryWidget->setFixedSize(314, 112); + if (batteryWidget) { + if (m_sessionButton->isHidden()) { + batteryWidget->setGeometry(buttonListWidget->x(), + height()- BOTTOM_MARGIN - buttonListWidget->height() - buttonListWidget->spacing() - batteryWidget->height(), 314*scale, 112*scale); + } else { + batteryWidget->setGeometry(buttonListWidget->x() + m_sessionButton->width() + 32, + height()- BOTTOM_MARGIN - buttonListWidget->height() - buttonListWidget->spacing() - batteryWidget->height(), 314*scale, 112*scale); + } + } + } + + if (batteryWidget && batteryWidget->isHidden()) { + batteryWidget->show(); + m_batteryonButton->setClickedStatus(CLICKED); + if (m_networkWidget && m_networkWidget->isVisible()) + m_networkWidget->hide(); + if (m_userListWidget && m_userListWidget->isVisible()) + m_userListWidget->hide(); + if (m_sessionListWidget && m_sessionListWidget->isVisible()) + m_sessionListWidget->hide(); + } else { + batteryWidget->hide(); + m_batteryonButton->setClickedStatus(NORMAL); + } +} + +void LockWidget::onShowUserListWidget() +{ + if (m_userListWidget && m_userListWidget->isHidden()) { + m_userListWidget->show(); + m_userListWidget->setFocus(); + m_userButton->setClickedStatus(CLICKED); + if (m_networkWidget && m_networkWidget->isVisible()) + m_networkWidget->hide(); + if (batteryWidget && batteryWidget->isVisible()) + batteryWidget->hide(); + if (m_sessionListWidget && m_sessionListWidget->isVisible()) + m_sessionListWidget->hide(); + } else { + m_userListWidget->hide(); + m_userButton->setClickedStatus(NORMAL); + } +} + +void LockWidget::onShowNetworkWidget() +{ + if (!m_networkWidget) { + m_networkWidget = new MyNetworkWidget(this); + m_networkWidget->installEventFilter(this); + } + m_networkWidget->setGeometry(this->width() - m_networkWidget->width() - RIGHT_MARGIN*scale, + this->height() - m_networkWidget->height() - BOTTOM_MARGIN*scale - buttonListWidget->spacing()*scale - buttonListWidget->height(), + m_networkWidget->width(), + m_networkWidget->height()); + if (m_networkWidget && m_networkWidget->isVisible()) { + m_networkWidget->hide(); + m_networkButton->setClickedStatus(NORMAL); + } else { + m_networkWidget->show(); + m_networkButton->setClickedStatus(CLICKED); + if (m_userListWidget && m_userListWidget->isVisible()) + m_userListWidget->hide(); + if (batteryWidget && batteryWidget->isVisible()) + batteryWidget->hide(); + if (m_sessionListWidget && m_sessionListWidget->isVisible()) + m_sessionListWidget->hide(); + } +} + +void LockWidget::onShowVirtualKeyboard() +{ + if(!m_virtualKeyboardWidget){ + m_virtualKeyboardWidget = new VirtualKeyboardWidget(this); + m_virtualKeyboardWidget->installEventFilter(this); + m_virtualKeyboardWidget->hide(); + + connect(m_virtualKeyboardWidget, &VirtualKeyboardWidget::aboutToClose, + this, &LockWidget::onHideVirkeyboard); + connect(m_virtualKeyboardWidget, &VirtualKeyboardWidget::aboutToFloat, + this, &LockWidget::onNetWorkResetLocation); + } + if (m_virtualKeyboardWidget->isHidden()) { + if (batteryWidget && batteryWidget->isVisible()) + batteryWidget->hide(); + if (m_sessionListWidget && m_sessionListWidget->isVisible()) + m_sessionListWidget->hide(); + if (m_userListWidget && m_userListWidget->isVisible()) + m_userListWidget->hide(); + m_virtualKeyboardWidget->show(); + authDialog->setFocus(); + } else { + m_virtualKeyboardWidget->hide(); + } + + if(!m_virtualKeyboardWidget->isHidden()){ + if(m_networkWidget && m_networkWidget->isVisible() && !m_virtualKeyboardWidget->getFloatStatus()) { + m_networkWidget->move(this->width() - m_networkWidget->width() - 20, + this->height() - m_networkWidget->height() - m_virtualKeyboardWidget->height()); + m_networkWidget->raise(); + } else { + } + m_virtualKeyboardWidget->raise(); + } + m_virKbButton->setClickedStatus(NORMAL); +} + +void LockWidget::onShowPowerListWidget() +{ + + if (m_powerListWidget->isHidden()) { + m_powerListWidget->show(); + authDialog->hide(); + m_powerListWidget->clearFocus(); + } else { + m_powerListWidget->hide(); + authDialog->show(); + authDialog->setFocus(); + } + if (m_userListWidget && m_userListWidget->isVisible()) + m_userListWidget->hide(); + if (m_virtualKeyboardWidget && m_virtualKeyboardWidget->isVisible()) + m_virtualKeyboardWidget->hide(); + if (batteryWidget && batteryWidget->isVisible()) + batteryWidget->hide(); + if (m_networkWidget && m_networkWidget->isVisible()) + m_networkWidget->hide(); + if (m_sessionListWidget && m_sessionListWidget->isVisible()) + m_sessionListWidget->hide(); + m_powerManagerButton->setClickedStatus(NORMAL); +} + +void LockWidget::onSetVirkeyboardPos() +{ + if(m_virtualKeyboardWidget) + { + m_virtualKeyboardWidget->adjustGeometry(); + } +} + +void LockWidget::onNetWorkResetLocation() +{ + if (m_networkWidget && m_networkWidget->isVisible()) { + if (m_virtualKeyboardWidget->getFloatStatus()) { + m_networkWidget->move(this->width() - m_networkWidget->width() - RIGHT_MARGIN, + this->height() - m_networkWidget->height() - BOTTOM_MARGIN - buttonListWidget->spacing() - buttonListWidget->height()) ; + } else { + m_networkWidget->move(this->width() - m_networkWidget->width() - RIGHT_MARGIN, + this->height() - m_networkWidget->height() - m_virtualKeyboardWidget->height()); + } + m_networkWidget->raise(); + } + if (m_virtualKeyboardWidget && m_virtualKeyboardWidget->isVisible()) { + m_virtualKeyboardWidget->raise(); + } +} + +void LockWidget::onHideVirkeyboard() +{ + if(m_virtualKeyboardWidget && m_virtualKeyboardWidget->isVisible()) { + m_virtualKeyboardWidget->hide(); + } + if(m_networkWidget && m_networkWidget->isVisible()) { + m_networkWidget->move(this->width() - m_networkWidget->width() - RIGHT_MARGIN, + this->height() - m_networkWidget->height() - BOTTOM_MARGIN - buttonListWidget->spacing() - buttonListWidget->height()); + } +} + +void LockWidget::onShowInhibitWarning(QStringList list, int type) +{ + m_blockWidget->setGeometry(this->geometry()); + m_blockWidget->setWarning(list, type); + m_blockWidget->show(); + m_powerListWidget->hide(); +} + +void LockWidget::onMulUsersLogined(QString inhibitType) +{ + m_inhibitType = inhibitType; + m_blockWidget->setGeometry(this->geometry()); + m_blockWidget->setTips(tr("Multiple users are logged in at the same time.Are you sure you want to %1 this system?").arg(inhibitType)); + m_blockWidget->show(); + m_powerListWidget->hide(); +} + +void LockWidget::onConfirmBtnClicked() +{ + m_blockWidget->hide(); + m_powerListWidget->hide(); + authDialog->show(); + buttonListWidget->show(); + Q_EMIT m_modelLockDialog->setPowerManager(m_inhibitType); +} + +void LockWidget::onCancelBtnClicked() +{ + m_blockWidget->hide(); + m_powerListWidget->show(); +} + +void LockWidget::onCustomRequestAccount(QString account) +{ + if(m_modelLockDialog) + Q_EMIT m_modelLockDialog->setCurrentUser(account); +} + +void LockWidget::onGetCustomPluginMsg(QString strMsg) +{ + QJsonParseError jsonParseError; + const QJsonDocument jsonDoc = QJsonDocument::fromJson(strMsg.toUtf8(), &jsonParseError); + if (jsonParseError.error != QJsonParseError::NoError) { + qWarning()<<"Parse message json failed!!"; + return ; + } else { + QJsonObject rootObj = jsonDoc.object(); + if (rootObj.isEmpty()) { + qWarning()<<"Message Json is null!!"; + return ; + } else { + QJsonObject contentObj = rootObj.value("Content").toObject(); + if (!contentObj.isEmpty()) { + QJsonObject configObj = contentObj.value("Configures").toObject(); + if (!configObj.isEmpty()) { + m_isCustomDefault = configObj.value("DefaultAuth").toBool(false); + m_isShowNetwork = configObj.value("ShowNetwork").toBool(true); + m_isShowUserSwitch = configObj.value("ShowUserSwitch").toBool(true); + } + } + } + } +} + diff --git a/src/widgets/lockwidget.h b/src/widgets/lockwidget.h new file mode 100644 index 0000000..7876bd4 --- /dev/null +++ b/src/widgets/lockwidget.h @@ -0,0 +1,164 @@ +#ifndef LOCKWIDGET_H +#define LOCKWIDGET_H + +#include +#include +#include "userinfo.h" + +class QListWidgetItem; +class MyListWidget; +class QPushButton; +class QPixmap; +class LockDialogModel; +class UserListWidget; +class SessionListWidget; +class AuthDialog; +class MyNetworkWidget; +class PowerListWidget; +class TimeWidget; +class BatteryWidget; +class VirtualKeyboardWidget; +class BlockWidget; +class StatusButton; +class NetWorkButton; + +class LockWidget : public QWidget +{ + Q_OBJECT +public: + explicit LockWidget(LockDialogModel *model, QWidget *parent = nullptr); + bool exitSubWidget(); +protected: + void paintEvent(QPaintEvent *event); + bool eventFilter(QObject *obj, QEvent *event); + void resizeEvent(QResizeEvent *event); + void keyReleaseEvent(QKeyEvent *e); + +signals: + +private: + void initUI(); + void initConnections(); + void initUserWidget(); + void initSessionWidget(); + void initPowerWidget(); + void initButtonWidget(); + void initTimeWidget(); + void initBlockWidget(); + void sendNetPluginVisible(bool visible); + + /** + * @brief 获取usd快捷键键值:QString + * + */ + void initUsdMediaKeys(); + /** + * @brief 快捷键转化:QString - QKeySequence + * @param shortcuts 快捷键键值 + * @return QKeySequence + */ + static const QKeySequence listFromString(QString shortcuts); + + void updateBottomButton(); + +private Q_SLOTS: + /** + * @brief item选中状态改变 + * @param current 前一个选中item + * previous 当前选中item + * @return + */ + void onPowerItemChanged(QListWidgetItem *current, QListWidgetItem *previous); + void onButtonItemChanged(QListWidgetItem *current, QListWidgetItem *previous); + /** + * @brief item点击响应 + * @param item + * @return + */ + void onButtonItemClicked(QListWidgetItem *item); + void onPowerItemClicked(QListWidgetItem *item); + + void onCurUserChanged(const QString &strUserName); + void onSessionChanged(const QString &strSession); + void onUserChangedByManual(const QString &userName); + + void onUsdMediaKeysChanged(const QString &keys, const QString &value); + + void onShowSessionListWidget(); + void onShowBatteryWidget(); + void onShowUserListWidget(); + void onShowNetworkWidget(); + void onShowPowerListWidget(); + void onShowVirtualKeyboard(); + + void onNetWorkResetLocation(); + void onSetVirkeyboardPos(); + void onHideVirkeyboard(); + + void onShowInhibitWarning(QStringList list, int type); + + void onMulUsersLogined(QString inhibitType); + + void onConfirmBtnClicked(); + void onCancelBtnClicked(); + /** + * @brief onCustomRequestAccount 请求切换认证用户 + * @param account 用户名 + */ + void onCustomRequestAccount(QString account); + /** + * @brief onGetCustomPluginMsg 获取插件消息槽 + * @param strMsg 消息json + */ + void onGetCustomPluginMsg(QString strMsg); + +Q_SIGNALS: + void authSucceed(QString strUserName); + +private: + // 日期时间 + TimeWidget *m_timeWidget = nullptr; + // 用户列表 + UserListWidget *m_userListWidget = nullptr; + // 会话列表 + SessionListWidget *m_sessionListWidget = nullptr; + // 电源管理列表 + PowerListWidget *m_powerListWidget = nullptr; + // 底部button列表 + MyListWidget *buttonListWidget = nullptr; + + QPixmap background; + + LockDialogModel *m_modelLockDialog = nullptr; + + UserInfo m_curUserInfo; + + AuthDialog *authDialog = nullptr; + + // usd快捷键键值 + QString m_areaScreenShot; + QString m_areaScreenShot2; + QString m_screenShot; + QString m_screenShot2; + QString m_windowScreenshot; + + MyNetworkWidget *m_networkWidget = nullptr; + BatteryWidget *batteryWidget = nullptr; + VirtualKeyboardWidget *m_virtualKeyboardWidget = nullptr; + BlockWidget *m_blockWidget = nullptr; + QString m_inhibitType; + + // 底部button + StatusButton *m_sessionButton = nullptr; + StatusButton *m_batteryonButton = nullptr; + StatusButton *m_userButton = nullptr; + NetWorkButton *m_networkButton = nullptr; + StatusButton *m_virKbButton = nullptr; + StatusButton *m_powerManagerButton = nullptr; + + bool m_isCustomDefault = false; /** 是否默认使用第三方认证 */ + bool m_isShowNetwork = true; /** 是否显示网络插件 */ + bool m_isShowUserSwitch = true; /** 是否显示用户切换 */ +}; + +#endif // LOCKWIDGET_H diff --git a/src/loginauthinterface.h b/src/widgets/loginauthinterface.h similarity index 100% rename from src/loginauthinterface.h rename to src/widgets/loginauthinterface.h diff --git a/src/loginoptionswidget.cpp b/src/widgets/loginoptionswidget.cpp similarity index 74% rename from src/loginoptionswidget.cpp rename to src/widgets/loginoptionswidget.cpp index 120b0f9..8b6ee14 100644 --- a/src/loginoptionswidget.cpp +++ b/src/widgets/loginoptionswidget.cpp @@ -1,63 +1,35 @@ -/* - * Copyright (C) 2022 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ #include "loginoptionswidget.h" #include #include #include -#include "giodbus.h" -#include "biometricdeviceinfo.h" -#include "configuration.h" +#include "../dbusifs/giodbus.h" +#include "../dbusifs/biometrichelper.h" #include "klabel.h" -#include +#include "common/configuration.h" #include "pluginsloader.h" - #include #include #include #include -#include #include #include #include #include #include #include -#include #include #include #include #include #include -#define ON_TAB_SHEET "QPushButton{background-color: rgba(255,255,255,15%); border-radius: 4px; border: 2px solid #2C73C8;}" -#define ON_NORMAL_SHEET "QPushButton{background-color: rgba(255,255,255,15%); border-radius: 4px; border: none;}\ - QPushButton::hover{ background-color: rgba(255,255,255,40%);}\ - QPushButton::pressed {background-color: rgba(255,255,255,40%);}\ - QPushButton::checked {background-color: rgba(255, 255, 255, 40%);}" - -LoginOptionsWidget::LoginOptionsWidget(BiometricProxy* proxy, int uid, UniAuthService* uniauthService, QWidget *parent) +LoginOptionsWidget::LoginOptionsWidget(BiometricHelper *bioHelper, int uid, UniAuthService *uniauthService, QWidget *parent) : QWidget(parent) - , m_biomericProxy(proxy) + , m_biomericProxy(bioHelper) , m_uid(uid) , m_uniauthService(uniauthService) - , configuration(Configuration::instance()) { m_listPriority.clear(); m_listPriority.push_back(BioT_Face); @@ -65,10 +37,8 @@ LoginOptionsWidget::LoginOptionsWidget(BiometricProxy* proxy, int uid, UniAuthSe m_listPriority.push_back(BioT_Iris); m_listPriority.push_back(BioT_VoicePrint); m_listPriority.push_back(BioT_FingerVein); - m_listPriority.push_back(REMOTE_QRCODE_TYPE); + m_listPriority.push_back(UniT_Remote); m_listPriority.push_back(UniT_General_Ukey); - curFontSize = configuration->getFontSize(); - m_ptToPx = configuration->getPtToPx(); initUI(); initConnections(); m_mapDisableDev.clear(); @@ -91,8 +61,9 @@ void LoginOptionsWidget::initUI() m_layoutOptBtns->setSpacing(16); m_labelOptTitle = new KLabel(); - m_labelOptTitle->setAlignment(Qt::AlignCenter); + curFontSize = 11; m_labelOptTitle->setFontSize(16); + m_labelOptTitle->setAlignment(Qt::AlignCenter); m_labelOptTitle->setText(tr("Login Options")); m_labelOptTitle->setFixedHeight(30); m_layoutMain->addWidget(m_labelOptTitle); @@ -107,16 +78,28 @@ void LoginOptionsWidget::initUI() this->setLayout(m_layoutMain); } +void LoginOptionsWidget::changeEvent(QEvent *event) +{ + if(event->type() == QEvent::LanguageChange){ + refreshTranslate(); + } +} + +void LoginOptionsWidget::refreshTranslate() +{ + m_labelOptTitle->setTipText(tr("Login Options")); +} + void LoginOptionsWidget::initConnections() { if(m_biomericProxy && m_biomericProxy->isValid()) { - connect(m_biomericProxy, &BiometricProxy::StatusChanged, + connect(m_biomericProxy, &BiometricHelper::StatusChanged, this, &LoginOptionsWidget::onStatusChanged); - connect(m_biomericProxy, &BiometricProxy::FrameWritten, + connect(m_biomericProxy, &BiometricHelper::FrameWritten, this, &LoginOptionsWidget::onFrameWritten); - connect(m_biomericProxy, &BiometricProxy::USBDeviceHotPlug, + connect(m_biomericProxy, &BiometricHelper::USBDeviceHotPlug, this, &LoginOptionsWidget::onUSBDeviceHotPlug); } connect(m_btnGroup, SIGNAL(buttonClicked(int)), this, SLOT(onOptionSelected(int))); @@ -137,63 +120,13 @@ unsigned LoginOptionsWidget::getLoginOptCount() return m_mapDevices.size(); } -int LoginOptionsWidget::getVisibleLoginOptCount() -{ - int nCount = 0; - QMap::iterator itMapBtn = m_mapOptBtns.begin(); - for ( ; itMapBtn != m_mapOptBtns.end(); itMapBtn++) { - if (itMapBtn.value() && itMapBtn.value()->isVisible()) { - nCount ++; - } - } - return nCount; -} - -DeviceInfoPtr LoginOptionsWidget::getFirstDevInfo() -{ - DeviceInfoPtr devInfo = nullptr; - int nDrvId = GetLastDevice(getpwuid(m_uid)->pw_name); - if (nDrvId >= 0) { - qDebug()<<"GetLastDevice:"<id == nDrvId && devinfo->deviceType != UniT_Custom) { - if (!isDeviceDisable(devinfo->id)) { - devInfo = devinfo; - break; - } - } - } - if (devInfo) { - break; - } - } - } - if (!devInfo) { - DeviceMap::iterator itDevInfo = m_mapDevices.begin(); - for (; itDevInfo != m_mapDevices.end(); itDevInfo++) { - for (auto devinfo : itDevInfo.value()) { - if (devinfo && !isDeviceDisable(devinfo->id) && devinfo->deviceType != UniT_Custom) { - devInfo = devinfo; - break; - } - } - if (devInfo) { - break; - } - } - } - return DeviceInfoPtr(devInfo); -} - DeviceInfoPtr LoginOptionsWidget::getWechatDevice() { DeviceInfoPtr devInfo = nullptr; - DeviceMap::iterator itDevInfo = m_mapDevices.begin(); + DeviceListMap::iterator itDevInfo = m_mapDevices.begin(); for (; itDevInfo != m_mapDevices.end(); itDevInfo++) { for (auto devinfo : itDevInfo.value()) { - if (devinfo && devinfo->deviceType == REMOTE_QRCODE_TYPE) { + if (devinfo && devinfo->deviceType == UniT_Remote) { if (!isDeviceDisable(devinfo->id)) { devInfo = devinfo; break; @@ -230,7 +163,7 @@ void LoginOptionsWidget::addOptionButton(unsigned uLoginOptType, int nDrvId, QSt int nLength = m_btnGroup->buttons().length(); m_btnGroup->addButton(newButton, nLength); m_listDriveId.append(nDrvId); - // } +// } QPixmap iconPixmap; switch (uLoginOptType) { case LOGINOPT_TYPE_PASSWORD: @@ -258,34 +191,34 @@ void LoginOptionsWidget::addOptionButton(unsigned uLoginOptType, int nDrvId, QSt iconPixmap = loadSvg(":/image/assets/ukui-loginopt-qrcode.svg", "white", 16); break; case LOGINOPT_TYPE_CUSTOM: - { - LoginAuthInterface *plugin = dynamic_cast(PluginsLoader::instance().findModulesByType(LoginPluginInterface::MODULETYPE_AUTH).values().first()); - QString strIcon = plugin->icon(); - if (strIcon.startsWith("/")) { - if (strIcon.endsWith(".svg")) { - iconPixmap = loadSvg(strIcon, "white", 16); + { + LoginAuthInterface *plugin = dynamic_cast(PluginsLoader::instance().findModulesByType(LoginPluginInterface::MODULETYPE_AUTH).values().first()); + QString strIcon = plugin->icon(); + if (strIcon.startsWith("/")) { + if (strIcon.endsWith(".svg")) { + iconPixmap = loadSvg(strIcon, "white", 16); + } else { + iconPixmap.load(strIcon); + iconPixmap.scaled(40, 40); + } } else { - iconPixmap.load(strIcon); - iconPixmap.scaled(40, 40); + iconPixmap = QIcon::fromTheme(strIcon).pixmap(48,48).scaled(40, 40); + } + if (iconPixmap.isNull()) { + iconPixmap = loadSvg(":/image/assets/ukui-loginopt-custom.svg", "white", 16); } - } else { - iconPixmap = QIcon::fromTheme(strIcon).pixmap(48,48).scaled(40, 40); } - if (iconPixmap.isNull()) { - iconPixmap = loadSvg(":/image/assets/ukui-loginopt-custom.svg", "white", 16); - } - } break; } //newLabel->setPixmap(iconPixmap); newButton->setIcon(iconPixmap); - newButton->setToolTip(strDrvName); - sysFont.setPointSize((14 + curFontSize) *m_ptToPx); - QToolTip::setFont(sysFont); - newButton->setStyleSheet("QPushButton{text-align:center;background-color: rgb(255,255,255,15%);border: none;border-radius: 4px;outline: none;}" - "QPushButton::hover{background-color: rgb(255,255,255,40%);}" + newButton->installEventFilter(this); + newButton->setObjectName(strDrvName); + newButton->setStyleSheet("QPushButton{text-align:center;background-color: rgba(255,255,255,15%);border: none;border-radius: 4px;outline: none;}" + "QPushButton::hover{background-color: rgba(255,255,255,40%);}" "QPushButton::pressed {background-color: rgba(255,255,255,40%);}" "QPushButton::checked {background-color: rgba(255,255,255,40%);}"); + nameList.append(strDrvName); newButton->setFixedSize(48, 48); if (isDeviceDisable(nDrvId)) { newButton->setDisabled(true); @@ -297,6 +230,25 @@ void LoginOptionsWidget::addOptionButton(unsigned uLoginOptType, int nDrvId, QSt m_mapOptBtns[nDrvId] = newButton; } +bool LoginOptionsWidget::eventFilter(QObject *obj, QEvent *event) +{ + for(int i = 0; iobjectName() == nameList.at(i)){ + if(event->type() == 110){ + Q_EMIT showKToolTipClicked(nameList.at(i)); + } else if (event->type() == 11){ + Q_EMIT hideKTooltipClicked(); + } + } + } + return false; +} + +bool LoginOptionsWidget::getHasUkeyOptions() +{ + return isShowUkey; +} + void LoginOptionsWidget::clearOptionButtons() { QMap::iterator itMapBtn = m_mapOptBtns.begin(); @@ -307,13 +259,8 @@ void LoginOptionsWidget::clearOptionButtons() itMapBtn.value()->deleteLater(); } } - m_listDriveId.clear(); m_mapOptBtns.clear(); -} - -bool LoginOptionsWidget::getHasUkeyOptions() -{ - return isShowUkey; + m_listDriveId.clear(); } void LoginOptionsWidget::updateOptionButtons() @@ -322,7 +269,7 @@ void LoginOptionsWidget::updateOptionButtons() bool hasCustom = false; clearOptionButtons(); addOptionButton(LOGINOPT_TYPE_PASSWORD, -1, tr("Password")); - DeviceMap::iterator itMapDev = m_mapDevices.begin(); + DeviceListMap::iterator itMapDev = m_mapDevices.begin(); for ( ; itMapDev != m_mapDevices.end(); itMapDev++) { for (DeviceInfoPtr devPtr : itMapDev.value()) { if (devPtr) { @@ -334,7 +281,7 @@ void LoginOptionsWidget::updateOptionButtons() hasCustom = true; continue; } - addOptionButton(itMapDev.key(), devPtr->id, DeviceType::getDeviceType_tr(devPtr->deviceType)); + addOptionButton(itMapDev.key(), devPtr->id, getDeviceType_tr(devPtr->deviceType)); } } } @@ -345,7 +292,7 @@ void LoginOptionsWidget::updateOptionButtons() for (DeviceInfoPtr devPtr : itMapDev.value()) { if(devPtr && devPtr->deviceType == UniT_General_Ukey){ //此处才添加ukey - addOptionButton(itMapDev.key(), devPtr->id, DeviceType::getDeviceType_tr(devPtr->deviceType)); + addOptionButton(itMapDev.key(), devPtr->id, getDeviceType_tr(devPtr->deviceType)); } else if (devPtr && devPtr->deviceType == UniT_Custom) { addOptionButton(itMapDev.key(), devPtr->id, tr("Other")); } @@ -354,14 +301,13 @@ void LoginOptionsWidget::updateOptionButtons() } //存在特征但没有插入ukey - if(!isShowUkey && m_biomericProxy->GetHasUkeyFeature(m_uid) ){ - addOptionButton(LOGINOPT_TYPE_GENERAL_UKEY,-2,DeviceType::getDeviceType_tr(LOGINOPT_TYPE_GENERAL_UKEY)); + if(!isShowUkey && m_biomericProxy->GetHasUkeyFeature(m_uid)){ + addOptionButton(LOGINOPT_TYPE_GENERAL_UKEY,-2,getDeviceType_tr(LOGINOPT_TYPE_GENERAL_UKEY)); isShowUkey = true; } - qDebug()<<"m_mapOptBtns.size():"<hide(); QMap::iterator itMapBtn = m_mapOptBtns.begin(); for ( ; itMapBtn != m_mapOptBtns.end(); itMapBtn++) { @@ -369,7 +315,7 @@ void LoginOptionsWidget::updateOptionButtons() itMapBtn.value()->hide(); } } - }else { + } else { m_labelOptTitle->show(); QMap::iterator itMapBtn = m_mapOptBtns.begin(); for ( ; itMapBtn != m_mapOptBtns.end(); itMapBtn++) { @@ -395,18 +341,18 @@ void LoginOptionsWidget::setUser(int uid) void LoginOptionsWidget::readDevicesInfo() { m_mapDevices.clear(); - bool isAuthEnable = getBioAuthEnable(ENABLETYPE_SAVER); + bool isAuthEnable = getBioAuthEnable(ENABLETYPE_GREETER); bool isQRCodeEnable = getQRCodeEnable(); DeviceList deviceList = m_biomericProxy->GetDevList(); QStringList listDefDevices = getAllDefDevices(); qDebug()<<"BeginGetFeature------!"; FeatureMap mapFeatures = m_biomericProxy->GetUserFeatures(m_uid); qDebug() << m_uid <<",count:"<deviceType <= DeviceType::VoicePrint) + for(auto pDeviceInfo : deviceList) + { + if (!isAuthEnable && pDeviceInfo->deviceType <= BioT_VoicePrint) continue; - if (!isQRCodeEnable && pDeviceInfo->deviceType == REMOTE_QRCODE_TYPE) + if (!isQRCodeEnable && pDeviceInfo->deviceType == UniT_Remote) continue; int nFeatureCount = 0; if (mapFeatures.contains(pDeviceInfo->shortName)) { @@ -422,8 +368,8 @@ void LoginOptionsWidget::readDevicesInfo() } } } - // 检查是否有第三方认证插件 - if (PluginsLoader::instance().findModulesByType(LoginPluginInterface::MODULETYPE_AUTH).size() > 0) { + // 检查是否有第三方认证插件(非root用户) + if (m_uid > 0 && PluginsLoader::instance().findModulesByType(LoginPluginInterface::MODULETYPE_AUTH).size() > 0) { LoginAuthInterface *plugin = dynamic_cast(PluginsLoader::instance() \ .findModulesByType(LoginPluginInterface::MODULETYPE_AUTH) \ .values().first()); @@ -478,7 +424,7 @@ void LoginOptionsWidget::startAuth(DeviceInfoPtr device, int uid) this->m_isStopped = false; this->m_curLoginOptType = convertDeviceType(this->m_curDevInfo->deviceType); updateUIStatus(); - SetLastDevice(this->m_strUserName, this->m_curDevInfo->id); + if(this->m_curLoginOptType == LOGINOPT_TYPE_GENERAL_UKEY) startUkeyAuth(); else @@ -592,13 +538,12 @@ void LoginOptionsWidget::onIdentifyComplete(QDBusPendingCallWatcher *watcher) Q_EMIT authComplete(false, -1); return; } - int result = reply.argumentAt(0).toInt(); int authUid = reply.argumentAt(1).toInt(); qDebug() << result << authUid << m_uid; // 特征识别成功,而且用户id匹配 - if(result == DBUS_RESULT_SUCCESS && authUid == m_uid) { + if(result == DBUS_RESULT_SUCCESS && authUid == m_uid) { qDebug() << "Identify success"; Q_EMIT authComplete(true, 0); } else if(result == DBUS_RESULT_NOTMATCH) { // 特征识别不匹配 @@ -609,14 +554,13 @@ void LoginOptionsWidget::onIdentifyComplete(QDBusPendingCallWatcher *watcher) qDebug()<<"StatusReslut:"<= OPS_GET_FLIST_SUCCESS && ret.opsStatus <= OPS_GET_FLIST_MAX) { Q_EMIT authComplete(false, -3); // 主动停止,直接重试 @@ -778,9 +722,7 @@ void LoginOptionsWidget::onUSBDeviceHotPlug(int drvid, int action, int /*devNum* //设备数量发生了变化 if(count != savedCount) { updateOptionButtons(); - Q_EMIT notifyOptionsChange(count, at_bioBtn); - if(at_bioBtn && count >= 1) - tabOptionSelected(FirstDevice); + Q_EMIT notifyOptionsChange(count); updateUIStatus(); } } @@ -811,7 +753,6 @@ void LoginOptionsWidget::updateUIStatus() btn->setChecked(true); } } - if (m_curDevInfo) { if (m_mapOptBtns.contains(m_curDevInfo->id)) { QPushButton* btn = m_mapOptBtns[m_curDevInfo->id]; @@ -822,140 +763,28 @@ void LoginOptionsWidget::updateUIStatus() } } -void LoginOptionsWidget::onOptionSelected(int nIndex, bool keyNavigation) +void LoginOptionsWidget::onOptionSelected(int nIndex) { if (nIndex < 0) return; - if(!keyNavigation) - tabOptionSelected(CLEAR); + if (nIndex < m_listDriveId.size()) { DeviceInfoPtr info = findDeviceById(m_listDriveId[nIndex]); if (info && !isDeviceDisable(info->id)) { - Q_EMIT optionSelected(convertDeviceType(info->deviceType), info, keyNavigation); + Q_EMIT optionSelected(convertDeviceType(info->deviceType), info); }else if(nIndex == 0 && m_listDriveId[nIndex] == -1){ stopAuth(); m_curDevInfo = nullptr; - Q_EMIT optionSelected(LOGINOPT_TYPE_PASSWORD, nullptr, keyNavigation); + Q_EMIT optionSelected(LOGINOPT_TYPE_PASSWORD,nullptr); }else if(m_listDriveId[nIndex] == -2){ //存在ukey特征,但未插入ukey stopAuth(); m_curDevInfo = nullptr; - Q_EMIT optionSelected(LOGINOPT_TYPE_GENERAL_UKEY, nullptr, keyNavigation); + Q_EMIT optionSelected(LOGINOPT_TYPE_GENERAL_UKEY,nullptr); } } } -void LoginOptionsWidget::tabOptionSelected(int option) -{ - switch(option) { - case RIGHT: - { - at_bioBtn = true; - int nCur = nowAt; - if(nCur >= 0 && nCur < m_listDriveId.count()) { - if (m_mapOptBtns.contains(m_listDriveId[nCur])) { - QPushButton* btn = m_mapOptBtns[m_listDriveId[nCur]]; - if (btn) { - btn->setStyleSheet(ON_NORMAL_SHEET); - } - } - } - for (int n = 0; n < m_listDriveId.count(); n ++) { - nCur = nCur + 1; - if (nCur >= m_listDriveId.count()) - nCur = 0; - if (m_mapOptBtns.contains(m_listDriveId[nCur])) { - QPushButton* btn = m_mapOptBtns[m_listDriveId[nCur]]; - if (btn && btn->isVisible()) { - btn->setStyleSheet(ON_TAB_SHEET); - nowAt = nCur; - break; - } - } - } - } - break; - case LEFT: - { - at_bioBtn = true; - int nCur = nowAt; - if(nCur >= 0 && nCur < m_listDriveId.count()) { - if (m_mapOptBtns.contains(m_listDriveId[nCur])) { - QPushButton* btn = m_mapOptBtns[m_listDriveId[nCur]]; - if (btn) { - btn->setStyleSheet(ON_NORMAL_SHEET); - } - } - } - for (int n = 0; n < m_listDriveId.count(); n ++) { - nCur = nCur - 1; - if (nCur < 0) - nCur = m_listDriveId.count() - 1; - if (m_mapOptBtns.contains(m_listDriveId[nCur])) { - QPushButton* btn = m_mapOptBtns[m_listDriveId[nCur]]; - if (btn && btn->isVisible()) { - btn->setStyleSheet(ON_TAB_SHEET); - nowAt = nCur; - break; - } - } - } - } - break; - case CLEAR: - at_bioBtn = false; - if(nowAt >= 0) { - for (int n = 0; n < m_listDriveId.count(); n ++) { - if (m_mapOptBtns.contains(m_listDriveId[n])) { - QPushButton* btn = m_mapOptBtns[m_listDriveId[n]]; - if (btn) { - btn->setStyleSheet(ON_NORMAL_SHEET); - } - } - } - nowAt = -1; - } - break; - case FirstDevice: - at_bioBtn = true; - if(nowAt >= 0) { - for (int n = 0; n < m_listDriveId.count(); n ++) { - if (m_mapOptBtns.contains(m_listDriveId[n])) { - QPushButton* btn = m_mapOptBtns[m_listDriveId[n]]; - if (btn) { - btn->setStyleSheet(ON_NORMAL_SHEET); - } - } - } - int nCur = 0; - for (int n = 0; n < m_listDriveId.count(); n ++) { - nCur = nCur + 1; - if (nCur >= m_listDriveId.count()) - nCur = 0; - if (m_mapOptBtns.contains(m_listDriveId[nCur])) { - QPushButton* btn = m_mapOptBtns[m_listDriveId[nCur]]; - if (btn && btn->isVisible()) { - btn->setStyleSheet(ON_TAB_SHEET); - nowAt = nCur; - break; - } - } - } - nowAt = 0; - } - break; - case CLICK: - at_bioBtn = false; - if (nowAt >= 0 && nowAt < m_listDriveId.count() && m_mapOptBtns.contains(m_listDriveId[nowAt])) { - QPushButton* btn = m_mapOptBtns[m_listDriveId[nowAt]]; - if (btn) { - onOptionSelected(nowAt, true); - } - } - break; - } -} - int LoginOptionsWidget::convertDeviceType(int nDevType) { int nLoginOptType = LOGINOPT_TYPE_OTHERS; @@ -1098,7 +927,7 @@ bool LoginOptionsWidget::getBioAuthEnable(int nType) return false; } } else { - return GetAuthEnable(); + return true; } } @@ -1107,7 +936,7 @@ bool LoginOptionsWidget::getQRCodeEnable() if (m_uniauthService && m_uniauthService->isActivatable()) { return m_uniauthService->getQRCodeEnable(); } else { - return GetQRCodeEnable(); + return true; } } @@ -1124,7 +953,7 @@ QString LoginOptionsWidget::getDefaultDevice(QString strUserName,int bioType) } return defaultDeviceName; } else { - return GetDefaultDevice(strUserName); + return ""; } } @@ -1144,7 +973,7 @@ QString LoginOptionsWidget::getDefaultDevice(QString strUserName) } return QString(defaultDeviceName); } else { - return GetDefaultDevice(strUserName); + return ""; } } @@ -1185,3 +1014,27 @@ LoginAuthInterface* LoginOptionsWidget::getCustomLoginAuth() } return dynamic_cast(PluginsLoader::instance().findModulesByType(LoginPluginInterface::MODULETYPE_AUTH).values().first()); } + +QString LoginOptionsWidget::getDeviceType_tr(int deviceType) +{ + switch(deviceType) + { + case BioT_FingerPrint: + return tr("FingerPrint"); + case BioT_FingerVein: + return tr("FingerVein"); + case BioT_Iris: + return tr("Iris"); + case BioT_Face: + return tr("Face"); + case BioT_VoicePrint: + return tr("VoicePrint"); + case UniT_General_Ukey: + return tr("Ukey"); + case UniT_Remote: + return tr("QRCode"); + default: + return ""; + } +} + diff --git a/src/loginoptionswidget.h b/src/widgets/loginoptionswidget.h similarity index 63% rename from src/loginoptionswidget.h rename to src/widgets/loginoptionswidget.h index 17c128f..7e9047a 100644 --- a/src/loginoptionswidget.h +++ b/src/widgets/loginoptionswidget.h @@ -1,73 +1,34 @@ -/* - * Copyright (C) 2022 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * -**/ #ifndef LOGINOPTIONSWIDGET_H #define LOGINOPTIONSWIDGET_H #include -#include "biometricproxy.h" -#include "biometricdeviceinfo.h" +#include "../dbusifs/biometrichelper.h" #include "uniauthservice.h" #include "loginauthinterface.h" +#include "definetypes.h" class QLabel; -class KLabel; class QButtonGroup; class QHBoxLayout; class QVBoxLayout; class QPushButton; class QTimer; class QPixmap; -class Configuration; - -typedef enum { - BioT_FingerPrint, /** 指纹 **/ - BioT_FingerVein, /** 指静脉 **/ - BioT_Iris, /** 虹膜 **/ - BioT_Face, /** 人脸 **/ - BioT_VoicePrint, /** 声纹 **/ - - UniT_KCM, /** 安全管控 **/ - UniT_General_Ukey, /** 普通的Ukey **/ - UniT_Advanced_Ukey, /** 高阶的Ukey **/ - UniT_Remote, /** 远程账户 **/ - UniT_Custom = 0xFFFF /** 第三方 **/ -}BioType; - -enum OPTION{ - RIGHT = 0, - LEFT, - CLEAR, - CLICK, - FirstDevice, -}; +class KLabel; #define CUSTOM_PLUGIN_DEV_PREFIX ("Custom:") +typedef QMap DeviceListMap; + class LoginOptionsWidget : public QWidget { Q_OBJECT public: - explicit LoginOptionsWidget(BiometricProxy* proxy, int uid, UniAuthService* uniauthService, QWidget *parent = nullptr); + explicit LoginOptionsWidget(BiometricHelper *bioHelper, int uid, UniAuthService *uniauthService, QWidget *parent = nullptr); virtual ~LoginOptionsWidget(); bool getCurLoginOpt(int& nLoginOptType, int& nDrvId); unsigned getLoginOptCount(); - DeviceInfoPtr getFirstDevInfo(); DeviceInfoPtr getWechatDevice(); int convertDeviceType(int nDevType); @@ -81,14 +42,14 @@ public: bool isDeviceDisable(int nDevId); bool getBioAuthEnable(int nType); bool getQRCodeEnable(); - QString getDefaultDevice(QString strUserName); QString getDefaultDevice(QString strUserName,int biotype); + QString getDefaultDevice(QString strUserName); QStringList getAllDefDevices(); void SetExtraInfo(QString extra_info,QString info_type); bool getHasUkeyOptions(); void setSelectedPassword(); void updateUIStatus(); - int getVisibleLoginOptCount(); + inline DeviceListMap getUserDevices() { return m_mapDevices; } QString getCustomDevName(); /** @@ -110,28 +71,31 @@ public: bool isAuthenticating() { return m_isInAuth; } + QPixmap loadSvg(QString path, QString color, int size); LoginAuthInterface* getCustomLoginAuth(); - QPixmap loadSvg(QString path, QString color, int size); -public Q_SLOTS: +public slots: void readDevicesInfo(); void onIdentifyComplete(QDBusPendingCallWatcher *watcher); void onUkeyIdentifyComplete(QDBusPendingCallWatcher *watcher); void onStatusChanged(int drvid, int status); void onFrameWritten(int drvid); void onUSBDeviceHotPlug(int drvid, int action, int devNum); - void onOptionSelected(int nIndex, bool keyNavigation = false); - void tabOptionSelected(int option); + void onOptionSelected(int nIndex); -Q_SIGNALS: - void notifyOptionsChange(unsigned uOptionsCount, bool is_bioBtn); - void optionSelected(unsigned uLoginOptType, const DeviceInfoPtr &deviceInfo, bool keyNavigation); +protected: + bool eventFilter(QObject *obj, QEvent *event); + +signals: + void notifyOptionsChange(unsigned uOptionsCount); + void optionSelected(unsigned uLoginOptType, const DeviceInfoPtr &deviceInfo); void updateImage(QImage img); void authComplete(bool bResult, int nStatus); void updateAuthMsg(QString strMsg); + void showKToolTipClicked(const QString text); + void hideKTooltipClicked(); void setLoadingImage(); - void deviceCountChanged(int num); void customPluginMsg(QString strMsg); private: @@ -144,18 +108,23 @@ private: void startUkeyAuth(); bool getAuthDouble(); QPixmap drawSymbolicColoredPixmap(QPixmap &source, QString cgColor); + QString getDeviceType_tr(int deviceType); + + void changeEvent(QEvent *event); + void refreshTranslate(); private: - BiometricProxy* m_biomericProxy = nullptr; - DeviceMap m_mapDevices; + BiometricHelper* m_biomericProxy = nullptr; + DeviceListMap m_mapDevices; unsigned m_curLoginOptType = LOGINOPT_TYPE_PASSWORD; int m_uid; QString m_strUserName; DeviceInfoPtr m_curDevInfo = nullptr; // 当前选择的设备信息 int m_dupFD = -1; // 透传的图像文件句柄 - bool m_isInAuth = false; // 是否正在验证 + bool m_isInAuth = false; // 是否正在验证 bool m_isStopped = false; // 是否被强制终止 QTimer *m_retrytimer = nullptr; // 重试定时器 + double curFontSize; // UI QVBoxLayout *m_layoutMain = nullptr; @@ -166,14 +135,12 @@ private: QList m_listDriveId; QMap m_mapOptBtns; QMap> m_mapDisableDev; - int nowAt = -1; - bool at_bioBtn = false; + + //ToolTip + QStringList nameList; UniAuthService *m_uniauthService = nullptr; QList m_listPriority; - Configuration *configuration; - double curFontSize = 0; - double m_ptToPx = 1.0; - QFont sysFont; + bool isShowUkey = false; }; diff --git a/src/loginplugininterface.h b/src/widgets/loginplugininterface.h similarity index 100% rename from src/loginplugininterface.h rename to src/widgets/loginplugininterface.h diff --git a/src/widgets/mylistwidget.cpp b/src/widgets/mylistwidget.cpp new file mode 100644 index 0000000..b63b34d --- /dev/null +++ b/src/widgets/mylistwidget.cpp @@ -0,0 +1,123 @@ +#include "mylistwidget.h" +#include +#include + +MyListWidget::MyListWidget(QWidget *parent) : QListWidget(parent) +{ + installEventFilter(this); + setFocusPolicy(Qt::TabFocus); +} + +void MyListWidget::setUserListWidget(bool isUserListWidget) +{ + m_isUserListWidget = isUserListWidget; +} + +bool MyListWidget::eventFilter(QObject *obj, QEvent *event) +{ + if (this->flow() == Flow::TopToBottom) { + /*在收到快捷键按下后,首先会收到keypress事件,随后会收到一个ShortcutOverride的快捷键响应事件, + * 收到这个事件后会把listWidget的currentRow往后移一个,随后才会收到keyrelease事件。*/ + if (event->type() == QEvent::KeyPress) { //先记录按键按下时的currentRow + m_lastRow = this->currentRow(); + } + if (event->type() == QEvent::KeyRelease) { + QKeyEvent *keyEvent = static_cast(event); + switch (keyEvent->key()) { + case Qt::Key_Up: + case Qt::Key_PageUp: + if (this->currentRow() == 0 && m_lastRow == 0) /*收到按键释放信号时,判断当前currentRow与按键按下时记录的currentRow是否一致*/ + this->setCurrentRow(this->count() - 1); + break; + case Qt::Key_Down: + case Qt::Key_PageDown: + if (this->currentRow() == this->count() - 1 && m_lastRow == this->count() - 1) + this->setCurrentRow(0); + break; + case Qt::Key_HomePage: + this->setCurrentRow(0); + break; + case Qt::Key_End: + this->setCurrentRow(this->count() - 1); + + break; + case Qt::Key_Enter: + case Qt::Key_Return: + Q_EMIT itemClicked(currentItem()); + default: + break; + } + } + } else { + /*在收到快捷键按下后,首先会收到keypress事件,随后会收到一个ShortcutOverride的快捷键响应事件, + * 收到这个事件后会把listWidget的currentRow往后移一个,随后才会收到keyrelease事件。*/ + if (event->type() == QEvent::KeyPress) { //先记录按键按下时的currentRow + m_lastRow = this->currentRow(); + } + if (event->type() == QEvent::KeyRelease) { + QKeyEvent *keyEvent = static_cast(event); + switch (keyEvent->key()) { + case Qt::Key_Left: + if (this->currentRow() == m_lastRow) { /*收到按键释放信号时,判断当前currentRow与按键按下时记录的currentRow是否一致*/ + for (int i = this->count() - 1; i >= 0; i--) { + if (!this->isRowHidden(i)) { + this->setCurrentRow(i); + break; + } + } + this->setCurrentRow(this->count() - 1); + } + break; + case Qt::Key_Right: + if (this->currentRow() == this->count() - 1 && m_lastRow == this->count() - 1) { + for (int i = 0; i < this->count(); i++) { + if (!this->isRowHidden(i)) { + this->setCurrentRow(i); + break; + } + } + } + break; + case Qt::Key_Home: + for (int i = 0; i < this->count(); i++) { + if (!this->isRowHidden(i)) { + this->setCurrentRow(i); + break; + } + } + break; + case Qt::Key_End: + this->setCurrentRow(this->count() - 1); + break; + case Qt::Key_Enter: + case Qt::Key_Return: + Q_EMIT itemClicked(currentItem()); + break; + default: + break; + } + } + } + if (event->type() == QEvent::FocusOut) { //焦点丢失,记录当前焦点所在item,清空选中状态 + if (!m_isUserListWidget) { + for (int i = 0; i < this->count(); i++) { + if (!this->isRowHidden(i)) { + this->setCurrentRow(i, QItemSelectionModel::SelectionFlag::Clear); + //焦点丢失时不会主动发送当前item改变的信号,需要手动发送 + Q_EMIT currentItemChanged(this->currentItem(), this->item(i)); + break; + } + } + } else { + this->setCurrentRow(this->currentRow(), QItemSelectionModel::SelectionFlag::Clear); + //焦点丢失时不会主动发送当前item改变的信号,需要手动发送 + Q_EMIT currentItemChanged(this->currentItem(), this->currentItem()); + } + } else if (event->type() == QEvent::MouseButtonRelease) { //鼠标点击设置选中状态 + + } else if (event->type() == QEvent::FocusIn) { //焦点进入设置选中状态 + + } + + return QListWidget::eventFilter(obj, event); +} diff --git a/src/widgets/mylistwidget.h b/src/widgets/mylistwidget.h new file mode 100644 index 0000000..cf2b31b --- /dev/null +++ b/src/widgets/mylistwidget.h @@ -0,0 +1,22 @@ +#ifndef MYLISTWIDGET_H +#define MYLISTWIDGET_H +#include +#include + +class MyListWidget : public QListWidget +{ + Q_OBJECT +public: + MyListWidget(QWidget *parent = nullptr); + void setUserListWidget(bool isUserListWidget); + +protected: + bool eventFilter(QObject *obj, QEvent *event); + +private: + // 标志位,记录前一个选中的item + int m_lastRow = -1; + bool m_isUserListWidget = false; +}; + +#endif // MYLISTWIDGET_H diff --git a/src/widgets/mynetworkwidget.cpp b/src/widgets/mynetworkwidget.cpp new file mode 100644 index 0000000..b9b8a6a --- /dev/null +++ b/src/widgets/mynetworkwidget.cpp @@ -0,0 +1,236 @@ +#include "mynetworkwidget.h" +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "mytabwidget.h" + +MyNetworkWidget::MyNetworkWidget(QWidget *parent) : QWidget(parent) +{ + setObjectName("m_networkWidget"); + setStyleSheet("#m_networkWidget{background-color: white; border-radius:12px;}"); + loadNetPlugin(); +} + +void MyNetworkWidget::loadNetPlugin() +{ + if(netloader.isLoaded() || wlanloader.isLoaded()) + return ; + + if(!tabWidget){ + tabWidget = new MyTabWidget(this); + tabWidget->setObjectName("tabwidget"); + tabWidget->setFixedSize(420,480); + tabWidget->tabBar()->setFixedHeight(40); + tabWidget->installEventFilter(this); + + QHBoxLayout *m_tabBarLayout = new QHBoxLayout(tabWidget); + m_tabBarLayout->setContentsMargins(0,0,0,0); + QLabel *m_lanLabel = new QLabel(tr("LAN")); + m_lanLabel->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter); + QLabel *m_wlanLabel = new QLabel(tr("WLAN")); + m_wlanLabel->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter); + m_tabBarLayout->addWidget(m_lanLabel); + m_tabBarLayout->addWidget(m_wlanLabel); + tabWidget->tabBar()->setLayout(m_tabBarLayout); + tabWidget->tabBar()->setFixedWidth(420); + } + + netloader.setFileName("/usr/lib/kylin-nm/libnetconnect.so"); //有线 + wlanloader.setFileName("/usr/lib/kylin-nm/libwlanconnect.so");//无线 + + //如果要修改插件加载顺序,涉及mkylinNM控件index的都需要修改 + if (netloader.load()) { + QObject * plugin = netloader.instance(); + + if (plugin) { + netInterface = qobject_cast(plugin); + // 插件是否启用 + if (!netInterface) { + return; + } + + netInterface->setPluginType(SIMPLE); + QWidget *widget = netInterface->pluginUi(); + tabWidget->addTab(widget,""); + //connect(plugin, SIGNAL(updatePluginHidden(bool)), this, SLOT(onUpdatePluginHidden(bool))); + } else { + qDebug() << "Load Failed: " << netloader.errorString() << "\n"; + return; + } + } else { + qDebug() << "Load Failed: " << netloader.errorString() << "\n"; + return; + } + + if (wlanloader.load()) { + QObject * plugin = wlanloader.instance(); + + if (plugin) { + wlanInterface = qobject_cast(plugin); + // 插件是否启用 + if (!wlanInterface) { + return; + } + + wlanInterface->setPluginType(SIMPLE); + + /*这里需要先调用setParentWidget,否则会出现网络连接弹窗无法弹出来的问题*/ + wlanInterface->setParentWidget(this); + QWidget *widget = wlanInterface->pluginUi(); + tabWidget->addTab(widget,""); + //connect(plugin, SIGNAL(updatePluginHidden(bool)), this, SLOT(onUpdatePluginHidden(bool))); + + } else { + qDebug() << "Load Failed: " << wlanloader.errorString() << "\n"; + return; + } + } else { + qDebug() << "Load Failed: " << wlanloader.errorString() << "\n"; + return; + } + + QPalette pal = qApp->palette(); + pal.setBrush(QPalette::Background, Qt::white); + // m_kylinNM->setPalette(pal); + tabWidget->widget(0)->setPalette(pal); + tabWidget->widget(1)->setPalette(pal); + + setGeometry(this->width() - tabWidget->width() - 20, + this->height() - tabWidget->height() - 72 - 8, + tabWidget->width(), + tabWidget->height()); + + connect(tabWidget, &MyTabWidget::currentChanged, + this, &MyNetworkWidget::onNetTabWidgetChanged); + + onUpdatePluginHidden(); + +} + +void MyNetworkWidget::unloadNetPlugin() +{ + if(wlanloader.isLoaded()){ + tabWidget->removeTab(1); + wlanloader.unload(); + } + + if(netloader.isLoaded()){ + tabWidget->removeTab(0); + netloader.unload(); + } + + if(tabWidget){ + tabWidget->hide(); + tabWidget->deleteLater(); + tabWidget = nullptr; + } + + if(tabWidget){ + tabWidget->hide(); + tabWidget->deleteLater(); + tabWidget = nullptr; + } +} + +void MyNetworkWidget::onNetTabWidgetChanged(int index) +{ +/* + if(index == 0){ + if(netInterface) + netInterface->setWidgetVisable(true); + if(wlanInterface){ + wlanInterface->setWidgetVisable(false); + } + }else if(index == 1){ + if(netInterface) + netInterface->setWidgetVisable(false); + if(wlanInterface) + wlanInterface->setWidgetVisable(true); + } +*/ +} + +void MyNetworkWidget::onUpdatePluginHidden() +{ +/* + if (netInterface && + m_netTabShow != netInterface->checkPluginIsHidden()) { + if (m_netTabShow) { + tabWidget->removeTab(0); + } else { + tabWidget->insertTab(0, netWidget, ""); + } + m_netTabShow = !m_netTabShow; + } + if (wlanInterface && + m_wlanTabShow != wlanInterface->checkPluginIsHidden()) { + if (m_wlanTabShow) { + if (m_netTabShow) + tabWidget->removeTab(1); + else + tabWidget->removeTab(0); + } else { + if (m_netTabShow) + tabWidget->insertTab(1, wlanWidget, ""); + else + tabWidget->insertTab(0, wlanWidget, ""); + + } + m_wlanTabShow = !m_wlanTabShow; + } + if (m_netTabShow && m_wlanTabShow) { + tabWidget->tabBar()->show(); + } else { + tabWidget->tabBar()->hide(); + } +*/ +} + +void MyNetworkWidget::sendNetPluginVisible(bool visible) +{ +/* + if(!tabWidget) + return; + if(tabWidget->currentIndex() == 0 && netInterface){ + netInterface->setWidgetVisable(visible); + }else if(tabWidget->currentIndex() == 1 && wlanInterface){ + wlanInterface->setWidgetVisable(visible); + } +*/ +} + +void MyNetworkWidget::showEvent(QShowEvent *event) +{ + sendNetPluginVisible(true); +} + +void MyNetworkWidget::hideEvent(QHideEvent *event) +{ + sendNetPluginVisible(false); +} + +void MyNetworkWidget::paintEvent(QPaintEvent *p1) +{ + //绘制样式 + QStyleOption opt; + opt.initFrom(this); + QPainter p(this); + style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);//绘制样式 + + QBitmap bmp(this->size()); + bmp.fill(); + QPainter painter(&bmp); + painter.setPen(Qt::NoPen); + painter.setBrush(Qt::white); + painter.setRenderHint(QPainter::Antialiasing); + painter.drawRoundedRect(bmp.rect(), 12, 12); + setMask(bmp); +} diff --git a/src/widgets/mynetworkwidget.h b/src/widgets/mynetworkwidget.h new file mode 100644 index 0000000..542746f --- /dev/null +++ b/src/widgets/mynetworkwidget.h @@ -0,0 +1,48 @@ +#ifndef MYNETWORKWIDGET_H +#define MYNETWORKWIDGET_H + +#include +#include + +class Interface; +class MyTabWidget; +class MyNetworkWidget : public QWidget +{ + Q_OBJECT +public: + explicit MyNetworkWidget(QWidget *parent = nullptr); + +private Q_SLOTS: + /** + * @brief 网络窗口有线和无线弹窗切换事件,用于通知网络插件窗口切换 + * @param index 当前页面索引 + * @return + */ + void onNetTabWidgetChanged(int index); + void onUpdatePluginHidden(); + void showEvent(QShowEvent *event) ; + void hideEvent(QHideEvent *event) ; + void paintEvent(QPaintEvent *p1); + +private: + void loadNetPlugin(); + void unloadNetPlugin(); + void sendNetPluginVisible(bool visible); + + QPluginLoader netloader; + QPluginLoader wlanloader; + + Interface *netInterface = nullptr; + Interface *wlanInterface = nullptr; + + MyTabWidget *tabWidget = nullptr; + + QWidget *netWidget = nullptr; + QWidget *wlanWidget = nullptr; + bool m_netTabShow = true; + bool m_wlanTabShow = true; + + +}; + +#endif // WIDGET_H diff --git a/src/widgets/mytabwidget.cpp b/src/widgets/mytabwidget.cpp new file mode 100644 index 0000000..2f03f0a --- /dev/null +++ b/src/widgets/mytabwidget.cpp @@ -0,0 +1,28 @@ +#include "mytabwidget.h" +#include +#include +#include + +MyTabWidget::MyTabWidget(QWidget *parent) : QTabWidget(parent) +{ + + +} + +void MyTabWidget::paintEvent(QPaintEvent *p1) +{ + //绘制样式 + QStyleOption opt; + opt.initFrom(this); + QPainter p(this); + style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);//绘制样式 + + QBitmap bmp(this->size()); + bmp.fill(); + QPainter painter(&bmp); + painter.setPen(Qt::NoPen); + painter.setBrush(Qt::black); + painter.setRenderHint(QPainter::Antialiasing); + painter.drawRoundedRect(bmp.rect(), 12, 12); + setMask(bmp); +} diff --git a/src/widgets/mytabwidget.h b/src/widgets/mytabwidget.h new file mode 100644 index 0000000..65ff60a --- /dev/null +++ b/src/widgets/mytabwidget.h @@ -0,0 +1,18 @@ +#ifndef MYTABWIDGET_H +#define MYTABWIDGET_H + +#include +#include + +class MyTabWidget : public QTabWidget +{ + Q_OBJECT +public: + explicit MyTabWidget(QWidget *parent = nullptr); + void paintEvent(QPaintEvent *event); + +signals: + +}; + +#endif // WIDGET_H diff --git a/src/widgets/networkbutton.cpp b/src/widgets/networkbutton.cpp new file mode 100644 index 0000000..2900d15 --- /dev/null +++ b/src/widgets/networkbutton.cpp @@ -0,0 +1,83 @@ +#include "networkbutton.h" +#include +#include +#include + +NetWorkButton::NetWorkButton(QWidget *parent) + : KyNetworkIcon(parent) +{ + setFixedSize(48, 48); + setIconSize(QSize(24, 24)); + setFocusPolicy(Qt::NoFocus); +} + +void NetWorkButton::setClickedStatus(int status) +{ + curStatus = status; + update(); +} + +void NetWorkButton::paintEvent(QPaintEvent *e) +{ + Q_UNUSED(e); + QStylePainter painter(this); + painter.setRenderHint(QPainter::Antialiasing); + QStyleOptionButton option; + initStyleOption(&option); + +// if (curStatus == NORMAL) { +// painter.save(); +// painter.setPen(Qt::NoPen); +// painter.setBrush(Qt::white); +// painter.setOpacity(0); +// painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6); +// painter.restore(); +// } + +// if (option.state & QStyle::State_MouseOver) { +// painter.save(); +// painter.setPen(Qt::NoPen); +// painter.setBrush(Qt::white); +// painter.setOpacity(0.25); +// painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6); +// painter.restore(); +// } + + if (curStatus == CLICKED) { + painter.save(); + painter.setPen(Qt::NoPen); + painter.setBrush(Qt::white); + painter.setOpacity(0.35); + painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6); + painter.restore(); + } + + if (curStatus == SELECT) { + painter.save(); + painter.setPen(Qt::NoPen); + painter.setBrush(Qt::white); + painter.setOpacity(0.25); + painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6); + painter.restore(); + + painter.save(); + QStyleOption opt; + QColor color = opt.palette.color(QPalette::Highlight); + painter.setPen(QPen(color, 2)); + painter.setBrush(Qt::NoBrush); + painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6); + painter.restore(); + } + QPushButton::paintEvent(e); + +} + +void NetWorkButton::mouseReleaseEvent(QMouseEvent *e) +{ + e->ignore(); +} + +void NetWorkButton::mousePressEvent(QMouseEvent *e) +{ + e->ignore(); +} diff --git a/src/widgets/networkbutton.h b/src/widgets/networkbutton.h new file mode 100644 index 0000000..31742d8 --- /dev/null +++ b/src/widgets/networkbutton.h @@ -0,0 +1,27 @@ +#ifndef NETWORKBUTTON_H +#define NETWORKBUTTON_H + +#include +#include +#include "statusbutton.h" + +class NetWorkButton : public KyNetworkIcon +{ + Q_OBJECT +public: + explicit NetWorkButton(QWidget *parent = 0); + /** + * @brief 设置按钮当前状态 + * @param selected 是否选中 + * @return + */ + void setClickedStatus(int status); +protected: + void paintEvent(QPaintEvent *e) override; + void mouseReleaseEvent(QMouseEvent *e); + void mousePressEvent(QMouseEvent *e); +private: + int curStatus = NORMAL; +}; + +#endif // NETWORKBUTTON_H diff --git a/src/pluginsloader.cpp b/src/widgets/pluginsloader.cpp similarity index 100% rename from src/pluginsloader.cpp rename to src/widgets/pluginsloader.cpp diff --git a/src/pluginsloader.h b/src/widgets/pluginsloader.h similarity index 100% rename from src/pluginsloader.h rename to src/widgets/pluginsloader.h diff --git a/src/widgets/poweritemwidget.cpp b/src/widgets/poweritemwidget.cpp new file mode 100644 index 0000000..64e89cc --- /dev/null +++ b/src/widgets/poweritemwidget.cpp @@ -0,0 +1,56 @@ +#include +#include +#include +#include "poweritemwidget.h" +#include "statusbutton.h" + +PowerItemWidget::PowerItemWidget(QWidget *parent) + : QFrame(parent) +{ + itemFace = new StatusButton(this, POWERBUTTON); + itemFace->setFixedSize(130, 130); + textLabel = new QLabel(this); + textLabel->setAlignment(Qt::AlignCenter); + textLabel->setStyleSheet("color: white"); + QVBoxLayout *itemlayout = new QVBoxLayout(this); + itemlayout->addWidget(itemFace); + itemlayout->addWidget(textLabel); + itemlayout->setAlignment(Qt::AlignHCenter); +} + +PowerItemWidget::~PowerItemWidget() +{ + +} + +bool PowerItemWidget::eventFilter(QObject *obj, QEvent *event) +{ + if (event->type() == QEvent::ToolTip) { + + } else if (event->type() == QEvent::Leave) { + + } + return QWidget::eventFilter(obj, event); +} + + + +void PowerItemWidget::setText(const QString text) +{ + textLabel->setText(text); +} + +void PowerItemWidget::setToolTip(const QString tip) +{ + itemFace->setToolTip(tip); +} + +void PowerItemWidget::setIcon(const QIcon &icon) +{ + itemFace->setIcon(icon); +} + +void PowerItemWidget::setSelected(int status) +{ + itemFace->setClickedStatus(status); +} diff --git a/src/widgets/poweritemwidget.h b/src/widgets/poweritemwidget.h new file mode 100644 index 0000000..039d1cf --- /dev/null +++ b/src/widgets/poweritemwidget.h @@ -0,0 +1,41 @@ +#ifndef POWERITEMWIDGET_H +#define POWERITEMWIDGET_H + +#include +#include + +class StatusButton; + +class PowerItemWidget : public QFrame +{ + Q_OBJECT + +public: + explicit PowerItemWidget(QWidget *parent = 0); + ~PowerItemWidget(); + void setText(const QString text); + void setToolTip(const QString tip); + void setIcon(const QIcon &icon); + /** + * @brief 设置按钮当前状态 + * @param selected 是否选中 + * @return + */ + void setSelected(int status); + +protected: + bool eventFilter(QObject *obj, QEvent *event); + +Q_SIGNALS: + /** + * @brief 响应点击事件 + * @return + */ + void clicked(); + +private: + StatusButton *itemFace = nullptr; + QLabel *textLabel = nullptr; +}; + +#endif // POWERITEMWIDGET_H diff --git a/src/widgets/powerlistwidget.cpp b/src/widgets/powerlistwidget.cpp new file mode 100644 index 0000000..875c1ac --- /dev/null +++ b/src/widgets/powerlistwidget.cpp @@ -0,0 +1,141 @@ +#include +#include "powerlistwidget.h" + +PowerListWidget::PowerListWidget(LockDialogModel *model ,QWidget *parent) + : m_modelLockDialog(model), + MyListWidget(parent) +{ + initBtnShowFlag(); + initUI(); + initConnections(); +} + +PowerListWidget::~PowerListWidget() +{ + +} + +bool PowerListWidget::eventFilter(QObject *obj, QEvent *event) +{ + if (event->type() == QEvent::KeyRelease) { + MyListWidget *listWidget = qobject_cast(obj); + if (listWidget) { + if (listWidget && listWidget->hasFocus()) { //Tab键切入时,设置焦点状态 + listWidget->setCurrentRow(listWidget->currentRow(), QItemSelectionModel::SelectionFlag::SelectCurrent); + listWidget->currentItemChanged(listWidget->currentItem(), nullptr); + } else { //Tab键切出时,清空焦点状态 + listWidget->setCurrentRow(listWidget->currentRow(), QItemSelectionModel::SelectionFlag::Clear); + } + } + } + return MyListWidget::eventFilter(obj, event); +} + +void PowerListWidget::initUI() +{ + setFlow(QListWidget::LeftToRight); + setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + QString powerListStyle = "QListWidget{background:rgba(255, 255, 255, 0%); border: 0px;}" + "QListWidget::item{background:rgba(255, 255, 255, 0%);}"; + setStyleSheet(powerListStyle); + setFixedSize(QSize(BTN_ITEM_SIZE_WIDTH*sizeof(powerBtnList)/sizeof(powerBtnList[0])+1, BTN_ITEM_SIZE_HEIGHT)); +// powerBtnList[0].func = &PowerListWidget::setSystemSuspend1(); + onUpdateListInfo(); +} + +void PowerListWidget::initConnections() +{ + connect(this, &PowerListWidget::itemClicked, this, &PowerListWidget::onListItemClicked); + +} +void PowerListWidget::initBtnShowFlag() +{ + for (int i = 0; i < sizeof(powerBtnList)/sizeof(powerBtnList[0]) ; i++) + { + if (powerBtnList[i].canFuncName == QString("CanPowerOff")) + powerBtnList[i].m_show_flag = m_modelLockDialog->getCanPowerOff(); + + if (powerBtnList[i].canFuncName == QString("CanSuspend")) + powerBtnList[i].m_show_flag = m_modelLockDialog->getCanSuspend(); + + if (powerBtnList[i].canFuncName == QString("CanReboot")) + powerBtnList[i].m_show_flag = m_modelLockDialog->getCanReboot(); + + if (powerBtnList[i].canFuncName == QString("CanHibernate")) + powerBtnList[i].m_show_flag = m_modelLockDialog->getCanHibernate(); + + } + +} + +void PowerListWidget::onUpdateListInfo() +{ + this->clear(); + + for (int i = 0; i < sizeof(powerBtnList)/sizeof(powerBtnList[0]) ; i++) + { + qWarning() << __LINE__ << __FUNCTION__<< "11111111111" << i << powerBtnList[i].m_strName << powerBtnList[i].m_show_flag ; + if (!powerBtnList[i].m_show_flag) + continue; + + PowerItemWidget *btnWdg = new PowerItemWidget(this); + btnWdg->setObjectName(powerBtnList[i].m_strName); + QListWidgetItem *btnItem = new QListWidgetItem(); + btnItem->setSizeHint(QSize(powerBtnList[i].m_item_width, powerBtnList[i].m_item_height)); + + this->insertItem(this->count(), btnItem); + this->setItemWidget(btnItem, btnWdg); + btnWdg->setText(powerBtnList[i].m_strName); + btnWdg->setToolTip(powerBtnList[i].m_strToolTip); + btnWdg->setIcon(QIcon(powerBtnList[i].m_strIcon).pixmap(powerBtnList[i].m_icon_width, powerBtnList[i].m_icon_width)); + } +} + +void PowerListWidget::onListItemClicked(QListWidgetItem *item) +{ + qWarning() << __FUNCTION__ << __LINE__ ; + QWidget *widget = itemWidget(item); + PowerItemWidget *currentItem = qobject_cast(widget); + for (int i = 0; i < sizeof(powerBtnList)/sizeof(powerBtnList[0]) ; i++) + { + if(powerBtnList[i].m_strName == currentItem->objectName()) + { + if (powerBtnList[i].setFuncName == "Hibernate" || powerBtnList[i].setFuncName == "Suspend") { + QStringList sleepLockcheck = m_modelLockDialog->getSleepLockcheck(); + if (!sleepLockcheck.isEmpty()) { + Q_EMIT showInhibitWarning(sleepLockcheck, powerBtnList[i].m_inhibitType); + break; + } + } + if (powerBtnList[i].setFuncName == "Reboot" || powerBtnList[i].setFuncName == "PowerOff") { + QStringList shutdownLockcheck = m_modelLockDialog->getShutdownLockcheck(); + if (shutdownLockcheck.count() > 0) { + Q_EMIT showInhibitWarning(shutdownLockcheck, powerBtnList[i].m_inhibitType); + break; + } else if (m_modelLockDialog->getLoggedInUsersCount() > 1) { + Q_EMIT mulUsersLogined(powerBtnList[i].m_strName); + break; + } + } + qWarning() << __LINE__ << "=================" << powerBtnList[i].setFuncName << __FUNCTION__; + Q_EMIT m_modelLockDialog->setPowerManager(powerBtnList[i].setFuncName); + break; + } + } +} + +void PowerListWidget::updateWidgetSize() +{ + if (count() * 40 + 10 > maximumHeight()) { + setFixedHeight(maximumHeight()); + } else { + setFixedHeight(count() * 40 + 10); + } + adjustSize(); +} + +void PowerListWidget::setSystemPowerStatus(QString statusName) +{ + qWarning() << __LINE__ << __FUNCTION__ << statusName; + +} diff --git a/src/widgets/powerlistwidget.h b/src/widgets/powerlistwidget.h new file mode 100644 index 0000000..c64baea --- /dev/null +++ b/src/widgets/powerlistwidget.h @@ -0,0 +1,150 @@ +#ifndef POWERLISTWIDGET_H +#define POWERLISTWIDGET_H + +#include +#include +#include +#include +#include +#include +#include + +#include "mylistwidget.h" +#include "poweritemwidget.h" +#include "lock-dialog/lockdialogmodel.h" + +class MyListWidget; +class PowerItemWidget; +class QListWidgetItem; +class LockDialogModel; +#define LISTSZIE(x) (sizeof(x)/sizeof(x[0])) +//电源管理界面 +#define BTN_ITEM_SIZE_WIDTH 204 +#define BTN_ITEM_SIZE_HEIGHT 200 +#define BTN_ICON_SIZE_WIDTH 48 +#define BTN_ICON_SIZE_HEIGHT 48 + +enum stateType { + REBOOT, + SHUTDOWN, + SLEEP, + HIBERNATE, + NOTHING +}; + +class PowerListWidget : public MyListWidget +{ + Q_OBJECT +public: + + explicit PowerListWidget(LockDialogModel *model,QWidget *parent = nullptr); + ~PowerListWidget(); + LockDialogModel * m_modelLockDialog; + + void updateWidgetSize(); + void setSystemSuspend1(); + + struct Btn_Data_Struct { + QString m_strName; + QString m_strToolTip; + QString m_strIcon; + bool m_show_flag; + + int m_item_width; + int m_item_height; + int m_icon_width; + int m_icon_height; + QString canFuncName; + QString setFuncName; + int m_inhibitType; +// void (*func)(); + } powerBtnList[4] = { + //1.Hibernate + { + .m_strName = tr("Hibernate"), + .m_strToolTip = tr("Turn off your computer, but the app stays open. When the computer is turned on, it can be restored to the state you left"), + .m_strIcon = ":/image/assets/hibernate.svg", + .m_show_flag = true, + .m_item_width = BTN_ITEM_SIZE_WIDTH, + .m_item_height = BTN_ITEM_SIZE_HEIGHT, + .m_icon_width = BTN_ICON_SIZE_WIDTH, + .m_icon_height = BTN_ICON_SIZE_HEIGHT, + .canFuncName = "CanHibernate", + .setFuncName = "Hibernate", + .m_inhibitType = HIBERNATE + }, + //2.Suspend + { + .m_strName = tr("Suspend"), + .m_strToolTip = tr("The computer stays on, but consumes less power. The app stays open and can quickly wake up and revert to where you left off"), + .m_strIcon = ":/image/assets/suspend.svg", + .m_show_flag = true, + .m_item_width = BTN_ITEM_SIZE_WIDTH, + .m_item_height = BTN_ITEM_SIZE_HEIGHT, + .m_icon_width = BTN_ICON_SIZE_WIDTH, + .m_icon_height = BTN_ICON_SIZE_HEIGHT, + .canFuncName = "CanSuspend", + .setFuncName = "Suspend", + .m_inhibitType = SLEEP + }, + //3.reboot + { + .m_strName = tr("Reboot"), + .m_strToolTip = tr("The computer stays on, but consumes less power. The app stays open and can quickly wake up and revert to where you left off"), + .m_strIcon = ":/image/assets/reboot.svg", + .m_show_flag = true, + .m_item_width = BTN_ITEM_SIZE_WIDTH, + .m_item_height = BTN_ITEM_SIZE_HEIGHT, + .m_icon_width = BTN_ICON_SIZE_WIDTH, + .m_icon_height = BTN_ICON_SIZE_HEIGHT, + .canFuncName = "CanReboot", + .setFuncName = "Reboot", + .m_inhibitType = REBOOT + }, + //4.Shut Down + { + .m_strName = tr("Power Off"), + .m_strToolTip = tr("Close all apps, and then shut down your computer"), + .m_strIcon = ":/image/assets/shutdown.svg", + .m_show_flag = true, + .m_item_width = BTN_ITEM_SIZE_WIDTH, + .m_item_height = BTN_ITEM_SIZE_HEIGHT, + .m_icon_width = BTN_ICON_SIZE_WIDTH, + .m_icon_height = BTN_ICON_SIZE_HEIGHT, + .canFuncName = "CanPowerOff", + .setFuncName = "PowerOff", + .m_inhibitType = SHUTDOWN + } + }; + + void setSystemPowerStatus(QString); + +protected: + bool eventFilter(QObject *obj, QEvent *event); + +Q_SIGNALS: + void mulUsersLogined(QString inhibitType); + void showInhibitWarning(QStringList list, int type); + +public Q_SLOTS: + void onUpdateListInfo(); + void onListItemClicked(QListWidgetItem *item); + +private: + +// QDBusInterface *sessionInterface; +// QDBusInterface *loginInterface; + + bool m_canSuspend; + bool m_canHibernate; + bool m_canReboot ; + bool m_canShutDown ; + + void initUI(); + void initBtnShowFlag(); + void initConnections(); +// void initDBusInterface(); + +}; + +#endif // POWERLISTWIDGET_H diff --git a/src/screensavermode.cpp b/src/widgets/screensaver.cpp similarity index 99% rename from src/screensavermode.cpp rename to src/widgets/screensaver.cpp index 37eab3c..744d33b 100644 --- a/src/screensavermode.cpp +++ b/src/widgets/screensaver.cpp @@ -15,7 +15,7 @@ * along with this program; if not, see . * **/ -#include "screensavermode.h" +#include "screensaver.h" #include #include #include diff --git a/src/screensavermode.h b/src/widgets/screensaver.h similarity index 95% rename from src/screensavermode.h rename to src/widgets/screensaver.h index 51c738e..2476042 100644 --- a/src/screensavermode.h +++ b/src/widgets/screensaver.h @@ -15,8 +15,8 @@ * along with this program; if not, see . * **/ -#ifndef SCREENSAVER_MODE_H -#define SCREENSAVER_MODE_H +#ifndef SCREENSAVER_H +#define SCREENSAVER_H #include #include @@ -74,4 +74,4 @@ Q_DECLARE_METATYPE(ScreenSaver) QDebug &operator<<(QDebug stream, const ScreenSaver &screensaver); -#endif // SCREENSAVER_MODE_H +#endif // SCREENSAVER_H diff --git a/src/screensaverwidget.cpp b/src/widgets/screensaverwidget.cpp similarity index 76% rename from src/screensaverwidget.cpp rename to src/widgets/screensaverwidget.cpp index 36bd944..ed5987a 100644 --- a/src/screensaverwidget.cpp +++ b/src/widgets/screensaverwidget.cpp @@ -24,7 +24,6 @@ #include #include #include -#include "screensaver.h" #include #include ScreenSaverWidget::ScreenSaverWidget(ScreenSaver *screensaver, QWidget *parent) @@ -34,10 +33,10 @@ ScreenSaverWidget::ScreenSaverWidget(ScreenSaver *screensaver, QWidget *parent) closing(false) { qDebug() << "ScreenSaverWidget::ScreenSaverWidget"; - setAttribute(Qt::WA_DeleteOnClose); setMouseTracking(true); setFocus(); this->installEventFilter(this); + setAttribute(Qt::WA_DeleteOnClose); QPalette pal(palette()); pal.setColor(QPalette::Background, Qt::black); //设置背景黑色 @@ -106,7 +105,7 @@ void ScreenSaverWidget::paintEvent(QPaintEvent *event) if(!screensaver->exists()) { QPainter painter(this); - painter.fillRect(0,0,this->width(),this->height(), Qt::black); + painter.fillRect(geometry(), Qt::black); } if(screensaver->mode == SAVER_IMAGE) { switch(screensaver->effect) { @@ -115,7 +114,7 @@ void ScreenSaverWidget::paintEvent(QPaintEvent *event) QPixmap pixmap(screensaver->path); pixmap.scaled(size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); QPainter painter(this); - painter.drawPixmap(0,0,this->width(),this->height(), pixmap); + painter.drawPixmap(geometry(), pixmap); break; } case TRANSITION_FADE_IN_OUT: @@ -124,15 +123,17 @@ void ScreenSaverWidget::paintEvent(QPaintEvent *event) QPixmap pixmap1(screensaver->lastPath); pixmap1.scaled(size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); painter.setOpacity(opacity); - painter.drawPixmap(0,0,this->width(),this->height(), pixmap1); + painter.drawPixmap(geometry(), pixmap1); QPixmap pixmap(screensaver->path); pixmap.scaled(size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); painter.setOpacity(1 - opacity); - painter.drawPixmap(0,0,this->width(),this->height(), pixmap); + painter.drawPixmap(geometry(), pixmap); break; } } + + } return QWidget::paintEvent(event); } @@ -141,9 +142,7 @@ bool ScreenSaverWidget::eventFilter(QObject *obj, QEvent *event) { if(event->type() == 23) { - if(QX11Info::isPlatformX11()){ - XSetInputFocus(QX11Info::display(),this->winId(),RevertToParent,CurrentTime); - } + XSetInputFocus(QX11Info::display(),this->winId(),RevertToParent,CurrentTime); } return false; } @@ -151,30 +150,12 @@ bool ScreenSaverWidget::eventFilter(QObject *obj, QEvent *event) /* Embed xscreensavers */ void ScreenSaverWidget::embedXScreensaver(const QString &path) { - qDebug()<<"embedXScreensaver path = "<mode == SAVER_SINGLE){ - QString cmd = path + " -window-id " + QString::number(winId()); - if(process.state() == QProcess::NotRunning) - process.start(cmd); - }else if(screensaver->mode == SAVER_DEFAULT || screensaver->mode == SAVER_DEFAULT_CUSTOM){ - if(!m_screensaver){ - m_screensaver = new Screensaver(true,this); - //m_screensaver->resize(1366,768); - //m_screensaver->setGeometry(this->geometry()); - // m_screensaver->setGeometry(0,0,1920,1080); - - } - } + QString cmd = path + " -window-id " + QString::number(winId()); + if(process.state() == QProcess::NotRunning) + process.start(cmd); } -void ScreenSaverWidget::resizeEvent(QResizeEvent *event) -{ - if(m_screensaver){ - m_screensaver->setGeometry(0,0,this->width(),this->height()); - } -} + void ScreenSaverWidget::onBackgroundChanged(const QString &/*path*/) { diff --git a/src/screensaverwidget.h b/src/widgets/screensaverwidget.h similarity index 91% rename from src/screensaverwidget.h rename to src/widgets/screensaverwidget.h index 7099cba..a76d428 100644 --- a/src/screensaverwidget.h +++ b/src/widgets/screensaverwidget.h @@ -20,9 +20,8 @@ #include #include -#include "screensavermode.h" +#include "screensaver.h" -class Screensaver; class ScreenSaverWidget : public QWidget { Q_OBJECT @@ -35,7 +34,6 @@ protected: void closeEvent(QCloseEvent *); void paintEvent(QPaintEvent *event); bool eventFilter(QObject *obj, QEvent *event); - void resizeEvent(QResizeEvent *event); private: void embedXScreensaver(const QString &path); @@ -48,7 +46,6 @@ private: bool closing; float opacity; QProcess process; - Screensaver *m_screensaver = nullptr; }; #endif // SCREENSAVERWIDGET_H diff --git a/src/widgets/sessionitemwidget.cpp b/src/widgets/sessionitemwidget.cpp new file mode 100644 index 0000000..c1e9860 --- /dev/null +++ b/src/widgets/sessionitemwidget.cpp @@ -0,0 +1,102 @@ +/* + * Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * +**/ +#include "sessionitemwidget.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include "commonfunc.h" + +#define PREFIX QString(RESOURCE_PATH) +#define IMAGE_DIR PREFIX+"/images/" + +SessionItemWidget::SessionItemWidget(QWidget *parent) : + QWidget(parent) +{ + setAttribute(Qt::WA_DeleteOnClose); + init(); + initIconLabel(); +} + +SessionItemWidget::~SessionItemWidget() +{ + +} + +bool SessionItemWidget::eventFilter(QObject *obj, QEvent *event) +{ + return QWidget::eventFilter(obj, event); +} + +void SessionItemWidget::paintEvent(QPaintEvent *event){ + Q_UNUSED(event) + QStyleOption opt; + opt.init(this); + QPainter p(this); + style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); +} + +void SessionItemWidget::init() +{ + QHBoxLayout* layout = new QHBoxLayout(); + layout->setAlignment(Qt::AlignCenter); + layout->setContentsMargins(8, 4, 8, 4); + layout->setSpacing(4); + m_labelImg = new QLabel(this); + m_labelName = new QLabel(this); + m_labelName->setFixedSize(184, 32); + layout->addWidget(m_labelImg); + layout->addWidget(m_labelName); + setLayout(layout); +} + +void SessionItemWidget::initIconLabel() +{ + m_labelImg->setFixedSize(32, 32); +} + +void SessionItemWidget::setSessionName(QString name) +{ + QString sessionPrefix = name.left(name.indexOf('-')); + if(name == "ukui-wayland") + sessionPrefix = "ukui_wayland"; + m_strImgPath = IMAGE_DIR + QString("badges/%1_badge.svg") + .arg(sessionPrefix.toLower()); + QFile iconFile(m_strImgPath); + if(!iconFile.exists()){ + m_strImgPath = IMAGE_DIR + QString("badges/unknown_badge.svg"); + } + qDebug()<<"setSessionName icon:"<setPixmap(ssIcon); + m_strSessionName = name; + m_labelName->setText(m_strSessionName); +} + +void SessionItemWidget::setSessionType(int nType) +{ + m_nSessionType = nType; +} diff --git a/src/widgets/sessionitemwidget.h b/src/widgets/sessionitemwidget.h new file mode 100644 index 0000000..1f53afc --- /dev/null +++ b/src/widgets/sessionitemwidget.h @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * +**/ +#ifndef SESSIONITEMWIDGET_H +#define SESSIONITEMWIDGET_H + +#include +#include + +class userLabel; +class QLabel; +class QPixmap; + +class SessionItemWidget : public QWidget +{ + Q_OBJECT + +public: + SessionItemWidget(QWidget *parent = 0); + ~SessionItemWidget(); + /** + * @brief 设置会话名 + * @param name 会话名 + * @return + */ + void setSessionName(QString name); + /** + * @brief 设置会话类型 + * @param nType 会话类型 + * @return + */ + void setSessionType(int nType); + + inline QString sessionName() { return m_strSessionName; } + + inline QString sessionImgPath() { return m_strImgPath; } + +protected: + bool eventFilter(QObject *obj, QEvent *event); + virtual void paintEvent(QPaintEvent * event); + +private: + void init(); + void initIconLabel(); + +Q_SIGNALS: + void enterWidget(); + void leaveWidget(); + +private: + QLabel *m_labelImg = nullptr; + QLabel* m_labelName = nullptr; + QString m_strSessionName; + int m_nSessionType; + QString m_strImgPath; +}; + +#endif // SESSIONITEMWIDGET_H diff --git a/src/widgets/sessionlistwidget.cpp b/src/widgets/sessionlistwidget.cpp new file mode 100644 index 0000000..308cfef --- /dev/null +++ b/src/widgets/sessionlistwidget.cpp @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * +**/ +#include "sessionlistwidget.h" +#include +#include "sessionitemwidget.h" + +SessionListWidget::SessionListWidget(LockDialogModel *model, QWidget *parent) + : MyListWidget(parent) + , m_modelLockDialog(model) +{ + initUI(); + initConnections(); +} + +void SessionListWidget::initUI() +{ + QString userListStyle = "QListWidget{ background-color: rgb(255,255,255,15%); border-radius: 8px; padding: 5px 5px 5px 5px;}" + "QListWidget::item{background:rgb(255,255,255,0%);height:40px; border-radius:4px}" + "QListWidget::item:hover{color:#333333; background-color:rgb(255,255,255,20%)}" + "QListWidget::item::selected{border-radius: 4px;background-color:rgb(255,255,255,40%);}"; + setStyleSheet(userListStyle); + setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + verticalScrollBar()->setProperty("drawScrollBarGroove", false); + + onUpdateListInfo(); +} + +void SessionListWidget::initConnections() +{ + // 响应点击事件 + connect(this, &SessionListWidget::itemClicked, this, &SessionListWidget::onListItemClicked); + + connect(m_modelLockDialog, &LockDialogModel::usersInfoChanged, this, &SessionListWidget::onUpdateListInfo); +} + +void SessionListWidget::onUpdateListInfo() +{ + this->clear(); + for (auto session : m_modelLockDialog->sessionsInfo()) { + QListWidgetItem *userItem = new QListWidgetItem(); + userItem->setSizeHint(QSize(240, 40)); + insertItem(count(), userItem); + SessionItemWidget *itemWidget = new SessionItemWidget(this); + itemWidget->setSessionName(session); + setItemWidget(userItem, itemWidget); + } +} + +void SessionListWidget::onListItemClicked(QListWidgetItem *item) +{ + QWidget *widget = itemWidget(item); + SessionItemWidget *currentItem = qobject_cast(widget); + if (currentItem) { + Q_EMIT sessionSelected(currentItem->sessionName()); + } +} + +void SessionListWidget::updateWidgetSize() +{ + if (count() * 40 + 10 > maximumHeight()) { + setFixedHeight(maximumHeight()); + } else { + setFixedHeight(count() * 40 + 10); + } + adjustSize(); +} diff --git a/src/digitalkeyboard.h b/src/widgets/sessionlistwidget.h similarity index 55% rename from src/digitalkeyboard.h rename to src/widgets/sessionlistwidget.h index 4a386fe..3d1c5fd 100644 --- a/src/digitalkeyboard.h +++ b/src/widgets/sessionlistwidget.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. + * Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -15,34 +15,35 @@ * along with this program; if not, see . * **/ -#ifndef DIGITALKEYBOARD_H -#define DIGITALKEYBOARD_H +#ifndef SESSIONLISTWIDGET_H +#define SESSIONLISTWIDGET_H #include -#include -#include +#include "lock-dialog/lockdialogmodel.h" +#include "mylistwidget.h" -class DigitalKeyBoard : public QWidget +class QListWidgetItem; +class SessionListWidget : public MyListWidget { Q_OBJECT - public: - explicit DigitalKeyBoard(QWidget *parent = nullptr); + explicit SessionListWidget(LockDialogModel *model, QWidget *parent = nullptr); + + void updateWidgetSize(); public Q_SLOTS: - void onKeyReleaseEvent(QKeyEvent *event); + void onUpdateListInfo(); + void onListItemClicked(QListWidgetItem *item); Q_SIGNALS: - void numbersButtonPress(int btn_id); + void sessionSelected(QString strSession); private: void initUI(); - void initConnect(); - void setQSS(); + void initConnections(); private: - QPushButton *m_pNumerPressBT[12]; // 0~9 是数字按键 10是删除键 11是清空键 + LockDialogModel *m_modelLockDialog = nullptr; }; -#endif // DIGITALKEYBOARD_H - +#endif // SESSIONLISTWIDGET_H diff --git a/src/widgets/statusbutton.cpp b/src/widgets/statusbutton.cpp new file mode 100644 index 0000000..f74424d --- /dev/null +++ b/src/widgets/statusbutton.cpp @@ -0,0 +1,176 @@ +#include "statusbutton.h" +#include + +#include + +StatusButton::StatusButton(QWidget *parent, int type) : QPushButton(parent) +{ + buttonType = type; + if (buttonType == BIOBUTTON || type == BOTBUTTON) { + setFixedSize(48, 48); + setIconSize(QSize(24, 24)); + } else if (buttonType == POWERBUTTON) { + setFixedSize(130, 130); + setIconSize(QSize(48, 48)); + } + this->setFocusPolicy(Qt::NoFocus); +} + +void StatusButton::setClickedStatus(int status) +{ + curStatus = status; + update(); +} + +void StatusButton::setDrivedId(int drivedId) +{ + m_drivedId = drivedId; +} + +void StatusButton::paintEvent(QPaintEvent *e) +{ + Q_UNUSED(e); + QStylePainter painter(this); + painter.setRenderHint(QPainter::Antialiasing); + QStyleOptionButton option; + initStyleOption(&option); + + if (option.state & QStyle::State_Sunken) { + painter.save(); + painter.setPen(Qt::NoPen); + painter.setBrush(Qt::white); + switch (buttonType) { + case BOTBUTTON: + painter.setOpacity(0); + painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6); + break; + case BIOBUTTON: + painter.setOpacity(0.1); + painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6); + break; + case POWERBUTTON: + painter.setOpacity(0.1); + painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 65, 65); + break; + default: + painter.setOpacity(0); + painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6); + break; + } + painter.restore(); + } + + if (option.state & QStyle::State_MouseOver) { + painter.save(); + painter.setPen(Qt::NoPen); + painter.setBrush(Qt::white); + painter.setOpacity(0.25); + switch (buttonType) { + case BOTBUTTON: + case BIOBUTTON: + painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6); + break; + case POWERBUTTON: + painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 65, 65); + break; + default: + painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6); + break; + } + painter.restore(); + } + + if (curStatus == CLICKED) { + painter.save(); + painter.setPen(Qt::NoPen); + painter.setBrush(Qt::white); + painter.setOpacity(0.35); + switch (buttonType) { + case BOTBUTTON: + case BIOBUTTON: + painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6); + break; + case POWERBUTTON: + painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 65, 65); + break; + default: + painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6); + break; + } + painter.restore(); + } + + if (curStatus == SELECT) { + painter.save(); + painter.setPen(Qt::NoPen); + painter.setBrush(Qt::white); + painter.setOpacity(0.25); + switch (buttonType) { + case BOTBUTTON: + case BIOBUTTON: + painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6); + break; + case POWERBUTTON: + painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 65, 65); + break; + default: + painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6); + break; + } + painter.restore(); + painter.save(); + QStyleOption opt; + QColor color = opt.palette.color(QPalette::Highlight); + painter.setPen(QPen(color, 2)); + painter.setBrush(Qt::NoBrush); + switch (buttonType) { + case BOTBUTTON: + case BIOBUTTON: + painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6); + break; + case POWERBUTTON: + painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 65, 65); + break; + default: + painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6); + break; + } + painter.restore(); + } + + // 绘制图片 + int buttonWidget = this->width(); + int buttonHeight = this->height(); + QRect buttonRect(0, 0, buttonWidget, buttonHeight); + + QPixmap pixmap = option.icon.pixmap(option.iconSize, QIcon::Active); + int pixmapWidth = static_cast(pixmap.width()); + int pixmapHeight = static_cast(pixmap.height()); + QRect pixmapRect(0, 0, pixmapWidth, pixmapHeight); + + int deltaX = 0; + int deltaY = 0; + if (pixmapRect.width() < buttonRect.width()) + deltaX = buttonRect.width() - pixmapRect.width(); + else + deltaX = pixmapRect.width() - buttonRect.width(); + if (pixmapRect.height() < buttonRect.height()) + deltaY = buttonRect.height() - pixmapRect.height(); + else + deltaY = pixmapRect.height() - buttonRect.height(); + + painter.save(); + painter.translate(deltaX / 2, deltaY / 2); + painter.drawPixmap(pixmapRect, pixmap); + painter.restore(); +} + +void StatusButton::mouseReleaseEvent(QMouseEvent *e) +{ + e->ignore(); +} + +void StatusButton::mousePressEvent(QMouseEvent *e) +{ + e->ignore(); +} diff --git a/src/widgets/statusbutton.h b/src/widgets/statusbutton.h new file mode 100644 index 0000000..fe7fa5f --- /dev/null +++ b/src/widgets/statusbutton.h @@ -0,0 +1,58 @@ +#ifndef STATUSBUTTON_H +#define STATUSBUTTON_H + +#include +#include +#include +#include +#include +#include + +enum BUTTONSTATUS { + NORMAL, + HOVER, + SELECT, + CLICKED, +}; + +enum BUTTONTYPE { + BOTBUTTON, + BIOBUTTON, + POWERBUTTON, +}; + +class StatusButton : public QPushButton +{ + Q_OBJECT +public: + explicit StatusButton(QWidget *parent = nullptr, int type = BOTBUTTON); + /** + * @brief 设置按钮当前状态 + * @param selected 是否选中 + * @return + */ + void setClickedStatus(int status); + + void setDrivedId(int drivedId); + + inline int getDrivedId() { return m_drivedId; } + inline int getButtonTyoe() { return buttonType; } +protected: + void paintEvent(QPaintEvent *e) override; + void mouseReleaseEvent(QMouseEvent *e); + void mousePressEvent(QMouseEvent *e); +Q_SIGNALS: + /** + * @brief 响应点击事件 + * @return + */ + void clicked(); + void buttonClicked(int drivedId); + +private: + int curStatus = NORMAL; + int buttonType; + int m_drivedId; +}; + +#endif // STATUSBUTTON_H diff --git a/src/widgets/timewidget.cpp b/src/widgets/timewidget.cpp new file mode 100644 index 0000000..ea34ff9 --- /dev/null +++ b/src/widgets/timewidget.cpp @@ -0,0 +1,87 @@ +#include "timewidget.h" + +#define TIME_FONT_SIZE 36 +#define TIME_DATE_SIZE 18 +#define TIMEWIDGET_SIZE 400,100 + +TimeWidget::TimeWidget(QWidget *parent) : QWidget(parent) +{ + this->setMinimumSize(TIMEWIDGET_SIZE); + + QVBoxLayout *m_VBLayout = new QVBoxLayout(this); + + m_t_label = new KLabel(this); + m_t_label->setAlignment(Qt::AlignCenter); + m_t_label->setFontSize(TIME_FONT_SIZE); + m_t_label->setStyleSheet("QLabel{color: white;}" + "QToolTip{border-radius:4px; background-color:#FFFFFF; color:black;}"); + m_t_label->setText(getLongFormatDate(TIME)); + m_t_label->adjustSize(); + + m_d_label = new KLabel(this); + m_d_label->setAlignment(Qt::AlignCenter); + m_d_label->setStyleSheet("QLabel{color: white;}" + "QToolTip{border-radius:4px; background-color:#FFFFFF; color:black;}"); + m_d_label->setText(getLongFormatDate(DATE)); + m_d_label->setFontSize(TIME_DATE_SIZE); + m_d_label->adjustSize(); + + m_VBLayout->addWidget(m_t_label); + m_VBLayout->addWidget(m_d_label); + this->setLayout(m_VBLayout); + this->adjustSize(); + + m_timer = new QTimer(this); + connect(m_timer, SIGNAL(timeout()), this, SLOT(update_datatime())); + this->timerStart(); +} + +TimeWidget::~TimeWidget() +{ + m_timer->deleteLater(); +} + +void TimeWidget::updateUI() +{ + this->setFixedSize(this->width()*scale, this->height()*scale); +} + +void TimeWidget::timerStart() +{ + m_timer->start(1000); +} + +void TimeWidget::timerStop() +{ + m_timer->stop(); +} + +QString TimeWidget::getLongFormatDate(int type) +{ + kdk_logn_dateinfo *dateInfo = kdk_system_login_lock_dateinfo(getenv("USER")); + if (type == DATE) + { + QString date = dateInfo->date; + QString week = dateInfo->week; + if (dateInfo) + { + kdk_free_logn_dateinfo(dateInfo); + } + return date + " " + week; + } + else if (type == TIME) + { + QString time = dateInfo->time; + if (dateInfo) + { + kdk_free_logn_dateinfo(dateInfo); + } + return time; + } +} + +void TimeWidget::update_datatime() +{ + m_t_label->setText(getLongFormatDate(TIME)); + m_d_label->setText(getLongFormatDate(DATE)); +} diff --git a/src/widgets/timewidget.h b/src/widgets/timewidget.h new file mode 100644 index 0000000..74c1232 --- /dev/null +++ b/src/widgets/timewidget.h @@ -0,0 +1,48 @@ +#ifndef TIMEWIDGET_H +#define TIMEWIDGET_H + +#include +#include +#include +#include +#include +#include + +#include +#include "klabel.h" + +enum dateinfo { + DATE, + TIME, +}; + + +extern float scale; +class TimeWidget : public QWidget +{ + Q_OBJECT +public: + explicit TimeWidget(QWidget *parent = nullptr); + ~TimeWidget(); + void updateUI(); + +Q_SIGNALS: + +public Q_SLOTS: + void update_datatime(); + void timerStart(); + void timerStop(); + +private: + + QString getLongFormatDate(int type); + + +private: + QTimer * m_timer = nullptr; + KLabel * m_t_label = nullptr; + KLabel * m_d_label = nullptr; + +}; + +#endif // TIMEWIDGET_H diff --git a/src/widgets/useritemwidget.cpp b/src/widgets/useritemwidget.cpp new file mode 100644 index 0000000..ce3fd3b --- /dev/null +++ b/src/widgets/useritemwidget.cpp @@ -0,0 +1,95 @@ +#include "useritemwidget.h" + +#include +#include +#include +#include +#include +#include +#include +#include "commonfunc.h" + +UserItemWidget::UserItemWidget(QWidget *parent) : + QWidget(parent) +{ + setAttribute(Qt::WA_DeleteOnClose); + init(); + initIconLabel(); +} + +UserItemWidget::~UserItemWidget() +{ + +} + +bool UserItemWidget::eventFilter(QObject *obj, QEvent *event) +{ + return QWidget::eventFilter(obj, event); +} + +void UserItemWidget::paintEvent(QPaintEvent *event){ + Q_UNUSED(event) + QStyleOption opt; + opt.init(this); + QPainter p(this); + style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); +} + +void UserItemWidget::init() +{ + QHBoxLayout* layout = new QHBoxLayout(); + layout->setAlignment(Qt::AlignCenter); + layout->setContentsMargins(8, 4, 8, 4); + layout->setSpacing(4); + m_labelHeadImg = new QLabel(this); + m_labelNickName = new QLabel(this); + m_labelNickName->setFixedSize(184, 32); + layout->addWidget(m_labelHeadImg); + layout->addWidget(m_labelNickName); + setLayout(layout); +} + +void UserItemWidget::initIconLabel() +{ + m_labelHeadImg->setFixedSize(32, 32); + QVBoxLayout *layoutImg = new QVBoxLayout(m_labelHeadImg); + layoutImg->setContentsMargins(18, 0, 0, 18); + layoutImg->setAlignment(Qt::AlignCenter); + m_labelLoggedIn = new QLabel(this); + layoutImg->addWidget(m_labelLoggedIn); +} + +void UserItemWidget::setUserName(QString name) +{ + m_strUserName = name; +} + +QString UserItemWidget::getUserName() +{ + return m_strUserName; +} + +void UserItemWidget::setUserNickName(QString strNickName) +{ + m_strNickName = strNickName; + m_labelNickName->setText(strNickName); +} + +void UserItemWidget::setUserPixmap(QPixmap userIcon) +{ + userIcon = scaledPixmap(userIcon); + userIcon = userIcon.scaled(32, 32, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + userIcon = PixmapToRound(userIcon, 16); + m_labelHeadImg->setPixmap(userIcon); +} + +void UserItemWidget::setUserStatus(bool status) +{ + if (status) { + QPixmap status(":/image/assets/selected.svg"); + status = scaledPixmap(status); + status = status.scaled(14,14, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + status = PixmapToRound(status, 7); + m_labelLoggedIn->setPixmap(status); + } +} diff --git a/src/widgets/useritemwidget.h b/src/widgets/useritemwidget.h new file mode 100644 index 0000000..47f1f94 --- /dev/null +++ b/src/widgets/useritemwidget.h @@ -0,0 +1,71 @@ +#ifndef USERITEMWIDGET_H +#define USERITEMWIDGET_H + +#include +#include + +class userLabel; +class QLabel; +class QPixmap; + +class UserItemWidget : public QWidget +{ + Q_OBJECT + +public: + UserItemWidget(QWidget *parent = 0); + ~UserItemWidget(); + /** + * @brief 设置用户名 + * @param name 用户名 + * @return + */ + void setUserName(QString name); + /** + * @brief 设置用户头像 + * @param userIcon 用户头像 + * @return + */ + void setUserPixmap(QPixmap userIcon); + /** + * @brief 设置用户登录状态 + * @param status 登录状态 + * @return + */ + void setUserStatus(bool status); + /** + * @brief 获取用户名 + * @return QString 用户名 + */ + QString getUserName(); + + void setUserNickName(QString strNickName); + inline QString userNickName() { return m_strNickName; } + +protected: + bool eventFilter(QObject *obj, QEvent *event); + virtual void paintEvent(QPaintEvent * event); + +private: + void init(); + void initIconLabel(); + +Q_SIGNALS: + void enterWidget(); + void leaveWidget(); + /** + * @brief 响应点击事件 + * @param userName 用户名 + * @return + */ + void clicked(QString m_strUserName); + +private: + QLabel *m_labelHeadImg = nullptr; + QLabel* m_labelNickName = nullptr; + QLabel* m_labelLoggedIn = nullptr; + QString m_strUserName; + QString m_strNickName; +}; + +#endif // USERITEMWIDGET_H diff --git a/src/widgets/userlistwidget.cpp b/src/widgets/userlistwidget.cpp new file mode 100644 index 0000000..2968b79 --- /dev/null +++ b/src/widgets/userlistwidget.cpp @@ -0,0 +1,72 @@ +#include "userlistwidget.h" +#include +#include "useritemwidget.h" + +UserListWidget::UserListWidget(LockDialogModel *model, QWidget *parent) + : MyListWidget(parent) + , m_modelLockDialog(model) +{ + initUI(); + initConnections(); + setUserListWidget(true); +} + +void UserListWidget::initUI() +{ + QString userListStyle = "QListWidget{ background-color: rgb(255,255,255,15%); border-radius: 8px; padding: 5px 5px 5px 5px;}" + "QListWidget::item{background:rgb(255,255,255,0%);height:40px; border-radius:4px}" + "QListWidget::item:hover{color:#333333; background-color:rgb(255,255,255,20%)}" + "QListWidget::item::selected{border-radius: 4px;background-color:rgb(255,255,255,40%);}"; + setStyleSheet(userListStyle); + setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + verticalScrollBar()->setProperty("drawScrollBarGroove", false); + + onUpdateListInfo(); +} + +void UserListWidget::initConnections() +{ + // 响应点击事件 + connect(this, &UserListWidget::itemClicked, this, &UserListWidget::onListItemClicked); + + connect(m_modelLockDialog, &LockDialogModel::usersInfoChanged, this, &UserListWidget::onUpdateListInfo); +} + +void UserListWidget::onUpdateListInfo() +{ + this->clear(); + for (auto user : m_modelLockDialog->usersInfo()) { + QListWidgetItem *userItem = new QListWidgetItem(); + userItem->setSizeHint(QSize(240, 40)); + insertItem(count(), userItem); + UserItemWidget *itemWidget = new UserItemWidget(this); + QPixmap p(user->headImage()); + itemWidget->setUserPixmap(p); + itemWidget->setUserNickName(user->fullName()); + itemWidget->setUserStatus(user->isLoggedIn()); + if (user->fullName() == m_modelLockDialog->currentUserName()) { + setCurrentItem(userItem, QItemSelectionModel::SelectionFlag::SelectCurrent); + } + itemWidget->setUserName(user->name()); + setItemWidget(userItem, itemWidget); + } +} + +void UserListWidget::onListItemClicked(QListWidgetItem *item) +{ + QWidget *widget = itemWidget(item); + UserItemWidget *currentItem = qobject_cast(widget); + if (currentItem) { + Q_EMIT userSelected(currentItem->getUserName()); + } +} + +void UserListWidget::updateWidgetSize() +{ + if (count() * 40*scale + 10*scale > maximumHeight()) { + setFixedHeight(maximumHeight()); + } else { + setFixedHeight(count() * 40*scale + 10*scale); + } + adjustSize(); +} diff --git a/src/widgets/userlistwidget.h b/src/widgets/userlistwidget.h new file mode 100644 index 0000000..596bed6 --- /dev/null +++ b/src/widgets/userlistwidget.h @@ -0,0 +1,34 @@ +#ifndef USERLISTWIDGET_H +#define USERLISTWIDGET_H + +#include +#include "lock-dialog/lockdialogmodel.h" +#include "mylistwidget.h" + +class QListWidgetItem; + +extern float scale; +class UserListWidget : public MyListWidget +{ + Q_OBJECT +public: + explicit UserListWidget(LockDialogModel *model, QWidget *parent = nullptr); + + void updateWidgetSize(); + +public Q_SLOTS: + void onUpdateListInfo(); + void onListItemClicked(QListWidgetItem *item); + +Q_SIGNALS: + void userSelected(QString strUserName); + +private: + void initUI(); + void initConnections(); + +private: + LockDialogModel *m_modelLockDialog = nullptr; +}; + +#endif // USERLISTWIDGET_H diff --git a/src/xeventmonitor.cpp b/src/xeventmonitor.cpp deleted file mode 100644 index 9eca744..0000000 --- a/src/xeventmonitor.cpp +++ /dev/null @@ -1,208 +0,0 @@ -/* -*- Mode: C++; indent-tabs-mode: nil; tab-width: 4 -*- - * -*- coding: utf-8 -*- - * - * Copyright (C) 2011 ~ 2017 Deepin, Inc. - * 2011 ~ 2017 Wang Yong - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * Author: Wang Yong - * Maintainer: Wang Yong - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include "xeventmonitor.h" -#include -#include -#include -#include -#include - -// Virtual button codes that are not defined by X11. -#define Button1 1 -#define Button2 2 -#define Button3 3 -#define WheelUp 4 -#define WheelDown 5 -#define WheelLeft 6 -#define WheelRight 7 -#define XButton1 8 -#define XButton2 9 - -class XEventMonitorPrivate -{ -public: - XEventMonitorPrivate(XEventMonitor *parent); - virtual ~XEventMonitorPrivate(); - void run(); - -protected: - XEventMonitor *q_ptr; - - bool filterWheelEvent(int detail); - static void callback(XPointer trash, XRecordInterceptData* data); - void handleRecordEvent(XRecordInterceptData *); - void emitButtonSignal(const char *member, xEvent *event); - void emitKeySignal(const char *member, xEvent *event); - -private: - Q_DECLARE_PUBLIC(XEventMonitor) -}; - -XEventMonitorPrivate::XEventMonitorPrivate(XEventMonitor *parent) - : q_ptr(parent) -{ - -} - -XEventMonitorPrivate::~XEventMonitorPrivate() -{ - -} - -void XEventMonitorPrivate::emitButtonSignal(const char *member, xEvent *event) -{ - int x = event->u.keyButtonPointer.rootX; - int y = event->u.keyButtonPointer.rootY; - QMetaObject::invokeMethod(q_ptr, member, - Qt::DirectConnection, - Q_ARG(int, x), - Q_ARG(int, y)); -} - -void XEventMonitorPrivate::emitKeySignal(const char *member, xEvent *event) -{ - if(QX11Info::display()){ - int keyCode = event->u.u.detail; - KeySym keySym = XkbKeycodeToKeysym(QX11Info::display(), event->u.u.detail, 0, 0); - char *keyStr = XKeysymToString(keySym); - QMetaObject::invokeMethod(q_ptr, member, - Qt::AutoConnection, - Q_ARG(int, keyCode)); - QMetaObject::invokeMethod(q_ptr, member, - Qt::AutoConnection, - Q_ARG(QString, keyStr)); - } -} - -void XEventMonitorPrivate::run() -{ - Display* display = XOpenDisplay(0); - if (display == 0) { - fprintf(stderr, "unable to open display\n"); - return; - } - - // Receive from ALL clients, including future clients. - XRecordClientSpec clients = XRecordAllClients; - XRecordRange* range = XRecordAllocRange(); - if (range == 0) { - fprintf(stderr, "unable to allocate XRecordRange\n"); - return; - } - - // Receive KeyPress, KeyRelease, ButtonPress, ButtonRelease and MotionNotify events. - memset(range, 0, sizeof(XRecordRange)); - range->device_events.first = ButtonPress; - range->device_events.last = MotionNotify; - - // And create the XRECORD context. - XRecordContext context = XRecordCreateContext(display, 0, &clients, 1, &range, 1); - if (context == 0) { - fprintf(stderr, "XRecordCreateContext failed\n"); - return; - } - XFree(range); - - XSync(display, True); - - Display* display_datalink = XOpenDisplay(0); - if (display_datalink == 0) { - fprintf(stderr, "unable to open second display\n"); - return; - } - if (!XRecordEnableContext(display_datalink, context, callback, (XPointer) this)) { - fprintf(stderr, "XRecordEnableContext() failed\n"); - return; - } - -} - -void XEventMonitorPrivate::callback(XPointer ptr, XRecordInterceptData* data) -{ - ((XEventMonitorPrivate *) ptr)->handleRecordEvent(data); -} - -void XEventMonitorPrivate::handleRecordEvent(XRecordInterceptData* data) -{ - - if (data->category == XRecordFromServer) { - xEvent * event = (xEvent *)data->data; - switch (event->u.u.type) - { - case ButtonPress: - if (filterWheelEvent(event->u.u.detail)) { - emitButtonSignal("buttonPress", event); - } - break; - case MotionNotify: - emitButtonSignal("buttonDrag", event); - break; - case ButtonRelease: - if (filterWheelEvent(event->u.u.detail)) { - emitButtonSignal("buttonRelease", event); - } - break; - case KeyPress: - emitKeySignal("keyPress", event); - break; - case KeyRelease: - emitKeySignal("keyRelease", event); - break; - default: - break; - } - } - fflush(stdout); - XRecordFreeData(data); -} - -bool XEventMonitorPrivate::filterWheelEvent(int detail) -{ - return detail != WheelUp && detail != WheelDown && detail != WheelLeft && detail != WheelRight; -} - - -XEventMonitor::XEventMonitor(QObject *parent) - : QThread(parent), - d_ptr(new XEventMonitorPrivate(this)) -{ - Q_D(XEventMonitor); -} - -XEventMonitor::~XEventMonitor() -{ - requestInterruption(); - quit(); - wait(); -} - -void XEventMonitor::run() -{ - if(!isInterruptionRequested()) - { - d_ptr->run(); - } -} diff --git a/src/xeventmonitor.h b/src/xeventmonitor.h deleted file mode 100644 index b30099d..0000000 --- a/src/xeventmonitor.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- Mode: C++; indent-tabs-mode: nil; tab-width: 4 -*- - * -*- coding: utf-8 -*- - * - * Copyright (C) 2011 ~ 2017 Deepin, Inc. - * 2011 ~ 2017 Wang Yong - * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd. - * - * Author: Wang Yong - * Maintainer: Wang Yong - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef XEVENTMONITOR_H -#define XEVENTMONITOR_H - -#include -#include -#include - -class XEventMonitorPrivate; -class XEventMonitor : public QThread -{ - Q_OBJECT - -public: - XEventMonitor(QObject *parent = 0); - ~XEventMonitor(); - -Q_SIGNALS: - void buttonPress(int x, int y); - void buttonDrag(int x, int y); - void buttonRelease(int x, int y); - void keyPress(int keyCode); - void keyRelease(int keyCode); - void keyPress(const QString &key); - void keyRelease(const QString &key); - -protected: - void run(); - -private: - XEventMonitorPrivate *d_ptr; - Q_DECLARE_PRIVATE(XEventMonitor) -}; - -#endif