@@ -599,9 +599,17 @@ bool MainWindow::setupTaskView()
|
||||
{
|
||||
// Task view
|
||||
if (d->hiddenDockWindows.find("Std_TaskView") == std::string::npos) {
|
||||
// clang-format off
|
||||
auto group = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")
|
||||
->GetGroup("DockWindows")
|
||||
->GetGroup("TaskView");
|
||||
// clang-format on
|
||||
auto taskView = new Gui::TaskView::TaskView(this);
|
||||
taskView->setObjectName
|
||||
(QString::fromLatin1(QT_TRANSLATE_NOOP("QDockWidget","Tasks")));
|
||||
bool restore = group->GetBool("RestoreWidth", taskView->shouldRestoreWidth());
|
||||
taskView->setRestoreWidth(restore);
|
||||
taskView->setObjectName(QString::fromLatin1(QT_TRANSLATE_NOOP("QDockWidget","Tasks")));
|
||||
taskView->setMinimumWidth(210);
|
||||
|
||||
DockWindowManager* pDockMgr = DockWindowManager::instance();
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -163,6 +163,10 @@ public:
|
||||
|
||||
QSize minimumSizeHint() const override;
|
||||
|
||||
// Restore width before opening a task panel
|
||||
void setRestoreWidth(bool on);
|
||||
bool shouldRestoreWidth() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void taskUpdate();
|
||||
|
||||
@@ -175,6 +179,8 @@ protected Q_SLOTS:
|
||||
private:
|
||||
void triggerMinimumSizeHint();
|
||||
void adjustMinimumSizeHint();
|
||||
void saveCurrentWidth();
|
||||
void tryRestoreWidth();
|
||||
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent* event) override;
|
||||
@@ -199,6 +205,8 @@ protected:
|
||||
QSint::ActionPanel* taskPanel;
|
||||
TaskDialog *ActiveDialog;
|
||||
TaskEditControl *ActiveCtrl;
|
||||
bool restoreWidth = false;
|
||||
int currentWidth = 0;
|
||||
|
||||
Connection connectApplicationActiveDocument;
|
||||
Connection connectApplicationDeleteDocument;
|
||||
|
||||
Reference in New Issue
Block a user