QmlDesigner: Move designer action to the center of the tool bar

Change-Id: I7d6b38ea31ebefe0c01acd9360271fc5ba062ffe
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Thomas Hartmann
2020-04-30 17:45:48 +02:00
committed by Tim Jenssen
parent 8a59bf19fe
commit 1549f5818c
2 changed files with 14 additions and 0 deletions

View File

@@ -1212,6 +1212,10 @@ void DesignerActionManager::addTransitionEffectAction(const TypeName &typeName)
DesignerActionToolBar::DesignerActionToolBar(QWidget *parentWidget) : Utils::StyledBar(parentWidget), DesignerActionToolBar::DesignerActionToolBar(QWidget *parentWidget) : Utils::StyledBar(parentWidget),
m_toolBar(new QToolBar("ActionToolBar", this)) m_toolBar(new QToolBar("ActionToolBar", this))
{ {
QWidget* empty = new QWidget();
empty->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
m_toolBar->addWidget(empty);
m_toolBar->setContentsMargins(0, 0, 0, 0); m_toolBar->setContentsMargins(0, 0, 0, 0);
m_toolBar->setFloatable(true); m_toolBar->setFloatable(true);
m_toolBar->setMovable(true); m_toolBar->setMovable(true);

View File

@@ -212,6 +212,13 @@ void DesignModeWidget::disableWidgets()
m_isDisabled = true; m_isDisabled = true;
} }
static void addSpacerToToolBar(QToolBar *toolBar)
{
QWidget* empty = new QWidget();
empty->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
toolBar->addWidget(empty);
}
void DesignModeWidget::setup() void DesignModeWidget::setup()
{ {
auto &actionManager = viewManager().designerActionManager(); auto &actionManager = viewManager().designerActionManager();
@@ -366,6 +373,7 @@ void DesignModeWidget::setup()
// Create toolbars // Create toolbars
auto toolBar = new QToolBar(); auto toolBar = new QToolBar();
toolBar->addAction(viewManager().componentViewAction()); toolBar->addAction(viewManager().componentViewAction());
toolBar->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); toolBar->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
DesignerActionToolBar *designerToolBar = QmlDesignerPlugin::instance()->viewManager().designerActionManager().createToolBar(m_toolBar); DesignerActionToolBar *designerToolBar = QmlDesignerPlugin::instance()->viewManager().designerActionManager().createToolBar(m_toolBar);
@@ -407,6 +415,8 @@ void DesignModeWidget::setup()
} }
}); });
addSpacerToToolBar(toolBar);
auto workspaceComboBox = new QComboBox(); auto workspaceComboBox = new QComboBox();
workspaceComboBox->setMinimumWidth(120); workspaceComboBox->setMinimumWidth(120);
workspaceComboBox->setToolTip(tr("Switch the active workspace.")); workspaceComboBox->setToolTip(tr("Switch the active workspace."));