This commit is contained in:
Gangphon 2023-04-18 18:02:58 +08:00
parent f2f5742ba5
commit a233c9a175
4 changed files with 8 additions and 7 deletions

View File

@ -2,7 +2,6 @@ QT += core gui widgets
QT += multimedia QT += multimedia
QT += network QT += network
QT += concurrent QT += concurrent
QT += serialport
QT += opengl QT += opengl
QT += webenginewidgets QT += webenginewidgets

View File

@ -5,8 +5,7 @@
#include <QPushButton> #include <QPushButton>
#include <QMessageBox> #include <QMessageBox>
#include <QSettings> #include <QSettings>
#include "cfg.h"
#include "QTextCodec"
ChangePasswordForm::ChangePasswordForm(QWidget *parent) : BaseDlg(parent) { ChangePasswordForm::ChangePasswordForm(QWidget *parent) : BaseDlg(parent) {
resize(240, 160); resize(240, 160);
auto vBox = new QVBoxLayout(this); auto vBox = new QVBoxLayout(this);
@ -53,7 +52,7 @@ ChangePasswordForm::ChangePasswordForm(QWidget *parent) : BaseDlg(parent) {
} }
QSettings settings; QSettings settings;
QString pwdRaw = settings.value("advUiPs").toString(); 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) { if(pwd != pwdOld) {
QMessageBox::critical(this, tr("Tip"), tr("Old password is wrong")); QMessageBox::critical(this, tr("Tip"), tr("Old password is wrong"));
fdOld->setFocus(); fdOld->setFocus();
@ -71,7 +70,7 @@ ChangePasswordForm::ChangePasswordForm(QWidget *parent) : BaseDlg(parent) {
fdAgn->setFocus(); fdAgn->setFocus();
return; 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")); QMessageBox::information(this, tr("Tip"), tr("Password changed successfully"));
accept(); accept();
}); });

View File

@ -3,7 +3,6 @@
#include <QPainter> #include <QPainter>
#include <QPainterPath> #include <QPainterPath>
#include <QIcon> #include <QIcon>
#include <windows.h>
BaseDlg::BaseDlg(QWidget *parent) : QDialog(parent) { BaseDlg::BaseDlg(QWidget *parent) : QDialog(parent) {
setWindowFlag(Qt::FramelessWindowHint); setWindowFlag(Qt::FramelessWindowHint);
@ -42,7 +41,8 @@ void BaseDlg::mouseMoveEvent(QMouseEvent *e) {
move(pressRel + e->globalPos()); move(pressRel + e->globalPos());
} }
} }
#ifdef Q_OS_WINDOWS
#include <windows.h>
bool BaseDlg::nativeEvent(const QByteArray &eventType, void *message, long *){ bool BaseDlg::nativeEvent(const QByteArray &eventType, void *message, long *){
if(eventType=="windows_generic_MSG"){ if(eventType=="windows_generic_MSG"){
MSG *msg = (MSG*)message; MSG *msg = (MSG*)message;
@ -53,3 +53,4 @@ bool BaseDlg::nativeEvent(const QByteArray &eventType, void *message, long *){
} }
return false; return false;
} }
#endif

View File

@ -18,7 +18,9 @@ protected:
void mousePressEvent(QMouseEvent *) override; void mousePressEvent(QMouseEvent *) override;
void mouseReleaseEvent(QMouseEvent *) override; void mouseReleaseEvent(QMouseEvent *) override;
void mouseMoveEvent(QMouseEvent *) override; void mouseMoveEvent(QMouseEvent *) override;
#ifdef Q_OS_WINDOWS
bool nativeEvent(const QByteArray &, void *, long *) override; bool nativeEvent(const QByteArray &, void *, long *) override;
#endif
QPoint pressRel; QPoint pressRel;
bool isActive = false; bool isActive = false;
}; };