FileDialog.qml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /****************************************************************************
  2. **
  3. ** Copyright (C) 2021 The Qt Company Ltd.
  4. ** Contact: http://www.qt.io/licensing/
  5. **
  6. ** This file is part of the Qt Quick Dialogs module of the Qt Toolkit.
  7. **
  8. ** $QT_BEGIN_LICENSE:LGPL3$
  9. ** Commercial License Usage
  10. ** Licensees holding valid commercial Qt licenses may use this file in
  11. ** accordance with the commercial license agreement provided with the
  12. ** Software or, alternatively, in accordance with the terms contained in
  13. ** a written agreement between you and The Qt Company. For licensing terms
  14. ** and conditions see http://www.qt.io/terms-conditions. For further
  15. ** information use the contact form at http://www.qt.io/contact-us.
  16. **
  17. ** GNU Lesser General Public License Usage
  18. ** Alternatively, this file may be used under the terms of the GNU Lesser
  19. ** General Public License version 3 as published by the Free Software
  20. ** Foundation and appearing in the file LICENSE.LGPLv3 included in the
  21. ** packaging of this file. Please review the following information to
  22. ** ensure the GNU Lesser General Public License version 3 requirements
  23. ** will be met: https://www.gnu.org/licenses/lgpl.html.
  24. **
  25. ** GNU General Public License Usage
  26. ** Alternatively, this file may be used under the terms of the GNU
  27. ** General Public License version 2.0 or later as published by the Free
  28. ** Software Foundation and appearing in the file LICENSE.GPL included in
  29. ** the packaging of this file. Please review the following information to
  30. ** ensure the GNU General Public License version 2.0 requirements will be
  31. ** met: http://www.gnu.org/licenses/gpl-2.0.html.
  32. **
  33. ** $QT_END_LICENSE$
  34. **
  35. ****************************************************************************/
  36. import Qt.labs.folderlistmodel
  37. import QtQuick
  38. import QtQuick.Controls
  39. import QtQuick.Controls.impl
  40. import QtQuick.Controls.Material
  41. import QtQuick.Controls.Material.impl
  42. import QtQuick.Dialogs
  43. import QtQuick.Dialogs.quickimpl
  44. import QtQuick.Layouts
  45. import QtQuick.Templates as T
  46. import "." as DialogsImpl
  47. FileDialogImpl {
  48. id: control
  49. implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
  50. contentWidth + leftPadding + rightPadding,
  51. implicitFooterWidth)
  52. implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
  53. contentHeight + topPadding + bottomPadding
  54. + (implicitHeaderHeight > 0 ? implicitHeaderHeight + spacing : 0)
  55. + (implicitFooterHeight > 0 ? implicitFooterHeight + spacing : 0))
  56. leftPadding: 24
  57. rightPadding: 24
  58. standardButtons: T.Dialog.Open | T.Dialog.Cancel
  59. Material.elevation: 24
  60. FileDialogImpl.buttonBox: buttonBox
  61. FileDialogImpl.nameFiltersComboBox: nameFiltersComboBox
  62. FileDialogImpl.fileDialogListView: fileDialogListView
  63. FileDialogImpl.breadcrumbBar: breadcrumbBar
  64. background: Rectangle {
  65. implicitWidth: 600
  66. implicitHeight: 400
  67. radius: 2
  68. color: control.Material.dialogColor
  69. layer.enabled: control.Material.elevation > 0
  70. layer.effect: ElevationEffect {
  71. elevation: control.Material.elevation
  72. }
  73. }
  74. header: ColumnLayout {
  75. spacing: 12
  76. Label {
  77. text: control.title
  78. visible: control.title.length > 0
  79. elide: Label.ElideRight
  80. font.bold: true
  81. font.pixelSize: 16
  82. Layout.leftMargin: 24
  83. Layout.rightMargin: 24
  84. Layout.topMargin: 24
  85. Layout.fillWidth: true
  86. }
  87. DialogsImpl.FolderBreadcrumbBar {
  88. id: breadcrumbBar
  89. fileDialog: control
  90. Layout.leftMargin: 24
  91. Layout.rightMargin: 24
  92. Layout.fillWidth: true
  93. Layout.maximumWidth: parent.width - 48
  94. }
  95. }
  96. contentItem: ListView {
  97. id: fileDialogListView
  98. objectName: "fileDialogListView"
  99. clip: true
  100. ScrollBar.vertical: ScrollBar {}
  101. model: FolderListModel {
  102. folder: control.currentFolder
  103. nameFilters: control.selectedNameFilter.globs
  104. showDirsFirst: true
  105. sortCaseSensitive: false
  106. }
  107. delegate: DialogsImpl.FileDialogDelegate {
  108. objectName: "fileDialogDelegate" + index
  109. width: ListView.view.width
  110. highlighted: ListView.isCurrentItem
  111. fileDialog: control
  112. fileDetailRowWidth: nameFiltersComboBox.width
  113. }
  114. }
  115. footer: RowLayout {
  116. id: rowLayout
  117. spacing: 20
  118. ComboBox {
  119. id: nameFiltersComboBox
  120. model: control.nameFilters
  121. Layout.leftMargin: 20
  122. Layout.fillWidth: true
  123. }
  124. DialogButtonBox {
  125. id: buttonBox
  126. standardButtons: control.standardButtons
  127. spacing: 12
  128. horizontalPadding: 0
  129. verticalPadding: 20
  130. Layout.rightMargin: 20
  131. }
  132. }
  133. Overlay.modal: Rectangle {
  134. color: Color.transparent(control.palette.shadow, 0.5)
  135. }
  136. Overlay.modeless: Rectangle {
  137. color: Color.transparent(control.palette.shadow, 0.12)
  138. }
  139. }