QFDAlert.cpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #include "QFDAlert.h"
  2. #include <dbService/ClassSet.h>
  3. #include <Widgets/InfoBar.h>
  4. void QFDAlert::showAlertWithCode(int code, QWidget *w)
  5. {
  6. if (code == QF_CODE_SUCCEEDED) {
  7. return;
  8. }
  9. QString msg;
  10. QFDAlertType type = Alert;
  11. if (code == QF_CODE_EMPTY_ACCOUNT) {
  12. msg = "账号不能为空";
  13. } else if (code == QF_CODE_EMPTY_PASSWORD) {
  14. msg = "密码不能为空";
  15. } else if (code == QF_CODE_USER_NOT_EXISTS) {
  16. msg = "用户不存在";
  17. } else if (code == QF_CODE_WRONG_PASSWORD) {
  18. msg = "密码错误";
  19. } else if (code == QF_CODE_PASSWORD_NOT_SAME) {
  20. msg = "两次输入密码不一致,请修改后重试";
  21. } else if (code == QF_CODE_PASSWORD_UNCHANGED) {
  22. msg = "不能与旧密码相同,请修改后重试";
  23. } else if (code == QF_CODE_DATA_ERROR) {
  24. msg = "数据异常";
  25. }
  26. if (code == QF_CODE_EMPTY_USERNAME) {
  27. msg = "专家名不能为空";
  28. } else if (code == QF_CODE_ACCOUNT_OCCUPIED) {
  29. msg = "用户名已存在或者数据库存储异常!";
  30. } else if (code == QF_CODE_ADD_USER_SUCCEEDED) {
  31. msg = "已添加";
  32. type = Success;
  33. }
  34. if (!msg.isEmpty()) {
  35. switch (type) {
  36. case None:
  37. break;
  38. case Info:
  39. InfoBar::info("提示", msg, Qt::Horizontal, false, 2000, InfoBarPosition::TOP_RIGHT, w);
  40. break;
  41. case Success:
  42. InfoBar::success("提示", msg, Qt::Horizontal, false, 2000, InfoBarPosition::TOP_RIGHT, w);
  43. break;
  44. case Alert:
  45. InfoBar::warning("提示", msg, Qt::Horizontal, false, 2000, InfoBarPosition::TOP_RIGHT, w);
  46. break;
  47. case Error:
  48. InfoBar::error("提示", msg, Qt::Horizontal, false, 2000, InfoBarPosition::TOP_RIGHT, w);
  49. break;
  50. }
  51. }
  52. }