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 {
|
StudioControls.MenuSeparator {
|
||||||
visible: itemsView.currentCategory === null
|
visible: itemsView.currentCategory === null && !rootView.searchActive
|
||||||
height: StudioTheme.Values.border
|
height: visible ? StudioTheme.Values.border : 0
|
||||||
}
|
}
|
||||||
|
|
||||||
StudioControls.MenuItem {
|
StudioControls.MenuItem {
|
||||||
text: qsTr("Expand All")
|
text: qsTr("Expand All")
|
||||||
visible: itemsView.currentCategory === null
|
visible: itemsView.currentCategory === null && !rootView.searchActive
|
||||||
height: visible ? implicitHeight : 0
|
height: visible ? implicitHeight : 0
|
||||||
onTriggered: itemLibraryModel.expandAll()
|
onTriggered: itemLibraryModel.expandAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
StudioControls.MenuItem {
|
StudioControls.MenuItem {
|
||||||
text: qsTr("Collapse All")
|
text: qsTr("Collapse All")
|
||||||
visible: itemsView.currentCategory === null
|
visible: itemsView.currentCategory === null && !rootView.searchActive
|
||||||
height: visible ? implicitHeight : 0
|
height: visible ? implicitHeight : 0
|
||||||
onTriggered: itemLibraryModel.collapseAll()
|
onTriggered: itemLibraryModel.collapseAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
StudioControls.MenuSeparator {
|
StudioControls.MenuSeparator {
|
||||||
visible: itemsView.currentCategory === null
|
visible: itemsView.currentCategory === null && !rootView.searchActive
|
||||||
height: StudioTheme.Values.border
|
height: visible ? StudioTheme.Values.border : 0
|
||||||
}
|
}
|
||||||
|
|
||||||
StudioControls.MenuItem {
|
StudioControls.MenuItem {
|
||||||
@@ -154,18 +154,22 @@ Item {
|
|||||||
|
|
||||||
StudioControls.MenuSeparator {
|
StudioControls.MenuSeparator {
|
||||||
visible: itemsView.currentCategory
|
visible: itemsView.currentCategory
|
||||||
height: StudioTheme.Values.border
|
height: visible ? StudioTheme.Values.border : 0
|
||||||
}
|
}
|
||||||
|
|
||||||
StudioControls.MenuItem {
|
StudioControls.MenuItem {
|
||||||
text: qsTr("Show Module Hidden Categories")
|
text: qsTr("Show Module Hidden Categories")
|
||||||
|
visible: !rootView.searchActive
|
||||||
enabled: itemsView.currentImport && !itemsView.currentImport.allCategoriesVisible
|
enabled: itemsView.currentImport && !itemsView.currentImport.allCategoriesVisible
|
||||||
|
height: visible ? implicitHeight : 0
|
||||||
onTriggered: itemLibraryModel.showImportHiddenCategories(itemsView.currentImport.importUrl)
|
onTriggered: itemLibraryModel.showImportHiddenCategories(itemsView.currentImport.importUrl)
|
||||||
}
|
}
|
||||||
|
|
||||||
StudioControls.MenuItem {
|
StudioControls.MenuItem {
|
||||||
text: qsTr("Show All Hidden Categories")
|
text: qsTr("Show All Hidden Categories")
|
||||||
|
visible: !rootView.searchActive
|
||||||
enabled: itemLibraryModel.isAnyCategoryHidden
|
enabled: itemLibraryModel.isAnyCategoryHidden
|
||||||
|
height: visible ? implicitHeight : 0
|
||||||
onTriggered: itemLibraryModel.showAllHiddenCategories()
|
onTriggered: itemLibraryModel.showAllHiddenCategories()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -230,8 +234,7 @@ Item {
|
|||||||
itemsView.importToRemove = importRemovable ? importUrl : ""
|
itemsView.importToRemove = importRemovable ? importUrl : ""
|
||||||
itemsView.currentImport = model
|
itemsView.currentImport = model
|
||||||
itemsView.currentCategory = null
|
itemsView.currentCategory = null
|
||||||
if (!rootView.isSearchActive())
|
moduleContextMenu.popup()
|
||||||
moduleContextMenu.popup()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
@@ -257,10 +260,11 @@ Item {
|
|||||||
onToggleExpand: categoryExpanded = !categoryExpanded
|
onToggleExpand: categoryExpanded = !categoryExpanded
|
||||||
useDefaulContextMenu: false
|
useDefaulContextMenu: false
|
||||||
onShowContextMenu: {
|
onShowContextMenu: {
|
||||||
itemsView.currentCategory = model
|
if (!rootView.searchActive) {
|
||||||
itemsView.currentImport = parent.currentImportModel
|
itemsView.currentCategory = model
|
||||||
if (!rootView.isSearchActive())
|
itemsView.currentImport = parent.currentImportModel
|
||||||
moduleContextMenu.popup()
|
moduleContextMenu.popup()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Grid {
|
Grid {
|
||||||
@@ -344,8 +348,7 @@ Item {
|
|||||||
itemsView.importToRemove = importRemovable ? importUrl : ""
|
itemsView.importToRemove = importRemovable ? importUrl : ""
|
||||||
itemsView.currentImport = model
|
itemsView.currentImport = model
|
||||||
itemsView.currentCategory = null
|
itemsView.currentCategory = null
|
||||||
if (!rootView.isSearchActive())
|
moduleContextMenu.popup()
|
||||||
moduleContextMenu.popup()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
@@ -385,7 +388,9 @@ Item {
|
|||||||
onClicked: (mouse) => {
|
onClicked: (mouse) => {
|
||||||
itemLibraryModel.selectImportCategory(parent.parent.currentImportModel.importUrl, model.index)
|
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.currentCategory = model
|
||||||
itemsView.currentImport = parent.parent.currentImportModel
|
itemsView.currentImport = parent.parent.currentImportModel
|
||||||
moduleContextMenu.popup()
|
moduleContextMenu.popup()
|
||||||
|
|||||||
@@ -334,7 +334,10 @@ QList<QToolButton *> ItemLibraryWidget::createToolBarWidgets()
|
|||||||
|
|
||||||
void ItemLibraryWidget::handleSearchfilterChanged(const QString &filterText)
|
void ItemLibraryWidget::handleSearchfilterChanged(const QString &filterText)
|
||||||
{
|
{
|
||||||
m_filterText = filterText;
|
if (filterText != m_filterText) {
|
||||||
|
m_filterText = filterText;
|
||||||
|
emit searchActiveChanged();
|
||||||
|
}
|
||||||
|
|
||||||
updateSearch();
|
updateSearch();
|
||||||
}
|
}
|
||||||
@@ -366,11 +369,6 @@ void ItemLibraryWidget::handleAddImport(int index)
|
|||||||
updateSearch();
|
updateSearch();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ItemLibraryWidget::isSearchActive() const
|
|
||||||
{
|
|
||||||
return !m_filterText.isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ItemLibraryWidget::handleFilesDrop(const QStringList &filesPaths)
|
void ItemLibraryWidget::handleFilesDrop(const QStringList &filesPaths)
|
||||||
{
|
{
|
||||||
addResources(filesPaths);
|
addResources(filesPaths);
|
||||||
@@ -568,6 +566,11 @@ bool ItemLibraryWidget::subCompEditMode() const
|
|||||||
return m_subCompEditMode;
|
return m_subCompEditMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ItemLibraryWidget::searchActive() const
|
||||||
|
{
|
||||||
|
return !m_filterText.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
void ItemLibraryWidget::setFlowMode(bool b)
|
void ItemLibraryWidget::setFlowMode(bool b)
|
||||||
{
|
{
|
||||||
m_itemLibraryModel->setFlowMode(b);
|
m_itemLibraryModel->setFlowMode(b);
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ class ItemLibraryWidget : public QFrame
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
Q_PROPERTY(bool subCompEditMode READ subCompEditMode NOTIFY subCompEditModeChanged)
|
Q_PROPERTY(bool subCompEditMode READ subCompEditMode NOTIFY subCompEditModeChanged)
|
||||||
|
Q_PROPERTY(bool searchActive READ searchActive NOTIFY searchActiveChanged)
|
||||||
|
|
||||||
ItemLibraryWidget(AsynchronousImageCache &imageCache,
|
ItemLibraryWidget(AsynchronousImageCache &imageCache,
|
||||||
AsynchronousImageCache &asynchronousFontImageCache,
|
AsynchronousImageCache &asynchronousFontImageCache,
|
||||||
@@ -97,6 +98,7 @@ public:
|
|||||||
inline static bool isHorizontalLayout = false;
|
inline static bool isHorizontalLayout = false;
|
||||||
|
|
||||||
bool subCompEditMode() const;
|
bool subCompEditMode() const;
|
||||||
|
bool searchActive() const;
|
||||||
|
|
||||||
Q_INVOKABLE void startDragAndDrop(const QVariant &itemLibEntry, const QPointF &mousePos);
|
Q_INVOKABLE void startDragAndDrop(const QVariant &itemLibEntry, const QPointF &mousePos);
|
||||||
Q_INVOKABLE void startDragAsset(const QStringList &assetPaths, 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 handleAddAsset();
|
||||||
Q_INVOKABLE void handleSearchfilterChanged(const QString &filterText);
|
Q_INVOKABLE void handleSearchfilterChanged(const QString &filterText);
|
||||||
Q_INVOKABLE void handleAddImport(int index);
|
Q_INVOKABLE void handleAddImport(int index);
|
||||||
Q_INVOKABLE bool isSearchActive() const;
|
|
||||||
Q_INVOKABLE void handleFilesDrop(const QStringList &filesPaths);
|
Q_INVOKABLE void handleFilesDrop(const QStringList &filesPaths);
|
||||||
Q_INVOKABLE QSet<QString> supportedDropSuffixes();
|
Q_INVOKABLE QSet<QString> supportedDropSuffixes();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void itemActivated(const QString &itemName);
|
void itemActivated(const QString &itemName);
|
||||||
void subCompEditModeChanged();
|
void subCompEditModeChanged();
|
||||||
|
void searchActiveChanged();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||||
|
|||||||
Reference in New Issue
Block a user