同步主线开发分支代码

This commit is contained in:
winnerym 2022-11-01 18:14:46 +08:00
parent b80aabb113
commit a8c9421501
97 changed files with 8318 additions and 2017 deletions

View File

@ -4,6 +4,7 @@ qt5_wrap_cpp(BiometricAuth_SRC
biometricauthwidget.h
biometricdeviceswidget.h
giodbus.h
uniauthservice.h
)
set(BiometricAuth_SRC
@ -13,6 +14,7 @@ set(BiometricAuth_SRC
biometricauthwidget.cpp
biometricdeviceswidget.cpp
giodbus.cpp
uniauthservice.cpp
)
include_directories(

View File

@ -34,6 +34,25 @@ QString DeviceType::getDeviceType(int 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)

View File

@ -69,6 +69,8 @@ public:
* @return
*/
static QString getDeviceType_tr(int deviceType);
//根据设备优先级获取设备类型
static int getBioType(int bioType);
};
/**

View File

@ -0,0 +1,251 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*
**/
#include "uniauthservice.h"
#include <QDebug>
#include <pwd.h>
#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"
UniAuthService::UniAuthService(QObject *parent)
: QDBusAbstractInterface(UNIAUTH_DBUS_SERVICE,
UNIAUTH_DBUS_PATH,
UNIAUTH_DBUS_INTERFACE,
QDBusConnection::systemBus(),
parent)
, m_isActivatable(false)
{
setTimeout(2147483647);
QDBusInterface *dbusService = new QDBusInterface(FD_DBUS_SERVICE,
FD_DBUS_PATH,
FD_DBUS_INTERFACE,
QDBusConnection::systemBus());
if (dbusService) {
QDBusReply<QStringList> 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;
}
}
}
}
// 设置默认设备
void UniAuthService::setDefaultDevice(int bioDevType, QString deviceName)
{
qDebug() << " bioType : " << bioDevType << "deviceName : " << deviceName;
QDBusMessage result = call(QStringLiteral("setDefaultDevice"), bioDevType, deviceName);
if(result.type() == QDBusMessage::ErrorMessage)
{
qWarning() << "setDefaultDevice error:" << result.errorMessage();
return ;
}
return ;
}
// 获取默认设备
QString UniAuthService::getDefaultDevice(QString userName, int bioDevType)
{
QDBusMessage result = call(QStringLiteral("getDefaultDevice"), userName, bioDevType);
if(result.type() == QDBusMessage::ErrorMessage)
{
qWarning() << "getDefaultDevice error:" << result.errorMessage();
return "";
}
QList<QVariant> varResult = result.arguments();
if (varResult.size() > 0) {
QString strDefDevice = varResult.takeFirst().toString();
return strDefDevice;
} else {
return "";
}
}
// 获取所有默认设备
QStringList UniAuthService::getAllDefaultDevice(QString userName)
{
QStringList listDefDevices;
QDBusReply<QStringList> result = call(QStringLiteral("getAllDefaultDevice"), userName);
if(!result.isValid()) {
qWarning() << "getAllDefaultDevice error:" << result.error().message();
} else {
listDefDevices = result.value();
}
return listDefDevices;
}
//生物特征开关接口
bool UniAuthService::getBioAuthStatus(QString userName, int bioAuthType)
{
QDBusMessage bioResult = call(QStringLiteral("getBioAuthStatus"), userName, bioAuthType);
if(bioResult.type() == QDBusMessage::ErrorMessage)
{
qWarning() << "getBioStatus error:" << bioResult.errorMessage();
return false;
}
QList<QVariant> varResult = bioResult.arguments();
if (varResult.size() > 0) {
return varResult.takeFirst().toBool();
} else {
return false;
}
}
void UniAuthService::setBioAuthStatus(int bioAuthType, bool status)
{
qDebug() << "setBioAuthStatus bioAuthType : " << bioAuthType << "status : " << status;
QDBusMessage result = call(QStringLiteral("setBioAuthStatus"), bioAuthType, status);
if(result.type() == QDBusMessage::ErrorMessage)
{
qWarning() << "setBioAuthStatus error:" << result.errorMessage();
return ;
}
return ;
}
// 获取最大失败次数
int UniAuthService::getMaxFailedTimes()
{
QDBusMessage result = call(QStringLiteral("getMaxFailedTimes"));
if(result.type() == QDBusMessage::ErrorMessage)
{
qWarning() << "getMaxFailedTimes error:" << result.errorMessage();
return false;
}
QList<QVariant> varResult = result.arguments();
if (varResult.size() > 0) {
return varResult.takeFirst().toInt();
} else {
return 3;
}
}
// 获取是否使能微信扫码登录
bool UniAuthService::getQRCodeEnable()
{
QDBusMessage result = call(QStringLiteral("getQRCodeEnable"));
if(result.type() == QDBusMessage::ErrorMessage)
{
qWarning() << "getQRCodeEnable error:" << result.errorMessage();
return false;
}
QList<QVariant> varResult = result.arguments();
if (varResult.size() > 0) {
return varResult.takeFirst().toBool();
} else {
return false;
}
}
// 获取是否双认证
bool UniAuthService::getDoubleAuth()
{
QDBusMessage result = call(QStringLiteral("getDoubleAuth"));
if(result.type() == QDBusMessage::ErrorMessage)
{
qWarning() << "getDoubleAuth error:" << result.errorMessage();
return false;
}
QList<QVariant> varResult = result.arguments();
if (varResult.size() > 0) {
return varResult.takeFirst().toBool();
} else {
return false;
}
}
// 获取用户绑定
bool UniAuthService::getUserBind()
{
QDBusMessage result = call(QStringLiteral("getUserBind"));
if(result.type() == QDBusMessage::ErrorMessage)
{
qWarning() << "getUserBind error:" << result.errorMessage();
return false;
}
QList<QVariant> varResult = result.arguments();
if (varResult.size() > 0) {
return varResult.takeFirst().toBool();
} else {
return false;
}
}
// 获取是否在控制面板显示
bool UniAuthService::getIsShownInControlCenter()
{
QDBusMessage result = call(QStringLiteral("getIsShownInControlCenter"));
if(result.type() == QDBusMessage::ErrorMessage)
{
qWarning() << "getIsShownInControlCenter error:" << result.errorMessage();
return false;
}
QList<QVariant> varResult = result.arguments();
if (varResult.size() > 0) {
return varResult.takeFirst().toBool();
} else {
return false;
}
}
// 获取是否使用第一个设备
bool UniAuthService::getUseFirstDevice()
{
QDBusMessage result = call(QStringLiteral("getUseFirstDevice"));
if(result.type() == QDBusMessage::ErrorMessage)
{
qWarning() << "getUseFirstDevice error:" << result.errorMessage();
return false;
}
QList<QVariant> varResult = result.arguments();
if (varResult.size() > 0) {
return varResult.takeFirst().toBool();
} else {
return false;
}
}
// 获取是否隐藏切换按钮
bool UniAuthService::getHiddenSwitchButton()
{
QDBusMessage result = call(QStringLiteral("getHiddenSwitchButton"));
if(result.type() == QDBusMessage::ErrorMessage)
{
qWarning() << "getHiddenSwitchButton error:" << result.errorMessage();
return false;
}
QList<QVariant> varResult = result.arguments();
if (varResult.size() > 0) {
return varResult.takeFirst().toBool();
} else {
return false;
}
}
bool UniAuthService::isActivatable()
{
return m_isActivatable;
}

View File

@ -0,0 +1,78 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*
**/
#ifndef UNIAUTH_SERVICE_H
#define UNIAUTH_SERVICE_H
#include <QtDBus>
#include <QDBusAbstractInterface>
enum authEnableType {
ENABLETYPE_BIO, // 全局总使能
ENABLETYPE_SAVER, // 锁屏
ENABLETYPE_GREETER, // 登录
ENABLETYPE_POLKIT, // 授权
ENABLETYPE_SU, // 暂保留
ENABLETYPE_SUDO, // 暂保留
ENABLETYPE_LOGIN, // 暂保留
};
class UniAuthService : public QDBusAbstractInterface
{
Q_OBJECT
public:
explicit UniAuthService(QObject *parent = nullptr);
public Q_SLOTS:
// 设置默认设备
void setDefaultDevice(int bioDevType, QString deviceName);
// 获取默认设备
QString getDefaultDevice(QString userName, int bioDevType);
// 获取所有默认设备
QStringList getAllDefaultDevice(QString userName);
//生物特征开关接口
bool getBioAuthStatus(QString userName, int bioAuthType);
void setBioAuthStatus(int bioAuthType, bool status);
// 获取最大失败次数
int getMaxFailedTimes();
// 获取是否使能微信扫码登录
bool getQRCodeEnable();
// 获取是否双认证
bool getDoubleAuth();
// 获取用户绑定
bool getUserBind();
// 获取是否在控制面板显示
bool getIsShownInControlCenter();
// 获取是否使用第一个设备
bool getUseFirstDevice();
// 获取是否隐藏切换按钮
bool getHiddenSwitchButton();
public:
bool isActivatable();
Q_SIGNALS:
//默认设备改变
void defaultDeviceChanged(QString userName, int bioDevType, QString deviceName);
//开关状态改变
void bioAuthStatusChanged(QString userName, int type, bool status);
private:
bool m_isActivatable;
};
#endif // UNIAUTH_SERVICE_H

View File

@ -7,6 +7,8 @@ find_package(OpenCV REQUIRED)
find_package(PkgConfig)
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)
# intel
option (USE_INTEL "intel项目" OFF)
@ -63,5 +65,5 @@ add_subdirectory(screensaver-focus-helper)
add_subdirectory(Common)
add_subdirectory(KylinNM)
add_dependencies(ukui-screensaver-dialog BiometricAuth VirtualKeyboard Common)
add_dependencies(ukui-screensaver-dialog BiometricAuth VirtualKeyboard Common Screensaver)
add_dependencies(ukui-screensaver-default Common)

View File

@ -21,6 +21,7 @@
#include <QMimeType>
#include <QSettings>
#include <QMimeDatabase>
#include <QPainter>
#include <QFileInfo>
#include <QFontMetrics>
#include "commonfunc.h"
@ -75,3 +76,36 @@ QString ElideText(QFont font,int width,QString strInfo)
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;
}

View File

@ -23,12 +23,15 @@
#include <QString>
#include <QFont>
#include <QPixmap>
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
{

View File

@ -33,17 +33,14 @@
BackThread::BackThread(QObject *parent) : QObject(parent)
{
cmdConnWifi = new QProcess(this);
connect(cmdConnWifi , SIGNAL(readyReadStandardOutput()) , this , SLOT(on_readoutput()));
connect(cmdConnWifi , SIGNAL(readyReadStandardError()) , this , SLOT(on_readerror()));
cmdConnWifi->start("bash");
cmdConnWifi->waitForStarted();
}
BackThread::~BackThread()
{
if (cmdConnWifi) {
cmdConnWifi->close();
}
}
//get the connection state of wired and wireles network
IFace* BackThread::execGetIface()
@ -278,7 +275,13 @@ void BackThread::execConnWifiPWD(QString connName, QString password)
void BackThread::execConnWifi(QString connName)
{
//disConnLanOrWifi("wifi");
if (!cmdConnWifi) {
cmdConnWifi = new QProcess(this);
connect(cmdConnWifi , SIGNAL(readyReadStandardOutput()) , this , SLOT(on_readoutput()));
connect(cmdConnWifi , SIGNAL(readyReadStandardError()) , this , SLOT(on_readerror()));
cmdConnWifi->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());
}

View File

@ -17,6 +17,11 @@
<summary>Automatic switching background</summary>
<description>Set this to TRUE to activate the automatic switching background.</description>
</key>
<key name="show-rest-time" type="b">
<default>true</default>
<summary>show rest time on screensaver</summary>
<description>Set this to TRUE to show rest time on screensaver.</description>
</key>
<key name="show-custom-rest-time" type="b">
<default>true</default>
<summary>show rest time on custom screensaver</summary>
@ -71,15 +76,25 @@
<description>Wait idle delay to lock</description>
</key>
<key name="idle-lock" type="i">
<default>5</default>
<default>-1</default>
<summary>idle lock to lock</summary>
<description>Display the lock screen</description>
</key>
<key name="lock-timeout" type="i">
<default>10</default>
<summary>screensaver with lock timeout</summary>
<description>Display the screensaver with lock's timeout</description>
</key>
<key name="sleep-activation-enabled" type="b">
<default>true</default>
<summary>Lock when sleep</summary>
<description>Set this to TRUE to lock the screen when the system goes sleep.</description>
</key>
<key name="close-activation-enabled" type="b">
<default>true</default>
<summary>Lock when close screen</summary>
<description>Set this to TRUE to lock the screen when the screen goes close.</description>
</key>
<key name="mode" enum="org.ukui.screensaver.Mode">
<default>'default-ukui'</default>
<summary>Screensaver theme selection mode</summary>

View File

@ -3,3 +3,5 @@
ukui-screensaver-dialog --lock-startup & >/dev/null 2>&1
/usr/lib/ukui-screensaver/screensaver-focus-helper & >/dev/null 2>&1
#如果锁屏和桌面进程并行启动会对锁屏启动时间有较大影响因此先启动锁屏1s后再往下执行
sleep 1

View File

@ -0,0 +1,23 @@
#-------------------------------------------------
#
# Project created by QtCreator 2022-07-01T18:13:09
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = LoadCustomPlugin
TEMPLATE = app
SOURCES += \
main.cpp \
widget.cpp
HEADERS += \
widget.h
FORMS += \
widget.ui

View File

@ -0,0 +1,11 @@
#include "widget.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Widget w;
w.show();
return a.exec();
}

View File

@ -0,0 +1,46 @@
#pragma execution_character_set("utf-8")
#include "widget.h"
#include "ui_widget.h"
#include <QFileDialog>
#include <QPluginLoader>
#include <QHBoxLayout>
#include <memory>
#include <ukui-screensaver/screensaverplugin.h>
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
connect(ui->load_plugin_btn,SIGNAL(clicked(bool)),this, SLOT(slot_load_plugin()));
}
Widget::~Widget()
{
delete ui;
}
void Widget::slot_load_plugin()
{
/*
QString file_path = QFileDialog::getOpenFileName(NULL,"加载插件",".","dll (*.dll *.so)");
if(file_path.isEmpty())
{
return;
}
*/
QPluginLoader pluginLoader("/usr/lib/ukui-screensaver/libscreensaver-default.so");
pluginLoader.load();
QObject* plugin = pluginLoader.instance();
if (plugin) {
std::unique_ptr<ScreensaverPlugin> interface_ptr = std::unique_ptr<ScreensaverPlugin>(qobject_cast<ScreensaverPlugin*>(plugin));
QWidget* widget = interface_ptr->createWidget(false,this);
widget->setFixedHeight(180);
widget->setFixedWidth(300);
QHBoxLayout* mainLayout = new QHBoxLayout(this);
mainLayout->addWidget(widget);
ui->widget->setLayout(mainLayout);
}
}

View File

@ -0,0 +1,25 @@
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
namespace Ui {
class Widget;
}
class Widget : public QWidget
{
Q_OBJECT
public:
explicit Widget(QWidget *parent = 0);
~Widget();
public slots:
void slot_load_plugin();
private:
Ui::Widget *ui;
};
#endif // WIDGET_H

View File

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Widget</class>
<widget class="QWidget" name="Widget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Widget</string>
</property>
<widget class="QPushButton" name="load_plugin_btn">
<property name="geometry">
<rect>
<x>140</x>
<y>30</y>
<width>111</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>LoadPlugin</string>
</property>
</widget>
<widget class="QWidget" name="widget" native="true">
<property name="geometry">
<rect>
<x>30</x>
<y>90</y>
<width>331</width>
<height>141</height>
</rect>
</property>
</widget>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>

View File

@ -4,108 +4,108 @@
<context>
<name>AuthDialog</name>
<message>
<location filename="../src/authdialog.cpp" line="653"/>
<location filename="../src/authdialog.cpp" line="656"/>
<source>Authentication failure, Please try again</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="251"/>
<location filename="../src/authdialog.cpp" line="252"/>
<location filename="../src/authdialog.cpp" line="315"/>
<location filename="../src/authdialog.cpp" line="248"/>
<location filename="../src/authdialog.cpp" line="249"/>
<location filename="../src/authdialog.cpp" line="316"/>
<location filename="../src/authdialog.cpp" line="317"/>
<source>Please try again in %1 minutes.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="260"/>
<location filename="../src/authdialog.cpp" line="261"/>
<location filename="../src/authdialog.cpp" line="324"/>
<location filename="../src/authdialog.cpp" line="258"/>
<location filename="../src/authdialog.cpp" line="259"/>
<location filename="../src/authdialog.cpp" line="325"/>
<location filename="../src/authdialog.cpp" line="326"/>
<source>Please try again in %1 seconds.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="268"/>
<location filename="../src/authdialog.cpp" line="269"/>
<location filename="../src/authdialog.cpp" line="270"/>
<location filename="../src/authdialog.cpp" line="333"/>
<location filename="../src/authdialog.cpp" line="334"/>
<location filename="../src/authdialog.cpp" line="335"/>
<source>Account locked permanently.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="449"/>
<location filename="../src/authdialog.cpp" line="455"/>
<source>Verify face recognition or enter password to unlock</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="454"/>
<location filename="../src/authdialog.cpp" line="460"/>
<source>Press fingerprint or enter password to unlock</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="459"/>
<location filename="../src/authdialog.cpp" line="465"/>
<source>Verify voiceprint or enter password to unlock</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="464"/>
<location filename="../src/authdialog.cpp" line="470"/>
<source>Verify finger vein or enter password to unlock</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="469"/>
<location filename="../src/authdialog.cpp" line="475"/>
<source>Verify iris or enter password to unlock</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="474"/>
<location filename="../src/authdialog.cpp" line="480"/>
<source>Use the bound wechat scanning code or enter the password to unlock</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="526"/>
<location filename="../src/authdialog.cpp" line="527"/>
<location filename="../src/authdialog.cpp" line="533"/>
<location filename="../src/authdialog.cpp" line="534"/>
<source>Password cannot be empty</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="614"/>
<location filename="../src/authdialog.cpp" line="617"/>
<source>Password </source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="616"/>
<location filename="../src/authdialog.cpp" line="619"/>
<source>Input Password</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="678"/>
<location filename="../src/authdialog.cpp" line="682"/>
<source>Login</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="684"/>
<location filename="../src/authdialog.cpp" line="694"/>
<source>Retry</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="912"/>
<location filename="../src/authdialog.cpp" line="916"/>
<source>Failed to verify %1, please enter password to unlock</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="916"/>
<location filename="../src/authdialog.cpp" line="920"/>
<source>Unable to verify %1, please enter password to unlock</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="922"/>
<location filename="../src/authdialog.cpp" line="926"/>
<source>Failed to verify %1, you still have %2 verification opportunities</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="933"/>
<source>NET Exception</source>
<location filename="../src/authdialog.cpp" line="937"/>
<source>Abnormal network</source>
<translation type="unfinished"></translation>
</message>
</context>
@ -253,32 +253,32 @@
<context>
<name>DeviceType</name>
<message>
<location filename="../BiometricAuth/biometricdeviceinfo.cpp" line="42"/>
<location filename="../BiometricAuth/biometricdeviceinfo.cpp" line="61"/>
<source>FingerPrint</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../BiometricAuth/biometricdeviceinfo.cpp" line="44"/>
<location filename="../BiometricAuth/biometricdeviceinfo.cpp" line="63"/>
<source>FingerVein</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../BiometricAuth/biometricdeviceinfo.cpp" line="46"/>
<location filename="../BiometricAuth/biometricdeviceinfo.cpp" line="65"/>
<source>Iris</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../BiometricAuth/biometricdeviceinfo.cpp" line="48"/>
<location filename="../BiometricAuth/biometricdeviceinfo.cpp" line="67"/>
<source>Face</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../BiometricAuth/biometricdeviceinfo.cpp" line="50"/>
<location filename="../BiometricAuth/biometricdeviceinfo.cpp" line="69"/>
<source>VoicePrint</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../BiometricAuth/biometricdeviceinfo.cpp" line="52"/>
<location filename="../BiometricAuth/biometricdeviceinfo.cpp" line="71"/>
<source>QRCode</source>
<translation type="unfinished"></translation>
</message>
@ -327,7 +327,6 @@
<name>DlgConnHidWifi</name>
<message>
<location filename="../KylinNM/wireless-security/dlgconnhidwifi.ui" line="14"/>
<location filename="../obj-x86_64-linux-gnu/KylinNM/ui_dlgconnhidwifi.h" line="122"/>
<source>Connect to Hidden Wi-Fi Network</source>
<translation type="unfinished"></translation>
</message>
@ -381,7 +380,6 @@
<name>DlgConnHidWifiLeap</name>
<message>
<location filename="../KylinNM/wireless-security/dlgconnhidwifileap.ui" line="14"/>
<location filename="../obj-x86_64-linux-gnu/KylinNM/ui_dlgconnhidwifileap.h" line="149"/>
<source>Connect to Hidden Wi-Fi Network</source>
<translation type="unfinished"></translation>
</message>
@ -465,7 +463,6 @@
<name>DlgConnHidWifiSecFast</name>
<message>
<location filename="../KylinNM/wireless-security/dlgconnhidwifisecfast.ui" line="14"/>
<location filename="../obj-x86_64-linux-gnu/KylinNM/ui_dlgconnhidwifisecfast.h" line="216"/>
<source>Connect to Hidden Wi-Fi Network</source>
<translation type="unfinished"></translation>
</message>
@ -600,7 +597,6 @@
<name>DlgConnHidWifiSecLeap</name>
<message>
<location filename="../KylinNM/wireless-security/dlgconnhidwifisecleap.ui" line="14"/>
<location filename="../obj-x86_64-linux-gnu/KylinNM/ui_dlgconnhidwifisecleap.h" line="161"/>
<source>Connect to Hidden Wi-Fi Network</source>
<translation type="unfinished"></translation>
</message>
@ -699,7 +695,6 @@
<name>DlgConnHidWifiSecPeap</name>
<message>
<location filename="../KylinNM/wireless-security/dlgconnhidwifisecpeap.ui" line="14"/>
<location filename="../obj-x86_64-linux-gnu/KylinNM/ui_dlgconnhidwifisecpeap.h" line="249"/>
<source>Connect to Hidden Wi-Fi Network</source>
<translation type="unfinished"></translation>
</message>
@ -849,7 +844,6 @@
<name>DlgConnHidWifiSecPwd</name>
<message>
<location filename="../KylinNM/wireless-security/dlgconnhidwifisecpwd.ui" line="14"/>
<location filename="../obj-x86_64-linux-gnu/KylinNM/ui_dlgconnhidwifisecpwd.h" line="161"/>
<source>Connect to Hidden Wi-Fi Network</source>
<translation type="unfinished"></translation>
</message>
@ -948,7 +942,6 @@
<name>DlgConnHidWifiSecTls</name>
<message>
<location filename="../KylinNM/wireless-security/dlgconnhidwifisectls.ui" line="14"/>
<location filename="../obj-x86_64-linux-gnu/KylinNM/ui_dlgconnhidwifisectls.h" line="250"/>
<source>Connect to Hidden Wi-Fi Network</source>
<translation type="unfinished"></translation>
</message>
@ -1092,7 +1085,6 @@
<name>DlgConnHidWifiSecTunnelTLS</name>
<message>
<location filename="../KylinNM/wireless-security/dlgconnhidwifisectunneltls.ui" line="14"/>
<location filename="../obj-x86_64-linux-gnu/KylinNM/ui_dlgconnhidwifisectunneltls.h" line="237"/>
<source>Connect to Hidden Wi-Fi Network</source>
<translation type="unfinished"></translation>
</message>
@ -1227,7 +1219,6 @@
<name>DlgConnHidWifiWep</name>
<message>
<location filename="../KylinNM/wireless-security/dlgconnhidwifiwep.ui" line="14"/>
<location filename="../obj-x86_64-linux-gnu/KylinNM/ui_dlgconnhidwifiwep.h" line="163"/>
<source>Connect to Hidden Wi-Fi Network</source>
<translation type="unfinished"></translation>
</message>
@ -1331,7 +1322,6 @@
<name>DlgConnHidWifiWpa</name>
<message>
<location filename="../KylinNM/wireless-security/dlgconnhidwifiwpa.ui" line="14"/>
<location filename="../obj-x86_64-linux-gnu/KylinNM/ui_dlgconnhidwifiwpa.h" line="137"/>
<source>Connect to Hidden Wi-Fi Network</source>
<translation type="unfinished"></translation>
</message>
@ -1390,7 +1380,6 @@
<name>DlgHotspotCreate</name>
<message>
<location filename="../KylinNM/hot-spot/dlghotspotcreate.ui" line="14"/>
<location filename="../obj-x86_64-linux-gnu/KylinNM/ui_dlghotspotcreate.h" line="89"/>
<source>Dialog</source>
<translation type="unfinished"></translation>
</message>
@ -1473,7 +1462,6 @@
<name>KeyboardWidget</name>
<message>
<location filename="../VirtualKeyboard/src/keyboardwidget.ui" line="29"/>
<location filename="../obj-x86_64-linux-gnu/VirtualKeyboard/VirtualKeyboard_autogen/include/ui_keyboardwidget.h" line="806"/>
<source>KeyboardWidget</source>
<translation type="unfinished"></translation>
</message>
@ -1482,7 +1470,6 @@
<name>KylinNM</name>
<message>
<location filename="../KylinNM/src/kylinnm.ui" line="14"/>
<location filename="../obj-x86_64-linux-gnu/KylinNM/ui_kylinnm.h" line="136"/>
<source>kylin-nm</source>
<translation type="unfinished"></translation>
</message>
@ -1617,32 +1604,44 @@
<name>LockWidget</name>
<message>
<location filename="../src/lockwidget.ui" line="14"/>
<location filename="../obj-x86_64-linux-gnu/src/ui_lockwidget.h" line="80"/>
<source>Form</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/lockwidget.ui" line="55"/>
<location filename="../obj-x86_64-linux-gnu/src/ui_lockwidget.h" line="83"/>
<location filename="../src/lockwidget.ui" line="72"/>
<source>Date</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/lockwidget.ui" line="48"/>
<location filename="../obj-x86_64-linux-gnu/src/ui_lockwidget.h" line="82"/>
<location filename="../src/lockwidget.ui" line="65"/>
<source>Time</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/lockwidget.cpp" line="523"/>
<source>Multiple users are logged in at the same time.Are you sure you want to reboot this system?</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/lockwidget.cpp" line="727"/>
<source>LAN</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/lockwidget.cpp" line="729"/>
<source>WLAN</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>LoginOptionsWidget</name>
<message>
<location filename="../src/loginoptionswidget.cpp" line="49"/>
<location filename="../src/loginoptionswidget.cpp" line="57"/>
<source>Login Options</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/loginoptionswidget.cpp" line="504"/>
<location filename="../src/loginoptionswidget.cpp" line="540"/>
<source>Identify device removed!</source>
<translation type="unfinished"></translation>
</message>
@ -1661,7 +1660,6 @@
<name>OneConnForm</name>
<message>
<location filename="../KylinNM/src/oneconnform.ui" line="14"/>
<location filename="../obj-x86_64-linux-gnu/KylinNM/ui_oneconnform.h" line="150"/>
<source>Form</source>
<translation type="unfinished"></translation>
</message>
@ -1723,7 +1721,6 @@
<name>OneLancForm</name>
<message>
<location filename="../KylinNM/src/onelancform.ui" line="14"/>
<location filename="../obj-x86_64-linux-gnu/KylinNM/ui_onelancform.h" line="127"/>
<source>Form</source>
<translation type="unfinished"></translation>
</message>
@ -1824,35 +1821,39 @@
<context>
<name>PowerManager</name>
<message>
<location filename="../src/powermanager.cpp" line="217"/>
<location filename="../src/powermanager.cpp" line="307"/>
<source>Log Out</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/powermanager.cpp" line="200"/>
<location filename="../src/powermanager.cpp" line="290"/>
<source>lock</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/powermanager.cpp" line="235"/>
<location filename="../src/powermanager.cpp" line="494"/>
<source>Restart</source>
<location filename="../src/powermanager.cpp" line="325"/>
<location filename="../src/powermanager.cpp" line="648"/>
<source>Reboot</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/powermanager.cpp" line="255"/>
<location filename="../src/powermanager.cpp" line="510"/>
<location filename="../src/powermanager.cpp" line="345"/>
<source>Power Off</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/powermanager.cpp" line="558"/>
<source>Suspend</source>
<location filename="../src/powermanager.cpp" line="666"/>
<source>Shut Down</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/powermanager.cpp" line="534"/>
<source>Sleep</source>
<location filename="../src/powermanager.cpp" line="692"/>
<source>Hibernate</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/powermanager.cpp" line="719"/>
<source>Suspend</source>
<translation type="unfinished"></translation>
</message>
</context>
@ -1872,17 +1873,17 @@
<context>
<name>Screensaver</name>
<message>
<location filename="../screensaver/screensaver.cpp" line="140"/>
<location filename="../screensaver/screensaver.cpp" line="142"/>
<source>Picture does not exist</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../screensaver/screensaver.cpp" line="1086"/>
<location filename="../screensaver/screensaver.cpp" line="1199"/>
<source>View</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../screensaver/screensaver.cpp" line="1242"/>
<location filename="../screensaver/screensaver.cpp" line="1364"/>
<source>You have new notification</source>
<translation type="unfinished"></translation>
</message>
@ -1890,8 +1891,51 @@
<context>
<name>SleepTime</name>
<message>
<location filename="../screensaver/sleeptime.cpp" line="70"/>
<source>You have rested:</source>
<location filename="../screensaver/sleeptime.cpp" line="64"/>
<source>You have rested</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SureWindow</name>
<message>
<location filename="../src/surewindow.ui" line="14"/>
<source>Form</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/surewindow.ui" line="56"/>
<source>TextLabel</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/surewindow.ui" line="157"/>
<source>Cancel</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/surewindow.ui" line="176"/>
<source>Confirm</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/surewindow.cpp" line="40"/>
<source>The following program is running to prevent the system from reboot!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/surewindow.cpp" line="43"/>
<source>The following program is running to prevent the system from shutting down!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/surewindow.cpp" line="46"/>
<source>The following program is running to prevent the system from suspend!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/surewindow.cpp" line="49"/>
<source>The following program is running to prevent the system from hibernate!</source>
<translation type="unfinished"></translation>
</message>
</context>
@ -2043,8 +2087,8 @@
</message>
<message>
<location filename="../src/ukui-screensaver-command.cpp" line="47"/>
<location filename="../src/ukui-screensaver-dialog.cpp" line="184"/>
<location filename="../src/ukui-screensaver-dialog.cpp" line="186"/>
<location filename="../src/ukui-screensaver-dialog.cpp" line="164"/>
<location filename="../src/ukui-screensaver-dialog.cpp" line="166"/>
<source>lock the screen immediately</source>
<translation type="unfinished"></translation>
</message>
@ -2064,23 +2108,23 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/ukui-screensaver-dialog.cpp" line="179"/>
<location filename="../src/ukui-screensaver-dialog.cpp" line="159"/>
<source>Dialog for the ukui ScreenSaver.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/ukui-screensaver-dialog.cpp" line="188"/>
<location filename="../src/ukui-screensaver-dialog.cpp" line="168"/>
<source>activated by session idle signal</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/ukui-screensaver-dialog.cpp" line="190"/>
<location filename="../src/ukui-screensaver-dialog.cpp" line="194"/>
<location filename="../src/ukui-screensaver-dialog.cpp" line="170"/>
<location filename="../src/ukui-screensaver-dialog.cpp" line="174"/>
<source>lock the screen and show screensaver immediately</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/ukui-screensaver-dialog.cpp" line="192"/>
<location filename="../src/ukui-screensaver-dialog.cpp" line="172"/>
<source>show screensaver immediately</source>
<translation type="unfinished"></translation>
</message>

File diff suppressed because it is too large Load Diff

View File

@ -83,10 +83,6 @@
<source>Verify iris or enter password to unlock</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>NET Exception</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Failed to verify %1, you still have %2 verification opportunities</source>
<translation type="unfinished"></translation>
@ -107,6 +103,10 @@
<source>Input Password</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Abnormal network</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>BioAuthWidget</name>
@ -1376,6 +1376,18 @@
<source>SwitchUser</source>
<translation type="vanished">Cambiar de usuario</translation>
</message>
<message>
<source>Multiple users are logged in at the same time.Are you sure you want to reboot this system?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LAN</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>WLAN</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>LoginOptionsWidget</name>
@ -1534,10 +1546,6 @@
<source>Log Out</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Restart</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Power Off</source>
<translation type="unfinished"></translation>
@ -1547,11 +1555,19 @@
<translation type="unfinished"></translation>
</message>
<message>
<source>Sleep</source>
<source>lock</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>lock</source>
<source>Shut Down</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Hibernate</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reboot</source>
<translation type="unfinished"></translation>
</message>
</context>
@ -1584,7 +1600,42 @@
<context>
<name>SleepTime</name>
<message>
<source>You have rested:</source>
<source>You have rested</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SureWindow</name>
<message>
<source>Form</source>
<translation type="unfinished">Formar</translation>
</message>
<message>
<source>TextLabel</source>
<translation type="unfinished">TextLabel</translation>
</message>
<message>
<source>Cancel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Confirm</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The following program is running to prevent the system from reboot!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The following program is running to prevent the system from shutting down!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The following program is running to prevent the system from suspend!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The following program is running to prevent the system from hibernate!</source>
<translation type="unfinished"></translation>
</message>
</context>

View File

@ -83,10 +83,6 @@
<source>Verify iris or enter password to unlock</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>NET Exception</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Failed to verify %1, you still have %2 verification opportunities</source>
<translation type="unfinished"></translation>
@ -107,6 +103,10 @@
<source>Input Password</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Abnormal network</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>BioAuthWidget</name>
@ -1376,6 +1376,18 @@
<source>SwitchUser</source>
<translation type="vanished">Changer d&apos;utilisateur</translation>
</message>
<message>
<source>Multiple users are logged in at the same time.Are you sure you want to reboot this system?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LAN</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>WLAN</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>LoginOptionsWidget</name>
@ -1534,10 +1546,6 @@
<source>Log Out</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Restart</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Power Off</source>
<translation type="unfinished"></translation>
@ -1547,11 +1555,19 @@
<translation type="unfinished"></translation>
</message>
<message>
<source>Sleep</source>
<source>lock</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>lock</source>
<source>Shut Down</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Hibernate</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reboot</source>
<translation type="unfinished"></translation>
</message>
</context>
@ -1584,7 +1600,42 @@
<context>
<name>SleepTime</name>
<message>
<source>You have rested:</source>
<source>You have rested</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SureWindow</name>
<message>
<source>Form</source>
<translation type="unfinished">Forme</translation>
</message>
<message>
<source>TextLabel</source>
<translation type="unfinished">TextLabel</translation>
</message>
<message>
<source>Cancel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Confirm</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The following program is running to prevent the system from reboot!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The following program is running to prevent the system from shutting down!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The following program is running to prevent the system from suspend!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The following program is running to prevent the system from hibernate!</source>
<translation type="unfinished"></translation>
</message>
</context>

