代码格式化
This commit is contained in:
parent
6ab12cec79
commit
60adb99618
File diff suppressed because it is too large
Load Diff
|
@ -104,7 +104,7 @@ void FullBackgroundWidget::initUI()
|
|||
QString title = m_modelLockDialog->getAgreementWindowPromptTitle();
|
||||
QString text = m_modelLockDialog->getAgreementWindowText();
|
||||
|
||||
//文本内容不为空 且 如果配置了标题,则标题不为空
|
||||
// 文本内容不为空 且 如果配置了标题,则标题不为空
|
||||
if (!text.isEmpty() && (hideTitle || (!hideTitle && !text.isEmpty()))) {
|
||||
m_agreementWindow = new AgreementWindow(hideTitle, title, text, this);
|
||||
m_lockWidget->hide();
|
||||
|
@ -115,7 +115,7 @@ void FullBackgroundWidget::initUI()
|
|||
m_agreementWindow->setFocusPolicy(Qt::StrongFocus);
|
||||
setFocusProxy(m_agreementWindow);
|
||||
m_agreementWindow->setFocus();
|
||||
//特别提示窗口抓取键盘,避免焦点在密码框上时输入事件跑到密码框,但会导致我已知晓按钮无法响应回车
|
||||
// 特别提示窗口抓取键盘,避免焦点在密码框上时输入事件跑到密码框,但会导致我已知晓按钮无法响应回车
|
||||
m_agreementWindow->grabKeyboard();
|
||||
connect(m_agreementWindow, &AgreementWindow::switchToGreeter, this, [this]() {
|
||||
m_agreementWindow->hide();
|
||||
|
@ -308,7 +308,7 @@ void FullBackgroundWidget::onShowScreensaver()
|
|||
ScreenSaverWidget *saverWidget = new ScreenSaverWidget(saver, this);
|
||||
qDebug() << " new ScreenSaverWidget";
|
||||
widgetXScreensaverList.push_back(saverWidget);
|
||||
//深色模式有一像素的白边,所以主屏幕向左,向右移一个像素点;这种操作后,外显上方仍旧会有一个像素的白边,暂时不对外显做偏移处理
|
||||
// 深色模式有一像素的白边,所以主屏幕向左,向右移一个像素点;这种操作后,外显上方仍旧会有一个像素的白边,暂时不对外显做偏移处理
|
||||
if (screen == qApp->primaryScreen()) {
|
||||
saverWidget->setGeometry(screen->geometry().x() - 1,
|
||||
screen->geometry().y() - 1,
|
||||
|
@ -399,8 +399,8 @@ void FullBackgroundWidget::onDesktopResized()
|
|||
|
||||
void FullBackgroundWidget::onPrepareForSleep(bool sleep)
|
||||
{
|
||||
///系统休眠时,会关闭总线,导致设备不可用,发生错误
|
||||
///在系统休眠之前停止认证,在系统唤醒后重新开始认证
|
||||
/// 系统休眠时,会关闭总线,导致设备不可用,发生错误
|
||||
/// 在系统休眠之前停止认证,在系统唤醒后重新开始认证
|
||||
qDebug() << "onPrepareForSleep:" << sleep;
|
||||
|
||||
if (!isVisible()) {
|
||||
|
@ -551,7 +551,7 @@ void FullBackgroundWidget::showEvent(QShowEvent *event)
|
|||
{
|
||||
if (QX11Info::isPlatformX11())
|
||||
tryGrabKeyboard();
|
||||
QTimer::singleShot(10, this, [=](){
|
||||
QTimer::singleShot(10, this, [=]() {
|
||||
KWindowSystem::setType(this->winId(), NET::ScreenLock);
|
||||
m_lockWidget->updateFont();
|
||||
m_lockWidget->updateFontSize();
|
||||
|
@ -600,8 +600,8 @@ bool FullBackgroundWidget::nativeEventFilter(const QByteArray &eventType, void *
|
|||
const uint8_t responseType = event->response_type & ~0x80;
|
||||
|
||||
if (responseType == XCB_FOCUS_OUT) {
|
||||
//丢焦点时,检测抢焦点的窗口是否为锁屏的子窗口,比如QMenu,QCombobox等,
|
||||
//如果不是子窗口,则重新给锁屏设置一次焦点
|
||||
// 丢焦点时,检测抢焦点的窗口是否为锁屏的子窗口,比如QMenu,QCombobox等,
|
||||
// 如果不是子窗口,则重新给锁屏设置一次焦点
|
||||
QString focusWindow = getFocusWindowName();
|
||||
if (focusWindow == "ukui-screensaver-dialog") {
|
||||
return false;
|
||||
|
@ -611,11 +611,11 @@ bool FullBackgroundWidget::nativeEventFilter(const QByteArray &eventType, void *
|
|||
laterActivate();
|
||||
qDebug() << "XCB_FOCUS_OUT !";
|
||||
} else if (responseType == XCB_FOCUS_IN) {
|
||||
//因为弹出菜单会释放键盘抓取,所以在锁屏窗口重新获取到焦点时,重新抓取一次键盘焦点
|
||||
// 因为弹出菜单会释放键盘抓取,所以在锁屏窗口重新获取到焦点时,重新抓取一次键盘焦点
|
||||
qDebug() << "XCB_FOCUS_IN !";
|
||||
} else if (responseType == XCB_GE_GENERIC) {
|
||||
//因为锁屏抓取了键盘,所以锁屏窗口不管有没有焦点,都能够输入,但仍然需要发送一个
|
||||
//虚拟的focusin事件,来激活窗口焦点,同时点击锁屏界面,也能触发锁屏键盘抓取
|
||||
// 因为锁屏抓取了键盘,所以锁屏窗口不管有没有焦点,都能够输入,但仍然需要发送一个
|
||||
// 虚拟的focusin事件,来激活窗口焦点,同时点击锁屏界面,也能触发锁屏键盘抓取
|
||||
xcb_ge_generic_event_t *xc = reinterpret_cast<xcb_ge_generic_event_t *>(event);
|
||||
if (xc->event_type == XCB_BUTTON_PRESS) {
|
||||
if (this->windowHandle()) {
|
||||
|
@ -753,7 +753,7 @@ void FullBackgroundWidget::loadingAllUserBackground()
|
|||
void FullBackgroundWidget::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
for (QScreen *screen : QApplication::screens()) {
|
||||
//在每个屏幕上绘制背景
|
||||
// 在每个屏幕上绘制背景
|
||||
QRect rect = screen->geometry();
|
||||
int width = rect.width();
|
||||
int height = rect.height();
|
||||
|
@ -810,7 +810,7 @@ void FullBackgroundWidget::onUpdateUserBackground(const QString &strUserName)
|
|||
return;
|
||||
m_oldUserName = m_currentUserName;
|
||||
m_currentUserName = strUserName;
|
||||
//是否需要开启渐变效果
|
||||
// 是否需要开启渐变效果
|
||||
bool gradualChangeEnable = isOpenGradation();
|
||||
qDebug() << __LINE__ << __FUNCTION__ << "==========" << gradualChangeEnable;
|
||||
|
||||
|
@ -1015,13 +1015,13 @@ void FullBackgroundWidget::onScreensChanged(QList<QString> listMonitors)
|
|||
|
||||
m_listMonitors = listMonitors;
|
||||
if (m_listMonitors.size() < 2) {
|
||||
//默认设置显示最大分辨率
|
||||
// 默认设置显示最大分辨率
|
||||
DisplayService::instance()->setOneDisplayMode();
|
||||
} else {
|
||||
int mode = Configuration::instance()->getValue("display-mode").toInt();
|
||||
DisplayService::instance()->switchDisplayMode((DisplayMode)mode);
|
||||
}
|
||||
//在调用xrandr打开显示器以后,不能马上设置窗口大小,会设置不正确的
|
||||
//分辨率,延时1000ms正常。
|
||||
// 在调用xrandr打开显示器以后,不能马上设置窗口大小,会设置不正确的
|
||||
// 分辨率,延时1000ms正常。
|
||||
QTimer::singleShot(1000, this, SLOT(onDesktopResized()));
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* 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 "iconbutton.h"
|
||||
#include <QPainter>
|
||||
#include <QStyleOptionButton>
|
||||
|
@ -29,18 +29,12 @@ static inline qreal mixQreal(qreal a, qreal b, qreal bias)
|
|||
return a + (b - a) * bias;
|
||||
}
|
||||
|
||||
IconButton::IconButton(QWidget *parent)
|
||||
:QPushButton(parent)
|
||||
IconButton::IconButton(QWidget *parent) : QPushButton(parent) {}
|
||||
|
||||
IconButton::~IconButton() {}
|
||||
|
||||
void IconButton::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
IconButton::~IconButton()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void IconButton::paintEvent(QPaintEvent *event){
|
||||
Q_UNUSED(event)
|
||||
QStyleOptionButton option;
|
||||
initStyleOption(&option);
|
||||
|
@ -59,15 +53,12 @@ void IconButton::paintEvent(QPaintEvent *event){
|
|||
painter.save();
|
||||
QStyleOption opt;
|
||||
|
||||
|
||||
QColor borderColor = option.palette.color(QPalette::Text);
|
||||
painter.setPen(QPen(borderColor, 2));
|
||||
// painter.setPen(Qt::NoPen);
|
||||
// painter.setPen(Qt::NoPen);
|
||||
painter.setBrush(Qt::NoBrush);
|
||||
painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 12, 12);
|
||||
painter.restore();
|
||||
|
||||
|
||||
}
|
||||
|
||||
int buttonWidget = this->width();
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
**/
|
||||
**/
|
||||
#include "iconedit.h"
|
||||
#include <QHBoxLayout>
|
||||
#include <QWidget>
|
||||
|
@ -30,16 +30,14 @@
|
|||
#include "commonfunc.h"
|
||||
#include "utils.h"
|
||||
|
||||
IconEdit::IconEdit(LockDialogModel *model, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_modelLockDialog(model)
|
||||
IconEdit::IconEdit(LockDialogModel *model, QWidget *parent) : QWidget(parent), m_modelLockDialog(model)
|
||||
{
|
||||
this->setFixedSize(240, 40);
|
||||
m_edit = new QLineEdit(this);
|
||||
|
||||
m_capsIcon = new QLabel(this);
|
||||
m_capsIcon->setPixmap(QIcon::fromTheme("ukui-capslock-symbolic").pixmap(QSize(16,16)));
|
||||
if (QString(qgetenv("XDG_SESSION_TYPE")) == "wayland"){
|
||||
m_capsIcon->setPixmap(QIcon::fromTheme("ukui-capslock-symbolic").pixmap(QSize(16, 16)));
|
||||
if (QString(qgetenv("XDG_SESSION_TYPE")) == "wayland") {
|
||||
m_capsState = checkCapsLockState();
|
||||
} else {
|
||||
m_capsState = m_modelLockDialog->getCapslockState();
|
||||
|
@ -53,7 +51,7 @@ IconEdit::IconEdit(LockDialogModel *model, QWidget *parent)
|
|||
m_modeButton->setFixedSize(24, 14);
|
||||
m_modeButton->setIconSize(QSize(16, 16));
|
||||
m_modeButton->setFocusPolicy(Qt::NoFocus);
|
||||
connect(m_modeButton, &QPushButton::clicked, this, [=](){
|
||||
connect(m_modeButton, &QPushButton::clicked, this, [=]() {
|
||||
if (m_edit->echoMode() == QLineEdit::Password) {
|
||||
setType(QLineEdit::Normal);
|
||||
} else {
|
||||
|
@ -63,7 +61,7 @@ IconEdit::IconEdit(LockDialogModel *model, QWidget *parent)
|
|||
|
||||
m_iconButton = new QPushButton(this);
|
||||
m_iconButton->installEventFilter(this);
|
||||
m_iconButton->setFixedSize(24*scale, 24*scale);
|
||||
m_iconButton->setFixedSize(24 * scale, 24 * scale);
|
||||
m_iconButton->setProperty("isRoundButton", true);
|
||||
m_iconButton->setProperty("isImportant", true);
|
||||
|
||||
|
@ -78,8 +76,8 @@ IconEdit::IconEdit(LockDialogModel *model, QWidget *parent)
|
|||
connect(m_edit, &QLineEdit::returnPressed, this, &IconEdit::clicked_cb);
|
||||
connect(m_iconButton, &QPushButton::clicked, this, &IconEdit::clicked_cb);
|
||||
|
||||
m_edit->setAttribute(Qt::WA_InputMethodEnabled, false); //禁用输入法
|
||||
m_edit->setContextMenuPolicy(Qt::NoContextMenu); //禁用右键菜单
|
||||
m_edit->setAttribute(Qt::WA_InputMethodEnabled, false); // 禁用输入法
|
||||
m_edit->setContextMenuPolicy(Qt::NoContextMenu); // 禁用右键菜单
|
||||
m_edit->installEventFilter(this);
|
||||
m_iconButton->setFocusPolicy(Qt::TabFocus);
|
||||
m_iconButton->installEventFilter(this);
|
||||
|
@ -96,13 +94,15 @@ void IconEdit::resizeEvent(QResizeEvent *)
|
|||
|
||||
bool IconEdit::eventFilter(QObject *obj, QEvent *event)
|
||||
{
|
||||
if(obj == m_edit){
|
||||
if(event->type() == 6){ //禁止复制粘贴功能。
|
||||
if (obj == m_edit) {
|
||||
if (event->type() == 6) { // 禁止复制粘贴功能。
|
||||
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
|
||||
if(keyEvent->matches(QKeySequence::Copy) || keyEvent->matches(QKeySequence::Cut) || keyEvent->matches(QKeySequence::Paste)){
|
||||
if (keyEvent->matches(QKeySequence::Copy) || keyEvent->matches(QKeySequence::Cut)
|
||||
|| keyEvent->matches(QKeySequence::Paste)) {
|
||||
event->ignore();
|
||||
return true;
|
||||
}else if((keyEvent->modifiers() & Qt::MetaModifier) || (keyEvent->modifiers() & Qt::AltModifier)){//当meta或者alt键被按下时,忽略按键事件
|
||||
} else if ((keyEvent->modifiers() & Qt::MetaModifier)
|
||||
|| (keyEvent->modifiers() & Qt::AltModifier)) { // 当meta或者alt键被按下时,忽略按键事件
|
||||
event->ignore();
|
||||
return true;
|
||||
}
|
||||
|
@ -110,23 +110,20 @@ bool IconEdit::eventFilter(QObject *obj, QEvent *event)
|
|||
if (event->type() == QEvent::MouseButtonPress) {
|
||||
Q_EMIT clickedPassword();
|
||||
}
|
||||
if(event->type() == 23)
|
||||
{
|
||||
if (event->type() == 23) {
|
||||
update();
|
||||
}else if(event->type() == QEvent::MouseButtonPress){
|
||||
} else if (event->type() == QEvent::MouseButtonPress) {
|
||||
update();
|
||||
} else if(event->type() == QEvent::MouseButtonRelease) { //禁用鼠标中键
|
||||
QMouseEvent *mouseevent = static_cast<QMouseEvent*>(event);
|
||||
if(mouseevent->button() == Qt::MidButton){
|
||||
} else if (event->type() == QEvent::MouseButtonRelease) { // 禁用鼠标中键
|
||||
QMouseEvent *mouseevent = static_cast<QMouseEvent *>(event);
|
||||
if (mouseevent->button() == Qt::MidButton) {
|
||||
event->ignore();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(obj == m_modeButton){
|
||||
if(event->type() == 2)
|
||||
{
|
||||
|
||||
if (obj == m_modeButton) {
|
||||
if (event->type() == 2) {
|
||||
}
|
||||
}
|
||||
if (obj == m_iconButton && event->type() == QEvent::KeyRelease) {
|
||||
|
@ -140,9 +137,9 @@ bool IconEdit::eventFilter(QObject *obj, QEvent *event)
|
|||
|
||||
void IconEdit::setIcon(const QIcon &icon, const QSize &size)
|
||||
{
|
||||
QPixmap pixmap = icon.pixmap(size.width()*scale, size.height()*scale);
|
||||
QPixmap pixmap = icon.pixmap(size.width() * scale, size.height() * scale);
|
||||
m_iconButton->setIcon(pixmap);
|
||||
m_iconButton->setIconSize(QSize(size.width()*scale, size.height()*scale));
|
||||
m_iconButton->setIconSize(QSize(size.width() * scale, size.height() * scale));
|
||||
m_iconButton->setText("");
|
||||
m_sizeIconBtn = size;
|
||||
m_icon = icon;
|
||||
|
@ -177,9 +174,9 @@ void IconEdit::setType(QLineEdit::EchoMode type)
|
|||
{
|
||||
m_edit->setEchoMode(type);
|
||||
if (type == 0) {
|
||||
m_modeButton->setIcon(QIcon::fromTheme("ukui-eye-display-symbolic"));
|
||||
m_modeButton->setIcon(QIcon::fromTheme("ukui-eye-display-symbolic"));
|
||||
} else {
|
||||
m_modeButton->setIcon(QIcon::fromTheme("ukui-eye-hidden-symbolic"));
|
||||
m_modeButton->setIcon(QIcon::fromTheme("ukui-eye-hidden-symbolic"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -202,21 +199,21 @@ void IconEdit::setModeBtnVisible(bool visible)
|
|||
void IconEdit::startWaiting()
|
||||
{
|
||||
m_edit->setReadOnly(true);
|
||||
//m_iconButton->setEnabled(false);
|
||||
// m_iconButton->setEnabled(false);
|
||||
|
||||
if(!m_timer)
|
||||
{
|
||||
if (!m_timer) {
|
||||
m_timer = new QTimer(this);
|
||||
m_timer->setInterval(150);
|
||||
connect(m_timer, &QTimer::timeout, this, &IconEdit::updatePixmap);
|
||||
}
|
||||
|
||||
//这里将QIcon转QPixmap传入(24,24)时,实际得到的pixmap大小为(24,24)乘上缩放比例,导致计算pixmap位置错误,因此需要重新设置一次大小
|
||||
//更好的解决方案应该是重写IconButton的setIcon函数?直接处理图片大小与icon大小一致?
|
||||
// QPixmap icon = QIcon::fromTheme("ukui-loading-0-symbolic").pixmap(16,16).scaled(16,16, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||
m_waitingPixmap = getLoadingIcon(16*scale);
|
||||
// 这里将QIcon转QPixmap传入(24,24)时,实际得到的pixmap大小为(24,24)乘上缩放比例,导致计算pixmap位置错误,因此需要重新设置一次大小
|
||||
// 更好的解决方案应该是重写IconButton的setIcon函数?直接处理图片大小与icon大小一致?
|
||||
// QPixmap icon = QIcon::fromTheme("ukui-loading-0-symbolic").pixmap(16,16).scaled(16,16, Qt::IgnoreAspectRatio,
|
||||
// Qt::SmoothTransformation);
|
||||
m_waitingPixmap = getLoadingIcon(16 * scale);
|
||||
m_iconButton->setIcon(m_waitingPixmap);
|
||||
m_iconButton->setIconSize(QSize(16*scale, 16*scale));
|
||||
m_iconButton->setIconSize(QSize(16 * scale, 16 * scale));
|
||||
m_timer->start();
|
||||
}
|
||||
|
||||
|
@ -228,9 +225,9 @@ void IconEdit::stopWaiting()
|
|||
m_iconButton->setAttribute(Qt::WA_TransparentForMouseEvents, false);
|
||||
m_edit->setReadOnly(false);
|
||||
if (!m_icon.isNull()) {
|
||||
QPixmap pixmap = m_icon.pixmap(m_sizeIconBtn.width()*scale, m_sizeIconBtn.height()*scale);
|
||||
QPixmap pixmap = m_icon.pixmap(m_sizeIconBtn.width() * scale, m_sizeIconBtn.height() * scale);
|
||||
m_iconButton->setIcon(pixmap);
|
||||
m_iconButton->setIconSize(QSize(m_sizeIconBtn.width()*scale, m_sizeIconBtn.height()*scale));
|
||||
m_iconButton->setIconSize(QSize(m_sizeIconBtn.width() * scale, m_sizeIconBtn.height() * scale));
|
||||
} else {
|
||||
m_iconButton->setText(m_iconText);
|
||||
}
|
||||
|
@ -238,17 +235,17 @@ void IconEdit::stopWaiting()
|
|||
|
||||
void IconEdit::updateUI()
|
||||
{
|
||||
m_iconButton->setFixedSize(QSize(24*scale, 24*scale));
|
||||
m_iconButton->setFixedSize(QSize(24 * scale, 24 * scale));
|
||||
if (!m_icon.isNull()) {
|
||||
QPixmap pixmap = m_icon.pixmap(m_sizeIconBtn.width()*scale, m_sizeIconBtn.height()*scale);
|
||||
QPixmap pixmap = m_icon.pixmap(m_sizeIconBtn.width() * scale, m_sizeIconBtn.height() * scale);
|
||||
m_iconButton->setIcon(pixmap);
|
||||
m_iconButton->setIconSize(QSize(m_sizeIconBtn.width()*scale, m_sizeIconBtn.height()*scale));
|
||||
m_iconButton->setIconSize(QSize(m_sizeIconBtn.width() * scale, m_sizeIconBtn.height() * scale));
|
||||
} else {
|
||||
m_iconButton->setText(m_iconText);
|
||||
}
|
||||
m_modeButton->setFixedSize(QSize(24*scale, 24*scale));
|
||||
m_modeButton->setIconSize(QSize(16*scale, 16*scale));
|
||||
m_capsIcon->setPixmap(QIcon::fromTheme("ukui-capslock-symbolic").pixmap(QSize(16*scale, 16*scale)));
|
||||
m_modeButton->setFixedSize(QSize(24 * scale, 24 * scale));
|
||||
m_modeButton->setIconSize(QSize(16 * scale, 16 * scale));
|
||||
m_capsIcon->setPixmap(QIcon::fromTheme("ukui-capslock-symbolic").pixmap(QSize(16 * scale, 16 * scale)));
|
||||
}
|
||||
|
||||
void IconEdit::updatePixmap()
|
||||
|
@ -259,7 +256,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*scale, 16*scale));
|
||||
m_iconButton->setIconSize(QSize(16 * scale, 16 * scale));
|
||||
}
|
||||
|
||||
void IconEdit::clicked_cb()
|
||||
|
@ -270,7 +267,7 @@ void IconEdit::clicked_cb()
|
|||
|
||||
void IconEdit::onCapsChanged(bool state)
|
||||
{
|
||||
if (QString(qgetenv("XDG_SESSION_TYPE")) == "wayland"){
|
||||
if (QString(qgetenv("XDG_SESSION_TYPE")) == "wayland") {
|
||||
m_capsState = checkCapsLockState();
|
||||
} else {
|
||||
m_capsState = state;
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* 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 "lockwidget.h"
|
||||
#include <QPixmap>
|
||||
#include <QPainter>
|
||||
|
@ -61,11 +61,9 @@
|
|||
#define BOTTOM_MARGIN 24
|
||||
|
||||
#define PREFIX QString(RESOURCE_PATH)
|
||||
#define IMAGE_DIR PREFIX+"/images/"
|
||||
#define IMAGE_DIR PREFIX + "/images/"
|
||||
float scale;
|
||||
LockWidget::LockWidget(LockDialogModel *model, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_modelLockDialog(model)
|
||||
LockWidget::LockWidget(LockDialogModel *model, QWidget *parent) : QWidget(parent), m_modelLockDialog(model)
|
||||
{
|
||||
scale = 1.0;
|
||||
m_curUserInfo = m_modelLockDialog->findUserByName(m_modelLockDialog->defaultUserName());
|
||||
|
@ -80,19 +78,18 @@ bool LockWidget::eventFilter(QObject *obj, QEvent *event)
|
|||
if (event->type() == QEvent::KeyRelease) {
|
||||
MyListWidget *listWidget = qobject_cast<MyListWidget *>(obj);
|
||||
if (listWidget) {
|
||||
if (listWidget && listWidget->hasFocus()) { //Tab键切入时,设置焦点状态
|
||||
if (listWidget && listWidget->hasFocus()) { // Tab键切入时,设置焦点状态
|
||||
listWidget->setCurrentRow(listWidget->currentRow(), QItemSelectionModel::SelectionFlag::SelectCurrent);
|
||||
listWidget->currentItemChanged(listWidget->currentItem(), nullptr);
|
||||
} else { //Tab键切出时,清空焦点状态
|
||||
} else { // Tab键切出时,清空焦点状态
|
||||
listWidget->setCurrentRow(listWidget->currentRow(), QItemSelectionModel::SelectionFlag::Clear);
|
||||
}
|
||||
}
|
||||
} else if (event->type() == QEvent::MouseButtonPress) {
|
||||
/// TODO
|
||||
if((m_networkWidget && m_networkWidget == obj) ||
|
||||
(m_userListWidget && m_userListWidget == obj) ||
|
||||
(m_sessionListWidget && m_sessionListWidget == obj) ||
|
||||
(m_virtualKeyboardWidget && m_virtualKeyboardWidget == obj)) {
|
||||
if ((m_networkWidget && m_networkWidget == obj) || (m_userListWidget && m_userListWidget == obj)
|
||||
|| (m_sessionListWidget && m_sessionListWidget == obj)
|
||||
|| (m_virtualKeyboardWidget && m_virtualKeyboardWidget == obj)) {
|
||||
return true;
|
||||
} else if (buttonListWidget && obj != buttonListWidget) {
|
||||
exitSubWidget();
|
||||
|
@ -105,12 +102,12 @@ bool LockWidget::eventFilter(QObject *obj, QEvent *event)
|
|||
bool LockWidget::exitSubWidget()
|
||||
{
|
||||
bool allExited = true;
|
||||
if(m_userListWidget && m_userListWidget->isVisible()){
|
||||
if (m_userListWidget && m_userListWidget->isVisible()) {
|
||||
m_userListWidget->hide();
|
||||
m_userButton->setClickedStatus(NORMAL);
|
||||
allExited = false;
|
||||
}
|
||||
if(m_powerListWidget && m_powerListWidget->isVisible()){
|
||||
if (m_powerListWidget && m_powerListWidget->isVisible()) {
|
||||
authDialog->setFocus();
|
||||
authDialog->show();
|
||||
authDialog->lower();
|
||||
|
@ -118,10 +115,10 @@ bool LockWidget::exitSubWidget()
|
|||
m_powerManagerButton->setClickedStatus(NORMAL);
|
||||
allExited = false;
|
||||
}
|
||||
if(m_networkWidget && m_networkWidget->isVisible()){
|
||||
if (m_networkWidget && m_networkWidget->isVisible()) {
|
||||
m_networkWidget->hide();
|
||||
m_networkButton->setClickedStatus(NORMAL);
|
||||
// sendNetPluginVisible(false);
|
||||
// sendNetPluginVisible(false);
|
||||
allExited = false;
|
||||
}
|
||||
if (m_virtualKeyboardWidget && m_virtualKeyboardWidget->isVisible()) {
|
||||
|
@ -150,7 +147,7 @@ void LockWidget::paintEvent(QPaintEvent *event)
|
|||
painter.drawPixmap(this->geometry(), background);
|
||||
QPainterPath path;
|
||||
painter.setOpacity(0.25);
|
||||
painter.setRenderHint(QPainter::Antialiasing); // 反锯齿;
|
||||
painter.setRenderHint(QPainter::Antialiasing); // 反锯齿;
|
||||
painter.setClipping(true);
|
||||
painter.setPen(Qt::transparent);
|
||||
path.addRect(this->rect());
|
||||
|
@ -164,52 +161,63 @@ void LockWidget::paintEvent(QPaintEvent *event)
|
|||
void LockWidget::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
QSize size = event->size();
|
||||
//重新计算缩放比例
|
||||
// 重新计算缩放比例
|
||||
scale = QString::number(size.width() / 1920.0, 'f', 1).toFloat();
|
||||
|
||||
authDialog->setGeometry((width()-this->geometry().width())/2, 148*scale, \
|
||||
this->width(), (height() - 150*scale - (24 + 48 + 16)*scale));
|
||||
authDialog->setGeometry((width() - this->geometry().width()) / 2,
|
||||
148 * scale,
|
||||
this->width(),
|
||||
(height() - 150 * scale - (24 + 48 + 16) * scale));
|
||||
authDialog->updateAuthSize();
|
||||
|
||||
m_timeWidget->updateUI();
|
||||
m_timeWidget->move((width() - m_timeWidget->width())/2, 48*scale);
|
||||
m_timeWidget->move((width() - m_timeWidget->width()) / 2, 48 * scale);
|
||||
if (m_userListWidget) {
|
||||
m_userListWidget->setMaxHeight(height()/2);
|
||||
m_userListWidget->setMaxHeight(height() / 2);
|
||||
m_userListWidget->updateWidgetSize();
|
||||
qDebug()<<"m_userListWidget:"<<m_userListWidget->geometry();
|
||||
qDebug() << "m_userListWidget:" << m_userListWidget->geometry();
|
||||
}
|
||||
|
||||
m_powerListWidget->move((width() - m_powerListWidget->width())/2, (height() - m_powerListWidget->height())/2 - BOTTOM_MARGIN*scale);
|
||||
m_powerListWidget->move((width() - m_powerListWidget->width()) / 2,
|
||||
(height() - m_powerListWidget->height()) / 2 - BOTTOM_MARGIN * scale);
|
||||
|
||||
updateBottomButton();
|
||||
if (m_curUserInfo->isLoggedIn() && m_sessionButton) {
|
||||
buttonListWidget->setFixedSize(QSize(48*(buttonListWidget->count() - 1) + buttonListWidget->spacing()*2*(buttonListWidget->count() - 1), 64));
|
||||
buttonListWidget->setFixedSize(QSize(48 * (buttonListWidget->count() - 1)
|
||||
+ buttonListWidget->spacing() * 2 * (buttonListWidget->count() - 1),
|
||||
64));
|
||||
} else {
|
||||
buttonListWidget->setFixedSize(QSize(48*buttonListWidget->count() + buttonListWidget->spacing()*2*buttonListWidget->count(), 64));
|
||||
buttonListWidget->setFixedSize(
|
||||
QSize(48 * buttonListWidget->count() + buttonListWidget->spacing() * 2 * buttonListWidget->count(), 64));
|
||||
}
|
||||
buttonListWidget->move(width() - buttonListWidget->width() - RIGHT_MARGIN*scale, height() - buttonListWidget->height() - BOTTOM_MARGIN*scale);
|
||||
buttonListWidget->move(width() - buttonListWidget->width() - RIGHT_MARGIN * scale,
|
||||
height() - buttonListWidget->height() - BOTTOM_MARGIN * scale);
|
||||
|
||||
if (m_sessionListWidget) {
|
||||
m_sessionListWidget->setMaxHeight(height()/2);
|
||||
m_sessionListWidget->setMaxHeight(height() / 2);
|
||||
m_sessionListWidget->updateWidgetSize();
|
||||
m_sessionListWidget->move(this->width() - m_sessionListWidget->width() - RIGHT_MARGIN*scale,
|
||||
height()- BOTTOM_MARGIN*scale - buttonListWidget->height() - buttonListWidget->spacing()*scale*2 - m_sessionListWidget->height());
|
||||
m_sessionListWidget->move(this->width() - m_sessionListWidget->width() - RIGHT_MARGIN * scale,
|
||||
height() - BOTTOM_MARGIN * scale - buttonListWidget->height()
|
||||
- buttonListWidget->spacing() * scale * 2 - m_sessionListWidget->height());
|
||||
}
|
||||
|
||||
if(m_networkWidget){
|
||||
m_networkWidget->setGeometry(this->width() - m_networkWidget->width() - RIGHT_MARGIN*scale,
|
||||
this->height() - m_networkWidget->height() - BOTTOM_MARGIN*scale - buttonListWidget->spacing()*scale*2 - buttonListWidget->height(),
|
||||
m_networkWidget->width(),
|
||||
m_networkWidget->height());
|
||||
if (m_networkWidget) {
|
||||
m_networkWidget->setGeometry(this->width() - m_networkWidget->width() - RIGHT_MARGIN * scale,
|
||||
this->height() - m_networkWidget->height() - BOTTOM_MARGIN * scale
|
||||
- buttonListWidget->spacing() * scale * 2 - buttonListWidget->height(),
|
||||
m_networkWidget->width(),
|
||||
m_networkWidget->height());
|
||||
}
|
||||
if (batteryWidget) {
|
||||
batteryWidget->move(this->width() - batteryWidget->width() - RIGHT_MARGIN*scale,
|
||||
height() - BOTTOM_MARGIN*scale - buttonListWidget->height() - buttonListWidget->spacing()*scale - batteryWidget->height());
|
||||
batteryWidget->move(this->width() - batteryWidget->width() - RIGHT_MARGIN * scale,
|
||||
height() - BOTTOM_MARGIN * scale - buttonListWidget->height()
|
||||
- buttonListWidget->spacing() * scale - batteryWidget->height());
|
||||
}
|
||||
|
||||
if (m_userListWidget) {
|
||||
m_userListWidget->move(width() - m_userListWidget->width() - RIGHT_MARGIN,
|
||||
height()- BOTTOM_MARGIN*scale - buttonListWidget->height() - buttonListWidget->spacing()*scale - m_userListWidget->height());
|
||||
height() - BOTTOM_MARGIN * scale - buttonListWidget->height()
|
||||
- buttonListWidget->spacing() * scale - m_userListWidget->height());
|
||||
}
|
||||
onSetVirkeyboardPos();
|
||||
}
|
||||
|
@ -217,35 +225,35 @@ void LockWidget::resizeEvent(QResizeEvent *event)
|
|||
void LockWidget::keyReleaseEvent(QKeyEvent *e)
|
||||
{
|
||||
if (e->key() == Qt::Key_K) {
|
||||
if(e->modifiers() & Qt::ControlModifier)
|
||||
if (e->modifiers() & Qt::ControlModifier)
|
||||
onShowVirtualKeyboard();
|
||||
}
|
||||
|
||||
// 监听按键事件实现快捷键功能
|
||||
switch (e->key()) {
|
||||
case Qt::Key_VolumeMute:
|
||||
Q_EMIT m_modelLockDialog->usdExternalDoAction(MIC_MUTE_KEY);
|
||||
break;
|
||||
case Qt::Key_VolumeDown:
|
||||
Q_EMIT m_modelLockDialog->usdExternalDoAction(VOLUME_DOWN_KEY);
|
||||
break;
|
||||
case Qt::Key_VolumeUp:
|
||||
Q_EMIT m_modelLockDialog->usdExternalDoAction(VOLUME_UP_KEY);
|
||||
break;
|
||||
case Qt::Key_MonBrightnessUp:
|
||||
Q_EMIT m_modelLockDialog->usdExternalDoAction(BRIGHT_UP_KEY);
|
||||
break;
|
||||
case Qt::Key_MonBrightnessDown:
|
||||
Q_EMIT m_modelLockDialog->usdExternalDoAction(BRIGHT_DOWN_KEY);
|
||||
break;
|
||||
case Qt::Key_TouchpadOn:
|
||||
Q_EMIT m_modelLockDialog->usdExternalDoAction(TOUCHPAD_ON_KEY);
|
||||
break;
|
||||
case Qt::Key_TouchpadOff:
|
||||
Q_EMIT m_modelLockDialog->usdExternalDoAction(TOUCHPAD_OFF_KEY);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case Qt::Key_VolumeMute:
|
||||
Q_EMIT m_modelLockDialog->usdExternalDoAction(MIC_MUTE_KEY);
|
||||
break;
|
||||
case Qt::Key_VolumeDown:
|
||||
Q_EMIT m_modelLockDialog->usdExternalDoAction(VOLUME_DOWN_KEY);
|
||||
break;
|
||||
case Qt::Key_VolumeUp:
|
||||
Q_EMIT m_modelLockDialog->usdExternalDoAction(VOLUME_UP_KEY);
|
||||
break;
|
||||
case Qt::Key_MonBrightnessUp:
|
||||
Q_EMIT m_modelLockDialog->usdExternalDoAction(BRIGHT_UP_KEY);
|
||||
break;
|
||||
case Qt::Key_MonBrightnessDown:
|
||||
Q_EMIT m_modelLockDialog->usdExternalDoAction(BRIGHT_DOWN_KEY);
|
||||
break;
|
||||
case Qt::Key_TouchpadOn:
|
||||
Q_EMIT m_modelLockDialog->usdExternalDoAction(TOUCHPAD_ON_KEY);
|
||||
break;
|
||||
case Qt::Key_TouchpadOff:
|
||||
Q_EMIT m_modelLockDialog->usdExternalDoAction(TOUCHPAD_OFF_KEY);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// 实现锁屏截图功能
|
||||
|
@ -268,9 +276,8 @@ void LockWidget::initUI()
|
|||
{
|
||||
// 检查并获取第三方认证插件配置信息
|
||||
if (PluginsLoader::instance().findModulesByType(LoginPluginInterface::MODULETYPE_AUTH).size() > 0) {
|
||||
LoginAuthInterface *plugin = dynamic_cast<LoginAuthInterface *>(PluginsLoader::instance() \
|
||||
.findModulesByType(LoginPluginInterface::MODULETYPE_AUTH) \
|
||||
.values().first());
|
||||
LoginAuthInterface *plugin = dynamic_cast<LoginAuthInterface *>(
|
||||
PluginsLoader::instance().findModulesByType(LoginPluginInterface::MODULETYPE_AUTH).values().first());
|
||||
QJsonObject rootObj;
|
||||
rootObj["MsgType"] = "GetInformations";
|
||||
rootObj["Key"] = "Configures";
|
||||
|
@ -286,8 +293,8 @@ void LockWidget::initUI()
|
|||
initPowerWidget();
|
||||
initButtonWidget();
|
||||
initBlockWidget();
|
||||
// authDialog->setFocus();
|
||||
// Q_EMIT m_modelLockDialog->setCurrentUser(m_modelLockDialog->defaultUserName());
|
||||
// authDialog->setFocus();
|
||||
// Q_EMIT m_modelLockDialog->setCurrentUser(m_modelLockDialog->defaultUserName());
|
||||
}
|
||||
|
||||
void LockWidget::initConnections()
|
||||
|
@ -301,40 +308,37 @@ void LockWidget::initConnections()
|
|||
connect(m_modelLockDialog, &LockDialogModel::fontSizeChanged, this, &LockWidget::onFontSizeChanged);
|
||||
if (authDialog) {
|
||||
connect(authDialog, SIGNAL(authSucceed(QString)), this, SIGNAL(authSucceed(QString)));
|
||||
connect(authDialog, &AuthDialog::userChangedByManual,
|
||||
this, &LockWidget::onUserChangedByManual);
|
||||
connect(authDialog, &AuthDialog::customRequestAccount,
|
||||
this, &LockWidget::onCustomRequestAccount);
|
||||
connect(authDialog, &AuthDialog::lineEditClicked,this, [=]{
|
||||
onLineEditClicked();
|
||||
});
|
||||
connect(authDialog, &AuthDialog::userChangedByManual, this, &LockWidget::onUserChangedByManual);
|
||||
connect(authDialog, &AuthDialog::customRequestAccount, this, &LockWidget::onCustomRequestAccount);
|
||||
connect(authDialog, &AuthDialog::lineEditClicked, this, [=] { onLineEditClicked(); });
|
||||
}
|
||||
connect(LanguageSetting::instance(this), &LanguageSetting::languageChanged, this, &LockWidget::onLanguageChanged);
|
||||
}
|
||||
void LockWidget::initTimeWidget()
|
||||
{
|
||||
m_timeWidget = new TimeWidget(m_modelLockDialog, this);
|
||||
m_timeWidget->move((width() - m_timeWidget->width())/2, 0);
|
||||
|
||||
m_timeWidget->move((width() - m_timeWidget->width()) / 2, 0);
|
||||
}
|
||||
void LockWidget::initUserWidget()
|
||||
{
|
||||
if (!m_userListWidget) {
|
||||
m_userListWidget = new UserListWidget(m_modelLockDialog, this);
|
||||
m_userListWidget->installEventFilter(this);
|
||||
m_userListWidget->setMaxHeight(height()/2);
|
||||
m_userListWidget->setMaxHeight(height() / 2);
|
||||
m_userListWidget->updateWidgetSize();
|
||||
m_userListWidget->hide();
|
||||
connect(m_userListWidget, &UserListWidget::userSelected, m_modelLockDialog, [=](QString strUserName){
|
||||
connect(m_userListWidget, &UserListWidget::userSelected, m_modelLockDialog, [=](QString strUserName) {
|
||||
SwitchToUser(strUserName);
|
||||
});
|
||||
connect(m_userListWidget, &UserListWidget::widgetSizeChanged, m_modelLockDialog, [=](){
|
||||
connect(m_userListWidget, &UserListWidget::widgetSizeChanged, m_modelLockDialog, [=]() {
|
||||
m_userListWidget->move(width() - m_userListWidget->width() - RIGHT_MARGIN,
|
||||
height()- BOTTOM_MARGIN*scale - buttonListWidget->height() - buttonListWidget->spacing()*scale - m_userListWidget->height());
|
||||
height() - BOTTOM_MARGIN * scale - buttonListWidget->height()
|
||||
- buttonListWidget->spacing() * scale - m_userListWidget->height());
|
||||
});
|
||||
m_userListWidget->clearFocus();
|
||||
m_userListWidget->move(width() - m_userListWidget->width() - RIGHT_MARGIN,
|
||||
height()- BOTTOM_MARGIN*scale - buttonListWidget->height() - buttonListWidget->spacing()*scale - m_userListWidget->height());
|
||||
height() - BOTTOM_MARGIN * scale - buttonListWidget->height()
|
||||
- buttonListWidget->spacing() * scale - m_userListWidget->height());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -343,23 +347,28 @@ void LockWidget::initSessionWidget()
|
|||
if (!m_sessionListWidget) {
|
||||
m_sessionListWidget = new SessionListWidget(m_modelLockDialog, this);
|
||||
m_sessionListWidget->installEventFilter(this);
|
||||
m_sessionListWidget->setMaxHeight(height()/2);
|
||||
m_sessionListWidget->setMaxHeight(height() / 2);
|
||||
m_sessionListWidget->updateWidgetSize();
|
||||
m_sessionListWidget->hide();
|
||||
connect(m_sessionListWidget, &SessionListWidget::sessionSelected, m_modelLockDialog, &LockDialogModel::setCurrentSession);
|
||||
connect(m_sessionListWidget,
|
||||
&SessionListWidget::sessionSelected,
|
||||
m_modelLockDialog,
|
||||
&LockDialogModel::setCurrentSession);
|
||||
m_sessionListWidget->clearFocus();
|
||||
if (buttonListWidget) {
|
||||
m_sessionListWidget->move(this->width() - m_sessionListWidget->width() - RIGHT_MARGIN*scale,
|
||||
height()- BOTTOM_MARGIN*scale - buttonListWidget->height() - buttonListWidget->spacing()*scale*2 - m_sessionListWidget->height());
|
||||
m_sessionListWidget->move(this->width() - m_sessionListWidget->width() - RIGHT_MARGIN * scale,
|
||||
height() - BOTTOM_MARGIN * scale - buttonListWidget->height()
|
||||
- buttonListWidget->spacing() * scale * 2 - m_sessionListWidget->height());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LockWidget::initPowerWidget()
|
||||
{
|
||||
m_powerListWidget = new PowerListWidget(m_modelLockDialog,this);
|
||||
m_powerListWidget->setMaximumHeight(height()/2);
|
||||
m_powerListWidget->move((width() - m_powerListWidget->width())/2, (height()-m_powerListWidget->height())/2-80);
|
||||
m_powerListWidget = new PowerListWidget(m_modelLockDialog, this);
|
||||
m_powerListWidget->setMaximumHeight(height() / 2);
|
||||
m_powerListWidget->move((width() - m_powerListWidget->width()) / 2,
|
||||
(height() - m_powerListWidget->height()) / 2 - 80);
|
||||
m_powerListWidget->hide();
|
||||
connect(m_powerListWidget, &MyListWidget::currentItemChanged, this, &LockWidget::onPowerItemChanged);
|
||||
connect(m_powerListWidget, &PowerListWidget::showInhibitWarning, this, &LockWidget::onShowInhibitWarning);
|
||||
|
@ -376,7 +385,7 @@ void LockWidget::initButtonWidget()
|
|||
buttonListWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
buttonListWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
QString buttonListStyle = "QListWidget{ background:rgba(255, 255, 255, 0%); border: 0px;}"
|
||||
"QListWidget::item{border-radius: 4px; background:rgba(255, 255, 255, 0%);}";
|
||||
"QListWidget::item{border-radius: 4px; background:rgba(255, 255, 255, 0%);}";
|
||||
buttonListWidget->setStyleSheet(buttonListStyle);
|
||||
buttonListWidget->setSpacing(8);
|
||||
|
||||
|
@ -395,14 +404,13 @@ void LockWidget::initButtonWidget()
|
|||
}
|
||||
QString strCurSession = m_modelLockDialog->currentSession();
|
||||
QString sessionPrefix = strCurSession.left(strCurSession.indexOf('-'));
|
||||
if(strCurSession == "ukui-wayland")
|
||||
if (strCurSession == "ukui-wayland")
|
||||
sessionPrefix = "ukui_wayland";
|
||||
if(strCurSession == "kylin-wlcom")
|
||||
if (strCurSession == "kylin-wlcom")
|
||||
sessionPrefix = "kylin_wlcom";
|
||||
strCurSession = IMAGE_DIR + QString("badges/%1_badge.svg")
|
||||
.arg(sessionPrefix.toLower());
|
||||
strCurSession = IMAGE_DIR + QString("badges/%1_badge.svg").arg(sessionPrefix.toLower());
|
||||
QFile iconFile(strCurSession);
|
||||
if(!iconFile.exists()){
|
||||
if (!iconFile.exists()) {
|
||||
strCurSession = IMAGE_DIR + QString("badges/unknown_badge.svg");
|
||||
}
|
||||
QPixmap ssIcon(strCurSession);
|
||||
|
@ -410,9 +418,7 @@ void LockWidget::initButtonWidget()
|
|||
ssIcon = ssIcon.scaled(32, 32, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||
ssIcon = PixmapToRound(ssIcon, 16);
|
||||
m_sessionButton->setIcon(ssIcon);
|
||||
connect(m_sessionButton, &StatusButton::clicked, this, [this]() {
|
||||
onShowSessionListWidget();
|
||||
});
|
||||
connect(m_sessionButton, &StatusButton::clicked, this, [this]() { onShowSessionListWidget(); });
|
||||
}
|
||||
|
||||
if (m_modelLockDialog->getIsBattery()) {
|
||||
|
@ -421,16 +427,15 @@ void LockWidget::initButtonWidget()
|
|||
buttonItem->setSizeHint(QSize(48, 48));
|
||||
buttonListWidget->insertItem(buttonListWidget->count(), buttonItem);
|
||||
buttonListWidget->setItemWidget(buttonItem, m_batteryonButton);
|
||||
QPixmap batteryIcon = drawSymbolicColoredPixmap(QIcon::fromTheme(m_modelLockDialog->getBatteryIconName()).pixmap(QSize(24, 24)), "white");
|
||||
QPixmap batteryIcon = drawSymbolicColoredPixmap(
|
||||
QIcon::fromTheme(m_modelLockDialog->getBatteryIconName()).pixmap(QSize(24, 24)), "white");
|
||||
m_batteryonButton->setIcon(batteryIcon);
|
||||
connect(m_modelLockDialog, &LockDialogModel::batteryStatusChanged, this, [=](const QString &iconName) {
|
||||
QPixmap batteryIcon = drawSymbolicColoredPixmap(QIcon::fromTheme(iconName).pixmap(QSize(24, 24)), "white");
|
||||
m_batteryonButton->setIcon(batteryIcon);
|
||||
});
|
||||
buttonListWidget->addItem(buttonItem);
|
||||
connect(m_batteryonButton, &StatusButton::clicked, this, [this]() {
|
||||
onShowBatteryWidget();
|
||||
});
|
||||
connect(m_batteryonButton, &StatusButton::clicked, this, [this]() { onShowBatteryWidget(); });
|
||||
}
|
||||
|
||||
m_userButton = new StatusButton(this, BOTBUTTON);
|
||||
|
@ -440,9 +445,7 @@ void LockWidget::initButtonWidget()
|
|||
buttonListWidget->setItemWidget(m_btnItemUser, m_userButton);
|
||||
m_userButton->setIcon(QIcon(":/image/assets/switchuser.svg"));
|
||||
buttonListWidget->addItem(m_btnItemUser);
|
||||
connect(m_userButton, &StatusButton::clicked, this, [this]() {
|
||||
onShowUserListWidget();
|
||||
});
|
||||
connect(m_userButton, &StatusButton::clicked, this, [this]() { onShowUserListWidget(); });
|
||||
if (m_modelLockDialog->usersInfo().count() > 1 || m_modelLockDialog->findUserByName("*login")) {
|
||||
buttonListWidget->setItemHidden(m_btnItemUser, false);
|
||||
} else {
|
||||
|
@ -455,9 +458,7 @@ void LockWidget::initButtonWidget()
|
|||
buttonListWidget->insertItem(buttonListWidget->count(), buttonItem);
|
||||
buttonListWidget->setItemWidget(buttonItem, m_networkButton);
|
||||
buttonListWidget->addItem(buttonItem);
|
||||
connect(m_networkButton, &NetWorkButton::clicked, this, [this]() {
|
||||
onShowNetworkWidget();
|
||||
});
|
||||
connect(m_networkButton, &NetWorkButton::clicked, this, [this]() { onShowNetworkWidget(); });
|
||||
|
||||
/*
|
||||
connect(buttonWidget, &KyNetworkIcon::updateIconHidden
|
||||
|
@ -480,12 +481,10 @@ void LockWidget::initButtonWidget()
|
|||
buttonListWidget->setItemWidget(kyeboardItem, m_virKbButton);
|
||||
m_virKbButton->setIcon(QIcon(":/image/assets/keyboard.svg"));
|
||||
buttonListWidget->addItem(kyeboardItem);
|
||||
connect(m_virKbButton, &StatusButton::clicked, this, [this]() {
|
||||
onShowVirtualKeyboard();
|
||||
});
|
||||
connect(m_virKbButton, &StatusButton::clicked, this, [this]() { onShowVirtualKeyboard(); });
|
||||
onShowVirtualKeyboard(m_modelLockDialog->getTabletMode());
|
||||
|
||||
if (m_powerListWidget->count() > 1 ) {
|
||||
if (m_powerListWidget->count() > 1) {
|
||||
m_powerManagerButton = new StatusButton(this, BOTBUTTON);
|
||||
QListWidgetItem *buttonItem = new QListWidgetItem();
|
||||
buttonItem->setSizeHint(QSize(48, 48));
|
||||
|
@ -493,17 +492,19 @@ void LockWidget::initButtonWidget()
|
|||
buttonListWidget->setItemWidget(buttonItem, m_powerManagerButton);
|
||||
m_powerManagerButton->setIcon(QIcon(":/image/assets/shutdown.svg"));
|
||||
buttonListWidget->addItem(buttonItem);
|
||||
connect(m_powerManagerButton, &StatusButton::clicked, this, [this]() {
|
||||
onShowPowerListWidget();
|
||||
});
|
||||
connect(m_powerManagerButton, &StatusButton::clicked, this, [this]() { onShowPowerListWidget(); });
|
||||
}
|
||||
|
||||
if (m_curUserInfo->isLoggedIn() && m_sessionButton) {
|
||||
buttonListWidget->setFixedSize(QSize(48*(buttonListWidget->count() - 1) + buttonListWidget->spacing()*2*(buttonListWidget->count() - 1), 64));
|
||||
buttonListWidget->setFixedSize(QSize(48 * (buttonListWidget->count() - 1)
|
||||
+ buttonListWidget->spacing() * 2 * (buttonListWidget->count() - 1),
|
||||
64));
|
||||
} else {
|
||||
buttonListWidget->setFixedSize(QSize(48*buttonListWidget->count() + buttonListWidget->spacing()*2*buttonListWidget->count(), 64));
|
||||
buttonListWidget->setFixedSize(
|
||||
QSize(48 * buttonListWidget->count() + buttonListWidget->spacing() * 2 * buttonListWidget->count(), 64));
|
||||
}
|
||||
buttonListWidget->move(width()- RIGHT_MARGIN -buttonListWidget->width(), height() - BOTTOM_MARGIN - buttonListWidget->spacing());
|
||||
buttonListWidget->move(width() - RIGHT_MARGIN - buttonListWidget->width(),
|
||||
height() - BOTTOM_MARGIN - buttonListWidget->spacing());
|
||||
connect(buttonListWidget, &MyListWidget::currentItemChanged, this, &LockWidget::onButtonItemChanged);
|
||||
connect(buttonListWidget, &MyListWidget::itemClicked, this, &LockWidget::onButtonItemClicked);
|
||||
buttonListWidget->clearFocus();
|
||||
|
@ -514,10 +515,8 @@ void LockWidget::initBlockWidget()
|
|||
m_blockWidget = new BlockWidget(m_modelLockDialog, this);
|
||||
m_blockWidget->setGeometry(this->geometry());
|
||||
m_blockWidget->hide();
|
||||
connect(m_blockWidget, SIGNAL(cancelButtonclicked()),
|
||||
this, SLOT(onCancelBtnClicked()));
|
||||
connect(m_blockWidget, SIGNAL(confirmButtonclicked()),
|
||||
this, SLOT(onConfirmBtnClicked()));
|
||||
connect(m_blockWidget, SIGNAL(cancelButtonclicked()), this, SLOT(onCancelBtnClicked()));
|
||||
connect(m_blockWidget, SIGNAL(confirmButtonclicked()), this, SLOT(onConfirmBtnClicked()));
|
||||
}
|
||||
|
||||
void LockWidget::initUsdMediaKeys()
|
||||
|
@ -545,17 +544,17 @@ void LockWidget::updateBottomButton()
|
|||
QList<StatusButton *> statusButton = this->findChildren<StatusButton *>();
|
||||
for (auto button : statusButton) {
|
||||
if (button->getButtonTyoe() == POWERBUTTON) {
|
||||
button->setFixedSize(130*scale, 130*scale);
|
||||
button->setIconSize(QSize(130*scale, 130*scale));
|
||||
button->setFixedSize(130 * scale, 130 * scale);
|
||||
button->setIconSize(QSize(130 * scale, 130 * scale));
|
||||
} else {
|
||||
button->setFixedSize(48*scale, 48*scale);
|
||||
button->setIconSize(QSize(24*scale, 24*scale));
|
||||
button->setFixedSize(48 * scale, 48 * scale);
|
||||
button->setIconSize(QSize(24 * scale, 24 * scale));
|
||||
}
|
||||
}
|
||||
QList<NetWorkButton *> networkButton = this->findChildren<NetWorkButton *>();
|
||||
for (auto button : networkButton) {
|
||||
button->setFixedSize(48*scale, 48*scale);
|
||||
button->setIconSize(QSize(24*scale, 24*scale));
|
||||
button->setFixedSize(48 * scale, 48 * scale);
|
||||
button->setIconSize(QSize(24 * scale, 24 * scale));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -642,8 +641,11 @@ void LockWidget::onUsersInfoChanged()
|
|||
m_userListWidget->hide();
|
||||
}
|
||||
if (m_userListWidget) {
|
||||
m_userListWidget->move(width() - (m_userListWidget->width()/2 + RIGHT_MARGIN*scale + (m_virKbButton->width() + buttonListWidget->spacing()*scale*2)*4),
|
||||
height()- BOTTOM_MARGIN*scale - buttonListWidget->height() - buttonListWidget->spacing()*scale - m_userListWidget->height());
|
||||
m_userListWidget->move(width()
|
||||
- (m_userListWidget->width() / 2 + RIGHT_MARGIN * scale
|
||||
+ (m_virKbButton->width() + buttonListWidget->spacing() * scale * 2) * 4),
|
||||
height() - BOTTOM_MARGIN * scale - buttonListWidget->height()
|
||||
- buttonListWidget->spacing() * scale - m_userListWidget->height());
|
||||
}
|
||||
}
|
||||
UserInfoPtr ptrUser = m_modelLockDialog->findUserByName(m_curUserInfo->name());
|
||||
|
@ -660,26 +662,26 @@ void LockWidget::onCurUserChanged(const QString &strUserName)
|
|||
UserInfoPtr ptrUser = m_modelLockDialog->findUserByName(strUserName);
|
||||
if (ptrUser) {
|
||||
m_curUserInfo = ptrUser;
|
||||
qDebug()<<"CurUserInfo:"<<*m_curUserInfo;
|
||||
qDebug() << "CurUserInfo:" << *m_curUserInfo;
|
||||
if (m_curUserInfo->name() != "*login" && m_curUserInfo->name() != "*guest") {
|
||||
LanguageSetting::instance()->onLanguageChanged(m_curUserInfo->lang());
|
||||
}
|
||||
if (authDialog)
|
||||
authDialog->onCurUserChanged(m_curUserInfo);
|
||||
//登录后绘制桌面背景而不是登录背景
|
||||
// 登录后绘制桌面背景而不是登录背景
|
||||
QString backgroundPath = m_curUserInfo->backGround();
|
||||
QFile backgroundPathFile(backgroundPath);
|
||||
if(backgroundPath.isEmpty() || !backgroundPathFile.exists()) {
|
||||
if (backgroundPath.isEmpty() || !backgroundPathFile.exists()) {
|
||||
backgroundPath = Configuration::instance(this)->getDefaultBackgroundName();
|
||||
}
|
||||
setRootWindowBgOptions(Configuration::instance(this)->getRootBackgroundOption(strUserName));
|
||||
setrootWindowBackground(rootWinPicture,0,backgroundPath);
|
||||
setrootWindowBackground(rootWinPicture, 0, backgroundPath);
|
||||
QString drawBackgroundColor = m_curUserInfo->backGroundColor();
|
||||
if(drawBackgroundColor.length() == 7 && drawBackgroundColor.startsWith("#")){
|
||||
drawBackgroundColor = drawBackgroundColor.remove(0,1);
|
||||
if (drawBackgroundColor.length() == 7 && drawBackgroundColor.startsWith("#")) {
|
||||
drawBackgroundColor = drawBackgroundColor.remove(0, 1);
|
||||
bool ok;
|
||||
int color = drawBackgroundColor.toUInt(&ok,16);
|
||||
setrootWindowBackground(rootWinColor,color,NULL);
|
||||
int color = drawBackgroundColor.toUInt(&ok, 16);
|
||||
setrootWindowBackground(rootWinColor, color, NULL);
|
||||
}
|
||||
reloadRootBackground();
|
||||
}
|
||||
|
@ -699,7 +701,6 @@ void LockWidget::onUserChangedByManual(const QString &userName)
|
|||
SwitchToUser(userName);
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -710,18 +711,17 @@ void LockWidget::onSessionChanged(const QString &strSession)
|
|||
QListWidgetItem *item = buttonListWidget->item(n);
|
||||
QWidget *widget = buttonListWidget->itemWidget(item);
|
||||
if (widget->objectName() == "BtnSession") {
|
||||
StatusButton *sButton = qobject_cast<StatusButton*>(widget);
|
||||
StatusButton *sButton = qobject_cast<StatusButton *>(widget);
|
||||
if (sButton) {
|
||||
QString strCurSession = strSession;
|
||||
QString sessionPrefix = strCurSession.left(strCurSession.indexOf('-'));
|
||||
if(strCurSession == "ukui-wayland")
|
||||
if (strCurSession == "ukui-wayland")
|
||||
sessionPrefix = "ukui_wayland";
|
||||
if(strCurSession == "kylin-wlcom")
|
||||
if (strCurSession == "kylin-wlcom")
|
||||
sessionPrefix = "kylin_wlcom";
|
||||
strCurSession = IMAGE_DIR + QString("badges/%1_badge.svg")
|
||||
.arg(sessionPrefix.toLower());
|
||||
strCurSession = IMAGE_DIR + QString("badges/%1_badge.svg").arg(sessionPrefix.toLower());
|
||||
QFile iconFile(strCurSession);
|
||||
if(!iconFile.exists()){
|
||||
if (!iconFile.exists()) {
|
||||
strCurSession = IMAGE_DIR + QString("badges/unknown_badge.svg");
|
||||
}
|
||||
QPixmap ssIcon(strCurSession);
|
||||
|
@ -776,7 +776,8 @@ void LockWidget::onShowBatteryWidget()
|
|||
batteryWidget->setFixedSize(420, 112);
|
||||
if (batteryWidget) {
|
||||
batteryWidget->move(this->width() - batteryWidget->width() - RIGHT_MARGIN,
|
||||
this->height() - batteryWidget->height() - BOTTOM_MARGIN - buttonListWidget->spacing()*2 - buttonListWidget->height());
|
||||
this->height() - batteryWidget->height() - BOTTOM_MARGIN
|
||||
- buttonListWidget->spacing() * 2 - buttonListWidget->height());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -819,15 +820,16 @@ void LockWidget::onShowNetworkWidget()
|
|||
if (!m_networkWidget) {
|
||||
m_networkWidget = new MyNetworkWidget(this);
|
||||
m_networkWidget->installEventFilter(this);
|
||||
connect(m_networkWidget, &MyNetworkWidget::showVirtualKeyboard, this, [=]{
|
||||
connect(m_networkWidget, &MyNetworkWidget::showVirtualKeyboard, this, [=] {
|
||||
onShowVirtualKeyboard(m_isTabletMode);
|
||||
});
|
||||
}
|
||||
m_networkWidget->loadNetPlugin();
|
||||
m_networkWidget->setGeometry(this->width() - m_networkWidget->width() - RIGHT_MARGIN*scale,
|
||||
this->height() - m_networkWidget->height() - BOTTOM_MARGIN*scale - buttonListWidget->spacing()*scale - buttonListWidget->height(),
|
||||
m_networkWidget->width(),
|
||||
m_networkWidget->height());
|
||||
m_networkWidget->setGeometry(this->width() - m_networkWidget->width() - RIGHT_MARGIN * scale,
|
||||
this->height() - m_networkWidget->height() - BOTTOM_MARGIN * scale
|
||||
- buttonListWidget->spacing() * scale - buttonListWidget->height(),
|
||||
m_networkWidget->width(),
|
||||
m_networkWidget->height());
|
||||
if (m_networkWidget && m_networkWidget->isVisible()) {
|
||||
m_networkWidget->hide();
|
||||
m_networkButton->setClickedStatus(NORMAL);
|
||||
|
@ -845,15 +847,14 @@ void LockWidget::onShowNetworkWidget()
|
|||
|
||||
void LockWidget::onLineEditClicked()
|
||||
{
|
||||
if(!m_virtualKeyboardWidget){
|
||||
if (!m_virtualKeyboardWidget) {
|
||||
m_virtualKeyboardWidget = new VirtualKeyboardWidget(this);
|
||||
m_virtualKeyboardWidget->installEventFilter(this);
|
||||
m_virtualKeyboardWidget->hide();
|
||||
|
||||
connect(m_virtualKeyboardWidget, &VirtualKeyboardWidget::aboutToClose,
|
||||
this, &LockWidget::onHideVirkeyboard);
|
||||
connect(m_virtualKeyboardWidget, &VirtualKeyboardWidget::aboutToFloat,
|
||||
this, &LockWidget::onNetWorkResetLocation);
|
||||
connect(m_virtualKeyboardWidget, &VirtualKeyboardWidget::aboutToClose, this, &LockWidget::onHideVirkeyboard);
|
||||
connect(
|
||||
m_virtualKeyboardWidget, &VirtualKeyboardWidget::aboutToFloat, this, &LockWidget::onNetWorkResetLocation);
|
||||
}
|
||||
if (m_isTabletMode) {
|
||||
if (batteryWidget && batteryWidget->isVisible())
|
||||
|
@ -869,15 +870,14 @@ void LockWidget::onLineEditClicked()
|
|||
|
||||
void LockWidget::onShowVirtualKeyboard()
|
||||
{
|
||||
if(!m_virtualKeyboardWidget){
|
||||
if (!m_virtualKeyboardWidget) {
|
||||
m_virtualKeyboardWidget = new VirtualKeyboardWidget(this);
|
||||
m_virtualKeyboardWidget->installEventFilter(this);
|
||||
m_virtualKeyboardWidget->hide();
|
||||
|
||||
connect(m_virtualKeyboardWidget, &VirtualKeyboardWidget::aboutToClose,
|
||||
this, &LockWidget::onHideVirkeyboard);
|
||||
connect(m_virtualKeyboardWidget, &VirtualKeyboardWidget::aboutToFloat,
|
||||
this, &LockWidget::onNetWorkResetLocation);
|
||||
connect(m_virtualKeyboardWidget, &VirtualKeyboardWidget::aboutToClose, this, &LockWidget::onHideVirkeyboard);
|
||||
connect(
|
||||
m_virtualKeyboardWidget, &VirtualKeyboardWidget::aboutToFloat, this, &LockWidget::onNetWorkResetLocation);
|
||||
}
|
||||
if (m_virtualKeyboardWidget->isHidden()) {
|
||||
if (batteryWidget && batteryWidget->isVisible())
|
||||
|
@ -892,10 +892,10 @@ void LockWidget::onShowVirtualKeyboard()
|
|||
m_virtualKeyboardWidget->hide();
|
||||
}
|
||||
|
||||
if(!m_virtualKeyboardWidget->isHidden()){
|
||||
if(m_networkWidget && m_networkWidget->isVisible() && !m_virtualKeyboardWidget->getFloatStatus()) {
|
||||
if (!m_virtualKeyboardWidget->isHidden()) {
|
||||
if (m_networkWidget && m_networkWidget->isVisible() && !m_virtualKeyboardWidget->getFloatStatus()) {
|
||||
m_networkWidget->move(this->width() - m_networkWidget->width() - 20,
|
||||
this->height() - m_networkWidget->height() - m_virtualKeyboardWidget->height());
|
||||
this->height() - m_networkWidget->height() - m_virtualKeyboardWidget->height());
|
||||
m_networkWidget->raise();
|
||||
} else {
|
||||
}
|
||||
|
@ -907,15 +907,14 @@ void LockWidget::onShowVirtualKeyboard()
|
|||
void LockWidget::onShowVirtualKeyboard(bool tabletMode)
|
||||
{
|
||||
m_isTabletMode = tabletMode;
|
||||
if(!m_virtualKeyboardWidget){
|
||||
if (!m_virtualKeyboardWidget) {
|
||||
m_virtualKeyboardWidget = new VirtualKeyboardWidget(this);
|
||||
m_virtualKeyboardWidget->installEventFilter(this);
|
||||
m_virtualKeyboardWidget->hide();
|
||||
|
||||
connect(m_virtualKeyboardWidget, &VirtualKeyboardWidget::aboutToClose,
|
||||
this, &LockWidget::onHideVirkeyboard);
|
||||
connect(m_virtualKeyboardWidget, &VirtualKeyboardWidget::aboutToFloat,
|
||||
this, &LockWidget::onNetWorkResetLocation);
|
||||
connect(m_virtualKeyboardWidget, &VirtualKeyboardWidget::aboutToClose, this, &LockWidget::onHideVirkeyboard);
|
||||
connect(
|
||||
m_virtualKeyboardWidget, &VirtualKeyboardWidget::aboutToFloat, this, &LockWidget::onNetWorkResetLocation);
|
||||
}
|
||||
if (tabletMode) {
|
||||
if (batteryWidget && batteryWidget->isVisible())
|
||||
|
@ -930,10 +929,10 @@ void LockWidget::onShowVirtualKeyboard(bool tabletMode)
|
|||
m_virtualKeyboardWidget->hide();
|
||||
}
|
||||
|
||||
if(!m_virtualKeyboardWidget->isHidden()){
|
||||
if(m_networkWidget && m_networkWidget->isVisible() && !m_virtualKeyboardWidget->getFloatStatus()) {
|
||||
if (!m_virtualKeyboardWidget->isHidden()) {
|
||||
if (m_networkWidget && m_networkWidget->isVisible() && !m_virtualKeyboardWidget->getFloatStatus()) {
|
||||
m_networkWidget->move(this->width() - m_networkWidget->width() - 20,
|
||||
this->height() - m_networkWidget->height() - m_virtualKeyboardWidget->height());
|
||||
this->height() - m_networkWidget->height() - m_virtualKeyboardWidget->height());
|
||||
m_networkWidget->raise();
|
||||
} else {
|
||||
}
|
||||
|
@ -977,8 +976,7 @@ void LockWidget::onShowPowerListWidget()
|
|||
|
||||
void LockWidget::onSetVirkeyboardPos()
|
||||
{
|
||||
if(m_virtualKeyboardWidget)
|
||||
{
|
||||
if (m_virtualKeyboardWidget) {
|
||||
m_virtualKeyboardWidget->adjustGeometry();
|
||||
}
|
||||
}
|
||||
|
@ -988,10 +986,11 @@ void LockWidget::onNetWorkResetLocation()
|
|||
if (m_networkWidget && m_networkWidget->isVisible()) {
|
||||
if (m_virtualKeyboardWidget->getFloatStatus()) {
|
||||
m_networkWidget->move(this->width() - m_networkWidget->width() - RIGHT_MARGIN,
|
||||
this->height() - m_networkWidget->height() - BOTTOM_MARGIN - buttonListWidget->spacing() - buttonListWidget->height()) ;
|
||||
this->height() - m_networkWidget->height() - BOTTOM_MARGIN
|
||||
- buttonListWidget->spacing() - buttonListWidget->height());
|
||||
} else {
|
||||
m_networkWidget->move(this->width() - m_networkWidget->width() - RIGHT_MARGIN,
|
||||
this->height() - m_networkWidget->height() - m_virtualKeyboardWidget->height());
|
||||
this->height() - m_networkWidget->height() - m_virtualKeyboardWidget->height());
|
||||
}
|
||||
m_networkWidget->raise();
|
||||
}
|
||||
|
@ -1002,12 +1001,13 @@ void LockWidget::onNetWorkResetLocation()
|
|||
|
||||
void LockWidget::onHideVirkeyboard()
|
||||
{
|
||||
if(m_virtualKeyboardWidget && m_virtualKeyboardWidget->isVisible()) {
|
||||
if (m_virtualKeyboardWidget && m_virtualKeyboardWidget->isVisible()) {
|
||||
m_virtualKeyboardWidget->hide();
|
||||
}
|
||||
if(m_networkWidget && m_networkWidget->isVisible()) {
|
||||
if (m_networkWidget && m_networkWidget->isVisible()) {
|
||||
m_networkWidget->move(this->width() - m_networkWidget->width() - RIGHT_MARGIN,
|
||||
this->height() - m_networkWidget->height() - BOTTOM_MARGIN - buttonListWidget->spacing() - buttonListWidget->height());
|
||||
this->height() - m_networkWidget->height() - BOTTOM_MARGIN - buttonListWidget->spacing()
|
||||
- buttonListWidget->height());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1023,7 +1023,8 @@ void LockWidget::onMulUsersLogined(QString inhibitType)
|
|||
{
|
||||
m_inhibitType = inhibitType;
|
||||
m_blockWidget->setGeometry(this->geometry());
|
||||
m_blockWidget->setTips(tr("Multiple users are logged in at the same time.Are you sure you want to %1 this system?").arg(inhibitType));
|
||||
m_blockWidget->setTips(
|
||||
tr("Multiple users are logged in at the same time.Are you sure you want to %1 this system?").arg(inhibitType));
|
||||
m_blockWidget->show();
|
||||
m_isInhibitStatus = true;
|
||||
}
|
||||
|
@ -1049,7 +1050,7 @@ void LockWidget::onCancelBtnClicked()
|
|||
|
||||
void LockWidget::onCustomRequestAccount(QString account)
|
||||
{
|
||||
if(m_modelLockDialog) {
|
||||
if (m_modelLockDialog) {
|
||||
SwitchToUser(account);
|
||||
}
|
||||
}
|
||||
|
@ -1059,13 +1060,13 @@ void LockWidget::onGetCustomPluginMsg(QString strMsg)
|
|||
QJsonParseError jsonParseError;
|
||||
const QJsonDocument jsonDoc = QJsonDocument::fromJson(strMsg.toUtf8(), &jsonParseError);
|
||||
if (jsonParseError.error != QJsonParseError::NoError) {
|
||||
qWarning()<<"Parse message json failed!!";
|
||||
return ;
|
||||
qWarning() << "Parse message json failed!!";
|
||||
return;
|
||||
} else {
|
||||
QJsonObject rootObj = jsonDoc.object();
|
||||
if (rootObj.isEmpty()) {
|
||||
qWarning()<<"Message Json is null!!";
|
||||
return ;
|
||||
qWarning() << "Message Json is null!!";
|
||||
return;
|
||||
} else {
|
||||
QJsonObject contentObj = rootObj.value("Content").toObject();
|
||||
if (!contentObj.isEmpty()) {
|
||||
|
@ -1082,14 +1083,14 @@ void LockWidget::onGetCustomPluginMsg(QString strMsg)
|
|||
|
||||
void LockWidget::stopAuth()
|
||||
{
|
||||
if(authDialog){
|
||||
if (authDialog) {
|
||||
authDialog->stopAuth();
|
||||
}
|
||||
}
|
||||
|
||||
void LockWidget::startAuth()
|
||||
{
|
||||
if(authDialog){
|
||||
if (authDialog) {
|
||||
authDialog->startAuth();
|
||||
}
|
||||
}
|
||||
|
@ -1126,21 +1127,21 @@ void LockWidget::onFontSizeChanged(double fontSize)
|
|||
|
||||
void LockWidget::SwitchToUser(QString strUserName)
|
||||
{
|
||||
if(m_modelLockDialog) {
|
||||
if (m_modelLockDialog) {
|
||||
int nSwitchRet = Q_EMIT m_modelLockDialog->switchToUser(strUserName);
|
||||
if (nSwitchRet != 0) {
|
||||
Q_EMIT m_modelLockDialog->setCurrentUser(strUserName);
|
||||
} else {
|
||||
// if(authDialog) {
|
||||
// authDialog->stopAuth();
|
||||
// }
|
||||
// if(authDialog) {
|
||||
// authDialog->stopAuth();
|
||||
// }
|
||||
if (!isCurUserSelf(strUserName) && !isHidden()) {
|
||||
this->hide();
|
||||
update();
|
||||
if (!m_timerChkActive) {
|
||||
m_timerChkActive = new QTimer(this);
|
||||
m_timerChkActive->setInterval(10*1000);
|
||||
connect(m_timerChkActive, &QTimer::timeout, this, [&,this](){
|
||||
m_timerChkActive->setInterval(10 * 1000);
|
||||
connect(m_timerChkActive, &QTimer::timeout, this, [&, this]() {
|
||||
if (this->isHidden()) {
|
||||
this->show();
|
||||
}
|
||||
|
@ -1153,7 +1154,7 @@ void LockWidget::SwitchToUser(QString strUserName)
|
|||
}
|
||||
m_timerChkActive->start();
|
||||
stopAuth();
|
||||
}else{
|
||||
} else {
|
||||
Q_EMIT m_modelLockDialog->setCurrentUser(strUserName);
|
||||
}
|
||||
}
|
||||
|
@ -1169,12 +1170,12 @@ void LockWidget::onLanguageChanged(bool isCompleted)
|
|||
}
|
||||
}
|
||||
|
||||
void LockWidget::setrootWindowBackground(int type,unsigned int color,QString filename)
|
||||
void LockWidget::setrootWindowBackground(int type, unsigned int color, QString filename)
|
||||
{
|
||||
drawBackgroundType = type;
|
||||
if(drawBackgroundType == rootWinPicture)
|
||||
if (drawBackgroundType == rootWinPicture)
|
||||
m_rootWindowBackground = filename;
|
||||
else if(drawBackgroundType == rootWinColor)
|
||||
else if (drawBackgroundType == rootWinColor)
|
||||
drawBackgroundColor = color;
|
||||
}
|
||||
|
||||
|
@ -1188,20 +1189,20 @@ bool LockWidget::getdrawBackgroundIsStarted()
|
|||
return drawBackgroundIsStarted;
|
||||
}
|
||||
|
||||
void LockWidget::setrootWindow(QList<QPair<QRect,QRect>> screenRectList)
|
||||
void LockWidget::setrootWindow(QList<QPair<QRect, QRect>> screenRectList)
|
||||
{
|
||||
drawBackgroundIsStarted = true;
|
||||
QString m_defaultBackgroundPath = DEFAULT_BACKGROUND_PATH;
|
||||
if(m_rootWindowBackground.isEmpty())
|
||||
if (m_rootWindowBackground.isEmpty())
|
||||
m_rootWindowBackground = m_defaultBackgroundPath;
|
||||
if(m_rootWindowBackground.isEmpty())
|
||||
if (m_rootWindowBackground.isEmpty())
|
||||
return;
|
||||
|
||||
char* path;
|
||||
char *path;
|
||||
QByteArray ba = m_rootWindowBackground.toLatin1(); // must
|
||||
path=ba.data();
|
||||
path = ba.data();
|
||||
|
||||
if(drawBackgroundType == 0)
|
||||
if (drawBackgroundType == 0)
|
||||
setRootWindowBackground(0, 0, path, screenRectList, m_nPicOptions);
|
||||
else
|
||||
setRootWindowBackground(1, drawBackgroundColor, NULL, screenRectList, m_nPicOptions);
|
||||
|
@ -1211,30 +1212,24 @@ void LockWidget::setrootWindow(QList<QPair<QRect,QRect>> screenRectList)
|
|||
void LockWidget::reloadRootBackground()
|
||||
{
|
||||
if (!isGreeterMode())
|
||||
return ;
|
||||
//记录当前的屏幕信息,写入QList保存,防止线程中在遍历屏幕信息时,因
|
||||
//屏幕插拔而崩溃
|
||||
return;
|
||||
// 记录当前的屏幕信息,写入QList保存,防止线程中在遍历屏幕信息时,因
|
||||
// 屏幕插拔而崩溃
|
||||
m_screenRectList.clear();
|
||||
for(QScreen *screen : QApplication::screens()){
|
||||
for (QScreen *screen : QApplication::screens()) {
|
||||
QRect rect1 = screen->geometry();
|
||||
QRect rect2 = screen->virtualGeometry();
|
||||
m_screenRectList.append(qMakePair(rect1,rect2));
|
||||
m_screenRectList.append(qMakePair(rect1, rect2));
|
||||
}
|
||||
if(getdrawBackgroundIsStarted()){
|
||||
if(m_futureDrawBg.isStarted()&& m_futureDrawBg.isRunning()){
|
||||
if (getdrawBackgroundIsStarted()) {
|
||||
if (m_futureDrawBg.isStarted() && m_futureDrawBg.isRunning()) {
|
||||
m_futureDrawBg.waitForFinished();
|
||||
m_futureDrawBg = QtConcurrent::run([=](){
|
||||
setrootWindow(m_screenRectList);
|
||||
});
|
||||
}else{
|
||||
m_futureDrawBg = QtConcurrent::run([=](){
|
||||
setrootWindow(m_screenRectList);
|
||||
});
|
||||
m_futureDrawBg = QtConcurrent::run([=]() { setrootWindow(m_screenRectList); });
|
||||
} else {
|
||||
m_futureDrawBg = QtConcurrent::run([=]() { setrootWindow(m_screenRectList); });
|
||||
}
|
||||
}else{
|
||||
m_futureDrawBg = QtConcurrent::run([=](){
|
||||
setrootWindow(m_screenRectList);
|
||||
});
|
||||
} else {
|
||||
m_futureDrawBg = QtConcurrent::run([=]() { setrootWindow(m_screenRectList); });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1252,13 +1247,13 @@ void LockWidget::updateFont()
|
|||
m_timeWidget->updateTimeFont(m_curFont);
|
||||
}
|
||||
if (m_powerListWidget) {
|
||||
QList<PowerItemWidget *>itemList = this->findChildren<PowerItemWidget *>();
|
||||
QList<PowerItemWidget *> itemList = this->findChildren<PowerItemWidget *>();
|
||||
for (int i = 0; i < itemList.count(); i++) {
|
||||
itemList.at(i)->setFontFamily(m_curFont);
|
||||
}
|
||||
}
|
||||
if (m_userListWidget) {
|
||||
QList<UserItemWidget *>itemList = this->findChildren<UserItemWidget *>();
|
||||
QList<UserItemWidget *> itemList = this->findChildren<UserItemWidget *>();
|
||||
for (int i = 0; i < itemList.count(); i++) {
|
||||
itemList.at(i)->setFontFamily(m_curFont);
|
||||
}
|
||||
|
@ -1277,13 +1272,13 @@ void LockWidget::updateFontSize()
|
|||
m_timeWidget->updateTimeFontSize(m_curFontSize);
|
||||
}
|
||||
if (m_powerListWidget) {
|
||||
QList<PowerItemWidget *>itemList = this->findChildren<PowerItemWidget *>();
|
||||
QList<PowerItemWidget *> itemList = this->findChildren<PowerItemWidget *>();
|
||||
for (int i = 0; i < itemList.count(); i++) {
|
||||
itemList.at(i)->setFontSize((16 + m_curFontSize) * m_ptToPx);
|
||||
}
|
||||
}
|
||||
if (m_userListWidget) {
|
||||
QList<UserItemWidget *>itemList = this->findChildren<UserItemWidget *>();
|
||||
QList<UserItemWidget *> itemList = this->findChildren<UserItemWidget *>();
|
||||
for (int i = 0; i < itemList.count(); i++) {
|
||||
itemList.at(i)->setFontSize((14 + m_curFontSize) * m_ptToPx);
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* 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 "loginoptionswidget.h"
|
||||
|
||||
#include <pwd.h>
|
||||
|
@ -42,11 +42,11 @@
|
|||
#include <QJsonArray>
|
||||
#include <QJsonParseError>
|
||||
|
||||
LoginOptionsWidget::LoginOptionsWidget(BiometricHelper *bioHelper, int uid, UniAuthService *uniauthService, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_biomericProxy(bioHelper)
|
||||
, m_uid(uid)
|
||||
, m_uniauthService(uniauthService)
|
||||
LoginOptionsWidget::LoginOptionsWidget(BiometricHelper *bioHelper,
|
||||
int uid,
|
||||
UniAuthService *uniauthService,
|
||||
QWidget *parent)
|
||||
: QWidget(parent), m_biomericProxy(bioHelper), m_uid(uid), m_uniauthService(uniauthService)
|
||||
{
|
||||
m_listPriority.clear();
|
||||
m_listPriority.push_back(BioT_Face);
|
||||
|
@ -61,20 +61,17 @@ LoginOptionsWidget::LoginOptionsWidget(BiometricHelper *bioHelper, int uid, UniA
|
|||
m_mapDisableDev.clear();
|
||||
}
|
||||
|
||||
LoginOptionsWidget::~LoginOptionsWidget()
|
||||
{
|
||||
|
||||
}
|
||||
LoginOptionsWidget::~LoginOptionsWidget() {}
|
||||
|
||||
void LoginOptionsWidget::initUI()
|
||||
{
|
||||
this->setFixedHeight(94);
|
||||
// 初始化UI
|
||||
m_layoutMain = new QVBoxLayout();
|
||||
m_layoutMain->setContentsMargins(0,0,0,0);
|
||||
m_layoutMain->setContentsMargins(0, 0, 0, 0);
|
||||
m_layoutMain->setSpacing(16);
|
||||
m_layoutOptBtns = new QHBoxLayout();
|
||||
m_layoutOptBtns->setContentsMargins(0,0,0,0);
|
||||
m_layoutOptBtns->setContentsMargins(0, 0, 0, 0);
|
||||
m_layoutOptBtns->setSpacing(16);
|
||||
|
||||
m_labelOptTitle = new KLabel();
|
||||
|
@ -97,7 +94,7 @@ void LoginOptionsWidget::initUI()
|
|||
|
||||
void LoginOptionsWidget::changeEvent(QEvent *event)
|
||||
{
|
||||
if(event->type() == QEvent::LanguageChange){
|
||||
if (event->type() == QEvent::LanguageChange) {
|
||||
refreshTranslate();
|
||||
}
|
||||
}
|
||||
|
@ -109,20 +106,16 @@ void LoginOptionsWidget::refreshTranslate()
|
|||
|
||||
void LoginOptionsWidget::initConnections()
|
||||
{
|
||||
if(m_biomericProxy && m_biomericProxy->isValid())
|
||||
{
|
||||
connect(m_biomericProxy, &BiometricHelper::StatusChanged,
|
||||
this, &LoginOptionsWidget::onStatusChanged);
|
||||
if (m_biomericProxy && m_biomericProxy->isValid()) {
|
||||
connect(m_biomericProxy, &BiometricHelper::StatusChanged, this, &LoginOptionsWidget::onStatusChanged);
|
||||
|
||||
connect(m_biomericProxy, &BiometricHelper::FrameWritten,
|
||||
this, &LoginOptionsWidget::onFrameWritten);
|
||||
connect(m_biomericProxy, &BiometricHelper::USBDeviceHotPlug,
|
||||
this, &LoginOptionsWidget::onUSBDeviceHotPlug);
|
||||
connect(m_biomericProxy, &BiometricHelper::FrameWritten, this, &LoginOptionsWidget::onFrameWritten);
|
||||
connect(m_biomericProxy, &BiometricHelper::USBDeviceHotPlug, this, &LoginOptionsWidget::onUSBDeviceHotPlug);
|
||||
}
|
||||
connect(m_btnGroup, SIGNAL(buttonClicked(int)), this, SLOT(onOptionSelected(int)));
|
||||
}
|
||||
|
||||
bool LoginOptionsWidget::getCurLoginOpt(int& nLoginOptType, int& nDrvId)
|
||||
bool LoginOptionsWidget::getCurLoginOpt(int &nLoginOptType, int &nDrvId)
|
||||
{
|
||||
if (m_curDevInfo) {
|
||||
nLoginOptType = convertDeviceType(m_curDevInfo->deviceType);
|
||||
|
@ -145,7 +138,7 @@ DeviceInfoPtr LoginOptionsWidget::getWechatDevice()
|
|||
for (auto devinfo : itDevInfo.value()) {
|
||||
if (devinfo && devinfo->deviceType == UniT_Remote) {
|
||||
if (!isDeviceDisable(devinfo->id)) {
|
||||
devInfo = devinfo;
|
||||
devInfo = devinfo;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -160,56 +153,56 @@ DeviceInfoPtr LoginOptionsWidget::getWechatDevice()
|
|||
void LoginOptionsWidget::addOptionButton(unsigned uLoginOptType, int nDrvId, QString strDrvName)
|
||||
{
|
||||
if (m_mapOptBtns.contains(nDrvId)) {
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
QPushButton *newButton = new QPushButton();
|
||||
// QVBoxLayout *layoutBtn = new QVBoxLayout();
|
||||
// newButton->setLayout(layoutBtn);
|
||||
// QLabel *newLabel = new QLabel();
|
||||
// layoutBtn->setAlignment(Qt::AlignCenter);
|
||||
// layoutBtn->addWidget(newLabel);
|
||||
// QVBoxLayout *layoutBtn = new QVBoxLayout();
|
||||
// newButton->setLayout(layoutBtn);
|
||||
// QLabel *newLabel = new QLabel();
|
||||
// layoutBtn->setAlignment(Qt::AlignCenter);
|
||||
// layoutBtn->addWidget(newLabel);
|
||||
newButton->setCheckable(true);
|
||||
newButton->setChecked(false);
|
||||
newButton->setFocusPolicy(Qt::NoFocus);
|
||||
// if (nDrvId == -1) {
|
||||
// //newButton->setEnabled(false);
|
||||
// newButton->setChecked(true);
|
||||
// //屏蔽鼠标事件
|
||||
// newButton->setAttribute(Qt::WA_TransparentForMouseEvents, true);
|
||||
// } else {
|
||||
int nLength = m_btnGroup->buttons().length();
|
||||
m_btnGroup->addButton(newButton, nLength);
|
||||
m_listDriveId.append(nDrvId);
|
||||
// }
|
||||
// if (nDrvId == -1) {
|
||||
// //newButton->setEnabled(false);
|
||||
// newButton->setChecked(true);
|
||||
// //屏蔽鼠标事件
|
||||
// newButton->setAttribute(Qt::WA_TransparentForMouseEvents, true);
|
||||
// } else {
|
||||
int nLength = m_btnGroup->buttons().length();
|
||||
m_btnGroup->addButton(newButton, nLength);
|
||||
m_listDriveId.append(nDrvId);
|
||||
// }
|
||||
QPixmap iconPixmap;
|
||||
switch (uLoginOptType) {
|
||||
case LOGINOPT_TYPE_PASSWORD:
|
||||
iconPixmap = loadSvg(":/image/assets/ukui-loginopt-password.svg", "white", 16);
|
||||
break;
|
||||
case LOGINOPT_TYPE_GENERAL_UKEY:
|
||||
iconPixmap = loadSvg(":/image/assets/ukui-loginopt-ukey.svg", "white", 16);
|
||||
break;
|
||||
case LOGINOPT_TYPE_FACE:
|
||||
iconPixmap = loadSvg(":/image/assets/ukui-loginopt-face.svg", "white", 16);
|
||||
break;
|
||||
case LOGINOPT_TYPE_FINGERPRINT:
|
||||
iconPixmap = loadSvg(":/image/assets/ukui-loginopt-finger.svg", "white", 16);
|
||||
break;
|
||||
case LOGINOPT_TYPE_IRIS:
|
||||
iconPixmap = loadSvg(":/image/assets/ukui-loginopt-iris.svg", "white", 16);
|
||||
break;
|
||||
case LOGINOPT_TYPE_VOICEPRINT:
|
||||
iconPixmap = loadSvg(":/image/assets/ukui-loginopt-voice.svg", "white", 16);
|
||||
break;
|
||||
case LOGINOPT_TYPE_FINGERVEIN:
|
||||
iconPixmap = loadSvg(":/image/assets/ukui-loginopt-fingervein.svg", "white", 16);
|
||||
break;
|
||||
case LOGINOPT_TYPE_QRCODE:
|
||||
iconPixmap = loadSvg(":/image/assets/ukui-loginopt-qrcode.svg", "white", 16);
|
||||
break;
|
||||
case LOGINOPT_TYPE_CUSTOM:
|
||||
{
|
||||
LoginAuthInterface *plugin = dynamic_cast<LoginAuthInterface *>(PluginsLoader::instance().findModulesByType(LoginPluginInterface::MODULETYPE_AUTH).values().first());
|
||||
case LOGINOPT_TYPE_PASSWORD:
|
||||
iconPixmap = loadSvg(":/image/assets/ukui-loginopt-password.svg", "white", 16);
|
||||
break;
|
||||
case LOGINOPT_TYPE_GENERAL_UKEY:
|
||||
iconPixmap = loadSvg(":/image/assets/ukui-loginopt-ukey.svg", "white", 16);
|
||||
break;
|
||||
case LOGINOPT_TYPE_FACE:
|
||||
iconPixmap = loadSvg(":/image/assets/ukui-loginopt-face.svg", "white", 16);
|
||||
break;
|
||||
case LOGINOPT_TYPE_FINGERPRINT:
|
||||
iconPixmap = loadSvg(":/image/assets/ukui-loginopt-finger.svg", "white", 16);
|
||||
break;
|
||||
case LOGINOPT_TYPE_IRIS:
|
||||
iconPixmap = loadSvg(":/image/assets/ukui-loginopt-iris.svg", "white", 16);
|
||||
break;
|
||||
case LOGINOPT_TYPE_VOICEPRINT:
|
||||
iconPixmap = loadSvg(":/image/assets/ukui-loginopt-voice.svg", "white", 16);
|
||||
break;
|
||||
case LOGINOPT_TYPE_FINGERVEIN:
|
||||
iconPixmap = loadSvg(":/image/assets/ukui-loginopt-fingervein.svg", "white", 16);
|
||||
break;
|
||||
case LOGINOPT_TYPE_QRCODE:
|
||||
iconPixmap = loadSvg(":/image/assets/ukui-loginopt-qrcode.svg", "white", 16);
|
||||
break;
|
||||
case LOGINOPT_TYPE_CUSTOM: {
|
||||
LoginAuthInterface *plugin = dynamic_cast<LoginAuthInterface *>(
|
||||
PluginsLoader::instance().findModulesByType(LoginPluginInterface::MODULETYPE_AUTH).values().first());
|
||||
QString strIcon = plugin->icon();
|
||||
if (strIcon.startsWith("/")) {
|
||||
if (strIcon.endsWith(".svg")) {
|
||||
|
@ -219,19 +212,19 @@ void LoginOptionsWidget::addOptionButton(unsigned uLoginOptType, int nDrvId, QSt
|
|||
iconPixmap.scaled(40, 40);
|
||||
}
|
||||
} else {
|
||||
iconPixmap = QIcon::fromTheme(strIcon).pixmap(48,48).scaled(40, 40);
|
||||
iconPixmap = QIcon::fromTheme(strIcon).pixmap(48, 48).scaled(40, 40);
|
||||
}
|
||||
if (iconPixmap.isNull()) {
|
||||
iconPixmap = loadSvg(":/image/assets/ukui-loginopt-custom.svg", "white", 16);
|
||||
}
|
||||
}
|
||||
break;
|
||||
} break;
|
||||
}
|
||||
//newLabel->setPixmap(iconPixmap);
|
||||
// newLabel->setPixmap(iconPixmap);
|
||||
newButton->setIcon(iconPixmap);
|
||||
newButton->installEventFilter(this);
|
||||
newButton->setObjectName(strDrvName);
|
||||
newButton->setStyleSheet("QPushButton{text-align:center;background-color: rgba(255,255,255,15%);border: none;border-radius: 4px;outline: none;}"
|
||||
newButton->setStyleSheet("QPushButton{text-align:center;background-color: rgba(255,255,255,15%);border: "
|
||||
"none;border-radius: 4px;outline: none;}"
|
||||
"QPushButton::hover{background-color: rgba(255,255,255,40%);}"
|
||||
"QPushButton::pressed {background-color: rgba(255,255,255,40%);}"
|
||||
"QPushButton::checked {background-color: rgba(255,255,255,40%);}");
|
||||
|
@ -249,11 +242,11 @@ void LoginOptionsWidget::addOptionButton(unsigned uLoginOptType, int nDrvId, QSt
|
|||
|
||||
bool LoginOptionsWidget::eventFilter(QObject *obj, QEvent *event)
|
||||
{
|
||||
for(int i = 0; i<nameList.count();i++){
|
||||
if(obj->objectName() == nameList.at(i)){
|
||||
if(event->type() == 110){
|
||||
for (int i = 0; i < nameList.count(); i++) {
|
||||
if (obj->objectName() == nameList.at(i)) {
|
||||
if (event->type() == 110) {
|
||||
Q_EMIT showKToolTipClicked(nameList.at(i));
|
||||
} else if (event->type() == 11){
|
||||
} else if (event->type() == 11) {
|
||||
Q_EMIT hideKTooltipClicked();
|
||||
}
|
||||
}
|
||||
|
@ -268,8 +261,8 @@ bool LoginOptionsWidget::getHasUkeyOptions()
|
|||
|
||||
void LoginOptionsWidget::clearOptionButtons()
|
||||
{
|
||||
QMap<int, QPushButton*>::iterator itMapBtn = m_mapOptBtns.begin();
|
||||
for ( ; itMapBtn != m_mapOptBtns.end(); itMapBtn++) {
|
||||
QMap<int, QPushButton *>::iterator itMapBtn = m_mapOptBtns.begin();
|
||||
for (; itMapBtn != m_mapOptBtns.end(); itMapBtn++) {
|
||||
if (itMapBtn.value()) {
|
||||
m_btnGroup->removeButton(itMapBtn.value());
|
||||
m_layoutOptBtns->removeWidget(itMapBtn.value());
|
||||
|
@ -287,11 +280,11 @@ void LoginOptionsWidget::updateOptionButtons()
|
|||
clearOptionButtons();
|
||||
addOptionButton(LOGINOPT_TYPE_PASSWORD, -1, tr("Password"));
|
||||
DeviceListMap::iterator itMapDev = m_mapDevices.begin();
|
||||
for ( ; itMapDev != m_mapDevices.end(); itMapDev++) {
|
||||
for (; itMapDev != m_mapDevices.end(); itMapDev++) {
|
||||
for (DeviceInfoPtr devPtr : itMapDev.value()) {
|
||||
if (devPtr) {
|
||||
if(devPtr->deviceType == UniT_General_Ukey){
|
||||
//ukey 设备类型排在二维码前,但实际上应该显示在二维码之后,因此暂时不添加
|
||||
if (devPtr->deviceType == UniT_General_Ukey) {
|
||||
// ukey 设备类型排在二维码前,但实际上应该显示在二维码之后,因此暂时不添加
|
||||
isShowUkey = true;
|
||||
continue;
|
||||
} else if (devPtr->deviceType == UniT_Custom) {
|
||||
|
@ -304,11 +297,11 @@ void LoginOptionsWidget::updateOptionButtons()
|
|||
}
|
||||
|
||||
itMapDev = m_mapDevices.begin();
|
||||
if(isShowUkey || hasCustom){
|
||||
for ( ; itMapDev != m_mapDevices.end(); itMapDev++) {
|
||||
if (isShowUkey || hasCustom) {
|
||||
for (; itMapDev != m_mapDevices.end(); itMapDev++) {
|
||||
for (DeviceInfoPtr devPtr : itMapDev.value()) {
|
||||
if(devPtr && devPtr->deviceType == UniT_General_Ukey){
|
||||
//此处才添加ukey
|
||||
if (devPtr && devPtr->deviceType == UniT_General_Ukey) {
|
||||
// 此处才添加ukey
|
||||
addOptionButton(itMapDev.key(), devPtr->id, getDeviceType_tr(devPtr->deviceType));
|
||||
} else if (devPtr && devPtr->deviceType == UniT_Custom) {
|
||||
addOptionButton(itMapDev.key(), devPtr->id, tr("Other"));
|
||||
|
@ -317,32 +310,32 @@ void LoginOptionsWidget::updateOptionButtons()
|
|||
}
|
||||
}
|
||||
|
||||
//存在特征但没有插入ukey
|
||||
if(!isShowUkey && m_biomericProxy->GetHasUkeyFeature(m_uid)){
|
||||
addOptionButton(LOGINOPT_TYPE_GENERAL_UKEY,-2,getDeviceType_tr(LOGINOPT_TYPE_GENERAL_UKEY));
|
||||
// 存在特征但没有插入ukey
|
||||
if (!isShowUkey && m_biomericProxy->GetHasUkeyFeature(m_uid)) {
|
||||
addOptionButton(LOGINOPT_TYPE_GENERAL_UKEY, -2, getDeviceType_tr(LOGINOPT_TYPE_GENERAL_UKEY));
|
||||
isShowUkey = true;
|
||||
}
|
||||
|
||||
if (m_mapOptBtns.size() <= 2 && (!isShowUkey && !m_mapDevices.contains(LOGINOPT_TYPE_CUSTOM))) {
|
||||
//因为默认添加一个密码选项,因此当ukey没有显示出来时,按钮数小于等于2时就隐藏选项界面
|
||||
// 因为默认添加一个密码选项,因此当ukey没有显示出来时,按钮数小于等于2时就隐藏选项界面
|
||||
m_labelOptTitle->hide();
|
||||
QMap<int, QPushButton*>::iterator itMapBtn = m_mapOptBtns.begin();
|
||||
for ( ; itMapBtn != m_mapOptBtns.end(); itMapBtn++) {
|
||||
QMap<int, QPushButton *>::iterator itMapBtn = m_mapOptBtns.begin();
|
||||
for (; itMapBtn != m_mapOptBtns.end(); itMapBtn++) {
|
||||
if (itMapBtn.value()) {
|
||||
itMapBtn.value()->hide();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
m_labelOptTitle->show();
|
||||
QMap<int, QPushButton*>::iterator itMapBtn = m_mapOptBtns.begin();
|
||||
for ( ; itMapBtn != m_mapOptBtns.end(); itMapBtn++) {
|
||||
QMap<int, QPushButton *>::iterator itMapBtn = m_mapOptBtns.begin();
|
||||
for (; itMapBtn != m_mapOptBtns.end(); itMapBtn++) {
|
||||
if (itMapBtn.value()) {
|
||||
itMapBtn.value()->show();
|
||||
}
|
||||
}
|
||||
}
|
||||
m_mapOptBtns[-1]->hide();
|
||||
if(m_mapOptBtns.size() == 2 && (isShowUkey || m_mapDevices.contains(LOGINOPT_TYPE_CUSTOM))) {
|
||||
if (m_mapOptBtns.size() == 2 && (isShowUkey || m_mapDevices.contains(LOGINOPT_TYPE_CUSTOM))) {
|
||||
m_mapOptBtns[-1]->show();
|
||||
} else if (m_mapOptBtns.size() == 3 && isShowUkey && m_mapDevices.contains(LOGINOPT_TYPE_CUSTOM)) {
|
||||
m_mapOptBtns[-1]->show();
|
||||
|
@ -362,11 +355,10 @@ void LoginOptionsWidget::readDevicesInfo()
|
|||
bool isQRCodeEnable = getQRCodeEnable();
|
||||
DeviceList deviceList = m_biomericProxy->GetDevList();
|
||||
QStringList listDefDevices = getAllDefDevices();
|
||||
qDebug()<<"BeginGetFeature------!";
|
||||
qDebug() << "BeginGetFeature------!";
|
||||
FeatureMap mapFeatures = m_biomericProxy->GetUserFeatures(m_uid);
|
||||
qDebug() << m_uid <<",count:"<<mapFeatures.size();
|
||||
for(auto pDeviceInfo : deviceList)
|
||||
{
|
||||
qDebug() << m_uid << ",count:" << mapFeatures.size();
|
||||
for (auto pDeviceInfo : deviceList) {
|
||||
if (!isAuthEnable && pDeviceInfo->deviceType <= BioT_VoicePrint)
|
||||
continue;
|
||||
if (!isQRCodeEnable && pDeviceInfo->deviceType == UniT_Remote)
|
||||
|
@ -375,24 +367,22 @@ void LoginOptionsWidget::readDevicesInfo()
|
|||
if (mapFeatures.contains(pDeviceInfo->shortName)) {
|
||||
nFeatureCount = mapFeatures[pDeviceInfo->shortName].size();
|
||||
}
|
||||
qDebug() << *pDeviceInfo <<",count:"<<nFeatureCount;
|
||||
if(nFeatureCount > 0) {
|
||||
qDebug() << *pDeviceInfo << ",count:" << nFeatureCount;
|
||||
if (nFeatureCount > 0) {
|
||||
int nDevType = LOGINOPT_TYPE_OTHERS;
|
||||
nDevType = convertDeviceType(pDeviceInfo->deviceType);
|
||||
if (listDefDevices.contains(pDeviceInfo->shortName) &&
|
||||
!m_mapDevices.contains(nDevType)) {
|
||||
if (listDefDevices.contains(pDeviceInfo->shortName) && !m_mapDevices.contains(nDevType)) {
|
||||
m_mapDevices[nDevType].push_back(pDeviceInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 检查是否有第三方认证插件(非root用户)
|
||||
if (m_uid > 0 && PluginsLoader::instance().findModulesByType(LoginPluginInterface::MODULETYPE_AUTH).size() > 0) {
|
||||
LoginAuthInterface *plugin = dynamic_cast<LoginAuthInterface *>(PluginsLoader::instance() \
|
||||
.findModulesByType(LoginPluginInterface::MODULETYPE_AUTH) \
|
||||
.values().first());
|
||||
LoginAuthInterface *plugin = dynamic_cast<LoginAuthInterface *>(
|
||||
PluginsLoader::instance().findModulesByType(LoginPluginInterface::MODULETYPE_AUTH).values().first());
|
||||
DeviceInfoPtr deviceInfoPtr = std::make_shared<DeviceInfo>();
|
||||
deviceInfoPtr->id = LOGINAUTH_CUSTOM_ID;
|
||||
deviceInfoPtr->shortName = CUSTOM_PLUGIN_DEV_PREFIX+plugin->name();
|
||||
deviceInfoPtr->shortName = CUSTOM_PLUGIN_DEV_PREFIX + plugin->name();
|
||||
deviceInfoPtr->deviceType = UniT_Custom;
|
||||
m_mapDevices[LOGINOPT_TYPE_CUSTOM].push_back(deviceInfoPtr);
|
||||
}
|
||||
|
@ -409,32 +399,29 @@ QString LoginOptionsWidget::getCustomDevName()
|
|||
|
||||
void LoginOptionsWidget::SetExtraInfo(QString extra_info, QString info_type)
|
||||
{
|
||||
if(!m_biomericProxy)
|
||||
{
|
||||
if (!m_biomericProxy) {
|
||||
qWarning() << "BiometricProxy doesn't exist.";
|
||||
return;
|
||||
}
|
||||
m_biomericProxy->SetExtraInfo(info_type,extra_info);
|
||||
m_biomericProxy->SetExtraInfo(info_type, extra_info);
|
||||
}
|
||||
|
||||
void LoginOptionsWidget::startAuth(DeviceInfoPtr device, int uid)
|
||||
{
|
||||
if(!m_biomericProxy)
|
||||
{
|
||||
if (!m_biomericProxy) {
|
||||
qWarning() << "BiometricProxy doesn't exist.";
|
||||
return;
|
||||
}
|
||||
if (!device) {
|
||||
qWarning() << "Biometric Auth device invalid.";
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
if(m_isInAuth)
|
||||
{
|
||||
if (m_isInAuth) {
|
||||
qDebug() << "Identification is currently under way, stop it";
|
||||
stopAuth();
|
||||
}
|
||||
qDebug()<<"deviceInfo:"<<device->id;
|
||||
qDebug() << "deviceInfo:" << device->id;
|
||||
this->m_curDevInfo = device;
|
||||
this->m_uid = uid;
|
||||
this->m_strUserName = getpwuid(uid)->pw_name;
|
||||
|
@ -442,7 +429,7 @@ void LoginOptionsWidget::startAuth(DeviceInfoPtr device, int uid)
|
|||
this->m_curLoginOptType = convertDeviceType(this->m_curDevInfo->deviceType);
|
||||
updateUIStatus();
|
||||
|
||||
if(this->m_curLoginOptType == LOGINOPT_TYPE_GENERAL_UKEY)
|
||||
if (this->m_curLoginOptType == LOGINOPT_TYPE_GENERAL_UKEY)
|
||||
startUkeyAuth();
|
||||
else
|
||||
startAuth_();
|
||||
|
@ -451,7 +438,7 @@ void LoginOptionsWidget::startAuth(DeviceInfoPtr device, int uid)
|
|||
void LoginOptionsWidget::startUkeyAuth()
|
||||
{
|
||||
if (!m_curDevInfo)
|
||||
return ;
|
||||
return;
|
||||
qDebug().noquote() << QString("Identify:[drvid: %1, uid: %2]").arg(m_curDevInfo->id).arg(m_uid);
|
||||
|
||||
m_isInAuth = true;
|
||||
|
@ -459,16 +446,15 @@ void LoginOptionsWidget::startUkeyAuth()
|
|||
|
||||
Q_EMIT setLoadingImage();
|
||||
m_biomericProxy->StopOps(m_curDevInfo->id);
|
||||
QDBusPendingCall call = m_biomericProxy->UkeyIdentify(m_curDevInfo->id, 2,m_uid);
|
||||
QDBusPendingCall call = m_biomericProxy->UkeyIdentify(m_curDevInfo->id, 2, m_uid);
|
||||
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this);
|
||||
connect(watcher, &QDBusPendingCallWatcher::finished,
|
||||
this, &LoginOptionsWidget::onIdentifyComplete);
|
||||
connect(watcher, &QDBusPendingCallWatcher::finished, this, &LoginOptionsWidget::onIdentifyComplete);
|
||||
}
|
||||
|
||||
void LoginOptionsWidget::startAuth_()
|
||||
{
|
||||
if (!m_curDevInfo)
|
||||
return ;
|
||||
return;
|
||||
qDebug().noquote() << QString("Identify:[drvid: %1, uid: %2]").arg(m_curDevInfo->id).arg(m_uid);
|
||||
|
||||
m_isInAuth = true;
|
||||
|
@ -487,16 +473,14 @@ void LoginOptionsWidget::startAuth_()
|
|||
m_biomericProxy->StopOps(m_curDevInfo->id);
|
||||
QDBusPendingCall call = m_biomericProxy->Identify(m_curDevInfo->id, m_uid);
|
||||
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this);
|
||||
connect(watcher, &QDBusPendingCallWatcher::finished,
|
||||
this, &LoginOptionsWidget::onIdentifyComplete);
|
||||
connect(watcher, &QDBusPendingCallWatcher::finished, this, &LoginOptionsWidget::onIdentifyComplete);
|
||||
}
|
||||
}
|
||||
|
||||
void LoginOptionsWidget::stopAuth()
|
||||
{
|
||||
m_isStopped = true;
|
||||
if(!m_isInAuth || !m_curDevInfo)
|
||||
{
|
||||
if (!m_isInAuth || !m_curDevInfo) {
|
||||
return;
|
||||
}
|
||||
if (m_curDevInfo->deviceType == UniT_Custom) {
|
||||
|
@ -510,7 +494,7 @@ void LoginOptionsWidget::stopAuth()
|
|||
} else {
|
||||
m_biomericProxy->StopOps(m_curDevInfo->id);
|
||||
}
|
||||
if(m_retrytimer&&m_retrytimer->isActive()){
|
||||
if (m_retrytimer && m_retrytimer->isActive()) {
|
||||
m_retrytimer->stop();
|
||||
delete m_retrytimer;
|
||||
m_retrytimer = nullptr;
|
||||
|
@ -521,12 +505,11 @@ void LoginOptionsWidget::stopAuth()
|
|||
|
||||
void LoginOptionsWidget::onUkeyIdentifyComplete(QDBusPendingCallWatcher *watcher)
|
||||
{
|
||||
if(m_isStopped == true)
|
||||
return ;
|
||||
if (m_isStopped == true)
|
||||
return;
|
||||
|
||||
QDBusPendingReply<int, int> reply = *watcher;
|
||||
if(reply.isError())
|
||||
{
|
||||
if (reply.isError()) {
|
||||
qWarning() << "Identify error: " << reply.error().message();
|
||||
Q_EMIT authComplete(false, -1);
|
||||
return;
|
||||
|
@ -534,7 +517,7 @@ void LoginOptionsWidget::onUkeyIdentifyComplete(QDBusPendingCallWatcher *watcher
|
|||
int result = reply.argumentAt(0).toInt();
|
||||
int authUid = reply.argumentAt(1).toInt();
|
||||
qDebug() << result << authUid << m_uid;
|
||||
if(result == DBUS_RESULT_SUCCESS) {
|
||||
if (result == DBUS_RESULT_SUCCESS) {
|
||||
qDebug() << "Identify success";
|
||||
Q_EMIT authComplete(true, 0);
|
||||
} else {
|
||||
|
@ -545,12 +528,11 @@ void LoginOptionsWidget::onUkeyIdentifyComplete(QDBusPendingCallWatcher *watcher
|
|||
|
||||
void LoginOptionsWidget::onIdentifyComplete(QDBusPendingCallWatcher *watcher)
|
||||
{
|
||||
if(m_isStopped == true)
|
||||
return ;
|
||||
if (m_isStopped == true)
|
||||
return;
|
||||
|
||||
QDBusPendingReply<int, int> reply = *watcher;
|
||||
if(reply.isError())
|
||||
{
|
||||
if (reply.isError()) {
|
||||
qWarning() << "Identify error: " << reply.error().message();
|
||||
Q_EMIT authComplete(false, -1);
|
||||
return;
|
||||
|
@ -560,24 +542,25 @@ void LoginOptionsWidget::onIdentifyComplete(QDBusPendingCallWatcher *watcher)
|
|||
qDebug() << result << authUid << m_uid;
|
||||
|
||||
// 特征识别成功,而且用户id匹配
|
||||
if(result == DBUS_RESULT_SUCCESS && authUid == m_uid) {
|
||||
if (result == DBUS_RESULT_SUCCESS && authUid == m_uid) {
|
||||
qDebug() << "Identify success";
|
||||
Q_EMIT authComplete(true, 0);
|
||||
} else if(result == DBUS_RESULT_NOTMATCH) { // 特征识别不匹配
|
||||
} else if (result == DBUS_RESULT_NOTMATCH) { // 特征识别不匹配
|
||||
qDebug() << "Identify failed";
|
||||
Q_EMIT authComplete(false, 2);
|
||||
} else if(result == DBUS_RESULT_ERROR) { //识别发生错误
|
||||
} else if (result == DBUS_RESULT_ERROR) { // 识别发生错误
|
||||
StatusReslut ret = m_biomericProxy->UpdateStatus(m_curDevInfo->id);
|
||||
qDebug()<<"StatusReslut:"<<ret.result<<","<<ret.enable<<","<<ret.devNum<<","
|
||||
<<ret.devStatus<<","<<ret.opsStatus<<","<<ret.notifyMessageId;
|
||||
//识别操作超时 304/404 认证超时;8 网络错误;
|
||||
if(ret.result == 0) {
|
||||
qDebug() << "StatusReslut:" << ret.result << "," << ret.enable << "," << ret.devNum << "," << ret.devStatus
|
||||
<< "," << ret.opsStatus << "," << ret.notifyMessageId;
|
||||
// 识别操作超时 304/404 认证超时;8 网络错误;
|
||||
if (ret.result == 0) {
|
||||
if (ret.opsStatus == OPS_IDENTIFY_TIMEOUT || ret.opsStatus == OPS_VERIFY_TIMEOUT
|
||||
|| ret.opsStatus == 8) { // 304认证超时, 8网络异常
|
||||
|| ret.opsStatus == 8) { // 304认证超时, 8网络异常
|
||||
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) { // 无法打开设备(设备是坏的/被占用),直接停止
|
||||
} 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); // 主动停止,直接重试
|
||||
|
@ -595,55 +578,52 @@ void LoginOptionsWidget::onIdentifyComplete(QDBusPendingCallWatcher *watcher)
|
|||
void LoginOptionsWidget::onFrameWritten(int drvid)
|
||||
{
|
||||
if (!m_curDevInfo || m_curDevInfo->id != drvid || !m_isInAuth) {
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
if(m_dupFD == -1){
|
||||
if (m_dupFD == -1) {
|
||||
m_dupFD = get_server_gvariant_stdout(drvid);
|
||||
}
|
||||
|
||||
if(m_dupFD <= 0)
|
||||
return ;
|
||||
if (m_dupFD <= 0)
|
||||
return;
|
||||
|
||||
cv::Mat img;
|
||||
lseek(m_dupFD, 0, SEEK_SET);
|
||||
char base64_bufferData[1024*1024];
|
||||
int rc = read(m_dupFD, base64_bufferData, 1024*1024);
|
||||
char base64_bufferData[1024 * 1024];
|
||||
int rc = read(m_dupFD, base64_bufferData, 1024 * 1024);
|
||||
// printf("rc = %d\n", rc);
|
||||
|
||||
cv::Mat mat2(1, sizeof(base64_bufferData), CV_8U, base64_bufferData);
|
||||
img = cv::imdecode(mat2, cv::IMREAD_COLOR);
|
||||
if (!img.data)
|
||||
return ;
|
||||
cv::cvtColor(img,img,cv::COLOR_BGR2RGB);
|
||||
return;
|
||||
cv::cvtColor(img, img, cv::COLOR_BGR2RGB);
|
||||
|
||||
QImage srcQImage = QImage((uchar*)(img.data), img.cols, img.rows, QImage::Format_RGB888);
|
||||
QImage srcQImage = QImage((uchar *)(img.data), img.cols, img.rows, QImage::Format_RGB888);
|
||||
Q_EMIT updateImage(srcQImage);
|
||||
}
|
||||
|
||||
void LoginOptionsWidget::onStatusChanged(int drvid, int status)
|
||||
{
|
||||
if(!m_isInAuth || !m_curDevInfo)
|
||||
{
|
||||
if (!m_isInAuth || !m_curDevInfo) {
|
||||
return;
|
||||
}
|
||||
if(drvid != m_curDevInfo->id)
|
||||
{
|
||||
if (drvid != m_curDevInfo->id) {
|
||||
return;
|
||||
}
|
||||
|
||||
// // 显示来自服务的提示信息
|
||||
// if(status == STATUS_NOTIFY)
|
||||
// {
|
||||
// QString notifyMsg = m_biomericProxy->GetNotifyMesg(drvid);
|
||||
// Q_EMIT updateAuthMsg(notifyMsg);
|
||||
// }
|
||||
// // 显示来自服务的提示信息
|
||||
// if(status == STATUS_NOTIFY)
|
||||
// {
|
||||
// QString notifyMsg = m_biomericProxy->GetNotifyMesg(drvid);
|
||||
// Q_EMIT updateAuthMsg(notifyMsg);
|
||||
// }
|
||||
}
|
||||
|
||||
void LoginOptionsWidget::setCurrentDevice(int drvid)
|
||||
{
|
||||
DeviceInfoPtr pDeviceInfo = findDeviceById(drvid);
|
||||
if(pDeviceInfo)
|
||||
{
|
||||
if (pDeviceInfo) {
|
||||
setCurrentDevice(pDeviceInfo);
|
||||
}
|
||||
}
|
||||
|
@ -651,8 +631,7 @@ void LoginOptionsWidget::setCurrentDevice(int drvid)
|
|||
void LoginOptionsWidget::setCurrentDevice(const QString &deviceName)
|
||||
{
|
||||
DeviceInfoPtr pDeviceInfo = findDeviceByName(deviceName);
|
||||
if(pDeviceInfo)
|
||||
{
|
||||
if (pDeviceInfo) {
|
||||
setCurrentDevice(pDeviceInfo);
|
||||
}
|
||||
}
|
||||
|
@ -664,15 +643,11 @@ void LoginOptionsWidget::setCurrentDevice(const DeviceInfoPtr &pDeviceInfo)
|
|||
|
||||
DeviceInfoPtr LoginOptionsWidget::findDeviceById(int drvid)
|
||||
{
|
||||
for(int type : m_mapDevices.keys())
|
||||
{
|
||||
for (int type : m_mapDevices.keys()) {
|
||||
DeviceList &deviceList = m_mapDevices[type];
|
||||
auto iter = std::find_if(deviceList.begin(), deviceList.end(),
|
||||
[&](DeviceInfoPtr ptr){
|
||||
return ptr->id == drvid;
|
||||
});
|
||||
if(iter != deviceList.end())
|
||||
{
|
||||
auto iter
|
||||
= std::find_if(deviceList.begin(), deviceList.end(), [&](DeviceInfoPtr ptr) { return ptr->id == drvid; });
|
||||
if (iter != deviceList.end()) {
|
||||
return *iter;
|
||||
}
|
||||
}
|
||||
|
@ -681,15 +656,11 @@ DeviceInfoPtr LoginOptionsWidget::findDeviceById(int drvid)
|
|||
|
||||
DeviceInfoPtr LoginOptionsWidget::findDeviceByName(const QString &name)
|
||||
{
|
||||
for(int type : m_mapDevices.keys())
|
||||
{
|
||||
for (int type : m_mapDevices.keys()) {
|
||||
DeviceList &deviceList = m_mapDevices[type];
|
||||
auto iter = std::find_if(deviceList.begin(), deviceList.end(),
|
||||
[&](DeviceInfoPtr ptr){
|
||||
return ptr->shortName == name;
|
||||
});
|
||||
if(iter != deviceList.end())
|
||||
{
|
||||
auto iter = std::find_if(
|
||||
deviceList.begin(), deviceList.end(), [&](DeviceInfoPtr ptr) { return ptr->shortName == name; });
|
||||
if (iter != deviceList.end()) {
|
||||
return *iter;
|
||||
}
|
||||
}
|
||||
|
@ -700,44 +671,40 @@ void LoginOptionsWidget::onUSBDeviceHotPlug(int drvid, int action, int /*devNum*
|
|||
{
|
||||
int savedDeviceId = (m_curDevInfo ? m_curDevInfo->id : -1);
|
||||
int savedCount = 0;
|
||||
for(int type : m_mapDevices.keys())
|
||||
for (int type : m_mapDevices.keys())
|
||||
savedCount += m_mapDevices.value(type).count();
|
||||
|
||||
switch(action)
|
||||
{
|
||||
case ACTION_ATTACHED:
|
||||
{
|
||||
//插入设备后,需要更新设备列表
|
||||
readDevicesInfo();
|
||||
break;
|
||||
}
|
||||
case ACTION_DETACHED:
|
||||
{
|
||||
DeviceInfoPtr pDeviceInfo = findDeviceById(drvid);
|
||||
if(pDeviceInfo)
|
||||
{
|
||||
int nDevType = LOGINOPT_TYPE_PASSWORD;
|
||||
nDevType = convertDeviceType(pDeviceInfo->deviceType);
|
||||
if (savedDeviceId == drvid) {
|
||||
if (m_isInAuth) {
|
||||
Q_EMIT updateAuthMsg(tr("Identify device removed!"));
|
||||
switch (action) {
|
||||
case ACTION_ATTACHED: {
|
||||
// 插入设备后,需要更新设备列表
|
||||
readDevicesInfo();
|
||||
break;
|
||||
}
|
||||
case ACTION_DETACHED: {
|
||||
DeviceInfoPtr pDeviceInfo = findDeviceById(drvid);
|
||||
if (pDeviceInfo) {
|
||||
int nDevType = LOGINOPT_TYPE_PASSWORD;
|
||||
nDevType = convertDeviceType(pDeviceInfo->deviceType);
|
||||
if (savedDeviceId == drvid) {
|
||||
if (m_isInAuth) {
|
||||
Q_EMIT updateAuthMsg(tr("Identify device removed!"));
|
||||
}
|
||||
}
|
||||
m_mapDevices[nDevType].removeOne(pDeviceInfo);
|
||||
if (m_mapDevices[nDevType].isEmpty()) {
|
||||
m_mapDevices.remove(nDevType);
|
||||
}
|
||||
}
|
||||
m_mapDevices[nDevType].removeOne(pDeviceInfo);
|
||||
if(m_mapDevices[nDevType].isEmpty()) {
|
||||
m_mapDevices.remove(nDevType);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
for(int type : m_mapDevices.keys())
|
||||
for (int type : m_mapDevices.keys())
|
||||
count += m_mapDevices.value(type).count();
|
||||
|
||||
//设备数量发生了变化
|
||||
if(count != savedCount) {
|
||||
// 设备数量发生了变化
|
||||
if (count != savedCount) {
|
||||
updateOptionButtons();
|
||||
Q_EMIT notifyOptionsChange(count);
|
||||
updateUIStatus();
|
||||
|
@ -754,7 +721,7 @@ bool LoginOptionsWidget::getAuthDouble()
|
|||
void LoginOptionsWidget::setSelectedPassword()
|
||||
{
|
||||
if (m_mapOptBtns.contains(-1)) {
|
||||
QPushButton* btn = m_mapOptBtns[-1];
|
||||
QPushButton *btn = m_mapOptBtns[-1];
|
||||
if (btn && btn->isVisible()) {
|
||||
btn->setChecked(true);
|
||||
}
|
||||
|
@ -765,14 +732,14 @@ void LoginOptionsWidget::setSelectedPassword()
|
|||
void LoginOptionsWidget::updateUIStatus()
|
||||
{
|
||||
if (!m_curDevInfo && m_mapOptBtns.contains(-1)) {
|
||||
QPushButton* btn = m_mapOptBtns[-1];
|
||||
QPushButton *btn = m_mapOptBtns[-1];
|
||||
if (btn && btn->isVisible()) {
|
||||
btn->setChecked(true);
|
||||
}
|
||||
}
|
||||
if (m_curDevInfo) {
|
||||
if (m_mapOptBtns.contains(m_curDevInfo->id)) {
|
||||
QPushButton* btn = m_mapOptBtns[m_curDevInfo->id];
|
||||
QPushButton *btn = m_mapOptBtns[m_curDevInfo->id];
|
||||
if (btn) {
|
||||
btn->setChecked(true);
|
||||
}
|
||||
|
@ -789,15 +756,15 @@ void LoginOptionsWidget::onOptionSelected(int nIndex)
|
|||
DeviceInfoPtr info = findDeviceById(m_listDriveId[nIndex]);
|
||||
if (info && !isDeviceDisable(info->id)) {
|
||||
Q_EMIT optionSelected(convertDeviceType(info->deviceType), info);
|
||||
}else if(nIndex == 0 && m_listDriveId[nIndex] == -1){
|
||||
} else if (nIndex == 0 && m_listDriveId[nIndex] == -1) {
|
||||
stopAuth();
|
||||
m_curDevInfo = nullptr;
|
||||
Q_EMIT optionSelected(LOGINOPT_TYPE_PASSWORD,nullptr);
|
||||
}else if(m_listDriveId[nIndex] == -2){
|
||||
//存在ukey特征,但未插入ukey
|
||||
Q_EMIT optionSelected(LOGINOPT_TYPE_PASSWORD, nullptr);
|
||||
} else if (m_listDriveId[nIndex] == -2) {
|
||||
// 存在ukey特征,但未插入ukey
|
||||
stopAuth();
|
||||
m_curDevInfo = nullptr;
|
||||
Q_EMIT optionSelected(LOGINOPT_TYPE_GENERAL_UKEY,nullptr);
|
||||
Q_EMIT optionSelected(LOGINOPT_TYPE_GENERAL_UKEY, nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -806,36 +773,36 @@ int LoginOptionsWidget::convertDeviceType(int nDevType)
|
|||
{
|
||||
int nLoginOptType = LOGINOPT_TYPE_OTHERS;
|
||||
switch (nDevType) {
|
||||
case BioT_FingerPrint:
|
||||
nLoginOptType = LOGINOPT_TYPE_FINGERPRINT;
|
||||
break;
|
||||
case BioT_FingerVein:
|
||||
nLoginOptType = LOGINOPT_TYPE_FINGERVEIN;
|
||||
break;
|
||||
case BioT_Iris:
|
||||
nLoginOptType = LOGINOPT_TYPE_IRIS;
|
||||
break;
|
||||
case BioT_Face:
|
||||
nLoginOptType = LOGINOPT_TYPE_FACE;
|
||||
break;
|
||||
case BioT_VoicePrint:
|
||||
nLoginOptType = LOGINOPT_TYPE_VOICEPRINT;
|
||||
break;
|
||||
case UniT_General_Ukey:
|
||||
nLoginOptType = LOGINOPT_TYPE_GENERAL_UKEY;
|
||||
break;
|
||||
case UniT_Advanced_Ukey:
|
||||
nLoginOptType = LOGINOPT_TYPE_ADVANCED_UKEY;
|
||||
break;
|
||||
case UniT_Remote:
|
||||
nLoginOptType = LOGINOPT_TYPE_QRCODE;
|
||||
break;
|
||||
case UniT_Custom:
|
||||
nLoginOptType = LOGINOPT_TYPE_CUSTOM;
|
||||
break;
|
||||
default:
|
||||
nLoginOptType = LOGINOPT_TYPE_OTHERS;
|
||||
break;
|
||||
case BioT_FingerPrint:
|
||||
nLoginOptType = LOGINOPT_TYPE_FINGERPRINT;
|
||||
break;
|
||||
case BioT_FingerVein:
|
||||
nLoginOptType = LOGINOPT_TYPE_FINGERVEIN;
|
||||
break;
|
||||
case BioT_Iris:
|
||||
nLoginOptType = LOGINOPT_TYPE_IRIS;
|
||||
break;
|
||||
case BioT_Face:
|
||||
nLoginOptType = LOGINOPT_TYPE_FACE;
|
||||
break;
|
||||
case BioT_VoicePrint:
|
||||
nLoginOptType = LOGINOPT_TYPE_VOICEPRINT;
|
||||
break;
|
||||
case UniT_General_Ukey:
|
||||
nLoginOptType = LOGINOPT_TYPE_GENERAL_UKEY;
|
||||
break;
|
||||
case UniT_Advanced_Ukey:
|
||||
nLoginOptType = LOGINOPT_TYPE_ADVANCED_UKEY;
|
||||
break;
|
||||
case UniT_Remote:
|
||||
nLoginOptType = LOGINOPT_TYPE_QRCODE;
|
||||
break;
|
||||
case UniT_Custom:
|
||||
nLoginOptType = LOGINOPT_TYPE_CUSTOM;
|
||||
break;
|
||||
default:
|
||||
nLoginOptType = LOGINOPT_TYPE_OTHERS;
|
||||
break;
|
||||
}
|
||||
return nLoginOptType;
|
||||
}
|
||||
|
@ -844,8 +811,8 @@ void LoginOptionsWidget::setDeviceDisable(int nDevId, bool bDisable)
|
|||
{
|
||||
if (bDisable) {
|
||||
m_mapDisableDev[m_uid][nDevId] = true;
|
||||
QMap<int, QPushButton*>::iterator itMapBtn = m_mapOptBtns.begin();
|
||||
for ( ; itMapBtn != m_mapOptBtns.end(); itMapBtn++) {
|
||||
QMap<int, QPushButton *>::iterator itMapBtn = m_mapOptBtns.begin();
|
||||
for (; itMapBtn != m_mapOptBtns.end(); itMapBtn++) {
|
||||
if (itMapBtn.key() == nDevId && itMapBtn.value()) {
|
||||
itMapBtn.value()->setDisabled(true);
|
||||
break;
|
||||
|
@ -853,8 +820,8 @@ void LoginOptionsWidget::setDeviceDisable(int nDevId, bool bDisable)
|
|||
}
|
||||
} else {
|
||||
m_mapDisableDev[m_uid][nDevId] = false;
|
||||
QMap<int, QPushButton*>::iterator itMapBtn = m_mapOptBtns.begin();
|
||||
for ( ; itMapBtn != m_mapOptBtns.end(); itMapBtn++) {
|
||||
QMap<int, QPushButton *>::iterator itMapBtn = m_mapOptBtns.begin();
|
||||
for (; itMapBtn != m_mapOptBtns.end(); itMapBtn++) {
|
||||
if (itMapBtn.key() == nDevId && itMapBtn.value()) {
|
||||
itMapBtn.value()->setDisabled(false);
|
||||
break;
|
||||
|
@ -875,7 +842,7 @@ QPixmap LoginOptionsWidget::loadSvg(QString path, QString color, int size)
|
|||
{
|
||||
int origSize = size;
|
||||
const auto ratio = qApp->devicePixelRatio();
|
||||
if ( 2 == ratio) {
|
||||
if (2 == ratio) {
|
||||
size += origSize;
|
||||
} else if (3 == ratio) {
|
||||
size += origSize;
|
||||
|
@ -900,22 +867,22 @@ QPixmap LoginOptionsWidget::drawSymbolicColoredPixmap(QPixmap &source, QString c
|
|||
for (int y = 0; y < img.height(); y++) {
|
||||
auto color = img.pixelColor(x, y);
|
||||
if (color.alpha() > 0) {
|
||||
if ( "white" == cgColor) {
|
||||
if ("white" == cgColor) {
|
||||
color.setRed(255);
|
||||
color.setGreen(255);
|
||||
color.setBlue(255);
|
||||
img.setPixelColor(x, y, color);
|
||||
} else if( "black" == cgColor) {
|
||||
} else if ("black" == cgColor) {
|
||||
color.setRed(0);
|
||||
color.setGreen(0);
|
||||
color.setBlue(0);
|
||||
img.setPixelColor(x, y, color);
|
||||
} else if ("gray"== cgColor) {
|
||||
} else if ("gray" == cgColor) {
|
||||
color.setRed(152);
|
||||
color.setGreen(163);
|
||||
color.setBlue(164);
|
||||
img.setPixelColor(x, y, color);
|
||||
} else if ("blue" == cgColor){
|
||||
} else if ("blue" == cgColor) {
|
||||
color.setRed(61);
|
||||
color.setGreen(107);
|
||||
color.setBlue(229);
|
||||
|
@ -957,17 +924,17 @@ bool LoginOptionsWidget::getQRCodeEnable()
|
|||
}
|
||||
}
|
||||
|
||||
QString LoginOptionsWidget::getDefaultDevice(QString strUserName,int bioType)
|
||||
QString LoginOptionsWidget::getDefaultDevice(QString strUserName, int bioType)
|
||||
{
|
||||
if (m_uniauthService && m_uniauthService->isActivatable()) {
|
||||
QString defaultDeviceName = "";
|
||||
QString strDeviceName = m_uniauthService->getDefaultDevice(strUserName, bioType);
|
||||
if(!strDeviceName.isEmpty()) {
|
||||
DeviceInfoPtr pDeviceInfo = findDeviceByName(strDeviceName);
|
||||
if (pDeviceInfo) {
|
||||
defaultDeviceName = strDeviceName;
|
||||
}
|
||||
QString strDeviceName = m_uniauthService->getDefaultDevice(strUserName, bioType);
|
||||
if (!strDeviceName.isEmpty()) {
|
||||
DeviceInfoPtr pDeviceInfo = findDeviceByName(strDeviceName);
|
||||
if (pDeviceInfo) {
|
||||
defaultDeviceName = strDeviceName;
|
||||
}
|
||||
}
|
||||
return defaultDeviceName;
|
||||
} else {
|
||||
return "";
|
||||
|
@ -980,7 +947,7 @@ QString LoginOptionsWidget::getDefaultDevice(QString strUserName)
|
|||
QString defaultDeviceName = "";
|
||||
for (auto bioType : m_listPriority) {
|
||||
QString strDeviceName = m_uniauthService->getDefaultDevice(strUserName, bioType);
|
||||
if(!strDeviceName.isEmpty()) {
|
||||
if (!strDeviceName.isEmpty()) {
|
||||
DeviceInfoPtr pDeviceInfo = findDeviceByName(strDeviceName);
|
||||
if (pDeviceInfo) {
|
||||
defaultDeviceName = strDeviceName;
|
||||
|
@ -1012,24 +979,25 @@ QStringList LoginOptionsWidget::getAllDefDevices()
|
|||
defaultDeviceName = userConfig.value("DefaultDevice").toString();
|
||||
qDebug() << defaultDeviceName;
|
||||
|
||||
if(defaultDeviceName.isEmpty()) {
|
||||
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()){
|
||||
if (!defaultDeviceName.isEmpty()) {
|
||||
listDefDevices.push_back(defaultDeviceName);
|
||||
}
|
||||
}
|
||||
return QStringList(listDefDevices);
|
||||
}
|
||||
|
||||
LoginAuthInterface* LoginOptionsWidget::getCustomLoginAuth()
|
||||
LoginAuthInterface *LoginOptionsWidget::getCustomLoginAuth()
|
||||
{
|
||||
if (PluginsLoader::instance().findModulesByType(LoginPluginInterface::MODULETYPE_AUTH).values().size() <= 0) {
|
||||
return nullptr;
|
||||
}
|
||||
return dynamic_cast<LoginAuthInterface *>(PluginsLoader::instance().findModulesByType(LoginPluginInterface::MODULETYPE_AUTH).values().first());
|
||||
return dynamic_cast<LoginAuthInterface *>(
|
||||
PluginsLoader::instance().findModulesByType(LoginPluginInterface::MODULETYPE_AUTH).values().first());
|
||||
}
|
||||
|
||||
void LoginOptionsWidget::updateLoginOptionFont(QString fontFamily)
|
||||
|
@ -1048,24 +1016,22 @@ void LoginOptionsWidget::updateLoginOptionFontSize(double fontSize)
|
|||
|
||||
QString LoginOptionsWidget::getDeviceType_tr(int deviceType)
|
||||
{
|
||||
switch(deviceType)
|
||||
{
|
||||
case BioT_FingerPrint:
|
||||
return tr("FingerPrint");
|
||||
case BioT_FingerVein:
|
||||
return tr("FingerVein");
|
||||
case BioT_Iris:
|
||||
return tr("Iris");
|
||||
case BioT_Face:
|
||||
return tr("Face");
|
||||
case BioT_VoicePrint:
|
||||
return tr("VoicePrint");
|
||||
case UniT_General_Ukey:
|
||||
return tr("Ukey");
|
||||
case UniT_Remote:
|
||||
return tr("QRCode");
|
||||
default:
|
||||
return "";
|
||||
switch (deviceType) {
|
||||
case BioT_FingerPrint:
|
||||
return tr("FingerPrint");
|
||||
case BioT_FingerVein:
|
||||
return tr("FingerVein");
|
||||
case BioT_Iris:
|
||||
return tr("Iris");
|
||||
case BioT_Face:
|
||||
return tr("Face");
|
||||
case BioT_VoicePrint:
|
||||
return tr("VoicePrint");
|
||||
case UniT_General_Ukey:
|
||||
return tr("Ukey");
|
||||
case UniT_Remote:
|
||||
return tr("QRCode");
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,15 +14,14 @@
|
|||
* 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 <QVBoxLayout>
|
||||
#include <QEvent>
|
||||
#include <QDebug>
|
||||
#include "poweritemwidget.h"
|
||||
#include "statusbutton.h"
|
||||
|
||||
PowerItemWidget::PowerItemWidget(QWidget *parent)
|
||||
: QFrame(parent)
|
||||
PowerItemWidget::PowerItemWidget(QWidget *parent) : QFrame(parent)
|
||||
{
|
||||
itemFace = new StatusButton(this, POWERBUTTON);
|
||||
itemFace->setFixedSize(130, 130);
|
||||
|
@ -35,23 +34,17 @@ PowerItemWidget::PowerItemWidget(QWidget *parent)
|
|||
itemlayout->setAlignment(Qt::AlignHCenter);
|
||||
}
|
||||
|
||||
PowerItemWidget::~PowerItemWidget()
|
||||
{
|
||||
|
||||
}
|
||||
PowerItemWidget::~PowerItemWidget() {}
|
||||
|
||||
bool PowerItemWidget::eventFilter(QObject *obj, QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::ToolTip) {
|
||||
|
||||
} else if (event->type() == QEvent::Leave) {
|
||||
|
||||
}
|
||||
return QWidget::eventFilter(obj, event);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void PowerItemWidget::setText(const QString text)
|
||||
{
|
||||
textLabel->setText(text);
|
||||
|
@ -81,10 +74,3 @@ void PowerItemWidget::setFontSize(double fontSize)
|
|||
{
|
||||
textLabel->setFontSize(fontSize);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -14,11 +14,11 @@
|
|||
* 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 "statusbutton.h"
|
||||
#include <QDebug>
|
||||
|
||||
#include<QMouseEvent>
|
||||
#include <QMouseEvent>
|
||||
|
||||
StatusButton::StatusButton(QWidget *parent, int type) : QPushButton(parent)
|
||||
{
|
||||
|
@ -57,22 +57,22 @@ void StatusButton::paintEvent(QPaintEvent *e)
|
|||
painter.setPen(Qt::NoPen);
|
||||
painter.setBrush(Qt::white);
|
||||
switch (buttonType) {
|
||||
case BOTBUTTON:
|
||||
painter.setOpacity(0);
|
||||
painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6);
|
||||
break;
|
||||
case BIOBUTTON:
|
||||
painter.setOpacity(0.1);
|
||||
painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6);
|
||||
break;
|
||||
case POWERBUTTON:
|
||||
painter.setOpacity(0.1);
|
||||
painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 65, 65);
|
||||
break;
|
||||
default:
|
||||
painter.setOpacity(0);
|
||||
painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6);
|
||||
break;
|
||||
case BOTBUTTON:
|
||||
painter.setOpacity(0);
|
||||
painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6);
|
||||
break;
|
||||
case BIOBUTTON:
|
||||
painter.setOpacity(0.1);
|
||||
painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6);
|
||||
break;
|
||||
case POWERBUTTON:
|
||||
painter.setOpacity(0.1);
|
||||
painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 65, 65);
|
||||
break;
|
||||
default:
|
||||
painter.setOpacity(0);
|
||||
painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6);
|
||||
break;
|
||||
}
|
||||
painter.restore();
|
||||
}
|
||||
|
@ -83,16 +83,16 @@ void StatusButton::paintEvent(QPaintEvent *e)
|
|||
painter.setBrush(Qt::white);
|
||||
painter.setOpacity(0.25);
|
||||
switch (buttonType) {
|
||||
case BOTBUTTON:
|
||||
case BIOBUTTON:
|
||||
painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6);
|
||||
break;
|
||||
case POWERBUTTON:
|
||||
painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 65, 65);
|
||||
break;
|
||||
default:
|
||||
painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6);
|
||||
break;
|
||||
case BOTBUTTON:
|
||||
case BIOBUTTON:
|
||||
painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6);
|
||||
break;
|
||||
case POWERBUTTON:
|
||||
painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 65, 65);
|
||||
break;
|
||||
default:
|
||||
painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6);
|
||||
break;
|
||||
}
|
||||
painter.restore();
|
||||
}
|
||||
|
@ -103,16 +103,16 @@ void StatusButton::paintEvent(QPaintEvent *e)
|
|||
painter.setBrush(Qt::white);
|
||||
painter.setOpacity(0.35);
|
||||
switch (buttonType) {
|
||||
case BOTBUTTON:
|
||||
case BIOBUTTON:
|
||||
painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6);
|
||||
break;
|
||||
case POWERBUTTON:
|
||||
painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 65, 65);
|
||||
break;
|
||||
default:
|
||||
painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6);
|
||||
break;
|
||||
case BOTBUTTON:
|
||||
case BIOBUTTON:
|
||||
painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6);
|
||||
break;
|
||||
case POWERBUTTON:
|
||||
painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 65, 65);
|
||||
break;
|
||||
default:
|
||||
painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6);
|
||||
break;
|
||||
}
|
||||
painter.restore();
|
||||
}
|
||||
|
@ -123,16 +123,16 @@ void StatusButton::paintEvent(QPaintEvent *e)
|
|||
painter.setBrush(Qt::white);
|
||||
painter.setOpacity(0.25);
|
||||
switch (buttonType) {
|
||||
case BOTBUTTON:
|
||||
case BIOBUTTON:
|
||||
painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6);
|
||||
break;
|
||||
case POWERBUTTON:
|
||||
painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 65, 65);
|
||||
break;
|
||||
default:
|
||||
painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6);
|
||||
break;
|
||||
case BOTBUTTON:
|
||||
case BIOBUTTON:
|
||||
painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6);
|
||||
break;
|
||||
case POWERBUTTON:
|
||||
painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 65, 65);
|
||||
break;
|
||||
default:
|
||||
painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6);
|
||||
break;
|
||||
}
|
||||
painter.restore();
|
||||
painter.save();
|
||||
|
@ -141,16 +141,16 @@ void StatusButton::paintEvent(QPaintEvent *e)
|
|||
painter.setPen(QPen(color, 2));
|
||||
painter.setBrush(Qt::NoBrush);
|
||||
switch (buttonType) {
|
||||
case BOTBUTTON:
|
||||
case BIOBUTTON:
|
||||
painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6);
|
||||
break;
|
||||
case POWERBUTTON:
|
||||
painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 65, 65);
|
||||
break;
|
||||
default:
|
||||
painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6);
|
||||
break;
|
||||
case BOTBUTTON:
|
||||
case BIOBUTTON:
|
||||
painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6);
|
||||
break;
|
||||
case POWERBUTTON:
|
||||
painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 65, 65);
|
||||
break;
|
||||
default:
|
||||
painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6);
|
||||
break;
|
||||
}
|
||||
painter.restore();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue