testbench: save search text between session

This makes using the testbench more convenient, as you don't need to
search for the controls you're interested in each time you run it.

Also added an extra font icon (clear), which required regenerating
the set from fontello. The same license is still applicable since
they're from Font Awesome.

Pick-to: 6.5
Change-Id: I9b44f7f8bce0bb4032071c19186eb5affbfe42a5
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
This commit is contained in:
Mitch Curtis 2022-12-27 13:26:37 +08:00
parent f641848af9
commit 29106dc0c0
5 changed files with 22 additions and 4 deletions

View File

@ -91,7 +91,7 @@ qt_internal_add_resource(testbench "qml"
${qml_resource_files}
)
set(fonts_resource_files
"fonts/fontawesome.ttf"
"fonts/fontello.ttf"
)
qt_internal_add_resource(testbench "fonts"

View File

@ -28,7 +28,7 @@ int main(int argc, char *argv[])
else
QQuickStyle::setStyle(settings.value("style").isValid() ? settings.value("style").toString() : "Imagine");
if (QFontDatabase::addApplicationFont(":/fonts/fontawesome.ttf") == -1) {
if (QFontDatabase::addApplicationFont(":/fonts/fontello.ttf") == -1) {
qWarning() << "Failed to load fontawesome font";
}

View File

@ -85,6 +85,8 @@ Ui.ApplicationWindow {
property bool autoFixImagineAssets
property alias imagineDirLastModified: assetFixer.assetDirectoryLastModified
property string lastSearchText
Component.onCompleted: settingsLoaded = true
}
@ -119,7 +121,7 @@ Ui.ApplicationWindow {
ToolButton {
text: "\uf0c9"
font.family: "fontawesome"
font.family: "fontello"
font.pixelSize: Qt.application.font.pixelSize * 1.6
onClicked: drawer.open()
}
@ -129,6 +131,22 @@ Ui.ApplicationWindow {
TextField {
id: searchTextField
placeholderText: "Search"
text: settings.lastSearchText
onTextEdited: settings.lastSearchText = text
}
ToolButton {
text: "\ue801"
font.family: "fontello"
visible: searchTextField.length > 0
onClicked: searchTextField.clear()
Layout.leftMargin: -5
}
Label {
text: controlFolderListModel.count + " result(s)"
visible: searchTextField.length > 0
}
Item {
@ -138,7 +156,7 @@ Ui.ApplicationWindow {
ToolButton {
id: optionsMenuButton
text: "\ue800"
font.family: "FontAwesome"
font.family: "fontello"
font.pixelSize: Qt.application.font.pixelSize * 1.6
checked: optionsMenu.visible
checkable: true