UnifiedSearchInputContainer.qml 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * Copyright (C) 2021 by Oleksandr Zolotov <alex@nextcloud.com>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  11. * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  12. * for more details.
  13. */
  14. import QtQml 2.15
  15. import QtQuick 2.15
  16. import QtQuick.Controls 2.15
  17. import QtGraphicalEffects 1.15
  18. import Style 1.0
  19. import com.nextcloud.desktopclient 1.0
  20. TextField {
  21. id: trayWindowUnifiedSearchTextField
  22. property bool isSearchInProgress: false
  23. readonly property color textFieldIconsColor: palette.dark
  24. readonly property int textFieldIconsOffset: Style.trayHorizontalMargin
  25. readonly property double textFieldIconsScaleFactor: 0.6
  26. readonly property int textFieldHorizontalPaddingOffset: Style.trayHorizontalMargin
  27. signal clearText()
  28. leftPadding: trayWindowUnifiedSearchTextFieldSearchIcon.width + trayWindowUnifiedSearchTextFieldSearchIcon.anchors.leftMargin + textFieldHorizontalPaddingOffset - 1
  29. rightPadding: trayWindowUnifiedSearchTextFieldClearTextButton.width + trayWindowUnifiedSearchTextFieldClearTextButton.anchors.rightMargin + textFieldHorizontalPaddingOffset
  30. placeholderText: qsTr("Search files, messages, events …")
  31. selectByMouse: true
  32. palette.text: palette.midlight
  33. background: Rectangle {
  34. radius: 5
  35. border.color: parent.activeFocus ? UserModel.currentUser.accentColor : palette.dark
  36. border.width: 1
  37. color: palette.window
  38. }
  39. Image {
  40. id: trayWindowUnifiedSearchTextFieldSearchIcon
  41. width: Style.trayListItemIconSize - anchors.leftMargin
  42. fillMode: Image.PreserveAspectFit
  43. horizontalAlignment: Image.AlignLeft
  44. anchors {
  45. left: parent.left
  46. leftMargin: parent.textFieldIconsOffset
  47. verticalCenter: parent.verticalCenter
  48. }
  49. visible: !trayWindowUnifiedSearchTextField.isSearchInProgress
  50. smooth: true;
  51. antialiasing: true
  52. mipmap: true
  53. source: "image://svgimage-custom-color/search.svg" + "/" + trayWindowUnifiedSearchTextField.textFieldIconsColor
  54. sourceSize: Qt.size(parent.height * parent.textFieldIconsScaleFactor, parent.height * parent.textFieldIconsScaleFactor)
  55. }
  56. NCBusyIndicator {
  57. id: busyIndicator
  58. anchors {
  59. left: trayWindowUnifiedSearchTextField.left
  60. bottom: trayWindowUnifiedSearchTextField.bottom
  61. leftMargin: trayWindowUnifiedSearchTextField.textFieldIconsOffset - 4
  62. topMargin: 4
  63. bottomMargin: 4
  64. verticalCenter: trayWindowUnifiedSearchTextField.verticalCenter
  65. }
  66. width: height
  67. color: trayWindowUnifiedSearchTextField.textFieldIconsColor
  68. visible: trayWindowUnifiedSearchTextField.isSearchInProgress
  69. running: visible
  70. }
  71. Image {
  72. id: trayWindowUnifiedSearchTextFieldClearTextButton
  73. anchors {
  74. right: parent.right
  75. rightMargin: parent.textFieldIconsOffset
  76. verticalCenter: parent.verticalCenter
  77. }
  78. smooth: true;
  79. antialiasing: true
  80. mipmap: true
  81. visible: parent.text
  82. source: "image://svgimage-custom-color/clear.svg" + "/" + trayWindowUnifiedSearchTextField.textFieldIconsColor
  83. sourceSize: Qt.size(parent.height * parent.textFieldIconsScaleFactor, parent.height * parent.textFieldIconsScaleFactor)
  84. MouseArea {
  85. id: trayWindowUnifiedSearchTextFieldClearTextButtonMouseArea
  86. anchors.fill: parent
  87. onClicked: trayWindowUnifiedSearchTextField.clearText()
  88. }
  89. }
  90. }