View File

@ -83,10 +83,6 @@
<source>Verify iris or enter password to unlock</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>NET Exception</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Failed to verify %1, you still have %2 verification opportunities</source>
<translation type="unfinished"></translation>
@ -107,6 +103,10 @@
<source>Input Password</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Abnormal network</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>BioAuthWidget</name>
@ -1376,6 +1376,18 @@
<source>SwitchUser</source>
<translation type="vanished">Mudar de utilizador</translation>
</message>
<message>
<source>Multiple users are logged in at the same time.Are you sure you want to reboot this system?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LAN</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>WLAN</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>LoginOptionsWidget</name>
@ -1534,10 +1546,6 @@
<source>Log Out</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Restart</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Power Off</source>
<translation type="unfinished"></translation>
@ -1547,11 +1555,19 @@
<translation type="unfinished"></translation>
</message>
<message>
<source>Sleep</source>
<source>lock</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>lock</source>
<source>Shut Down</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Hibernate</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reboot</source>
<translation type="unfinished"></translation>
</message>
</context>
@ -1584,7 +1600,42 @@
<context>
<name>SleepTime</name>
<message>
<source>You have rested:</source>
<source>You have rested</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SureWindow</name>
<message>
<source>Form</source>
<translation type="unfinished">Formato</translation>
</message>
<message>
<source>TextLabel</source>
<translation type="unfinished">TextLabel</translation>
</message>
<message>
<source>Cancel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Confirm</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The following program is running to prevent the system from reboot!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The following program is running to prevent the system from shutting down!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The following program is running to prevent the system from suspend!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The following program is running to prevent the system from hibernate!</source>
<translation type="unfinished"></translation>
</message>
</context>

View File

@ -83,10 +83,6 @@
<source>Verify iris or enter password to unlock</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>NET Exception</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Failed to verify %1, you still have %2 verification opportunities</source>
<translation type="unfinished"></translation>
@ -107,6 +103,10 @@
<source>Input Password</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Abnormal network</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>BioAuthWidget</name>
@ -1376,6 +1376,18 @@
<source>SwitchUser</source>
<translation type="vanished">Сменить пользователя</translation>
</message>
<message>
<source>Multiple users are logged in at the same time.Are you sure you want to reboot this system?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LAN</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>WLAN</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>LoginOptionsWidget</name>
@ -1534,10 +1546,6 @@
<source>Log Out</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Restart</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Power Off</source>
<translation type="unfinished"></translation>
@ -1547,11 +1555,19 @@
<translation type="unfinished"></translation>
</message>
<message>
<source>Sleep</source>
<source>lock</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>lock</source>
<source>Shut Down</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Hibernate</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reboot</source>
<translation type="unfinished"></translation>
</message>
</context>
@ -1584,7 +1600,42 @@
<context>
<name>SleepTime</name>
<message>
<source>You have rested:</source>
<source>You have rested</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SureWindow</name>
<message>
<source>Form</source>
<translation type="unfinished">форма</translation>
</message>
<message>
<source>TextLabel</source>
<translation type="unfinished">TextLabel</translation>
</message>
<message>
<source>Cancel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Confirm</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The following program is running to prevent the system from reboot!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The following program is running to prevent the system from shutting down!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The following program is running to prevent the system from suspend!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The following program is running to prevent the system from hibernate!</source>
<translation type="unfinished"></translation>
</message>
</context>

View File

@ -16,7 +16,7 @@
<translation type="obsolete">Parola</translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="684"/>
<location filename="../src/authdialog.cpp" line="694"/>
<source>Retry</source>
<translation type="unfinished">Yeniden Dene</translation>
</message>
@ -41,103 +41,103 @@
<translation type="vanished">Kimlik doğrulama hatası, hala %1 kalan denemen var</translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="653"/>
<location filename="../src/authdialog.cpp" line="656"/>
<source>Authentication failure, Please try again</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="251"/>
<location filename="../src/authdialog.cpp" line="252"/>
<location filename="../src/authdialog.cpp" line="315"/>
<location filename="../src/authdialog.cpp" line="248"/>
<location filename="../src/authdialog.cpp" line="249"/>
<location filename="../src/authdialog.cpp" line="316"/>
<location filename="../src/authdialog.cpp" line="317"/>
<source>Please try again in %1 minutes.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="260"/>
<location filename="../src/authdialog.cpp" line="261"/>
<location filename="../src/authdialog.cpp" line="324"/>
<location filename="../src/authdialog.cpp" line="258"/>
<location filename="../src/authdialog.cpp" line="259"/>
<location filename="../src/authdialog.cpp" line="325"/>
<location filename="../src/authdialog.cpp" line="326"/>
<source>Please try again in %1 seconds.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="268"/>
<location filename="../src/authdialog.cpp" line="269"/>
<location filename="../src/authdialog.cpp" line="270"/>
<location filename="../src/authdialog.cpp" line="333"/>
<location filename="../src/authdialog.cpp" line="334"/>
<location filename="../src/authdialog.cpp" line="335"/>
<source>Account locked permanently.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="449"/>
<location filename="../src/authdialog.cpp" line="455"/>
<source>Verify face recognition or enter password to unlock</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="454"/>
<location filename="../src/authdialog.cpp" line="460"/>
<source>Press fingerprint or enter password to unlock</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="459"/>
<location filename="../src/authdialog.cpp" line="465"/>
<source>Verify voiceprint or enter password to unlock</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="464"/>
<location filename="../src/authdialog.cpp" line="470"/>
<source>Verify finger vein or enter password to unlock</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="469"/>
<location filename="../src/authdialog.cpp" line="475"/>
<source>Verify iris or enter password to unlock</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="474"/>
<location filename="../src/authdialog.cpp" line="480"/>
<source>Use the bound wechat scanning code or enter the password to unlock</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="526"/>
<location filename="../src/authdialog.cpp" line="527"/>
<location filename="../src/authdialog.cpp" line="533"/>
<location filename="../src/authdialog.cpp" line="534"/>
<source>Password cannot be empty</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="614"/>
<location filename="../src/authdialog.cpp" line="617"/>
<source>Password </source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="616"/>
<location filename="../src/authdialog.cpp" line="619"/>
<source>Input Password</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="678"/>
<location filename="../src/authdialog.cpp" line="682"/>
<source>Login</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="912"/>
<location filename="../src/authdialog.cpp" line="916"/>
<source>Failed to verify %1, please enter password to unlock</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="916"/>
<location filename="../src/authdialog.cpp" line="920"/>
<source>Unable to verify %1, please enter password to unlock</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="922"/>
<location filename="../src/authdialog.cpp" line="926"/>
<source>Failed to verify %1, you still have %2 verification opportunities</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="933"/>
<source>NET Exception</source>
<location filename="../src/authdialog.cpp" line="937"/>
<source>Abnormal network</source>
<translation type="unfinished"></translation>
</message>
<message>
@ -335,32 +335,32 @@
<context>
<name>DeviceType</name>
<message>
<location filename="../BiometricAuth/biometricdeviceinfo.cpp" line="42"/>
<location filename="../BiometricAuth/biometricdeviceinfo.cpp" line="61"/>
<source>FingerPrint</source>
<translation type="unfinished">Parmak İzi</translation>
</message>
<message>
<location filename="../BiometricAuth/biometricdeviceinfo.cpp" line="44"/>
<location filename="../BiometricAuth/biometricdeviceinfo.cpp" line="63"/>
<source>FingerVein</source>
<translation type="unfinished">Parmak Damarı</translation>
</message>
<message>
<location filename="../BiometricAuth/biometricdeviceinfo.cpp" line="46"/>
<location filename="../BiometricAuth/biometricdeviceinfo.cpp" line="65"/>
<source>Iris</source>
<translation type="unfinished">Göz</translation>
</message>
<message>
<location filename="../BiometricAuth/biometricdeviceinfo.cpp" line="48"/>
<location filename="../BiometricAuth/biometricdeviceinfo.cpp" line="67"/>
<source>Face</source>
<translation type="unfinished">Yüz</translation>
</message>
<message>
<location filename="../BiometricAuth/biometricdeviceinfo.cpp" line="50"/>
<location filename="../BiometricAuth/biometricdeviceinfo.cpp" line="69"/>
<source>VoicePrint</source>
<translation type="unfinished">Ses İzi</translation>
</message>
<message>
<location filename="../BiometricAuth/biometricdeviceinfo.cpp" line="52"/>
<location filename="../BiometricAuth/biometricdeviceinfo.cpp" line="71"/>
<source>QRCode</source>
<translation type="unfinished"></translation>
</message>
@ -409,7 +409,6 @@
<name>DlgConnHidWifi</name>
<message>
<location filename="../KylinNM/wireless-security/dlgconnhidwifi.ui" line="14"/>
<location filename="../obj-x86_64-linux-gnu/KylinNM/ui_dlgconnhidwifi.h" line="122"/>
<source>Connect to Hidden Wi-Fi Network</source>
<translation type="unfinished"></translation>
</message>
@ -463,7 +462,6 @@
<name>DlgConnHidWifiLeap</name>
<message>
<location filename="../KylinNM/wireless-security/dlgconnhidwifileap.ui" line="14"/>
<location filename="../obj-x86_64-linux-gnu/KylinNM/ui_dlgconnhidwifileap.h" line="149"/>
<source>Connect to Hidden Wi-Fi Network</source>
<translation type="unfinished"></translation>
</message>
@ -547,7 +545,6 @@
<name>DlgConnHidWifiSecFast</name>
<message>
<location filename="../KylinNM/wireless-security/dlgconnhidwifisecfast.ui" line="14"/>
<location filename="../obj-x86_64-linux-gnu/KylinNM/ui_dlgconnhidwifisecfast.h" line="216"/>
<source>Connect to Hidden Wi-Fi Network</source>
<translation type="unfinished"></translation>
</message>
@ -682,7 +679,6 @@
<name>DlgConnHidWifiSecLeap</name>
<message>
<location filename="../KylinNM/wireless-security/dlgconnhidwifisecleap.ui" line="14"/>
<location filename="../obj-x86_64-linux-gnu/KylinNM/ui_dlgconnhidwifisecleap.h" line="161"/>
<source>Connect to Hidden Wi-Fi Network</source>
<translation type="unfinished"></translation>
</message>
@ -781,7 +777,6 @@
<name>DlgConnHidWifiSecPeap</name>
<message>
<location filename="../KylinNM/wireless-security/dlgconnhidwifisecpeap.ui" line="14"/>
<location filename="../obj-x86_64-linux-gnu/KylinNM/ui_dlgconnhidwifisecpeap.h" line="249"/>
<source>Connect to Hidden Wi-Fi Network</source>
<translation type="unfinished"></translation>
</message>
@ -931,7 +926,6 @@
<name>DlgConnHidWifiSecPwd</name>
<message>
<location filename="../KylinNM/wireless-security/dlgconnhidwifisecpwd.ui" line="14"/>
<location filename="../obj-x86_64-linux-gnu/KylinNM/ui_dlgconnhidwifisecpwd.h" line="161"/>
<source>Connect to Hidden Wi-Fi Network</source>
<translation type="unfinished"></translation>
</message>
@ -1030,7 +1024,6 @@
<name>DlgConnHidWifiSecTls</name>
<message>
<location filename="../KylinNM/wireless-security/dlgconnhidwifisectls.ui" line="14"/>
<location filename="../obj-x86_64-linux-gnu/KylinNM/ui_dlgconnhidwifisectls.h" line="250"/>
<source>Connect to Hidden Wi-Fi Network</source>
<translation type="unfinished"></translation>
</message>
@ -1174,7 +1167,6 @@
<name>DlgConnHidWifiSecTunnelTLS</name>
<message>
<location filename="../KylinNM/wireless-security/dlgconnhidwifisectunneltls.ui" line="14"/>
<location filename="../obj-x86_64-linux-gnu/KylinNM/ui_dlgconnhidwifisectunneltls.h" line="237"/>
<source>Connect to Hidden Wi-Fi Network</source>
<translation type="unfinished"></translation>
</message>
@ -1309,7 +1301,6 @@
<name>DlgConnHidWifiWep</name>
<message>
<location filename="../KylinNM/wireless-security/dlgconnhidwifiwep.ui" line="14"/>
<location filename="../obj-x86_64-linux-gnu/KylinNM/ui_dlgconnhidwifiwep.h" line="163"/>
<source>Connect to Hidden Wi-Fi Network</source>
<translation type="unfinished"></translation>
</message>
@ -1413,7 +1404,6 @@
<name>DlgConnHidWifiWpa</name>
<message>
<location filename="../KylinNM/wireless-security/dlgconnhidwifiwpa.ui" line="14"/>
<location filename="../obj-x86_64-linux-gnu/KylinNM/ui_dlgconnhidwifiwpa.h" line="137"/>
<source>Connect to Hidden Wi-Fi Network</source>
<translation type="unfinished"></translation>
</message>
@ -1472,7 +1462,6 @@
<name>DlgHotspotCreate</name>
<message>
<location filename="../KylinNM/hot-spot/dlghotspotcreate.ui" line="14"/>
<location filename="../obj-x86_64-linux-gnu/KylinNM/ui_dlghotspotcreate.h" line="89"/>
<source>Dialog</source>
<translation type="unfinished"></translation>
</message>
@ -1555,7 +1544,6 @@
<name>KeyboardWidget</name>
<message>
<location filename="../VirtualKeyboard/src/keyboardwidget.ui" line="29"/>
<location filename="../obj-x86_64-linux-gnu/VirtualKeyboard/VirtualKeyboard_autogen/include/ui_keyboardwidget.h" line="806"/>
<source>KeyboardWidget</source>
<translation type="unfinished"></translation>
</message>
@ -1564,7 +1552,6 @@
<name>KylinNM</name>
<message>
<location filename="../KylinNM/src/kylinnm.ui" line="14"/>
<location filename="../obj-x86_64-linux-gnu/KylinNM/ui_kylinnm.h" line="136"/>
<source>kylin-nm</source>
<translation type="unfinished"></translation>
</message>
@ -1699,19 +1686,16 @@
<name>LockWidget</name>
<message>
<location filename="../src/lockwidget.ui" line="14"/>
<location filename="../obj-x86_64-linux-gnu/src/ui_lockwidget.h" line="80"/>
<source>Form</source>
<translation></translation>
</message>
<message>
<location filename="../src/lockwidget.ui" line="55"/>
<location filename="../obj-x86_64-linux-gnu/src/ui_lockwidget.h" line="83"/>
<location filename="../src/lockwidget.ui" line="72"/>
<source>Date</source>
<translation type="unfinished">Tarih</translation>
</message>
<message>
<location filename="../src/lockwidget.ui" line="48"/>
<location filename="../obj-x86_64-linux-gnu/src/ui_lockwidget.h" line="82"/>
<location filename="../src/lockwidget.ui" line="65"/>
<source>Time</source>
<translation type="unfinished">Zaman</translation>
</message>
@ -1723,11 +1707,26 @@
<source>SwitchUser</source>
<translation type="vanished">Kullanıcı Değiştir</translation>
</message>
<message>
<location filename="../src/lockwidget.cpp" line="523"/>
<source>Multiple users are logged in at the same time.Are you sure you want to reboot this system?</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/lockwidget.cpp" line="727"/>
<source>LAN</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/lockwidget.cpp" line="729"/>
<source>WLAN</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>LoginOptionsWidget</name>
<message>
<location filename="../src/loginoptionswidget.cpp" line="49"/>
<location filename="../src/loginoptionswidget.cpp" line="57"/>
<source>Login Options</source>
<translation type="unfinished"></translation>
</message>
@ -1736,7 +1735,7 @@
<translation type="obsolete">Parola</translation>
</message>
<message>
<location filename="../src/loginoptionswidget.cpp" line="504"/>
<location filename="../src/loginoptionswidget.cpp" line="540"/>
<source>Identify device removed!</source>
<translation type="unfinished"></translation>
</message>
@ -1755,7 +1754,6 @@
<name>OneConnForm</name>
<message>
<location filename="../KylinNM/src/oneconnform.ui" line="14"/>
<location filename="../obj-x86_64-linux-gnu/KylinNM/ui_oneconnform.h" line="150"/>
<source>Form</source>
<translation type="unfinished"></translation>
</message>
@ -1817,7 +1815,6 @@
<name>OneLancForm</name>
<message>
<location filename="../KylinNM/src/onelancform.ui" line="14"/>
<location filename="../obj-x86_64-linux-gnu/KylinNM/ui_onelancform.h" line="127"/>
<source>Form</source>
<translation type="unfinished"></translation>
</message>
@ -1918,7 +1915,7 @@
<context>
<name>PowerManager</name>
<message>
<location filename="../src/powermanager.cpp" line="200"/>
<location filename="../src/powermanager.cpp" line="290"/>
<source>lock</source>
<translation>kilit</translation>
</message>
@ -1947,30 +1944,38 @@
<translation type="obsolete">Kullanıcı Değiştir</translation>
</message>
<message>
<location filename="../src/powermanager.cpp" line="217"/>
<location filename="../src/powermanager.cpp" line="307"/>
<source>Log Out</source>
<translation type="unfinished">Çıkış</translation>
</message>
<message>
<location filename="../src/powermanager.cpp" line="235"/>
<location filename="../src/powermanager.cpp" line="494"/>
<source>Restart</source>
<translation type="unfinished">Yeniden Başlat</translation>
<translation type="obsolete">Yeniden Başlat</translation>
</message>
<message>
<location filename="../src/powermanager.cpp" line="255"/>
<location filename="../src/powermanager.cpp" line="510"/>
<location filename="../src/powermanager.cpp" line="325"/>
<location filename="../src/powermanager.cpp" line="648"/>
<source>Reboot</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/powermanager.cpp" line="345"/>
<source>Power Off</source>
<translation type="unfinished">Bilgisayarı Kapat</translation>
</message>
<message>
<location filename="../src/powermanager.cpp" line="558"/>
<source>Suspend</source>
<location filename="../src/powermanager.cpp" line="666"/>
<source>Shut Down</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/powermanager.cpp" line="534"/>
<source>Sleep</source>
<location filename="../src/powermanager.cpp" line="692"/>
<source>Hibernate</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/powermanager.cpp" line="719"/>
<source>Suspend</source>
<translation type="unfinished"></translation>
</message>
</context>
@ -1998,17 +2003,17 @@
<translation type="obsolete">çıkış</translation>
</message>
<message>
<location filename="../screensaver/screensaver.cpp" line="140"/>
<location filename="../screensaver/screensaver.cpp" line="142"/>
<source>Picture does not exist</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../screensaver/screensaver.cpp" line="1086"/>
<location filename="../screensaver/screensaver.cpp" line="1199"/>
<source>View</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../screensaver/screensaver.cpp" line="1242"/>
<location filename="../screensaver/screensaver.cpp" line="1364"/>
<source>You have new notification</source>
<translation type="unfinished"></translation>
</message>
@ -2024,8 +2029,51 @@
<context>
<name>SleepTime</name>
<message>
<location filename="../screensaver/sleeptime.cpp" line="70"/>
<source>You have rested:</source>
<location filename="../screensaver/sleeptime.cpp" line="64"/>
<source>You have rested</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SureWindow</name>
<message>
<location filename="../src/surewindow.ui" line="14"/>
<source>Form</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/surewindow.ui" line="56"/>
<source>TextLabel</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/surewindow.ui" line="157"/>
<source>Cancel</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/surewindow.ui" line="176"/>
<source>Confirm</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/surewindow.cpp" line="40"/>
<source>The following program is running to prevent the system from reboot!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/surewindow.cpp" line="43"/>
<source>The following program is running to prevent the system from shutting down!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/surewindow.cpp" line="46"/>
<source>The following program is running to prevent the system from suspend!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/surewindow.cpp" line="49"/>
<source>The following program is running to prevent the system from hibernate!</source>
<translation type="unfinished"></translation>
</message>
</context>
@ -2157,8 +2205,8 @@
</message>
<message>
<location filename="../src/ukui-screensaver-command.cpp" line="47"/>
<location filename="../src/ukui-screensaver-dialog.cpp" line="184"/>
<location filename="../src/ukui-screensaver-dialog.cpp" line="186"/>
<location filename="../src/ukui-screensaver-dialog.cpp" line="164"/>
<location filename="../src/ukui-screensaver-dialog.cpp" line="166"/>
<source>lock the screen immediately</source>
<translation type="unfinished">Ekranı hemen kilitle</translation>
</message>
@ -2178,23 +2226,23 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/ukui-screensaver-dialog.cpp" line="179"/>
<location filename="../src/ukui-screensaver-dialog.cpp" line="159"/>
<source>Dialog for the ukui ScreenSaver.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/ukui-screensaver-dialog.cpp" line="188"/>
<location filename="../src/ukui-screensaver-dialog.cpp" line="168"/>
<source>activated by session idle signal</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/ukui-screensaver-dialog.cpp" line="190"/>
<location filename="../src/ukui-screensaver-dialog.cpp" line="194"/>
<location filename="../src/ukui-screensaver-dialog.cpp" line="170"/>
<location filename="../src/ukui-screensaver-dialog.cpp" line="174"/>
<source>lock the screen and show screensaver immediately</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/ukui-screensaver-dialog.cpp" line="192"/>
<location filename="../src/ukui-screensaver-dialog.cpp" line="172"/>
<source>show screensaver immediately</source>
<translation type="unfinished"></translation>
</message>

View File

@ -16,7 +16,7 @@
<translation type="obsolete">使</translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="681"/>
<location filename="../src/authdialog.cpp" line="696"/>
<source>Retry</source>
<translation></translation>
</message>
@ -45,76 +45,81 @@
<translation type="vanished">%1%2</translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="251"/>
<location filename="../src/authdialog.cpp" line="252"/>
<location filename="../src/authdialog.cpp" line="315"/>
<location filename="../src/authdialog.cpp" line="248"/>
<location filename="../src/authdialog.cpp" line="249"/>
<location filename="../src/authdialog.cpp" line="316"/>
<location filename="../src/authdialog.cpp" line="317"/>
<source>Please try again in %1 minutes.</source>
<translation>%1</translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="260"/>
<location filename="../src/authdialog.cpp" line="261"/>
<location filename="../src/authdialog.cpp" line="324"/>
<location filename="../src/authdialog.cpp" line="258"/>
<location filename="../src/authdialog.cpp" line="259"/>
<location filename="../src/authdialog.cpp" line="325"/>
<location filename="../src/authdialog.cpp" line="326"/>
<source>Please try again in %1 seconds.</source>
<translation>%1</translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="268"/>
<location filename="../src/authdialog.cpp" line="269"/>
<location filename="../src/authdialog.cpp" line="270"/>
<location filename="../src/authdialog.cpp" line="333"/>
<location filename="../src/authdialog.cpp" line="334"/>
<location filename="../src/authdialog.cpp" line="335"/>
<source>Account locked permanently.</source>
<translation></translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="449"/>
<location filename="../src/authdialog.cpp" line="455"/>
<source>Verify face recognition or enter password to unlock</source>
<translation></translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="454"/>
<location filename="../src/authdialog.cpp" line="460"/>
<source>Press fingerprint or enter password to unlock</source>
<translation></translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="459"/>
<location filename="../src/authdialog.cpp" line="465"/>
<source>Verify voiceprint or enter password to unlock</source>
<translation></translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="464"/>
<location filename="../src/authdialog.cpp" line="470"/>
<source>Verify finger vein or enter password to unlock</source>
<translation></translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="469"/>
<location filename="../src/authdialog.cpp" line="475"/>
<source>Verify iris or enter password to unlock</source>
<translation></translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="613"/>
<location filename="../src/authdialog.cpp" line="619"/>
<source>Input Password</source>
<translation></translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="909"/>
<location filename="../src/authdialog.cpp" line="916"/>
<source>Failed to verify %1, please enter password to unlock</source>
<translation>%1</translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="913"/>
<location filename="../src/authdialog.cpp" line="920"/>
<source>Unable to verify %1, please enter password to unlock</source>
<translation>%1</translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="937"/>
<source>Abnormal network</source>
<translation></translation>
</message>
<message>
<source>Use the bound wechat scanning code or enter the password to log in</source>
<translation type="vanished">使</translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="527"/>
<location filename="../src/authdialog.cpp" line="528"/>
<location filename="../src/authdialog.cpp" line="533"/>
<location filename="../src/authdialog.cpp" line="534"/>
<source>Password cannot be empty</source>
<translation></translation>
</message>
@ -127,7 +132,7 @@
<translation type="vanished">%1.</translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="919"/>
<location filename="../src/authdialog.cpp" line="926"/>
<source>Failed to verify %1, you still have %2 verification opportunities</source>
<translation>%1%2</translation>
</message>
@ -140,9 +145,8 @@
<translation type="vanished">/%1</translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="930"/>
<source>NET Exception</source>
<translation></translation>
<translation type="vanished"></translation>
</message>
<message>
<source>Password Incorrect, Please try again</source>
@ -157,22 +161,22 @@
<translation type="vanished"></translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="650"/>
<location filename="../src/authdialog.cpp" line="656"/>
<source>Authentication failure, Please try again</source>
<translation></translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="474"/>
<location filename="../src/authdialog.cpp" line="480"/>
<source>Use the bound wechat scanning code or enter the password to unlock</source>
<translation>使</translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="611"/>
<location filename="../src/authdialog.cpp" line="617"/>
<source>Password </source>
<translation> </translation>
</message>
<message>
<location filename="../src/authdialog.cpp" line="675"/>
<location filename="../src/authdialog.cpp" line="682"/>
<source>Login</source>
<translation></translation>
</message>
@ -197,6 +201,31 @@
<translation type="vanished">%1</translation>
</message>
</context>
<context>
<name>BatteryWidget</name>
<message>
<location filename="../src/batterywidget.cpp" line="71"/>
<location filename="../src/batterywidget.cpp" line="139"/>
<source>BatteryMode</source>
<translation></translation>
</message>
<message>
<location filename="../src/batterywidget.cpp" line="71"/>
<location filename="../src/batterywidget.cpp" line="136"/>
<source>PowerMode</source>
<translation></translation>
</message>
<message>
<location filename="../src/batterywidget.cpp" line="129"/>
<source>Charging...</source>
<translation>...</translation>
</message>
<message>
<location filename="../src/batterywidget.cpp" line="131"/>
<source>fully charged</source>
<translation></translation>
</message>
</context>
<context>
<name>BioDevices</name>
<message>
@ -391,32 +420,32 @@
<context>
<name>DeviceType</name>
<message>
<location filename="../BiometricAuth/biometricdeviceinfo.cpp" line="42"/>
<location filename="../BiometricAuth/biometricdeviceinfo.cpp" line="61"/>
<source>FingerPrint</source>
<translation></translation>
</message>
<message>
<location filename="../BiometricAuth/biometricdeviceinfo.cpp" line="44"/>
<location filename="../BiometricAuth/biometricdeviceinfo.cpp" line="63"/>
<source>FingerVein</source>
<translation></translation>
</message>
<message>
<location filename="../BiometricAuth/biometricdeviceinfo.cpp" line="46"/>
<location filename="../BiometricAuth/biometricdeviceinfo.cpp" line="65"/>
<source>Iris</source>
<translation></translation>
</message>
<message>
<location filename="../BiometricAuth/biometricdeviceinfo.cpp" line="48"/>
<location filename="../BiometricAuth/biometricdeviceinfo.cpp" line="67"/>
<source>Face</source>
<translation></translation>
</message>
<message>
<location filename="../BiometricAuth/biometricdeviceinfo.cpp" line="50"/>
<location filename="../BiometricAuth/biometricdeviceinfo.cpp" line="69"/>
<source>VoicePrint</source>
<translation></translation>
</message>
<message>
<location filename="../BiometricAuth/biometricdeviceinfo.cpp" line="52"/>
<location filename="../BiometricAuth/biometricdeviceinfo.cpp" line="71"/>
<source>QRCode</source>
<translation></translation>
</message>
@ -1602,6 +1631,124 @@
<translation type="unfinished">WPA WPA2 </translation>
</message>
</context>
<context>
<name>EngineDevice</name>
<message>
<location filename="../src/enginedevice.cpp" line="101"/>
<source>yes</source>
<translation></translation>
</message>
<message>
<location filename="../src/enginedevice.cpp" line="101"/>
<source>no</source>
<translation></translation>
</message>
<message>
<location filename="../src/enginedevice.cpp" line="120"/>
<source>Yes</source>
<translation></translation>
</message>
<message>
<location filename="../src/enginedevice.cpp" line="120"/>
<source>No</source>
<translation></translation>
</message>
<message>
<location filename="../src/enginedevice.cpp" line="284"/>
<source>%1% available, charged</source>
<translation></translation>
</message>
<message>
<location filename="../src/enginedevice.cpp" line="290"/>
<source>Left %1h %2m (%3%)</source>
<translation></translation>
</message>
<message>
<location filename="../src/enginedevice.cpp" line="295"/>
<source>%1% available</source>
<translation></translation>
</message>
<message>
<location filename="../src/enginedevice.cpp" line="301"/>
<source>Left %1h %2m to full</source>
<translation></translation>
</message>
<message>
<location filename="../src/enginedevice.cpp" line="303"/>
<source>charging (%1%)</source>
<translation></translation>
</message>
<message>
<location filename="../src/enginedevice.cpp" line="309"/>
<source>%1 waiting to discharge (%2%)</source>
<translation></translation>
</message>
<message>
<location filename="../src/enginedevice.cpp" line="314"/>
<source>%1 waiting to charge (%2%)</source>
<translation></translation>
</message>
<message>
<location filename="../src/enginedevice.cpp" line="334"/>
<source>AC adapter</source>
<translation></translation>
</message>
<message>
<location filename="../src/enginedevice.cpp" line="338"/>
<source>Laptop battery</source>
<translation></translation>
</message>
<message>
<location filename="../src/enginedevice.cpp" line="342"/>
<source>UPS</source>
<translation></translation>
</message>
<message>
<location filename="../src/enginedevice.cpp" line="346"/>
<source>Monitor</source>
<translation></translation>
</message>
<message>
<location filename="../src/enginedevice.cpp" line="350"/>
<source>Mouse</source>
<translation></translation>
</message>
<message>
<location filename="../src/enginedevice.cpp" line="354"/>
<source>Keyboard</source>
<translation></translation>
</message>
<message>
<location filename="../src/enginedevice.cpp" line="358"/>
<source>PDA</source>
<translation></translation>
</message>
<message>
<location filename="../src/enginedevice.cpp" line="362"/>
<source>Cell phone</source>
<translation></translation>
</message>
<message>
<location filename="../src/enginedevice.cpp" line="366"/>
<source>Media player</source>
<translation></translation>
</message>
<message>
<location filename="../src/enginedevice.cpp" line="370"/>
<source>Tablet</source>
<translation></translation>
</message>
<message>
<location filename="../src/enginedevice.cpp" line="374"/>
<source>Computer</source>
<translation></translation>
</message>
<message>
<location filename="../src/enginedevice.cpp" line="378"/>
<source>unrecognised</source>
<translation></translation>
</message>
</context>
<context>
<name>InputInfos</name>
<message>
@ -1897,12 +2044,12 @@
<translation></translation>
</message>
<message>
<location filename="../src/lockwidget.ui" line="55"/>
<location filename="../src/lockwidget.ui" line="72"/>
<source>Date</source>
<translation></translation>
</message>
<message>
<location filename="../src/lockwidget.ui" line="48"/>
<location filename="../src/lockwidget.ui" line="65"/>
<source>Time</source>
<translation></translation>
</message>
@ -1914,11 +2061,26 @@
<source>SwitchUser</source>
<translation type="vanished"></translation>
</message>
<message>
<location filename="../src/lockwidget.cpp" line="523"/>
<source>Multiple users are logged in at the same time.Are you sure you want to reboot this system?</source>
<translation>退</translation>
</message>
<message>
<location filename="../src/lockwidget.cpp" line="727"/>
<source>LAN</source>
<translation type="unfinished">线</translation>
</message>
<message>
<location filename="../src/lockwidget.cpp" line="729"/>
<source>WLAN</source>
<translation type="unfinished">线</translation>
</message>
</context>
<context>
<name>LoginOptionsWidget</name>
<message>
<location filename="../src/loginoptionswidget.cpp" line="49"/>
<location filename="../src/loginoptionswidget.cpp" line="57"/>
<source>Login Options</source>
<translation></translation>
</message>
@ -1931,7 +2093,7 @@
<translation type="vanished"></translation>
</message>
<message>
<location filename="../src/loginoptionswidget.cpp" line="504"/>
<location filename="../src/loginoptionswidget.cpp" line="540"/>
<source>Identify device removed!</source>
<translation>!</translation>
</message>
@ -2139,7 +2301,7 @@
<context>
<name>PowerManager</name>
<message>
<location filename="../src/powermanager.cpp" line="380"/>
<location filename="../src/powermanager.cpp" line="290"/>
<source>lock</source>
<translation></translation>
</message>
@ -2168,33 +2330,37 @@
<translation type="vanished"></translation>
</message>
<message>
<location filename="../src/powermanager.cpp" line="397"/>
<location filename="../src/powermanager.cpp" line="307"/>
<source>Log Out</source>
<translation></translation>
</message>
<message>
<location filename="../src/powermanager.cpp" line="415"/>
<location filename="../src/powermanager.cpp" line="699"/>
<location filename="../src/powermanager.cpp" line="325"/>
<source>Restart</source>
<translation></translation>
</message>
<message>
<location filename="../src/powermanager.cpp" line="435"/>
<location filename="../src/powermanager.cpp" line="325"/>
<source>Reboot</source>
<translation></translation>
</message>
<message>
<location filename="../src/powermanager.cpp" line="345"/>
<source>Power Off</source>
<translation></translation>
</message>
<message>
<location filename="../src/powermanager.cpp" line="717"/>
<location filename="../src/powermanager.cpp" line="666"/>
<source>Shut Down</source>
<translation></translation>
</message>
<message>
<location filename="../src/powermanager.cpp" line="743"/>
<location filename="../src/powermanager.cpp" line="692"/>
<source>Hibernate</source>
<translation></translation>
</message>
<message>
<location filename="../src/powermanager.cpp" line="770"/>
<location filename="../src/powermanager.cpp" line="719"/>
<source>Suspend</source>
<translation></translation>
</message>
@ -2216,6 +2382,15 @@
<translation></translation>
</message>
</context>
<context>
<name>S:</name>
<message>
<location filename="../src/enginedevice.cpp" line="308"/>
<source></source>
<comment>this is only shown for laptops with multiple batteries</comment>
<translation></translation>
</message>
</context>
<context>
<name>Screensaver</name>
<message>
@ -2227,7 +2402,7 @@
<translation type="vanished">退</translation>
</message>
<message>
<location filename="../screensaver/screensaver.cpp" line="140"/>
<location filename="../screensaver/screensaver.cpp" line="142"/>
<source>Picture does not exist</source>
<translation></translation>
</message>
@ -2244,12 +2419,12 @@
<translation type="obsolete">%1</translation>
</message>
<message>
<location filename="../screensaver/screensaver.cpp" line="1289"/>
<location filename="../screensaver/screensaver.cpp" line="1364"/>
<source>You have new notification</source>
<translation></translation>
</message>
<message>
<location filename="../screensaver/screensaver.cpp" line="1133"/>
<location filename="../screensaver/screensaver.cpp" line="1199"/>
<source>View</source>
<translation></translation>
</message>
@ -2257,9 +2432,13 @@
<context>
<name>SleepTime</name>
<message>
<location filename="../screensaver/sleeptime.cpp" line="70"/>
<source>You have rested:</source>
<translation>:</translation>
<translation type="vanished">:</translation>
</message>
<message>
<location filename="../screensaver/sleeptime.cpp" line="64"/>
<source>You have rested</source>
<translation></translation>
</message>
</context>
<context>
@ -2275,19 +2454,38 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/surewindow.ui" line="108"/>
<location filename="../src/surewindow.ui" line="157"/>
<source>Cancel</source>
<translation></translation>
</message>
<message>
<location filename="../src/surewindow.ui" line="127"/>
<location filename="../src/surewindow.ui" line="176"/>
<source>Confirm</source>
<translation></translation>
</message>
<message>
<location filename="../src/surewindow.cpp" line="9"/>
<source>Multiple users are logged in at the same time.Are you sure you want to reboot this system?</source>
<translation>退</translation>
<translation type="vanished">退</translation>
</message>
<message>
<location filename="../src/surewindow.cpp" line="46"/>
<source>The following program is running to prevent the system from suspend!</source>
<translation></translation>
</message>
<message>
<location filename="../src/surewindow.cpp" line="49"/>
<source>The following program is running to prevent the system from hibernate!</source>
<translation></translation>
</message>
<message>
<location filename="../src/surewindow.cpp" line="43"/>
<source>The following program is running to prevent the system from shutting down!</source>
<translation></translation>
</message>
<message>
<location filename="../src/surewindow.cpp" line="40"/>
<source>The following program is running to prevent the system from reboot!</source>
<translation></translation>
</message>
</context>
<context>
@ -2441,8 +2639,8 @@
</message>
<message>
<location filename="../src/ukui-screensaver-command.cpp" line="47"/>
<location filename="../src/ukui-screensaver-dialog.cpp" line="163"/>
<location filename="../src/ukui-screensaver-dialog.cpp" line="165"/>
<location filename="../src/ukui-screensaver-dialog.cpp" line="164"/>
<location filename="../src/ukui-screensaver-dialog.cpp" line="166"/>
<source>lock the screen immediately</source>
<translation></translation>
</message>
@ -2462,23 +2660,23 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/ukui-screensaver-dialog.cpp" line="158"/>
<location filename="../src/ukui-screensaver-dialog.cpp" line="159"/>
<source>Dialog for the ukui ScreenSaver.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/ukui-screensaver-dialog.cpp" line="167"/>
<location filename="../src/ukui-screensaver-dialog.cpp" line="168"/>
<source>activated by session idle signal</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/ukui-screensaver-dialog.cpp" line="169"/>
<location filename="../src/ukui-screensaver-dialog.cpp" line="173"/>
<location filename="../src/ukui-screensaver-dialog.cpp" line="170"/>
<location filename="../src/ukui-screensaver-dialog.cpp" line="174"/>
<source>lock the screen and show screensaver immediately</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/ukui-screensaver-dialog.cpp" line="171"/>
<location filename="../src/ukui-screensaver-dialog.cpp" line="172"/>
<source>show screensaver immediately</source>
<translation type="unfinished"></translation>
</message>

