From a233c9a17583852668808f485c3904fbda56ee24 Mon Sep 17 00:00:00 2001 From: Gangphon Date: Tue, 18 Apr 2023 18:02:58 +0800 Subject: [PATCH] ledok --- LedOK/LedOK.pro | 1 - LedOK/base/changepasswordform.cpp | 7 +++---- LedOK/basedlg.cpp | 5 +++-- LedOK/basedlg.h | 2 ++ 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/LedOK/LedOK.pro b/LedOK/LedOK.pro index baeca29..69dfbf7 100644 --- a/LedOK/LedOK.pro +++ b/LedOK/LedOK.pro @@ -2,7 +2,6 @@ QT += core gui widgets QT += multimedia QT += network QT += concurrent -QT += serialport QT += opengl QT += webenginewidgets diff --git a/LedOK/base/changepasswordform.cpp b/LedOK/base/changepasswordform.cpp index cadff25..0771f11 100644 --- a/LedOK/base/changepasswordform.cpp +++ b/LedOK/base/changepasswordform.cpp @@ -5,8 +5,7 @@ #include #include #include -#include "cfg.h" -#include "QTextCodec" + ChangePasswordForm::ChangePasswordForm(QWidget *parent) : BaseDlg(parent) { resize(240, 160); auto vBox = new QVBoxLayout(this); @@ -53,7 +52,7 @@ ChangePasswordForm::ChangePasswordForm(QWidget *parent) : BaseDlg(parent) { } QSettings settings; QString pwdRaw = settings.value("advUiPs").toString(); - QString pwd = pwdRaw.isEmpty() ? "888" : QTextCodec::codecForName("GBK")->toUnicode(QByteArray::fromBase64(pwdRaw.toLocal8Bit())); + QString pwd = pwdRaw.isEmpty() ? "888" : QString::fromUtf8(QByteArray::fromBase64(pwdRaw.toLatin1())); if(pwd != pwdOld) { QMessageBox::critical(this, tr("Tip"), tr("Old password is wrong")); fdOld->setFocus(); @@ -71,7 +70,7 @@ ChangePasswordForm::ChangePasswordForm(QWidget *parent) : BaseDlg(parent) { fdAgn->setFocus(); return; } - settings.setValue("advUiPs", QString::fromLatin1(pwdNew.toLocal8Bit().toBase64())); + settings.setValue("advUiPs", QString::fromLatin1(pwdNew.toUtf8().toBase64())); QMessageBox::information(this, tr("Tip"), tr("Password changed successfully")); accept(); }); diff --git a/LedOK/basedlg.cpp b/LedOK/basedlg.cpp index 74dc2ab..5af071e 100644 --- a/LedOK/basedlg.cpp +++ b/LedOK/basedlg.cpp @@ -3,7 +3,6 @@ #include #include #include -#include BaseDlg::BaseDlg(QWidget *parent) : QDialog(parent) { setWindowFlag(Qt::FramelessWindowHint); @@ -42,7 +41,8 @@ void BaseDlg::mouseMoveEvent(QMouseEvent *e) { move(pressRel + e->globalPos()); } } - +#ifdef Q_OS_WINDOWS +#include bool BaseDlg::nativeEvent(const QByteArray &eventType, void *message, long *){ if(eventType=="windows_generic_MSG"){ MSG *msg = (MSG*)message; @@ -53,3 +53,4 @@ bool BaseDlg::nativeEvent(const QByteArray &eventType, void *message, long *){ } return false; } +#endif diff --git a/LedOK/basedlg.h b/LedOK/basedlg.h index 0ca28f1..8f4090b 100644 --- a/LedOK/basedlg.h +++ b/LedOK/basedlg.h @@ -18,7 +18,9 @@ protected: void mousePressEvent(QMouseEvent *) override; void mouseReleaseEvent(QMouseEvent *) override; void mouseMoveEvent(QMouseEvent *) override; +#ifdef Q_OS_WINDOWS bool nativeEvent(const QByteArray &, void *, long *) override; +#endif QPoint pressRel; bool isActive = false; };