forked from qt-creator/qt-creator
ADS: Set default minimum size on empty dock widget
* Set a default minimum size on empty dock widgets. Dock widgets are empty if their content minimum size isEmpty (width or height <= 0) * Replace 0 with nullptr as return value * Fix some code formatting Task-number: QDS-11255 Change-Id: Ifa7320fd57e73367f71087232dedd939d19ae490 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io> Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io>
This commit is contained in:
committed by
Tim Jenssen
parent
ccc9010d26
commit
f2eee58e00
@@ -161,8 +161,8 @@ bool isSideBarArea(DockWidgetArea area);
|
||||
|
||||
/**
|
||||
* Searches for the parent widget of the given type. Returns the parent widget of the given
|
||||
* widget or 0 if the widget is not child of any widget of type T.
|
||||
* It is not safe to use this function in in DockWidget because only the current dock widget has a
|
||||
* widget or nullptr if the widget is not child of any widget of type T.
|
||||
* It is not safe to use this function in DockWidget, because only the current dock widget has a
|
||||
* parent. All dock widgets that are not the current dock widget in a dock area have no parent.
|
||||
*/
|
||||
template<class T>
|
||||
@@ -171,12 +171,12 @@ T findParent(const QWidget *widget)
|
||||
QWidget *parentWidget = widget->parentWidget();
|
||||
while (parentWidget) {
|
||||
T parentImpl = qobject_cast<T>(parentWidget);
|
||||
if (parentImpl) {
|
||||
if (parentImpl)
|
||||
return parentImpl;
|
||||
}
|
||||
|
||||
parentWidget = parentWidget->parentWidget();
|
||||
}
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -50,9 +50,8 @@ bool DockSplitter::hasVisibleContent() const
|
||||
{
|
||||
// TODO Cache or precalculate this to speed up
|
||||
for (int i = 0; i < count(); ++i) {
|
||||
if (!widget(i)->isHidden()) {
|
||||
if (!widget(i)->isHidden())
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@@ -70,6 +70,27 @@ static void hideToolButtons(QList<QToolButton*> &buttons)
|
||||
button->hide();
|
||||
}
|
||||
|
||||
static void ensureMinimumSize(QWidget *widget)
|
||||
{
|
||||
if (widget->minimumSize().isEmpty())
|
||||
widget->setMinimumSize(widget->minimumSize().expandedTo(QSize(60, 60)));
|
||||
}
|
||||
|
||||
static ADS::DockWidget *createDockWidget(QWidget *widget,
|
||||
const QString &uniqueId,
|
||||
const QString &title,
|
||||
ADS::DockWidget::eMinimumSizeHintMode minimumSizeHintMode)
|
||||
{
|
||||
ADS::DockWidget *dockWidget = new ADS::DockWidget(uniqueId);
|
||||
dockWidget->setWidget(widget, ADS::DockWidget::ForceNoScrollArea);
|
||||
dockWidget->setWindowTitle(title);
|
||||
dockWidget->setMinimumSizeHintMode(minimumSizeHintMode);
|
||||
|
||||
widget->setObjectName(uniqueId); // Set unique id as object name
|
||||
|
||||
return dockWidget;
|
||||
}
|
||||
|
||||
namespace QmlDesigner {
|
||||
namespace Internal {
|
||||
|
||||
@@ -308,15 +329,10 @@ void DesignModeWidget::setup()
|
||||
sheet += "QLabel { background-color: creatorTheme.DSsectionHeadBackground; }";
|
||||
navigationView.widget->setStyleSheet(Theme::replaceCssColors(QString::fromUtf8(sheet)));
|
||||
|
||||
// Create DockWidget
|
||||
ADS::DockWidget *dockWidget = new ADS::DockWidget(uniqueId);
|
||||
dockWidget->setWidget(navigationView.widget, ADS::DockWidget::ForceNoScrollArea);
|
||||
dockWidget->setWindowTitle(title);
|
||||
dockWidget->setMinimumSizeHintMode(m_minimumSizeHintMode);
|
||||
m_dockManager->addDockWidget(ADS::NoDockWidgetArea, dockWidget);
|
||||
ensureMinimumSize(navigationView.widget);
|
||||
|
||||
// Set unique id as object name
|
||||
navigationView.widget->setObjectName(uniqueId);
|
||||
auto dockWidget = createDockWidget(navigationView.widget, uniqueId, title, m_minimumSizeHintMode);
|
||||
m_dockManager->addDockWidget(ADS::NoDockWidgetArea, dockWidget);
|
||||
|
||||
// Create menu action
|
||||
auto command = Core::ActionManager::registerAction(dockWidget->toggleViewAction(),
|
||||
@@ -328,19 +344,17 @@ void DesignModeWidget::setup()
|
||||
|
||||
// Afterwards get all the other widgets
|
||||
for (const WidgetInfo &widgetInfo : viewManager().widgetInfos()) {
|
||||
// Create DockWidget
|
||||
ADS::DockWidget *dockWidget = new ADS::DockWidget(widgetInfo.uniqueId);
|
||||
dockWidget->setWidget(widgetInfo.widget, ADS::DockWidget::ForceNoScrollArea);
|
||||
dockWidget->setWindowTitle(widgetInfo.tabName);
|
||||
dockWidget->setMinimumSizeHintMode(m_minimumSizeHintMode);
|
||||
ensureMinimumSize(widgetInfo.widget);
|
||||
|
||||
auto dockWidget = createDockWidget(widgetInfo.widget,
|
||||
widgetInfo.uniqueId,
|
||||
widgetInfo.tabName,
|
||||
m_minimumSizeHintMode);
|
||||
m_dockManager->addDockWidget(ADS::NoDockWidgetArea, dockWidget);
|
||||
|
||||
// Add to view widgets
|
||||
m_viewWidgets.append(widgetInfo.widget);
|
||||
|
||||
// Set unique id as object name
|
||||
widgetInfo.widget->setObjectName(widgetInfo.uniqueId);
|
||||
|
||||
// Create menu action
|
||||
auto command = Core::ActionManager::registerAction(dockWidget->toggleViewAction(),
|
||||
actionToggle.withSuffix(
|
||||
@@ -354,14 +368,14 @@ void DesignModeWidget::setup()
|
||||
{
|
||||
const QString uniqueId = "OutputPane";
|
||||
auto outputPanePlaceholder = new Core::OutputPanePlaceHolder(Core::Constants::MODE_DESIGN);
|
||||
m_outputPaneDockWidget = new ADS::DockWidget(uniqueId);
|
||||
m_outputPaneDockWidget->setWidget(outputPanePlaceholder, ADS::DockWidget::ForceNoScrollArea);
|
||||
m_outputPaneDockWidget->setWindowTitle(tr("Output"));
|
||||
m_outputPaneDockWidget->setMinimumSizeHintMode(m_minimumSizeHintMode);
|
||||
m_dockManager->addDockWidget(ADS::NoDockWidgetArea, m_outputPaneDockWidget);
|
||||
|
||||
// Set unique id as object name
|
||||
outputPanePlaceholder->setObjectName(uniqueId);
|
||||
ensureMinimumSize(outputPanePlaceholder);
|
||||
|
||||
m_outputPaneDockWidget = createDockWidget(outputPanePlaceholder,
|
||||
uniqueId,
|
||||
tr("Output"),
|
||||
m_minimumSizeHintMode);
|
||||
m_dockManager->addDockWidget(ADS::NoDockWidgetArea, m_outputPaneDockWidget);
|
||||
|
||||
// Create menu action
|
||||
auto command = Core::ActionManager::registerAction(m_outputPaneDockWidget->toggleViewAction(),
|
||||
|
Reference in New Issue
Block a user