forked from qt-creator/qt-creator
QmlDesigner: Enable component library context menu while searching
The only item visible in the menu is remove module, as hiding categories during search is not supported. Fixes: QDS-5687 Change-Id: I8f5bb3f1b27eb37ae32d72b93c6ce2156dfa8eb7 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user