View File

@ -29,7 +29,7 @@ qt5_wrap_cpp(screensaver_SRC
cyclelabel.h
scconfiguration.h
sleeptime.h
weathermanager.h
../src/weathermanager.h
../src/networkwatcher.h
)
set(screensaver_SRC
@ -41,18 +41,85 @@ set(screensaver_SRC
cyclelabel.cpp
scconfiguration.cpp
sleeptime.cpp
weathermanager.cpp
../src/weathermanager.cpp
../src/networkwatcher.cpp
)
add_executable(ukui-screensaver-default ${screensaver_SRC})
target_link_libraries(ukui-screensaver-default Qt5::Core Qt5::Widgets Qt5::X11Extras Qt5::Xml Qt5::Network ${EXTRA_LIBS})
qt5_add_resources(screensaver_Plugin_SRC
default.qrc
)
qt5_wrap_cpp(screensaver_Plugin_SRC
chinesedate.h
screensaver.h
mbackground.h
cyclelabel.h
scconfiguration.h
sleeptime.h
../src/weathermanager.h
../src/networkwatcher.h
customplugin.h
screensaverplugin.h
)
set(screensaver_Plugin_SRC
${screensaver_Plugin_SRC}
chinesedate.cpp
mbackground.cpp
screensaver.cpp
cyclelabel.cpp
scconfiguration.cpp
sleeptime.cpp
../src/weathermanager.cpp
../src/networkwatcher.cpp
customplugin.cpp
)
add_library(screensaver-default SHARED ${screensaver_Plugin_SRC})
target_link_libraries(screensaver-default Qt5::Core Qt5::Widgets Qt5::X11Extras Qt5::Xml Qt5::Network ${EXTRA_LIBS})
qt5_add_resources(Screensaver_SRC
default.qrc
)
qt5_wrap_cpp(Screensaver_SRC
chinesedate.h
screensaver.h
mbackground.h
cyclelabel.h
scconfiguration.h
sleeptime.h
../src/weathermanager.h
../src/networkwatcher.h
)
set(Screensaver_SRC
${screensaver_Plugin_SRC}
chinesedate.cpp
mbackground.cpp
screensaver.cpp
cyclelabel.cpp
scconfiguration.cpp
sleeptime.cpp
../src/weathermanager.cpp
../src/networkwatcher.cpp
)
add_library(Screensaver STATIC ${Screensaver_SRC})
target_link_libraries(Screensaver Qt5::Core Qt5::Widgets Qt5::X11Extras Qt5::Xml Qt5::Network ${EXTRA_LIBS})
install(TARGETS
ukui-screensaver-default
screensaver-default
DESTINATION lib/ukui-screensaver)
install(FILES
language/screensaver-zh_CN.ini
language/screensaver-en_US.ini
language/screensaver-bo_CN.ini
language/screensaver-jd.ini
DESTINATION share/ukui-screensaver/language)
install(FILES
screensaverplugin.h
DESTINATION include/ukui-screensaver/)

View File

@ -38,10 +38,10 @@ QLabel#authorLabel {
color: #ffffff;
}
QLabel#myText{
font-size:18px;
font-size:24px;
border-radius: 6px;
background: rgba(255, 255, 255, 82%);
padding: 24px 48px 24px 48px;
padding: 24px 24px 24px 24px;
color: #000000;
}
QPushButton{

View File

@ -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";
}

View File

@ -0,0 +1,21 @@
#ifndef CUSTOMPLUGIN_H
#define CUSTOMPLUGIN_H
#include "screensaverplugin.h"
#include <QObject>
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

View File

@ -0,0 +1,84 @@
[1]
FL=སྐྱེ་བོ་ཡོན་ཏན་ཡོད་མེད་པའི།། བླང་དོར་བློ་གྲོས་ལྡན་པ་མཁས།།
SL=རྡུལ་དང་འདྲེས་པའི་ལྕགས་ཕྱེ་རྣམས།། ཁབ་ལེན་རྡོ་ཡིས་ལེན་པར་ཤེས།།
[2]
FL=ལེགས་བཤད་མཁས་པའི་བློ་གྲོས་ཀྱིས།། གོ་ཡི་བླུན་པོས་དེ་ལྟ་མིན།།
SL=ཉི་མའི་འོད་ཟེར་ཤར་བ་ན།། འབྱུང་པོའི་བྱ་རྣམས་ལོང་བར་འགྱུར།།
[3]
FL=བློ་ཆུང་གྲོས་གཉིས་འཁྲུགས་པའི་ཚེ།། བློ་ལྡན་ཐབས་ཀྱིས་བདེ་བར་གསོ།།
SL=ཆུ་ཀླུང་རྙོག་པས་ཆུད་གཟན་པ།། ཆུ་དྭངས་ནོར་བུས་དྭངས་པར་བྱེད།།
[4]
FL=ཤེས་རབ་ལྡན་པ་མགོ་བསྐོར་ཡང་།། བྱ་བའི་ཆ་ལ་རྨོངས་མི་འགྱུར།།
SL=སྲོག་ཆགས་གྲོག་མ་མིག་མེད་ཀྱང་།། མིག་ལྡན་གཞན་ལས་ལྷག་པར་མགྱོགས།།
[5]
FL=བླུན་པོས་ཡོན་ཏན་ཁར་འབྱིན་ཏེ།། མཁས་པས་ཡོན་ཏན་ཁོང་དུ་སྦེད།།
SL=སོག་མ་ཆུ་ཡི་སྟེང་དུ་འཕྱོ།། ནོར་བུ་སྟེང་དུ་བཞག་ཀྱང་འབྱིང་།།
[6]
FL=མཁས་པ་ཡོན་ཏན་དཔག་མེད་ཀྱང་།། གཞན་གྱི་ཡོན་ཏན་ཆུང་ངུའང་ལེན།།
SL=དེ་ལྟར་རྒྱུན་དུ་སྤྱད་པ་ཡིས།། མྱུར་དུ་ཐམས་ཅད་མཁྱེན་པར་འགྲོ།།
[7]
FL=མཁས་པ་སློབ་པའི་དུས་ན་སྡུག། བདེ་བར་སྡོད་ལ་མཁས་མི་སྲིད།།
SL=བདེ་བ་ཆུང་ལ་ཆགས་པ་དེས།། ཆེན་པོའི་བདེ་བ་ཐོབ་མི་སྲིད།།
[8]
FL=དམ་པའི་ཡོན་ཏན་སྦས་གྱུར་ཀྱང་།། འཇིག་རྟེན་ཀུན་ལ་ཁྱབ་པར་གསལ།།
SL=སྣ་མའི་མེ་ཏོག་ལེགས་བཀབ་ཀྱང་།། དྲི་ཞིམ་ཀུན་ཏུ་ཁྱབ་པར་འགྱུར།།
[9]
FL=བློ་དང་ལྡན་ན་ཉམ་ཆུང་ཡང་།། སྟོབས་ལྡན་དགྲ་བོས་ཅི་བྱར་ཡོད།།
SL=རི་དྭགས་རྒྱལ་པོ་སྟོབས་ལྡན་ཡང་།། རི་བོང་བློ་དང་ལྡན་པས་བསད།།
[10]
FL=བླུན་པོ་བྱ་བ་ལ་སྦྱར་ན།། དོན་ཉམས་དེ་ཡང་ཉམས་པར་འགྱུར།།
SL=ཝ་སྐྱེས་རྒྱལ་པོར་བསྐོས་པ་ཡིས།། འཁོར་སྡིག་རང་ཡང་བསད་ཅེས་གྲགས།།
[11]
FL=ཕན་དང་མི་ཕན་མི་དཔྱོད་ཅིང་།། བློ་དང་ཐོས་པ་མི་སྒྲུབ་པར།།
SL=ལྟོ་འགྲངས་འབའ་ཞིག་དོན་གཉེར་བ།། སྤུ་མེད་པ་ཡི་ཕག་པ་ཡིན།།
[12]
FL=ཡོན་ཏན་ཆུང་རྣམས་ང་རྒྱལ་ཆེ།། མཁས་པར་གྱུར་ན་དུལ་བར་གནས།།
SL=ཆུ་ཕྲན་རྟག་ཏུ་ཀུ་ཅོ་ཆེ།། རྒྱ་མཚོས་ཅ་ཅོ་ག་ལ་སྒྲོག།
[13]
FL=དམ་པ་དུལ་བས་རང་གཞན་སྐྱོང་།།ངན་པ་རེངས་པས་རང་གཞན་སྡུག།
SL=འབྲས་ལྡན་ཤིང་གིས་རང་གཞན་སྲུང་།། ཤིང་སྐམ་རེངས་པས་རང་གཞན་སྲེག།
[14]
FL=ཧ་ཅང་གཡོ་སྒྱུ་མང་དྲགས་ན།། རེ་ཞིག་གྲུབ་ཀྱང་མཐའ་མར་བརླགས།།
SL=གཟིག་ལྤགས་བཀབ་པའི་བོང་བུ་ཡིས།། ལོ་ཏོག་ཟོས་མཐར་གཞན་གྱི་བསད།།
[15]
FL=གཡོ་ཅན་བཟང་བོའི་ཚུལ་བཟུང་ནས།། ཕྱི་ནས་དོན་ལ་བསླུ་བ་ཡོད།།རི་དྭགས་རྔ་མ་བསྟན་ནས་ནི།། ཁྲེལ་འདས་བོང་བུའི་ཤ་དག་འཚོང་།།
SL=མང་བོ་གཅིག་ཏུ་བློ་མཐུན་ན།། ཉམ་ཆུང་གིས་ཀྱང་དོན་ཆེན་འགྲུབ།།སྲོག་ཆགས་གྲོག་མའི་ཚོགས་འདུས་པས།།སེང་གེའི་ཕྲུ་གུ་བསད་ཅེས་གྲགས།།
[16]
FL=བདག་ཉིད་དཔོན་དུ་བསྐོས་གྱུར་ན།། དེ་ཡི་བྱ་བ་ཤེས་པ་དཀོན།།
SL=གཞན་ལ་ལྟ་བའི་མིག་ཡོད་ཀྱང་།། རང་ཉིད་བལྟ་ན་མེ་ལོང་དགོས།།
[17]
FL=རང་གིས་ངན་སྤྱོད་མ་བྱས་ན།། བརྒྱ་བྱིན་གྱིས་ཀྱང་སྨན་མི་ནུས།།
SL=ཆུ་མིག་རང་ཉིད་མ་བསྐམས་ན།། ས་ཡིས་མནན་པས་ག་ལ་ཐུབ།།
[18]
FL=བློ་ལྡན་བྱ་བ་ཅུང་ཟད་ཀྱང་།། རྒྱུན་དུ་གྲོས་ཀྱིས་བསྒྲུབ་པར་བྱ།།
SL=གྲུབ་པར་གྱུར་ན་ལྟ་ཅི་སྨྲོས།། མ་གྲུབ་ན་ཡང་མཛེས་པའི་རྒྱུ།།
[19]
FL=རང་ལ་དགོས་པའི་བསྟན་བཅོས་རྣམས།། ཉི་མ་རེ་ལ་ཚིག་རེ་ཟུངས།།
SL=གྲོག་མཁར་དང་ནི་སྦྲང་རྩི་ལྟར།། རིང་བོར་མི་ཐོགས་མཁས་པར་འགྱུར།།
[20]
FL=མཁས་པ་ཡོན་ཏན་མཛོད་འཛིན་པ།། དེ་དག་ལེགས་བཤད་རིན་ཆེན་སྡུད།།
SL=རྒྱ་མཚོ་ཆེན་པོ་ཆུ་བོའི་གཏེར།། ཡིན་ཕྱིར་ཆུ་ཕྲན་ཐམས་ཅད་འབབ།།
[21]
FL=ཡོན་ཏན་ལྡན་ན་སྐྱེ་བོ་ཀུན།། མ་བསྡུས་པར་ཡང་རང་ཉིད་འདུ།།
SL=དྲི་ལྡན་མེ་ཏོག་རྒྱང་རིང་ཡང་།། བུང་བ་སྤྲིན་གྱི་ཚོགས་བཞིན་འཁོར།།
[22]
FL=བློ་གྲོས་ལྡན་པ་གཉིས་བགྲོས་ན།། བློ་གྲོས་ལེགས་པ་གཞན་འབྱུང་སྲིད།།
SL=ཡུང་བ་དང་ནི་ཚ་ལེ་ལས།། ཁ་དོག་གཞན་ཞིག་སྐྱེ་བར་འགྱུར།།
[23]
FL=ཐབས་ལ་མཁས་ན་ཆེན་པོ་ཡང་།། བྲན་དུ་བཀོལ་བར་ག་ལ་དཀའ།།
SL=མཁའ་ལྡིང་མཐུ་རྩལ་ཆེ་ན་ཡང་།། གོས་སེར་ཅན་གྱི་བཞོན་པར་གྱུར།།
[24]
FL=བློ་དང་ལྡན་ན་མ་སྨྲས་ཀྱང་།། རྣམ་འགྱུར་ཉིད་ལས་བསམ་པ་གོ།
SL=བལ་བོའི་སེའུ་མ་ཟོས་ཀྱང་།། ཁ་དོག་ཉིད་ལས་བྲོ་བ་ཤེས།།
[25]
FL=དམ་པ་རྒྱང་ན་གནས་ན་ཡང་།། འཁོར་འདབས་ཕན་པས་རིང་ནས་སྐྱོང་།།
SL=མཁའ་ལ་སྤྲིན་ཆེན་འཁྲིགས་པ་ཡིས།། ས་ཡི་ལོ་ཏོག་ཁྱད་པར་འཕེལ།།
[26]
FL=དམ་པ་སྡིག་པ་ཆུང་ཡང་སྤོང་།། དམན་རྣམས་ཆེན་པོའང་དེ་ལྟ་མིན།།
SL=ཞོ་ལ་རྡུལ་ཕྲན་འབྱར་བ་སེལ།།ཆང་ལ་ཕབ་ཀྱང་ལྷག་པར་འདེབས།།
[27]
FL=རྒྱལ་པོ་རང་ཡུལ་ཆེ་བ་ཙམ།། དམ་པ་གང་དུ་ཕྱིན་པར་བཀུར།།
SL=མེ་ཏོག་ཕལ་ཆེར་ཉིན་རེའི་རྒྱན།། གཙུག་གི་ནོར་བུ་གང་དུའང་མཆོད།།
[28]
FL=རིག་པ་ནངས་པར་འཆི་ཡང་བསླབ།། ཚེ་འདིར་མཁས་པར་མ་གྱུར་ཀྱང་།།
SL=སྐྱེ་བ་ཕྱི་མར་བཅོལ་བ་ཡི།། ནོར་ལ་རང་ཉིད་ལེན་དང་མཚུངས།།

View File

@ -1,161 +1,168 @@
[1]
FL=因为有悔,所以披星戴月
SL=因为有梦,所以奋不顾身
author=
OL=天生我材必有用,千金散尽还复来。
author=李白《将进酒》
[2]
OL=大直若屈,大巧若拙,大辩若讷
author=《老子》
OL=新时代的伟大成就是党和人民一道拼出来、干出来、奋斗出来的
author=习近平
[3]
OL=博学之,审问之,慎思之,明辨之,笃行之
author=《礼记
OL=莫愁前路无知己,天下谁人不识君
author=高适《别董大二首
[4]
OL=兼听则明,偏听则暗
author=《资治通鉴
OL=莫听穿林打叶声,何妨吟啸且徐行
author=苏轼《定风波
[5]
FL=一花一世界,一叶一追寻。
SL=一曲一场叹,一生为一人。
author=威廉·布莱克《天真的预言》
OL=党用伟大奋斗创造了百年伟业,也一定能用新的伟大奋斗创造新的伟业。
author=习近平
[6]
FL=月光下,你带着笑地向我步来,
SL=月色与雪色之间,你是第三种绝色。
author=余光中
OL=巧言令色,鲜矣仁!
author=《论语》
[7]
OL=不要问我心里有没有你,我余光中都是你。
author=余光中
FL=与君初相识,犹如故人归。
SL=天涯明月新,朝暮最相思。
author=杜牧《会友》
[8]
FL=你要是愿意,我就永远爱你,
SL=你要是不愿意,我就永远相思
author=王小波
FL=一个饱经沧桑而初心不变的党,才能基业常青;
SL=一个铸就辉煌仍勇于自我革命的党,才能无坚不摧
author=习近平
[9]
FL=草在结它的种子,风在摇它的叶子。
SL=我们站着,不说话,就十分美好。
author=顾城
OL=见贤思齐焉,见不贤而内自省也。
author=《论语》
[10]
OL=见到你,我觉得多少适应了这个世界
author=村上春树
OL=为政以德,譬如北辰,居其所而众星共之
author=《论语》
[11]
OL=不须耳鬓常厮伴,一笑低头意已倾。
author=朱生豪
FL=道阻且长,行则将至。前进道路上,无论是风高浪急还是惊涛骇浪,
SL=人民永远是我们最坚实的依托、最强大的底气。
author=习近平
[12]
FL=君臣一梦,今古空名。
SL=但远山长,云山乱,晓山青。
author=苏轼
OL=知彼知己,百战不殆。
author=《孙子兵法》
[13]
FL=心如规矩,志如尺衡,
SL=平静如水,正直如绳。
author=严遵
OL=人患不知其过,既知之,不能改,是无勇也。
author=韩愈《五箴》
[14]
OL=近水知鱼性,近山识鸟音。
author=周希陶
FL=新征程是充满光荣和梦想的远征。蓝图已经绘就,号角已经吹响。
SL=我们要踔厉奋发、勇毅前行,努力创造更加灿烂的明天。
author=习近平
[15]
OL=此处果有可乐,我即别无所思。
author=林语堂
OL=万物并育而不相害,道并行而不相悖
author=《礼记·中庸》
[16]
FL=心之所向,素履以往,
SL=生如逆旅,一苇以航。
author=七堇年《尘曲》
OL=自信人生二百年,会当水击三千里
author=毛泽东《七古·残句》
[17]
FL=你说,我们就山居于此吧,
SL=胭脂用尽时,桃花就开了。
author=与谢野晶子
OL=我们完全有信心有能力在新时代新征程创造令世人刮目相看的新的更大奇迹。
author=习近平
[18]
OL=世间所有的相遇,都是久别重逢
author=白落梅
OL=青春虚度无所成,白首衔悲亦何及
author=权德舆《放歌行》
[19]
OL=浮云一别后,流水十年间
author=韦应物《淮上喜会梁川故人》
OL=劳动模范是民族的精英、人民的楷模,是共和国的功臣
author=习近平
[20]
OL=最是人间留不住,朱颜辞镜花辞树。
author=王国维《蝶恋花》
FL=当前最重要的任务是撸起袖子加油干,
SL=一步一个脚印把党的二十大作出的重大决策部署付诸行动、见之于成效。
author=习近平
[21]
OL=行到水穷处,坐看云起时。
author=王维
FL=广大人民群众坚持爱国奉献,无怨无悔,让我感到千千万万普通人最伟大,
SL=同时让我感到幸福都是奋斗出来的。
author=2018新年贺词 习近平
[22]
OL=我有一瓢酒,可以慰风尘
author=韦应物
OL=中华文化既是历史的、也是当代的,既是民族的、也是世界的
author=习近平
[23]
OL=墙头马上遥相顾,一见知君即断肠
author=白居易
OL=没有坚实的物质技术基础,就不可能全面建成社会主义现代化强国
author=习近平
[24]
OL=人生到处知何似,应似飞鸿踏雪泥
author=《和子由渑池怀旧》
OL=我们党没有自己的特殊利益,党在任何时候都是把群众利益放在第一位
author=习近平
[25]
OL=粗缯大布裹生涯,腹有诗书气自华
author=《和董传留别
OL=知者行之始。行者知之成
author=王阳明《传习录·卷上·门人陆澄录
[26]
OL=清风徐来,水波不兴。
author=《前赤壁赋》
FL=江山就是人民,人民就是江山。
SL=中国共产党领导人民打江山、守江山,守的是人民的心,治国有常,利民为本。
author=习近平
[27]
OL=我有斗酒,藏之久矣,以待子不时之须
author=《后赤壁赋》
OL=此心不动,随机而动
author=王阳明
[28]
FL=若是有缘,千山暮雪,万里层云,终会重逢。
SL=若是无缘,自此一去,天涯海角,再难相会。
author=白落梅《你若安好便是晴天》
OL=你未看此花时,此花与汝心同归于寂。
author=《传习录·卷下·门人黄省曾录》
[29]
FL=愿你一生努力,一生被爱。
SL=想要的都拥有,得不到的都释怀
author=八月长安
FL=时代呼唤我们,人民期待着我们,
SL=唯有矢志不渝、笃行不怠,方能不负时代、不负人民
author=习近平
[30]
OL=凌晨四点醒来,发现海棠花未眠
author=川端康成
OL=省察是有事时存养,存养是无事时省察
author=王阳明《传习录》
[31]
OL=无路可走的时候,就不断回到原点
author=东野圭吾
OL=路漫漫其修远兮,吾将上下而求索
author=《离骚》
[32]
OL=你要批评指点四周的风景,你首先要爬上屋顶
author=歌德
OL=当代中国青年生逢其时,施展才干的舞台无比广阔,实现梦想的前景无比光明
author=习近平
[33]
OL=只有流过血的手指,才能弹出世间的绝唱。
author=泰戈尔
FL=解决台湾问题是中国人自己的事,要由中国人来决定。
SL=国家统一、民族复兴的历史车轮滚滚向前,祖国完全统一一定要实现,也一定能够实现。
author=习近平
[34]
FL=幸亏时光不会倒流,
SL=否则万物一定会朝旧岁月里疾步奔跑。
author=《迷楼》
OL=悲莫悲兮生别离,乐莫乐兮新相知。
author=《九歌·少司命》
[35]
FL=我看到那些岁月如何奔驰,
SL=挨过了冬季,便迎来了春天。
author=《瓦尔登湖》
OL=风飒飒兮木萧萧,思公子兮徒离忧。
author=《九歌·山鬼》
[36]
FL=整个世界展现在我们面前,
SL=期待着我们去创造,而不是去重复。
author=毕加索
OL=善守者,藏于九地之下,善攻者,动于九天之上。
author=《孙子兵法》
[37]
FL=不必太纠结于当下,也不必太忧虑未来
SL=当你经历过一些事情的时候,眼前的风景已经和从前不一样了
author=村上春树
FL=我们正意气风发迈向全面建设社会主义现代化国家新征程
SL=向第二个百年奋斗目标进军,以中国式现代化全面推进中华民族伟大复兴
author=习近平
[38]
OL=三更梦醒,你是檐上落下的星
author=佚名
OL=善战者,致人而不致于人
author=《孙子兵法·虚实第六》
[39]
OL=我将永远忠于自己,披星戴月的奔向理想与自由
author=佚名
OL=乱生于治,怯生于勇,弱生于强
author=《孙子兵法·兵势第五》
[40]
OL=有一天我看了43次日落
author=《小王子》
FL=中国式现代化是中国共产党和中国人民长期实践探索的成果,
SL=是一项伟大而艰巨的事业。惟其艰巨,所以伟大;惟其艰巨,更显光荣。
author=习近平
[41]
OL=当太阳升到最高点的时候,影子就不见了
author=佚名
OL=不战而屈人之兵,善之善者也
author=《孙子兵法·谋攻第三》
[42]
OL=拯救地球好累,虽然有些疲惫但我还是会
author=超人不会飞
OL=天行健,君子以自强不息
author=周易.乾卦
[43]
OL=陌上花开,可缓缓归矣
author=佚名
FL=中国开放的大门只会越来越大。我们将坚定不移全面深化改革开放,
SL=坚定不移推动高质量发展,以自身发展为世界创造更多机遇。
author=习近平
[44]
OL=别慌,月亮也正在大海某处迷茫
author=佚名
OL=积善之家,必有余庆;积不善之家,必有余殃。
author=《周易.坤卦》
[45]
OL=夏天到了,春天的不甘该统统放下了
author=佚名
OL=穷则变,变则通,通则久。
author=《周易.系辞下》
[46]
OL=保持热爱,奔赴山海
author=佚名
FL=我们历来主张,人类的前途命运应该由世界各国人民来把握和决定。
SL=只要共行天下大道,各国就能够和睦相处、合作共赢,携手创造世界的美好未来。
author=习近平
[47]
FL=你好,是故事的开始,
SL=你要好好的,是故事的结局。
author=佚名
OL=天若有情天亦老,人间正道是沧桑
author=毛泽东《七律·人民解放军占领南京》
[48]
OL=工欲善其事,必先利其器。
author=《孔子》
OL=仰天大笑出门去,我辈岂是蓬蒿人。
author=李白《南陵别儿童入京》
[49]
OL=落叶秋风生渭水,落叶满长安。
author=贾岛《忆江上吴处士》
[50]
OL=人生来是精神所附丽的物质,免不掉物质所常有的惰性。
author=朱光潜《朝抵抗力最大的路径走》
[51]
FL=能朝抵抗力最大的路径走,是人的特点。
SL=人在能尽量发挥这特点时,就足见出他有富裕的生活力。
author=朱光潜《朝抵抗力最大的路径走》

View File

