diff --git a/src/Gui/TaskView/TaskView.cpp b/src/Gui/TaskView/TaskView.cpp index bb14149e8ef6..712df39ee21a 100644 --- a/src/Gui/TaskView/TaskView.cpp +++ b/src/Gui/TaskView/TaskView.cpp @@ -407,6 +407,30 @@ void TaskView::keyPressEvent(QKeyEvent* ke) } } +void TaskView::triggerMinimumSizeHint() +{ + // NOLINTNEXTLINE + QTimer::singleShot(100, this, &TaskView::adjustMinimumSizeHint); +} + +void TaskView::adjustMinimumSizeHint() +{ + QSize ms = minimumSizeHint(); + setMinimumWidth(ms.width()); +} + +QSize TaskView::minimumSizeHint() const +{ + QSize ms = QScrollArea::minimumSizeHint(); + int spacing = 0; + if (QLayout* layout = taskPanel->layout()) { + spacing = 2 * layout->spacing(); + } + + ms.setWidth(taskPanel->minimumSizeHint().width() + spacing); + return ms; +} + void TaskView::slotActiveDocument(const App::Document& doc) { Q_UNUSED(doc); @@ -477,6 +501,7 @@ void TaskView::showDialog(TaskDialog *dlg) ActiveCtrl->buttonBox->setStandardButtons(dlg->getStandardButtons()); TaskDialogAttorney::setButtonBox(dlg, ActiveCtrl->buttonBox); + // clang-format off // make connection to the needed signals connect(ActiveCtrl->buttonBox, &QDialogButtonBox::accepted, this, &TaskView::accept); @@ -486,6 +511,7 @@ void TaskView::showDialog(TaskDialog *dlg) this, &TaskView::helpRequested); connect(ActiveCtrl->buttonBox, &QDialogButtonBox::clicked, this, &TaskView::clicked); + // clang-format on const std::vector& cont = dlg->getDialogContent(); @@ -516,6 +542,7 @@ void TaskView::showDialog(TaskDialog *dlg) ActiveDialog->open(); getMainWindow()->updateActions(); + triggerMinimumSizeHint(); } void TaskView::removeDialog() @@ -554,6 +581,8 @@ void TaskView::removeDialog() remove->emitDestructionSignal(); delete remove; } + + triggerMinimumSizeHint(); } void TaskView::updateWatcher() @@ -591,6 +620,8 @@ void TaskView::updateWatcher() // give it the focus back. if (fwp && fwp->isVisible()) fwp->setFocus(); + + triggerMinimumSizeHint(); } void TaskView::addTaskWatcher(const std::vector &Watcher) diff --git a/src/Gui/TaskView/TaskView.h b/src/Gui/TaskView/TaskView.h index f73a5485d7be..c199b3ea4e76 100644 --- a/src/Gui/TaskView/TaskView.h +++ b/src/Gui/TaskView/TaskView.h @@ -158,15 +158,21 @@ class GuiExport TaskView : public QScrollArea, public Gui::SelectionSingleton::O void clearActionStyle(); void restoreActionStyle(); + QSize minimumSizeHint() const override; + protected Q_SLOTS: void accept(); void reject(); void helpRequested(); void clicked (QAbstractButton * button); +private: + void triggerMinimumSizeHint(); + void adjustMinimumSizeHint(); + protected: - void keyPressEvent(QKeyEvent*) override; - bool event(QEvent*) override; + void keyPressEvent(QKeyEvent* event) override; + bool event(QEvent* event) override; void addTaskWatcher(); void removeTaskWatcher();