FocusFrame.qml 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Copyright (C) 2024 The Qt Company Ltd.
  2. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
  3. // Qt-Security score:significant reason:default
  4. import QtQuick
  5. import QtQuick.Controls
  6. import QtQuick.Layouts
  7. @Deprecated {
  8. reason: "FocusFrame component has been moved to private FluentWinUI3.impl module \
  9. and is no longer part of the public QML API."
  10. }
  11. Rectangle {
  12. Component.onCompleted: {
  13. print("FocusFrame has been moved to private FluentWinUI3.impl module "
  14. + "and is no longer part of the public QML API.")
  15. }
  16. function moveToItem(item) {
  17. if (!item) {
  18. targetItem = null;
  19. parent = null;
  20. return;
  21. }
  22. parent = item.parent
  23. targetItem = item
  24. }
  25. property Item targetItem
  26. property real innerFrameSize: 1
  27. property real outerFrameSize: 3
  28. property real frameRadius: 4.0
  29. x: targetItem ? targetItem.x - outerFrameSize : 0
  30. y: targetItem ? targetItem.y - outerFrameSize : 0
  31. // Stack on top of all siblings of the targetItem
  32. z: 100
  33. width: targetItem ? targetItem.width + outerFrameSize * 2 : 0
  34. height: targetItem ? targetItem.height + outerFrameSize * 2 : 0
  35. radius: frameRadius + outerFrameSize
  36. visible: targetItem && targetItem.visible
  37. color: "transparent"
  38. border.color: Application.styleHints.colorScheme === Qt.Light ? "black" : "white"
  39. border.width: outerFrameSize - (Application.styleHints.colorScheme === Qt.Light ? innerFrameSize : 0)
  40. Rectangle {
  41. id: innerFocusFrame
  42. z: 10
  43. x: outerFrameSize - innerFrameSize
  44. y: outerFrameSize - innerFrameSize
  45. width: targetItem ? targetItem.width + innerFrameSize * 2 : 0
  46. height: targetItem ? targetItem.height + innerFrameSize * 2 : 0
  47. radius: frameRadius + innerFrameSize
  48. visible: targetItem && targetItem.visible
  49. color: "transparent"
  50. border.color: Application.styleHints.colorScheme === Qt.Light ? "white" : "black"
  51. border.width: innerFrameSize
  52. }
  53. }