Preferences.cpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. 
  2. #include "Preferences.h"
  3. #include "ConfigUtils.h"
  4. QString QPreferences::m_strProjectPath = DEFAULT_PROJECT_PATH; //项目路径
  5. QString QPreferences::m_strProjectName = DEFAULT_PROJECT_NAME; //项目名称
  6. QString QPreferences::m_strProjectInfo = "This Project Info"; //项目的描述
  7. QString QPreferences::m_strHdwConfigID = ""; //项目的硬件组态ID
  8. QString QPreferences::m_strLiveTime = ""; //运行时长
  9. QString QPreferences::m_strSystemTime = ""; //系统时间
  10. QString QPreferences::m_strCurr_UserName = ("admin"); //用户名
  11. QString QPreferences::m_strCurr_PassWord = ("admin"); //密码
  12. QString QPreferences::m_strCurr_UserType = "User";
  13. QString QPreferences::m_strDefaultDocument = ("");
  14. QString QPreferences::m_strConfigPath = ""; //配置信息目录
  15. QString QPreferences::m_strProductName = "VisionPlus v3"; //产品名称
  16. QString QPreferences::m_strMessage = ("Message");
  17. bool QPreferences::m_bEnableDebugView = false;
  18. bool QPreferences::m_bEnableRunningMode = false;
  19. bool QPreferences::m_bEnablePreventStandby = false;
  20. bool QPreferences::m_bEnableAutoRun = false;
  21. bool QPreferences::m_bEnableAutoStart = false;
  22. bool QPreferences::m_bEnableAlone = false;
  23. bool QPreferences::m_bEnableAutoLodin = false;
  24. bool QPreferences::m_bEnableAutoSave = false;
  25. bool QPreferences::m_bEnableRibbonBar = false;
  26. bool QPreferences::m_bCleanState = false;
  27. bool QPreferences::m_bCleanDATA = false;
  28. bool QPreferences::m_bWriteProtection = false;
  29. bool QPreferences::m_bSystemIsRunning = false; //系统运行中
  30. QString QPreferences::m_strExeDir;
  31. QString QPreferences::m_strBuildInfo;
  32. QString QPreferences::m_strTitle;
  33. QString QPreferences::m_strPhine;
  34. QString QPreferences::m_strMailbox;
  35. QString QPreferences::m_strURL;
  36. QString QPreferences::m_strCompanyName;
  37. QString QPreferences::m_strAuthorizeInfo;
  38. int QPreferences::m_nRunningCount = 0; //运行计数
  39. int QPreferences::m_nTotalRunningCount = 0; //总运行计数
  40. int QPreferences::m_nRunningTime = 0; //运行计数
  41. int QPreferences::m_nTotalRunningTime = 0; //总运行计数
  42. int QPreferences::m_nDocVersion = 0; // 当前加载的工程文件版本号
  43. int QPreferences::m_nHdwVersion = 0; // 当前加载的工程文件版本号
  44. //// 设置UI界面的默认初始值
  45. //int QPreferences::m_nUiViewWidth = DEFAULT_UIVIEW_WIDTH;
  46. //int QPreferences::m_nUiViewHeight = DEFAULT_UIVIEW_HEIGHT;
  47. //
  48. //// UiFrame各个窗体的拉伸尺寸
  49. //QList<int> QPreferences::listUiStretchFactors;
  50. //// PouFrame各个窗体的拉伸尺寸
  51. //QList<int> QPreferences::listPouStretchFactors;
  52. QPreferences::QPreferences()
  53. {
  54. //// 初始化UiFrame各个窗体的拉伸尺寸
  55. //listUiStretchFactors.push_back(4);
  56. //listUiStretchFactors.push_back(2);
  57. // PouFrame各个窗体的拉伸尺寸
  58. }
  59. QPreferences::~QPreferences()
  60. {
  61. Uninit();
  62. }
  63. void QPreferences::Init()
  64. {
  65. QString runPath = QCoreApplication::applicationDirPath(); //获取exe路径
  66. m_strProjectPath = runPath + "//..//Project";
  67. m_strConfigPath = runPath + "/Config/Preferences.ini";
  68. /// System
  69. m_nTotalRunningCount = ConfigUtils::getCfgInt(m_strConfigPath, "System", "RunningCount", 0);
  70. /// OEM
  71. m_strProductName = ConfigUtils::getCfgStr(m_strConfigPath, "OEM", "ProductName", m_strProductName);
  72. }
  73. void QPreferences::Uninit()
  74. {
  75. // 计数总运行计数。
  76. m_nTotalRunningCount = m_nTotalRunningCount + m_nRunningCount;
  77. /// System
  78. ConfigUtils::setCfgInt(m_strConfigPath, "System", "RunningCount", m_nTotalRunningCount);
  79. /// OEM
  80. ConfigUtils::setCfgStr(m_strConfigPath, "OEM", "ProductName", m_strProductName);
  81. }