From e31debc0e7e5c1cb69d64163b3cecbf99b7fa9f2 Mon Sep 17 00:00:00 2001 From: Mahmoud Badri Date: Mon, 26 Sep 2022 15:59:22 +0300 Subject: QmlDesigner: Move SearchBox to StudioControls Fixes: QDS-7759 Change-Id: Idf33aa47f5e793c4053f825ae8a203b97c078bf1 Reviewed-by: Miikka Heikkinen --- .../qmldesigner/itemLibraryQmlSources/Assets.qml | 2 +- .../itemLibraryQmlSources/ItemsView.qml | 2 +- .../materialBrowserQmlSource/MaterialBrowser.qml | 2 +- .../imports/HelperWidgets/SearchBox.qml | 168 --------------------- .../imports/HelperWidgets/qmldir | 1 - .../imports/StudioControls/SearchBox.qml | 168 +++++++++++++++++++++ .../imports/StudioControls/qmldir | 1 + 7 files changed, 172 insertions(+), 172 deletions(-) delete mode 100644 share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/SearchBox.qml create mode 100644 share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/SearchBox.qml diff --git a/share/qtcreator/qmldesigner/itemLibraryQmlSources/Assets.qml b/share/qtcreator/qmldesigner/itemLibraryQmlSources/Assets.qml index d88b129794..eb6408a08f 100644 --- a/share/qtcreator/qmldesigner/itemLibraryQmlSources/Assets.qml +++ b/share/qtcreator/qmldesigner/itemLibraryQmlSources/Assets.qml @@ -436,7 +436,7 @@ Item { width: parent.width - SearchBox { + StudioControls.SearchBox { id: searchBox width: parent.width - addAssetButton.width - 5 diff --git a/share/qtcreator/qmldesigner/itemLibraryQmlSources/ItemsView.qml b/share/qtcreator/qmldesigner/itemLibraryQmlSources/ItemsView.qml index 8a926e2273..1f7c8ad662 100644 --- a/share/qtcreator/qmldesigner/itemLibraryQmlSources/ItemsView.qml +++ b/share/qtcreator/qmldesigner/itemLibraryQmlSources/ItemsView.qml @@ -221,7 +221,7 @@ Item { Row { width: parent.width - SearchBox { + StudioControls.SearchBox { id: searchBox width: parent.width - addModuleButton.width - 5 diff --git a/share/qtcreator/qmldesigner/materialBrowserQmlSource/MaterialBrowser.qml b/share/qtcreator/qmldesigner/materialBrowserQmlSource/MaterialBrowser.qml index 756a7a98a6..0e3b3a086a 100644 --- a/share/qtcreator/qmldesigner/materialBrowserQmlSource/MaterialBrowser.qml +++ b/share/qtcreator/qmldesigner/materialBrowserQmlSource/MaterialBrowser.qml @@ -230,7 +230,7 @@ Item { width: root.width enabled: !materialBrowserModel.hasMaterialRoot && materialBrowserModel.hasQuick3DImport - SearchBox { + StudioControls.SearchBox { id: searchBox width: root.width - addMaterialButton.width diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/SearchBox.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/SearchBox.qml deleted file mode 100644 index 3b4f785faa..0000000000 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/SearchBox.qml +++ /dev/null @@ -1,168 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2022 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -import QtQuick 2.15 -import QtQuick.Controls 2.15 -import QtQuickDesignerTheme 1.0 -import StudioTheme 1.0 as StudioTheme - -Item { - id: root - - property alias text: searchFilterText.text - - signal searchChanged(string searchText); - - function clear() - { - searchFilterText.text = ""; - } - - function isEmpty() - { - return searchFilterText.text === ""; - } - - implicitWidth: searchFilterText.width - implicitHeight: searchFilterText.height - - TextField { - id: searchFilterText - - placeholderText: qsTr("Search") - placeholderTextColor: StudioTheme.Values.themePlaceholderTextColor - color: StudioTheme.Values.themeTextColor - selectionColor: StudioTheme.Values.themeTextSelectionColor - selectedTextColor: StudioTheme.Values.themeTextSelectedTextColor - background: Rectangle { - id: textFieldBackground - color: StudioTheme.Values.themeControlBackground - border.color: StudioTheme.Values.themeControlOutline - border.width: StudioTheme.Values.border - - Behavior on color { - ColorAnimation { - duration: StudioTheme.Values.hoverDuration - easing.type: StudioTheme.Values.hoverEasing - } - } - } - - height: StudioTheme.Values.defaultControlHeight - - leftPadding: 32 - rightPadding: 30 - topPadding: 6 - anchors.left: parent.left - anchors.right: parent.right - anchors.leftMargin: 5 - anchors.rightMargin: 5 - selectByMouse: true - hoverEnabled: true - - onTextChanged: root.searchChanged(text) - - Label { - text: StudioTheme.Constants.search - font.family: StudioTheme.Constants.iconFont.family - font.pixelSize: StudioTheme.Values.myIconFontSize - anchors.left: parent.left - anchors.leftMargin: 7 - anchors.verticalCenter: parent.verticalCenter - color: StudioTheme.Values.themeIconColor - } - - Rectangle { // x button - width: 16 - height: 15 - anchors.right: parent.right - anchors.rightMargin: 5 - anchors.verticalCenter: parent.verticalCenter - visible: searchFilterText.text !== "" - color: xMouseArea.containsMouse ? StudioTheme.Values.themePanelBackground - : "transparent" - - Label { - text: StudioTheme.Constants.closeCross - font.family: StudioTheme.Constants.iconFont.family - font.pixelSize: StudioTheme.Values.myIconFontSize - verticalAlignment: Text.AlignVCenter - horizontalAlignment: Text.AlignHCenter - anchors.centerIn: parent - color: StudioTheme.Values.themeIconColor - } - - MouseArea { - id: xMouseArea - hoverEnabled: true - anchors.fill: parent - onClicked: searchFilterText.text = "" - } - } - - states: [ - State { - name: "default" - when: !searchFilterText.hovered && !searchFilterText.activeFocus - PropertyChanges { - target: textFieldBackground - color: StudioTheme.Values.themeControlBackground - border.color: StudioTheme.Values.themeControlOutline - } - PropertyChanges { - target: searchFilterText - placeholderTextColor: StudioTheme.Values.themePlaceholderTextColor - } - }, - State { - name: "hover" - when: root.enabled && searchFilterText.hovered && !searchFilterText.activeFocus - PropertyChanges { - target: textFieldBackground - color: StudioTheme.Values.themeControlBackgroundHover - border.color: StudioTheme.Values.themeControlOutline - } - - PropertyChanges { - target: searchFilterText - placeholderTextColor: StudioTheme.Values.themePlaceholderTextColor - } - }, - State { - name: "edit" - when: searchFilterText.activeFocus - PropertyChanges { - target: textFieldBackground - color: StudioTheme.Values.themeControlBackgroundInteraction - border.color: StudioTheme.Values.themeControlOutlineInteraction - } - PropertyChanges { - target: searchFilterText - placeholderTextColor: StudioTheme.Values.themePlaceholderTextColorInteraction - } - } - ] - } -} diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/qmldir b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/qmldir index 5a18d24846..f145b09877 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/qmldir +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/qmldir @@ -61,7 +61,6 @@ RoundedPanel 2.0 RoundedPanel.qml ScrollView 2.0 ScrollView.qml SecondColumnLayout 2.0 SecondColumnLayout.qml Section 2.0 Section.qml -SearchBox 2.0 SearchBox.qml SectionLayout 2.0 SectionLayout.qml Spacer 2.0 Spacer.qml SpinBox 2.0 SpinBox.qml diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/SearchBox.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/SearchBox.qml new file mode 100644 index 0000000000..3b4f785faa --- /dev/null +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/SearchBox.qml @@ -0,0 +1,168 @@ +/**************************************************************************** +** +** Copyright (C) 2022 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +import QtQuick 2.15 +import QtQuick.Controls 2.15 +import QtQuickDesignerTheme 1.0 +import StudioTheme 1.0 as StudioTheme + +Item { + id: root + + property alias text: searchFilterText.text + + signal searchChanged(string searchText); + + function clear() + { + searchFilterText.text = ""; + } + + function isEmpty() + { + return searchFilterText.text === ""; + } + + implicitWidth: searchFilterText.width + implicitHeight: searchFilterText.height + + TextField { + id: searchFilterText + + placeholderText: qsTr("Search") + placeholderTextColor: StudioTheme.Values.themePlaceholderTextColor + color: StudioTheme.Values.themeTextColor + selectionColor: StudioTheme.Values.themeTextSelectionColor + selectedTextColor: StudioTheme.Values.themeTextSelectedTextColor + background: Rectangle { + id: textFieldBackground + color: StudioTheme.Values.themeControlBackground + border.color: StudioTheme.Values.themeControlOutline + border.width: StudioTheme.Values.border + + Behavior on color { + ColorAnimation { + duration: StudioTheme.Values.hoverDuration + easing.type: StudioTheme.Values.hoverEasing + } + } + } + + height: StudioTheme.Values.defaultControlHeight + + leftPadding: 32 + rightPadding: 30 + topPadding: 6 + anchors.left: parent.left + anchors.right: parent.right + anchors.leftMargin: 5 + anchors.rightMargin: 5 + selectByMouse: true + hoverEnabled: true + + onTextChanged: root.searchChanged(text) + + Label { + text: StudioTheme.Constants.search + font.family: StudioTheme.Constants.iconFont.family + font.pixelSize: StudioTheme.Values.myIconFontSize + anchors.left: parent.left + anchors.leftMargin: 7 + anchors.verticalCenter: parent.verticalCenter + color: StudioTheme.Values.themeIconColor + } + + Rectangle { // x button + width: 16 + height: 15 + anchors.right: parent.right + anchors.rightMargin: 5 + anchors.verticalCenter: parent.verticalCenter + visible: searchFilterText.text !== "" + color: xMouseArea.containsMouse ? StudioTheme.Values.themePanelBackground + : "transparent" + + Label { + text: StudioTheme.Constants.closeCross + font.family: StudioTheme.Constants.iconFont.family + font.pixelSize: StudioTheme.Values.myIconFontSize + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + anchors.centerIn: parent + color: StudioTheme.Values.themeIconColor + } + + MouseArea { + id: xMouseArea + hoverEnabled: true + anchors.fill: parent + onClicked: searchFilterText.text = "" + } + } + + states: [ + State { + name: "default" + when: !searchFilterText.hovered && !searchFilterText.activeFocus + PropertyChanges { + target: textFieldBackground + color: StudioTheme.Values.themeControlBackground + border.color: StudioTheme.Values.themeControlOutline + } + PropertyChanges { + target: searchFilterText + placeholderTextColor: StudioTheme.Values.themePlaceholderTextColor + } + }, + State { + name: "hover" + when: root.enabled && searchFilterText.hovered && !searchFilterText.activeFocus + PropertyChanges { + target: textFieldBackground + color: StudioTheme.Values.themeControlBackgroundHover + border.color: StudioTheme.Values.themeControlOutline + } + + PropertyChanges { + target: searchFilterText + placeholderTextColor: StudioTheme.Values.themePlaceholderTextColor + } + }, + State { + name: "edit" + when: searchFilterText.activeFocus + PropertyChanges { + target: textFieldBackground + color: StudioTheme.Values.themeControlBackgroundInteraction + border.color: StudioTheme.Values.themeControlOutlineInteraction + } + PropertyChanges { + target: searchFilterText + placeholderTextColor: StudioTheme.Values.themePlaceholderTextColorInteraction + } + } + ] + } +} diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/qmldir b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/qmldir index 878b2307c3..fea940d878 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/qmldir +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/qmldir @@ -30,6 +30,7 @@ RealSpinBoxIndicator 1.0 RealSpinBoxIndicator.qml RealSpinBoxInput 1.0 RealSpinBoxInput.qml ScrollBar 1.0 ScrollBar.qml ScrollView 1.0 ScrollView.qml +SearchBox 1.0 SearchBox.qml SecondColumnLayout 1.0 SecondColumnLayout.qml Section 1.0 Section.qml SectionLabel 1.0 SectionLabel.qml -- cgit v1.2.3