From 5273c47c1bee1bed733cfc9ef8d5c8ef2bd023b8 Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 14 Jul 2015 14:22:00 +0200 Subject: [PATCH] + fix layouting problem due to bad implementation of minimumSizeHint() in ActionPanel and ActionGroup --- src/Gui/TaskView/TaskView.cpp | 49 +++++++++++++++++++++++++++++++++-- src/Gui/TaskView/TaskView.h | 13 ++++++++++ 2 files changed, 60 insertions(+), 2 deletions(-) diff --git a/src/Gui/TaskView/TaskView.cpp b/src/Gui/TaskView/TaskView.cpp index a914e8990..bf8ccee42 100644 --- a/src/Gui/TaskView/TaskView.cpp +++ b/src/Gui/TaskView/TaskView.cpp @@ -207,6 +207,21 @@ TaskBox::TaskBox(const QPixmap &icon, const QString &title, bool expandable, QWi : QSint::ActionGroup(icon, title, expandable, parent), wasShown(false) { } + +QSize TaskBox::minimumSizeHint() const +{ + // ActionGroup returns a size of 200x100 which leads to problems + // when there are several task groups in a panel and the first + // one is collapsed. In this case the task panel doesn't expand to + // the actually required size and all the remaining groups are + // squeezed into the available space and thus the widgets in there + // often can't be used any more. + // To fix this problem minimumSizeHint() is implemented to again + // respect the layout's minimum size. + QSize s1 = QSint::ActionGroup::minimumSizeHint(); + QSize s2 = QWidget::minimumSizeHint(); + return QSize(qMax(s1.width(), s2.width()), qMax(s1.height(), s2.height())); +} #endif TaskBox::~TaskBox() @@ -305,6 +320,36 @@ void TaskBox::actionEvent (QActionEvent* e) } } +//************************************************************************** +//************************************************************************** +// TaskPanel +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +#if defined (QSINT_ACTIONPANEL) +TaskPanel::TaskPanel(QWidget *parent) + : QSint::ActionPanel(parent) +{ +} + +TaskPanel::~TaskPanel() +{ +} + +QSize TaskPanel::minimumSizeHint() const +{ + // ActionPanel returns a size of 200x150 which leads to problems + // when there are several task groups in the panel and the first + // one is collapsed. In this case the task panel doesn't expand to + // the actually required size and all the remaining groups are + // squeezed into the available space and thus the widgets in there + // often can't be used any more. + // To fix this problem minimumSizeHint() is implemented to again + // respect the layout's minimum size. + QSize s1 = QSint::ActionPanel::minimumSizeHint(); + QSize s2 = QWidget::minimumSizeHint(); + return QSize(qMax(s1.width(), s2.width()), qMax(s1.height(), s2.height())); +} +#endif //************************************************************************** //************************************************************************** @@ -321,8 +366,8 @@ TaskView::TaskView(QWidget *parent) taskPanel = new iisTaskPanel(this); taskPanel->setScheme(iisFreeCADTaskPanelScheme::defaultScheme()); #else - taskPanel = new QSint::ActionPanel(this); - QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding); + taskPanel = new TaskPanel(this); + QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); sizePolicy.setHorizontalStretch(0); sizePolicy.setVerticalStretch(0); sizePolicy.setHeightForWidth(taskPanel->sizePolicy().hasHeightForWidth()); diff --git a/src/Gui/TaskView/TaskView.h b/src/Gui/TaskView/TaskView.h index d7355366e..ae73e41d9 100644 --- a/src/Gui/TaskView/TaskView.h +++ b/src/Gui/TaskView/TaskView.h @@ -127,6 +127,7 @@ public: const QString& title, bool expandable = true, QWidget *parent = 0); + virtual QSize minimumSizeHint() const; #endif ~TaskBox(); void hideGroupBox(); @@ -140,6 +141,18 @@ private: bool wasShown; }; +#if defined (QSINT_ACTIONPANEL) +class GuiExport TaskPanel : public QSint::ActionPanel +{ + Q_OBJECT + +public: + explicit TaskPanel(QWidget *parent = 0); + virtual ~TaskPanel(); + virtual QSize minimumSizeHint() const; +}; +#endif + /// Father class of content of a Free widget (without header and Icon), shut be an exception! class GuiExport TaskWidget : public QWidget, public TaskContent {