QmlDesigner: Add back toolbar to NavigatorView

Change-Id: I9e8c0372a85ec40b795f8d8fc68bb22959f73513
Reviewed-by: Aleksei German <aleksei.german@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Thomas Hartmann
2020-03-09 18:37:17 +01:00
parent af8e153077
commit 97112f3e4d
2 changed files with 22 additions and 2 deletions

View File

@@ -61,6 +61,11 @@ NavigatorWidget::NavigatorWidget(NavigatorView *view)
layout->setSpacing(0);
layout->setContentsMargins(0, 0, 0, 0);
QWidget *toolBar = createToolBar();
toolBar->setParent(this);
layout->addWidget(toolBar);
layout->addWidget(m_treeView);
setLayout(layout);
@@ -124,8 +129,10 @@ QList<QToolButton *> NavigatorWidget::createToolBarWidgets()
auto filterMenu = new QMenu(filter);
auto objectAction = new QAction(tr("Show only visible items."), nullptr);
objectAction->setCheckable(true);
objectAction->setChecked(
DesignerSettings::getValue(DesignerSettingsKey::NAVIGATOR_SHOW_ONLY_VISIBLE_ITEMS).toBool());
bool filterFlag = DesignerSettings::getValue(DesignerSettingsKey::NAVIGATOR_SHOW_ONLY_VISIBLE_ITEMS).toBool();
objectAction->setChecked(filterFlag);
connect(objectAction, &QAction::toggled, this, &NavigatorWidget::filterToggled);
filterMenu->addAction(objectAction);
filter->setMenu(filterMenu);
@@ -134,6 +141,17 @@ QList<QToolButton *> NavigatorWidget::createToolBarWidgets()
return buttons;
}
QToolBar *NavigatorWidget::createToolBar()
{
const QList<QToolButton*> buttons = createToolBarWidgets();
auto toolBar = new QToolBar();
for (auto toolButton : buttons)
toolBar->addWidget(toolButton);
return toolBar;
}
void NavigatorWidget::contextHelp(const Core::IContext::HelpCallback &callback) const
{
if (navigatorView())

View File

@@ -32,6 +32,7 @@
#include "navigatortreeview.h"
QT_FORWARD_DECLARE_CLASS(QToolBar)
QT_FORWARD_DECLARE_CLASS(QToolButton)
QT_FORWARD_DECLARE_CLASS(QAbstractItemModel)
@@ -48,6 +49,7 @@ public:
void setTreeModel(QAbstractItemModel *model);
QTreeView *treeView() const;
QList<QToolButton *> createToolBarWidgets();
QToolBar *createToolBar();
void contextHelp(const Core::IContext::HelpCallback &callback) const;
void disableNavigator();