EXConfig.cpp 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #include "EXConfig.h"
  2. #include <QSettings>
  3. QSettings *EXConfig::defaultConfig()
  4. {
  5. static QSettings *config = nullptr;
  6. if (config == nullptr) {
  7. config = new QSettings("clientConfig.ini", QSettings::IniFormat);
  8. config->setIniCodec("UTF-8");
  9. }
  10. return config;
  11. }
  12. const QString EXConfig::username()
  13. {
  14. return defaultConfig()->value("USERCONFIG/UserName", "").toString();
  15. }
  16. void EXConfig::setUsername(const QString username)
  17. {
  18. defaultConfig()->setValue("USERCONFIG/UserName", username);
  19. }
  20. const QString EXConfig::password()
  21. {
  22. return defaultConfig()->value("USERCONFIG/Password", "").toString();
  23. }
  24. void EXConfig::setPassword(const QString password)
  25. {
  26. defaultConfig()->setValue("USERCONFIG/Password", password);
  27. }
  28. bool EXConfig::rememberPassword()
  29. {
  30. return defaultConfig()->value("USERCONFIG/RememberPassword", false).toBool();
  31. }
  32. void EXConfig::setRememberPassword(bool rememberPassword)
  33. {
  34. defaultConfig()->setValue("USERCONFIG/RememberPassword", rememberPassword);
  35. if (rememberPassword == false) {
  36. setUsername("");
  37. setPassword("");
  38. }
  39. }
  40. int EXConfig::roleType()
  41. {
  42. return defaultConfig()->value("USERCONFIG/RoleType", "").toInt();
  43. }
  44. void EXConfig::setRoleType(int roleType)
  45. {
  46. defaultConfig()->setValue("USERCONFIG/RoleType", roleType);
  47. }
  48. const QString EXConfig::techMessaureConfig()
  49. {
  50. return defaultConfig()->value("USERCONFIG/TechMessaureConfig", "").toString();
  51. }
  52. void EXConfig::setTechMessaureConfig(const QString techMessaureConfig)
  53. {
  54. defaultConfig()->setValue("USERCONFIG/TechMessaureConfig", techMessaureConfig);
  55. }
  56. const QString EXConfig::dbPath()
  57. {
  58. return defaultConfig()->value("USERCONFIG/DbPath", "").toString();
  59. }
  60. void EXConfig::setDbPath(const QString dbPath)
  61. {
  62. defaultConfig()->setValue("USERCONFIG/DbPath", dbPath);
  63. }
  64. const QString EXConfig::project()
  65. {
  66. return defaultConfig()->value("USERCONFIG/Project", "").toString();
  67. }
  68. void EXConfig::setProject(const QString project)
  69. {
  70. defaultConfig()->setValue("USERCONFIG/Project", project);
  71. }
  72. bool EXConfig::passwordModified()
  73. {
  74. return defaultConfig()->value("USERCONFIG/PasswordModified", false).toBool();
  75. }
  76. void EXConfig::setPasswordModified(bool modified)
  77. {
  78. defaultConfig()->setValue("USERCONFIG/PasswordModified", modified);
  79. }