Only fix simple search height if there are no other widgets in the dock area (#13005)

This commit is contained in:
Juergen Spitzmueller 2024-01-13 11:58:35 +01:00
parent 8899e4d6cc
commit 6f4054222c
4 changed files with 52 additions and 8 deletions

View File

@ -31,6 +31,9 @@ DockView::DockView(GuiView & parent, QString const & name,
hide();
connect(&parent, SIGNAL(bufferViewChanged()),
this, SLOT(onBufferViewChanged()));
connect(this, SIGNAL(visibilityChanged(bool)),
&parent, SLOT(onDockWidgetVisibilityChanged()));
// Make dock widgets sub windows to prevent focusNextPrevChild
// (Tab key) switching to the parent rather than to the next

View File

@ -67,9 +67,6 @@ GuiSearchWidget::GuiSearchWidget(QWidget * parent, GuiView & view)
{
setupUi(this);
// fix height to minimum
setFixedHeight(sizeHint().height());
// align items in grid on top
gridLayout->setAlignment(Qt::AlignTop);
@ -126,6 +123,9 @@ GuiSearchWidget::GuiSearchWidget(QWidget * parent, GuiView & view)
replacePB->setEnabled(false);
replacePrevPB->setEnabled(false);
replaceallPB->setEnabled(false);
connect(&view_, SIGNAL(dockWidgetVisibilityChanged()),
this, SLOT(onDockWidgetVisibilityChanged()));
}
@ -568,6 +568,25 @@ void GuiSearchWidget::restoreSession(QString const & session_key)
}
bool GuiSearchWidget::hasCoWidgets(QDockWidget * dw)
{
int res = 0;
QList<QDockWidget *> dockWidgets = view_.findChildren<QDockWidget *>();
for (int i = 0; i < dockWidgets.size(); ++i) {
if (dockWidgets.at(i)->isVisible()
&& view_.dockWidgetArea(dockWidgets.at(i)) == view_.dockWidgetArea(dw))
++res;
}
return res > 1;
}
void GuiSearchWidget::onDockWidgetVisibilityChanged()
{
Q_EMIT needSizeUpdate();
}
GuiSearch::GuiSearch(GuiView & parent, Qt::DockWidgetArea area, Qt::WindowFlags flags)
: DockView(parent, "findreplace", qt_("Search and Replace"), area, flags),
widget_(new GuiSearchWidget(this, parent))
@ -661,6 +680,20 @@ void GuiSearch::updateTitle()
void GuiSearch::updateSize()
{
// This can be triggered before the search widget is visible
// Nothing to do in that case
if (!widget_->isVisible())
return;
// if we have more than this widget in the current dock
// we do not fix the size as other widgets might want to
// remain resizable
if (widget_->hasCoWidgets(this)) {
widget_->setMaximumHeight(QWIDGETSIZE_MAX);
widget_->setMinimumHeight(0);
setMaximumHeight(QWIDGETSIZE_MAX);
setMinimumHeight(0);
} else {
widget_->setFixedHeight(widget_->sizeHint().height());
if (widget_->isMinimized())
setFixedHeight(widget_->sizeHint().height());
@ -669,6 +702,7 @@ void GuiSearch::updateSize()
setMaximumHeight(QWIDGETSIZE_MAX);
setMinimumHeight(0);
}
}
update();
}

View File

@ -43,6 +43,8 @@ public:
bool initialiseParams(std::string const &);
///
bool isMinimized() { return minimized_; }
///
bool hasCoWidgets(QDockWidget * dw);
private Q_SLOTS:
void findChanged();
@ -59,6 +61,7 @@ private Q_SLOTS:
void immediateActTriggered();
void immediateClicked();
void wrapActTriggered();
void onDockWidgetVisibilityChanged();
Q_SIGNALS:
void needTitleBarUpdate() const;
void needSizeUpdate() const;

View File

@ -232,6 +232,8 @@ Q_SIGNALS:
void scriptKilled();
/// emitted when track changes status toggled
void changeTrackingToggled(bool);
///
void dockWidgetVisibilityChanged();
public Q_SLOTS:
///
@ -245,6 +247,8 @@ public Q_SLOTS:
void updateWindowTitle(GuiWorkArea * wa);
///
void disableShellEscape();
///
void onDockWidgetVisibilityChanged() { Q_EMIT dockWidgetVisibilityChanged(); }
private Q_SLOTS:
///