Main.qml 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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: "7A0F7761276CA0ACFD172072656BA4B6567C0D73526F505C4383F731A317F0756F5FA09CD0B3CD0D0F30279EC5EA2D0FD851E07D4E59CDB32E3C5E26B341969809B11E2051E4881C86B38D72897C0808F5593230C44D3B5B3C4929986F4354F11BE16FB196173178BE2D52B4BD4803CCF2BC85B3E96B0023CA0904B3DEDEC45EC24ECD27EAABCE9DA4A1EB5CDA9B340C4691E6F8487D894BD777574A6A0FF22AAF95815969D68CC8C31798E2B0B5366346236DFAEF6CD2FE6596930C402195EAFA06ECB608B90947EA8CA20D97EC36A0D57B87288EBC33AEFFE2B124FB741972B70D8178E14690C4409774487F7F0C4A2B8F6C48CA3EC9A81075CB50EB46D9A6775DE013346B616165EDC9D2064C6DC3F5B51227B1685449BB441DFC11876CD23813C3737107B6BEC44EBC1B691A45E6"
  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. }