Main.qml 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. import QtQuick
  2. import Felgo 4.0
  3. import "pages"
  4. import "common"
  5. import "logic"
  6. import "model"
  7. App {
  8. id: app
  9. licenseKey: "6BBDF824AF729C33ECAA6DC917319EDB8A7F76A9EB5217C380F81C28203CF84078DBCEEC5DB44C7DB60373C0FFE65240DA17EAC1C8376F5939F26782D2A3110CFCDB938C557DDAC8C63F942AF917CD7BCD4235973E76002E69BE740BD2FE99BB7F22AD12408FB5EE3D3A538E604803F0947C372A8486E63B5CF101A18B6CEDF7AEDC615273B15ADBCF1DCC54F123FA093609F650378D2F2BC11C74421663CAB7C178C4123AF6C8B6E44EE45A5A790448F85D4039D7EB1C23C3CA97B42E0724B2987C185114E732662A4EFD507EDC0E5DC2DA7A9FF7754678F48BFC8AAFD40B21926B5A1FD427E279FDE44EC0315229371F4D77B918CC4663CB71572051E1E84DCBF8E183C44981C9D921DB7C5A02879E2D9352ECEC03FF21D99F941B9E31E10D6D625D2603135C101658FEA17FB7B397"
  10. color: "#000"
  11. property string theme_md: ""
  12. property string theme_select: "day"
  13. property color theme_backgroundColor: theme_select == "day" ? "#d8d8d8" :(theme_select == "night" ? "#00000":"#d8d8d8")
  14. property color cardColor: theme_select == "day" ? "#f5f5f5" :(theme_select == "night" ? "#2b2b2b":"#f5f5f5") //背景色 //前景色
  15. property color fontColor: theme_select == "day" ? "black" :(theme_select == "night" ? "white":"black")
  16. property string boardversionText: ""
  17. property string appversionText: ""
  18. property int logoutcnt
  19. property bool log_enable: false
  20. property bool stitch_enable: false
  21. property bool photoclarity: false
  22. signal logoutClicked
  23. signal tmChange(string md)
  24. signal stitchEnable(bool sw)
  25. onInitTheme: {
  26. Theme.platform = "ios"
  27. Theme.navigationTabBar.titlePressedColor= "green"
  28. Theme.navigationTabBar.backgroundColor= app.cardColor
  29. Theme.navigationTabBar.titleColor = app.fontColor
  30. }
  31. // 新增一个函数来接收 HomePage 发送的文本
  32. function bvReceived(datbv){
  33. boardversionText = datbv
  34. }
  35. function appReceived(datbv){
  36. appversionText = datbv
  37. }
  38. onLogoutClicked: {
  39. // loginpage.pushed()
  40. logic.logout()
  41. // jump to main page after logout
  42. navigation.currentIndex = 0
  43. //navigation.currentNavigationItem.navigationStack.popAllExceptFirst()
  44. }
  45. // business logic}
  46. Logic {
  47. id: logic
  48. }
  49. // model
  50. DataModel {
  51. id: dataModel
  52. dispatcher: logic // data model handles actions sent by logic
  53. }
  54. // view
  55. Navigation {
  56. objectName: "Navigation_main"
  57. id: navigation
  58. navigationMode: Theme.isAndroid ? navigationModeTabs : navigationModeDefault
  59. drawerLogoBackgroundColor: "red"
  60. Component.onCompleted: {
  61. for(var i = 0;i < navigation.count; i++){
  62. navigation.currentIndex = i
  63. }
  64. navigation.currentIndex = 0
  65. }
  66. function setCurrentTab(index){
  67. navigation.currentIndex = index
  68. }
  69. // only enable if user is logged in
  70. // login page below overlays navigation then
  71. // first tab
  72. NavigationItem {
  73. id: uiComponentsItem
  74. title: "主界面"
  75. iconType: IconType.home
  76. Loader{
  77. asynchronous: true
  78. source: "pages/HomePage.qml"
  79. }
  80. }
  81. NavigationItem {
  82. title: "测试维护"
  83. iconType: IconType.gears
  84. objectName: "autofocus_Item"
  85. TestPage {
  86. //id: autofocus_id
  87. }
  88. }
  89. // second tab
  90. NavigationItem {
  91. title: qsTr("图像查看") // use qsTr for strings you want to translate
  92. iconType: IconType.qrcode
  93. NavigationStack {
  94. PhotostitcherPage {
  95. onVisibleChanged: {
  96. if(visible){
  97. console.log("进入图像查看界面,开始初始化加载...")
  98. loadRootDirectory()
  99. }
  100. }
  101. }
  102. }
  103. }
  104. // fourth tab
  105. NavigationItem {
  106. objectName: "systemset_Item"
  107. title: qsTr("系统设置") // use qsTr for strings you want to translate
  108. iconType: IconType.gears
  109. NavigationStack {
  110. initialPage: ProfilePage {
  111. id: page_sys
  112. onThemChange: {
  113. app.theme_select = mode
  114. app.theme_md = mode
  115. Theme.navigationTabBar.backgroundColor= app.cardColor
  116. Theme.navigationTabBar.titleColor = app.fontColor
  117. Theme.navigationTabBar.dividerColor = "green"
  118. console.log("配置主题模式:",app.theme_select)
  119. }
  120. // handle logout
  121. onLogoutClicked: {
  122. //loginpage.pushed()
  123. logic.logout()
  124. // jump to main page after logout
  125. navigation.currentIndex = 0
  126. serial.setLightness(-255)
  127. //navigation.currentNavigationItem.navigationStack.popAllExceptFirst()
  128. }
  129. }
  130. }
  131. }
  132. tabPosition: Navigation.Left
  133. }
  134. Timer{
  135. interval: 1000
  136. running: true
  137. repeat: true
  138. onTriggered: {
  139. if(navigation.currentIndex === 0&&loginpage.logintimeout%5===0){
  140. serial.readBoardData()
  141. }
  142. loginpage.logintimeout--
  143. ProfilePage.boardversion = "123"
  144. console.log("休眠计数:",loginpage.logintimeout)
  145. if(loginpage.logintimeout===0){ //?秒后进入休眠
  146. loginpage.logintimeout = 300
  147. logoutClicked()
  148. //关闭屏幕(亮度设置为0)
  149. serial.setLightness(-255)
  150. }
  151. }
  152. }
  153. Connections{
  154. target: curl
  155. onDownloadFinished :function(result){
  156. //notificationPage.visible = false
  157. if(result){
  158. navigation.setCurrentTab(1) //升级文件下载成功,跳转到日志界面
  159. }
  160. }
  161. }
  162. LocalNotificationPage {
  163. id: notificationPage
  164. visible:false
  165. }
  166. // login page lies on top of previous items and overlays if user is not logged in
  167. LoginPage {
  168. id: loginpage
  169. title: "植物病菌孢子捕捉分析系统"
  170. Connections{
  171. target: serial
  172. }
  173. visible: opacity > 0
  174. enabled: visible
  175. opacity: dataModel.userLoggedIn ? 0 : 1 // hide if user is logged in
  176. /*
  177. 这段代码的作用是设置页面的透明度,并且添加了一个数值动画(NumberAnimation),动画持续时间为250毫秒。
  178. 具体解释如下:
  179. opacity:表示设置元素的透明度。在这里,可能是应用于页面元素,用于控制页面的可见性。
  180. NumberAnimation:是一个数字动画,用于在一段时间内改变一个数字的值,这里是用来控制透明度的变化。
  181. duration: 250:指定动画的持续时间,这里是250毫秒,表示透明度变化会在250毫秒内完成。
  182. 综合起来,这段代码实现了一个在页面上添加的透明度变化效果,使页面在250毫秒内淡入或淡出,具体效果可能会受到上下文和其他代码的影响。
  183. */
  184. Behavior on opacity { NumberAnimation { duration: 250 } } // page fade in/out
  185. }
  186. }