Skip to content

Commit

Permalink
Gui: fixes FreeCAD#10724: TaskView gets truncated
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer authored and chennes committed Sep 22, 2023
1 parent 5743ce4 commit fdc44d5
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
31 changes: 31 additions & 0 deletions src/Gui/TaskView/TaskView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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<QWidget*>& cont = dlg->getDialogContent();

Expand Down Expand Up @@ -516,6 +542,7 @@ void TaskView::showDialog(TaskDialog *dlg)
ActiveDialog->open();

getMainWindow()->updateActions();
triggerMinimumSizeHint();
}

void TaskView::removeDialog()
Expand Down Expand Up @@ -554,6 +581,8 @@ void TaskView::removeDialog()
remove->emitDestructionSignal();
delete remove;
}

triggerMinimumSizeHint();
}

void TaskView::updateWatcher()
Expand Down Expand Up @@ -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<TaskWatcher*> &Watcher)
Expand Down
10 changes: 8 additions & 2 deletions src/Gui/TaskView/TaskView.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit fdc44d5

Please sign in to comment.