Gui: Restore previous width when closing task dialog

This fixes #11016
This commit is contained in:
wmayer
2024-05-18 15:59:54 +02:00
committed by Chris Hennes
parent cded7480bf
commit ae2b881477
3 changed files with 49 additions and 2 deletions

View File

@@ -27,6 +27,7 @@
# include <QActionEvent>
# include <QApplication>
# include <QCursor>
# include <QDockWidget>
# include <QLineEdit>
# include <QPointer>
# include <QPushButton>
@@ -558,6 +559,7 @@ void TaskView::showDialog(TaskDialog *dlg)
ActiveDialog->open();
saveCurrentWidth();
getMainWindow()->updateActions();
triggerMinimumSizeHint();
@@ -602,6 +604,7 @@ void TaskView::removeDialog()
delete remove;
}
tryRestoreWidth();
triggerMinimumSizeHint();
}
@@ -713,6 +716,34 @@ void TaskView::addTaskWatcher()
taskPanel->setScheme(QSint::FreeCADPanelScheme::defaultScheme());
}
void TaskView::saveCurrentWidth()
{
if (shouldRestoreWidth()) {
if (auto parent = qobject_cast<QDockWidget*>(parentWidget())) {
currentWidth = parent->width();
}
}
}
void TaskView::tryRestoreWidth()
{
if (shouldRestoreWidth()) {
if (auto parent = qobject_cast<QDockWidget*>(parentWidget())) {
Gui::getMainWindow()->resizeDocks({parent}, {currentWidth}, Qt::Horizontal);
}
}
}
void TaskView::setRestoreWidth(bool on)
{
restoreWidth = on;
}
bool TaskView::shouldRestoreWidth() const
{
return restoreWidth;
}
void TaskView::removeTaskWatcher()
{
// In case a child of the TaskView has the focus and get hidden we have