@ -34,7 +34,6 @@
#include "config.h"
#define WORKING_DIRECTORY "/usr/share/ukui-screensaver"
bool bControlFlg = false;//是否控制面板窗口
int main(int argc, char *argv[])
@ -45,18 +44,10 @@ int main(int argc, char *argv[])
#endif
QApplication a(argc, argv);
prctl(PR_SET_PDEATHSIG, SIGHUP);
//加载翻译文件
QString locale = QLocale::system().name();
QTranslator translator;
QString qmFile = QString(WORKING_DIRECTORY"/i18n_qm/%1.qm").arg(locale);
translator.load(qmFile);
a.installTranslator(&translator);
qDebug() << "load translation file " << qmFile;
QCommandLineParser parser;
QString windowId;
Screensaver s;
Screensaver s(false);
XWindowAttributes xwa;
parser.setApplicationDescription("Test helper");
@ -88,7 +79,7 @@ int main(int argc, char *argv[])
s.winId();
s.windowHandle()->setParent(window);
XGetWindowAttributes (QX11Info::display(), wid, &xwa);
/*
#ifndef USE_INTEL
XClassHint ch;
ch.res_name = NULL;
@ -96,10 +87,9 @@ int main(int argc, char *argv[])
XGetClassHint (QX11Info::display(), wid, &ch);
if(ch.res_name && strcmp(ch.res_name,"ukui-control-center")==0){
bControlFlg = true;
s.addClickedEvent();
}
#endif
*/
//获取屏保所在屏幕对应的缩放比例。
for(auto screen : QGuiApplication::screens())
{

View File

@ -48,14 +48,16 @@
#include <QX11Info>
#include <QDBusInterface>
#include <QDBusReply>
#include <QTranslator>
#include <QApplication>
#include "../src/weathermanager.h"
#include "commonfunc.h"
#include "screensaver.h"
#include <X11/extensions/XTest.h>
#include <X11/keysym.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include "commonfunc.h"
#include "config.h"
#define TIME_TYPE_SCHEMA "org.ukui.control-center.panel.plugins"
@ -66,11 +68,13 @@
#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(QWidget *parent):
Screensaver::Screensaver(bool isscreensaver,QWidget *parent):
isScreensaver(isscreensaver),
QWidget(parent),
switchTimer(nullptr),
backgroundPath(""),
@ -93,9 +97,16 @@ Screensaver::Screensaver(QWidget *parent):
hasChanged(false),
process(nullptr),
screenLabel(nullptr),
respondClick(false),
m_weatherManager(new WeatherManager(this))
respondClick(false)
{
//加载翻译文件
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();
@ -117,7 +128,7 @@ Screensaver::Screensaver(QWidget *parent):
m_background = new MBackground();
QString backgroundFile = configuration->getDefaultBackground();
background = QPixmap(backgroundFile);
background = loadFromFile(backgroundFile);
QList<QLabel*> labelList = this->findChildren<QLabel *>();
for(int i = 0;i<labelList.count();i++)
@ -173,7 +184,7 @@ void Screensaver::themeChanged()
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:18px;border-radius: 6px;background: %1;color: %2;padding: 24px 48px 24px 48px;border-width: 1px;border-style: solid;border-color:%3;") \
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));
}
}
@ -367,7 +378,7 @@ bool Screensaver::eventFilter(QObject *obj, QEvent *event)
#ifndef USE_INTEL
if(obj == this){
if(event->type()==QEvent::MouseButtonPress){
if(respondClick){
if(!isScreensaver){
if(!process){
process = new QProcess(this);
}
@ -495,7 +506,7 @@ void Screensaver::resizeEvent(QResizeEvent */*event*/)
{
float scale = 1.0;
scale = (float)width()/1920;
if(width() < 600 || height()<400){//当显示在控制面板上时,字体缩小三倍。
if((width() < 600 || height()<400) && !isScreensaver){//当显示在控制面板上时,字体缩小三倍。
if(flag == 0)
{
QList<QLabel*> labelList = this->findChildren<QLabel *>();
@ -651,7 +662,10 @@ void Screensaver::setUpdateCenterWidget()
lang=lang.split('.')[0];
qDebug()<<"langStr = "<<lang;
}
QString languageFilePath=languageDirPath+"screensaver-"+lang+".ini";
//不管系统语言,默认显示中文
QString languageFilePath=languageDirPath+"screensaver-zh_CN.ini";
//QString languageFilePath=languageDirPath+"screensaver-"+lang+".ini";
QString homeLanguageFilePath=homePath+"/.config/ukui/screensaver-"+lang+".ini";
QString jdLanguageFilePath=languageDirPath+"screensaver-jd" + ".ini";
qDebug()<<"langnguageFile = "<<languageFilePath;
@ -710,7 +724,7 @@ void Screensaver::updateBackgroundPath()
void Screensaver::enterEvent(QEvent*){
// qDebug() << "enter ScreenSaver::enterEvent";
//当前是否是控制面板窗口
if(bControlFlg){
if(!isScreensaver){
setPreviewText(true);
}
}
@ -724,7 +738,7 @@ void Screensaver::leaveEvent(QEvent*){
void Screensaver::startSwitchImages()
{
if(!imagePaths.empty()) {
background = QPixmap(imagePaths.at(0));
background = loadFromFile(imagePaths.at(0));
currentPath = imagePaths.at(0);
qDebug()<<currentPath;
is_gif = currentPath.endsWith(".gif");
@ -733,7 +747,7 @@ void Screensaver::startSwitchImages()
connect(switchTimer, &QTimer::timeout, this, [&]{
if(isAutoSwitch){
int index = qrand() % imagePaths.count();
background = QPixmap(imagePaths.at(index));
background = loadFromFile(imagePaths.at(index));
currentPath = imagePaths.at(index);
is_gif = currentPath.endsWith(".gif");
}else{
@ -742,7 +756,7 @@ void Screensaver::startSwitchImages()
}else{
currentIndex ++;
}
background = QPixmap(imagePaths.at(currentIndex));
background = loadFromFile(imagePaths.at(currentIndex));
currentPath = imagePaths.at(currentIndex);
is_gif = currentPath.endsWith(".gif");
}
@ -790,7 +804,10 @@ void Screensaver::updateCenterWidget(int index)
}
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());
@ -798,8 +815,14 @@ void Screensaver::updateCenterWidget(int index)
}
else if(qsettings->contains("FL"))
{
centerlabel1->setText(qsettings->value("FL").toString());
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());
@ -1038,7 +1061,7 @@ void Screensaver::updateDate()
timer->setTimerType(Qt::PreciseTimer);
connect(timer, SIGNAL(timeout()), this, SLOT(updateTime()));
}
timer->start(800);
timer->start(500);
updateTime();
}
@ -1078,15 +1101,19 @@ void Screensaver::updateTime()
m_currentTime = QTime::currentTime();
#else
QDateTime curDateTime = QDateTime::currentDateTime();
if (m_lastDateTime.isNull() || qAbs(curDateTime.secsTo(m_lastDateTime)) >=1) {
if(timeType == 12)
this->dateOfLocaltime->setText(QDateTime::currentDateTime().toString("A hh:mm"));
this->dateOfLocaltime->setText(curDateTime.toString("A hh:mm"));
else
this->dateOfLocaltime->setText(QDateTime::currentDateTime().toString("hh:mm"));
this->dateOfLocaltime->setText(curDateTime.toString("hh:mm"));
if(dateType == "cn")
this->dateOfDay->setText(QDate::currentDate().toString("yyyy/MM/dd ddd"));
this->dateOfDay->setText(curDateTime.date().toString("yyyy/MM/dd ddd"));
else
this->dateOfDay->setText(QDate::currentDate().toString("yyyy-MM-dd ddd"));
this->dateOfDay->setText(curDateTime.date().toString("yyyy-MM-dd ddd"));
m_lastDateTime = curDateTime;
}
if(sleepTime){
if(!sleepTime->setTime(QDateTime::currentDateTime())){
@ -1107,7 +1134,7 @@ void Screensaver::updateBackground()
{
QString path = m_background->getRand();
if(!path.isEmpty() && ispicture(path)){
background = QPixmap(path);
background = loadFromFile(path);
hasChanged=true;
isMovie();
}
@ -1122,7 +1149,7 @@ void Screensaver::setRandomText()
cycleLabel = new QLabel(this);
cycleLabel->setFixedSize(16,16);
layout->addWidget(cycleLabel);
layout->setSpacing(16);
layout->setSpacing(8);
myTextLabel = new QLabel(myTextWidget);
myTextLabel->setObjectName("myText");
// myTextLabel->setBackgroundRole(QPalette::Base);
@ -1147,7 +1174,7 @@ void Screensaver::setRandomText()
// .arg(stringColor).arg(textString).arg(borderString));
blur_Num = configuration->getBlurNumber();
curStyle = configuration->getcurStyle();
qDebug()<<"cuStyle= "<<curStyle;
qDebug()<<"curStyle= "<<curStyle;
if(curStyle == "ukui-dark" || curStyle == "ukui-black"){
myTextLabel->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));
@ -1214,7 +1241,10 @@ void Screensaver::setCenterWidget()
authorlabel = new QLabel("");
}
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(' '));
centerlabel2 = new QLabel("");
centerlabel2->hide();
#ifndef USE_INTEL
@ -1223,8 +1253,14 @@ void Screensaver::setCenterWidget()
}
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")
centerlabel2 = new QLabel(qsettings->value("SL").toString());
else
centerlabel2 = new QLabel(qsettings->value("SL").toStringList().join(' '));
centerlabel2->show();
#ifndef USE_INTEL
authorlabel = new QLabel(qsettings->value("author").toString());
@ -1356,6 +1392,15 @@ void Screensaver::hideNotice()
{
m_widgetNotice->hide();
}
QPixmap Screensaver::loadFromFile(QString strPath)
{
QImageReader reader;
reader.setFileName(strPath);
reader.setAutoTransform(true);
reader.setDecideFormatFromContent(true);
return QPixmap::fromImageReader(&reader);
}
/*
void Screensaver::setDesktopBackground()
{

View File

@ -37,14 +37,15 @@
#include "checkbutton.h"
#include "scconfiguration.h"
#include "cyclelabel.h"
#include "weathermanager.h"
class WeatherManager;
class Screensaver : public QWidget
{
Q_OBJECT
public:
explicit Screensaver(QWidget *parent = 0);
explicit Screensaver(bool isScreensaver,QWidget *parent = 0);
~Screensaver();
void addClickedEvent();
@ -69,6 +70,7 @@ private:
void enterEvent(QEvent*);
void leaveEvent(QEvent*);
void isMovie();
QPixmap loadFromFile(QString strPath);
QTimer *switchTimer;
QTimer *fadeTimer;
@ -135,7 +137,7 @@ private:
int blur_Num;
QString curStyle;
WeatherManager *m_weatherManager;
WeatherManager *m_weatherManager=nullptr;
QWidget *m_weatherLaout;
QLabel *m_weatherIcon;
QLabel *m_weatherArea;
@ -153,7 +155,8 @@ private:
int delayTime;
QTimer *movieTimer = nullptr;
int currentCount = 0;
QDateTime m_lastDateTime;
bool isScreensaver = false;
protected:
void paintEvent(QPaintEvent *event);
void resizeEvent(QResizeEvent *event);

View File

@ -0,0 +1,27 @@
#ifndef SCREENSAVER_PLUGIN_H
#define SCREENSAVER_PLUGIN_H
#include <QWidget>
class ScreensaverPlugin
{
public:
virtual ~ScreensaverPlugin() {}
//插件实例的名称
virtual QString name() const = 0;
//创建UI的实例
virtual QWidget* createWidget(bool isScreensaver,QWidget* parent) = 0;
//获得插件的展示名称
virtual QString displayName() const = 0;
};
//定义了在QT系统中该接口的全局唯一的ID
//实现该SDK的插件也要定义相同的ID
//接口的ID中包含了版本信息,通过该ID我们可以区别不同版本的SDK和插件
//Q_DECLARE_INTERFACE宏将类型和ID关联起来,这样QT就可以验证加载的插件是否可以转换成MyPluginInterface类型
#define interface_iid "org.ukui.screensaver.screensaver-default1.0.0"
Q_DECLARE_INTERFACE(ScreensaverPlugin, interface_iid)
#endif // FILTER_H

View File

@ -22,7 +22,9 @@
#include <QListWidget>
SleepTime::SleepTime(QWidget *parent) : QWidget(parent),
sleepTime(0)
sleepTime(0),
m_nLastSleepLeave(0),
m_nLastSleepTimeSecs(0)
{
init();
}
@ -36,29 +38,21 @@ void SleepTime::init()
{
layout = new QHBoxLayout(this);
layout->setDirection(QBoxLayout::RightToLeft);
layout->setSpacing(4);
layout->setSpacing(8);
for(int i=0;i<2;i++)
for(int i=0;i<3;i++)
{
QLabel *label = new QLabel(this);
label->setText("0");
label->setFixedSize(40,40);
label->setObjectName("clockTime");
list.append(label);
}
if (i < 2) {
QLabel *colon = new QLabel(this);
colon->setText(":");
colon->setObjectName("colon");
list.append(colon);
for(int i=0;i<2;i++)
{
QLabel *label = new QLabel(this);
label->setText("0");
label->setFixedSize(40,40);
label->setObjectName("clockTime");
list.append(label);
}
}
for(int i=0;i<list.count();i++)
@ -67,48 +61,82 @@ void SleepTime::init()
}
restTime = new QLabel(this);
restTime->setText(tr("You have rested:"));
restTime->setText(tr("You have rested"));
restTime->setObjectName("restTime");
restTime->setAlignment(Qt::AlignBottom);
restTime->adjustSize();
layout->addSpacing(8);
layout->addWidget(restTime);
initTime = QDateTime::currentDateTime();
m_lastTime = initTime;
}
int SleepTime::setTime(QDateTime time)
{
sleepTime = initTime.secsTo(time);
if(sleepTime>5999 || sleepTime<0){
hide();
return false;
// 与上一次取时间的时间差
long nNewSleepTime = qAbs(m_lastTime.msecsTo(time));
sleepTime = qAbs(initTime.msecsTo(time));
// 时间差大于1s则认为时间异常变化保存已过去的时间
if (nNewSleepTime > 1000) {
m_nLastSleepLeave += qAbs(m_lastTime.msecsTo(initTime));
sleepTime = 0;
initTime = time;
}
m_lastTime = time;
//当前时间差+异常情况过去的时间
sleepTime += m_nLastSleepLeave;
sleepTime = sleepTime/1000;
int sec = sleepTime % 60;
int min = sleepTime/60;
if (m_nLastSleepTimeSecs == 0 || qAbs(sleepTime - m_nLastSleepTimeSecs) >= 1) {
int hour = sleepTime / 3600;
int sec = sleepTime % 3600 % 60;
int min = sleepTime % 3600 / 60;
setHour(hour);
setSeconds(sec);
setMinute(min);
m_nLastSleepTimeSecs = sleepTime;
}
return true;
}
void SleepTime::setHour(int hour)
{
QString time;
if (hour >= 100) {
QLabelSetText(list.at(4), QString::number(hour));
} else if (hour < 10) {
time = "0" + QString::number(hour);
list.at(4)->setText(time);
} else {
time = QString::number(hour);
list.at(4)->setText(time);
}
}
void SleepTime::setSeconds(int seconds)
{
int sec1 = seconds%10;
int sec2 = seconds/10;
list.at(0)->setText(QString::number(sec1));
list.at(1)->setText(QString::number(sec2));
QString time;
if (seconds < 10) {
time = "0" + QString::number(seconds);
} else {
time = QString::number(seconds);
}
list.at(0)->setText(time);
}
void SleepTime::setMinute(int minutes)
{
int min1 = minutes%10;
int min2 = minutes/10;
list.at(3)->setText(QString::number(min1));
list.at(4)->setText(QString::number(min2));
QString time;
if (minutes < 10) {
time = "0" + QString::number(minutes);
} else {
time = QString::number(minutes);
}
list.at(2)->setText(time);
}
void SleepTime::setSmallMode()
@ -117,3 +145,18 @@ void SleepTime::setSmallMode()
list.at(i)->setFixedSize(8,8);
adjustSize();
}
bool SleepTime::QLabelSetText(QLabel *label, QString string)
{
bool is_over_length = false;
QFontMetrics fontMetrics(label->font());
int fontSize = fontMetrics.width(string);
QString str = string;
if (fontSize > (label->width()-5)) {
str = fontMetrics.elidedText(string, Qt::ElideRight, label->width());
is_over_length = true;
}
label->setText(str);
return is_over_length;
}

View File

@ -39,12 +39,17 @@ private:
QLabel *restTime;
QList<QLabel *> list;
QHBoxLayout *layout;
int sleepTime;
long long sleepTime;
long long m_nLastSleepLeave;
long long m_nLastSleepTimeSecs;
QDateTime initTime;
QDateTime m_lastTime;
void init();
void setHour(int hour);
void setSeconds(int seconds);
void setMinute(int minutes);
bool QLabelSetText(QLabel *label, QString string);
};
#endif // SLEEPTIME_H

View File

@ -1,122 +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 <http://www.gnu.org/licenses/>.
*
* Authors: ZHAI Kang-ning <zhaikangning@kylinos.cn>
**/
#ifndef WEATHERMANAGER_H
#define WEATHERMANAGER_H
#include <QObject>
#include <functional>
#include <QTimer>
#include <QGSettings>
#include "../src/networkwatcher.h"
class QNetworkAccessManager;
class QNetworkReply;
class LocalWeatherInfo;
class WeatherManager : public QObject
{
Q_OBJECT
public:
explicit WeatherManager(QObject *parent = nullptr);
Q_SIGNALS:
void onWeatherUpdate(QString city, QString cond, QString temperature);
private Q_SLOTS:
void replyFinished(QNetworkReply *);
void onNetworkStateChanged(uint state);
public:
void getWeather();
QPixmap getWeatherIcon();
QPixmap getWeatherIcon(QString cond);
QString getCityName();
QString getCond();
QString getTemperature();
private:
bool updateLocation();//更新位置,从用户设置获取城市信息,如有多个,只取第一个,未对接
void weatherRequest();
bool getLogcalWeather();
QString getLogcalCityId();
private:
QString m_city_id; // "101030100" 默认天津
QString m_city_name;
QString m_cond_txt; //天气条件 晴、阴等
QString m_temperature;//温度 10、20等
QNetworkAccessManager *m_net_manager;
QTimer *m_timer;
QGSettings *m_settings;
LocalWeatherInfo *m_local_weather_info;
NetWorkWatcher *m_networkWatcher;
int m_networkTryNum = 0;
};
class LocalWeatherInfo : QObject
{
//"1920-08-27 10:17:42,101310204,澄迈,小雨,95%25℃,北风,1级," 时间,城市编码,城市名称,天气,湿度,温度,风向,风力
Q_OBJECT
public:
explicit LocalWeatherInfo(QObject *parent = nullptr);
private:
QString m_update_time;
QString m_city_id;
QString m_city_name;
QString m_cond_text;
QString m_air_humidity;
QString m_temperature;
QString m_wind_direction;
QString m_wind_force;
public:
bool isTimeValid();
void setTime(QString time);
QString getTime();
void setCityId(QString cityId);
QString getCityId();
void setCityName(QString cityName);
QString getCityName();
void setCondText(QString condText);
QString getCondText();
void setAirHumidity(QString airHumidity);
QString getAirHumidity();
void setTemperature(QString temperature);
QString getTemperature();
void setWindDirection(QString windDirection);
QString getWindDirection();
void setWindForce(QString windForce);
QString getWindForce();
};
#endif // WEATHERMANAGER_H

View File

@ -6,6 +6,7 @@ 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)
find_library(PAM_LIBRARIES pam)
@ -13,6 +14,7 @@ include_directories(${PROJECT_BINARY_DIR})
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)
@ -25,6 +27,7 @@ include_directories(
${QGS_INCLUDE_DIRS}
${GLIB_INCLUDE_DIRS}
${MMIX_INCLUDE_DIRS}
${kylin-nm-base_INCLUDE_DIRS}
)
set(EXTRA_LIBS
@ -38,6 +41,7 @@ set(EXTRA_LIBS
${MMIX_LIBRARIES}
-lrt
-lpthread
-llibnm-icon-kylin
)
qt5_wrap_ui(dialog_SRC
@ -48,6 +52,7 @@ qt5_wrap_ui(dialog_SRC
qt5_add_resources(dialog_SRC
assets.qrc
../KylinNM/nmqrc.qrc #
../screensaver/default.qrc
)
# Xlib.h
@ -60,7 +65,9 @@ qt5_wrap_cpp(dialog_SRC
screensaverwidget.h
auth.h
auth-pam.h
screensaver.h
authpamthread.h
screensavermode.h
screensaverwndadaptor.h
xeventmonitor.h
monitorwatcher.h
configuration.h
@ -86,10 +93,17 @@ qt5_wrap_cpp(dialog_SRC
networkwatcher.h
digitalkeyboard.h
surewindow.h
loginedusers.h
lockchecker.h
servicemanager.h
mytabwidget.h
PhysicalDeviceSet/brightnessdeviceset.h
PhysicalDeviceSet/flightmodeset.h
PhysicalDeviceSet/sounddeviceset.h
PhysicalDeviceSet/touchscreenset.h
device.h
enginedevice.h
batterywidget.h
)
set(dialog_SRC
@ -102,11 +116,13 @@ set(dialog_SRC
loginoptionswidget.cpp
screensaverwidget.cpp
auth-pam.cpp
authpamthread.cpp
xeventmonitor.cpp
monitorwatcher.cpp
grab-x11.cpp
configuration.cpp
screensaver.cpp
screensavermode.cpp
screensaverwndadaptor.cpp
powermanager.cpp
utils.cpp
users.cpp
@ -128,12 +144,20 @@ set(dialog_SRC
networkwatcher.cpp
digitalkeyboard.cpp
surewindow.cpp
loginedusers.cpp
lockchecker.cpp
servicemanager.cpp
mytabwidget.cpp
PhysicalDeviceSet/brightnessdeviceset.cpp
PhysicalDeviceSet/flightmodeset.cpp
PhysicalDeviceSet/sounddeviceset.cpp
PhysicalDeviceSet/touchscreenset.cpp
device.cpp
enginedevice.cpp
batterywidget.cpp
)
add_executable(ukui-screensaver-dialog ${dialog_SRC})
add_definitions(-DAPP_API_MAJOR=0 -DAPP_API_MINOR=11 -DAPP_API_FUNC=0)
target_link_libraries(ukui-screensaver-dialog
Qt5::Core
@ -148,6 +172,7 @@ target_link_libraries(ukui-screensaver-dialog
Common
Kylin-nm
ukui-log4qt
Screensaver
)
link_libraries(libmatemixer.so glib-2.0.so)

View File

@ -11,6 +11,9 @@ QPushButton::hover{
QPushButton::pressed {
background-color: rgba(255,255,255,40%);
}
QPushButton::checked {
background-color: rgba(255, 255, 255, 40%);
}
QToolButton{
text-align:center;
@ -60,7 +63,7 @@ QToolTip{
/* 密码输入框 */
QLineEdit {
background: #FFFFFF;
border: 1px solid #FFFFFF;
border: 2px solid #FFFFFF;
border-radius: 6px;
color:black;
font-size: 14px;
@ -68,10 +71,10 @@ QLineEdit {
}
QLineEdit::hover {
border: 1px solid #FFFFFF;
border: 2px solid #FFFFFF;
}
QLineEdit::focus{
border: 2px solid #2C73C8;
}
/* 大写提示 */
@ -95,6 +98,7 @@ QLineEdit::focus{
}
#echoModeButton::checked {
}
/* 登录按钮 */
#loginButton{
min-width: 24px;
@ -106,6 +110,11 @@ QLineEdit::focus{
border-radius:12px;
}
#loginButton::hover,
#loginButton::pressed{
background:#9B3D6BE5;
}
/* PAM message提示*/
#messageLabel {
font-size: 16px;
@ -124,7 +133,7 @@ QMenu{
background-color: rgb(255,255,255,15%);
color: white;
border-radius: 4px;
width:260px;
width:250px;
font-size: 16px;
padding: 5px 5px 5px 5px;
}

View File

@ -36,7 +36,6 @@ static int pam_conversation(int msgLength, const struct pam_message **msg,
void sigchld_handler(int signo);
AuthPAM::AuthPAM(QObject *parent)
: Auth(parent),
pid(0),
nPrompts(0),
_isAuthenticated(false),
_isAuthenticating(false)
@ -50,54 +49,33 @@ void AuthPAM::authenticate(const QString &userName)
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]);
m_authPamThread = new AuthPamThread();
m_authPamThread->startAuthPam(toChild[0], toParent[1], userName);
_isAuthenticating = true;
notifier = new QSocketNotifier(toParent[0], QSocketNotifier::Read);
connect(notifier, &QSocketNotifier::activated, this, &AuthPAM::onSockRead);
}
}
void AuthPAM::stopAuth()
{
if(pid != 0)
{
if (m_authPamThread) {
messageList.clear();
responseList.clear();
_isAuthenticating = false;
_isAuthenticated = false;
nPrompts = 0;
::kill(pid, SIGKILL);
close(toParent[0]);
close(toChild[1]);
if(notifier){
notifier->deleteLater();
disconnect(notifier, &QSocketNotifier::activated, this, &AuthPAM::onSockRead);
delete notifier;
notifier = nullptr;
}
pid = 0;
close(toParent[1]);
close(toChild[1]);
m_authPamThread->stopAuthPam();
delete m_authPamThread;
m_authPamThread = nullptr;
close(toParent[0]);
close(toChild[0]);
}
}

View File

@ -22,6 +22,7 @@
#include <QList>
#include <security/pam_appl.h>
#include "authpamthread.h"
typedef struct pam_message PAM_MESSAGE;
typedef struct pam_response PAM_RESPONSE;
@ -47,7 +48,7 @@ private Q_SLOTS:
private:
QString userName;
pid_t pid;
AuthPamThread *m_authPamThread = nullptr;
QSocketNotifier *notifier;
int nPrompts;
QStringList responseList;

View File

@ -36,13 +36,14 @@
#include "pam-tally.h"
#include "commonfunc.h"
#include "loginoptionswidget.h"
#include "servicemanager.h"
#include "imageutil.h"
AuthDialog::AuthDialog(const UserItem &user, QWidget *parent) :
QWidget(parent),
user(user),
auth(new AuthPAM(this)),
authMode(UNKNOWN),
m_deviceCount(-1),
m_biometricProxy(nullptr),
m_widgetLoginOpts(nullptr),
m_buttonsWidget(nullptr),
@ -52,17 +53,30 @@ AuthDialog::AuthDialog(const UserItem &user, QWidget *parent) :
m_timer(nullptr),
isLockingFlg(false),
m_nCurLockMin(0),
useFirstDevice(false)
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());
}
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);
useFirstDevice = getUseFirstDevice();
m_failedTimes.clear();
connect(m_messageButton, &QPushButton::clicked,
this, &AuthDialog::onMessageButtonClicked);
}
void AuthDialog::startAuth()
@ -88,29 +102,11 @@ void AuthDialog::stopAuth()
clearMessage();
// auth->stopAuth();
m_passwordEdit->readOnly(true);
// m_passwordEdit->readOnly(true);
// if(m_passwdWidget)
// m_passwdWidget->hide();
}
QPixmap AuthDialog::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;
}
void AuthDialog::initUI()
{
if (scale < 0.5) {
@ -132,6 +128,7 @@ void AuthDialog::initUI()
m_labelHeadImg->hide();
QPixmap facePixmap(user.icon);
facePixmap = scaledPixmap(facePixmap);
facePixmap = facePixmap.scaled(154*scale,154*scale, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
facePixmap = PixmapToRound(facePixmap, 77*scale);
m_labelHeadImg->setAlignment(Qt::AlignCenter);
@ -161,7 +158,6 @@ void AuthDialog::initUI()
m_labelQRCode->setLayout(layoutQRCode);
m_labelQRCodeTip = new QLabel();
m_labelQRCodeTip->setFixedSize(22,22);
m_labelQRCodeTip->setPixmap(QIcon::fromTheme("ukui-dialog-warning").pixmap(QSize(22,22)));
layoutQRCode->addWidget(m_labelQRCodeTip, 0, Qt::AlignHCenter);
m_labelQRCodeMsg = new QLabel();
m_labelQRCodeMsg->setFixedHeight(24);
@ -200,12 +196,16 @@ void AuthDialog::initUI()
m_passwdWidget->setInputMethodHints(Qt::ImhNone);
m_passwordEdit->setObjectName(QStringLiteral("passwordEdit"));
m_passwordEdit->setIcon(QIcon(":/image/assets/login-button.svg"));
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);
//setFocusProxy(m_passwordEdit);
connect(m_passwordEdit, SIGNAL(clicked(const QString&)),
this, SLOT(onRespond(const QString&)));
@ -375,6 +375,7 @@ void AuthDialog::setChildrenGeometry()
m_labelHeadImg->setStyleSheet(QString("border-radius: %1px; border:0px solid white;").arg(77*scale));
m_labelHeadImg->setGeometry((width() - 154*scale) / 2 , m_labelLoginTypeTip->geometry().bottom()+24*scale, 154*scale, 154*scale);
QPixmap facePixmap(user.icon);
facePixmap = scaledPixmap(facePixmap);
facePixmap = facePixmap.scaled(154*scale,154*scale, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
facePixmap = PixmapToRound(facePixmap, 77*scale);
m_labelHeadImg->setPixmap(facePixmap);
@ -395,9 +396,13 @@ void AuthDialog::setChildrenGeometry()
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, 20);
width()-(m_passwdWidget->width() - 240)/2, 36);
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)}");
setBiometricWidgetGeometry();
}
@ -580,6 +585,52 @@ void AuthDialog::setX11Focus()
}
}
void AuthDialog::setFocusin(int target)
{
if(m_passwordEdit && m_widgetLoginOpts) {
switch (target) {
case REMOVE: //焦点清除
m_widgetLoginOpts->tabOptionSelected(2);
m_passwordEdit->setFocusin(2);
m_nameLabel->setFocus();
break;
case IN_LIGIN: //焦点在登录按钮
m_widgetLoginOpts->tabOptionSelected(2);
m_passwordEdit->setFocusin(1);
break;
case BIO_RIGHT: //登录选项焦点右移
m_widgetLoginOpts->tabOptionSelected(0);
m_passwordEdit->setFocusin(2);
m_nameLabel->setFocus();
break;
case BIO_LEFT: //登录选项焦点左移
m_widgetLoginOpts->tabOptionSelected(1);
m_passwordEdit->setFocusin(target);
m_nameLabel->setFocus();
break;
case IN_LINEEDIT: //焦点在密码输入框
m_widgetLoginOpts->tabOptionSelected(2);
m_passwordEdit->setFocusin(0);
break;
default:
m_passwordEdit->setFocusin(target);
m_widgetLoginOpts->tabOptionSelected(2);
break;
}
}
}
void AuthDialog::setClick()
{
m_widgetLoginOpts->tabOptionSelected(3);
}
void AuthDialog::checkPassword()
{
m_passwordEdit->clicked_cb();
setFocusin(REMOVE);
}
void AuthDialog::onShowPrompt(const QString &prompt, Auth::PromptType type)
{
qDebug() << "-------prompt: " << prompt;
@ -620,6 +671,7 @@ void AuthDialog::onShowPrompt(const QString &prompt, Auth::PromptType type)
m_passwordEdit->clear();
m_passwordEdit->setPrompt(text);
m_passwordEdit->show();
m_passwordEdit->setFocus();
if(!m_timer){
m_timer = new QTimer(this);
m_timer->setInterval(200);
@ -667,17 +719,24 @@ 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();
m_messageButton->setFocus();
m_messageButton->setDefault(true);
connect(m_messageButton, &QPushButton::clicked,
this, &AuthDialog::onMessageButtonClicked);
if(successful)
{
isretry = false;
m_messageButton->setText(tr("Login"));
switchLoginOptType(LOGINOPT_TYPE_PASSWORD);
// QTimer::singleShot(100, this, [=](){
// qDebug()<<"Delay to focus msgBtn!!";
// m_messageButton->show();
// m_messageButton->setFocus();
// m_messageButton->setDefault(true);
// });
}
else
{
@ -706,6 +765,10 @@ void AuthDialog::onMessageButtonClicked()
void AuthDialog::onRespond(const QString &text)
{
if (!prompted && text != BIOMETRIC_SUCCESS) {
qInfo()<<"Wait for input passwd!";
return;
}
unacknowledged_messages=false;
clearMessage();
startWaiting();
@ -752,9 +815,14 @@ void AuthDialog::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())
@ -773,14 +841,8 @@ void AuthDialog::performBiometricAuth()
//初始化生物识别认证UI
initBiometricWidget();
//初始化enableBiometriAuth
if(m_deviceCount <= 0)
{
m_deviceCount = m_widgetLoginOpts->getLoginOptCount();
}
//没有可用设备,不启用生物识别认证
if(m_deviceCount < 1)
if(m_widgetLoginOpts->getLoginOptCount() < 1)
{
qWarning() << "No available devices";
skipBiometricAuth();
@ -788,9 +850,8 @@ void AuthDialog::performBiometricAuth()
}
//获取默认设备
if(m_deviceName.isEmpty())
{
m_deviceName = GetDefaultDevice(user.name);
if (m_widgetLoginOpts) {
m_deviceName = m_widgetLoginOpts->getDefaultDevice(user.name);
}
qDebug() << m_deviceName;
if (m_deviceInfo) {
@ -800,30 +861,24 @@ void AuthDialog::performBiometricAuth()
}
}
//如果默认设备为空的话,第一次不启动生物识别认证
//如果默认设备为空的话,不进行生物认证
if(m_deviceName.isEmpty() && !m_deviceInfo)
{
if(useFirstDevice == true) {
m_deviceInfo = m_widgetLoginOpts->getFirstDevInfo();
} else {
skipBiometricAuth();
return;
}
}
//clearMessage();
if(!m_deviceInfo)
{
m_deviceInfo = m_widgetLoginOpts->findDeviceByName(m_deviceName);
if (!m_deviceInfo)
m_deviceInfo = m_widgetLoginOpts->getFirstDevInfo();
}
if(!m_deviceInfo)
{
skipBiometricAuth();
return;
}
}
switchLoginOptType(m_widgetLoginOpts->convertDeviceType(m_deviceInfo->deviceType));
startBioAuth();
skipBiometricAuth();
@ -839,13 +894,15 @@ void AuthDialog::initBiometricWidget()
if(m_widgetLoginOpts) {
m_widgetLoginOpts->setUser(user.uid);
} else {
m_widgetLoginOpts = new LoginOptionsWidget(m_biometricProxy, user.uid, this);
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,
@ -874,10 +931,17 @@ void AuthDialog::setBiometricWidgetGeometry()
}
}
void AuthDialog::onDeviceChanged(unsigned uCurLoginOptType, const DeviceInfoPtr &deviceInfo)
int AuthDialog::getBioNum()
{
return m_widgetLoginOpts->getLoginOptCount();
}
void AuthDialog::onDeviceChanged(unsigned uCurLoginOptType, const DeviceInfoPtr &deviceInfo, bool keyNavigation)
{
if (!deviceInfo)
return;
if(!keyNavigation)
Q_EMIT loginOptionClicked();
qDebug() << "device changed: " << *deviceInfo;
if(m_failedTimes.contains(deviceInfo->id) &&
m_failedTimes[deviceInfo->id] >= maxFailedTimes){
@ -896,7 +960,13 @@ void AuthDialog::onDeviceChanged(unsigned uCurLoginOptType, const DeviceInfoPtr
void AuthDialog::onBiometricAuthComplete(bool result, int nStatus)
{
if(!result) {
if (nStatus >= 2) {
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;
@ -931,12 +1001,12 @@ void AuthDialog::onBiometricAuthComplete(bool result, int nStatus)
qDebug()<<"Biometric dbus error:"<<nStatus;
}
if (m_uCurLoginOptType == LOGINOPT_TYPE_QRCODE && nStatus == 1) {
setQRCodeMsg(tr("NET Exception"));
setQRCodeMsg(tr("Abnormal network"));
startBioAuth(10000);
} else {
startBioAuth();
}
if (nStatus >= 2 && m_deviceInfo) {
if (nStatus >= 2 && nStatus != 5 && m_deviceInfo) {
if (m_deviceInfo->deviceType == DeviceType::Face) {
QImage imgFailed;
setFaceImg(imgFailed, 1);
@ -985,6 +1055,7 @@ void AuthDialog::setQRCode(QImage& imgQRCode)
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);
@ -995,10 +1066,16 @@ void AuthDialog::setQRCodeMsg(QString strMsg)
{
if (strMsg.isEmpty()) {
m_labelQRCodeMsg->hide();
m_labelQRCodeTip->hide();
//m_labelQRCodeTip->hide();
} else {
//一开始认证时就没有网,直接停止加载状态
if(w_timer && w_timer->isActive())
{
w_timer->stop();
}
m_labelQRCodeMsg->setText(strMsg);
m_labelQRCodeMsg->show();
m_labelQRCodeTip->setPixmap(QIcon::fromTheme("dialog-warning").pixmap(QSize(22,22)));
m_labelQRCodeTip->show();
}
}
@ -1015,6 +1092,10 @@ void AuthDialog::setFaceImg(QImage& imgFace, int 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,20%);").arg(77*scale));
break;
default:
faceImage = QPixmap(":/image/assets/ukui-loginopt-smile.svg");
break;
@ -1025,6 +1106,19 @@ void AuthDialog::setFaceImg(QImage& imgFace, int nStatus)
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::setLoginTypeTip(QString strLoginTypeTip)
{
m_strLoginTypeTip = strLoginTypeTip;
@ -1044,7 +1138,7 @@ void AuthDialog::setLoginMsg(QString strLoginMsg)
setLoginTypeTip(strLoginMsg);
}
void AuthDialog::onLoginOptsCount(unsigned uCount)
void AuthDialog::onLoginOptsCount(unsigned uCount, bool is_bioBtn)
{
qDebug()<<"----------------------onLoginOptsCount Count:"<<uCount;
if (!m_widgetLoginOpts)
@ -1061,8 +1155,47 @@ void AuthDialog::onLoginOptsCount(unsigned uCount)
|| m_widgetLoginOpts->isDeviceDisable(m_deviceInfo->id)) {
m_widgetLoginOpts->stopAuth();
authMode = BIOMETRIC;
startAuth();
//初始化生物识别认证UI
initBiometricWidget();
//没有可用设备,不启用生物识别认证
if(m_widgetLoginOpts->getLoginOptCount() < 1)
{
qWarning() << "No available devices";
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();
}
if(is_bioBtn && uCount <= 1)
Q_EMIT loginOptionClicked();
}
void AuthDialog::onLoginOptImage(QImage img)
@ -1075,4 +1208,98 @@ void AuthDialog::onLoginOptImage(QImage 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:"<<bActive;
if (bActive) {
QTimer::singleShot(1000, this, [=](){
qDebug()<<"OnDelay init biometric!!";
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";
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";
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();
});
}
}

View File

@ -30,6 +30,7 @@
#include "users.h"
#include "biometricdeviceinfo.h"
#include "pam-tally.h"
#include "uniauthservice.h"
namespace Ui {
class AuthDialog;
@ -45,6 +46,14 @@ class BiometricDevicesWidget;
class PamTally;
class LoginOptionsWidget;
enum FOCUS {
REMOVE = 0,
IN_LIGIN,
BIO_RIGHT,
BIO_LEFT,
IN_LINEEDIT,
};
extern float scale;
class AuthDialog : public QWidget
{
@ -56,6 +65,10 @@ public:
void closeEvent(QCloseEvent *event);
void setUserOfAuth();
void setX11Focus();
void setFocusin(int target);
void setClick();
void checkPassword();
int getBioNum();
private:
void initUI();
void startWaiting();
@ -66,10 +79,10 @@ private:
void initBiometricWidget();
void setChildrenGeometry();
void setBiometricWidgetGeometry();
QPixmap PixmapToRound(const QPixmap &src, int radius);
void startBioAuth(unsigned uTimeout = 1000);
void show_authenticated (bool successful = true);
void setLoginTypeTip(QString strLoginTypeTip);
void updatePixmap();
private Q_SLOTS:
void onShowMessage(const QString &message, Auth::MessageType type);
@ -80,7 +93,7 @@ private Q_SLOTS:
// void onBioAuthStop();
// void setBioMovieImage();
// void updateIcon();
void onDeviceChanged(unsigned uCurLoginOptType, const DeviceInfoPtr &deviceInfo);
void onDeviceChanged(unsigned uCurLoginOptType, const DeviceInfoPtr &deviceInfo, bool keyNavigation);
void onBiometricAuthComplete(bool result, int nStatus);
void onBiometricButtonClicked();
void onPasswordButtonClicked();
@ -89,13 +102,15 @@ private Q_SLOTS:
void pamBioSuccess();
void onMessageButtonClicked();
void switchLoginOptType(unsigned uLoginOptType);
void onLoginOptsCount(unsigned uCount);
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();
@ -108,6 +123,7 @@ public Q_SLOTS:
Q_SIGNALS:
void authenticateCompete(bool result);
void clickPassword(bool clicked);
void loginOptionClicked();
private:
UserItem user;
Auth *auth;
@ -117,7 +133,6 @@ private:
AuthMode authMode;
// biometric auth
int m_deviceCount;
QString m_deviceName;
DeviceInfoPtr m_deviceInfo = nullptr;
BiometricProxy *m_biometricProxy;
@ -153,7 +168,6 @@ private:
bool isHiddenSwitchButton;
QMap<int,int> m_failedTimes;
QTimer *m_bioTimer;
bool useFirstDevice;
bool isLockingFlg; //判断当前是否正在锁定倒计时
int m_nCurLockMin; //当前锁定的分钟数
bool prompted = false;
@ -171,6 +185,10 @@ private:
unsigned m_uCurLoginOptType = LOGINOPT_TYPE_PASSWORD; // 当前登录验证方式
QString m_strLoginTypeTip = "";
int m_nLastDeviceId = -1;
QPixmap m_waitingPixmap;
QTimer *w_timer;
UniAuthService *m_uniauthService = nullptr;
};
#endif // AUTHDIALOG_H

201
src/authpamthread.cpp Normal file
View File

@ -0,0 +1,201 @@
#include "authpamthread.h"
#include <security/pam_appl.h>
#include <unistd.h>
#include <wait.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/prctl.h>
#include <QDebug>
#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) {
/*检测账户有效性,即使密码认证通过,如果账户锁定或无效,也无法解锁*/
authRet = pam_acct_mgmt(pamh, 0);
}
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:"<<m_fdRead<<m_fdWrite<<m_strUserName;
}
}
void AuthPamThread::stopAuthPam()
{
qDebug()<<"stopAuthPam begin!";
m_isAuthenticating = false;
if (isRunning()) {
quit();
wait();
}
qDebug()<<"stopAuthPam end";
}

35
src/authpamthread.h Normal file
View File

@ -0,0 +1,35 @@
#ifndef AUTHPAMTHREAD_H
#define AUTHPAMTHREAD_H
#include <QThread>
class AuthPamThread : public QThread
{
Q_OBJECT
public:
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:
void _authenticate(const char *userName);
public:
int m_fdRead = -1;
int m_fdWrite = -1;
QString m_strUserName = "";
private:
bool m_isAuthenticating = false;
};
#endif // AUTHPAMTHREAD_H

180
src/batterywidget.cpp Normal file
View File

@ -0,0 +1,180 @@
#include "batterywidget.h"
#include <QVBoxLayout>
#include <QDBusReply>
#include <QDebug>
#include <QStyleOption>
#include <QPainter>
BatteryWidget::BatteryWidget(QPoint point, QWidget *parent) :
QWidget(parent),
mPoint(point)
{
// setWindowOpacity(0);
setAttribute(Qt::WA_TranslucentBackground);
initUi();
setupComponent();
}
void BatteryWidget::initUi()
{
QVBoxLayout *Lyt = new QVBoxLayout(this);
Lyt->setContentsMargins(16, 16, 16, 16);
Lyt->setSpacing(8);
mModeLabel = new QLabel(this);
mModeLabel->setFixedHeight(24);
mModeLabel->setStyleSheet("QLabel{font-size: 16px;font-family: NotoSansCJKsc-Bold, NotoSansCJKsc;"
"font-weight: bold;}");
QHBoxLayout *Lyt_1 = new QHBoxLayout();
Lyt_1->setSpacing(4);
mIconBtn = new QPushButton(this);
mIconBtn->setFixedSize(48, 32);
mIconBtn->setStyleSheet("QPushButton{\
color: rgb(255, 255, 255, 255);\
border: none;\
border-radius: 4px;\
outline: none;\
}");
mValueLabel = new QLabel(this);
mValueLabel->setFixedSize(48, 48);
mStatusLabel = new QLabel(this);
mStatusLabel->setFixedHeight(36);
mStatusLabel->setAlignment(Qt::AlignRight);
Lyt_1->addWidget(mIconBtn);
Lyt_1->addWidget(mValueLabel);
Lyt_1->addStretch();
Lyt_1->addWidget(mStatusLabel);
Lyt->addWidget(mModeLabel);
Lyt->addLayout(Lyt_1);
Lyt->addStretch();
}
void BatteryWidget::setupComponent()
{
QString batteryPath = "";
dface = new QDBusInterface(UPOWER_SERVICE, UPOWER_PATH, UPOWER_INTERFACE, QDBusConnection::systemBus(), this);
QDBusReply<QList<QDBusObjectPath>> 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);
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());
int size;
size = ed->devices.size();
for (int i = 0; i < size; i++) {
DEVICE *dv;
dv = ed->devices.at(i);
if (dv->m_dev.kind == UP_DEVICE_KIND_LINE_POWER) {
continue;
}
connect(ed, &EngineDevice::engine_signal_Battery_State, this, &BatteryWidget::onBatteryChanged);
continue;
}
}
void BatteryWidget::setPoint(QPoint point)
{
mPoint = point;
}
QString BatteryWidget::getBatteryIconName()
{
if (dface->isValid() && iface->isValid()) {
bool batteryState = false;
QDBusReply<QVariant> reply = iface->call("Get", UPOWER_SERVICE, "OnBattery");
if (reply.isValid()) {
batteryState = reply.value().toBool();
}
double percentage = -1.0;
QDBusReply<QVariant> 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;
opt.init(this);
QPainter p(this);
p.setRenderHint(QPainter::Antialiasing, true);
p.save();
p.setBrush(opt.palette.color(QPalette::Base));
p.setPen(Qt::transparent);
p.setOpacity(0.75);
p.drawRoundedRect(this->rect(), 16, 16);
p.restore();
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();
int batteryState = args.at(1).toInt();
if (batteryState == 1 || batteryState == 5) {
mStatusLabel->setText(tr("Charging..."));
} else if (batteryState == 4) {
mStatusLabel->setText(tr("fully charged"));
}
if (batteryState == 4 || batteryState == 1 || batteryState == 5) {
mStatusLabel->setVisible(true);
mModeLabel->setText(tr("PowerMode"));
} else {
mStatusLabel->setVisible(false);
mModeLabel->setText(tr("BatteryMode"));
}
mValueLabel->setText(QString("<font size='5';font color=#262626>%1</font>%").arg(battery));
}
void BatteryWidget::dealMessage(QDBusMessage)
{
mIconBtn->setIcon(QIcon::fromTheme(getBatteryIconName()));
}

54
src/batterywidget.h Normal file
View File

@ -0,0 +1,54 @@
#ifndef BATTERYWIDGET_H
#define BATTERYWIDGET_H
#include <QObject>
#include <QWidget>
#include <QLabel>
#include <QDBusInterface>
#include <QPushButton>
#include <QPoint>
#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"
class BatteryWidget : public QWidget
{
Q_OBJECT
public:
BatteryWidget(QPoint point, QWidget *parent = nullptr);
void initUi();
void setupComponent();
void setPoint(QPoint point);
QString getBatteryIconName();
protected:
void showEvent(QShowEvent *event);
void paintEvent(QPaintEvent *event);
private:
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);
};
#endif // BATTERYWIDGET_H

View File

@ -38,6 +38,7 @@
#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;
@ -51,13 +52,13 @@ Configuration::Configuration(QObject *parent) : QObject(parent)
/* Initiailization */
mode = gsettings->get(KEY_MODE).toString();
themes = gsettings->get(KEY_THEMES).toStringList();
idleDelay = gsettings->get(
KEY_IDLE_DELAY).toInt();
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();
m_nLockTimeout = gsettings->get(KEY_LOCK_TIMEOUT).toInt();
qDebug() << mode << themes;
qDebug() << imageSwitchInterval << imageTSEffect;
@ -118,6 +119,8 @@ void Configuration::onConfigurationChanged(QString key)
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();
}
/*
@ -205,12 +208,22 @@ QString Configuration::getBackground()
return "/usr/share/backgrounds/1-warty-final-ubuntukylin.jpg";
}
int Configuration::xscreensaverActivatedWhenIdle()
{
return idleDelay;
}
bool Configuration::lockWhenXScreensaverActivated()
{
return lockEnabled;
}
int Configuration::idlelock()
{
return idleLock;
}
int Configuration::idledelay()
{
return idleDelay;
}
int Configuration::locktimeout()
{
return m_nLockTimeout;
}

View File

@ -25,7 +25,7 @@
//#include "gsettings.h"
#include <QObject>
#include "screensaver.h"
#include "screensavermode.h"
class QGSettings;
@ -39,8 +39,10 @@ public:
ScreenSaver *getScreensaver();
static Configuration *instance(QObject *parent = nullptr);
QString getBackground();
int xscreensaverActivatedWhenIdle();
bool lockWhenXScreensaverActivated();
int idlelock();
int idledelay();
int locktimeout();
public Q_SLOTS:
void onConfigurationChanged(QString key);
@ -56,11 +58,12 @@ private:
QString background;
bool idleActivationEnabled;
bool lockEnabled;
int idleDelay;
int idleLock;
int idleDelay = -1;
int idleLock = -1;
int imageTSEffect;
int imageSwitchInterval;
static Configuration *instance_;
int m_nLockTimeout = -1;
};
#endif // CONFIGURATION_H

28
src/device.cpp Normal file
View File

@ -0,0 +1,28 @@
/*
* 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 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 <http://www.gnu.org/licenses/>.
*/
#include "device.h"
#include <QDebug>
DEVICE::DEVICE(QObject *parent) : QObject(parent) {}
void DEVICE::handleChanged(QDBusMessage msg)
{
Q_EMIT device_property_changed(msg, m_dev.path);
}
DEVICE::~DEVICE() {}

255
src/device.h Normal file
View File

@ -0,0 +1,255 @@
/*
* 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 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 <http://www.gnu.org/licenses/>.
*/
#ifndef DEVICE_H
#define DEVICE_H
#include <QDBusMessage>
#define GPM_DBUS_SERVICE "org.ukui.PowerManager"
#define GPM_DBUS_INTERFACE "org.ukui.PowerManager"
#define GPM_DBUS_INTERFACE_BACKLIGHT "org.ukui.PowerManager.Backlight"
#define GPM_DBUS_INTERFACE_KBD_BACKLIGHT "org.ukui.PowerManager.KbdBacklight"
#define GPM_DBUS_PATH "/org/ukui/PowerManager"
#define GPM_DBUS_PATH_BACKLIGHT "/org/ukui/PowerManager/Backlight"
#define GPM_DBUS_PATH_KBD_BACKLIGHT "/org/ukui/PowerManager/KbdBacklight"
/* common descriptions of this program */
#define GPM_NAME _("Power Manager")
#define GPM_DESCRIPTION _("Power Manager for the MATE desktop")
/* schema location */
#define GPM_SETTINGS_SCHEMA "org.ukui.power-manager"
#define GPM_SETTINGS_KEY_POLICY "icon-policy"
/* actions */
#define GPM_SETTINGS_ACTION_CRITICAL_UPS "action-critical-ups"
#define GPM_SETTINGS_ACTION_CRITICAL_BATT "action-critical-battery"
#define GPM_SETTINGS_ACTION_LOW_UPS "action-low-ups"
#define GPM_SETTINGS_ACTION_SLEEP_TYPE_AC "action-sleep-type-ac"
#define GPM_SETTINGS_ACTION_SLEEP_TYPE_BATT "action-sleep-type-battery"
#define GPM_SETTINGS_SLEEP_WHEN_CLOSED "event-when-closed-battery"
/* backlight stuff */
#define GPM_SETTINGS_BACKLIGHT_ENABLE "backlight-enable"
#define GPM_SETTINGS_BACKLIGHT_BATTERY_REDUCE "backlight-battery-reduce"
#define GPM_SETTINGS_DPMS_METHOD_AC "dpms-method-ac"
#define GPM_SETTINGS_DPMS_METHOD_BATT "dpms-method-battery"
#define GPM_SETTINGS_IDLE_BRIGHTNESS "idle-brightness"
#define GPM_SETTINGS_IDLE_DIM_AC "idle-dim-ac"
#define GPM_SETTINGS_IDLE_DIM_BATT "idle-dim-battery"
#define GPM_SETTINGS_IDLE_DIM_TIME "idle-dim-time"
#define GPM_SETTINGS_BRIGHTNESS_AC "brightness-ac"
#define GPM_SETTINGS_BRIGHTNESS_BAT "brightness-bat"
#define GPM_SETTINGS_BRIGHTNESS_DIM_BATT "brightness-dim-battery"
/* keyboard backlight */
#define GPM_SETTINGS_KBD_BACKLIGHT_BATT_REDUCE "kbd-backlight-battery-reduce"
#define GPM_SETTINGS_KBD_BRIGHTNESS_ON_AC "kbd-brightness-on-ac"
#define GPM_SETTINGS_KBD_BRIGHTNESS_DIM_BY_ON_BATT "kbd-brightness-dim-by-on-battery"
#define GPM_SETTINGS_KBD_BRIGHTNESS_DIM_BY_ON_IDLE "kbd-brightness-dim-by-on-idle"
/* buttons */
#define GPM_SETTINGS_BUTTON_LID_AC "button-lid-ac"
#define GPM_SETTINGS_BUTTON_LID_BATT "button-lid-battery"
#define GPM_SETTINGS_BUTTON_SUSPEND "button-suspend"
#define GPM_SETTINGS_BUTTON_HIBERNATE "button-hibernate"
#define GPM_SETTINGS_BUTTON_POWER "button-power"
/* general */
#define GPM_SETTINGS_USE_TIME_POLICY "use-time-for-policy"
#define GPM_SETTINGS_NETWORKMANAGER_SLEEP "network-sleep"
#define GPM_SETTINGS_IDLE_CHECK_CPU "check-type-cpu"
/* notify */
#define GPM_SETTINGS_NOTIFY_LOW_CAPACITY "notify-low-capacity"
#define GPM_SETTINGS_NOTIFY_DISCHARGING "notify-discharging"
#define GPM_SETTINGS_NOTIFY_FULLY_CHARGED "notify-fully-charged"
#define GPM_SETTINGS_NOTIFY_SLEEP_FAILED "notify-sleep-failed"
#define GPM_SETTINGS_NOTIFY_SLEEP_FAILED_URI "notify-sleep-failed-uri"
#define GPM_SETTINGS_NOTIFY_LOW_POWER "notify-low-power"
#define GPM_SETTINGS_BAT_POLICY "power-policy-battery"
#define GPM_SETTINGS_ON_BAT_AUTO_SAVE "on-battery-auto-save"
#define GPM_SETTINGS_LOW_BAT_AUTO_SAVE "low-battery-auto-save"
#define GPM_SETTINGS_DISPLAY_LEFT_TIME "dispaly-left-time-of-charge-and-discharge"
/* thresholds */
#define GPM_SETTINGS_PERCENTAGE_LOW "percentage-low"
#define GPM_SETTINGS_PERCENTAGE_CRITICAL "percentage-critical"
#define GPM_SETTINGS_PERCENTAGE_ACTION "percentage-action"
#define GPM_SETTINGS_TIME_LOW "time-low"
#define GPM_SETTINGS_TIME_CRITICAL "time-critical"
#define GPM_SETTINGS_TIME_ACTION "time-action"
/* timeout */
#define GPM_SETTINGS_SLEEP_COMPUTER_AC "sleep-computer-ac"
#define GPM_SETTINGS_SLEEP_COMPUTER_BATT "sleep-computer-battery"
#define GPM_SETTINGS_SLEEP_COMPUTER_UPS "sleep-computer-ups"
#define GPM_SETTINGS_SLEEP_DISPLAY_AC "sleep-display-ac"
#define GPM_SETTINGS_SLEEP_DISPLAY_BATT "sleep-display-battery"
#define GPM_SETTINGS_SLEEP_DISPLAY_UPS "sleep-display-ups"
/* ui */
#define GPM_SETTINGS_ICON_POLICY "icon-policy"
#define GPM_SETTINGS_ENABLE_SOUND "enable-sound"
#define GPM_SETTINGS_SHOW_ACTIONS "show-actions"
/* statistics */
#define GPM_SETTINGS_INFO_HISTORY_TIME "info-history-time"
#define GPM_SETTINGS_INFO_HISTORY_TYPE "info-history-type"
#define GPM_SETTINGS_INFO_HISTORY_GRAPH_SMOOTH "info-history-graph-smooth"
#define GPM_SETTINGS_INFO_HISTORY_GRAPH_POINTS "info-history-graph-points"
#define GPM_SETTINGS_INFO_STATS_TYPE "info-stats-type"
#define GPM_SETTINGS_INFO_STATS_GRAPH_SMOOTH "info-stats-graph-smooth"
#define GPM_SETTINGS_INFO_STATS_GRAPH_POINTS "info-stats-graph-points"
#define GPM_SETTINGS_INFO_PAGE_NUMBER "info-page-number"
#define GPM_SETTINGS_INFO_LAST_DEVICE "info-last-device"
#if __aarch64__
#define ARCH64 TRUE
#else
#define ARCH64 FALSE
#endif
typedef enum {
GPM_ICON_POLICY_ALWAYS,
GPM_ICON_POLICY_PRESENT,
GPM_ICON_POLICY_CHARGE,
GPM_ICON_POLICY_LOW,
GPM_ICON_POLICY_CRITICAL,
GPM_ICON_POLICY_NEVER
} GpmIconPolicy;
typedef enum {
GPM_ACTION_POLICY_BLANK,
GPM_ACTION_POLICY_SUSPEND,
GPM_ACTION_POLICY_SHUTDOWN,
GPM_ACTION_POLICY_HIBERNATE,
GPM_ACTION_POLICY_INTERACTIVE,
GPM_ACTION_POLICY_NOTHING
} GpmActionPolicy;
typedef enum {
UP_DEVICE_KIND_UNKNOWN,
UP_DEVICE_KIND_LINE_POWER,
UP_DEVICE_KIND_BATTERY,
UP_DEVICE_KIND_UPS,
UP_DEVICE_KIND_MONITOR,
UP_DEVICE_KIND_MOUSE,
UP_DEVICE_KIND_KEYBOARD,
UP_DEVICE_KIND_PDA,
UP_DEVICE_KIND_PHONE,
UP_DEVICE_KIND_MEDIA_PLAYER,
UP_DEVICE_KIND_TABLET,
UP_DEVICE_KIND_COMPUTER,
UP_DEVICE_KIND_LAST
} UpDeviceKind;
/**
* UpDeviceState:
*
* The device state.
**/
typedef enum {
UP_DEVICE_STATE_UNKNOWN,
UP_DEVICE_STATE_CHARGING,
UP_DEVICE_STATE_DISCHARGING,
UP_DEVICE_STATE_EMPTY,
UP_DEVICE_STATE_FULLY_CHARGED,
UP_DEVICE_STATE_PENDING_CHARGE,
UP_DEVICE_STATE_PENDING_DISCHARGE,
UP_DEVICE_STATE_LAST
} UpDeviceState;
/**
* UpDeviceTechnology:
*
* The device technology.
**/
typedef enum {
UP_DEVICE_TECHNOLOGY_UNKNOWN,
UP_DEVICE_TECHNOLOGY_LITHIUM_ION,
UP_DEVICE_TECHNOLOGY_LITHIUM_POLYMER,
UP_DEVICE_TECHNOLOGY_LITHIUM_IRON_PHOSPHATE,
UP_DEVICE_TECHNOLOGY_LEAD_ACID,
UP_DEVICE_TECHNOLOGY_NICKEL_CADMIUM,
UP_DEVICE_TECHNOLOGY_NICKEL_METAL_HYDRIDE,
UP_DEVICE_TECHNOLOGY_LAST
} UpDeviceTechnology;
/**
* UpDeviceLevel:
*
* The warning level of a battery.
**/
typedef enum {
UP_DEVICE_LEVEL_UNKNOWN,
UP_DEVICE_LEVEL_NONE,
UP_DEVICE_LEVEL_DISCHARGING,
UP_DEVICE_LEVEL_LOW,
UP_DEVICE_LEVEL_CRITICAL,
UP_DEVICE_LEVEL_ACTION,
UP_DEVICE_LEVEL_LAST
} UpDeviceLevel;
struct DEV
{
UpDeviceKind kind;
UpDeviceLevel warnlevel;
QString Device;
QString Type;
QString PowerSupply;
QString Online;
QString Model;
QString Energy;
QString EnergyEmpty;
QString EnergyFull;
QString EnergyRate;
bool IsPresent;
QString IsRechargeable;
double Percentage;
UpDeviceState State;
qlonglong TimeToEmpty;
qlonglong TimeToFull;
QString Voltage;
double Capacity;
QString Technology;
QString path;
};
class DEVICE : public QObject
{
Q_OBJECT
public:
explicit DEVICE(QObject *parent = nullptr);
~DEVICE();
Q_SIGNALS:
void device_property_changed(QDBusMessage msg,QString path);
public Q_SLOTS:
void handleChanged(QDBusMessage msg);
public:
DEV m_dev;
};
#endif // DEVICE_H

381
src/enginedevice.cpp Normal file
View File

@ -0,0 +1,381 @@
/*
* 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 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 <http://www.gnu.org/licenses/>.
*/
#include "enginedevice.h"
#include "device.h"
#include <QDBusObjectPath>
#include <QDBusMessage>
#include <QDBusConnection>
#include <QDBusInterface>
#include <QDebug>
EngineDevice *EngineDevice::instance = NULL;
void EngineDevice::power_device_get_devices()
{
QList<QDBusObjectPath> deviceNames;
/* call enum dbus*/
QDBusMessage msg = QDBusMessage::createMethodCall(DBUS_SERVICE, DBUS_OBJECT, DBUS_INTERFACE, "EnumerateDevices");
QDBusMessage res = QDBusConnection::systemBus().call(msg);
if (res.type() == QDBusMessage::ReplyMessage) {
const QDBusArgument &dbusArg = res.arguments().at(0).value<QDBusArgument>();
dbusArg >> deviceNames;
} else {
}
int len = deviceNames.size();
// qDebug()<<deviceNames.at(1).path();
for (int i = 0; i < len; i++) {
DEVICE *device = new DEVICE;
device->m_dev.path = deviceNames.at(i).path();
getProperty(device->m_dev.path, device->m_dev);
/* connect the nofity signal to changecallback */
QDBusConnection::systemBus().connect(
DBUS_SERVICE,
device->m_dev.path,
DBUS_INTERFACE_PRO,
QString("PropertiesChanged"),
device,
SLOT(handleChanged(QDBusMessage)));
connect(
device,
SIGNAL(device_property_changed(QDBusMessage, QString)),
this,
SLOT(power_device_change_callback(QDBusMessage, QString)));
/* add to device list*/
devices.append(device);
}
}
EngineDevice::EngineDevice(QObject *parent) : QObject(parent)
{
settings = new QGSettings(GPM_SETTINGS_SCHEMA);
power_device_get_devices();
}
void EngineDevice::getProperty(QString path, DEV &dev)
{
QDBusMessage msg = QDBusMessage::createMethodCall(DBUS_SERVICE, path, DBUS_INTERFACE_PRO, "GetAll");
msg << DBUS_INTERFACE_DEV;
QDBusMessage res = QDBusConnection::systemBus().call(msg);
if (res.type() == QDBusMessage::ReplyMessage) {
const QDBusArgument &dbusArg = res.arguments().at(0).value<QDBusArgument>();
QMap<QString, QVariant> map;
dbusArg >> map;
dev.kind = (UpDeviceKind)map.value(QString("Type")).toInt();
dev.Type = engine_kind_to_localised_text((UpDeviceKind)map.value(QString("Type")).toInt(), 1);
dev.Model = map.value(QString("Model")).toString();
dev.Device = map.value(QString("NativePath")).toString();
dev.IsPresent = (map.value(QString("IsPresent")).toBool());
dev.PowerSupply = boolToString(map.value(QString("PowerSupply")).toBool());
dev.Percentage = map.value(QString("Percentage")).toDouble();
dev.Percentage = ((float)((int)((dev.Percentage + 0.05) * 10))) / 10;
dev.Online = boolToString(map.value(QString("Online")).toBool());
dev.State = (UpDeviceState)map.value(QString("State")).toInt();
dev.TimeToEmpty = map.value(QString("TimeToEmpty")).toLongLong();
dev.TimeToFull = map.value(QString("TimeToFull")).toLongLong();
}
}
QString EngineDevice::boolToString(bool ret)
{
return ret ? tr("yes") : tr("no");
}
void EngineDevice::putAttributes(QMap<QString, QVariant> &map, DEV &btrDetailData)
{
if (map.contains("TimeToFull")) {
btrDetailData.TimeToFull = map.value(QString("TimeToFull")).toLongLong();
}
if (map.contains("TimeToEmpty")) {
btrDetailData.TimeToEmpty = map.value(QString("TimeToEmpty")).toLongLong();
}
if (map.contains("State")) {
btrDetailData.State = (UpDeviceState)map.value(QString("State")).toInt();
}
if (map.contains("Percentage")) {
btrDetailData.Percentage = map.value(QString("Percentage")).toDouble();
btrDetailData.Percentage = ((float)((int)((btrDetailData.Percentage + 0.05) * 10))) / 10;
}
if (map.contains("PowerSupply")) {
btrDetailData.PowerSupply = (map.value(QString("PowerSupply")).toBool()) ? tr("Yes") : tr("No");
}
if (map.contains("IsPresent")) {
btrDetailData.IsPresent = (map.value(QString("IsPresent")).toBool());
}
}
void EngineDevice::power_device_change_callback(QDBusMessage msg, QString path)
{
/* if battery change to display devices */
/* judge state */
DEVICE *item = nullptr;
Q_FOREACH (auto item_tmp, devices) {
if (item_tmp->m_dev.path == path) {
item = item_tmp;
break;
}
}
if (item == nullptr)
return;
const QDBusArgument &arg = msg.arguments().at(1).value<QDBusArgument>();
QMap<QString, QVariant> map;
arg >> map;
putAttributes(map, item->m_dev);
/*recaculate state*/
power_device_recalculate_state();
}
void EngineDevice::power_device_recalculate_state()
{
engine_recalculate_summary();
}
/**
* engine_recalculate_summary:
*/
bool EngineDevice::engine_recalculate_summary()
{
QString summary;
QStringList Battery_State;
Battery_State = engine_get_state();
summary = engine_get_summary();
if (Battery_State.isEmpty()) {
return false;
}
if (previous_summary.isNull()) {
previous_summary = summary;
Q_EMIT engine_signal_summary_change(summary);
Q_EMIT engine_signal_Battery_State(Battery_State);
return true;
}
if (previous_summary != summary) {
previous_summary = summary;
Q_EMIT engine_signal_summary_change(summary);
Q_EMIT engine_signal_Battery_State(Battery_State);
return true;
}
return false;
}
QStringList EngineDevice::engine_get_state()
{
DEVICE *device;
UpDeviceState state;
QStringList tooltip;
QStringList part;
bool is_present;
UpDeviceKind kind;
Q_FOREACH (device, devices) {
is_present = device->m_dev.IsPresent;
state = device->m_dev.State;
kind = device->m_dev.kind;
if ((!is_present) || (kind != UP_DEVICE_KIND_BATTERY))
continue;
if (state == UP_DEVICE_STATE_EMPTY)
continue;
part = engine_get_Battery_State(device);
if (!part.isEmpty())
tooltip.append(part);
}
return tooltip;
}
QStringList EngineDevice::engine_get_Battery_State(DEVICE *dv)
{
UpDeviceState state;
double percentage;
QStringList result;
state = dv->m_dev.State;
int EMPTY = dv->m_dev.TimeToEmpty;
percentage = dv->m_dev.Percentage;
bool is_present;
is_present = dv->m_dev.IsPresent;
if (!is_present)
return result;
result.append(QString("%1").arg(percentage));
result.append(QString("%1").arg(state));
result.append(QString("%1").arg(EMPTY));
return result;
}
/**
* engine_get_summary:
*
* Returns the complete tooltip ready for display
**/
QString EngineDevice::engine_get_summary()
{
DEVICE *device;
UpDeviceState state;
QString tooltip;
QString part;
bool is_present;
UpDeviceKind kind;
Q_FOREACH (device, devices) {
is_present = device->m_dev.IsPresent;
state = device->m_dev.State;
kind = device->m_dev.kind;
if ((!is_present) || (kind != UP_DEVICE_KIND_BATTERY))
continue;
if (state == UP_DEVICE_STATE_EMPTY)
continue;
part = engine_get_device_summary(device);
if (!part.isNull())
tooltip = QString("%1").arg(part);
}
return tooltip;
}
/**
* engine_get_device_summary:
**/
QString EngineDevice::engine_get_device_summary(DEVICE *dv)
{
QString kind_desc;
UpDeviceKind kind;
UpDeviceState state;
double percentage;
bool is_present;
uint time_to_full;
uint time_to_empty;
QString result;
kind = dv->m_dev.kind;
is_present = dv->m_dev.IsPresent;
state = dv->m_dev.State;
percentage = dv->m_dev.Percentage;
time_to_empty = dv->m_dev.TimeToEmpty;
time_to_full = dv->m_dev.TimeToFull;
if (!is_present)
return NULL;
kind_desc = engine_kind_to_localised_text(kind, 1);
if (state == UP_DEVICE_STATE_FULLY_CHARGED) {
result = tr("%1% available, charged").arg(percentage);
} else if (state == UP_DEVICE_STATE_DISCHARGING) {
int is_show = settings->get(GPM_SETTINGS_DISPLAY_LEFT_TIME).toInt();
if (is_show) {
result = tr("Left %1h %2m (%3%)")
.arg((time_to_empty) / 3600)
.arg(((time_to_empty) % 3600) / 60)
.arg(percentage);
} else {
result = tr("%1% available").arg(percentage);
}
} else if (state == UP_DEVICE_STATE_CHARGING) {
int is_show = settings->get(GPM_SETTINGS_DISPLAY_LEFT_TIME).toInt();
if (is_show) {
result = tr("Left %1h %2m to full").arg((time_to_full) / 3600).arg(((time_to_full) % 3600) / 60);
} else {
result = tr("charging (%1%)").arg(percentage);
}
} else if (state == UP_DEVICE_STATE_PENDING_DISCHARGE) {
/* TRANSLATORS: this is only shown for laptops with multiple batteries */
result = tr("%1 waiting to discharge (%2%)").arg(kind_desc).arg(percentage);
} else if (state == UP_DEVICE_STATE_PENDING_CHARGE) {
/* TRANSLATORS: this is only shown for laptops with multiple batteries */
result = tr("%1 waiting to charge (%2%)").arg(kind_desc).arg(percentage);
} else {
printf("in an undefined state we are not charging or "
"discharging and the batteries are also not charged");
result = QString("%1 (%2%)").arg(kind_desc).arg(percentage);
}
return result;
}
/**
* engine_kind_to_localised_text:
**/
QString EngineDevice::engine_kind_to_localised_text(UpDeviceKind kind, uint number)
{
Q_UNUSED(number);
QString text;
switch (kind) {
case UP_DEVICE_KIND_LINE_POWER:
text = tr("AC adapter");
break;
case UP_DEVICE_KIND_BATTERY:
/* TRANSLATORS: laptop primary battery */
text = tr("Laptop battery");
break;
case UP_DEVICE_KIND_UPS:
/* TRANSLATORS: battery-backed AC power source */
text = tr("UPS");
break;
case UP_DEVICE_KIND_MONITOR:
/* TRANSLATORS: a monitor is a device to measure voltage and current */
text = tr("Monitor");
break;
case UP_DEVICE_KIND_MOUSE:
/* TRANSLATORS: wireless mice with internal batteries */
text = tr("Mouse");
break;
case UP_DEVICE_KIND_KEYBOARD:
/* TRANSLATORS: wireless keyboard with internal battery */
text = tr("Keyboard");
break;
case UP_DEVICE_KIND_PDA:
/* TRANSLATORS: portable device */
text = tr("PDA");
break;
case UP_DEVICE_KIND_PHONE:
/* TRANSLATORS: cell phone (mobile...) */
text = tr("Cell phone");
break;
case UP_DEVICE_KIND_MEDIA_PLAYER:
/* TRANSLATORS: media player, mp3 etc */
text = tr("Media player");
break;
case UP_DEVICE_KIND_TABLET:
/* TRANSLATORS: tablet device */
text = tr("Tablet");
break;
case UP_DEVICE_KIND_COMPUTER:
/* TRANSLATORS: tablet device */
text = tr("Computer");
break;
default:
printf("enum unrecognised: %i", kind);
text = tr("unrecognised");
}
return text;
}

100
src/enginedevice.h Normal file
View File

@ -0,0 +1,100 @@
/*
* 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 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 <http://www.gnu.org/licenses/>.
*/
#ifndef ENGINEDEVICE_H
#define ENGINEDEVICE_H
#include <QObject>
#include "device.h"
#include <QDBusMetaType>
#include <QDBusVariant>
#include <QString>
#include <QGSettings>
#define DBUS_SERVICE "org.freedesktop.UPower"
#define DBUS_OBJECT "/org/freedesktop/UPower"
#define DBUS_INTERFACE "org.freedesktop.UPower"
#define DBUS_INTERFACE_PRO "org.freedesktop.DBus.Properties"
#define DBUS_INTERFACE_DEV "org.freedesktop.UPower.Device"
class EngineDevice : public QObject
{
Q_OBJECT
private:
static EngineDevice* instance;
explicit EngineDevice(QObject *parent = nullptr);
class Deconstructor
{
public:
~Deconstructor() {
if(instance)
{
delete instance;
instance = nullptr;
}
}
};
static Deconstructor deconstructor;
public:
static EngineDevice* getInstance()
{
if(instance==nullptr)
{
instance = new EngineDevice;
}
return instance;
}
Q_SIGNALS:
void engine_signal_discharge(DEV dv);
void engine_signal_charge(DEV dv);
void engine_signal_fullycharge(DEV dv);
void engine_signal_charge_low(DEV dv);
void engine_signal_charge_critical(DEV dv);
void engine_signal_charge_action(DEV dv);
void engine_signal_summary_change(QString summary);
void engine_signal_Battery_State(QStringList Battery_State);
public Q_SLOTS:
void power_device_change_callback(QDBusMessage msg, QString path);
public:
QGSettings *settings;
QList<DEVICE*> devices;
QString previous_icon;
QString previous_summary;
DEVICE *composite_device;
void power_device_recalculate_state();
bool engine_recalculate_summary();
void getProperty(QString path, DEV &dev);
QString engine_get_summary();
QStringList engine_get_state ();
QString engine_kind_to_localised_text(UpDeviceKind kind, uint number);
void power_device_get_devices();
QStringList engine_get_Battery_State(DEVICE* dv);
QString boolToString(bool ret);
QString engine_get_device_summary(DEVICE *dv);
void putAttributes(QMap<QString, QVariant> &map, DEV &btrDetailData);
};
#endif // ENGINEDEVICE_H

View File

@ -30,8 +30,10 @@
#include <QDesktopWidget>
#include <QCloseEvent>
#include <QDBusPendingReply>
#include <QDBusReply>
#include <QImageReader>
#include <QX11Info>
#include "lockwidget.h"
#include <X11/Xatom.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
@ -48,11 +50,10 @@
#include <sys/syslog.h>
#include <xcb/xcb.h>
#include "lockwidget.h"
#include "xeventmonitor.h"
#include "monitorwatcher.h"
#include "configuration.h"
#include "screensaver.h"
#include "screensavermode.h"
#include "screensaverwidget.h"
#include "grab-x11.h"
#include "tabletlockwidget.h"
@ -75,10 +76,8 @@ extern void qt_blurImage(QPainter *p, QImage &blurImage, qreal radius, bool qual
QT_END_NAMESPACE
#define BLUR_RADIUS 300
#define GSETTINGS_SCHEMA_SCREENSAVER "org.ukui.screensaver"
#define KEY_IDLE_DELAY "idleDelay"
#define KEY_IDLE_LOCK "idleLock"
#define KEY_IDLE_LOCK_ENABLED "idleLockEnabled"
#define SUBWND_COUNT_MAX 1024
QPixmap scaledPixmap(int width, int height, QString url)
{
@ -198,7 +197,7 @@ QPixmap blurPixmap(QPixmap pixmap)
FullBackgroundWidget::FullBackgroundWidget(QWidget *parent)
: QWidget(parent),
lockWidget(nullptr),
xEventMonitor(new XEventMonitor(this)),
//xEventMonitor(new XEventMonitor(this)),
//monitorWatcher(new MonitorWatcher(this)),
configuration(Configuration::instance()),
isLocked(false),
@ -209,19 +208,23 @@ FullBackgroundWidget::FullBackgroundWidget(QWidget *parent)
m_delay(false)
{
qDebug() << "init - screenStatus: " << screenStatus;
m_listWndIds.clear();
setMouseTracking(true);
// connect(monitorWatcher, &MonitorWatcher::monitorCountChanged,
// this, &FullBackgroundWidget::onScreenCountChanged);
QDesktopWidget *desktop = QApplication::desktop();
// 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(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",
@ -236,33 +239,17 @@ FullBackgroundWidget::FullBackgroundWidget(QWidget *parent)
SS_DBUS_INTERFACE,
QDBusConnection::sessionBus());
connect(interfaceScreensaver, SIGNAL(SessionIdle()),
this, SLOT(showScreensaver()));
connect(interfaceScreensaver, SIGNAL(SecondRunParam(QString)),
this, SLOT(onSecondRunParam(QString)));
// 闲置不会主动锁住
// QDBusInterface *interfaceLock = new QDBusInterface(
// SS_DBUS_SERVICE,
// SS_DBUS_PATH,
// SS_DBUS_INTERFACE,
// QDBusConnection::sessionBus());
settings_delay = new QGSettings(GSETTINGS_SCHEMA_SCREENSAVER, "", this);
connect(settings_delay, &QGSettings::changed,
this, &FullBackgroundWidget::onConfigurationDelayChanged);
idleDelay = settings_delay->get("idle-delay").toInt();
qDebug()<<"idleDelay="<<idleDelay;
settings_lock = new QGSettings(GSETTINGS_SCHEMA_SCREENSAVER, "", this);
connect(settings_lock, &QGSettings::changed,
this, &FullBackgroundWidget::onConfigurationLockChanged);
idleLock = settings_lock->get("idle-lock").toInt();
// lockEnabled_Key = new QGSettings(GSETTINGS_SCHEMA_SCREENSAVER, "", this);
// connect(lockEnabled_Key, &QGSettings::changed,
// this, &FullBackgroundWidget::lockEnabledChanged);
// lockEnabled = lockEnabled_Key->get("idle-lock-enabled").toBool();
// qDebug()<<lockEnabled;
QDBusInterface *interfaceLock = new QDBusInterface(
SS_DBUS_SERVICE,
SS_DBUS_PATH,
SS_DBUS_INTERFACE,
QDBusConnection::sessionBus());
connect(interfaceLock, SIGNAL(SessionLockIdle()),
this, SLOT(showLock()));
// connect(interfaceLock, SIGNAL(SessionLockIdle()),
// this, SLOT(showLock()));
#ifdef USE_INTEL
QDBusConnection::systemBus().connect("org.freedesktop.UPower", "/org/freedesktop/UPower", "org.freedesktop.DBus.Properties", "PropertiesChanged",
this, SLOT(propertiesChangedSlot(QString, QMap<QString, QVariant>, QStringList)));
@ -316,32 +303,26 @@ void FullBackgroundWidget::laterActivate()
{
activateWindow();
raise();
raiseOtherWnd();
setFocus();
if(lockWidget && lockWidget->isVisible())
lockWidget->setFocus();
if(lockWidget && lockWidget->isVisible()) {
//lockWidget->setFocus();
lockWidget->onActiveWindpw();//将焦点设置到密码框
}
update();
}
void FullBackgroundWidget::onConfigurationDelayChanged(QString key)
void FullBackgroundWidget::laterOtherActivate()
{
if(key == KEY_IDLE_DELAY){
idleDelay = settings_delay->get("idle-delay").toInt();
activateWindow();
raiseOtherWnd();
//setFocus();
if(lockWidget && lockWidget->isVisible()) {
//lockWidget->setFocus();
lockWidget->onActiveWindpw();//将焦点设置到密码框
}
}
void FullBackgroundWidget::onConfigurationLockChanged(QString key)
{
if(key == KEY_IDLE_LOCK){
idleLock = settings_lock->get("idle-lock").toInt();
}
}
//void FullBackgroundWidget::lockEnabledChanged(QString key)
//{
// if(key == KEY_IDLE_LOCK_ENABLED){
// lockEnabled = lockEnabled_Key->get("idle-lock-enabled").toBool();
// }
//}
void FullBackgroundWidget::setLockState()
{
if(lockState == true)
@ -380,6 +361,15 @@ void FullBackgroundWidget::killWindow()
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)
@ -423,7 +413,12 @@ void FullBackgroundWidget::paintEvent(QPaintEvent *event)
void FullBackgroundWidget::closeEvent(QCloseEvent *event)
{
qDebug() << "FullBackgroundWidget::closeEvent";
if (isStartup)
setIsStartup(false);
if(future.isRunning()){
future.cancel();
future.waitForFinished();
}
#ifdef USE_INTEL
//蓝牙连接后 唤醒信号会有延迟 以防退出时未收到信号导致kwin compositor未resume
QDBusInterface *interface = new QDBusInterface("org.ukui.KWin",
@ -472,37 +467,124 @@ bool FullBackgroundWidget::nativeEventFilter(const QByteArray &eventType, void *
const uint8_t responseType = event->response_type & ~0x80;
if (responseType == XCB_CONFIGURE_NOTIFY) {
xcb_configure_notify_event_t *xc = reinterpret_cast<xcb_configure_notify_event_t*>(event);
if(xc->window == winId())
if(xc->window == winId()) {
laterOtherActivate();
return false;
XWindowAttributes window_attributes;
XGetWindowAttributes (QX11Info::display(), xc->window,&window_attributes);
}
XClassHint ch;
ch.res_name = NULL;
ch.res_class = NULL;
XGetClassHint (QX11Info::display(), xc->window, &ch);
if(QString(ch.res_name) == "ukui-screensaver-dialog")
Display* display = XOpenDisplay(0);
if (!display) {
return false;
}
XGetClassHint (display, xc->window, &ch);
XCloseDisplay(display);
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<xcb_map_notify_event_t*>(event);
if(xm->window == winId())
if(xm->window == winId()) {
laterOtherActivate();
return false;
XWindowAttributes window_attributes;
XGetWindowAttributes (QX11Info::display(), xm->window,&window_attributes);
}
XClassHint ch;
ch.res_name = NULL;
ch.res_class = NULL;
XGetClassHint (QX11Info::display(), xm->window, &ch);
if(QString(ch.res_name) == "ukui-screensaver-dialog")
Display* display = XOpenDisplay(0);
if (!display) {
return false;
}
XGetClassHint (display, xm->window, &ch);
XCloseDisplay(display);
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<xcb_destroy_notify_event_t*>(event);
if(isOtherWnd(xd->window)) {
UnRegisteSubWnd(xd->window);
return false;
}
} else if (responseType == XCB_UNMAP_NOTIFY) {
xcb_unmap_notify_event_t *xum = reinterpret_cast<xcb_unmap_notify_event_t*>(event);
if(isOtherWnd(xum->window)) {
UnRegisteSubWnd(xum->window);
return false;
}
} else if (responseType == XCB_KEY_PRESS) {
//xcb_key_press_event_t *xc = reinterpret_cast<xcb_key_press_event_t*>(event);
//qDebug()<<"---------------------XCB_KEY_PRESS:"<<xc->detail;
//onGlobalKeyPress(xc->detail);
} else if (responseType == XCB_KEY_RELEASE) {
//xcb_key_release_event_t *xc = reinterpret_cast<xcb_key_release_event_t*>(event);
//qDebug()<<"---------------------XCB_KEY_RELEASE:"<<xc->detail;
//onGlobalKeyRelease(xc->detail);
} else if(responseType == XCB_GE_GENERIC){
xcb_ge_generic_event_t *xc = reinterpret_cast<xcb_ge_generic_event_t*>(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<xcb_button_press_event_t*>(event);
int x = xc->root_x;
int y = xc->root_y;
onGlobalButtonPressed(x, y);
qDebug()<<"---------------------XCB_BUTTON_PRESS:"<<x<<","<<y;
} else if (responseType == XCB_BUTTON_RELEASE) {
} else if (responseType == XCB_MOTION_NOTIFY) { //此处获取的是窗口外的鼠标移动
xcb_motion_notify_event_t *xc = reinterpret_cast<xcb_motion_notify_event_t*>(event);
int x = xc->root_x;
int y = xc->root_y;
onGlobalButtonDrag(x, y);
qDebug()<<"---------------------XCB_MOTION_NOTIFY:"<<x<<","<<y;
}
return false;
}
void FullBackgroundWidget::mouseMoveEvent(QMouseEvent *e)
{
/*注释掉抓取鼠标后,使用触摸时会出现第一次触摸收不到事件,因此在这里也添加一下*/
if(screenStatus & SCREEN_SAVER && !isBlank)
{
clearScreensavers();
}
onCursorMoved(QCursor::pos());
return QWidget::mouseMoveEvent(e);
}
@ -517,6 +599,12 @@ void FullBackgroundWidget::mousePressEvent(QMouseEvent *e)
return ;
clearScreensavers();
}
#else
/*注释掉抓取鼠标后,使用触摸时会出现第一次触摸收不到事件,因此在这里也添加一下*/
if(screenStatus & SCREEN_SAVER && !isBlank)
{
clearScreensavers();
}
#endif
}
@ -542,6 +630,7 @@ void FullBackgroundWidget::init()
QImageReader reader;
reader.setFileName(configuration->getBackground());
reader.setAutoTransform(true);
reader.setDecideFormatFromContent(true);
reader.setScaledSize(QApplication::primaryScreen()->size());
background = QPixmap::fromImageReader(&reader);
@ -552,6 +641,8 @@ void FullBackgroundWidget::init()
setWindowFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint
| Qt::X11BypassWindowManagerHint);
/*x100下会出现黑色小方块问题设置此属性时正常*/
setAttribute(Qt::WA_TranslucentBackground);
XWindowAttributes rootAttr;
@ -566,16 +657,10 @@ void FullBackgroundWidget::init()
// QDBusConnection::sessionBus());
// connect(smInterface, SIGNAL(StatusChanged(uint)),
// this, SLOT(onSessionStatusChanged(uint)));
connect(xEventMonitor, SIGNAL(keyPress(const QString &)),
this, SLOT(onGlobalKeyPress(const QString &)));
connect(xEventMonitor, SIGNAL(keyRelease(const QString &)),
this, SLOT(onGlobalKeyRelease(const QString &)));
connect(xEventMonitor, SIGNAL(buttonDrag(int, int)),
this, SLOT(onGlobalButtonDrag(int, int)));
connect(xEventMonitor, SIGNAL(buttonPress(int, int)),
this, SLOT(onGlobalButtonPressed(int, int)));
// connect(xEventMonitor, SIGNAL(buttonDrag(int, int)),
// this, SLOT(onGlobalButtonDrag(int, int)));
// connect(xEventMonitor, SIGNAL(buttonPress(int, int)),
// this, SLOT(onGlobalButtonPressed(int, int)));
// int totalWidth = 0;
// int totalHeight = 0;
@ -588,7 +673,7 @@ void FullBackgroundWidget::init()
QDesktopWidget *desktop = QApplication::desktop();
setGeometry(desktop->geometry());
xEventMonitor->start();
// xEventMonitor->start();
#ifdef USE_INTEL
SoundDeviceSet::instance();
@ -667,8 +752,11 @@ void FullBackgroundWidget::showLockWidget()
});
#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());
@ -678,9 +766,25 @@ void FullBackgroundWidget::showLockWidget()
repaint();
}
void FullBackgroundWidget::showScreensaver()
void FullBackgroundWidget::onSecondRunParam(QString strParam)
{
qDebug()<<"onSecondRunParam:"<<strParam;
if (strParam == "SessionIdle") {
showScreensaver();
} else if (strParam == "SleepLock") {
showLock();
} else if (strParam == "CloseLock") {
showLock();
}
}
void FullBackgroundWidget::showScreensaver(bool isPreview/* = false*/)
{
if(screenStatus & SCREEN_SAVER){
if (!isPreview && !(screenStatus & SCREEN_LOCK)) {
// 延迟启动锁屏
delayLockScreen();
}
return ;
}
#ifdef USE_INTEL
@ -688,11 +792,19 @@ void FullBackgroundWidget::showScreensaver()
#else
screenStatus = (ScreenStatus)(screenStatus | SCREEN_SAVER);
#endif
m_isAlreadyShowSaver = true;
qDebug() << "showScreensaver - screenStatus: " << screenStatus;
for(auto screen : QGuiApplication::screens())
{
ScreenSaver *saver = configuration->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);
@ -713,10 +825,15 @@ void FullBackgroundWidget::showScreensaver()
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
@ -727,7 +844,7 @@ void FullBackgroundWidget::clearScreensavers()
widget->close();
}
widgetXScreensaverList.clear();
setAttribute(Qt::WA_TranslucentBackground,true);
qDebug() << "clearScreensavers - screenStatus: " << screenStatus;
unsetCursor();
@ -751,7 +868,7 @@ int FullBackgroundWidget::onSessionStatusChanged(uint status)
}
qDebug() << "onSessionStatusChanged - screenStatus: " << screenStatus;
if(!configuration->xscreensaverActivatedWhenIdle())
if(configuration->idledelay() == -1)
{
return -1;
}
@ -778,28 +895,42 @@ int FullBackgroundWidget::onSessionStatusChanged(uint status)
showLockWidget();
showScreensaver();
#else
if(configuration->xscreensaverActivatedWhenIdle() != -1 && configuration->lockWhenXScreensaverActivated())
{
//显示锁屏和屏保
showLockWidget();
//显示屏保
showScreensaver();
}
else if(configuration->xscreensaverActivatedWhenIdle() != -1)
{
if( idleDelay == idleLock && idleLock != -1){
//显示锁屏和屏保
showLockWidget();
showScreensaver();
}else{
//只显示屏保
showScreensaver();
}
}
#endif
}
return 0;
}
void FullBackgroundWidget::delayLockScreen()
{
if (!m_timerLock) {
m_timerLock = new QTimer(this);
connect(m_timerLock, &QTimer::timeout, this, &FullBackgroundWidget::onLockScreenTimeout);
}
qDebug()<<"LockTimeout:"<<configuration->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:"<<configuration->lockWhenXScreensaverActivated();
if (configuration->lockWhenXScreensaverActivated()) {
showLock();
}
m_timerLock->stop();
}
void FullBackgroundWidget::onBlankScreensaver()
{
showLockWidget();
@ -816,6 +947,23 @@ void FullBackgroundWidget::onBlankScreensaver()
}
setCursor(Qt::BlankCursor);
isBlank = true;
/*在进行压力测试时,可能会出现锁屏界面启动极慢,导致在睡眠之前调用了锁屏,但
*
* */
QDBusInterface *interface = new QDBusInterface(SS_DBUS_SERVICE,
SS_DBUS_PATH,
SS_DBUS_INTERFACE);
QDBusReply<bool> stateReply = interface->call("GetBlankState");
if(!stateReply.isValid()){
return ;
}
if(!stateReply){
isBlank = false;
clearScreensavers();
}
}
void FullBackgroundWidget::onScreensaver()
@ -824,7 +972,7 @@ void FullBackgroundWidget::onScreensaver()
showScreensaver();
}
void FullBackgroundWidget::onGlobalKeyPress(const QString &key)
void FullBackgroundWidget::onGlobalKeyPress(const quint8 &key)
{
#ifdef USE_INTEL
qDebug() << "onGlobalKeyPress " << key << "screenStatus " << screenStatus;
@ -851,10 +999,12 @@ void FullBackgroundWidget::onGlobalKeyPress(const QString &key)
// lockWidget->RecieveKey(keyValue);
// }
// }
#else
#endif
}
void FullBackgroundWidget::onGlobalKeyRelease(const QString &key)
void FullBackgroundWidget::onGlobalKeyRelease(int key)
{
// if(key == "Caps_Lock")
// {
@ -899,11 +1049,15 @@ void FullBackgroundWidget::onGlobalKeyRelease(const QString &key)
// 键盘上的num_lock生效、不需要登录界面进行管理
}
#else
if(key == "Escape" && screenStatus == SCREEN_LOCK)
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();
}
@ -1038,6 +1192,7 @@ void FullBackgroundWidget::onPrepareForSleep(bool sleep)
{
///系统休眠时,会关闭总线,导致设备不可用,发生错误
///在系统休眠之前停止认证,在系统唤醒后重新开始认证
qDebug()<<"onPrepareForSleep:"<<sleep;
if(sleep)
{
if(lockWidget)
@ -1122,6 +1277,49 @@ QPixmap FullBackgroundWidget::getPaddingPixmap(QPixmap pixmap, int width, int he
return paddingPixmap;
}
int FullBackgroundWidget::RegisteSubWnd(quint64 uWndId)
{
if (!m_listWndIds.contains(uWndId) && m_listWndIds.size() < SUBWND_COUNT_MAX) {
m_listWndIds.append(uWndId);
qDebug()<<"RegisterSubWnd:"<<uWndId;
QTimer::singleShot(50,this,SLOT(laterActivate()));
return m_listWndIds.size();
} else {
return -1;
}
}
int FullBackgroundWidget::UnRegisteSubWnd(quint64 uWndId)
{
if (m_listWndIds.contains(uWndId)) {
m_listWndIds.removeAll(uWndId);
qDebug()<<"UnRegisterSubWnd:"<<uWndId;
QTimer::singleShot(50,this,SLOT(laterActivate()));
return m_listWndIds.size();
} else {
return -1;
}
}
QList<quint64> FullBackgroundWidget::GetSubWndIds()
{
return m_listWndIds;
}
void FullBackgroundWidget::raiseOtherWnd()
{
//qDebug()<<"raiseOtherWnd----:"<<m_listWndIds.size();
for (auto wndId : m_listWndIds) {
XRaiseWindow(QX11Info::display(), wndId);
XFlush(QX11Info::display());
}
}
bool FullBackgroundWidget::isOtherWnd(int wndId)
{
return m_listWndIds.contains(wndId);
}
#ifdef USE_INTEL
void FullBackgroundWidget::onShowBlackBackGround()
{

View File

@ -56,12 +56,18 @@ public:
void closeScreensaver();
void setIsStartup(bool val);
int RegisteSubWnd(quint64 uWndId);
int UnRegisteSubWnd(quint64 uWndId);
QList<quint64> GetSubWndIds();
bool IsStartupMode();
public Q_SLOTS:
void onCursorMoved(const QPoint &pos);
void lock();
void showLockWidget();
void showLock();
void showScreensaver();
void showScreensaver(bool isPreview = false);
void onSecondRunParam(QString strParam);
int onSessionStatusChanged(uint status);
void inhibit();
void uninhibit();
@ -69,6 +75,10 @@ public Q_SLOTS:
void propertiesChangedSlot(QString, QMap<QString, QVariant>, QStringList);
void onShowBlackBackGround();
#endif
Q_SIGNALS:
void StartupModeChanged(bool isStartup);
private:
void init();
void clearScreensavers();
@ -77,24 +87,27 @@ private:
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();
private Q_SLOTS:
void onScreenCountChanged(int);
void onDesktopResized();
void onGlobalKeyPress(const QString &key);
void onGlobalKeyRelease(const QString &key);
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 onConfigurationDelayChanged(QString key);
void onConfigurationLockChanged(QString key);
// void lockEnabledChanged(QString key);
void onLockScreenTimeout();
private:
QDBusInterface *smInterface;
@ -117,15 +130,15 @@ private:
bool isPassed;
bool m_delay;
int isBlank;
QGSettings *settings_delay;
QGSettings *settings_lock;
QGSettings *lockEnabled_Key;
QProcess *process = nullptr;
int idleDelay;
int idleLock;
bool lockEnabled;
bool isStartup = false;
QFuture<void> future;
// 上层窗口管理
QList<quint64> m_listWndIds;
QTimer *m_timerLock = nullptr;
bool m_isAlreadyShowSaver = false;
};
#endif // FULLBACKGROUNDWIDGET_H

View File

@ -41,7 +41,7 @@ static bool grabKeyboard()
static bool grabMouse()
{
#define GRABEVENTS ButtonPressMask | ButtonReleaseMask | PointerMotionMask | \
EnterWindowMask | LeaveWindowMask | KeyPressMask | KeyReleaseMask
EnterWindowMask | LeaveWindowMask
int rv = XGrabPointer(QX11Info::display(), QX11Info::appRootWindow(),
True, GRABEVENTS, GrabModeAsync, GrabModeAsync, None,
None, CurrentTime);
@ -60,24 +60,26 @@ bool establishGrab()
if(!grabKeyboard())
return false;
/*抓取鼠标会导致触摸无效,因此这里先注释掉*/
/*
if(!grabMouse()) {
XUngrabKeyboard(QX11Info::display(), CurrentTime);
XFlush(QX11Info::display());
return false;
}
*/
return true;
}
bool closeGrab()
{
XSync(QX11Info::display(), False);
//XSync(QX11Info::display(), False);
XServerGraber xserverGraber;
Q_UNUSED(xserverGraber);
XUngrabKeyboard(QX11Info::display(), CurrentTime);
XUngrabPointer(QX11Info::display(), CurrentTime);
// XUngrabPointer(QX11Info::display(), CurrentTime);
XFlush(QX11Info::display());
return true;
}

View File

@ -69,15 +69,15 @@ IconEdit::IconEdit(QWidget *parent)
m_iconButton = new QPushButton(this);
m_iconButton->setObjectName(QStringLiteral("loginButton"));
m_iconButton->setFocusPolicy(Qt::NoFocus);
m_iconButton->setCursor(QCursor(Qt::PointingHandCursor));
m_iconButton->installEventFilter(this);
m_iconButton->setFocusPolicy(Qt::FocusPolicy::NoFocus);
m_modeButton = new QPushButton(this);
m_modeButton->setObjectName(QStringLiteral("echoModeButton"));
m_modeButton->setCheckable(true);
m_modeButton->setIcon(QIcon::fromTheme("ukui-eye-display-symbolic"));
m_modeButton->setFocusPolicy(Qt::NoFocus);
m_modeButton->setFocusPolicy(Qt::FocusPolicy::NoFocus);
m_modeButton->setCursor(Qt::PointingHandCursor);
m_modeButton->installEventFilter(this);
connect(m_modeButton, &QPushButton::clicked, this, [&](bool checked){
@ -114,14 +114,15 @@ bool IconEdit::eventFilter(QObject *obj, QEvent *event)
}
if(event->type() == 2)
{
setFocusin(0);
Q_EMIT clickedPassword(true);
}
if(event->type() == 23)
{
XSetInputFocus(QX11Info::display(),this->winId(),RevertToParent,CurrentTime);
//XSetInputFocus(QX11Info::display(),this->winId(),RevertToParent,CurrentTime);
update();
}else if(event->type() == QEvent::MouseButtonPress){
XSetInputFocus(QX11Info::display(),this->winId(),RevertToParent,CurrentTime);
//XSetInputFocus(QX11Info::display(),this->winId(),RevertToParent,CurrentTime);
update();
}
}
@ -132,18 +133,14 @@ bool IconEdit::eventFilter(QObject *obj, QEvent *event)
}
if(event->type() == 2)
{
setFocusin(0);
Q_EMIT clickedPassword(true);
}
if(event->type() == QEvent::HoverEnter){
setIcon(QIcon(":/image/assets/login-button-hover.svg"));
}
else if(event->type() == QEvent::HoverLeave){
setIcon(QIcon(":/image/assets/login-button.svg"));
}
}
if(obj == m_modeButton){
if(event->type() == 2)
{
setFocusin(0);
Q_EMIT clickedPassword(true);
}
}
@ -174,10 +171,31 @@ void IconEdit::resizeEvent(QResizeEvent *)
void IconEdit::setX11Focus()
{
XSetInputFocus(QX11Info::display(),this->winId(),RevertToParent,CurrentTime);
//XSetInputFocus(QX11Info::display(),this->winId(),RevertToParent,CurrentTime);
update();
}
void IconEdit::setFocusin(int target)
{
switch (target) {
case 0:
m_edit->setFocus();
m_iconButton->setStyleSheet("min-width: 24px; max-width: 24px; min-height: 24px; max-height: 24px;"
"icon-size: 22px; background:#3D6BE5; border-radius:12px;");
break;
case 1:
m_edit->clearFocus();
m_iconButton->setStyleSheet("min-width: 24px; max-width: 24px; min-height: 24px; max-height: 24px;"
"icon-size: 22px; background:#000000; border-radius:12px;");
break;
default:
m_iconButton->setStyleSheet("min-width: 24px; max-width: 24px; min-height: 24px; max-height: 24px;"
"icon-size: 22px; background:#3D6BE5; border-radius:12px;");
m_edit->clearFocus();
break;
}
}
void IconEdit::clicked_cb()
{
startWaiting();
@ -209,6 +227,7 @@ void IconEdit::setIcon(const QString &text)
void IconEdit::setIcon(const QIcon &icon)
{
m_iconButton->setIcon(icon);
m_iconButton->setIconSize(QSize(12,12));
m_iconButton->setText("");
m_icon = icon;
m_iconText = "";
@ -268,9 +287,10 @@ void IconEdit::startWaiting()
// m_waitingPixmap = ImageUtil::loadSvg(":/image/assets/ukui-loginopt-face.svg", "white", 24);
// m_iconButton->setIcon(QIcon(m_waitingPixmap));
QPixmap icon = QIcon::fromTheme("ukui-loading-symbolic-0").pixmap(16,16);
QPixmap icon = QIcon::fromTheme("ukui-loading-0-symbolic").pixmap(16,16);
m_waitingPixmap = ImageUtil::drawSymbolicColoredPixmap(icon, "white");
m_iconButton->setIcon(m_waitingPixmap);
m_iconButton->setIconSize(QSize(16,16));
m_timer->start();
}
@ -284,8 +304,10 @@ void IconEdit::stopWaiting()
m_iconButton->setAttribute(Qt::WA_TransparentForMouseEvents, false);
m_edit->setReadOnly(false);
//m_iconButton->setEnabled(true);
if(!m_icon.isNull())
if(!m_icon.isNull()) {
m_iconButton->setIcon(m_icon);
m_iconButton->setIconSize(QSize(12,12));
}
else
m_iconButton->setText(m_iconText);
}
@ -298,6 +320,7 @@ void IconEdit::updatePixmap()
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)

