FontDialog.qml 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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 QtQuick
  37. import QtQuick.Controls
  38. import QtQuick.Controls.impl
  39. import QtQuick.Controls.Imagine
  40. import QtQuick.Controls.Imagine.impl
  41. import QtQuick.Dialogs
  42. import QtQuick.Dialogs.quickimpl
  43. import QtQuick.Layouts
  44. import QtQuick.Templates as T
  45. FontDialogImpl {
  46. id: control
  47. // Can't set implicitWidth of the NinePatchImage background, so we do it here.
  48. implicitWidth: Math.max(600,
  49. implicitBackgroundWidth + leftInset + rightInset,
  50. contentWidth + leftPadding + rightPadding,
  51. implicitHeaderWidth,
  52. implicitFooterWidth)
  53. implicitHeight: Math.max(400,
  54. implicitBackgroundHeight + topInset + bottomInset,
  55. contentHeight + topPadding + bottomPadding
  56. + (implicitHeaderHeight > 0 ? implicitHeaderHeight + spacing : 0)
  57. + (implicitFooterHeight > 0 ? implicitFooterHeight + spacing : 0))
  58. topPadding: background ? background.topPadding : 0
  59. leftPadding: background ? background.leftPadding : 0
  60. rightPadding: background ? background.rightPadding : 0
  61. bottomPadding: background ? background.bottomPadding : 0
  62. topInset: background ? -background.topInset || 0 : 0
  63. leftInset: background ? -background.leftInset || 0 : 0
  64. rightInset: background ? -background.rightInset || 0 : 0
  65. bottomInset: background ? -background.bottomInset || 0 : 0
  66. standardButtons: T.Dialog.Ok | T.Dialog.Cancel
  67. FontDialogImpl.buttonBox: buttonBox
  68. FontDialogImpl.familyListView: content.familyListView
  69. FontDialogImpl.styleListView: content.styleListView
  70. FontDialogImpl.sizeListView: content.sizeListView
  71. FontDialogImpl.sampleEdit: content.sampleEdit
  72. FontDialogImpl.writingSystemComboBox: writingSystemComboBox
  73. FontDialogImpl.underlineCheckBox: content.underline
  74. FontDialogImpl.strikeoutCheckBox: content.strikeout
  75. FontDialogImpl.familyEdit: content.familyEdit
  76. FontDialogImpl.styleEdit: content.styleEdit
  77. FontDialogImpl.sizeEdit: content.sizeEdit
  78. background: NinePatchImage {
  79. source: Imagine.url + "dialog-background"
  80. NinePatchImageSelector on source {
  81. states: [
  82. {"modal": control.modal},
  83. {"dim": control.dim}
  84. ]
  85. }
  86. }
  87. Overlay.modal: NinePatchImage {
  88. source: Imagine.url + "dialog-overlay"
  89. NinePatchImageSelector on source {
  90. states: [
  91. {"modal": true}
  92. ]
  93. }
  94. }
  95. Overlay.modeless: NinePatchImage {
  96. source: Imagine.url + "dialog-overlay"
  97. NinePatchImageSelector on source {
  98. states: [
  99. {"modal": false}
  100. ]
  101. }
  102. }
  103. header: Label {
  104. text: control.title
  105. elide: Label.ElideRight
  106. font.bold: true
  107. leftPadding: 16
  108. rightPadding: 16
  109. topPadding: 12
  110. height: control.title.length > 0 ? implicitHeight : 0
  111. background: NinePatchImage {
  112. width: parent.width
  113. height: parent.height
  114. source: Imagine.url + "dialog-title"
  115. NinePatchImageSelector on source {
  116. states: [
  117. {"modal": control.modal},
  118. {"dim": control.dim}
  119. ]
  120. }
  121. }
  122. }
  123. contentItem: FontDialogContent {
  124. id: content
  125. rowSpacing: 16
  126. }
  127. footer: RowLayout {
  128. id: rowLayout
  129. spacing: 20
  130. Label {
  131. text: qsTr("Writing System")
  132. Layout.leftMargin: 20
  133. Layout.bottomMargin: 16
  134. }
  135. ComboBox{
  136. id: writingSystemComboBox
  137. Layout.fillWidth: true
  138. Layout.bottomMargin: 16
  139. }
  140. DialogButtonBox {
  141. id: buttonBox
  142. standardButtons: control.standardButtons
  143. spacing: 12
  144. Layout.rightMargin: 20
  145. Layout.bottomMargin: 16
  146. }
  147. }
  148. }