FileDialog.qml 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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.Universal
  40. import QtQuick.Dialogs
  41. import QtQuick.Dialogs.quickimpl
  42. import QtQuick.Layouts
  43. import QtQuick.Templates as T
  44. import "." as DialogsImpl
  45. FileDialogImpl {
  46. id: control
  47. implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
  48. contentWidth + leftPadding + rightPadding,
  49. implicitHeaderWidth,
  50. implicitFooterWidth)
  51. implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
  52. contentHeight + topPadding + bottomPadding
  53. + (implicitHeaderHeight > 0 ? implicitHeaderHeight + spacing : 0)
  54. + (implicitFooterHeight > 0 ? implicitFooterHeight + spacing : 0))
  55. padding: 24
  56. verticalPadding: 18
  57. standardButtons: T.Dialog.Open | T.Dialog.Cancel
  58. FileDialogImpl.buttonBox: buttonBox
  59. FileDialogImpl.nameFiltersComboBox: nameFiltersComboBox
  60. FileDialogImpl.fileDialogListView: fileDialogListView
  61. FileDialogImpl.breadcrumbBar: breadcrumbBar
  62. background: Rectangle {
  63. implicitWidth: 600
  64. implicitHeight: 400
  65. color: control.Universal.chromeMediumLowColor
  66. border.color: control.Universal.chromeHighColor
  67. border.width: 1 // FlyoutBorderThemeThickness
  68. }
  69. header: ColumnLayout {
  70. spacing: 12
  71. Label {
  72. text: control.title
  73. elide: Label.ElideRight
  74. // TODO: QPlatformTheme::TitleBarFont
  75. font.pixelSize: 20
  76. Layout.leftMargin: 24
  77. Layout.rightMargin: 24
  78. Layout.topMargin: 18
  79. Layout.fillWidth: true
  80. Layout.preferredHeight: control.title.length > 0 ? implicitHeight : 0
  81. background: Rectangle {
  82. x: 1; y: 1 // // FlyoutBorderThemeThickness
  83. color: control.Universal.chromeMediumLowColor
  84. width: parent.width - 2
  85. height: parent.height - 1
  86. }
  87. }
  88. DialogsImpl.FolderBreadcrumbBar {
  89. id: breadcrumbBar
  90. fileDialog: control
  91. Layout.leftMargin: 24
  92. Layout.rightMargin: 24
  93. Layout.fillWidth: true
  94. Layout.maximumWidth: parent.width - 48
  95. }
  96. }
  97. contentItem: ListView {
  98. id: fileDialogListView
  99. objectName: "fileDialogListView"
  100. clip: true
  101. boundsBehavior: Flickable.StopAtBounds
  102. ScrollBar.vertical: ScrollBar {}
  103. model: FolderListModel {
  104. folder: control.currentFolder
  105. nameFilters: control.selectedNameFilter.globs
  106. showDirsFirst: true
  107. sortCaseSensitive: false
  108. }
  109. delegate: DialogsImpl.FileDialogDelegate {
  110. objectName: "fileDialogDelegate" + index
  111. width: ListView.view.width
  112. highlighted: ListView.isCurrentItem
  113. fileDialog: control
  114. fileDetailRowWidth: nameFiltersComboBox.width
  115. }
  116. }
  117. footer: RowLayout {
  118. id: rowLayout
  119. spacing: 24
  120. ComboBox {
  121. id: nameFiltersComboBox
  122. model: control.nameFilters
  123. Layout.leftMargin: 24
  124. Layout.fillWidth: true
  125. Layout.topMargin: 6
  126. Layout.bottomMargin: 24
  127. }
  128. DialogButtonBox {
  129. id: buttonBox
  130. standardButtons: control.standardButtons
  131. spacing: 12
  132. horizontalPadding: 0
  133. Layout.rightMargin: 24
  134. }
  135. }
  136. T.Overlay.modal: Rectangle {
  137. color: control.Universal.baseLowColor
  138. }
  139. T.Overlay.modeless: Rectangle {
  140. color: control.Universal.baseLowColor
  141. }
  142. }