View File

@ -44,6 +44,7 @@ public:
void startWaiting();
void stopWaiting();
void setX11Focus();
void setFocusin(int target);
void readOnly(bool enabled);
void setLocked(bool lock);
//void setEnabled(bool enabled);

View File

@ -24,12 +24,15 @@
#include <unistd.h>
#include <QDBusPendingReply>
#include <QGSettings>
#include <QDBusReply>
#include <signal.h>
#include <QFileInfo>
#include <unistd.h>
#include <fcntl.h>
Interface::Interface(QObject *parent)
: QObject(parent),
m_timerCount(0),
settings(nullptr),
m_timer(nullptr)
{
lockState = false;
@ -54,16 +57,49 @@ Interface::Interface(QObject *parent)
emitLockState(false);
});
settings = new QGSettings("org.ukui.screensaver","",this);
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)));
inhibit();
// 监听一些会话状态
m_sessionWatcher = new SessionWatcher(this);
connect(m_sessionWatcher, &SessionWatcher::sessionIdle,
this, &Interface::onSessionIdleReceived);
// connect(m_sessionWatcher, &SessionWatcher::sessionLockIdle,
// this, &Interface::Lock);
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::sessionLockIdle,
// this, [=](){
// QDBusMessage message;
// message = QDBusMessage::createSignal(SS_DBUS_PATH,
// SS_DBUS_INTERFACE,
// "SessionLockIdle");
// QDBusConnection::sessionBus().send(message);
// });
connect(m_sessionWatcher, &SessionWatcher::sessionIdleExit,
this, &Interface::onSessionIdleExit);
connect(m_sessionWatcher, &SessionWatcher::lidStateChanged,
this, &Interface::onLidStateChaned);
// 监听关屏信号
QDBusConnection::sessionBus().connect(QString(),
"/",
"ukui.power.manager",
"TurnOffDisplay",
this,
SLOT(onScreenClosed(bool)));
inhibit();
}
bool Interface::GetSlpState()
@ -76,6 +112,11 @@ bool Interface::GetLockState()
return ((process.state() != QProcess::NotRunning) && lockState);
}
bool Interface::GetBlankState()
{
return blankState;
}
void Interface::SetLockState()
{
lockState = true;
@ -104,8 +145,9 @@ void Interface::UnLock()
void Interface::Lock()
{
if(process.state() != QProcess::NotRunning)
if(process.state() != QProcess::NotRunning) {
return ;
}
qDebug() << "Lock requested";
lockState = false;
QString cmd = QString("/usr/bin/ukui-screensaver-dialog --lock");
@ -117,6 +159,11 @@ void Interface::Lock()
void Interface::onSessionIdleReceived()
{
qDebug()<<"onSessionIdleReceived--------";
if (!checkStatus(SESSION_STATUS_SCREENSAVER)) {
qDebug()<<"m_nStatus:"<<m_nStatus<<" can't do screensaver!";
return ;
}
if(process.state() != QProcess::NotRunning)
return ;
@ -130,8 +177,15 @@ void Interface::onSessionIdleReceived()
void Interface::onShowBlankScreensaver()
{
if(process.state() != QProcess::NotRunning)
if(process.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";
lockState = false;
@ -185,11 +239,50 @@ void Interface::onNameLost(const QString &serviceName)
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) {
return false;
} else {
if (lock.l_type == F_UNLCK) {
return false;
} else {
return true;
}
}
}
void Interface::onPrepareForSleep(bool sleep)
{
qDebug()<<"onPrepareForSleep:"<<sleep<<"--------";
if(sleep)
{
if(!settings->get("sleep-activation-enabled").toBool()){
if (!checkStatus(SESSION_STATUS_SLEEPED)) {
uninhibit();
return;
}
if (checkScreenDialogRunning()) {
uninhibit();
return;
}
@ -204,6 +297,7 @@ void Interface::onPrepareForSleep(bool sleep)
return;
}
blankState = true;
this->onShowBlankScreensaver();
if(!m_timer){
@ -222,10 +316,49 @@ void Interface::onPrepareForSleep(bool sleep)
}
else
{
m_nStatus &= ~SESSION_STATUS_SLEEPED;
blankState = false;
inhibit();
}
}
void Interface::onSessionIdleExit()
{
qDebug()<<"onSessionIdleExit--------";
m_nStatus &= ~SESSION_STATUS_SCREENSAVER;
m_nStatus &= ~SESSION_STATUS_SCREENCLOSE;
}
void Interface::onScreenClosed(bool state)
{
qDebug()<<"onScreenClosed:"<<state<<"------";
if (state) {
if (!checkStatus(SESSION_STATUS_SCREENCLOSE)) {
qDebug()<<"m_nStatus:"<<m_nStatus<<" can't do screenclose lock!";
return ;
}
if(process.state() != QProcess::NotRunning) {
QDBusMessage message;
message = QDBusMessage::createSignal(SS_DBUS_PATH,
SS_DBUS_INTERFACE,
"SecondRunParam");
message<<"CloseLock";
QDBusConnection::sessionBus().send(message);
return ;
}
Lock();
}
}
void Interface::onLidStateChaned(bool isClosed)
{
if (!isClosed) {
if (m_sessionWatcher->isLidCloseWithBlank()) {
m_nStatus &= ~SESSION_STATUS_SCREENCLOSE;
}
}
}
void Interface::ShowScreensaver()
{
if(process.state() != QProcess::NotRunning)
@ -269,3 +402,54 @@ void Interface::uninhibit()
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 and Close disable!";
return false;
}
}
break;
default:
return false;
}
return true;
}

View File

@ -25,6 +25,7 @@
#include <QDBusUnixFileDescriptor>
#include "types.h"
#include "logind.h"
#include "sessionwatcher.h"
class QGSettings;
class Interface : public QObject, protected QDBusContext
@ -34,10 +35,13 @@ class Interface : public QObject, protected QDBusContext
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;
Q_SIGNALS:
void SessionIdle();
public Q_SLOTS:
/**
@ -54,19 +58,27 @@ public Q_SLOTS:
void onShowBlankScreensaver();
void onNameLost(const QString&);
void onPrepareForSleep(bool sleep);
bool checkScreenDialogRunning();
void onSessionIdleExit();
void onScreenClosed(bool state);
void onLidStateChaned(bool isClosed);
bool GetBlankState();
private:
bool checkExistChild();
void inhibit();
void uninhibit();
void emitLockState(bool);
bool checkStatus(int nStatus);
private:
bool lockState;
bool slpState;
void emitLockState(bool);
int m_timerCount;
QGSettings *settings;
SessionWatcher *m_sessionWatcher = nullptr;
QTimer *m_timer;
QDBusUnixFileDescriptor m_inhibitFileDescriptor;
int m_nStatus = 0; // 当前状态
bool blankState = false;
private:
QProcess process;
};

237
src/lockchecker.cpp Normal file
View File

@ -0,0 +1,237 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*
**/
#include "lockchecker.h"
#include "loginedusers.h"
#include <sys/file.h>
#include <pwd.h>
#include <QString>
#include <QDebug>
#include <QDBusMetaType>
#include <QDBusReply>
#include <QDBusInterface>
#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>("LoginedUsers");
qDBusRegisterMetaType<LoginedUsers>();
QDBusInterface loginInterface(SYSTEMD_SERVICE,
SYSTEMD_PATH,
SYSTEMD_INTERFACE,
QDBusConnection::systemBus());
if (loginInterface.isValid()) {
qDebug() << "create interface success";
}
QDBusMessage result = loginInterface.call("ListUsers");
QList<QVariant> outArgs = result.arguments();
QVariant first = outArgs.at(0);
const QDBusArgument &dbusArgs = first.value<QDBusArgument>();
QVector<LoginedUsers> 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<QVariant> 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<InhibitInfo::InhibitorInfo> LockChecker::listInhibitor(QString type)
{
qDBusRegisterMetaType<InhibitInfo::InhibitorInfo>();
QVector<InhibitInfo::InhibitorInfo> 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<QVariant> outArgs = result.arguments();
QVariant first = outArgs.at(0);
const QDBusArgument &dbusArgs = first.value<QDBusArgument>();
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="<<a;
struct passwd *user1;
user1 = getpwuid(a.toInt());
qDebug() << "name=" << user1->pw_name << ",uid=" << user1->pw_uid;
if (user1->pw_name == NULL) {
return user;
}
user = user1->pw_name;
}
k++;
}
}
return user;
}
int LockChecker::getCachedUsers()
{
QDBusInterface loginInterface("org.freedesktop.Accounts",
"/org/freedesktop/Accounts",
"org.freedesktop.Accounts",
QDBusConnection::systemBus());
if (loginInterface.isValid()) {
qDebug() << "create interface success";
}
QDBusMessage ret = loginInterface.call("ListCachedUsers");
QList<QVariant> outArgs = ret.arguments();
QVariant first = outArgs.at(0);
const QDBusArgument &dbusArgs = first.value<QDBusArgument>();
QDBusObjectPath path;
dbusArgs.beginArray();
int userNum = 0;
while (!dbusArgs.atEnd()) {
dbusArgs >> path;
userNum++;
}
dbusArgs.endArray();
qDebug() << userNum;
return userNum;
}

