ColorChooser.qml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * Copyright (C) 2012 Intel Corporation. All rights reserved.
  3. *
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. * 1. Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * 2. Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. *
  15. * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
  16. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  17. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  18. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
  19. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  20. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  21. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  22. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  23. * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  25. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. import QtQuick 2.0
  28. MouseArea {
  29. anchors.fill: parent
  30. onClicked: model.reject()
  31. Rectangle {
  32. id: dialog
  33. property int spacing: 10
  34. color: "gainsboro"
  35. opacity: 0.8
  36. radius: 5
  37. width: 200
  38. height: 200
  39. x: (model.elementRect.x + width > parent.width) ? parent.width - width : model.elementRect.x
  40. y: (model.elementRect.y + model.elementRect.height + height < parent.height ) ? model.elementRect.y + model.elementRect.height
  41. : model.elementRect.y - height;
  42. Rectangle {
  43. color: "red"
  44. anchors.left: parent.left
  45. anchors.top: parent.top
  46. anchors.margins: dialog.spacing
  47. width: parent.width / 2 - dialog.spacing
  48. height: parent.height / 2 - dialog.spacing
  49. MouseArea {
  50. anchors.fill: parent
  51. onClicked: model.accept(parent.color)
  52. }
  53. }
  54. Rectangle {
  55. color: "blue"
  56. anchors.right: parent.right
  57. anchors.top: parent.top
  58. anchors.margins: dialog.spacing
  59. width: parent.width / 2 - dialog.spacing
  60. height: parent.height / 2 - dialog.spacing
  61. MouseArea {
  62. anchors.fill: parent
  63. onClicked: model.accept(parent.color)
  64. }
  65. }
  66. Rectangle {
  67. color: "green"
  68. anchors.bottom: parent.bottom
  69. anchors.left: parent.left
  70. anchors.margins: dialog.spacing
  71. width: parent.width / 2 - dialog.spacing
  72. height: parent.height / 2 - dialog.spacing
  73. MouseArea {
  74. anchors.fill: parent
  75. onClicked: model.accept(parent.color)
  76. }
  77. }
  78. Rectangle {
  79. color: model.currentColor
  80. anchors.bottom: parent.bottom
  81. anchors.right: parent.right
  82. anchors.margins: dialog.spacing * 2
  83. width: parent.width / 2 - dialog.spacing * 4
  84. height: parent.height / 2 - dialog.spacing * 4
  85. Text {
  86. text: "Current"
  87. anchors.bottom: parent.top
  88. anchors.horizontalCenter: parent.horizontalCenter
  89. }
  90. }
  91. }
  92. }