Skip to content

Commit

Permalink
+ fix layouting problem due to bad implementation of minimumSizeHint(…
Browse files Browse the repository at this point in the history
…) in ActionPanel and ActionGroup
  • Loading branch information
wwmayer committed Jul 14, 2015
1 parent 4d2e817 commit 5273c47
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 2 deletions.
49 changes: 47 additions & 2 deletions src/Gui/TaskView/TaskView.cpp
Expand Up @@ -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()
Expand Down Expand Up @@ -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

//**************************************************************************
//**************************************************************************
Expand All @@ -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());
Expand Down
13 changes: 13 additions & 0 deletions src/Gui/TaskView/TaskView.h
Expand Up @@ -127,6 +127,7 @@ class GuiExport TaskBox : public QSint::ActionGroup, public TaskContent
const QString& title,
bool expandable = true,
QWidget *parent = 0);
virtual QSize minimumSizeHint() const;
#endif
~TaskBox();
void hideGroupBox();
Expand All @@ -140,6 +141,18 @@ class GuiExport TaskBox : public QSint::ActionGroup, public TaskContent
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
{
Expand Down

0 comments on commit 5273c47

Please sign in to comment.