FluNavigationView.qml 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931
  1. import QtQuick
  2. import QtQuick.Window
  3. import QtQuick.Controls
  4. import QtQuick.Controls.Basic
  5. import QtQuick.Layouts
  6. import FluentUI
  7. Item {
  8. enum DisplayMode {
  9. Open,
  10. Compact,
  11. Minimal,
  12. Auto
  13. }
  14. property url logo
  15. property string title: ""
  16. property FluObject items
  17. property FluObject footerItems
  18. property int displayMode: FluNavigationView.Auto
  19. property Component autoSuggestBox
  20. property var window : {
  21. if(Window.window == null)
  22. return null
  23. return Window.window
  24. }
  25. id:control
  26. QtObject{
  27. id:d
  28. property bool enableStack: true
  29. property int displayMode: {
  30. if(control.displayMode !==FluNavigationView.Auto){
  31. return control.displayMode
  32. }
  33. if(control.width<=700){
  34. return FluNavigationView.Minimal
  35. }else if(control.width<=900){
  36. return FluNavigationView.Compact
  37. }else{
  38. return FluNavigationView.Open
  39. }
  40. }
  41. property var stackItems: []
  42. property bool enableNavigationPanel: false
  43. property bool isCompact: d.displayMode === FluNavigationView.Compact
  44. property bool isMinimal: d.displayMode === FluNavigationView.Minimal
  45. property bool isCompactAndPanel: d.displayMode === FluNavigationView.Compact && d.enableNavigationPanel
  46. property bool isCompactAndNotPanel:d.displayMode === FluNavigationView.Compact && !d.enableNavigationPanel
  47. property bool isMinimalAndPanel: d.displayMode === FluNavigationView.Minimal && d.enableNavigationPanel
  48. onIsCompactAndNotPanelChanged: {
  49. collapseAll()
  50. }
  51. onDisplayModeChanged: {
  52. if(d.displayMode === FluNavigationView.Compact){
  53. collapseAll()
  54. }
  55. if(d.displayMode === FluNavigationView.Minimal){
  56. anim_layout_list_x.enabled = false
  57. d.enableNavigationPanel = false
  58. timer_anim_x_enable.restart()
  59. }
  60. }
  61. function handleItems(){
  62. var idx = 0
  63. var data = []
  64. if(items){
  65. for(var i=0;i<items.children.length;i++){
  66. var item = items.children[i]
  67. item.idx = idx
  68. data.push(item)
  69. idx++
  70. if(item instanceof FluPaneItemExpander){
  71. for(var j=0;j<item.children.length;j++){
  72. var itemChild = item.children[j]
  73. itemChild.parent = item
  74. itemChild.idx = idx
  75. data.push(itemChild)
  76. idx++
  77. }
  78. }
  79. }
  80. if(footerItems){
  81. var comEmpty = Qt.createComponent("FluPaneItemEmpty.qml");
  82. for(var k=0;k<footerItems.children.length;k++){
  83. var itemFooter = footerItems.children[k]
  84. if (comEmpty.status === Component.Ready) {
  85. var objEmpty = comEmpty.createObject(items,{idx:idx});
  86. itemFooter.idx = idx;
  87. data.push(objEmpty)
  88. idx++
  89. }
  90. }
  91. }
  92. }
  93. return data
  94. }
  95. }
  96. Component{
  97. id:com_panel_item_empty
  98. Item{
  99. visible: false
  100. }
  101. }
  102. Component{
  103. id:com_panel_item_separatorr
  104. FluDivider{
  105. width: layout_list.width
  106. height: {
  107. if(model.parent){
  108. return model.parent.isExpand ? 1 : 0
  109. }
  110. return 1
  111. }
  112. Behavior on height {
  113. NumberAnimation{
  114. duration: 167
  115. easing.type: Easing.BezierSpline
  116. easing.bezierCurve: [ 0, 0, 0, 1 ]
  117. }
  118. }
  119. }
  120. }
  121. Component{
  122. id:com_panel_item_header
  123. Item{
  124. height: {
  125. if(model.parent){
  126. return model.parent.isExpand ? 30 : 0
  127. }
  128. return 30
  129. }
  130. Behavior on height {
  131. NumberAnimation{
  132. duration: 167
  133. easing.type: Easing.BezierSpline
  134. easing.bezierCurve: [ 0, 0, 0, 1 ]
  135. }
  136. }
  137. width: layout_list.width
  138. FluText{
  139. text:model.title
  140. font: FluTextStyle.BodyStrong
  141. anchors{
  142. bottom: parent.bottom
  143. left:parent.left
  144. leftMargin: 10
  145. }
  146. }
  147. }
  148. }
  149. Component{
  150. id:com_panel_item_expander
  151. Item{
  152. height: 38
  153. width: layout_list.width
  154. Rectangle{
  155. radius: 4
  156. anchors{
  157. top: parent.top
  158. bottom: parent.bottom
  159. left: parent.left
  160. right: parent.right
  161. topMargin: 2
  162. bottomMargin: 2
  163. leftMargin: 6
  164. rightMargin: 6
  165. }
  166. Rectangle{
  167. width: 3
  168. height: 18
  169. radius: 1.5
  170. color: FluTheme.primaryColor.dark
  171. visible: {
  172. for(var i=0;i<model.children.length;i++){
  173. var item = model.children[i]
  174. if(item.idx === nav_list.currentIndex && !model.isExpand){
  175. return true
  176. }
  177. }
  178. return false
  179. }
  180. anchors{
  181. verticalCenter: parent.verticalCenter
  182. }
  183. }
  184. FluIcon{
  185. rotation: model.isExpand?0:180
  186. iconSource:FluentIcons.ChevronUp
  187. iconSize: 15
  188. anchors{
  189. verticalCenter: parent.verticalCenter
  190. right: parent.right
  191. rightMargin: 12
  192. }
  193. opacity: {
  194. if(d.isCompactAndNotPanel){
  195. return false
  196. }
  197. return true
  198. }
  199. visible:opacity
  200. Behavior on opacity {
  201. NumberAnimation{
  202. duration: 83
  203. }
  204. }
  205. Behavior on rotation {
  206. NumberAnimation{
  207. duration: 83
  208. }
  209. }
  210. }
  211. MouseArea{
  212. id:item_mouse
  213. hoverEnabled: true
  214. anchors.fill: parent
  215. onClicked: {
  216. if(d.isCompactAndNotPanel){
  217. control_popup.showPopup(Qt.point(50,mapToItem(control,0,0).y),model.children)
  218. return
  219. }
  220. model.isExpand = !model.isExpand
  221. }
  222. }
  223. color: {
  224. if(FluTheme.dark){
  225. if((nav_list.currentIndex === idx)&&type===0){
  226. return Qt.rgba(1,1,1,0.06)
  227. }
  228. if(item_mouse.containsMouse){
  229. return Qt.rgba(1,1,1,0.03)
  230. }
  231. return Qt.rgba(0,0,0,0)
  232. }else{
  233. if(nav_list.currentIndex === idx&&type===0){
  234. return Qt.rgba(0,0,0,0.06)
  235. }
  236. if(item_mouse.containsMouse){
  237. return Qt.rgba(0,0,0,0.03)
  238. }
  239. return Qt.rgba(0,0,0,0)
  240. }
  241. }
  242. Component{
  243. id:com_icon
  244. FluIcon{
  245. iconSource: {
  246. if(model.icon){
  247. return model.icon
  248. }
  249. return 0
  250. }
  251. iconSize: 15
  252. }
  253. }
  254. Item{
  255. id:item_icon
  256. width: 30
  257. height: 30
  258. anchors{
  259. verticalCenter: parent.verticalCenter
  260. left:parent.left
  261. leftMargin: 3
  262. }
  263. Loader{
  264. anchors.centerIn: parent
  265. sourceComponent: {
  266. if(model.cusIcon){
  267. return model.cusIcon
  268. }
  269. return com_icon
  270. }
  271. }
  272. }
  273. FluText{
  274. id:item_title
  275. text:model.title
  276. opacity: {
  277. if(d.isCompactAndNotPanel){
  278. return false
  279. }
  280. return true
  281. }
  282. visible:opacity
  283. Behavior on opacity {
  284. NumberAnimation{
  285. duration: 83
  286. }
  287. }
  288. anchors{
  289. verticalCenter: parent.verticalCenter
  290. left:item_icon.right
  291. }
  292. color:{
  293. if(item_mouse.pressed){
  294. return FluTheme.dark ? FluColors.Grey80 : FluColors.Grey120
  295. }
  296. return FluTheme.dark ? FluColors.White : FluColors.Grey220
  297. }
  298. }
  299. }
  300. }
  301. }
  302. Component{
  303. id:com_panel_item
  304. Item{
  305. Behavior on height {
  306. NumberAnimation{
  307. duration: 167
  308. easing.type: Easing.BezierSpline
  309. easing.bezierCurve: [ 0, 0, 0, 1 ]
  310. }
  311. }
  312. clip: true
  313. height: {
  314. if(model.parent){
  315. return model.parent.isExpand ? 38 : 0
  316. }
  317. return 38
  318. }
  319. width: layout_list.width
  320. Rectangle{
  321. radius: 4
  322. anchors{
  323. top: parent.top
  324. bottom: parent.bottom
  325. left: parent.left
  326. right: parent.right
  327. topMargin: 2
  328. bottomMargin: 2
  329. leftMargin: 6
  330. rightMargin: 6
  331. }
  332. MouseArea{
  333. id:item_mouse
  334. hoverEnabled: true
  335. anchors.fill: parent
  336. onClicked: {
  337. if(type === 0){
  338. if(model.tapFunc){
  339. model.tapFunc()
  340. }else{
  341. nav_list.currentIndex = idx
  342. layout_footer.currentIndex = -1
  343. if(d.isMinimal || d.isCompact){
  344. d.enableNavigationPanel = false
  345. }
  346. }
  347. }else{
  348. if(model.tapFunc){
  349. model.tapFunc()
  350. }else{
  351. model.tap()
  352. d.stackItems.push(model)
  353. nav_list.currentIndex = nav_list.count-layout_footer.count+idx
  354. layout_footer.currentIndex = idx
  355. if(d.isMinimal || d.isCompact){
  356. d.enableNavigationPanel = false
  357. }
  358. }
  359. }
  360. nav_app_bar_pane_title.text = model.title
  361. }
  362. }
  363. color: {
  364. if(FluTheme.dark){
  365. if(type===0){
  366. if(nav_list.currentIndex === idx){
  367. return Qt.rgba(1,1,1,0.06)
  368. }
  369. }else{
  370. if(nav_list.currentIndex === (nav_list.count-layout_footer.count+idx)){
  371. return Qt.rgba(1,1,1,0.06)
  372. }
  373. }
  374. if(item_mouse.containsMouse){
  375. return Qt.rgba(1,1,1,0.03)
  376. }
  377. return Qt.rgba(0,0,0,0)
  378. }else{
  379. if(type===0){
  380. if(nav_list.currentIndex === idx){
  381. return Qt.rgba(0,0,0,0.06)
  382. }
  383. }else{
  384. if(nav_list.currentIndex === (nav_list.count-layout_footer.count+idx)){
  385. return Qt.rgba(0,0,0,0.06)
  386. }
  387. }
  388. if(item_mouse.containsMouse){
  389. return Qt.rgba(0,0,0,0.03)
  390. }
  391. return Qt.rgba(0,0,0,0)
  392. }
  393. }
  394. Component{
  395. id:com_icon
  396. FluIcon{
  397. iconSource: {
  398. if(model.icon){
  399. return model.icon
  400. }
  401. return 0
  402. }
  403. iconSize: 15
  404. }
  405. }
  406. Item{
  407. id:item_icon
  408. width: 30
  409. height: 30
  410. anchors{
  411. verticalCenter: parent.verticalCenter
  412. left:parent.left
  413. leftMargin: 3
  414. }
  415. Loader{
  416. anchors.centerIn: parent
  417. sourceComponent: {
  418. if(model.cusIcon){
  419. return model.cusIcon
  420. }
  421. return com_icon
  422. }
  423. }
  424. }
  425. FluText{
  426. id:item_title
  427. text:model.title
  428. opacity: {
  429. if(d.isCompactAndNotPanel){
  430. return false
  431. }
  432. return true
  433. }
  434. visible:opacity
  435. Behavior on opacity {
  436. NumberAnimation{
  437. duration: 83
  438. }
  439. }
  440. color:{
  441. if(item_mouse.pressed){
  442. return FluTheme.dark ? FluColors.Grey80 : FluColors.Grey120
  443. }
  444. return FluTheme.dark ? FluColors.White : FluColors.Grey220
  445. }
  446. anchors{
  447. verticalCenter: parent.verticalCenter
  448. left:item_icon.right
  449. }
  450. }
  451. }
  452. }
  453. }
  454. Item {
  455. id:nav_app_bar
  456. width: parent.width
  457. height: 40
  458. z:999
  459. RowLayout{
  460. height:parent.height
  461. spacing: 0
  462. // FluIconButton{
  463. // iconSource: FluentIcons.ChromeBack
  464. // Layout.leftMargin: 5
  465. // Layout.preferredWidth: 40
  466. // Layout.preferredHeight: 40
  467. // Layout.alignment: Qt.AlignVCenter
  468. // disabled: nav_swipe.depth === 1
  469. // iconSize: 13
  470. // onClicked: {
  471. // nav_swipe.pop()
  472. // d.stackItems.pop()
  473. // var item = d.stackItems[d.stackItems.length-1]
  474. // d.enableStack = false
  475. // if(item.idx<(nav_list.count - layout_footer.count)){
  476. // layout_footer.currentIndex = -1
  477. // }else{
  478. // console.debug(item.idx-(nav_list.count-layout_footer.count))
  479. // layout_footer.currentIndex = item.idx-(nav_list.count-layout_footer.count)
  480. // }
  481. // nav_list.currentIndex = item.idx
  482. // d.enableStack = true
  483. // }
  484. // }
  485. FluIconButton{
  486. id:btn_nav
  487. iconSource: FluentIcons.GlobalNavButton
  488. iconSize: 15
  489. Layout.preferredWidth: d.isMinimal ? 40 : 0
  490. Layout.preferredHeight: 40
  491. Layout.alignment: Qt.AlignVCenter
  492. onClicked: {
  493. d.enableNavigationPanel = !d.enableNavigationPanel
  494. }
  495. visible: d.isMinimal
  496. Behavior on Layout.preferredWidth{
  497. NumberAnimation{
  498. duration: 167
  499. easing.type: Easing.BezierSpline
  500. easing.bezierCurve: [ 0, 0, 0, 1 ]
  501. }
  502. }
  503. }
  504. Item{
  505. Layout.preferredHeight: 40
  506. Layout.preferredWidth: 40
  507. Layout.alignment: Qt.AlignVCenter
  508. Layout.leftMargin: 5
  509. Image{
  510. width: 20
  511. height: 20
  512. anchors.centerIn: parent
  513. id:image_logo
  514. source: control.logo
  515. }
  516. MouseArea{
  517. anchors.fill: parent
  518. onClicked: Qt.openUrlExternally("https://github.com/runhey/OnmyojiAutoScript")
  519. }
  520. }
  521. FluText{
  522. Layout.alignment: Qt.AlignVCenter
  523. text:control.title
  524. Layout.leftMargin: 12
  525. font: FluTextStyle.Body
  526. }
  527. FluText{
  528. Layout.alignment: Qt.AlignVCenter
  529. text: ">"
  530. Layout.leftMargin: 2
  531. font: FluTextStyle.Body
  532. }
  533. FluText{
  534. id: nav_app_bar_pane_title
  535. Layout.alignment: Qt.AlignVCenter
  536. text:"主页"
  537. Layout.leftMargin: 2
  538. font: FluTextStyle.Body
  539. }
  540. }
  541. }
  542. Item{
  543. anchors{
  544. left: d.isMinimal || d.isCompactAndPanel ? parent.left : layout_list.right
  545. top: nav_app_bar.bottom
  546. right: parent.right
  547. bottom: parent.bottom
  548. leftMargin: d.isCompactAndPanel ? 50 : 0
  549. }
  550. StackView{
  551. id:nav_swipe
  552. anchors.fill: parent
  553. clip: true
  554. popEnter : Transition{}
  555. popExit : Transition {
  556. NumberAnimation {
  557. properties: "y"
  558. from: 0
  559. to: nav_swipe.height
  560. duration: 167
  561. easing.type: Easing.BezierSpline
  562. easing.bezierCurve: [ 1, 0, 0, 0 ]
  563. }
  564. }
  565. pushEnter: Transition {
  566. NumberAnimation {
  567. properties: "y";
  568. from: nav_swipe.height;
  569. to: 0
  570. duration: 167
  571. easing.type: Easing.BezierSpline
  572. easing.bezierCurve: [ 0, 0, 0, 1 ]
  573. }
  574. }
  575. pushExit : Transition{}
  576. replaceEnter : Transition{}
  577. replaceExit : Transition{}
  578. }
  579. }
  580. MouseArea{
  581. anchors.fill: parent
  582. visible: d.isMinimalAndPanel||d.isCompactAndPanel
  583. onClicked: {
  584. d.enableNavigationPanel = false
  585. }
  586. }
  587. Rectangle{
  588. id:layout_list
  589. width: {
  590. if(d.isCompactAndNotPanel){
  591. return 50
  592. }
  593. return 200
  594. }
  595. Behavior on width{
  596. NumberAnimation{
  597. duration: 167
  598. easing.type: Easing.BezierSpline
  599. easing.bezierCurve: [ 0, 0, 0, 1 ]
  600. }
  601. }
  602. Behavior on x{
  603. id:anim_layout_list_x
  604. NumberAnimation{
  605. duration: 167
  606. easing.type: Easing.BezierSpline
  607. easing.bezierCurve: [ 0, 0, 0, 1 ]
  608. }
  609. }
  610. anchors{
  611. top: parent.top
  612. bottom: parent.bottom
  613. }
  614. border.color: FluTheme.dark ? Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(226/255,230/255,234/255,1)
  615. border.width: d.isMinimal || d.isCompactAndPanel ? 1 : 0
  616. color: {
  617. if(d.isMinimal || d.isCompactAndPanel){
  618. return FluTheme.dark ? Qt.rgba(61/255,61/255,61/255,1) : Qt.rgba(243/255,243/255,243/255,1)
  619. }
  620. if(window && window.active){
  621. return FluTheme.dark ? Qt.rgba(26/255,34/255,41/255,1) : Qt.rgba(238/255,244/255,249/255,1)
  622. }
  623. return FluTheme.dark ? Qt.rgba(32/255,32/255,32/255,1) : Qt.rgba(243/255,243/255,243/255,1)
  624. }
  625. Behavior on color{
  626. ColorAnimation {
  627. duration: 300
  628. }
  629. }
  630. x: {
  631. if(d.displayMode !== FluNavigationView.Minimal)
  632. return 0
  633. return d.isMinimalAndPanel ? 0 : -width
  634. }
  635. Item{
  636. id:layout_header
  637. width: layout_list.width
  638. clip: true
  639. y:nav_app_bar.height
  640. height: autoSuggestBox ? 38 : 0
  641. Loader{
  642. id:loader_auto_suggest_box
  643. anchors.centerIn: parent
  644. sourceComponent: autoSuggestBox
  645. opacity: {
  646. if(d.isCompactAndNotPanel){
  647. return false
  648. }
  649. return true
  650. }
  651. visible: opacity
  652. Behavior on opacity{
  653. NumberAnimation{
  654. duration: 83
  655. }
  656. }
  657. }
  658. FluIconButton{
  659. visible:opacity
  660. opacity:d.isCompactAndNotPanel
  661. Behavior on opacity{
  662. NumberAnimation{
  663. duration: 83
  664. }
  665. }
  666. hoverColor: FluTheme.dark ? Qt.rgba(1,1,1,0.03) : Qt.rgba(0,0,0,0.03)
  667. pressedColor: FluTheme.dark ? Qt.rgba(1,1,1,0.03) : Qt.rgba(0,0,0,0.03)
  668. normalColor: FluTheme.dark ? Qt.rgba(0,0,0,0) : Qt.rgba(0,0,0,0)
  669. width:38
  670. height:34
  671. x:6
  672. y:2
  673. iconSize: 15
  674. iconSource: {
  675. if(loader_auto_suggest_box.item){
  676. return loader_auto_suggest_box.item.autoSuggestBoxReplacement
  677. }
  678. return 0
  679. }
  680. onClicked: {
  681. d.enableNavigationPanel = !d.enableNavigationPanel
  682. }
  683. }
  684. }
  685. ListView{
  686. id:nav_list
  687. clip: true
  688. ScrollBar.vertical: FluScrollBar {}
  689. model:d.handleItems()
  690. highlightMoveDuration: 150
  691. highlight: Item{
  692. clip: true
  693. Rectangle{
  694. height: 18
  695. radius: 1.5
  696. color: FluTheme.primaryColor.dark
  697. width: 3
  698. anchors{
  699. verticalCenter: parent.verticalCenter
  700. left: parent.left
  701. leftMargin: 6
  702. }
  703. }
  704. }
  705. onCurrentIndexChanged: {
  706. if(d.enableStack){
  707. var item = model[currentIndex]
  708. if(item instanceof FluPaneItem){
  709. item.tap()
  710. d.stackItems.push(item)
  711. }
  712. }
  713. }
  714. currentIndex: -1
  715. anchors{
  716. top: layout_header.bottom
  717. topMargin: 0
  718. left: parent.left
  719. right: parent.right
  720. bottom: layout_footer.top
  721. }
  722. delegate: Loader{
  723. property var model: modelData
  724. property var idx: index
  725. property int type: 0
  726. sourceComponent: {
  727. if(modelData instanceof FluPaneItem){
  728. return com_panel_item
  729. }
  730. if(modelData instanceof FluPaneItemHeader){
  731. return com_panel_item_header
  732. }
  733. if(modelData instanceof FluPaneItemSeparator){
  734. return com_panel_item_separatorr
  735. }
  736. if(modelData instanceof FluPaneItemExpander){
  737. return com_panel_item_expander
  738. }
  739. if(modelData instanceof FluPaneItemEmpty){
  740. return com_panel_item_empty
  741. }
  742. }
  743. }
  744. }
  745. ListView{
  746. id:layout_footer
  747. clip: true
  748. width: layout_list.width
  749. height: childrenRect.height
  750. anchors.bottom: parent.bottom
  751. interactive: false
  752. currentIndex: -1
  753. model: {
  754. if(footerItems){
  755. return footerItems.children
  756. }
  757. }
  758. highlightMoveDuration: 150
  759. highlight: Item{
  760. clip: true
  761. Rectangle{
  762. height: 18
  763. radius: 1.5
  764. color: FluTheme.primaryColor.dark
  765. width: 3
  766. anchors{
  767. verticalCenter: parent.verticalCenter
  768. left: parent.left
  769. leftMargin: 6
  770. }
  771. }
  772. }
  773. delegate: Loader{
  774. property var model: modelData
  775. property var idx: index
  776. property int type: 1
  777. sourceComponent: {
  778. if(modelData instanceof FluPaneItem){
  779. return com_panel_item
  780. }
  781. if(modelData instanceof FluPaneItemHeader){
  782. return com_panel_item_header
  783. }
  784. if(modelData instanceof FluPaneItemSeparator){
  785. return com_panel_item_separatorr
  786. }
  787. }
  788. }
  789. }
  790. }
  791. Popup{
  792. property var childModel
  793. id:control_popup
  794. enter: Transition {
  795. NumberAnimation {
  796. property: "opacity"
  797. from:0
  798. to:1
  799. duration: 83
  800. }
  801. }
  802. background: Rectangle{
  803. width: 160
  804. radius: 4
  805. FluShadow{
  806. radius: 4
  807. }
  808. color: FluTheme.dark ? Qt.rgba(51/255,48/255,48/255,1) : Qt.rgba(248/255,250/255,253/255,1)
  809. height: 38*Math.min(Math.max(list_view.count,1),8)
  810. ListView{
  811. id:list_view
  812. anchors.fill: parent
  813. clip: true
  814. currentIndex: -1
  815. model: control_popup.childModel
  816. ScrollBar.vertical: FluScrollBar {}
  817. delegate:Button{
  818. width: 160
  819. padding:10
  820. background: Rectangle{
  821. color: {
  822. if(hovered){
  823. return FluTheme.dark ? Qt.rgba(63/255,60/255,61/255,1) : Qt.rgba(237/255,237/255,242/255,1)
  824. }
  825. return FluTheme.dark ? Qt.rgba(51/255,48/255,48/255,1) : Qt.rgba(0,0,0,0)
  826. }
  827. }
  828. contentItem: FluText{
  829. text:modelData.title
  830. anchors{
  831. verticalCenter: parent.verticalCenter
  832. }
  833. }
  834. onClicked: {
  835. if(modelData.tapFunc){
  836. modelData.tapFunc()
  837. }else{
  838. nav_list.currentIndex = idx
  839. layout_footer.currentIndex = -1
  840. if(d.isMinimal || d.isCompact){
  841. d.enableNavigationPanel = false
  842. }
  843. }
  844. control_popup.close()
  845. }
  846. }
  847. }
  848. }
  849. function showPopup(pos,model){
  850. control_popup.x = pos.x
  851. control_popup.y = pos.y
  852. control_popup.childModel = model
  853. control_popup.open()
  854. }
  855. }
  856. Timer{
  857. id:timer_anim_x_enable
  858. interval: 150
  859. onTriggered: {
  860. anim_layout_list_x.enabled = true
  861. }
  862. }
  863. function collapseAll(){
  864. for(var i=0;i<nav_list.model.length;i++){
  865. var item = nav_list.model[i]
  866. if(item instanceof FluPaneItemExpander){
  867. item.isExpand = false
  868. }
  869. }
  870. }
  871. function setCurrentIndex(index){
  872. nav_list.currentIndex = index
  873. }
  874. function getItems(){
  875. return nav_list.model
  876. }
  877. function push(url){
  878. nav_swipe.push(url)
  879. }
  880. function getCurrentIndex(){
  881. return nav_list.currentIndex
  882. }
  883. function startPageByItem(data){
  884. var items = getItems();
  885. for(var i=0;i<items.length;i++){
  886. var item = items[i]
  887. if(item.key === data.key){
  888. if(getCurrentIndex() === i){
  889. return
  890. }
  891. setCurrentIndex(i)
  892. if(item.parent && !d.isCompactAndNotPanel){
  893. item.parent.isExpand = true
  894. }
  895. return
  896. }
  897. }
  898. }
  899. }