75
src/lockchecker.h Normal file
View File

@ -0,0 +1,75 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*
**/
#ifndef LOCKCHECKER_H
#define LOCKCHECKER_H
#include <QFile>
#include <QDBusArgument>
namespace InhibitInfo {
struct InhibitorInfo {
QString name;
QString icon;
};
QDBusArgument &operator<<(QDBusArgument &argument, const InhibitInfo::InhibitorInfo &mystruct);
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
{
public:
LockChecker();
~LockChecker();
public:
static int checkLock();
static QStringList getLoginedUsers();
// static QVector<Inhibitor> getInhibitors();
static QVector<InhibitInfo::InhibitorInfo> 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();
private:
static QString getName(QFile *a);
};
#endif // LOCKCHECKER_H

File diff suppressed because it is too large Load Diff

View File

@ -25,8 +25,13 @@
#include <QWidget>
#include <QResizeEvent>
#include <QDBusArgument>
#include <QTabWidget>
#include <kylin-nm/kynetworkicon.h>
#include "kylin-nm/kylin-nm-interface.h"
#include "surewindow.h"
#include "lockchecker.h"
#include "xeventmonitor.h"
#include "batterywidget.h"
namespace Ui {
class LockWidget;
@ -52,6 +57,23 @@ class QMenu;
class QScrollArea;
class KylinNM;
enum TABAT {
EMPTY = -1,
LINEEDIT = 0,
ENTERBTN,
BIOBTN,
BOTTMBTN,
POWERMANAGER,
};
enum HORIZONBTN {
BATTERYBTN = 0,
SWITCHBTN,
NETWORKBTN,
KEYBOARDBTN,
POWERBTN,
};
class LockWidget : public QWidget
{
Q_OBJECT
@ -64,8 +86,13 @@ public:
void stopAuth();
void setX11Focus();
bool exitSubWidget();
void setStartupMode(bool mode);
void onActiveWindpw();
QString getBatteryIconName();
Q_SIGNALS:
void closed();
void keyGlobalRelease(int key);
// void capsLockChanged();
private:
@ -75,22 +102,35 @@ private:
void updateNetIcon(int status);
bool getLoadStatus(const QString &name);
int getNetStatus();
QPixmap PixmapToRound(const QPixmap &src, int radius);
void keyBdRelease(QString key);
void key_OB_release(int key);
void key_tab_release(int key);
void key_shiftTab_release();
void key_LR_release(int key);
void key_enter_release(int key);
int getLoginedNum();
void loadNetPlugin();
void setBottomBtnSheet();
void setCheckedSheet(int type, bool show);
private Q_SLOTS:
void onUserAdded(const UserItem &user);
void onUserDeleted(const UserItem &user);
void onUserMenuTrigged(QAction *action);
void showVirtualKeyboard();
void showPowerManager();
void showNetManager();
void showPowerManager(bool keynavigation = false);
void showUserMenu();
void showNetManager(bool keynavigation = false);
void showBattery();
void switchToGreeter();
void switchToSureDialog(int type);
void showWarning(QVector<InhibitInfo::InhibitorInfo> &list, int type);
void hideSureDialog();
void confirmClicked();
void hideNetManager();
void onGlobalKeyPress(const QString &key);
void onGlobalkeyRelease(const QString &key);
void onClickPassword();
void hideBottomPlugins();
void resetNavigation();
void setBatteryIcon(QString str);
void dealMessage(QDBusMessage);
protected:
bool eventFilter(QObject *obj, QEvent *event);
void resizeEvent(QResizeEvent *event);
@ -112,13 +152,28 @@ private:
QScrollArea *scrollArea;
QWidget *scrollContents;
KylinNM *m_kylinNM = nullptr;
QWidget *m_kylinNM = nullptr;
BatteryWidget *mBatteryWidget = nullptr;
QTabWidget *mkylinNM = nullptr;
QWidget *m_NetManagerWidget;
QStringList m_loginedUser;
bool isNetFinished = false;
int powermanagerType;
XEventMonitor *xEventMonitor;
int nowAt = -1;
int loginedNum = 0;
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;
int at_power = false;
bool at_plugins = false;
QDBusInterface *batInterface = nullptr;
QDBusInterface *iface = nullptr;
QDBusInterface *dface = nullptr;
};
#endif // LOCKWIDGET_H

View File

@ -28,6 +28,23 @@
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="styleSheet">
<string notr="true">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%);
}
</string>
</property>
<property name="text">
<string/>
</property>
@ -73,6 +90,23 @@
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="styleSheet">
<string notr="true">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%);
}
</string>
</property>
<property name="text">
<string/>
</property>
@ -89,24 +123,56 @@
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="styleSheet">
<string notr="true">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%);
}
</string>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QPushButton" name="btnNetworkManager">
<widget class="QPushButton" name="btnBatteryStatus">
<property name="geometry">
<rect>
<x>370</x>
<x>330</x>
<y>10</y>
<width>80</width>
<height>26</height>
<width>97</width>
<height>32</height>
</rect>
</property>
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
<property name="styleSheet">
<string notr="true">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%);
}</string>
</property>
<property name="text">
<string/>

