From f12a289c57358e0ffaf9a9f47b05348f939e0be5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=AF=E4=BD=B3?= <13101321+jfen5577@user.noreply.gitee.com> Date: Sat, 13 Sep 2025 17:03:22 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=AE=A1=E7=90=86=EF=BC=88?= =?UTF-8?q?=E6=9C=AA=E5=AE=8C=E6=88=90=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- QT5_Project/KD_ZM_8_XCF/UIFrameWork.py | 20 +- .../Shared_CODE/DialogFaceUserManage.py | 46 ++++- QT5_Project/Shared_UI/DialogUsers.ui | 187 ++++++++++++++++++ QT5_Project/Shared_UI/users.ui | 59 +++++- system_parameter.ini | 2 +- 5 files changed, 292 insertions(+), 22 deletions(-) create mode 100644 QT5_Project/Shared_UI/DialogUsers.ui diff --git a/QT5_Project/KD_ZM_8_XCF/UIFrameWork.py b/QT5_Project/KD_ZM_8_XCF/UIFrameWork.py index df991f3..8701006 100644 --- a/QT5_Project/KD_ZM_8_XCF/UIFrameWork.py +++ b/QT5_Project/KD_ZM_8_XCF/UIFrameWork.py @@ -940,11 +940,12 @@ class UIFrameWork(QMainWindow, class_comm_mqtt_interface): def do_enroll_itg_single(self): - dlg = EnrollItgSingleDialog(self) - if dlg.exec_() == QDialog.Accepted: - admin_val, uname, face_dir, timeout_val, itg_val = dlg.values() - self.last_enroll_name = uname - self.send(build_enroll_itg_single(admin_val, uname, face_dir, timeout_val, itg_val)) + admin_val = 0 + uname = " " + face_dir = 31 + timeout_val = system_parameter().get_verify_timeout() + itg_val = 0 + self.send(build_enroll_itg_single(admin_val, uname, face_dir, timeout_val, itg_val)) def do_manage_users(self): UserManageDialog(self, self.send).exec_() @@ -958,9 +959,9 @@ class UIFrameWork(QMainWindow, class_comm_mqtt_interface): self.video_worker.stop() self.video_worker.wait(300) self.video_worker = None - self.video_label.setText("未打开") - self.video_label.setPixmap(QPixmap()) - self.btn_video.setText("打开视频") + # self.video_label.setText("未打开") + # self.video_label.setPixmap(QPixmap()) + self.log("[INFO] 视频已关闭") inform_box : DialogInform = DialogInform() inform_box.information("提示", "视频已关闭") @@ -971,9 +972,8 @@ class UIFrameWork(QMainWindow, class_comm_mqtt_interface): self.video_worker = VideoWorker(cam_index=0, target_size=self.video_label.size()) self.video_worker.pixmap_ready.connect(self.video_label.setPixmap) - self.video_worker.log_message.connect(self.log) + # self.video_worker.log_message.connect(self.log) self.video_worker.start() - self.btn_video.setText("关闭视频") self.log("[INFO] 正在打开视频") inform_box : DialogInform = DialogInform() inform_box.information("提示", "正在打开视频") diff --git a/QT5_Project/Shared_CODE/DialogFaceUserManage.py b/QT5_Project/Shared_CODE/DialogFaceUserManage.py index 3813bed..506bcd9 100644 --- a/QT5_Project/Shared_CODE/DialogFaceUserManage.py +++ b/QT5_Project/Shared_CODE/DialogFaceUserManage.py @@ -11,7 +11,7 @@ from PyQt5.QtWidgets import ( QApplication, QMainWindow, QWidget, QVBoxLayout, QHBoxLayout, QLabel, QPushButton, QComboBox, QTextEdit, QFileDialog, QMessageBox, QGroupBox, QGridLayout, QDialog, QFormLayout, QSpinBox, QCheckBox, - QLineEdit, QTableWidget, QTableWidgetItem,QDialogButtonBox,QShortcut + QLineEdit, QTableWidget, QTableWidgetItem,QDialogButtonBox,QShortcut, QHeaderView ) sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) @@ -30,7 +30,7 @@ from Shared_CODE.FaceRecognitionProtocol import ( sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) ui_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '../Shared_UI')) -users_ui_file_path = os.path.join(ui_path, "users.ui") +users_ui_file_path = os.path.join(ui_path, "DialogUsers.ui") CSV_FILE = os.path.join(ui_path, "users.csv") # -------------------- CSV 工具 --------------------" @@ -79,6 +79,32 @@ class UserManageDialog(QDialog): self.btn_del_all.clicked.connect(self.delete_all_users) self.refresh() + header = self.table.horizontalHeader() + # 用户ID列固定宽度 + self.table.setColumnWidth(0, 100) + # 用户名列自适应内容 + header.setSectionResizeMode(1, QHeaderView.ResizeToContents) + # 注册时间列填充剩余空间 + header.setSectionResizeMode(2, QHeaderView.Stretch) + + self.message_timer = QTimer() + self.message_timer.timeout.connect(self.close_dialog_timeout) + + self.setWindowTitle("消息提示") + self.setWindowFlag(Qt.FramelessWindowHint) + button_box : QDialogButtonBox = self.buttonBox + ok_button = button_box.button(QDialogButtonBox.Ok) + if ok_button: + ok_button.setText('确定') + else: + button_box.addButton(QDialogButtonBox.Ok) + #定义4个快捷键, Key_Enter, Key_Escape经常被各类程序模块使用, 用Key_End, 与Key_Home来代替 + QShortcut(QKeySequence(Qt.Key_PageDown), self, activated=self.key_enter_process) + QShortcut(QKeySequence(Qt.Key_PageUp), self, activated=self.key_escape_process) + QShortcut(QKeySequence(Qt.Key_End), self, activated=self.key_enter_process) + QShortcut(QKeySequence(Qt.Key_Home), self, activated=self.key_escape_process) + + QShortcut(QKeySequence(Qt.Key_Return), self, activated=self.key_enter_process) # 普通回车 def refresh(self): users = load_users() @@ -114,6 +140,22 @@ class UserManageDialog(QDialog): self.refresh() QMessageBox.information(self, "提示", "已请求删除所有用户并清空本地记录") + def key_enter_process(self): + button_box : QDialogButtonBox = self.buttonBox + select_button = button_box.button(QDialogButtonBox.Ok) + if select_button: + select_button.click() + + def key_escape_process(self): + button_box : QDialogButtonBox = self.buttonBox + select_button = button_box.button(QDialogButtonBox.Cancel) + if select_button: + select_button.click() + + #消息超时 + def close_dialog_timeout(self): + self.key_enter_process() + if __name__ == '__main__': app = QApplication(sys.argv) dialog = UserManageDialog() diff --git a/QT5_Project/Shared_UI/DialogUsers.ui b/QT5_Project/Shared_UI/DialogUsers.ui new file mode 100644 index 0000000..2bfb349 --- /dev/null +++ b/QT5_Project/Shared_UI/DialogUsers.ui @@ -0,0 +1,187 @@ + + + DialogInform + + + + 0 + 0 + 632 + 483 + + + + Dialog + + + false + + + border:none; +background-color: rgba(0, 0, 0, 0); + + + + + 200 + 270 + 381 + 31 + + + + Qt::Horizontal + + + QDialogButtonBox::NoButton + + + + + + 90 + 0 + 411 + 51 + + + + + Microsoft YaHei UI + 16 + false + false + + + + background-color: rgba(85, 170, 127,0); +color: rgb(255, 170, 0); +font: 16pt "Microsoft YaHei UI"; + + + TextLabel + + + Qt::AlignCenter + + + + + + 60 + 70 + 521 + 295 + + + + background-color: rgb(255, 255, 255); + + + + 用户ID + + + + + 用户名 + + + + + 注册时间 + + + + + + + 388 + 430 + 106 + 23 + + + + 删除所有用户 + + + + + + 50 + 430 + 107 + 23 + + + + 删除选中用户 + + + + + + 163 + 430 + 106 + 23 + + + + background-color: rgb(0, 0, 0); + + + 刷新 + + + + + + 275 + 430 + 107 + 23 + + + + 获取设备用户列表 + + + + + + + buttonBox + accepted() + DialogInform + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + DialogInform + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/QT5_Project/Shared_UI/users.ui b/QT5_Project/Shared_UI/users.ui index 290b3e3..dedb578 100644 --- a/QT5_Project/Shared_UI/users.ui +++ b/QT5_Project/Shared_UI/users.ui @@ -2,30 +2,71 @@ UserManageDialog - 用户管理 + + + 0 + 0 + 464 + 344 + + + + 用户管理 + - 用户ID + + 用户ID + - 用户名 + + 用户名 + - 注册时间 + + 注册时间 + - 删除选中用户 - 刷新 - 获取设备用户列表 - 删除所有用户 - Qt::Horizontal + + + + 删除选中用户 + + + + + + + 刷新 + + + + + + + 获取设备用户列表 + + + + + + + 删除所有用户 + + + + + diff --git a/system_parameter.ini b/system_parameter.ini index 8f03ebb..e97a3d2 100644 --- a/system_parameter.ini +++ b/system_parameter.ini @@ -2,5 +2,5 @@ language = zh_CN blanking_time = 360 password = 2008 -facerecognition_timeout = 20 +facerecognition_timeout = 10