diff options
3 files changed, 32 insertions, 22 deletions
diff --git a/share/qtcreator/qmldesigner/itemLibraryQmlSources/ItemsView.qml b/share/qtcreator/qmldesigner/itemLibraryQmlSources/ItemsView.qml index f37a0e05d0..6f7fbc454f 100644 --- a/share/qtcreator/qmldesigner/itemLibraryQmlSources/ItemsView.qml +++ b/share/qtcreator/qmldesigner/itemLibraryQmlSources/ItemsView.qml @@ -121,27 +121,27 @@ Item { } StudioControls.MenuSeparator { - visible: itemsView.currentCategory === null - height: StudioTheme.Values.border + visible: itemsView.currentCategory === null && !rootView.searchActive + height: visible ? StudioTheme.Values.border : 0 } StudioControls.MenuItem { text: qsTr("Expand All") - visible: itemsView.currentCategory === null + visible: itemsView.currentCategory === null && !rootView.searchActive height: visible ? implicitHeight : 0 onTriggered: itemLibraryModel.expandAll() } StudioControls.MenuItem { text: qsTr("Collapse All") - visible: itemsView.currentCategory === null + visible: itemsView.currentCategory === null && !rootView.searchActive height: visible ? implicitHeight : 0 onTriggered: itemLibraryModel.collapseAll() } StudioControls.MenuSeparator { - visible: itemsView.currentCategory === null - height: StudioTheme.Values.border + visible: itemsView.currentCategory === null && !rootView.searchActive + height: visible ? StudioTheme.Values.border : 0 } StudioControls.MenuItem { @@ -154,18 +154,22 @@ Item { StudioControls.MenuSeparator { visible: itemsView.currentCategory - height: StudioTheme.Values.border + height: visible ? StudioTheme.Values.border : 0 } StudioControls.MenuItem { text: qsTr("Show Module Hidden Categories") + visible: !rootView.searchActive enabled: itemsView.currentImport && !itemsView.currentImport.allCategoriesVisible + height: visible ? implicitHeight : 0 onTriggered: itemLibraryModel.showImportHiddenCategories(itemsView.currentImport.importUrl) } StudioControls.MenuItem { text: qsTr("Show All Hidden Categories") + visible: !rootView.searchActive enabled: itemLibraryModel.isAnyCategoryHidden + height: visible ? implicitHeight : 0 onTriggered: itemLibraryModel.showAllHiddenCategories() } } @@ -230,8 +234,7 @@ Item { itemsView.importToRemove = importRemovable ? importUrl : "" itemsView.currentImport = model itemsView.currentCategory = null - if (!rootView.isSearchActive()) - moduleContextMenu.popup() + moduleContextMenu.popup() } Column { @@ -257,10 +260,11 @@ Item { onToggleExpand: categoryExpanded = !categoryExpanded useDefaulContextMenu: false onShowContextMenu: { - itemsView.currentCategory = model - itemsView.currentImport = parent.currentImportModel - if (!rootView.isSearchActive()) + if (!rootView.searchActive) { + itemsView.currentCategory = model + itemsView.currentImport = parent.currentImportModel moduleContextMenu.popup() + } } Grid { @@ -344,8 +348,7 @@ Item { itemsView.importToRemove = importRemovable ? importUrl : "" itemsView.currentImport = model itemsView.currentCategory = null - if (!rootView.isSearchActive()) - moduleContextMenu.popup() + moduleContextMenu.popup() } Column { @@ -385,7 +388,9 @@ Item { onClicked: (mouse) => { itemLibraryModel.selectImportCategory(parent.parent.currentImportModel.importUrl, model.index) - if (mouse.button === Qt.RightButton && !rootView.isSearchActive() && categoryModel.rowCount() !== 1) { + if (mouse.button === Qt.RightButton + && categoryModel.rowCount() !== 1 + && !rootView.searchActive) { itemsView.currentCategory = model itemsView.currentImport = parent.parent.currentImportModel moduleContextMenu.popup() diff --git a/src/plugins/qmldesigner/components/itemlibrary/itemlibrarywidget.cpp b/src/plugins/qmldesigner/components/itemlibrary/itemlibrarywidget.cpp index 2bb563ded3..955f04a7ac 100644 --- a/src/plugins/qmldesigner/components/itemlibrary/itemlibrarywidget.cpp +++ b/src/plugins/qmldesigner/components/itemlibrary/itemlibrarywidget.cpp @@ -334,7 +334,10 @@ QList<QToolButton *> ItemLibraryWidget::createToolBarWidgets() void ItemLibraryWidget::handleSearchfilterChanged(const QString &filterText) { - m_filterText = filterText; + if (filterText != m_filterText) { + m_filterText = filterText; + emit searchActiveChanged(); + } updateSearch(); } @@ -366,11 +369,6 @@ void ItemLibraryWidget::handleAddImport(int index) updateSearch(); } -bool ItemLibraryWidget::isSearchActive() const -{ - return !m_filterText.isEmpty(); -} - void ItemLibraryWidget::handleFilesDrop(const QStringList &filesPaths) { addResources(filesPaths); @@ -568,6 +566,11 @@ bool ItemLibraryWidget::subCompEditMode() const return m_subCompEditMode; } +bool ItemLibraryWidget::searchActive() const +{ + return !m_filterText.isEmpty(); +} + void ItemLibraryWidget::setFlowMode(bool b) { m_itemLibraryModel->setFlowMode(b); diff --git a/src/plugins/qmldesigner/components/itemlibrary/itemlibrarywidget.h b/src/plugins/qmldesigner/components/itemlibrary/itemlibrarywidget.h index cd00a18fc2..d67c3df71d 100644 --- a/src/plugins/qmldesigner/components/itemlibrary/itemlibrarywidget.h +++ b/src/plugins/qmldesigner/components/itemlibrary/itemlibrarywidget.h @@ -72,6 +72,7 @@ class ItemLibraryWidget : public QFrame public: Q_PROPERTY(bool subCompEditMode READ subCompEditMode NOTIFY subCompEditModeChanged) + Q_PROPERTY(bool searchActive READ searchActive NOTIFY searchActiveChanged) ItemLibraryWidget(AsynchronousImageCache &imageCache, AsynchronousImageCache &asynchronousFontImageCache, @@ -97,6 +98,7 @@ public: inline static bool isHorizontalLayout = false; bool subCompEditMode() const; + bool searchActive() const; Q_INVOKABLE void startDragAndDrop(const QVariant &itemLibEntry, const QPointF &mousePos); Q_INVOKABLE void startDragAsset(const QStringList &assetPaths, const QPointF &mousePos); @@ -107,13 +109,13 @@ public: Q_INVOKABLE void handleAddAsset(); Q_INVOKABLE void handleSearchfilterChanged(const QString &filterText); Q_INVOKABLE void handleAddImport(int index); - Q_INVOKABLE bool isSearchActive() const; Q_INVOKABLE void handleFilesDrop(const QStringList &filesPaths); Q_INVOKABLE QSet<QString> supportedDropSuffixes(); signals: void itemActivated(const QString &itemName); void subCompEditModeChanged(); + void searchActiveChanged(); protected: bool eventFilter(QObject *obj, QEvent *event) override; |