36
src/loginedusers.cpp Normal file
View File

@ -0,0 +1,36 @@
/*
* 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 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
* 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 "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;
}

41
src/loginedusers.h Normal file
View File

@ -0,0 +1,41 @@
/* -*- 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 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
* 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 LOGINEDUSER_H
#define LOGINEDUSER_H
#include <QDBusArgument>
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

View File

@ -12,17 +12,32 @@
#include <QHBoxLayout>
#include <QButtonGroup>
#include <QToolButton>
#include <QPushButton>
#include <QTimer>
#include <QPainter>
#include <QtSvg/QSvgRenderer>
#include <QImage>
#include <QApplication>
LoginOptionsWidget::LoginOptionsWidget(BiometricProxy* proxy, int uid, QWidget *parent)
#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,0); border-radius: 4px; border: 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%);}"
LoginOptionsWidget::LoginOptionsWidget(BiometricProxy* proxy, int uid, UniAuthService* uniauthService, QWidget *parent)
: QWidget(parent)
, m_biomericProxy(proxy)
, m_uid(uid)
, m_uniauthService(uniauthService)
{
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(REMOTE_QRCODE_TYPE);
initUI();
initConnections();
m_mapDisableDev.clear();
@ -129,17 +144,37 @@ DeviceInfoPtr LoginOptionsWidget::getFirstDevInfo()
return devInfo;
}
DeviceInfoPtr LoginOptionsWidget::getWechatDevice()
{
DeviceInfoPtr devInfo = nullptr;
DeviceMap::iterator itDevInfo = m_mapDevices.begin();
for (; itDevInfo != m_mapDevices.end(); itDevInfo++) {
for (auto devinfo : itDevInfo.value()) {
if (devinfo && devinfo->deviceType == REMOTE_QRCODE_TYPE) {
if (!isDeviceDisable(devinfo->id)) {
devInfo = devinfo;
break;
}
}
}
if (devInfo) {
break;
}
}
return devInfo;
}
void LoginOptionsWidget::addOptionButton(unsigned uLoginOptType, int nDrvId, QString strDrvName)
{
if (m_mapOptBtns.contains(nDrvId)) {
return ;
}
QToolButton *newButton = new QToolButton();
QPushButton *newButton = new QPushButton();
QVBoxLayout *layoutBtn = new QVBoxLayout();
newButton->setLayout(layoutBtn);
QLabel *newLabel = new QLabel();
//QLabel *newLabel = new QLabel();
layoutBtn->setAlignment(Qt::AlignCenter);
layoutBtn->addWidget(newLabel);
//layoutBtn->addWidget(newLabel);
newButton->setCheckable(true);
newButton->setChecked(false);
newButton->setFocusPolicy(Qt::NoFocus);
@ -177,7 +212,8 @@ void LoginOptionsWidget::addOptionButton(unsigned uLoginOptType, int nDrvId, QSt
iconPixmap = loadSvg(":/image/assets/ukui-loginopt-qrcode.svg", "white", 16);
break;
}
newLabel->setPixmap(iconPixmap);
newButton->setIcon(iconPixmap);
//newLabel->setPixmap(iconPixmap);
newButton->setToolTip(strDrvName);
newButton->setStyleSheet("QToolTip{border-radius:4px;background-color:#FFFFFF;color:black;font-size:16px}");
newButton->setFixedSize(48, 48);
@ -193,7 +229,7 @@ void LoginOptionsWidget::addOptionButton(unsigned uLoginOptType, int nDrvId, QSt
void LoginOptionsWidget::clearOptionButtons()
{
QMap<int, QToolButton*>::iterator itMapBtn = m_mapOptBtns.begin();
QMap<int, QPushButton*>::iterator itMapBtn = m_mapOptBtns.begin();
for ( ; itMapBtn != m_mapOptBtns.end(); itMapBtn++) {
if (itMapBtn.value()) {
m_btnGroup->removeButton(itMapBtn.value());
@ -220,7 +256,7 @@ void LoginOptionsWidget::updateOptionButtons()
qDebug()<<"m_mapOptBtns.size():"<<m_mapOptBtns.size();
if (m_mapOptBtns.size() <= 1) {
m_labelOptTitle->hide();
QMap<int, QToolButton*>::iterator itMapBtn = m_mapOptBtns.begin();
QMap<int, QPushButton*>::iterator itMapBtn = m_mapOptBtns.begin();
for ( ; itMapBtn != m_mapOptBtns.end(); itMapBtn++) {
if (itMapBtn.value()) {
itMapBtn.value()->hide();
@ -228,7 +264,7 @@ void LoginOptionsWidget::updateOptionButtons()
}
} else {
m_labelOptTitle->show();
QMap<int, QToolButton*>::iterator itMapBtn = m_mapOptBtns.begin();
QMap<int, QPushButton*>::iterator itMapBtn = m_mapOptBtns.begin();
for ( ; itMapBtn != m_mapOptBtns.end(); itMapBtn++) {
if (itMapBtn.value()) {
itMapBtn.value()->show();
@ -246,9 +282,10 @@ void LoginOptionsWidget::setUser(int uid)
void LoginOptionsWidget::readDevicesInfo()
{
m_mapDevices.clear();
bool isAuthEnable = GetAuthEnable();
bool isQRCodeEnable = GetQRCodeEnable();
bool isAuthEnable = getBioAuthEnable(ENABLETYPE_SAVER);
bool isQRCodeEnable = getQRCodeEnable();
DeviceList deviceList = m_biomericProxy->GetDevList();
QStringList listDefDevices = getAllDefDevices();
for(auto pDeviceInfo : deviceList)
{
qDebug()<<"BeginGetFeature------!";
@ -261,9 +298,12 @@ void LoginOptionsWidget::readDevicesInfo()
continue;
int nDevType = LOGINOPT_TYPE_OTHERS;
nDevType = convertDeviceType(pDeviceInfo->deviceType);
if (listDefDevices.contains(pDeviceInfo->shortName) &&
!m_mapDevices.contains(nDevType)) {
m_mapDevices[nDevType].push_back(pDeviceInfo);
}
}
}
updateOptionButtons();
}
@ -304,6 +344,8 @@ void LoginOptionsWidget::startAuth_()
m_isInAuth = true;
m_dupFD = -1;
Q_EMIT setLoadingImage();
QDBusPendingCall call = m_biomericProxy->Identify(m_curDevInfo->id, m_uid);
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this);
connect(watcher, &QDBusPendingCallWatcher::finished,
@ -362,6 +404,10 @@ void LoginOptionsWidget::onIdentifyComplete(QDBusPendingCallWatcher *watcher)
Q_EMIT authComplete(false, 1);
} else if (ret.opsStatus == OPS_IDENTIFY_STOP_BY_USER || ret.opsStatus == OPS_VERIFY_STOP_BY_USER) {
Q_EMIT authComplete(false, -2); // 主动停止,直接重试
} else if (ret.opsStatus == OPS_OPEN_FAIL || ret.opsStatus == OPS_OPEN_ERROR) { // 无法打开设备(设备是坏的/被占用),直接禁用
Q_EMIT authComplete(false, 5);
} else if (ret.opsStatus >= OPS_GET_FLIST_SUCCESS && ret.opsStatus <= OPS_GET_FLIST_MAX) {
Q_EMIT authComplete(false, -3); // 主动停止,直接重试
} else {
Q_EMIT authComplete(false, 2);
}
@ -520,7 +566,10 @@ void LoginOptionsWidget::onUSBDeviceHotPlug(int drvid, int action, int /*devNum*
//设备数量发生了变化
if(count != savedCount) {
updateOptionButtons();
Q_EMIT notifyOptionsChange(count);
Q_EMIT notifyOptionsChange(count, at_bioBtn);
if(at_bioBtn && count >= 1)
tabOptionSelected(FirstDevice);
updateUIStatus();
}
}
@ -534,14 +583,14 @@ bool LoginOptionsWidget::getAuthDouble()
void LoginOptionsWidget::updateUIStatus()
{
if (m_mapOptBtns.contains(-1)) {
QToolButton* btn = m_mapOptBtns[-1];
QPushButton* btn = m_mapOptBtns[-1];
if (btn) {
btn->setChecked(true);
}
}
if (m_curDevInfo) {
if (m_mapOptBtns.contains(m_curDevInfo->id)) {
QToolButton* btn = m_mapOptBtns[m_curDevInfo->id];
QPushButton* btn = m_mapOptBtns[m_curDevInfo->id];
if (btn) {
btn->setChecked(true);
}
@ -549,18 +598,148 @@ void LoginOptionsWidget::updateUIStatus()
}
}
void LoginOptionsWidget::onOptionSelected(int nIndex)
void LoginOptionsWidget::onOptionSelected(int nIndex, bool keyNavigation)
{
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);
Q_EMIT optionSelected(convertDeviceType(info->deviceType), info ,keyNavigation);
}
}
}
void LoginOptionsWidget::tabOptionSelected(int option)
{
switch(option) {
case RIGHT:
at_bioBtn = true;
if(nowAt+1 < m_listDriveId.count()) {
DeviceInfoPtr infoNow = findDeviceById(m_listDriveId[nowAt+1]);
if (infoNow) {
QPushButton* btn = m_mapOptBtns[infoNow->id];
if (btn) {
btn->setStyleSheet(ON_TAB_SHEET);
}
}
if(nowAt >= 0) {
DeviceInfoPtr infoOld = findDeviceById(m_listDriveId[nowAt]);
if (infoOld) {
QPushButton* btn = m_mapOptBtns[infoOld->id];
if (btn) {
btn->setStyleSheet(ON_NORMAL_SHEET);
}
}
}
nowAt += 1;
} else if (nowAt+1 == m_listDriveId.count()) {
DeviceInfoPtr infoNow = findDeviceById(m_listDriveId[0]);
if (infoNow) {
QPushButton* btn = m_mapOptBtns[infoNow->id];
if (btn) {
btn->setStyleSheet(ON_TAB_SHEET);
}
}
DeviceInfoPtr infoOld = findDeviceById(m_listDriveId[nowAt]);
if (infoOld) {
QPushButton* btn = m_mapOptBtns[infoOld->id];
if (btn) {
btn->setStyleSheet(ON_NORMAL_SHEET);
}
}
nowAt = 0;
}
break;
case LEFT:
at_bioBtn = true;
if(nowAt-1 >= 0) {
DeviceInfoPtr infoNow = findDeviceById(m_listDriveId[nowAt-1]);
if (infoNow) {
QPushButton* btn = m_mapOptBtns[infoNow->id];
if (btn) {
btn->setStyleSheet(ON_TAB_SHEET);
}
}
DeviceInfoPtr infoOld = findDeviceById(m_listDriveId[nowAt]);
if (infoOld) {
QPushButton* btn = m_mapOptBtns[infoOld->id];
if (btn) {
btn->setStyleSheet(ON_NORMAL_SHEET);
}
}
nowAt -= 1;
} else if (nowAt-1 < 0) {
DeviceInfoPtr infoNow = findDeviceById(m_listDriveId[m_listDriveId.count() - 1]);
if (infoNow) {
QPushButton* btn = m_mapOptBtns[infoNow->id];
if (btn) {
btn->setStyleSheet(ON_TAB_SHEET);
}
}
DeviceInfoPtr infoOld = findDeviceById(m_listDriveId[0]);
if (infoOld) {
QPushButton* btn = m_mapOptBtns[infoOld->id];
if (btn) {
btn->setStyleSheet(ON_NORMAL_SHEET);
}
}
nowAt = m_listDriveId.count() - 1;
}
break;
case CLEAR:
at_bioBtn = false;
if(nowAt >= 0) {
for(int i = 0; i < getLoginOptCount(); i++) {
DeviceInfoPtr infoClear = findDeviceById(m_listDriveId[i]);
if (infoClear) {
QPushButton* btn = m_mapOptBtns[infoClear->id];
if (btn) {
btn->setStyleSheet(ON_NORMAL_SHEET);
}
}
}
nowAt = -1;
}
break;
case FirstDevice:
at_bioBtn = true;
if(nowAt >= 0) {
for(int i = 0; i < getLoginOptCount(); i++) {
DeviceInfoPtr infoClear = findDeviceById(m_listDriveId[i]);
if (infoClear) {
QPushButton* btn = m_mapOptBtns[infoClear->id];
if (btn) {
btn->setStyleSheet(ON_NORMAL_SHEET);
}
}
}
DeviceInfoPtr infoFirst = findDeviceById(m_listDriveId[0]);
if (infoFirst) {
QPushButton* btn = m_mapOptBtns[infoFirst->id];
if (btn) {
btn->setStyleSheet(ON_TAB_SHEET);
}
}
nowAt = 0;
}
break;
case CLICK:
at_bioBtn = false;
DeviceInfoPtr infoClick = findDeviceById(m_listDriveId[nowAt]);
if (infoClick) {
QPushButton* btn = m_mapOptBtns[infoClick->id];
if (btn) {
onOptionSelected(nowAt, true);
}
}
break;
}
}
int LoginOptionsWidget::convertDeviceType(int nDevType)
{
int nLoginOptType = LOGINOPT_TYPE_OTHERS;
@ -594,7 +773,7 @@ void LoginOptionsWidget::setDeviceDisable(int nDevId, bool bDisable)
{
if (bDisable) {
m_mapDisableDev[m_uid][nDevId] = true;
QMap<int, QToolButton*>::iterator itMapBtn = m_mapOptBtns.begin();
QMap<int, QPushButton*>::iterator itMapBtn = m_mapOptBtns.begin();
for ( ; itMapBtn != m_mapOptBtns.end(); itMapBtn++) {
if (itMapBtn.key() == nDevId && itMapBtn.value()) {
itMapBtn.value()->setDisabled(true);
@ -603,7 +782,7 @@ void LoginOptionsWidget::setDeviceDisable(int nDevId, bool bDisable)
}
} else {
m_mapDisableDev[m_uid][nDevId] = false;
QMap<int, QToolButton*>::iterator itMapBtn = m_mapOptBtns.begin();
QMap<int, QPushButton*>::iterator itMapBtn = m_mapOptBtns.begin();
for ( ; itMapBtn != m_mapOptBtns.end(); itMapBtn++) {
if (itMapBtn.key() == nDevId && itMapBtn.value()) {
itMapBtn.value()->setDisabled(false);
@ -678,3 +857,82 @@ QPixmap LoginOptionsWidget::drawSymbolicColoredPixmap(QPixmap &source, QString c
}
return QPixmap::fromImage(img);
}
bool LoginOptionsWidget::getBioAuthEnable(int nType)
{
bool isEnable = false;
if (m_uniauthService && m_uniauthService->isActivatable()) {
struct passwd *pwInfo = getpwuid(m_uid);
if (pwInfo) {
isEnable = m_uniauthService->getBioAuthStatus(pwInfo->pw_name, ENABLETYPE_BIO);
if (isEnable) {
isEnable = m_uniauthService->getBioAuthStatus(pwInfo->pw_name, nType);
}
return isEnable;
} else {
return false;
}
} else {
return GetAuthEnable();
}
}
bool LoginOptionsWidget::getQRCodeEnable()
{
if (m_uniauthService && m_uniauthService->isActivatable()) {
return m_uniauthService->getQRCodeEnable();
} else {
return GetQRCodeEnable();
}
}
QString LoginOptionsWidget::getDefaultDevice(QString strUserName)
{
if (m_uniauthService && m_uniauthService->isActivatable()) {
QString defaultDeviceName = "";
for (auto bioType : m_listPriority) {
QString strDeviceName = m_uniauthService->getDefaultDevice(strUserName, bioType);
if(!strDeviceName.isEmpty()) {
DeviceInfoPtr pDeviceInfo = findDeviceByName(strDeviceName);
if (pDeviceInfo) {
defaultDeviceName = strDeviceName;
break;
}
}
}
return defaultDeviceName;
} else {
return GetDefaultDevice(strUserName);
}
}
QStringList LoginOptionsWidget::getAllDefDevices()
{
QStringList listDefDevices;
if (m_uniauthService && m_uniauthService->isActivatable()) {
struct passwd *pwdInfo = getpwuid(m_uid);
if (pwdInfo) {
listDefDevices = m_uniauthService->getAllDefaultDevice(pwdInfo->pw_name);
}
} else {
QString defaultDeviceName;
struct passwd *pwd = getpwuid(m_uid);
QString userConfigFile = QString(pwd->pw_dir) + "/.biometric_auth/ukui_biometric.conf";
QSettings userConfig(userConfigFile, QSettings::IniFormat);
qDebug() << userConfig.fileName();
defaultDeviceName = userConfig.value("DefaultDevice").toString();
qDebug() << defaultDeviceName;
if(defaultDeviceName.isEmpty()) {
QSettings sysConfig("/etc/biometric-auth/ukui-biometric.conf", QSettings::IniFormat);
defaultDeviceName = sysConfig.value("DefaultDevice").toString();
}
qDebug() << "default device: " << defaultDeviceName;
if(!defaultDeviceName.isEmpty()){
listDefDevices.push_back(defaultDeviceName);
}
}
return listDefDevices;
}

View File

@ -4,12 +4,13 @@
#include <QWidget>
#include "biometricproxy.h"
#include "biometricdeviceinfo.h"
#include "uniauthservice.h"
class QLabel;
class QButtonGroup;
class QHBoxLayout;
class QVBoxLayout;
class QToolButton;
class QPushButton;
class QTimer;
class QPixmap;
@ -26,16 +27,25 @@ typedef enum {
UniT_Remote, /** 远程账户 **/
}BioType;
enum OPTION{
RIGHT = 0,
LEFT,
CLEAR,
CLICK,
FirstDevice,
};
class LoginOptionsWidget : public QWidget
{
Q_OBJECT
public:
explicit LoginOptionsWidget(BiometricProxy* proxy, int uid, QWidget *parent = nullptr);
explicit LoginOptionsWidget(BiometricProxy* proxy, 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);
void setUser(int uid);
@ -46,6 +56,10 @@ public:
DeviceInfoPtr findDeviceByName(const QString &name);
void setDeviceDisable(int nDevId, bool bDisable = true);
bool isDeviceDisable(int nDevId);
bool getBioAuthEnable(int nType);
bool getQRCodeEnable();
QString getDefaultDevice(QString strUserName);
QStringList getAllDefDevices();
/**
* @brief
@ -67,21 +81,24 @@ public:
return m_isInAuth;
}
QPixmap loadSvg(QString path, QString color, int size);
public Q_SLOTS:
void readDevicesInfo();
void onIdentifyComplete(QDBusPendingCallWatcher *watcher);
void onStatusChanged(int drvid, int status);
void onFrameWritten(int drvid);
void onUSBDeviceHotPlug(int drvid, int action, int devNum);
void onOptionSelected(int nIndex);
void onOptionSelected(int nIndex, bool keyNavigation = false);
void tabOptionSelected(int option);
Q_SIGNALS:
void notifyOptionsChange(unsigned uOptionsCount);
void optionSelected(unsigned uLoginOptType, const DeviceInfoPtr &deviceInfo);
void notifyOptionsChange(unsigned uOptionsCount, bool is_bioBtn);
void optionSelected(unsigned uLoginOptType, const DeviceInfoPtr &deviceInfo, bool keyNavigation);
void updateImage(QImage img);
void authComplete(bool bResult, int nStatus);
void updateAuthMsg(QString strMsg);
void setLoadingImage();
void deviceCountChanged(int num);
private:
void initUI();
void initConnections();
@ -91,7 +108,6 @@ private:
void startAuth_();
bool getAuthDouble();
void updateUIStatus();
QPixmap loadSvg(QString path, QString color, int size);
QPixmap drawSymbolicColoredPixmap(QPixmap &source, QString cgColor);
private:
@ -113,8 +129,12 @@ private:
QLabel *m_labelOptTitle = nullptr;
QButtonGroup *m_btnGroup = nullptr;
QList<int> m_listDriveId;
QMap<int, QToolButton*> m_mapOptBtns;
QMap<int, QPushButton*> m_mapOptBtns;
QMap<int, QMap<int,bool>> m_mapDisableDev;
int nowAt = -1;
bool at_bioBtn = false;
UniAuthService *m_uniauthService = nullptr;
QList<int> m_listPriority;
};
#endif // LOGINOPTIONSWIDGET_H

40
src/mytabwidget.cpp Normal file
View File

@ -0,0 +1,40 @@
#include "mytabwidget.h"
#include <QStyleOption>
#include <QPainter>
#include <QBitmap>
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);
}

18
src/mytabwidget.h Normal file
View File

@ -0,0 +1,18 @@
#ifndef MYTABWIDGET_H
#define MYTABWIDGET_H
#include <QWidget>
#include <QTabWidget>
class MyTabWidget : public QTabWidget
{
Q_OBJECT
public:
explicit MyTabWidget(QWidget *parent = nullptr);
void paintEvent(QPaintEvent *event);
signals:
};
#endif // WIDGET_H

View File

@ -9,6 +9,9 @@
</signal>
<signal name="unlock">
</signal>
<signal name="SecondRunParam">
<arg name="param" type="s" />
</signal>
<method name="Lock">
</method>
<method name="ShowScreensaver">
@ -20,5 +23,8 @@
<method name="GetLockState">
<arg type="b" direction="out"/>
</method>
<method name="GetBlankState">
<arg type="b" direction="out"/>
</method>
</interface>
</node>

View File

@ -358,13 +358,19 @@ pam_modutil_read(int fd, char *buffer, int count)
void get_tally(uid_t uid, int *tfile, struct tallylog *tally)
{
char filename[50]={0};
sprintf(filename,"%s","/tmp/.tallylog");
sprintf(filename,"/tmp/.tallylog.d/.%d",uid);
fprintf(stderr,"new_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);
if ((*tfile = open(filename, O_RDONLY)) == -1){
fprintf(stderr, "open tallylog failed \n");
return ;
}
}
if (lseek(*tfile, (off_t)uid*(off_t)sizeof(*tally), SEEK_SET) == (off_t)-1) {
fprintf(stderr, "lseek tallylog failed \n");

View File

@ -27,11 +27,15 @@
#include <QDebug>
#include <QDBusInterface>
#include "powermanager.h"
#include "lockchecker.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),
@ -42,11 +46,16 @@ PowerManager::PowerManager(QWidget *parent)
setQSS();
}
#else
PowerManager::PowerManager(QWidget *parent)
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);
@ -54,8 +63,6 @@ PowerManager::PowerManager(QWidget *parent)
//QObject::connect(this,SIGNAL(itemClicked(QListWidgetItem*)),this,SLOT(powerClicked(QListWidgetItem*)));
// QObject::connect(this, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this,\
// SLOT(keyboardPressed(QListWidgetItem*,QListWidgetItem*)));
sessionInterface = new QDBusInterface("org.gnome.SessionManager",
"/org/gnome/SessionManager",
@ -69,13 +76,6 @@ PowerManager::PowerManager(QWidget *parent)
QDBusConnection::systemBus(),
this);
xEventMonitor = new XEventMonitor(this);
connect(xEventMonitor, SIGNAL(keyPress(const QString &)), this,
SLOT(onGlobalKeyPress(const QString &)));
connect(xEventMonitor, SIGNAL(keyRelease(const QString &)), this,
SLOT(onGlobalkeyRelease(const QString &)));
xEventMonitor->start();
QDBusReply<QString> stateReply = loginInterface->call("CanSuspend");
if(stateReply.isValid() && stateReply.value() == "yes"){
canSuspend = true;
@ -93,45 +93,15 @@ PowerManager::PowerManager(QWidget *parent)
initUI();
resize((ITEM_WIDTH+ITEM_SPACING*2)*this->count()-ITEM_SPACING*2, ITEM_HEIGHT+ITEM_SPACING*2);
//setCurrentRow(0);
loginedNum = num;
}
void PowerManager::keyboardPressed(QListWidgetItem *item_c, QListWidgetItem *item_p)
{
// if(item_p){
// QString name = itemWidget(item_c)->objectName();
// if(name == rebootWidget->objectName()){
// rebootFace->setStyleSheet("background-color: rgba(255, 255, 255, 40%),\
// QLabel:hover{background-color:rgb(255,255,255,40%)");
// } else if(name == shutdownWidget->objectName()){
// shutdownFace->setStyleSheet("background-color: rgba(255, 255, 255, 40%)");
// } else if(suspendWidget && name == suspendWidget->objectName()){
// suspendFace->setStyleSheet("background-color: rgba(255, 255, 255, 40%)");
// } else if(hibernateWidget && name == hibernateWidget->objectName()){
// hibernateFace->setStyleSheet("background-color: rgba(255, 255, 255, 40%)");
// }
// QString name_p = itemWidget(item_p)->objectName();
// if(name_p == rebootWidget->objectName()){
// rebootFace->setStyleSheet("background-color: rgba(255, 255, 255, 20% QLabel:hover{background-color:rgb(255,255,255,40%))");
// } else if(name_p == shutdownWidget->objectName()){
// shutdownFace->setStyleSheet("background-color: rgba(255, 255, 255, 20%\
// QLabel:hover{background-color:rgb(255,255,255,40%))");
// } else if(suspendWidget && name_p == suspendWidget->objectName()){
// suspendFace->setStyleSheet("background-color: rgba(255, 255, 255, 20%\
// QLabel:hover{background-color:rgb(255,255,255,40%))");
// } else if(hibernateWidget && name_p == hibernateWidget->objectName()){
// hibernateFace->setStyleSheet("background-color: rgba(255, 255, 255, 20%); QLabel:hover{background-color:rgb(255,255,255,40%))");
// }
// }
}
bool PowerManager::eventFilter(QObject *obj, QEvent *event)
{
if(event->type() != QEvent::MouseButtonPress){
return false;
/*这里之前使用点击事件,再某些机器上会出现点击睡眠后,先睡眠,再自动唤醒的问题,
* */
if(event->type() != QEvent::MouseButtonRelease){
return QWidget::eventFilter(obj, event);
}
QString name = obj->objectName();
@ -149,69 +119,67 @@ bool PowerManager::eventFilter(QObject *obj, QEvent *event)
else if(name == "hibernateFace")
hibernateWidgetClicked();
return false;
return QWidget::eventFilter(obj, event);
}
void PowerManager::onGlobalKeyPress(const QString &key)
void PowerManager::onGlobalKeyPress(const quint8 &key)
{
}
void PowerManager::onGlobalkeyRelease(const QString &key)
void PowerManager::onGlobalkeyRelease(const quint8 &key)
{
if (key == "Escape") {
// if (key == 9) { // "Escape"
} else if (key == "Left" || key == "Right" || key == "Return" || key == "KP_Enter") {
keyBdRelease(key);
}
// } else if (key == 113 || key == 114 || key == 36 || key == 104) { // "Left" "Right" "Return" "KP_Enter"
// keyBdRelease(key);
// }
}
void PowerManager::keyBdRelease(QString key)
void PowerManager::keyBdRelease(int key)
{
QString focus = "focus";
QString normal = "normal";
if(key == "Right"){
if(key == Qt::Key_Right){ // "Right"
if(nowAt == -1){
nowAt = 0;
setButtonStyle(focus);
setButtonStyle(FOCUS);
} else if(nowAt == 0){
setButtonStyle(normal);
setButtonStyle(NORMAL);
nowAt = 1;
setButtonStyle(focus);
setButtonStyle(FOCUS);
} else if(nowAt == 1){
setButtonStyle(normal);
setButtonStyle(NORMAL);
nowAt = 2;
setButtonStyle(focus);
setButtonStyle(FOCUS);
} else if(nowAt == 2){
setButtonStyle(normal);
setButtonStyle(NORMAL);
nowAt = 3;
setButtonStyle(focus);
setButtonStyle(FOCUS);
} else if(nowAt == 3){
setButtonStyle(normal);
setButtonStyle(NORMAL);
nowAt = 0;
setButtonStyle(focus);
setButtonStyle(FOCUS);
}
} else if(key == "Left") {
} else if(key == Qt::Key_Left) { // "Left"
if(nowAt == -1){
nowAt = 3;
setButtonStyle(focus);
setButtonStyle(FOCUS);
} else if(nowAt == 3){
setButtonStyle(normal);
setButtonStyle(NORMAL);
nowAt = 2;
setButtonStyle(focus);
setButtonStyle(FOCUS);
} else if(nowAt == 2){
setButtonStyle(normal);
setButtonStyle(NORMAL);
nowAt = 1;
setButtonStyle(focus);
setButtonStyle(FOCUS);
} else if(nowAt == 1){
setButtonStyle(normal);
setButtonStyle(NORMAL);
nowAt = 0;
setButtonStyle(focus);
setButtonStyle(FOCUS);
} else if(nowAt == 0){
setButtonStyle(normal);
setButtonStyle(NORMAL);
nowAt = 3;
setButtonStyle(focus);
setButtonStyle(FOCUS);
}
} else if(key == "Return" || key == "KP_Enter"){
} 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())
@ -223,72 +191,22 @@ void PowerManager::keyBdRelease(QString key)
}
}
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%);QLabel:hover{background-color:rgb(255,255,255,40%);QLabel:pressed{background-color:rgb(255,255,255,30%))");
listLabel.at(nowAt)->setStyleSheet("background-color: rgba(255, 255, 255, 15%);QLabel:hover{background-color:rgba(255,255,255,40%)};QLabel: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;");
}
QStringList PowerManager::getLoginedUsers()
{
QStringList m_loginedUser;
QDBusMessage result = loginInterface->call("ListUsers");
QList<QVariant> outArgs = result.arguments();
QVariant first = outArgs.at(0);
QDBusArgument dbvFirst = first.value<QDBusArgument>();
QVariant vFirst = dbvFirst.asVariant();
const QDBusArgument &dbusArgs = vFirst.value<QDBusArgument>();
QVector<usersInfo> loginedUsers;
dbusArgs.beginArray();
while (!dbusArgs.atEnd()) {
usersInfo user;
dbusArgs >> user;
loginedUsers.push_back(user);
}
for (usersInfo user: loginedUsers) {
QDBusInterface userPertyInterface("org.freedesktop.login1", user.usersPath.path(),
"org.freedesktop.DBus.Properties",
QDBusConnection::systemBus());
QDBusReply<QVariant> reply =
userPertyInterface.call("Get", "org.freedesktop.login1.User", "State");
if (reply.isValid()) {
QString status = reply.value().toString();
if ("closing" != status) {
m_loginedUser.append(user.usersName);
}
}
}
return m_loginedUser;
}
QDBusArgument &operator <<(QDBusArgument &arg, const usersInfo &userInfo)
{
arg.beginStructure();
arg << userInfo.usersId
<< userInfo.usersName
<< userInfo.usersPath;
arg.endStructure();
return arg;
}
const QDBusArgument &operator >>(const QDBusArgument &arg, usersInfo &userInfo)
{
arg.beginStructure();
arg >> userInfo.usersId
>> userInfo.usersName
>> userInfo.usersPath;
arg.endStructure();
return arg;
}
void PowerManager::powerClicked(QListWidgetItem *item)
{
int interval = lasttime.msecsTo(QTime::currentTime());
@ -412,7 +330,7 @@ void PowerManager::initUI()
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->setText(tr("Reboot"));
rebootLabel->setAlignment(Qt::AlignBottom | Qt::AlignHCenter);
QVBoxLayout *rebootlayout = new QVBoxLayout(rebootWidget);
@ -562,45 +480,98 @@ void PowerManager::setQSS()
void PowerManager::doEvent(int type)
{
switch (type) {
case REBOOT:
sessionInterface->call("reboot");
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;
case SHOTDOWN:
sessionInterface->call("powerOff");
default:
break;
}
}
void PowerManager::setStartupMode(bool mode)
{
m_isStartupMode = mode;
}
void PowerManager::suspendWidgetClicked()
{
loginInterface->call("Suspend",true);
QVector<InhibitInfo::InhibitorInfo> 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()
{
loginInterface->call("Hibernate",true);
QVector<InhibitInfo::InhibitorInfo> res = LockChecker::listInhibitor("sleep");
if (!res.isEmpty()) {
Q_EMIT showInhibitWarning(res, HIBERNATE);
return;
}
emit lock();
loginInterface->call("Hibernate",true);
}
void PowerManager::shutdownWidgetClicked()
{
if(getLoginedUsers().count() > 1){
Q_EMIT mulUsersLogined(SHOTDOWN);
QVector<InhibitInfo::InhibitorInfo> 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()
{
if(getLoginedUsers().count() > 1){
QVector<InhibitInfo::InhibitorInfo> 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()
{
@ -696,7 +667,7 @@ void PowerManager::initUI()
rebootFace->installEventFilter(this);
rebootLabel->setAlignment(Qt::AlignCenter);
rebootFace->setPixmap(QPixmap(":/image/assets/reboot.png").scaled(58,58));
rebootLabel->setText(tr("Restart"));
rebootLabel->setText(tr("Reboot"));
rebootWidget->setFixedSize(ITEM_WIDTH,ITEM_HEIGHT);
QVBoxLayout *rebootlayout = new QVBoxLayout(rebootWidget);
rebootlayout->addWidget(rbLabelWidget);

View File

@ -23,7 +23,7 @@
#include <QTime>
#include <QDBusArgument>
#include "config.h"
#include "xeventmonitor.h"
#include "lockchecker.h"
#ifdef USE_INTEL
#define ITEM_WIDTH 128
#define ITEM_HEIGHT (ITEM_WIDTH + 40)
@ -38,19 +38,12 @@ class PowerManager:public QWidget
enum stateType {
REBOOT,
SHOTDOWN,
NOTHING
SHUTDOWN,
SLEEP,
HIBERNATE,
NOTHING,
};
struct usersInfo {
int usersId;
QString usersName;
QDBusObjectPath usersPath;
};
QDBusArgument &operator <<(QDBusArgument &arg, const usersInfo &userInfo);
const QDBusArgument &operator >>(const QDBusArgument &arg, usersInfo &userInfo);
class QLabel;
class QListWidget;
class QListWidgetItem;
@ -61,13 +54,20 @@ class PowerManager:public QListWidget
Q_OBJECT
public:
PowerManager(QWidget *parent = 0);
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();
@ -85,6 +85,7 @@ private:
QDBusInterface *loginInterface;
QDBusInterface *actService;
int login_Num;
bool is_hibernate = false;
bool canSuspend;
bool canHibernate;
@ -96,11 +97,12 @@ private:
QWidget *rebootWidget;
QWidget *shutdownWidget;
QTime lasttime;
XEventMonitor *xEventMonitor;
QLabel *rebootFace;
QLabel *shutdownFace;
QLabel *hibernateFace;
QLabel *suspendFace;
int loginedNum = 0;
bool m_isStartupMode = false;
private:
void lockWidgetClicked();
@ -109,7 +111,7 @@ private:
void rebootWidgetClicked();
QStringList getLoginedUsers();
void shutdownWidgetClicked();
void keyBdRelease(QString key);
//void keyBdRelease(quint8 key);
void setButtonStyle(QString Style);
#ifdef USE_INTEL
bool reboot();
@ -122,14 +124,14 @@ private Q_SLOTS:
#ifndef USE_INTEL
void powerClicked(QListWidgetItem *item);
bool eventFilter(QObject *obj, QEvent *event);
void onGlobalKeyPress(const QString &key);
void onGlobalkeyRelease(const QString &key);
void keyboardPressed(QListWidgetItem *item,QListWidgetItem*);
#endif
Q_SIGNALS:
void switchToUser();
void lock();
void mulUsersLogined(int type);
void showInhibitWarning(QVector<InhibitInfo::InhibitorInfo> &list, int type);
void clickedSuspend();
};
#endif // POWERMANAGER_H

View File

@ -15,7 +15,7 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*
**/
#include "screensaver.h"
#include "screensavermode.h"
#include <QFileInfo>
#include <QDir>
#include <QImageReader>

View File

@ -15,8 +15,8 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*
**/
#ifndef SCREENSAVER_H
#define SCREENSAVER_H
#ifndef SCREENSAVER_MODE_H
#define SCREENSAVER_MODE_H
#include <QObject>
#include <QTimer>
@ -44,7 +44,7 @@ class ScreenSaver : public QObject
public:
SaverMode mode;
//path is a directory or a file path if mode is SAVER_IMAGE
QString path;
QString path = "";
QString lastPath;
//for images saver
@ -74,4 +74,4 @@ Q_DECLARE_METATYPE(ScreenSaver)
QDebug &operator<<(QDebug stream, const ScreenSaver &screensaver);
#endif // SCREENSAVER_H
#endif // SCREENSAVER_MODE_H

View File

@ -24,6 +24,7 @@
#include <QPainter>
#include <QKeyEvent>
#include <QtX11Extras/QX11Info>
#include "screensaver.h"
#include <X11/Xlib.h>
#include <sys/prctl.h>
ScreenSaverWidget::ScreenSaverWidget(ScreenSaver *screensaver, QWidget *parent)
@ -33,6 +34,7 @@ ScreenSaverWidget::ScreenSaverWidget(ScreenSaver *screensaver, QWidget *parent)
closing(false)
{
qDebug() << "ScreenSaverWidget::ScreenSaverWidget";
setAttribute(Qt::WA_DeleteOnClose);
setMouseTracking(true);
setFocus();
this->installEventFilter(this);
@ -83,8 +85,10 @@ ScreenSaverWidget::~ScreenSaverWidget()
void ScreenSaverWidget::closeEvent(QCloseEvent *event)
{
qDebug() << "ScreenSaverWidget::closeEvent---beginStop";
if(process.state() != QProcess::NotRunning)
if(process.state() != QProcess::NotRunning) {
process.kill();
process.waitForFinished(200);
}
if(!closing){
closing = true;
@ -147,12 +151,30 @@ bool ScreenSaverWidget::eventFilter(QObject *obj, QEvent *event)
/* Embed xscreensavers */
void ScreenSaverWidget::embedXScreensaver(const QString &path)
{
qDebug()<<"embedXScreensaver path = "<<path;
/*屏保模式为ukui或者自定义时直接加载对象为其他屏保时使用调用命令方式实现*/
if(screensaver->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);
}
}
}
void ScreenSaverWidget::resizeEvent(QResizeEvent *event)
{
if(m_screensaver){
m_screensaver->setGeometry(this->geometry());
}
}
void ScreenSaverWidget::onBackgroundChanged(const QString &/*path*/)
{

View File

@ -20,8 +20,9 @@
#include <QWidget>
#include <QProcess>
#include "screensaver.h"
#include "screensavermode.h"
class Screensaver;
class ScreenSaverWidget : public QWidget
{
Q_OBJECT
@ -34,6 +35,7 @@ protected:
void closeEvent(QCloseEvent *);
void paintEvent(QPaintEvent *event);
bool eventFilter(QObject *obj, QEvent *event);
void resizeEvent(QResizeEvent *event);
private:
void embedXScreensaver(const QString &path);
@ -46,6 +48,7 @@ private:
bool closing;
float opacity;
QProcess process;
Screensaver *m_screensaver = nullptr;
};
#endif // SCREENSAVERWIDGET_H

View File

@ -0,0 +1,52 @@
#include "screensaverwndadaptor.h"
#include <QtCore/QMetaObject>
#include <QtCore/QByteArray>
#include <QtCore/QList>
#include <QtCore/QMap>
#include <QtCore/QString>
#include <QtCore/QStringList>
#include <QtCore/QVariant>
ScreenSaverWndAdaptor::ScreenSaverWndAdaptor(FullBackgroundWidget *parent)
: QDBusAbstractAdaptor(parent)
, m_parentWidget(parent)
{
// constructor
setAutoRelaySignals(true);
connect(m_parentWidget, SIGNAL(StartupModeChanged(bool)), this, SIGNAL(StartupModeChanged(bool)));
}
ScreenSaverWndAdaptor::~ScreenSaverWndAdaptor()
{
}
int ScreenSaverWndAdaptor::RegisteSubWnd(quint64 uWndId)
{
int nWndCount = m_parentWidget->RegisteSubWnd(uWndId);
if (nWndCount >= 0) {
Q_EMIT SubWndChanged(nWndCount);
}
return nWndCount;
}
int ScreenSaverWndAdaptor::UnRegisteSubWnd(quint64 uWndId)
{
int nWndCount = m_parentWidget->UnRegisteSubWnd(uWndId);
if (nWndCount >= 0) {
Q_EMIT SubWndChanged(nWndCount);
}
return nWndCount;
}
QList<quint64> ScreenSaverWndAdaptor::GetSubWndIds()
{
return m_parentWidget->GetSubWndIds();
}
bool ScreenSaverWndAdaptor::IsStartupMode()
{
return m_parentWidget->IsStartupMode();
}

View File

@ -0,0 +1,58 @@
#ifndef SCREENSAVERWNDADAPTOR_H
#define SCREENSAVERWNDADAPTOR_H
#include <QtCore/QObject>
#include <QtDBus/QtDBus>
#include "fullbackgroundwidget.h"
QT_BEGIN_NAMESPACE
class QByteArray;
template<class T> class QList;
template<class Key, class Value> class QMap;
class QString;
class QStringList;
class QVariant;
QT_END_NAMESPACE
class ScreenSaverWndAdaptor : public QDBusAbstractAdaptor
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.ukui.ScreenSaverWnd")
Q_CLASSINFO("D-Bus Introspection", ""
" <interface name=\"org.ukui.ScreenSaverWnd\">\n"
" <signal name=\"SubWndChanged\"/>\n"
" <signal name=\"StartupModeChanged\"/>\n"
" <method name=\"RegisteSubWnd\">\n"
" <arg name=\"wndid\" direction=\"in\" type=\"t\"/>\n"
" <arg name=\"result\" direction=\"out\" type=\"i\"/>\n"
" </method>\n"
" <method name=\"UnRegisteSubWnd\">\n"
" <arg name=\"wndid\" direction=\"in\" type=\"t\"/>\n"
" <arg name=\"result\" direction=\"out\" type=\"i\"/>\n"
" </method>\n"
" <method name=\"GetSubWndIds\">\n"
" <arg name=\"result\" direction=\"out\" type=\"at\"/>\n"
" </method>\n"
" <method name=\"IsStartupMode\">\n"
" <arg name=\"result\" direction=\"out\" type=\"b\"/>\n"
" </method>\n"
" </interface>\n"
"")
public:
ScreenSaverWndAdaptor(FullBackgroundWidget *parent = nullptr);
virtual ~ScreenSaverWndAdaptor();
public Q_SLOTS:
int RegisteSubWnd(quint64 uWndId);
int UnRegisteSubWnd(quint64 uWndId);
QList<quint64> GetSubWndIds();
bool IsStartupMode();
Q_SIGNALS:
void SubWndChanged(int nCount);
void StartupModeChanged(bool isStartup);
private:
FullBackgroundWidget *m_parentWidget = nullptr;
};
#endif // SCREENSAVERWNDADAPTOR_H

122
src/servicemanager.cpp Normal file
View File

@ -0,0 +1,122 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*
**/
#include "servicemanager.h"
#include <QDebug>
#include <QDBusReply>
#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<bool> 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<int> 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);
}

53
src/servicemanager.h Normal file
View File

@ -0,0 +1,53 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*
**/
#ifndef SERVICEMANAGER_H
#define SERVICEMANAGER_H
#include <QObject>
#include <QDBusInterface>
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

View File

@ -19,6 +19,7 @@
#include <QDBusInterface>
#include <QDebug>
#include <QFile>
#include <QDBusReply>
#include "types.h"
#define GSETTINGS_SCHEMA_SCREENSAVER "org.ukui.screensaver"
@ -28,6 +29,17 @@
#define KEY_IDLE_LOCK_ENABLED "idleLockEnabled"
#define TIME_TYPE_SCHEMA "org.ukui.control-center.panel.plugins"
#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"
SessionWatcher::SessionWatcher(QObject *parent) : QObject(parent)
{
sessionPath = qgetenv("XDG_SESSION_PATH");
@ -36,7 +48,7 @@ SessionWatcher::SessionWatcher(QObject *parent) : QObject(parent)
SM_DBUS_SERVICE,
SM_DBUS_PATH,
SM_DBUS_INTERFACE,
QDBusConnection::sessionBus());
QDBusConnection::sessionBus(), this);
connect(interface, SIGNAL(StatusChanged(unsigned int)),
this, SLOT(onStatusChanged(unsigned int)));
@ -45,19 +57,81 @@ SessionWatcher::SessionWatcher(QObject *parent) : QObject(parent)
DM_DBUS_SERVICE,
DM_DBUS_PATH,
DM_DBUS_INTERFACE,
QDBusConnection::systemBus());
QDBusConnection::systemBus(), this);
connect(displayManagerInterface, SIGNAL(SessionRemoved(QDBusObjectPath)),
this, SLOT(onSessionRemoved(QDBusObjectPath)));
settings_delay = new QGSettings(GSETTINGS_SCHEMA_SCREENSAVER, "", this);
connect(settings_delay, &QGSettings::changed,
this, &SessionWatcher::onConfigurationDelayChanged);
idleDelay = settings_delay->get("idle-delay").toInt();
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();
}
settings_lock = new QGSettings(GSETTINGS_SCHEMA_SCREENSAVER, "", this);
connect(settings_lock, &QGSettings::changed,
this, &SessionWatcher::onConfigurationLockChanged);
idleLock = settings_lock->get("idle-lock").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;
@ -77,29 +151,17 @@ SessionWatcher::SessionWatcher(QObject *parent) : QObject(parent)
connect(timegsettings, &QGSettings::changed,
this, &SessionWatcher::onConfigurationTimeTpChanged);
// activationEnabled_Key = new QGSettings(GSETTINGS_SCHEMA_SCREENSAVER, "", this);
// connect(activationEnabled_Key, &QGSettings::changed,
// this, &SessionWatcher::activationEnabledChanged);
// idleActivationEnabled = activationEnabled_Key->get("idle-activation-enabled").toBool();
// lockEnabled_Key = new QGSettings(GSETTINGS_SCHEMA_SCREENSAVER, "", this);
// connect(lockEnabled_Key, &QGSettings::changed,
// this, &SessionWatcher::lockEnabledChanged);
// lockEnabled = lockEnabled_Key->get("idle-lock-enabled").toBool();
// qDebug()<<lockEnabled;
// 监听合盖信号
QDBusConnection::systemBus().connect(
UPOWER_SERVICE, UPOWER_PATH, FREEDESKTOP_UPOWER, "PropertiesChanged", this, SLOT(onLidWatcherMessage(void)));
}
void SessionWatcher::onConfigurationDelayChanged(QString key)
void SessionWatcher::onSSConfigChanged(QString strKey)
{
if(key == KEY_IDLE_DELAY){
idleDelay = settings_delay->get("idle-delay").toInt();
}
}
void SessionWatcher::onConfigurationLockChanged(QString key)
{
if(key == KEY_IDLE_LOCK){
idleLock = settings_lock->get("idle-lock").toInt();
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();
}
}
@ -119,25 +181,13 @@ void SessionWatcher::onConfigurationTimeTpChanged(QString key)
void SessionWatcher::setValue(const QString &key, const QVariant &value)
{
if (!configSettings)
return;
configSettings->beginGroup("Greeter");
configSettings->setValue(key, value);
configSettings->endGroup();
}
//void SessionWatcher::activationEnabledChanged(QString key)
//{
// if(key == KEY_IDLE_ACTIVATION_ENABLED){
// idleActivationEnabled = activationEnabled_Key->get("idle-activation-enabled").toBool();
// }
//}
//void SessionWatcher::lockEnabledChanged(QString key)
//{
// if(key == KEY_IDLE_LOCK_ENABLED){
// lockEnabled = lockEnabled_Key->get("idle-lock-enabled").toBool();
// }
//}
void SessionWatcher::onStatusChanged(unsigned int status)
{
if(status == SESSION_IDLE) {
@ -179,6 +229,7 @@ void SessionWatcher::onStatusChanged(unsigned int status)
if(m_timer2 && m_timer2->isActive()){
m_timer2->stop();
}
Q_EMIT sessionIdleExit();
}
}
@ -188,3 +239,94 @@ void SessionWatcher::onSessionRemoved(const QDBusObjectPath &objectPath)
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;
}
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<QVariant> 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!";
}
}

