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 += network
QT += concurrent
QT += serialport
QT += opengl
QT += webenginewidgets

View File

@ -5,8 +5,7 @@
#include <QPushButton>
#include <QMessageBox>
#include <QSettings>
#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();
});

View File

@ -3,7 +3,6 @@
#include <QPainter>
#include <QPainterPath>
#include <QIcon>
#include <windows.h>
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 <windows.h>
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

View File

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