|
| 1 | +# Copyright (c) 2025 Erwan MATHIEU |
| 2 | + |
| 3 | +import QtQuick 2.15 |
| 4 | +import QtQuick.Window 2.2 |
| 5 | +import QtQuick.Controls 2.3 |
| 6 | +import QtQuick.Layouts 1.15 |
| 7 | + |
| 8 | +import Cura 1.5 as Cura |
| 9 | +import UM 1.5 as UM |
| 10 | + |
| 11 | + |
| 12 | +Item |
| 13 | +{ |
| 14 | + id: root |
| 15 | + implicitHeight: filter.implicitHeight + 2 * UM.Theme.getSize("default_margin").width |
| 16 | + |
| 17 | + UM.I18nCatalog{id: catalog; name:"onshape"} |
| 18 | + |
| 19 | + Timer |
| 20 | + { |
| 21 | + id: settingsSearchTimer |
| 22 | + onTriggered: root.doSearch() |
| 23 | + interval: 500 |
| 24 | + running: false |
| 25 | + repeat: false |
| 26 | + } |
| 27 | + |
| 28 | + Cura.TextField |
| 29 | + { |
| 30 | + id: filter |
| 31 | + implicitWidth: UM.Theme.getSize("print_setup_big_item").width |
| 32 | + implicitHeight: UM.Theme.getSize("print_setup_big_item").height |
| 33 | + anchors.left: parent.left |
| 34 | + anchors.top: parent.top |
| 35 | + anchors.margins: UM.Theme.getSize("default_margin").width |
| 36 | + leftPadding: searchIcon.width + UM.Theme.getSize("default_margin").width * 2 |
| 37 | + placeholderText: catalog.i18nc("@textfield:placeholder", "Search") |
| 38 | + font: UM.Theme.getFont("default_italic") |
| 39 | + |
| 40 | + UM.ColorImage |
| 41 | + { |
| 42 | + id: searchIcon |
| 43 | + |
| 44 | + anchors |
| 45 | + { |
| 46 | + verticalCenter: parent.verticalCenter |
| 47 | + left: parent.left |
| 48 | + leftMargin: UM.Theme.getSize("default_margin").width |
| 49 | + } |
| 50 | + source: UM.Theme.getIcon("Magnifier") |
| 51 | + height: UM.Theme.getSize("small_button_icon").height |
| 52 | + width: height |
| 53 | + color: UM.Theme.getColor("text") |
| 54 | + } |
| 55 | + |
| 56 | + onTextChanged: settingsSearchTimer.restart() |
| 57 | + |
| 58 | + onEditingFinished: root.doSearch() |
| 59 | + |
| 60 | + Keys.onEscapePressed: filter.text = "" |
| 61 | + } |
| 62 | + |
| 63 | + UM.SimpleButton |
| 64 | + { |
| 65 | + id: clearFilterButton |
| 66 | + iconSource: UM.Theme.getIcon("Cancel") |
| 67 | + visible: filter.text !== "" |
| 68 | + |
| 69 | + height: Math.round(filter.height * 0.4) |
| 70 | + width: height |
| 71 | + |
| 72 | + anchors.verticalCenter: filter.verticalCenter |
| 73 | + anchors.right: filter.right |
| 74 | + anchors.rightMargin: UM.Theme.getSize("default_margin").width |
| 75 | + |
| 76 | + color: UM.Theme.getColor("setting_control_button") |
| 77 | + hoverColor: UM.Theme.getColor("setting_control_button_hover") |
| 78 | + |
| 79 | + onClicked: |
| 80 | + { |
| 81 | + filter.text = "" |
| 82 | + filter.forceActiveFocus() |
| 83 | + root.doSearch() |
| 84 | + } |
| 85 | + } |
| 86 | + |
| 87 | + function doSearch() |
| 88 | + { |
| 89 | + console.debug("Search " + filter.text) |
| 90 | + } |
| 91 | +} |
0 commit comments