View File

@ -31,32 +31,39 @@ class SessionWatcher : public QObject
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(); // 合盖关屏
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 onConfigurationDelayChanged(QString key);
void onConfigurationLockChanged(QString key);
void onConfigurationTimeTpChanged(QString key);
// void activationEnabledChanged(QString key);
// void lockEnabledChanged(QString key);
void onSSConfigChanged(QString strKey);
void onLidWatcherMessage(void);
private:
QString sessionPath;
QGSettings *settings_delay;
QGSettings *settings_lock;
QGSettings *activationEnabled_Key;
QGSettings *lockEnabled_Key;
QGSettings *timegsettings;
QSettings *configSettings;
bool idleActivationEnabled;
bool lockEnabled;
int idleDelay;
int idleLock;
QGSettings *timegsettings = nullptr;
QSettings *configSettings = nullptr;
QGSettings *m_ssSettings = nullptr;
QGSettings *m_pmSettings = nullptr;
QGSettings *m_sdSettings = nullptr;
int idleDelay = -1;
int idleLock = -1;
QTimer *m_timer = nullptr;
QTimer *m_timer2 = nullptr;
bool m_lidState = false;
};
#endif // SESSIONWATCHER_H

View File

@ -1,20 +1,14 @@
#include "surewindow.h"
#include "ui_surewindow.h"
#include <QDebug>
#include <QStandardItemModel>
SureWindow::SureWindow(QWidget *parent) :
QWidget(parent),
ui(new Ui::SureWindow)
{
ui->setupUi(this);
ui->tipLabel->setText(tr("Multiple users are logged in at the same time.Are you sure "
"you want to reboot this system?"));
ui->tipLabel->setStyleSheet("color:white;font:14pt;");
ui->cancelBtn->setStyleSheet("QPushButton{background: rgba(255, 255, 255, 0.2);border-radius: 8px;}"
"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;}"
"QPushButton:hover{background: rgba(255, 255, 255, 0.25);border-radius: 8px;}"
"QPushButton:pressed {background: rgba(255, 255, 255, 0.3);border-radius: 8px;}");
//ui->tipLabel->setWordWrap(true);
connect(ui->cancelBtn, &QPushButton::clicked, this, [&]() { emit cantelButtonclicked(); });
connect(ui->confirmBtn, &QPushButton::clicked, this, [&]() { emit confirmButtonclicked(); });
}
@ -22,11 +16,71 @@ SureWindow::SureWindow(QWidget *parent) :
SureWindow::~SureWindow()
{
delete ui;
}
void SureWindow::setText(const QString tips)
void SureWindow::setTips(const QString tips)
{
ui->cancelBtn->setStyleSheet("QPushButton{background: rgba(255, 255, 255, 0.2);border-radius: 8px;}"
"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;}"
"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->show();
ui->tipLabel->show();
ui->listView->hide();
ui->tipLabel->setText(tips);
}
void SureWindow::setWarning(QVector<InhibitInfo::InhibitorInfo> &list, int type)
{
switch (type) {
case 0:
ui->tipLabel->setText(tr("The following program is running to prevent the system from reboot!"));
break;
case 1:
ui->tipLabel->setText(tr("The following program is running to prevent the system from shutting down!"));
break;
case 2:
ui->tipLabel->setText(tr("The following program is running to prevent the system from suspend!"));
break;
case 3:
ui->tipLabel->setText(tr("The following program is running to prevent the system from hibernate!"));
break;
default:
break;
}
ui->tipLabel->adjustSize();
adjustSize();
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("font:10pt;color:white; background-color: rgba(255,255,255,30%); border-radius: 12px;");
ui->listView->setEditTriggers(QAbstractItemView::NoEditTriggers);
ui->listView->setIconSize(QSize(32,32));
ui->listView->setModel(model);
ui->listView->setFixedSize(520, 320);
adjustSize();
ui->cancelBtn->setFixedSize(120, 48);
ui->confirmBtn->hide();
ui->cancelBtn->setStyleSheet("QPushButton{background: rgba(255, 255, 255, 0.2);border-radius: 24px;}"
"QPushButton:hover{background: rgba(255, 255, 255, 0.4);border-radius: 24px;}"
"QPushButton:pressed {background: rgba(255, 255, 255, 0.3);border-radius: 24px;}");
}

View File

@ -1,6 +1,7 @@
#ifndef SUREWINDOW_H
#define SUREWINDOW_H
#include "lockchecker.h"
#include <QWidget>
namespace Ui {
@ -14,7 +15,8 @@ class SureWindow : public QWidget
public:
explicit SureWindow(QWidget *parent = nullptr);
~SureWindow();
void setText(const QString tips);
void setTips(const QString tips);
void setWarning(QVector<InhibitInfo::InhibitorInfo> &list, int type);
private:
Ui::SureWindow *ui;

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>821</width>
<height>631</height>
<width>632</width>
<height>674</height>
</rect>
</property>
<property name="windowTitle">
@ -15,7 +15,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>46</number>
<number>24</number>
</property>
<item>
<spacer name="verticalSpacer_2">
@ -72,11 +72,60 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>19</number>
</property>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QListView" name="listView">
<property name="minimumSize">
<size>
<width>520</width>
<height>320</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>24</number>
</property>
<property name="topMargin">
<number>5</number>
</property>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
@ -100,8 +149,8 @@
</property>
<property name="maximumSize">
<size>
<width>96</width>
<height>36</height>
<width>120</width>
<height>48</height>
</size>
</property>
<property name="text">
@ -113,14 +162,14 @@
<widget class="QPushButton" name="confirmBtn">
<property name="minimumSize">
<size>
<width>96</width>
<height>36</height>
<width>120</width>
<height>48</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>96</width>
<height>36</height>
<width>120</width>
<height>48</height>
</size>
</property>
<property name="text">

View File

@ -78,7 +78,8 @@ TabletLockWidget::TabletLockWidget(QWidget *parent) :
m_vKeyboard->installEventFilter(this);
this->installEventFilter(this);
powermanager = new PowerManager(this);
powermanager = new PowerManager(0, this);
powermanager->setStartupMode(m_isStartupMode);
powermanager->hide();
initUI();
@ -118,6 +119,14 @@ bool TabletLockWidget::eventFilter(QObject *obj, QEvent *event)
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();
@ -632,3 +641,17 @@ EduPlatformInterface* TabletLockWidget::getEduPlatformInterface()
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);
}
}

View File

@ -65,6 +65,11 @@ public:
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();
@ -122,6 +127,7 @@ private:
int m_authType;
int m_pageType = 0;
bool m_isStartupMode = false;
};
#endif // TABLETLOCKWIDGET_H

View File

@ -56,6 +56,10 @@ enum ScreenStatus
#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 BIO_ERROR -1
#define BIO_FAILED 0
#define BIO_SUCCESS 1

View File

@ -21,7 +21,6 @@
#include <QGSettings>
#include "interface.h"
#include "sessionwatcher.h"
#include "screensaveradaptor.h"
#include "types.h"
@ -31,8 +30,6 @@
#include <stdio.h>
#include <ukui-log4qt.h>
#define POWER_TYPE_SCHENA "org.ukui.power-manager"
void sig_chld(int /*signo*/)
{
pid_t pid;
@ -43,10 +40,6 @@ void sig_chld(int /*signo*/)
int main(int argc, char *argv[])
{
// if(signal(SIGCHLD, sig_chld) == SIG_ERR) {
// perror("signal error");
// exit(EXIT_FAILURE);
// }
initUkuiLog4qt("ukui-screensaver-backend");
// 重启或关机时不被session关掉
qunsetenv("SESSION_MANAGER");
@ -65,31 +58,6 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
FILE *fp;
// for PowerManager
fp = popen("xset s 0 0", "r");
fclose(fp);
// Q_UNUSED(fp)
QGSettings *powerSettings;
if(QGSettings::isSchemaInstalled(POWER_TYPE_SCHENA)){
powerSettings = new QGSettings(POWER_TYPE_SCHENA,"",NULL);
QStringList keys = powerSettings->keys();
if (keys.contains("lockSuspend")) {
bool ret = powerSettings->get("lockSuspend").toBool();
if(ret){
powerSettings->set("lock-suspend",false);
}
}
if (keys.contains("lockHibernate")) {
bool ret = powerSettings->get("lockHibernate").toBool();
if(ret){
powerSettings->set("lock-hibernate",false);
}
}
}
// 注册DBus
Interface *interface = new Interface();
ScreenSaverAdaptor adaptor(interface);
@ -107,41 +75,6 @@ int main(int argc, char *argv[])
}
qDebug() << service.baseService();
// 发送DBus信号
SessionWatcher *watcher = new SessionWatcher;
QObject::connect(watcher, &SessionWatcher::sessionIdle,
interface, &Interface::onSessionIdleReceived);
QObject::connect(watcher, &SessionWatcher::sessionLockIdle,
interface, &Interface::Lock);
QObject::connect(watcher, &SessionWatcher::sessionIdle,
&a, [&]{
QDBusMessage message = QDBusMessage::createSignal(SS_DBUS_PATH,
SS_DBUS_INTERFACE,
"SessionIdle");
service.send(message);
//qDebug()<<"message="<<message;
});
QObject::connect(watcher, &SessionWatcher::sessionLockIdle,
&a, [&]{
QDBusMessage message = QDBusMessage::createSignal(SS_DBUS_PATH,
SS_DBUS_INTERFACE,
"SessionLockIdle");
service.send(message);
qDebug()<<"message="<<message;
});
// QTimer *timer = new QTimer;
// QObject::connect(timer, &QTimer::timeout, &a, [&]{
// QDBusMessage message = QDBusMessage::createSignal(SS_DBUS_PATH,
// SS_DBUS_INTERFACE,
// "SessionLockIdle");
// service.send(message);
// });
// timer->start(3000);
QObject::connect(checkInterface, SIGNAL(NameLost(QString)),
interface, SLOT(onNameLost(QString)));

View File

@ -33,6 +33,7 @@
#include <fcntl.h>
#include <sys/types.h>
#include <QProcess>
#include "screensaverwndadaptor.h"
#include <X11/Xlib.h>
#include <ukui-log4qt.h>
#include "fullbackgroundwidget.h"
@ -196,11 +197,27 @@ int main(int argc, char *argv[])
window = new FullBackgroundWidget();
QFile qssFile(":/qss/assets/authdialog.qss");
if(qssFile.open(QIODevice::ReadOnly)) {
a.setStyleSheet(qssFile.readAll());
// QFile qssFile(":/qss/assets/authdialog.qss");
// if(qssFile.open(QIODevice::ReadOnly)) {
// a.setStyleSheet(qssFile.readAll());
// }
// qssFile.close();
// 注册DBus
ScreenSaverWndAdaptor adaptorWnd(window);
QDBusConnection service = QDBusConnection::sessionBus();
if(!service.registerService(SSWND_DBUS_SERVICE)) {
qDebug() << service.lastError().message();
return 1;
}
qssFile.close();
if(!service.registerObject(SSWND_DBUS_PATH, SSWND_DBUS_SERVICE, &adaptorWnd,
QDBusConnection::ExportAllSlots |
QDBusConnection::ExportAllSignals)) {
qDebug() << service.lastError().message();
return 1;
}
qDebug() << service.baseService();
if(parser.isSet(blankOption))
{
@ -218,15 +235,17 @@ int main(int argc, char *argv[])
if(parser.isSet(lstOption))
{
window->lock();
window->setIsStartup(true);
window->lock();
}
if(parser.isSet(sessionIdleOption))
{
if(window->onSessionStatusChanged(SESSION_IDLE) == -1)
if(window->onSessionStatusChanged(SESSION_IDLE) == -1) {
window->close();
return 0;
}
}
if(parser.isSet(lscreensaverOption))
{
@ -240,7 +259,7 @@ int main(int argc, char *argv[])
*/
if(parser.isSet(screensaverOption))
{
window->showScreensaver();
window->showScreensaver(true);
}
#ifdef USE_INTEL

View File

@ -44,7 +44,7 @@ SOURCES += \
auxiliary.cpp \
configuration.cpp \
screensaverwidget.cpp \
screensaver.cpp \
screensavermode.cpp \
event_monitor.cpp \
monitorwatcher.cpp
@ -58,7 +58,7 @@ HEADERS += \
auxiliary.h \
configuration.h \
screensaverwidget.h \
screensaver.h \
screensavermode.h \
event_monitor.h \
monitorwatcher.h
@ -73,7 +73,8 @@ TRANSLATIONS = ../i18n_ts/zh_CN.ts \
../i18n_ts/ru.ts \
../i18n_ts/fr.ts \
../i18n_ts/pt.ts \
../i18n_ts/es.ts
../i18n_ts/es.ts \
../i18n_ts/bo_CN.ts
target.path = /usr/bin/

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd.
* 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
@ -40,17 +40,18 @@ const int weatherReqInterval = 1000 * 60 * 20; //定时更新天气,和麒麟天
const QByteArray schemaWeather = "org.china-weather-data.settings";
static const QMap<QString, QString> weatherMap {
{"NA", "55"},
{"", "0"},
{"多云", "1"},
{"", "2"},
{"阵雨", "3"},
{"雷阵雨", "4"},
{"小雨", "7"},
{"中雨", "8"},
{"大雨", "9"},
{"中到大雨", "9"},
{"", "13"},
{"", "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)
@ -66,6 +67,20 @@ WeatherManager::WeatherManager(QObject *parent) : QObject(parent)
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()
@ -96,6 +111,9 @@ bool WeatherManager::updateLocation()
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();
@ -153,6 +171,23 @@ QString WeatherManager::getLogcalCityId()
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;
@ -180,13 +215,14 @@ void WeatherManager::replyFinished(QNetworkReply *reply)
}
if (now.contains("tmp")){
m_temperature = now.mid(4);
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();
@ -202,17 +238,33 @@ QPixmap WeatherManager::getWeatherIcon(QString cond)
if (cond.isEmpty())
{
qWarning() << "cond info is unknown";
return QPixmap(":/image/assets/weather/55.png").scaled(32,32);
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(":/image/assets/weather/" + numStr +".png").scaled(32,32);
return QPixmap(":/weather/assets/weather-icon/" + numStr +".svg").scaled(32,32);
}
return QPixmap(":/image/assets/weather/55.png").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)

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd.
* 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
@ -24,6 +24,8 @@
#include <QTimer>
#include <QGSettings>
#include "../src/networkwatcher.h"
class QNetworkAccessManager;
class QNetworkReply;
class LocalWeatherInfo;
@ -39,12 +41,17 @@ Q_SIGNALS:
private Q_SLOTS:
void replyFinished(QNetworkReply *);
void onNetworkStateChanged(uint state);
public:
void getWeather();
QPixmap getWeatherIcon();
QPixmap getWeatherIcon(QString cond);
QString getCityName();
QString getCond();
QString getTemperature();
private:
bool updateLocation();//更新位置,从用户设置获取城市信息,如有多个,只取第一个,未对接
void weatherRequest();
@ -63,6 +70,9 @@ private:
QGSettings *m_settings;
LocalWeatherInfo *m_local_weather_info;
NetWorkWatcher *m_networkWatcher;
int m_networkTryNum = 0;
};
class LocalWeatherInfo : QObject

View File

@ -115,7 +115,7 @@ void XEventMonitorPrivate::run()
// Receive KeyPress, KeyRelease, ButtonPress, ButtonRelease and MotionNotify events.
memset(range, 0, sizeof(XRecordRange));
range->device_events.first = KeyPress;
range->device_events.first = ButtonPress;
range->device_events.last = MotionNotify;
// And create the XRECORD context.