UnifiedSearchInputContainer.qml 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. background: Rectangle {
  33. radius: Style.slightlyRoundedButtonRadius
  34. border.color: parent.activeFocus ? UserModel.currentUser.accentColor : palette.dark
  35. border.width: Style.normalBorderWidth
  36. color: palette.window
  37. }
  38. Image {
  39. id: trayWindowUnifiedSearchTextFieldSearchIcon
  40. width: Style.trayListItemIconSize - anchors.leftMargin
  41. fillMode: Image.PreserveAspectFit
  42. horizontalAlignment: Image.AlignLeft
  43. anchors {
  44. left: parent.left
  45. leftMargin: parent.textFieldIconsOffset
  46. verticalCenter: parent.verticalCenter
  47. }
  48. visible: !trayWindowUnifiedSearchTextField.isSearchInProgress
  49. smooth: true;
  50. antialiasing: true
  51. mipmap: true
  52. source: "image://svgimage-custom-color/search.svg" + "/" + trayWindowUnifiedSearchTextField.textFieldIconsColor
  53. sourceSize: Qt.size(parent.height * parent.textFieldIconsScaleFactor, parent.height * parent.textFieldIconsScaleFactor)
  54. }
  55. NCBusyIndicator {
  56. id: busyIndicator
  57. anchors {
  58. left: trayWindowUnifiedSearchTextField.left
  59. bottom: trayWindowUnifiedSearchTextField.bottom
  60. leftMargin: trayWindowUnifiedSearchTextField.textFieldIconsOffset - 4
  61. topMargin: Style.smallSpacing
  62. bottomMargin: Style.smallSpacing
  63. verticalCenter: trayWindowUnifiedSearchTextField.verticalCenter
  64. }
  65. width: height
  66. color: trayWindowUnifiedSearchTextField.textFieldIconsColor
  67. visible: trayWindowUnifiedSearchTextField.isSearchInProgress
  68. running: visible
  69. }
  70. Image {
  71. id: trayWindowUnifiedSearchTextFieldClearTextButton
  72. anchors {
  73. right: parent.right
  74. rightMargin: parent.textFieldIconsOffset
  75. verticalCenter: parent.verticalCenter
  76. }
  77. smooth: true;
  78. antialiasing: true
  79. mipmap: true
  80. visible: parent.text
  81. source: "image://svgimage-custom-color/clear.svg" + "/" + trayWindowUnifiedSearchTextField.textFieldIconsColor
  82. sourceSize: Qt.size(parent.height * parent.textFieldIconsScaleFactor, parent.height * parent.textFieldIconsScaleFactor)
  83. MouseArea {
  84. id: trayWindowUnifiedSearchTextFieldClearTextButtonMouseArea
  85. anchors.fill: parent
  86. onClicked: trayWindowUnifiedSearchTextField.clearText()
  87. }
  88. }
  89. }