aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/designer
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2023-11-16 08:34:02 +0100
committerEike Ziller <eike.ziller@qt.io>2023-11-27 08:32:26 +0000
commit22f5ec4c874fd8664a6a29d31e762f7d5afbd67d (patch)
tree6b8e6e8caf861e0622adbc0a652d03bc230ff743 /src/plugins/designer
parent73ddecd723f81a1b8102afc79f4f91a647c49438 (diff)
Widget Designer: Adapt after dock widget redesign
Before the redesign, the dock widgets didn't have a "tool bar" at the top, so we had the designer tool bar with the document dropdown and form related tool buttons spanning the whole design mode width (to have a continuous styled bar at the top of the window). Now the dock widgets' title widget is a styled bar, so we would have the designer tool bar, and below that the styled bar from the dock widgets, which unnecessarily creates a big blog of styled bars. Instead, move the designer tool bar inside the central form widget. The title bars from the dock widgets complete the top styled bar now. This is also more consistent with Edit mode. Change-Id: I7d322a75a8a34120763b4dd85c44ddf674930e36 Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Diffstat (limited to 'src/plugins/designer')
-rw-r--r--src/plugins/designer/editorwidget.cpp20
-rw-r--r--src/plugins/designer/editorwidget.h8
-rw-r--r--src/plugins/designer/formeditor.cpp19
3 files changed, 29 insertions, 18 deletions
diff --git a/src/plugins/designer/editorwidget.cpp b/src/plugins/designer/editorwidget.cpp
index 664e953b3bc..271bdadbcb1 100644
--- a/src/plugins/designer/editorwidget.cpp
+++ b/src/plugins/designer/editorwidget.cpp
@@ -2,10 +2,15 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "editorwidget.h"
+
#include "formeditor.h"
#include "formeditorstack.h"
+#include "formwindoweditor.h"
+
+#include <utils/layoutbuilder.h>
#include <coreplugin/editormanager/ieditor.h>
+#include <coreplugin/editortoolbar.h>
#include <QDockWidget>
#include <QAbstractItemView>
@@ -17,12 +22,18 @@ namespace Internal {
// ---------- EditorWidget
-EditorWidget::EditorWidget(QWidget *parent) :
- Utils::FancyMainWindow(parent),
- m_stack(new FormEditorStack)
+EditorWidget::EditorWidget(Core::EditorToolBar *toolBar, QWidget *parent)
+ : Utils::FancyMainWindow(parent)
+ , m_stack(new FormEditorStack)
+ , m_toolBar(toolBar)
{
+ using namespace Layouting;
+ QWidget *centralWidget = Layouting::Column{noMargin, spacing(0), m_toolBar, m_stack}.emerge();
+ centralWidget->setMinimumHeight(100);
+ centralWidget->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
+
setObjectName("EditorWidget");
- setCentralWidget(m_stack);
+ setCentralWidget(centralWidget);
setDocumentMode(true);
setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::South);
setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
@@ -79,6 +90,7 @@ void EditorWidget::add(SharedTools::WidgetHost *widgetHost, FormWindowEditor *fo
data.formWindowEditor = formWindowEditor;
data.widgetHost = widgetHost;
m_stack->add(data);
+ m_toolBar->addEditor(formWindowEditor);
}
void EditorWidget::removeFormWindowEditor(Core::IEditor *xmlEditor)
diff --git a/src/plugins/designer/editorwidget.h b/src/plugins/designer/editorwidget.h
index fe1d17bdc12..b367def96f9 100644
--- a/src/plugins/designer/editorwidget.h
+++ b/src/plugins/designer/editorwidget.h
@@ -12,7 +12,10 @@ class QDesignerFormWindowInterface;
QT_END_NAMESPACE
namespace SharedTools { class WidgetHost; }
-namespace Core { class IEditor; }
+namespace Core {
+class EditorToolBar;
+class IEditor;
+} // namespace Core
namespace Designer {
@@ -29,7 +32,7 @@ class EditorWidget : public Utils::FancyMainWindow
Q_OBJECT
public:
- explicit EditorWidget(QWidget *parent = nullptr);
+ explicit EditorWidget(Core::EditorToolBar *toolBar, QWidget *parent = nullptr);
QDockWidget* const* designerDockWidgets() const;
@@ -46,6 +49,7 @@ public:
private:
FormEditorStack *m_stack = nullptr;
QDockWidget *m_designerDockWidgets[Designer::Constants::DesignerSubWindowCount];
+ Core::EditorToolBar *m_toolBar = nullptr;
};
} // namespace Internal
diff --git a/src/plugins/designer/formeditor.cpp b/src/plugins/designer/formeditor.cpp
index cbd405c3d57..1588aa89140 100644
--- a/src/plugins/designer/formeditor.cpp
+++ b/src/plugins/designer/formeditor.cpp
@@ -200,9 +200,6 @@ public:
QWidget *m_modeWidget = nullptr;
EditorWidget *m_editorWidget = nullptr;
- QWidget *m_editorToolBar = nullptr;
- EditorToolBar *m_toolBar = nullptr;
-
QMap<Command *, QAction *> m_commandToDesignerAction;
FormWindowEditorFactory *m_xmlEditorFactory = nullptr;
};
@@ -392,25 +389,24 @@ void FormEditorData::fullInit()
m_editorWidget->removeFormWindowEditor(editor);
});
+ QWidget *editorToolBar = createEditorToolBar();
+ auto toolBar = new EditorToolBar;
+ toolBar->setToolbarCreationFlags(EditorToolBar::FlagsStandalone);
+ toolBar->setNavigationVisible(false);
+ toolBar->addCenterToolBar(editorToolBar);
+
// Nest toolbar and editor widget
- m_editorWidget = new EditorWidget;
+ m_editorWidget = new EditorWidget(toolBar);
QtcSettings *settings = ICore::settings();
settings->beginGroup(settingsGroupC);
m_editorWidget->restoreSettings(settings);
settings->endGroup();
- m_editorToolBar = createEditorToolBar();
- m_toolBar = new EditorToolBar;
- m_toolBar->setToolbarCreationFlags(EditorToolBar::FlagsStandalone);
- m_toolBar->setNavigationVisible(false);
- m_toolBar->addCenterToolBar(m_editorToolBar);
-
m_modeWidget = new QWidget;
m_modeWidget->setObjectName("DesignerModeWidget");
auto layout = new QVBoxLayout(m_modeWidget);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
- layout->addWidget(m_toolBar);
// Avoid mode switch to 'Edit' mode when the application started by
// 'Run' in 'Design' mode emits output.
auto splitter = new MiniSplitter(Qt::Vertical);
@@ -772,7 +768,6 @@ IEditor *FormEditorData::createEditor()
FormWindowEditor *formWindowEditor = m_xmlEditorFactory->create(form);
m_editorWidget->add(widgetHost, formWindowEditor);
- m_toolBar->addEditor(formWindowEditor);
if (formWindowEditor) {
Utils::InfoBarEntry info(Id(Constants::INFO_READ_ONLY),