ApplicationWindowStyle.qml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /****************************************************************************
  2. **
  3. ** Copyright (C) 2016 The Qt Company Ltd.
  4. ** Contact: https://www.qt.io/licensing/
  5. **
  6. ** This file is part of the Qt Quick Controls module of the Qt Toolkit.
  7. **
  8. ** $QT_BEGIN_LICENSE:LGPL$
  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 https://www.qt.io/terms-conditions. For further
  15. ** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
  28. ** Public license version 3 or any later version approved by the KDE Free
  29. ** Qt Foundation. The licenses are as published by the Free Software
  30. ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
  31. ** included in the packaging of this file. Please review the following
  32. ** information to ensure the GNU General Public License requirements will
  33. ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
  34. ** https://www.gnu.org/licenses/gpl-3.0.html.
  35. **
  36. ** $QT_END_LICENSE$
  37. **
  38. ****************************************************************************/
  39. import QtQuick 2.2
  40. import QtQuick.Controls 1.2
  41. import QtQuick.Controls.Private 1.0
  42. /*!
  43. \qmltype ApplicationWindowStyle
  44. \inqmlmodule QtQuick.Controls.Styles
  45. \since 5.4
  46. \ingroup controlsstyling
  47. \brief Provides custom styling for ApplicationWindow.
  48. You can create a custom window background by replacing the "background"
  49. delegate of ApplicationWindowStyle with a custom design.
  50. Example:
  51. \qml
  52. ApplicationWindow {
  53. style: ApplicationWindowStyle {
  54. background: BorderImage {
  55. source: "background.png"
  56. border { left: 20; top: 20; right: 20; bottom: 20 }
  57. }
  58. }
  59. }
  60. \endqml
  61. */
  62. QtObject {
  63. /*! The window attached to this style. */
  64. readonly property ApplicationWindow control: __control
  65. /*! A custom background for the window.
  66. \note The window might have a custom background color set. The custom
  67. background color is automatically filled by the window. The background
  68. delegate should respect the custom background color by either hiding
  69. itself altogether when a custom background color is set, or by letting
  70. the custom background color shine through.
  71. The following read-only property is available within the scope
  72. of the background delegate:
  73. \table
  74. \row \li \b {styleData.hasColor} : bool \li Whether the window has a custom background color set.
  75. \endtable
  76. */
  77. property Component background: Rectangle {
  78. visible: !styleData.hasColor
  79. color: SystemPaletteSingleton.window(true)
  80. }
  81. /*! \internal */
  82. property Component panel: Item {
  83. readonly property alias contentArea: contentArea
  84. readonly property alias menuBarArea: menuBarArea
  85. readonly property alias toolBarArea: toolBarArea
  86. readonly property alias statusBarArea: statusBarArea
  87. Loader {
  88. anchors.fill: parent
  89. sourceComponent: background
  90. }
  91. Item {
  92. id: contentArea
  93. anchors.top: toolBarArea.bottom
  94. anchors.left: parent.left
  95. anchors.right: parent.right
  96. anchors.bottom: statusBarArea.top
  97. }
  98. Item {
  99. id: toolBarArea
  100. anchors.top: parent.menuBarArea.bottom
  101. anchors.left: parent.left
  102. anchors.right: parent.right
  103. implicitHeight: childrenRect.height
  104. height: visibleChildren.length > 0 ? implicitHeight: 0
  105. }
  106. Item {
  107. id: menuBarArea
  108. anchors.top: parent.top
  109. anchors.left: parent.left
  110. anchors.right: parent.right
  111. implicitHeight: childrenRect.height
  112. height: visibleChildren.length > 0 ? implicitHeight: 0
  113. }
  114. Item {
  115. id: statusBarArea
  116. anchors.bottom: parent.bottom
  117. anchors.left: parent.left
  118. anchors.right: parent.right
  119. implicitHeight: childrenRect.height
  120. height: visibleChildren.length > 0 ? implicitHeight: 0
  121. }
  122. }
  123. }